import{f as C}from"./index-CrhdX_qG.js";import{g as S}from"./@radix-C7hRs6Kx.js";import{z as F}from"./index-D2iSHVZq.js";var d,y;function j(){if(y)return d;y=1,d=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u=void 0,i=void 0,c=void 0,s=[];return function(){var p=o(r),g=new Date().getTime(),P=!u||g-u>p;u=g;for(var b=arguments.length,l=Array(b),f=0;f<b;f++)l[f]=arguments[f];if(P&&a.leading)return a.accumulate?Promise.resolve(t.call(this,[l])).then(function(v){return v[0]}):Promise.resolve(t.call.apply(t,[this].concat(l)));if(i?clearTimeout(c):i=n(),s.push(l),c=setTimeout(D.bind(this),p),a.accumulate){var w=s.length-1;return i.promise.then(function(v){return v[w]})}return i.promise};function D(){var m=i;clearTimeout(c),Promise.resolve(a.accumulate?t.call(this,s):t.apply(this,s[s.length-1])).then(m.resolve,m.reject),s=[],i=null}};function o(e){return typeof e=="function"?e():e}function n(){var e={};return e.promise=new Promise(function(t,r){e.resolve=t,e.reject=r}),e}return d}var k=j();const O=S(k);function T(o){var n=null,e=null,t=new Promise(function(r,a){n=r,e=a});return o&&o.then(function(r){n&&n(r)},function(r){e&&e(r)}),{promise:t,resolve:function(r){n&&n(r)},reject:function(r){e&&e(r)},cancel:function(){n=null,e=null}}}function x(o){var n=null,e=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];n&&n();var a=o.apply(void 0,t),u=T(a),i=u.promise,c=u.cancel;return n=c,i};return e}/*! *****************************************************************************
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 h=function(){return h=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a])}return n},h.apply(this,arguments)},A={key:function(){return null},onlyResolvesLast:!0},R=function(){function o(n){this.config=n,this.debounceSingleton=null,this.debounceCache={}}return o.prototype._createDebouncedFunction=function(){var n=O(this.config.func,this.config.wait,this.config.options);return this.config.options.onlyResolvesLast&&(n=x(n)),{func:n}},o.prototype.getDebouncedFunction=function(n){var e,t=(e=this.config.options).key.apply(e,n);return t===null||typeof t>"u"?(this.debounceSingleton||(this.debounceSingleton=this._createDebouncedFunction()),this.debounceSingleton):(this.debounceCache[t]||(this.debounceCache[t]=this._createDebouncedFunction()),this.debounceCache[t])},o}();function q(o,n,e){var t=h({},A,e),r=new R({func:o,wait:n,options:t}),a=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 a}const L=q(async o=>(await C({name:o})).total===0,500),z=F.string().trim().min(1,"Stack name is required").max(255,"Stack name must be less than 255 characters").refine(o=>L(o),"Stack name is already in use");export{z as s};
