@aperture-browser/session-element 0.0.0-init.0 → 0.0.0-nightly.81.d77f21219f66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -19,4 +19,4 @@ Error generating stack: `+e.message+`
|
|
|
19
19
|
`)},io=e=>Xa(e).map(ao).join(`
|
|
20
20
|
`),ao=e=>e.cause?`${e.stack} {\n${oo(e.cause,` `)}\n}`:e.stack,oo=(e,t)=>{let n=e.stack.split(`
|
|
21
21
|
`),r=`${t}[cause]: ${n[0]}`;for(let e=1,i=n.length;e<i;e++)r+=`\n${t}${n[e]}`;return e.cause&&(r+=` {\n${oo(e.cause,`${t} `)}\n${t}}`),r},so=`~effect/Fiber`,co={_A:x,_E:x},lo={id:0},uo=()=>globalThis[et],fo=class{constructor(e,t=!0){this[so]=co,this.setContext(e),this.id=++lo.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}[so];id;interruptible;currentOpCount;_stack;_observers;_exit;_children;_interruptedCause;_yielded;_running;_deferredInterrupt;_parent;context;cache;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return Lr(this.context,e)}addObserver(e){return this._exit?(e(this._exit),ne):(this._observers===void 0?this._observers=[e]:this._observers.push(e),()=>{if(this._exit||this._observers===void 0)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)})}interruptUnsafe(e,t){if(this._exit)return;let n=za(e);this.cache.stackFrame&&(n=Jt(n,jr(rn,this.cache.stackFrame))),t&&(n=Jt(n,t)),this._interruptedCause=this._interruptedCause?Ka(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(F(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===At)return;let n=ho.interruptChildren&&ho.interruptChildren(this);if(n!==void 0)return this.evaluate(is(n,()=>t));if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&=(this._parent._children?.delete(this),void 0),this._observers!==void 0){let e=this._observers;this._observers=void 0;for(let n=0;n<e.length;n++)e[n](t)}this._stack.length=0,this._children=void 0,this.context=kr()}runLoop(e){let t=globalThis[et];globalThis[et]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;){this._deferredInterrupt&&(this._deferredInterrupt=!1,i=F(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!r&&!e.preventYield&&e.scheduler.shouldYield(this)){r=!0;let e=i;i=is(wo,()=>e)}if(i=e.tracerContext?e.tracerContext(i,this):i[j](this),i===At){let e=this._yielded;if(wt in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return At}}}catch(e){return D(i,j)?this.runLoop(cn(e)):cn(`Fiber.runLoop: Not a valid effect: ${String(i)}`)}finally{this._running=n,globalThis[et]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,mo;for(;;){let t=this._stack.pop();if(!t)return;let n=t[kt];if(n!==void 0){let r=n.call(t,this);if(r)return r[e]=r,r}if(t[e])return t}}yieldWith(e){return this._yielded=e,At}children(){return this._children??=new Set}pipe(){return _(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&Er(t,e))return;let n=e.cacheRoot,r=n._fiberCache??=po(e);this.cache!==void 0&&this.cache.scheduler!==r.scheduler&&(this._dispatcher=void 0),this.cache=r}get currentSpanLocal(){let e=this.cache.span;return e?._tag===`Span`?e:void 0}},po=e=>{let t=Fr(e,xa);return{scheduler:Lr(e,ea),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:Lr(e,Da),span:Fr(e,ha),logLevel:Lr(e,Ma),minimumLogLevel:Lr(e,Na),stackFrame:Lr(e,Ea),runtimeMetrics:Fr(e,Ta),maxOpsBeforeYield:Lr(e,sa),preventYield:Lr(e,ca)}},mo={[Dt](e,t){return F(t._interruptedCause)},[Ot](e,t){return F(t._interruptedCause)}},ho={interruptChildren:void 0},go=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(an.key,e.cache.stackFrame),wr(t)},_o=e=>{let t=e;return t._exit?P(t._exit):No(n=>t._exit?n(P(t._exit)):So(e.addObserver(e=>n(P(e)))))},vo=e=>No(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;){if(e.value._exit){r.push(e.value._exit),e=n.next();continue}i=e.value.addObserver(e=>{r.push(e),a()});return}t(P(r))}return a(),So(()=>i?.())}),yo=e=>ln(t=>bo(e,t.id)),bo=b(e=>D(e[0],so),(e,t,n)=>ln(r=>{let i=go(r);return i=i&&n?Vr(i,n):i??n,e.interruptUnsafe(t,i),rs(_o(e))})),N=e=>ln(t=>{let n=go(t),r=Ki();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return rs(vo(r))}),P=nn,F=on,xo=sn,So=en({op:`Sync`,[j](e){let t=this[A](),n=e.getCont(Dt);return n?n[Dt](t,e):e.yieldWith(nn(t))}}),Co=en({op:`Suspend`,[j](e){return this[A]()}}),wo=en({op:`Yield`,[j](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(ps)},this[A]??0),e.yieldWith(()=>{t=!0})}})(0),To=P(er()),Eo=e=>Co(()=>F(bt(e))),Do=e=>cn(e),I=P(void 0),Oo=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Cl(e,`An error occurred in Effect.try`):e.catch;return Co(()=>{try{return P(bt(t))}catch(e){return xo(bt(()=>n(e)))}})},ko=e=>jo(function(t,n){bt(()=>e(n)).then(e=>t(P(e)),e=>t(Do(e)))},e.length!==0),Ao=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Cl(e,`An error occurred in Effect.tryPromise`):e.catch;return jo(function(e,r){let i=t=>{try{e(xo(bt(()=>n(t))))}catch(t){e(Do(t))}};try{bt(()=>t(r)).then(t=>e(P(t)),i)}catch(e){i(e)}},t.length!==0)},jo=function(){let e=$t({op:`Async`,[j](e){let t=bt(()=>this.register.bind(e.cache.scheduler)),n=!1,r=!1,i=this.withSignal?new AbortController:void 0,a=t(t=>{n||(n=!0,r?e.evaluate(t):r=t)},i?.signal);return r===!1?(r=!0,e._yielded=()=>{n=!0},i===void 0&&a===void 0||e._stack.push(Mo(()=>(n=!0,i?.abort(),a??ps))),At):r}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),Mo=en({op:`AsyncFinalizer`,[kt](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Tc))},[Ot](e,t){return Ha(e)?is(this[A](),()=>F(e)):F(e)}}),No=e=>jo(e,e.length>=2),Po=No(ne),Fo=(...e)=>{if(e.length===1){let t=e[0];return Co(()=>Uo(t()))}let[t,n]=e;return Co(()=>Uo(n.call(t.self)))},Io=(e,...t)=>{let n=t.length===0?function(){return Co(()=>Uo(e.apply(this,arguments)))}:function(){let n=Co(()=>Uo(e.apply(this,arguments)));for(let e=0;e<t.length;e++)n=t[e](n,...arguments);return n};return Lo(e.length,n)},Lo=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),Ro=Ia(2),zo=function(){let e=typeof arguments[0]==`string`,t=e?arguments[0]:`Effect.fn`,n=e?arguments[1]:void 0,r=_t(),i;return r!==0&&(vt(2),i=new globalThis.Error,vt(r)),e?(r,...a)=>Bo(t,r,i,a,e,n):Bo(t,arguments[0],i,Array.prototype.slice.call(arguments,1),e,n)},Bo=(e,t,n,r,i,a)=>{let o=typeof t==`function`?t:r.shift().bind(t.self);return Lo(o.length,function(...t){let s=Co(()=>{let e=o.apply(this,arguments);return Nt(e)?e:Uo(e)});for(let e=0;e<r.length;e++)s=r[e](s,...t);if(!Nt(s))return s;let c=_t(),l;return c!==0&&(vt(2),l=new globalThis.Error,vt(c)),_s(i?ll(e,a,e=>ul(s,e)):s,Ea,t=>({name:e,stack:l?Ro(()=>l.stack):te,parent:{name:`${e} (definition)`,stack:n?Ro(()=>n.stack):te,parent:t}}))})},Vo=(e,...t)=>Lo(e.length,t.length===0?function(){return Ho(()=>e.apply(this,arguments))}:function(){let n=Ho(()=>e.apply(this,arguments));for(let e of t)n=e(n,...arguments);return n}),Ho=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return P(r.value);let i=r.value;if(i&&i._tag===`Success`){n=i.value;continue}else if(i&&i._tag===`Failure`)return r.value;else{let n=!0;return Co(()=>n?(n=!1,is(r.value,e=>Uo(t,e))):Co(()=>Uo(e())))}}}catch(e){return Do(e)}},Uo=function(){let e=$t({op:`Iterator`,[Dt](e,t){let n=this.iterator;for(;;){let r=n.next(e);if(r.done)return P(r.value);if(!as(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[j](e){return this[Dt](this.initial,e)}}),t=function(e,t){this.iterator=e,this.initial=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),Wo=b(2,(e,t)=>new Jo(e,Yo,P(t))),Go=function(e){return e._stack.push(this),this[A]},Ko=$t({op:`OnSuccess`,[j]:Go}),qo=function(e,t){this[A]=e,this[Dt]=t};qo.prototype=Ko;var Jo=function(e,t,n){this[A]=e,this[Dt]=t,this.payload=n};Jo.prototype=Ko;var Yo=function(){return this.payload},Xo=function(e){let t=this.payload;return P(bt(()=>t(e)))},Zo=function(e){let t=this.payload;return bt(()=>t(e))},Qo=function(e){let t=this.payload;return new Jo(bt(()=>t(e)),Yo,nn(e))},$o=function(e){return new Jo(this.payload,Yo,nn(e))},es=e=>cs(e,tr),ts=b(2,(e,t)=>new Jo(e,Nt(t)?Yo:Zo,t)),ns=b(2,(e,t)=>new Jo(e,Nt(t)?$o:Qo,t)),rs=e=>new Jo(e,Yo,ps),is=b(2,(e,t)=>new qo(e,t.length===1?t:e=>t(e))),as=e=>e[wt]!==void 0,os=b(2,(e,t)=>as(e)?e._tag===`Success`?t(e.value):e:is(e,t)),ss=e=>is(e,x),cs=b(2,(e,t)=>new Jo(e,Xo,t)),ls=b(2,(e,t)=>as(e)?ms(e,t):cs(e,t)),us=e=>e._tag===`Success`,ds=e=>e._tag===`Failure`,fs=e=>e._tag===`Failure`?Ei(e.cause):Di(e),ps=nn(void 0),ms=b(2,(e,t)=>e._tag===`Success`?nn(t(e.value)):e),hs=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?ps:on(Ut(t))},gs=b(2,(e,t)=>ln(n=>{let r=n.context,i=t(r);return r===i?e:(n.setContext(i),pc(e,()=>{n.setContext(r)}))})),_s=b(3,(e,t,n)=>gs(e,e=>{let r=Ir(e,t),i=n(r);return r===i?e:Mr(e,t,i)})),vs=()=>ys,ys=ln(e=>P(e.context)),bs=e=>ln(t=>e(t.context)),xs=b(2,(e,t)=>as(e)?e:gs(e,Vr(t))),Ss=function(){return arguments.length===1?b(2,(e,t)=>Cs(e,arguments[0],t)):b(3,(e,t,n)=>Cs(e,t,n)).apply(this,arguments)},Cs=(e,t,n)=>gs(e,Mr(t,n)),ws=b(2,(e,t)=>is(t,t=>t?es(e):To)),Ts=b(e=>Nt(e[0]),(e,t)=>Ac({while:S,body:ee(t?.disableYield?e:is(e,e=>wo)),step:ne})),Es=b(2,(e,t)=>new Os(e,t.length===1?t:e=>t(e))),Ds=$t({op:`OnFailure`,[j]:Go}),Os=function(e,t){this[A]=e,this[Ot]=t};Os.prototype=Ds;var ks=b(3,(e,t,n)=>Es(e,e=>{let r=t(e);return ki(r)?F(r.failure):bt(()=>n(r.success,e))})),As=b(2,(e,t)=>ks(e,Va,e=>t(e))),js=b(3,(e,t,n)=>Es(e,e=>{let r=t(e);return ki(r)?F(e):ts(bt(()=>n(r.success,e)),F(e))})),Ms=b(2,(e,t)=>js(e,Va,e=>t(e))),Ns=b(e=>Nt(e[0]),(e,t,n,r)=>Es(e,e=>{let i=Va(e);return ki(i)?F(i.failure):t(i.success)?bt(()=>n(i.success)):r?bt(()=>r(i.success)):F(e)})),Ps=b(e=>Nt(e[0]),(e,t,n,r)=>Es(e,e=>{let i=Va(e);if(ki(i))return F(i.failure);let a=t(i.success);return ki(a)?r?bt(()=>r(a.failure)):F(e):bt(()=>n(a.success))})),Fs=b(e=>Nt(e[0]),(e,t,n,r)=>Ns(e,Array.isArray(t)?e=>D(e,`_tag`)&&t.includes(e._tag):O(t),n,r)),Is=b(e=>Nt(e[0]),(e,t,n)=>{let r;return Ps(e,e=>(r??=Object.keys(t),D(e,`_tag`)&&oe(e._tag)&&r.includes(e._tag)?Ei(e):Di(e)),e=>bt(()=>t[e._tag](e)),n)}),Ls=b(e=>Nt(e[0]),(e,t,n,r)=>{let i;return Ns(e,e=>O(e,t)&&D(e,`reason`)&&D(e.reason,`_tag`)&&oe(e.reason._tag)&&(r!==void 0||(i??=Object.keys(n)).includes(e.reason._tag)),e=>{let t=e.reason;return i??=Object.keys(n),i.includes(t._tag)?bt(()=>n[t._tag](t,e)):r?bt(()=>r(t,e)):xo(e)})}),Rs=b(2,(e,t)=>As(e,e=>So(()=>t(e)))),zs=b(e=>Nt(e[0]),(e,t)=>{if(!t?.log)return Us(e,{onFailure:e=>I,onSuccess:e=>I});let n=Ml(t.log===!0?void 0:t.log);return Bs(e,{onFailure(e){let r=Ba(e);return ki(r)?F(r.failure):t.message===void 0?n(e):n(t.message,e)},onSuccess:e=>I})}),Bs=b(2,(e,t)=>new Hs(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),Vs=$t({op:`OnSuccessAndFailure`,[j]:Go}),Hs=function(e,t,n){this[A]=e,this[Dt]=t,this[Ot]=n};Hs.prototype=Vs;var Us=b(2,(e,t)=>Bs(e,{onFailure:e=>{let n=e.reasons.find(Yt);return n?bt(()=>t.onFailure(n.error)):F(e)},onSuccess:t.onSuccess})),Ws=b(2,(e,t)=>Us(e,{onFailure:e=>So(()=>t.onFailure(e)),onSuccess:e=>So(()=>t.onSuccess(e))})),Gs=e=>as(e)?nn(e):Ks(e),Ks=en({op:`Exit`,[j](e){return e._stack.push(this),this[A]},[Dt](e,t,n){return P(n??nn(e))},[Ot](e,t,n){return P(n??on(e))}}),qs=b(2,(e,t)=>ts(yl(t),e)),Js=`~effect/Scope`,Ys=`~effect/Scope/Closeable`,Xs=dr(`effect/Scope`),Zs=(e,t)=>Co(()=>Qs(e,t)??I),Qs=(e,t)=>{if(e.state._tag===`Closed`)return;let n={_tag:`Closed`,exit:t};if(e.state._tag===`Empty`){e.state=n;return}let r=e.state;if(e.state=n,r.finalizer!==void 0)return r.finalizer(t);let i=r.finalizers;if(!(i===void 0||i.size===0))return i.size===1?i.values().next().value(t):ec(e,i,t)},$s=(e,t)=>us(e)?t:Es(t,t=>F(Ka(e.cause,t))),ec=Io(function*(e,t,n){let r=[],i=[],a=Array.from(t.values()),o=uo();for(let t=a.length-1;t>=0;t--){let s=a[t];e.strategy===`sequential`?r.push(yield*Gs(s(n))):i.push(Rc(o,s(n),!0,!0,`inherit`))}return i.length>0&&(r=yield*vo(i)),yield*hs(r)}),tc=(e,t)=>{let n=oc(t);if(e.state._tag===`Closed`)return n.state=e.state,n;let r={};return ic(e,r,e=>Zs(n,e)),ic(n,r,t=>So(()=>ac(e,r))),n},nc=(e,t)=>Co(()=>e.state._tag===`Closed`?t(e.state.exit):(ic(e,{},t),I)),rc=(e,t)=>nc(e,ee(t)),ic=(e,t,n)=>{if(e.state._tag===`Empty`)e.state={_tag:`Open`,finalizerKey:t,finalizer:n,finalizers:void 0};else if(e.state._tag===`Open`){let r=e.state;r.finalizer===void 0?r.finalizers===void 0?(r.finalizerKey=t,r.finalizer=n):r.finalizers.set(t,n):(r.finalizers=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0,r.finalizers.set(t,n))}},ac=(e,t)=>{if(e.state._tag===`Open`){let n=e.state;n.finalizerKey===t?(n.finalizerKey=void 0,n.finalizer=void 0):n.finalizers!==void 0&&n.finalizers.delete(t)}},oc=(e=`sequential`)=>({[Ys]:Ys,[Js]:Js,strategy:e,state:sc}),sc={_tag:`Empty`},cc=Xs,lc=Ss(Xs),uc=e=>ln(t=>{let n=t.context,r=oc();return t.setContext(Mr(t.context,Xs,r)),pc(e,e=>(t.setContext(n),Qs(r,e)))}),dc=(e,t,n)=>bs(r=>kc(i=>is(cc,a=>ns(n?.interruptible?i(e):e,e=>nc(a,n=>xs(t(e,n),r)))))),fc=e=>is(cc,t=>bs(n=>nc(t,t=>xs(e(t),n)))),pc=function(){let e=$t({op:`OnExit`,[j](e){return e._stack.push(this),this.effect},[kt](e){e.interruptible&&this.interruptible!==!0&&(e._stack.push(Tc),e.interruptible=!1)},[Dt](e,t,n){n??=nn(e);let r=this.onExit(n);return r?is(r,e=>n):n},[Ot](e,t,n){n??=on(e);let r=this.onExit(n);return r?is($s(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,function(e,n,r){return new t(e,n,r)}}(),mc=b(2,pc),hc=b(2,(e,t)=>mc(e,e=>t)),gc=b(3,(e,t,n)=>mc(e,e=>{let r=t(e);return ki(r)?I:n(r.success,e)})),_c=b(2,(e,t)=>gc(e,fs,t)),vc=b(3,(e,t,n)=>mc(e,e=>{if(e._tag!==`Failure`)return I;let r=t(e.cause);return ki(r)?I:n(r.success,e.cause)})),yc=b(2,(e,t)=>vc(Ua,t)(e)),bc=(e,t,n)=>kc(r=>is(e,e=>pc(Co(()=>r(t(e))),t=>n(e,t),!0))),xc=e=>So(()=>{let t=tl(!1),n=!1,r,i=is(t.await,()=>r);return Co(()=>r===void 0?n?i:(n=!0,mc(e,e=>So(()=>{r=e,t.openUnsafe()}))):r)}),Sc=ln(e=>F(za(e.id))),Cc=e=>ln(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Tc),e):e),wc=en({op:`SetInterruptible`,[kt](e){if(e.interruptible=this[A],e._interruptedCause&&e.interruptible)return()=>F(e._interruptedCause)}}),Tc=wc(!0),Ec=wc(!1),Dc=e=>{if(e.interruptible=!0,e._stack.push(Ec),e._interruptedCause)return F(e._interruptedCause)},Oc=e=>ln(t=>t.interruptible?e:Dc(t)??e),kc=e=>ln(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Tc),e(Oc)):e(x)),Ac=en({op:`While`,[Dt](e,t){return this[A].step(e),this[A].while()?(t._stack.push(this),this[A].body()):ps},[j](e){return this[A].while()?(e._stack.push(this),this[A].body()):ps}}),jc=b(e=>typeof e[1]==`function`,(e,t,n)=>Co(()=>{let r=Nc(n?.concurrency);if(r===1)return Mc(e,t,n);let i=Vi(e),a=i.length;if(a===0)return n?.discard?I:P([]);let o=n?.discard?void 0:Array(a),s=Lc({f:t,out:o},i,{concurrency:r});return s?Wo(s,o):P(o)})),Mc=(e,t,n)=>Co(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return Wo(Ac({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),Nc=e=>e===`unbounded`?1/0:Math.max(1,e??1),Pc=()=>e=>{let t=e.onItem,n=e.step,r=(e,i,a=0,o=i.length)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!as(c))return is(Gs(c),t=>n(e,s,t,a)??r(e,i,a+1,o)??I);let l=n(e,s,c,a);if(l)return l._tag===`Failure`?l:void 0}};return r},Fc=e=>{let t=e.onItem,n=e.step;return(e,r,i)=>{let a=0,o=i.end??r.length,s=i.concurrency,c=!1,l,u,d,f=!1,p,m,h=e=>{let t=cn(e);return p=t,c=!0,f=!0,u&&u.size>0?is(Cc(N(Array.from(u))),()=>t):t},g=()=>{let i=!1;for(;!p&&a<o;a++){let o=r[a],_=m??t(e,o,a);if(as(_)){if(p=n(e,o,_,a),p)break}else if(l){m=void 0;let t=Rc(l,_,!0,!0,`inherit`);if(t._exit){if(p=n(e,o,t._exit,a),p)break;continue}u.add(t);let r=a;if(t.addObserver(a=>{u.delete(t);try{if(p){if(!f&&a._tag===`Failure`)for(let e of a.cause.reasons)if(e._tag===`Interrupt`)continue;else p._tag===`Failure`?p.cause.reasons.push(e):p=on(Ut([e]))}else{let t=n(e,o,a,r);t&&(p=t._tag===`Failure`?on(Ut(t.cause.reasons.slice())):t,g())}if(i){let e=g();e&&d(e)}else c&&u.size===0&&d(p??I)}catch(e){d(h(e))}}),u.size<s)continue;i=!0,a++;return}else return No(e=>{l=uo(),u=new Set,m=_,d=e;let t;try{t=g()}catch(t){return e(h(t))}return t?e(t):Co(()=>(p=ps,f=!0,u?N(u):I))})}if(c=!0,p){if(u&&u.size>0){let e=go(l);u.forEach(t=>t.interruptUnsafe(l.id,e));return}if(d||p._tag===`Failure`)return p}else if(d)if(u)u.size===0&&d(I);else return ps};return g()}},Ic=()=>e=>Fc(e),Lc=Fc({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag===`Failure`)return n;e.out&&(e.out[r]=n.value)}}),Rc=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new fo(a.context,o);return n?s.evaluate(t):a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0),!r&&!s._exit&&(a.children().add(s),s._parent=a),s},zc=e=>(t,n)=>{let r=new fo(n?.scheduler?Mr(e,ea,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal)if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}return n?.onFiberStart&&n.onFiberStart(r),r},Bc=b(2,(e,t)=>{if(e._exit)return e;if(t.state._tag===`Closed`)return e.interruptUnsafe(e.id),e;let n={};return ic(t,n,()=>yo(e)),e.addObserver(()=>ac(t,n)),e}),Vc=zc(kr()),Hc=e=>{let t=zc(e);return(e,n)=>{let r=t(e,n);return n?.onExit&&r.addObserver(n.onExit),e=>r.interruptUnsafe(e)}},Uc=Hc(kr()),Wc=e=>{let t=zc(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},Gc=Wc(kr()),Kc=e=>{let t=Wc(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw Ya(e.cause);return e.value})},qc=Kc(kr()),Jc=e=>{let t=zc(e);return e=>{if(as(e))return e;let n=new aa(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??cn(new xl(r))}},Yc=Jc(kr()),Xc=e=>{let t=Jc(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw Ya(n.cause);return n.value}},Zc=Xc(kr()),Qc=P(!0),$c=P(!1),el=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return Qc;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],Qc}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](ps)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](ps)}open=ln(e=>this._isOpen?$c:(this._isOpen=!0,this.scheduleUnsafe(e)));release=ln(e=>this._isOpen?$c:this.scheduleUnsafe(e));openUnsafe(){return this._isOpen?!1:(this._isOpen=!0,this.flushWaiters(),!0)}await=No(e=>this._isOpen?e(I):(this.waiters.push(e),So(()=>{let t=this.waiters.indexOf(e);t===-1?this.scheduled!==void 0&&(t=this.scheduled.indexOf(e),t!==-1&&this.scheduled.splice(t,1)):this.waiters.splice(t,1)})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=So(()=>this.closeUnsafe());whenOpen=e=>is(this.await,()=>e);isOpen(){return this._isOpen}},tl=e=>new el(e??!1),nl=BigInt(0),rl={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:nl,endTime:nl,exit:ps},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},il=e=>Object.assign(Object.create(rl),e),al=e=>e?Lr(e.annotations,va)?e._tag===`Span`?al(sr(e.parent)):er():tr(e):er(),ol=(e,t,n)=>{let r=!e.getRef(Da)||n?.annotations&&Lr(n.annotations,va),i=n?.parent===void 0?n?.root?er():al(e.cache.span):tr(n.parent),a;if(r)a=il({name:t,parent:i,annotations:Mr(n?.annotations??kr(),va,!0)});else{let r=e.getRef(Sa),o=e.getRef(fl),s=e.getRef(Oa),c=e.getRef(ka),l=e.getRef(Aa),u=n?.level??e.getRef(ya),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??kr(),links:d,startTime:s?o.currentTimeNanosUnsafe():nl,kind:n?.kind??`internal`,root:n?.root??nr(i),sampled:n?.sampled??(rr(i)&&i.value.sampled===!1?!1:!Tl(e.getRef(ba),u))});for(let e in c)a.attribute(e,c[e]);if(n?.attributes!==void 0)for(let e in n.attributes)a.attribute(e,n.attributes[e])}return a},sl=(e,t)=>(t=typeof t==`function`?t:te,_s(Ea,n=>({name:e,stack:t,parent:n}))),cl=(e,t,n,r)=>So(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():nl,t)}),ll=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return ln(t=>{let i=ol(t,e,n),a=t.getRef(fl),o=t.getRef(Oa);return mc(Co(()=>bt(()=>r(i))),e=>cl(i,e,a,o))})},ul=Ss(ga),dl=function(){let e=Nt(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=x;return t._tag===`Span`&&(n=Fa(n),r=sl(t.name,n?.captureStackTrace)),e?ul(r(arguments[0]),t):e=>ul(r(e),t)},fl=Ur(`effect/Clock`,{defaultValue:()=>new ml}),pl=2**31-1,ml=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=So(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return _l()}currentTimeNanos=So(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return gl()}monotonicTimeNanos=So(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(vi(e))}sleepMillis(e){return e<=0?wo:Number.isFinite(e)?No(t=>{let n=e>pl?this.sleepMillis(e-pl):I,r=setTimeout(()=>t(n),Math.min(e,pl));return So(()=>clearTimeout(r))}):Po}},hl=BigInt(1e6),gl=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==`function`)return()=>e.bigint();if(typeof performance<`u`&&typeof performance.now==`function`)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*hl;return e>t&&(t=e),t}}(),_l=function(){let e=BigInt(1e9),t;return()=>{let n=gl(),r=BigInt(Date.now())*hl;if(t===void 0)t=r-n;else{let i=t+n;(r>i?r-i:i-r)>e&&(t=r-n)}return t+n}}(),vl=e=>ln(t=>e(t.getRef(fl))),yl=e=>vl(t=>t.sleep(ei(e)));fn(`TimeoutError`),fn(`IllegalArgumentError`),fn(`ExceededCapacityError`);var bl=`~effect/Cause/AsyncFiberError`,xl=class extends fn(`AsyncFiberError`){[bl]=bl;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},Sl=`~effect/Cause/UnknownError`,Cl=class extends fn(`UnknownError`){[Sl]=Sl;constructor(e,t){super({message:t,cause:e})}},wl=Ur(`effect/Console`,{defaultValue:()=>globalThis.console}),Tl=Zn(Yn(Jn,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),El=Ur(`effect/Logger/CurrentLoggers`,{defaultValue:()=>new Set([Fl,Il])}),Dl=Ur(`effect/Logger/LogToStderr`,{defaultValue:C}),Ol={"~effect/Logger":{_Message:x,_Output:x},pipe(){return _(this,arguments)}},kl=e=>{let t=Object.create(Ol);return t.log=e,t},Al=e=>e.replace(/[\s="]/g,`_`),jl=(e,t)=>`${Al(e[0])}=${t-e[1]}ms`,Ml=e=>(...t)=>{let n;for(let e=0,r=t.length;e<r;e++){let r=t[e];Lt(r)&&(n?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),n=n?Ut(n.reasons.concat(r.reasons)):r,e--)}return n===void 0&&(n=Wt),ln(r=>{let i=e??r.cache.logLevel;if(Tl(r.cache.minimumLogLevel,i))return I;let a=r.getRef(fl),o=r.getRef(El);if(o.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of o)a.log({cause:n,fiber:r,date:e,logLevel:i,message:t})}return I})},Nl={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};Nl.gray,Nl.blue,Nl.green,Nl.yellow,Nl.red,Nl.bgBrightRed,Nl.black;var Pl=e=>`${e.getHours().toString().padStart(2,`0`)}:${e.getMinutes().toString().padStart(2,`0`)}:${e.getSeconds().toString().padStart(2,`0`)}.${e.getMilliseconds().toString().padStart(3,`0`)}`,Fl=kl(({cause:e,date:t,fiber:n,logLevel:r,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(io(e));let o=t.getTime(),s=n.getRef(Pa),c=``;for(let e of s)c+=` ${jl(e,o)}`;let l=n.getRef(ja);Object.keys(l).length>0&&a.push(l);let u=n.getRef(wl);(n.getRef(Dl)?u.error:u.log)(`[${Pl(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...a)}),Il=kl(({cause:e,fiber:t,logLevel:n,message:r})=>{let i=t.getRef(fl),a=t.getRef(ja),o=t.cache.span;if(o===void 0||o._tag===`ExternalSpan`)return;let s={};for(let[e,t]of Object.entries(a))xt(s,e,t);s[`effect.fiberId`]=t.id,s[`effect.logLevel`]=n.toUpperCase(),e.reasons.length>0&&(s[`effect.cause`]=io(e)),o.event(pt(Array.isArray(r)&&r.length===1?r[0]:r),i.currentTimeNanosUnsafe(),s)}),Ll=nn,Rl=on,zl=sn,Bl=ps,Vl=us,Hl=ds,Ul={"~effect/Deferred":{_A:x,_E:x},pipe(){return _(this,arguments)}},Wl=function(){this.resumes=void 0,this.effect=void 0};Wl.prototype=Ul;var Gl=()=>new Wl,Kl=e=>No(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),So(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),ql=b(2,(e,t)=>So(()=>L(e,t))),Jl=b(2,(e,t)=>ql(e,on(t))),Yl=b(2,(e,t)=>Jl(e,za(t))),L=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let e=0;e<n.length;e++)n[e](t)}return!0},Xl=b(2,(e,t)=>kc(n=>is(Gs(n(e)),e=>ql(t,e)))),Zl=Xs,Ql=oc,$l=lc,eu=nc,tu=rc,nu=tc,ru=Zs,iu=`~effect/Layer`,au=`~effect/Layer/MemoMap`,ou=(e,t)=>(e.observers++,ts(nc(t,t=>e.finalizer(t)),e.effect)),su={[iu]:{_ROut:x,_E:x,_RIn:x},pipe(){return _(this,arguments)}},cu=e=>{let t=Object.create(su);return t.build=e,t},lu=e=>cu((t,n)=>{let r=nu(n);return mc(e(t,r),e=>e._tag===`Failure`?ru(r,e):I)}),uu=e=>{let t=lu((n,r)=>n.getOrElseMemoize(t,r,e));return t},du=(e,t,n,r)=>{let i=Ql(),a=Gl(),o={observers:1,effect:Kl(a),finalizer:n=>Co(()=>(o.observers--,o.observers===0?(e.map.delete(t),ru(i,n)):I))};return e.map.set(t,o),nc(n,o.finalizer).pipe(is(()=>r(e,i)),mc(e=>(o.effect=e,ql(a,e))))},fu=class{get[au](){return au}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?ou(n,t):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return Co(()=>this.get(e,t)||du(this,e,t,n))}},pu=()=>new fu,mu=e=>new fu(e),hu=class e extends dr()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=Pr(t,e);return n?mu(n):pu()}},gu=b(3,(e,t,n)=>Ss(cs(e.build(t,n),Mr(hu,t)),hu,t)),_u=function(){return arguments.length===1?e=>vu(jr(arguments[0],e)):vu(jr(arguments[0],arguments[1]))},vu=e=>cu(ee(P(e))),yu=vu(kr()),bu=function(){return arguments.length===1?e=>xu(arguments[0],e):xu(arguments[0],arguments[1])},xu=(e,t)=>Su(cs(t,t=>jr(e,t))),Su=e=>uu((t,n)=>$l(e,n)),Cu=(e,t,n)=>{let r=nu(n,`parallel`);return jc(e,e=>e.build(t,nu(r,`sequential`)),{concurrency:e.length}).pipe(cs(e=>Hr(...e)))},wu=(...e)=>lu((t,n)=>Cu(e,t,n)),Tu=(e,t,n)=>lu((r,i)=>is(Array.isArray(t)?Cu(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(xs(t),cs(e=>n(e,t))))),Eu=b(2,(e,t)=>Tu(e,t,x)),Du=b(2,(e,t)=>Tu(e,t,(e,t)=>Vr(t,e))),Ou=Yt,ku=Ut,Au=qt,ju=Wa,Mu=qa,Nu=Ya,Pu=Ha,Fu=Ua,Iu=mn,Lu=vn;dr()(`effect/Cause/StackTrace`),dr()(`effect/Cause/InterruptorStackTrace`);var Ru=`~effect/DateTime`,zu=`~effect/DateTime/TimeZone`,Bu={[Ru]:Ru,pipe(){return _(this,arguments)},[dt](){return this.toString()},toJSON(){return Hu(this).toJSON()}};({...Bu}),{...Bu};var Vu={[zu]:zu,[dt](){return this.toString()}};({...Vu}),{...Vu};var Hu=e=>new Date(e.epochMilliseconds),Uu=b(2,(e,t)=>ks(e,Ku,e=>t(e))),Wu=e=>e._tag===`Fail`&&Iu(e.error),Gu=e=>{let t,n=!1;for(let r of e.reasons)Wu(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?Di(e):n?Di(ku(e.reasons.filter(e=>!Wu(e)))):Ei(t)},Ku=e=>{let t=Gu(e);return ki(t)?t:Ei(t.success.value)},qu=e=>{let t=Gu(e);return ki(t)?Rl(t.failure):Ll(t.success.value)},Ju=b(2,(e,t)=>Bs(e,{onSuccess:t.onSuccess,onFailure:e=>{let n=Gu(e);return ki(n)?t.onFailure(n.failure):t.onDone(n.success.value)}})),Yu=`~effect/Schedule`,Xu=Ur(`effect/Schedule/CurrentMetadata`,{defaultValue:ee({input:void 0,output:void 0,duration:ci,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),Zu={[Yu]:{_Out:x,_In:x,_Env:x},pipe(){return _(this,arguments)}},Qu=e=>D(e,Yu),$u=e=>{let t=Object.create(Zu);return t.step=e,t},ed=()=>{let e=0,t,n;return(r,i)=>{n===void 0&&(n=r);let a=r-n,o=t===void 0?0:r-t;return t=r,{input:i,attempt:++e,start:n,now:r,elapsed:a,elapsedSincePrevious:o}}},td=e=>$u(cs(e,e=>{let t=ed();return(n,r)=>e(t(n,r))})),nd=e=>Es(e.step,e=>P(()=>F(e))),rd=e=>vl(t=>cs(nd(e),e=>{let n=ed();return r=>Co(()=>{let i=t.currentTimeMillisUnsafe();return is(e(i,r),([e,t])=>{let a=n(i,r);return a.output=e,a.duration=t,Wo(yl(t),a)})})})),id=e=>$u(cs(nd(e),e=>(t,n)=>Ju(e(t,n),{onSuccess:e=>P([n,e[1]]),onFailure:F,onDone:()=>Lu(n)}))),ad=e=>{let t=ei(e);return td(P(e=>P([e.attempt-1,t])))},od=b(2,(e,t)=>$u(cs(nd(e),e=>{let n=ed();return(r,i)=>is(e(r,i),e=>{let[a,o]=e,s=t({...n(r,i),output:a,duration:o});return is(Nt(s)?s:P(s),t=>t?P(e):Lu(a))})}))),sd=ad(ci),cd=b(3,(e,t,n)=>is(rd(t),t=>{let r=Xu.defaultValue();return As(Ts(ns(is(Co(()=>Ss(e,Xu,r)),t),e=>So(()=>{r=e})),{disableYield:!0}),e=>mn(e)?P(e.value):n(e,r.attempt===0?er():tr(r)))})),ld=b(2,(e,t)=>cd(e,typeof t==`function`?t(x):Qu(t)?t:dd(t),xo)),ud=id(sd),dd=e=>{let t=e.schedule?id(e.schedule):ud;return e.while&&(t=od(t,({input:t})=>{let n=e.while(t);return Nt(n)?n:P(n)})),e.until&&(t=od(t,({input:t})=>{let n=e.until(t);return Nt(n)?cs(n,e=>!e):P(!n)})),e.times!==void 0&&(t=od(t,({attempt:t})=>P(t<=e.times))),t},fd=jc,pd=Ac,md=ko,hd=Ao,R=P,gd=Co,z=So,_d=I,vd=Po,yd=Fo,B=xo,bd=F,xd=Eo,Sd=Do,Cd=Oo,wd=ln,V=is,Td=ss,Ed=ts,Dd=ns,Od=Gs,kd=cs,H=Wo,Ad=rs,jd=As,Md=Fs,Nd=Is,Pd=Ls,Fd=Es,Id=Ms,Ld=zs,Rd=Rs,zd=qs,Bd=yl,Vd=ws,Hd=Ws,Ud=Bs,Wd=vs,Gd=bs,Kd=xs,qd=gs,Jd=Ss,Yd=uc,Xd=dc,Zd=bc,Qd=fc,$d=hc,ef=_c,tf=mc,nf=xc,rf=Sc,af=yc,of=Cc,sf=kc,cf=Ts,lf=ld,uf=ll,df=dl,ff=Vc,pf=zc,mf=Hc,hf=Uc,gf=qc,_f=Kc,vf=Gc,yf=Wc,bf=Zc,xf=Xc,Sf=Yc,Cf=Jc,wf=Io,U=zo;dr()(`effect/Effect/Transaction`);var Tf=ls,Ef=os,Df=Vo,Of=_o,kf=yo,Af=N,jf=Bc,Mf=tl,Nf=`~effect/MutableRef`,Pf={[Nf]:Nf,...jt,toJSON(){return{_id:`MutableRef`,current:ft(this.current)}}},Ff=e=>{let t=Object.create(Pf);return t.current=e,t},If=b(2,(e,t)=>(e.current=t,e)),Lf=Symbol.for(`effect/MutableList/Empty`),Rf=()=>({head:void 0,tail:void 0,length:0}),zf=()=>({array:[],mutable:!0,offset:0,next:void 0}),Bf=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=zf(),e.tail=e.tail.next):e.head=e.tail=zf(),e.tail.array.push(t),e.length++},Vf=(e,t)=>{e.head={array:[t],mutable:!0,offset:0,next:e.head},e.tail||=e.head,e.length++},Hf=e=>{e.head=e.tail=void 0,e.length=0},Uf=(e,t)=>{if(t=Ti(t),t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let t=e.head.array;return Hf(e),t}let n=Array(t),r=0,i=e.head;for(;i;){for(;i.offset<i.array.length;)if(n[r++]=i.array[i.offset],i.mutable&&(i.array[i.offset]=void 0),i.offset++,r===t)return e.head=i,e.length-=t,e.length===0&&Hf(e),n;i=i.next}return Hf(e),n},Wf=e=>Uf(e,e.length),Gf=e=>{if(!e.head)return Lf;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length&&(e.head.next?e.head=e.head.next:Hf(e)),t},Kf=(e,t)=>{let n=[],r=e.head;for(;r;){for(let e=r.offset;e<r.array.length;e++)t(r.array[e],e)&&n.push(r.array[e]);r=r.next}if(n.length===0){Hf(e);return}e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0},e.length=n.length},qf=(e,t)=>Kf(e,e=>e!==t),Jf=`~effect/PubSub`,Yf=`~effect/PubSub/Subscription`,Xf=e=>z(()=>pp(e.atomicPubSub(),new Map,Ql(),Mf(!1),Ff(!1),e.strategy())),Zf=e=>Xf({atomicPubSub:()=>Qf(e),strategy:()=>new mp}),Qf=e=>{let t=e?.replay;return new lp(t&&t>0?new _p(Math.ceil(t)):void 0)},$f=b(2,(e,t)=>gd(()=>e.shutdownFlag.current?R(!1):e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),R(!0)):e.strategy.handleSurplus(e.pubsub,e.subscribers,[t],e.shutdownFlag))),ep=b(2,(e,t)=>e.shutdownFlag.current?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),tp=e=>of(Gd(t=>{let n=Lr(t,Zl),r=nu(e.scope),i=cp(e.pubsub,e.subscribers,e.strategy);return tu(r,np(i)).pipe(Ed(eu(n,e=>ru(r,e))),H(i))})),np=e=>of(wd(t=>(If(e.shutdownFlag,!0),fd(Wf(e.pollers),e=>Yl(e,t.id),{discard:!0,concurrency:`unbounded`}).pipe(Dd(()=>z(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),Vd(e.shutdownHook.open),Ad)))),rp=e=>gd(function t(n){if(e.shutdownFlag.current)return rf;let r=e.pollers.length===0?e.subscription.pollUpTo(1/0):[];return n&&(r=n.concat(r)),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0?R(e.replayWindow.takeAll().concat(r)):Ui(r)?R(r):V(ip(e),e=>t([e]))}),ip=e=>{let t=Gl(),n=e.subscribers.get(e.subscription);return n||(n=new Set,e.subscribers.set(e.subscription,n)),n.add(e.pollers),Bf(e.pollers,t),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),af(Kl(t),()=>(qf(e.pollers,t),_d))},ap=Symbol.for(`effect/PubSub/AbsentValue`),op=(e,t,n)=>{e.has(t)||e.set(t,new Set),e.get(t).add(n)},sp=(e,t,n)=>{if(!e.has(t))return;let r=e.get(t);r.delete(n),r.size===0&&e.delete(t)},cp=(e,t,n)=>new dp(e,t,e.subscribe(),Rf(),Mf(!1),Ff(!1),n,e.replayWindow()),lp=class{publisherHead={value:ap,replayIndex:void 0,subscribers:0,next:null};publisherTail=this.publisherHead;publisherIndex=0;subscribersIndex=0;capacity=2**53-1;replayBuffer;constructor(e){this.replayBuffer=e}replayWindow(){return this.replayBuffer?new vp(this.replayBuffer):yp}isEmpty(){return this.publisherHead===this.publisherTail}isFull(){return!1}size(){return this.publisherIndex-this.subscribersIndex}publish(e){let t=this.replayBuffer?.offer(e),n=this.publisherTail.subscribers;if(n!==0){let r={value:e,replayIndex:t,subscribers:n,next:null};this.publisherTail.next=r,this.publisherTail=this.publisherTail.next,this.publisherIndex+=1}return!0}publishAll(e){if(this.publisherTail.subscribers!==0)for(let t of e)this.publish(t);else this.replayBuffer&&this.replayBuffer.offerAll(e);return[]}slide(){if(this.publisherHead!==this.publisherTail){let e=this.publisherHead.next,t=e.value;this.publisherHead=this.publisherHead.next,this.publisherHead.value=ap,this.subscribersIndex+=1,this.replayBuffer?.slide(t,e.replayIndex)}}subscribe(){return this.publisherTail.subscribers+=1,new up(this,this.publisherTail,this.publisherIndex,!1)}},up=class{self;subscriberHead;subscriberIndex;unsubscribed;constructor(e,t,n,r){this.self=e,this.subscriberHead=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){if(this.unsubscribed)return!0;let e=!0,t=!0;for(;t;)this.subscriberHead===this.self.publisherTail?t=!1:this.subscriberHead.next.value===ap?(this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1):(e=!1,t=!1);return e}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Lf;let e=!0,t=Lf;for(;e;)if(this.subscriberHead===this.self.publisherTail)e=!1;else{let n=this.subscriberHead.next.value;n!==ap&&(t=n,--this.subscriberHead.subscribers,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=ap,this.self.subscribersIndex+=1),e=!1),this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1}return t}pollUpTo(e){e=Ti(e);let t=[],n=0;for(;n!==e;){let r=this.poll();r===Lf?n=e:(t.push(r),n+=1)}return t}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,--this.self.publisherTail.subscribers;this.subscriberHead!==this.self.publisherTail;)this.subscriberHead.next.value!==ap&&(--this.subscriberHead.subscribers,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=ap,this.self.subscribersIndex+=1)),this.subscriberHead=this.subscriberHead.next}},dp=class{[Yf]={_A:x};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;constructor(e,t,n,r,i,a,o,s){this.pubsub=e,this.subscribers=t,this.subscription=n,this.pollers=r,this.shutdownHook=i,this.shutdownFlag=a,this.strategy=o,this.replayWindow=s}pipe(){return _(this,arguments)}},fp=class{[Jf]={_A:x};pubsub;subscribers;scope;shutdownHook;shutdownFlag;strategy;constructor(e,t,n,r,i,a){this.pubsub=e,this.subscribers=t,this.scope=n,this.shutdownHook=r,this.shutdownFlag=i,this.strategy=a}pipe(){return _(this,arguments)}},pp=(e,t,n,r,i,a)=>new fp(e,t,n,r,i,a),mp=class{get shutdown(){return _d}handleSurplus(e,t,n,r){return R(!1)}onPubSubEmptySpaceUnsafe(e,t){}completePollersUnsafe(e,t,n,r){return hp(this,e,t,n,r)}completeSubscribersUnsafe(e,t){return gp(this,e,t)}},hp=(e,t,n,r,i)=>{let a=!0;for(;a&&!r.isEmpty();){let o=Gf(i);if(o===Lf)sp(n,r,i),i.length===0?a=!1:op(n,r,i);else{let a=r.poll();a===Lf?Vf(i,o):(L(o,Ll(a)),e.onPubSubEmptySpaceUnsafe(t,n))}}},gp=(e,t,n)=>{for(let[r,i]of n)for(let a of i)e.completePollersUnsafe(t,n,r,a)},_p=class{capacity;head={value:ap,index:0,next:null};tail=this.head;slideValues=[];size=0;index=0;publisherIndex=0;constructor(e){this.capacity=e}slide(e,t){this.slideValues[this.index%this.capacity]={value:e,index:t},this.index++}offer(e){let t=this.publisherIndex++;return this.tail.value=e,this.tail.index=t,this.tail.next={value:ap,index:0,next:null},this.tail=this.tail.next,this.size===this.capacity?this.head=this.head.next:this.size+=1,t}offerAll(e){for(let t of e)this.offer(t)}},vp=class{buffer;values;index=0;remaining;slideIndex;newestIndex=-1;constructor(e){this.buffer=e,this.remaining=e.size,this.slideIndex=e.index,this.values=Array(this.remaining);let t=e.head;for(let e=0;e<this.remaining;e++)this.values[e]=t.value,this.newestIndex=t.index,t=t.next}close(){this.values.length=0,this.remaining=0}sync(){let e=this.buffer.index-this.slideIndex;if(e===0||this.remaining===0)return;let t=Math.min(e,this.buffer.capacity),n=this.buffer.index-t;for(let e=0;e<t;e++){let t=this.buffer.slideValues[(n+e)%this.buffer.capacity];t.index>this.newestIndex&&(this.index=(this.index+1)%this.values.length,this.values[(this.index+this.remaining-1)%this.values.length]=t.value,this.newestIndex=t.index)}this.slideIndex=this.buffer.index}take(){if(this.remaining===0)return;this.sync();let e=this.values[this.index];return this.values[this.index]=ap,this.index=(this.index+1)%this.values.length,this.remaining--,this.remaining===0&&this.close(),e}takeN(e){e=Ti(e);let t=Math.min(e,this.remaining),n=Array(t);for(let e=0;e<t;e++)n[e]=this.take();return n}takeAll(){return this.takeN(this.remaining)}},yp={remaining:0,take:()=>void 0,takeN:()=>[],takeAll:()=>[],close:()=>void 0},bp=e=>new Sp(e),xp=(e,t,n)=>No(r=>{if(e.free>=t)return r(n);let i=()=>{e.free<t||(e.waiters.delete(i),r(n))};return e.waiters.add(i),So(()=>{e.waiters.delete(i)})}),Sp=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=Co(()=>this.free<e?xp(this,e,t):(this.taken+=e,P(e)));return t}takeIfAvailable(e){return Co(()=>this.free<e?P(!1):(this.taken+=e,P(!0)))}releaseUnsafe(e,t){return this.taken-=t,this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{for(let e of this.waiters){if(this.free<=0)break;e()}},0),this.free}resize(e){return ln(t=>(this.permits=e,this.free<0||this.releaseUnsafe(t,0),I))}release(e){return ln(t=>P(this.releaseUnsafe(t,e)))}get releaseAll(){return ln(e=>P(this.releaseUnsafe(e,this.taken)))}withPermits(e){return t=>kc(n=>{let r=Co(()=>this.free<e?is(n(xp(this,e,I)),()=>r):(this.taken+=e,pc(n(t),()=>{this.releaseUnsafe(uo(),e)},!0)));return r})}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>kc(n=>this.free<e?To:(this.taken+=e,pc(n(es(t)),()=>{this.releaseUnsafe(uo(),e)},!0)))}},Cp={"~effect/Channel":{_Env:x,_InErr:x,_InElem:x,_OutErr:x,_OutElem:x},pipe(){return _(this,arguments)}},wp=e=>{let t=Object.create(Cp);return t.transform=(t,n)=>Fd(e(t,n),e=>R(bd(e))),t},Tp=e=>wp((t,n)=>e),Ep=e=>wp(wf(function*(t,n){let r=nu(n),i=e=>ru(r,qu(e));return ef(yield*ef(e(t,n,r),i),i)})),Dp=e=>e.transform,Op=e=>wp((t,n)=>gd(()=>Dp(e())(t,n))),kp=e=>Tp(R(B(e))),Ap=e=>Tp(R(af(rp(e),()=>Lu()))),jp=e=>Pp(kd(tp(e),Ap)),Mp=e=>wp((t,n)=>Np({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),Np=e=>{let t=e.readable.getReader(),n=e.exit??Ff(void 0),r=gd(()=>n.current?n.current:Ud(hd({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??bd(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?Lu():R(qi(t))}));return H(tu(e.scope,e.releaseLockOnEnd?z(()=>t.releaseLock()):md(()=>t.cancel().catch(ne))),r)},Pp=e=>wp((t,n)=>{let r;return R(gd(()=>r||e.pipe($l(n),V(e=>Dp(e)(t,n)),V(e=>r=e))))}),Fp=b(2,(e,t)=>Ep((n,r,i)=>eu(i,t).pipe(Ed(Dp(e)(n,r))))),Ip=b(2,(e,t)=>Fp(e,e=>t)),Lp=(e,t,n)=>gd(()=>{let r=Ql();return Uu(V(Dp(e)(Lu(),r),t),n||R).pipe(tf(e=>ru(r,e)))}),Rp=b(2,(e,t)=>Lp(e,e=>cf(V(e,t),{disableYield:!0}))),zp=`~effect/Stream`,Bp={_R:x,_E:x,_A:x},Vp=function(e){this.channel=e};Vp.prototype={[zp]:Bp,pipe(){return _(this,arguments)}};var Hp=e=>new Vp(e),Up=`~effect/Stream`,Wp=e=>D(e,Up),Gp=Hp,Kp=e=>Gp(Op(()=>e().channel)),qp=e=>Gp(kp(e)),Jp=e=>Gp(jp(e)),Yp=e=>Gp(Mp(e)),Xp=b(2,(e,t)=>Gp(Ip(e.channel,t))),Zp=b(2,(e,t)=>Rp(e.channel,e=>{let n=0;return pd({while:()=>n<e.length,body:()=>t(e[n++]),step:ne})})),Qp=b(2,(e,t)=>Rp(e.channel,t)),$p=b(e=>Wp(e[0]),(e,t,n)=>{let r,i,a=Mf(!1);return new ReadableStream({start(n){i=ff(Kd(Qp(e,e=>a.whenOpen(z(()=>{a.closeUnsafe();for(let t=0;t<e.length;t++)n.enqueue(e[t]);r(),r=void 0}))),t)),i.addObserver(e=>{e._tag===`Failure`?n.error(Nu(e.cause)):n.close()})},pull(){return new Promise(e=>{r=e,a.openUnsafe()})},cancel(){if(i)return gf(Ad(kf(i)))}},n?.strategy)}),em=b(e=>Wp(e[0]),(e,t)=>kd(Wd(),n=>$p(e,n,t))),tm={Escape:1,Digit1:2,Digit2:3,Digit3:4,Digit4:5,Digit5:6,Digit6:7,Digit7:8,Digit8:9,Digit9:10,Digit0:11,Minus:12,Equal:13,Backspace:14,Tab:15,KeyQ:16,KeyW:17,KeyE:18,KeyR:19,KeyT:20,KeyY:21,KeyU:22,KeyI:23,KeyO:24,KeyP:25,BracketLeft:26,BracketRight:27,Enter:28,ControlLeft:29,KeyA:30,KeyS:31,KeyD:32,KeyF:33,KeyG:34,KeyH:35,KeyJ:36,KeyK:37,KeyL:38,Semicolon:39,Quote:40,Backquote:41,ShiftLeft:42,Backslash:43,KeyZ:44,KeyX:45,KeyC:46,KeyV:47,KeyB:48,KeyN:49,KeyM:50,Comma:51,Period:52,Slash:53,ShiftRight:54,NumpadMultiply:55,AltLeft:56,Space:57,CapsLock:58,F1:59,F2:60,F3:61,F4:62,F5:63,F6:64,F7:65,F8:66,F9:67,F10:68,NumLock:69,ScrollLock:70,Numpad7:71,Numpad8:72,Numpad9:73,NumpadSubtract:74,Numpad4:75,Numpad5:76,Numpad6:77,NumpadAdd:78,Numpad1:79,Numpad2:80,Numpad3:81,Numpad0:82,NumpadDecimal:83,IntlBackslash:86,F11:87,F12:88,NumpadEnter:96,ControlRight:97,NumpadDivide:98,PrintScreen:99,AltRight:100,Home:102,ArrowUp:103,PageUp:104,ArrowLeft:105,ArrowRight:106,End:107,ArrowDown:108,PageDown:109,Insert:110,Delete:111,Pause:119,MetaLeft:125,MetaRight:126,ContextMenu:127},nm={Backspace:8,Tab:9,Enter:13,NumpadEnter:13,ShiftLeft:16,ShiftRight:16,ControlLeft:17,ControlRight:17,AltLeft:18,AltRight:18,Pause:19,CapsLock:20,Escape:27,Space:32,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,Insert:45,Delete:46,MetaLeft:91,MetaRight:92,ContextMenu:93,Semicolon:186,Equal:187,Comma:188,Minus:189,Period:190,Slash:191,Backquote:192,BracketLeft:219,Backslash:220,BracketRight:221,Quote:222},rm={Backspace:8,Tab:9,Enter:13,Shift:16,Control:17,Alt:18,Pause:19,CapsLock:20,Escape:27," ":32,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,Insert:45,Delete:46,Meta:91,ContextMenu:93},im=new Set(`KeyA.KeyC.KeyF.KeyG.KeyH.KeyJ.KeyK.KeyL.KeyN.KeyO.KeyP.KeyR.KeyS.KeyT.KeyW.KeyX.KeyV.KeyZ.KeyY.BracketLeft.BracketRight.ArrowLeft.ArrowRight.ArrowUp.ArrowDown.Backspace.Delete.Enter.Tab`.split(`.`));function am(e){let t=0;return e.altKey&&(t|=1),e.ctrlKey&&(t|=2),e.metaKey&&(t|=4),e.shiftKey&&(t|=8),t}function om(e){return e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function sm(e,t){let n=lm(e.code,e.key),r=am(e),i=t===`down`&&om(e)?e.key:void 0,a=e.key.length===1?e.key:void 0;return{key:e.key,code:e.code,text:i,unmodifiedText:a,modifiers:r,windowsVirtualKeyCode:n,nativeVirtualKeyCode:n,location:e.location,autoRepeat:e.repeat,isKeypad:e.location===KeyboardEvent.DOM_KEY_LOCATION_NUMPAD}}function cm(e){return e.key===`Escape`?!1:um(e.code)||!(e.metaKey||e.ctrlKey)?!0:im.has(e.code)}function lm(e,t){let n=e?nm[e]:void 0;if(n!==void 0)return n;if(e?.startsWith(`Key`)&&e.length===4)return e.charCodeAt(3);if(e?.startsWith(`Digit`)&&e.length===6)return e.charCodeAt(5);if(e?.startsWith(`Numpad`)&&e.length===7){let t=Number(e.slice(6));if(Number.isInteger(t)&&t>=0&&t<=9)return 96+t}if(e?.startsWith(`F`)){let t=Number(e.slice(1));if(Number.isInteger(t)&&t>=1&&t<=24)return 111+t}let r=t?rm[t]:void 0;return r===void 0?t?.length===1?t.toUpperCase().charCodeAt(0):0:r}function um(e){return e===`AltLeft`||e===`AltRight`||e===`ControlLeft`||e===`ControlRight`||e===`MetaLeft`||e===`MetaRight`||e===`ShiftLeft`||e===`ShiftRight`}var dm=`~effect/BigDecimal`,fm={[dm]:dm,[ge](){let e=bm(this);return ve(k(e.value),xe(e.scale))},[Ne](e){return pm(e)&&km(this,e)},toString(){return`BigDecimal(${Am(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[dt](){return this.toJSON()},pipe(){return _(this,arguments)}},pm=e=>D(e,dm),mm=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(fm);return n.value=e,n.scale=t,n},hm=(e,t)=>{if(e!==gm&&e%vm===gm)throw RangeError(`Value must be normalized`);let n=mm(e,t);return n.normalized=n,n},gm=BigInt(0),_m=BigInt(1),vm=BigInt(10),ym=hm(gm,0),bm=e=>{if(e.normalized===void 0)if(e.value===gm)e.normalized=ym;else{let t=`${e.value}`,n=0;for(let e=t.length-1;e>=0&&t[e]===`0`;e--)n++;n===0&&(e.normalized=e),e.normalized=hm(BigInt(t.substring(0,t.length-n)),e.scale-n)}return e.normalized},xm=100,Sm=[_m],Cm=(e,t)=>e===t?0:e<t?-1:1,wm=(e,t)=>{let n=`${e.value<gm?-e.value:e.value}`,r=`${t.value<gm?-t.value:t.value}`,i=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==gm)return i<gm?-1:1;let a=Math.max(n.length,r.length);for(let e=0;e<a;e++){let t=e<n.length?n.charCodeAt(e):48,i=e<r.length?r.charCodeAt(e):48;if(t!==i)return t<i?-1:1}return 0},Tm=(e,t)=>{if(e.scale===t.scale)return Cm(e.value,t.value);let n=Em(e),r=Em(t);if(n!==r)return n<r?-1:1;if(n===0)return 0;let i=e.scale-t.scale,a=Math.abs(i);if(a>xm)return n===-1?wm(t,e):wm(e,t);let o=Sm[a]??=vm**BigInt(a);return i>0?Cm(e.value,t.value*o):Cm(e.value*o,t.value)},Em=e=>e.value===gm?0:e.value<gm?-1:1,Dm=e=>e.value<gm?mm(-e.value,e.scale):e,Om=bn((e,t)=>Tm(e,t)===0),km=b(2,(e,t)=>Om(e,t)),Am=e=>{let t=bm(e);if(Math.abs(t.scale)>=16)return jm(t);let n=t.value<gm,r=n?`${t.value}`.substring(1):`${t.value}`,i,a;if(t.scale>=r.length)i=`0`,a=`0`.repeat(t.scale-r.length)+r;else{let e=r.length-t.scale;if(e>r.length){let t=e-r.length;i=`${r}${`0`.repeat(t)}`,a=``}else a=r.slice(e),i=r.slice(0,e)}let o=a===``?i:`${i}.${a}`;return n?`-${o}`:o},jm=e=>{if(Mm(e))return`0e+0`;let t=bm(e),n=`${Dm(t).value}`,r=n.slice(0,1),i=n.slice(1),a=`${Nm(t)?`-`:``}${r}`;i!==``&&(a+=`.${i}`);let o=i.length-t.scale;return`${a}e${o>=0?`+`:``}${o}`},Mm=e=>e.value===gm,Nm=e=>e.value<gm;dr()(`effect/DateTime/CurrentTimeZone`);function Pm(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}var Fm=`~structural`,Im=`~sentinels`,Lm=`~constructor`,Rm=re(e=>{let t=Pm(e)?.identifier;return typeof t==`string`?t:e.getExpected(Rm)}),W=Symbol(),zm=Ll,Bm=zm(W),Vm=zm(W),Hm=e=>e===W?er():tr(e),Um=e=>e._tag===`None`?Bm:zm(e.value),Wm=`~effect/SchemaIssue/Issue`;function Gm(e){return D(e,Wm)&&e[Wm]===Wm}function Km(e){return Object.hasOwn(e,`input`)}var qm=class{[Wm]=Wm;constructor(e,t){t?.reportInput===!0&&e!==W&&(this.input=e)}},Jm=class extends qm{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},Ym=class extends qm{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},Xm=class extends qm{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},Zm=class extends qm{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},Qm=class extends qm{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},$m=class extends qm{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},eh=class extends qm{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},th=class extends qm{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},nh=class extends qm{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},rh=class extends qm{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function ih(e,t,n){if(Gm(e))return e;if(typeof e==`string`)return new th({message:e},t,n);let r=typeof e.issue==`string`?new th({message:e.issue},t,n):e.issue;return new Xm(e.path,r)}function ah(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new th(void 0,t,n):ih(e,t,n)}function oh(e,t,n,r){return Array.isArray(t)?Wi(t)?t.length===1?ih(t[0],n,r):new $m(e,Ji(t,e=>ih(e,n,r)),n,r):void 0:ah(t,n,r)}var sh=e=>{let t=gh(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return dh(Rm(e.ast),e);case`InvalidValue`:{let t=uh(e);if(t!==void 0)return dh(t,e);let n=lh(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=lh(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=lh(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},ch=e=>gh(e.issue)??gh(e);function lh(e){return Km(e)?rt(e.input):void 0}function uh(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function dh(e,t){let n=lh(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function fh(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>fh(e)).join(` & `)}}function ph(){return e=>hh(e,``)}var mh=ph();function hh(e,t){let n;switch(e._tag){case`Filter`:{let r=ch(e);if(r!==void 0)n=r;else{if(e.issue._tag!==`InvalidValue`)return hh(e.issue,t);let r=uh(e.issue);n=r===void 0?dh(fh(e.filter),e):dh(r,e.issue)}break}case`Encoding`:return hh(e.issue,t);case`Pointer`:return hh(e.issue,t+ot(e.path));case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>hh(e,t)).join(`
|
|
22
|
-
`);n=gh(e)??dh(Rm(e.ast),e);break;default:n=sh(e);break}return t?`${n}\n at ${t}`:n}function gh(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return gh(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function _h(e){let t;for(let n of e.reasons){if(!Ou(n)||!Gm(n.error))return;t??=n.error}return t}function vh(e,t){let n=_h(e);if(n===void 0)throw Error(t,{cause:e});return n}var yh=e=>Object.assign(Object.create(v),e),bh=yh({_tag:`Passthrough`});function xh(){return bh}function Sh(e){return yh({_tag:`Transform`,transform:e})}function Ch(e){return yh({_tag:`TransformEffect`,transform:e})}function wh(e){return yh({_tag:`TransformOptional`,transform:e})}function Th(e){return yh({_tag:`TransformOptionalEffect`,transform:e})}function Eh(){return wh(()=>er())}function Dh(e){return Th(t=>{let n=lr(t,E);return rr(n)?R(n):Tf(e,tr)})}function Oh(){return Sh(globalThis.String)}function kh(){return Sh(globalThis.Number)}function Ah(e){return Ch((t,n)=>Cd({try:()=>JSON.parse(t,e?.reviver),catch:()=>new th({expected:`a valid JSON string`},t,n)}))}function jh(e){return Ch((t,n)=>Cd({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new th({expected:`a JSON-serializable value`},t,n)}))}var Mh=class extends y{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Mh(this.encode,this.decode)}},Nh=`~effect/SchemaTransformation/Transformation`,Ph=class extends y{[Nh]=Nh;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Ph(this.encode,this.decode)}};function Fh(e){return D(e,Nh)&&e[Nh]===Nh}var Ih=e=>Fh(e)?e:new Ph(e.decode,e.encode);function Lh(e){return new Ph(Sh(e.decode),Sh(e.encode))}var Rh=new Ph(xh(),xh());function zh(){return Rh}var Bh=new Ph(kh(),Oh()),Vh=e=>pe(e)&&typeof e.message==`string`,Hh=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:Kh(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},Uh=e=>{try{let t=ut(e);return t===void 0?rt(e):JSON.parse(t)}catch{return rt(e)}},Wh=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},Gh=e=>{let t=new WeakSet,n=r=>{if(he(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=Wh(r,e,n);return t.delete(r),i}return Uh(r)};return n},Kh=e=>Vh(e)?Hh(e):e,qh=e=>Lh({decode:Kh,encode:Gh(e)});function Jh(e){return new Ph(Ah(e??{}),jh(e))}function Yh(e){return t=>t._tag===e}var Xh=Yh(`Declaration`),Zh=Yh(`Never`),Qh=Yh(`Literal`),$h=Yh(`UniqueSymbol`),eg=Yh(`Arrays`),tg=Yh(`Objects`),ng=Yh(`Suspend`),rg=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},ig={},ag=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},og=`~effect/Schema`,sg=class{[og]=og;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},cg=class extends sg{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>t===W?Bm:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(e,t,n,r,i){let a=O_(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new cg(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},lg=new class extends sg{_tag=`Null`;getParser(){return G_(this,null)}getExpected(){return`null`}},ug=class extends sg{_tag=`Undefined`;getParser(){return G_(this,void 0)}toCodecJson(){return g_(this,[dg])}getExpected(){return`undefined`}},dg=new rg(lg,new Ph(Sh(()=>void 0),Sh(()=>null))),fg=new ug,pg=new class extends sg{_tag=`Unknown`;getParser(){return K_(this,fe)}getExpected(){return`unknown`}},mg=class extends sg{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${rt(e)}`);this.literal=e}getParser(){return G_(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?hg(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:hg(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function hg(e){let t=globalThis.String(e.literal);return g_(e,[new rg(new mg(t),new Ph(Sh(()=>e.literal),Sh(()=>t)))])}var gg=new class extends sg{_tag=`String`;getParser(){return K_(this,oe)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&tv(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},_g=class extends sg{_tag=`Number`;getParser(){return K_(this,se)}matchKey(e,t){return this._match(X_,e,t)}matchPart(e,t){return this._match(Y_,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:tv(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(vg(this.checks,`effect/schema/isFinite`)||vg(this.checks,`effect/schema/isInt`))?this:g_(this,[d_])}toCodecStringTree(){return this.toCodecJson()===this?g_(this,[$_]):g_(this,[ev])}getExpected(){return`number`}};function vg(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&vg(e.checks,t))}var yg=new _g,bg=new class extends sg{_tag=`Boolean`;getParser(){return K_(this,ce)}getExpected(){return`boolean`}},xg=class extends sg{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(L_(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(L_(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}return Df(function*(e,c){if(e===W)return W;if(!Array.isArray(e))return yield*B(new eh(n,e,c));r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)})));let l=e.length,u={ast:n,getParser:s,input:e,len:l,tailThreshold:Math.max(a,l-o),output:new globalThis.Array(l),issues:void 0,options:c},d=n.rest.length===0?a:Math.max(l,a+o),f=c.concurrency===void 0?1:Nc(c.concurrency),p=f===1?wg(u,e,0,d):Tg(u,e,{concurrency:f,end:d});if(p&&(yield*p),n.rest.length===0&&l>a)for(let t=a;t<=l-1;t++){let r=new Qm(n,e[t],c),i=new Xm([t],r);if(c.errors===`all`)u.issues?u.issues.push(i):u.issues=[i];else return yield*B(new $m(n,[i],e,c))}return u.issues?yield*B(new $m(n,u.issues,e,c)):u.output})}_rebuild(e,t,n){let r=O_(this.elements,e),i=O_(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new xg(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function Sg(e,t,n,r){if(n._tag===`Failure`)return Eg(e,e.ast,r,n);let i=n===Vm?t:n[A];if(i!==W)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(L_(t.ast))return;let n=new Xm([r],new Zm(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return zl(new $m(e.ast,[n],e.input,e.options))}}var Cg={onItem(e,t,n){let r=n<e.len?t:W;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:Sg},wg=Pc()(Cg),Tg=Ic()(Cg),Eg=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=_h(r.cause);if(i===void 0)return Rl(Mu(r.cause,r=>new $m(t,[new Xm([n],r)],e.input,e.options)));let a=new Xm([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return zl(new $m(t,[a],e.input,e.options))},Dg=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function Og(e,t,n=ig){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(q_(V_(t)))}var kg=class{name;type;constructor(e,t){this.name=e,this.type=t}};function Ag(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(Ag);default:return!1}}function jg(e){let t=v_(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(jg);default:return!1}}function Mg(e){return Ag(e)&&jg(e)}var Ng=class{parameter;type;constructor(e,t){if(!Mg(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,L_(t)&&!W_(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},Pg=class extends sg{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o;let s=new Set,c=[];for(let t of e){let e=t.name;s.has(e)?c.push(e):s.add(e)}if(c.length>0)throw Error(`Duplicate identifiers: ${JSON.stringify(c)}. ts(2300)`)}getParser(e,t=e){let n=this,r=[];for(let e of n.propertySignatures)r.push(typeof e.name==`number`?globalThis.String(e.name):e.name);let i=r.length,a=n.indexSignatures.length,o=i&&a?new Set(r):void 0;if(!i&&!a)return K_(n,de);let s,c,l=(e,t,r,a,s)=>{if(s._tag===`Failure`)return Eg(e,n,t,s)??Bl;let c=s===Vm?a:s[A];if(r!==W&&c!==W){if(i&&(o.has(t)||o.has(typeof r==`number`?globalThis.String(r):r)))return Bl;xt(e.out,r,c)}return Bl},u=(e,t,r,i)=>{if(!i){let n=r.parserKey(t,e.options);if(!as(n))return V(Od(n),n=>u(e,t,r,n));i=n}if(i._tag===`Failure`)return Eg(e,n,t,i)??Bl;let a=i===Vm?t:i[A],o=e.input[t],s=r.parserValue(o,e.options);return as(s)?l(e,t,a,o,s):V(Od(s),n=>l(e,t,a,o,n))},d=(e,t,n)=>{let r=e.input[t],i=n.parserValue(r,e.options);return as(i)?l(e,t,t,r,i):V(Od(i),n=>l(e,t,t,r,n))},f=a?Ic()({onItem:(e,[t,n])=>n.is.parameter===gg?d(e,t,n):u(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0,p=()=>(s||(s=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),c=a?n.indexSignatures.map(n=>({is:n,parserKey:e(q_(n.parameter)),parserValue:t(n.type)})):void 0),s),m=Df(function*(e,t){if(e===W)return W;if(!(typeof e==`object`&&e&&!Array.isArray(e)))return yield*B(new eh(n,e,t));p();let l=e,m={},h={ast:n,input:l,out:m,issues:void 0,options:t},g=t.errors===`all`,_=t.onExcessProperty===`error`,v=t.concurrency===void 0?1:Nc(t.concurrency),y=a&&_?n.indexSignatures.map(e=>Og(l,e.parameter,t)):void 0;if(_){o??=new Set(r);let i=y?new Set(o):o;if(y)for(let e of y)for(let t of e)i.add(t);let a=Reflect.ownKeys(l);for(let r=0;r<a.length;r++){let o=a[r];if(!i.has(o)){let r=new Qm(n,l[o],t),i=new Xm([o],r);if(g){h.issues?h.issues.push(i):h.issues=[i];continue}else return yield*B(new $m(n,[i],e,t))}}}if(i){let e=v===1?Lg(h,s):Rg(h,s,{concurrency:v});e&&(yield*e)}if(a&&v===1)for(let e=0;e<a;e++){let n=c[e],r=n.is.parameter===gg?d:u,i=y?.[e]??(n.is.parameter===gg?Object.keys(l):Og(l,n.is.parameter,t));for(let e=0;e<i.length;e++){let t=r(h,i[e],n);if(!as(t))yield*t;else if(t._tag===`Failure`)return yield*t}}else if(f){let e=Ki();for(let n=0;n<a;n++){let r=c[n],i=y?.[n]??(r.is.parameter===gg?Object.keys(l):Og(l,r.is.parameter,t));for(let t=0;t<i.length;t++)e.push([i[t],r])}let n=f(h,e,{concurrency:v});n&&(yield*n)}return h.issues?yield*B(new $m(n,h.issues,e,t)):m});if(a)return m;let h=(e,t,n)=>{let r=s[t];return V(Od(n),n=>{let i=Fg(e,r,n);if(i)return i;let a=()=>zm(e.out),o=Lg(e,s.slice(t+1));return o?Ef(o,a):a()})};return(e,t)=>{if(e===W)return Bm;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&Nc(t.concurrency)!==1)return m(e,t);if(!(typeof e==`object`&&e&&!Array.isArray(e)))return B(new eh(n,e,t));let r=p(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=Xg(i,s),l=c?i[s]:W,u=n.parser(l,t);if(!as(u))return h(o,e,u);if(u===Vm){c&&xt(a,s,l);continue}let d=Fg(o,n,u);if(d)return d}}catch(e){return Sd(e)}return zm(a)}}_rebuild(e,t,n,r){let i=O_(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new kg(t.name,n)}),a=O_(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new Ng(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new Pg(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function Fg(e,t,n){if(n._tag===`Failure`)return Eg(e,e.ast,t.name,n);if(n===Vm)return;let r=n[A];if(r!==W){xt(e.out,t.name,r);return}if(delete e.out[t.name],!L_(t.type)){let n=new Xm([t.name],new Zm(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}else return zl(new $m(e.ast,[n],e.input,e.options))}}var Ig={onItem(e,t){if(!Xg(e.input,t.name))return t.parser(W,e.options);let n=e.input[t.name];return xt(e.out,t.name,n),t.parser(n,e.options)},step:Fg},Lg=Pc()(Ig),Rg=Ic()(Ig);function zg(e,t){return e?t?[...e,...t]:e:t}function Bg(e,t,n){return new Pg(Reflect.ownKeys(e).map(t=>new kg(t,e[t].ast)),[],n,t)}function Vg(e){return e.ast}function Hg(e,t=void 0){return new xg(!1,e.map(e=>e.ast),[],void 0,t)}function Ug(e,t,n){return new e_(e.map(Vg),t,void 0,n)}function Wg(e){if(e.encoding)throw Error(`mutable does not support encodings`);return new xg(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}var Gg=w(e=>{for(;;){if(ng(e))return pg;let t=e.encoding;if(!t)return e.recur?.(Gg,x)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==x))return pg;e=t[t.length-1].to}});function Kg(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(Kg)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function qg(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[Im];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!L_(t)){if(Qh(t))return[{key:e.name,literal:t.literal}];if($h(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!L_(e)){if(Qh(e))return[{key:t,literal:e.literal}];if($h(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>qg(Gg(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return qg(e.thunk())}}var Jg=new WeakMap,Yg=Object.freeze([]),Xg=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function Zg(e){let t=Jg.get(e);if(t)return t;let n,r=0,i,a,o=!0;for(let t=0;t<e.length;t++){let s=e[t],c=Gg(s);if(Zh(c))continue;if(o)if(Qh(c)||$h(c)){a??=new Map;let e=Qh(c)?c.literal:c.symbol,t=a.get(e);t||a.set(e,t=[]),t.push(s)}else o=!1;let l=qg(c);if(l.length){n??=new Map,r++;for(let{key:e,literal:r}of l){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=Kg(c);for(let n of e)(i[n]??=[]).push(t)}}if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??Yg;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=i;for(let[t,n]of i)a.set(t,Object.freeze(Array.from(n,t=>e[t])));t=(t,n)=>{if(me(t)){let i=Xg(t,r)?t[r]:void 0;if(i!==void 0)return a.get(i)??Yg;if(n)return e}return Yg}}else if(n){let a;for(let e of n)(!a||e[1][0].size>a[1][0].size)&&e[1][1].size===r&&(a=e);t=(t,r)=>{let o=i?.[t===null?`null`:Array.isArray(t)?`array`:typeof t]??Yg;if(!me(t))return o.map(t=>e[t]);let s=new Set(o),c;if(a){let[n,[i]]=a,l=Xg(t,n),u=l?t[n]:void 0;if(l&&(!r||u!==void 0)){let t=i.get(u);if(!t)return o.map(t=>e[t]);for(let e of t)s.add(e);c=n}}if(c===void 0)for(let[e,[i,a]]of n){let n=Xg(t,e),o=n?t[e]:void 0;if(n&&(!r||o!==void 0)){let e=i.get(o);if(e)for(let t of e)s.add(t)}else if(r)for(let e of a)s.add(e)}for(let[e,[i,a]]of n){if(e===c)continue;let n=Xg(t,e),o=n?t[e]:void 0;if(n&&(!r||o!==void 0)){let e=i.get(o);for(let t of s)a.has(t)&&!e?.has(t)&&s.delete(t)}}return Array.from(s).sort((e,t)=>e-t).map(t=>e[t])}}else t=t=>(i?.[t===null?`null`:Array.isArray(t)?`array`:typeof t]??Yg).map(t=>e[t]).filter(Qg(t));return Jg.set(e,t),t}function Qg(e){return t=>{let n=Gg(t);return n._tag===`Literal`?n.literal===e:n._tag===`UniqueSymbol`?n.symbol===e:!0}}function $g(e,t,n=!1){return Zg(t)(e,n)}var e_=class extends sg{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this;return(r,i)=>{if(r===W)return Bm;let a=$g(r,n.types,t!==void 0);if(a.length===0)return B(new nh(n,[],r,i));if(a.length===1){let t=e(a[0])(r,i);return t._tag===`Success`?t:as(t)?t_(n,t.cause,r,i):Fd(t,e=>t_(n,e,r,i))}let o={ast:n,compile:e,input:r,out:void 0,successes:n.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},s=n_(o,a);return s?Ef(s,e=>o.out===Vm?R(r):o.out?o.out:B(new nh(n,o.issues??[],r,i))):o.out?o.out:B(new nh(n,o.issues??[],r,i))}}_rebuild(e,t,n){let r=O_(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new e_(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=V_(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(Qh);if(t.length>0)return`${i_(n.isMutable)}[ ${t.map(t=>e(t)+a_(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>Qh(e.type));if(t.length>0)return`{ ${t.map(t=>`${i_(t.type.context?.isMutable)}${at(t.name)}${a_(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function t_(e,t,n,r){let i=_h(t);return i?zl(new nh(e,[i],n,r)):Rl(t)}var n_=Pc()({onItem(e,t){return e.compile(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=_h(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(t),zl(new rh(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(t);else return Bl}}}),r_=new e_([new mg(`Infinity`),new mg(`-Infinity`),new mg(`NaN`)]);function i_(e){return e?``:`readonly `}function a_(e){return e?`?`:``}var o_=class extends sg{_tag=`Suspend`;thunk;constructor(e,t,n,r,i){if(n)throw Error(`Cannot add checks to Suspend`);super(t,void 0,r,i);let a;this.thunk=()=>a??=e()}getParser(e){let t;return(n,r)=>(t??=e(this.thunk()))(n,r)}recur(e){return new o_(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}},s_=class extends y{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new s_(this.run,{...this.annotations,...e},this.aborted)}abort(){return new s_(this.run,this.annotations,!0)}and(e,t){return new c_([this,e],t)}},c_=class extends y{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new c_(this.checks,{...this.annotations,...e})}and(e,t){return new c_([this,e],t)}};function l_(e,t,n=!1){return new s_((t,n,r)=>oh(n,e(t,n,r),t,r),t,n)}function u_(e){return l_(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}var d_=new rg(new e_([x_(yg,[u_()]),r_]),new Ph(kh(),Sh(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function f_(e,t){let n=e.source,r=new globalThis.RegExp(n,e.flags);return l_(e=>(r.lastIndex=0,r.test(e)),{expected:`a string matching the RegExp ${n}`,representation:{id:`effect/schema/isPattern`,payload:{source:n,flags:e.flags}},toJsonSchema:()=>({pattern:n}),arbitraryConstraint:{patterns:[{source:e.source,flags:e.flags}]},...t})}function p_(e,t){let n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}var m_=new WeakMap;function h_(e){return m_.get(e)??e}function g_(e,t){return e.encoding===t?e:p_(e,e=>{e.encoding.value=t})}function __(e,t){if(e.context===t)return e;let n=h_(e);if(n.context===t)return n;let r=p_(e,e=>{e.context.value=t});return m_.set(r,n),r}function v_(e){return e.encoding?v_(e.encoding[e.encoding.length-1].to):e}function y_(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return b_(e,Hi(e.checks.slice(0,-1),n.annotate(t)))}return p_(e,e=>{e.annotations.value={...e.annotations.value,...t}})}function b_(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:p_(e,e=>{e.checks.value=t})}function x_(e,t){return b_(e,zg(e.checks,t))}function S_(e,t){let n=t(e.to);return n===e.to?e:new rg(n,e.transformation)}function C_(e,t){let n=e,r=n[n.length-1],i=S_(r,t);return i===r?e:Hi(e.slice(0,e.length-1),i)}function w_(e){return t=>t.encoding?g_(t,C_(t.encoding,e)):t}function T_(e,t){return w_(e=>__(e,t))(e)}function E_(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:g_(r,C_(r.encoding,n))}return e(r)}return w(n)}function D_(e,t,n){let r=new rg(e,t);return g_(n,n.encoding?[...n.encoding,r]:[r])}function O_(e,t){let n=!1,r=Array(e.length);for(let i=0;i<e.length;i++){let a=e[i],o=t(a);o!==a&&(n=!0),r[i]=o}return n?r:e}function k_(e,t){return __(e,e.context?new ag(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new ag(!1,!1,void 0,t))}var A_=w(e=>j_(__(e,e.context?e.context.isOptional===!1?new ag(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new ag(!0,!1)))),j_=w_(A_),M_=re(e=>A_(new e_([e,fg])));function N_(e,t){return __(e,e.context?new ag(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new ag(!1,!1,t))}function P_(e,t,n){return D_(e,n,t)}function F_(e){let t=[],n=[];function r(e){switch(e._tag){case`Literal`:ue(e.literal)&&t.push(e.literal);return;case`UniqueSymbol`:t.push(e.symbol);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)r(e.types[t]);return;default:n.push(e)}}return r(e),{literals:t,parameters:n}}function I_(e,t){let{literals:n,parameters:r}=F_(e);return new Pg(n.map(e=>new kg(e,t)),r.map(e=>new Ng(e,t)))}function L_(e){return e.context?.isOptional??!1}function R_(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(R_)}function z_(e){function t(e){return R_(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Ui(n)?n:void 0}var B_=w(e=>{if(e.encoding)return B_(g_(e,void 0));let t=e,n=t.recur?.(B_)??t,r=n.encodingChecks;if(r){let t=n===e?r:eg(n)||tg(n)||Xh(n)&&n.typeParameters.length>0?z_(r):void 0;return p_(n,e=>{e.encodingChecks.value=void 0,e.checks.value=zg(n.checks,t)})}return n}),V_=w(e=>B_(U_(e)));function H_(e,t){let n=t,r=n.length,i=n[r-1],a=[new rg(U_(g_(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new rg(U_(n[e-1].to),n[e].transformation.flip()));let o=U_(i.to);return o.encoding?g_(o,[...o.encoding,...a]):g_(o,a)}var U_=re(e=>{if(e.encoding)return H_(e,e.encoding);let t=e;return t.flip?.(U_)??t.recur?.(U_)??t});function W_(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(W_);default:return!1}}function G_(e,t){let n=t===0?Vm:zm(t);return(r,i)=>r===W?Bm:r===t?n:B(new eh(e,r,i))}function K_(e,t){return(n,r)=>n===W?Bm:t(n)?Vm:B(new eh(e,n,r))}var q_=E_(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(q_)}}),J_=E_(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(J_)}}),Y_=new globalThis.RegExp(`^${Dg}$`),X_=new globalThis.RegExp(`^(?:${Dg}|Infinity|-Infinity|NaN)$`);function Z_(e){return f_(Y_,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:Y_.source}),...e})}var Q_=x_(gg,[Z_()]),$_=new rg(Q_,Bh),ev=new rg(new e_([Q_,r_]),Bh);function tv(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=tv(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new Jm(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function nv(e){if(!Xh(e))return;let t=e.annotations?.[Lm];return T(t)?t(e.typeParameters):void 0}function rv(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function iv(e){return e===void 0||typeof e==`string`}function av(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function ov(e){return av(e,rv)}var sv=new cg([],()=>(e,t,n)=>ov(e)?Vm:B(new eh(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>dv}),cv=new rg(sv,zh()),lv=new rg(new e_([new xg(!1,[],[sv]),new Pg([],[new Ng(gg,sv)])]),zh());function uv(e){return av(e,iv)}var dv=new rg(new cg([],()=>(e,t,n)=>uv(e)?Vm:B(new eh(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),zh()),fv=(e,t,n)=>e===Vm?n(t):Ef(e,n);function pv(e){if(e._tag===`Middleware`)return(t,n,r)=>mv(t===Vm?e.decode(zm(Hm(n)),r):e.decode(Tf(t,Hm),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===Vm?zm(t):e;case`Transform`:{let e=e=>e===W?Bm:zm(t.transform(e));return(t,n)=>fv(t,n,e)}case`TransformOptional`:{let e=e=>Um(t.transform(Hm(e)));return(t,n)=>fv(t,n,e)}case`TransformEffect`:return(e,n,r)=>fv(e,n,e=>e===W?Bm:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>fv(e,n,e=>mv(t.transform(Hm(e),r)))}}var mv=e=>Ef(e,Um),hv=(e,t,n,r)=>Fd(r,r=>xd(()=>Mu(r,r=>new Ym(e,r,t,n))));function gv(e,t){let n=pv(e.link.transformation),r;return(i,a)=>{if(i===W)return Bm;if(e.isConstructed(i))return Vm;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function _v(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==W&&r!==void 0)return t(r,i);let a=n;if(as(a)&&a._tag===`Success`){let e=t(a[A],i);return e===Vm?a:e}return Ef(hv(e,r,i,a),e=>{let n=t(e,i);return n===Vm?zm(e):n})}}function vv(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:_v(e,n)}function yv(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?nv(e):void 0,o=a?gv(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>pv(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);if(u&&!n.disableChecks)if(as(r)){if(r._tag===`Success`){let i=r===Vm?t:r[A];if(t!==W&&i!==W){let i=tv(u,t,void 0,e,n);i&&(r=B(new $m(e,i,t,n)))}}}else r=V(r,r=>{if(t!==W&&r!==W){let r=tv(u,t,void 0,e,n);if(r)return B(new $m(e,r,t,n))}return R(r)});if(s&&!n.disableChecks)if(as(r)){if(r._tag===`Success`){let i=r===Vm?t:r[A];if(i===W)return r;let a=tv(s,i,void 0,e,n);a&&(r=B(new $m(e,a,i,n)))}}else r=V(r,t=>{if(t!==W){let r=tv(s,t,void 0,e,n);if(r)return B(new $m(e,r,t,n))}return R(t)});return r},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[A],o=t(a,r)):o=Ef(o,e=>{let n=t(e,r);return n===Vm?zm(e):n})}if(o._tag===`Success`){let e=o[A],t=p(e,r);return t===Vm?o:t}return o=hv(e,n,r,o),Ef(o,e=>{let t=p(e,r);return t===Vm?zm(e):t})}:p}var bv=Symbol(),xv=new WeakMap,Sv,Cv=e=>Av(e).parser,wv=e=>Av(e).makeEffect,Tv=e=>vv(e,wv),Ev=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=yv(this.ast,Cv)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=yv(this.ast,wv,Tv)}},Dv=class extends Ev{compiled;resolve;constructor(e,t,n){super(e),this.compiled=t,this.resolve=n}save(e,t){return Object.defineProperty(this,e,{value:t}),t}operation(e){let t=this.compiled;return typeof t==`function`?t(this.ast,this.resolve,e):t?.[e]}get is(){return this.save(`is`,this.operation(`is`))}get decode(){return this.save(`decode`,this.operation(`decode`))}get make(){return this.save(`make`,this.operation(`make`))}get decodeEffect(){return this.save(`decodeEffect`,this.operation(`decodeEffect`)??yv(this.ast,e=>kv(this.resolve,e,`parser`)))}get parser(){let e=this.decode;return e===void 0?this.decodeEffect:this.save(`parser`,Ov(e,()=>this.decodeEffect))}get makeEffect(){let e=this.operation(`makeEffect`);if(e!==void 0)return this.save(`makeEffect`,e);let t=e=>kv(this.resolve,e,`makeEffect`);return this.save(`makeEffect`,yv(this.ast,t,e=>vv(e,t)))}};function Ov(e,t){let n;return(r,i)=>{if(r!==W)try{let t=e(r,i);if(t!==bv)return t===r?Vm:zm(t)}catch(e){return Sd(e)}return(n??=t())(r,i)}}function kv(e,t,n){let r=e(t);if(r.compiled===void 0||Object.hasOwn(r,n))return r[n];let i;return(e,t)=>(i??=r[n])(e,t)}function Av(e){let t=xv.get(e);if(t!==void 0)return t;let n=Sv===void 0?new Ev(e):new Dv(e,Sv(e,Av),Av);return xv.set(e,n),n}function jv(e){let t=e.ast,n;return(e,r)=>(n??=Bv(Kv,B_(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function Mv(e){let t=jv(e);return(e,n)=>{let r=Sf(t(e,n));return Vl(r)?tr(r.value):(vh(r.cause,`Option adapter can only return none for schema issues`),er())}}function Nv(e){return Wv(B_(e.ast))}function Pv(e,t){let n=Rv(e.ast);return t===void 0?n:(e,r)=>n(e,Iv(t,r))}function Fv(e,t){return Hv(Pv(e,t))}var Iv=(e,t)=>t?{...e,...t}:e,Lv=e=>e===W?B(new th):R(e);function Rv(e){return Bv(Gv,e)}function zv(e,t){return e===Vm?R(t):as(e)?e[A]===W?Lv(W):e:Ef(e,Lv)}function Bv(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??ig);return a===Vm?R(r):as(a)?a[A]===W?Lv(W):a:Ef(a,Lv)}}function Vv(e){return(t,n)=>Sf(e(t,n))}function Hv(e){let t=Vv(e);return(e,n)=>{let r=t(e,n);return Vl(r)?tr(r.value):(vh(r.cause,`Option adapter can only return none for schema issues`),er())}}function Uv(e,t){let n=Sf(e);if(Vl(n))return n.value;let r=vh(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}function Wv(e){let t,n;return(r,i)=>{t??=Av(e);let a=i?.disableChecks?i.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions??ig,o=t.make;if(o!==void 0&&r!==W){let e;try{e=o(r,a)}catch(e){throw vh(Au(e),`Constructor adapter can only throw schema issues`),e}if(e!==bv&&e!==W)return e}return Uv(zv((n??=t.makeEffect)(r,a),r),`Constructor adapter can only throw schema issues`)}}var Gv=e=>Av(e).parser,Kv=e=>Av(e).makeEffect,qv=`~effect/Schema/Schema`,Jv={[qv]:qv,pipe(){return _(this,arguments)},annotate(e){return this.rebuild(y_(this.ast,e))},annotateKey(e){return this.rebuild(k_(this.ast,e))},check(...e){return this.rebuild(x_(this.ast,e))}};function Yv(e,t){function n(){}let r=Object.setPrototypeOf(n,Jv);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r.ast=e,r.rebuild=e=>Yv(e,t),r.makeEffect=jv(r),r.make=Nv(r),r.makeOption=Mv(r),r}function Xv(e){return Yv(Zv(e.ast),{schema:e})}var Zv=E_(e=>{let t=ny(e,Zv),n=e.context;return t===e||n===void 0?t:T_(t,Qv(n))});function Qv(e){return e.constructorDefault===void 0?e:new ag(e.isOptional,e.isMutable,void 0,e.annotations)}function $v(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function ey(e){return t=>{let n=new Map;for(let e=0;e<t.length;e++)n.set(V_(t[e]),e);let r=[...t].sort((t,r)=>{t=V_(t),r=V_(r);let i=e(t),a=e(r);return i===a?n.get(t)-n.get(r):i-a});return r.some((e,n)=>e!==t[n])?r:t}}var ty=ey(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function ny(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!T(n))return g_(e,[cv]);let r=n(e.typeParameters.map(e=>Yv(V_(e))));return r===void 0?e:g_(e,[S_(r,t)])}case`Unknown`:return g_(e,[cv]);case`ObjectKeyword`:return g_(e,[lv]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return $v(e),e.recur(t,J_);case`Union`:{let n=ty(e.types);return n===e.types?e.recur(t):new e_(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var ry=e=>e,iy=`~effect/Schema/SchemaError`,ay=new WeakMap,oy=e=>{if(ay.has(e))return ay.get(e);throw Error(`Unable to get redacted value`+(e.label?` with label: "${e.label}"`:``))},sy=e=>typeof e==`string`?e:oy(e),cy=`~effect/Redacted`,ly=e=>D(e,cy),uy=(e,t)=>{let n=Object.create(dy);return t?.label&&(n.label=t.label),ay.set(n,e),n},dy={[cy]:{_A:e=>e},label:void 0,...jt,toJSON(){return this.toString()},toString(){return`<redacted${oe(this.label)?`:`+this.label:``}>`},[ge](){return k(ay.get(this))},[Ne](e){return ly(e)&&Pe(ay.get(this),ay.get(e))}},fy=`~effect/http/Cookies`,py=`~effect/http/Cookies/Cookie`;la(`CookiesError`);var my={[fy]:fy,...mt,toJSON(){return{_id:`effect/Cookies`,cookies:Ii(this.cookies,e=>e.toJSON())}},pipe(){return _(this,arguments)}},hy=e=>{let t=Object.create(my);return t.cookies=e,t},gy=e=>{let t={};for(let n of e)xt(t,n.name,n);return hy(t)},_y=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=vy(e.trim());t&&n.push(t)}return gy(n)};function vy(e){let t=e.split(`;`).map(e=>e.trim()).filter(e=>e!==``);if(t.length===0)return;let n=t[0].indexOf(`=`);if(n===-1)return;let r=t[0].slice(0,n);if(!yy.test(r))return;let i=t[0].slice(n+1),a=xy(i);if(t.length===1)return Object.assign(Object.create(by),{name:r,value:a,valueEncoded:i});let o={};for(let e=1;e<t.length;e++){let n=t[e],r=n.indexOf(`=`),i=r===-1?n:n.slice(0,r).trim(),a=r===-1?void 0:n.slice(r+1).trim();switch(i.toLowerCase()){case`domain`:{if(a===void 0)break;let e=a.trim().replace(/^\./,``);e&&(o.domain=e);break}case`expires`:{if(a===void 0)break;let e=new Date(a);isNaN(e.getTime())||(o.expires=e);break}case`max-age`:{if(a===void 0)break;let e=parseInt(a,10);isNaN(e)||(o.maxAge=pi(e));break}case`path`:if(a===void 0)break;a[0]===`/`&&(o.path=a);break;case`priority`:if(a===void 0)break;switch(a.toLowerCase()){case`low`:o.priority=`low`;break;case`medium`:o.priority=`medium`;break;case`high`:o.priority=`high`;break}break;case`httponly`:o.httpOnly=!0;break;case`secure`:o.secure=!0;break;case`partitioned`:o.partitioned=!0;break;case`samesite`:if(a===void 0)break;switch(a.toLowerCase()){case`lax`:o.sameSite=`lax`;break;case`strict`:o.sameSite=`strict`;break;case`none`:o.sameSite=`none`;break}break}}return Object.assign(Object.create(by),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var yy=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,by={[py]:py,...mt,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},xy=e=>{try{return decodeURIComponent(e)}catch{return e}},Sy=Symbol.for(`~effect/http/Headers`),Cy=Object.defineProperties(Object.create(null),{[Sy]:{value:Sy},[Xe]:{value(e){return Ny(this,Lr(e,Fy))}},toJSON:{value(){return Qe(this)}},[Ne]:{value(e){return Ty(this,e)}},[ge]:{value(){return we(this)}},toString:{value:mt.toString},[dt]:{value:mt[dt]}}),wy=e=>Object.assign(Object.create(Cy),e),Ty=zi(Sn()),Ey=Object.create(Cy),Dy=e=>{if(e===void 0)return Ey;if(Symbol.iterator in e){let t=Object.create(Cy);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(Cy);for(let[n,r]of Object.entries(e))Array.isArray(r)?t[n.toLowerCase()]=r.join(`, `):r!==void 0&&(t[n.toLowerCase()]=r);return t},Oy=e=>Object.setPrototypeOf(e,Cy),ky=b(3,(e,t,n)=>{let r=wy(e);return r[t.toLowerCase()]=n,r}),Ay=b(2,(e,t)=>wy({...e,...Dy(t)})),jy=b(2,(e,t)=>{let n=wy(e);return Object.assign(n,t),n}),My=b(2,(e,t)=>{let n=wy(e);return delete n[t.toLowerCase()],n}),Ny=b(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=uy(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=uy(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),Py=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(typeof r==`string`){if(r.toLowerCase()===e.toLowerCase())return!0}else if(e.search(r)!==-1)return!0}return!1},Fy=Ur(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),Iy=`~effect/http/UrlParams`,Ly=e=>D(e,Iy),Ry={...jt,[Iy]:Iy,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:`UrlParams`,params:Object.fromEntries(this.params)}},[Ne](e){return Hy(this,e)},[ge](){return Ee(this.params.flat())}},zy=e=>{let t=Object.create(Ry);return t.params=e,t},By=e=>{if(Ly(e))return e;let t=Vy(e),n=[];for(let e=0;e<t.length;e++)if(Array.isArray(t[e][0])){let[r,i]=t[e];n.push([`${r[0]}[${r.slice(1).join(`][`)}]`,i])}else n.push(t[e]);return zy(n)},Vy=e=>{let t=typeof e[Symbol.iterator]==`function`?Vi(e):Object.entries(e),n=[];for(let[e,r]of t)if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]!==void 0&&n.push([e,String(r[t])]);else if(typeof r==`object`&&r){let t=Vy(r);for(let[r,i]of t)n.push([[e,...typeof r==`string`?[r]:r],i])}else r!==void 0&&n.push([e,String(r)]);return n},Hy=bn((e,t)=>Uy(e.params,t.params)),Uy=Yi(ji([Sn(),Sn()])),Wy=zy([]),Gy=b(2,(e,t)=>{let n=By(t).params.slice(),r=new Set;for(let e=0;e<n.length;e++)r.add(n[e][0]);for(let t=0;t<e.params.length;t++)r.has(e.params[t][0])||n.push(e.params[t]);return zy(n)}),Ky=qv,qy=class extends la(`SchemaError`){[iy]=iy;constructor(e){let t=_t();vt(0);try{super({issue:e})}finally{vt(t)}}get message(){return mh(this.issue)}toString(){return`SchemaError(${this.message})`}};function Jy(e){return as(e)?Yy(e):Fd(e,e=>xd(()=>Mu(e,e=>new qy(e))))}function Yy(e){return Vl(e)?e:Rl(Mu(e.cause,e=>new qy(e)))}function Xy(e,t){let n=Pv(e,t);return(e,t)=>Jy(n(e,t))}var Zy=Xy,Qy=Fv,$y=Yv;function eb(e){return D(e,Ky)&&e[Ky]===Ky}var G=ry(e=>$y(A_(e.ast),{schema:e})),tb=ry(e=>{let t=hb(e);return $y(M_(e.ast),{schema:t})}),nb=ry(e=>$y(V_(e.ast),{schema:e}));function rb(e){let t=$y(new mg(e),{literal:e,transform(n){return t.pipe(_b(rb(n),{decode:Sh(()=>n),encode:Sh(()=>e)}))}});return t}var ib=$y(pg),ab=$y(lg),ob=$y(fg),K=$y(gg),q=$y(yg),sb=$y(bg);function cb(e,t){return $y(e,{fields:t,mapFields(e,t){let n=e(this.fields);return cb(Bg(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function J(e){return cb(Bg(e,void 0),e)}function lb(e,t){return $y(I_(e.ast,t.ast),{key:e,value:t})}function ub(e,t){return $y(e,{elements:t,mapElements(e,t){let n=e(this.elements);return ub(Hg(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}var Y=ry(e=>$y(new xg(!1,[],[e.ast]),{value:e})),db=ry(e=>$y(Wg(e.ast),{schema:e}));function fb(e,t){return $y(e,{members:t,mapMembers(e,t){let n=e(this.members);return fb(Ug(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function pb(e,t){return fb(Ug(e,t,void 0),e)}function X(e){let t=e.map(rb);return $y(Ug(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return pb(e(this.members))},pick(e){return X(e)},transform(e){return pb(t.map((t,n)=>t.transform(e[n])))}})}var mb=ry(e=>pb([e,ab])),hb=ry(e=>pb([e,ob]));function gb(e){return $y(new o_(()=>e().ast))}function _b(e,t){return n=>$y(P_(n.ast,e.ast,t?Ih(t):zh()),{from:n,to:e})}function vb(e){return t=>$y(N_(t.ast,e),{schema:t})}function yb(e){return Fd(e,e=>xd(()=>Mu(e,e=>e.issue)))}function bb(e,t){let n=t?.encodingStrategy===`omit`?Eh():xh();return t=>G(nb(t)).pipe(_b(t,{decode:Dh(yb(e)),encode:n}))}function xb(e){return rb(e).pipe(vb(R(e)))}function Sb(e,t){return J({_tag:xb(e),...t})}var Cb=l_;function wb(e,t){let n=e.source,r=e.flags,i=r===``?`new RegExp(${rt(n)})`:`new RegExp(${rt(n)}, ${rt(r)})`;return f_(e,{toCode:()=>({runtime:`Schema.isPattern(${i})`}),...t})}var Tb=u_;function Eb(e){let t=Zn(e.order),n=e.formatter??rt;return(r,i)=>Cb(e=>t(e,r),{expected:`a value greater than ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r,exclusiveMinimum:!0},...e.annotate?.(r),...i})}function Db(e){let t=$n(e.order),n=e.formatter??rt;return(r,i)=>Cb(e=>t(e,r),{expected:`a value greater than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r},...e.annotate?.(r),...i})}function Ob(e){let t=Qn(e.order),n=e.formatter??rt;return(r,i)=>Cb(e=>t(e,r),{expected:`a value less than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,maximum:r},...e.annotate?.(r),...i})}function kb(e){let t=$n(e.order),n=Zn(e.order),r=Qn(e.order),i=Xn(e.order),a=e.formatter??rt;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return Cb(e=>c(e,o.minimum)&&l(e,o.maximum),{expected:`a value between ${a(o.minimum)}${o.exclusiveMinimum?` (excluded)`:``} and ${a(o.maximum)}${o.exclusiveMaximum?` (excluded)`:``}`,arbitraryConstraint:{order:e.order,minimum:o.minimum,maximum:o.maximum,...o.exclusiveMinimum&&{exclusiveMinimum:!0},...o.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(o),...s})}}function Ab(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${rt(e)}`);return e}var jb=Eb({order:Jn,annotate:e=>({representation:{id:`effect/schema/isGreaterThan`,payload:{exclusiveMinimum:Ab(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${rt(e)})`})})}),Mb=Db({order:Jn,annotate:e=>({representation:{id:`effect/schema/isGreaterThanOrEqualTo`,payload:{minimum:Ab(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${rt(e)})`})})}),Nb=Ob({order:Jn,annotate:e=>({representation:{id:`effect/schema/isLessThanOrEqualTo`,payload:{maximum:Ab(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${rt(e)})`})})}),Pb=kb({order:Jn,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:Ab(e.minimum),maximum:Ab(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${rt(e.minimum)}, maximum: ${rt(e.maximum)}, exclusiveMinimum: ${rt(t)}, exclusiveMaximum: ${rt(n)} })`})}}});function Fb(e){return Cb(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>({type:`integer`}),toCode:()=>({runtime:`Schema.isInt()`}),arbitraryConstraint:{number:`integer`},...e})}function Ib(e,t){return e=Math.max(0,Math.floor(e)),Cb(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:`effect/schema/isMinLength`,payload:{minLength:e}},toJsonSchema:({type:t})=>t===`array`?{minItems:e}:{minLength:e},toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[Fm]:!0,arbitraryConstraint:{minLength:e},...t})}function Lb(e,t){return e=Math.max(0,Math.floor(e)),Cb(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:`effect/schema/isMaxLength`,payload:{maxLength:e}},toJsonSchema:({type:t})=>t===`array`?{maxItems:e}:{maxLength:e},toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[Fm]:!0,arbitraryConstraint:{maxLength:e},...t})}function Rb(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),Cb(n=>n.length>=e&&n.length<=t,{expected:e===t?`a value with a length of ${e}`:`a value with a length between ${e} and ${t}`,representation:{id:`effect/schema/isLengthBetween`,payload:{minimum:e,maximum:t}},toJsonSchema:({type:n})=>n===`array`?{allOf:[{minItems:e},{maxItems:t}]}:{allOf:[{minLength:e},{maxLength:t}]},toCode:()=>({runtime:`Schema.isLengthBetween(${e}, ${t})`}),[Fm]:!0,arbitraryConstraint:{minLength:e,maxLength:t},...n})}function zb(e){return Cb(e=>Xi(e).length===e.length,{expected:`an array with unique items`,representation:{id:`effect/schema/isUnique`,payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:`Schema.isUnique()`}),arbitraryConstraint:{uniqueBy:x},...e})}var Bb=e=>e?.includeStack===!0|(e?.excludeCause===!0?2:0),Vb=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},Hb=[];function Ub(e){let t=Bb(e),n=Hb[t];if(n!==void 0)return n;let r=nx.pipe(_b(ib,qh(Vb(t))));return Hb[t]=r,r}globalThis.RegExp,globalThis.URL;var Wb=K.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function Gb(e,t){return Wb.pipe(_b(e,Jh(t)))}globalThis.File,globalThis.FormData,globalThis.URLSearchParams,globalThis.Uint8Array;var Kb=globalThis.Symbol.for(`immer-draftable`),qb={};function Jb(e,t,n,r,i){let a=Zb(n,t,r),o=Xb(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===qb?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:qb,value:i}})}static[Ky]=Ky;get[o](){return o}static[Kb]=!0;static identifier=t;static fields=n.fields;static get ast(){return a(this).ast}static pipe(){return _(this,arguments)}static rebuild(e){return a(this).rebuild(e)}static make(e,t){return Nv(a(this))(e??{},t)}static makeOption(e,t){return Mv(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(y_(this.ast,e))}static annotateKey(e){return this.rebuild(k_(this.ast,e))}static check(...e){return this.rebuild(x_(this.ast,e))}static extend(e){return(t,r)=>{let a=Qb(t)?t:J(t),o={...n.fields,...a.fields},s=Bg(o,n.ast.checks,{identifier:e});return Jb(this,e,cb(x_(s,a.ast.checks),o),r,i)}}static mapFields(e,t){return n.mapFields(e,t)}};return i!==void 0&&Object.assign(s.prototype,i(t)),s}function Yb(e){return new Ph(Sh(t=>new e(t,{"~payload":{token:qb,value:t}})),xh())}function Xb(e){return`~effect/Schema/Class/${e}`}function Zb(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=Xb(t),o=e=>e instanceof i||D(e,a),s=Yb(i);return r=_b($y(new cg([e.ast],()=>(e,t,n)=>o(e)?R(e):B(new eh(t,e,n)),{identifier:t,[Lm]:([e])=>({isConstructed:o,link:new rg(e,s)}),toCodec:([e])=>new rg(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[Im]:qg(e.ast),...n})),s)(e)}}function Qb(e){return eb(e)}var $b=e=>(t,n)=>Jb(dn,e,Qb(t)?t:J(t),n,e=>({name:e})),ex=e=>(t,n,r)=>{let i=Qb(n)?n.mapFields(e=>({_tag:xb(t),...e}),{unsafePreserveChecks:!0}):Sb(t,n);return $b(e??t)(i,r)},tx=Xv,nx=$y(y_(sv,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),rx=`~effect/http/HttpBody`;la(`HttpBodyError`);var ix=class{[rx];constructor(){this[rx]=rx}[dt](){return this.toJSON()}toString(){return rt(this,{ignoreToString:!0})}},ax=new class extends ix{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},ox=class extends ix{_tag=`Uint8Array`;contentType;contentLength;text;_body;constructor(e,t,n,r){super(),this._body=e,this.text=r,this.contentType=t,this.contentLength=n}get body(){return this._body??=lx(this.text)}toJSON(){return{_id:`effect/HttpBody`,_tag:`Uint8Array`,body:this.contentType.startsWith(`text/`)||this.contentType.endsWith(`json`)?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},sx=new TextEncoder,cx=globalThis.Buffer,lx=cx===void 0?e=>sx.encode(e):e=>cx.from(e,`utf8`),ux=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),cx!==void 0)return new ox(void 0,t??`text/plain`,cx.byteLength(e,`utf8`),e);let n=sx.encode(e);return new ox(n,t??`text/plain`,n.length,e)},dx=(e,t)=>ux(JSON.stringify(e),t??`application/json`),fx=`~effect/http/HttpClientError`,px=class extends la(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[fx]=fx;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},mx=e=>e.endsWith(`Error`)?e.slice(0,-5):e,hx=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,gx=class extends la(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return hx(mx(this._tag),this.description,this.methodAndUrl)}};la(`EncodeError`);var _x=class extends la(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return hx(mx(this._tag),this.description,this.methodAndUrl)}},vx=class extends la(`StatusCodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return hx(mx(this._tag),this.description,e)}},yx=class extends la(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return hx(mx(this._tag),this.description,e)}},bx=class extends la(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return hx(mx(this._tag),this.description,e)}};$b(fx)({_tag:xb(`HttpError`),kind:X([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:tb(Ub())});var xx=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],Sx=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?My(My(e,`content-type`),`content-length`):(e=t.contentType===void 0?My(e,`content-type`):ky(e,`content-type`,t.contentType),t.contentLength===void 0?My(e,`content-length`):ky(e,`content-length`,t.contentLength.toString())),Cx=class extends la(`UrlError`){},wx=(e,t,n)=>Oi({try:()=>{let r=new URL(e,Tx());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,i)}return n!==void 0&&(r.hash=n),r},catch:e=>new Cx({cause:e})}),Tx=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},Ex=`~effect/http/HttpClientRequest`,Dx={[Ex]:Ex,...mt,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Qe(this.headers),body:this.body.toJSON()}},pipe(){return _(this,arguments)}};function Ox(e,t,n,r,i,a){let o=Object.create(Dx);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var kx=Ox(`GET`,``,Wy,er(),Ey,ax),Ax=e=>(t,n)=>Ix(kx,{method:e,url:t,...n??void 0}),jx=Ax(`GET`),Mx=Ax(`POST`),Nx=Ax(`PATCH`),Px=Ax(`PUT`),Fx=Ax(`DELETE`),Ix=b(2,(e,t)=>{let n=e;return t.method&&(n=Lx(n,t.method)),t.url&&(n=Gx(n,t.url)),t.headers&&(n=zx(n,t.headers)),t.urlParams&&(n=Jx(n,t.urlParams)),t.hash&&(n=Yx(n,t.hash)),t.body&&(n=Xx(n,t.body)),t.accept&&(n=Ux(n,t.accept)),t.acceptJson&&(n=Wx(n)),n}),Lx=b(2,(e,t)=>Ox(t,e.url,e.urlParams,e.hash,e.headers,e.body)),Rx=b(3,(e,t,n)=>Ox(e.method,e.url,e.urlParams,e.hash,ky(e.headers,t,n),e.body)),zx=b(2,(e,t)=>Ox(e.method,e.url,e.urlParams,e.hash,Ay(e.headers,t),e.body)),Bx=b(2,(e,t)=>Ox(e.method,e.url,e.urlParams,e.hash,t(e.headers),e.body)),Vx=b(2,(e,t)=>Bx(e,My(t))),Hx=b(2,(e,t)=>Rx(e,`Authorization`,`Bearer ${sy(t)}`)),Ux=b(2,(e,t)=>Rx(e,`Accept`,t)),Wx=Ux(`application/json`),Gx=b(2,(e,t)=>{if(typeof t==`string`)return Ox(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=By(n.searchParams),i=or(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Ox(e.method,n.toString(),r,i,e.headers,e.body)}),Kx=b(2,(e,t)=>t===``?e:Ox(e.method,qx(t,e.url),e.urlParams,e.hash,e.headers,e.body)),qx=(e,t)=>{let n=e.endsWith(`/`),r=t.startsWith(`/`);return n&&r?e+t.slice(1):!n&&!r?e+`/`+t:e+t},Jx=b(2,(e,t)=>Ox(e.method,e.url,Gy(e.urlParams,t),e.hash,e.headers,e.body)),Yx=b(2,(e,t)=>Ox(e.method,e.url,e.urlParams,tr(t),e.headers,e.body)),Xx=b(2,(e,t)=>Ox(e.method,e.url,e.urlParams,e.hash,Sx(e.headers,t),t)),Zx=b(2,(e,t)=>Xx(e,dx(t)));function Qx(e){let t=wx(e.url,e.urlParams,sr(e.hash));return Ai(t)?tr(t.success):er()}var $x=`~effect/http/HttpIncomingMessage`,eS=(e,t)=>{let n=Zy(tx(e)),r=t?.reviver===void 0?void 0:Zy(Gb(tx(e),t));return e=>r===void 0?V(e.json,e=>n(e,t)):V(e.text,i=>i===``?V(e.json,e=>n(e,t)):r(i,t))},tS=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=bf(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=bf(e.text)}catch{}let i={...t,headers:Qe(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},nS=`~effect/http/HttpClientResponse`,rS=(e,t)=>new aS(e,t),Z=b(2,(e,t)=>{let n=e.status;return t[n]?t[n](e):n>=200&&n<300&&t[`2xx`]?t[`2xx`](e):n>=300&&n<400&&t[`3xx`]?t[`3xx`](e):n>=400&&n<500&&t[`4xx`]?t[`4xx`](e):n>=500&&n<600&&t[`5xx`]?t[`5xx`](e):t.orElse(e)}),iS=e=>e.status>=200&&e.status<300?R(e):B(new px({reason:new vx({response:e,request:e.request,description:`non 2xx status code`})})),aS=class extends ht{[$x];[nS];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[$x]=$x,this[nS]=nS}toJSON(){return tS(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split(`#`)[0];let e=Qx(this.request);return nr(e)?``:(e.value.hash=``,e.value.href)}get headers(){return Dy(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=_y(this.source.headers.getSetCookie())}get remoteAddress(){return er()}get stream(){return this.source.body?Yp({evaluate:()=>this.source.body,onError:e=>new px({reason:new yx({request:this.request,response:this,cause:e})})}):qp(new px({reason:new bx({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return V(this.text,e=>Cd({try:()=>e===``?null:JSON.parse(e),catch:e=>new px({reason:new yx({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=kd(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return V(this.text,e=>Cd({try:()=>By(new URLSearchParams(e)),catch:e=>new px({reason:new yx({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=hd({try:()=>this.source.formData(),catch:e=>new px({reason:new yx({request:this.request,response:this,cause:e})})}).pipe(nf,bf)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=hd({try:()=>this.source.arrayBuffer(),catch:e=>new px({reason:new yx({request:this.request,response:this,cause:e})})}).pipe(nf,bf),this.arrayBufferBody}pipe(){return _(this,arguments)}},oS=e=>Oy({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${ir(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),sS=`~effect/http/HttpClient`,cS=dr(`effect/HttpClient`),lS=b(2,(e,t)=>dS(n=>t(e.postprocess(n)),e.preprocess)),uS=lS(V(iS)),dS=(e,t)=>{let n=Object.create(fS);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},fS={[sS]:sS,pipe(){return _(this,arguments)},...mt,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(xx.map(([e,t])=>[t,function(t,n){return this.execute(Ax(e)(t,n))}]))},pS=e=>dS(t=>V(t,t=>wd(n=>{let r=SS.get(t),i=r??new AbortController,a=wx(t.url,t.urlParams,sr(t.hash));if(ki(a))return B(new px({reason:new _x({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(va)||n.getRef(gS)(t)){let a=e(t,o,i.signal,n);return r?a:sf(e=>Ud(e(a),{onSuccess(e){return xS.register(e,i),R(new CS(e,i))},onFailure(e){return Pu(e)&&i.abort(),bd(e)}}))}return uf(n.getRef(yS)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method),a.attribute(`server.address`,o.origin),o.port!==``&&a.attribute(`server.port`,+o.port),a.attribute(`url.full`,o.toString()),a.attribute(`url.path`,o.pathname),a.attribute(`url.scheme`,o.protocol.slice(0,-1));let s=o.search.slice(1);s!==``&&a.attribute(`url.query`,s);let c=n.getRef(Fy),l=n.getRef(_S);for(let e in t.headers)l(e,`request`)&&a.attribute(`http.request.header.${e}`,Py(e,c)?`<redacted>`:t.headers[e]);return t=n.getRef(vS)?zx(t,oS(a)):t,sf(s=>s(e(t,o,i.signal,n)).pipe(df(a,{captureStackTrace:!1}),Ud({onSuccess:e=>{a.attribute(`http.response.status_code`,e.status);for(let t in e.headers)l(t,`response`)&&a.attribute(`http.response.header.${t}`,Py(t,c)?`<redacted>`:e.headers[t]);return r?R(e):(xS.register(e,i),R(new CS(e,i)))},onFailure(e){return!r&&Pu(e)&&i.abort(),bd(e)}})))})})),R),mS=b(2,(e,t)=>dS(e.postprocess,n=>kd(e.preprocess(n),t))),hS=b(2,(e,t)=>dS(e.postprocess,n=>V(e.preprocess(n),t))),gS=Ur(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>C}),_S=Ur(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>S}),vS=Ur(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:S}),yS=Ur(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),bS=e=>bu(cS)(Gd(t=>kd(e,e=>lS(e,qd(e=>Vr(t,e)))))),xS=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),SS=new WeakMap,CS=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[nS]=nS;[$x]=$x;applyInterrupt(e){return gd(()=>(xS.unregister(this.original),af(e,()=>z(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return Kp(()=>(xS.unregister(this.original),Xp(this.original.stream,z(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[dt](){return this.original[dt]()}pipe(){return _(this,arguments)}},wS=J({status:rb(`ok`).annotate({description:"Process health. A successful response currently reports `ok`."}),color:X([`blue`,`green`]).annotate({description:`Deployment color of the process that handled the request.`}),role:X([`active`,`inactive`]).annotate({description:`Whether this deployment color currently serves active traffic.`}),version:K.annotate({description:`Build or release version embedded in the running binary.`,examples:[`1.4.0`]}),activeColor:X([`blue`,`green`]).annotate({description:`Deployment color currently selected as active.`})}).annotate({description:`Local deployment health and blue-green role information.`,examples:[{status:`ok`,color:`blue`,role:`active`,version:`1.4.0`,activeColor:`blue`}],identifier:`Health`}),Q=K.annotate({description:`Time-ordered UUID version 7 generated by Aperture.`,examples:[`019f6cf0-0000-7000-8000-000000000001`],format:`uuid`,identifier:`UUIDv7`}),TS=X([`api_token`,`user`,`system`]).annotate({description:`Stable category of the authenticated or audited actor.`,examples:[`api_token`],identifier:`PrincipalType`}),ES=X([`system_admin`,`tenant`]).annotate({description:"Authorization boundary. `system_admin` principals may administer the deployment and select tenants. `tenant` principals act within one effective tenant.\n",examples:[`tenant`],identifier:`AuthorityType`}),DS=X([`system:admin`,`sessions:read`,`sessions:write`,`snapshots:read`,`snapshots:write`,`tenant:write`,`tenants:write`]).annotate({description:"Permission granted to a principal. `system:admin` implies every scope. Tenant credentials and memberships cannot receive `system:admin` or `tenants:write`.\n",examples:[`sessions:write`],identifier:`Scope`}),OS=X([`all`,`allowlist`]).annotate({description:`Whether a tenant API token can access every tenant resource or only explicit grants.`,default:`all`,examples:[`allowlist`],identifier:`ResourceMode`}),kS=X([`session`,`snapshot`]).annotate({description:`Tenant resource category accepted by API token allowlists.`,examples:[`session`],identifier:`ResourceType`}),AS=J({code:K.annotate({description:`Stable code enumerated by each operation response.`,examples:[`insufficient_scope`]}),message:K.annotate({description:`Human-readable explanation. It may include resource or validation context.`,examples:[`insufficient scope`]})}).annotate({description:`Stable machine-readable error code with a human-readable explanation.`,identifier:`ErrorDetail`}),jS=J({name:K.annotate({description:`Configured browser channel name.`,examples:[`chromium`]})}).annotate({description:`Browser runtime selectable when creating a session.`,identifier:`BrowserChannel`}),MS=J({limit:q.annotate({description:`Effective page size after applying the default and maximum.`,examples:[50]}).check(Fb().annotate({expected:`an integer`})).check(Mb(1).annotate({expected:`a value greater than or equal to 1`})).check(Nb(100).annotate({expected:`a value less than or equal to 100`})),nextCursor:G(K.annotate({description:`Opaque cursor for the next page. Omitted when there is no next page.`,examples:[`eyJjcmVhdGVkQXQiOiIyMDI2LTA3LTE3VDEyOjAwOjAwWiIsImlkIjoiMDE5ZjZjZjAtMDAwMC03MDAwLTgwMDAtMDAwMDAwMDAwMDAwIn0`]})),hasMore:sb.annotate({description:`Whether another page is available.`,examples:[!0]})}).annotate({description:`Cursor pagination metadata for a newest-first result page.`,identifier:`PageMeta`});J({displayName:K.annotate({description:`Human-readable tenant name. Leading and trailing whitespace is removed and whitespace-only values are rejected.`,examples:[`Example engineering`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(wb(RegExp(`.*\\S.*`)).annotate({expected:`a string matching the RegExp .*\\S.*`}))}).annotate({description:`Tenant fields accepted by create and update operations.`,identifier:`TenantInput`}),J({email:G(pb([K,ab]).annotate({description:`Optional normalized login and contact email.`,format:`email`})),displayName:K.check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(wb(RegExp(`.*\\S.*`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),isSystemAdmin:sb.annotate({description:`Grants deployment-wide administration independently of tenant memberships.`})}).annotate({identifier:`UserInput`});var NS=J({token:K.annotate({description:`Raw setup token. Store and transmit it as a secret.`}),expiresAt:K.annotate({format:`date-time`})}).annotate({description:`One-time account setup secret returned only when created.`,identifier:`UserInvitation`}),PS=X([`sessions:read`,`sessions:write`,`snapshots:read`,`snapshots:write`,`tenant:write`]).annotate({description:`Scope allowed on a tenant-bound API token.`,examples:[`sessions:write`],identifier:`TenantScope`}),FS=X([`creating`,`running`,`suspended`,`deleted`,`expired`,`failed`]).annotate({description:"Session lifecycle state:\n\n- `creating`: browser startup is in progress; the CDP endpoint does not answer yet.\n- `running`: browser and routing are available and the CDP endpoint answers.\n- `suspended`: browser is intentionally stopped while retained state remains available.\n- `deleted`: session is soft-deleted and may be reopened while retained.\n- `expired`: retention elapsed and the session can no longer be used.\n- `failed`: startup or reopen failed; retained state may still be reopenable.\n",examples:[`running`],identifier:`SessionStatus`}),IS=J({urls:Y(K).annotate({description:`STUN or TURN server URLs.`,examples:[[`turn:turn.example.com:3478?transport=udp`]]}),username:G(K.annotate({description:`TURN username. Omitted when the server does not require authentication.`,examples:[`aperture-session`]})),credential:G(K.annotate({description:`TURN credential. Treat it as a secret and do not persist it in logs.`,examples:[`REDACTED`]}))}).annotate({description:`ICE server configuration supplied to WebRTC consumers.`,identifier:`IceServer`}),LS=lb(K,K).annotate({description:`Arbitrary string key-value metadata. Tag-writing operations additionally reject blank keys and blank values.`,examples:[{environment:`production`,region:`eu-west-1`}],identifier:`StringMap`}),RS=J({editorToken:K.annotate({examples:[`ape_019f6cf0000070008000000000000010_REDACTED`]}),viewerToken:K.annotate({examples:[`apv_019f6cf0000070008000000000000010_REDACTED`]})}).annotate({description:`Owner-visible role-scoped secrets used to build collaboration links.`,identifier:`SessionCollaborationCapabilities`}),zS=J({upstream:X([`direct`,`proxy`,`tunnel`]).annotate({description:`Upstream strategy for new connections.`,examples:[`tunnel`]}),url:G(K.annotate({description:"Generic upstream proxy URL. Omitted unless `upstream` is `proxy`. The password is masked, so this value cannot be replayed as a write.",examples:[`socks5://user:pass@proxy.example.com:1080`]})),tunnel:G(J({url:G(K.annotate({description:`Compound tunnel URL.`,examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]}))}).annotate({description:"Tunnel endpoint. Omitted unless `upstream` is `tunnel`. The secret is never returned."})),bypass:G(K.annotate({description:"Extra `--proxy-bypass-list` entries.",examples:[`*.internal.example.com`]}))}).annotate({description:`Stored session egress proxy assignment. Secrets are write-only — tunnel auth never appears here, and an upstream proxy URL comes back with its password masked.`,identifier:`SessionProxy`}),BS=J({channel:K.annotate({description:"Channel returned by `GET /api/browser/channels`.",examples:[`chromium`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(wb(RegExp(`.*\\S.*`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),args:G(Y(K).annotate({description:`Additional Chromium command-line arguments. Aperture rejects arguments that conflict with supervisor-owned behavior or deployment policy.`,examples:[[`--lang=en-US`]]}))}).annotate({description:`Browser runtime configuration used to create or reopen the session.`,identifier:`BrowserConfig`}),VS=J({name:K,value:K.annotate({description:`Browser storage value. Never log this field.`})}).annotate({identifier:`BrowserStorageEntry`}),HS=J({x:q.check(Tb().annotate({expected:`a finite number`})),y:q.check(Tb().annotate({expected:`a finite number`}))}).annotate({identifier:`InitialBrowserScrollPosition`}),US=J({tag:K.check(wb(RegExp(`^[a-z][a-z0-9-]*$`)).annotate({expected:`a string matching the RegExp ^[a-z][a-z0-9-]*$`})),index:q.check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))}).annotate({identifier:`InitialBrowserElementPathStep`}),WS=J({start:q.check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`})),end:q.check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`})),direction:X([`forward`,`backward`,`none`])}).annotate({identifier:`InitialBrowserControlSelection`}),GS=X([`Strict`,`Lax`,`None`]).annotate({identifier:`BrowserCookieSameSite`}),KS=J({topLevelSite:K.annotate({format:`uri`}).check(wb(RegExp(`^https?:\\/\\/[^/]+$`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),hasCrossSiteAncestor:G(sb)}).annotate({identifier:`InitialBrowserCookiePartitionKey`}),qS=J({kind:X([`none`,`string`,`array`]),value:G(Y(K))}).annotate({description:`Object-store key path. String paths contain one value; array paths contain at least one.`,identifier:`InitialIndexedDBKeyPath`}),JS=J({kind:X([`string`,`array`]),value:Y(K).check(Ib(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Index key path. String paths contain one value; array paths contain at least one.`,identifier:`InitialIndexedDBIndexKeyPath`}),YS=J({key:K.annotate({description:`JSON-encoded structured-clone key.`}),value:K.annotate({description:`JSON-encoded structured-clone value.`})}).annotate({identifier:`InitialIndexedDBRecord`}),XS=J({path:K.check(Ib(1).annotate({expected:`a value with a length of at least 1`})),body:K.annotate({contentEncoding:`base64`})}).annotate({identifier:`InitialOPFSFile`}),ZS=J({url:G(K.annotate({description:"Compound tunnel URL (`ws+yamux+socks5://` or `wss+yamux+socks5://`).",examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]})),auth:G(K.annotate({description:`Per-assignment bearer secret for the tunnel handshake. Write-only; never returned.`,examples:[`REDACTED`]}))}).annotate({description:"Tunnel endpoint for the `tunnel` upstream. Minted by the tunnel operator.",identifier:`ProxyTunnelConfig`}),QS=J({visible:sb.annotate({description:`Whether to include the remote cursor in live streams and recordings.`})}).annotate({description:`Whether the remote browser cursor is composited into session media.`,identifier:`CursorVisibility`}),$S=J({recordingId:K.annotate({description:`Stable recording identifier retained across target changes.`,format:`uuid`}),mode:X([`tab`,`viewer`]).annotate({description:`Tab recordings stay on their specified top-level target; viewer recordings follow a live session client's selected top-level target and cannot be explicitly retargeted.`}),targetId:K.annotate({description:`Identifier of the top-level target currently recorded.`}),captureGeneration:q.annotate({description:`Assignment generation for the current top-level target.`,format:`int64`}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`})),status:X([`starting`,`running`,`stopped`,`failed`]),stopReason:G(K.annotate({description:`Lifecycle reason recorded after the recording stops or fails.`})),relativePath:K.annotate({description:`Path below the session root; absolute host paths are never exposed.`,examples:[`recordings/recording-550e8400-e29b-41d4-a716-446655440000.webm`]}),startedAt:K.annotate({format:`date-time`}),stoppedAt:G(K.annotate({format:`date-time`})),sizeBytes:G(q.annotate({format:`int64`}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),fps:q.check(Fb().annotate({expected:`an integer`})).check(Mb(1).annotate({expected:`a value greater than or equal to 1`})),bitrateKbps:q.check(Fb().annotate({expected:`an integer`})).check(Mb(1).annotate({expected:`a value greater than or equal to 1`})),codec:X([`vp8`,`h264-va`])}).annotate({description:`One logical recording of a top-level target.`,identifier:`Recording`});J({targetId:K.annotate({description:`Identifier of the ready top-level target to record.`}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})),fps:G(q.annotate({description:`Requested frames per second. Omit or use a non-positive value for the instance default.`,examples:[60]}).check(Fb().annotate({expected:`an integer`}))),bitrateKbps:G(q.annotate({description:`Requested video bitrate in kilobits per second. Omit or use a non-positive value for the instance default.`,examples:[6e3]}).check(Fb().annotate({expected:`an integer`}))),codec:G(X([`vp8`,`h264-va`]).annotate({description:`Video codec. Omit for the instance default.`,examples:[`vp8`]}))}).annotate({description:`Top-level target and optional recording settings.`,identifier:`CreateSessionRecordingInput`}),J({targetId:K.annotate({description:`Identifier of the ready destination top-level target.`}).check(Ib(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Destination for a running tab recording.`,identifier:`RetargetSessionRecordingInput`});var eC=J({name:K.annotate({description:`File name without directory components.`,examples:[`screencast-20260801T120000Z.webm`]}),relativePath:K.annotate({description:"Path below the session root. The first component is `downloads` or `recordings`.",examples:[`recordings/screencast-20260801T120000Z.webm`]}),size:q.annotate({description:`File size in bytes.`,examples:[1048576],format:`int64`}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`})),modifiedAt:K.annotate({description:`Last file modification time.`,examples:[`2026-08-01T12:05:00Z`],format:`date-time`}),mimeType:K.annotate({description:`Detected media type.`,examples:[`video/webm`]})}).annotate({description:`Regular file retained with a browser session.`,identifier:`SessionFile`});J({relativePath:K.annotate({description:"Path from a `SessionFile` result.",examples:[`recordings/screencast-20260801T120000Z.webm`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})),ttlSeconds:G(q.annotate({description:"Requested lifetime in seconds. Omit it to use `signed_file_url_ttl`; values above `signed_file_url_max_ttl` are rejected.",examples:[900]}).check(Fb().annotate({expected:`an integer`})).check(Mb(1).annotate({expected:`a value greater than or equal to 1`})))}).annotate({description:`Session file path and requested signed URL lifetime.`,identifier:`SessionFileDownloadURLInput`});var tC=J({url:K.annotate({description:"URL containing a path-bound `apf_` token.",examples:[`https://aperture.example.com/sessions/019f6cf0-0000-7000-8000-000000000010/files/recordings/screencast-20260801T120000Z.webm?token=apf_REDACTED`],format:`uri`}),expiresAt:K.annotate({description:`Time after which the URL is rejected.`,examples:[`2026-08-01T12:20:00Z`],format:`date-time`})}).annotate({description:`Signed attachment URL for one session file.`,identifier:`SessionFileDownloadURL`});J({description:G(pb([K,ab]).annotate({description:"New description. Send `null` to clear it; an empty string is stored as an empty description.",examples:[`Updated signed-in state`]}))}).annotate({description:`Replacement snapshot description.`,identifier:`UpdateSnapshotInput`});var nC=J({id:gb(()=>Q).annotate({description:`Tenant identifier.`}),displayName:K.annotate({description:`Human-readable tenant name.`,examples:[`Example engineering`]}),createdAt:K.annotate({description:`Time the tenant was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),deletedAt:G(pb([K,ab]).annotate({description:"Soft-deactivation time, or `null` for an active tenant.",examples:[null],format:`date-time`}))}).annotate({description:`Tenant account. Deletion is a reversible soft deactivation.`,identifier:`Tenant`}),rC=J({id:Q,email:G(pb([K,ab]).annotate({format:`email`})),displayName:K,isSystemAdmin:sb,createdAt:K.annotate({format:`date-time`}),updatedAt:K.annotate({format:`date-time`}),disabledAt:G(pb([K,ab]).annotate({format:`date-time`})),passwordSetupStatus:G(X([`available`,`configured`,`email_required`,`user_disabled`,`login_disabled`]).annotate({description:`Password setup state included by the get-user operation.`}))}).annotate({identifier:`User`});J({ids:Y(Q).annotate({description:`Up to 100 unique UUIDv7 values. An empty array is valid.`,examples:[[`019f6cf0-0000-7000-8000-000000000010`,`019f6cf0-0000-7000-8000-000000000011`]]}).check(Lb(100).annotate({expected:`a value with a length of at most 100`})).check(zb().annotate({expected:`an array with unique items`}))}).annotate({description:`Ordered session IDs for a tenant-scoped bulk lookup. Missing, foreign, and deleted IDs are omitted from the result.`,identifier:`SessionBulkInput`});var iC=J({id:gb(()=>Q).annotate({description:`Event identifier.`}),tenantId:gb(()=>Q).annotate({description:`Tenant that owns the event.`}),resourceType:K.annotate({description:`Resource category associated with the event. Currently session events are the primary source; new categories may be added.`,examples:[`session`]}),resourceId:K.annotate({description:"Identifier of the associated resource. Its format depends on `resourceType`.",examples:[`019f6cf0-0000-7000-8000-000000000010`]}),type:K.annotate({description:`Extensible event type used for programmatic handling.`,examples:[`session.token_rotated`]}),message:K.annotate({description:`Human-readable event summary.`,examples:[`session token rotated`]}),data:lb(K,nx.annotate({expected:`JSON value`})).annotate({description:`Event-specific JSON payload, such as error details or upload metadata.`,examples:[{reason:`manual rotation`}]}),createdAt:K.annotate({description:`Time the event was recorded.`,examples:[`2026-07-17T12:30:00Z`],format:`date-time`})}).annotate({description:`Immutable tenant-scoped audit or lifecycle event.`,identifier:`Event`}),aC=J({id:Q,actorType:TS,actorId:G(pb([K,ab])),tenantId:G(pb([Q,ab],{mode:`oneOf`})),action:K.annotate({examples:[`tenant_membership.upserted`]}),resourceType:K.annotate({examples:[`tenant_membership`]}),resourceId:G(pb([K,ab])),data:lb(K,nx.annotate({expected:`JSON value`})),createdAt:K.annotate({format:`date-time`})}).annotate({identifier:`AuditEvent`}),oC=J({resourceType:kS,resourceId:Q}).annotate({description:`Access to one existing tenant session or snapshot by its stable UUIDv7 identifier.`,identifier:`ResourceGrant`}),sC=J({error:AS}).annotate({description:`Standard error envelope returned by REST API operations.`,identifier:`Error`}),cC=J({channels:Y(jS)}).annotate({description:`Browser channels enabled on this deployment.`,examples:[{channels:[{name:`chromium`}]}],identifier:`BrowserChannels`}),lC=J({tenantId:Q,userId:Q,scopes:Y(PS).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(zb().annotate({expected:`an array with unique items`})),createdAt:K.annotate({format:`date-time`}),updatedAt:K.annotate({format:`date-time`})}).annotate({identifier:`TenantMembership`});J({scopes:Y(PS).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(zb().annotate({expected:`an array with unique items`}))}).annotate({identifier:`TenantMembershipInput`});var uC=J({mode:X([`auto`,`cdp`]).annotate({description:"Configured media mode. `auto` enables deployment-selected media support; `cdp` exposes Chrome DevTools access only.",examples:[`auto`]}),webrtcProducer:sb.annotate({description:`Whether the compositor WebRTC producer is available for this session.`,examples:[!0]}),iceServers:G(Y(IS).annotate({description:`ICE configuration for WebRTC setup. Omitted when WebRTC is unavailable or does not need configured ICE servers.`}))}).annotate({description:`Media capabilities currently available for the session.`,identifier:`SessionMedia`}),dC=J({url:K.annotate({format:`uri`}),requestHeaders:LS,responseHeaders:LS,responseStatus:q.check(Fb().annotate({expected:`an integer`})).check(Mb(100).annotate({expected:`a value greater than or equal to 100`})).check(Nb(599).annotate({expected:`a value less than or equal to 599`})),responseStatusText:K,responseBody:K.annotate({contentEncoding:`base64`})}).annotate({identifier:`InitialCacheStorageEntry`});J({tags:gb(()=>LS).annotate({description:`Complete tag map. Keys and values must contain non-whitespace characters.`})}).annotate({description:`Complete replacement tag set. The map may be empty to clear all tags.`,examples:[{tags:{environment:`production`,region:`eu-west-1`}}],identifier:`ReplaceTagsInput`}),J({name:K.annotate({description:`Tenant-unique snapshot name. Leading and trailing whitespace is removed.`,examples:[`signed-in-base`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(wb(RegExp(`.*\\S.*`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),description:G(pb([K,ab]).annotate({description:"Optional snapshot description. `null` creates the snapshot without a description.",examples:[`Signed-in storefront state for checkout tests`]})),force:G(sb.annotate({description:"Deleted snapshot names are reused automatically. Set `true` to replace an active snapshot, which is renamed to its tombstone name and retained for the configured snapshot retention period.",default:!1})),tags:G(gb(()=>LS).annotate({description:`Initial complete tag map for the new snapshot.`}))}).annotate({description:`Snapshot metadata created from a stopped, retained session.`,examples:[{name:`signed-in-base`,description:`Signed-in storefront state for checkout tests`,force:!1,tags:{application:`storefront`,environment:`staging`}}],identifier:`PromoteSessionInput`});var fC=J({id:gb(()=>Q).annotate({description:`Snapshot identifier.`}),name:K.annotate({description:`Human-selected tenant-unique snapshot name.`,examples:[`signed-in-base`]}),tenantId:gb(()=>Q).annotate({description:`Tenant that owns the snapshot.`}),description:G(pb([K,ab]).annotate({description:"Operator-provided description, or `null` when none is set.",examples:[`Signed-in storefront state for checkout tests`]})),parentSnapshotId:G(gb(()=>Q).annotate({description:`Base snapshot from which the source session was created. Omitted for snapshots without a parent.`})),promotedFromSessionId:G(gb(()=>Q).annotate({description:`Session whose retained overlay produced this snapshot. Omitted when lineage is unavailable.`})),createdAt:K.annotate({description:`Time the snapshot was created.`,examples:[`2026-07-17T12:45:00Z`],format:`date-time`}),deletedAt:G(pb([K,ab]).annotate({description:"Soft-deletion time, or `null` for an active snapshot.",examples:[null],format:`date-time`})),expiresAt:G(K.annotate({description:`Purge eligibility time for a deleted snapshot. Omitted for active snapshots.`,examples:[`2026-08-16T12:45:00Z`],format:`date-time`})),tags:G(gb(()=>LS).annotate({description:`Snapshot metadata tags. Omitted when no tags are set.`}))}).annotate({description:`Reusable retained browser filesystem state. Deletion is soft until the retention deadline.`,identifier:`Snapshot`}),pC=J({origin:K.annotate({format:`uri`}).check(wb(RegExp(`^https?:\\/\\/[^/]+$`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),entries:Y(VS)}).annotate({identifier:`InitialTargetStorageOrigin`}),mC=J({tag:K.check(wb(RegExp(`^[a-z][a-z0-9-]*$`)).annotate({expected:`a string matching the RegExp ^[a-z][a-z0-9-]*$`})),id:G(K),name:G(K),inputType:G(K),autocomplete:G(K),ariaLabel:G(K),placeholder:G(K),path:Y(US).check(Lb(256).annotate({expected:`a value with a length of at most 256`}))}).annotate({description:`Semantic element identity with a structural fallback. It is not a CSS selector.`,identifier:`InitialBrowserElementLocator`}),hC=J({name:K.check(Ib(1).annotate({expected:`a value with a length of at least 1`})),value:K.annotate({description:`Cookie value. Never log this field.`}),domain:K.annotate({examples:[`.example.com`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})),hostOnly:G(sb.annotate({description:"Scope the cookie to exactly `domain`, without subdomains. `domain` must then be a plain hostname.",default:!1})),path:K.annotate({examples:[`/`]}).check(wb(RegExp(`^\\/`)).annotate({expected:`a string matching the RegExp ^\\/`})),expires:G(q.annotate({description:`Unix timestamp in seconds. Omit for a session cookie.`}).check(Tb().annotate({expected:`a finite number`})).check(jb(0).annotate({expected:`a value greater than 0`}))),httpOnly:G(sb.annotate({default:!1})),secure:G(sb.annotate({default:!1})),sameSite:G(GS),partitionKey:G(KS)}).annotate({description:`Cookie imported into the new browser profile.`,identifier:`InitialBrowserCookie`}),gC=J({name:K,keyPath:JS,unique:sb,multiEntry:sb}).annotate({identifier:`InitialIndexedDBIndex`}),_C=J({upstream:G(X([`direct`,`proxy`,`tunnel`]).annotate({description:"Upstream strategy for new connections. Defaults to `direct`.",examples:[`tunnel`]})),url:G(K.annotate({description:"Generic upstream proxy URL (`http`, `https`, `socks`, `socks5`, `socks5h`). Required when `upstream` is `proxy`. Credentials go in the userinfo (`socks5://user:pass@host:1080`) and are sent as Basic `Proxy-Authorization` for `http`/`https` or RFC 1929 username/password for the socks schemes. An omitted port defaults to 1080 (socks), 80 (http) or 443 (https).",examples:[`socks5://user:pass@proxy.example.com:1080`]})),tunnel:G(ZS),bypass:G(K.annotate({description:"Extra `--proxy-bypass-list` entries. Loopback is always bypassed.",examples:[`*.internal.example.com`]}))}).annotate({description:`Session egress proxy assignment. Omitted for direct egress.`,identifier:`ProxyConfig`});J({upstream:G(X([`direct`,`proxy`,`tunnel`]).annotate({description:"Upstream strategy for new connections. Defaults to `direct`.",examples:[`tunnel`]})),url:G(K.annotate({description:"Generic upstream proxy URL (`http`, `https`, `socks`, `socks5`, `socks5h`). Required when `upstream` is `proxy`. Credentials go in the userinfo (`socks5://user:pass@host:1080`) and are sent as Basic `Proxy-Authorization` for `http`/`https` or RFC 1929 username/password for the socks schemes. An omitted port defaults to 1080 (socks), 80 (http) or 443 (https).",examples:[`socks5://user:pass@proxy.example.com:1080`]})),tunnel:G(ZS),bypass:G(K.annotate({description:"Extra `--proxy-bypass-list` entries. Loopback is always bypassed.",examples:[`*.internal.example.com`]})),drain:G(sb.annotate({description:`Reset live tunnel streams instead of letting them drain. New connections use the new assignment either way.`,examples:[!1]}))}).annotate({description:`Replacement session egress proxy assignment.`,identifier:`UpdateProxyAssignment`});var vC=J({data:Y(nC),meta:MS}).annotate({description:`Cursor-paginated tenants.`,identifier:`TenantPage`}),yC=J({data:Y(rC),meta:MS}).annotate({identifier:`UserPage`}),bC=J({data:Y(iC),meta:MS}).annotate({description:`Cursor-paginated tenant events.`,identifier:`EventPage`}),xC=J({data:Y(aC),meta:MS}).annotate({identifier:`AuditEventPage`}),SC=J({type:TS,id:K.annotate({description:`Stable identifier of the authenticated subject.`}),authMethod:X([`api_token`,`oidc`,`passkey`,`password`]).annotate({description:`Authentication mechanism used for this request.`}),tokenId:pb([Q,ab],{mode:`oneOf`}).annotate({description:"Identifier of the API token used for authentication, or `null` for account-backed sessions."}),userId:G(pb([Q,ab],{mode:`oneOf`}).annotate({description:"User identifier for account-backed authentication, or `null` for API tokens."})),name:K.annotate({description:`Display name of the authenticated credential or user.`,examples:[`deployment automation`]}),authorityType:ES,tenantId:G(pb([Q,ab],{mode:`oneOf`}).annotate({description:"Effective tenant for tenant authority, or `null` when no tenant is selected."})),scopes:Y(DS).annotate({description:`Scopes granted to the authenticated principal.`}).check(zb().annotate({expected:`an array with unique items`})),resourceMode:OS,resourceGrants:Y(oC).annotate({description:"Explicit grants when `resourceMode` is `allowlist`; empty when it is `all`."}).check(zb().annotate({expected:`an array with unique items`}))}).annotate({description:`Authenticated subject identity and authorization context.`,identifier:`Principal`}),CC=J({id:gb(()=>Q).annotate({description:`Token identifier. This is not the bearer secret.`}),authorityType:ES,tenantId:G(pb([Q,ab],{mode:`oneOf`}).annotate({description:"Bound tenant for a tenant token, or `null` for a system administrator token."})),name:K.annotate({description:`Operator-assigned token name, unique within its authority and tenant context.`,examples:[`ci automation`]}),scopes:Y(DS).annotate({description:`Unique scopes granted to the token.`}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(zb().annotate({expected:`an array with unique items`})),createdAt:K.annotate({description:`Time the token was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),createdByType:gb(()=>TS).annotate({description:`Principal category that created the token.`}),createdById:pb([Q,ab],{mode:`oneOf`}).annotate({description:"User or API token identifier that created the token, or `null` for trusted local system actions."}),parentTokenId:pb([Q,ab],{mode:`oneOf`}).annotate({description:"API token used to delegate this token, or `null` when a user or trusted local system created it."}),resourceMode:OS,resourceGrants:Y(oC).annotate({description:"Explicit session and snapshot grants when `resourceMode` is `allowlist`."}).check(zb().annotate({expected:`an array with unique items`})),expiresAt:G(pb([K,ab]).annotate({description:"Authentication expiry time, or `null` when the token does not expire automatically.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),revokedAt:G(pb([K,ab]).annotate({description:"Revocation time, or `null` while the token is active.",examples:[null],format:`date-time`}))}).annotate({description:`API token metadata. The raw bearer secret is never included in this schema.`,identifier:`Token`});pb([J({name:K.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`platform admin`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(wb(RegExp(`.*\\S.*`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),authorityType:rb(`system_admin`),scopes:Y(DS).annotate({description:"Must include `system:admin`.",examples:[[`system:admin`]]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(zb().annotate({expected:`an array with unique items`})),expiresAt:G(pb([K,ab]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:G(rb(`all`).annotate({description:`System administrator tokens cannot use resource allowlists.`,default:`all`})),resourceGrants:G(Y(oC).annotate({description:`Must be empty for a system administrator token.`}).check(Lb(0).annotate({expected:`a value with a length of at most 0`})))}),J({name:K.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`tenant automation`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(wb(RegExp(`.*\\S.*`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),authorityType:rb(`tenant`),tenantId:gb(()=>Q).annotate({description:`Active tenant to bind permanently to the token.`}),scopes:Y(PS).annotate({description:"Tenant-compatible scopes. `system:admin` and `tenants:write` are rejected.",examples:[[`sessions:read`,`sessions:write`]]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(zb().annotate({expected:`an array with unique items`})),expiresAt:G(pb([K,ab]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:G(OS),resourceGrants:G(Y(oC).annotate({description:"Existing tenant resources granted when `resourceMode` is `allowlist`; must be empty for `all`."}).check(zb().annotate({expected:`an array with unique items`})))})],{mode:`oneOf`}).annotate({description:`Token definition accepted by the system administrator token endpoint.`,identifier:`CreateAdminTokenInput`}),J({name:K.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`browser worker`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(wb(RegExp(`.*\\S.*`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),scopes:Y(PS).annotate({description:"Tenant-compatible scopes. `system:admin` and `tenants:write` are rejected.",examples:[[`sessions:read`,`sessions:write`]]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(zb().annotate({expected:`an array with unique items`})),expiresAt:G(pb([K,ab]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:G(OS),resourceGrants:G(Y(oC).annotate({description:"Existing tenant resources granted when `resourceMode` is `allowlist`; must be empty for `all`."}).check(zb().annotate({expected:`an array with unique items`})))}).annotate({description:`Token definition automatically bound to the authenticated tenant.`,identifier:`CreateTenantTokenInput`});var wC=J({id:gb(()=>Q).annotate({description:`Session identifier.`}),tenantId:gb(()=>Q).annotate({description:`Tenant that owns the session.`}),baseSnapshotName:G(K.annotate({description:`Snapshot name used as the session base. Omitted for a blank session.`,examples:[`signed-in-base`]})),label:G(K.annotate({description:`Optional operator-facing session label.`,examples:[`checkout smoke test`]})),status:FS,browserChannel:G(K.annotate({description:`Browser channel used to create and reopen the session.`,examples:[`chromium`]})),media:uC,createdAt:K.annotate({description:`Time the session record was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),startedAt:G(K.annotate({description:`Most recent successful browser start time. Omitted before startup succeeds.`,examples:[`2026-07-17T12:00:03Z`],format:`date-time`})),stoppedAt:G(K.annotate({description:`Most recent browser stop time. Omitted while no stop has occurred.`,examples:[`2026-07-17T13:00:00Z`],format:`date-time`})),deletedAt:G(pb([K,ab]).annotate({description:"Soft-deletion time, or `null` for a session that has not been deleted.",examples:[null],format:`date-time`})),expiresAt:K.annotate({description:`Retention deadline after which the session and its overlay may be purged. This is not token expiry.`,examples:[`2026-07-24T12:00:00Z`],format:`date-time`}),lastConnectedAt:G(K.annotate({description:`Most recent routed client activity time. Omitted until a client connects.`,examples:[`2026-07-17T12:30:00Z`],format:`date-time`})),suspendedAt:G(K.annotate({description:`Most recent suspension time. Omitted unless the session is suspended.`,examples:[`2026-07-17T13:00:00Z`],format:`date-time`})),tags:G(gb(()=>LS).annotate({description:`Session metadata tags. Omitted when no tags are set.`})),cdpUrl:G(K.annotate({description:"Authenticated Chrome DevTools endpoint. Omitted when the session is not currently routable. Use it with `sessionToken`.",examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`})),sessionToken:G(K.annotate({description:`Session access secret returned when live access credentials are available. Rotation invalidates the previous token immediately.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]})),collaboration:G(RS),proxy:G(zS)}).annotate({description:`Browser session state, retention metadata, tags, and currently available access credentials.`,identifier:`Session`}),TC=J({name:K,entries:Y(dC)}).annotate({identifier:`InitialCacheStorageCache`}),EC=J({snapshot:fC}).annotate({description:`Snapshot returned after a mutation.`,identifier:`SnapshotMutation`}),DC=J({data:Y(fC),meta:MS}).annotate({description:`Cursor-paginated snapshots.`,identifier:`SnapshotPage`}),OC=J({locator:mC,value:K,checked:G(sb),selectedIndices:G(Y(q.check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`})))),selection:G(WS)}).annotate({identifier:`InitialBrowserControlState`}),kC=J({locator:mC,html:K}).annotate({identifier:`InitialBrowserContentEditableState`}),AC=J({locator:mC,x:q.check(Tb().annotate({expected:`a finite number`})),y:q.check(Tb().annotate({expected:`a finite number`}))}).annotate({identifier:`InitialBrowserElementScrollPosition`}),jC=J({locator:mC,nodePath:Y(q.check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))).check(Lb(256).annotate({expected:`a value with a length of at most 256`})),offset:q.check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))}).annotate({identifier:`InitialBrowserSelectionEndpoint`}),MC=J({name:K,keyPath:qS,autoIncrement:sb,indexes:Y(gC),records:Y(YS)}).annotate({identifier:`InitialIndexedDBObjectStore`}),NC=J({principal:SC,selectedTenant:pb([nC,ab],{mode:`oneOf`}).annotate({description:"Effective tenant, or `null` when the principal has not selected one."}),availableTenants:Y(nC).annotate({description:`Active tenant memberships available to an account-backed principal. API-token principals return an empty array.`})}).annotate({description:`Current principal and its effective tenant selection.`,identifier:`AuthMe`}),PC=J({data:Y(CC),meta:MS}).annotate({description:`Cursor-paginated API token metadata without bearer secrets.`,identifier:`TokenPage`}),FC=J({token:CC,rawToken:K.annotate({description:`One-time Aperture API bearer token. Store it immediately; later reads return only token metadata.`,examples:[`apt_019f6cf0000070008000000000000002_REDACTED`]})}).annotate({description:`Created token metadata and its one-time bearer secret.`,identifier:`CreateTokenResponse`}),IC=J({data:Y(wC),meta:MS}).annotate({description:`Cursor-paginated browser sessions.`,identifier:`SessionPage`}),LC=J({session:wC,cdpUrl:K.annotate({description:`Authenticated Chrome DevTools endpoint for the new session.`,examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`}),sessionToken:K.annotate({description:`Initial session access secret. Store it immediately.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]})}).annotate({description:`Newly created session and its one-time initial access credentials.`,identifier:`CreateSessionResult`}),RC=J({sessions:Y(wC)}).annotate({description:`Sessions found for the requested IDs, preserving request order.`,identifier:`SessionBulkResponse`}),zC=J({session:wC,cdpUrl:G(K.annotate({description:`Current Chrome DevTools endpoint. Omitted by operations that do not expose live access.`,examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`})),sessionToken:G(K.annotate({description:`Current raw session access secret. Omitted by operations that do not expose or replace credentials.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]}))}).annotate({description:`Updated session and operation-specific live access credentials when available.`,identifier:`SessionMutation`}),BC=J({anchor:jC,focus:jC}).annotate({identifier:`InitialBrowserDocumentSelection`}),VC=J({name:K,version:q.check(Fb().annotate({expected:`an integer`})).check(Mb(1).annotate({expected:`a value greater than or equal to 1`})),objectStores:Y(MC)}).annotate({identifier:`InitialIndexedDBDatabase`}),HC=J({version:rb(1),windowName:G(K),historyState:G(K.annotate({description:`JSON-encoded structured-clone history state.`})),controls:Y(OC).check(Lb(1e4).annotate({expected:`a value with a length of at most 10000`})),contentEditables:Y(kC).check(Lb(1e4).annotate({expected:`a value with a length of at most 10000`})),scrollPositions:Y(AC).check(Lb(1e4).annotate({expected:`a value with a length of at most 10000`})),focus:G(mC),selection:G(BC)}).annotate({description:`Sensitive top-document state replayed during initial navigation.`,identifier:`InitialBrowserDocumentState`}),UC=J({origin:K.annotate({examples:[`https://example.com`],format:`uri`}).check(wb(RegExp(`^https?:\\/\\/[^/]+$`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),ancestorOrigins:G(Y(K.annotate({format:`uri`}).check(wb(RegExp(`^https?:\\/\\/[^/]+$`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`}))).annotate({description:`Top-down HTTP origin chain for partitioned storage. Omitted for a top-level origin.`}).check(Lb(32).annotate({expected:`a value with a length of at most 32`}))),localStorage:Y(VS),indexedDB:G(Y(VC)),cacheStorage:G(Y(TC)),opfs:G(Y(XS))}).annotate({description:`Profile-scoped browser storage imported for one exact HTTP origin and ancestor partition.`,identifier:`InitialStorageOrigin`}),WC=J({url:K.annotate({description:`Absolute HTTP or HTTPS URL without embedded credentials.`,examples:[`https://example.com/account`],format:`uri`}).check(wb(RegExp(`^https?:\\/\\/`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/`})),sessionStorage:G(Y(pC).annotate({description:`Per-origin session storage installed in target frames before page scripts execute.`})),scroll:G(HS),documentState:G(HC),openerTargetIndex:G(q.annotate({description:`Index of another initial target that opened this target.`}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),active:G(sb.annotate({description:`Select this target for the first connected session client. At most one target may be active.`,default:!1}))}).annotate({description:`HTTP page and target-scoped state opened during session creation.`,identifier:`InitialBrowserTarget`}),GC=J({cookies:Y(hC).check(Lb(1e4).annotate({expected:`a value with a length of at most 10000`})),origins:Y(UC).check(Lb(100).annotate({expected:`a value with a length of at most 100`}))}).annotate({description:`Profile-scoped browser storage imported before initial browser targets are opened.`,identifier:`InitialBrowserStorageState`});J({baseSnapshotName:G(pb([K,ab]).annotate({description:"Active snapshot used as the browser filesystem base. Omit, send `null`, or send an empty value for a blank session.",examples:[`signed-in-base`]})),label:G(pb([K,ab]).annotate({description:`Optional operator-facing label for the session.`,examples:[`checkout smoke test`]})),browser:BS,initialTargets:G(Y(WC).annotate({description:`Browser targets that replace the browser's startup page after storage import. Result order follows input order; opener dependencies may be created first.`}).check(Lb(50).annotate({expected:`a value with a length of at most 50`}))),storageState:G(GC),tags:G(gb(()=>LS).annotate({description:`Initial session tags.`})),proxy:G(_C)}).annotate({description:`Configuration for a new retained browser session.`,examples:[{baseSnapshotName:`signed-in-base`,label:`checkout smoke test`,browser:{channel:`chromium`,args:[`--lang=en-US`]},initialTargets:[{url:`https://example.com/account`}],storageState:{cookies:[],origins:[{origin:`https://example.com`,localStorage:[{name:`access-token`,value:`REDACTED`}]}]},tags:{environment:`staging`,suite:`checkout`}}],identifier:`CreateSessionInput`});var KC=wS;J({"X-Aperture-Tenant-Id":G(Q)});var qC=NC,JC=cC;J({limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),deleted:G(X([`active`,`deleted`,`all`]).annotate({default:`active`})),includeDeleted:G(sb.annotate({default:!1}))});var YC=vC,XC=nC,ZC=nC,QC=nC,$C=nC;J({limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),query:G(K),disabled:G(X([`active`,`disabled`,`all`]).annotate({default:`active`}))});var ew=yC,tw=rC,nw=rC,rw=rC,iw=rC,aw=rC,ow=NS,sw=Y(lC),cw=Y(lC),lw=lC,uw=sC;J({limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),tenantId:G(Q),actorType:G(TS),actorId:G(K),action:G(K),resourceType:G(K),resourceId:G(K)});var dw=xC;J({limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),authorityType:G(ES),tenantId:G(Q),name:G(K),scope:G(DS),revoked:G(X([`active`,`revoked`,`all`]).annotate({default:`all`}))});var fw=PC,pw=FC,mw=sC,hw=nC,gw=nC;J({limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),name:G(K),scope:G(DS),revoked:G(X([`active`,`revoked`,`all`]).annotate({default:`all`}))});var _w=PC,vw=FC,yw=sC;J({"X-Aperture-Tenant-Id":G(Q),limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),includeDeleted:G(sb.annotate({default:!1})),status:G(FS),tagKey:G(Y(K.check(Ib(1).annotate({expected:`a value with a length of at least 1`})))),tagValue:G(Y(K.check(Ib(1).annotate({expected:`a value with a length of at least 1`})))),tagOperator:G(Y(X([`eq`,`neq`,`in`,`not_in`])))});var bw=IC;J({"X-Aperture-Tenant-Id":G(Q),waitForReady:G(sb.annotate({default:!0}))});var xw=LC;J({"X-Aperture-Tenant-Id":G(Q)});var Sw=RC;J({"X-Aperture-Tenant-Id":G(Q)});var Cw=wC;J({"X-Aperture-Tenant-Id":G(Q)});var ww=zC;J({"X-Aperture-Tenant-Id":G(Q)});var Tw=zC;J({"X-Aperture-Tenant-Id":G(Q)});var Ew=zC;J({"X-Aperture-Tenant-Id":G(Q)});var Dw=zC;J({"X-Aperture-Tenant-Id":G(Q)});var Ow=zC;J({"X-Aperture-Tenant-Id":G(Q)});var kw=zC;J({"X-Aperture-Tenant-Id":G(Q)});var Aw=zC;J({"X-Aperture-Tenant-Id":G(Q)});var jw=QS;J({"X-Aperture-Tenant-Id":G(Q)});var Mw=QS;J({"X-Aperture-Tenant-Id":G(Q)});var Nw=Y($S);J({"X-Aperture-Tenant-Id":G(Q)});var Pw=$S;J({"X-Aperture-Tenant-Id":G(Q)});var Fw=$S;J({"X-Aperture-Tenant-Id":G(Q)});var Iw=$S;J({"X-Aperture-Tenant-Id":G(Q)});var Lw=eC;J({"X-Aperture-Tenant-Id":G(Q)});var Rw=tC;J({"X-Aperture-Tenant-Id":G(Q)});var zw=EC;J({"X-Aperture-Tenant-Id":G(Q),limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),name:G(K),deleted:G(X([`active`,`deleted`,`all`]).annotate({default:`active`})),includeDeleted:G(sb.annotate({default:!1})),tagKey:G(Y(K.check(Ib(1).annotate({expected:`a value with a length of at least 1`})))),tagValue:G(Y(K.check(Ib(1).annotate({expected:`a value with a length of at least 1`})))),tagOperator:G(Y(X([`eq`,`neq`,`in`,`not_in`])))});var Bw=DC;J({"X-Aperture-Tenant-Id":G(Q)});var Vw=EC;J({"X-Aperture-Tenant-Id":G(Q)});var Hw=EC;J({"X-Aperture-Tenant-Id":G(Q)});var Uw=EC;J({"X-Aperture-Tenant-Id":G(Q)});var Ww=EC;J({"X-Aperture-Tenant-Id":G(Q),limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),resourceType:G(K),resourceId:G(K)});var Gw=bC,Kw=(e,t={})=>{let n=e=>V(Rd(e.json,()=>`Unexpected status code`),t=>B(new px({reason:new vx({request:e.request,response:e,description:typeof t==`string`?t:JSON.stringify(t)})}))),r=n=>r=>{let i=n?.includeResponse?e=>kd(r(e),t=>[t,e]):e=>r(e);return t?.transformClient?n=>V(V(t.transformClient(e),e=>e.execute(n)),i):t=>V(e.execute(t),i)},i=encodeURIComponent,a=(e,t,n)=>gd(()=>{let r=(t,n)=>B(new px({reason:new _x({request:e(``),cause:n,description:t})}));if(t.some(e=>e===``||/^(?:\.|%2e){1,2}$/i.test(e)))return r(`Path parameters must be non-empty and cannot be dot segments`);let i;try{i=n()}catch(e){return r(`Failed to encode path parameter`,e)}return i.split(`/`).some(e=>/^(?:\.|%2e){1,2}$/i.test(e))?r(`Request paths cannot contain dot segments`):R(e(i))}),o=e=>t=>eS(e)(t);return{httpClient:e,getHealth:e=>jx(`/api/health`).pipe(r(e?.config)(Z({"2xx":o(KC),orElse:n}))),getCurrentPrincipal:e=>jx(`/api/auth/me`).pipe(zx({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":o(qC),orElse:n}))),listBrowserChannels:e=>jx(`/api/browser/channels`).pipe(r(e?.config)(Z({"2xx":o(JC),orElse:n}))),listTenants:e=>jx(`/api/admin/tenants`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,deleted:e?.params?.deleted,includeDeleted:e?.params?.includeDeleted}),r(e?.config)(Z({"2xx":o(YC),orElse:n}))),createTenant:e=>Mx(`/api/admin/tenants`).pipe(Zx(e.payload),r(e.config)(Z({"2xx":o(XC),orElse:n}))),deleteTenant:(e,t)=>a(Fx,[e],()=>`/api/admin/tenants/`+i(e)).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(ZC),orElse:n}))))),updateTenant:(e,t)=>a(Nx,[e],()=>`/api/admin/tenants/`+i(e)).pipe(V(e=>e.pipe(Zx(t.payload),r(t.config)(Z({"2xx":o(QC),orElse:n}))))),restoreTenant:(e,t)=>a(Mx,[e],()=>`/api/admin/tenants/`+i(e)+`/restore`).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o($C),orElse:n}))))),listUsers:e=>jx(`/api/admin/users`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,query:e?.params?.query,disabled:e?.params?.disabled}),r(e?.config)(Z({"2xx":o(ew),orElse:n}))),createUser:e=>Mx(`/api/admin/users`).pipe(Zx(e.payload),r(e.config)(Z({"2xx":o(tw),orElse:n}))),getUser:(e,t)=>a(jx,[e],()=>`/api/admin/users/`+i(e)).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(nw),orElse:n}))))),disableUser:(e,t)=>a(Fx,[e],()=>`/api/admin/users/`+i(e)).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(rw),orElse:n}))))),updateUser:(e,t)=>a(Nx,[e],()=>`/api/admin/users/`+i(e)).pipe(V(e=>e.pipe(Zx(t.payload),r(t.config)(Z({"2xx":o(iw),orElse:n}))))),restoreUser:(e,t)=>a(Mx,[e],()=>`/api/admin/users/`+i(e)+`/restore`).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(aw),orElse:n}))))),createUserInvitation:(e,t)=>a(Mx,[e],()=>`/api/admin/users/`+i(e)+`/invitation`).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(ow),orElse:n}))))),listUserMemberships:(e,t)=>a(jx,[e],()=>`/api/admin/users/`+i(e)+`/memberships`).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(sw),orElse:n}))))),listTenantMemberships:(e,t)=>a(jx,[e],()=>`/api/admin/tenants/`+i(e)+`/memberships`).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(cw),orElse:n}))))),upsertTenantMembership:(e,t,s)=>a(Px,[e,t],()=>`/api/admin/tenants/`+i(e)+`/memberships/`+i(t)).pipe(V(e=>e.pipe(Zx(s.payload),r(s.config)(Z({"2xx":o(lw),orElse:n}))))),deleteTenantMembership:(e,t,s)=>a(Fx,[e,t],()=>`/api/admin/tenants/`+i(e)+`/memberships/`+i(t)).pipe(V(e=>e.pipe(r(s?.config)(Z({"2xx":o(uw),204:()=>_d,orElse:n}))))),listAuditEvents:e=>jx(`/api/admin/audit-events`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,tenantId:e?.params?.tenantId,actorType:e?.params?.actorType,actorId:e?.params?.actorId,action:e?.params?.action,resourceType:e?.params?.resourceType,resourceId:e?.params?.resourceId}),r(e?.config)(Z({"2xx":o(dw),orElse:n}))),listAdminTokens:e=>jx(`/api/admin/tokens`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,authorityType:e?.params?.authorityType,tenantId:e?.params?.tenantId,name:e?.params?.name,scope:e?.params?.scope,revoked:e?.params?.revoked}),r(e?.config)(Z({"2xx":o(fw),orElse:n}))),createAdminToken:e=>Mx(`/api/admin/tokens`).pipe(Zx(e.payload),r(e.config)(Z({"2xx":o(pw),orElse:n}))),revokeAdminToken:(e,t)=>a(Mx,[e],()=>`/api/admin/tokens/`+i(e)+`/revoke`).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(mw),204:()=>_d,orElse:n}))))),getTenant:e=>jx(`/api/tenant`).pipe(r(e?.config)(Z({"2xx":o(hw),orElse:n}))),updateSelectedTenant:e=>Nx(`/api/tenant`).pipe(Zx(e.payload),r(e.config)(Z({"2xx":o(gw),orElse:n}))),listTenantTokens:e=>jx(`/api/tenant/tokens`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,name:e?.params?.name,scope:e?.params?.scope,revoked:e?.params?.revoked}),r(e?.config)(Z({"2xx":o(_w),orElse:n}))),createTenantToken:e=>Mx(`/api/tenant/tokens`).pipe(Zx(e.payload),r(e.config)(Z({"2xx":o(vw),orElse:n}))),revokeTenantToken:(e,t)=>a(Mx,[e],()=>`/api/tenant/tokens/`+i(e)+`/revoke`).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(yw),204:()=>_d,orElse:n}))))),listSessions:e=>jx(`/api/sessions`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,includeDeleted:e?.params?.includeDeleted,status:e?.params?.status,tagKey:e?.params?.tagKey,tagValue:e?.params?.tagValue,tagOperator:e?.params?.tagOperator}),zx({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":o(bw),orElse:n}))),createSession:e=>Mx(`/api/sessions`).pipe(Jx({waitForReady:e.params?.waitForReady}),zx({"X-Aperture-Tenant-Id":e.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(e.payload),r(e.config)(Z({"2xx":o(xw),orElse:n}))),getSessionsBulk:e=>Mx(`/api/sessions/bulk`).pipe(zx({"X-Aperture-Tenant-Id":e.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(e.payload),r(e.config)(Z({"2xx":o(Sw),orElse:n}))),getSession:(e,t)=>a(jx,[e],()=>`/api/sessions/`+i(e)).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(Cw),orElse:n}))))),deleteSession:(e,t)=>a(Fx,[e],()=>`/api/sessions/`+i(e)).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(ww),orElse:n}))))),replaceSessionTags:(e,t)=>a(Px,[e],()=>`/api/sessions/`+i(e)+`/tags`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(Tw),orElse:n}))))),updateSessionProxy:(e,t)=>a(Px,[e],()=>`/api/sessions/`+i(e)+`/proxy`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(Ew),orElse:n}))))),suspendSession:(e,t)=>a(Mx,[e],()=>`/api/sessions/`+i(e)+`/suspend`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(Dw),orElse:n}))))),reopenSession:(e,t)=>a(Mx,[e],()=>`/api/sessions/`+i(e)+`/reopen`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(Ow),orElse:n}))))),rotateSessionToken:(e,t)=>a(Mx,[e],()=>`/api/sessions/`+i(e)+`/session-token/rotate`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(kw),orElse:n}))))),rotateCollaborationCapability:(e,t,s)=>a(Mx,[e,t],()=>`/api/sessions/`+i(e)+`/collaboration-capabilities/`+i(t)+`/rotate`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":s?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(s?.config)(Z({"2xx":o(Aw),orElse:n}))))),getSessionCursor:(e,t)=>a(jx,[e],()=>`/api/sessions/`+i(e)+`/cursor`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(jw),orElse:n}))))),setSessionCursor:(e,t)=>a(Px,[e],()=>`/api/sessions/`+i(e)+`/cursor`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(Mw),orElse:n}))))),listSessionRecordings:(e,t)=>a(jx,[e],()=>`/api/sessions/`+i(e)+`/recordings`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(Nw),orElse:n}))))),createSessionRecording:(e,t)=>a(Mx,[e],()=>`/api/sessions/`+i(e)+`/recordings`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(Pw),orElse:n}))))),getSessionRecording:(e,t,s)=>a(jx,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":s?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(s?.config)(Z({"2xx":o(Fw),orElse:n}))))),retargetSessionRecording:(e,t,s)=>a(Mx,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/retarget`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":s.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(s.payload),r(s.config)(Z({"2xx":o(Iw),orElse:n}))))),stopSessionRecording:(e,t,s)=>a(Mx,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/stop`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":s?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(s?.config)(Z({"2xx":o(Lw),orElse:n}))))),createSessionFileDownloadURL:(e,t)=>a(Mx,[e],()=>`/api/sessions/`+i(e)+`/files/download-url`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(Rw),orElse:n}))))),promoteSession:(e,t)=>a(Mx,[e],()=>`/api/sessions/`+i(e)+`/promote`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(zw),orElse:n}))))),listSnapshots:e=>jx(`/api/snapshots`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,name:e?.params?.name,deleted:e?.params?.deleted,includeDeleted:e?.params?.includeDeleted,tagKey:e?.params?.tagKey,tagValue:e?.params?.tagValue,tagOperator:e?.params?.tagOperator}),zx({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":o(Bw),orElse:n}))),deleteSnapshot:(e,t)=>a(Fx,[e],()=>`/api/snapshots/`+i(e)).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(Vw),orElse:n}))))),updateSnapshot:(e,t)=>a(Nx,[e],()=>`/api/snapshots/`+i(e)).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(Hw),orElse:n}))))),replaceSnapshotTags:(e,t)=>a(Px,[e],()=>`/api/snapshots/`+i(e)+`/tags`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(Uw),orElse:n}))))),restoreSnapshot:(e,t)=>a(Mx,[e],()=>`/api/snapshots/`+i(e)+`/restore`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(Ww),orElse:n}))))),listEvents:e=>jx(`/api/events`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,resourceType:e?.params?.resourceType,resourceId:e?.params?.resourceId}),zx({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":o(Gw),orElse:n})))}},qw=`X-Aperture-Tenant-Id`,Jw={kind:`session`,authorityType:null,tenantId:null,selectedTenantId:null};function Yw(e,t){if(t!==`none`){if(t===`optional`)return e.selectedTenantId??void 0;if(e.authorityType===`tenant`)return e.kind===`bearer`?void 0:e.tenantId??void 0;if(e.authorityType===`system_admin`)return e.selectedTenantId??void 0}}var Xw={anonymous:{},webSession:{credentials:Jw},of:e=>({credentials:e}),tenantScoped:e=>({credentials:e,tenantHeader:`tenant-scoped`})},Zw=class extends dr()(`@aperture-browser/api-client/ApiAuthorization`){},Qw=X([`ble`,`cable`,`hybrid`,`internal`,`nfc`,`smart-card`,`usb`]),$w=J({id:K,type:rb(`public-key`),transports:G(db(Y(Qw)))}),eT=G(J({appid:G(K),credProps:G(sb),hmacCreateSecret:G(sb),minPinLength:G(sb)})),tT=X([`hybrid`,`security-key`,`client-device`]),nT=X([`discouraged`,`preferred`,`required`]),rT=J({methods:Y(pb([J({type:rb(`password`)}),J({type:rb(`api_token`)}),J({type:rb(`passkey`)}),J({type:rb(`oidc`),id:K,name:K,loginUrl:K})]))}),iT=J({publicKey:J({challenge:K,timeout:G(q),rpId:G(K),allowCredentials:G(db(Y($w))),userVerification:G(nT),hints:G(db(Y(tT))),extensions:eT})}),aT=J({publicKey:J({rp:J({id:G(K),name:K}),user:J({id:K,name:K,displayName:K}),challenge:K,pubKeyCredParams:db(Y(J({alg:X([-7,-8,-35,-36,-37,-38,-39,-257,-258,-259]),type:rb(`public-key`)}))),timeout:G(q),excludeCredentials:G(db(Y($w))),authenticatorSelection:G(J({authenticatorAttachment:G(X([`platform`,`cross-platform`])),requireResidentKey:G(sb),residentKey:G(X([`discouraged`,`preferred`,`required`])),userVerification:G(nT)})),hints:G(db(Y(tT))),attestation:G(X([`direct`,`enterprise`,`indirect`,`none`])),attestationFormats:G(db(Y(X([`fido-u2f`,`packed`,`android-safetynet`,`android-key`,`tpm`,`apple`,`none`])))),extensions:eT})}),oT=J({id:K,name:K,createdAt:K,lastUsedAt:mb(K)}),sT=J({passkeys:Y(oT)}),cT=J({passkey:oT}),lT=J({mfaRequired:sb}),uT=J({hasPassword:sb,totpEnabled:sb,recoveryCodesRemaining:q.check(Fb(),Mb(0))}),dT=J({secret:K,otpauthUrl:K,qrCodeDataUrl:K}),fT=J({recoveryCodes:Y(K)}),pT=class extends dr()(`@aperture-browser/api-client/AuthApi`){},mT=e=>({body:dx(e)}),hT=bu(pT,yd(function*(){let e=yield*cS,{authorize:t}=yield*Zw,n=uS(e),r=Kw(e),i=t(Xw.anonymous),a=t(Xw.webSession),o=U(`AuthApi.listLoginMethods`)(function*(){return yield*n.get(`/auth/login-methods`).pipe(V(eS(rT)),i)}),s=U(`AuthApi.loginWithPassword`)(function*(e,t){return yield*n.post(`/auth/password/login`,mT({email:e,password:t})).pipe(V(eS(lT)),i)}),c=U(`AuthApi.completePasswordMFA`)(function*(e){yield*n.post(`/auth/password/login/mfa`,mT({code:e})).pipe(i)}),l=U(`AuthApi.loginWithAPIToken`)(function*(e){yield*n.post(`/auth/token/login`,mT({token:e})).pipe(i)}),u=U(`AuthApi.beginPasskeyLogin`)(function*(){return yield*n.post(`/auth/passkeys/login/options`).pipe(V(eS(iT)),i)}),d=U(`AuthApi.finishPasskeyLogin`)(function*(e){yield*n.post(`/auth/passkeys/login/finish`,mT(e)).pipe(i)}),f=U(`AuthApi.acceptUserInvitation`)(function*(e,t){yield*n.post(`/auth/invitations/accept`,mT({token:e,password:t})).pipe(i)}),p=U(`AuthApi.logoutWebSession`)(function*(){yield*n.post(`/auth/logout`).pipe(a)}),m=U(`AuthApi.getAuthMe`)(function*(e=null,n=Jw){return yield*r.getCurrentPrincipal(void 0).pipe(t({credentials:{...n,selectedTenantId:e},tenantHeader:`optional`}))}),h=U(`AuthApi.getSecurityStatus`)(function*(){return yield*n.get(`/auth/security`).pipe(V(eS(uT)),a)}),g=U(`AuthApi.setPassword`)(function*(e,t){yield*n.put(`/auth/password`,mT({currentPassword:e,newPassword:t})).pipe(a)}),_=U(`AuthApi.listPasskeys`)(function*(){return yield*n.get(`/auth/passkeys`).pipe(V(eS(sT)),a)}),v=U(`AuthApi.beginPasskeyRegistration`)(function*(e){return yield*n.post(`/auth/passkeys/registration/options`,mT({name:e})).pipe(V(eS(aT)),a)}),y=U(`AuthApi.finishPasskeyRegistration`)(function*(e){return yield*n.post(`/auth/passkeys/registration/finish`,mT(e)).pipe(V(eS(cT)),a)}),b=U(`AuthApi.renamePasskey`)(function*(e,t){return yield*n.patch(`/auth/passkeys/${encodeURIComponent(e)}`,mT({name:t})).pipe(V(eS(cT)),a)}),x=U(`AuthApi.deletePasskey`)(function*(e){yield*n.del(`/auth/passkeys/${encodeURIComponent(e)}`).pipe(a)}),ee=U(`AuthApi.beginTOTPEnrollment`)(function*(){return yield*n.post(`/auth/totp/enrollment/options`).pipe(V(eS(dT)),a)}),S=U(`AuthApi.completeTOTPEnrollment`)(function*(e){return yield*n.post(`/auth/totp/enrollment/finish`,mT({code:e})).pipe(V(eS(fT)),a)}),C=U(`AuthApi.regenerateRecoveryCodes`)(function*(e){return yield*n.post(`/auth/totp/recovery-codes`,mT({code:e})).pipe(V(eS(fT)),a)}),te=U(`AuthApi.disableTOTP`)(function*(e){yield*n.post(`/auth/totp/disable`,mT({code:e})).pipe(a)});return pT.of({listLoginMethods:o,loginWithPassword:s,completePasswordMFA:c,loginWithAPIToken:l,beginPasskeyLogin:u,finishPasskeyLogin:d,acceptUserInvitation:f,logoutWebSession:p,getAuthMe:m,getSecurityStatus:h,setPassword:g,listPasskeys:_,beginPasskeyRegistration:v,finishPasskeyRegistration:y,renamePasskey:b,deletePasskey:x,beginTOTPEnrollment:ee,completeTOTPEnrollment:S,regenerateRecoveryCodes:C,disableTOTP:te})})),gT=J({error:J({code:K,message:K})}),_T=class extends ex()(`ApiRequestError`,{code:K,message:K,status:q}){},vT=e=>new _T({code:`internal_error`,message:`Invalid response`,status:e}),yT=new _T({code:`network_error`,message:`The server could not be reached`,status:0}),bT=e=>e.pipe(Pd(`HttpClientError`,{StatusCodeError:({response:e})=>eS(gT)(e).pipe(kd(({error:t})=>new _T({...t,status:e.status})),Rd(()=>new _T({code:`internal_error`,message:`Request failed`,status:e.status})),V(B)),DecodeError:({response:e})=>B(vT(e.status))}),Nd({HttpClientError:()=>B(yT),SchemaError:()=>B(vT(0))})),xT=Ur(`@aperture-browser/api-client/CurrentAuthorization`,{defaultValue:()=>({})}),ST=e=>xT.useSync(({credentials:t,bearerToken:n,tenantHeader:r=`none`})=>{let i=n??(t?.kind===`bearer`?t.token.trim():void 0),a=t?Yw(t,r):void 0;return e.pipe(Wx,i?Hx(i):x,a?Rx(qw,a):Vx(qw))}),CT=new Set([`authentication_required`,`invalid_authentication_token`,`authentication_token_expired`,`authentication_token_revoked`,`user_disabled`]),wT=bu(cS,kd(cS,hS(ST))),TT=bu(Zw,yd(function*(){let e=yield*Zf();return Zw.of({authorize:t=>n=>n.pipe(bT,Id(n=>t.credentials?.kind===`session`&&CT.has(n.code)?$f(e,void 0):_d),Jd(xT,t)),sessionAuthenticationFailures:Jp(e)})})),ET=e=>({tagKey:e?.map(e=>e.key),tagOperator:e?.map(e=>e.operator),tagValue:e?.map(e=>e.values.join(`,`))}),DT=e=>Object.fromEntries(Object.entries(e).flatMap(([e,t])=>{if(t==null||t===``)return[];if(!Array.isArray(t))return[[e,t]];let n=t.filter(e=>e!==``);return n.length>0?[[e,n]]:[]})),OT=class extends dr()(`@aperture-browser/api-client/EventsApi`){},kT=bu(OT,yd(function*(){let e=yield*cS,{authorize:t}=yield*Zw,n=Kw(e),r=U(`EventsApi.listEvents`)(function*(e,r={}){return yield*n.listEvents({params:DT({limit:r.limit,cursor:r.cursor,resourceType:r.resourceType,resourceId:r.resourceId})}).pipe(t(Xw.tenantScoped(e)))});return OT.of({listEvents:r})})),AT=q.check(Fb(),jb(0)),jT=R([]),MT=J({sessionId:K,cdpUrl:K,media:uC,targets:Y(J({targetId:K,generation:AT,state:X([`pending`,`ready`,`unavailable`,`closed`]),title:K,url:K,viewport:J({width:AT,height:AT,deviceScaleFactor:q.check(jb(0)),contentWidth:AT,contentHeight:AT,canvasWidth:AT,canvasHeight:AT})})).pipe(bb(jT))}),NT=J({recordingId:K,mode:X([`tab`,`viewer`]),targetId:K,captureGeneration:AT,status:X([`starting`,`running`,`stopped`,`failed`]),stopReason:G(K),path:K,startedAt:K,stoppedAt:G(K),sizeBytes:G(q.check(Fb(),Mb(0))),fps:AT,bitrateKbps:AT,codec:K}),PT=class extends dr()(`@aperture-browser/api-client/SessionsApi`){},FT=e=>e?.match(/filename="([^"]+)"/)?.[1]??null,IT=bu(PT,yd(function*(){let e=yield*cS,{authorize:t}=yield*Zw,n=uS(e),r=Kw(e),i=e=>t(Xw.tenantScoped(e)),a=U(`SessionsApi.listSessions`)(function*(e,t={}){return yield*r.listSessions({params:DT({limit:t.limit,cursor:t.cursor,includeDeleted:t.includeDeleted||void 0,status:t.status,...ET(t.tags)})}).pipe(i(e))}),o=U(`SessionsApi.getSession`)(function*(e,t){return yield*r.getSession(t,void 0).pipe(i(e))}),s=U(`SessionsApi.getSessionsBulk`)(function*(e,t){return yield*r.getSessionsBulk({payload:{ids:t}}).pipe(i(e))}),c=U(`SessionsApi.createSession`)(function*(e,t,n={}){return yield*r.createSession({params:DT({waitForReady:n.waitForReady}),payload:{baseSnapshotName:t.baseSnapshotName??null,label:t.label??null,browser:{channel:t.browser.channel,args:t.browser.args??[]},initialTargets:t.initialTargets??[],...t.storageState===void 0?{}:{storageState:t.storageState},tags:t.tags??{}}}).pipe(i(e))}),l=U(`SessionsApi.deleteSession`)(function*(e,t){return yield*r.deleteSession(t,void 0).pipe(i(e))}),u=U(`SessionsApi.reopenSession`)(function*(e,t){return yield*r.reopenSession(t,void 0).pipe(i(e))}),d=U(`SessionsApi.suspendSession`)(function*(e,t){return yield*r.suspendSession(t,void 0).pipe(i(e))}),f=U(`SessionsApi.rotateSessionToken`)(function*(e,t){return yield*r.rotateSessionToken(t,void 0).pipe(i(e))}),p=U(`SessionsApi.rotateCollaborationCapability`)(function*(e,t,n){return yield*r.rotateCollaborationCapability(t,n,void 0).pipe(i(e))}),m=U(`SessionsApi.replaceSessionTags`)(function*(e,t,n){return yield*r.replaceSessionTags(t,{payload:{tags:n}}).pipe(i(e))}),h=U(`SessionsApi.promoteSession`)(function*(e,t,n){return yield*r.promoteSession(t,{payload:{name:n.name,description:n.description??null,force:n.force??!1,tags:n.tags??{}}}).pipe(i(e))}),g=U(`SessionsApi.getBrowserChannels`)(function*(e){return yield*r.listBrowserChannels(void 0).pipe(i(e))}),_=U(`SessionsApi.getBrowserStatus`)(function*(e,r,i){return yield*n.get(`/sessions/${encodeURIComponent(r)}/browser/status`).pipe(V(eS(MT)),t({credentials:e,bearerToken:i}))}),v=U(`SessionsApi.downloadSessionRecording`)(function*(e,r,i,a){return yield*n.get(`/sessions/${encodeURIComponent(r)}/recordings/${encodeURIComponent(i)}/content`).pipe(V(e=>kd(e.arrayBuffer,t=>({blob:new Blob([t],{type:e.headers[`content-type`]??``}),filename:FT(e.headers[`content-disposition`])}))),t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}))});return PT.of({listSessions:a,getSession:o,getSessionsBulk:s,createSession:c,deleteSession:l,reopenSession:u,suspendSession:d,rotateSessionToken:f,rotateCollaborationCapability:p,replaceSessionTags:m,promoteSession:h,getBrowserChannels:g,getBrowserStatus:_,downloadSessionRecording:v})})),LT=class extends dr()(`@aperture-browser/api-client/SnapshotsApi`){},RT=bu(LT,yd(function*(){let e=yield*cS,{authorize:t}=yield*Zw,n=Kw(e),r=e=>t(Xw.tenantScoped(e)),i=U(`SnapshotsApi.listSnapshots`)(function*(e,t={}){return yield*n.listSnapshots({params:DT({limit:t.limit,cursor:t.cursor,includeDeleted:t.includeDeleted||void 0,deleted:t.deleted,name:t.name,...ET(t.tags)})}).pipe(r(e))}),a=U(`SnapshotsApi.updateSnapshot`)(function*(e,t,i){return yield*n.updateSnapshot(t,{payload:i}).pipe(r(e))}),o=U(`SnapshotsApi.replaceSnapshotTags`)(function*(e,t,i){return yield*n.replaceSnapshotTags(t,{payload:{tags:i}}).pipe(r(e))}),s=U(`SnapshotsApi.deleteSnapshot`)(function*(e,t){return yield*n.deleteSnapshot(t,void 0).pipe(r(e))}),c=U(`SnapshotsApi.restoreSnapshot`)(function*(e,t){return yield*n.restoreSnapshot(t,void 0).pipe(r(e))});return LT.of({listSnapshots:i,updateSnapshot:a,replaceSnapshotTags:o,deleteSnapshot:s,restoreSnapshot:c})})),zT=class extends dr()(`@aperture-browser/api-client/TenantsApi`){},BT=bu(zT,yd(function*(){let e=yield*cS,{authorize:t}=yield*Zw,n=Kw(e),r=U(`TenantsApi.listTenants`)(function*(e,r={}){return yield*n.listTenants({params:DT({limit:r.limit,cursor:r.cursor,includeDeleted:r.includeDeleted||void 0,deleted:r.deleted})}).pipe(t(Xw.of(e)))}),i=U(`TenantsApi.createTenant`)(function*(e,r){return yield*n.createTenant({payload:r}).pipe(t(Xw.of(e)))}),a=U(`TenantsApi.updateTenant`)(function*(e,r,i){return yield*n.updateTenant(r,{payload:i}).pipe(t(Xw.of(e)))}),o=U(`TenantsApi.deleteTenant`)(function*(e,r){return yield*n.deleteTenant(r,void 0).pipe(t(Xw.of(e)))}),s=U(`TenantsApi.restoreTenant`)(function*(e,r){return yield*n.restoreTenant(r,void 0).pipe(t(Xw.of(e)))});return zT.of({listTenants:r,createTenant:i,updateTenant:a,deleteTenant:o,restoreTenant:s})})),VT=class extends dr()(`@aperture-browser/api-client/TokensApi`){},HT=bu(VT,yd(function*(){let e=yield*cS,{authorize:t}=yield*Zw,n=Kw(e),r=U(`TokensApi.listAdminTokens`)(function*(e,r={}){return yield*n.listAdminTokens({params:DT({limit:r.limit,cursor:r.cursor,tenantId:r.tenantId,name:r.name,authorityType:r.authorityType,revoked:r.revoked,scope:r.scope})}).pipe(t(Xw.of(e)))}),i=U(`TokensApi.createAdminToken`)(function*(e,r){let i=r.authorityType===`system_admin`;return yield*n.createAdminToken({payload:{name:r.name,authorityType:r.authorityType,tenantId:r.tenantId??null,scopes:r.scopes,resourceMode:i?`all`:r.resourceMode,resourceGrants:i?[]:r.resourceGrants,expiresAt:r.expiresAt??null}}).pipe(t(Xw.of(e)))}),a=U(`TokensApi.revokeAdminToken`)(function*(e,r){yield*n.revokeAdminToken(r,void 0).pipe(t(Xw.of(e)))}),o=U(`TokensApi.listTenantTokens`)(function*(e,r={}){return yield*n.listTenantTokens({params:DT({limit:r.limit,cursor:r.cursor,name:r.name,revoked:r.revoked,scope:r.scope})}).pipe(t(Xw.of(e)))}),s=U(`TokensApi.createTenantToken`)(function*(e,r){return yield*n.createTenantToken({payload:{name:r.name,scopes:r.scopes,resourceMode:r.resourceMode,resourceGrants:r.resourceGrants,expiresAt:r.expiresAt??null}}).pipe(t(Xw.of(e)))}),c=U(`TokensApi.revokeTenantToken`)(function*(e,r){yield*n.revokeTenantToken(r,void 0).pipe(t(Xw.of(e)))});return VT.of({listAdminTokens:r,createAdminToken:i,revokeAdminToken:a,listTenantTokens:o,createTenantToken:s,revokeTenantToken:c})})),UT=class extends dr()(`@aperture-browser/api-client/UsersApi`){},WT=wu(hT,BT,bu(UT,yd(function*(){let e=yield*cS,{authorize:t}=yield*Zw,n=Kw(e),r=U(`UsersApi.listUsers`)(function*(e,r={}){return yield*n.listUsers({params:DT({limit:r.limit,cursor:r.cursor,query:r.query,disabled:r.disabled})}).pipe(t(Xw.of(e)))}),i=U(`UsersApi.createUser`)(function*(e,r){return yield*n.createUser({payload:r}).pipe(t(Xw.of(e)))}),a=U(`UsersApi.getUser`)(function*(e,r){return yield*n.getUser(r,void 0).pipe(t(Xw.of(e)))}),o=U(`UsersApi.updateUser`)(function*(e,r,i){return yield*n.updateUser(r,{payload:i}).pipe(t(Xw.of(e)))}),s=U(`UsersApi.createUserInvitation`)(function*(e,r){return yield*n.createUserInvitation(r,void 0).pipe(t(Xw.of(e)))}),c=U(`UsersApi.disableUser`)(function*(e,r){return yield*n.disableUser(r,void 0).pipe(t(Xw.of(e)))}),l=U(`UsersApi.restoreUser`)(function*(e,r){return yield*n.restoreUser(r,void 0).pipe(t(Xw.of(e)))}),u=U(`UsersApi.listUserMemberships`)(function*(e,r){return yield*n.listUserMemberships(r,void 0).pipe(t(Xw.of(e)))}),d=U(`UsersApi.upsertTenantMembership`)(function*(e,r,i,a){let o={scopes:a};return yield*n.upsertTenantMembership(r,i,{payload:o}).pipe(t(Xw.of(e)))}),f=U(`UsersApi.deleteTenantMembership`)(function*(e,r,i){yield*n.deleteTenantMembership(r,i,void 0).pipe(t(Xw.of(e)))});return UT.of({listUsers:r,createUser:i,getUser:a,updateUser:o,createUserInvitation:s,disableUser:c,restoreUser:l,listUserMemberships:u,upsertTenantMembership:d,deleteTenantMembership:f})})),IT,RT,HT,kT).pipe(Eu(wT),Du(TT)),GT=e=>bu(cS,kd(cS,mS(Kx(e)))),KT=`aperture-session.v1`,qT={onExcessProperty:`error`},JT=q.check(Fb()),YT=q.check(jb(0)),XT=JT.check(jb(0)),ZT=q.check(Pb({minimum:0,maximum:1})),QT=R([]);function $T(e){return Y(e).pipe(bb(QT))}var eE=X([`implicit`,`explicit`]),tE=J({profile:K,fps:JT.check(Pb({minimum:1,maximum:120})),bitrateKbps:JT.check(Mb(100)),keyframeInterval:XT}),nE=J({id:K,label:K,codec:K,mimeType:K,sdpFmtpLine:K}),rE=J({quality:G(tE),profiles:Y(nE),cursorVisible:sb}),iE=J({id:K,type:K,title:K,url:K,loading:sb,viewport:G(J({width:YT,height:YT,contentWidth:YT,contentHeight:YT,canvasWidth:YT,canvasHeight:YT,deviceScaleFactor:YT}))}),aE=J({clientId:K,name:K,avatarHash:K,role:X([`owner`,`editor`,`viewer`,`automation`]),activeTargetId:G(K),followingClientId:G(K),holdingInput:sb,leaseMode:G(eE),recovering:G(sb)}),oE=Qy(Gb(pb([J({type:rb(`session.snapshot`),clientId:K,resumeSecret:K,role:X([`owner`,`editor`,`viewer`]),transport:X([`webrtc`,`websocket`]),holderClientId:G(K),mode:G(eE),activeTargetId:G(K),targets:$T(iE),participants:$T(aE),recordings:$T(NT),presentation:rE}),J({type:rb(`presence.state`),participants:$T(aE)}),J({type:rb(`input.state`),holderClientId:G(K),mode:G(eE)}),J({type:rb(`presence.cursor`),clientId:K,targetId:K,x:ZT,y:ZT,realtimeCounter:XT}),J({type:rb(`presence.cursor.clear`),clientId:K,realtimeCounter:XT}),J({type:rb(`paint.point`),clientId:K,targetId:K,strokeId:K,color:K.check(wb(/^#[0-9a-fA-F]{6}$/)),width:q.check(Pb({minimum:1,maximum:16})),phase:X([`start`,`move`,`end`]),x:ZT,y:ZT,realtimeCounter:G(XT)}),J({type:rb(`targets.state`),activeTargetId:G(K),targets:$T(iE)}),J({type:rb(`recordings.state`),recordings:$T(NT)}),J({type:rb(`presentation.state`),presentation:rE}),J({type:rb(`error`),code:K,message:K}),J({type:X([`target.select.result`,`target.create.result`,`target.close.result`,`page.navigate.result`,`page.history-back.result`,`page.history-forward.result`,`page.reload.result`,`page.stop-loading.result`,`viewport.set.result`,`presentation.quality.set.result`,`presentation.cursor.set.result`,`recording.start.result`,`recording.stop.result`,`recording.cancel.result`]),requestId:K,ok:sb,code:G(K),message:G(K),targetId:G(K),recording:G(NT),presentation:G(rE)})])),qT),sE=J({type:rb(`presentation.frame`),targetId:K,width:YT,height:YT}),cE=[dE(1280,720,1),dE(1440,900,1),dE(1920,1080,1),dE(2560,1440,1),dE(768,1024,1),dE(390,844,1)],lE=cE[0],uE=[1,1.5,2,3];function dE(e,t,n){return{id:`${e}x${t}@${fE(n)}`,label:`${e}×${t}`,width:e,height:t,deviceScaleFactor:n}}function fE(e){return Number.isInteger(e)?String(e):String(e).replace(/0+$/,``).replace(/\.$/,``)}function pE(e,t,n,r){if(n<=0||r<=0||e<=0||t<=0)return{scale:1,offsetX:0,offsetY:0,renderedWidth:e,renderedHeight:t};let i=Math.min(e/n,t/r),a=n*i,o=r*i;return{scale:i,offsetX:(e-a)/2,offsetY:(t-o)/2,renderedWidth:a,renderedHeight:o}}var mE=`~effect/FiberSet`,hE=e=>D(e,mE),gE={[mE]:mE,[Symbol.iterator](){return this.state._tag===`Closed`?Pi():this.state.backing[Symbol.iterator]()},...jt,toJSON(){return{_id:`FiberSet`,state:this.state}}},_E=(e,t)=>{let n=Object.create(gE);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},vE=()=>Xd(z(()=>_E(new Set,Gl())),e=>gd(()=>{let t=e.state;if(t._tag===`Closed`)return _d;e.state={_tag:`Closed`};let n=t.backing;return Af(n).pipe(Xl(e.deferred))})),yE=()=>V(vE(),e=>wE(e)()),bE=-1,xE=Zi($i(Fu,Qi(bE))),SE=b(e=>hE(e[0]),(e,t,n)=>{if(e.state._tag===`Closed`){t.interruptUnsafe(bE);return}else if(e.state.backing.has(t))return;e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),Hl(r)&&(n?.propagateInterruption===!0?!xE(r.cause):!ju(r.cause))&&L(e.deferred,r))})}),CE=function(){let e;return()=>(e===void 0&&(e=ff(rf)),e)}(),wE=e=>()=>kd(Wd(),t=>{let n=pf(t);return(t,r)=>{if(e.state._tag===`Closed`)return CE();let i=n(t,r);return SE(e,i,r),i}}),TE=class extends la(`LiveSessionError`){},EE=Qy(Gb(pb([J({version:rb(1),type:rb(`answer`),sdp:K}),J({version:rb(1),type:rb(`ice-candidate`),candidate:J({candidate:K,sdpMid:G(mb(K)),sdpMLineIndex:G(mb(q.check(Fb()))),usernameFragment:G(mb(K))})}),J({version:rb(1),type:rb(`error`),error:J({code:K,message:K})})])),qT),DE=Qy(Gb(sE),qT),OE=5e3,kE=500,AE=15e3,jE=wf(function*(e){let{callbacks:t}=e,n=yield*yE(),r=e=>n(e),i=(e,t)=>r(Bd(e).pipe(Ed(z(t)))),a=null,o=null,s=null,c=e.webrtcSupported?`webrtc`:`websocket`,l=null,u=!1,d=null,f=1e3,p=0,m=0,h=0,g=[],_=null,v=new Map,y={hello:()=>({type:`session.hello`,...s??e.identity}),message:(e,t)=>ae(e,t),ready:e=>w(e),failed:(e,t)=>ie(e,t),frame:(e,n)=>{a===e?t.onFrame(n):o===e&&(_=n)}},b=()=>{o?.close(),o=null,g=[],_=null},x=()=>{d?.interruptUnsafe(),d=null},ee=e=>{let t=new TE({message:e});for(let e of v.values())L(e,B(t));v.clear()},S=e=>{if(!l)return;let t=l;l=null,L(t.deferred,B(new TE({message:e})))},C=()=>{c===`webrtc`&&e.webrtcSupported?te():ne()},te=()=>{if(u||o)return;let t;try{t=new PE({baseUrl:e.baseUrl,sessionId:e.sessionId,credentials:e.credentials,sessionToken:e.sessionToken,iceServers:e.iceServers,callbacks:y,fork:r})}catch(e){ce(`webrtc`,ME(e,`WebRTC setup failed`));return}o=t,g=[],_=null,t.connect(),i(OE,()=>{o===t&&(b(),ce(`webrtc`,new TE({message:`WebRTC presentation timed out`})))})},ne=()=>{if(u||o)return;let t;try{t=new NE({baseUrl:e.baseUrl,sessionId:e.sessionId,credentials:e.credentials,sessionToken:e.sessionToken,callbacks:y,fork:r})}catch(e){ce(`websocket`,ME(e,`WebSocket setup failed`));return}o=t,g=[],_=null,t.connect()},re=e=>i(e,()=>{!u&&a===null&&o===null&&ne()}),w=n=>{if(u||o!==n){n.close();return}let r=a,i=g,s=_;if(r&&r!==n&&ee(`live session transport replaced`),o=null,g=[],_=null,a=n,m=0,h=0,f=1e3,t.onPhase(`connected`),t.onTransport(n.kind),l?.kind===n.kind){let e=l;l=null,L(e.deferred,_d)}n instanceof PE?(t.onFrame(null),t.onStream(n.mediaStream())):(t.onStream(null),s&&t.onFrame(s));for(let e of i)oe(e);n.kind===`websocket`&&c===`webrtc`&&e.webrtcSupported&&se(),r&&r!==n&&r.close()},ie=(e,n)=>{if(!u){if(o===e){b(),ce(e.kind,n);return}a===e&&(a=null,e.close(),ee(`live session transport was lost`),t.onPhase(`disconnected`),t.onError(n.message),t.onFrame(null),t.onStream(null),t.onTransport(null),re(e.kind===`webrtc`?0:kE))}},ae=(e,t)=>{if(t.type===`error`&&t.code===`resume_rejected`&&o===e&&a===null&&(s=null),t.type===`session.snapshot`&&(s={clientId:t.clientId,resumeSecret:t.resumeSecret}),a!==e){if(o!==e)return;g.push(t),t.type===`session.snapshot`&&e.kind===`websocket`&&w(e);return}oe(t)},oe=e=>{if(`realtimeCounter`in e&&e.realtimeCounter!==void 0){if(e.realtimeCounter<=h)return;h=e.realtimeCounter}if(`requestId`in e){let t=v.get(e.requestId);t&&(v.delete(e.requestId),L(t,e.ok?R(e):B(new TE({message:e.message??`live session command failed`}))))}t.onMessage(e)},se=()=>{if(u||c!==`webrtc`||!e.webrtcSupported||a?.kind===`webrtc`||d!==null)return;let t=f;f=Math.min(AE,f*2),d=i(t,()=>{d=null,te()})},ce=(e,n)=>{if(l?.kind===e&&(S(n.message),a&&(c=a.kind)),a){a.kind===`websocket`&&se();return}if(e===`webrtc`){ne();return}t.onPhase(`disconnected`),t.onError(n.message),re(kE)},le=e=>a?.sendReliable(e)??!1,ue=e=>(m+=1,a?.sendRealtime({realtimeCounter:m,...e})??!1),T=()=>{u=!0,x(),b(),a?.close(),a=null,S(`live session connection closed`),ee(`live session connection closed`),t.onFrame(null),t.onStream(null),t.onTransport(null)};return yield*Qd(()=>z(T)),t.onPhase(`connecting`),C(),{reconnect:z(()=>{x(),b(),a?.close(),a=null,S(`live session transport replaced`),ee(`live session transport replaced`),t.onPhase(`connecting`),C()}),selectTransport:t=>gd(()=>{if(t===`webrtc`&&!e.webrtcSupported)return B(new TE({message:`WebRTC presentation is unavailable`}));if(c=t,x(),o&&o.kind!==t&&b(),S(`presentation selection was replaced`),a?.kind===t)return _d;let n=Gl();return l={kind:t,deferred:n},o===null&&(t===`webrtc`?te():ne()),Kl(n)}),sendReliable:le,sendRealtime:ue,command:(e,t={})=>gd(()=>{p+=1;let n=`request-${p}`,r=Gl();return v.set(n,r),le({type:e,requestId:n,...t})?Kl(r).pipe(af(()=>z(()=>v.delete(n)))):(v.delete(n),B(new TE({message:`live session transport is unavailable`})))})}});function ME(e,t){return new TE({message:e instanceof Error&&e.message?e.message:t})}var NE=class{kind=`websocket`;socket;callbacks;fork;pendingRealtime=new Map;pendingRasterPacket=null;rasterDecoder=null;decodingRaster=!1;realtimeFrame=null;closed=!1;constructor(e){this.callbacks=e.callbacks,this.fork=e.fork,this.socket=new WebSocket(IE(e.baseUrl,e.sessionId),zE(e.credentials,e.sessionToken)),this.socket.binaryType=`blob`}connect(){this.socket.addEventListener(`open`,()=>{this.sendReliable(this.callbacks.hello())}),this.socket.addEventListener(`message`,e=>{if(typeof e.data==`string`){let t=oE(e.data);rr(t)&&this.callbacks.message(this,t.value);return}e.data instanceof Blob&&(this.pendingRasterPacket=e.data,this.decodingRaster||(this.decodingRaster=!0,this.rasterDecoder=this.fork(this.decodeRasterPackets())))}),this.socket.addEventListener(`close`,()=>{this.closed||this.callbacks.failed(this,new TE({message:`WebSocket session transport closed`}))}),this.socket.addEventListener(`error`,()=>{this.closed||this.callbacks.failed(this,new TE({message:`WebSocket session transport failed`}))})}sendReliable(e){return this.flushRealtime(),this.sendNow(e)}sendRealtime(e){return this.socket.readyState===WebSocket.OPEN?(this.pendingRealtime.delete(e.type),this.pendingRealtime.set(e.type,e),this.realtimeFrame===null&&(this.realtimeFrame=window.requestAnimationFrame(()=>{this.realtimeFrame=null,this.flushRealtime()})),!0):!1}close(){this.closed=!0,this.pendingRasterPacket=null,this.rasterDecoder?.interruptUnsafe(),this.rasterDecoder=null,this.realtimeFrame!==null&&(window.cancelAnimationFrame(this.realtimeFrame),this.realtimeFrame=null),this.pendingRealtime.clear(),this.socket.close()}decodeRasterPackets(){return yd({self:this},function*(){for(;;){let e=this.pendingRasterPacket;if(e===null||this.closed){this.decodingRaster=!1;return}this.pendingRasterPacket=null;let t=yield*FE(e);rr(t)&&!this.closed&&this.callbacks.frame(this,t.value)}})}flushRealtime(){this.realtimeFrame!==null&&(window.cancelAnimationFrame(this.realtimeFrame),this.realtimeFrame=null);for(let e of this.pendingRealtime.values())this.sendNow(e);this.pendingRealtime.clear()}sendNow(e){return this.socket.readyState===WebSocket.OPEN?(this.socket.send(JSON.stringify(e)),!0):!1}},PE=class{kind=`webrtc`;connection;reliable;realtime;signal;callbacks;fork;pendingCandidates=[];reliableOpen=!1;realtimeOpen=!1;helloSent=!1;snapshotReceived=!1;stream=null;streamReady=!1;closed=!1;constructor(e){this.callbacks=e.callbacks,this.fork=e.fork,this.connection=new RTCPeerConnection({iceServers:e.iceServers.map(e=>({...e,urls:[...e.urls]}))}),this.reliable=this.connection.createDataChannel(`application`,{ordered:!0}),this.realtime=this.connection.createDataChannel(`application-realtime`,{ordered:!1,maxRetransmits:0}),this.connection.addTransceiver(`video`,{direction:`recvonly`}),this.signal=new WebSocket(LE(e.baseUrl,e.sessionId),zE(e.credentials,e.sessionToken))}connect(){this.reliable.addEventListener(`open`,()=>{this.reliableOpen=!0,this.sendHello()}),this.realtime.addEventListener(`open`,()=>{this.realtimeOpen=!0,this.sendHello()}),this.reliable.addEventListener(`message`,e=>this.handleApplicationMessage(e)),this.realtime.addEventListener(`message`,e=>this.handleApplicationMessage(e));for(let e of[this.reliable,this.realtime])e.addEventListener(`close`,()=>this.fail(`WebRTC session channel closed`)),e.addEventListener(`error`,()=>this.fail(`WebRTC session channel failed`));this.connection.addEventListener(`track`,e=>{this.stream=e.streams[0]??new MediaStream([e.track]);let t=()=>{this.stream&&(this.streamReady=!0,this.maybeReady())};e.track.muted?e.track.addEventListener(`unmute`,t,{once:!0}):t()}),this.connection.addEventListener(`icecandidate`,e=>{e.candidate&&this.signal.readyState===WebSocket.OPEN&&this.signal.send(JSON.stringify({version:1,type:`ice-candidate`,candidate:e.candidate.toJSON()}))}),this.connection.addEventListener(`connectionstatechange`,()=>{(this.connection.connectionState===`failed`||this.connection.connectionState===`closed`)&&this.fail(`WebRTC ${this.connection.connectionState}`)}),this.signal.addEventListener(`open`,()=>{this.fork(this.sendOffer().pipe(Md(`LiveSessionError`,e=>z(()=>this.fail(e.message)))))}),this.signal.addEventListener(`message`,e=>this.handleSignal(e)),this.signal.addEventListener(`close`,()=>this.fail(`WebRTC signaling closed`)),this.signal.addEventListener(`error`,()=>this.fail(`WebRTC signaling failed`))}sendReliable(e){return this.reliable.readyState===`open`?(this.reliable.send(JSON.stringify(e)),!0):!1}sendRealtime(e){return this.realtime.readyState===`open`?(this.realtime.send(JSON.stringify(e)),!0):!1}close(){this.closed=!0,this.reliable.close(),this.realtime.close(),this.connection.close(),this.signal.close()}mediaStream(){return this.stream}sendHello(){this.helloSent||!this.reliableOpen||!this.realtimeOpen||(this.helloSent=this.sendReliable(this.callbacks.hello()))}handleApplicationMessage(e){if(typeof e.data!=`string`)return;let t=oE(e.data);if(nr(t)){this.fail(`WebRTC session message is invalid`);return}this.callbacks.message(this,t.value),t.value.type===`session.snapshot`&&(this.snapshotReceived=!0,this.maybeReady())}handleSignal(e){let t=typeof e.data==`string`?EE(e.data):er();if(nr(t)){this.fail(`WebRTC signaling message is invalid`);return}let n=t.value;if(n.type===`error`){this.fail(n.error.message);return}if(n.type===`answer`){this.fork(hd(()=>this.connection.setRemoteDescription({type:`answer`,sdp:n.sdp})).pipe(Ed(gd(()=>fd(this.pendingCandidates.splice(0),e=>hd(()=>this.connection.addIceCandidate(e)),{discard:!0}))),jd(()=>z(()=>this.fail(`WebRTC answer is invalid`)))));return}if(!this.connection.remoteDescription){this.pendingCandidates.push(n.candidate);return}this.fork(hd(()=>this.connection.addIceCandidate(n.candidate)).pipe(jd(()=>z(()=>this.fail(`WebRTC ICE candidate is invalid`)))))}sendOffer(){return yd({self:this},function*(){let e=e=>ME(e,`WebRTC negotiation failed`),t=yield*hd({try:()=>this.connection.createOffer(),catch:e});yield*hd({try:()=>this.connection.setLocalDescription(t),catch:e});let n=this.connection.localDescription?.sdp;if(!n)return yield*new TE({message:`WebRTC offer is unavailable`});this.signal.send(JSON.stringify({version:1,type:`offer`,sdp:n}))})}maybeReady(){this.snapshotReceived&&this.stream&&this.streamReady&&this.callbacks.ready(this)}fail(e){this.closed||this.callbacks.failed(this,new TE({message:e}))}};function FE(e){return yd(function*(){if(e.size<4)return er();let t=yield*hd(()=>e.slice(0,4).arrayBuffer()),n=new DataView(t).getUint32(0);return n===0||n>e.size-4?er():cr(DE(yield*hd(()=>e.slice(4,4+n).text())),t=>({targetId:t.targetId,data:e.slice(4+n,e.size,`image/jpeg`),width:t.width,height:t.height}))}).pipe(Rd(()=>er()))}function IE(e,t){return RE(e,`/sessions/${encodeURIComponent(t)}/session`)}function LE(e,t){return RE(e,`/sessions/${encodeURIComponent(t)}/webrtc/signal`)}function RE(e,t){let n=new URL(t,e??window.location.href);return n.protocol=n.protocol===`https:`?`wss:`:`ws:`,n.toString()}function zE(e,t){let n=[KT];t?n.push(`authorization.bearer.${t}`):e.kind===`bearer`&&n.push(`authorization.bearer.${e.token}`);let r=Yw(e,`tenant-scoped`);return r&&n.push(`x-aperture-tenant-id.${r}`),n}var $=c(f(),1),BE=`~effect/SubscriptionRef`,VE={...jt,[BE]:{_A:x},toJSON(){return{_id:`SubscriptionRef`,value:this.value}}},HE=e=>kd(Zf({replay:1}),t=>{let n=Object.create(VE);return n.semaphore=bp(1),n.value=e,n.pubsub=t,ep(n.pubsub,e),n}),UE=e=>Jp(e.pubsub),WE=(e,t)=>{e.value=t,ep(e.pubsub,t)},GE=b(2,(e,t)=>e.semaphore.withPermit(z(()=>WE(e,t)))),KE=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),qE=o(((e,t)=>{t.exports=KE()})),JE=qE(),YE=(0,$.createContext)(null),XE=class extends la(`RuntimeProviderMissingError`){message=`useRuntime must be used inside RuntimeProvider`};function ZE({runtime:e,baseUrl:t,children:n}){let r=(0,$.useMemo)(()=>({runtime:e,baseUrl:t}),[e,t]);return(0,JE.jsx)(YE.Provider,{value:r,children:n})}function QE(){let e=(0,$.useContext)(YE);if(!e)throw new XE;return e}function $E(){return QE().runtime}function eD(){return QE().baseUrl}function tD(e,t){let n=$E();(0,$.useEffect)(()=>{let t=e();if(!t)return;let r=n.runFork(t);return()=>r.interruptUnsafe()},[n,...t])}function nD(e,t){let n=$E(),r=(0,$.useRef)(new Set);return(0,$.useEffect)(()=>{let e=r.current;return()=>{for(let t of e)t.interruptUnsafe();e.clear()}},[]),(0,$.useCallback)((...t)=>{let i=n.runFork(e(...t));i.pollUnsafe()||(r.current.add(i),i.addObserver(()=>r.current.delete(i)))},[n,...t])}var rD=2e3,iD=()=>new TE({message:`live session transport is unavailable`}),aD=40,oD=7e3,sD={left:272,right:273,middle:274};function cD({sessionId:e,displayName:t=null,credentials:n,sessionToken:r,role:i,enabled:a,webrtcSupported:o,iceServers:s}){let c=(0,$.useMemo)(()=>uD(i,t),[t,i]),l=$E(),u=eD(),d=(0,$.useMemo)(()=>l.runSync(HE(null)),[l]),f=(0,$.useMemo)(()=>l.runSync(Zf()),[l]),p=(0,$.useMemo)(()=>UE(d),[d]),m=(0,$.useMemo)(()=>Jp(f),[f]),h=(0,$.useCallback)(e=>l.runSync(GE(d,e)),[d,l]),g=(0,$.useCallback)(e=>ep(f,e),[f]),_=(0,$.useRef)(null),v=(0,$.useRef)(null),y=(0,$.useRef)(``),b=(0,$.useRef)(!1),x=(0,$.useRef)(!1),ee=(0,$.useRef)(!1),S=(0,$.useRef)(0),C=(0,$.useRef)([]),te=(0,$.useRef)(null),ne=(0,$.useRef)(null),re=(0,$.useRef)(null),w=(0,$.useRef)(null),ie=(0,$.useRef)(!1),[ae,oe]=(0,$.useState)(`idle`),[se,ce]=(0,$.useState)([]),[le,ue]=(0,$.useState)(null),[T,E]=(0,$.useState)(null),[de,fe]=(0,$.useState)(null),[pe,me]=(0,$.useState)(null),[D,O]=(0,$.useState)(!1),[he,ge]=(0,$.useState)(!1),[k,_e]=(0,$.useState)(null),[ve,ye]=(0,$.useState)([]),[be,xe]=(0,$.useState)(``),[Se,Ce]=(0,$.useState)(null),[we,Te]=(0,$.useState)(null),[Ee,De]=(0,$.useState)([]),[Oe,ke]=(0,$.useState)(()=>new Map),[Ae,je]=(0,$.useState)(null);ne.current=de,re.current=pe,w.current=k;let Me=(0,$.useCallback)(e=>{switch(e.type){case`session.snapshot`:y.current=e.clientId,xe(e.clientId),v.current=e.holderClientId??null,Ce(e.holderClientId??null),Te(e.mode??null),C.current=e.participants,De(e.participants),te.current=e.participants.find(t=>t.clientId===e.clientId)?.followingClientId??null,ce(e.targets),ue(e.activeTargetId??null),fe(pD(e.targets,e.activeTargetId)),ye(e.recordings),_e(e.presentation??null),je(null);return;case`targets.state`:ce(e.targets),ue(e.activeTargetId??null),fe(pD(e.targets,e.activeTargetId)),O(!1);return;case`presence.state`:C.current=e.participants,De(e.participants),te.current=e.participants.find(e=>e.clientId===y.current)?.followingClientId??null,ke(e=>{let t=te.current;if(!t)return e.size===0?e:new Map;let n=e.get(t);return n?new Map([[t,n]]):new Map});return;case`input.state`:v.current=e.holderClientId??null,Ce(e.holderClientId??null),Te(e.mode??null),b.current=!1,x.current=!1,je(e=>e?.code===`input_busy`||e?.code===`input_not_owned`?null:e);return;case`presence.cursor`:if(e.clientId!==te.current)return;ke(t=>new Map(t).set(e.clientId,e));return;case`presence.cursor.clear`:ke(t=>{if(!t.has(e.clientId))return t;let n=new Map(t);return n.delete(e.clientId),n});return;case`paint.point`:C.current.some(t=>t.clientId===e.clientId)&&g({type:`point`,message:e});return;case`recordings.state`:ye(e.recordings);return;case`presentation.state`:_e(e.presentation);return;case`error`:b.current=!1,x.current=!1,je({code:e.code,message:e.message});return;default:e.presentation&&_e(e.presentation),e.ok||je({code:e.code??`request_rejected`,message:e.message??`Live session command failed.`})}},[g]);tD(()=>{if(!a||!e||!n){_.current=null,oe(`idle`),ce([]),ue(null),E(null),fe(null),me(null),_e(null),O(!1),ge(!1),De([]),ke(new Map),ye([]),h(null),g({type:`clear`});return}return yd(function*(){let t=yield*jE({baseUrl:u,sessionId:e,credentials:n,sessionToken:r,identity:c,iceServers:s,webrtcSupported:o,callbacks:{onPhase:oe,onMessage:Me,onFrame:h,onStream:E,onTransport:me,onError:e=>je({code:`connection_failed`,message:e})}});return _.current=t,yield*Qd(()=>z(()=>{_.current===t&&(_.current=null)})),yield*vd}).pipe(Yd,$d(z(()=>{h(null),g({type:`clear`})})))},[u,n,a,Me,s,c,h,g,e,r,o]);let Ne=(0,$.useCallback)(e=>_.current?.sendReliable(e)??!1,[]),Pe=(0,$.useCallback)(e=>_.current?.sendRealtime(e)??!1,[]),Fe=nD((e,t,n)=>e.command(t,n).pipe(jd(e=>z(()=>{O(!1),je({code:`request_rejected`,message:e.message})}))),[]),Ie=(0,$.useCallback)((e,t={})=>{let n=_.current;return n?(Fe(n,e,t),!0):!1},[Fe]),Le=(0,$.useCallback)((e,t={})=>gd(()=>_.current?_.current.command(e,t):B(iD())),[]),Re=nD((e,t)=>e.command(`target.select`,{targetId:t}).pipe(Hd({onSuccess:()=>ue(t),onFailure:e=>je({code:`request_rejected`,message:e.message})}),$d(z(()=>O(!1)))),[]),ze=(0,$.useCallback)(e=>gd(()=>{let t=_.current;return t?(O(!0),t.command(`target.select`,{targetId:e}).pipe(Dd(()=>z(()=>ue(e))),Id(e=>z(()=>je({code:`request_rejected`,message:e.message}))),$d(z(()=>O(!1))),Ad)):B(iD())}),[]),Be=(0,$.useCallback)(e=>{let t=_.current;return t?(O(!0),Re(t,e),!0):!1},[Re]),Ve=(0,$.useCallback)(e=>gd(()=>{let t=_.current;return t?ie.current?B(new TE({message:`another presentation update is already in progress`})):(ie.current=!0,ge(!0),yd(function*(){switch(e.kind){case`jpeg`:return yield*t.selectTransport(`websocket`);case`webrtc-retry`:return yield*t.selectTransport(`webrtc`);case`webrtc`:{let n=ne.current;if(!n)return yield*new TE({message:`presentation size is unavailable`});let r=w.current?.quality?.profile!==e.quality.profile&&re.current===`webrtc`;r&&(yield*t.selectTransport(`websocket`));let i=yield*t.command(`presentation.quality.set`,{profile:e.quality.profile,width:n.canvasWidth,height:n.canvasHeight,fps:e.quality.fps,bitrateKbps:e.quality.bitrateKbps}).pipe(Id(()=>r?Ld(t.selectTransport(`webrtc`)):_d));return i.presentation&&_e(i.presentation),yield*t.selectTransport(`webrtc`)}default:return e}}).pipe(Id(e=>z(()=>je({code:`presentation_update_failed`,message:e.message}))),$d(z(()=>{ie.current=!1,ge(!1)})))):B(iD())}),[]),He=(0,$.useCallback)((e,t)=>i===`viewer`||!Ne({type:`input.claim`,targetId:e,mode:t})?!1:(b.current=!0,x.current=!1,!0),[i,Ne]),Ue=(0,$.useCallback)(()=>x.current||v.current!==y.current||!Ne({type:`input.release`})?!1:(x.current=!0,b.current=!1,!0),[Ne]),We=(0,$.useCallback)(e=>e?Be(e):!1,[Be]),Ge=(0,$.useCallback)(e=>Ne({type:`follow.set`,followingClientId:e??``}),[Ne]),Ke=(0,$.useCallback)((e,t,n,r)=>{let i=performance.now();if(i-S.current<aD)return!1;S.current=i;let a=Pe({type:`presence.cursor`,targetId:e,x:mD(t,r.width),y:mD(n,r.height)});return a&&(ee.current=!0),a},[Pe]),qe=(0,$.useCallback)(e=>e.phase===`move`?Pe({type:`paint.point`,...e}):Ne({type:`paint.point`,...e}),[Pe,Ne]),Je=(0,$.useCallback)(()=>!ee.current||!Ne({type:`presence.cursor.clear`})?!1:(ee.current=!1,!0),[Ne]),Ye=(0,$.useCallback)((e,t=!1)=>t?Pe(e):Ne(e),[Pe,Ne]),Xe=(0,$.useCallback)((e,t)=>{if(i===`viewer`||v.current!==y.current&&!b.current)return!1;switch(e.type){case`input.mouse`:{let n=mD(e.x,t.width),r=mD(e.y,t.height);if(e.action===`move`)return Ye({type:`input.pointer.motion.absolute`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,modifiers:e.modifiers??0},!0);if(e.button===`none`)return!0;let i=sD[e.button??`left`],a=(a,o)=>Ye({type:`input.pointer.button`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,buttonCode:i,pressed:a,clickCount:o,modifiers:e.modifiers??0});if(e.action===`down`||e.action===`up`)return a(e.action===`down`,e.clickCount??1);let o=e.action===`doubleClick`?2:1;for(let t=0;t<o;t+=1){let n=e.action===`doubleClick`?t+1:1;a(!0,n),a(!1,n)}return!0}case`input.wheel`:{let n=mD(e.x,t.width),r=mD(e.y,t.height);return Ye({type:`input.pointer.scroll`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,horizontal:e.deltaX,vertical:e.deltaY,stopHorizontal:!1,stopVertical:!1,modifiers:e.modifiers??0}),Ye({type:`input.pointer.scroll`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,horizontal:0,vertical:0,stopHorizontal:e.deltaX!==0,stopVertical:e.deltaY!==0,modifiers:e.modifiers??0})}case`input.key`:{if(e.action===`char`)return e.text?Ye({type:`input.keyboard.text`,targetId:e.targetId,text:e.text}):!1;let t=tm[e.code??``];if(!t)return!1;let n=e.windowsVirtualKeyCode??lm(e.code,e.key);return Ye({type:`input.keyboard.key`,targetId:e.targetId,keycode:t,pressed:e.action===`down`,key:e.key,code:e.code,text:e.text,unmodifiedText:e.unmodifiedText,modifiers:e.modifiers??0,windowsVirtualKeyCode:n,nativeVirtualKeyCode:e.nativeVirtualKeyCode??n,location:e.location??0,autoRepeat:e.autoRepeat??!1,isKeypad:e.isKeypad??!1})}case`clipboard.copy`:return hD(Ye,e.targetId,`KeyC`);case`clipboard.cut`:return hD(Ye,e.targetId,`KeyX`);case`clipboard.paste`:{let t=e.items.find(e=>e.mimeType===`text/plain`);return t?Ye({type:`input.keyboard.text`,targetId:e.targetId,text:t.data}):!1}default:return e}},[i,Ye]),Ze=Se===be&&be!==``,Qe=Ee.find(e=>e.clientId===be)?.followingClientId??null;return tD(()=>Ze?Bd(rD).pipe(Ed(z(()=>{v.current===y.current&&Ne({type:`input.heartbeat`})})),cf):void 0,[Ze,Ne]),{phase:ae,targets:se,activeTargetId:le,frames:p,mediaStream:T,mediaSize:de,transport:pe,presentation:k,mediaSwitching:D||he,recordings:ve,sendBrowserInput:Xe,selectTarget:Be,requestSelectTarget:ze,command:Ie,request:Le,selectPresentation:Ve,reconnect:()=>{let e=_.current;e&&l.runSync(e.reconnect)},collaboration:{phase:ae===`error`?`disconnected`:ae,role:i,clientId:be,holderClientId:Se,leaseMode:we,hasControl:Ze,canRequestControl:i!==`viewer`&&ae===`connected`,lastError:Ae,participants:Ee,cursors:Oe,paintEvents:m,followingClientId:Qe,claim:He,release:Ue,setActiveTarget:We,follow:Ge,sendCursor:Ke,sendPaintPoint:qe,clearCursor:Je,sendInput:Xe}}}var lD=Qy(Gb(J({name:K.check(Rb(1,48)),avatarHash:K.check(wb(/^[0-9a-f]{32}$/))})),qT);function uD(e,t){let n=dD();return e!==`owner`||!t?.trim()?n:{...n,name:Array.from(t.trim()).slice(0,48).join(``)}}function dD(){let e=`aperture.collaboration.identity`;try{let t=window.localStorage.getItem(e);if(t){let e=lD(t);if(rr(e))return e.value}let n=fD();return window.localStorage.setItem(e,JSON.stringify(n)),n}catch{return fD()}}function fD(){let e=[`Amber`,`Brisk`,`Calm`,`Clever`,`Misty`,`Quiet`,`Swift`,`Warm`],t=[`Badger`,`Falcon`,`Fox`,`Koala`,`Otter`,`Panda`,`Raven`,`Tiger`],n=new Uint8Array(18);return crypto.getRandomValues(n),{name:`${e[(n.at(0)??0)%e.length]??`Quiet`} ${t[(n.at(1)??0)%t.length]??`Otter`}`,avatarHash:Array.from(n.slice(2),e=>e.toString(16).padStart(2,`0`)).join(``)}}function pD(e,t){let n=e.find(e=>e.id===t)?.viewport;return n?{width:n.width,height:n.height,canvasWidth:n.canvasWidth,canvasHeight:n.canvasHeight,deviceScaleFactor:n.deviceScaleFactor}:null}function mD(e,t){return t<=1?0:Math.min(1,Math.max(0,e/t))}function hD(e,t,n){let r=tm.ControlLeft,i=tm[n];if(!r||!i)return!1;let a=lm(`ControlLeft`,`Control`),o=n===`KeyC`?`c`:`x`,s=lm(n,o);return e({type:`input.keyboard.key`,targetId:t,keycode:r,pressed:!0,key:`Control`,code:`ControlLeft`,windowsVirtualKeyCode:a,nativeVirtualKeyCode:a,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:i,pressed:!0,key:o,code:n,windowsVirtualKeyCode:s,nativeVirtualKeyCode:s,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:i,pressed:!1,key:o,code:n,windowsVirtualKeyCode:s,nativeVirtualKeyCode:s,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:r,pressed:!1,key:`Control`,code:`ControlLeft`,windowsVirtualKeyCode:a,nativeVirtualKeyCode:a,modifiers:0})}var gD=[`#f43f5e`,`#f97316`,`#eab308`,`#22c55e`,`#06b6d4`,`#8b5cf6`],_D=4,vD=24,yD=2048,bD=512;function xD({collaboration:e,targetId:t,enabled:n,visible:r,left:i,top:a,width:o,height:s}){let c=(0,$.useRef)(null),l=(0,$.useRef)(null),u=(0,$.useRef)(null),d=(0,$.useRef)(0),f=(0,$.useRef)(new Map),p=wD(e.clientId);tD(()=>{let n=c.current;if(!n)return;let r=window.devicePixelRatio||1;n.width=Math.max(1,Math.round(o*r)),n.height=Math.max(1,Math.round(s*r));let i=n.getContext(`2d`);if(!i)return;let a=null,l=new Set(e.participants.map(e=>e.clientId)),u=Date.now();for(let[e,t]of f.current)!t.ended&&!l.has(t.clientId)&&f.current.set(e,{...t,updatedAt:u,ended:!0});let d=()=>{a=null,i.setTransform(r,0,0,r,0,0),i.clearRect(0,0,o,s);let e=Date.now(),n=0;for(let[r,a]of f.current){let c=e-a.updatedAt;if(a.ended&&c>=7e3){f.current.delete(r);continue}if(a.ended&&(n+=1),a.targetId!==t||a.points.length===0)continue;let l=a.ended?1-c/oD:1;i.globalAlpha=l,i.strokeStyle=a.color,i.fillStyle=a.color,i.lineWidth=a.width,i.lineCap=`round`,i.lineJoin=`round`;let u=a.points[0];if(!u)continue;if(a.points.length===1){i.beginPath(),i.arc(u.x*o,u.y*s,a.width/2,0,Math.PI*2),i.fill();continue}i.beginPath(),i.moveTo(u.x*o,u.y*s);for(let e=1;e<a.points.length-1;e+=1){let t=a.points[e],n=a.points[e+1];!t||!n||i.quadraticCurveTo(t.x*o,t.y*s,(t.x+n.x)/2*o,(t.y+n.y)/2*s)}let d=a.points[a.points.length-1];d&&i.lineTo(d.x*o,d.y*s),i.stroke()}i.globalAlpha=1,n>0&&(a=window.requestAnimationFrame(d))},p=()=>{a===null&&(a=window.requestAnimationFrame(d))},m=e=>{if(e.type===`clear`){f.current.clear(),p();return}let t=e.message,n=`${t.clientId}:${t.targetId}:${t.strokeId}`,r=f.current.get(n);if(t.phase!==`start`&&!r||r?.ended&&t.phase!==`start`)return;let i=Date.now();if(t.phase===`start`)for(let[e,n]of f.current)!n.ended&&n.clientId===t.clientId&&f.current.set(e,{...n,updatedAt:i,ended:!0});let a=t.phase===`start`||!r?[{x:t.x,y:t.y}]:[...r.points,{x:t.x,y:t.y}];if(a.length>yD&&(a=a.filter((e,t)=>t%2==0)),!r&&f.current.size>=bD){let e=null,t=1/0;for(let[n,r]of f.current)r.ended&&r.updatedAt<t&&(e=n,t=r.updatedAt);e&&f.current.delete(e)}f.current.set(n,{clientId:t.clientId,targetId:t.targetId,color:t.color,width:t.width,points:a,updatedAt:i,ended:t.phase===`end`}),p()};return d(),Zp(e.paintEvents,e=>z(()=>m(e))).pipe($d(z(()=>{a!==null&&window.cancelAnimationFrame(a)})))},[e.paintEvents,e.participants,s,t,o]),(0,$.useEffect)(()=>{l.current=null,u.current=null},[n,t]);function m(n,r){let i=l.current,a=SD(n);!i||!a||e.sendPaintPoint({targetId:t,strokeId:i,color:p,width:_D,phase:r,x:a.x,y:a.y})}function h(n){if(CD(n),!n.isPrimary||n.button!==0||u.current!==null)return;n.currentTarget.focus(),l.current=crypto.randomUUID(),u.current=n.pointerId,d.current=performance.now();try{n.currentTarget.setPointerCapture(n.pointerId)}catch{}let r=SD(n);r&&e.sendCursor(t,r.x*o,r.y*s,{width:o,height:s}),m(n,`start`)}function g(n){if(CD(n),u.current!==null&&n.pointerId!==u.current)return;let r=SD(n);r&&e.sendCursor(t,r.x*o,r.y*s,{width:o,height:s}),!(!l.current||performance.now()-d.current<vD)&&(d.current=performance.now(),m(n,`move`))}function _(e){CD(e),!(!l.current||u.current!==e.pointerId)&&(m(e,`end`),l.current=null,u.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))}return(0,JE.jsx)(`canvas`,{ref:c,tabIndex:-1,style:{position:`absolute`,zIndex:20,touchAction:`none`,cursor:n?`crosshair`:void 0,pointerEvents:n?void 0:`none`,visibility:r?void 0:`hidden`,left:i,top:a,width:o,height:s},"aria-label":`Shared drawing overlay`,onPointerDown:h,onPointerMove:g,onPointerUp:_,onPointerCancel:_,onWheel:CD,onContextMenu:CD})}function SD(e){let t=e.currentTarget.getBoundingClientRect();return t.width===0||t.height===0?null:{x:Math.max(0,Math.min(1,(e.clientX-t.left)/t.width)),y:Math.max(0,Math.min(1,(e.clientY-t.top)/t.height))}}function CD(e){e.preventDefault(),e.stopPropagation()}function wD(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)>>>0;return gD[t%gD.length]??`#f43f5e`}var TD=500,ED=5;function DD({control:e,viewport:t=e.viewport,localCursorEnabled:n=!0,paintingEnabled:r=!1,onPaintingEnabledChange:i,onNotice:a,className:o,style:s,renderOverlay:c}){let l=(0,$.useRef)(null),u=(0,$.useRef)(null),d=(0,$.useRef)(null),f=(0,$.useRef)({decodingFrame:null,generation:0,pending:null}),p=(0,$.useRef)(null),m=(0,$.useRef)(new Map),h=(0,$.useRef)(new Set),g=(0,$.useRef)(null),_=(0,$.useRef)(null),v=(0,$.useRef)(!1),y=(0,$.useRef)(null),b=(0,$.useRef)(null),[x,ee]=(0,$.useState)(null),[S,C]=(0,$.useState)(null),[te,ne]=(0,$.useState)(null),re=e.mediaPath===`webrtc-live`&&e.mediaPhase===`live`&&!!e.mediaStream&&!!e.activeTargetId,w=re&&(e.mediaSwitching||e.mediaTargetId!==e.activeTargetId||te?.stream!==e.mediaStream||te?.targetId!==e.activeTargetId),ie=r&&(re||S!==null)&&e.collaboration.phase===`connected`&&!e.mediaSwitching&&!w,ae=r||e.mediaSwitching||w||e.collaboration.phase!==`connected`||e.collaboration.role===`viewer`,oe=w&&te?te.size:e.mediaSize,se=re?oe?.width??t.width:S?.width??t.width,ce=re?oe?.height??t.height:S?.height??t.height,le=re?se:t.width,ue=re?ce:t.height,T=re?Math.min(oe?.canvasWidth??se,Math.round(se*(oe?.deviceScaleFactor??1))):se,E=re?Math.min(oe?.canvasHeight??ce,Math.round(ce*(oe?.deviceScaleFactor??1))):ce,de=pE(e.browserViewportSize?.width??se,e.browserViewportSize?.height??ce,se,ce),fe=OD(e.phase),pe=kD(e.collaboration),me=fe??pe,D=me?y.current??x:null,O=e.collaboration.followingClientId?e.collaboration.participants.find(t=>t.clientId===e.collaboration.followingClientId):null,he=O?e.collaboration.cursors.get(O.clientId):null,ge=he?.targetId===e.activeTargetId?{x:de.offsetX+he.x*de.renderedWidth,y:de.offsetY+he.y*de.renderedHeight}:null;(0,$.useEffect)(()=>{e.setInputDimensions({width:le,height:ue})},[e.setInputDimensions,ue,le]);let k=(0,$.useCallback)(()=>{let t=[...m.current.entries()].reverse();m.current.clear();for(let[n,r]of t)e.sendInput({type:`input.key`,targetId:r.targetId,action:`up`,...r.input,text:void 0,modifiers:0,autoRepeat:!1})&&h.current.add(n)},[e.sendInput]);tD(()=>{let t=t=>{if(!t){u.current?PD(u.current,f.current):FD(f.current),p.current!==null&&(p.current=null,C(null));return}if(t.targetId!==e.activeTargetId)return;u.current&&!re?jD(u.current,f.current,t):f.current.pending=t;let n=p.current;if(n?.width!==t.width||n?.height!==t.height){let e={width:t.width,height:t.height};p.current=e,C(e)}};return Zp(e.frames,e=>z(()=>t(e))).pipe($d(z(()=>{u.current?PD(u.current,f.current):FD(f.current)})))},[e.activeTargetId,e.frames,re]),(0,$.useLayoutEffect)(()=>{let t=f.current,n=e.activeTargetId,r=t.pending?.targetId===n?t.pending:t.decodingFrame?.targetId===n?t.decodingFrame:null,i=u.current;if(i?PD(i,t):FD(t),r){t.pending=r;let e={width:r.width,height:r.height};p.current=e,C(e),i&&MD(i,t)}else p.current!==null&&(p.current=null,C(null))},[e.activeTargetId]),(0,$.useEffect)(()=>{let e=u.current;re||!e||MD(e,f.current)},[S,re]),(0,$.useEffect)(()=>{d.current&&(d.current.srcObject=re?e.mediaStream:null)},[e.mediaStream,re]),(0,$.useEffect)(()=>{let t=d.current,n=e.mediaStream,r=e.activeTargetId,i=e.mediaSize;if(!re||!t||!n||!r||!i||e.mediaSwitching||e.mediaTargetId!==r||te?.stream===n&&te.targetId===r)return;let a=t.requestVideoFrameCallback(()=>{ne({stream:n,targetId:r,size:i})});return()=>t.cancelVideoFrameCallback(a)},[e.activeTargetId,e.mediaSize,e.mediaStream,e.mediaSwitching,e.mediaTargetId,te,re]),(0,$.useEffect)(()=>{let t=l.current;if(!t)return;let n=(t,n)=>{e.setBrowserViewportSize({width:t,height:n})},r=t.getBoundingClientRect();n(r.width,r.height);let i=new ResizeObserver(e=>{let t=e[0];t&&n(t.contentRect.width,t.contentRect.height)});return i.observe(t),()=>i.disconnect()},[e.setBrowserViewportSize]),(0,$.useEffect)(()=>()=>{_.current?.(),k()},[k]),(0,$.useEffect)(()=>{let e=()=>{k(),be()},t=()=>{document.visibilityState===`hidden`&&(k(),be())};return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,t)}},[k,e.collaboration]),(0,$.useEffect)(()=>{ae&&(_.current?.(),k(),be())},[ae,k]),(0,$.useEffect)(()=>{r&&(e.setCaptured(!1),v.current=!1),e.collaboration.hasControl&&e.collaboration.leaseMode===`implicit`&&!v.current&&e.collaboration.release()},[e.collaboration.hasControl,e.collaboration.leaseMode,e.collaboration.release,e.setCaptured,r]);function _e(e,t){let n=l.current?.getBoundingClientRect();if(!n)return null;let r=pE(n.width,n.height,se,ce),i=e.clientX-n.left-r.offsetX,a=e.clientY-n.top-r.offsetY;if(!t&&(i<0||a<0||i>r.renderedWidth||a>r.renderedHeight))return null;let o=i/r.scale*(le/se),s=a/r.scale*(ue/ce);return t?{x:Math.round(VD(o,0,Math.max(le-1,0))),y:Math.round(VD(s,0,Math.max(ue-1,0)))}:{x:Math.round(o),y:Math.round(s)}}function ve(){return e.phase!==`connected`||!e.activeTargetId||ae?null:(e.captured||e.setCaptured(!0),ye(e.activeTargetId),l.current?.focus(),e.activeTargetId)}function ye(t){v.current=!0,e.collaboration.hasControl||e.collaboration.claim(t,`implicit`)}function be(){v.current=!1,e.collaboration.hasControl&&e.collaboration.leaseMode===`implicit`&&e.collaboration.release()}function xe(e){e.preventDefault(),e.stopPropagation()}function Se(e){e.cancelable&&e.preventDefault(),e.stopPropagation()}function Ce(){e.phase!==`connected`||ae||(e.setCaptured(!0),e.activeTargetId&&ye(e.activeTargetId),l.current?.focus())}function we(t){Ie(t),!(ae||!e.activeTargetId)&&(e.setCaptured(!0),ye(e.activeTargetId))}function Te(){y.current=null,ee(null),e.collaboration.clearCursor(),g.current||(k(),be(),e.setCaptured(!1))}function Ee(){e.captured||Ce()}function De(t){Ie(t);let n=_e(t,!1);if(e.activeTargetId&&n?e.collaboration.sendCursor(e.activeTargetId,n.x,n.y,{width:le,height:ue}):n||e.collaboration.clearCursor(),ae||g.current?.pointerId===t.pointerId)return;let r=e.captured&&t.buttons===0?e.activeTargetId:null;r&&n&&(xe(t),e.sendInput({type:`input.mouse`,targetId:r,action:`move`,x:n.x,y:n.y,button:`none`,buttons:0,clickCount:0,modifiers:am(t.nativeEvent)}))}function Oe(t){Ie(t);let n=ve();if(!n)return;let r=_e(t,!1);if(!r)return;let i=l.current;if(!i)return;let a=RD(t.button),o=Date.now(),s=zD(n,a,r,o,b.current);b.current={targetId:n,button:a,point:r,time:o,clickCount:s},xe(t),g.current={pointerId:t.pointerId,targetId:n,button:a,clickCount:s},_.current?.();try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}je({pointerId:t.pointerId,targetId:n,button:a,clickCount:s,element:i}),e.sendInput({type:`input.mouse`,targetId:n,action:`down`,x:r.x,y:r.y,button:a,buttons:t.buttons,clickCount:s,modifiers:am(t.nativeEvent)})}function ke(t){if(ae)return;let n=g.current,r=n?.pointerId===t.pointerId?n.targetId:e.activeTargetId;if(!r)return;let i=_e(t,n?.pointerId===t.pointerId);i&&(xe(t),e.sendInput({type:`input.mouse`,targetId:r,action:`up`,x:i.x,y:i.y,button:n?.button??RD(t.button),buttons:t.buttons,clickCount:n?.clickCount??1,modifiers:am(t.nativeEvent)}),n?.pointerId===t.pointerId&&(g.current=null,t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId)))}function Ae(t){let n=g.current;if(n?.pointerId!==t.pointerId)return;let r=_e(t,!0);g.current=null,t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId),!(!r||ae)&&(xe(t),e.sendInput({type:`input.mouse`,targetId:n.targetId,action:`up`,x:r.x,y:r.y,button:n.button,buttons:0,clickCount:n.clickCount,modifiers:am(t.nativeEvent)}))}function je({pointerId:t,targetId:n,button:r,clickCount:i,element:a}){let o=a=>{if(a.pointerId!==t)return;let o=_e(a,!0);Se(a),o&&(e.collaboration.sendCursor(n,o.x,o.y,{width:le,height:ue}),e.sendInput({type:`input.mouse`,targetId:n,action:`move`,x:o.x,y:o.y,button:r,buttons:a.buttons||BD(r),clickCount:i,modifiers:am(a)}))},s=(a,o)=>{if(a.pointerId!==t)return;let s=_e(a,!0);_e(a,!1)||e.collaboration.clearCursor(),Se(a),s&&(e.sendInput({type:`input.mouse`,targetId:n,action:`up`,x:s.x,y:s.y,button:r,buttons:0,clickCount:i,modifiers:am(a)}),o||(b.current={targetId:n,button:r,point:s,time:Date.now(),clickCount:i})),u()},c=e=>s(e,!1),l=e=>s(e,!0),u=()=>{window.removeEventListener(`pointermove`,o,!0),window.removeEventListener(`pointerup`,c,!0),window.removeEventListener(`pointercancel`,l,!0);try{a.hasPointerCapture(t)&&a.releasePointerCapture(t)}catch{}g.current?.pointerId===t&&(g.current=null),_.current===u&&(_.current=null)};_.current=u,window.addEventListener(`pointermove`,o,!0),window.addEventListener(`pointerup`,c,!0),window.addEventListener(`pointercancel`,l,!0)}function Me(t){let n=ve();if(!n)return;let r=_e(t,!1);if(!r)return;xe(t);let i=HD(t.deltaMode,ue);e.sendInput({type:`input.wheel`,targetId:n,x:r.x,y:r.y,deltaX:t.deltaX*i,deltaY:t.deltaY*i,modifiers:am(t.nativeEvent)})}function Ne(t){if(t.key===`Escape`&&r){t.preventDefault(),t.stopPropagation(),i?.(!1);return}if(t.key===`Escape`){e.captured&&(t.preventDefault(),t.stopPropagation(),e.setCaptured(!1),be());return}let n=t.code||t.key;if(t.repeat&&h.current.has(n)){t.preventDefault(),t.stopPropagation();return}let o=e.activeTargetId;if(ae||!o||!e.captured&&GD(l.current)!==l.current&&!l.current?.contains(t.target))return;t.preventDefault(),t.stopPropagation();let s=LD(t.nativeEvent);if(s===`copy`){e.sendInput({type:`clipboard.copy`,targetId:o});return}if(s===`cut`){e.sendInput({type:`clipboard.cut`,targetId:o});return}if(s===`paste`){UD(e,a);return}if(!cm(t.nativeEvent))return;let c=sm(t.nativeEvent,`down`);e.sendInput({type:`input.key`,targetId:o,action:`down`,...c})&&(h.current.delete(n),m.current.set(n,{targetId:o,input:c}))}function Pe(t){let n=t.code||t.key;if(h.current.delete(n)){t.preventDefault(),t.stopPropagation();return}let r=m.current.get(n),i=r?.targetId??e.activeTargetId,a=!ae&&(e.captured||GD(l.current)===l.current||!!l.current?.contains(t.target));!i||!r&&!a||t.key!==`Escape`&&(t.preventDefault(),t.stopPropagation(),!(!r&&LD(t.nativeEvent))&&(!r&&!cm(t.nativeEvent)||e.sendInput({type:`input.key`,targetId:i,action:`up`,...sm(t.nativeEvent,`up`)})&&m.current.delete(n)))}function Fe(t){t.relatedTarget instanceof Node&&t.currentTarget.contains(t.relatedTarget)||(k(),be(),e.setCaptured(!1))}function Ie(e){let t=l.current?.getBoundingClientRect();if(!t)return;let n={x:e.clientX-t.left,y:e.clientY-t.top};y.current=n,me&&ee(n)}let Le=WD(e.phase,S!==null,e.mediaPhase,e.mediaPath,re),Re=ID(e.phase,e.mediaPhase,e.mediaSwitching),ze=pe||AD(e.collaboration.lastError)?null:e.collaboration.lastError;return(0,JE.jsxs)(`div`,{ref:l,tabIndex:0,onKeyDown:Ne,onKeyUp:Pe,onBlur:Fe,onClick:Ee,onPointerMove:De,onFocus:()=>{!ae&&e.activeTargetId&&ye(e.activeTargetId)},onPointerEnter:we,onPointerLeave:Te,onPointerDown:Oe,onPointerUp:ke,onPointerCancel:Ae,onWheel:Me,onContextMenu:t=>{e.captured&&t.preventDefault()},"aria-busy":w,"aria-disabled":ae,className:o,style:{position:`relative`,display:`flex`,flex:`1 1 0%`,minHeight:0,alignItems:`center`,justifyContent:`center`,overflow:`hidden`,outline:`none`,touchAction:`none`,cursor:n?void 0:`none`,...s},children:[re?(0,JE.jsx)(`div`,{style:{position:`relative`,overflow:`hidden`,background:`black`,transition:`opacity 150ms`,opacity:w?.75:1,width:de.renderedWidth,height:de.renderedHeight},children:(0,JE.jsx)(`video`,{ref:d,autoPlay:!0,muted:!0,playsInline:!0,"data-viewport-width":se,"data-viewport-height":ce,style:{position:`absolute`,top:0,left:0,maxWidth:`none`,objectFit:`fill`,width:de.renderedWidth*((oe?.canvasWidth??T)/T),height:de.renderedHeight*((oe?.canvasHeight??E)/E)}})}):S?(0,JE.jsx)(`div`,{style:{position:`relative`,overflow:`hidden`,background:`black`,width:de.renderedWidth,height:de.renderedHeight},children:(0,JE.jsx)(`img`,{ref:u,alt:``,draggable:!1,style:{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:`contain`}})}):null,e.activeTargetId?(0,JE.jsx)(xD,{collaboration:e.collaboration,targetId:e.activeTargetId,enabled:ie,visible:!e.mediaSwitching&&!w&&(re||S!==null),left:de.offsetX,top:de.offsetY,width:de.renderedWidth,height:de.renderedHeight}):null,c?.({status:Le,placeholder:re||S?null:Re,cursorHint:me&&D?{text:me,...D}:null,followedCursor:ge&&O?{name:O.name,...ge}:null,collaborationError:ze?.message??null})]})}function OD(e){return e===`disconnected`||e===`error`?`Session disconnected`:null}function kD(e){return e.holderClientId!==null&&e.holderClientId!==e.clientId?`Input in use`:e.hasControl?null:e.lastError?.code===`input_busy`||e.lastError?.code===`input_not_owned`?`Input in use`:e.lastError?.code===`input_unavailable`?`Input unavailable`:null}function AD(e){return e?.code===`input_busy`||e?.code===`input_not_owned`}function jD(e,t,n){t.pending=n,MD(e,t)}function MD(e,t){if(t.decodingFrame!==null||t.pending===null)return;let n=t.pending,r=t.generation;t.pending=null,t.decodingFrame=n,ND(e,n).then(()=>{t.generation===r&&(t.decodingFrame=null,MD(e,t))})}async function ND(e,t){let n=e.src,r=URL.createObjectURL(t.data);e.src=r;try{await e.decode()}catch{}finally{n.startsWith(`blob:`)&&URL.revokeObjectURL(n),e.src!==r&&URL.revokeObjectURL(r)}}function PD(e,t){FD(t);let n=e.src;e.removeAttribute(`src`),n.startsWith(`blob:`)&&URL.revokeObjectURL(n)}function FD(e){e.generation+=1,e.decodingFrame=null,e.pending=null}function ID(e,t,n){return e===`connecting`?`connecting`:e===`connected`&&t===`connecting`?`connecting-media`:e===`connected`&&n?`switching`:e===`disconnected`||e===`error`?`disconnected`:`waiting`}function LD(e){if(!(e.metaKey||e.ctrlKey)||e.altKey)return null;switch(e.code){case`KeyC`:return`copy`;case`KeyX`:return`cut`;case`KeyV`:return`paste`;default:return null}}function RD(e){return e===0?`left`:e===1?`middle`:e===2?`right`:`none`}function zD(e,t,n,r,i){return i&&i.targetId===e&&i.button===t&&r-i.time<=TD&&Math.abs(i.point.x-n.x)<=ED&&Math.abs(i.point.y-n.y)<=ED?Math.min(i.clickCount+1,3):1}function BD(e){switch(e){case`left`:return 1;case`right`:return 2;case`middle`:return 4;case`none`:return 0;default:return e}}function VD(e,t,n){return Math.min(Math.max(e,t),n)}function HD(e,t){return e===WheelEvent.DOM_DELTA_LINE?16:e===WheelEvent.DOM_DELTA_PAGE?t:1}async function UD(e,t){if(!e.activeTargetId)return;let n=``;try{n=await navigator.clipboard.readText()}catch(e){console.warn(`Clipboard read failed`,e),t?.({level:`error`,message:`Clipboard read failed`});return}n&&e.sendInput({type:`clipboard.paste`,targetId:e.activeTargetId,items:[{mimeType:`text/plain`,data:n}]})}function WD(e,t,n,r,i){return e===`connected`?n===`live`&&i?`webrtc`:t?r===`websocket-live`?`websocket`:`webrtc`:`offline`:`offline`}function GD(e){let t=e?.getRootNode();return t instanceof Document||t instanceof ShadowRoot?t.activeElement:null}var KD=[];function qD({sessionId:e,credentials:t,displayName:n,sessionToken:r,collaborationRole:i=`owner`,enabled:a=!0,webrtcProducerSupported:o=!1,webrtcIceServers:s=KD,onNotice:c}){let l=$E(),u=(0,$.useRef)(c);u.current=c;let d=(e,t)=>z(()=>u.current?.({level:e,message:t})),f=cD({sessionId:e,displayName:n,credentials:t,sessionToken:r,role:i,enabled:!!(a&&e&&t),webrtcSupported:o,iceServers:s}),[p,m]=(0,$.useState)([]),h=(0,$.useMemo)(()=>JD(p,f.targets),[f.targets,p]),g=(0,$.useRef)(f.targets);g.current=f.targets;let _=(0,$.useRef)(f.phase);_.current=f.phase;let[v,y]=(0,$.useState)(lE),[b,x]=(0,$.useState)(null),[ee,S]=(0,$.useState)(!1),[C,te]=(0,$.useState)(!1),[ne,re]=(0,$.useState)(!1),w=(0,$.useRef)(null),ie=(0,$.useRef)(v),ae=(0,$.useRef)(lE),oe=(0,$.useRef)(null),se=(0,$.useRef)(!1);w.current=f.activeTargetId,ie.current=v,oe.current=b,se.current=ee,(0,$.useEffect)(()=>{f.phase!==`connected`&&te(!1)},[f.phase]),(0,$.useEffect)(()=>{if(!f.mediaSize)return;let e=ie.current;e.width===f.mediaSize.width&&e.height===f.mediaSize.height&&e.deviceScaleFactor===f.mediaSize.deviceScaleFactor||y(YD(f.mediaSize,f.mediaSize.deviceScaleFactor))},[f.mediaSize]);let ce=(0,$.useCallback)(n=>!a||!e||!t?!1:f.sendBrowserInput(n,ae.current),[t,a,f,e]),le=(0,$.useCallback)(e=>{f.selectTarget(e)},[f]),ue=(0,$.useCallback)((e,t,n)=>{e!==t&&m(r=>{let i=JD(r,g.current).map(e=>e.id),a=i.indexOf(e),o=i.indexOf(t),s=i[a];if(a===-1||o===-1||!s)return r;let c=[...i];c.splice(a,1);let l=n===`after`?o+1:o,u=a<l?l-1:l;return u===a?r:(c.splice(u,0,s),c)})},[]),T=(0,$.useCallback)(e=>l.runPromise(f.request(`target.create`,{url:e}).pipe(kd(e=>e.targetId??null),jd(e=>d(`error`,ZD(e,`Tab could not be created`)).pipe(H(null))))),[f,l]),E=(0,$.useCallback)((e=`about:blank`)=>{T(e)},[T]),de=(0,$.useCallback)(e=>{T(e.url||`about:blank`).then(t=>{t&&ue(t,e.id,`after`)})},[T,ue]),fe=(0,$.useCallback)(e=>{f.command(`target.close`,{targetId:e})},[f]),pe=(0,$.useCallback)(e=>{let t=w.current;t&&f.command(`page.navigate`,{targetId:t,url:e})},[f]),me=(0,$.useCallback)(e=>{f.command(`page.reload`,{targetId:e})},[f]),D=(0,$.useCallback)(()=>{let e=w.current;e&&f.command(`page.stop-loading`,{targetId:e})},[f]),O=(0,$.useCallback)(()=>{let e=w.current;e&&f.command(`page.history-back`,{targetId:e})},[f]),he=(0,$.useCallback)(()=>{let e=w.current;e&&f.command(`page.history-forward`,{targetId:e})},[f]),ge=(0,$.useCallback)(e=>{y(e);let t=w.current;t&&f.command(`viewport.set`,{targetId:t,width:e.width,height:e.height,deviceScaleFactor:e.deviceScaleFactor})},[f]),k=(0,$.useCallback)(e=>{se.current=!1,S(!1),ge(e)},[ge]),_e=(0,$.useCallback)(e=>{let t={width:Math.round(e.width),height:Math.round(e.height)};if(t.width<1||t.height<1)return;let n=oe.current;n?.width===t.width&&n.height===t.height||(oe.current=t,x(t),se.current&&ge(YD(t,ie.current.deviceScaleFactor)))},[ge]),ve=(0,$.useCallback)(e=>{se.current=e,S(e);let t=oe.current;e&&t&&ge(YD(t,ie.current.deviceScaleFactor))},[ge]),ye=(0,$.useCallback)(()=>{let e=oe.current;e&&(se.current=!1,S(!1),ge(YD(e,ie.current.deviceScaleFactor)))},[ge]),be=(e,t)=>e.pipe(jd(e=>d(`error`,ZD(e,t))),$d(z(()=>re(!1)))),xe=nD((e,t)=>be(f.request(`recording.start`,{mode:e,targetId:t}),`Recording failed to start`),[f]),Se=(0,$.useCallback)(e=>{let t=w.current;!t||i!==`owner`||ne||(re(!0),xe(e,t))},[i,ne,xe]),Ce=nD((e,t,n)=>be(f.request(`recording.stop`,{recordingId:n}).pipe(Ed(PT.use(i=>i.downloadSessionRecording(e,t,n,r))),V(({blob:e,filename:r})=>{let i=f.recordings.find(e=>e.recordingId===n);return XD(e,r??`${t}-${i?.targetId??`target`}-${n}.webm`)}),Ed(d(`success`,`Recording saved`))),`Recording failed to stop`),[f,r]),we=(0,$.useCallback)(n=>{!e||!t||ne||(re(!0),Ce(t,e,n))},[t,ne,Ce,e]),Te=nD(e=>be(f.request(`recording.cancel`,{recordingId:e}).pipe(Ed(d(`success`,`Recording stopped`))),`Recording failed to stop`),[f]),Ee=(0,$.useCallback)(e=>{ne||(re(!0),Te(e))},[ne,Te]),De=nD(e=>f.request(`presentation.cursor.set`,{visible:e}).pipe(jd(e=>d(`error`,ZD(e,`Remote cursor could not be updated`)))),[f]),Oe=(0,$.useCallback)(n=>{e&&t&&De(n)},[t,De,e]),ke=nD(e=>f.selectPresentation(e).pipe(jd(e=>d(`error`,ZD(e,`Presentation could not be updated`)))),[f]),Ae=(0,$.useCallback)(n=>!a||!e||!t||f.mediaSwitching?!1:(ke(n),!0),[t,a,f.mediaSwitching,ke,e]),je=(0,$.useCallback)(e=>Ae({kind:`webrtc`,quality:e}),[Ae]),Me=(0,$.useMemo)(()=>{let e=e=>gd(()=>_.current===`connected`?e:B(new TE({message:`the session is not connected`}))),t=(t,n)=>e(f.request(t,n)),n=(t,n={})=>e(gd(()=>{let e=w.current;return e?f.request(t,{targetId:e,...n}):B(new TE({message:`no tab is active`}))})).pipe(Ad);return{navigate:e=>n(`page.navigate`,{url:e}),historyBack:()=>n(`page.history-back`),historyForward:()=>n(`page.history-forward`),reload:e=>e?t(`page.reload`,{targetId:e}).pipe(Ad):n(`page.reload`),stopLoading:()=>n(`page.stop-loading`),createTarget:(e=`about:blank`)=>t(`target.create`,{url:e}).pipe(kd(e=>e.targetId??null)),closeTarget:e=>t(`target.close`,{targetId:e}).pipe(Ad),activateTarget:t=>e(f.requestSelectTarget(t))}},[f.request,f.requestSelectTarget]),Ne=(0,$.useMemo)(()=>h.find(e=>e.id===f.activeTargetId)??null,[f.activeTargetId,h]),Pe=f.transport===`webrtc`?`webrtc-live`:`websocket-live`,Fe=f.phase===`connected`?`live`:f.phase===`connecting`?`connecting`:f.phase===`error`?`failed`:`idle`;return{phase:f.phase,targets:h,activeTargetId:f.activeTargetId,activeTarget:Ne,frames:f.frames,mediaPhase:Fe,mediaStream:f.mediaStream,mediaStreamSettings:f.presentation?.quality??null,mediaVideoProfiles:f.presentation?.profiles??[],mediaSize:f.mediaSize,mediaPath:Pe,mediaTargetId:f.activeTargetId,mediaSwitching:f.mediaSwitching,viewport:v,browserViewportSize:b,viewportAutoSync:ee,captured:C,recordings:f.recordings,recordingBusy:ne,remoteCursorEnabled:f.presentation?.cursorVisible??!0,collaboration:f.collaboration,commands:Me,setCaptured:te,setInputDimensions:e=>{ae.current=e},setViewport:k,setBrowserViewportSize:_e,setViewportAutoSync:ve,setViewportToBrowserSize:ye,setWebRTCStreamSettings:je,selectMediaStream:Ae,sendInput:ce,activateTarget:le,reorderTargets:ue,createTarget:E,duplicateTarget:de,closeTarget:fe,navigate:pe,reload:me,stopLoading:D,historyBack:O,historyForward:he,startRecording:Se,stopRecording:we,cancelRecording:Ee,setRemoteCursorEnabled:Oe,reconnect:f.reconnect}}function JD(e,t){let n=new Map(t.map(e=>[e.id,e])),r=new Set,i=[];for(let t of e){let e=n.get(t);e&&(i.push(e),r.add(e.id))}for(let e of t)r.has(e.id)||i.push(e);return i}function YD(e,t){return dE(e.width,e.height,t)}var XD=(e,t)=>Zd(z(()=>URL.createObjectURL(e)),e=>z(()=>{let n=document.createElement(`a`);n.href=e,n.download=t,n.click()}),e=>z(()=>URL.revokeObjectURL(e)).pipe(zd(0)));function ZD(e,t){return e instanceof Error&&e.message?e.message:t}var QD=`~effect/ManagedRuntime`,$D=(e,t)=>{let n=t?.memoMap??pu(),r=Ql(`parallel`),i=nu(r,`sequential`),a={onFiberStart:jf(r)},o=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,s,c=wd(t=>(s||=ff(Dd(gu(e,n,i),e=>z(()=>{l.cachedContext=e})),{...a,scheduler:t.cache.scheduler}),Td(Of(s)))),l={[QD]:QD,memoMap:n,scope:r,contextEffect:c,cachedContext:void 0,context(){return l.cachedContext===void 0?gf(l.contextEffect):Promise.resolve(l.cachedContext)},dispose(){return gf(l.disposeEffect)},[Symbol.asyncDispose](){return l.dispose()},disposeEffect:gd(()=>(l.contextEffect=Sd(`ManagedRuntime disposed`),l.cachedContext=void 0,ru(l.scope,Bl))),runFork(e,t){return l.cachedContext===void 0?ff(eO(l,e),o(t)):pf(l.cachedContext)(e,o(t))},runCallback(e,t){return l.cachedContext===void 0?hf(eO(l,e),o(t)):mf(l.cachedContext)(e,o(t))},runSyncExit(e){return l.cachedContext===void 0?Sf(eO(l,e)):Cf(l.cachedContext)(e)},runSync(e){return l.cachedContext===void 0?bf(eO(l,e)):xf(l.cachedContext)(e)},runPromiseExit(e,t){return l.cachedContext===void 0?vf(eO(l,e),o(t)):yf(l.cachedContext)(e,o(t))},runPromise(e,t){return l.cachedContext===void 0?gf(eO(l,e),o(t)):_f(l.cachedContext)(e,o(t))}};return l};function eO(e,t){return V(e.contextEffect,e=>Kd(t,e))}var tO=Ur(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),nO=class extends dr()(`effect/http/FetchHttpClient/RequestInit`){},rO=bS(R(pS((e,t,n,r)=>{let i=r.getRef(tO),a=Pr(r.context,nO)??{},o=a.headers?jy(Dy(a.headers),e.headers):e.headers;o[`content-length`]&&(o=My(o,`content-length`));let s=r=>kd(hd({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:typeof ReadableStream<`u`&&r instanceof ReadableStream?`half`:void 0,signal:n}),catch:t=>new px({reason:new gx({request:e,cause:t})})}),t=>rS(e,t));switch(e.body._tag){case`Raw`:case`Uint8Array`:return s(e.body.body);case`FormData`:return s(e.body.formData);case`Stream`:return V(em(e.body.stream),s)}return s(void 0)}))),iO=(e={})=>$D(wu(WT.pipe(Eu(e.baseUrl?GT(e.baseUrl):yu),Eu(rO)),_u(vS,!1)));function aO({baseUrl:e,children:t}){let[n,r]=(0,$.useState)(null);return(0,$.useEffect)(()=>{let t=iO({baseUrl:e});return r(t),()=>{r(null),t.dispose()}},[e]),n?(0,JE.jsx)(ZE,{runtime:n,baseUrl:e,children:t}):null}function oO(e){let t=e.slice(4,40),n=e.startsWith(`ape_`)?`editor`:e.startsWith(`apv_`)?`viewer`:null;return!n||e[40]!==`_`||!t||!e.slice(41)?null:{token:e,sessionId:t,role:n}}var sO=[];function cO({token:e,displayName:t,onNotice:n}){let r=(0,$.useMemo)(()=>oO(e),[e]),i=(0,$.useMemo)(()=>r&&{kind:`bearer`,token:r.token,authorityType:null,tenantId:null,selectedTenantId:null},[r]),[a,o]=(0,$.useState)({kind:`loading`});tD(()=>r&&i?z(()=>o({kind:`loading`})).pipe(Ed(PT.use(e=>e.getBrowserStatus(i,r.sessionId))),Hd({onFailure:e=>o({kind:e.status===410?`expired`:`unavailable`}),onSuccess:e=>o(e.sessionId===r.sessionId?{kind:`ready`,browser:e}:{kind:`unavailable`})})):void 0,[i,r]);let s=a.kind===`ready`?a.browser:null,c=qD({sessionId:r?.sessionId??null,credentials:s?i:null,displayName:t,sessionToken:r?.token,collaborationRole:r?.role??`viewer`,enabled:s!==null,webrtcProducerSupported:s?.media.mode===`auto`&&s.media.webrtcProducer,webrtcIceServers:s?.media.iceServers??sO,onNotice:n});return{status:r?a.kind:`invalid`,share:r,browser:s,control:c}}export{g as C,c as D,o as E,la as S,f as T,gd as _,tD as a,_d as b,uE as c,fE as d,Ed as f,gf as g,lf as h,nD as i,cE as l,B as m,aO as n,qE as o,Md as p,DD as r,TE as s,cO as t,dE as u,z as v,m as w,ad as x,hd as y};
|
|
22
|
+
`);n=gh(e)??dh(Rm(e.ast),e);break;default:n=sh(e);break}return t?`${n}\n at ${t}`:n}function gh(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return gh(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function _h(e){let t;for(let n of e.reasons){if(!Ou(n)||!Gm(n.error))return;t??=n.error}return t}function vh(e,t){let n=_h(e);if(n===void 0)throw Error(t,{cause:e});return n}var yh=e=>Object.assign(Object.create(v),e),bh=yh({_tag:`Passthrough`});function xh(){return bh}function Sh(e){return yh({_tag:`Transform`,transform:e})}function Ch(e){return yh({_tag:`TransformEffect`,transform:e})}function wh(e){return yh({_tag:`TransformOptional`,transform:e})}function Th(e){return yh({_tag:`TransformOptionalEffect`,transform:e})}function Eh(){return wh(()=>er())}function Dh(e){return Th(t=>{let n=lr(t,E);return rr(n)?R(n):Tf(e,tr)})}function Oh(){return Sh(globalThis.String)}function kh(){return Sh(globalThis.Number)}function Ah(e){return Ch((t,n)=>Cd({try:()=>JSON.parse(t,e?.reviver),catch:()=>new th({expected:`a valid JSON string`},t,n)}))}function jh(e){return Ch((t,n)=>Cd({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new th({expected:`a JSON-serializable value`},t,n)}))}var Mh=class extends y{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Mh(this.encode,this.decode)}},Nh=`~effect/SchemaTransformation/Transformation`,Ph=class extends y{[Nh]=Nh;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Ph(this.encode,this.decode)}};function Fh(e){return D(e,Nh)&&e[Nh]===Nh}var Ih=e=>Fh(e)?e:new Ph(e.decode,e.encode);function Lh(e){return new Ph(Sh(e.decode),Sh(e.encode))}var Rh=new Ph(xh(),xh());function zh(){return Rh}var Bh=new Ph(kh(),Oh()),Vh=e=>pe(e)&&typeof e.message==`string`,Hh=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:Kh(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},Uh=e=>{try{let t=ut(e);return t===void 0?rt(e):JSON.parse(t)}catch{return rt(e)}},Wh=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},Gh=e=>{let t=new WeakSet,n=r=>{if(he(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=Wh(r,e,n);return t.delete(r),i}return Uh(r)};return n},Kh=e=>Vh(e)?Hh(e):e,qh=e=>Lh({decode:Kh,encode:Gh(e)});function Jh(e){return new Ph(Ah(e??{}),jh(e))}function Yh(e){return t=>t._tag===e}var Xh=Yh(`Declaration`),Zh=Yh(`Never`),Qh=Yh(`Literal`),$h=Yh(`UniqueSymbol`),eg=Yh(`Arrays`),tg=Yh(`Objects`),ng=Yh(`Suspend`),rg=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},ig={},ag=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},og=`~effect/Schema`,sg=class{[og]=og;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},cg=class extends sg{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>t===W?Bm:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(e,t,n,r,i){let a=O_(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new cg(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},lg=new class extends sg{_tag=`Null`;getParser(){return G_(this,null)}getExpected(){return`null`}},ug=class extends sg{_tag=`Undefined`;getParser(){return G_(this,void 0)}toCodecJson(){return g_(this,[dg])}getExpected(){return`undefined`}},dg=new rg(lg,new Ph(Sh(()=>void 0),Sh(()=>null))),fg=new ug,pg=new class extends sg{_tag=`Unknown`;getParser(){return K_(this,fe)}getExpected(){return`unknown`}},mg=class extends sg{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${rt(e)}`);this.literal=e}getParser(){return G_(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?hg(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:hg(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function hg(e){let t=globalThis.String(e.literal);return g_(e,[new rg(new mg(t),new Ph(Sh(()=>e.literal),Sh(()=>t)))])}var gg=new class extends sg{_tag=`String`;getParser(){return K_(this,oe)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&tv(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},_g=class extends sg{_tag=`Number`;getParser(){return K_(this,se)}matchKey(e,t){return this._match(X_,e,t)}matchPart(e,t){return this._match(Y_,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:tv(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(vg(this.checks,`effect/schema/isFinite`)||vg(this.checks,`effect/schema/isInt`))?this:g_(this,[d_])}toCodecStringTree(){return this.toCodecJson()===this?g_(this,[$_]):g_(this,[ev])}getExpected(){return`number`}};function vg(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&vg(e.checks,t))}var yg=new _g,bg=new class extends sg{_tag=`Boolean`;getParser(){return K_(this,ce)}getExpected(){return`boolean`}},xg=class extends sg{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(L_(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(L_(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}return Df(function*(e,c){if(e===W)return W;if(!Array.isArray(e))return yield*B(new eh(n,e,c));r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)})));let l=e.length,u={ast:n,getParser:s,input:e,len:l,tailThreshold:Math.max(a,l-o),output:new globalThis.Array(l),issues:void 0,options:c},d=n.rest.length===0?a:Math.max(l,a+o),f=c.concurrency===void 0?1:Nc(c.concurrency),p=f===1?wg(u,e,0,d):Tg(u,e,{concurrency:f,end:d});if(p&&(yield*p),n.rest.length===0&&l>a)for(let t=a;t<=l-1;t++){let r=new Qm(n,e[t],c),i=new Xm([t],r);if(c.errors===`all`)u.issues?u.issues.push(i):u.issues=[i];else return yield*B(new $m(n,[i],e,c))}return u.issues?yield*B(new $m(n,u.issues,e,c)):u.output})}_rebuild(e,t,n){let r=O_(this.elements,e),i=O_(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new xg(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function Sg(e,t,n,r){if(n._tag===`Failure`)return Eg(e,e.ast,r,n);let i=n===Vm?t:n[A];if(i!==W)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(L_(t.ast))return;let n=new Xm([r],new Zm(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return zl(new $m(e.ast,[n],e.input,e.options))}}var Cg={onItem(e,t,n){let r=n<e.len?t:W;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:Sg},wg=Pc()(Cg),Tg=Ic()(Cg),Eg=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=_h(r.cause);if(i===void 0)return Rl(Mu(r.cause,r=>new $m(t,[new Xm([n],r)],e.input,e.options)));let a=new Xm([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return zl(new $m(t,[a],e.input,e.options))},Dg=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function Og(e,t,n=ig){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(q_(V_(t)))}var kg=class{name;type;constructor(e,t){this.name=e,this.type=t}};function Ag(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(Ag);default:return!1}}function jg(e){let t=v_(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(jg);default:return!1}}function Mg(e){return Ag(e)&&jg(e)}var Ng=class{parameter;type;constructor(e,t){if(!Mg(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,L_(t)&&!W_(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},Pg=class extends sg{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o;let s=new Set,c=[];for(let t of e){let e=t.name;s.has(e)?c.push(e):s.add(e)}if(c.length>0)throw Error(`Duplicate identifiers: ${JSON.stringify(c)}. ts(2300)`)}getParser(e,t=e){let n=this,r=[];for(let e of n.propertySignatures)r.push(typeof e.name==`number`?globalThis.String(e.name):e.name);let i=r.length,a=n.indexSignatures.length,o=i&&a?new Set(r):void 0;if(!i&&!a)return K_(n,de);let s,c,l=(e,t,r,a,s)=>{if(s._tag===`Failure`)return Eg(e,n,t,s)??Bl;let c=s===Vm?a:s[A];if(r!==W&&c!==W){if(i&&(o.has(t)||o.has(typeof r==`number`?globalThis.String(r):r)))return Bl;xt(e.out,r,c)}return Bl},u=(e,t,r,i)=>{if(!i){let n=r.parserKey(t,e.options);if(!as(n))return V(Od(n),n=>u(e,t,r,n));i=n}if(i._tag===`Failure`)return Eg(e,n,t,i)??Bl;let a=i===Vm?t:i[A],o=e.input[t],s=r.parserValue(o,e.options);return as(s)?l(e,t,a,o,s):V(Od(s),n=>l(e,t,a,o,n))},d=(e,t,n)=>{let r=e.input[t],i=n.parserValue(r,e.options);return as(i)?l(e,t,t,r,i):V(Od(i),n=>l(e,t,t,r,n))},f=a?Ic()({onItem:(e,[t,n])=>n.is.parameter===gg?d(e,t,n):u(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0,p=()=>(s||(s=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),c=a?n.indexSignatures.map(n=>({is:n,parserKey:e(q_(n.parameter)),parserValue:t(n.type)})):void 0),s),m=Df(function*(e,t){if(e===W)return W;if(!(typeof e==`object`&&e&&!Array.isArray(e)))return yield*B(new eh(n,e,t));p();let l=e,m={},h={ast:n,input:l,out:m,issues:void 0,options:t},g=t.errors===`all`,_=t.onExcessProperty===`error`,v=t.concurrency===void 0?1:Nc(t.concurrency),y=a&&_?n.indexSignatures.map(e=>Og(l,e.parameter,t)):void 0;if(_){o??=new Set(r);let i=y?new Set(o):o;if(y)for(let e of y)for(let t of e)i.add(t);let a=Reflect.ownKeys(l);for(let r=0;r<a.length;r++){let o=a[r];if(!i.has(o)){let r=new Qm(n,l[o],t),i=new Xm([o],r);if(g){h.issues?h.issues.push(i):h.issues=[i];continue}else return yield*B(new $m(n,[i],e,t))}}}if(i){let e=v===1?Lg(h,s):Rg(h,s,{concurrency:v});e&&(yield*e)}if(a&&v===1)for(let e=0;e<a;e++){let n=c[e],r=n.is.parameter===gg?d:u,i=y?.[e]??(n.is.parameter===gg?Object.keys(l):Og(l,n.is.parameter,t));for(let e=0;e<i.length;e++){let t=r(h,i[e],n);if(!as(t))yield*t;else if(t._tag===`Failure`)return yield*t}}else if(f){let e=Ki();for(let n=0;n<a;n++){let r=c[n],i=y?.[n]??(r.is.parameter===gg?Object.keys(l):Og(l,r.is.parameter,t));for(let t=0;t<i.length;t++)e.push([i[t],r])}let n=f(h,e,{concurrency:v});n&&(yield*n)}return h.issues?yield*B(new $m(n,h.issues,e,t)):m});if(a)return m;let h=(e,t,n)=>{let r=s[t];return V(Od(n),n=>{let i=Fg(e,r,n);if(i)return i;let a=()=>zm(e.out),o=Lg(e,s.slice(t+1));return o?Ef(o,a):a()})};return(e,t)=>{if(e===W)return Bm;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&Nc(t.concurrency)!==1)return m(e,t);if(!(typeof e==`object`&&e&&!Array.isArray(e)))return B(new eh(n,e,t));let r=p(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=Xg(i,s),l=c?i[s]:W,u=n.parser(l,t);if(!as(u))return h(o,e,u);if(u===Vm){c&&xt(a,s,l);continue}let d=Fg(o,n,u);if(d)return d}}catch(e){return Sd(e)}return zm(a)}}_rebuild(e,t,n,r){let i=O_(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new kg(t.name,n)}),a=O_(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new Ng(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new Pg(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function Fg(e,t,n){if(n._tag===`Failure`)return Eg(e,e.ast,t.name,n);if(n===Vm)return;let r=n[A];if(r!==W){xt(e.out,t.name,r);return}if(delete e.out[t.name],!L_(t.type)){let n=new Xm([t.name],new Zm(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}else return zl(new $m(e.ast,[n],e.input,e.options))}}var Ig={onItem(e,t){if(!Xg(e.input,t.name))return t.parser(W,e.options);let n=e.input[t.name];return xt(e.out,t.name,n),t.parser(n,e.options)},step:Fg},Lg=Pc()(Ig),Rg=Ic()(Ig);function zg(e,t){return e?t?[...e,...t]:e:t}function Bg(e,t,n){return new Pg(Reflect.ownKeys(e).map(t=>new kg(t,e[t].ast)),[],n,t)}function Vg(e){return e.ast}function Hg(e,t=void 0){return new xg(!1,e.map(e=>e.ast),[],void 0,t)}function Ug(e,t,n){return new e_(e.map(Vg),t,void 0,n)}function Wg(e){if(e.encoding)throw Error(`mutable does not support encodings`);return new xg(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}var Gg=w(e=>{for(;;){if(ng(e))return pg;let t=e.encoding;if(!t)return e.recur?.(Gg,x)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==x))return pg;e=t[t.length-1].to}});function Kg(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(Kg)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function qg(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[Im];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!L_(t)){if(Qh(t))return[{key:e.name,literal:t.literal}];if($h(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!L_(e)){if(Qh(e))return[{key:t,literal:e.literal}];if($h(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>qg(Gg(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return qg(e.thunk())}}var Jg=new WeakMap,Yg=Object.freeze([]),Xg=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function Zg(e){let t=Jg.get(e);if(t)return t;let n,r=0,i,a,o=!0;for(let t=0;t<e.length;t++){let s=e[t],c=Gg(s);if(Zh(c))continue;if(o)if(Qh(c)||$h(c)){a??=new Map;let e=Qh(c)?c.literal:c.symbol,t=a.get(e);t||a.set(e,t=[]),t.push(s)}else o=!1;let l=qg(c);if(l.length){n??=new Map,r++;for(let{key:e,literal:r}of l){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=Kg(c);for(let n of e)(i[n]??=[]).push(t)}}if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??Yg;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=i;for(let[t,n]of i)a.set(t,Object.freeze(Array.from(n,t=>e[t])));t=(t,n)=>{if(me(t)){let i=Xg(t,r)?t[r]:void 0;if(i!==void 0)return a.get(i)??Yg;if(n)return e}return Yg}}else if(n){let a;for(let e of n)(!a||e[1][0].size>a[1][0].size)&&e[1][1].size===r&&(a=e);t=(t,r)=>{let o=i?.[t===null?`null`:Array.isArray(t)?`array`:typeof t]??Yg;if(!me(t))return o.map(t=>e[t]);let s=new Set(o),c;if(a){let[n,[i]]=a,l=Xg(t,n),u=l?t[n]:void 0;if(l&&(!r||u!==void 0)){let t=i.get(u);if(!t)return o.map(t=>e[t]);for(let e of t)s.add(e);c=n}}if(c===void 0)for(let[e,[i,a]]of n){let n=Xg(t,e),o=n?t[e]:void 0;if(n&&(!r||o!==void 0)){let e=i.get(o);if(e)for(let t of e)s.add(t)}else if(r)for(let e of a)s.add(e)}for(let[e,[i,a]]of n){if(e===c)continue;let n=Xg(t,e),o=n?t[e]:void 0;if(n&&(!r||o!==void 0)){let e=i.get(o);for(let t of s)a.has(t)&&!e?.has(t)&&s.delete(t)}}return Array.from(s).sort((e,t)=>e-t).map(t=>e[t])}}else t=t=>(i?.[t===null?`null`:Array.isArray(t)?`array`:typeof t]??Yg).map(t=>e[t]).filter(Qg(t));return Jg.set(e,t),t}function Qg(e){return t=>{let n=Gg(t);return n._tag===`Literal`?n.literal===e:n._tag===`UniqueSymbol`?n.symbol===e:!0}}function $g(e,t,n=!1){return Zg(t)(e,n)}var e_=class extends sg{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this;return(r,i)=>{if(r===W)return Bm;let a=$g(r,n.types,t!==void 0);if(a.length===0)return B(new nh(n,[],r,i));if(a.length===1){let t=e(a[0])(r,i);return t._tag===`Success`?t:as(t)?t_(n,t.cause,r,i):Fd(t,e=>t_(n,e,r,i))}let o={ast:n,compile:e,input:r,out:void 0,successes:n.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},s=n_(o,a);return s?Ef(s,e=>o.out===Vm?R(r):o.out?o.out:B(new nh(n,o.issues??[],r,i))):o.out?o.out:B(new nh(n,o.issues??[],r,i))}}_rebuild(e,t,n){let r=O_(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new e_(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=V_(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(Qh);if(t.length>0)return`${i_(n.isMutable)}[ ${t.map(t=>e(t)+a_(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>Qh(e.type));if(t.length>0)return`{ ${t.map(t=>`${i_(t.type.context?.isMutable)}${at(t.name)}${a_(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function t_(e,t,n,r){let i=_h(t);return i?zl(new nh(e,[i],n,r)):Rl(t)}var n_=Pc()({onItem(e,t){return e.compile(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=_h(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(t),zl(new rh(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(t);else return Bl}}}),r_=new e_([new mg(`Infinity`),new mg(`-Infinity`),new mg(`NaN`)]);function i_(e){return e?``:`readonly `}function a_(e){return e?`?`:``}var o_=class extends sg{_tag=`Suspend`;thunk;constructor(e,t,n,r,i){if(n)throw Error(`Cannot add checks to Suspend`);super(t,void 0,r,i);let a;this.thunk=()=>a??=e()}getParser(e){let t;return(n,r)=>(t??=e(this.thunk()))(n,r)}recur(e){return new o_(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}},s_=class extends y{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new s_(this.run,{...this.annotations,...e},this.aborted)}abort(){return new s_(this.run,this.annotations,!0)}and(e,t){return new c_([this,e],t)}},c_=class extends y{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new c_(this.checks,{...this.annotations,...e})}and(e,t){return new c_([this,e],t)}};function l_(e,t,n=!1){return new s_((t,n,r)=>oh(n,e(t,n,r),t,r),t,n)}function u_(e){return l_(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}var d_=new rg(new e_([x_(yg,[u_()]),r_]),new Ph(kh(),Sh(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function f_(e,t){let n=e.source,r=new globalThis.RegExp(n,e.flags);return l_(e=>(r.lastIndex=0,r.test(e)),{expected:`a string matching the RegExp ${n}`,representation:{id:`effect/schema/isPattern`,payload:{source:n,flags:e.flags}},toJsonSchema:()=>({pattern:n}),arbitraryConstraint:{patterns:[{source:e.source,flags:e.flags}]},...t})}function p_(e,t){let n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}var m_=new WeakMap;function h_(e){return m_.get(e)??e}function g_(e,t){return e.encoding===t?e:p_(e,e=>{e.encoding.value=t})}function __(e,t){if(e.context===t)return e;let n=h_(e);if(n.context===t)return n;let r=p_(e,e=>{e.context.value=t});return m_.set(r,n),r}function v_(e){return e.encoding?v_(e.encoding[e.encoding.length-1].to):e}function y_(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return b_(e,Hi(e.checks.slice(0,-1),n.annotate(t)))}return p_(e,e=>{e.annotations.value={...e.annotations.value,...t}})}function b_(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:p_(e,e=>{e.checks.value=t})}function x_(e,t){return b_(e,zg(e.checks,t))}function S_(e,t){let n=t(e.to);return n===e.to?e:new rg(n,e.transformation)}function C_(e,t){let n=e,r=n[n.length-1],i=S_(r,t);return i===r?e:Hi(e.slice(0,e.length-1),i)}function w_(e){return t=>t.encoding?g_(t,C_(t.encoding,e)):t}function T_(e,t){return w_(e=>__(e,t))(e)}function E_(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:g_(r,C_(r.encoding,n))}return e(r)}return w(n)}function D_(e,t,n){let r=new rg(e,t);return g_(n,n.encoding?[...n.encoding,r]:[r])}function O_(e,t){let n=!1,r=Array(e.length);for(let i=0;i<e.length;i++){let a=e[i],o=t(a);o!==a&&(n=!0),r[i]=o}return n?r:e}function k_(e,t){return __(e,e.context?new ag(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new ag(!1,!1,void 0,t))}var A_=w(e=>j_(__(e,e.context?e.context.isOptional===!1?new ag(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new ag(!0,!1)))),j_=w_(A_),M_=re(e=>A_(new e_([e,fg])));function N_(e,t){return __(e,e.context?new ag(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new ag(!1,!1,t))}function P_(e,t,n){return D_(e,n,t)}function F_(e){let t=[],n=[];function r(e){switch(e._tag){case`Literal`:ue(e.literal)&&t.push(e.literal);return;case`UniqueSymbol`:t.push(e.symbol);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)r(e.types[t]);return;default:n.push(e)}}return r(e),{literals:t,parameters:n}}function I_(e,t){let{literals:n,parameters:r}=F_(e);return new Pg(n.map(e=>new kg(e,t)),r.map(e=>new Ng(e,t)))}function L_(e){return e.context?.isOptional??!1}function R_(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(R_)}function z_(e){function t(e){return R_(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Ui(n)?n:void 0}var B_=w(e=>{if(e.encoding)return B_(g_(e,void 0));let t=e,n=t.recur?.(B_)??t,r=n.encodingChecks;if(r){let t=n===e?r:eg(n)||tg(n)||Xh(n)&&n.typeParameters.length>0?z_(r):void 0;return p_(n,e=>{e.encodingChecks.value=void 0,e.checks.value=zg(n.checks,t)})}return n}),V_=w(e=>B_(U_(e)));function H_(e,t){let n=t,r=n.length,i=n[r-1],a=[new rg(U_(g_(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new rg(U_(n[e-1].to),n[e].transformation.flip()));let o=U_(i.to);return o.encoding?g_(o,[...o.encoding,...a]):g_(o,a)}var U_=re(e=>{if(e.encoding)return H_(e,e.encoding);let t=e;return t.flip?.(U_)??t.recur?.(U_)??t});function W_(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(W_);default:return!1}}function G_(e,t){let n=t===0?Vm:zm(t);return(r,i)=>r===W?Bm:r===t?n:B(new eh(e,r,i))}function K_(e,t){return(n,r)=>n===W?Bm:t(n)?Vm:B(new eh(e,n,r))}var q_=E_(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(q_)}}),J_=E_(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(J_)}}),Y_=new globalThis.RegExp(`^${Dg}$`),X_=new globalThis.RegExp(`^(?:${Dg}|Infinity|-Infinity|NaN)$`);function Z_(e){return f_(Y_,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:Y_.source}),...e})}var Q_=x_(gg,[Z_()]),$_=new rg(Q_,Bh),ev=new rg(new e_([Q_,r_]),Bh);function tv(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=tv(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new Jm(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function nv(e){if(!Xh(e))return;let t=e.annotations?.[Lm];return T(t)?t(e.typeParameters):void 0}function rv(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function iv(e){return e===void 0||typeof e==`string`}function av(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function ov(e){return av(e,rv)}var sv=new cg([],()=>(e,t,n)=>ov(e)?Vm:B(new eh(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>dv}),cv=new rg(sv,zh()),lv=new rg(new e_([new xg(!1,[],[sv]),new Pg([],[new Ng(gg,sv)])]),zh());function uv(e){return av(e,iv)}var dv=new rg(new cg([],()=>(e,t,n)=>uv(e)?Vm:B(new eh(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),zh()),fv=(e,t,n)=>e===Vm?n(t):Ef(e,n);function pv(e){if(e._tag===`Middleware`)return(t,n,r)=>mv(t===Vm?e.decode(zm(Hm(n)),r):e.decode(Tf(t,Hm),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===Vm?zm(t):e;case`Transform`:{let e=e=>e===W?Bm:zm(t.transform(e));return(t,n)=>fv(t,n,e)}case`TransformOptional`:{let e=e=>Um(t.transform(Hm(e)));return(t,n)=>fv(t,n,e)}case`TransformEffect`:return(e,n,r)=>fv(e,n,e=>e===W?Bm:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>fv(e,n,e=>mv(t.transform(Hm(e),r)))}}var mv=e=>Ef(e,Um),hv=(e,t,n,r)=>Fd(r,r=>xd(()=>Mu(r,r=>new Ym(e,r,t,n))));function gv(e,t){let n=pv(e.link.transformation),r;return(i,a)=>{if(i===W)return Bm;if(e.isConstructed(i))return Vm;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function _v(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==W&&r!==void 0)return t(r,i);let a=n;if(as(a)&&a._tag===`Success`){let e=t(a[A],i);return e===Vm?a:e}return Ef(hv(e,r,i,a),e=>{let n=t(e,i);return n===Vm?zm(e):n})}}function vv(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:_v(e,n)}function yv(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?nv(e):void 0,o=a?gv(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>pv(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);if(u&&!n.disableChecks)if(as(r)){if(r._tag===`Success`){let i=r===Vm?t:r[A];if(t!==W&&i!==W){let i=tv(u,t,void 0,e,n);i&&(r=B(new $m(e,i,t,n)))}}}else r=V(r,r=>{if(t!==W&&r!==W){let r=tv(u,t,void 0,e,n);if(r)return B(new $m(e,r,t,n))}return R(r)});if(s&&!n.disableChecks)if(as(r)){if(r._tag===`Success`){let i=r===Vm?t:r[A];if(i===W)return r;let a=tv(s,i,void 0,e,n);a&&(r=B(new $m(e,a,i,n)))}}else r=V(r,t=>{if(t!==W){let r=tv(s,t,void 0,e,n);if(r)return B(new $m(e,r,t,n))}return R(t)});return r},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[A],o=t(a,r)):o=Ef(o,e=>{let n=t(e,r);return n===Vm?zm(e):n})}if(o._tag===`Success`){let e=o[A],t=p(e,r);return t===Vm?o:t}return o=hv(e,n,r,o),Ef(o,e=>{let t=p(e,r);return t===Vm?zm(e):t})}:p}var bv=Symbol(),xv=new WeakMap,Sv,Cv=e=>Av(e).parser,wv=e=>Av(e).makeEffect,Tv=e=>vv(e,wv),Ev=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=yv(this.ast,Cv)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=yv(this.ast,wv,Tv)}},Dv=class extends Ev{compiled;resolve;constructor(e,t,n){super(e),this.compiled=t,this.resolve=n}save(e,t){return Object.defineProperty(this,e,{value:t}),t}operation(e){let t=this.compiled;return typeof t==`function`?t(this.ast,this.resolve,e):t?.[e]}get is(){return this.save(`is`,this.operation(`is`))}get decode(){return this.save(`decode`,this.operation(`decode`))}get make(){return this.save(`make`,this.operation(`make`))}get decodeEffect(){return this.save(`decodeEffect`,this.operation(`decodeEffect`)??yv(this.ast,e=>kv(this.resolve,e,`parser`)))}get parser(){let e=this.decode;return e===void 0?this.decodeEffect:this.save(`parser`,Ov(e,()=>this.decodeEffect))}get makeEffect(){let e=this.operation(`makeEffect`);if(e!==void 0)return this.save(`makeEffect`,e);let t=e=>kv(this.resolve,e,`makeEffect`);return this.save(`makeEffect`,yv(this.ast,t,e=>vv(e,t)))}};function Ov(e,t){let n;return(r,i)=>{if(r!==W)try{let t=e(r,i);if(t!==bv)return t===r?Vm:zm(t)}catch(e){return Sd(e)}return(n??=t())(r,i)}}function kv(e,t,n){let r=e(t);if(r.compiled===void 0||Object.hasOwn(r,n))return r[n];let i;return(e,t)=>(i??=r[n])(e,t)}function Av(e){let t=xv.get(e);if(t!==void 0)return t;let n=Sv===void 0?new Ev(e):new Dv(e,Sv(e,Av),Av);return xv.set(e,n),n}function jv(e){let t=e.ast,n;return(e,r)=>(n??=Bv(Kv,B_(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function Mv(e){let t=jv(e);return(e,n)=>{let r=Sf(t(e,n));return Vl(r)?tr(r.value):(vh(r.cause,`Option adapter can only return none for schema issues`),er())}}function Nv(e){return Wv(B_(e.ast))}function Pv(e,t){let n=Rv(e.ast);return t===void 0?n:(e,r)=>n(e,Iv(t,r))}function Fv(e,t){return Hv(Pv(e,t))}var Iv=(e,t)=>t?{...e,...t}:e,Lv=e=>e===W?B(new th):R(e);function Rv(e){return Bv(Gv,e)}function zv(e,t){return e===Vm?R(t):as(e)?e[A]===W?Lv(W):e:Ef(e,Lv)}function Bv(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??ig);return a===Vm?R(r):as(a)?a[A]===W?Lv(W):a:Ef(a,Lv)}}function Vv(e){return(t,n)=>Sf(e(t,n))}function Hv(e){let t=Vv(e);return(e,n)=>{let r=t(e,n);return Vl(r)?tr(r.value):(vh(r.cause,`Option adapter can only return none for schema issues`),er())}}function Uv(e,t){let n=Sf(e);if(Vl(n))return n.value;let r=vh(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}function Wv(e){let t,n;return(r,i)=>{t??=Av(e);let a=i?.disableChecks?i.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions??ig,o=t.make;if(o!==void 0&&r!==W){let e;try{e=o(r,a)}catch(e){throw vh(Au(e),`Constructor adapter can only throw schema issues`),e}if(e!==bv&&e!==W)return e}return Uv(zv((n??=t.makeEffect)(r,a),r),`Constructor adapter can only throw schema issues`)}}var Gv=e=>Av(e).parser,Kv=e=>Av(e).makeEffect,qv=`~effect/Schema/Schema`,Jv={[qv]:qv,pipe(){return _(this,arguments)},annotate(e){return this.rebuild(y_(this.ast,e))},annotateKey(e){return this.rebuild(k_(this.ast,e))},check(...e){return this.rebuild(x_(this.ast,e))}};function Yv(e,t){function n(){}let r=Object.setPrototypeOf(n,Jv);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r.ast=e,r.rebuild=e=>Yv(e,t),r.makeEffect=jv(r),r.make=Nv(r),r.makeOption=Mv(r),r}function Xv(e){return Yv(Zv(e.ast),{schema:e})}var Zv=E_(e=>{let t=ny(e,Zv),n=e.context;return t===e||n===void 0?t:T_(t,Qv(n))});function Qv(e){return e.constructorDefault===void 0?e:new ag(e.isOptional,e.isMutable,void 0,e.annotations)}function $v(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function ey(e){return t=>{let n=new Map;for(let e=0;e<t.length;e++)n.set(V_(t[e]),e);let r=[...t].sort((t,r)=>{t=V_(t),r=V_(r);let i=e(t),a=e(r);return i===a?n.get(t)-n.get(r):i-a});return r.some((e,n)=>e!==t[n])?r:t}}var ty=ey(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function ny(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!T(n))return g_(e,[cv]);let r=n(e.typeParameters.map(e=>Yv(V_(e))));return r===void 0?e:g_(e,[S_(r,t)])}case`Unknown`:return g_(e,[cv]);case`ObjectKeyword`:return g_(e,[lv]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return $v(e),e.recur(t,J_);case`Union`:{let n=ty(e.types);return n===e.types?e.recur(t):new e_(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var ry=e=>e,iy=`~effect/Schema/SchemaError`,ay=new WeakMap,oy=e=>{if(ay.has(e))return ay.get(e);throw Error(`Unable to get redacted value`+(e.label?` with label: "${e.label}"`:``))},sy=e=>typeof e==`string`?e:oy(e),cy=`~effect/Redacted`,ly=e=>D(e,cy),uy=(e,t)=>{let n=Object.create(dy);return t?.label&&(n.label=t.label),ay.set(n,e),n},dy={[cy]:{_A:e=>e},label:void 0,...jt,toJSON(){return this.toString()},toString(){return`<redacted${oe(this.label)?`:`+this.label:``}>`},[ge](){return k(ay.get(this))},[Ne](e){return ly(e)&&Pe(ay.get(this),ay.get(e))}},fy=`~effect/http/Cookies`,py=`~effect/http/Cookies/Cookie`;la(`CookiesError`);var my={[fy]:fy,...mt,toJSON(){return{_id:`effect/Cookies`,cookies:Ii(this.cookies,e=>e.toJSON())}},pipe(){return _(this,arguments)}},hy=e=>{let t=Object.create(my);return t.cookies=e,t},gy=e=>{let t={};for(let n of e)xt(t,n.name,n);return hy(t)},_y=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=vy(e.trim());t&&n.push(t)}return gy(n)};function vy(e){let t=e.split(`;`).map(e=>e.trim()).filter(e=>e!==``);if(t.length===0)return;let n=t[0].indexOf(`=`);if(n===-1)return;let r=t[0].slice(0,n);if(!yy.test(r))return;let i=t[0].slice(n+1),a=xy(i);if(t.length===1)return Object.assign(Object.create(by),{name:r,value:a,valueEncoded:i});let o={};for(let e=1;e<t.length;e++){let n=t[e],r=n.indexOf(`=`),i=r===-1?n:n.slice(0,r).trim(),a=r===-1?void 0:n.slice(r+1).trim();switch(i.toLowerCase()){case`domain`:{if(a===void 0)break;let e=a.trim().replace(/^\./,``);e&&(o.domain=e);break}case`expires`:{if(a===void 0)break;let e=new Date(a);isNaN(e.getTime())||(o.expires=e);break}case`max-age`:{if(a===void 0)break;let e=parseInt(a,10);isNaN(e)||(o.maxAge=pi(e));break}case`path`:if(a===void 0)break;a[0]===`/`&&(o.path=a);break;case`priority`:if(a===void 0)break;switch(a.toLowerCase()){case`low`:o.priority=`low`;break;case`medium`:o.priority=`medium`;break;case`high`:o.priority=`high`;break}break;case`httponly`:o.httpOnly=!0;break;case`secure`:o.secure=!0;break;case`partitioned`:o.partitioned=!0;break;case`samesite`:if(a===void 0)break;switch(a.toLowerCase()){case`lax`:o.sameSite=`lax`;break;case`strict`:o.sameSite=`strict`;break;case`none`:o.sameSite=`none`;break}break}}return Object.assign(Object.create(by),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var yy=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,by={[py]:py,...mt,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},xy=e=>{try{return decodeURIComponent(e)}catch{return e}},Sy=Symbol.for(`~effect/http/Headers`),Cy=Object.defineProperties(Object.create(null),{[Sy]:{value:Sy},[Xe]:{value(e){return Ny(this,Lr(e,Fy))}},toJSON:{value(){return Qe(this)}},[Ne]:{value(e){return Ty(this,e)}},[ge]:{value(){return we(this)}},toString:{value:mt.toString},[dt]:{value:mt[dt]}}),wy=e=>Object.assign(Object.create(Cy),e),Ty=zi(Sn()),Ey=Object.create(Cy),Dy=e=>{if(e===void 0)return Ey;if(Symbol.iterator in e){let t=Object.create(Cy);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(Cy);for(let[n,r]of Object.entries(e))Array.isArray(r)?t[n.toLowerCase()]=r.join(`, `):r!==void 0&&(t[n.toLowerCase()]=r);return t},Oy=e=>Object.setPrototypeOf(e,Cy),ky=b(3,(e,t,n)=>{let r=wy(e);return r[t.toLowerCase()]=n,r}),Ay=b(2,(e,t)=>wy({...e,...Dy(t)})),jy=b(2,(e,t)=>{let n=wy(e);return Object.assign(n,t),n}),My=b(2,(e,t)=>{let n=wy(e);return delete n[t.toLowerCase()],n}),Ny=b(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=uy(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=uy(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),Py=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(typeof r==`string`){if(r.toLowerCase()===e.toLowerCase())return!0}else if(e.search(r)!==-1)return!0}return!1},Fy=Ur(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),Iy=`~effect/http/UrlParams`,Ly=e=>D(e,Iy),Ry={...jt,[Iy]:Iy,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:`UrlParams`,params:Object.fromEntries(this.params)}},[Ne](e){return Hy(this,e)},[ge](){return Ee(this.params.flat())}},zy=e=>{let t=Object.create(Ry);return t.params=e,t},By=e=>{if(Ly(e))return e;let t=Vy(e),n=[];for(let e=0;e<t.length;e++)if(Array.isArray(t[e][0])){let[r,i]=t[e];n.push([`${r[0]}[${r.slice(1).join(`][`)}]`,i])}else n.push(t[e]);return zy(n)},Vy=e=>{let t=typeof e[Symbol.iterator]==`function`?Vi(e):Object.entries(e),n=[];for(let[e,r]of t)if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]!==void 0&&n.push([e,String(r[t])]);else if(typeof r==`object`&&r){let t=Vy(r);for(let[r,i]of t)n.push([[e,...typeof r==`string`?[r]:r],i])}else r!==void 0&&n.push([e,String(r)]);return n},Hy=bn((e,t)=>Uy(e.params,t.params)),Uy=Yi(ji([Sn(),Sn()])),Wy=zy([]),Gy=b(2,(e,t)=>{let n=By(t).params.slice(),r=new Set;for(let e=0;e<n.length;e++)r.add(n[e][0]);for(let t=0;t<e.params.length;t++)r.has(e.params[t][0])||n.push(e.params[t]);return zy(n)}),Ky=qv,qy=class extends la(`SchemaError`){[iy]=iy;constructor(e){let t=_t();vt(0);try{super({issue:e})}finally{vt(t)}}get message(){return mh(this.issue)}toString(){return`SchemaError(${this.message})`}};function Jy(e){return as(e)?Yy(e):Fd(e,e=>xd(()=>Mu(e,e=>new qy(e))))}function Yy(e){return Vl(e)?e:Rl(Mu(e.cause,e=>new qy(e)))}function Xy(e,t){let n=Pv(e,t);return(e,t)=>Jy(n(e,t))}var Zy=Xy,Qy=Fv,$y=Yv;function eb(e){return D(e,Ky)&&e[Ky]===Ky}var G=ry(e=>$y(A_(e.ast),{schema:e})),tb=ry(e=>{let t=hb(e);return $y(M_(e.ast),{schema:t})}),nb=ry(e=>$y(V_(e.ast),{schema:e}));function rb(e){let t=$y(new mg(e),{literal:e,transform(n){return t.pipe(_b(rb(n),{decode:Sh(()=>n),encode:Sh(()=>e)}))}});return t}var ib=$y(pg),ab=$y(lg),ob=$y(fg),K=$y(gg),q=$y(yg),sb=$y(bg);function cb(e,t){return $y(e,{fields:t,mapFields(e,t){let n=e(this.fields);return cb(Bg(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function J(e){return cb(Bg(e,void 0),e)}function lb(e,t){return $y(I_(e.ast,t.ast),{key:e,value:t})}function ub(e,t){return $y(e,{elements:t,mapElements(e,t){let n=e(this.elements);return ub(Hg(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}var Y=ry(e=>$y(new xg(!1,[],[e.ast]),{value:e})),db=ry(e=>$y(Wg(e.ast),{schema:e}));function fb(e,t){return $y(e,{members:t,mapMembers(e,t){let n=e(this.members);return fb(Ug(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function pb(e,t){return fb(Ug(e,t,void 0),e)}function X(e){let t=e.map(rb);return $y(Ug(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return pb(e(this.members))},pick(e){return X(e)},transform(e){return pb(t.map((t,n)=>t.transform(e[n])))}})}var mb=ry(e=>pb([e,ab])),hb=ry(e=>pb([e,ob]));function gb(e){return $y(new o_(()=>e().ast))}function _b(e,t){return n=>$y(P_(n.ast,e.ast,t?Ih(t):zh()),{from:n,to:e})}function vb(e){return t=>$y(N_(t.ast,e),{schema:t})}function yb(e){return Fd(e,e=>xd(()=>Mu(e,e=>e.issue)))}function bb(e,t){let n=t?.encodingStrategy===`omit`?Eh():xh();return t=>G(nb(t)).pipe(_b(t,{decode:Dh(yb(e)),encode:n}))}function xb(e){return rb(e).pipe(vb(R(e)))}function Sb(e,t){return J({_tag:xb(e),...t})}var Cb=l_;function wb(e,t){let n=e.source,r=e.flags,i=r===``?`new RegExp(${rt(n)})`:`new RegExp(${rt(n)}, ${rt(r)})`;return f_(e,{toCode:()=>({runtime:`Schema.isPattern(${i})`}),...t})}var Tb=u_;function Eb(e){let t=Zn(e.order),n=e.formatter??rt;return(r,i)=>Cb(e=>t(e,r),{expected:`a value greater than ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r,exclusiveMinimum:!0},...e.annotate?.(r),...i})}function Db(e){let t=$n(e.order),n=e.formatter??rt;return(r,i)=>Cb(e=>t(e,r),{expected:`a value greater than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r},...e.annotate?.(r),...i})}function Ob(e){let t=Qn(e.order),n=e.formatter??rt;return(r,i)=>Cb(e=>t(e,r),{expected:`a value less than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,maximum:r},...e.annotate?.(r),...i})}function kb(e){let t=$n(e.order),n=Zn(e.order),r=Qn(e.order),i=Xn(e.order),a=e.formatter??rt;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return Cb(e=>c(e,o.minimum)&&l(e,o.maximum),{expected:`a value between ${a(o.minimum)}${o.exclusiveMinimum?` (excluded)`:``} and ${a(o.maximum)}${o.exclusiveMaximum?` (excluded)`:``}`,arbitraryConstraint:{order:e.order,minimum:o.minimum,maximum:o.maximum,...o.exclusiveMinimum&&{exclusiveMinimum:!0},...o.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(o),...s})}}function Ab(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${rt(e)}`);return e}var jb=Eb({order:Jn,annotate:e=>({representation:{id:`effect/schema/isGreaterThan`,payload:{exclusiveMinimum:Ab(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${rt(e)})`})})}),Mb=Db({order:Jn,annotate:e=>({representation:{id:`effect/schema/isGreaterThanOrEqualTo`,payload:{minimum:Ab(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${rt(e)})`})})}),Nb=Ob({order:Jn,annotate:e=>({representation:{id:`effect/schema/isLessThanOrEqualTo`,payload:{maximum:Ab(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${rt(e)})`})})}),Pb=kb({order:Jn,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:Ab(e.minimum),maximum:Ab(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${rt(e.minimum)}, maximum: ${rt(e.maximum)}, exclusiveMinimum: ${rt(t)}, exclusiveMaximum: ${rt(n)} })`})}}});function Fb(e){return Cb(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>({type:`integer`}),toCode:()=>({runtime:`Schema.isInt()`}),arbitraryConstraint:{number:`integer`},...e})}function Ib(e,t){return e=Math.max(0,Math.floor(e)),Cb(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:`effect/schema/isMinLength`,payload:{minLength:e}},toJsonSchema:({type:t})=>t===`array`?{minItems:e}:{minLength:e},toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[Fm]:!0,arbitraryConstraint:{minLength:e},...t})}function Lb(e,t){return e=Math.max(0,Math.floor(e)),Cb(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:`effect/schema/isMaxLength`,payload:{maxLength:e}},toJsonSchema:({type:t})=>t===`array`?{maxItems:e}:{maxLength:e},toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[Fm]:!0,arbitraryConstraint:{maxLength:e},...t})}function Rb(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),Cb(n=>n.length>=e&&n.length<=t,{expected:e===t?`a value with a length of ${e}`:`a value with a length between ${e} and ${t}`,representation:{id:`effect/schema/isLengthBetween`,payload:{minimum:e,maximum:t}},toJsonSchema:({type:n})=>n===`array`?{allOf:[{minItems:e},{maxItems:t}]}:{allOf:[{minLength:e},{maxLength:t}]},toCode:()=>({runtime:`Schema.isLengthBetween(${e}, ${t})`}),[Fm]:!0,arbitraryConstraint:{minLength:e,maxLength:t},...n})}function zb(e){return Cb(e=>Xi(e).length===e.length,{expected:`an array with unique items`,representation:{id:`effect/schema/isUnique`,payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:`Schema.isUnique()`}),arbitraryConstraint:{uniqueBy:x},...e})}var Bb=e=>e?.includeStack===!0|(e?.excludeCause===!0?2:0),Vb=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},Hb=[];function Ub(e){let t=Bb(e),n=Hb[t];if(n!==void 0)return n;let r=nx.pipe(_b(ib,qh(Vb(t))));return Hb[t]=r,r}globalThis.RegExp,globalThis.URL;var Wb=K.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function Gb(e,t){return Wb.pipe(_b(e,Jh(t)))}globalThis.File,globalThis.FormData,globalThis.URLSearchParams,globalThis.Uint8Array;var Kb=globalThis.Symbol.for(`immer-draftable`),qb={};function Jb(e,t,n,r,i){let a=Zb(n,t,r),o=Xb(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===qb?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:qb,value:i}})}static[Ky]=Ky;get[o](){return o}static[Kb]=!0;static identifier=t;static fields=n.fields;static get ast(){return a(this).ast}static pipe(){return _(this,arguments)}static rebuild(e){return a(this).rebuild(e)}static make(e,t){return Nv(a(this))(e??{},t)}static makeOption(e,t){return Mv(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(y_(this.ast,e))}static annotateKey(e){return this.rebuild(k_(this.ast,e))}static check(...e){return this.rebuild(x_(this.ast,e))}static extend(e){return(t,r)=>{let a=Qb(t)?t:J(t),o={...n.fields,...a.fields},s=Bg(o,n.ast.checks,{identifier:e});return Jb(this,e,cb(x_(s,a.ast.checks),o),r,i)}}static mapFields(e,t){return n.mapFields(e,t)}};return i!==void 0&&Object.assign(s.prototype,i(t)),s}function Yb(e){return new Ph(Sh(t=>new e(t,{"~payload":{token:qb,value:t}})),xh())}function Xb(e){return`~effect/Schema/Class/${e}`}function Zb(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=Xb(t),o=e=>e instanceof i||D(e,a),s=Yb(i);return r=_b($y(new cg([e.ast],()=>(e,t,n)=>o(e)?R(e):B(new eh(t,e,n)),{identifier:t,[Lm]:([e])=>({isConstructed:o,link:new rg(e,s)}),toCodec:([e])=>new rg(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[Im]:qg(e.ast),...n})),s)(e)}}function Qb(e){return eb(e)}var $b=e=>(t,n)=>Jb(dn,e,Qb(t)?t:J(t),n,e=>({name:e})),ex=e=>(t,n,r)=>{let i=Qb(n)?n.mapFields(e=>({_tag:xb(t),...e}),{unsafePreserveChecks:!0}):Sb(t,n);return $b(e??t)(i,r)},tx=Xv,nx=$y(y_(sv,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),rx=`~effect/http/HttpBody`;la(`HttpBodyError`);var ix=class{[rx];constructor(){this[rx]=rx}[dt](){return this.toJSON()}toString(){return rt(this,{ignoreToString:!0})}},ax=new class extends ix{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},ox=class extends ix{_tag=`Uint8Array`;contentType;contentLength;text;_body;constructor(e,t,n,r){super(),this._body=e,this.text=r,this.contentType=t,this.contentLength=n}get body(){return this._body??=lx(this.text)}toJSON(){return{_id:`effect/HttpBody`,_tag:`Uint8Array`,body:this.contentType.startsWith(`text/`)||this.contentType.endsWith(`json`)?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},sx=new TextEncoder,cx=globalThis.Buffer,lx=cx===void 0?e=>sx.encode(e):e=>cx.from(e,`utf8`),ux=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),cx!==void 0)return new ox(void 0,t??`text/plain`,cx.byteLength(e,`utf8`),e);let n=sx.encode(e);return new ox(n,t??`text/plain`,n.length,e)},dx=(e,t)=>ux(JSON.stringify(e),t??`application/json`),fx=`~effect/http/HttpClientError`,px=class extends la(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[fx]=fx;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},mx=e=>e.endsWith(`Error`)?e.slice(0,-5):e,hx=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,gx=class extends la(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return hx(mx(this._tag),this.description,this.methodAndUrl)}};la(`EncodeError`);var _x=class extends la(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return hx(mx(this._tag),this.description,this.methodAndUrl)}},vx=class extends la(`StatusCodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return hx(mx(this._tag),this.description,e)}},yx=class extends la(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return hx(mx(this._tag),this.description,e)}},bx=class extends la(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return hx(mx(this._tag),this.description,e)}};$b(fx)({_tag:xb(`HttpError`),kind:X([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:tb(Ub())});var xx=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],Sx=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?My(My(e,`content-type`),`content-length`):(e=t.contentType===void 0?My(e,`content-type`):ky(e,`content-type`,t.contentType),t.contentLength===void 0?My(e,`content-length`):ky(e,`content-length`,t.contentLength.toString())),Cx=class extends la(`UrlError`){},wx=(e,t,n)=>Oi({try:()=>{let r=new URL(e,Tx());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,i)}return n!==void 0&&(r.hash=n),r},catch:e=>new Cx({cause:e})}),Tx=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},Ex=`~effect/http/HttpClientRequest`,Dx={[Ex]:Ex,...mt,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Qe(this.headers),body:this.body.toJSON()}},pipe(){return _(this,arguments)}};function Ox(e,t,n,r,i,a){let o=Object.create(Dx);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var kx=Ox(`GET`,``,Wy,er(),Ey,ax),Ax=e=>(t,n)=>Ix(kx,{method:e,url:t,...n??void 0}),jx=Ax(`GET`),Mx=Ax(`POST`),Nx=Ax(`PATCH`),Px=Ax(`PUT`),Fx=Ax(`DELETE`),Ix=b(2,(e,t)=>{let n=e;return t.method&&(n=Lx(n,t.method)),t.url&&(n=Gx(n,t.url)),t.headers&&(n=zx(n,t.headers)),t.urlParams&&(n=Jx(n,t.urlParams)),t.hash&&(n=Yx(n,t.hash)),t.body&&(n=Xx(n,t.body)),t.accept&&(n=Ux(n,t.accept)),t.acceptJson&&(n=Wx(n)),n}),Lx=b(2,(e,t)=>Ox(t,e.url,e.urlParams,e.hash,e.headers,e.body)),Rx=b(3,(e,t,n)=>Ox(e.method,e.url,e.urlParams,e.hash,ky(e.headers,t,n),e.body)),zx=b(2,(e,t)=>Ox(e.method,e.url,e.urlParams,e.hash,Ay(e.headers,t),e.body)),Bx=b(2,(e,t)=>Ox(e.method,e.url,e.urlParams,e.hash,t(e.headers),e.body)),Vx=b(2,(e,t)=>Bx(e,My(t))),Hx=b(2,(e,t)=>Rx(e,`Authorization`,`Bearer ${sy(t)}`)),Ux=b(2,(e,t)=>Rx(e,`Accept`,t)),Wx=Ux(`application/json`),Gx=b(2,(e,t)=>{if(typeof t==`string`)return Ox(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=By(n.searchParams),i=or(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Ox(e.method,n.toString(),r,i,e.headers,e.body)}),Kx=b(2,(e,t)=>t===``?e:Ox(e.method,qx(t,e.url),e.urlParams,e.hash,e.headers,e.body)),qx=(e,t)=>{let n=e.endsWith(`/`),r=t.startsWith(`/`);return n&&r?e+t.slice(1):!n&&!r?e+`/`+t:e+t},Jx=b(2,(e,t)=>Ox(e.method,e.url,Gy(e.urlParams,t),e.hash,e.headers,e.body)),Yx=b(2,(e,t)=>Ox(e.method,e.url,e.urlParams,tr(t),e.headers,e.body)),Xx=b(2,(e,t)=>Ox(e.method,e.url,e.urlParams,e.hash,Sx(e.headers,t),t)),Zx=b(2,(e,t)=>Xx(e,dx(t)));function Qx(e){let t=wx(e.url,e.urlParams,sr(e.hash));return Ai(t)?tr(t.success):er()}var $x=`~effect/http/HttpIncomingMessage`,eS=(e,t)=>{let n=Zy(tx(e)),r=t?.reviver===void 0?void 0:Zy(Gb(tx(e),t));return e=>r===void 0?V(e.json,e=>n(e,t)):V(e.text,i=>i===``?V(e.json,e=>n(e,t)):r(i,t))},tS=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=bf(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=bf(e.text)}catch{}let i={...t,headers:Qe(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},nS=`~effect/http/HttpClientResponse`,rS=(e,t)=>new aS(e,t),Z=b(2,(e,t)=>{let n=e.status;return t[n]?t[n](e):n>=200&&n<300&&t[`2xx`]?t[`2xx`](e):n>=300&&n<400&&t[`3xx`]?t[`3xx`](e):n>=400&&n<500&&t[`4xx`]?t[`4xx`](e):n>=500&&n<600&&t[`5xx`]?t[`5xx`](e):t.orElse(e)}),iS=e=>e.status>=200&&e.status<300?R(e):B(new px({reason:new vx({response:e,request:e.request,description:`non 2xx status code`})})),aS=class extends ht{[$x];[nS];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[$x]=$x,this[nS]=nS}toJSON(){return tS(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split(`#`)[0];let e=Qx(this.request);return nr(e)?``:(e.value.hash=``,e.value.href)}get headers(){return Dy(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=_y(this.source.headers.getSetCookie())}get remoteAddress(){return er()}get stream(){return this.source.body?Yp({evaluate:()=>this.source.body,onError:e=>new px({reason:new yx({request:this.request,response:this,cause:e})})}):qp(new px({reason:new bx({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return V(this.text,e=>Cd({try:()=>e===``?null:JSON.parse(e),catch:e=>new px({reason:new yx({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=kd(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return V(this.text,e=>Cd({try:()=>By(new URLSearchParams(e)),catch:e=>new px({reason:new yx({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=hd({try:()=>this.source.formData(),catch:e=>new px({reason:new yx({request:this.request,response:this,cause:e})})}).pipe(nf,bf)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=hd({try:()=>this.source.arrayBuffer(),catch:e=>new px({reason:new yx({request:this.request,response:this,cause:e})})}).pipe(nf,bf),this.arrayBufferBody}pipe(){return _(this,arguments)}},oS=e=>Oy({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${ir(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),sS=`~effect/http/HttpClient`,cS=dr(`effect/HttpClient`),lS=b(2,(e,t)=>dS(n=>t(e.postprocess(n)),e.preprocess)),uS=lS(V(iS)),dS=(e,t)=>{let n=Object.create(fS);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},fS={[sS]:sS,pipe(){return _(this,arguments)},...mt,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(xx.map(([e,t])=>[t,function(t,n){return this.execute(Ax(e)(t,n))}]))},pS=e=>dS(t=>V(t,t=>wd(n=>{let r=SS.get(t),i=r??new AbortController,a=wx(t.url,t.urlParams,sr(t.hash));if(ki(a))return B(new px({reason:new _x({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(va)||n.getRef(gS)(t)){let a=e(t,o,i.signal,n);return r?a:sf(e=>Ud(e(a),{onSuccess(e){return xS.register(e,i),R(new CS(e,i))},onFailure(e){return Pu(e)&&i.abort(),bd(e)}}))}return uf(n.getRef(yS)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method),a.attribute(`server.address`,o.origin),o.port!==``&&a.attribute(`server.port`,+o.port),a.attribute(`url.full`,o.toString()),a.attribute(`url.path`,o.pathname),a.attribute(`url.scheme`,o.protocol.slice(0,-1));let s=o.search.slice(1);s!==``&&a.attribute(`url.query`,s);let c=n.getRef(Fy),l=n.getRef(_S);for(let e in t.headers)l(e,`request`)&&a.attribute(`http.request.header.${e}`,Py(e,c)?`<redacted>`:t.headers[e]);return t=n.getRef(vS)?zx(t,oS(a)):t,sf(s=>s(e(t,o,i.signal,n)).pipe(df(a,{captureStackTrace:!1}),Ud({onSuccess:e=>{a.attribute(`http.response.status_code`,e.status);for(let t in e.headers)l(t,`response`)&&a.attribute(`http.response.header.${t}`,Py(t,c)?`<redacted>`:e.headers[t]);return r?R(e):(xS.register(e,i),R(new CS(e,i)))},onFailure(e){return!r&&Pu(e)&&i.abort(),bd(e)}})))})})),R),mS=b(2,(e,t)=>dS(e.postprocess,n=>kd(e.preprocess(n),t))),hS=b(2,(e,t)=>dS(e.postprocess,n=>V(e.preprocess(n),t))),gS=Ur(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>C}),_S=Ur(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>S}),vS=Ur(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:S}),yS=Ur(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),bS=e=>bu(cS)(Gd(t=>kd(e,e=>lS(e,qd(e=>Vr(t,e)))))),xS=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),SS=new WeakMap,CS=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[nS]=nS;[$x]=$x;applyInterrupt(e){return gd(()=>(xS.unregister(this.original),af(e,()=>z(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return Kp(()=>(xS.unregister(this.original),Xp(this.original.stream,z(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[dt](){return this.original[dt]()}pipe(){return _(this,arguments)}},wS=J({status:rb(`ok`).annotate({description:"Process health. A successful response currently reports `ok`."}),color:X([`blue`,`green`]).annotate({description:`Deployment color of the process that handled the request.`}),role:X([`active`,`inactive`]).annotate({description:`Whether this deployment color currently serves active traffic.`}),version:K.annotate({description:`Build or release version embedded in the running binary.`,examples:[`1.4.0`]}),activeColor:X([`blue`,`green`]).annotate({description:`Deployment color currently selected as active.`})}).annotate({description:`Local deployment health and blue-green role information.`,examples:[{status:`ok`,color:`blue`,role:`active`,version:`1.4.0`,activeColor:`blue`}],identifier:`Health`}),Q=K.annotate({description:`Time-ordered UUID version 7 generated by Aperture.`,examples:[`019f6cf0-0000-7000-8000-000000000001`],format:`uuid`,identifier:`UUIDv7`}),TS=X([`api_token`,`user`,`system`]).annotate({description:`Stable category of the authenticated or audited actor.`,examples:[`api_token`],identifier:`PrincipalType`}),ES=X([`system_admin`,`tenant`]).annotate({description:"Authorization boundary. `system_admin` principals may administer the deployment and select tenants. `tenant` principals act within one effective tenant.\n",examples:[`tenant`],identifier:`AuthorityType`}),DS=X([`system:admin`,`sessions:read`,`sessions:write`,`snapshots:read`,`snapshots:write`,`tenant:write`,`tenants:write`]).annotate({description:"Permission granted to a principal. `system:admin` implies every scope. Tenant credentials and memberships cannot receive `system:admin` or `tenants:write`.\n",examples:[`sessions:write`],identifier:`Scope`}),OS=X([`all`,`allowlist`]).annotate({description:`Whether a tenant API token can access every tenant resource or only explicit grants.`,default:`all`,examples:[`allowlist`],identifier:`ResourceMode`}),kS=X([`session`,`snapshot`]).annotate({description:`Tenant resource category accepted by API token allowlists.`,examples:[`session`],identifier:`ResourceType`}),AS=J({code:K.annotate({description:`Stable code enumerated by each operation response.`,examples:[`insufficient_scope`]}),message:K.annotate({description:`Human-readable explanation. It may include resource or validation context.`,examples:[`insufficient scope`]})}).annotate({description:`Stable machine-readable error code with a human-readable explanation.`,identifier:`ErrorDetail`}),jS=J({name:K.annotate({description:`Configured browser channel name.`,examples:[`chromium`]})}).annotate({description:`Browser runtime selectable when creating a session.`,identifier:`BrowserChannel`}),MS=J({limit:q.annotate({description:`Effective page size after applying the default and maximum.`,examples:[50]}).check(Fb().annotate({expected:`an integer`})).check(Mb(1).annotate({expected:`a value greater than or equal to 1`})).check(Nb(100).annotate({expected:`a value less than or equal to 100`})),nextCursor:G(K.annotate({description:`Opaque cursor for the next page. Omitted when there is no next page.`,examples:[`eyJjcmVhdGVkQXQiOiIyMDI2LTA3LTE3VDEyOjAwOjAwWiIsImlkIjoiMDE5ZjZjZjAtMDAwMC03MDAwLTgwMDAtMDAwMDAwMDAwMDAwIn0`]})),hasMore:sb.annotate({description:`Whether another page is available.`,examples:[!0]})}).annotate({description:`Cursor pagination metadata for a newest-first result page.`,identifier:`PageMeta`});J({displayName:K.annotate({description:`Human-readable tenant name. Leading and trailing whitespace is removed and whitespace-only values are rejected.`,examples:[`Example engineering`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(wb(RegExp(`.*\\S.*`)).annotate({expected:`a string matching the RegExp .*\\S.*`}))}).annotate({description:`Tenant fields accepted by create and update operations.`,identifier:`TenantInput`}),J({email:G(pb([K,ab]).annotate({description:`Optional normalized login and contact email.`,format:`email`})),displayName:K.check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(wb(RegExp(`.*\\S.*`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),isSystemAdmin:sb.annotate({description:`Grants deployment-wide administration independently of tenant memberships.`})}).annotate({identifier:`UserInput`});var NS=J({token:K.annotate({description:`Raw setup token. Store and transmit it as a secret.`}),expiresAt:K.annotate({format:`date-time`})}).annotate({description:`One-time account setup secret returned only when created.`,identifier:`UserInvitation`}),PS=X([`sessions:read`,`sessions:write`,`snapshots:read`,`snapshots:write`,`tenant:write`]).annotate({description:`Scope allowed on a tenant-bound API token.`,examples:[`sessions:write`],identifier:`TenantScope`}),FS=X([`creating`,`running`,`suspended`,`deleted`,`expired`,`failed`]).annotate({description:"Session lifecycle state:\n\n- `creating`: browser startup is in progress; the CDP endpoint does not answer yet.\n- `running`: browser and routing are available and the CDP endpoint answers.\n- `suspended`: browser is intentionally stopped while retained state remains available.\n- `deleted`: session is soft-deleted and may be reopened while retained.\n- `expired`: retention elapsed and the session can no longer be used.\n- `failed`: startup or reopen failed; retained state may still be reopenable.\n",examples:[`running`],identifier:`SessionStatus`}),IS=J({urls:Y(K).annotate({description:`STUN or TURN server URLs.`,examples:[[`turn:turn.example.com:3478?transport=udp`]]}),username:G(K.annotate({description:`TURN username. Omitted when the server does not require authentication.`,examples:[`aperture-session`]})),credential:G(K.annotate({description:`TURN credential. Treat it as a secret and do not persist it in logs.`,examples:[`REDACTED`]}))}).annotate({description:`ICE server configuration supplied to WebRTC consumers.`,identifier:`IceServer`}),LS=lb(K,K).annotate({description:`Arbitrary string key-value metadata. Tag-writing operations additionally reject blank keys and blank values.`,examples:[{environment:`production`,region:`eu-west-1`}],identifier:`StringMap`}),RS=J({editorToken:K.annotate({examples:[`ape_019f6cf0000070008000000000000010_REDACTED`]}),viewerToken:K.annotate({examples:[`apv_019f6cf0000070008000000000000010_REDACTED`]})}).annotate({description:`Owner-visible role-scoped secrets used to build collaboration links.`,identifier:`SessionCollaborationCapabilities`}),zS=J({url:K.annotate({examples:[`socks5://user:xxxxx@proxy.example.com:1080`]})}).annotate({description:`A named upstream as stored. The secret is never returned and proxy URL passwords are masked.`,identifier:`SessionProxyUpstream`}),BS=J({match:K.annotate({description:"`host` or `host:port`, where the host is exact, `*.suffix` for subdomains, or `*` for any host. `*` never matches `localhost`, which only a rule naming it routes. Loopback IPs never reach the proxy, so local services are matched as `localhost`.",examples:[`*.example.test`]}),via:K.annotate({description:"`direct` dials from the session host, `refuse` fails the connection, `local` uses the attached local tunnel and fails while none is attached. Anything else names an upstream, or is an inline proxy URL without a secret.",examples:[`operator`]})}).annotate({description:`Routes the browser connections its match covers.`,identifier:`ProxyRule`}),VS=J({channel:K.annotate({description:"Channel returned by `GET /api/browser/channels`.",examples:[`chromium`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(wb(RegExp(`.*\\S.*`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),args:G(Y(K).annotate({description:`Additional Chromium command-line arguments. Aperture rejects arguments that conflict with supervisor-owned behavior or deployment policy.`,examples:[[`--lang=en-US`]]}))}).annotate({description:`Browser runtime configuration used to create or reopen the session.`,identifier:`BrowserConfig`}),HS=J({name:K,value:K.annotate({description:`Browser storage value. Never log this field.`})}).annotate({identifier:`BrowserStorageEntry`}),US=J({x:q.check(Tb().annotate({expected:`a finite number`})),y:q.check(Tb().annotate({expected:`a finite number`}))}).annotate({identifier:`InitialBrowserScrollPosition`}),WS=J({tag:K.check(wb(RegExp(`^[a-z][a-z0-9-]*$`)).annotate({expected:`a string matching the RegExp ^[a-z][a-z0-9-]*$`})),index:q.check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))}).annotate({identifier:`InitialBrowserElementPathStep`}),GS=J({start:q.check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`})),end:q.check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`})),direction:X([`forward`,`backward`,`none`])}).annotate({identifier:`InitialBrowserControlSelection`}),KS=X([`Strict`,`Lax`,`None`]).annotate({identifier:`BrowserCookieSameSite`}),qS=J({topLevelSite:K.annotate({format:`uri`}).check(wb(RegExp(`^https?:\\/\\/[^/]+$`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),hasCrossSiteAncestor:G(sb)}).annotate({identifier:`InitialBrowserCookiePartitionKey`}),JS=J({kind:X([`none`,`string`,`array`]),value:G(Y(K))}).annotate({description:`Object-store key path. String paths contain one value; array paths contain at least one.`,identifier:`InitialIndexedDBKeyPath`}),YS=J({kind:X([`string`,`array`]),value:Y(K).check(Ib(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Index key path. String paths contain one value; array paths contain at least one.`,identifier:`InitialIndexedDBIndexKeyPath`}),XS=J({key:K.annotate({description:`JSON-encoded structured-clone key.`}),value:K.annotate({description:`JSON-encoded structured-clone value.`})}).annotate({identifier:`InitialIndexedDBRecord`}),ZS=J({path:K.check(Ib(1).annotate({expected:`a value with a length of at least 1`})),body:K.annotate({contentEncoding:`base64`})}).annotate({identifier:`InitialOPFSFile`}),QS=J({url:K.annotate({description:"A generic proxy URL (`http`, `https`, `socks`, `socks5`, `socks5h`) or a compound tunnel URL (`ws+yamux+socks5://`, `wss+yamux+socks5://`). Proxy credentials go in the userinfo (`socks5://user:pass@host:1080`) and are sent as Basic `Proxy-Authorization` for `http`/`https` or RFC 1929 username/password for the socks schemes. An omitted port defaults to 1080 (socks), 80 (http) or 443 (https).",examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]}),auth:G(K.annotate({description:`Bearer secret for a tunnel URL's handshake. Required for a tunnel URL and invalid for a proxy URL. Write-only; never returned.`,examples:[`REDACTED`]}))}).annotate({description:`A named upstream that proxy rules route through.`,identifier:`ProxyUpstream`}),$S=J({url:G(K.annotate({description:"Compound tunnel URL (`ws+yamux+socks5://` or `wss+yamux+socks5://`).",examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]})),auth:G(K.annotate({description:`Bearer secret for the tunnel handshake. Write-only; never returned.`,examples:[`REDACTED`]}))}).annotate({description:"Legacy tunnel endpoint for `upstream` `tunnel`; both fields are required with it. Use a tunnel URL in `upstreams`.",identifier:`ProxyTunnelConfig`}),eC=J({visible:sb.annotate({description:`Whether to include the remote cursor in live streams and recordings.`})}).annotate({description:`Whether the remote browser cursor is composited into session media.`,identifier:`CursorVisibility`}),tC=J({recordingId:K.annotate({description:`Stable recording identifier retained across target changes.`,format:`uuid`}),mode:X([`tab`,`viewer`]).annotate({description:`Tab recordings stay on their specified top-level target; viewer recordings follow a live session client's selected top-level target and cannot be explicitly retargeted.`}),targetId:K.annotate({description:`Identifier of the top-level target currently recorded.`}),captureGeneration:q.annotate({description:`Assignment generation for the current top-level target.`,format:`int64`}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`})),status:X([`starting`,`running`,`stopped`,`failed`]),stopReason:G(K.annotate({description:`Lifecycle reason recorded after the recording stops or fails.`})),relativePath:K.annotate({description:`Path below the session root; absolute host paths are never exposed.`,examples:[`recordings/recording-550e8400-e29b-41d4-a716-446655440000.webm`]}),startedAt:K.annotate({format:`date-time`}),stoppedAt:G(K.annotate({format:`date-time`})),sizeBytes:G(q.annotate({format:`int64`}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),fps:q.check(Fb().annotate({expected:`an integer`})).check(Mb(1).annotate({expected:`a value greater than or equal to 1`})),bitrateKbps:q.check(Fb().annotate({expected:`an integer`})).check(Mb(1).annotate({expected:`a value greater than or equal to 1`})),codec:X([`vp8`,`h264-va`])}).annotate({description:`One logical recording of a top-level target.`,identifier:`Recording`});J({targetId:K.annotate({description:`Identifier of the ready top-level target to record.`}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})),fps:G(q.annotate({description:`Requested frames per second. Omit or use a non-positive value for the instance default.`,examples:[60]}).check(Fb().annotate({expected:`an integer`}))),bitrateKbps:G(q.annotate({description:`Requested video bitrate in kilobits per second. Omit or use a non-positive value for the instance default.`,examples:[6e3]}).check(Fb().annotate({expected:`an integer`}))),codec:G(X([`vp8`,`h264-va`]).annotate({description:`Video codec. Omit for the instance default.`,examples:[`vp8`]}))}).annotate({description:`Top-level target and optional recording settings.`,identifier:`CreateSessionRecordingInput`}),J({targetId:K.annotate({description:`Identifier of the ready destination top-level target.`}).check(Ib(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Destination for a running tab recording.`,identifier:`RetargetSessionRecordingInput`});var nC=J({name:K.annotate({description:`File name without directory components.`,examples:[`screencast-20260801T120000Z.webm`]}),relativePath:K.annotate({description:"Path below the session root. The first component is `downloads` or `recordings`.",examples:[`recordings/screencast-20260801T120000Z.webm`]}),size:q.annotate({description:`File size in bytes.`,examples:[1048576],format:`int64`}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`})),modifiedAt:K.annotate({description:`Last file modification time.`,examples:[`2026-08-01T12:05:00Z`],format:`date-time`}),mimeType:K.annotate({description:`Detected media type.`,examples:[`video/webm`]})}).annotate({description:`Regular file retained with a browser session.`,identifier:`SessionFile`});J({relativePath:K.annotate({description:"Path from a `SessionFile` result.",examples:[`recordings/screencast-20260801T120000Z.webm`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})),ttlSeconds:G(q.annotate({description:"Requested lifetime in seconds. Omit it to use `signed_file_url_ttl`; values above `signed_file_url_max_ttl` are rejected.",examples:[900]}).check(Fb().annotate({expected:`an integer`})).check(Mb(1).annotate({expected:`a value greater than or equal to 1`})))}).annotate({description:`Session file path and requested signed URL lifetime.`,identifier:`SessionFileDownloadURLInput`});var rC=J({url:K.annotate({description:"URL containing a path-bound `apf_` token.",examples:[`https://aperture.example.com/sessions/019f6cf0-0000-7000-8000-000000000010/files/recordings/screencast-20260801T120000Z.webm?token=apf_REDACTED`],format:`uri`}),expiresAt:K.annotate({description:`Time after which the URL is rejected.`,examples:[`2026-08-01T12:20:00Z`],format:`date-time`})}).annotate({description:`Signed attachment URL for one session file.`,identifier:`SessionFileDownloadURL`});J({description:G(pb([K,ab]).annotate({description:"New description. Send `null` to clear it; an empty string is stored as an empty description.",examples:[`Updated signed-in state`]}))}).annotate({description:`Replacement snapshot description.`,identifier:`UpdateSnapshotInput`});var iC=J({id:gb(()=>Q).annotate({description:`Tenant identifier.`}),displayName:K.annotate({description:`Human-readable tenant name.`,examples:[`Example engineering`]}),createdAt:K.annotate({description:`Time the tenant was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),deletedAt:G(pb([K,ab]).annotate({description:"Soft-deactivation time, or `null` for an active tenant.",examples:[null],format:`date-time`}))}).annotate({description:`Tenant account. Deletion is a reversible soft deactivation.`,identifier:`Tenant`}),aC=J({id:Q,email:G(pb([K,ab]).annotate({format:`email`})),displayName:K,isSystemAdmin:sb,createdAt:K.annotate({format:`date-time`}),updatedAt:K.annotate({format:`date-time`}),disabledAt:G(pb([K,ab]).annotate({format:`date-time`})),passwordSetupStatus:G(X([`available`,`configured`,`email_required`,`user_disabled`,`login_disabled`]).annotate({description:`Password setup state included by the get-user operation.`}))}).annotate({identifier:`User`});J({ids:Y(Q).annotate({description:`Up to 100 unique UUIDv7 values. An empty array is valid.`,examples:[[`019f6cf0-0000-7000-8000-000000000010`,`019f6cf0-0000-7000-8000-000000000011`]]}).check(Lb(100).annotate({expected:`a value with a length of at most 100`})).check(zb().annotate({expected:`an array with unique items`}))}).annotate({description:`Ordered session IDs for a tenant-scoped bulk lookup. Missing, foreign, and deleted IDs are omitted from the result.`,identifier:`SessionBulkInput`});var oC=J({id:gb(()=>Q).annotate({description:`Event identifier.`}),tenantId:gb(()=>Q).annotate({description:`Tenant that owns the event.`}),resourceType:K.annotate({description:`Resource category associated with the event. Currently session events are the primary source; new categories may be added.`,examples:[`session`]}),resourceId:K.annotate({description:"Identifier of the associated resource. Its format depends on `resourceType`.",examples:[`019f6cf0-0000-7000-8000-000000000010`]}),type:K.annotate({description:`Extensible event type used for programmatic handling.`,examples:[`session.token_rotated`]}),message:K.annotate({description:`Human-readable event summary.`,examples:[`session token rotated`]}),data:lb(K,nx.annotate({expected:`JSON value`})).annotate({description:`Event-specific JSON payload, such as error details or upload metadata.`,examples:[{reason:`manual rotation`}]}),createdAt:K.annotate({description:`Time the event was recorded.`,examples:[`2026-07-17T12:30:00Z`],format:`date-time`})}).annotate({description:`Immutable tenant-scoped audit or lifecycle event.`,identifier:`Event`}),sC=J({id:Q,actorType:TS,actorId:G(pb([K,ab])),tenantId:G(pb([Q,ab],{mode:`oneOf`})),action:K.annotate({examples:[`tenant_membership.upserted`]}),resourceType:K.annotate({examples:[`tenant_membership`]}),resourceId:G(pb([K,ab])),data:lb(K,nx.annotate({expected:`JSON value`})),createdAt:K.annotate({format:`date-time`})}).annotate({identifier:`AuditEvent`}),cC=J({resourceType:kS,resourceId:Q}).annotate({description:`Access to one existing tenant session or snapshot by its stable UUIDv7 identifier.`,identifier:`ResourceGrant`}),lC=J({error:AS}).annotate({description:`Standard error envelope returned by REST API operations.`,identifier:`Error`}),uC=J({channels:Y(jS)}).annotate({description:`Browser channels enabled on this deployment.`,examples:[{channels:[{name:`chromium`}]}],identifier:`BrowserChannels`}),dC=J({tenantId:Q,userId:Q,scopes:Y(PS).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(zb().annotate({expected:`an array with unique items`})),createdAt:K.annotate({format:`date-time`}),updatedAt:K.annotate({format:`date-time`})}).annotate({identifier:`TenantMembership`});J({scopes:Y(PS).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(zb().annotate({expected:`an array with unique items`}))}).annotate({identifier:`TenantMembershipInput`});var fC=J({mode:X([`auto`,`cdp`]).annotate({description:"Configured media mode. `auto` enables deployment-selected media support; `cdp` exposes Chrome DevTools access only.",examples:[`auto`]}),webrtcProducer:sb.annotate({description:`Whether the compositor WebRTC producer is available for this session.`,examples:[!0]}),iceServers:G(Y(IS).annotate({description:`ICE configuration for WebRTC setup. Omitted when WebRTC is unavailable or does not need configured ICE servers.`}))}).annotate({description:`Media capabilities currently available for the session.`,identifier:`SessionMedia`}),pC=J({url:K.annotate({format:`uri`}),requestHeaders:LS,responseHeaders:LS,responseStatus:q.check(Fb().annotate({expected:`an integer`})).check(Mb(100).annotate({expected:`a value greater than or equal to 100`})).check(Nb(599).annotate({expected:`a value less than or equal to 599`})),responseStatusText:K,responseBody:K.annotate({contentEncoding:`base64`})}).annotate({identifier:`InitialCacheStorageEntry`});J({tags:gb(()=>LS).annotate({description:`Complete tag map. Keys and values must contain non-whitespace characters.`})}).annotate({description:`Complete replacement tag set. The map may be empty to clear all tags.`,examples:[{tags:{environment:`production`,region:`eu-west-1`}}],identifier:`ReplaceTagsInput`}),J({name:K.annotate({description:`Tenant-unique snapshot name. Leading and trailing whitespace is removed.`,examples:[`signed-in-base`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(wb(RegExp(`.*\\S.*`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),description:G(pb([K,ab]).annotate({description:"Optional snapshot description. `null` creates the snapshot without a description.",examples:[`Signed-in storefront state for checkout tests`]})),force:G(sb.annotate({description:"Deleted snapshot names are reused automatically. Set `true` to replace an active snapshot, which is renamed to its tombstone name and retained for the configured snapshot retention period.",default:!1})),tags:G(gb(()=>LS).annotate({description:`Initial complete tag map for the new snapshot.`}))}).annotate({description:`Snapshot metadata created from a stopped, retained session.`,examples:[{name:`signed-in-base`,description:`Signed-in storefront state for checkout tests`,force:!1,tags:{application:`storefront`,environment:`staging`}}],identifier:`PromoteSessionInput`});var mC=J({id:gb(()=>Q).annotate({description:`Snapshot identifier.`}),name:K.annotate({description:`Human-selected tenant-unique snapshot name.`,examples:[`signed-in-base`]}),tenantId:gb(()=>Q).annotate({description:`Tenant that owns the snapshot.`}),description:G(pb([K,ab]).annotate({description:"Operator-provided description, or `null` when none is set.",examples:[`Signed-in storefront state for checkout tests`]})),parentSnapshotId:G(gb(()=>Q).annotate({description:`Base snapshot from which the source session was created. Omitted for snapshots without a parent.`})),promotedFromSessionId:G(gb(()=>Q).annotate({description:`Session whose retained overlay produced this snapshot. Omitted when lineage is unavailable.`})),createdAt:K.annotate({description:`Time the snapshot was created.`,examples:[`2026-07-17T12:45:00Z`],format:`date-time`}),deletedAt:G(pb([K,ab]).annotate({description:"Soft-deletion time, or `null` for an active snapshot.",examples:[null],format:`date-time`})),expiresAt:G(K.annotate({description:`Purge eligibility time for a deleted snapshot. Omitted for active snapshots.`,examples:[`2026-08-16T12:45:00Z`],format:`date-time`})),tags:G(gb(()=>LS).annotate({description:`Snapshot metadata tags. Omitted when no tags are set.`}))}).annotate({description:`Reusable retained browser filesystem state. Deletion is soft until the retention deadline.`,identifier:`Snapshot`}),hC=J({upstreams:lb(K,zS),rules:Y(BS),upstream:X([`direct`,`proxy`,`tunnel`]).annotate({description:"Legacy single-upstream view of `rules`; read `upstreams` and `rules` instead. Exact when the rules are optional leading `direct` rules followed by one final `*` rule via an upstream proxy or tunnel, with no other upstreams, and `direct` when there are no rules. Otherwise it approximates the route of the last `*` rule (`local` reads as `tunnel`, `refuse` as `direct`), or `direct` without one, and `url`, `tunnel` and `bypass` are omitted.",examples:[`tunnel`]}),url:G(K.annotate({description:"Legacy upstream proxy URL with its password masked. Only present when `upstream` is exactly `proxy`.",examples:[`socks5://user:xxxxx@proxy.example.com:1080`]})),tunnel:G(J({url:G(K.annotate({examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]}))}).annotate({description:"Legacy tunnel endpoint. Only present when `upstream` is exactly `tunnel`. The secret is never returned."})),bypass:G(K.annotate({description:"Legacy `;`-separated matches of the leading `direct` rules. Only present with an exact `proxy` or `tunnel` value.",examples:[`*.internal.example.com`]}))}).annotate({description:`Stored session egress proxy configuration. Secrets are write-only, so this value cannot be replayed as a write.`,identifier:`SessionProxy`}),gC=J({origin:K.annotate({format:`uri`}).check(wb(RegExp(`^https?:\\/\\/[^/]+$`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),entries:Y(HS)}).annotate({identifier:`InitialTargetStorageOrigin`}),_C=J({tag:K.check(wb(RegExp(`^[a-z][a-z0-9-]*$`)).annotate({expected:`a string matching the RegExp ^[a-z][a-z0-9-]*$`})),id:G(K),name:G(K),inputType:G(K),autocomplete:G(K),ariaLabel:G(K),placeholder:G(K),path:Y(WS).check(Lb(256).annotate({expected:`a value with a length of at most 256`}))}).annotate({description:`Semantic element identity with a structural fallback. It is not a CSS selector.`,identifier:`InitialBrowserElementLocator`}),vC=J({name:K.check(Ib(1).annotate({expected:`a value with a length of at least 1`})),value:K.annotate({description:`Cookie value. Never log this field.`}),domain:K.annotate({examples:[`.example.com`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})),hostOnly:G(sb.annotate({description:"Scope the cookie to exactly `domain`, without subdomains. `domain` must then be a plain hostname.",default:!1})),path:K.annotate({examples:[`/`]}).check(wb(RegExp(`^\\/`)).annotate({expected:`a string matching the RegExp ^\\/`})),expires:G(q.annotate({description:`Unix timestamp in seconds. Omit for a session cookie.`}).check(Tb().annotate({expected:`a finite number`})).check(jb(0).annotate({expected:`a value greater than 0`}))),httpOnly:G(sb.annotate({default:!1})),secure:G(sb.annotate({default:!1})),sameSite:G(KS),partitionKey:G(qS)}).annotate({description:`Cookie imported into the new browser profile.`,identifier:`InitialBrowserCookie`}),yC=J({name:K,keyPath:YS,unique:sb,multiEntry:sb}).annotate({identifier:`InitialIndexedDBIndex`}),bC=J({upstreams:G(lb(K,QS).annotate({description:"Upstreams by name. Names use lowercase letters, digits and dashes; `direct`, `refuse` and `local` are reserved."})),rules:G(Y(BS).check(Lb(256).annotate({expected:`a value with a length of at most 256`}))),upstream:G(X([`direct`,`proxy`,`tunnel`]).annotate({description:"Legacy single-upstream shape; use `upstreams` and `rules`. Cannot be combined with them. `proxy` becomes a final `*` rule via `url`, `tunnel` a `tunnel` upstream and a final `*` rule via it, each preceded by `direct` rules for the `bypass` entries. `direct` or omitted means no rules.",examples:[`tunnel`]})),url:G(K.annotate({description:"Legacy upstream proxy URL, required with `upstream` `proxy`. Use `upstreams` and `rules`.",examples:[`socks5://user:pass@proxy.example.com:1080`]})),tunnel:G($S),bypass:G(K.annotate({description:"Legacy hosts to send direct, separated by `;` or `,`. Each entry must be a valid rule `match`; a leading `.` means any subdomain. CIDR ranges, `<local>` and scheme prefixes are rejected. Use `upstreams` and `rules`.",examples:[`*.internal.example.com`]}))}).annotate({description:"Session egress proxy configuration. Rules are checked in order and the first match routes the connection; unmatched connections go direct, and unmatched `localhost` stays on the session host. Omitted for direct egress.",identifier:`ProxyConfig`});J({upstreams:G(lb(K,QS)),rules:G(Y(BS).check(Lb(256).annotate({expected:`a value with a length of at most 256`}))),upstream:G(X([`direct`,`proxy`,`tunnel`]).annotate({description:"Legacy single-upstream shape; use `upstreams` and `rules`."})),url:G(K.annotate({description:"Legacy upstream proxy URL; use `upstreams` and `rules`."})),tunnel:G($S),bypass:G(K.annotate({description:"Legacy hosts to send direct; use `upstreams` and `rules`."})),drain:G(sb.annotate({description:`Reset live tunnel streams instead of letting them drain. New connections use the new rules either way.`,examples:[!1]}))}).annotate({description:"Replacement session egress proxy configuration. Fields other than `drain` are as in `ProxyConfig`.",identifier:`UpdateProxyConfig`});var xC=J({data:Y(iC),meta:MS}).annotate({description:`Cursor-paginated tenants.`,identifier:`TenantPage`}),SC=J({data:Y(aC),meta:MS}).annotate({identifier:`UserPage`}),CC=J({data:Y(oC),meta:MS}).annotate({description:`Cursor-paginated tenant events.`,identifier:`EventPage`}),wC=J({data:Y(sC),meta:MS}).annotate({identifier:`AuditEventPage`}),TC=J({type:TS,id:K.annotate({description:`Stable identifier of the authenticated subject.`}),authMethod:X([`api_token`,`oidc`,`passkey`,`password`]).annotate({description:`Authentication mechanism used for this request.`}),tokenId:pb([Q,ab],{mode:`oneOf`}).annotate({description:"Identifier of the API token used for authentication, or `null` for account-backed sessions."}),userId:G(pb([Q,ab],{mode:`oneOf`}).annotate({description:"User identifier for account-backed authentication, or `null` for API tokens."})),name:K.annotate({description:`Display name of the authenticated credential or user.`,examples:[`deployment automation`]}),authorityType:ES,tenantId:G(pb([Q,ab],{mode:`oneOf`}).annotate({description:"Effective tenant for tenant authority, or `null` when no tenant is selected."})),scopes:Y(DS).annotate({description:`Scopes granted to the authenticated principal.`}).check(zb().annotate({expected:`an array with unique items`})),resourceMode:OS,resourceGrants:Y(cC).annotate({description:"Explicit grants when `resourceMode` is `allowlist`; empty when it is `all`."}).check(zb().annotate({expected:`an array with unique items`}))}).annotate({description:`Authenticated subject identity and authorization context.`,identifier:`Principal`}),EC=J({id:gb(()=>Q).annotate({description:`Token identifier. This is not the bearer secret.`}),authorityType:ES,tenantId:G(pb([Q,ab],{mode:`oneOf`}).annotate({description:"Bound tenant for a tenant token, or `null` for a system administrator token."})),name:K.annotate({description:`Operator-assigned token name, unique within its authority and tenant context.`,examples:[`ci automation`]}),scopes:Y(DS).annotate({description:`Unique scopes granted to the token.`}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(zb().annotate({expected:`an array with unique items`})),createdAt:K.annotate({description:`Time the token was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),createdByType:gb(()=>TS).annotate({description:`Principal category that created the token.`}),createdById:pb([Q,ab],{mode:`oneOf`}).annotate({description:"User or API token identifier that created the token, or `null` for trusted local system actions."}),parentTokenId:pb([Q,ab],{mode:`oneOf`}).annotate({description:"API token used to delegate this token, or `null` when a user or trusted local system created it."}),resourceMode:OS,resourceGrants:Y(cC).annotate({description:"Explicit session and snapshot grants when `resourceMode` is `allowlist`."}).check(zb().annotate({expected:`an array with unique items`})),expiresAt:G(pb([K,ab]).annotate({description:"Authentication expiry time, or `null` when the token does not expire automatically.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),revokedAt:G(pb([K,ab]).annotate({description:"Revocation time, or `null` while the token is active.",examples:[null],format:`date-time`}))}).annotate({description:`API token metadata. The raw bearer secret is never included in this schema.`,identifier:`Token`});pb([J({name:K.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`platform admin`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(wb(RegExp(`.*\\S.*`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),authorityType:rb(`system_admin`),scopes:Y(DS).annotate({description:"Must include `system:admin`.",examples:[[`system:admin`]]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(zb().annotate({expected:`an array with unique items`})),expiresAt:G(pb([K,ab]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:G(rb(`all`).annotate({description:`System administrator tokens cannot use resource allowlists.`,default:`all`})),resourceGrants:G(Y(cC).annotate({description:`Must be empty for a system administrator token.`}).check(Lb(0).annotate({expected:`a value with a length of at most 0`})))}),J({name:K.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`tenant automation`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(wb(RegExp(`.*\\S.*`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),authorityType:rb(`tenant`),tenantId:gb(()=>Q).annotate({description:`Active tenant to bind permanently to the token.`}),scopes:Y(PS).annotate({description:"Tenant-compatible scopes. `system:admin` and `tenants:write` are rejected.",examples:[[`sessions:read`,`sessions:write`]]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(zb().annotate({expected:`an array with unique items`})),expiresAt:G(pb([K,ab]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:G(OS),resourceGrants:G(Y(cC).annotate({description:"Existing tenant resources granted when `resourceMode` is `allowlist`; must be empty for `all`."}).check(zb().annotate({expected:`an array with unique items`})))})],{mode:`oneOf`}).annotate({description:`Token definition accepted by the system administrator token endpoint.`,identifier:`CreateAdminTokenInput`}),J({name:K.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`browser worker`]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(wb(RegExp(`.*\\S.*`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),scopes:Y(PS).annotate({description:"Tenant-compatible scopes. `system:admin` and `tenants:write` are rejected.",examples:[[`sessions:read`,`sessions:write`]]}).check(Ib(1).annotate({expected:`a value with a length of at least 1`})).check(zb().annotate({expected:`an array with unique items`})),expiresAt:G(pb([K,ab]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:G(OS),resourceGrants:G(Y(cC).annotate({description:"Existing tenant resources granted when `resourceMode` is `allowlist`; must be empty for `all`."}).check(zb().annotate({expected:`an array with unique items`})))}).annotate({description:`Token definition automatically bound to the authenticated tenant.`,identifier:`CreateTenantTokenInput`});var DC=J({name:K,entries:Y(pC)}).annotate({identifier:`InitialCacheStorageCache`}),OC=J({snapshot:mC}).annotate({description:`Snapshot returned after a mutation.`,identifier:`SnapshotMutation`}),kC=J({data:Y(mC),meta:MS}).annotate({description:`Cursor-paginated snapshots.`,identifier:`SnapshotPage`}),AC=J({id:gb(()=>Q).annotate({description:`Session identifier.`}),tenantId:gb(()=>Q).annotate({description:`Tenant that owns the session.`}),baseSnapshotName:G(K.annotate({description:`Snapshot name used as the session base. Omitted for a blank session.`,examples:[`signed-in-base`]})),label:G(K.annotate({description:`Optional operator-facing session label.`,examples:[`checkout smoke test`]})),status:FS,browserChannel:G(K.annotate({description:`Browser channel used to create and reopen the session.`,examples:[`chromium`]})),media:fC,createdAt:K.annotate({description:`Time the session record was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),startedAt:G(K.annotate({description:`Most recent successful browser start time. Omitted before startup succeeds.`,examples:[`2026-07-17T12:00:03Z`],format:`date-time`})),stoppedAt:G(K.annotate({description:`Most recent browser stop time. Omitted while no stop has occurred.`,examples:[`2026-07-17T13:00:00Z`],format:`date-time`})),deletedAt:G(pb([K,ab]).annotate({description:"Soft-deletion time, or `null` for a session that has not been deleted.",examples:[null],format:`date-time`})),expiresAt:K.annotate({description:`Retention deadline after which the session and its overlay may be purged. This is not token expiry.`,examples:[`2026-07-24T12:00:00Z`],format:`date-time`}),lastConnectedAt:G(K.annotate({description:`Most recent routed client activity time. Omitted until a client connects.`,examples:[`2026-07-17T12:30:00Z`],format:`date-time`})),suspendedAt:G(K.annotate({description:`Most recent suspension time. Omitted unless the session is suspended.`,examples:[`2026-07-17T13:00:00Z`],format:`date-time`})),tags:G(gb(()=>LS).annotate({description:`Session metadata tags. Omitted when no tags are set.`})),cdpUrl:G(K.annotate({description:"Authenticated Chrome DevTools endpoint. Omitted when the session is not currently routable. Use it with `sessionToken`.",examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`})),sessionToken:G(K.annotate({description:`Session access secret returned when live access credentials are available. Rotation invalidates the previous token immediately.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]})),collaboration:G(RS),proxy:G(hC)}).annotate({description:`Browser session state, retention metadata, tags, and currently available access credentials.`,identifier:`Session`}),jC=J({locator:_C,value:K,checked:G(sb),selectedIndices:G(Y(q.check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`})))),selection:G(GS)}).annotate({identifier:`InitialBrowserControlState`}),MC=J({locator:_C,html:K}).annotate({identifier:`InitialBrowserContentEditableState`}),NC=J({locator:_C,x:q.check(Tb().annotate({expected:`a finite number`})),y:q.check(Tb().annotate({expected:`a finite number`}))}).annotate({identifier:`InitialBrowserElementScrollPosition`}),PC=J({locator:_C,nodePath:Y(q.check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))).check(Lb(256).annotate({expected:`a value with a length of at most 256`})),offset:q.check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))}).annotate({identifier:`InitialBrowserSelectionEndpoint`}),FC=J({name:K,keyPath:JS,autoIncrement:sb,indexes:Y(yC),records:Y(XS)}).annotate({identifier:`InitialIndexedDBObjectStore`}),IC=J({principal:TC,selectedTenant:pb([iC,ab],{mode:`oneOf`}).annotate({description:"Effective tenant, or `null` when the principal has not selected one."}),availableTenants:Y(iC).annotate({description:`Active tenant memberships available to an account-backed principal. API-token principals return an empty array.`})}).annotate({description:`Current principal and its effective tenant selection.`,identifier:`AuthMe`}),LC=J({data:Y(EC),meta:MS}).annotate({description:`Cursor-paginated API token metadata without bearer secrets.`,identifier:`TokenPage`}),RC=J({token:EC,rawToken:K.annotate({description:`One-time Aperture API bearer token. Store it immediately; later reads return only token metadata.`,examples:[`apt_019f6cf0000070008000000000000002_REDACTED`]})}).annotate({description:`Created token metadata and its one-time bearer secret.`,identifier:`CreateTokenResponse`}),zC=J({data:Y(AC),meta:MS}).annotate({description:`Cursor-paginated browser sessions.`,identifier:`SessionPage`}),BC=J({session:AC,cdpUrl:K.annotate({description:`Authenticated Chrome DevTools endpoint for the new session.`,examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`}),sessionToken:K.annotate({description:`Initial session access secret. Store it immediately.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]})}).annotate({description:`Newly created session and its one-time initial access credentials.`,identifier:`CreateSessionResult`}),VC=J({sessions:Y(AC)}).annotate({description:`Sessions found for the requested IDs, preserving request order.`,identifier:`SessionBulkResponse`}),HC=J({session:AC,cdpUrl:G(K.annotate({description:`Current Chrome DevTools endpoint. Omitted by operations that do not expose live access.`,examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`})),sessionToken:G(K.annotate({description:`Current raw session access secret. Omitted by operations that do not expose or replace credentials.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]}))}).annotate({description:`Updated session and operation-specific live access credentials when available.`,identifier:`SessionMutation`}),UC=J({anchor:PC,focus:PC}).annotate({identifier:`InitialBrowserDocumentSelection`}),WC=J({name:K,version:q.check(Fb().annotate({expected:`an integer`})).check(Mb(1).annotate({expected:`a value greater than or equal to 1`})),objectStores:Y(FC)}).annotate({identifier:`InitialIndexedDBDatabase`}),GC=J({version:rb(1),windowName:G(K),historyState:G(K.annotate({description:`JSON-encoded structured-clone history state.`})),controls:Y(jC).check(Lb(1e4).annotate({expected:`a value with a length of at most 10000`})),contentEditables:Y(MC).check(Lb(1e4).annotate({expected:`a value with a length of at most 10000`})),scrollPositions:Y(NC).check(Lb(1e4).annotate({expected:`a value with a length of at most 10000`})),focus:G(_C),selection:G(UC)}).annotate({description:`Sensitive top-document state replayed during initial navigation.`,identifier:`InitialBrowserDocumentState`}),KC=J({origin:K.annotate({examples:[`https://example.com`],format:`uri`}).check(wb(RegExp(`^https?:\\/\\/[^/]+$`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),ancestorOrigins:G(Y(K.annotate({format:`uri`}).check(wb(RegExp(`^https?:\\/\\/[^/]+$`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`}))).annotate({description:`Top-down HTTP origin chain for partitioned storage. Omitted for a top-level origin.`}).check(Lb(32).annotate({expected:`a value with a length of at most 32`}))),localStorage:Y(HS),indexedDB:G(Y(WC)),cacheStorage:G(Y(DC)),opfs:G(Y(ZS))}).annotate({description:`Profile-scoped browser storage imported for one exact HTTP origin and ancestor partition.`,identifier:`InitialStorageOrigin`}),qC=J({url:K.annotate({description:`Absolute HTTP or HTTPS URL without embedded credentials.`,examples:[`https://example.com/account`],format:`uri`}).check(wb(RegExp(`^https?:\\/\\/`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/`})),sessionStorage:G(Y(gC).annotate({description:`Per-origin session storage installed in target frames before page scripts execute.`})),scroll:G(US),documentState:G(GC),openerTargetIndex:G(q.annotate({description:`Index of another initial target that opened this target.`}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),active:G(sb.annotate({description:`Select this target for the first connected session client. At most one target may be active.`,default:!1}))}).annotate({description:`HTTP page and target-scoped state opened during session creation.`,identifier:`InitialBrowserTarget`}),JC=J({cookies:Y(vC).check(Lb(1e4).annotate({expected:`a value with a length of at most 10000`})),origins:Y(KC).check(Lb(100).annotate({expected:`a value with a length of at most 100`}))}).annotate({description:`Profile-scoped browser storage imported before initial browser targets are opened.`,identifier:`InitialBrowserStorageState`});J({baseSnapshotName:G(pb([K,ab]).annotate({description:"Active snapshot used as the browser filesystem base. Omit, send `null`, or send an empty value for a blank session.",examples:[`signed-in-base`]})),label:G(pb([K,ab]).annotate({description:`Optional operator-facing label for the session.`,examples:[`checkout smoke test`]})),browser:VS,initialTargets:G(Y(qC).annotate({description:`Browser targets that replace the browser's startup page after storage import. Result order follows input order; opener dependencies may be created first.`}).check(Lb(50).annotate({expected:`a value with a length of at most 50`}))),storageState:G(JC),tags:G(gb(()=>LS).annotate({description:`Initial session tags.`})),proxy:G(bC)}).annotate({description:`Configuration for a new retained browser session.`,examples:[{baseSnapshotName:`signed-in-base`,label:`checkout smoke test`,browser:{channel:`chromium`,args:[`--lang=en-US`]},initialTargets:[{url:`https://example.com/account`}],storageState:{cookies:[],origins:[{origin:`https://example.com`,localStorage:[{name:`access-token`,value:`REDACTED`}]}]},tags:{environment:`staging`,suite:`checkout`}}],identifier:`CreateSessionInput`});var YC=wS;J({"X-Aperture-Tenant-Id":G(Q)});var XC=IC,ZC=uC;J({limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),deleted:G(X([`active`,`deleted`,`all`]).annotate({default:`active`})),includeDeleted:G(sb.annotate({default:!1}))});var QC=xC,$C=iC,ew=iC,tw=iC,nw=iC;J({limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),query:G(K),disabled:G(X([`active`,`disabled`,`all`]).annotate({default:`active`}))});var rw=SC,iw=aC,aw=aC,ow=aC,sw=aC,cw=aC,lw=NS,uw=Y(dC),dw=Y(dC),fw=dC,pw=lC;J({limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),tenantId:G(Q),actorType:G(TS),actorId:G(K),action:G(K),resourceType:G(K),resourceId:G(K)});var mw=wC;J({limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),authorityType:G(ES),tenantId:G(Q),name:G(K),scope:G(DS),revoked:G(X([`active`,`revoked`,`all`]).annotate({default:`all`}))});var hw=LC,gw=RC,_w=lC,vw=iC,yw=iC;J({limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),name:G(K),scope:G(DS),revoked:G(X([`active`,`revoked`,`all`]).annotate({default:`all`}))});var bw=LC,xw=RC,Sw=lC;J({"X-Aperture-Tenant-Id":G(Q),limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),includeDeleted:G(sb.annotate({default:!1})),status:G(FS),tagKey:G(Y(K.check(Ib(1).annotate({expected:`a value with a length of at least 1`})))),tagValue:G(Y(K.check(Ib(1).annotate({expected:`a value with a length of at least 1`})))),tagOperator:G(Y(X([`eq`,`neq`,`in`,`not_in`])))});var Cw=zC;J({"X-Aperture-Tenant-Id":G(Q),waitForReady:G(sb.annotate({default:!0}))});var ww=BC;J({"X-Aperture-Tenant-Id":G(Q)});var Tw=VC;J({"X-Aperture-Tenant-Id":G(Q)});var Ew=AC;J({"X-Aperture-Tenant-Id":G(Q)});var Dw=HC;J({"X-Aperture-Tenant-Id":G(Q)});var Ow=HC;J({"X-Aperture-Tenant-Id":G(Q)});var kw=HC;J({"X-Aperture-Tenant-Id":G(Q)});var Aw=HC;J({"X-Aperture-Tenant-Id":G(Q)});var jw=HC;J({"X-Aperture-Tenant-Id":G(Q)});var Mw=HC;J({"X-Aperture-Tenant-Id":G(Q)});var Nw=HC;J({"X-Aperture-Tenant-Id":G(Q)});var Pw=eC;J({"X-Aperture-Tenant-Id":G(Q)});var Fw=eC;J({"X-Aperture-Tenant-Id":G(Q)});var Iw=Y(tC);J({"X-Aperture-Tenant-Id":G(Q)});var Lw=tC;J({"X-Aperture-Tenant-Id":G(Q)});var Rw=tC;J({"X-Aperture-Tenant-Id":G(Q)});var zw=tC;J({"X-Aperture-Tenant-Id":G(Q)});var Bw=nC;J({"X-Aperture-Tenant-Id":G(Q)});var Vw=rC;J({"X-Aperture-Tenant-Id":G(Q)});var Hw=OC;J({"X-Aperture-Tenant-Id":G(Q),limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),name:G(K),deleted:G(X([`active`,`deleted`,`all`]).annotate({default:`active`})),includeDeleted:G(sb.annotate({default:!1})),tagKey:G(Y(K.check(Ib(1).annotate({expected:`a value with a length of at least 1`})))),tagValue:G(Y(K.check(Ib(1).annotate({expected:`a value with a length of at least 1`})))),tagOperator:G(Y(X([`eq`,`neq`,`in`,`not_in`])))});var Uw=kC;J({"X-Aperture-Tenant-Id":G(Q)});var Ww=OC;J({"X-Aperture-Tenant-Id":G(Q)});var Gw=OC;J({"X-Aperture-Tenant-Id":G(Q)});var Kw=OC;J({"X-Aperture-Tenant-Id":G(Q)});var qw=OC;J({"X-Aperture-Tenant-Id":G(Q),limit:G(q.annotate({default:50}).check(Fb().annotate({expected:`an integer`})).check(Mb(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:G(K),resourceType:G(K),resourceId:G(K)});var Jw=CC,Yw=(e,t={})=>{let n=e=>V(Rd(e.json,()=>`Unexpected status code`),t=>B(new px({reason:new vx({request:e.request,response:e,description:typeof t==`string`?t:JSON.stringify(t)})}))),r=n=>r=>{let i=n?.includeResponse?e=>kd(r(e),t=>[t,e]):e=>r(e);return t?.transformClient?n=>V(V(t.transformClient(e),e=>e.execute(n)),i):t=>V(e.execute(t),i)},i=encodeURIComponent,a=(e,t,n)=>gd(()=>{let r=(t,n)=>B(new px({reason:new _x({request:e(``),cause:n,description:t})}));if(t.some(e=>e===``||/^(?:\.|%2e){1,2}$/i.test(e)))return r(`Path parameters must be non-empty and cannot be dot segments`);let i;try{i=n()}catch(e){return r(`Failed to encode path parameter`,e)}return i.split(`/`).some(e=>/^(?:\.|%2e){1,2}$/i.test(e))?r(`Request paths cannot contain dot segments`):R(e(i))}),o=e=>t=>eS(e)(t);return{httpClient:e,getHealth:e=>jx(`/api/health`).pipe(r(e?.config)(Z({"2xx":o(YC),orElse:n}))),getCurrentPrincipal:e=>jx(`/api/auth/me`).pipe(zx({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":o(XC),orElse:n}))),listBrowserChannels:e=>jx(`/api/browser/channels`).pipe(r(e?.config)(Z({"2xx":o(ZC),orElse:n}))),listTenants:e=>jx(`/api/admin/tenants`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,deleted:e?.params?.deleted,includeDeleted:e?.params?.includeDeleted}),r(e?.config)(Z({"2xx":o(QC),orElse:n}))),createTenant:e=>Mx(`/api/admin/tenants`).pipe(Zx(e.payload),r(e.config)(Z({"2xx":o($C),orElse:n}))),deleteTenant:(e,t)=>a(Fx,[e],()=>`/api/admin/tenants/`+i(e)).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(ew),orElse:n}))))),updateTenant:(e,t)=>a(Nx,[e],()=>`/api/admin/tenants/`+i(e)).pipe(V(e=>e.pipe(Zx(t.payload),r(t.config)(Z({"2xx":o(tw),orElse:n}))))),restoreTenant:(e,t)=>a(Mx,[e],()=>`/api/admin/tenants/`+i(e)+`/restore`).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(nw),orElse:n}))))),listUsers:e=>jx(`/api/admin/users`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,query:e?.params?.query,disabled:e?.params?.disabled}),r(e?.config)(Z({"2xx":o(rw),orElse:n}))),createUser:e=>Mx(`/api/admin/users`).pipe(Zx(e.payload),r(e.config)(Z({"2xx":o(iw),orElse:n}))),getUser:(e,t)=>a(jx,[e],()=>`/api/admin/users/`+i(e)).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(aw),orElse:n}))))),disableUser:(e,t)=>a(Fx,[e],()=>`/api/admin/users/`+i(e)).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(ow),orElse:n}))))),updateUser:(e,t)=>a(Nx,[e],()=>`/api/admin/users/`+i(e)).pipe(V(e=>e.pipe(Zx(t.payload),r(t.config)(Z({"2xx":o(sw),orElse:n}))))),restoreUser:(e,t)=>a(Mx,[e],()=>`/api/admin/users/`+i(e)+`/restore`).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(cw),orElse:n}))))),createUserInvitation:(e,t)=>a(Mx,[e],()=>`/api/admin/users/`+i(e)+`/invitation`).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(lw),orElse:n}))))),listUserMemberships:(e,t)=>a(jx,[e],()=>`/api/admin/users/`+i(e)+`/memberships`).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(uw),orElse:n}))))),listTenantMemberships:(e,t)=>a(jx,[e],()=>`/api/admin/tenants/`+i(e)+`/memberships`).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(dw),orElse:n}))))),upsertTenantMembership:(e,t,s)=>a(Px,[e,t],()=>`/api/admin/tenants/`+i(e)+`/memberships/`+i(t)).pipe(V(e=>e.pipe(Zx(s.payload),r(s.config)(Z({"2xx":o(fw),orElse:n}))))),deleteTenantMembership:(e,t,s)=>a(Fx,[e,t],()=>`/api/admin/tenants/`+i(e)+`/memberships/`+i(t)).pipe(V(e=>e.pipe(r(s?.config)(Z({"2xx":o(pw),204:()=>_d,orElse:n}))))),listAuditEvents:e=>jx(`/api/admin/audit-events`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,tenantId:e?.params?.tenantId,actorType:e?.params?.actorType,actorId:e?.params?.actorId,action:e?.params?.action,resourceType:e?.params?.resourceType,resourceId:e?.params?.resourceId}),r(e?.config)(Z({"2xx":o(mw),orElse:n}))),listAdminTokens:e=>jx(`/api/admin/tokens`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,authorityType:e?.params?.authorityType,tenantId:e?.params?.tenantId,name:e?.params?.name,scope:e?.params?.scope,revoked:e?.params?.revoked}),r(e?.config)(Z({"2xx":o(hw),orElse:n}))),createAdminToken:e=>Mx(`/api/admin/tokens`).pipe(Zx(e.payload),r(e.config)(Z({"2xx":o(gw),orElse:n}))),revokeAdminToken:(e,t)=>a(Mx,[e],()=>`/api/admin/tokens/`+i(e)+`/revoke`).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(_w),204:()=>_d,orElse:n}))))),getTenant:e=>jx(`/api/tenant`).pipe(r(e?.config)(Z({"2xx":o(vw),orElse:n}))),updateSelectedTenant:e=>Nx(`/api/tenant`).pipe(Zx(e.payload),r(e.config)(Z({"2xx":o(yw),orElse:n}))),listTenantTokens:e=>jx(`/api/tenant/tokens`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,name:e?.params?.name,scope:e?.params?.scope,revoked:e?.params?.revoked}),r(e?.config)(Z({"2xx":o(bw),orElse:n}))),createTenantToken:e=>Mx(`/api/tenant/tokens`).pipe(Zx(e.payload),r(e.config)(Z({"2xx":o(xw),orElse:n}))),revokeTenantToken:(e,t)=>a(Mx,[e],()=>`/api/tenant/tokens/`+i(e)+`/revoke`).pipe(V(e=>e.pipe(r(t?.config)(Z({"2xx":o(Sw),204:()=>_d,orElse:n}))))),listSessions:e=>jx(`/api/sessions`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,includeDeleted:e?.params?.includeDeleted,status:e?.params?.status,tagKey:e?.params?.tagKey,tagValue:e?.params?.tagValue,tagOperator:e?.params?.tagOperator}),zx({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":o(Cw),orElse:n}))),createSession:e=>Mx(`/api/sessions`).pipe(Jx({waitForReady:e.params?.waitForReady}),zx({"X-Aperture-Tenant-Id":e.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(e.payload),r(e.config)(Z({"2xx":o(ww),orElse:n}))),getSessionsBulk:e=>Mx(`/api/sessions/bulk`).pipe(zx({"X-Aperture-Tenant-Id":e.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(e.payload),r(e.config)(Z({"2xx":o(Tw),orElse:n}))),getSession:(e,t)=>a(jx,[e],()=>`/api/sessions/`+i(e)).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(Ew),orElse:n}))))),deleteSession:(e,t)=>a(Fx,[e],()=>`/api/sessions/`+i(e)).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(Dw),orElse:n}))))),replaceSessionTags:(e,t)=>a(Px,[e],()=>`/api/sessions/`+i(e)+`/tags`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(Ow),orElse:n}))))),updateSessionProxy:(e,t)=>a(Px,[e],()=>`/api/sessions/`+i(e)+`/proxy`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(kw),orElse:n}))))),suspendSession:(e,t)=>a(Mx,[e],()=>`/api/sessions/`+i(e)+`/suspend`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(Aw),orElse:n}))))),reopenSession:(e,t)=>a(Mx,[e],()=>`/api/sessions/`+i(e)+`/reopen`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(jw),orElse:n}))))),rotateSessionToken:(e,t)=>a(Mx,[e],()=>`/api/sessions/`+i(e)+`/session-token/rotate`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(Mw),orElse:n}))))),rotateCollaborationCapability:(e,t,s)=>a(Mx,[e,t],()=>`/api/sessions/`+i(e)+`/collaboration-capabilities/`+i(t)+`/rotate`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":s?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(s?.config)(Z({"2xx":o(Nw),orElse:n}))))),getSessionCursor:(e,t)=>a(jx,[e],()=>`/api/sessions/`+i(e)+`/cursor`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(Pw),orElse:n}))))),setSessionCursor:(e,t)=>a(Px,[e],()=>`/api/sessions/`+i(e)+`/cursor`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(Fw),orElse:n}))))),listSessionRecordings:(e,t)=>a(jx,[e],()=>`/api/sessions/`+i(e)+`/recordings`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(Iw),orElse:n}))))),createSessionRecording:(e,t)=>a(Mx,[e],()=>`/api/sessions/`+i(e)+`/recordings`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(Lw),orElse:n}))))),getSessionRecording:(e,t,s)=>a(jx,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":s?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(s?.config)(Z({"2xx":o(Rw),orElse:n}))))),retargetSessionRecording:(e,t,s)=>a(Mx,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/retarget`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":s.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(s.payload),r(s.config)(Z({"2xx":o(zw),orElse:n}))))),stopSessionRecording:(e,t,s)=>a(Mx,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/stop`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":s?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(s?.config)(Z({"2xx":o(Bw),orElse:n}))))),createSessionFileDownloadURL:(e,t)=>a(Mx,[e],()=>`/api/sessions/`+i(e)+`/files/download-url`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(Vw),orElse:n}))))),promoteSession:(e,t)=>a(Mx,[e],()=>`/api/sessions/`+i(e)+`/promote`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(Hw),orElse:n}))))),listSnapshots:e=>jx(`/api/snapshots`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,name:e?.params?.name,deleted:e?.params?.deleted,includeDeleted:e?.params?.includeDeleted,tagKey:e?.params?.tagKey,tagValue:e?.params?.tagValue,tagOperator:e?.params?.tagOperator}),zx({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":o(Uw),orElse:n}))),deleteSnapshot:(e,t)=>a(Fx,[e],()=>`/api/snapshots/`+i(e)).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(Ww),orElse:n}))))),updateSnapshot:(e,t)=>a(Nx,[e],()=>`/api/snapshots/`+i(e)).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(Gw),orElse:n}))))),replaceSnapshotTags:(e,t)=>a(Px,[e],()=>`/api/snapshots/`+i(e)+`/tags`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Zx(t.payload),r(t.config)(Z({"2xx":o(Kw),orElse:n}))))),restoreSnapshot:(e,t)=>a(Mx,[e],()=>`/api/snapshots/`+i(e)+`/restore`).pipe(V(e=>e.pipe(zx({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":o(qw),orElse:n}))))),listEvents:e=>jx(`/api/events`).pipe(Jx({limit:e?.params?.limit,cursor:e?.params?.cursor,resourceType:e?.params?.resourceType,resourceId:e?.params?.resourceId}),zx({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":o(Jw),orElse:n})))}},Xw=`X-Aperture-Tenant-Id`,Zw={kind:`session`,authorityType:null,tenantId:null,selectedTenantId:null};function Qw(e,t){if(t!==`none`){if(t===`optional`)return e.selectedTenantId??void 0;if(e.authorityType===`tenant`)return e.kind===`bearer`?void 0:e.tenantId??void 0;if(e.authorityType===`system_admin`)return e.selectedTenantId??void 0}}var $w={anonymous:{},webSession:{credentials:Zw},of:e=>({credentials:e}),tenantScoped:e=>({credentials:e,tenantHeader:`tenant-scoped`})},eT=class extends dr()(`@aperture-browser/api-client/ApiAuthorization`){},tT=X([`ble`,`cable`,`hybrid`,`internal`,`nfc`,`smart-card`,`usb`]),nT=J({id:K,type:rb(`public-key`),transports:G(db(Y(tT)))}),rT=G(J({appid:G(K),credProps:G(sb),hmacCreateSecret:G(sb),minPinLength:G(sb)})),iT=X([`hybrid`,`security-key`,`client-device`]),aT=X([`discouraged`,`preferred`,`required`]),oT=J({methods:Y(pb([J({type:rb(`password`)}),J({type:rb(`api_token`)}),J({type:rb(`passkey`)}),J({type:rb(`oidc`),id:K,name:K,loginUrl:K})]))}),sT=J({publicKey:J({challenge:K,timeout:G(q),rpId:G(K),allowCredentials:G(db(Y(nT))),userVerification:G(aT),hints:G(db(Y(iT))),extensions:rT})}),cT=J({publicKey:J({rp:J({id:G(K),name:K}),user:J({id:K,name:K,displayName:K}),challenge:K,pubKeyCredParams:db(Y(J({alg:X([-7,-8,-35,-36,-37,-38,-39,-257,-258,-259]),type:rb(`public-key`)}))),timeout:G(q),excludeCredentials:G(db(Y(nT))),authenticatorSelection:G(J({authenticatorAttachment:G(X([`platform`,`cross-platform`])),requireResidentKey:G(sb),residentKey:G(X([`discouraged`,`preferred`,`required`])),userVerification:G(aT)})),hints:G(db(Y(iT))),attestation:G(X([`direct`,`enterprise`,`indirect`,`none`])),attestationFormats:G(db(Y(X([`fido-u2f`,`packed`,`android-safetynet`,`android-key`,`tpm`,`apple`,`none`])))),extensions:rT})}),lT=J({id:K,name:K,createdAt:K,lastUsedAt:mb(K)}),uT=J({passkeys:Y(lT)}),dT=J({passkey:lT}),fT=J({mfaRequired:sb}),pT=J({hasPassword:sb,totpEnabled:sb,recoveryCodesRemaining:q.check(Fb(),Mb(0))}),mT=J({secret:K,otpauthUrl:K,qrCodeDataUrl:K}),hT=J({recoveryCodes:Y(K)}),gT=class extends dr()(`@aperture-browser/api-client/AuthApi`){},_T=e=>({body:dx(e)}),vT=bu(gT,yd(function*(){let e=yield*cS,{authorize:t}=yield*eT,n=uS(e),r=Yw(e),i=t($w.anonymous),a=t($w.webSession),o=U(`AuthApi.listLoginMethods`)(function*(){return yield*n.get(`/auth/login-methods`).pipe(V(eS(oT)),i)}),s=U(`AuthApi.loginWithPassword`)(function*(e,t){return yield*n.post(`/auth/password/login`,_T({email:e,password:t})).pipe(V(eS(fT)),i)}),c=U(`AuthApi.completePasswordMFA`)(function*(e){yield*n.post(`/auth/password/login/mfa`,_T({code:e})).pipe(i)}),l=U(`AuthApi.loginWithAPIToken`)(function*(e){yield*n.post(`/auth/token/login`,_T({token:e})).pipe(i)}),u=U(`AuthApi.beginPasskeyLogin`)(function*(){return yield*n.post(`/auth/passkeys/login/options`).pipe(V(eS(sT)),i)}),d=U(`AuthApi.finishPasskeyLogin`)(function*(e){yield*n.post(`/auth/passkeys/login/finish`,_T(e)).pipe(i)}),f=U(`AuthApi.acceptUserInvitation`)(function*(e,t){yield*n.post(`/auth/invitations/accept`,_T({token:e,password:t})).pipe(i)}),p=U(`AuthApi.logoutWebSession`)(function*(){yield*n.post(`/auth/logout`).pipe(a)}),m=U(`AuthApi.getAuthMe`)(function*(e=null,n=Zw){return yield*r.getCurrentPrincipal(void 0).pipe(t({credentials:{...n,selectedTenantId:e},tenantHeader:`optional`}))}),h=U(`AuthApi.getSecurityStatus`)(function*(){return yield*n.get(`/auth/security`).pipe(V(eS(pT)),a)}),g=U(`AuthApi.setPassword`)(function*(e,t){yield*n.put(`/auth/password`,_T({currentPassword:e,newPassword:t})).pipe(a)}),_=U(`AuthApi.listPasskeys`)(function*(){return yield*n.get(`/auth/passkeys`).pipe(V(eS(uT)),a)}),v=U(`AuthApi.beginPasskeyRegistration`)(function*(e){return yield*n.post(`/auth/passkeys/registration/options`,_T({name:e})).pipe(V(eS(cT)),a)}),y=U(`AuthApi.finishPasskeyRegistration`)(function*(e){return yield*n.post(`/auth/passkeys/registration/finish`,_T(e)).pipe(V(eS(dT)),a)}),b=U(`AuthApi.renamePasskey`)(function*(e,t){return yield*n.patch(`/auth/passkeys/${encodeURIComponent(e)}`,_T({name:t})).pipe(V(eS(dT)),a)}),x=U(`AuthApi.deletePasskey`)(function*(e){yield*n.del(`/auth/passkeys/${encodeURIComponent(e)}`).pipe(a)}),ee=U(`AuthApi.beginTOTPEnrollment`)(function*(){return yield*n.post(`/auth/totp/enrollment/options`).pipe(V(eS(mT)),a)}),S=U(`AuthApi.completeTOTPEnrollment`)(function*(e){return yield*n.post(`/auth/totp/enrollment/finish`,_T({code:e})).pipe(V(eS(hT)),a)}),C=U(`AuthApi.regenerateRecoveryCodes`)(function*(e){return yield*n.post(`/auth/totp/recovery-codes`,_T({code:e})).pipe(V(eS(hT)),a)}),te=U(`AuthApi.disableTOTP`)(function*(e){yield*n.post(`/auth/totp/disable`,_T({code:e})).pipe(a)});return gT.of({listLoginMethods:o,loginWithPassword:s,completePasswordMFA:c,loginWithAPIToken:l,beginPasskeyLogin:u,finishPasskeyLogin:d,acceptUserInvitation:f,logoutWebSession:p,getAuthMe:m,getSecurityStatus:h,setPassword:g,listPasskeys:_,beginPasskeyRegistration:v,finishPasskeyRegistration:y,renamePasskey:b,deletePasskey:x,beginTOTPEnrollment:ee,completeTOTPEnrollment:S,regenerateRecoveryCodes:C,disableTOTP:te})})),yT=J({error:J({code:K,message:K})}),bT=class extends ex()(`ApiRequestError`,{code:K,message:K,status:q}){},xT=e=>new bT({code:`internal_error`,message:`Invalid response`,status:e}),ST=new bT({code:`network_error`,message:`The server could not be reached`,status:0}),CT=e=>e.pipe(Pd(`HttpClientError`,{StatusCodeError:({response:e})=>eS(yT)(e).pipe(kd(({error:t})=>new bT({...t,status:e.status})),Rd(()=>new bT({code:`internal_error`,message:`Request failed`,status:e.status})),V(B)),DecodeError:({response:e})=>B(xT(e.status))}),Nd({HttpClientError:()=>B(ST),SchemaError:()=>B(xT(0))})),wT=Ur(`@aperture-browser/api-client/CurrentAuthorization`,{defaultValue:()=>({})}),TT=e=>wT.useSync(({credentials:t,bearerToken:n,tenantHeader:r=`none`})=>{let i=n??(t?.kind===`bearer`?t.token.trim():void 0),a=t?Qw(t,r):void 0;return e.pipe(Wx,i?Hx(i):x,a?Rx(Xw,a):Vx(Xw))}),ET=new Set([`authentication_required`,`invalid_authentication_token`,`authentication_token_expired`,`authentication_token_revoked`,`user_disabled`]),DT=bu(cS,kd(cS,hS(TT))),OT=bu(eT,yd(function*(){let e=yield*Zf();return eT.of({authorize:t=>n=>n.pipe(CT,Id(n=>t.credentials?.kind===`session`&&ET.has(n.code)?$f(e,void 0):_d),Jd(wT,t)),sessionAuthenticationFailures:Jp(e)})})),kT=e=>({tagKey:e?.map(e=>e.key),tagOperator:e?.map(e=>e.operator),tagValue:e?.map(e=>e.values.join(`,`))}),AT=e=>Object.fromEntries(Object.entries(e).flatMap(([e,t])=>{if(t==null||t===``)return[];if(!Array.isArray(t))return[[e,t]];let n=t.filter(e=>e!==``);return n.length>0?[[e,n]]:[]})),jT=class extends dr()(`@aperture-browser/api-client/EventsApi`){},MT=bu(jT,yd(function*(){let e=yield*cS,{authorize:t}=yield*eT,n=Yw(e),r=U(`EventsApi.listEvents`)(function*(e,r={}){return yield*n.listEvents({params:AT({limit:r.limit,cursor:r.cursor,resourceType:r.resourceType,resourceId:r.resourceId})}).pipe(t($w.tenantScoped(e)))});return jT.of({listEvents:r})})),NT=q.check(Fb(),jb(0)),PT=R([]),FT=J({sessionId:K,cdpUrl:K,media:fC,targets:Y(J({targetId:K,generation:NT,state:X([`pending`,`ready`,`unavailable`,`closed`]),title:K,url:K,viewport:J({width:NT,height:NT,deviceScaleFactor:q.check(jb(0)),contentWidth:NT,contentHeight:NT,canvasWidth:NT,canvasHeight:NT})})).pipe(bb(PT))}),IT=J({recordingId:K,mode:X([`tab`,`viewer`]),targetId:K,captureGeneration:NT,status:X([`starting`,`running`,`stopped`,`failed`]),stopReason:G(K),path:K,startedAt:K,stoppedAt:G(K),sizeBytes:G(q.check(Fb(),Mb(0))),fps:NT,bitrateKbps:NT,codec:K}),LT=class extends dr()(`@aperture-browser/api-client/SessionsApi`){},RT=e=>e?.match(/filename="([^"]+)"/)?.[1]??null,zT=bu(LT,yd(function*(){let e=yield*cS,{authorize:t}=yield*eT,n=uS(e),r=Yw(e),i=e=>t($w.tenantScoped(e)),a=U(`SessionsApi.listSessions`)(function*(e,t={}){return yield*r.listSessions({params:AT({limit:t.limit,cursor:t.cursor,includeDeleted:t.includeDeleted||void 0,status:t.status,...kT(t.tags)})}).pipe(i(e))}),o=U(`SessionsApi.getSession`)(function*(e,t){return yield*r.getSession(t,void 0).pipe(i(e))}),s=U(`SessionsApi.getSessionsBulk`)(function*(e,t){return yield*r.getSessionsBulk({payload:{ids:t}}).pipe(i(e))}),c=U(`SessionsApi.createSession`)(function*(e,t,n={}){return yield*r.createSession({params:AT({waitForReady:n.waitForReady}),payload:{baseSnapshotName:t.baseSnapshotName??null,label:t.label??null,browser:{channel:t.browser.channel,args:t.browser.args??[]},initialTargets:t.initialTargets??[],...t.storageState===void 0?{}:{storageState:t.storageState},tags:t.tags??{}}}).pipe(i(e))}),l=U(`SessionsApi.deleteSession`)(function*(e,t){return yield*r.deleteSession(t,void 0).pipe(i(e))}),u=U(`SessionsApi.reopenSession`)(function*(e,t){return yield*r.reopenSession(t,void 0).pipe(i(e))}),d=U(`SessionsApi.suspendSession`)(function*(e,t){return yield*r.suspendSession(t,void 0).pipe(i(e))}),f=U(`SessionsApi.rotateSessionToken`)(function*(e,t){return yield*r.rotateSessionToken(t,void 0).pipe(i(e))}),p=U(`SessionsApi.rotateCollaborationCapability`)(function*(e,t,n){return yield*r.rotateCollaborationCapability(t,n,void 0).pipe(i(e))}),m=U(`SessionsApi.replaceSessionTags`)(function*(e,t,n){return yield*r.replaceSessionTags(t,{payload:{tags:n}}).pipe(i(e))}),h=U(`SessionsApi.promoteSession`)(function*(e,t,n){return yield*r.promoteSession(t,{payload:{name:n.name,description:n.description??null,force:n.force??!1,tags:n.tags??{}}}).pipe(i(e))}),g=U(`SessionsApi.getBrowserChannels`)(function*(e){return yield*r.listBrowserChannels(void 0).pipe(i(e))}),_=U(`SessionsApi.getBrowserStatus`)(function*(e,r,i){return yield*n.get(`/sessions/${encodeURIComponent(r)}/browser/status`).pipe(V(eS(FT)),t({credentials:e,bearerToken:i}))}),v=U(`SessionsApi.downloadSessionRecording`)(function*(e,r,i,a){return yield*n.get(`/sessions/${encodeURIComponent(r)}/recordings/${encodeURIComponent(i)}/content`).pipe(V(e=>kd(e.arrayBuffer,t=>({blob:new Blob([t],{type:e.headers[`content-type`]??``}),filename:RT(e.headers[`content-disposition`])}))),t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}))});return LT.of({listSessions:a,getSession:o,getSessionsBulk:s,createSession:c,deleteSession:l,reopenSession:u,suspendSession:d,rotateSessionToken:f,rotateCollaborationCapability:p,replaceSessionTags:m,promoteSession:h,getBrowserChannels:g,getBrowserStatus:_,downloadSessionRecording:v})})),BT=class extends dr()(`@aperture-browser/api-client/SnapshotsApi`){},VT=bu(BT,yd(function*(){let e=yield*cS,{authorize:t}=yield*eT,n=Yw(e),r=e=>t($w.tenantScoped(e)),i=U(`SnapshotsApi.listSnapshots`)(function*(e,t={}){return yield*n.listSnapshots({params:AT({limit:t.limit,cursor:t.cursor,includeDeleted:t.includeDeleted||void 0,deleted:t.deleted,name:t.name,...kT(t.tags)})}).pipe(r(e))}),a=U(`SnapshotsApi.updateSnapshot`)(function*(e,t,i){return yield*n.updateSnapshot(t,{payload:i}).pipe(r(e))}),o=U(`SnapshotsApi.replaceSnapshotTags`)(function*(e,t,i){return yield*n.replaceSnapshotTags(t,{payload:{tags:i}}).pipe(r(e))}),s=U(`SnapshotsApi.deleteSnapshot`)(function*(e,t){return yield*n.deleteSnapshot(t,void 0).pipe(r(e))}),c=U(`SnapshotsApi.restoreSnapshot`)(function*(e,t){return yield*n.restoreSnapshot(t,void 0).pipe(r(e))});return BT.of({listSnapshots:i,updateSnapshot:a,replaceSnapshotTags:o,deleteSnapshot:s,restoreSnapshot:c})})),HT=class extends dr()(`@aperture-browser/api-client/TenantsApi`){},UT=bu(HT,yd(function*(){let e=yield*cS,{authorize:t}=yield*eT,n=Yw(e),r=U(`TenantsApi.listTenants`)(function*(e,r={}){return yield*n.listTenants({params:AT({limit:r.limit,cursor:r.cursor,includeDeleted:r.includeDeleted||void 0,deleted:r.deleted})}).pipe(t($w.of(e)))}),i=U(`TenantsApi.createTenant`)(function*(e,r){return yield*n.createTenant({payload:r}).pipe(t($w.of(e)))}),a=U(`TenantsApi.updateTenant`)(function*(e,r,i){return yield*n.updateTenant(r,{payload:i}).pipe(t($w.of(e)))}),o=U(`TenantsApi.deleteTenant`)(function*(e,r){return yield*n.deleteTenant(r,void 0).pipe(t($w.of(e)))}),s=U(`TenantsApi.restoreTenant`)(function*(e,r){return yield*n.restoreTenant(r,void 0).pipe(t($w.of(e)))});return HT.of({listTenants:r,createTenant:i,updateTenant:a,deleteTenant:o,restoreTenant:s})})),WT=class extends dr()(`@aperture-browser/api-client/TokensApi`){},GT=bu(WT,yd(function*(){let e=yield*cS,{authorize:t}=yield*eT,n=Yw(e),r=U(`TokensApi.listAdminTokens`)(function*(e,r={}){return yield*n.listAdminTokens({params:AT({limit:r.limit,cursor:r.cursor,tenantId:r.tenantId,name:r.name,authorityType:r.authorityType,revoked:r.revoked,scope:r.scope})}).pipe(t($w.of(e)))}),i=U(`TokensApi.createAdminToken`)(function*(e,r){let i=r.authorityType===`system_admin`;return yield*n.createAdminToken({payload:{name:r.name,authorityType:r.authorityType,tenantId:r.tenantId??null,scopes:r.scopes,resourceMode:i?`all`:r.resourceMode,resourceGrants:i?[]:r.resourceGrants,expiresAt:r.expiresAt??null}}).pipe(t($w.of(e)))}),a=U(`TokensApi.revokeAdminToken`)(function*(e,r){yield*n.revokeAdminToken(r,void 0).pipe(t($w.of(e)))}),o=U(`TokensApi.listTenantTokens`)(function*(e,r={}){return yield*n.listTenantTokens({params:AT({limit:r.limit,cursor:r.cursor,name:r.name,revoked:r.revoked,scope:r.scope})}).pipe(t($w.of(e)))}),s=U(`TokensApi.createTenantToken`)(function*(e,r){return yield*n.createTenantToken({payload:{name:r.name,scopes:r.scopes,resourceMode:r.resourceMode,resourceGrants:r.resourceGrants,expiresAt:r.expiresAt??null}}).pipe(t($w.of(e)))}),c=U(`TokensApi.revokeTenantToken`)(function*(e,r){yield*n.revokeTenantToken(r,void 0).pipe(t($w.of(e)))});return WT.of({listAdminTokens:r,createAdminToken:i,revokeAdminToken:a,listTenantTokens:o,createTenantToken:s,revokeTenantToken:c})})),KT=class extends dr()(`@aperture-browser/api-client/UsersApi`){},qT=wu(vT,UT,bu(KT,yd(function*(){let e=yield*cS,{authorize:t}=yield*eT,n=Yw(e),r=U(`UsersApi.listUsers`)(function*(e,r={}){return yield*n.listUsers({params:AT({limit:r.limit,cursor:r.cursor,query:r.query,disabled:r.disabled})}).pipe(t($w.of(e)))}),i=U(`UsersApi.createUser`)(function*(e,r){return yield*n.createUser({payload:r}).pipe(t($w.of(e)))}),a=U(`UsersApi.getUser`)(function*(e,r){return yield*n.getUser(r,void 0).pipe(t($w.of(e)))}),o=U(`UsersApi.updateUser`)(function*(e,r,i){return yield*n.updateUser(r,{payload:i}).pipe(t($w.of(e)))}),s=U(`UsersApi.createUserInvitation`)(function*(e,r){return yield*n.createUserInvitation(r,void 0).pipe(t($w.of(e)))}),c=U(`UsersApi.disableUser`)(function*(e,r){return yield*n.disableUser(r,void 0).pipe(t($w.of(e)))}),l=U(`UsersApi.restoreUser`)(function*(e,r){return yield*n.restoreUser(r,void 0).pipe(t($w.of(e)))}),u=U(`UsersApi.listUserMemberships`)(function*(e,r){return yield*n.listUserMemberships(r,void 0).pipe(t($w.of(e)))}),d=U(`UsersApi.upsertTenantMembership`)(function*(e,r,i,a){let o={scopes:a};return yield*n.upsertTenantMembership(r,i,{payload:o}).pipe(t($w.of(e)))}),f=U(`UsersApi.deleteTenantMembership`)(function*(e,r,i){yield*n.deleteTenantMembership(r,i,void 0).pipe(t($w.of(e)))});return KT.of({listUsers:r,createUser:i,getUser:a,updateUser:o,createUserInvitation:s,disableUser:c,restoreUser:l,listUserMemberships:u,upsertTenantMembership:d,deleteTenantMembership:f})})),zT,VT,GT,MT).pipe(Eu(DT),Du(OT)),JT=e=>bu(cS,kd(cS,mS(Kx(e)))),YT=`aperture-session.v1`,XT={onExcessProperty:`error`},ZT=q.check(Fb()),QT=q.check(jb(0)),$T=ZT.check(jb(0)),eE=q.check(Pb({minimum:0,maximum:1})),tE=R([]);function nE(e){return Y(e).pipe(bb(tE))}var rE=X([`implicit`,`explicit`]),iE=J({profile:K,fps:ZT.check(Pb({minimum:1,maximum:120})),bitrateKbps:ZT.check(Mb(100)),keyframeInterval:$T}),aE=J({id:K,label:K,codec:K,mimeType:K,sdpFmtpLine:K}),oE=J({quality:G(iE),profiles:Y(aE),cursorVisible:sb}),sE=J({id:K,type:K,title:K,url:K,loading:sb,viewport:G(J({width:QT,height:QT,contentWidth:QT,contentHeight:QT,canvasWidth:QT,canvasHeight:QT,deviceScaleFactor:QT}))}),cE=J({clientId:K,name:K,avatarHash:K,role:X([`owner`,`editor`,`viewer`,`automation`]),activeTargetId:G(K),followingClientId:G(K),holdingInput:sb,leaseMode:G(rE),recovering:G(sb)}),lE=Qy(Gb(pb([J({type:rb(`session.snapshot`),clientId:K,resumeSecret:K,role:X([`owner`,`editor`,`viewer`]),transport:X([`webrtc`,`websocket`]),holderClientId:G(K),mode:G(rE),activeTargetId:G(K),targets:nE(sE),participants:nE(cE),recordings:nE(IT),presentation:oE}),J({type:rb(`presence.state`),participants:nE(cE)}),J({type:rb(`input.state`),holderClientId:G(K),mode:G(rE)}),J({type:rb(`presence.cursor`),clientId:K,targetId:K,x:eE,y:eE,realtimeCounter:$T}),J({type:rb(`presence.cursor.clear`),clientId:K,realtimeCounter:$T}),J({type:rb(`paint.point`),clientId:K,targetId:K,strokeId:K,color:K.check(wb(/^#[0-9a-fA-F]{6}$/)),width:q.check(Pb({minimum:1,maximum:16})),phase:X([`start`,`move`,`end`]),x:eE,y:eE,realtimeCounter:G($T)}),J({type:rb(`targets.state`),activeTargetId:G(K),targets:nE(sE)}),J({type:rb(`recordings.state`),recordings:nE(IT)}),J({type:rb(`presentation.state`),presentation:oE}),J({type:rb(`error`),code:K,message:K}),J({type:X([`target.select.result`,`target.create.result`,`target.close.result`,`page.navigate.result`,`page.history-back.result`,`page.history-forward.result`,`page.reload.result`,`page.stop-loading.result`,`viewport.set.result`,`presentation.quality.set.result`,`presentation.cursor.set.result`,`recording.start.result`,`recording.stop.result`,`recording.cancel.result`]),requestId:K,ok:sb,code:G(K),message:G(K),targetId:G(K),recording:G(IT),presentation:G(oE)})])),XT),uE=J({type:rb(`presentation.frame`),targetId:K,width:QT,height:QT}),dE=[mE(1280,720,1),mE(1440,900,1),mE(1920,1080,1),mE(2560,1440,1),mE(768,1024,1),mE(390,844,1)],fE=dE[0],pE=[1,1.5,2,3];function mE(e,t,n){return{id:`${e}x${t}@${hE(n)}`,label:`${e}×${t}`,width:e,height:t,deviceScaleFactor:n}}function hE(e){return Number.isInteger(e)?String(e):String(e).replace(/0+$/,``).replace(/\.$/,``)}function gE(e,t,n,r){if(n<=0||r<=0||e<=0||t<=0)return{scale:1,offsetX:0,offsetY:0,renderedWidth:e,renderedHeight:t};let i=Math.min(e/n,t/r),a=n*i,o=r*i;return{scale:i,offsetX:(e-a)/2,offsetY:(t-o)/2,renderedWidth:a,renderedHeight:o}}var _E=`~effect/FiberSet`,vE=e=>D(e,_E),yE={[_E]:_E,[Symbol.iterator](){return this.state._tag===`Closed`?Pi():this.state.backing[Symbol.iterator]()},...jt,toJSON(){return{_id:`FiberSet`,state:this.state}}},bE=(e,t)=>{let n=Object.create(yE);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},xE=()=>Xd(z(()=>bE(new Set,Gl())),e=>gd(()=>{let t=e.state;if(t._tag===`Closed`)return _d;e.state={_tag:`Closed`};let n=t.backing;return Af(n).pipe(Xl(e.deferred))})),SE=()=>V(xE(),e=>DE(e)()),CE=-1,wE=Zi($i(Fu,Qi(CE))),TE=b(e=>vE(e[0]),(e,t,n)=>{if(e.state._tag===`Closed`){t.interruptUnsafe(CE);return}else if(e.state.backing.has(t))return;e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),Hl(r)&&(n?.propagateInterruption===!0?!wE(r.cause):!ju(r.cause))&&L(e.deferred,r))})}),EE=function(){let e;return()=>(e===void 0&&(e=ff(rf)),e)}(),DE=e=>()=>kd(Wd(),t=>{let n=pf(t);return(t,r)=>{if(e.state._tag===`Closed`)return EE();let i=n(t,r);return TE(e,i,r),i}}),OE=class extends la(`LiveSessionError`){},kE=Qy(Gb(pb([J({version:rb(1),type:rb(`answer`),sdp:K}),J({version:rb(1),type:rb(`ice-candidate`),candidate:J({candidate:K,sdpMid:G(mb(K)),sdpMLineIndex:G(mb(q.check(Fb()))),usernameFragment:G(mb(K))})}),J({version:rb(1),type:rb(`error`),error:J({code:K,message:K})})])),XT),AE=Qy(Gb(uE),XT),jE=5e3,ME=500,NE=15e3,PE=wf(function*(e){let{callbacks:t}=e,n=yield*SE(),r=e=>n(e),i=(e,t)=>r(Bd(e).pipe(Ed(z(t)))),a=null,o=null,s=null,c=e.webrtcSupported?`webrtc`:`websocket`,l=null,u=!1,d=null,f=1e3,p=0,m=0,h=0,g=[],_=null,v=new Map,y={hello:()=>({type:`session.hello`,...s??e.identity}),message:(e,t)=>ae(e,t),ready:e=>w(e),failed:(e,t)=>ie(e,t),frame:(e,n)=>{a===e?t.onFrame(n):o===e&&(_=n)}},b=()=>{o?.close(),o=null,g=[],_=null},x=()=>{d?.interruptUnsafe(),d=null},ee=e=>{let t=new OE({message:e});for(let e of v.values())L(e,B(t));v.clear()},S=e=>{if(!l)return;let t=l;l=null,L(t.deferred,B(new OE({message:e})))},C=()=>{c===`webrtc`&&e.webrtcSupported?te():ne()},te=()=>{if(u||o)return;let t;try{t=new LE({baseUrl:e.baseUrl,sessionId:e.sessionId,credentials:e.credentials,sessionToken:e.sessionToken,iceServers:e.iceServers,callbacks:y,fork:r})}catch(e){ce(`webrtc`,FE(e,`WebRTC setup failed`));return}o=t,g=[],_=null,t.connect(),i(jE,()=>{o===t&&(b(),ce(`webrtc`,new OE({message:`WebRTC presentation timed out`})))})},ne=()=>{if(u||o)return;let t;try{t=new IE({baseUrl:e.baseUrl,sessionId:e.sessionId,credentials:e.credentials,sessionToken:e.sessionToken,callbacks:y,fork:r})}catch(e){ce(`websocket`,FE(e,`WebSocket setup failed`));return}o=t,g=[],_=null,t.connect()},re=e=>i(e,()=>{!u&&a===null&&o===null&&ne()}),w=n=>{if(u||o!==n){n.close();return}let r=a,i=g,s=_;if(r&&r!==n&&ee(`live session transport replaced`),o=null,g=[],_=null,a=n,m=0,h=0,f=1e3,t.onPhase(`connected`),t.onTransport(n.kind),l?.kind===n.kind){let e=l;l=null,L(e.deferred,_d)}n instanceof LE?(t.onFrame(null),t.onStream(n.mediaStream())):(t.onStream(null),s&&t.onFrame(s));for(let e of i)oe(e);n.kind===`websocket`&&c===`webrtc`&&e.webrtcSupported&&se(),r&&r!==n&&r.close()},ie=(e,n)=>{if(!u){if(o===e){b(),ce(e.kind,n);return}a===e&&(a=null,e.close(),ee(`live session transport was lost`),t.onPhase(`disconnected`),t.onError(n.message),t.onFrame(null),t.onStream(null),t.onTransport(null),re(e.kind===`webrtc`?0:ME))}},ae=(e,t)=>{if(t.type===`error`&&t.code===`resume_rejected`&&o===e&&a===null&&(s=null),t.type===`session.snapshot`&&(s={clientId:t.clientId,resumeSecret:t.resumeSecret}),a!==e){if(o!==e)return;g.push(t),t.type===`session.snapshot`&&e.kind===`websocket`&&w(e);return}oe(t)},oe=e=>{if(`realtimeCounter`in e&&e.realtimeCounter!==void 0){if(e.realtimeCounter<=h)return;h=e.realtimeCounter}if(`requestId`in e){let t=v.get(e.requestId);t&&(v.delete(e.requestId),L(t,e.ok?R(e):B(new OE({message:e.message??`live session command failed`}))))}t.onMessage(e)},se=()=>{if(u||c!==`webrtc`||!e.webrtcSupported||a?.kind===`webrtc`||d!==null)return;let t=f;f=Math.min(NE,f*2),d=i(t,()=>{d=null,te()})},ce=(e,n)=>{if(l?.kind===e&&(S(n.message),a&&(c=a.kind)),a){a.kind===`websocket`&&se();return}if(e===`webrtc`){ne();return}t.onPhase(`disconnected`),t.onError(n.message),re(ME)},le=e=>a?.sendReliable(e)??!1,ue=e=>(m+=1,a?.sendRealtime({realtimeCounter:m,...e})??!1),T=()=>{u=!0,x(),b(),a?.close(),a=null,S(`live session connection closed`),ee(`live session connection closed`),t.onFrame(null),t.onStream(null),t.onTransport(null)};return yield*Qd(()=>z(T)),t.onPhase(`connecting`),C(),{reconnect:z(()=>{x(),b(),a?.close(),a=null,S(`live session transport replaced`),ee(`live session transport replaced`),t.onPhase(`connecting`),C()}),selectTransport:t=>gd(()=>{if(t===`webrtc`&&!e.webrtcSupported)return B(new OE({message:`WebRTC presentation is unavailable`}));if(c=t,x(),o&&o.kind!==t&&b(),S(`presentation selection was replaced`),a?.kind===t)return _d;let n=Gl();return l={kind:t,deferred:n},o===null&&(t===`webrtc`?te():ne()),Kl(n)}),sendReliable:le,sendRealtime:ue,command:(e,t={})=>gd(()=>{p+=1;let n=`request-${p}`,r=Gl();return v.set(n,r),le({type:e,requestId:n,...t})?Kl(r).pipe(af(()=>z(()=>v.delete(n)))):(v.delete(n),B(new OE({message:`live session transport is unavailable`})))})}});function FE(e,t){return new OE({message:e instanceof Error&&e.message?e.message:t})}var IE=class{kind=`websocket`;socket;callbacks;fork;pendingRealtime=new Map;pendingRasterPacket=null;rasterDecoder=null;decodingRaster=!1;realtimeFrame=null;closed=!1;constructor(e){this.callbacks=e.callbacks,this.fork=e.fork,this.socket=new WebSocket(zE(e.baseUrl,e.sessionId),HE(e.credentials,e.sessionToken)),this.socket.binaryType=`blob`}connect(){this.socket.addEventListener(`open`,()=>{this.sendReliable(this.callbacks.hello())}),this.socket.addEventListener(`message`,e=>{if(typeof e.data==`string`){let t=lE(e.data);rr(t)&&this.callbacks.message(this,t.value);return}e.data instanceof Blob&&(this.pendingRasterPacket=e.data,this.decodingRaster||(this.decodingRaster=!0,this.rasterDecoder=this.fork(this.decodeRasterPackets())))}),this.socket.addEventListener(`close`,()=>{this.closed||this.callbacks.failed(this,new OE({message:`WebSocket session transport closed`}))}),this.socket.addEventListener(`error`,()=>{this.closed||this.callbacks.failed(this,new OE({message:`WebSocket session transport failed`}))})}sendReliable(e){return this.flushRealtime(),this.sendNow(e)}sendRealtime(e){return this.socket.readyState===WebSocket.OPEN?(this.pendingRealtime.delete(e.type),this.pendingRealtime.set(e.type,e),this.realtimeFrame===null&&(this.realtimeFrame=window.requestAnimationFrame(()=>{this.realtimeFrame=null,this.flushRealtime()})),!0):!1}close(){this.closed=!0,this.pendingRasterPacket=null,this.rasterDecoder?.interruptUnsafe(),this.rasterDecoder=null,this.realtimeFrame!==null&&(window.cancelAnimationFrame(this.realtimeFrame),this.realtimeFrame=null),this.pendingRealtime.clear(),this.socket.close()}decodeRasterPackets(){return yd({self:this},function*(){for(;;){let e=this.pendingRasterPacket;if(e===null||this.closed){this.decodingRaster=!1;return}this.pendingRasterPacket=null;let t=yield*RE(e);rr(t)&&!this.closed&&this.callbacks.frame(this,t.value)}})}flushRealtime(){this.realtimeFrame!==null&&(window.cancelAnimationFrame(this.realtimeFrame),this.realtimeFrame=null);for(let e of this.pendingRealtime.values())this.sendNow(e);this.pendingRealtime.clear()}sendNow(e){return this.socket.readyState===WebSocket.OPEN?(this.socket.send(JSON.stringify(e)),!0):!1}},LE=class{kind=`webrtc`;connection;reliable;realtime;signal;callbacks;fork;pendingCandidates=[];reliableOpen=!1;realtimeOpen=!1;helloSent=!1;snapshotReceived=!1;stream=null;streamReady=!1;closed=!1;constructor(e){this.callbacks=e.callbacks,this.fork=e.fork,this.connection=new RTCPeerConnection({iceServers:e.iceServers.map(e=>({...e,urls:[...e.urls]}))}),this.reliable=this.connection.createDataChannel(`application`,{ordered:!0}),this.realtime=this.connection.createDataChannel(`application-realtime`,{ordered:!1,maxRetransmits:0}),this.connection.addTransceiver(`video`,{direction:`recvonly`}),this.signal=new WebSocket(BE(e.baseUrl,e.sessionId),HE(e.credentials,e.sessionToken))}connect(){this.reliable.addEventListener(`open`,()=>{this.reliableOpen=!0,this.sendHello()}),this.realtime.addEventListener(`open`,()=>{this.realtimeOpen=!0,this.sendHello()}),this.reliable.addEventListener(`message`,e=>this.handleApplicationMessage(e)),this.realtime.addEventListener(`message`,e=>this.handleApplicationMessage(e));for(let e of[this.reliable,this.realtime])e.addEventListener(`close`,()=>this.fail(`WebRTC session channel closed`)),e.addEventListener(`error`,()=>this.fail(`WebRTC session channel failed`));this.connection.addEventListener(`track`,e=>{this.stream=e.streams[0]??new MediaStream([e.track]);let t=()=>{this.stream&&(this.streamReady=!0,this.maybeReady())};e.track.muted?e.track.addEventListener(`unmute`,t,{once:!0}):t()}),this.connection.addEventListener(`icecandidate`,e=>{e.candidate&&this.signal.readyState===WebSocket.OPEN&&this.signal.send(JSON.stringify({version:1,type:`ice-candidate`,candidate:e.candidate.toJSON()}))}),this.connection.addEventListener(`connectionstatechange`,()=>{(this.connection.connectionState===`failed`||this.connection.connectionState===`closed`)&&this.fail(`WebRTC ${this.connection.connectionState}`)}),this.signal.addEventListener(`open`,()=>{this.fork(this.sendOffer().pipe(Md(`LiveSessionError`,e=>z(()=>this.fail(e.message)))))}),this.signal.addEventListener(`message`,e=>this.handleSignal(e)),this.signal.addEventListener(`close`,()=>this.fail(`WebRTC signaling closed`)),this.signal.addEventListener(`error`,()=>this.fail(`WebRTC signaling failed`))}sendReliable(e){return this.reliable.readyState===`open`?(this.reliable.send(JSON.stringify(e)),!0):!1}sendRealtime(e){return this.realtime.readyState===`open`?(this.realtime.send(JSON.stringify(e)),!0):!1}close(){this.closed=!0,this.reliable.close(),this.realtime.close(),this.connection.close(),this.signal.close()}mediaStream(){return this.stream}sendHello(){this.helloSent||!this.reliableOpen||!this.realtimeOpen||(this.helloSent=this.sendReliable(this.callbacks.hello()))}handleApplicationMessage(e){if(typeof e.data!=`string`)return;let t=lE(e.data);if(nr(t)){this.fail(`WebRTC session message is invalid`);return}this.callbacks.message(this,t.value),t.value.type===`session.snapshot`&&(this.snapshotReceived=!0,this.maybeReady())}handleSignal(e){let t=typeof e.data==`string`?kE(e.data):er();if(nr(t)){this.fail(`WebRTC signaling message is invalid`);return}let n=t.value;if(n.type===`error`){this.fail(n.error.message);return}if(n.type===`answer`){this.fork(hd(()=>this.connection.setRemoteDescription({type:`answer`,sdp:n.sdp})).pipe(Ed(gd(()=>fd(this.pendingCandidates.splice(0),e=>hd(()=>this.connection.addIceCandidate(e)),{discard:!0}))),jd(()=>z(()=>this.fail(`WebRTC answer is invalid`)))));return}if(!this.connection.remoteDescription){this.pendingCandidates.push(n.candidate);return}this.fork(hd(()=>this.connection.addIceCandidate(n.candidate)).pipe(jd(()=>z(()=>this.fail(`WebRTC ICE candidate is invalid`)))))}sendOffer(){return yd({self:this},function*(){let e=e=>FE(e,`WebRTC negotiation failed`),t=yield*hd({try:()=>this.connection.createOffer(),catch:e});yield*hd({try:()=>this.connection.setLocalDescription(t),catch:e});let n=this.connection.localDescription?.sdp;if(!n)return yield*new OE({message:`WebRTC offer is unavailable`});this.signal.send(JSON.stringify({version:1,type:`offer`,sdp:n}))})}maybeReady(){this.snapshotReceived&&this.stream&&this.streamReady&&this.callbacks.ready(this)}fail(e){this.closed||this.callbacks.failed(this,new OE({message:e}))}};function RE(e){return yd(function*(){if(e.size<4)return er();let t=yield*hd(()=>e.slice(0,4).arrayBuffer()),n=new DataView(t).getUint32(0);return n===0||n>e.size-4?er():cr(AE(yield*hd(()=>e.slice(4,4+n).text())),t=>({targetId:t.targetId,data:e.slice(4+n,e.size,`image/jpeg`),width:t.width,height:t.height}))}).pipe(Rd(()=>er()))}function zE(e,t){return VE(e,`/sessions/${encodeURIComponent(t)}/session`)}function BE(e,t){return VE(e,`/sessions/${encodeURIComponent(t)}/webrtc/signal`)}function VE(e,t){let n=new URL(t,e??window.location.href);return n.protocol=n.protocol===`https:`?`wss:`:`ws:`,n.toString()}function HE(e,t){let n=[YT];t?n.push(`authorization.bearer.${t}`):e.kind===`bearer`&&n.push(`authorization.bearer.${e.token}`);let r=Qw(e,`tenant-scoped`);return r&&n.push(`x-aperture-tenant-id.${r}`),n}var $=c(f(),1),UE=`~effect/SubscriptionRef`,WE={...jt,[UE]:{_A:x},toJSON(){return{_id:`SubscriptionRef`,value:this.value}}},GE=e=>kd(Zf({replay:1}),t=>{let n=Object.create(WE);return n.semaphore=bp(1),n.value=e,n.pubsub=t,ep(n.pubsub,e),n}),KE=e=>Jp(e.pubsub),qE=(e,t)=>{e.value=t,ep(e.pubsub,t)},JE=b(2,(e,t)=>e.semaphore.withPermit(z(()=>qE(e,t)))),YE=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),XE=o(((e,t)=>{t.exports=YE()})),ZE=XE(),QE=(0,$.createContext)(null),$E=class extends la(`RuntimeProviderMissingError`){message=`useRuntime must be used inside RuntimeProvider`};function eD({runtime:e,baseUrl:t,children:n}){let r=(0,$.useMemo)(()=>({runtime:e,baseUrl:t}),[e,t]);return(0,ZE.jsx)(QE.Provider,{value:r,children:n})}function tD(){let e=(0,$.useContext)(QE);if(!e)throw new $E;return e}function nD(){return tD().runtime}function rD(){return tD().baseUrl}function iD(e,t){let n=nD();(0,$.useEffect)(()=>{let t=e();if(!t)return;let r=n.runFork(t);return()=>r.interruptUnsafe()},[n,...t])}function aD(e,t){let n=nD(),r=(0,$.useRef)(new Set);return(0,$.useEffect)(()=>{let e=r.current;return()=>{for(let t of e)t.interruptUnsafe();e.clear()}},[]),(0,$.useCallback)((...t)=>{let i=n.runFork(e(...t));i.pollUnsafe()||(r.current.add(i),i.addObserver(()=>r.current.delete(i)))},[n,...t])}var oD=2e3,sD=()=>new OE({message:`live session transport is unavailable`}),cD=40,lD=7e3,uD={left:272,right:273,middle:274};function dD({sessionId:e,displayName:t=null,credentials:n,sessionToken:r,role:i,enabled:a,webrtcSupported:o,iceServers:s}){let c=(0,$.useMemo)(()=>pD(i,t),[t,i]),l=nD(),u=rD(),d=(0,$.useMemo)(()=>l.runSync(GE(null)),[l]),f=(0,$.useMemo)(()=>l.runSync(Zf()),[l]),p=(0,$.useMemo)(()=>KE(d),[d]),m=(0,$.useMemo)(()=>Jp(f),[f]),h=(0,$.useCallback)(e=>l.runSync(JE(d,e)),[d,l]),g=(0,$.useCallback)(e=>ep(f,e),[f]),_=(0,$.useRef)(null),v=(0,$.useRef)(null),y=(0,$.useRef)(``),b=(0,$.useRef)(!1),x=(0,$.useRef)(!1),ee=(0,$.useRef)(!1),S=(0,$.useRef)(0),C=(0,$.useRef)([]),te=(0,$.useRef)(null),ne=(0,$.useRef)(null),re=(0,$.useRef)(null),w=(0,$.useRef)(null),ie=(0,$.useRef)(!1),[ae,oe]=(0,$.useState)(`idle`),[se,ce]=(0,$.useState)([]),[le,ue]=(0,$.useState)(null),[T,E]=(0,$.useState)(null),[de,fe]=(0,$.useState)(null),[pe,me]=(0,$.useState)(null),[D,O]=(0,$.useState)(!1),[he,ge]=(0,$.useState)(!1),[k,_e]=(0,$.useState)(null),[ve,ye]=(0,$.useState)([]),[be,xe]=(0,$.useState)(``),[Se,Ce]=(0,$.useState)(null),[we,Te]=(0,$.useState)(null),[Ee,De]=(0,$.useState)([]),[Oe,ke]=(0,$.useState)(()=>new Map),[Ae,je]=(0,$.useState)(null);ne.current=de,re.current=pe,w.current=k;let Me=(0,$.useCallback)(e=>{switch(e.type){case`session.snapshot`:y.current=e.clientId,xe(e.clientId),v.current=e.holderClientId??null,Ce(e.holderClientId??null),Te(e.mode??null),C.current=e.participants,De(e.participants),te.current=e.participants.find(t=>t.clientId===e.clientId)?.followingClientId??null,ce(e.targets),ue(e.activeTargetId??null),fe(gD(e.targets,e.activeTargetId)),ye(e.recordings),_e(e.presentation??null),je(null);return;case`targets.state`:ce(e.targets),ue(e.activeTargetId??null),fe(gD(e.targets,e.activeTargetId)),O(!1);return;case`presence.state`:C.current=e.participants,De(e.participants),te.current=e.participants.find(e=>e.clientId===y.current)?.followingClientId??null,ke(e=>{let t=te.current;if(!t)return e.size===0?e:new Map;let n=e.get(t);return n?new Map([[t,n]]):new Map});return;case`input.state`:v.current=e.holderClientId??null,Ce(e.holderClientId??null),Te(e.mode??null),b.current=!1,x.current=!1,je(e=>e?.code===`input_busy`||e?.code===`input_not_owned`?null:e);return;case`presence.cursor`:if(e.clientId!==te.current)return;ke(t=>new Map(t).set(e.clientId,e));return;case`presence.cursor.clear`:ke(t=>{if(!t.has(e.clientId))return t;let n=new Map(t);return n.delete(e.clientId),n});return;case`paint.point`:C.current.some(t=>t.clientId===e.clientId)&&g({type:`point`,message:e});return;case`recordings.state`:ye(e.recordings);return;case`presentation.state`:_e(e.presentation);return;case`error`:b.current=!1,x.current=!1,je({code:e.code,message:e.message});return;default:e.presentation&&_e(e.presentation),e.ok||je({code:e.code??`request_rejected`,message:e.message??`Live session command failed.`})}},[g]);iD(()=>{if(!a||!e||!n){_.current=null,oe(`idle`),ce([]),ue(null),E(null),fe(null),me(null),_e(null),O(!1),ge(!1),De([]),ke(new Map),ye([]),h(null),g({type:`clear`});return}return yd(function*(){let t=yield*PE({baseUrl:u,sessionId:e,credentials:n,sessionToken:r,identity:c,iceServers:s,webrtcSupported:o,callbacks:{onPhase:oe,onMessage:Me,onFrame:h,onStream:E,onTransport:me,onError:e=>je({code:`connection_failed`,message:e})}});return _.current=t,yield*Qd(()=>z(()=>{_.current===t&&(_.current=null)})),yield*vd}).pipe(Yd,$d(z(()=>{h(null),g({type:`clear`})})))},[u,n,a,Me,s,c,h,g,e,r,o]);let Ne=(0,$.useCallback)(e=>_.current?.sendReliable(e)??!1,[]),Pe=(0,$.useCallback)(e=>_.current?.sendRealtime(e)??!1,[]),Fe=aD((e,t,n)=>e.command(t,n).pipe(jd(e=>z(()=>{O(!1),je({code:`request_rejected`,message:e.message})}))),[]),Ie=(0,$.useCallback)((e,t={})=>{let n=_.current;return n?(Fe(n,e,t),!0):!1},[Fe]),Le=(0,$.useCallback)((e,t={})=>gd(()=>_.current?_.current.command(e,t):B(sD())),[]),Re=aD((e,t)=>e.command(`target.select`,{targetId:t}).pipe(Hd({onSuccess:()=>ue(t),onFailure:e=>je({code:`request_rejected`,message:e.message})}),$d(z(()=>O(!1)))),[]),ze=(0,$.useCallback)(e=>gd(()=>{let t=_.current;return t?(O(!0),t.command(`target.select`,{targetId:e}).pipe(Dd(()=>z(()=>ue(e))),Id(e=>z(()=>je({code:`request_rejected`,message:e.message}))),$d(z(()=>O(!1))),Ad)):B(sD())}),[]),Be=(0,$.useCallback)(e=>{let t=_.current;return t?(O(!0),Re(t,e),!0):!1},[Re]),Ve=(0,$.useCallback)(e=>gd(()=>{let t=_.current;return t?ie.current?B(new OE({message:`another presentation update is already in progress`})):(ie.current=!0,ge(!0),yd(function*(){switch(e.kind){case`jpeg`:return yield*t.selectTransport(`websocket`);case`webrtc-retry`:return yield*t.selectTransport(`webrtc`);case`webrtc`:{let n=ne.current;if(!n)return yield*new OE({message:`presentation size is unavailable`});let r=w.current?.quality?.profile!==e.quality.profile&&re.current===`webrtc`;r&&(yield*t.selectTransport(`websocket`));let i=yield*t.command(`presentation.quality.set`,{profile:e.quality.profile,width:n.canvasWidth,height:n.canvasHeight,fps:e.quality.fps,bitrateKbps:e.quality.bitrateKbps}).pipe(Id(()=>r?Ld(t.selectTransport(`webrtc`)):_d));return i.presentation&&_e(i.presentation),yield*t.selectTransport(`webrtc`)}default:return e}}).pipe(Id(e=>z(()=>je({code:`presentation_update_failed`,message:e.message}))),$d(z(()=>{ie.current=!1,ge(!1)})))):B(sD())}),[]),He=(0,$.useCallback)((e,t)=>i===`viewer`||!Ne({type:`input.claim`,targetId:e,mode:t})?!1:(b.current=!0,x.current=!1,!0),[i,Ne]),Ue=(0,$.useCallback)(()=>x.current||v.current!==y.current||!Ne({type:`input.release`})?!1:(x.current=!0,b.current=!1,!0),[Ne]),We=(0,$.useCallback)(e=>e?Be(e):!1,[Be]),Ge=(0,$.useCallback)(e=>Ne({type:`follow.set`,followingClientId:e??``}),[Ne]),Ke=(0,$.useCallback)((e,t,n,r)=>{let i=performance.now();if(i-S.current<cD)return!1;S.current=i;let a=Pe({type:`presence.cursor`,targetId:e,x:_D(t,r.width),y:_D(n,r.height)});return a&&(ee.current=!0),a},[Pe]),qe=(0,$.useCallback)(e=>e.phase===`move`?Pe({type:`paint.point`,...e}):Ne({type:`paint.point`,...e}),[Pe,Ne]),Je=(0,$.useCallback)(()=>!ee.current||!Ne({type:`presence.cursor.clear`})?!1:(ee.current=!1,!0),[Ne]),Ye=(0,$.useCallback)((e,t=!1)=>t?Pe(e):Ne(e),[Pe,Ne]),Xe=(0,$.useCallback)((e,t)=>{if(i===`viewer`||v.current!==y.current&&!b.current)return!1;switch(e.type){case`input.mouse`:{let n=_D(e.x,t.width),r=_D(e.y,t.height);if(e.action===`move`)return Ye({type:`input.pointer.motion.absolute`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,modifiers:e.modifiers??0},!0);if(e.button===`none`)return!0;let i=uD[e.button??`left`],a=(a,o)=>Ye({type:`input.pointer.button`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,buttonCode:i,pressed:a,clickCount:o,modifiers:e.modifiers??0});if(e.action===`down`||e.action===`up`)return a(e.action===`down`,e.clickCount??1);let o=e.action===`doubleClick`?2:1;for(let t=0;t<o;t+=1){let n=e.action===`doubleClick`?t+1:1;a(!0,n),a(!1,n)}return!0}case`input.wheel`:{let n=_D(e.x,t.width),r=_D(e.y,t.height);return Ye({type:`input.pointer.scroll`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,horizontal:e.deltaX,vertical:e.deltaY,stopHorizontal:!1,stopVertical:!1,modifiers:e.modifiers??0}),Ye({type:`input.pointer.scroll`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,horizontal:0,vertical:0,stopHorizontal:e.deltaX!==0,stopVertical:e.deltaY!==0,modifiers:e.modifiers??0})}case`input.key`:{if(e.action===`char`)return e.text?Ye({type:`input.keyboard.text`,targetId:e.targetId,text:e.text}):!1;let t=tm[e.code??``];if(!t)return!1;let n=e.windowsVirtualKeyCode??lm(e.code,e.key);return Ye({type:`input.keyboard.key`,targetId:e.targetId,keycode:t,pressed:e.action===`down`,key:e.key,code:e.code,text:e.text,unmodifiedText:e.unmodifiedText,modifiers:e.modifiers??0,windowsVirtualKeyCode:n,nativeVirtualKeyCode:e.nativeVirtualKeyCode??n,location:e.location??0,autoRepeat:e.autoRepeat??!1,isKeypad:e.isKeypad??!1})}case`clipboard.copy`:return vD(Ye,e.targetId,`KeyC`);case`clipboard.cut`:return vD(Ye,e.targetId,`KeyX`);case`clipboard.paste`:{let t=e.items.find(e=>e.mimeType===`text/plain`);return t?Ye({type:`input.keyboard.text`,targetId:e.targetId,text:t.data}):!1}default:return e}},[i,Ye]),Ze=Se===be&&be!==``,Qe=Ee.find(e=>e.clientId===be)?.followingClientId??null;return iD(()=>Ze?Bd(oD).pipe(Ed(z(()=>{v.current===y.current&&Ne({type:`input.heartbeat`})})),cf):void 0,[Ze,Ne]),{phase:ae,targets:se,activeTargetId:le,frames:p,mediaStream:T,mediaSize:de,transport:pe,presentation:k,mediaSwitching:D||he,recordings:ve,sendBrowserInput:Xe,selectTarget:Be,requestSelectTarget:ze,command:Ie,request:Le,selectPresentation:Ve,reconnect:()=>{let e=_.current;e&&l.runSync(e.reconnect)},collaboration:{phase:ae===`error`?`disconnected`:ae,role:i,clientId:be,holderClientId:Se,leaseMode:we,hasControl:Ze,canRequestControl:i!==`viewer`&&ae===`connected`,lastError:Ae,participants:Ee,cursors:Oe,paintEvents:m,followingClientId:Qe,claim:He,release:Ue,setActiveTarget:We,follow:Ge,sendCursor:Ke,sendPaintPoint:qe,clearCursor:Je,sendInput:Xe}}}var fD=Qy(Gb(J({name:K.check(Rb(1,48)),avatarHash:K.check(wb(/^[0-9a-f]{32}$/))})),XT);function pD(e,t){let n=mD();return e!==`owner`||!t?.trim()?n:{...n,name:Array.from(t.trim()).slice(0,48).join(``)}}function mD(){let e=`aperture.collaboration.identity`;try{let t=window.localStorage.getItem(e);if(t){let e=fD(t);if(rr(e))return e.value}let n=hD();return window.localStorage.setItem(e,JSON.stringify(n)),n}catch{return hD()}}function hD(){let e=[`Amber`,`Brisk`,`Calm`,`Clever`,`Misty`,`Quiet`,`Swift`,`Warm`],t=[`Badger`,`Falcon`,`Fox`,`Koala`,`Otter`,`Panda`,`Raven`,`Tiger`],n=new Uint8Array(18);return crypto.getRandomValues(n),{name:`${e[(n.at(0)??0)%e.length]??`Quiet`} ${t[(n.at(1)??0)%t.length]??`Otter`}`,avatarHash:Array.from(n.slice(2),e=>e.toString(16).padStart(2,`0`)).join(``)}}function gD(e,t){let n=e.find(e=>e.id===t)?.viewport;return n?{width:n.width,height:n.height,canvasWidth:n.canvasWidth,canvasHeight:n.canvasHeight,deviceScaleFactor:n.deviceScaleFactor}:null}function _D(e,t){return t<=1?0:Math.min(1,Math.max(0,e/t))}function vD(e,t,n){let r=tm.ControlLeft,i=tm[n];if(!r||!i)return!1;let a=lm(`ControlLeft`,`Control`),o=n===`KeyC`?`c`:`x`,s=lm(n,o);return e({type:`input.keyboard.key`,targetId:t,keycode:r,pressed:!0,key:`Control`,code:`ControlLeft`,windowsVirtualKeyCode:a,nativeVirtualKeyCode:a,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:i,pressed:!0,key:o,code:n,windowsVirtualKeyCode:s,nativeVirtualKeyCode:s,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:i,pressed:!1,key:o,code:n,windowsVirtualKeyCode:s,nativeVirtualKeyCode:s,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:r,pressed:!1,key:`Control`,code:`ControlLeft`,windowsVirtualKeyCode:a,nativeVirtualKeyCode:a,modifiers:0})}var yD=[`#f43f5e`,`#f97316`,`#eab308`,`#22c55e`,`#06b6d4`,`#8b5cf6`],bD=4,xD=24,SD=2048,CD=512;function wD({collaboration:e,targetId:t,enabled:n,visible:r,left:i,top:a,width:o,height:s}){let c=(0,$.useRef)(null),l=(0,$.useRef)(null),u=(0,$.useRef)(null),d=(0,$.useRef)(0),f=(0,$.useRef)(new Map),p=DD(e.clientId);iD(()=>{let n=c.current;if(!n)return;let r=window.devicePixelRatio||1;n.width=Math.max(1,Math.round(o*r)),n.height=Math.max(1,Math.round(s*r));let i=n.getContext(`2d`);if(!i)return;let a=null,l=new Set(e.participants.map(e=>e.clientId)),u=Date.now();for(let[e,t]of f.current)!t.ended&&!l.has(t.clientId)&&f.current.set(e,{...t,updatedAt:u,ended:!0});let d=()=>{a=null,i.setTransform(r,0,0,r,0,0),i.clearRect(0,0,o,s);let e=Date.now(),n=0;for(let[r,a]of f.current){let c=e-a.updatedAt;if(a.ended&&c>=7e3){f.current.delete(r);continue}if(a.ended&&(n+=1),a.targetId!==t||a.points.length===0)continue;let l=a.ended?1-c/lD:1;i.globalAlpha=l,i.strokeStyle=a.color,i.fillStyle=a.color,i.lineWidth=a.width,i.lineCap=`round`,i.lineJoin=`round`;let u=a.points[0];if(!u)continue;if(a.points.length===1){i.beginPath(),i.arc(u.x*o,u.y*s,a.width/2,0,Math.PI*2),i.fill();continue}i.beginPath(),i.moveTo(u.x*o,u.y*s);for(let e=1;e<a.points.length-1;e+=1){let t=a.points[e],n=a.points[e+1];!t||!n||i.quadraticCurveTo(t.x*o,t.y*s,(t.x+n.x)/2*o,(t.y+n.y)/2*s)}let d=a.points[a.points.length-1];d&&i.lineTo(d.x*o,d.y*s),i.stroke()}i.globalAlpha=1,n>0&&(a=window.requestAnimationFrame(d))},p=()=>{a===null&&(a=window.requestAnimationFrame(d))},m=e=>{if(e.type===`clear`){f.current.clear(),p();return}let t=e.message,n=`${t.clientId}:${t.targetId}:${t.strokeId}`,r=f.current.get(n);if(t.phase!==`start`&&!r||r?.ended&&t.phase!==`start`)return;let i=Date.now();if(t.phase===`start`)for(let[e,n]of f.current)!n.ended&&n.clientId===t.clientId&&f.current.set(e,{...n,updatedAt:i,ended:!0});let a=t.phase===`start`||!r?[{x:t.x,y:t.y}]:[...r.points,{x:t.x,y:t.y}];if(a.length>SD&&(a=a.filter((e,t)=>t%2==0)),!r&&f.current.size>=CD){let e=null,t=1/0;for(let[n,r]of f.current)r.ended&&r.updatedAt<t&&(e=n,t=r.updatedAt);e&&f.current.delete(e)}f.current.set(n,{clientId:t.clientId,targetId:t.targetId,color:t.color,width:t.width,points:a,updatedAt:i,ended:t.phase===`end`}),p()};return d(),Zp(e.paintEvents,e=>z(()=>m(e))).pipe($d(z(()=>{a!==null&&window.cancelAnimationFrame(a)})))},[e.paintEvents,e.participants,s,t,o]),(0,$.useEffect)(()=>{l.current=null,u.current=null},[n,t]);function m(n,r){let i=l.current,a=TD(n);!i||!a||e.sendPaintPoint({targetId:t,strokeId:i,color:p,width:bD,phase:r,x:a.x,y:a.y})}function h(n){if(ED(n),!n.isPrimary||n.button!==0||u.current!==null)return;n.currentTarget.focus(),l.current=crypto.randomUUID(),u.current=n.pointerId,d.current=performance.now();try{n.currentTarget.setPointerCapture(n.pointerId)}catch{}let r=TD(n);r&&e.sendCursor(t,r.x*o,r.y*s,{width:o,height:s}),m(n,`start`)}function g(n){if(ED(n),u.current!==null&&n.pointerId!==u.current)return;let r=TD(n);r&&e.sendCursor(t,r.x*o,r.y*s,{width:o,height:s}),!(!l.current||performance.now()-d.current<xD)&&(d.current=performance.now(),m(n,`move`))}function _(e){ED(e),!(!l.current||u.current!==e.pointerId)&&(m(e,`end`),l.current=null,u.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))}return(0,ZE.jsx)(`canvas`,{ref:c,tabIndex:-1,style:{position:`absolute`,zIndex:20,touchAction:`none`,cursor:n?`crosshair`:void 0,pointerEvents:n?void 0:`none`,visibility:r?void 0:`hidden`,left:i,top:a,width:o,height:s},"aria-label":`Shared drawing overlay`,onPointerDown:h,onPointerMove:g,onPointerUp:_,onPointerCancel:_,onWheel:ED,onContextMenu:ED})}function TD(e){let t=e.currentTarget.getBoundingClientRect();return t.width===0||t.height===0?null:{x:Math.max(0,Math.min(1,(e.clientX-t.left)/t.width)),y:Math.max(0,Math.min(1,(e.clientY-t.top)/t.height))}}function ED(e){e.preventDefault(),e.stopPropagation()}function DD(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)>>>0;return yD[t%yD.length]??`#f43f5e`}var OD=500,kD=5;function AD({control:e,viewport:t=e.viewport,localCursorEnabled:n=!0,paintingEnabled:r=!1,onPaintingEnabledChange:i,onNotice:a,className:o,style:s,renderOverlay:c}){let l=(0,$.useRef)(null),u=(0,$.useRef)(null),d=(0,$.useRef)(null),f=(0,$.useRef)({decodingFrame:null,generation:0,pending:null}),p=(0,$.useRef)(null),m=(0,$.useRef)(new Map),h=(0,$.useRef)(new Set),g=(0,$.useRef)(null),_=(0,$.useRef)(null),v=(0,$.useRef)(!1),y=(0,$.useRef)(null),b=(0,$.useRef)(null),[x,ee]=(0,$.useState)(null),[S,C]=(0,$.useState)(null),[te,ne]=(0,$.useState)(null),re=e.mediaPath===`webrtc-live`&&e.mediaPhase===`live`&&!!e.mediaStream&&!!e.activeTargetId,w=re&&(e.mediaSwitching||e.mediaTargetId!==e.activeTargetId||te?.stream!==e.mediaStream||te?.targetId!==e.activeTargetId),ie=r&&(re||S!==null)&&e.collaboration.phase===`connected`&&!e.mediaSwitching&&!w,ae=r||e.mediaSwitching||w||e.collaboration.phase!==`connected`||e.collaboration.role===`viewer`,oe=w&&te?te.size:e.mediaSize,se=re?oe?.width??t.width:S?.width??t.width,ce=re?oe?.height??t.height:S?.height??t.height,le=re?se:t.width,ue=re?ce:t.height,T=re?Math.min(oe?.canvasWidth??se,Math.round(se*(oe?.deviceScaleFactor??1))):se,E=re?Math.min(oe?.canvasHeight??ce,Math.round(ce*(oe?.deviceScaleFactor??1))):ce,de=gE(e.browserViewportSize?.width??se,e.browserViewportSize?.height??ce,se,ce),fe=jD(e.phase),pe=MD(e.collaboration),me=fe??pe,D=me?y.current??x:null,O=e.collaboration.followingClientId?e.collaboration.participants.find(t=>t.clientId===e.collaboration.followingClientId):null,he=O?e.collaboration.cursors.get(O.clientId):null,ge=he?.targetId===e.activeTargetId?{x:de.offsetX+he.x*de.renderedWidth,y:de.offsetY+he.y*de.renderedHeight}:null;(0,$.useEffect)(()=>{e.setInputDimensions({width:le,height:ue})},[e.setInputDimensions,ue,le]);let k=(0,$.useCallback)(()=>{let t=[...m.current.entries()].reverse();m.current.clear();for(let[n,r]of t)e.sendInput({type:`input.key`,targetId:r.targetId,action:`up`,...r.input,text:void 0,modifiers:0,autoRepeat:!1})&&h.current.add(n)},[e.sendInput]);iD(()=>{let t=t=>{if(!t){u.current?LD(u.current,f.current):RD(f.current),p.current!==null&&(p.current=null,C(null));return}if(t.targetId!==e.activeTargetId)return;u.current&&!re?PD(u.current,f.current,t):f.current.pending=t;let n=p.current;if(n?.width!==t.width||n?.height!==t.height){let e={width:t.width,height:t.height};p.current=e,C(e)}};return Zp(e.frames,e=>z(()=>t(e))).pipe($d(z(()=>{u.current?LD(u.current,f.current):RD(f.current)})))},[e.activeTargetId,e.frames,re]),(0,$.useLayoutEffect)(()=>{let t=f.current,n=e.activeTargetId,r=t.pending?.targetId===n?t.pending:t.decodingFrame?.targetId===n?t.decodingFrame:null,i=u.current;if(i?LD(i,t):RD(t),r){t.pending=r;let e={width:r.width,height:r.height};p.current=e,C(e),i&&FD(i,t)}else p.current!==null&&(p.current=null,C(null))},[e.activeTargetId]),(0,$.useEffect)(()=>{let e=u.current;re||!e||FD(e,f.current)},[S,re]),(0,$.useEffect)(()=>{d.current&&(d.current.srcObject=re?e.mediaStream:null)},[e.mediaStream,re]),(0,$.useEffect)(()=>{let t=d.current,n=e.mediaStream,r=e.activeTargetId,i=e.mediaSize;if(!re||!t||!n||!r||!i||e.mediaSwitching||e.mediaTargetId!==r||te?.stream===n&&te.targetId===r)return;let a=t.requestVideoFrameCallback(()=>{ne({stream:n,targetId:r,size:i})});return()=>t.cancelVideoFrameCallback(a)},[e.activeTargetId,e.mediaSize,e.mediaStream,e.mediaSwitching,e.mediaTargetId,te,re]),(0,$.useEffect)(()=>{let t=l.current;if(!t)return;let n=(t,n)=>{e.setBrowserViewportSize({width:t,height:n})},r=t.getBoundingClientRect();n(r.width,r.height);let i=new ResizeObserver(e=>{let t=e[0];t&&n(t.contentRect.width,t.contentRect.height)});return i.observe(t),()=>i.disconnect()},[e.setBrowserViewportSize]),(0,$.useEffect)(()=>()=>{_.current?.(),k()},[k]),(0,$.useEffect)(()=>{let e=()=>{k(),be()},t=()=>{document.visibilityState===`hidden`&&(k(),be())};return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,t)}},[k,e.collaboration]),(0,$.useEffect)(()=>{ae&&(_.current?.(),k(),be())},[ae,k]),(0,$.useEffect)(()=>{r&&(e.setCaptured(!1),v.current=!1),e.collaboration.hasControl&&e.collaboration.leaseMode===`implicit`&&!v.current&&e.collaboration.release()},[e.collaboration.hasControl,e.collaboration.leaseMode,e.collaboration.release,e.setCaptured,r]);function _e(e,t){let n=l.current?.getBoundingClientRect();if(!n)return null;let r=gE(n.width,n.height,se,ce),i=e.clientX-n.left-r.offsetX,a=e.clientY-n.top-r.offsetY;if(!t&&(i<0||a<0||i>r.renderedWidth||a>r.renderedHeight))return null;let o=i/r.scale*(le/se),s=a/r.scale*(ue/ce);return t?{x:Math.round(WD(o,0,Math.max(le-1,0))),y:Math.round(WD(s,0,Math.max(ue-1,0)))}:{x:Math.round(o),y:Math.round(s)}}function ve(){return e.phase!==`connected`||!e.activeTargetId||ae?null:(e.captured||e.setCaptured(!0),ye(e.activeTargetId),l.current?.focus(),e.activeTargetId)}function ye(t){v.current=!0,e.collaboration.hasControl||e.collaboration.claim(t,`implicit`)}function be(){v.current=!1,e.collaboration.hasControl&&e.collaboration.leaseMode===`implicit`&&e.collaboration.release()}function xe(e){e.preventDefault(),e.stopPropagation()}function Se(e){e.cancelable&&e.preventDefault(),e.stopPropagation()}function Ce(){e.phase!==`connected`||ae||(e.setCaptured(!0),e.activeTargetId&&ye(e.activeTargetId),l.current?.focus())}function we(t){Ie(t),!(ae||!e.activeTargetId)&&(e.setCaptured(!0),ye(e.activeTargetId))}function Te(){y.current=null,ee(null),e.collaboration.clearCursor(),g.current||(k(),be(),e.setCaptured(!1))}function Ee(){e.captured||Ce()}function De(t){Ie(t);let n=_e(t,!1);if(e.activeTargetId&&n?e.collaboration.sendCursor(e.activeTargetId,n.x,n.y,{width:le,height:ue}):n||e.collaboration.clearCursor(),ae||g.current?.pointerId===t.pointerId)return;let r=e.captured&&t.buttons===0?e.activeTargetId:null;r&&n&&(xe(t),e.sendInput({type:`input.mouse`,targetId:r,action:`move`,x:n.x,y:n.y,button:`none`,buttons:0,clickCount:0,modifiers:am(t.nativeEvent)}))}function Oe(t){Ie(t);let n=ve();if(!n)return;let r=_e(t,!1);if(!r)return;let i=l.current;if(!i)return;let a=VD(t.button),o=Date.now(),s=HD(n,a,r,o,b.current);b.current={targetId:n,button:a,point:r,time:o,clickCount:s},xe(t),g.current={pointerId:t.pointerId,targetId:n,button:a,clickCount:s},_.current?.();try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}je({pointerId:t.pointerId,targetId:n,button:a,clickCount:s,element:i}),e.sendInput({type:`input.mouse`,targetId:n,action:`down`,x:r.x,y:r.y,button:a,buttons:t.buttons,clickCount:s,modifiers:am(t.nativeEvent)})}function ke(t){if(ae)return;let n=g.current,r=n?.pointerId===t.pointerId?n.targetId:e.activeTargetId;if(!r)return;let i=_e(t,n?.pointerId===t.pointerId);i&&(xe(t),e.sendInput({type:`input.mouse`,targetId:r,action:`up`,x:i.x,y:i.y,button:n?.button??VD(t.button),buttons:t.buttons,clickCount:n?.clickCount??1,modifiers:am(t.nativeEvent)}),n?.pointerId===t.pointerId&&(g.current=null,t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId)))}function Ae(t){let n=g.current;if(n?.pointerId!==t.pointerId)return;let r=_e(t,!0);g.current=null,t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId),!(!r||ae)&&(xe(t),e.sendInput({type:`input.mouse`,targetId:n.targetId,action:`up`,x:r.x,y:r.y,button:n.button,buttons:0,clickCount:n.clickCount,modifiers:am(t.nativeEvent)}))}function je({pointerId:t,targetId:n,button:r,clickCount:i,element:a}){let o=a=>{if(a.pointerId!==t)return;let o=_e(a,!0);Se(a),o&&(e.collaboration.sendCursor(n,o.x,o.y,{width:le,height:ue}),e.sendInput({type:`input.mouse`,targetId:n,action:`move`,x:o.x,y:o.y,button:r,buttons:a.buttons||UD(r),clickCount:i,modifiers:am(a)}))},s=(a,o)=>{if(a.pointerId!==t)return;let s=_e(a,!0);_e(a,!1)||e.collaboration.clearCursor(),Se(a),s&&(e.sendInput({type:`input.mouse`,targetId:n,action:`up`,x:s.x,y:s.y,button:r,buttons:0,clickCount:i,modifiers:am(a)}),o||(b.current={targetId:n,button:r,point:s,time:Date.now(),clickCount:i})),u()},c=e=>s(e,!1),l=e=>s(e,!0),u=()=>{window.removeEventListener(`pointermove`,o,!0),window.removeEventListener(`pointerup`,c,!0),window.removeEventListener(`pointercancel`,l,!0);try{a.hasPointerCapture(t)&&a.releasePointerCapture(t)}catch{}g.current?.pointerId===t&&(g.current=null),_.current===u&&(_.current=null)};_.current=u,window.addEventListener(`pointermove`,o,!0),window.addEventListener(`pointerup`,c,!0),window.addEventListener(`pointercancel`,l,!0)}function Me(t){let n=ve();if(!n)return;let r=_e(t,!1);if(!r)return;xe(t);let i=GD(t.deltaMode,ue);e.sendInput({type:`input.wheel`,targetId:n,x:r.x,y:r.y,deltaX:t.deltaX*i,deltaY:t.deltaY*i,modifiers:am(t.nativeEvent)})}function Ne(t){if(t.key===`Escape`&&r){t.preventDefault(),t.stopPropagation(),i?.(!1);return}if(t.key===`Escape`){e.captured&&(t.preventDefault(),t.stopPropagation(),e.setCaptured(!1),be());return}let n=t.code||t.key;if(t.repeat&&h.current.has(n)){t.preventDefault(),t.stopPropagation();return}let o=e.activeTargetId;if(ae||!o||!e.captured&&JD(l.current)!==l.current&&!l.current?.contains(t.target))return;t.preventDefault(),t.stopPropagation();let s=BD(t.nativeEvent);if(s===`copy`){e.sendInput({type:`clipboard.copy`,targetId:o});return}if(s===`cut`){e.sendInput({type:`clipboard.cut`,targetId:o});return}if(s===`paste`){KD(e,a);return}if(!cm(t.nativeEvent))return;let c=sm(t.nativeEvent,`down`);e.sendInput({type:`input.key`,targetId:o,action:`down`,...c})&&(h.current.delete(n),m.current.set(n,{targetId:o,input:c}))}function Pe(t){let n=t.code||t.key;if(h.current.delete(n)){t.preventDefault(),t.stopPropagation();return}let r=m.current.get(n),i=r?.targetId??e.activeTargetId,a=!ae&&(e.captured||JD(l.current)===l.current||!!l.current?.contains(t.target));!i||!r&&!a||t.key!==`Escape`&&(t.preventDefault(),t.stopPropagation(),!(!r&&BD(t.nativeEvent))&&(!r&&!cm(t.nativeEvent)||e.sendInput({type:`input.key`,targetId:i,action:`up`,...sm(t.nativeEvent,`up`)})&&m.current.delete(n)))}function Fe(t){t.relatedTarget instanceof Node&&t.currentTarget.contains(t.relatedTarget)||(k(),be(),e.setCaptured(!1))}function Ie(e){let t=l.current?.getBoundingClientRect();if(!t)return;let n={x:e.clientX-t.left,y:e.clientY-t.top};y.current=n,me&&ee(n)}let Le=qD(e.phase,S!==null,e.mediaPhase,e.mediaPath,re),Re=zD(e.phase,e.mediaPhase,e.mediaSwitching),ze=pe||ND(e.collaboration.lastError)?null:e.collaboration.lastError;return(0,ZE.jsxs)(`div`,{ref:l,tabIndex:0,onKeyDown:Ne,onKeyUp:Pe,onBlur:Fe,onClick:Ee,onPointerMove:De,onFocus:()=>{!ae&&e.activeTargetId&&ye(e.activeTargetId)},onPointerEnter:we,onPointerLeave:Te,onPointerDown:Oe,onPointerUp:ke,onPointerCancel:Ae,onWheel:Me,onContextMenu:t=>{e.captured&&t.preventDefault()},"aria-busy":w,"aria-disabled":ae,className:o,style:{position:`relative`,display:`flex`,flex:`1 1 0%`,minHeight:0,alignItems:`center`,justifyContent:`center`,overflow:`hidden`,outline:`none`,touchAction:`none`,cursor:n?void 0:`none`,...s},children:[re?(0,ZE.jsx)(`div`,{style:{position:`relative`,overflow:`hidden`,background:`black`,transition:`opacity 150ms`,opacity:w?.75:1,width:de.renderedWidth,height:de.renderedHeight},children:(0,ZE.jsx)(`video`,{ref:d,autoPlay:!0,muted:!0,playsInline:!0,"data-viewport-width":se,"data-viewport-height":ce,style:{position:`absolute`,top:0,left:0,maxWidth:`none`,objectFit:`fill`,width:de.renderedWidth*((oe?.canvasWidth??T)/T),height:de.renderedHeight*((oe?.canvasHeight??E)/E)}})}):S?(0,ZE.jsx)(`div`,{style:{position:`relative`,overflow:`hidden`,background:`black`,width:de.renderedWidth,height:de.renderedHeight},children:(0,ZE.jsx)(`img`,{ref:u,alt:``,draggable:!1,style:{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:`contain`}})}):null,e.activeTargetId?(0,ZE.jsx)(wD,{collaboration:e.collaboration,targetId:e.activeTargetId,enabled:ie,visible:!e.mediaSwitching&&!w&&(re||S!==null),left:de.offsetX,top:de.offsetY,width:de.renderedWidth,height:de.renderedHeight}):null,c?.({status:Le,placeholder:re||S?null:Re,cursorHint:me&&D?{text:me,...D}:null,followedCursor:ge&&O?{name:O.name,...ge}:null,collaborationError:ze?.message??null})]})}function jD(e){return e===`disconnected`||e===`error`?`Session disconnected`:null}function MD(e){return e.holderClientId!==null&&e.holderClientId!==e.clientId?`Input in use`:e.hasControl?null:e.lastError?.code===`input_busy`||e.lastError?.code===`input_not_owned`?`Input in use`:e.lastError?.code===`input_unavailable`?`Input unavailable`:null}function ND(e){return e?.code===`input_busy`||e?.code===`input_not_owned`}function PD(e,t,n){t.pending=n,FD(e,t)}function FD(e,t){if(t.decodingFrame!==null||t.pending===null)return;let n=t.pending,r=t.generation;t.pending=null,t.decodingFrame=n,ID(e,n).then(()=>{t.generation===r&&(t.decodingFrame=null,FD(e,t))})}async function ID(e,t){let n=e.src,r=URL.createObjectURL(t.data);e.src=r;try{await e.decode()}catch{}finally{n.startsWith(`blob:`)&&URL.revokeObjectURL(n),e.src!==r&&URL.revokeObjectURL(r)}}function LD(e,t){RD(t);let n=e.src;e.removeAttribute(`src`),n.startsWith(`blob:`)&&URL.revokeObjectURL(n)}function RD(e){e.generation+=1,e.decodingFrame=null,e.pending=null}function zD(e,t,n){return e===`connecting`?`connecting`:e===`connected`&&t===`connecting`?`connecting-media`:e===`connected`&&n?`switching`:e===`disconnected`||e===`error`?`disconnected`:`waiting`}function BD(e){if(!(e.metaKey||e.ctrlKey)||e.altKey)return null;switch(e.code){case`KeyC`:return`copy`;case`KeyX`:return`cut`;case`KeyV`:return`paste`;default:return null}}function VD(e){return e===0?`left`:e===1?`middle`:e===2?`right`:`none`}function HD(e,t,n,r,i){return i&&i.targetId===e&&i.button===t&&r-i.time<=OD&&Math.abs(i.point.x-n.x)<=kD&&Math.abs(i.point.y-n.y)<=kD?Math.min(i.clickCount+1,3):1}function UD(e){switch(e){case`left`:return 1;case`right`:return 2;case`middle`:return 4;case`none`:return 0;default:return e}}function WD(e,t,n){return Math.min(Math.max(e,t),n)}function GD(e,t){return e===WheelEvent.DOM_DELTA_LINE?16:e===WheelEvent.DOM_DELTA_PAGE?t:1}async function KD(e,t){if(!e.activeTargetId)return;let n=``;try{n=await navigator.clipboard.readText()}catch(e){console.warn(`Clipboard read failed`,e),t?.({level:`error`,message:`Clipboard read failed`});return}n&&e.sendInput({type:`clipboard.paste`,targetId:e.activeTargetId,items:[{mimeType:`text/plain`,data:n}]})}function qD(e,t,n,r,i){return e===`connected`?n===`live`&&i?`webrtc`:t?r===`websocket-live`?`websocket`:`webrtc`:`offline`:`offline`}function JD(e){let t=e?.getRootNode();return t instanceof Document||t instanceof ShadowRoot?t.activeElement:null}var YD=[];function XD({sessionId:e,credentials:t,displayName:n,sessionToken:r,collaborationRole:i=`owner`,enabled:a=!0,webrtcProducerSupported:o=!1,webrtcIceServers:s=YD,onNotice:c}){let l=nD(),u=(0,$.useRef)(c);u.current=c;let d=(e,t)=>z(()=>u.current?.({level:e,message:t})),f=dD({sessionId:e,displayName:n,credentials:t,sessionToken:r,role:i,enabled:!!(a&&e&&t),webrtcSupported:o,iceServers:s}),[p,m]=(0,$.useState)([]),h=(0,$.useMemo)(()=>ZD(p,f.targets),[f.targets,p]),g=(0,$.useRef)(f.targets);g.current=f.targets;let _=(0,$.useRef)(f.phase);_.current=f.phase;let[v,y]=(0,$.useState)(fE),[b,x]=(0,$.useState)(null),[ee,S]=(0,$.useState)(!1),[C,te]=(0,$.useState)(!1),[ne,re]=(0,$.useState)(!1),w=(0,$.useRef)(null),ie=(0,$.useRef)(v),ae=(0,$.useRef)(fE),oe=(0,$.useRef)(null),se=(0,$.useRef)(!1);w.current=f.activeTargetId,ie.current=v,oe.current=b,se.current=ee,(0,$.useEffect)(()=>{f.phase!==`connected`&&te(!1)},[f.phase]),(0,$.useEffect)(()=>{if(!f.mediaSize)return;let e=ie.current;e.width===f.mediaSize.width&&e.height===f.mediaSize.height&&e.deviceScaleFactor===f.mediaSize.deviceScaleFactor||y(QD(f.mediaSize,f.mediaSize.deviceScaleFactor))},[f.mediaSize]);let ce=(0,$.useCallback)(n=>!a||!e||!t?!1:f.sendBrowserInput(n,ae.current),[t,a,f,e]),le=(0,$.useCallback)(e=>{f.selectTarget(e)},[f]),ue=(0,$.useCallback)((e,t,n)=>{e!==t&&m(r=>{let i=ZD(r,g.current).map(e=>e.id),a=i.indexOf(e),o=i.indexOf(t),s=i[a];if(a===-1||o===-1||!s)return r;let c=[...i];c.splice(a,1);let l=n===`after`?o+1:o,u=a<l?l-1:l;return u===a?r:(c.splice(u,0,s),c)})},[]),T=(0,$.useCallback)(e=>l.runPromise(f.request(`target.create`,{url:e}).pipe(kd(e=>e.targetId??null),jd(e=>d(`error`,eO(e,`Tab could not be created`)).pipe(H(null))))),[f,l]),E=(0,$.useCallback)((e=`about:blank`)=>{T(e)},[T]),de=(0,$.useCallback)(e=>{T(e.url||`about:blank`).then(t=>{t&&ue(t,e.id,`after`)})},[T,ue]),fe=(0,$.useCallback)(e=>{f.command(`target.close`,{targetId:e})},[f]),pe=(0,$.useCallback)(e=>{let t=w.current;t&&f.command(`page.navigate`,{targetId:t,url:e})},[f]),me=(0,$.useCallback)(e=>{f.command(`page.reload`,{targetId:e})},[f]),D=(0,$.useCallback)(()=>{let e=w.current;e&&f.command(`page.stop-loading`,{targetId:e})},[f]),O=(0,$.useCallback)(()=>{let e=w.current;e&&f.command(`page.history-back`,{targetId:e})},[f]),he=(0,$.useCallback)(()=>{let e=w.current;e&&f.command(`page.history-forward`,{targetId:e})},[f]),ge=(0,$.useCallback)(e=>{y(e);let t=w.current;t&&f.command(`viewport.set`,{targetId:t,width:e.width,height:e.height,deviceScaleFactor:e.deviceScaleFactor})},[f]),k=(0,$.useCallback)(e=>{se.current=!1,S(!1),ge(e)},[ge]),_e=(0,$.useCallback)(e=>{let t={width:Math.round(e.width),height:Math.round(e.height)};if(t.width<1||t.height<1)return;let n=oe.current;n?.width===t.width&&n.height===t.height||(oe.current=t,x(t),se.current&&ge(QD(t,ie.current.deviceScaleFactor)))},[ge]),ve=(0,$.useCallback)(e=>{se.current=e,S(e);let t=oe.current;e&&t&&ge(QD(t,ie.current.deviceScaleFactor))},[ge]),ye=(0,$.useCallback)(()=>{let e=oe.current;e&&(se.current=!1,S(!1),ge(QD(e,ie.current.deviceScaleFactor)))},[ge]),be=(e,t)=>e.pipe(jd(e=>d(`error`,eO(e,t))),$d(z(()=>re(!1)))),xe=aD((e,t)=>be(f.request(`recording.start`,{mode:e,targetId:t}),`Recording failed to start`),[f]),Se=(0,$.useCallback)(e=>{let t=w.current;!t||i!==`owner`||ne||(re(!0),xe(e,t))},[i,ne,xe]),Ce=aD((e,t,n)=>be(f.request(`recording.stop`,{recordingId:n}).pipe(Ed(LT.use(i=>i.downloadSessionRecording(e,t,n,r))),V(({blob:e,filename:r})=>{let i=f.recordings.find(e=>e.recordingId===n);return $D(e,r??`${t}-${i?.targetId??`target`}-${n}.webm`)}),Ed(d(`success`,`Recording saved`))),`Recording failed to stop`),[f,r]),we=(0,$.useCallback)(n=>{!e||!t||ne||(re(!0),Ce(t,e,n))},[t,ne,Ce,e]),Te=aD(e=>be(f.request(`recording.cancel`,{recordingId:e}).pipe(Ed(d(`success`,`Recording stopped`))),`Recording failed to stop`),[f]),Ee=(0,$.useCallback)(e=>{ne||(re(!0),Te(e))},[ne,Te]),De=aD(e=>f.request(`presentation.cursor.set`,{visible:e}).pipe(jd(e=>d(`error`,eO(e,`Remote cursor could not be updated`)))),[f]),Oe=(0,$.useCallback)(n=>{e&&t&&De(n)},[t,De,e]),ke=aD(e=>f.selectPresentation(e).pipe(jd(e=>d(`error`,eO(e,`Presentation could not be updated`)))),[f]),Ae=(0,$.useCallback)(n=>!a||!e||!t||f.mediaSwitching?!1:(ke(n),!0),[t,a,f.mediaSwitching,ke,e]),je=(0,$.useCallback)(e=>Ae({kind:`webrtc`,quality:e}),[Ae]),Me=(0,$.useMemo)(()=>{let e=e=>gd(()=>_.current===`connected`?e:B(new OE({message:`the session is not connected`}))),t=(t,n)=>e(f.request(t,n)),n=(t,n={})=>e(gd(()=>{let e=w.current;return e?f.request(t,{targetId:e,...n}):B(new OE({message:`no tab is active`}))})).pipe(Ad);return{navigate:e=>n(`page.navigate`,{url:e}),historyBack:()=>n(`page.history-back`),historyForward:()=>n(`page.history-forward`),reload:e=>e?t(`page.reload`,{targetId:e}).pipe(Ad):n(`page.reload`),stopLoading:()=>n(`page.stop-loading`),createTarget:(e=`about:blank`)=>t(`target.create`,{url:e}).pipe(kd(e=>e.targetId??null)),closeTarget:e=>t(`target.close`,{targetId:e}).pipe(Ad),activateTarget:t=>e(f.requestSelectTarget(t))}},[f.request,f.requestSelectTarget]),Ne=(0,$.useMemo)(()=>h.find(e=>e.id===f.activeTargetId)??null,[f.activeTargetId,h]),Pe=f.transport===`webrtc`?`webrtc-live`:`websocket-live`,Fe=f.phase===`connected`?`live`:f.phase===`connecting`?`connecting`:f.phase===`error`?`failed`:`idle`;return{phase:f.phase,targets:h,activeTargetId:f.activeTargetId,activeTarget:Ne,frames:f.frames,mediaPhase:Fe,mediaStream:f.mediaStream,mediaStreamSettings:f.presentation?.quality??null,mediaVideoProfiles:f.presentation?.profiles??[],mediaSize:f.mediaSize,mediaPath:Pe,mediaTargetId:f.activeTargetId,mediaSwitching:f.mediaSwitching,viewport:v,browserViewportSize:b,viewportAutoSync:ee,captured:C,recordings:f.recordings,recordingBusy:ne,remoteCursorEnabled:f.presentation?.cursorVisible??!0,collaboration:f.collaboration,commands:Me,setCaptured:te,setInputDimensions:e=>{ae.current=e},setViewport:k,setBrowserViewportSize:_e,setViewportAutoSync:ve,setViewportToBrowserSize:ye,setWebRTCStreamSettings:je,selectMediaStream:Ae,sendInput:ce,activateTarget:le,reorderTargets:ue,createTarget:E,duplicateTarget:de,closeTarget:fe,navigate:pe,reload:me,stopLoading:D,historyBack:O,historyForward:he,startRecording:Se,stopRecording:we,cancelRecording:Ee,setRemoteCursorEnabled:Oe,reconnect:f.reconnect}}function ZD(e,t){let n=new Map(t.map(e=>[e.id,e])),r=new Set,i=[];for(let t of e){let e=n.get(t);e&&(i.push(e),r.add(e.id))}for(let e of t)r.has(e.id)||i.push(e);return i}function QD(e,t){return mE(e.width,e.height,t)}var $D=(e,t)=>Zd(z(()=>URL.createObjectURL(e)),e=>z(()=>{let n=document.createElement(`a`);n.href=e,n.download=t,n.click()}),e=>z(()=>URL.revokeObjectURL(e)).pipe(zd(0)));function eO(e,t){return e instanceof Error&&e.message?e.message:t}var tO=`~effect/ManagedRuntime`,nO=(e,t)=>{let n=t?.memoMap??pu(),r=Ql(`parallel`),i=nu(r,`sequential`),a={onFiberStart:jf(r)},o=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,s,c=wd(t=>(s||=ff(Dd(gu(e,n,i),e=>z(()=>{l.cachedContext=e})),{...a,scheduler:t.cache.scheduler}),Td(Of(s)))),l={[tO]:tO,memoMap:n,scope:r,contextEffect:c,cachedContext:void 0,context(){return l.cachedContext===void 0?gf(l.contextEffect):Promise.resolve(l.cachedContext)},dispose(){return gf(l.disposeEffect)},[Symbol.asyncDispose](){return l.dispose()},disposeEffect:gd(()=>(l.contextEffect=Sd(`ManagedRuntime disposed`),l.cachedContext=void 0,ru(l.scope,Bl))),runFork(e,t){return l.cachedContext===void 0?ff(rO(l,e),o(t)):pf(l.cachedContext)(e,o(t))},runCallback(e,t){return l.cachedContext===void 0?hf(rO(l,e),o(t)):mf(l.cachedContext)(e,o(t))},runSyncExit(e){return l.cachedContext===void 0?Sf(rO(l,e)):Cf(l.cachedContext)(e)},runSync(e){return l.cachedContext===void 0?bf(rO(l,e)):xf(l.cachedContext)(e)},runPromiseExit(e,t){return l.cachedContext===void 0?vf(rO(l,e),o(t)):yf(l.cachedContext)(e,o(t))},runPromise(e,t){return l.cachedContext===void 0?gf(rO(l,e),o(t)):_f(l.cachedContext)(e,o(t))}};return l};function rO(e,t){return V(e.contextEffect,e=>Kd(t,e))}var iO=Ur(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),aO=class extends dr()(`effect/http/FetchHttpClient/RequestInit`){},oO=bS(R(pS((e,t,n,r)=>{let i=r.getRef(iO),a=Pr(r.context,aO)??{},o=a.headers?jy(Dy(a.headers),e.headers):e.headers;o[`content-length`]&&(o=My(o,`content-length`));let s=r=>kd(hd({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:typeof ReadableStream<`u`&&r instanceof ReadableStream?`half`:void 0,signal:n}),catch:t=>new px({reason:new gx({request:e,cause:t})})}),t=>rS(e,t));switch(e.body._tag){case`Raw`:case`Uint8Array`:return s(e.body.body);case`FormData`:return s(e.body.formData);case`Stream`:return V(em(e.body.stream),s)}return s(void 0)}))),sO=(e={})=>nO(wu(qT.pipe(Eu(e.baseUrl?JT(e.baseUrl):yu),Eu(oO)),_u(vS,!1)));function cO({baseUrl:e,children:t}){let[n,r]=(0,$.useState)(null);return(0,$.useEffect)(()=>{let t=sO({baseUrl:e});return r(t),()=>{r(null),t.dispose()}},[e]),n?(0,ZE.jsx)(eD,{runtime:n,baseUrl:e,children:t}):null}function lO(e){let t=e.slice(4,40),n=e.startsWith(`ape_`)?`editor`:e.startsWith(`apv_`)?`viewer`:null;return!n||e[40]!==`_`||!t||!e.slice(41)?null:{token:e,sessionId:t,role:n}}var uO=[];function dO({token:e,displayName:t,onNotice:n}){let r=(0,$.useMemo)(()=>lO(e),[e]),i=(0,$.useMemo)(()=>r&&{kind:`bearer`,token:r.token,authorityType:null,tenantId:null,selectedTenantId:null},[r]),[a,o]=(0,$.useState)({kind:`loading`});iD(()=>r&&i?z(()=>o({kind:`loading`})).pipe(Ed(LT.use(e=>e.getBrowserStatus(i,r.sessionId))),Hd({onFailure:e=>o({kind:e.status===410?`expired`:`unavailable`}),onSuccess:e=>o(e.sessionId===r.sessionId?{kind:`ready`,browser:e}:{kind:`unavailable`})})):void 0,[i,r]);let s=a.kind===`ready`?a.browser:null,c=XD({sessionId:r?.sessionId??null,credentials:s?i:null,displayName:t,sessionToken:r?.token,collaborationRole:r?.role??`viewer`,enabled:s!==null,webrtcProducerSupported:s?.media.mode===`auto`&&s.media.webrtcProducer,webrtcIceServers:s?.media.iceServers??uO,onNotice:n});return{status:r?a.kind:`invalid`,share:r,browser:s,control:c}}export{g as C,c as D,o as E,la as S,f as T,gd as _,iD as a,_d as b,pE as c,hE as d,Ed as f,gf as g,lf as h,aD as i,dE as l,B as m,cO as n,XE as o,Md as p,AD as r,OE as s,dO as t,mE as u,z as v,m as w,ad as x,hd as y};
|