@deslop/workbench 0.0.344 → 0.0.357

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