import{f as y}from"./index-CEV4Cvaf.js";import{g as D}from"./@radix-DeK6qiuw.js";import{z as P}from"./index-CCOPpudF.js";var w=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=void 0,o=void 0,u=void 0,i=[];return function(){var h=S(t),d=new Date().getTime(),g=!r||d-r>h;r=d;for(var p=arguments.length,s=Array(p),l=0;l<p;l++)s[l]=arguments[l];if(g&&a.leading)return a.accumulate?Promise.resolve(e.call(this,[s])).then(function(m){return m[0]}):Promise.resolve(e.call.apply(e,[this].concat(s)));if(o?clearTimeout(u):o=C(),i.push(s),u=setTimeout(c.bind(this),h),a.accumulate){var b=i.length-1;return o.promise.then(function(m){return m[b]})}return o.promise};function c(){var f=o;clearTimeout(u),Promise.resolve(a.accumulate?e.call(this,i):e.apply(this,i[i.length-1])).then(f.resolve,f.reject),i=[],o=null}};function S(n){return typeof n=="function"?n():n}function C(){var n={};return n.promise=new Promise(function(e,t){n.resolve=e,n.reject=t}),n}const F=D(w);function j(n){var e=null,t=null,a=new Promise(function(r,o){e=r,t=o});return n&&n.then(function(r){e&&e(r)},function(r){t&&t(r)}),{promise:a,resolve:function(r){e&&e(r)},reject:function(r){t&&t(r)},cancel:function(){e=null,t=null}}}function k(n){var e=null,t=function(){for(var a=[],r=0;r<arguments.length;r++)a[r]=arguments[r];e&&e();var o=n.apply(void 0,a),u=j(o),i=u.promise,c=u.cancel;return e=c,i};return t}/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.

See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */var v=function(){return v=Object.assign||function(e){for(var t,a=1,r=arguments.length;a<r;a++){t=arguments[a];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},v.apply(this,arguments)},A={key:function(){return null},onlyResolvesLast:!0},O=function(){function n(e){this.config=e,this.debounceSingleton=null,this.debounceCache={}}return n.prototype._createDebouncedFunction=function(){var e=F(this.config.func,this.config.wait,this.config.options);return this.config.options.onlyResolvesLast&&(e=k(e)),{func:e}},n.prototype.getDebouncedFunction=function(e){var t,a=(t=this.config.options).key.apply(t,e);return a===null||typeof a>"u"?(this.debounceSingleton||(this.debounceSingleton=this._createDebouncedFunction()),this.debounceSingleton):(this.debounceCache[a]||(this.debounceCache[a]=this._createDebouncedFunction()),this.debounceCache[a])},n}();function T(n,e,t){var a=v({},A,t),r=new O({func:n,wait:e,options:a}),o=function(){for(var u=[],i=0;i<arguments.length;i++)u[i]=arguments[i];var c=r.getDebouncedFunction(u).func;return c.apply(void 0,u)};return o}const x=T(async n=>(await y({name:n})).total===0,500),z=P.string().trim().min(1,"Stack name is required").max(32,"Stack name must be less than 32 characters").regex(/^[a-zA-Z0-9-]+$/,"Stack name can only contain alphanumeric characters and hyphens").refine(n=>x(n),"Stack name is already in use");export{z as s};
