@deslop/workbench 0.0.315 → 0.0.320

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.
Files changed (41) hide show
  1. package/dist/client/assets/agent-DAD7EQOa.js +2 -0
  2. package/dist/client/assets/{agent-BIuVSeAF.js → agent-DHWhwvQy.js} +1 -1
  3. package/dist/client/assets/{button-CP1KTzaA.js → button-fe_R2wzr.js} +11 -11
  4. package/dist/client/assets/{diff-B287sB8S.js → diff-BbjpVkn4.js} +10 -10
  5. package/dist/client/assets/diff-HFsBcdrM.js +2 -0
  6. package/dist/client/assets/{external-link-DxUqDR8g.js → external-link-CTjuCORn.js} +1 -1
  7. package/dist/client/assets/{fallbacks-D55g6vQC.js → fallbacks-DZ7ciusO.js} +1 -1
  8. package/dist/client/assets/index-Ci3BZgXN.css +2 -0
  9. package/dist/client/assets/index-Ds4rq0zQ.js +10 -0
  10. package/dist/client/assets/input-group-BtEJur4W.js +153 -0
  11. package/dist/client/assets/loader-circle-B1mHTP2Y.js +1 -0
  12. package/dist/client/assets/portless-DFKFPX3Z.js +1 -0
  13. package/dist/client/assets/portless-DexDlqwA.js +2 -0
  14. package/dist/client/assets/resizable-B1fIW9sm.js +1 -0
  15. package/dist/client/assets/route-CUHeGENe.js +45 -0
  16. package/dist/client/assets/route-DOWKJR6H.js +2 -0
  17. package/dist/client/assets/run-BvHiSlty.js +2 -0
  18. package/dist/client/assets/run-L2YCL4H0.js +1 -0
  19. package/dist/client/assets/state-T-ZhKyUm.js +2 -0
  20. package/dist/client/assets/{terminal-DWl9BK6U.js → terminal-CGe8qF7_.js} +1 -1
  21. package/dist/client/assets/{terminal-CMql1niz.js → terminal-Ci9YBovb.js} +2 -2
  22. package/dist/client/assets/terminal-t4CeG_V9.js +2 -0
  23. package/dist/client/assets/{triangle-alert-BBj9uTaq.js → triangle-alert-CGj-8H_a.js} +1 -1
  24. package/dist/client/index.html +12 -12
  25. package/dist/server.js +414 -1159
  26. package/package.json +5 -4
  27. package/dist/client/assets/agent-Cvk2rNLW.js +0 -2
  28. package/dist/client/assets/browser-ZCteqApb.js +0 -2
  29. package/dist/client/assets/browser-qFOBXYmj.js +0 -1
  30. package/dist/client/assets/composite-DrpN5NPU.js +0 -1
  31. package/dist/client/assets/dialog-DNzOF5Pr.js +0 -153
  32. package/dist/client/assets/diff-Dz1s0ttU.js +0 -2
  33. package/dist/client/assets/index-4j0hsxXB.css +0 -2
  34. package/dist/client/assets/index-C8lKBTMr.js +0 -10
  35. package/dist/client/assets/loader-circle-CjJdQ-6r.js +0 -1
  36. package/dist/client/assets/route-CaWOfZWN.js +0 -2
  37. package/dist/client/assets/route-VC_QtiiN.js +0 -45
  38. package/dist/client/assets/run-B0jQ0k3F.js +0 -2
  39. package/dist/client/assets/run-CFcWKZn5.js +0 -1
  40. package/dist/client/assets/state-m9GNWCBT.js +0 -2
  41. package/dist/client/assets/terminal-CgkXzq-O.js +0 -2
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./chunk-QTnfLwEv.js";import{r as t}from"./compiler-runtime-rGeCHUuX.js";import{$ as n,$a as r,$i as i,$n as a,$r as o,$t as s,Aa as c,Ai as l,An as u,Ao as d,Ar as f,At as p,B as m,Ba as h,Bi as ee,Bn as te,Bo as ne,Br as g,Bt as re,Ci as ie,Cn as ae,Co as oe,Cr as se,Ct as ce,Da as le,Di as ue,Dn as de,Do as fe,Dr as pe,Dt as me,Ei as he,En as ge,Eo as _e,Er as ve,F as ye,Fa as be,Fi as xe,Fn as _,Fo as Se,Fr as Ce,Ft as we,G as Te,Ga as Ee,Gi as De,Gn as Oe,Go as v,Gr as ke,Gt as Ae,H as je,Ha as Me,Hi as Ne,Hn as Pe,Hr as Fe,Ht as Ie,I as Le,Ia as Re,Ii as ze,In as y,Io as Be,Ir as Ve,It as He,J as b,Ji as Ue,Jn as x,Jo as We,Jr as Ge,Jt as Ke,K as qe,Ka as Je,Ki as Ye,Kn as Xe,Ko as Ze,Kr as Qe,Kt as $e,L as S,La as et,Li as tt,Ln as nt,Lo as rt,Lr as it,Lt as at,Ma as ot,Mi as st,Mn as ct,Mo as lt,Mr as ut,Mt as dt,Ni as ft,Nn as C,No as pt,Nr as mt,Nt as ht,Oi as gt,On as _t,Oo as vt,Or as yt,Ot as bt,P as w,Pa as xt,Pi as St,Pn as Ct,Po as wt,Pr as Tt,Pt as Et,Qa as Dt,Qi as Ot,Qn as kt,Qt as At,R as jt,Ri as Mt,Rn as Nt,Ro as Pt,Rr as Ft,Rt as It,Sa as Lt,Si as Rt,Sn as zt,So as Bt,Sr as Vt,St as Ht,Ta as Ut,Ti as Wt,Tn as Gt,To as Kt,Tr as qt,Tt as Jt,U as Yt,Ua as Xt,Ui as Zt,Un as Qt,Uo as $t,Ur as en,Ut as tn,V as nn,Va as rn,Vi as an,Vn as on,Vo as sn,Vr as cn,Vt as ln,W as un,Wa as dn,Wi as fn,Wn as pn,Wo as mn,Wr as hn,Wt as T,X as gn,Xa as _n,Xi as vn,Xn as yn,Xr as bn,Xt as xn,Y as E,Ya as Sn,Yi as Cn,Yn as wn,Yo as Tn,Yr as En,Yt as Dn,Z as On,Za as kn,Zi as An,Zn as jn,Zo as Mn,Zr as Nn,Zt as Pn,_a as Fn,_i as In,_n as Ln,_o as Rn,_r as zn,_t as Bn,aa as Vn,ai as Hn,an as Un,ao as D,ar as Wn,at as Gn,ba as Kn,bi as qn,bn as Jn,bo as Yn,br as Xn,bt as Zn,ca as Qn,ci as $n,cn as er,co as tr,ct as nr,da as rr,di as ir,dn as ar,do as or,dt as sr,ea as cr,ei as lr,en as ur,eo as dr,er as fr,et as pr,fi as mr,fn as hr,fo as gr,ft as O,ga as _r,gi as vr,gn as yr,go as br,gr as xr,hi as Sr,hn as Cr,ho as wr,ht as Tr,ia as Er,ii as Dr,in as Or,io as kr,ir as Ar,ji as jr,jn as Mr,jo as Nr,jr as Pr,jt as Fr,ki as Ir,kn as Lr,ko as Rr,kr as zr,kt as Br,la as Vr,li as Hr,ln as Ur,lo as Wr,lr as Gr,lt as Kr,mi as qr,mn as Jr,mo as Yr,mt as Xr,na as Zr,ni as Qr,nn as $r,no as ei,nr as ti,nt as ni,oa as ri,oi as ii,on as k,oo as ai,or as oi,ot as si,pa as ci,pi as li,pn as ui,po as di,pt as fi,q as pi,qa as mi,qi as hi,qn as gi,qo as A,qr as _i,qt as j,ra as vi,ri as yi,rn as bi,ro as xi,rr as Si,rt as Ci,sa as wi,si as Ti,sn as Ei,so as M,st as Di,ta as Oi,tn as ki,to as Ai,tr as ji,tt as Mi,ui as Ni,un as Pi,uo as Fi,ut as Ii,vi as Li,vn as Ri,vo as zi,vr as Bi,vt as Vi,wa as Hi,wi as Ui,wn as Wi,wo as Gi,wr as Ki,wt as qi,xi as Ji,xn as Yi,xo as Xi,xr as Zi,xt as Qi,ya as $i,yi as ea,yn as ta,yo as na,yr as ra,yt as ia,z as aa,za as oa,zi as sa,zn as ca,zo as la,zr as ua,zt as da}from"./button-fe_R2wzr.js";var fa=Rt,pa=ie,ma=qn,ha=Ji,ga=ue,_a=Ui,va=Ir,ya=Symbol.for(`effect/MutableList/Empty`),ba=()=>({head:void 0,tail:void 0,length:0}),xa=()=>({array:[],mutable:!0,offset:0,next:void 0}),Sa=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=xa(),e.tail=e.tail.next):e.head=e.tail=xa(),e.tail.array.push(t),e.length++},Ca=(e,t)=>wa(e,Lt(t),!Array.isArray(t)),wa=(e,t,n=!1)=>{if(t.length===0)return 0;let r={array:t,mutable:n,offset:0,next:void 0};return e.head?e.tail=e.tail.next=r:e.head=e.tail=r,e.length+=t.length,t.length},Ta=e=>{e.head=e.tail=void 0,e.length=0},Ea=(e,t)=>{if(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 Ta(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&&Ta(e),n;i=i.next}return Ta(e),n},Da=e=>Ea(e,e.length),Oa=e=>{if(!e.head)return ya;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:Ta(e)),t},ka=(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}e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0},e.length=n.length},Aa=(e,t)=>ka(e,e=>e!==t),ja=`~effect/MutableRef`,Ma={[ja]:ja,...Fi,toJSON(){return{_id:`MutableRef`,current:Yn(this.current)}}},Na=e=>{let t=Object.create(Ma);return t.current=e,t},Pa=v(2,(e,t)=>(e.current=t,e)),Fa=`~effect/PubSub/Subscription`,Ia=v(2,(e,t)=>e.shutdownFlag.current?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),La=e=>pn(da(t=>{let n=Zr(t,zr),r=mt(e.scope),i=Va(e.pubsub,e.subscribers,e.strategy);return f(r,Ra(i)).pipe(Br(Pr(n,e=>ut(r,e))),Fr(i))})),Ra=e=>pn(jn(t=>(Pa(e.shutdownFlag,!0),Ke(Da(e.pollers),e=>g(e,t.id),{discard:!0,concurrency:`unbounded`}).pipe(nt(()=>y(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),wn(e.shutdownHook.open),dt)))),za=e=>_(function t(n){if(e.shutdownFlag.current)return ki;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?C(e.replayWindow.takeAll().concat(r)):Ut(r)?C(r):T(Ba(e),e=>t([e]))}),Ba=e=>{let t=Fe(),n=e.subscribers.get(e.subscription);return n||(n=new Set,e.subscribers.set(e.subscription,n)),n.add(e.pollers),Sa(e.pollers,t),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),Jr(Ft(t),()=>(Aa(e.pollers,t),x))},Va=(e,t,n)=>new Ha(e,t,e.subscribe(),ba(),va(!1),Na(!1),n,e.replayWindow()),Ha=class{[Fa]={_A:A};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 Tn(this,arguments)}},Ua=`~effect/Queue`,Wa=`~effect/Queue/Enqueue`,Ga=`~effect/Queue/Dequeue`,Ka={_A:A,_E:A},qa={[Ua]:Ka,[Wa]:Ka,[Ga]:Ka,...Fi,toJSON(){return{_id:`effect/Queue`,state:this.state._tag,size:co(this)}}},Ja=e=>br(t=>{let n=Object.create(qa);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??1/0,n.strategy=e?.strategy??`suspend`,n.messages=ba(),n.scheduleRunning=!1,n.state={_tag:`Open`,takers:new Set,offers:new Set,awaiters:new Set},jr(n)}),Ya=e=>Ja({capacity:e}),Xa=(e,t)=>ft(()=>{if(e.state._tag!==`Open`)return lo;if(e.messages.length>=e.capacity)switch(e.strategy){case`dropping`:return lo;case`suspend`:return e.capacity<=0&&e.state.takers.size>0?(Sa(e.messages,t),mo(e),uo):_o(e,t);case`sliding`:return Oa(e.messages),Sa(e.messages,t),uo}return Sa(e.messages,t),ho(e),uo}),Za=(e,t)=>e.state._tag===`Open`?e.messages.length>=e.capacity?e.strategy===`sliding`?(Oa(e.messages),Sa(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0?(Sa(e.messages,t),mo(e),!0):!1:(Sa(e.messages,t),ho(e),!0):!1,Qa=(e,t)=>ft(()=>{if(e.state._tag!==`Open`)return jr(Lt(t));let n=$a(e,t);return n.length===0?Yr([]):e.strategy===`dropping`?jr(n):vo(e,n)}),$a=(e,t)=>{if(e.state._tag!==`Open`)return Lt(t);if(e.capacity===1/0||e.strategy===`sliding`)return Ca(e.messages,t),e.strategy===`sliding`&&Ea(e.messages,e.messages.length-e.capacity),ho(e),[];let n=e.capacity<=0?e.state.takers.size:e.capacity-e.messages.length;if(n===0)return Lt(t);let r=[],i=0;for(let a of t)i<n?Sa(e.messages,a):r.push(a),i++;return ho(e),r},eo=v(2,(e,t)=>St(()=>to(e,t))),to=(e,t)=>{if(e.state._tag!==`Open`)return!1;let n=ea(di(t),fo);return e.state.offers.size===0&&e.messages.length===0?(xo(e,n),!0):(e.state={...e.state,_tag:`Closing`,exit:n},!0)},no=e=>eo(e,or(Wr())),ro=e=>St(()=>{if(e.state._tag===`Done`)return!0;Ta(e.messages);let t=e.state.offers;if(xo(e,e.state._tag===`Open`?po:e.state.exit),t.size>0){for(let e of t)e._tag===`Single`?e.resume(lo):e.resume(Yr(e.remaining.slice(e.offset)));t.clear()}return!0}),io=e=>ao(e,1,1/0),ao=(e,t,n)=>ft(()=>go(e,t,n)??qr(bo(e),ao(e,1,n))),oo=e=>ft(()=>so(e)??qr(bo(e),oo(e))),so=e=>{if(e.state._tag===`Done`)return e.state.exit;if(e.messages.length>0){let t=Oa(e.messages);return yo(e),Yr(t)}else if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,yo(e),e.capacity=0;let t=Oa(e.messages);return yo(e),Yr(t)}},co=e=>e.state._tag===`Done`?0:e.messages.length,lo=Yr(!1),uo=Yr(!0),fo=gr(Wr()),po=In(),mo=e=>{if(e.scheduleRunning=!1,!(e.state._tag===`Done`||e.state.takers.size===0)){for(let t of e.state.takers)if(e.state.takers.delete(t),t(Li),e.messages.length===0)break}},ho=e=>{e.scheduleRunning||e.state._tag===`Done`||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>mo(e),0))},go=(e,t,n)=>{if(e.state._tag===`Done`)return e.state.exit;if(n<=0||t<=0)return Yr([]);if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,yo(e),e.capacity=0;let t=[Oa(e.messages)];return yo(e),Yr(t)}if(t=Math.min(t,e.capacity||1),t<=e.messages.length){let t=Ea(e.messages,n);return yo(e),Yr(t)}},_o=(e,t)=>vr(n=>{if(e.state._tag!==`Open`)return n(lo);let r={_tag:`Single`,message:t,resume:n};return e.state.offers.add(r),St(()=>{e.state._tag===`Open`&&e.state.offers.delete(r)})}),vo=(e,t)=>vr(n=>{if(e.state._tag!==`Open`)return n(Yr(t));let r={_tag:`Array`,remaining:t,offset:0,resume:n};return e.state.offers.add(r),St(()=>{e.state._tag===`Open`&&e.state.offers.delete(r)})}),yo=e=>{if(e.state._tag===`Done`)return oi(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag===`Closing`&&e.messages.length===0?(xo(e,e.state.exit),oi(e.state.exit.cause)):!1;let t=e.capacity-e.messages.length;for(let n of e.state.offers)if(t===0)break;else if(n._tag===`Single`)Sa(e.messages,n.message),t--,n.resume(uo),e.state.offers.delete(n);else{for(;n.offset<n.remaining.length;n.offset++){if(t===0)return!1;Sa(e.messages,n.remaining[n.offset]),t--}n.resume(Yr([])),e.state.offers.delete(n)}return!1},bo=e=>vr(t=>e.state._tag===`Done`?t(e.state.exit):(e.state.takers.add(t),St(()=>{e.state._tag!==`Done`&&e.state.takers.delete(t)}))),xo=(e,t)=>{if(e.state._tag===`Done`)return;let n=e.state;e.state={_tag:`Done`,exit:t};for(let e of n.takers)e(t);n.takers.clear();for(let e of n.awaiters)e(t);n.awaiters.clear()},So=e=>new Co(e),Co=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=ft(()=>this.free<e?vr(n=>{if(this.free>=e)return n(t);let r=()=>{this.free<e||(this.waiters.delete(r),n(t))};return this.waiters.add(r),St(()=>{this.waiters.delete(r)})}):(this.taken+=e,jr(e)));return t}updateTakenUnsafe(e,t){return this.taken=t(this.taken),this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{let e=this.waiters.values(),t=e.next();for(;t.done===!1&&this.free>0;)t.value(),t=e.next()},0),this.free}updateTaken(e){return br(t=>jr(this.updateTakenUnsafe(t,e)))}resize(e){return br(t=>(this.permits=e,this.free<0||this.updateTakenUnsafe(t,e=>e),ze))}release(e){return this.updateTaken(t=>t-e)}get releaseAll(){return this.updateTaken(e=>0)}withPermits(e){return t=>xe(n=>Wt(n(this.take(e)),e=>l(n(t),()=>{this.updateTakenUnsafe(ue(),t=>t-e)},!0)))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>xe(n=>this.free<e?st:(this.taken+=e,l(n(Sr(t)),()=>{this.updateTakenUnsafe(ue(),t=>t-e)},!0)))}},wo=`~effect/Channel`,To=e=>Be(e,wo),Eo={[wo]:{_Env:A,_InErr:A,_InElem:A,_OutErr:A,_OutElem:A},pipe(){return Tn(this,arguments)}},Do=e=>{let t=Object.create(Eo);return t.transform=(t,n)=>we(e(t,n),e=>C(tn(e))),t},Oo=(e,t)=>Do((n,r)=>T(jo(e)(n,r),e=>t(e,r))),ko=e=>Do((t,n)=>e),Ao=e=>Do(j(function*(t,n){let r=mt(n),i=e=>ut(r,Wn(e));return hr(yield*hr(e(t,n,r),i),i)})),jo=e=>e.transform,Mo=(e,t,n)=>Ja({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(nt(t=>f(e,ro(t))),nt(n=>Pn(Ce(t(n),e),e))),No=(e,t)=>Do((n,r)=>k(Mo(r,e,t),io)),Po=e=>Do((t,n)=>_(()=>jo(e())(t,n))),Fo=ko(C(Qr())),Io=e=>ko(C(Ie(e))),Lo=e=>ko(C(io(e))),Ro=e=>ko(C(Jr(za(e),()=>Qr()))),zo=e=>Yo(k(La(e),Ro)),Bo=v(2,(e,t)=>Oo(e,e=>y(()=>{let n=0;return k(e,e=>t(e,n++))}))),Vo=e=>e===void 0||e!==`unbounded`&&e<=1,Ho=v(e=>To(e[0]),(e,t,n)=>Vo(n?.concurrency)?Uo(e,t):Wo(e,t,n)),Uo=(e,t)=>Do((n,r)=>{let i=0;return k(jo(e)(n,r),T(e=>t(e,i++)))}),Wo=(e,t,n)=>Ao(j(function*(r,i,a){let o=0,s=yield*jo(e)(r,i),c=n.concurrency===`unbounded`?2**53-1:n.concurrency,l=yield*Ya(0);yield*f(a,ro(l));let u=Wi(yield*It()),d=_a(a);if(n.unordered){let e=So(c),n=mn(e.release(1)),r=Pi({onFailure:e=>T(eo(l,e),n),onSuccess:e=>T(Xa(l,e),n)});yield*e.take(1).pipe(T(()=>s),T(e=>(d(u(r(t(e,o++)))),x)),Dn({disableYield:!0}),we(t=>e.withPermits(c-1)(eo(l,t))),Pn(a))}else{let e=yield*Ya(c-2);yield*f(a,ro(l)),yield*oo(e).pipe($e,T(e=>Xa(l,e)),Dn({disableYield:!0}),we(e=>eo(l,e)),Pn(a));let n,r=e=>{e._tag!==`Success`&&(n=e.cause,to(l,e.cause))};yield*s.pipe(T(i=>{if(n)return tn(n);let a=u(t(i,o++));return d(a),a.addObserver(r),Xa(e,fa(a))}),Dn({disableYield:!0}),we(t=>Xa(e,ke(t)).pipe(Br(eo(e,t)))),Pn(a))}return oo(l)})),Go=e=>Oo(e,e=>{let t,n=0;return C(_(function r(){if(t===void 0)return T(e,e=>{switch(e.length){case 0:return r();case 1:return C(e[0]);default:return t=e,C(e[n++])}});let i=t[n++];return n>=t.length&&(t=void 0,n=0),C(i)}))}),Ko=v(2,(e,t)=>Oo(e,e=>C(T(e,function n(r){let i=[];for(let e=0;e<r.length;e++)t(r[e])&&i.push(r[e]);return le(i)?C(i):T(e,n)})))),qo=v(2,(e,t)=>Oo(e,e=>C(T(e,function n(r){let i=[];for(let e=0;e<r.length;e++){let n=t(r[e]);Je(n)&&i.push(n.success)}return le(i)?C(i):T(e,n)})))),Jo=v(e=>To(e[0]),(e,t,n,r)=>Do((i,a)=>k(jo(e)(i,a),e=>{let i=t(),a,o=0,s,c=Pi(e,{onFailure(e){s=e;let t=r?.onHalt&&r.onHalt(i);return t&&t.length>0?C([i,t]):tn(e)},onSuccess(e){let t=n(i,e);return Hi(t)?C(t):t}});return _(function e(){if(a===void 0)return s?tn(s):T(c,([t,n])=>(i=t,n.length===0?e():n.length===1?C(n[0]):(a=n,e())));let t=a[o++];return o>=a.length&&(a=void 0,o=0),C(t)})}))),Yo=e=>Do((t,n)=>{let r;return C(_(()=>r||e.pipe(Ce(n),T(e=>jo(e)(t,n)),T(e=>r=e))))}),Xo=v(2,(e,t)=>Ao((n,r,i)=>Pr(i,t).pipe(Br(jo(e)(n,r))))),Zo=v(2,(e,t)=>Xo(e,e=>t)),Qo=(e,t,n)=>_(()=>{let r=Tt();return Ar(T(jo(e)(Qr(),r),t),n||C).pipe(ui(e=>ut(r,e)))}),$o=v(2,(e,t)=>Do((n,r)=>k(Ri(jo(e)(n,r),t),Ri(t)))),es=v(2,(e,t)=>Qo(e,e=>Dn(T(e,t),{disableYield:!0}))),ts=j(function*(e){let t=So(1),n=yield*It(),r=Zr(n,zr);return(yield*jo(e)(Qr(),r)).pipe(Ri(n),t.withPermits(1))},we(e=>C(tn(e)))),ns=(e,t)=>jo(e)(Qr(),t),rs=`~effect/Stream`,is={_R:A,_E:A,_A:A},as={[rs]:is,pipe(){return Tn(this,arguments)}},os=e=>{let t=Object.create(as);return t.channel=e,t},ss=`~effect/Sink`,cs={_A:A,_In:A,_L:A,_E:A,_R:A},ls={[ss]:cs,pipe(){return Tn(this,arguments)}},us=e=>{let t=Object.create(ls);return t.transform=e,t},ds=e=>us(t=>{let n=[];if(e<=0)return C([n]);let r;return t.pipe(T(t=>{if(n.length+t.length<=e)return n.push(...t),n.length===e?Qr():x;for(let i=0;i<t.length;i++)if(n.push(t[i]),n.length===e)return i+1<t.length&&(r=t.slice(i+1)),Qr();return x}),Dn({disableYield:!0}),Ar(()=>C([n,r])))}),fs=`~effect/collections/MutableHashMap`,ps={[fs]:fs,[Symbol.iterator](){return this.backing[Symbol.iterator]()},toString(){return`MutableHashMap(${Bt(Array.from(this))})`},toJSON(){return{_id:`MutableHashMap`,values:Yn(Array.from(this))}},[na](){return this.toJSON()},pipe(){return Tn(this,arguments)}},ms=()=>{let e=Object.create(ps);return e.backing=new Map,e.buckets=new Map,e},hs=v(2,(e,t)=>{if(e.backing.has(t))return M(e.backing.get(t));if(_s(t))return D();let n=gs.get(e);if(n!==void 0)return e.backing.has(n)?M(e.backing.get(n)):D();let r=lt(t),i=e.buckets.get(r);return i===void 0?D():vs(e,i,t)}),gs=new WeakMap,_s=e=>typeof e!=`object`&&typeof e!=`function`,vs=(e,t,n)=>{for(let r=0,i=t.length;r<i;r++)if(vt(n,t[r])){let i=t[r];return gs.set(n,i),M(e.backing.get(i))}return D()},ys=v(3,(e,t,n)=>{if(e.backing.has(t)||_s(t))return e.backing.set(t,n),e;let r=gs.get(e);if(r!==void 0&&e.backing.has(r))return e.backing.set(r,n),e;let i=lt(t),a=e.buckets.get(i);return a===void 0?(e.buckets.set(i,[t]),e.backing.set(t,n),e):(r=bs(a,t),r===void 0&&(a.push(t),r=t),e.backing.set(r,n),e)}),bs=(e,t)=>{for(let n=0,r=e.length;n<r;n++)if(vt(t,e[n]))return gs.set(t,e[n]),e[n]},xs=v(2,(e,t)=>{if(_s(t))return e.backing.delete(t),e;let n=gs.get(e)??t,r=lt(n),i=e.buckets.get(r);if(i===void 0)return e;for(let t=0,r=i.length;t<r;t++){let r=i[t];if(r===n||vt(n,r)){e.backing.delete(r),i.splice(t,1);break}}return i.length===0&&e.buckets.delete(r),e}),Ss=`~effect/Stream`,Cs=e=>Be(e,Ss),N=os,ws=e=>e.channel,Ts=(e,t)=>N(No(e,t)),Es=N(Fo),Ds=e=>N(Po(()=>e().channel)),Os=e=>N(Io(e)),ks=e=>N(Lo(e)),As=e=>N(zo(e)),js=e=>N(Do(j(function*(t,n){let r=e.evaluate().getReader();return yield*f(n,e.releaseLockOnEnd?y(()=>r.releaseLock()):yr(()=>r.cancel())),T(Pe({try:()=>r.read(),catch:t=>e.onError(t)}),({done:e,value:t})=>e?Qr():C(xt(t)))}))),Ms=e=>N(Yo(k(e,ws))),Ns=v(e=>Cs(e[0]),(e,t,n)=>e.channel.pipe(Go,Ho(t,n),Bo(xt),N)),Ps=v(2,(e,t)=>N(Ko(ws(e),t))),Fs=v(2,(e,t)=>N(qo(ws(e),t))),Is=v(3,(e,t,n)=>Ds(()=>{let r=!0;return N(Jo(e.channel,mn(t),(e,t)=>{let i=_r();r&&(r=!1,i.push(e));for(let r=0;r<t.length;r++)e=n(e,t[r]),i.push(e);return[e,xt(i)]}))})),Ls=v(3,(e,t,n)=>Rs(e,ds(t),ti(n))),Rs=v(3,(e,t,n)=>N(Ao(j(function*(r,i,a){let o=yield*ns(e.channel,i),s=va(!1),c=Symbol(),l=yield*Ja({capacity:0});yield*o.pipe(s.whenOpen,T(e=>(s.closeUnsafe(),Xa(l,e))),Dn,we(e=>eo(l,e)),Pn(a));let u=D(),d,f=!1,p=yield*Si(n),m=_(function e(){return p(u).pipe(T(()=>f?Xa(l,c):e()),T(()=>ar),Ar(()=>Qr()))}),h=oo(l).pipe(T(e=>e===c?Qr():(f=!0,C(e)))),ee=_(()=>{if(d!==void 0){let e=d;return d=void 0,f=!0,C(e)}return s.openUnsafe(),h}),te=T(([e,t])=>!f&&l.state._tag===`Done`?Qr():(u=M(e),d=t,C(xt(e))));return _(()=>l.state._tag===`Done`&&d===void 0?l.state.exit:(f=d!==void 0,C(_(()=>t.transform(ee,a))))).pipe(T(e=>Jn(te(e),m)))})))),zs=v(2,(e,t)=>N(Zo(e.channel,t))),Bs=v(2,(e,t)=>N($o(e.channel,t))),Vs=v(2,(e,t)=>es(e.channel,t)),Hs=e=>ts(e.channel),Us=v(e=>Cs(e[0]),(e,t,n)=>{let r,i,a=va(!1);return new ReadableStream({start(n){i=ae(Ri(Vs(e,e=>a.whenOpen(y(()=>{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(mr(e.cause)):n.close()})},pull(){return new Promise(e=>{r=e,a.openUnsafe()})},cancel(){if(i)return Gt(dt(ma(i)))}},n?.strategy)}),Ws=v(e=>Cs(e[0]),(e,t)=>k(It(),n=>Us(e,n,t))),Gs=e(t(),1),Ks=e(Mn(),1);function qs(e){return{_tag:`Value`,value:e}}function Js(e,t){return{_tag:`Record`,keys:e,value:t}}function Ys(e,t){return{_tag:`Array`,length:e,value:t}}o(`SourceError`);var Xs=Ot(`effect/ConfigProvider`,{defaultValue:()=>rc()}),Zs={...Fi,toJSON(){return{_id:`ConfigProvider`}}};function Qs(e,t,n){let r=Object.create(Zs);return r.get=e,r.mapInput=t,r.prefix=n,r.load=r=>(t&&(r=t(r)),n&&(r=[...n,...r]),e(r)),r}var $s=e=>bi(e)?Bi(Xs)(e):pe(Xs)(e);function ec(e){return Qs(t=>C(tc(e,t)))}function tc(e,t){let n=e;for(let e of t){if(n==null)return;if(Array.isArray(n)){if(typeof e!=`number`||!Number.isInteger(e)||e<0||e>=n.length)return;n=n[e];continue}if(Pt(n)){if(typeof e!=`string`||!Object.hasOwn(n,e))return;n=n[e];continue}return}return nc(n)}function nc(e){if(e!=null)return typeof e==`string`?qs(e):typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`?qs(String(e)):Array.isArray(e)?Ys(e.length):Pt(e)?Js(new Set(Object.keys(e))):qs(Bt(e))}function rc(e){let t=e?.env??{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`},n=ic(t);return Qs(e=>C(oc(n,t,e)))}function ic(e){let t={};for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let e=n.split(`_`),i=t;for(let t of e)i.children??={},i=i.children[t]??={};i.value=r}return t}var ac=/^(0|[1-9][0-9]*)$/;function oc(e,t,n){let r=t[n.map(String).join(`_`)],i=sc(e,n),a=i?.children?Object.keys(i.children):[];return a.length===0?r===void 0?void 0:qs(r):a.every(e=>ac.test(e))?Ys(Math.max(...a.map(e=>parseInt(e,10)))+1,r):Js(new Set(a),r)}function sc(e,t){if(t.length===0)return e;let n=e;for(let e of t)if(n=n?.children?.[String(e)],!n)return;return n}var cc=`~effect/Config`,lc=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},uc={...Qn({label:`Config`,evaluate(e){return this.parse(e.getRef(Xs))}}),[cc]:cc,toJSON(){return{_id:`Config`}}};function dc(e){let t=Object.create(uc);return t.parse=e,t}var fc=v(2,(e,t)=>dc(n=>k(e.parse(n),t))),pc=v(2,(e,t)=>dc(n=>at(e.parse(n),e=>t(e).parse(n))));function mc(e){switch(e._tag){case`MissingKey`:return!0;case`InvalidType`:case`InvalidValue`:return Ai(e.actual)||ei(e.actual)&&e.actual.value===void 0;case`OneOf`:return e.actual===void 0;case`Encoding`:return Ai(e.actual)||ei(e.actual)&&e.actual.value===void 0?!0:mc(e.issue);case`Pointer`:case`Filter`:return mc(e.issue);case`UnexpectedKey`:return!1;case`Forbidden`:return!1;case`Composite`:case`AnyOf`:return e.issues.every(mc)}}var hc=v(2,(e,t)=>pc(e,e=>{if(Kr(e.cause)){let n=e.cause.issue;if(mc(n))return xc(t)}return bc(e.cause)})),gc=e=>e.pipe(fc(M),hc(D())),_c=j(function*(e,t){let n=yield*e.load(t);if(n!==void 0)switch(n._tag){case`Value`:return n.value;case`Record`:{if(n.value!==void 0)return n.value;let r={};for(let i of n.keys){let n=yield*_c(e,[...t,i]);n!==void 0&&(r[i]=n)}return r}case`Array`:{if(n.value!==void 0)return n.value;let r=[];for(let i=0;i<n.length;i++)r.push(yield*_c(e,[...t,i]));return r}}}),vc=j(function*(e,t,n){switch(e._tag){case`Objects`:{let r={};for(let i of e.propertySignatures){let e=i.name;if(typeof e==`string`){let a=yield*vc(i.type,t,[...n,e]);a!==void 0&&(r[e]=a)}}if(e.indexSignatures.length>0){let i=yield*t.load(n);if(i&&i._tag===`Record`)for(let a of e.indexSignatures){let e=Vi(a.parameter);for(let o of i.keys)if(!Object.hasOwn(r,o)&&e(o)){let e=yield*vc(a.type,t,[...n,o]);e!==void 0&&(r[o]=e)}}}return r}case`Arrays`:{let r=yield*t.load(n);if(r&&r._tag===`Value`)return r.value;let i=[];for(let r=0;r<e.elements.length;r++)i.push(yield*vc(e.elements[r],t,[...n,r]));return i}case`Union`:return yield*_c(t,n);case`Suspend`:return yield*vc(e.thunk(),t,n);default:{let e=yield*t.load(n);return e===void 0?void 0:e._tag===`Value`||e._tag===`Record`&&e.value!==void 0||e._tag===`Array`&&e.value!==void 0?e.value:void 0}}});function yc(e,t){let n=Tr(e),r=ia(n),i=Zn(n.ast),a=typeof t==`string`?[t]:t??[];return dc(e=>{let t=e.prefix?[...e.prefix,...a]:a;return vc(i,e,a).pipe(Ae(e=>r(e).pipe(Ur(e=>new Bn(t.length>0?new qi(t,e):e)))),Ur(e=>new lc(e)))})}function bc(e){return dc(()=>Ie(new lc(e)))}function xc(e){return dc(()=>C(e))}function Sc(e){return yc(b,e)}var Cc=`~effect/SubscriptionRef`,wc=e=>Be(e,Cc);({...Fi});var Tc=e=>As(e.pubsub),Ec=e=>y(()=>e.value),Dc=(e,t)=>{e.value=t,Ia(e.pubsub,t)},Oc=v(2,(e,t)=>e.semaphore.withPermit(y(()=>Dc(e,t)))),kc=class extends i()(`effect/reactivity/Reactivity`){},Ac=y(()=>{let e=new Map,t=t=>{Ic(t,t=>{let n=e.get(t);n!==void 0&&n.forEach(e=>e())})},n=e=>da(n=>{let r=n.mapUnsafe.get(jc.key);return r?Ic(e,e=>{r.add(e)}):t(e),x}),r=(e,t)=>nt(t,n(e)),i=(t,n)=>{let r=[];return Ic(t,t=>{r.push(t);let i=e.get(t);i===void 0&&(i=new Set,e.set(t,i)),i.add(n)}),()=>{for(let t=0;t<r.length;t++){let i=e.get(r[t]);i.delete(n),i.size===0&&e.delete(r[t])}}},a=(e,t)=>s(function*(){let n=yield*It(),r=Zr(n,zr),a=yield*Ja(),o=Ze(Wi(n),_a(r)),s=!1,c=!1,l=e=>{e._tag===`Failure`?to(a,e.cause):Za(a,e.value),c?(c=!1,o(t).addObserver(l)):s=!1};function u(){if(s){c=!0;return}s=!0,o(t).addObserver(l)}return yield*f(r,y(i(e,u))),u(),a});return kc.of({mutation:r,query:a,stream:(e,t)=>a(e,t).pipe(k(ks),Ms),invalidateUnsafe:t,invalidate:n,registerUnsafe:i,withBatch:t=>_(()=>{let n=new Set;return t.pipe(ta(jc,n),ui(t=>y(()=>{n.forEach(t=>{let n=e.get(t);n!==void 0&&n.forEach(e=>e())})})))})})}),jc=class extends i()(`effect/reactivity/Reactivity/PendingInvalidation`){},Mc=v(2,(e,t)=>kc.use(n=>n.mutation(t,e))),Nc=e=>kc.use(t=>t.invalidate(e)),Pc=Bi(kc)(Ac);function Fc(e){switch(typeof e){case`string`:case`number`:case`bigint`:case`boolean`:return String(e);default:return lt(e)}}var Ic=(e,t)=>{if(Array.isArray(e)){for(let n=0;n<e.length;n++)t(Fc(e[n]));return}for(let n in e){t(n);let r=e[n];for(let e=0;e<r.length;e++)t(`${n}:${Fc(r[e])}`)}},Lc=`~effect/reactivity/AsyncResult`,Rc=e=>Be(e,Lc),zc={[Lc]:{E:A,A},pipe(){return Tn(this,arguments)},[Rr](e){if(this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case`Initial`:return!0;case`Success`:return vt(this.value,e.value);case`Failure`:return vt(this.cause,e.cause)}},[Se](){let e=pt(`${this._tag}:${this.waiting}`);return this._tag===`Initial`?e:Nr(e)(this._tag===`Success`?lt(this.value):lt(this.cause))}},Bc=(e,t)=>e._tag===`Success`?P(e.value):Jc(e.cause,{previous:t}),Vc=e=>e._tag===`None`?Wc(!0):Xc(e.value),Hc=e=>e._tag===`Initial`,Uc=e=>e._tag!==`Initial`,Wc=(e=!1)=>{let t=Object.create(zc);return t._tag=`Initial`,t.waiting=e,t},Gc=e=>e._tag===`Success`,P=(e,t)=>{let n=Object.create(zc);return n._tag=`Success`,n.value=e,n.waiting=t?.waiting??!1,n.timestamp=t?.timestamp??Date.now(),n},Kc=e=>e._tag===`Failure`,qc=(e,t)=>{let n=Object.create(zc);return n._tag=`Failure`,n.cause=e,n.previousSuccess=t?.previousSuccess??D(),n.waiting=t?.waiting??!1,n},Jc=(e,t)=>qc(e,{previousSuccess:Sn(t.previous,e=>Gc(e)?M(e):Kc(e)?e.previousSuccess:D()),waiting:t.waiting}),Yc=(e,t)=>Jc(yi(e),t),Xc=(e,t)=>{if(e.waiting)return t?.touch?Zc(e):e;let n=Object.assign(Object.create(zc),e);return n.waiting=!0,t?.touch&&Gc(n)&&(n.timestamp=Date.now()),n},Zc=e=>Gc(e)?P(e.value,{waiting:e.waiting}):e,Qc=(e,t)=>e._tag===`Failure`?Jc(e.cause,{previous:t,waiting:e.waiting}):e,$c=e=>e._tag===`Success`?M(e.value):e._tag===`Failure`?xi(e.previousSuccess,e=>e.value):D(),el=e=>r($c(e),()=>new lr(`AsyncResult.getOrThrow: no value found`)),tl=e=>{switch(e._tag){case`Success`:return bn(e.value);case`Failure`:return ke(e.cause);default:return hn(new lr)}},nl=v(2,(e,t)=>{switch(e._tag){case`Initial`:return e;case`Failure`:return qc(e.cause,{previousSuccess:xi(e.previousSuccess,e=>P(t(e.value),e)),waiting:e.waiting});case`Success`:return P(t(e.value),e)}}),rl=e=>{let t=e.success??Yt,r=e.error??Yt,i=ni()([t,Le(r,jt)],([e,t])=>(n,r,i)=>{if(!Rc(n))return Ie(new ce(r,M(n)));switch(n._tag){case`Initial`:return C(n);case`Success`:return Ei(ia(e)(n.value,i),{onSuccess:e=>P(e,n),onFailure:e=>new Ht(r,M(n),[new qi([`value`],e)])});case`Failure`:{let a=n.previousSuccess.pipe(xi(t=>Ei(ia(e)(t.value,i),{onSuccess:e=>M(P(e,t)),onFailure:e=>new Ht(r,M(n),[new qi([`previousSuccess`,`value`],e)])})),Dt(()=>Ct)),o=Ur(ia(t)(n.cause,i),e=>new Ht(r,M(n),[new qi([`cause`],e)]));return Ae(a,e=>er(o,t=>qc(t,{previousSuccess:e,waiting:n.waiting})))}}},{expected:`AsyncResult`,toCodec([e,t]){let r=On(`Success`,{value:e,waiting:ye,timestamp:Te});return Ii()(n([On(`Initial`,{waiting:ye}),r,On(`Failure`,{cause:t,previousSuccess:qe(r),waiting:ye})]),Qi({decode:e=>{switch(e._tag){case`Initial`:return Wc(e.waiting);case`Success`:return P(e.value,{waiting:e.waiting,timestamp:e.timestamp});case`Failure`:return qc(e.cause,{previousSuccess:xi(e.previousSuccess,e=>P(e.value,e)),waiting:e.waiting})}},encode(e){switch(e._tag){case`Initial`:return{_tag:`Initial`,waiting:e.waiting};case`Success`:return{_tag:`Success`,value:e.value,waiting:e.waiting,timestamp:e.timestamp};case`Failure`:return{_tag:`Failure`,cause:e.cause,previousSuccess:e.previousSuccess,waiting:e.waiting}}}}))},toEquivalence:fe,toFormatter:([e,t])=>n=>{switch(n._tag){case`Success`:return`AsyncResult.Success(${e(n.value)}, ${n.waiting}, ${n.timestamp})`;case`Failure`:return`AsyncResult.Failure(${t(n.cause)}, ${n.waiting})`;case`Initial`:return`AsyncResult.Initial(${n.waiting}, ${n.waiting})`}}});return Object.assign(i,{success:t,error:r})},il=`~effect/reactivity/AtomRegistry`,al=e=>Be(e,il),ol=e=>new pl(e?.initialValues,e?.scheduleTask,e?.timeoutResolution,e?.defaultIdleTTL),sl=i(il),cl=v(e=>al(e[0]),(e,t,n)=>{let r=n?.suspendOnWaiting??!1;return Et(n=>{let i=e.get(t);if(i._tag!==`Initial`&&!(r&&i.waiting))return n(tl(i));let a=e.subscribe(t,e=>{e._tag!==`Initial`&&!(r&&e.waiting)&&(n(tl(e)),a())});return y(a)})}),ll={immediate:!0},ul=e=>{e()},dl=`~effect-atom/atom/Atom/Serializable`,fl=e=>dl in e?e[dl].key:e,pl=class{[il];timeoutResolution;defaultIdleTTL;scheduler;schedulerAsync;dispatcher;onNodeAdded;onNodeRemoved;constructor(e,t,n,r){if(this[il]=il,this.scheduler=new Ne(`sync`,t),this.schedulerAsync=new Ne(`async`,t),this.dispatcher=this.schedulerAsync.makeDispatcher(),this.defaultIdleTTL=r,n===void 0&&r!==void 0?this.timeoutResolution=Math.round(r/2):this.timeoutResolution=n??1e3,e!==void 0)for(let[t,n]of e){let e=t;for(;e.initialValueTarget;)e=e.initialValueTarget;this.ensureNode(e).setInitialValue(n)}}nodes=new Map;preloadedSerializable=new Map;timeoutBuckets=new Map;nodeTimeoutBucket=new Map;disposed=!1;getNodes(){return this.nodes}get(e){return this.ensureNode(e).value()}set(e,t){e.write(this.ensureNode(e).writeContext,t)}setSerializable(e,t){this.preloadedSerializable.set(e,t)}modify(e,t){let n=this.ensureNode(e),r=t(n.value());return e.write(n.writeContext,r[1]),r[0]}update(e,t){let n=this.ensureNode(e);e.write(n.writeContext,t(n.value()))}refresh=e=>{e.refresh===void 0?this.invalidateAtom(e):e.refresh(this.refresh)};subscribe(e,t,n){let r=this.ensureNode(e);n?.immediate&&t(r.value());let i=r.subscribe(function(){t(r._value)});return()=>{i(),r.canBeRemoved&&this.scheduleNodeRemoval(r)}}mount(e){return this.subscribe(e,$t,ll)}atomHasTtl(e){return!e.keepAlive&&e.idleTTL!==0&&(e.idleTTL!==void 0||this.defaultIdleTTL!==void 0)}ensureNode(e){let t=fl(e),n=this.nodes.get(t);if(n===void 0?(n=this.createNode(e),this.nodes.set(t,n),this.onNodeAdded?.(n)):this.atomHasTtl(e)&&this.removeNodeTimeout(n),typeof t==`string`&&this.preloadedSerializable.has(t)){let r=this.preloadedSerializable.get(t);this.preloadedSerializable.delete(t);let i=e[dl].decode(r);n.setValue(i)}return n}createNode(e){if(this.disposed)throw Error(`Cannot access Atom ${e}: registry is disposed`);return e.keepAlive||this.scheduleAtomRemoval(e),new hl(this,e)}invalidateAtom=e=>{this.ensureNode(e).invalidate()};scheduleAtomRemoval(e){this.dispatcher.scheduleTask(()=>{let t=this.nodes.get(fl(e));t!==void 0&&t.canBeRemoved&&this.removeNode(t)},0)}scheduleNodeRemoval(e){this.dispatcher.scheduleTask(()=>{e.canBeRemoved&&this.removeNode(e)},0)}removeNode(e){this.atomHasTtl(e.atom)?this.setNodeTimeout(e):(this.nodes.delete(fl(e.atom)),e.remove(),this.onNodeRemoved?.(e))}setNodeTimeout(e){if(this.nodeTimeoutBucket.has(e))return;let t=e.atom.idleTTL??this.defaultIdleTTL;if(this.#e!==null&&(t-=this.#e,t<=0)){this.nodes.delete(fl(e.atom)),e.remove(),this.onNodeRemoved?.(e);return}let n=Math.ceil(t/this.timeoutResolution)*this.timeoutResolution,r=Date.now()+n,i=r-r%this.timeoutResolution+this.timeoutResolution,a=this.timeoutBuckets.get(i);a===void 0&&(a=[new Set,setTimeout(()=>this.sweepBucket(i),i-Date.now())],this.timeoutBuckets.set(i,a)),a[0].add(e),this.nodeTimeoutBucket.set(e,i)}removeNodeTimeout(e){let t=this.nodeTimeoutBucket.get(e);if(t===void 0)return;this.nodeTimeoutBucket.delete(e),this.scheduleNodeRemoval(e);let[n,r]=this.timeoutBuckets.get(t);n.delete(e),n.size===0&&(clearTimeout(r),this.timeoutBuckets.delete(t))}#e=null;sweepBucket(e){let t=this.timeoutBuckets.get(e)[0];this.timeoutBuckets.delete(e),t.forEach(e=>{this.nodeTimeoutBucket.delete(e),e.canBeRemoved&&(this.nodes.delete(fl(e.atom)),this.onNodeRemoved?.(e),this.#e=e.atom.idleTTL??this.defaultIdleTTL,e.remove(),this.#e=null)})}reset(){this.timeoutBuckets.forEach(([,e])=>clearTimeout(e)),this.timeoutBuckets.clear(),this.nodeTimeoutBucket.clear(),this.nodes.forEach(e=>{e.remove(),this.onNodeRemoved?.(e)}),this.nodes.clear()}dispose(){this.disposed=!0,this.reset()}},ml={alive:1,initialized:2,waitingForValue:4},F={uninitialized:ml.alive|ml.waitingForValue,stale:ml.alive|ml.initialized|ml.waitingForValue,valid:ml.alive|ml.initialized,removed:0},hl=class{constructor(e,t){this.registry=e,this.atom=t,this.writeContext=new yl(e,this)}registry;atom;state=F.uninitialized;lifetime;writeContext;preserveInitialValueOnBuild=!1;parents=[];previousParents;children=[];listeners=new Set;skipInvalidation=!1;currentState(){switch(this.state){case F.uninitialized:return`uninitialized`;case F.stale:return`stale`;case F.valid:return`valid`;default:return`removed`}}get canBeRemoved(){return!this.atom.keepAlive&&this.listeners.size===0&&this.children.length===0&&this.state!==0}_value=void 0;value(){if((this.state&ml.waitingForValue)!==0){this.lifetime=vl(this);let e=this.atom.read(this.lifetime);if((this.state&ml.waitingForValue)!==0&&(this.preserveInitialValueOnBuild?(this.preserveInitialValueOnBuild=!1,this.state=F.valid):this.setValue(e)),this.previousParents){let e=this.previousParents;this.previousParents=void 0;for(let t=0;t<e.length;t++)e[t].removeChild(this),e[t].canBeRemoved&&this.registry.scheduleNodeRemoval(e[t])}}return this._value}valueOption(){return(this.state&ml.initialized)===0?D():M(this._value)}setInitialValue(e){if((this.state&ml.initialized)===0){this.preserveInitialValueOnBuild=!0,this.state=F.stale,this._value=e,I.phase===bl.collect?I.notify.add(this):this.notify();return}this.setValue(e)}setValue(e){if((this.state&ml.initialized)===0){this.state=F.valid,this._value=e,I.phase===bl.collect?I.notify.add(this):this.notify();return}this.state=F.valid,!Object.is(this._value,e)&&(this._value=e,this.skipInvalidation?this.skipInvalidation=!1:this.invalidateChildren(),this.listeners.size>0&&(I.phase===bl.collect?I.notify.add(this):this.notify()))}addParent(e){if(this.parents.push(e),this.previousParents!==void 0){let t=this.previousParents.indexOf(e);t!==-1&&(this.previousParents[t]=this.previousParents[this.previousParents.length-1],this.previousParents.pop()===void 0&&(this.previousParents=void 0))}e.children.indexOf(this)===-1&&(e.children.push(this),e.skipInvalidation&&=!1)}removeChild(e){let t=this.children.indexOf(e);t!==-1&&(this.children[t]=this.children[this.children.length-1],this.children.pop())}invalidate(){this.state===F.valid&&(this.state=F.stale,this.disposeLifetime()),I.phase===bl.collect?I.stale.push(this):this.atom.lazy&&this.listeners.size===0&&!gl(this.children)?(this.invalidateChildren(),this.skipInvalidation=!0):this.value()}invalidateChildren(){if(this.children.length===0)return;let e=this.children;this.children=[];for(let t=0;t<e.length;t++)e[t].invalidate()}notify(){this.listeners.forEach(ul),I.phase===bl.commit&&I.notify.delete(this)}disposeLifetime(){this.lifetime!==void 0&&(this.lifetime.dispose(),this.lifetime=void 0),this.parents.length!==0&&(this.previousParents=this.parents,this.parents=[])}remove(){if(this.state=F.removed,this.listeners.clear(),this.lifetime===void 0||(this.disposeLifetime(),this.previousParents===void 0))return;let e=this.previousParents;this.previousParents=void 0;for(let t=0;t<e.length;t++)e[t].removeChild(this),e[t].canBeRemoved&&this.registry.removeNode(e[t])}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}};function gl(e){if(e.length===0)return!1;let t=e,n,r=0;for(;t!==void 0;){for(let e=0,r=t.length;e<r;e++){let r=t[e];if(!r.atom.lazy||r.listeners.size>0)return!0;r.children.length>0&&(n===void 0?n=[r.children]:n.push(r.children))}t=n?.[r++]}return!1}var _l={get registry(){return this.node.registry},addFinalizer(e){if(this.disposed)return e();this.finalizers??=[],this.finalizers.push(e)},get(e){if(this.disposed)return this.node.registry.get(e);let t=this.node.registry.ensureNode(e);return this.node.addParent(t),t.value()},result(e,t){if(this.disposed||this.isFn)return this.resultOnce(e,t);let n=this.get(e);if(t?.suspendOnWaiting&&n.waiting)return ar;switch(n._tag){case`Initial`:return ar;case`Failure`:return ke(n.cause);case`Success`:return C(n.value)}},resultOnce(e,t){return Et(n=>{let r=this.once(e);if(r._tag!==`Initial`&&!(t?.suspendOnWaiting&&r.waiting))return n(tl(r));let i=this.node.registry.subscribe(e,e=>{e._tag===`Initial`||t?.suspendOnWaiting&&e.waiting||(i(),n(tl(e)))},{immediate:!1});return y(i)})},setResult(e,t){return this.disposed?ar:(this.node.registry.set(e,t),this.resultOnce(e,{suspendOnWaiting:!0}))},some(e){if(this.disposed||this.isFn)return this.someOnce(e);let t=this.get(e);return t._tag===`None`?ar:C(t.value)},someOnce(e){return Et(t=>{let n=this.once(e);if(ei(n))return t(C(n.value));let r=this.node.registry.subscribe(e,e=>{Ai(e)||(r(),t(C(e.value)))},{immediate:!1});return y(r)})},once(e){return this.node.registry.get(e)},self(){return this.disposed?D():this.node.valueOption()},refresh(e){this.disposed||this.node.registry.refresh(e)},refreshSelf(){this.disposed||this.node.invalidate()},mount(e){this.disposed||this.addFinalizer(this.node.registry.mount(e))},subscribe(e,t,n){this.disposed||this.addFinalizer(this.node.registry.subscribe(e,t,n))},setSelf(e){this.disposed||this.node.setValue(e)},set(e,t){this.disposed||this.node.registry.set(e,t)},stream(e,t){return this.disposed?Es:Ts(n=>y(()=>{this.subscribe(e,e=>Za(n,e),{immediate:!t?.withoutInitialValue})}))},streamResult(e,t){return this.stream(e,t).pipe(Ps(Uc),Ns(e=>e._tag===`Success`?C(e.value):tn(e.cause)))},dispose(){if(this.disposed=!0,this.finalizers===void 0)return;let e=this.finalizers;this.finalizers=void 0;for(let t=e.length-1;t>=0;t--)e[t]()}},vl=e=>{function t(n){if(t.disposed||t.isFn)return e.registry.get(n);let r=e.registry.ensureNode(n),i=r.value();return e.addParent(r),i}return Object.setPrototypeOf(t,_l),t.isFn=!1,t.disposed=!1,t.finalizers=void 0,t.node=e,t},yl=class{constructor(e,t){this.registry=e,this.node=t}registry;node;get(e){return this.registry.get(e)}set(e,t){return this.registry.set(e,t)}setSelf(e){return this.node.setValue(e)}refreshSelf(){return this.node.invalidate()}},bl={disabled:0,collect:1,commit:2},I={phase:bl.disabled,depth:0,stale:[],notify:new Set};function xl(e){I.phase=bl.collect,I.depth++;try{if(e(),I.depth===1){for(let e=0;e<I.stale.length;e++)Sl(I.stale[e]);I.phase=bl.commit;for(let e of I.notify)e.notify();I.notify.clear()}}finally{I.depth--,I.depth===0&&(I.phase=bl.disabled,I.stale=[])}}function Sl(e){if(e.state!==F.valid){for(let t=0;t<e.parents.length;t++){let n=e.parents[t];n.state!==F.valid&&Sl(n)}e.state!==F.valid&&e.value()}}var Cl=`~effect/reactivity/Atom`,wl=e=>Be(e,Cl),Tl=`~effect/reactivity/Atom/Writable`,El=v(2,(e,t)=>{let n=hi(t),r=Ue(n);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!r,idleTTL:r?An(n):void 0})}),Dl=El(0),Ol={[Cl]:Cl,...Fi,toJSON(){return{_id:`Atom`,keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},kl={...Ol,atom(e,t){let n=Ll(e,t);return Nl(e=>{let t=e.self(),r=e(this);return r._tag===`Success`?n(e,r.value):Qc(r,t)})},fn(e,t){return arguments.length===0?(e,t)=>Al(this,e,t):Al(this,e,t)},pull(e,t){let n=Dl(Bl(0));return tu(n,Nl(r=>{let i=r.self(),a=r(this);return a._tag===`Success`?Hl(r,eu(r,n,e,t),Wc(!0),a.value):Qc(a,i)}))},subscriptionRef(e){return Jl(Dl(Nl(t=>{let n=t.self(),r=t(this);if(r._tag!==`Success`)return Qc(r,n);let i=typeof e==`function`?e(t):e;return wc(i)?i:Hl(t,i,Wc(!0),r.value)})),(e,t)=>ql(e,t,el(e(this))))}},Al=(e,t,n)=>{let[r,i,a]=$l(n?.reactivityKeys?(e,r)=>{let i=t(e,r);return bi(i)?Mc(i,n.reactivityKeys):zs(i,Nc(n.reactivityKeys))}:t,n);return Pl(t=>{t.get(a);let n=t.self(),i=t.get(e);return i._tag===`Success`?r(t,i.value):Qc(i,n)},i)},jl={...Ol,[Tl]:Tl},Ml=e=>Tl in e,Nl=(e,t)=>{let n=Object.create(Ol);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.refresh=t,n},Pl=(e,t,n)=>{let r=Object.create(jl);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.write=t,r.refresh=n,r};function Fl(e,t){e.setSelf(t)}var Il=(e,t)=>{let n=Ll(e,t);return`~effect/reactivity/Atom`in n?n:Nl(n)},Ll=(e,t)=>{if(typeof e==`function`&&!bi(e)&&!Cs(e)){let n=e;return function(e,r){let i=n(e);switch(typeof i){case`function`:case`object`:return i===null?i:Rl in i?Vl(e,i,t,r):zl in i?Gl(e,i,t,r):i;default:return i}}}else if(bi(e))return function(n,r){return Vl(n,e,t,r)};else if(Cs(e))return function(n,r){return Gl(n,e,t,r)};return Bl(e)},Rl=`~effect/Effect`,zl=`~effect/Stream`,Bl=e=>Pl(function(t){return e},Fl),Vl=(e,t,n,r)=>Hl(e,t,n?.initialValue===void 0?Wc():P(n.initialValue),r,n?.uninterruptible);function Hl(e,t,n,r=Oi(),i=!1){let a=e.self(),o=Tt();e.addFinalizer(()=>{Wi(r)(ut(o,Nn))});let s=new Map(r.mapUnsafe);s.set(zr.key,o),s.set(sl.key,e.registry),s.set(Zt.key,e.registry.scheduler);let c,l=!1,u=Ul(ri(s),t,function(t){c=Bc(t,a),l&&e.setSelf(c)},i);return l=!0,u!==void 0&&e.addFinalizer(u),c===void 0?a._tag===`Some`?Vc(a):Xc(n):c}function Ul(e,t,n,r=!1){if(_i(t)){n(t);return}let i=Wi(e)(t);i.currentDispatcher?.flush();let a=i.pollUnsafe();if(a){n(a);return}let o=i.addObserver(n);function s(){o(),r||i.interruptUnsafe()}return s}var Wl=(e=>{let t=Pc;function n(r){let i=Object.create(kl);i.keepAlive=!1,i.lazy=!0,i.refresh=void 0,i.factory=n;let a=ru(Nl(typeof r==`function`?e=>ve(r(e),t):()=>ve(r,t)));return i.layer=a,i.read=function(t){let n=t(a);return Vl(t,T(Lr,t=>zn(n,e.memoMap,t)),{uninterruptible:!0})},i}n.memoMap=e.memoMap,n.addGlobalLayer=e=>{t=ve(t,qt(e,Pc))};let r=Dl(Il(da(t=>zn(Pc,e.memoMap,Zr(t,zr))).pipe(k(Zr(kc)))));return n.withReactivity=e=>t=>au(t,n=>{let i=el(n(r));return n.addFinalizer(i.registerUnsafe(e,()=>{n.refresh(t)})),n.subscribe(t,e=>n.setSelf(e)),n.once(t)},{initialValueTarget:t}),n})({memoMap:Vt()});Wl.withReactivity;var Gl=(e,t,n,r)=>Kl(e,t,n?.initialValue===void 0?Wc():P(n.initialValue),r);function Kl(e,t,n,r=Oi()){let i=e.self();r=cr(r,sl,e.registry);let a=u(n=>T(ns(t.channel,n),t=>yn({while:sn,body:()=>t,step(t){e.setSelf(P(c(t),{waiting:!0}))}}))).pipe(we(t=>(oi(t)?We(e.self(),Sn($c),kr({onNone:()=>e.setSelf(Yc(new lr,{previous:e.self()})),onSome:t=>e.setSelf(P(t))})):e.setSelf(Jc(t,{previous:e.self()})),x))),o=new Map(r.mapUnsafe);o.set(sl.key,e.registry),o.set(Zt.key,e.registry.scheduler);let s=Ul(ri(o),a,$t,!1);return s!==void 0&&e.addFinalizer(s),i._tag===`Some`?Vc(i):Xc(n)}var ql=(e,t,n=Oi())=>wc(t)?(e.addFinalizer(Tc(t).pipe(Vs(t=>{for(let n=0;n<t.length;n++)e.setSelf(t[n]);return x}),zt(n))),_t(n)(Ec(t))):t._tag===`Success`?Kl(e,Tc(t.value),Wc(!0),n):t,Jl=(e,t)=>{function n(t,n){let r=t.get(e);wc(r)?de(Oc(r,n)):Gc(r)&&de(Oc(r.value,n))}return Pl(n=>{let r=n(e);return wc(r)||Gc(r)?t(n,r):r},n)},Yl=Symbol.for(`effect/reactivity/atom/Atom/Reset`),Xl=Symbol.for(`effect/reactivity/atom/Atom/Interrupt`),Zl=function(...e){return e.length===0?Ql:Ql(...e)},Ql=(e,t)=>{let[n,r]=$l(e,t);return Pl(n,r)};function $l(e,t){let n=Dl(Bl([0,void 0])),r=t?.initialValue===void 0?Wc():P(t.initialValue),i=t?.concurrent?Dl(Nl(e=>{let t=new Set;return e.addFinalizer(()=>t.forEach(e=>e.interruptUnsafe())),t})):void 0;function a(t,a){let o=i?t(i):void 0;t.isFn=!0;let[s,c]=t.get(n);if(s===0)return r;if(c===Xl)return Jc($n(),{previous:t.self()});let l=e(c,t);return Rl in l?(o&&(l=T(xn(l,{startImmediately:!0}),e=>(o.add(e),e.addObserver(()=>o.delete(e)),k(pa(o),e=>e[0])))),Hl(t,l,r,a,!1)):Kl(t,l,r,a)}function o(e,t){uu(()=>{t===Yl?e.set(n,[0,void 0]):t===Xl?e.set(n,[e.get(n)[0]+1,Xl]):e.set(n,[e.get(n)[0]+1,t]),e.refreshSelf()})}return[a,o,n]}var eu=(e,t,n,r)=>T(Hs(typeof n==`function`?n(e):n),n=>{let i=ga().context,a=_r(),o=Pi(n,{onFailure(e){return oi(e)?le(a)?C({done:!0,items:a}):Ie(new lr(`Atom.pull: no items`)):tn(e)},onSuccess(e){let t;return r?.disableAccumulation?t=e:(t=rr(a,e),a=t),C({done:!1,items:t})}}),s=new Set;return e.addFinalizer(()=>{for(let e of s)e()}),e.once(t),e.subscribe(t,()=>{e.setSelf(Vc(e.self()));let t;t=Ul(i,o,n=>{t&&s.delete(t);let r=Bc(n,e.self()),i=s.size>0;e.setSelf(i?Xc(r):r)}),t&&s.add(t)}),o}),tu=(e,t)=>Pl(t.read,function(t,n){t.set(e,t.get(e)+1)}),nu=typeof WeakRef>`u`||typeof FinalizationRegistry>`u`?e=>{let t=ms();return function(n){let r=hs(t,n);if(r._tag===`Some`)return r.value;let i=e(n);return ys(t,n,i),i}}:e=>{let t=ms(),n=new FinalizationRegistry(e=>{xs(t,e)});return function(r){let i=hs(t,r).pipe(_n(e=>e.deref()));if(i._tag===`Some`)return i.value;let a=e(r);return ys(t,r,new WeakRef(a)),n.register(a,r),a}},ru=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0}),iu=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!1}),au=v(e=>wl(e[0]),(e,t,n)=>{let r=Dl(Ml(e)?Pl(n=>t(n,e),function(t,n){t.set(e,n)},e.refresh??function(t){t(e)}):Nl(n=>t(n,e),e.refresh??function(t){t(e)}));return n?.initialValueTarget&&(r.initialValueTarget=ou(n.initialValueTarget)),r}),ou=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t},su=v(2,(e,t)=>au(e,n=>t(n(e)))),cu=e=>{let t=0,n=Dl(Bl([t,void 0]));return Pl(t=>{let r=t.once(e),i=!1;t.subscribe(e,e=>{if(r=e,a.size>0)return;if(i=!1,!Rc(e))return t.setSelf(e);let n=dr(t.self());switch(e._tag){case`Initial`:Hc(n)&&t.setSelf(e);return;case`Success`:Gc(n)?!e.waiting&&e.timestamp>=n.timestamp&&t.setSelf(e):t.setSelf(e);return;case`Failure`:return t.setSelf(e)}});let a=new Set,o=new Set;return t.subscribe(n,([,n])=>{if(a.has(n))return;a.add(n);let s;s=t.registry.subscribe(n,c=>{if(Gc(c)&&c.waiting)return t.setSelf(c.value);a.delete(n),s&&(o.delete(s),s()),!i&&!Kc(c)&&(i=!0),a.size===0&&(i?(i=!1,t.refresh(e)):t.setSelf(r))},{immediate:!0}),a.has(n)?o.add(s):s()}),t.addFinalizer(()=>{for(let e of o)e();a.clear(),o.clear()}),r},(e,r)=>e.set(n,[++t,r]),t=>t(e))},lu=v(2,(e,t)=>{let n=Dl(Bl(Wc()));return Zl((r,i)=>{let a=t.reducer(i(e),r);Rc(a)&&(a=Xc(a,{touch:!0})),i.set(n,P(a,{waiting:!0})),i.set(e,n);let o=typeof t.fn==`function`?iu(t.fn(e=>i.set(n,P(Rc(e)?Xc(e):e,{waiting:!0})))):t.fn;return i.set(o,r),Et(e=>{i.subscribe(o,t=>{t._tag===`Initial`||t.waiting||(i.set(n,nl(t,()=>a)),e(tl(t)))},{immediate:!0})})})}),uu=xl,du=`~effect-atom/atom/Atom/Serializable`,fu=v(2,(e,t)=>{let n=Xr(t.schema);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:e.label??[t.key,Error().stack?.split(`
2
+ `)[5]??``],[du]:{key:t.key,encode:Di(n),decode:Ci(n)}})}),pu=`~effect-atom/atom/Atom/ServerValue`,mu=v(2,(e,t)=>`~effect-atom/atom/Atom/ServerValue`in e?e[pu](e=>t.get(e)):t.get(e));function hu(e){let t=Ks.unstable_scheduleCallback(4,e);return()=>Ks.unstable_cancelCallback(t)}var gu=Gs.createContext(ol({scheduleTask:hu,defaultIdleTTL:400})),_u=new WeakMap;function vu(e,t){let n=_u.get(e);n===void 0&&(n=new WeakMap,_u.set(e,n));let r=n.get(t);if(r!==void 0)return r;let i={subscribe(n){return e.subscribe(t,n)},snapshot(){return e.get(t)},getServerSnapshot(){return mu(t,e)}};return n.set(t,i),i}function yu(e,t){let n=vu(e,t);return Gs.useSyncExternalStore(n.subscribe,n.snapshot,n.getServerSnapshot)}var bu=(e,t)=>{let n=Gs.useContext(gu);return t?yu(n,Gs.useMemo(()=>su(e,t),[e,t])):yu(n,e)};function xu(e,t){Gs.useEffect(()=>e.mount(t),[t,e])}function Su(e,t,n){return n?.mode===`promise`||n?.mode===`promiseExit`?Gs.useCallback(r=>{e.set(t,r);let i=ge(cl(e,t,{suspendOnWaiting:!0}));return n.mode===`promise`?i.then(Cu):i},[e,t,n.mode]):Gs.useCallback(n=>{e.set(t,typeof n==`function`?n(e.get(t)):n)},[e,t])}var Cu=e=>{if(En(e))return e.value;throw mr(e.cause)},wu=(e,t)=>{let n=Gs.useContext(gu);return xu(n,e),Su(n,e,t)},Tu=e=>{let t=Gs.useContext(gu);return xu(t,e),Gs.useCallback(()=>{t.refresh(e)},[t,e])},Eu={suspendOnWaiting:new Map,default:new Map};function Du(e,t,n){let r=n?Eu.suspendOnWaiting:Eu.default,i=r.get(t);return i===void 0?(i=new Promise(i=>{let a=e.subscribe(t,e=>{e._tag===`Initial`||n&&e.waiting||(setTimeout(a,1e3),i(),r.delete(t))})}),r.set(t,i),i):i}function Ou(e,t,n){let r=yu(e,t);if(r._tag===`Initial`||n&&r.waiting)throw Du(e,t,n);return r}var ku=(e,t)=>{let n=Ou(Gs.useContext(gu),e,t?.suspendOnWaiting??!1);if(n._tag===`Failure`&&!t?.includeFailure)throw mr(n.cause);return n},Au=Symbol.for(`~effect/http/Headers`),ju=Object.create(null);Object.defineProperties(ju,{[Au]:{value:Au},[Gi]:{value(e){return Vu(this,Zr(e,Hu))}},toJSON:{value(){return oe(this)}},[Rr]:{value(e){return Nu(this,e)}},[Se]:{value(){return wt(this)}},toString:{value:Rn.toString},[na]:{value:Rn[na]}});var Mu=e=>Object.assign(Object.create(ju),e),Nu=oa(_e()),Pu=Object.create(ju),Fu=e=>{if(e===void 0)return Pu;if(Symbol.iterator in e){let t=Object.create(ju);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(ju);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},Iu=e=>Object.setPrototypeOf(e,ju),Lu=v(3,(e,t,n)=>{let r=Mu(e);return r[t.toLowerCase()]=n,r}),Ru=v(2,(e,t)=>Mu({...e,...Fu(t)})),zu=v(2,(e,t)=>{let n=Mu(e);return Object.assign(n,t),n}),Bu=v(2,(e,t)=>{let n=Mu(e);return delete n[t.toLowerCase()],n}),Vu=v(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=Jt(e[r]))}else for(let r in e)t.test(r)&&(n[r]=Jt(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),Hu=Ot(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),Uu=`~effect/http/Cookies`,Wu=`~effect/http/Cookies/Cookie`;o(`CookieError`);var Gu={[Uu]:Uu,...Rn,toJSON(){return{_id:`effect/Cookies`,cookies:h(this.cookies,e=>e.toJSON())}},pipe(){return Tn(this,arguments)}},Ku=e=>{let t=Object.create(Gu);return t.cookies=e,t},qu=e=>{let t={};for(let n of e)t[n.name]=n;return Ku(t)},Ju=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=Yu(e.trim());t&&n.push(t)}return qu(n)};function Yu(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(!Xu.test(r))return;let i=t[0].slice(n+1),a=Qu(i);if(t.length===1)return Object.assign(Object.create(Zu),{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=vn(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(Zu),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var Xu=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Zu={[Wu]:Wu,...Rn,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},Qu=e=>{try{return decodeURIComponent(e)}catch{return e}},$u=`~effect/http/HttpClientError`,ed=class extends o(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[$u]=$u;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},td=e=>e.endsWith(`Error`)?e.slice(0,-5):e,nd=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,rd=class extends o(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return nd(td(this._tag),this.description,this.methodAndUrl)}};o(`EncodeError`);var id=class extends o(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return nd(td(this._tag),this.description,this.methodAndUrl)}};o(`StatusCodeError`);var ad=class extends o(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return nd(td(this._tag),this.description,e)}},od=class extends o(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return nd(td(this._tag),this.description,e)}},sd=class e extends aa($u)({_tag:fi(`HttpError`),kind:je([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:O(jt)}){static fromHttpClientError(t){return new e({_tag:`HttpError`,kind:t.reason._tag,cause:t.reason})}},cd=`~effect/http/UrlParams`,ld={...Fi,[cd]:cd,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:`UrlParams`,params:Object.fromEntries(this.params)}},[Rr](e){return pd(this,e)},[Se](){return d(this.params.flat())}},ud=e=>{let t=Object.create(ld);return t.params=e,t},dd=e=>{let t=fd(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 ud(n)},fd=e=>{let t=typeof e[Symbol.iterator]==`function`?Lt(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`){let t=fd(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},pd=Kt((e,t)=>md(e.params,t.params)),md=ot(Me([_e(),_e()])),hd=ud([]),gd=v(2,(e,t)=>{let n=dd(t),r=n.params,i=new Set;for(let e=0;e<r.length;e++)i.add(r[e][0]);for(let t=0;t<e.params.length;t++)i.has(e.params[t][0])||r.push(e.params[t]);return n}),_d=class extends o(`UrlParamsError`){},vd=(e,t,n)=>{try{let r=new URL(e,yd());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),mi(r)}catch(e){return Xt(new _d({cause:e}))}},yd=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},bd=`~effect/http/HttpBody`;o(`HttpBodyError`);var xd=class{[bd];constructor(){this[bd]=bd}[na](){return this.toJSON()}toString(){return Bt(this,{ignoreToString:!0})}},Sd=new class extends xd{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},Cd=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`]],wd=`~effect/http/HttpClientRequest`,Td={[wd]:wd,...Rn,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:oe(this.headers),body:this.body.toJSON()}},pipe(){return Tn(this,arguments)}};function Ed(e,t,n,r,i,a){let o=Object.create(Td);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var Dd=Ed(`GET`,``,hd,D(),Pu,Sd),Od=e=>(t,n)=>kd(Dd,{method:e,url:t,...n??void 0}),kd=v(2,(e,t)=>{let n=e;return t.method&&(n=Ad(n,t.method)),t.url&&(n=Fd(n,t.url)),t.headers&&(n=Md(n,t.headers)),t.urlParams&&(n=Id(n,t.urlParams)),t.hash&&(n=Ld(n,t.hash)),t.body&&(n=Rd(n,t.body)),t.accept&&(n=Nd(n,t.accept)),t.acceptJson&&(n=Pd(n)),n}),Ad=v(2,(e,t)=>Ed(t,e.url,e.urlParams,e.hash,e.headers,e.body)),jd=v(3,(e,t,n)=>Ed(e.method,e.url,e.urlParams,e.hash,Lu(e.headers,t,n),e.body)),Md=v(2,(e,t)=>Ed(e.method,e.url,e.urlParams,e.hash,Ru(e.headers,t),e.body)),Nd=v(2,(e,t)=>jd(e,`Accept`,t)),Pd=Nd(`application/json`),Fd=v(2,(e,t)=>{if(typeof t==`string`)return Ed(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=dd(n.searchParams),i=kn(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Ed(e.method,n.toString(),r,i,e.headers,e.body)}),Id=v(2,(e,t)=>Ed(e.method,e.url,gd(e.urlParams,t),e.hash,e.headers,e.body)),Ld=v(2,(e,t)=>Ed(e.method,e.url,e.urlParams,M(t),e.headers,e.body)),Rd=v(2,(e,t)=>{let n=e.headers;return t._tag===`Empty`||t._tag===`FormData`?n=Bu(Bu(n,`Content-Type`),`Content-length`):(t.contentType&&(n=Lu(n,`content-type`,t.contentType)),t.contentLength!==void 0&&(n=Lu(n,`content-length`,t.contentLength.toString()))),Ed(e.method,e.url,e.urlParams,e.hash,n,t)}),zd=`~effect/http/HttpIncomingMessage`,Bd=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=de(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=de(e.text)}catch{}let i={...t,headers:oe(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},Vd=`~effect/http/HttpClientResponse`,Hd=(e,t)=>new Ud(e,t),Ud=class extends zi{[zd];[Vd];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[zd]=zd,this[Vd]=Vd}toJSON(){return Bd(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get headers(){return Fu(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=Ju(this.source.headers.getSetCookie())}get remoteAddress(){return D()}get stream(){return this.source.body?js({evaluate:()=>this.source.body,onError:e=>new ed({reason:new ad({request:this.request,response:this,cause:e})})}):Os(new ed({reason:new od({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return T(this.text,e=>Qt({try:()=>e===``?null:JSON.parse(e),catch:e=>new ed({reason:new ad({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody?this.textBody:(this.textBody=Pe({try:()=>this.source.text(),catch:e=>new ed({reason:new ad({request:this.request,response:this,cause:e})})}).pipe(ht,de),this.arrayBufferBody=k(this.textBody,e=>new TextEncoder().encode(e).buffer),this.textBody)}get urlParamsBody(){return T(this.text,e=>Qt({try:()=>dd(new URLSearchParams(e)),catch:e=>new ed({reason:new ad({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=Pe({try:()=>this.source.formData(),catch:e=>new ed({reason:new ad({request:this.request,response:this,cause:e})})}).pipe(ht,de)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody?this.arrayBufferBody:(this.arrayBufferBody=Pe({try:()=>this.source.arrayBuffer(),catch:e=>new ed({reason:new ad({request:this.request,response:this,cause:e})})}).pipe(ht,de),this.textBody=k(this.arrayBufferBody,e=>new TextDecoder().decode(e)),this.arrayBufferBody)}pipe(){return Tn(this,arguments)}},Wd=e=>Iu({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${kr(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),Gd=`~effect/http/HttpClient`,Kd=i(`effect/HttpClient`),qd=v(2,(e,t)=>Jd(n=>t(e.postprocess(n)),e.preprocess)),Jd=(e,t)=>{let n=Object.create(Yd);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},Yd={[Gd]:Gd,pipe(){return Tn(this,arguments)},...Rn,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(Cd.map(([e,t])=>[t,function(t,n){return this.execute(Od(e)(t,n))}]))},Xd=e=>Jd(t=>T(t,t=>jn(n=>{let r=nf.get(t),i=r??new AbortController,a=vd(t.url,t.urlParams,dr(t.hash));if(Ee(a))return Ie(new ed({reason:new id({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(tt)||n.getRef(Zd)(t)){let a=e(t,o,i.signal,n);return r?a:Oe(e=>Pi(e(a),{onSuccess(e){return tf.register(e,i),C(new rf(e,i))},onFailure(e){return ii(e)&&i.abort(),tn(e)}}))}return gi(n.getRef($d)(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(Hu),l=Vu(t.headers,c);for(let e in l)a.attribute(`http.request.header.${e}`,String(l[e]));return t=n.getRef(Qd)?Md(t,Wd(a)):t,Oe(s=>s(e(t,o,i.signal,n)).pipe(kt(a,{captureStackTrace:!1}),Pi({onSuccess:e=>{a.attribute(`http.response.status_code`,e.status);let t=Vu(e.headers,c);for(let e in t)a.attribute(`http.response.header.${e}`,String(t[e]));return r?C(e):(tf.register(e,i),C(new rf(e,i)))},onFailure(e){return!r&&ii(e)&&i.abort(),tn(e)}})))})})),C),Zd=Ot(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>ne}),Qd=Ot(`effect/HttpClient/TracerPropagationEnabled`,{defaultValue:sn}),$d=Ot(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),ef=e=>Bi(Kd)(da(t=>k(e,e=>qd(e,Xe(e=>wi(t,e)))))),tf=(()=>{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))}}})(),nf=new WeakMap,rf=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[Vd]=Vd;[zd]=zd;applyInterrupt(e){return _(()=>(tf.unregister(this.original),Jr(e,()=>y(()=>{this.controller.abort()}))))}get request(){return this.original.request}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 Ds(()=>(tf.unregister(this.original),zs(this.original.stream,y(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[na](){return this.original[na]()}pipe(){return Tn(this,arguments)}},af=Ot(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),of=class extends i()(`effect/http/FetchHttpClient/RequestInit`){},sf=ef(C(Xd((e,t,n,r)=>{let i=r.getRef(af),a=r.context.mapUnsafe.get(of.key)??{},o=a.headers?zu(Fu(a.headers),e.headers):e.headers;o[`content-length`]&&(o=Bu(o,`content-length`));let s=r=>k(Pe({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:e.body._tag===`Stream`?`half`:void 0,signal:n}),catch:t=>new ed({reason:new rd({request:e,cause:t})})}),t=>Hd(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 T(Ws(e.body.stream),s)}return s(void 0)}))),cf=`~effect/FiberSet`,lf=e=>Be(e,cf),uf={[cf]:cf,[Symbol.iterator](){return this.state._tag===`Closed`?rn():this.state.backing[Symbol.iterator]()},...Fi,toJSON(){return{_id:`FiberMap`,state:this.state}}},df=(e,t)=>{let n=Object.create(uf);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},ff=()=>me(y(()=>df(new Set,Fe())),e=>_(()=>{let t=e.state;if(t._tag===`Closed`)return x;e.state={_tag:`Closed`};let n=t.backing;return ha(n).pipe(cn(e.deferred))})),pf=-1,mf=Ye(fn(Dr,De(pf))),hf=v(e=>lf(e[0]),(e,t,n)=>{if(e.state._tag===`Closed`){t.interruptUnsafe(pf);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),Ge(r)&&(n?.propagateInterruption===!0?!mf(r.cause):!Ti(r.cause))&&ua(e.deferred,r))})}),gf=function(){let e;return()=>(e===void 0&&(e=ae(ki)),e)}(),_f=e=>()=>k(It(),t=>{let n=Wi(t);return(t,r)=>{if(e.state._tag===`Closed`)return gf();let i=n(t,r);return hf(e,i),i}}),vf=e=>Ft(e.deferred),yf=`~effect/socket/Socket`,bf=i(`effect/socket/Socket`),xf=e=>bf.of({[yf]:yf,runRaw:e.runRaw,run:e.run??((t,n)=>e.runRaw(e=>typeof e==`string`?t(Sf.encode(e)):e instanceof Uint8Array?t(e):t(new Uint8Array(e)),n)),runString:e.runString??(e.run?(t,n)=>e.run(e=>t(Cf.decode(e)),n):(t,n)=>e.runRaw(e=>typeof e==`string`?t(e):e instanceof Uint8Array?t(Cf.decode(e)):t(Cf.decode(new Uint8Array(e))),n)),writer:e.writer}),Sf=new TextEncoder,Cf=new TextDecoder,wf=`~effect/socket/Socket/CloseEvent`,Tf=e=>Be(e,wf),Ef=`~effect/socket/Socket/SocketError`,Df=e=>Be(e,Ef),Of=class extends aa(`effect/socket/Socket/SocketReadError`)({_tag:fi(`SocketReadError`),cause:jt}){message=`An error occurred during Read`},kf=class extends aa(`effect/socket/Socket/SocketWriteError`)({_tag:fi(`SocketWriteError`),cause:jt}){message=`An error occurred during Write`},Af=class extends aa(`effect/socket/Socket/SocketOpenError`)({_tag:fi(`SocketOpenError`),kind:je([`Unknown`,`Timeout`]),cause:jt}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},jf=class extends aa(`effect/socket/Socket/SocketCloseError`)({_tag:fi(`SocketCloseError`),code:Te,closeReason:O(b)}){static filterClean(e){return function(t){return Nf.is(t)&&t.reason._tag===`SocketCloseError`&&e(t.reason.code)?mi(t.reason):Xt(t)}}get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},Mf=n([Of,kf,Af,jf]),Nf=class extends gn(Ef)(`SocketError`,{_tag:fi(`SocketError`),reason:Mf}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[Ef]=Ef;static is(e){return Df(e)}message=this.reason.message},Pf=e=>!0,Ff=class extends i()(`~effect/socket/Socket/WebSocket`){},If=class extends i()(`@effect/platform/Socket/WebSocketConstructor`){},Lf=pe(If)((e,t)=>new globalThis.WebSocket(e,t)),Rf=(e,t)=>If.use(n=>zf(me((typeof e==`string`?C(e):e).pipe(k(e=>n(e,t?.protocols))),e=>y(()=>e.close(1e3))),t)),zf=(e,t)=>jn(n=>{let r,i=va(!1),a=n.context,o=t?.closeCodeIsError??Pf;return C(xf({runRaw:(n,s)=>u(j(function*(a){let c=yield*ff().pipe(Ce(a)),l=yield*Ce(e,a),u=yield*ta(_f(c)(),Ff,l),d=!1;function f(e){if(e.data instanceof Blob)return u(T(yr(()=>e.data.arrayBuffer()),e=>{let t=n(new Uint8Array(e));return bi(t)?t:x}));let t=n(e.data);bi(t)&&u(t)}function p(e){l.removeEventListener(`message`,f),l.removeEventListener(`close`,m),ua(c.deferred,Ie(new Nf({reason:d?new Of({cause:e}):new Af({kind:`Unknown`,cause:e})})))}function m(e){let t=typeof e.code==`number`?e.code:1001;l.removeEventListener(`message`,f),l.removeEventListener(`error`,p),ua(c.deferred,Ie(new Nf({reason:new jf({code:t,closeReason:e.reason})})))}if(l.addEventListener(`close`,m,{once:!0}),l.addEventListener(`error`,p,{once:!0}),l.addEventListener(`message`,f),l.readyState!==1){let e=Fe();l.addEventListener(`open`,()=>{d=!0,ua(e,x)},{once:!0}),yield*Ft(e).pipe(on({duration:t?.openTimeout??1e4,orElse:()=>Ie(new Nf({reason:new Af({kind:`Timeout`,cause:Error(`timeout waiting for "open"`)})}))}),Jn(vf(c)))}return d=!0,r=l,i.openUnsafe(),s?.onOpen&&(yield*s.onOpen),yield*He(vf(c),jf.filterClean(e=>!o(e)),()=>x)})).pipe(Xe(e=>wi(a,e)),ln(y(()=>{i.closeUnsafe(),r=void 0}))),writer:C(e=>i.whenOpen(y(()=>{let t=r;Tf(e)?t.close(e.code,e.reason):t.send(e)})))}))}),Bf=Ze(Rf,Bi(bf)),Vf=class extends i()(`effect/workers/Transferable/Collector`){},Hf=()=>{let e=[],t=t=>{e.push(...t)},n=()=>e,r=()=>{let t=e;return e=[],t};return Vf.of({addAllUnsafe:t,addAll:e=>y(()=>t(e)),readUnsafe:n,read:y(n),clearUnsafe:r,clear:y(r)})},Uf=`~effect/workers/WorkerError`,Wf=n([class extends aa(`effect/workers/WorkerError/WorkerSpawnError`)({_tag:fi(`WorkerSpawnError`),message:b,cause:O(jt)}){},class extends aa(`effect/workers/WorkerError/WorkerSendError`)({_tag:fi(`WorkerSendError`),message:b,cause:O(jt)}){},class extends aa(`effect/workers/WorkerError/WorkerReceiveError`)({_tag:fi(`WorkerReceiveError`),message:b,cause:O(jt)}){},class extends aa(`effect/workers/WorkerError/WorkerUnknownError`)({_tag:fi(`WorkerUnknownError`),message:b,cause:O(jt)}){}]);aa(Uf)({_tag:fi(`WorkerError`),reason:Wf});var Gf=`~effect/interfaces/PrimaryKey`,Kf=`~effect/rpc/RpcSchema/StreamSchema`;function qf(e){return Be(e,Kf)}function Jf(e){return qf(e)?M({success:e.success,error:e.error}):D()}var Yf=Mi(Cs);function Xf(e,t){return sr(Yf.ast,{[Kf]:Kf,success:e,error:t})}i()(`effect/rpc/RpcSchema/ClientAbort`);var Zf=`~effect/rpc/Rpc`,Qf={[Zf]:Zf,pipe(){return Tn(this,arguments)},setSuccess(e){return $f({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return $f({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return $f({_tag:this._tag,payloadSchema:nr(e)?e:E(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return $f({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},prefix(e){return $f({_tag:`${e}${this._tag}`,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},annotate(e,t){return $f({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:cr(this.annotations,e,t)})},annotateMerge(e){return $f({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:wi(this.annotations,e)})}},$f=e=>{function t(){}return Object.setPrototypeOf(t,Qf),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},L=(e,t)=>{let n=t?.success??pr,r=t?.error??Yt,i=t?.defect??jt,a;return a=t?.primaryKey?class extends S(`effect/rpc/Rpc/${e}`)(t.payload){[Gf](){return t.primaryKey(this)}}:nr(t?.payload)?t?.payload:t?.payload?E(t?.payload):pr,$f({_tag:e,payloadSchema:a,successSchema:t?.stream?Xf(n,r):n,errorSchema:t?.stream?Yt:r,defectSchema:i,annotations:Oi(),middlewares:new Set})},ep=new WeakMap,tp=e=>{if(ep.has(e))return ep.get(e);let t=e,r=new Set([t.errorSchema]),i=Jf(t.successSchema);ei(i)&&r.add(i.value.error);for(let e of t.middlewares)r.add(e.error);let a=m(ei(i)?pr:t.successSchema,n([...r]),t.defectSchema);return ep.set(e,a),a},np=`~effect/rpc/Rpc/Wrapper`,rp=e=>np in e,ip=`~effect/rpc/RpcClientError`,ap=class extends aa(`effect/rpc/RpcClientError/RpcClientDefect`)({_tag:fi(`RpcClientDefect`),message:b,cause:jt}){},op=class extends aa(ip)({_tag:fi(`RpcClientError`),reason:n([Wf,Mf,sd,ap])}){[ip]=ip;get message(){return`${this.reason._tag}: ${this.reason.message}`}},sp=e=>typeof e==`bigint`?e:BigInt(e),cp={_tag:`Ping`},lp;try{lp=new TextDecoder}catch{}var R,up,z=0,dp=[],fp=dp,pp=0,B={},V,mp,hp=0,gp=0,H,_p,vp=[],U,yp={useRecords:!1,mapsAsObjects:!0},bp=class{},xp=new bp;xp.name=`MessagePack 0xC1`;var Sp=!1,Cp=2,wp=class e{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=0&&(e.structures=[],e.maxSharedStructures||=0)),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType=`number`)),Object.assign(this,e)}unpack(t,n){if(R)return Zp(()=>(Qp(),this?this.unpack(t,n):e.prototype.unpack.call(yp,t,n)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<`u`?Buffer.from(t):new Uint8Array(t)),typeof n==`object`?(up=n.end||t.length,z=n.start||0):(z=0,up=n>-1?n:t.length),pp=0,gp=0,mp=null,fp=dp,H=null,R=t;try{U=t.dataView||=new DataView(t.buffer,t.byteOffset,t.byteLength)}catch(e){throw R=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(B=this,this.structures)return V=this.structures,Tp(n);(!V||V.length>0)&&(V=[])}else B=yp,(!V||V.length>0)&&(V=[]);return Tp(n)}unpackMultiple(e,t){let n,r=0;try{Sp=!0;let i=e.length,a=this?this.unpack(e,i):em.unpack(e,i);if(t){if(t(a,r,z)===!1)return;for(;z<i;)if(r=z,t(Tp(),r,z)===!1)return}else{for(n=[a];z<i;)r=z,n.push(Tp());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{Sp=!1,Qp()}}_mergeStructures(e,t){this._onLoadedStructures&&(e=this._onLoadedStructures(e)),e||=[],Object.isFrozen(e)&&(e=e.map(e=>e.slice(0)));for(let t=0,n=e.length;t<n;t++){let n=e[t];n&&(n.isShared=!0,t>=32&&(n.highByte=t-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let r=e[n],i=t[n];i&&(r&&((e.restoreStructures||=[])[n]=r),e[n]=i)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Tp(e){try{if(!B.trusted&&!Sp){let e=V.sharedLength||0;e<V.length&&(V.length=e)}let t;if(B._readStruct&&R[z]<64&&R[z]>=32?(t=B._readStruct(R,z,up),R=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),z=up):t=W(),H&&=(z=H.postBundlePosition,null),Sp&&(V.restoreStructures=null),z==up)V&&V.restoreStructures&&Ep(),V=null,R=null,_p&&=null;else if(z>up)throw Error(`Unexpected end of MessagePack data`);else if(!Sp){let e;try{e=JSON.stringify(t,(e,t)=>typeof t==`bigint`?`${t}n`:t).slice(0,100)}catch(t){e=`(JSON view not available `+t+`)`}throw Error(`Data read, but end of buffer not reached `+e)}return t}catch(e){throw V&&V.restoreStructures&&Ep(),Qp(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`)||z>up)&&(e.incomplete=!0),e}}function Ep(){for(let e in V.restoreStructures)V[e]=V.restoreStructures[e];V.restoreStructures=null}function W(){let e=R[z++];if(e<160)if(e<128){if(e<64)return e;{let t=V[e&63]||B.getStructures&&Ap()[e&63];return t?(t.read||=Op(t,e&63),t.read()):e}}else if(e<144)if(e-=128,B.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=Wp();e===`__proto__`&&(e=`__proto_`),t[e]=W()}return t}else{let t=new Map;for(let n=0;n<e;n++)t.set(W(),W());return t}else{e-=144;let t=Array(e);for(let n=0;n<e;n++)t[n]=W();return B.freezeData?Object.freeze(t):t}else if(e<192){let t=e-160;if(gp>=z)return mp.slice(z-hp,(z+=t)-hp);if(gp==0&&up<140){let e=t<16?zp(t):Rp(t);if(e!=null)return e}return jp(t)}else{let t;switch(e){case 192:return null;case 193:return H?(t=W(),t>0?H[1].slice(H.position1,H.position1+=t):H[0].slice(H.position0,H.position0-=t)):xp;case 194:return!1;case 195:return!0;case 196:if(t=R[z++],t===void 0)throw Error(`Unexpected end of buffer`);return Vp(t);case 197:return t=U.getUint16(z),z+=2,Vp(t);case 198:return t=U.getUint32(z),z+=4,Vp(t);case 199:return Hp(R[z++]);case 200:return t=U.getUint16(z),z+=2,Hp(t);case 201:return t=U.getUint32(z),z+=4,Hp(t);case 202:if(t=U.getFloat32(z),B.useFloat32>2){let e=$p[(R[z]&127)<<1|R[z+1]>>7];return z+=4,(e*t+(t>0?.5:-.5)>>0)/e}return z+=4,t;case 203:return t=U.getFloat64(z),z+=8,t;case 204:return R[z++];case 205:return t=U.getUint16(z),z+=2,t;case 206:return t=U.getUint32(z),z+=4,t;case 207:return B.int64AsType===`number`?(t=U.getUint32(z)*4294967296,t+=U.getUint32(z+4)):B.int64AsType===`string`?t=U.getBigUint64(z).toString():B.int64AsType===`auto`?(t=U.getBigUint64(z),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=U.getBigUint64(z),z+=8,t;case 208:return U.getInt8(z++);case 209:return t=U.getInt16(z),z+=2,t;case 210:return t=U.getInt32(z),z+=4,t;case 211:return B.int64AsType===`number`?(t=U.getInt32(z)*4294967296,t+=U.getUint32(z+4)):B.int64AsType===`string`?t=U.getBigInt64(z).toString():B.int64AsType===`auto`?(t=U.getBigInt64(z),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=U.getBigInt64(z),z+=8,t;case 212:if(t=R[z++],t==114)return Kp(R[z++]&63);{let e=vp[t];if(e)return e.read?(z++,e.read(W())):e.noBuffer?(z++,e()):e(R.subarray(z,++z));throw Error(`Unknown extension `+t)}case 213:return t=R[z],t==114?(z++,Kp(R[z++]&63,R[z++])):Hp(2);case 214:return Hp(4);case 215:return Hp(8);case 216:return Hp(16);case 217:return t=R[z++],gp>=z?mp.slice(z-hp,(z+=t)-hp):Mp(t);case 218:return t=U.getUint16(z),z+=2,gp>=z?mp.slice(z-hp,(z+=t)-hp):Np(t);case 219:return t=U.getUint32(z),z+=4,gp>=z?mp.slice(z-hp,(z+=t)-hp):Pp(t);case 220:return t=U.getUint16(z),z+=2,Ip(t);case 221:return t=U.getUint32(z),z+=4,Ip(t);case 222:return t=U.getUint16(z),z+=2,Lp(t);case 223:return t=U.getUint32(z),z+=4,Lp(t);default:if(e>=224)return e-256;if(e===void 0){let e=Error(`Unexpected end of MessagePack data`);throw e.incomplete=!0,e}throw Error(`Unknown MessagePack token `+e)}}}var Dp=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Op(e,t){function n(){if(n.count++>Cp){let r;try{r=e.read=Function(`r`,`return function(){return `+(B.freezeData?`Object.freeze`:``)+`({`+e.map(e=>e===`__proto__`?`__proto_:r()`:Dp.test(e)?e+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`})}`)(W)}catch{return Cp=1/0,n()}return e.highByte===0&&(e.read=kp(t,e.read)),r()}let r={};for(let t=0,n=e.length;t<n;t++){let n=e[t];n===`__proto__`&&(n=`__proto_`),r[n]=W()}return B.freezeData?Object.freeze(r):r}return n.count=0,e.highByte===0?kp(t,n):n}var kp=(e,t)=>function(){let n=R[z++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5),i=V[r]||Ap()[r];if(!i)throw Error(`Record id is not defined for `+r);return i.read||=Op(i,e),i.read()};function Ap(){let e=Zp(()=>(R=null,B.getStructures()));return V=B._mergeStructures(e,V)}var jp=Fp,Mp=Fp,Np=Fp,Pp=Fp;function Fp(e){let t;if(e<16&&(t=zp(e)))return t;if(e>64&&lp)return lp.decode(R.subarray(z,z+=e));let n=z+e,r=[];for(t=``;z<n;){let e=R[z++];if(!(e&128))r.push(e);else if((e&224)==192){let t=R[z++]&63,n=(e&31)<<6|t;n<128?r.push(65533):r.push(n)}else if((e&240)==224){let t=R[z++]&63,n=R[z++]&63,i=(e&31)<<12|t<<6|n;i<2048||i>=55296&&i<=57343?r.push(65533):r.push(i)}else if((e&248)==240){let t=R[z++]&63,n=R[z++]&63,i=R[z++]&63,a=(e&7)<<18|t<<12|n<<6|i;a<65536||a>1114111?r.push(65533):a>65535?(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023,r.push(a)):r.push(a)}else r.push(65533);r.length>=4096&&(t+=G.apply(String,r),r.length=0)}return r.length>0&&(t+=G.apply(String,r)),t}function Ip(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=W();return B.freezeData?Object.freeze(t):t}function Lp(e){if(B.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=Wp();e===`__proto__`&&(e=`__proto_`),t[e]=W()}return t}else{let t=new Map;for(let n=0;n<e;n++)t.set(W(),W());return t}}var G=String.fromCharCode;function Rp(e){let t=z,n=Array(e);for(let r=0;r<e;r++){let e=R[z++];if((e&128)>0){z=t;return}n[r]=e}return G.apply(String,n)}function zp(e){if(e<4)if(e<2){if(e===0)return``;{let e=R[z++];if((e&128)>1){--z;return}return G(e)}}else{let t=R[z++],n=R[z++];if((t&128)>0||(n&128)>0){z-=2;return}if(e<3)return G(t,n);let r=R[z++];if((r&128)>0){z-=3;return}return G(t,n,r)}else{let t=R[z++],n=R[z++],r=R[z++],i=R[z++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){z-=4;return}if(e<6){if(e===4)return G(t,n,r,i);{let e=R[z++];if((e&128)>0){z-=5;return}return G(t,n,r,i,e)}}else if(e<8){let a=R[z++],o=R[z++];if((a&128)>0||(o&128)>0){z-=6;return}if(e<7)return G(t,n,r,i,a,o);let s=R[z++];if((s&128)>0){z-=7;return}return G(t,n,r,i,a,o,s)}else{let a=R[z++],o=R[z++],s=R[z++],c=R[z++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){z-=8;return}if(e<10){if(e===8)return G(t,n,r,i,a,o,s,c);{let e=R[z++];if((e&128)>0){z-=9;return}return G(t,n,r,i,a,o,s,c,e)}}else if(e<12){let l=R[z++],u=R[z++];if((l&128)>0||(u&128)>0){z-=10;return}if(e<11)return G(t,n,r,i,a,o,s,c,l,u);let d=R[z++];if((d&128)>0){z-=11;return}return G(t,n,r,i,a,o,s,c,l,u,d)}else{let l=R[z++],u=R[z++],d=R[z++],f=R[z++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){z-=12;return}if(e<14){if(e===12)return G(t,n,r,i,a,o,s,c,l,u,d,f);{let e=R[z++];if((e&128)>0){z-=13;return}return G(t,n,r,i,a,o,s,c,l,u,d,f,e)}}else{let p=R[z++],m=R[z++];if((p&128)>0||(m&128)>0){z-=14;return}if(e<15)return G(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=R[z++];if((h&128)>0){z-=15;return}return G(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function Bp(){let e=R[z++],t;if(e<192)t=e-160;else switch(e){case 217:t=R[z++];break;case 218:t=U.getUint16(z),z+=2;break;case 219:t=U.getUint32(z),z+=4;break;default:throw Error(`Expected string`)}return Fp(t)}function Vp(e){return B.copyBuffers?Uint8Array.prototype.slice.call(R,z,z+=e):R.subarray(z,z+=e)}function Hp(e){let t=R[z++];if(vp[t]){let n;return vp[t](R.subarray(z,n=z+=e),e=>{z=e;try{return W()}finally{z=n}})}else throw Error(`Unknown extension type `+t)}var Up=Array(4096);function Wp(){let e=R[z++];if(e>=160&&e<192){if(e-=160,gp>=z)return mp.slice(z-hp,(z+=e)-hp);if(!(gp==0&&up<180))return jp(e)}else return z--,Gp(W());let t=(e<<5^(e>1?U.getUint16(z):e>0?R[z]:0))&4095,n=Up[t],r=z,i=z+e-3,a,o=0;if(n&&n.bytes==e){for(;r<i;){if(a=U.getUint32(r),a!=n[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(a=R[r++],a!=n[o++]){r=1879048192;break}if(r===i)return z=r,n.string;i-=3,r=z}for(n=[],Up[t]=n,n.bytes=e;r<i;)a=U.getUint32(r),n.push(a),r+=4;for(i+=3;r<i;)a=R[r++],n.push(a);let s=e<16?zp(e):Rp(e);return s==null?n.string=jp(e):n.string=s}function Gp(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;if(B.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(e=>[`string`,`number`,`boolean`,`bigint`].includes(typeof e)))return e.flat().toString();throw Error(`Invalid property type for record: ${typeof e}`)}var Kp=(e,t)=>{let n=W().map(Gp),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,n.highByte=t);let i=V[e];return i&&(i.isShared||Sp)&&((V.restoreStructures||=[])[e]=i),V[e]=n,n.read=Op(n,r),n.read()};vp[0]=()=>{},vp[0].noBuffer=!0,vp[66]=e=>{let t=e.byteLength%8||8,n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++)n<<=BigInt(8),n+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=(e,t)=>{let n=t-e;if(n<=40){let n=r.getBigUint64(e);for(let i=e+8;i<t;i+=8)n<<=BigInt(64),n|=r.getBigUint64(i);return n}let a=e+(n>>4<<3),o=i(e,a),s=i(a,t);return o<<BigInt((t-a)*8)|s};n=n<<BigInt((r.byteLength-t)*8)|i(t,r.byteLength)}return n};var qp={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError==`function`?AggregateError:null};vp[101]=()=>{let e=W();if(!qp[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return qp[e[0]](e[1],{cause:e[2]})},vp[105]=e=>{if(B.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=U.getUint32(z-4);_p||=new Map;let n=R[z],r;r=n>=144&&n<160||n==220||n==221?[]:n>=128&&n<144||n==222||n==223?new Map:(n>=199&&n<=201||n>=212&&n<=216)&&R[z+1]===115?new Set:{};let i={target:r};_p.set(t,i);let a=W();if(i.used)Object.assign(r,a);else return i.target=a;if(r instanceof Map)for(let[e,t]of a.entries())r.set(e,t);if(r instanceof Set)for(let e of Array.from(a))r.add(e);return r},vp[112]=e=>{if(B.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=U.getUint32(z-4),n=_p.get(t);return n.used=!0,n.target},vp[115]=()=>new Set(W());var Jp=[`Int8`,`Uint8`,`Uint8Clamped`,`Int16`,`Uint16`,`Int32`,`Uint32`,`Float32`,`Float64`,`BigInt64`,`BigUint64`].map(e=>e+`Array`),Yp=typeof globalThis==`object`?globalThis:window;vp[116]=e=>{let t=e[0],n=Uint8Array.prototype.slice.call(e,1).buffer,r=Jp[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw Error(`Could not find typed array for code `+t)}return new Yp[r](n)},vp[120]=()=>{let e=W();return new RegExp(e[0],e[1])};var Xp=[];vp[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],n=z;return z+=t-e.length,H=Xp,H=[Bp(),Bp()],H.position0=0,H.position1=0,H.postBundlePosition=z,z=n,W()},vp[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date(`invalid`);function Zp(e){B&&B._onSaveState&&B._onSaveState();let t=up,n=z,r=pp,i=hp,a=gp,o=mp,s=fp,c=_p,l=H,u=new Uint8Array(R.slice(0,up)),d=V,f=V.slice(0,V.length),p=B,m=Sp,h=e();return up=t,z=n,pp=r,hp=i,gp=a,mp=o,fp=s,_p=c,H=l,R=u,Sp=m,V=d,V.splice(0,V.length,...f),B=p,U=new DataView(R.buffer,R.byteOffset,R.byteLength),h}function Qp(){R=null,_p=null,V=null}var $p=Array(147);for(let e=0;e<256;e++)$p[e]=+(`1e`+Math.floor(45.15-e*.30103));var em=new wp({useRecords:!1});em.unpack,em.unpackMultiple,em.unpack;var tm={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};new Uint8Array(new Float32Array(1).buffer,0,4),wp.SUPPORTS_STRUCT_HOOKS=!0;var nm;try{nm=new TextEncoder}catch{}var rm,im,am=typeof Buffer<`u`,om=am?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,sm=am?Buffer:Uint8Array,cm=am?4294967296:2144337920,K,lm,q,J=0,Y,X=null,um=21760,dm=/[\u0080-\uFFFF]/,fm=Symbol(`record-id`),pm=class extends wp{constructor(e){super(e),this.offset=0;let t,n,r,i,a=sm.prototype.utf8Write?function(e,t){return K.utf8Write(e,t,K.byteLength-t)}:nm&&nm.encodeInto?function(e,t){return nm.encodeInto(e,K.subarray(t)).written}:!1,o=this;e||={};let s=e&&e.sequential,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?32:0,l>8160)throw Error(`Maximum maxSharedStructure is 8160`);e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let u=e.maxOwnStructures;u??=c?32:64,!this.structures&&e.useRecords!=0&&(this.structures=[]);let d=l>32||u+l>64,f=l+64,p=l+u+64;if(p>8256)throw Error(`Maximum maxSharedStructure + maxOwnStructure is 8192`);let m=[],h=0,ee=0;this.pack=this.encode=function(e,a){if(K||(K=new om(8192),q=K.dataView||=new DataView(K.buffer,0,8192),J=0),Y=K.length-10,Y-J<2048?(K=new om(K.length),q=K.dataView||=new DataView(K.buffer,0,K.length),Y=K.length-10,J=0):J=J+7&2147483640,t=J,a&2048&&(J+=a&255),i=o.structuredClone?new Map:null,o.bundleStrings&&typeof e!=`string`?(X=[],X.size=1/0):X=null,r=o.structures,r){r.uninitialized&&(r=o._mergeStructures(o.getStructures()));let e=r.sharedLength||0;if(e>l)throw Error(`Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to `+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let t=0;t<e;t++){let e=r[t];if(!e)continue;let n,i=r.transitions;for(let t=0,r=e.length;t<r;t++){let r=e[t];n=i[r],n||=i[r]=Object.create(null),i=n}i[fm]=t+64}this.lastNamedStructuresLength=e}s||(r.nextId=e+64)}n&&=!1;let c;try{o._writeStruct&&e&&typeof e==`object`?e.constructor===Object?se(e):e.constructor!==Map&&!Array.isArray(e)&&!im.some(t=>e instanceof t)?se(e.toJSON?e.toJSON():e):g(e):g(e);let n=X;if(X&&vm(t,g,0),i&&i.idsToInsert){let e=i.idsToInsert.sort((e,t)=>e.offset>t.offset?1:-1),r=e.length,a=-1;for(;n&&r>0;){let i=e[--r].offset+t;i<n.stringsPosition+t&&a===-1&&(a=0),i>n.position+t?a>=0&&(a+=6):(a>=0&&(q.setUint32(n.position+t,q.getUint32(n.position+t)+a),a=-1),n=n.previous,r++)}a>=0&&n&&q.setUint32(n.position+t,q.getUint32(n.position+t)+a),J+=e.length*6,J>Y&&ce(J),o.offset=J;let s=_m(K.subarray(t,J),e);return i=null,s}return o.offset=J,a&512?(K.start=t,K.end=J,K):K.subarray(t,J)}catch(e){throw c=e,e}finally{if(r&&(te(),n&&o.saveStructures)){let n=r.sharedLength||0,i=K.subarray(t,J),s=(o._prepareStructures||ym)(r,o);if(!c)return o.saveStructures(s,s.isCompatible)===!1?o.pack(e,a):(o.lastNamedStructuresLength=n,K.length>1073741824&&(K=null),i)}K.length>1073741824&&(K=null),a&1024&&(J=t)}};let te=()=>{ee<10&&ee++;let e=r.sharedLength||0;if(r.length>e&&!s&&(r.length=e),h>1e4)r.transitions=null,ee=0,h=0,m.length>0&&(m=[]);else if(m.length>0&&!s){for(let e=0,t=m.length;e<t;e++)m[e][fm]=0;m=[]}},ne=e=>{var t=e.length;t<16?K[J++]=144|t:t<65536?(K[J++]=220,K[J++]=t>>8,K[J++]=t&255):(K[J++]=221,q.setUint32(J,t),J+=4);for(let n=0;n<t;n++)g(e[n])},g=e=>{J>Y&&(K=ce(J));var n=typeof e,r;if(n===`string`){let n=e.length;if(X&&n>=4&&n<4096){if((X.size+=n)>um){let e,n=(X[0]?X[0].length*3+X[1].length:0)+10;J+n>Y&&(K=ce(J+n));let r;X.position?(r=X,K[J]=200,J+=3,K[J++]=98,e=J-t,J+=4,vm(t,g,0),q.setUint16(e+t-3,J-t-e)):(K[J++]=214,K[J++]=98,e=J-t,J+=4),X=[``,``],X.previous=r,X.size=0,X.position=e}let r=dm.test(e);X[+!r]+=e,K[J++]=193,g(r?-n:n);return}let i;i=n<32?1:n<256?2:n<65536?3:5;let o=n*3;if(J+o>Y&&(K=ce(J+o)),n<64||!a){let t,a,o,s=J+i;for(t=0;t<n;t++)a=e.charCodeAt(t),a<128?K[s++]=a:a<2048?(K[s++]=a>>6|192,K[s++]=a&63|128):(a&64512)==55296&&((o=e.charCodeAt(t+1))&64512)==56320?(a=65536+((a&1023)<<10)+(o&1023),t++,K[s++]=a>>18|240,K[s++]=a>>12&63|128,K[s++]=a>>6&63|128,K[s++]=a&63|128):(K[s++]=a>>12|224,K[s++]=a>>6&63|128,K[s++]=a&63|128);r=s-J-i}else r=a(e,J+i);r<32?K[J++]=160|r:r<256?(i<2&&K.copyWithin(J+2,J+1,J+1+r),K[J++]=217,K[J++]=r):r<65536?(i<3&&K.copyWithin(J+3,J+2,J+2+r),K[J++]=218,K[J++]=r>>8,K[J++]=r&255):(i<5&&K.copyWithin(J+5,J+3,J+3+r),K[J++]=219,q.setUint32(J,r),J+=4),J+=r}else if(n===`number`)if(e>>>0===e)e<32||e<128&&this.useRecords===!1||e<64&&!this._writeStruct?K[J++]=e:e<256?(K[J++]=204,K[J++]=e):e<65536?(K[J++]=205,K[J++]=e>>8,K[J++]=e&255):(K[J++]=206,q.setUint32(J,e),J+=4);else if(e>>0===e)e>=-32?K[J++]=256+e:e>=-128?(K[J++]=208,K[J++]=e+256):e>=-32768?(K[J++]=209,q.setInt16(J,e),J+=2):(K[J++]=210,q.setInt32(J,e),J+=4);else{let t;if((t=this.useFloat32)>0&&e<4294967296&&e>=-2147483648){K[J++]=202,q.setFloat32(J,e);let n;if(t<4||(n=e*$p[(K[J]&127)<<1|K[J+1]>>7])>>0===n){J+=4;return}else J--}K[J++]=203,q.setFloat64(J,e),J+=8}else if(n===`object`||n===`function`)if(!e)K[J++]=192;else{if(i){let n=i.get(e);if(n){n.id||=(i.idsToInsert||=[]).push(n),K[J++]=214,K[J++]=112,q.setUint32(J,n.id),J+=4;return}else i.set(e,{offset:J-t})}let a=e.constructor;if(a===Object)oe(e);else if(a===Array)ne(e);else if(a===Map)if(this.mapAsEmptyObject)K[J++]=128;else{r=e.size,r<16?K[J++]=128|r:r<65536?(K[J++]=222,K[J++]=r>>8,K[J++]=r&255):(K[J++]=223,q.setUint32(J,r),J+=4);for(let[t,n]of e)g(t),g(n)}else{for(let t=0,n=rm.length;t<n;t++){let n=im[t];if(e instanceof n){let n=rm[t];if(n.write){n.type&&(K[J++]=212,K[J++]=n.type,K[J++]=0);let t=n.write.call(this,e);t===e?Array.isArray(e)?ne(e):oe(e):g(t);return}let r=K,i=q,a=J;K=null;let o;try{o=n.pack.call(this,e,e=>(K=r,r=null,J+=e,J>Y&&ce(J),{target:K,targetView:q,position:J-e}),g)}finally{r&&(K=r,q=i,J=a,Y=K.length-10)}o&&(o.length+J>Y&&ce(o.length+J),J=gm(o,K,J,n.type));return}}if(Array.isArray(e))ne(e);else{if(e.toJSON){let t=e.toJSON();if(t!==e)return g(t)}if(n===`function`)return g(this.writeFunction&&this.writeFunction(e));oe(e)}}}else if(n===`boolean`)K[J++]=e?195:194;else if(n===`bigint`){if(e<0x8000000000000000&&e>=-0x8000000000000000)K[J++]=211,q.setBigInt64(J,e);else if(e<0x10000000000000000&&e>0)K[J++]=207,q.setBigUint64(J,e);else if(this.largeBigIntToFloat)K[J++]=203,q.setFloat64(J,Number(e));else if(this.largeBigIntToString)return g(e.toString());else if(this.useBigIntExtension||this.moreTypes){let t=BigInt(e<0?-1:0),n;if(e>>BigInt(65536)===t){let r=BigInt(0x10000000000000000)-BigInt(1),i=[];for(;i.push(e&r),e>>BigInt(63)!==t;)e>>=BigInt(64);n=new Uint8Array(new BigUint64Array(i).buffer),n.reverse()}else{let t=e<0,r=(t?~e:e).toString(16);if(r.length%2?r=`0`+r:parseInt(r.charAt(0),16)>=8&&(r=`00`+r),am)n=Buffer.from(r,`hex`);else{n=new Uint8Array(r.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(r.slice(e*2,e*2+2),16)}if(t)for(let e=0;e<n.length;e++)n[e]=~n[e]}n.length+J>Y&&ce(n.length+J),J=gm(n,K,J,66);return}else throw RangeError(e+` was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string`);J+=8}else if(n===`undefined`)this.encodeUndefinedAsNil?K[J++]=192:(K[J++]=212,K[J++]=0,K[J++]=0);else throw Error(`Unknown type: `+n)},re=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?e=>{let t;if(this.skipValues){t=[];for(let n in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(n))&&!this.skipValues.includes(e[n])&&t.push(n)}else t=Object.keys(e);let n=t.length;n<16?K[J++]=128|n:n<65536?(K[J++]=222,K[J++]=n>>8,K[J++]=n&255):(K[J++]=223,q.setUint32(J,n),J+=4);let r;if(this.coercibleKeyAsNumber)for(let i=0;i<n;i++){r=t[i];let n=Number(r);g(isNaN(n)?r:n),g(e[r])}else for(let i=0;i<n;i++)g(r=t[i]),g(e[r])}:e=>{K[J++]=222;let n=J-t;J+=2;let r=0;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(g(t),g(e[t]),r++);if(r>65535)throw Error(`Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object`);K[n+++t]=r>>8,K[n+t]=r&255},ie=this.useRecords===!1?re:e.progressiveRecords&&!d?e=>{let n,i=r.transitions||=Object.create(null),a=J++-t,o;for(let s in e)if(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(s)){if(n=i[s],n)i=n;else{let c=Object.keys(e),l=i;i=r.transitions;let u=0;for(let e=0,t=c.length;e<t;e++){let t=c[e];n=i[t],n||(n=i[t]=Object.create(null),u++),i=n}a+t+1==J?(J--,le(i,c,u)):ue(i,c,a,u),o=!0,i=l[s]}g(e[s])}if(!o){let n=i[fm];n?K[a+t]=n:ue(i,Object.keys(e),a,0)}}:e=>{let t,n=r.transitions||=Object.create(null),i=0;for(let r in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(r))&&(t=n[r],t||(t=n[r]=Object.create(null),i++),n=t);let a=n[fm];a?a>=96&&d?(K[J++]=((a-=96)&31)+96,K[J++]=a>>5):K[J++]=a:le(n,n.__keys__||Object.keys(e),i);for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&g(e[t])},ae=typeof this.useRecords==`function`&&this.useRecords,oe=ae?e=>{ae(e)?ie(e):re(e)}:ie,se=e=>{let i=o._writeStruct(e,K,t,J,r,ce,(e,t,r)=>{if(r)return n=!0;J=t;let i=K;return g(e),te(),i===K?J:{position:J,targetView:q,target:K}});if(i===0)return oe(e);J=i},ce=e=>{let n;if(e>16777216){if(e-t>cm)throw Error(`Packed buffer would be larger than maximum buffer size`);n=Math.min(cm,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,K.length-1)>>12)+1<<12;let r=new om(n);return q=r.dataView||=new DataView(r.buffer,0,n),e=Math.min(e,K.length),K.copy?K.copy(r,0,t,e):r.set(K.slice(t,e)),J-=t,t=0,Y=r.length-10,K=r},le=(e,t,i)=>{let a=r.nextId;a||=64,a<f&&this.shouldShareStructure&&!this.shouldShareStructure(t)?(a=r.nextOwnId,a<p||(a=f),r.nextOwnId=a+1):(a>=p&&(a=f),r.nextId=a+1);let o=t.highByte=a>=96&&d?a-96>>5:-1;e[fm]=a,e.__keys__=t,r[a-64]=t,a<f?(t.isShared=!0,r.sharedLength=a-63,n=!0,o>=0?(K[J++]=(a&31)+96,K[J++]=o):K[J++]=a):(o>=0?(K[J++]=213,K[J++]=114,K[J++]=(a&31)+96,K[J++]=o):(K[J++]=212,K[J++]=114,K[J++]=a),i&&(h+=ee*i),m.length>=u&&(m.shift()[fm]=0),m.push(e),g(t))},ue=(e,n,r,i)=>{let a=K,o=J,s=Y,c=t;K=lm,J=0,t=0,K||(lm=K=new om(8192)),Y=K.length-10,le(e,n,i),lm=K;let l=J;if(K=a,J=o,Y=s,t=c,l>1){let e=J+l-1;e>Y&&ce(e);let n=r+t;K.copyWithin(n+l,n+1,J),K.set(lm.slice(0,l),n),J=e}else K[r+t]=lm[0]}}useBuffer(e){K=e,K.dataView||=new DataView(K.buffer,K.byteOffset,K.byteLength),q=K.dataView,J=0}set position(e){J=e}get position(){return J}clearSharedData(){this.structures&&=[],this.typedStructs&&=[]}};im=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,bp],rm=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:e,targetView:n,position:i}=t(6);e[i++]=214,e[i++]=255,n.setUint32(i,r)}else if(r>0&&r<4294967296){let{target:n,targetView:i,position:a}=t(10);n[a++]=215,n[a++]=255,i.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),n(this.onInvalidDate());let{target:e,targetView:r,position:i}=t(3);e[i++]=212,e[i++]=255,e[i++]=255}else{let{target:n,targetView:i,position:a}=t(15);n[a++]=199,n[a++]=12,n[a++]=255,i.setUint32(a,e.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject)return t(0),n({});let r=Array.from(e),{target:i,position:a}=t(this.moreTypes?3:0);this.moreTypes&&(i[a++]=212,i[a++]=115,i[a++]=0),n(r)}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=101,r[i++]=0),n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=120,r[i++]=0),n([e.source,e.flags])}},{pack(e,t){this.moreTypes?mm(e,16,t):hm(am?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;n!==sm&&this.moreTypes?mm(e,Jp.indexOf(n.name),t):hm(e,t)}},{pack(e,t){this.moreTypes?mm(e,17,t):hm(am?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function mm(e,t,n,r){let i=e.byteLength;if(i+1<256){var{target:a,position:o}=n(4+i);a[o++]=199,a[o++]=i+1}else if(i+1<65536){var{target:a,position:o}=n(5+i);a[o++]=200,a[o++]=i+1>>8,a[o++]=i+1&255}else{var{target:a,position:o,targetView:s}=n(7+i);a[o++]=201,s.setUint32(o,i+1),o+=4}a[o++]=116,a[o++]=t,e.buffer||(e=new Uint8Array(e)),a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),o)}function hm(e,t){let n=e.byteLength;var r,i;if(n<256){var{target:r,position:i}=t(n+2);r[i++]=196,r[i++]=n}else if(n<65536){var{target:r,position:i}=t(n+3);r[i++]=197,r[i++]=n>>8,r[i++]=n&255}else{var{target:r,position:i,targetView:a}=t(n+5);r[i++]=198,a.setUint32(i,n),i+=4}r.set(e,i)}function gm(e,t,n,r){let i=e.length;switch(i){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:i<256?(t[n++]=199,t[n++]=i):i<65536?(t[n++]=200,t[n++]=i>>8,t[n++]=i&255):(t[n++]=201,t[n++]=i>>24,t[n++]=i>>16&255,t[n++]=i>>8&255,t[n++]=i&255)}return t[n++]=r,t.set(e,n),n+=i,n}function _m(e,t){let n,r=t.length*6,i=e.length-r;for(;n=t.pop();){let t=n.offset,a=n.id;e.copyWithin(t+r,t,i),r-=6;let o=t+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,i=t}return e}function vm(e,t,n){if(X.length>0){q.setUint32(X.position+e,J+n-X.position-e),X.stringsPosition=J-e;let r=X;X=null,t(r[0]),t(r[1])}}function ym(e,t){return e.isCompatible=e=>{let n=!e||(t.lastNamedStructuresLength||0)===e.length;return n||t._mergeStructures(e),n},e}pm.SUPPORTS_STRUCT_HOOKS=!0;var bm=new pm({useRecords:!1});bm.pack,bm.pack;var{NEVER:xm,ALWAYS:Sm,DECIMAL_ROUND:Cm,DECIMAL_FIT:wm}=tm,Tm=class extends i()(`effect/rpc/RpcSerialization`){},Em=(e=>Tm.of({contentType:`application/msgpack`,includesFraming:!0,makeUnsafe:()=>{let t=new wp(e),n=new pm(e),r=new TextEncoder,i;return{decode(e){let n=typeof e==`string`?r.encode(e):e;if(i!==void 0){let t=n;e=new Uint8Array(i.length+n.length),e.set(i),e.set(t,i.length),n=e,i=void 0}try{return t.unpackMultiple(n)}catch(e){let t=e;if(t.incomplete)return i=n.subarray(t.lastPosition),t.values??[];throw e}},encode:e=>n.pack(e)}}}))({useRecords:!0}),Dm=pe(Tm)(Em),Om=e=>_(()=>{let t=new Set,n=new Map,r=new Map,i=(e,t)=>da(r=>{let i=n.get(e);return i||(i=[],n.set(e,i)),i.push([t,r]),x});return k(e((e,t)=>{let n=r.get(e);return n?n(t):i(e,t)},t),e=>({...e,run(e,i){return s(function*(){t.add(e),r.set(e,i);let a=n.get(e);if(a){n.delete(e);for(let[e,t]of a)yield*Ri(_(()=>i(e)),t)}return yield*ui(ar,()=>(t.delete(e),r.delete(e),x))})}}))}),km=BigInt(0),Am=j(function*(e,t){let n=t?.spanPrefix??`RpcClient`,r=t?.supportsAck??!0,i=t?.disableTracing??!1,a=t?.generateRequestId??(()=>km++),o=yield*It(),s=Zr(o,zr),c=new Map,l=!1;yield*f(s,jn(e=>(l=!0,u(Qe(e.id)))));let u=j(function*(e){for(let[t,n]of c)c.delete(t),n._tag===`Queue`?yield*e._tag===`Success`?no(n.queue):eo(n.queue,e.cause):n.resume(e)}),d=e=>{let r=qf(e.successSchema),a=h(e);return(o,s)=>{let c=s?.headers?Fu(s.headers):Pu,l=s?.context??Oi();if(!r){let r=t=>p(e,a,t,e.payloadSchema.make(o),c,l,s?.discard??!1);return i?r(void 0):gi(`${n}.${e._tag}`,{attributes:t.spanAttributes},r)}let u=m(e,a,e.payloadSchema.make(o),c,s?.streamBufferSize??16,l);return s?.asQueue?u:Ms(k(u,ks))}},p=(e,n,r,i,o,s,u)=>jn(d=>{if(l)return ki;let f=a(),p=n(e=>t.onFromClient({message:e,context:s,discard:u}),{_tag:`Request`,id:f,tag:e._tag,payload:i,...r?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{},headers:zu(d.getRef(Fm),o)});if(u)return p;let m;return Jr(Et(t=>{let n={_tag:`Effect`,rpc:e,context:s,resume(e){t(e),m&&!m.pollUnsafe()&&d.currentDispatcher.scheduleTask(()=>{m.interruptUnsafe(d.id)},0)}};c.set(f,n),m=p.pipe(r?kt(r,{captureStackTrace:!1}):A,Wi(d.context)),m.addObserver(e=>{if(e._tag===`Failure`)return t(e)})}),e=>(c.delete(f),Br(ma(m),ee(f,Array.from(e),s))))}),m=j(function*(e,r,o,s,u,d){if(l)return yield*ki;let f=i?void 0:yield*Un(`${n}.${e._tag}`,{attributes:t.spanAttributes}),p=ga(),m=a(),h=Er(p.context,zr);yield*Pr(h,e=>c.has(m)?(c.delete(m),ee(m,Ge(e)?Array.from(Hr(e.cause)):[],d)):x);let te=yield*Ya(u);return c.set(m,{_tag:`Queue`,rpc:e,queue:te,scope:h,context:d}),yield*r(e=>t.onFromClient({message:e,context:d,discard:!1}),{_tag:`Request`,id:m,tag:e._tag,payload:o,...f?{traceId:f.traceId,spanId:f.spanId,sampled:f.sampled}:{},headers:zu(p.getRef(Fm),s)}).pipe(f?kt(f,{captureStackTrace:!1}):A,we(e=>eo(te,e)),$r,Pn(h,{startImmediately:!0})),te}),h=e=>{let t=[];for(let n of e.middlewares.values()){let e=o.mapUnsafe.get(`${n.key}/Client`);e&&t.push(e)}return t.length===0?(e,t)=>e(t):function n(r,i,a=t.length-1){return a===-1?r(i):t[a]({rpc:e,request:i,next(e){return n(r,e,a-1)}})}},ee=(e,n,r)=>Et(i=>{let a=ga();t.onFromClient({message:{_tag:`Interrupt`,requestId:e,interruptors:n},context:r,discard:!1}).pipe(ca(1e3),Wi(a.context)).addObserver(()=>{i(x)})}),te=e=>{switch(e._tag){case`Chunk`:{let n=e.requestId,i=c.get(n);return!i||i._tag!==`Queue`?x:Qa(i.queue,e.values).pipe(r?T(()=>t.onFromClient({message:{_tag:`Ack`,requestId:e.requestId},context:i.context,discard:!1})):A,we(e=>eo(i.queue,e)))}case`Exit`:{let t=e.requestId,n=c.get(t);return n?(c.delete(t),n._tag===`Effect`?(n.resume(e.exit),x):e.exit._tag===`Success`?no(n.queue):eo(n.queue,e.exit.cause)):x}case`Defect`:return u(en(e.defect));case`ClientEnd`:return x}},ne;if(t.flatten){let t=new Map;ne=function(n,r,i){let a=t.get(n);return a||(a=d(e.requests.get(n)),t.set(n,a)),a(r,i)}}else ne={},e.requests.forEach(e=>{ne[e._tag]=d(e)});return{client:ne,write:te}}),jm=0,Mm=j(function*(e,t){let n=jm++,{run:r,send:i,supportsAck:a,supportsTransferables:o}=yield*Im,s=new Map,{client:c,write:l}=yield*Am(e,{...t,supportsAck:a,onFromClient({message:t}){switch(t._tag){case`Request`:{let r=e.requests.get(t.tag),a=o?Hf():void 0,c=ga(),l={rpc:r,context:a?cr(c.context,Vf,a):c.context,schemas:Pm(r)};return s.set(t.id,l),l.schemas.encodePayload(t.payload).pipe(Ri(l.context),Cr,T(e=>i(n,{...t,id:String(t.id),payload:e,headers:Object.entries(t.headers)},a&&a.readUnsafe())))}case`Ack`:return s.get(t.requestId)?i(n,{_tag:`Ack`,requestId:String(t.requestId)}):x;case`Interrupt`:return s.get(t.requestId)?(s.delete(t.requestId),i(n,{_tag:`Interrupt`,requestId:String(t.requestId)})):x;case`Eof`:return x}}});return yield*r(n,e=>{switch(e._tag){case`Chunk`:{let t=sp(e.requestId),n=s.get(t);return!n||Ai(n.schemas.decodeChunk)?x:n.schemas.decodeChunk.value(e.values).pipe(Ri(n.context),Cr,T(t=>l({_tag:`Chunk`,clientId:0,requestId:sp(e.requestId),values:t})),hr(t=>l({_tag:`Exit`,clientId:0,requestId:sp(e.requestId),exit:ke(t)})))}case`Exit`:{let t=sp(e.requestId),n=s.get(t);return n?(s.delete(t),n.schemas.decodeExit(e.exit).pipe(Ri(n.context),Cr,Pi({onSuccess:e=>l({_tag:`Exit`,clientId:0,requestId:t,exit:e}),onFailure:e=>l({_tag:`Exit`,clientId:0,requestId:t,exit:ke(e)})}))):x}case`Defect`:return l({_tag:`Defect`,clientId:0,defect:Hm(e.defect)});case`ClientProtocolError`:{let t=hn(e.error);return Ke(s.keys(),e=>l({_tag:`Exit`,clientId:0,requestId:e,exit:t}))}default:return x}}).pipe(we(Or),$r,At),c}),Nm=new WeakMap,Pm=e=>{let t=Nm.get(e);return t===void 0?(t={decodeChunk:xi(Jf(e.successSchema),e=>Gn(Xr(un(e.success)))),encodePayload:si(Xr(e.payloadSchema)),decodeExit:Gn(Xr(tp(e)))},Nm.set(e,t),t):t},Fm=Ot(`effect/rpc/RpcClient/CurrentHeaders`,{defaultValue:()=>Pu}),Im=class extends i()(`effect/rpc/RpcClient/Protocol`){static make=Om},Lm=e=>Im.make(j(function*(t,n){let r=yield*bf,i=yield*Tm,a=yield*ct(Vm),o=new Map,s=yield*r.writer,c=i.makeUnsafe(),l=yield*zm(s(c.encode(cp))),u,d=_(()=>(u=void 0,ei(a)?a.value.onConnect:x)),f=e=>Ke(n,n=>t(n,e));return yield*_(()=>(c=i.makeUnsafe(),l.reset(),r.runRaw(e=>{try{let n=c.decode(e);if(n.length===0)return;let r=0;return yn({while:()=>r<n.length,body:()=>{let e=n[r++];if(e._tag===`Pong`)return l.onPong(),x;if(`requestId`in e){let n=o.get(e.requestId);if(n!==void 0)return e._tag===`Exit`&&o.delete(e.requestId),t(n,e)}return f(e)},step:$t})}catch(e){return f({_tag:`ClientProtocolError`,error:new op({reason:new ap({message:`Error decoding message`,cause:e})})})}},{onOpen:d}).pipe(Jn(T(l.timeout,()=>Ie(new Nf({reason:new Af({kind:`Timeout`,cause:Error(`ping timeout`)})}))))))).pipe(T(()=>Ie(new Nf({reason:new jf({code:1e3})}))),ei(a)?ln(a.value.onDisconnect):A,Nt(t=>{let n=Hn(t),r=Je(n);return e?.retryTransientErrors&&r&&n.success.reason._tag===`SocketOpenError`?x:(u=new op({reason:r?n.success.reason:new ap({message:`Unknown socket error`,cause:mr(t)})}),f({_tag:`ClientProtocolError`,error:u}))}),Yi(e?.retryPolicy??Rm),p({module:`RpcClient`,method:`makeProtocolSocket`}),At),{send(e,t){if(u)return Ie(u);t._tag===`Request`&&o.set(t.id,e);let n=c.encode(t);return n===void 0?x:Cr(s(n))},supportsAck:!0,supportsTransferables:!1}})),Rm=ji(500,1.5).pipe(fr(ti(5e3))),zm=j(function*(e){let t=!0,n=va();return yield*_(()=>t?(t=!1,e):n.open).pipe(re(`5 seconds`),ur,Dn,$r,At),{timeout:n.await,reset:()=>{t=!0,n.closeUnsafe()},onPong:()=>{t=!0}}}),Bm=e=>Bi(Im)(Lm(e)),Vm=class extends i()(`effect/rpc/RpcClient/ConnectionHooks`){},Hm=Ci(jt),Um=()=>(e,t)=>{let n=i()(e),r=Bi(n,t.makeEffect??Mm(t.group,{...t,flatten:!0}));n.runtime=(t.runtime??Wl)(typeof t.protocol==`function`?e=>qt(r,Ki(t.protocol(e))):qt(r,Ki(t.protocol))),n.mutation=nu(e=>{let r=t.group.requests.get(e);return n.runtime.fn()(j(function*({headers:t,payload:r,reactivityKeys:i}){let a=(yield*n)(e,r,{headers:t});return yield*i?Mc(a,i):a})).pipe(fu({key:`AtomRpc:mutation:${e}`,schema:rl({success:r.successSchema,error:Wm(r)})}))});let a=nu(e=>{let{headers:r,payload:i,reactivityKeys:a,tag:o,timeToLive:s}=e,c=t.group.requests.get(o),l=qf(c.successSchema),u=l?n.runtime.pull(Ms(n.use(e=>C(e(o,i,{headers:r}))))):n.runtime.atom(n.use(e=>e(o,i,{headers:r})));return!l&&e.serializationKey&&(u=fu(u,{key:`AtomRpc:${e.tag}:${e.serializationKey}`,schema:rl({success:c.successSchema,error:Wm(c)})})),s&&(u=Ue(s)?El(u,s):ru(u)),a?n.runtime.factory.withReactivity(a)(u):u});return n.query=(e,t,n)=>a({tag:e,payload:t,headers:n?.headers?Fu(n.headers):void 0,reactivityKeys:n?.reactivityKeys,timeToLive:n?.timeToLive?hi(n.timeToLive):void 0,serializationKey:n?.serializationKey}),n},Wm=e=>n([e.errorSchema,...Array.from(e.middlewares,e=>e.error),op]),Gm={add(...e){let t=new Map(this.requests);for(let n of e)t.set(n._tag,n);return Km({requests:t,annotations:this.annotations})},merge(...e){let t=new Map(this.requests),n=new Map(this.annotations.mapUnsafe);for(let r of e){for(let[e,n]of r.requests)t.set(e,n);for(let[e,t]of r.annotations.mapUnsafe)n.set(e,t)}return Km({requests:t,annotations:ri(n)})},omit(...e){let t=new Map(this.requests);for(let n of e)t.delete(n);return Km({requests:t,annotations:this.annotations})},middleware(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.middleware(e));return Km({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return s(function*(){let n=yield*It(),r=bi(e)?yield*e:e,i=new Map;for(let[e,a]of Object.entries(r)){let r=t.requests.get(e);i.set(r.key,{tag:r._tag,handler:a,context:n})}return ri(i)})},prefix(e){let t=new Map;for(let n of this.requests.values()){let r=n.prefix(e);t.set(r._tag,r)}return Km({requests:t,annotations:this.annotations})},toLayer(e){return ra(this.toHandlers(e))},of:A,toLayerHandler(e,t){let n=this;return ra(s(function*(){let r=yield*It(),i=bi(t)?yield*t:t,a=new Map,o=n.requests.get(e);return a.set(o.key,{handler:i,context:r}),ri(a)}))},accessHandler(e){return da(t=>{let n=this.requests.get(e),{handler:r,context:i}=t.mapUnsafe.get(n.key);return C((e,t)=>{t.rpc=n;let a=r(e,t),o=rp(a)?a.value:a;return bi(o)?Ln(o,i):Bs(o,i)})})},annotate(e,t){return Km({requests:this.requests,annotations:cr(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(Vn(e,t))},annotateMerge(e){return Km({requests:this.requests,annotations:wi(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.annotateMerge(wi(e,r.annotations)));return Km({requests:t,annotations:this.annotations})}},Km=e=>Object.assign(function(){},Gm,{requests:e.requests,annotations:e.annotations}),qm=(...e)=>Km({requests:new Map(e.map(e=>[e._tag,e])),annotations:Oi()}),Z=class extends gn()(`GitError`,{cause:O(jt),message:O(b)}){},Jm=je([`added`,`deleted`,`modified`,`renamed`]),Ym=class extends S(`GitDiffSegment`)({filePath:b,fingerprint:b,id:b,type:je([`commit`,`worktree`])}){},Xm=class extends S(`GitDiff`)({filePath:b,patch:b,segments:w(Ym),status:Jm}){},Zm=n([E({ref:b,type:nn(`ref`)}),E({base:b,type:nn(`merge-base`)})]),Qm=n([E({ref:b,type:nn(`ref`)}),E({type:nn(`worktree`)})]),$m=class extends S(`GitCommit`)({hash:b,parents:w(b),shortHash:b,subject:b,wip:ye}){},eh=class extends S(`GitReviewMetadata`)({base:b,branch:b,commits:w($m),defaultBranch:b,dirty:ye,prUrl:O(b),unpushedCommits:ye}){},th=class extends S(`GitHubReviewThread`)({body:b,filePath:b,id:b,lineNumber:Te,resolved:ye,side:O(je([`additions`,`deletions`])),url:O(b)}){},nh=class extends S(`GitRepository`)({gitDirectory:b,root:b}){},rh=class extends S(`GitBranch`)({name:b,remote:O(b),type:je([`local`,`remote`])}){},ih=class extends S(`GitBranchesSnapshot`)({branches:w(rh),defaultBranch:b}){},ah=class extends S(`GitWorktreeStatus`)({ahead:Te,behind:Te,dirtyTracked:ye,unpushedCommits:ye,untracked:ye}){},oh=class extends S(`GitWorktree`)({branch:O(b),root:b,status:O(ah)}){},sh=class extends S(`GitProject`)({repository:nh,worktrees:w(oh)}){},ch=class extends gn()(`TerminalError`,{cause:O(jt),message:O(b)}){},lh=n([E({data:b,type:nn(`data`)}),E({type:nn(`reset`)})]);n([E({data:b,type:nn(`write`)}),E({cols:Te,rows:Te,type:nn(`resize`)}),E({type:nn(`restart`)}),E({type:nn(`stop`)})]);var uh=E({runId:Te,state:je([`idle`,`starting`,`running`,`waiting`,`needs_input`,`stopped`,`exited`,`failed`]),title:b});function dh(e){return e===`idle`||e===`starting`||e===`running`||e===`waiting`||e===`needs_input`}var fh=n([E({state:uh,type:nn(`state`)}),E({event:lh,type:nn(`event`)})]),ph=E({args:O(w(b)),command:O(b),cwd:b,env:O(pi(b,b)),sessionId:O(b)}),mh=E({baseOrigin:O(b),command:b,cwd:b,env:O(pi(b,b)),name:b,origin:O(b),packageFolder:b,packagePath:b,portless:O(ye),service:O(b),sessionId:b}),hh=E({args:w(b),command:b,cwd:b,icon:je([`opencode`,`codex`,`pi`]),label:b,uuid:b}),gh=class extends S(`ReviewMark`)({filePath:b,fingerprint:b,segmentId:b}){},_h=class extends S(`ReviewComment`)({body:b,filePath:b,lineNumber:Te,resolved:O(ye),side:O(je([`additions`,`deletions`]))}){},vh=class extends S(`ReviewState`)({comments:w(_h),marks:w(gh)}){},yh=class extends qm(L(`agents.create`,{error:ch,payload:E({args:w(b),command:b,cwd:b,icon:je([`opencode`,`codex`,`pi`]),label:b}),success:hh}),L(`agents.remove`,{error:ch,payload:E({cwd:b,uuid:b})}),L(`agents.watch`,{error:ch,payload:E({cwd:b}),stream:!0,success:w(hh)}),L(`projects.watch`,{stream:!0,success:w(sh)}),L(`projects.branches`,{error:Z,payload:E({cwd:b}),success:ih}),L(`review.metadata`,{error:Z,payload:E({base:O(b),cwd:b}),success:eh}),L(`review.watchRange`,{error:Z,payload:E({cwd:b,from:Zm,to:Qm}),stream:!0,success:w(Xm)}),L(`review.state.watch`,{error:Z,payload:E({base:b,cwd:b}),stream:!0,success:vh}),L(`review.state.mark`,{error:Z,payload:E({base:b,cwd:b,marks:w(gh)})}),L(`review.state.unmark`,{error:Z,payload:E({base:b,cwd:b,marks:w(gh)})}),L(`review.comments.save`,{error:Z,payload:E({base:b,comment:_h,cwd:b})}),L(`review.comments.resolve`,{error:Z,payload:E({base:b,cwd:b,filePath:b,lineNumber:Te,side:O(je([`additions`,`deletions`]))})}),L(`review.createWipCommit`,{error:Z,payload:E({cwd:b,message:b})}),L(`review.commitAndPush`,{error:Z,payload:E({base:b,cwd:b,message:b})}),L(`review.githubThreads`,{error:Z,payload:E({cwd:b}),success:w(th)}),L(`review.githubThreads.resolve`,{error:Z,payload:E({cwd:b,threadId:b})}),L(`review.stageFile`,{error:Z,payload:E({cwd:b,filePath:b})}),L(`review.unstageFile`,{error:Z,payload:E({cwd:b,filePath:b})}),L(`review.discardFile`,{error:Z,payload:E({cwd:b,filePath:b})}),L(`projects.createWorktree`,{error:Z,payload:E({baseBranch:b,branch:b,cwd:b,mode:je([`existing-local`,`existing-remote`,`new-local`])}),success:b}),L(`projects.deleteWorktree`,{error:Z,payload:E({cwd:b,force:ye})}),L(`runs.portless`,{error:ch,payload:E({cwd:b}),success:w(mh)}),L(`terminal.write`,{error:ch,payload:E({args:O(w(b)),command:O(b),cwd:b,data:b,env:O(pi(b,b)),sessionId:O(b)}),success:uh}),L(`terminal.resize`,{error:ch,payload:E({args:O(w(b)),cols:Te,command:O(b),cwd:b,env:O(pi(b,b)),rows:Te,sessionId:O(b)}),success:uh}),L(`terminal.restart`,{error:ch,payload:ph,success:uh}),L(`terminal.stop`,{error:ch,payload:ph,success:uh}),L(`terminal.watch`,{error:ch,payload:ph,stream:!0,success:fh})){},bh=`1.9.1`,xh=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Sh(e){let t=new Set([e]),n=new Set,r=e.match(xh);if(!r)return()=>!1;let i={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(i.prerelease!=null)return function(t){return t===e};function a(e){return n.add(e),!1}function o(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(n.has(e))return!1;let r=e.match(xh);if(!r)return a(e);let s={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};return s.prerelease!=null||i.major!==s.major?a(e):i.major===0?i.minor===s.minor&&i.patch<=s.patch?o(e):a(e):i.minor<=s.minor?o(e):a(e)}}var Ch=Sh(bh),wh=bh.split(`.`)[0],Th=Symbol.for(`opentelemetry.js.api.${wh}`),Eh=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{};function Dh(e,t,n,r=!1){let i=Eh[Th]=Eh[Th]??{version:bh};if(!r&&i[e]){let t=Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);return n.error(t.stack||t.message),!1}if(i.version!==`1.9.1`){let t=Error(`@opentelemetry/api: Registration of version v${i.version} for ${e} does not match previously registered API v${bh}`);return n.error(t.stack||t.message),!1}return i[e]=t,n.debug(`@opentelemetry/api: Registered a global for ${e} v${bh}.`),!0}function Oh(e){let t=Eh[Th]?.version;if(!(!t||!Ch(t)))return Eh[Th]?.[e]}function kh(e,t){t.debug(`@opentelemetry/api: Unregistering a global for ${e} v${bh}.`);let n=Eh[Th];n&&delete n[e]}var Ah=class{constructor(e){this._namespace=e.namespace||`DiagComponentLogger`}debug(...e){return jh(`debug`,this._namespace,e)}error(...e){return jh(`error`,this._namespace,e)}info(...e){return jh(`info`,this._namespace,e)}warn(...e){return jh(`warn`,this._namespace,e)}verbose(...e){return jh(`verbose`,this._namespace,e)}};function jh(e,t,n){let r=Oh(`diag`);if(r)return r[e](t,...n)}var Mh;(function(e){e[e.NONE=0]=`NONE`,e[e.ERROR=30]=`ERROR`,e[e.WARN=50]=`WARN`,e[e.INFO=60]=`INFO`,e[e.DEBUG=70]=`DEBUG`,e[e.VERBOSE=80]=`VERBOSE`,e[e.ALL=9999]=`ALL`})(Mh||={});function Nh(e,t){e<Mh.NONE?e=Mh.NONE:e>Mh.ALL&&(e=Mh.ALL),t||={};function n(n,r){let i=t[n];return typeof i==`function`&&e>=r?i.bind(t):function(){}}return{error:n(`error`,Mh.ERROR),warn:n(`warn`,Mh.WARN),info:n(`info`,Mh.INFO),debug:n(`debug`,Mh.DEBUG),verbose:n(`verbose`,Mh.VERBOSE)}}var Ph=`diag`,Fh=class e{static instance(){return this._instance||=new e,this._instance}constructor(){function e(e){return function(...t){let n=Oh(`diag`);if(n)return n[e](...t)}}let t=this;t.setLogger=(e,n={logLevel:Mh.INFO})=>{if(e===t){let e=Error(`Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation`);return t.error(e.stack??e.message),!1}typeof n==`number`&&(n={logLevel:n});let r=Oh(`diag`),i=Nh(n.logLevel??Mh.INFO,e);if(r&&!n.suppressOverrideMessage){let e=Error().stack??`<failed to generate stacktrace>`;r.warn(`Current logger will be overwritten from ${e}`),i.warn(`Current logger will overwrite one already registered from ${e}`)}return Dh(`diag`,i,t,!0)},t.disable=()=>{kh(Ph,t)},t.createComponentLogger=e=>new Ah(e),t.verbose=e(`verbose`),t.debug=e(`debug`),t.info=e(`info`),t.warn=e(`warn`),t.error=e(`error`)}},Ih=class e{constructor(e){this._entries=e?new Map(e):new Map}getEntry(e){let t=this._entries.get(e);if(t)return Object.assign({},t)}getAllEntries(){return Array.from(this._entries.entries())}setEntry(t,n){let r=new e(this._entries);return r._entries.set(t,n),r}removeEntry(t){let n=new e(this._entries);return n._entries.delete(t),n}removeEntries(...t){let n=new e(this._entries);for(let e of t)n._entries.delete(e);return n}clear(){return new e}},Lh=Symbol(`BaggageEntryMetadata`),Rh=Fh.instance();function zh(e={}){return new Ih(new Map(Object.entries(e)))}function Bh(e){return typeof e!=`string`&&(Rh.error(`Cannot create baggage metadata from unknown type: ${typeof e}`),e=``),{__TYPE__:Lh,toString(){return e}}}function Vh(e){return Symbol.for(e)}var Hh=new class e{constructor(t){let n=this;n._currentContext=t?new Map(t):new Map,n.getValue=e=>n._currentContext.get(e),n.setValue=(t,r)=>{let i=new e(n._currentContext);return i._currentContext.set(t,r),i},n.deleteValue=t=>{let r=new e(n._currentContext);return r._currentContext.delete(t),r}}},Uh=class{constructor(){}createGauge(e,t){return tg}createHistogram(e,t){return ng}createCounter(e,t){return eg}createUpDownCounter(e,t){return rg}createObservableGauge(e,t){return ag}createObservableCounter(e,t){return ig}createObservableUpDownCounter(e,t){return og}addBatchObservableCallback(e,t){}removeBatchObservableCallback(e){}},Wh=class{},Gh=class extends Wh{add(e,t){}},Kh=class extends Wh{add(e,t){}},qh=class extends Wh{record(e,t){}},Jh=class extends Wh{record(e,t){}},Yh=class{addCallback(e){}removeCallback(e){}},Xh=class extends Yh{},Zh=class extends Yh{},Qh=class extends Yh{},$h=new Uh,eg=new Gh,tg=new qh,ng=new Jh,rg=new Kh,ig=new Xh,ag=new Zh,og=new Qh;function sg(){return $h}var cg;(function(e){e[e.INT=0]=`INT`,e[e.DOUBLE=1]=`DOUBLE`})(cg||={});var lg={get(e,t){if(e!=null)return e[t]},keys(e){return e==null?[]:Object.keys(e)}},ug={set(e,t,n){e!=null&&(e[t]=n)}},dg=class{active(){return Hh}with(e,t,n,...r){return t.call(n,...r)}bind(e,t){return t}enable(){return this}disable(){return this}},fg=`context`,pg=new dg,mg=class e{constructor(){}static getInstance(){return this._instance||=new e,this._instance}setGlobalContextManager(e){return Dh(fg,e,Fh.instance())}active(){return this._getContextManager().active()}with(e,t,n,...r){return this._getContextManager().with(e,t,n,...r)}bind(e,t){return this._getContextManager().bind(e,t)}_getContextManager(){return Oh(fg)||pg}disable(){this._getContextManager().disable(),kh(fg,Fh.instance())}},hg;(function(e){e[e.NONE=0]=`NONE`,e[e.SAMPLED=1]=`SAMPLED`})(hg||={});var gg={traceId:`00000000000000000000000000000000`,spanId:`0000000000000000`,traceFlags:hg.NONE},_g=class{constructor(e=gg){this._spanContext=e}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}addEvent(e,t){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}},vg=Vh(`OpenTelemetry Context Key SPAN`);function yg(e){return e.getValue(vg)||void 0}function bg(){return yg(mg.getInstance().active())}function xg(e,t){return e.setValue(vg,t)}function Sg(e){return e.deleteValue(vg)}function Cg(e,t){return xg(e,new _g(t))}function wg(e){return yg(e)?.spanContext()}var Tg=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function Eg(e,t){if(typeof e!=`string`||e.length!==t)return!1;let n=0;for(let t=0;t<e.length;t+=4)n+=(Tg[e.charCodeAt(t)]|0)+(Tg[e.charCodeAt(t+1)]|0)+(Tg[e.charCodeAt(t+2)]|0)+(Tg[e.charCodeAt(t+3)]|0);return n===t}function Dg(e){return Eg(e,32)&&e!==`00000000000000000000000000000000`}function Og(e){return Eg(e,16)&&e!==`0000000000000000`}function kg(e){return Dg(e.traceId)&&Og(e.spanId)}function Ag(e){return new _g(e)}var jg=mg.getInstance(),Mg=class{startSpan(e,t,n=jg.active()){if(t?.root)return new _g;let r=n&&wg(n);return Ng(r)&&kg(r)?new _g(r):new _g}startActiveSpan(e,t,n,r){let i,a,o;if(arguments.length<2)return;arguments.length===2?o=t:arguments.length===3?(i=t,o=n):(i=t,a=n,o=r);let s=a??jg.active(),c=this.startSpan(e,i,s),l=xg(s,c);return jg.with(l,o,void 0,c)}};function Ng(e){return typeof e==`object`&&!!e&&`spanId`in e&&typeof e.spanId==`string`&&`traceId`in e&&typeof e.traceId==`string`&&`traceFlags`in e&&typeof e.traceFlags==`number`}var Pg=new Mg,Fg=class{constructor(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}startSpan(e,t,n){return this._getTracer().startSpan(e,t,n)}startActiveSpan(e,t,n,r){let i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)}_getTracer(){if(this._delegate)return this._delegate;let e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):Pg}},Ig=new class{getTracer(e,t,n){return new Mg}},Lg=class{getTracer(e,t,n){return this.getDelegateTracer(e,t,n)??new Fg(this,e,t,n)}getDelegate(){return this._delegate??Ig}setDelegate(e){this._delegate=e}getDelegateTracer(e,t,n){return this._delegate?.getTracer(e,t,n)}},Rg;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(Rg||={});var zg;(function(e){e[e.INTERNAL=0]=`INTERNAL`,e[e.SERVER=1]=`SERVER`,e[e.CLIENT=2]=`CLIENT`,e[e.PRODUCER=3]=`PRODUCER`,e[e.CONSUMER=4]=`CONSUMER`})(zg||={});var Bg;(function(e){e[e.UNSET=0]=`UNSET`,e[e.OK=1]=`OK`,e[e.ERROR=2]=`ERROR`})(Bg||={});var Vg=mg.getInstance(),Q=Fh.instance(),Hg=class{inject(e,t){}extract(e,t){return e}fields(){return[]}},Ug=Vh(`OpenTelemetry Baggage Key`);function Wg(e){return e.getValue(Ug)||void 0}function Gg(){return Wg(mg.getInstance().active())}function Kg(e,t){return e.setValue(Ug,t)}function qg(e){return e.deleteValue(Ug)}var Jg=`propagation`,Yg=new Hg,Xg=class e{constructor(){this.createBaggage=zh,this.getBaggage=Wg,this.getActiveBaggage=Gg,this.setBaggage=Kg,this.deleteBaggage=qg}static getInstance(){return this._instance||=new e,this._instance}setGlobalPropagator(e){return Dh(Jg,e,Fh.instance())}inject(e,t,n=ug){return this._getGlobalPropagator().inject(e,t,n)}extract(e,t,n=lg){return this._getGlobalPropagator().extract(e,t,n)}fields(){return this._getGlobalPropagator().fields()}disable(){kh(Jg,Fh.instance())}_getGlobalPropagator(){return Oh(Jg)||Yg}}.getInstance(),Zg=`trace`,$=class e{constructor(){this._proxyTracerProvider=new Lg,this.wrapSpanContext=Ag,this.isSpanContextValid=kg,this.deleteSpan=Sg,this.getSpan=yg,this.getActiveSpan=bg,this.getSpanContext=wg,this.setSpan=xg,this.setSpanContext=Cg}static getInstance(){return this._instance||=new e,this._instance}setGlobalTracerProvider(e){let t=Dh(Zg,this._proxyTracerProvider,Fh.instance());return t&&this._proxyTracerProvider.setDelegate(e),t}getTracerProvider(){return Oh(Zg)||this._proxyTracerProvider}getTracer(e,t){return this.getTracerProvider().getTracer(e,t)}disable(){kh(Zg,Fh.instance()),this._proxyTracerProvider=new Lg}}.getInstance(),Qg=Vh(`OpenTelemetry SDK Context Key SUPPRESS_TRACING`);function $g(e){return e.setValue(Qg,!0)}function e_(e){return e.getValue(Qg)===!0}var t_=`baggage`,n_=4096;function r_(e){return e.reduce((e,t)=>{let n=`${e}${e===``?``:`,`}${t}`;return n.length>8192?e:n},``)}function i_(e){return e.getAllEntries().map(([e,t])=>{let n=`${encodeURIComponent(e)}=${encodeURIComponent(t.value)}`;return t.metadata!==void 0&&(n+=`;`+t.metadata.toString()),n})}function a_(e){if(!e)return;let t=e.indexOf(`;`),n=t===-1?e:e.substring(0,t),r=n.indexOf(`=`);if(r<=0)return;let i=n.substring(0,r).trim(),a=n.substring(r+1).trim();if(!i||!a)return;let o,s;try{o=decodeURIComponent(i),s=decodeURIComponent(a)}catch{return}let c;return t!==-1&&t<e.length-1&&(c=Bh(e.substring(t+1))),{key:o,value:s,metadata:c}}var o_=class{inject(e,t,n){let r=Xg.getBaggage(e);if(!r||e_(e))return;let i=r_(i_(r).filter(e=>e.length<=n_).slice(0,180));i.length>0&&n.set(t,t_,i)}extract(e,t,n){let r=n.get(t,t_),i=Array.isArray(r)?r.join(`,`):r;if(!i)return e;let a={};return i.length===0||(i.split(`,`).forEach(e=>{let t=a_(e);if(t){let e={value:t.value};t.metadata&&(e.metadata=t.metadata),a[t.key]=e}}),Object.entries(a).length===0)?e:Xg.setBaggage(e,Xg.createBaggage(a))}fields(){return[t_]}};function s_(e){let t={};if(typeof e!=`object`||!e)return t;for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(!c_(n)){Q.warn(`Invalid attribute key: ${n}`);continue}let r=e[n];if(!l_(r)){Q.warn(`Invalid attribute value set for key: ${n}`);continue}Array.isArray(r)?t[n]=r.slice():t[n]=r}return t}function c_(e){return typeof e==`string`&&e!==``}function l_(e){return e==null?!0:Array.isArray(e)?u_(e):d_(typeof e)}function u_(e){let t;for(let n of e){if(n==null)continue;let e=typeof n;if(e!==t){if(!t){if(d_(e)){t=e;continue}return!1}return!1}}return!0}function d_(e){switch(e){case`number`:case`boolean`:case`string`:return!0}return!1}function f_(){return e=>{Q.error(p_(e))}}function p_(e){return typeof e==`string`?e:JSON.stringify(m_(e))}function m_(e){let t={},n=e;for(;n!==null;)Object.getOwnPropertyNames(n).forEach(e=>{if(t[e])return;let r=n[e];r&&(t[e]=String(r))}),n=Object.getPrototypeOf(n);return t}var h_=f_();function g_(e){try{h_(e)}catch{}}var __=`2.7.1`,v_=`exception.message`,y_=`exception.stacktrace`,b_=`exception.type`,x_=`service.name`,S_=`service.version`,C_=`telemetry.sdk.language`,w_=`nodejs`,T_=`webjs`,E_=`telemetry.sdk.name`,D_=`telemetry.sdk.version`,O_=`process.runtime.name`,k_={[E_]:`opentelemetry`,[O_]:`browser`,[C_]:T_,[D_]:__},A_=performance,j_=9,M_=10**6,N_=10**j_;function P_(e){let t=e/1e3;return[Math.trunc(t),Math.round(e%1e3*M_)]}function F_(e){return V_(P_(A_.timeOrigin),P_(typeof e==`number`?e:A_.now()))}function I_(e){if(z_(e))return e;if(typeof e==`number`)return e<A_.timeOrigin?F_(e):P_(e);if(e instanceof Date)return P_(e.getTime());throw TypeError(`Invalid input type`)}function L_(e,t){let n=t[0]-e[0],r=t[1]-e[1];return r<0&&(--n,r+=N_),[n,r]}function R_(e){return e[0]*N_+e[1]}function z_(e){return Array.isArray(e)&&e.length===2&&typeof e[0]==`number`&&typeof e[1]==`number`}function B_(e){return z_(e)||typeof e==`number`||e instanceof Date}function V_(e,t){let n=[e[0]+t[0],e[1]+t[1]];return n[1]>=N_&&(n[1]-=N_,n[0]+=1),n}var H_;(function(e){e[e.SUCCESS=0]=`SUCCESS`,e[e.FAILED=1]=`FAILED`})(H_||={});var U_=class{_propagators;_fields;constructor(e={}){this._propagators=e.propagators??[];let t=new Set;for(let e of this._propagators){let n=typeof e.fields==`function`?e.fields():[];for(let e of n)t.add(e)}this._fields=Array.from(t)}inject(e,t,n){for(let r of this._propagators)try{r.inject(e,t,n)}catch(e){Q.warn(`Failed to inject with ${r.constructor.name}. Err: ${e.message}`)}}extract(e,t,n){return this._propagators.reduce((e,r)=>{try{return r.extract(e,t,n)}catch(e){Q.warn(`Failed to extract with ${r.constructor.name}. Err: ${e.message}`)}return e},e)}fields(){return this._fields.slice()}},W_=`[_0-9a-z-*/]`,G_=RegExp(`^(?:${`[a-z]${W_}{0,255}`}|${`[a-z0-9]${W_}{0,240}@[a-z]${W_}{0,13}`})$`),K_=/^[ -~]{0,255}[!-~]$/,q_=/,|=/;function J_(e){return G_.test(e)}function Y_(e){return K_.test(e)&&!q_.test(e)}var X_=32,Z_=512,Q_=`,`,$_=`=`,ev=class e{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e==`string`?e:``,this._length=this._rawTraceState.length}set(e,t){if(!J_(e)||!Y_(t))return this;let n=this._getState(),r=n.get(e),i=this._length;if(typeof r==`string`?i+=t.length-r.length:i+=e.length+t.length+(n.size>0?2:1),i>Z_)return this;let a=new Map(n);return a.delete(e),a.set(e,t),this._fromState(a,i)}unset(e){let t=this._getState(),n=t.get(e);if(typeof n!=`string`)return this;let r=this._length-(e.length+n.length+1);t.size>1&&--r;let i=new Map(t);return i.delete(e),this._fromState(i,r)}get(e){return this._getState().get(e)}serialize(){let e=``,t=0;for(let n of this._getState())t>0&&(e=Q_+e),e=`${n[0]}${$_}${n[1]}`+e,t++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(Q_),t=new Map,n=0;for(let r of e){let e=r.trim(),i=e.indexOf($_);if(i===-1)continue;let a=e.slice(0,i),o=e.slice(i+1);if(!J_(a)||!Y_(o))continue;let s=n+e.length+ +(t.size>0);if(!(s>Z_)&&(t.set(a,o),n=s,t.size>=X_))break}return this._length=n,this._internalState=new Map(Array.from(t.entries()).reverse()),this._internalState}_fromState(t,n){let r=Object.create(e.prototype);return r._internalState=t,r._length=n,r}},tv=`traceparent`,nv=`tracestate`,rv=`00`,iv=RegExp(`^\\s?((?!ff)[\\da-f]{2})-((?![0]{32})[\\da-f]{32})-((?![0]{16})[\\da-f]{16})-([\\da-f]{2})(-.*)?\\s?$`);function av(e){let t=iv.exec(e);return!t||t[1]===`00`&&t[5]?null:{traceId:t[2],spanId:t[3],traceFlags:parseInt(t[4],16)}}var ov=class{inject(e,t,n){let r=$.getSpanContext(e);if(!r||e_(e)||!kg(r))return;let i=`${rv}-${r.traceId}-${r.spanId}-0${Number(r.traceFlags||hg.NONE).toString(16)}`;n.set(t,tv,i),r.traceState&&n.set(t,nv,r.traceState.serialize())}extract(e,t,n){let r=n.get(t,tv);if(!r)return e;let i=Array.isArray(r)?r[0]:r;if(typeof i!=`string`)return e;let a=av(i);if(!a)return e;a.isRemote=!0;let o=n.get(t,nv);if(o){let e=Array.isArray(o)?o.join(`,`):o;a.traceState=new ev(typeof e==`string`?e:void 0)}return $.setSpanContext(e,a)}fields(){return[tv,nv]}},sv=`[object Object]`,cv=`[object Null]`,lv=`[object Undefined]`,uv=Function.prototype.toString,dv=uv.call(Object),fv=Object.getPrototypeOf,pv=Object.prototype,mv=pv.hasOwnProperty,hv=Symbol?Symbol.toStringTag:void 0,gv=pv.toString;function _v(e){if(!vv(e)||yv(e)!==sv)return!1;let t=fv(e);if(t===null)return!0;let n=mv.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&uv.call(n)===dv}function vv(e){return typeof e==`object`&&!!e}function yv(e){return e==null?e===void 0?lv:cv:hv&&hv in Object(e)?bv(e):xv(e)}function bv(e){let t=mv.call(e,hv),n=e[hv],r=!1;try{e[hv]=void 0,r=!0}catch{}let i=gv.call(e);return r&&(t?e[hv]=n:delete e[hv]),i}function xv(e){return gv.call(e)}var Sv=20;function Cv(...e){let t=e.shift(),n=new WeakMap;for(;e.length>0;)t=Tv(t,e.shift(),0,n);return t}function wv(e){return Dv(e)?e.slice():e}function Tv(e,t,n=0,r){let i;if(!(n>Sv)){if(n++,Av(e)||Av(t)||Ov(t))i=wv(t);else if(Dv(e)){if(i=e.slice(),Dv(t))for(let e=0,n=t.length;e<n;e++)i.push(wv(t[e]));else if(kv(t)){let e=Object.keys(t);for(let n=0,r=e.length;n<r;n++){let r=e[n];r===`__proto__`||r===`constructor`||r===`prototype`||(i[r]=wv(t[r]))}}}else if(kv(e))if(kv(t)){if(!jv(e,t))return t;i=Object.assign({},e);let a=Object.keys(t);for(let o=0,s=a.length;o<s;o++){let s=a[o];if(s===`__proto__`||s===`constructor`||s===`prototype`)continue;let c=t[s];if(Av(c))c===void 0?delete i[s]:i[s]=c;else{let a=i[s],o=c;if(Ev(e,s,r)||Ev(t,s,r))delete i[s];else{if(kv(a)&&kv(o)){let n=r.get(a)||[],i=r.get(o)||[];n.push({obj:e,key:s}),i.push({obj:t,key:s}),r.set(a,n),r.set(o,i)}i[s]=Tv(i[s],c,n,r)}}}}else i=t;return i}}function Ev(e,t,n){let r=n.get(e[t])||[];for(let n=0,i=r.length;n<i;n++){let i=r[n];if(i.key===t&&i.obj===e)return!0}return!1}function Dv(e){return Array.isArray(e)}function Ov(e){return typeof e==`function`}function kv(e){return!Av(e)&&!Dv(e)&&!Ov(e)&&typeof e==`object`}function Av(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e===void 0||e instanceof Date||e instanceof RegExp||e===null}function jv(e,t){return!(!_v(e)||!_v(t))}var Mv=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function Nv(e,t){let n,r=new Promise(function(e,r){n=setTimeout(function(){r(new Mv(`Operation timed out.`))},t)});return Promise.race([e,r]).then(e=>(clearTimeout(n),e),e=>{throw clearTimeout(n),e})}var Pv=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}},Fv=class{_isCalled=!1;_deferred=new Pv;_callback;_that;constructor(e,t){this._callback=e,this._that=t}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(e=>this._deferred.resolve(e),e=>this._deferred.reject(e))}catch(e){this._deferred.reject(e)}}return this._deferred.promise}};function Iv(e,t){return new Promise(n=>{Vg.with($g(Vg.active()),()=>{e.export(t,n)})})}var Lv={_export:Iv},Rv;function zv(){if(Rv===void 0)try{let e=globalThis.process.argv0;Rv=e?`unknown_service:${e}`:`unknown_service`}catch{Rv=`unknown_service`}return Rv}var Bv=e=>typeof e==`object`&&!!e&&typeof e.then==`function`,Vv=class e{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(t,n){let r=new e({},n);return r._rawAttributes=Wv(t),r._asyncAttributesPending=t.filter(([e,t])=>Bv(t)).length>0,r}constructor(e,t){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([e,t])=>(Bv(t)&&(this._asyncAttributesPending=!0),[e,t])),this._rawAttributes=Wv(this._rawAttributes),this._schemaUrl=Gv(t?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[t,n]=this._rawAttributes[e];this._rawAttributes[e]=[t,Bv(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&Q.error(`Accessing resource attributes before async attributes settled`),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[t,n]of this._rawAttributes){if(Bv(n)){Q.debug(`Unsettled resource attribute ${t} skipped`);continue}n!=null&&(e[t]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(t){if(t==null)return this;let n=Kv(this,t),r=n?{schemaUrl:n}:void 0;return e.FromAttributeList([...t.getRawAttributes(),...this.getRawAttributes()],r)}};function Hv(e,t){return Vv.FromAttributeList(Object.entries(e),t)}function Uv(){return Hv({[x_]:zv(),[C_]:k_[C_],[E_]:k_[E_],[D_]:k_[D_]})}function Wv(e){return e.map(([e,t])=>Bv(t)?[e,t.catch(t=>{Q.debug(`promise rejection for resource attribute: %s - %s`,e,t)})]:[e,t])}function Gv(e){if(typeof e==`string`||e===void 0)return e;Q.warn(`Schema URL must be string or undefined, got %s. Schema URL will be ignored.`,e)}function Kv(e,t){let n=e?.schemaUrl,r=t?.schemaUrl,i=n===void 0||n===``,a=r===void 0||r===``;if(i)return r;if(a||n===r)return n;Q.warn(`Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.`,n,r)}var qv=`exception`,Jv=class{_spanContext;kind;parentSpanContext;attributes={};links=[];events=[];startTime;resource;instrumentationScope;_droppedAttributesCount=0;_droppedEventsCount=0;_droppedLinksCount=0;_attributesCount=0;name;status={code:Bg.UNSET};endTime=[0,0];_ended=!1;_duration=[-1,-1];_spanProcessor;_spanLimits;_attributeValueLengthLimit;_recordEndMetrics;_performanceStartTime;_performanceOffset;_startTimeProvided;constructor(e){let t=Date.now();if(this._spanContext=e.spanContext,this._performanceStartTime=A_.now(),this._performanceOffset=t-(this._performanceStartTime+A_.timeOrigin),this._startTimeProvided=e.startTime!=null,this._spanLimits=e.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit??0,this._spanProcessor=e.spanProcessor,this.name=e.name,this.parentSpanContext=e.parentSpanContext,this.kind=e.kind,e.links)for(let t of e.links)this.addLink(t);this.startTime=this._getTime(e.startTime??t),this.resource=e.resource,this.instrumentationScope=e.scope,this._recordEndMetrics=e.recordEndMetrics,e.attributes!=null&&this.setAttributes(e.attributes),this._spanProcessor.onStart(this,e.context)}spanContext(){return this._spanContext}setAttribute(e,t){if(t==null||this._isSpanEnded())return this;if(e.length===0)return Q.warn(`Invalid attribute key: ${e}`),this;if(!l_(t))return Q.warn(`Invalid attribute value set for key: ${e}`),this;let{attributeCountLimit:n}=this._spanLimits,r=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n!==void 0&&this._attributesCount>=n&&r?(this._droppedAttributesCount++,this):(this.attributes[e]=this._truncateToSize(t),r&&this._attributesCount++,this)}setAttributes(e){for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.setAttribute(t,e[t]);return this}addEvent(e,t,n){if(this._isSpanEnded())return this;let{eventCountLimit:r}=this._spanLimits;if(r===0)return Q.warn(`No events allowed.`),this._droppedEventsCount++,this;r!==void 0&&this.events.length>=r&&(this._droppedEventsCount===0&&Q.debug(`Dropping extra events.`),this.events.shift(),this._droppedEventsCount++),B_(t)&&(B_(n)||(n=t),t=void 0);let i=s_(t),{attributePerEventCountLimit:a}=this._spanLimits,o={},s=0,c=0;for(let e in i){if(!Object.prototype.hasOwnProperty.call(i,e))continue;let t=i[e];if(a!==void 0&&c>=a){s++;continue}o[e]=this._truncateToSize(t),c++}return this.events.push({name:e,attributes:o,time:this._getTime(n),droppedAttributesCount:s}),this}addLink(e){if(this._isSpanEnded())return this;let{linkCountLimit:t}=this._spanLimits;if(t===0)return this._droppedLinksCount++,this;t!==void 0&&this.links.length>=t&&(this._droppedLinksCount===0&&Q.debug(`Dropping extra links.`),this.links.shift(),this._droppedLinksCount++);let{attributePerLinkCountLimit:n}=this._spanLimits,r=s_(e.attributes),i={},a=0,o=0;for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e))continue;let t=r[e];if(n!==void 0&&o>=n){a++;continue}i[e]=this._truncateToSize(t),o++}let s={context:e.context};return o>0&&(s.attributes=i),a>0&&(s.droppedAttributesCount=a),this.links.push(s),this}addLinks(e){for(let t of e)this.addLink(t);return this}setStatus(e){if(this._isSpanEnded()||e.code===Bg.UNSET||this.status.code===Bg.OK)return this;let t={code:e.code};return e.code===Bg.ERROR&&(typeof e.message==`string`?t.message=e.message:e.message!=null&&Q.warn(`Dropping invalid status.message of type '${typeof e.message}', expected 'string'`)),this.status=t,this}updateName(e){return this._isSpanEnded()||(this.name=e),this}end(e){if(this._isSpanEnded()){Q.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);return}this.endTime=this._getTime(e),this._duration=L_(this.startTime,this.endTime),this._duration[0]<0&&(Q.warn(`Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.`,this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&Q.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._droppedLinksCount>0&&Q.warn(`Dropped ${this._droppedLinksCount} links because linkCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),this._recordEndMetrics?.(),this._ended=!0,this._spanProcessor.onEnd(this)}_getTime(e){if(typeof e==`number`&&e<=A_.now())return F_(e+this._performanceOffset);if(typeof e==`number`)return P_(e);if(e instanceof Date)return P_(e.getTime());if(z_(e))return e;if(this._startTimeProvided)return P_(Date.now());let t=A_.now()-this._performanceStartTime;return V_(this.startTime,P_(t))}isRecording(){return this._ended===!1}recordException(e,t){let n={};typeof e==`string`?n[v_]=e:e&&(e.code?n[b_]=e.code.toString():e.name&&(n[b_]=e.name),e.message&&(n[v_]=e.message),e.stack&&(n[y_]=e.stack)),n[`exception.type`]||n[`exception.message`]?this.addEvent(qv,n,t):Q.warn(`Failed to record an exception ${e}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){let e=Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);Q.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,e)}return this._ended}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_truncateToSize(e){let t=this._attributeValueLengthLimit;return t<=0?(Q.warn(`Attribute value limit must be positive, got ${t}`),e):typeof e==`string`?this._truncateToLimitUtil(e,t):Array.isArray(e)?e.map(e=>typeof e==`string`?this._truncateToLimitUtil(e,t):e):e}},Yv;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(Yv||={});var Xv=class{shouldSample(){return{decision:Yv.NOT_RECORD}}toString(){return`AlwaysOffSampler`}},Zv=class{shouldSample(){return{decision:Yv.RECORD_AND_SAMPLED}}toString(){return`AlwaysOnSampler`}},Qv=class{_root;_remoteParentSampled;_remoteParentNotSampled;_localParentSampled;_localParentNotSampled;constructor(e){this._root=e.root,this._root||=(g_(Error(`ParentBasedSampler must have a root sampler configured`)),new Zv),this._remoteParentSampled=e.remoteParentSampled??new Zv,this._remoteParentNotSampled=e.remoteParentNotSampled??new Xv,this._localParentSampled=e.localParentSampled??new Zv,this._localParentNotSampled=e.localParentNotSampled??new Xv}shouldSample(e,t,n,r,i,a){let o=$.getSpanContext(e);return!o||!kg(o)?this._root.shouldSample(e,t,n,r,i,a):o.isRemote?o.traceFlags&hg.SAMPLED?this._remoteParentSampled.shouldSample(e,t,n,r,i,a):this._remoteParentNotSampled.shouldSample(e,t,n,r,i,a):o.traceFlags&hg.SAMPLED?this._localParentSampled.shouldSample(e,t,n,r,i,a):this._localParentNotSampled.shouldSample(e,t,n,r,i,a)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}},$v=class{_ratio;_upperBound;constructor(e=0){this._ratio=this._normalize(e),this._upperBound=Math.floor(this._ratio*4294967295)}shouldSample(e,t){return{decision:Dg(t)&&this._accumulate(t)<this._upperBound?Yv.RECORD_AND_SAMPLED:Yv.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(e){return typeof e!=`number`||isNaN(e)?0:e>=1?1:e<=0?0:e}_accumulate(e){let t=0;for(let n=0;n<32;n+=8){let r=0;for(let t=0;t<8;t++){let i=e.charCodeAt(n+t),a=i<58?i-48:i<71?i-55:i-87;r=r<<4|a}t=(t^r)>>>0}return t}},ey;(function(e){e.AlwaysOff=`always_off`,e.AlwaysOn=`always_on`,e.ParentBasedAlwaysOff=`parentbased_always_off`,e.ParentBasedAlwaysOn=`parentbased_always_on`,e.ParentBasedTraceIdRatio=`parentbased_traceidratio`,e.TraceIdRatio=`traceidratio`})(ey||={});var ty=1;function ny(){return{sampler:ry(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128},spanLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128,linkCountLimit:128,eventCountLimit:128,attributePerEventCountLimit:128,attributePerLinkCountLimit:128}}}function ry(){let e=ey.ParentBasedAlwaysOn;switch(e){case ey.AlwaysOn:return new Zv;case ey.AlwaysOff:return new Xv;case ey.ParentBasedAlwaysOn:return new Qv({root:new Zv});case ey.ParentBasedAlwaysOff:return new Qv({root:new Xv});case ey.TraceIdRatio:return new $v(iy());case ey.ParentBasedTraceIdRatio:return new Qv({root:new $v(iy())});default:return Q.error(`OTEL_TRACES_SAMPLER value "${e}" invalid, defaulting to "${ey.ParentBasedAlwaysOn}".`),new Qv({root:new Zv})}}function iy(){return Q.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${ty}.`),ty}function ay(e){let t={sampler:ry()},n=ny(),r=Object.assign({},n,t,e);return r.generalLimits=Object.assign({},n.generalLimits,e.generalLimits||{}),r.spanLimits=Object.assign({},n.spanLimits,e.spanLimits||{}),r}function oy(e){let t=Object.assign({},e.spanLimits);return t.attributeCountLimit=e.spanLimits?.attributeCountLimit??e.generalLimits?.attributeCountLimit??void 0??void 0??128,t.attributeValueLengthLimit=e.spanLimits?.attributeValueLengthLimit??e.generalLimits?.attributeValueLengthLimit??void 0??void 0??1/0,Object.assign({},e,{spanLimits:t})}var sy=16,cy=8,ly=new Uint8Array(sy),uy=new Uint8Array(cy),dy=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function fy(e){for(let t=0;t<e.length;t++)e[t]=Math.random()*256>>>0;for(let t=0;t<e.length;t++)if(e[t]>0)return;e[e.length-1]=1}function py(e){let t=``;for(let n=0;n<e.length;n++)t+=dy[e[n]];return t}var my=class{generateTraceId(){return fy(ly),py(ly)}generateSpanId(){return fy(uy),py(uy)}},hy=`otel.span.parent.origin`,gy=`otel.span.sampling_result`,_y=`otel.sdk.span.live`,vy=`otel.sdk.span.started`,yy=class{startedSpans;liveSpans;constructor(e){this.startedSpans=e.createCounter(vy,{unit:`{span}`,description:`The number of created spans.`}),this.liveSpans=e.createUpDownCounter(_y,{unit:`{span}`,description:`The number of currently live spans.`})}startSpan(e,t){let n=xy(t);if(this.startedSpans.add(1,{[hy]:by(e),[gy]:n}),t===Yv.NOT_RECORD)return()=>{};let r={[gy]:n};return this.liveSpans.add(1,r),()=>{this.liveSpans.add(-1,r)}}};function by(e){return e?e.isRemote?`remote`:`local`:`none`}function xy(e){switch(e){case Yv.RECORD_AND_SAMPLED:return`RECORD_AND_SAMPLE`;case Yv.RECORD:return`RECORD_ONLY`;case Yv.NOT_RECORD:return`DROP`}}var Sy=`2.7.1`,Cy=class{_sampler;_generalLimits;_spanLimits;_idGenerator;instrumentationScope;_resource;_spanProcessor;_tracerMetrics;constructor(e,t,n,r){let i=ay(t);this._sampler=i.sampler,this._generalLimits=i.generalLimits,this._spanLimits=i.spanLimits,this._idGenerator=t.idGenerator||new my,this._resource=n,this._spanProcessor=r,this.instrumentationScope=e;let a=i.meterProvider?i.meterProvider.getMeter(`@opentelemetry/sdk-trace`,Sy):sg();this._tracerMetrics=new yy(a)}startSpan(e,t={},n=Vg.active()){t.root&&(n=$.deleteSpan(n));let r=$.getSpan(n);if(e_(n))return Q.debug(`Instrumentation suppressed, returning Noop Span`),$.wrapSpanContext(gg);let i=r?.spanContext(),a=this._idGenerator.generateSpanId(),o,s,c;!i||!$.isSpanContextValid(i)?s=this._idGenerator.generateTraceId():(s=i.traceId,c=i.traceState,o=i);let l=t.kind??zg.INTERNAL,u=(t.links??[]).map(e=>({context:e.context,attributes:s_(e.attributes)})),d=s_(t.attributes),f=this._sampler.shouldSample(n,s,e,l,d,u),p=this._tracerMetrics.startSpan(i,f.decision);c=f.traceState??c;let m=f.decision===Rg.RECORD_AND_SAMPLED?hg.SAMPLED:hg.NONE,h={traceId:s,spanId:a,traceFlags:m,traceState:c};if(f.decision===Rg.NOT_RECORD)return Q.debug(`Recording is off, propagating context in a non-recording span`),$.wrapSpanContext(h);let ee=s_(Object.assign(d,f.attributes));return new Jv({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:h,name:e,kind:l,links:u,parentSpanContext:o,attributes:ee,startTime:t.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits,recordEndMetrics:p})}startActiveSpan(e,t,n,r){let i,a,o;if(arguments.length<2)return;arguments.length===2?o=t:arguments.length===3?(i=t,o=n):(i=t,a=n,o=r);let s=a??Vg.active(),c=this.startSpan(e,i,s),l=$.setSpan(s,c);return Vg.with(l,o,void 0,c)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}},wy=class{_spanProcessors;constructor(e){this._spanProcessors=e}forceFlush(){let e=[];for(let t of this._spanProcessors)e.push(t.forceFlush());return new Promise(t=>{Promise.all(e).then(()=>{t()}).catch(e=>{g_(e||Error(`MultiSpanProcessor: forceFlush failed`)),t()})})}onStart(e,t){for(let n of this._spanProcessors)n.onStart(e,t)}onEnding(e){for(let t of this._spanProcessors)t.onEnding&&t.onEnding(e)}onEnd(e){for(let t of this._spanProcessors)t.onEnd(e)}shutdown(){let e=[];for(let t of this._spanProcessors)e.push(t.shutdown());return new Promise((t,n)=>{Promise.all(e).then(()=>{t()},n)})}},Ty;(function(e){e[e.resolved=0]=`resolved`,e[e.timeout=1]=`timeout`,e[e.error=2]=`error`,e[e.unresolved=3]=`unresolved`})(Ty||={});var Ey=class{_config;_tracers=new Map;_resource;_activeSpanProcessor;constructor(e={}){let t=Cv({},ny(),oy(e));this._resource=t.resource??Uv(),this._config=Object.assign({},t,{resource:this._resource});let n=[];e.spanProcessors?.length&&n.push(...e.spanProcessors),this._activeSpanProcessor=new wy(n)}getTracer(e,t,n){let r=`${e}@${t||``}:${n?.schemaUrl||``}`;return this._tracers.has(r)||this._tracers.set(r,new Cy({name:e,version:t,schemaUrl:n?.schemaUrl},this._config,this._resource,this._activeSpanProcessor)),this._tracers.get(r)}forceFlush(){let e=this._config.forceFlushTimeoutMillis,t=this._activeSpanProcessor._spanProcessors.map(t=>new Promise(n=>{let r,i=setTimeout(()=>{n(Error(`Span processor did not completed within timeout period of ${e} ms`)),r=Ty.timeout},e);t.forceFlush().then(()=>{clearTimeout(i),r!==Ty.timeout&&(r=Ty.resolved,n(r))}).catch(e=>{clearTimeout(i),r=Ty.error,n(e)})}));return new Promise((e,n)=>{Promise.all(t).then(t=>{let r=t.filter(e=>e!==Ty.resolved);r.length>0?n(r):e()}).catch(e=>n([e]))})}shutdown(){return this._activeSpanProcessor.shutdown()}},Dy=class{_exporter;_shutdownOnce;_pendingExports;constructor(e){this._exporter=e,this._shutdownOnce=new Fv(this._shutdown,this),this._pendingExports=new Set}async forceFlush(){await Promise.all(Array.from(this._pendingExports)),this._exporter.forceFlush&&await this._exporter.forceFlush()}onStart(e,t){}onEnd(e){if(this._shutdownOnce.isCalled||(e.spanContext().traceFlags&hg.SAMPLED)===0)return;let t=this._doExport(e).catch(e=>g_(e));this._pendingExports.add(t),t.finally(()=>this._pendingExports.delete(t))}async _doExport(e){e.resource.asyncAttributesPending&&await e.resource.waitForAsyncAttributes?.();let t=await Lv._export(this._exporter,[e]);if(t.code!==H_.SUCCESS)throw t.error??Error(`SimpleSpanProcessor: span export failed (status ${t})`)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return this._exporter.shutdown()}},Oy=class{_enabled=!1;_currentContext=Hh;_bindFunction(e=Hh,t){let n=this,r=function(...r){return n.with(e,()=>t.apply(this,r))};return Object.defineProperty(r,"length",{enumerable:!1,configurable:!0,writable:!1,value:t.length}),r}active(){return this._currentContext}bind(e,t){return e===void 0&&(e=this.active()),typeof t==`function`?this._bindFunction(e,t):t}disable(){return this._currentContext=Hh,this._enabled=!1,this}enable(){return this._enabled?this:(this._enabled=!0,this._currentContext=Hh,this)}with(e,t,n,...r){let i=this._currentContext;this._currentContext=e||Hh;try{return t.call(n,...r)}finally{this._currentContext=i}}};function ky(e){if(e!==null){if(e===void 0){let e=new Oy;e.enable(),Vg.setGlobalContextManager(e);return}e.enable(),Vg.setGlobalContextManager(e)}}function Ay(e){if(e!==null){if(e===void 0){Xg.setGlobalPropagator(new U_({propagators:[new ov,new o_]}));return}Xg.setGlobalPropagator(e)}}var jy=class extends Ey{constructor(e={}){super(e)}register(e={}){$.setGlobalTracerProvider(this),Ay(e.propagator),ky(e.contextManager)}},My=e=>e!==void 0&&!(Array.isArray(e)&&e.length===0),Ny;(function(e){e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TRACE=1]=`TRACE`,e[e.TRACE2=2]=`TRACE2`,e[e.TRACE3=3]=`TRACE3`,e[e.TRACE4=4]=`TRACE4`,e[e.DEBUG=5]=`DEBUG`,e[e.DEBUG2=6]=`DEBUG2`,e[e.DEBUG3=7]=`DEBUG3`,e[e.DEBUG4=8]=`DEBUG4`,e[e.INFO=9]=`INFO`,e[e.INFO2=10]=`INFO2`,e[e.INFO3=11]=`INFO3`,e[e.INFO4=12]=`INFO4`,e[e.WARN=13]=`WARN`,e[e.WARN2=14]=`WARN2`,e[e.WARN3=15]=`WARN3`,e[e.WARN4=16]=`WARN4`,e[e.ERROR=17]=`ERROR`,e[e.ERROR2=18]=`ERROR2`,e[e.ERROR3=19]=`ERROR3`,e[e.ERROR4=20]=`ERROR4`,e[e.FATAL=21]=`FATAL`,e[e.FATAL2=22]=`FATAL2`,e[e.FATAL3=23]=`FATAL3`,e[e.FATAL4=24]=`FATAL4`})(Ny||={});var Py=new class{emit(e){}enabled(){return!1}};function Fy(e){return Iy(e,new WeakSet)}function Iy(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e instanceof Uint8Array)return!0;if(typeof e==`object`){if(t.has(e))return!1;if(t.add(e),Array.isArray(e))return e.every(e=>Iy(e,t));let n=e;return n.constructor!==Object&&n.constructor!==void 0?!1:Object.values(n).every(e=>Iy(e,t))}return!1}var Ly=class{hrTime;hrTimeObserved;spanContext;resource;instrumentationScope;attributes={};_severityText;_severityNumber;_body;_eventName;_attributesCount=0;_droppedAttributesCount=0;_isReadonly=!1;_logRecordLimits;set severityText(e){this._isLogRecordReadonly()||(this._severityText=e)}get severityText(){return this._severityText}set severityNumber(e){this._isLogRecordReadonly()||(this._severityNumber=e)}get severityNumber(){return this._severityNumber}set body(e){this._isLogRecordReadonly()||(this._body=e)}get body(){return this._body}get eventName(){return this._eventName}set eventName(e){this._isLogRecordReadonly()||(this._eventName=e)}get droppedAttributesCount(){return this._droppedAttributesCount}constructor(e,t,n){let{timestamp:r,observedTimestamp:i,eventName:a,severityNumber:o,severityText:s,body:c,attributes:l={},exception:u,context:d}=n,f=Date.now();if(this.hrTime=I_(r??f),this.hrTimeObserved=I_(i??f),d){let e=$.getSpanContext(d);e&&kg(e)&&(this.spanContext=e)}this.severityNumber=o,this.severityText=s,this.body=c,this.resource=e.resource,this.instrumentationScope=t,this._logRecordLimits=e.logRecordLimits,this._eventName=a,this.setAttributes(l),u!=null&&this._setException(u)}setAttribute(e,t){if(this._isLogRecordReadonly())return this;if(e.length===0)return Q.warn(`Invalid attribute key: ${e}`),this;if(!Fy(t))return Q.warn(`Invalid attribute value set for key: ${e}`),this;let n=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n&&this._attributesCount>=this._logRecordLimits.attributeCountLimit?(this._droppedAttributesCount++,this._droppedAttributesCount===1&&Q.warn(`Dropping extra attributes.`),this):(this.attributes[e]=this._truncateToSize(t),n&&this._attributesCount++,this)}setAttributes(e){for(let[t,n]of Object.entries(e))this.setAttribute(t,n);return this}setBody(e){return this.body=e,this}setEventName(e){return this.eventName=e,this}setSeverityNumber(e){return this.severityNumber=e,this}setSeverityText(e){return this.severityText=e,this}_makeReadonly(){this._isReadonly=!0}_truncateToSize(e){let t=this._logRecordLimits.attributeValueLengthLimit;if(t<=0)return Q.warn(`Attribute value limit must be positive, got ${t}`),e;if(e==null)return e;if(typeof e==`string`)return this._truncateToLimitUtil(e,t);if(e instanceof Uint8Array)return e;if(Array.isArray(e))return e.map(e=>this._truncateToSize(e));if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=this._truncateToSize(r);return t}return e}_setException(e){let t=!1;if(typeof e==`string`||typeof e==`number`)Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(v_,String(e)),t=!0;else if(e&&typeof e==`object`){let n=e;n.code?(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(b_,n.code.toString()),t=!0):n.name&&(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(b_,n.name),t=!0),n.message&&(Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(v_,n.message),t=!0),n.stack&&(Object.hasOwn(this.attributes,`exception.stacktrace`)||this.setAttribute(y_,n.stack),t=!0)}t||Q.warn(`Failed to record an exception ${e}`)}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_isLogRecordReadonly(){return this._isReadonly&&Q.warn(`Can not execute the operation on emitted log record`),this._isReadonly}},Ry=class{instrumentationScope;_sharedState;_loggerConfig;constructor(e,t){this.instrumentationScope=e,this._sharedState=t,this._loggerConfig=this._sharedState.getLoggerConfig(this.instrumentationScope)}emit(e){let t=e.context||Vg.active();if(!this.enabled(e))return;let n=new Ly(this._sharedState,this.instrumentationScope,{context:t,...e});this._sharedState.loggerMetrics.emitLog(),this._sharedState.activeProcessor.onEmit(n,t),n._makeReadonly()}enabled(e){let t=this._loggerConfig;if(t.disabled)return!1;let n=e?.severityNumber;if(typeof n==`number`&&n!==Ny.UNSPECIFIED&&n<t.minimumSeverity)return!1;let r=e?.context||Vg.active();if(t.traceBased){let e=$.getSpanContext(r);if(e&&kg(e)&&(e.traceFlags&hg.SAMPLED)!==hg.SAMPLED)return!1}let i={context:r,instrumentationScope:this.instrumentationScope,severityNumber:e?.severityNumber,eventName:e?.eventName};for(let e of this._sharedState.processors)if(!e.enabled||e.enabled(i))return!0;return!1}},zy=class{forceFlush(){return Promise.resolve()}onEmit(e,t){}shutdown(){return Promise.resolve()}enabled(e){return!1}},By=class{processors;forceFlushTimeoutMillis;constructor(e,t){this.processors=e,this.forceFlushTimeoutMillis=t}async forceFlush(){let e=this.forceFlushTimeoutMillis;await Promise.all(this.processors.map(t=>Nv(t.forceFlush(),e)))}onEmit(e,t){this.processors.forEach(n=>n.onEmit(e,t))}async shutdown(){await Promise.all(this.processors.map(e=>e.shutdown()))}enabled(e){for(let t of this.processors)if(!t.enabled||t.enabled(e))return!0;return!1}};function Vy(e){return`${e.name}@${e.version||``}:${e.schemaUrl||``}`}var Hy=`otel.sdk.log.created`,Uy=class{createdLogs;constructor(e){this.createdLogs=e.createCounter(Hy,{unit:`{log_record}`,description:`The number of logs submitted to enabled SDK Loggers.`})}emitLog(){this.createdLogs.add(1)}},Wy=`0.218.0`,Gy={disabled:!1,minimumSeverity:Ny.UNSPECIFIED,traceBased:!1},Ky=()=>({...Gy}),qy=class{loggers=new Map;activeProcessor;registeredLogRecordProcessors=[];resource;forceFlushTimeoutMillis;logRecordLimits;processors;loggerMetrics;_loggerConfigurator;_loggerConfigs=new Map;constructor(e,t,n,r,i,a){this.resource=e,this.forceFlushTimeoutMillis=t,this.logRecordLimits=n,this.processors=r,r.length>0?(this.registeredLogRecordProcessors=r,this.activeProcessor=new By(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis)):this.activeProcessor=new zy,this._loggerConfigurator=i??Ky;let o=a?a.getMeter(`@opentelemetry/sdk-logs`,Wy):sg();this.loggerMetrics=new Uy(o)}getLoggerConfig(e){let t=Vy(e),n=this._loggerConfigs.get(t);return n||(n=this._loggerConfigurator(e),this._loggerConfigs.set(t,n),n)}},Jy=class{_shutdownOnce;_sharedState;constructor(e={}){let t={resource:e.resource??Uv(),forceFlushTimeoutMillis:e.forceFlushTimeoutMillis??3e4,logRecordLimits:{attributeCountLimit:e.logRecordLimits?.attributeCountLimit??128,attributeValueLengthLimit:e.logRecordLimits?.attributeValueLengthLimit??1/0},loggerConfigurator:e.loggerConfigurator??Ky,processors:e.processors??[],meterProvider:e.meterProvider};this._sharedState=new qy(t.resource,t.forceFlushTimeoutMillis,t.logRecordLimits,t.processors,t.loggerConfigurator,t.meterProvider),this._shutdownOnce=new Fv(this._shutdown,this)}getLogger(e,t,n){if(this._shutdownOnce.isCalled)return Q.warn(`A shutdown LoggerProvider cannot provide a Logger`),Py;e||Q.warn(`Logger requested without instrumentation scope name.`);let r=e||`unknown`,i=`${r}@${t||``}:${n?.schemaUrl||``}`;return this._sharedState.loggers.has(i)||this._sharedState.loggers.set(i,new Ry({name:r,version:t,schemaUrl:n?.schemaUrl},this._sharedState)),this._sharedState.loggers.get(i)}forceFlush(){return this._shutdownOnce.isCalled?(Q.warn(`invalid attempt to force flush after LoggerProvider shutdown`),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush()}shutdown(){return this._shutdownOnce.isCalled?(Q.warn(`shutdown may only be called once per LoggerProvider`),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.activeProcessor.shutdown()}},Yy=li,Xy=gt,Zy=(e,t)=>Bi(Yy,br(he(function*(n){let r=new Set(t?.mergeWithExisting===!0?n.getRef(li):[]);for(let t of e)r.add(wr(t)?yield*t:t);return r}))),Qy=BigInt(1e9),$y=e=>[Number(e/Qy),Number(e%Qy)],eb=e=>{let t={};for(let[n,r]of Object.entries(e))t[n]=tb(r);return t},tb=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:typeof e==`bigint`?e.toString():Xi(e),nb=class extends i()(`@effect/opentelemetry/Resource`){},rb=e=>pe(nb,Hv(ib(e))),ib=e=>{let t={...e.attributes??void 0,[x_]:e.serviceName,[E_]:`@effect/opentelemetry`,[C_]:globalThis.document===void 0?w_:T_};return e.serviceVersion&&(t[S_]=e.serviceVersion),t},ab=class extends i()(`@effect/opentelemetry/Logger/OtelLoggerProvider`){},ob=e=>{switch(e){case`Trace`:return Ny.TRACE;case`Debug`:return Ny.DEBUG;case`Info`:return Ny.INFO;case`Warn`:return Ny.WARN;case`Error`:return Ny.ERROR;case`Fatal`:return Ny.FATAL;default:return Ny.UNSPECIFIED}},sb=s(function*(){let e=yield*ab,t=yield*xr,n=e.getLogger(`@effect/opentelemetry`);return Xy(e=>{let r={fiberId:e.fiber.id},i=vi(e.fiber.context,Mt);rt(i)&&(r.spanId=i.spanId,r.traceId=i.traceId);for(let[t,n]of Object.entries(e.fiber.getRef(Ve)))r[t]=tb(n);let a=e.date.getTime();for(let[t,n]of e.fiber.getRef(it))r[`logSpan.${t}`]=`${a-n}ms`;let o=Fn(e.message).map(tb),s=$y(t.currentTimeNanosUnsafe());n.emit({body:o.length===1?o[0]:o,severityText:e.logLevel,severityNumber:ob(e.logLevel),timestamp:s,observedTimestamp:s,attributes:r})})}),cb=e=>Zy([sb],{mergeWithExisting:e.mergeWithExisting??!0}),lb=(e,t)=>Bi(ab,s(function*(){let n=yield*nb;return yield*me(y(()=>new Jy({...t??void 0,processors:Fn(e),resource:n})),e=>yr(()=>e.forceFlush().then(()=>e.shutdown())).pipe(ur,$r,te(t?.shutdownTimeout??3e3)))})),ub;(function(e){e[e.DELTA=0]=`DELTA`,e[e.CUMULATIVE=1]=`CUMULATIVE`})(ub||={});var db;(function(e){e.COUNTER=`COUNTER`,e.GAUGE=`GAUGE`,e.HISTOGRAM=`HISTOGRAM`,e.UP_DOWN_COUNTER=`UP_DOWN_COUNTER`,e.OBSERVABLE_COUNTER=`OBSERVABLE_COUNTER`,e.OBSERVABLE_GAUGE=`OBSERVABLE_GAUGE`,e.OBSERVABLE_UP_DOWN_COUNTER=`OBSERVABLE_UP_DOWN_COUNTER`})(db||={});var fb;(function(e){e[e.HISTOGRAM=0]=`HISTOGRAM`,e[e.EXPONENTIAL_HISTOGRAM=1]=`EXPONENTIAL_HISTOGRAM`,e[e.GAUGE=2]=`GAUGE`,e[e.SUM=3]=`SUM`})(fb||={});var pb=`@effect/opentelemetry/Metrics`,mb=class{resource;context;temporality;startTimes;startTimeNanos;previousExportTimeNanos;previousCounterState;previousHistogramState;previousFrequencyState;previousSummaryState;constructor(e,t,n=`cumulative`){this.resource=e,this.context=t,this.temporality=n,this.startTimes=new Map,this.startTimeNanos=gb(),this.previousExportTimeNanos=this.startTimeNanos,this.previousCounterState=new Map,this.previousHistogramState=new Map,this.previousFrequencyState=new Map,this.previousSummaryState=new Map}startTimeFor(e,t){return this.startTimes.has(e)?this.startTimes.get(e):(this.startTimes.set(e,t),t)}collect(e){let t=a(this.context),n=gb(),r=[],i=new Map,o=e=>{r.push(e),i.set(e.descriptor.name,e)},s=this.temporality===`delta`,c=s?ub.DELTA:ub.CUMULATIVE,l=s?this.previousExportTimeNanos:this.startTimeNanos;for(let e=0,r=t.length;e<r;e++){let r=t[e],a=r.attributes?be(Object.entries(r.attributes),{},(e,[t,n])=>(e[t]=String(n),e)):{},u=hb(r.id,r.attributes);switch(r.type){case`Counter`:{let e=r.state.count,t=e;if(s){let n=this.previousCounterState.get(u);if(n!==void 0)if(typeof e==`bigint`&&typeof n==`bigint`)t=e-n,t<BigInt(0)&&(t=e);else{let r=Number(e);t=r-Number(n),t<0&&(t=r)}this.previousCounterState.set(u,e)}let d=_b(r,a),f={startTime:this.startTimeFor(d.name,l),endTime:n,attributes:a,value:Number(t)};i.has(r.id)?i.get(r.id).dataPoints.push(f):o({dataPointType:fb.SUM,descriptor:d,isMonotonic:r.state.incremental,aggregationTemporality:c,dataPoints:[f]});break}case`Gauge`:{let e=_b(r,a),t={startTime:this.startTimeFor(e.name,this.startTimeNanos),endTime:n,attributes:a,value:Number(r.state.value)};i.has(r.id)?i.get(r.id).dataPoints.push(t):o({dataPointType:fb.GAUGE,descriptor:e,aggregationTemporality:ub.CUMULATIVE,dataPoints:[t]});break}case`Histogram`:{let e=r.state.buckets.length,t={boundaries:Vr(e-1),counts:Vr(e)},d=0,f=0;for(let[n,i]of r.state.buckets)d<e-1&&(t.boundaries[d]=n),t.counts[d]=i-f,f=i,d++;let p=r.state.count,m=r.state.sum,h=t.counts,ee=r.state.min,te=r.state.max;if(s){let e=this.previousHistogramState.get(u);e!==void 0&&(p=r.state.count-e.count,m=r.state.sum-e.sum,h=t.counts.map((t,n)=>Math.max(0,t-(e.bucketCounts[n]??0)))),this.previousHistogramState.set(u,{count:r.state.count,sum:r.state.sum,bucketCounts:t.counts.slice(),min:r.state.min,max:r.state.max})}let ne=_b(r,a),g={startTime:this.startTimeFor(ne.name,l),endTime:n,attributes:a,value:{buckets:{boundaries:t.boundaries,counts:h},count:p,min:ee,max:te,sum:m}};i.has(r.id)?i.get(r.id).dataPoints.push(g):o({dataPointType:fb.HISTOGRAM,descriptor:ne,aggregationTemporality:c,dataPoints:[g]});break}case`Frequency`:{let e=[],t=new Map;for(let[i,o]of r.state.occurrences){t.set(i,o);let c=o;if(s){let e=this.previousFrequencyState.get(u);if(e!==void 0){let t=e.get(i)??0;c=Math.max(0,o-t)}}let d=_b(r,a),f=this.startTimeFor(d.name,l);e.push({startTime:f,endTime:n,attributes:{...a,key:i},value:c})}if(s&&this.previousFrequencyState.set(u,t),i.has(r.id))i.get(r.id).dataPoints.push(...e);else{let t=_b(r,a);o({dataPointType:fb.SUM,descriptor:t,aggregationTemporality:c,isMonotonic:!0,dataPoints:e})}break}case`Summary`:{let e=[{startTime:l,endTime:n,attributes:{...a,quantile:`min`},value:r.state.min}];for(let[t,i]of r.state.quantiles)e.push({startTime:l,endTime:n,attributes:{...a,quantile:t.toString()},value:i??0});e.push({startTime:l,endTime:n,attributes:{...a,quantile:`max`},value:r.state.max});let t=r.state.count,d=r.state.sum;if(s){let e=this.previousSummaryState.get(u);e!==void 0&&(t=r.state.count-e.count,d=r.state.sum-e.sum),this.previousSummaryState.set(u,{count:r.state.count,sum:r.state.sum})}let f={startTime:l,endTime:n,attributes:a,value:t},p={startTime:l,endTime:n,attributes:a,value:d};if(i.has(`${r.id}_quantiles`))i.get(`${r.id}_quantiles`).dataPoints.push(...e),i.get(`${r.id}_count`).dataPoints.push(f),i.get(`${r.id}_sum`).dataPoints.push(p);else{let t=_b(r,a);o({dataPointType:fb.SUM,descriptor:{...t,name:`${t.name}_quantiles`},aggregationTemporality:c,isMonotonic:!1,dataPoints:e}),o({dataPointType:fb.SUM,descriptor:{name:`${r.id}_count`,description:r.description??``,unit:`1`,type:db.COUNTER,valueType:cg.INT,advice:{}},aggregationTemporality:c,isMonotonic:!0,dataPoints:[f]}),o({dataPointType:fb.SUM,descriptor:{name:`${r.id}_sum`,description:r.description??``,unit:`1`,type:db.COUNTER,valueType:cg.DOUBLE,advice:{}},aggregationTemporality:c,isMonotonic:!0,dataPoints:[p]})}break}}}return s&&(this.previousExportTimeNanos=n),Promise.resolve({resourceMetrics:{resource:this.resource,scopeMetrics:[{scope:{name:pb},metrics:r}]},errors:[]})}},hb=(e,t)=>{if(t===void 0||Object.keys(t).length===0)return e;let n=Object.entries(t).sort((e,t)=>e[0].localeCompare(t[0]));return`${e}:${JSON.stringify(n)}`},gb=()=>{let e=Date.now();return[Math.floor(e/1e3),e%1e3*1e6]},_b=(e,t)=>{let n=t.unit??t.time_unit??`1`;return{name:e.id,description:e.description??``,unit:n,type:vb(e),valueType:yb(e),advice:{}}},vb=e=>{switch(e.type){case`Histogram`:return db.HISTOGRAM;case`Gauge`:return db.OBSERVABLE_GAUGE;case`Frequency`:return db.COUNTER;case`Counter`:return e.state.incremental?db.COUNTER:db.UP_DOWN_COUNTER;case`Summary`:return db.COUNTER}},yb=e=>e.type===`Counter`?typeof e.state.count==`bigint`?cg.INT:cg.DOUBLE:e.type===`Gauge`&&typeof e.state.value==`bigint`?cg.INT:cg.DOUBLE,bb=e=>s(function*(){return new mb(yield*nb,yield*It(),e)}),xb=(e,t,n)=>me(y(()=>{let n=t(),r=Array.isArray(n)?n:[n];return r.forEach(t=>t.setMetricProducer(e)),r}),e=>yr(()=>Promise.all(e.map(e=>e.shutdown()))).pipe(ur,$r,te(n?.shutdownTimeout??3e3))),Sb=(e,t)=>Xn(T(bb(t?.temporality),n=>xb(n,e,t))),Cb=class extends i()(`@effect/opentelemetry/Tracer`){},wb=class extends i()(`@effect/opentelemetry/Tracer/OtelTracerProvider`){},Tb=class extends i()(`@effect/opentelemetry/Tracer/OtelTraceFlags`){},Eb=class extends i()(`@effect/opentelemetry/Tracer/OtelTraceState`){},Db=k(Mr(Cb),e=>an({span(t){return new Mb(Vg,$,e,t)},context(e,t){let n=t.currentSpan;return n===void 0?e[`~effect/Effect/evaluate`](t):Vg.with(zb(Vg.active(),n),()=>e[`~effect/Effect/evaluate`](t))}})),Ob=Bi(Cb,s(function*(){let e=yield*nb;return(yield*wb).getTracer(e.attributes[x_],e.attributes[S_])})),kb=Bi(sa,Db).pipe(ve(Ob)),Ab=`~@effect/opentelemetry/Tracer/OtelSpan`,jb={internal:zg.INTERNAL,client:zg.CLIENT,server:zg.SERVER,producer:zg.PRODUCER,consumer:zg.CONSUMER},Mb=class{[Ab];_tag=`Span`;name;kind;annotations;links;span;spanId;traceId;attributes=new Map;sampled;parent;status;constructor(e,t,n,r){this[Ab]=Ab,this.name=r.name,this.annotations=r.annotations,this.links=r.links,this.kind=r.kind;let i=e.active();this.parent=r.root===!0?r.parent:ai(r.parent,()=>Pb(t,i,r.annotations)),this.span=n.startSpan(r.name,{startTime:$y(r.startTime),links:r.links.length>0?r.links.map(e=>({context:Fb(e.span),attributes:eb(e.attributes)})):void 0,kind:jb[this.kind]},ei(this.parent)?zb(i,this.parent.value,r.annotations):$.deleteSpan(i));let a=this.span.spanContext();this.spanId=a.spanId,this.traceId=a.traceId,this.status={_tag:`Started`,startTime:r.startTime},this.sampled=Nb(a.traceFlags)}attribute(e,t){this.span.setAttribute(e,tb(t)),this.attributes.set(e,t)}addLinks(e){this.links.push(...e),this.span.addLinks(e.map(e=>({context:Fb(e.span),attributes:eb(e.attributes)})))}end(e,t){let n=$y(e);if(this.status={_tag:`Ended`,endTime:e,exit:t,startTime:this.status.startTime},t._tag===`Success`)this.span.setStatus({code:Bg.OK});else if(Ti(t.cause))this.span.setStatus({code:Bg.OK,message:Ni(t.cause)}),this.span.setAttribute(`span.label`,`⚠︎ Interrupted`),this.span.setAttribute(`status.interrupted`,!0);else{let e=ir(t.cause);if(e.length>0){for(let t of e)this.span.recordException(t,n);this.span.setStatus({code:Bg.ERROR,message:e[0].message})}else this.span.setStatus({code:Bg.OK})}this.span.end(n)}event(e,t,n){this.span.addEvent(e,n?eb(n):void 0,$y(t))}},Nb=e=>(e&hg.SAMPLED)===hg.SAMPLED,Pb=(e,t,n)=>{let r=e.getSpan(t)?.spanContext();return r?M(ee({spanId:r.spanId,traceId:r.traceId,sampled:(r.traceFlags&1)==1,annotations:n})):D()},Fb=(e,t)=>{let n=Ib(e,t),r=Lb(e,t);return{spanId:e.spanId,traceId:e.traceId,isRemote:e._tag===`ExternalSpan`,traceFlags:n,traceState:r}},Ib=(e,t)=>{let n;return rt(t)&&(n=Rb(e,t,Tb),la(n)&&(n=vi(e.annotations,Tb))),n??hg.SAMPLED},Lb=(e,t)=>{let n;return rt(t)&&(n=Rb(e,t,Eb),la(n)&&(n=vi(e.annotations,Eb))),n},Rb=(e,t,n)=>{let r=vi(t,n);return rt(r)?r:vi(e.annotations,n)},zb=(e,t,n)=>t instanceof Mb?$.setSpan(e,t.span):$.setSpanContext(e,Fb(t,n)),Bb=(e,t)=>Bi(wb,s(function*(){let n=yield*nb;return yield*me(y(()=>new jy({...t??void 0,resource:n,spanProcessors:Array.isArray(e)?e:[e]})),e=>ur(yr(()=>e.forceFlush().then(()=>e.shutdown()))))})),Vb=e=>yt(s(function*(){let t=yield*bi(e)?e:y(e),n=rb(t.resource),r=My(t.spanProcessor)?qt(kb,Bb(t.spanProcessor,t.tracerConfig)):Zi,i=My(t.logRecordProcessor)?qt(cb({mergeWithExisting:t.loggerMergeWithExisting}),lb(t.logRecordProcessor,t.loggerProviderConfig)):Zi;return se(r,My(t.metricReader)?Sb(mn(t.metricReader),{temporality:t.metricTemporality}):Zi,i).pipe(ve(n))})),Hb=class{_delegate;constructor(e){this._delegate=e}export(e,t){this._delegate.export(e,t)}forceFlush(){return this._delegate.forceFlush()}shutdown(){return this._delegate.shutdown()}};function Ub(e,t){let n={attributes:Gb(e.attributes,t),droppedAttributesCount:0},r=e.schemaUrl;return r&&r!==``&&(n.schemaUrl=r),n}function Wb(e){return{name:e.name,version:e.version}}function Gb(e,t){return Object.keys(e).map(n=>Kb(n,e[n],t))}function Kb(e,t,n){return{key:e,value:qb(t,n)}}function qb(e,t){let n=typeof e;if(n===`string`)return{stringValue:e};if(n===`number`)return Number.isInteger(e)?{intValue:e}:{doubleValue:e};if(n===`boolean`)return{boolValue:e};if(e instanceof Uint8Array)return{bytesValue:t.encodeUint8Array(e)};if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=qb(e[r],t);return{arrayValue:{values:n}}}if(n===`object`&&e!=null){let n=Object.keys(e),r=Array(n.length);for(let i=0;i<n.length;i++)r[i]={key:n[i],value:qb(e[n[i]],t)};return{kvlistValue:{values:r}}}return{}}var Jb=256,Yb=512;function Xb(e,t){let n=e&255|Jb;return t&&(n|=Yb),n}function Zb(e,t){let n=e.spanContext(),r=e.status,i=e.parentSpanContext?.spanId?t.encodeSpanContext(e.parentSpanContext?.spanId):void 0;return{traceId:t.encodeSpanContext(n.traceId),spanId:t.encodeSpanContext(n.spanId),parentSpanId:i,traceState:n.traceState?.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:Gb(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(e=>$b(e,t)),droppedEventsCount:e.droppedEventsCount,status:{code:r.code,message:r.message},links:e.links.map(e=>Qb(e,t)),droppedLinksCount:e.droppedLinksCount,flags:Xb(n.traceFlags,e.parentSpanContext?.isRemote)}}function Qb(e,t){return{attributes:e.attributes?Gb(e.attributes,t):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:e.context.traceState?.serialize(),droppedAttributesCount:e.droppedAttributesCount||0,flags:Xb(e.context.traceFlags,e.context.isRemote)}}function $b(e,t){return{attributes:e.attributes?Gb(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function ex(e,t){return{resourceSpans:nx(e,t)}}function tx(e){let t=new Map;for(let n of e){let e=t.get(n.resource);e||(e=new Map,t.set(n.resource,e));let r=`${n.instrumentationScope.name}@${n.instrumentationScope.version||``}:${n.instrumentationScope.schemaUrl||``}`,i=e.get(r);i||(i=[],e.set(r,i)),i.push(n)}return t}function nx(e,t){let n=tx(e),r=[],i=n.entries(),a=i.next();for(;!a.done;){let[e,n]=a.value,o=[],s=n.values(),c=s.next();for(;!c.done;){let e=c.value;if(e.length>0){let n=e.map(e=>Zb(e,t));o.push({scope:Wb(e[0].instrumentationScope),spans:n,schemaUrl:e[0].instrumentationScope.schemaUrl})}c=s.next()}let l=Ub(e,t),u={resource:l,scopeSpans:o,schemaUrl:l.schemaUrl};r.push(u),a=i.next()}return r}function rx(e){let t=BigInt(1e9);return BigInt(Math.trunc(e[0]))*t+BigInt(Math.trunc(e[1]))}function ix(e){return rx(e).toString()}var ax=typeof BigInt<`u`?ix:R_;function ox(e){return e}var sx={encodeHrTime:ax,encodeSpanContext:ox,encodeOptionalSpanContext:ox,encodeUint8Array:e=>{if(typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=String.fromCharCode(e[n]);return btoa(t.join(``))}},cx={serializeRequest:e=>{let t=ex(e,sx);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return Q.warn(`Failed to parse trace export response: ${e.message}. Returning empty response`),{}}}},lx=5,ux=1e3,dx=5e3,fx=1.5,px=.2;function mx(){return 2*px*Math.random()-px}var hx=class{_transport;constructor(e){this._transport=e}retry(e,t,n){return new Promise((r,i)=>{setTimeout(()=>{this._transport.send(e,t).then(r,i)},n)})}async send(e,t){let n=lx,r=ux,i=Date.now()+t,a=await this._transport.send(e,t);for(;a.status===`retryable`&&n>0;){n--;let t=Math.max(Math.min(r*(1+mx()),dx),0);r*=fx;let o=a.retryInMillis??t,s=i-Date.now();if(o>s)return Q.info(`Export retry time ${Math.round(o)}ms exceeds remaining timeout ${Math.round(s)}ms, not retrying further.`),a;Q.verbose(`Scheduling export retry in ${Math.round(o)}ms`),a=await this.retry(e,s,o)}return a.status===`success`?Q.verbose(`Export succeeded after ${lx-n} retry attempts.`):a.status===`retryable`?Q.info(`Export failed after maximum retry attempts (${lx}).`):Q.info(`Export failed with non-retryable error: ${a.error}`),a}shutdown(){return this._transport.shutdown()}};function gx(e){return new hx(e.transport)}var _x=class{_concurrencyLimit;_sendingPromises=[];constructor(e){this._concurrencyLimit=e}pushPromise(e){if(this.hasReachedLimit())throw Error(`Concurrency Limit reached`);this._sendingPromises.push(e);let t=()=>{let t=this._sendingPromises.indexOf(e);this._sendingPromises.splice(t,1)};e.then(t,t)}hasReachedLimit(){return this._sendingPromises.length>=this._concurrencyLimit}async awaitAll(){await Promise.all(this._sendingPromises)}};function vx(e){return new _x(e.concurrencyLimit)}var yx=class extends Error{code;name=`OTLPExporterError`;data;constructor(e,t,n){super(e),this.data=n,this.code=t}};function bx(e){return Object.prototype.hasOwnProperty.call(e,`partialSuccess`)}function xx(){return{handleResponse(e){e==null||!bx(e)||e.partialSuccess==null||Object.keys(e.partialSuccess).length===0||Q.warn(`Received Partial Success response:`,JSON.stringify(e.partialSuccess))}}}var Sx=class{_diagLogger;_transport;_serializer;_responseHandler;_promiseQueue;_timeout;constructor(e,t,n,r,i){this._transport=e,this._serializer=t,this._responseHandler=n,this._promiseQueue=r,this._timeout=i,this._diagLogger=Q.createComponentLogger({namespace:`OTLPExportDelegate`})}export(e,t){if(this._diagLogger.debug(`items to be sent`,e),this._promiseQueue.hasReachedLimit()){t({code:H_.FAILED,error:Error(`Concurrent export limit reached`)});return}let n=this._serializer.serializeRequest(e);if(n==null){t({code:H_.FAILED,error:Error(`Nothing to send`)});return}this._promiseQueue.pushPromise(this._transport.send(n,this._timeout).then(e=>{if(e.status===`success`){if(e.data!=null)try{this._responseHandler.handleResponse(this._serializer.deserializeResponse(e.data))}catch(t){this._diagLogger.warn(`Export succeeded but could not deserialize response - is the response specification compliant?`,t,e.data)}t({code:H_.SUCCESS});return}else if(e.status===`failure`&&e.error){t({code:H_.FAILED,error:e.error});return}else e.status===`retryable`?t({code:H_.FAILED,error:e.error??new yx(`Export failed with retryable status`)}):t({code:H_.FAILED,error:new yx(`Export failed with unknown error`)})},e=>t({code:H_.FAILED,error:e})))}forceFlush(){return this._promiseQueue.awaitAll()}async shutdown(){this._diagLogger.debug(`shutdown started`),await this.forceFlush(),this._transport.shutdown()}};function Cx(e,t){return new Sx(e.transport,e.serializer,xx(),e.promiseHandler,t.timeout)}function wx(e,t,n){return Cx({transport:n,serializer:t,promiseHandler:vx(e)},{timeout:e.timeoutMillis})}function Tx(e){return e===429||e===502||e===503||e===504}function Ex(e){if(e==null)return;let t=Number.parseInt(e,10);if(Number.isInteger(t))return t>0?t*1e3:-1;let n=new Date(e).getTime()-Date.now();return n>=0?n:0}var Dx=60*1024,Ox=9,kx=0,Ax=0,jx=class{_parameters;constructor(e){this._parameters=e}async send(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),t),i=globalThis.fetch;typeof i.__original==`function`&&(i=i.__original);let a=e.byteLength,o=kx+a>Dx,s=!o&&!(Ax>=Ox);if(s)kx+=a,Ax++;else{let e=o?`size limit`:`count limit`;Q.debug(`keepalive disabled: ${(a/1024).toFixed(1)}KB payload, ${Ax} pending (${e})`)}try{let t=new URL(this._parameters.url),r=await i(t.href,{method:`POST`,headers:await this._parameters.headers(),body:e,signal:n.signal,keepalive:s,mode:globalThis.location?globalThis.location.origin===t.origin?`same-origin`:`cors`:`no-cors`});return r.status>=200&&r.status<=299?(Q.debug(`export response success (status: ${r.status})`),{status:`success`}):Tx(r.status)?(Q.warn(`export response retryable (status: ${r.status})`),{status:`retryable`,retryInMillis:Ex(r.headers.get(`Retry-After`))}):(Q.error(`export response failure (status: ${r.status})`),{status:`failure`,error:Error(`Fetch request failed with non-retryable status ${r.status}`)})}catch(e){return Nx(e)?(Q.warn(`export request retryable (network error: ${e})`),{status:`retryable`,error:Error(`Fetch request encountered a network error`,{cause:e})}):(Q.error(`export request failure (error: ${e})`),{status:`failure`,error:Error(`Fetch request errored`,{cause:e})})}finally{clearTimeout(r),s&&(kx-=a,Ax--)}}shutdown(){}};function Mx(e){return new jx(e)}function Nx(e){return e instanceof TypeError&&!e.cause}function Px(e,t){return wx(e,t,gx({transport:Mx(e)}))}function Fx(e){if(Number.isFinite(e)&&e>0)return e;throw Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${e}')`)}function Ix(e){if(e!=null)return async()=>e}function Lx(e,t,n){return{timeoutMillis:Fx(e.timeoutMillis??t.timeoutMillis??n.timeoutMillis),concurrencyLimit:e.concurrencyLimit??t.concurrencyLimit??n.concurrencyLimit,compression:e.compression??t.compression??n.compression}}function Rx(){return{timeoutMillis:1e4,concurrencyLimit:30,compression:`none`}}function zx(e){let t={};return Object.entries(e??{}).forEach(([e,n])=>{n===void 0?Q.warn(`Header "${e}" has invalid value (${n}) and will be ignored`):t[e]=String(n)}),t}function Bx(e,t,n){return async()=>{let r={...await n()},i={};return t!=null&&Object.assign(i,await t()),e!=null&&Object.assign(i,zx(await e())),Object.assign(i,r)}}function Vx(e){if(e!=null)try{let t=globalThis.location?.href;return new URL(e,t).href}catch{throw Error(`Configuration: Could not parse user-provided export URL: '${e}'`)}}function Hx(e,t,n){return{...Lx(e,t,n),headers:Bx(e.headers,t.headers,n.headers),url:Vx(e.url)??t.url??n.url}}function Ux(e,t){return{...Rx(),headers:async()=>e,url:`http://localhost:4318/`+t}}function Wx(e){return typeof e.headers==`function`?e.headers:Ix(e.headers)}function Gx(e,t,n){return Hx({url:e.url,timeoutMillis:e.timeoutMillis,headers:Wx(e),concurrencyLimit:e.concurrencyLimit},{},Ux(n,t))}function Kx(e,t,n,r){return Px(Gx(e,n,r),t)}var qx=class extends Hb{constructor(e={}){super(Kx(e,cx,`v1/traces`,{"Content-Type":`application/json`}))}};function Jx(e){return yt(k(gc(Sc(`VITE_OTEL_URL`)),kr({onNone:()=>Zi,onSome:t=>Vb(()=>({resource:{serviceName:e},spanProcessor:new Dy(new qx({url:t}))}))})))}var Yx=We(Zi,ve(Jx(`workbench-client`)),ve(sf),ve(Dm),ve($s(ec({VITE_OTEL_URL:{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`}.VITE_OTEL_URL,VITE_PORTLESS_BASE_ORIGIN:{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`}.VITE_PORTLESS_BASE_ORIGIN,VITE_PORTLESS_ORIGIN:{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`}.VITE_PORTLESS_ORIGIN})))),Xx=class extends Um()(`ApiClient`,{group:yh,protocol:We(Bm({retryTransientErrors:!0}),ve(Bf(We(bt({base:gc(Sc(`VITE_PORTLESS_BASE_ORIGIN`)),origin:gc(Sc(`VITE_PORTLESS_ORIGIN`))}),k(e=>We(e.base,xi(e=>{let t=new URL(e);return t.hostname=`server.${t.hostname}`,t.origin}),ai(()=>xi(e.origin,e=>{let t=new URL(e);return t.hostname=[`server`,...t.hostname.split(`.`).slice(1)].join(`.`),t.origin})),kr({onNone:()=>`${location.origin}/api/rpc`,onSome:e=>`${e}/api/rpc`}))),Cr))),ve(Lf),ve(Yx))}){};function Zx(e){return Math.abs(pt(e)).toString(36)}function Qx(e){return{runId:0,state:e.command===void 0&&e.sessionId===void 0?`starting`:`idle`,title:``}}function $x(e){return{events:_r(),state:Qx(e)}}var eS=nu(e=>Xx.runtime.atom(We(Xx,k(t=>t(`terminal.watch`,e)),Ms,Ls(100,Cn(16)),Is($x(e),(e,t)=>We(Lt(t),be({...e,events:_r()},(e,t)=>t.type===`state`?{...e,state:t.state}:{...e,events:[...e.events,t.event]})))),{initialValue:$x(e)})),tS=nu(e=>Xx.runtime.atom(We(Xx,k(t=>t(`terminal.watch`,e)),Ms,Fs(e=>e.type===`state`?mi(e.state):dn)),{initialValue:Qx(e)})),nS=nu(e=>ru(Xx.runtime.atom(T(Xx,t=>Gr(e)?t(`runs.portless`,{cwd:e}):C([])),{initialValue:[]}))),rS=nu(e=>Il(t=>We(t.result(nS(e)),k(e=>We(e,$i(e=>e.origin===void 0?dn:mi(e.origin)),ci,et(tr)))))),iS=ru(Xx.runtime.atom(We(Xx,k(e=>e(`projects.watch`,void 0)),Ms))),aS=nu(e=>ru(Il(t=>We(t.result(iS),k(t=>{let n=Kn(t,t=>Re(t.worktrees,t=>Zx(t.root)===e)),r=We(n,Sn(t=>Kn(t.worktrees,t=>Zx(t.root)===e)));return{activeProject:dr(n),activeWorktree:dr(r),projects:t}}))))),oS=nu(e=>Xx.runtime.atom(We(Xx,k(t=>t(`agents.watch`,{cwd:e})),Ms)));export{lu as C,cu as S,Ms as T,bu as _,iS as a,Il as b,Zx as c,vh as d,dh as f,ku as g,wu as h,nS as i,Xx as l,Tu as m,oS as n,tS as o,ih as p,rS as r,eS as s,aS as t,_h as u,nu as v,Kc as w,su as x,ru as y};
@@ -1 +1 @@
1
- import{n as e,t}from"./compiler-runtime-rGeCHUuX.js";import{Xs as n}from"./button-CP1KTzaA.js";import{g as r,h as i,l as a,s as o,t as s}from"./state-m9GNWCBT.js";import{t as c}from"./terminal-CgkXzq-O.js";import{t as l}from"./terminal-CMql1niz.js";var u=t(),d=e();function f(){let e=(0,u.c)(5),t=c.useParams(),i;e[0]===t.worktree?i=e[1]:(i=s(t.worktree),e[0]=t.worktree,e[1]=i);let a=r(i);if(!a.value.activeWorktree){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,d.jsx)(n,{to:`/`,replace:!0}),e[2]=t):t=e[2],t}let o;return e[3]===a.value.activeWorktree.root?o=e[4]:(o=(0,d.jsx)(p,{cwd:a.value.activeWorktree.root},a.value.activeWorktree.root),e[3]=a.value.activeWorktree.root,e[4]=o),o}function p(e){let t=(0,u.c)(17),n,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=a.mutation(`terminal.resize`),s={mode:`promise`},t[0]=n,t[1]=s):(n=t[0],s=t[1]);let c=i(n,s),f,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=a.mutation(`terminal.write`),p={mode:`promise`},t[2]=f,t[3]=p):(f=t[2],p=t[3]);let m=i(f,p),h;t[4]===e.cwd?h=t[5]:(h=o({cwd:e.cwd}),t[4]=e.cwd,t[5]=h);let g=r(h),_;t[6]!==e.cwd||t[7]!==m?(_=t=>void m({payload:{cwd:e.cwd,data:t}}),t[6]=e.cwd,t[7]=m,t[8]=_):_=t[8];let v;t[9]!==e.cwd||t[10]!==c?(v=t=>void c({payload:{cols:t.cols,cwd:e.cwd,rows:t.rows}}),t[9]=e.cwd,t[10]=c,t[11]=v):v=t[11];let y;return t[12]!==_||t[13]!==v||t[14]!==g.value.events||t[15]!==g.value.state.state?(y=(0,d.jsx)(`div`,{className:`bg-background h-full min-h-0 min-w-0`,children:(0,d.jsx)(l,{className:`h-full min-h-0 w-full min-w-0 overflow-hidden`,events:g.value.events,onData:_,onResize:v,state:g.value.state.state})}),t[12]=_,t[13]=v,t[14]=g.value.events,t[15]=g.value.state.state,t[16]=y):y=t[16],y}export{f as component};
1
+ import{n as e,t}from"./compiler-runtime-rGeCHUuX.js";import{Vs as n}from"./button-fe_R2wzr.js";import{g as r,h as i,l as a,s as o,t as s}from"./state-T-ZhKyUm.js";import{t as c}from"./terminal-t4CeG_V9.js";import{t as l}from"./terminal-Ci9YBovb.js";var u=t(),d=e();function f(){let e=(0,u.c)(5),t=c.useParams(),i;e[0]===t.worktree?i=e[1]:(i=s(t.worktree),e[0]=t.worktree,e[1]=i);let a=r(i);if(!a.value.activeWorktree){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,d.jsx)(n,{to:`/`,replace:!0}),e[2]=t):t=e[2],t}let o;return e[3]===a.value.activeWorktree.root?o=e[4]:(o=(0,d.jsx)(p,{cwd:a.value.activeWorktree.root},a.value.activeWorktree.root),e[3]=a.value.activeWorktree.root,e[4]=o),o}function p(e){let t=(0,u.c)(17),n,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=a.mutation(`terminal.resize`),s={mode:`promise`},t[0]=n,t[1]=s):(n=t[0],s=t[1]);let c=i(n,s),f,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=a.mutation(`terminal.write`),p={mode:`promise`},t[2]=f,t[3]=p):(f=t[2],p=t[3]);let m=i(f,p),h;t[4]===e.cwd?h=t[5]:(h=o({cwd:e.cwd}),t[4]=e.cwd,t[5]=h);let g=r(h),_;t[6]!==e.cwd||t[7]!==m?(_=t=>void m({payload:{cwd:e.cwd,data:t}}),t[6]=e.cwd,t[7]=m,t[8]=_):_=t[8];let v;t[9]!==e.cwd||t[10]!==c?(v=t=>void c({payload:{cols:t.cols,cwd:e.cwd,rows:t.rows}}),t[9]=e.cwd,t[10]=c,t[11]=v):v=t[11];let y;return t[12]!==_||t[13]!==v||t[14]!==g.value.events||t[15]!==g.value.state.state?(y=(0,d.jsx)(`div`,{className:`bg-background h-full min-h-0 min-w-0`,children:(0,d.jsx)(l,{className:`h-full min-h-0 w-full min-w-0 overflow-hidden`,events:g.value.events,onData:_,onResize:v,state:g.value.state.state})}),t[12]=_,t[13]=v,t[14]=g.value.events,t[15]=g.value.state.state,t[16]=y):y=t[16],y}export{f as component};