import{__exports as r}from"../../../_virtual/es.async-disposable-stack.constructor.mjs";import{__require as e}from"../internals/export.mjs";import{__require as s}from"../internals/descriptors.mjs";import{__require as t}from"../internals/get-built-in.mjs";import{__require as i}from"../internals/a-callable.mjs";import{__require as n}from"../internals/an-instance.mjs";import{__require as o}from"../internals/define-built-in.mjs";import{__require as a}from"../internals/define-built-ins.mjs";import{__require as u}from"../internals/define-built-in-accessor.mjs";import{__require as c}from"../internals/well-known-symbol.mjs";import{__require as m}from"../internals/internal-state.mjs";import{__require as l}from"../internals/add-disposable-resource.mjs";import{__require as p}from"../internals/environment-v8-version.mjs";var f;function d(){if(f)return r;f=1;var d=e(),_=s(),v=t(),b=i(),h=n(),j=o(),q=a(),y=u(),k=c(),g=m(),w=l(),A=p(),S=v("Promise"),x=v("SuppressedError"),D=ReferenceError,E=k("asyncDispose"),F=k("toStringTag"),P="AsyncDisposableStack",R=g.set,T=g.getterFor(P),W="async-dispose",z="disposed",B=function(r){var e=T(r);if(e.state===z)throw new D(P+" already disposed");return e},C=function(){R(h(this,G),{type:P,state:"pending",stack:[]}),_||(this.disposed=!1)},G=C.prototype;return q(G,{disposeAsync:function(){var r=this;return new S(function(e,s){var t=T(r);if(t.state===z)return e(void 0);t.state=z,_||(r.disposed=!0);var i,n=t.stack,o=n.length,a=!1,u=function(r){a?i=new x(r,i):(a=!0,i=r),c()},c=function(){if(o){var r=n[--o];n[o]=null;try{S.resolve(r()).then(c,u)}catch(r){u(r)}}else t.stack=null,a?s(i):e(void 0)};c()})},use:function(r){return w(B(this),r,W),r},adopt:function(r,e){var s=B(this);return b(e),w(s,void 0,W,function(){return e(r)}),r},defer:function(r){var e=B(this);b(r),w(e,void 0,W,r)},move:function(){var r=B(this),e=new C;return T(e).stack=r.stack,r.stack=[],r.state=z,_||(this.disposed=!0),e}}),_&&y(G,"disposed",{configurable:!0,get:function(){return T(this).state===z}}),j(G,E,G.disposeAsync,{name:"disposeAsync"}),j(G,F,P,{nonWritable:!0}),d({global:!0,constructor:!0,forced:A&&A<136},{AsyncDisposableStack:C}),r}export{d as __require};