@deslop/auth 0.1.1248 → 0.1.1250
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.
- package/README.md +1 -1
- package/dist/client/apple-touch-icon.png +0 -0
- package/dist/client/assets/(home)-CsFFJloK.js +20 -0
- package/dist/client/assets/Check.es-Bp5djBLz.js +1 -0
- package/dist/client/assets/components-DxFAwEtI.js +1 -0
- package/dist/client/assets/dialog-DKm49liV.js +1 -0
- package/dist/client/assets/effect-Cym5PIVz.js +17 -0
- package/dist/client/assets/icon-CPvsBESP.svg +1 -0
- package/dist/client/assets/index-IIm2ZEY_.js +2 -0
- package/dist/client/assets/index-e2xUPxy0.css +2 -0
- package/dist/client/assets/people-BvjrADRC.js +1 -0
- package/dist/client/assets/{react-BUjtWCUj.js → react-COyt-gOi.js} +1 -1
- package/dist/client/assets/route-NUCS2u02.js +41 -0
- package/dist/client/assets/utils-CQ8HfW2q.js +2 -0
- package/dist/client/index.html +6 -6
- package/dist/server.js +16873 -16322
- package/package.json +3 -2
- package/dist/client/assets/(home)-DHUWljGI.js +0 -20
- package/dist/client/assets/check-BOBAceOT.js +0 -1
- package/dist/client/assets/components-ChAYWt2_.js +0 -1
- package/dist/client/assets/dialog-DP3mNUWu.js +0 -1
- package/dist/client/assets/effect-BHGTxpcr.js +0 -17
- package/dist/client/assets/icon-3Ql0zGr9.svg +0 -1
- package/dist/client/assets/index-Bj3hDmy3.js +0 -2
- package/dist/client/assets/index-Bl4kPiWk.css +0 -2
- package/dist/client/assets/people-BjDSIbpy.js +0 -1
- package/dist/client/assets/route-MBpVwG3h.js +0 -41
- package/dist/client/assets/toast-nSmXyoKy.js +0 -3
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{$ as t,$a as n,$n as r,$r as i,$t as a,A as o,Aa as s,Ai as c,An as l,Ar as u,B as d,Bn as f,Br as p,Bt as m,C as h,Ca as g,Ci as _,Cn as v,Cr as y,Ct as b,D as x,Da as S,Di as C,Dn as w,Dr as T,Dt as E,E as D,Ea as O,Ei as k,En as A,Er as j,Et as M,F as ee,Fa as N,Fn as P,Fr as te,Ft as F,G as I,Ga as ne,Gn as L,Ha as re,Hi as ie,Hn as ae,Hr as oe,I as R,Ia as z,Ii as se,In as ce,Ir as B,It as le,J as ue,Ji as de,Jn as fe,Jr as pe,Jt as V,K as me,Ka as H,Ki as he,Kn as ge,Kr as _e,Kt as ve,L as ye,Li as be,Ln as xe,Lr as Se,M as Ce,Ma as we,Mi as Te,Mn as Ee,Mr as De,Mt as Oe,N as ke,Ni as Ae,Nn as je,Nr as Me,Nt as Ne,O as Pe,Oa as Fe,Oi as Ie,Or as U,Ot as W,P as Le,Pa as Re,Pi as ze,Pn as Be,Pr as Ve,Q as He,Qi as Ue,Qn as We,Qr as Ge,Qt as Ke,Ra as qe,Ri as Je,Rn as Ye,Rr as Xe,S as Ze,Sa as Qe,Si as $e,Sn as et,Sr as tt,St as nt,T as rt,Ta as it,Ti as at,Tn as ot,Tr as st,Tt as ct,U as lt,Ua as ut,Ui as dt,Un as ft,Ur as pt,Ut as mt,V as ht,Va as gt,Vi as _t,Vn as vt,Vr as yt,Vt as bt,W as xt,Wa as St,Wi as Ct,Wn as wt,Wt as Tt,Xi as Et,Xn as Dt,Xr as Ot,Xt as kt,Y as At,Yi as jt,Yn as Mt,Yr as Nt,Yt as Pt,Zi as Ft,Zn as It,Zr as Lt,Zt as Rt,_a as zt,_i as Bt,_n as Vt,_r as Ht,_t as Ut,a as Wt,aa as Gt,ai as Kt,an as qt,ar as G,b as Jt,ba as Yt,bi as Xt,bn as Zt,br as Qt,bt as $t,ca as en,cn as tn,cr as nn,ct as rn,d as an,da as on,dn as sn,dr as cn,dt as ln,ea as un,ei as dn,en as fn,eo as pn,er as mn,et as hn,f as gn,fa as _n,fn as vn,fr as yn,ft as bn,ga as xn,gi as Sn,gn as Cn,gr as wn,h as Tn,ha as En,hi as Dn,hn as On,hr as kn,ht as An,i as jn,ia as Mn,ii as Nn,in as Pn,ir as Fn,j as In,ja as Ln,ji as Rn,jn as zn,jr as Bn,jt as Vn,k as Hn,ka as Un,ki as Wn,kn as Gn,kr as K,kt as q,l as Kn,la as qn,ln as Jn,lr as Yn,lt as Xn,ma as Zn,mi as Qn,mn as $n,mr as er,mt as tr,n as nr,na as rr,ni as ir,nn as ar,nr as or,nt as sr,oa as cr,oi as lr,on as ur,or as dr,ot as fr,pa as pr,pn as mr,pr as hr,pt as gr,q as _r,qi as vr,qn as yr,r as br,ra as xr,ri as Sr,rn as Cr,rr as wr,rt as Tr,sa as Er,si as Dr,sn as Or,sr as kr,st as Ar,t as jr,ta as Mr,ti as Nr,tn as Pr,to as Fr,tr as Ir,tt as Lr,u as Rr,ua as zr,un as Br,ur as Vr,ut as Hr,v as Ur,vi as Wr,vn as Gr,vr as Kr,vt as qr,w as Jr,wa as Yr,wi as Xr,wn as Zr,wr as Qr,wt as $r,x as ei,xi as ti,xn as ni,xr as ri,xt as ii,y as ai,ya as oi,yi as si,yn as ci,yr as li,yt as ui,z as di,za as fi,zi as pi,zn as mi,zr as hi,zt as gi}from"./effect-BHGTxpcr.js";import{i as _i,n as vi,o as yi,s as bi,t as xi}from"./react-BUjtWCUj.js";import{$ as Si,$t as Ci,A as wi,An as Ti,At as Ei,B as Di,C as Oi,Cn as ki,Ct as Ai,D as ji,Dn as Mi,Dt as Ni,E as Pi,En as Fi,Et as Ii,F as Li,Fn as Ri,Ft as zi,G as Bi,Gt as Vi,H as Hi,Ht as Ui,I as Wi,It as Gi,J as Ki,Jt as qi,K as Ji,L as Yi,Lt as Xi,M as Zi,N as Qi,O as $i,Ot as ea,P as ta,Pt as na,Q as ra,Qt as ia,R as aa,Rt as oa,S as sa,Sn as ca,St as la,Tn as ua,Tt as da,U as fa,V as pa,W as ma,Wt as ha,X as ga,Xt as _a,Y as va,Yt as ya,Z as ba,Zt as xa,_ as Sa,_n as Ca,_t as J,a as wa,an as Y,at as Ta,b as Ea,bn as Da,bt as Oa,c as ka,cn as Aa,ct as ja,d as Ma,dn as Na,dt as Pa,en as Fa,et as Ia,f as La,fn as Ra,ft as za,g as Ba,gn as Va,gt as Ha,h as Ua,hn as Wa,ht as Ga,i as Ka,in as qa,it as Ja,j as Ya,jt as Xa,k as Za,kn as Qa,kt as $a,l as eo,ln as to,lt as no,m as ro,mn as io,mt as ao,n as oo,nn as so,nt as co,o as lo,on as X,ot as uo,p as fo,pn as po,pt as mo,q as ho,qt as go,r as _o,rn as vo,rt as yo,sn as bo,st as xo,tn as So,tt as Co,u as wo,un as To,ut as Eo,v as Do,vn as Oo,vt as ko,w as Ao,wn as jo,wt as Mo,x as No,xn as Po,xt as Fo,y as Io,yn as Lo,yt as Ro,z as zo,zt as Bo}from"./toast-nSmXyoKy.js";var Vo={name:`app-window`,size:24,node:[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]};Vo.node;var Ho=Ti(Vo),Uo={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Uo.node;var Wo=Ti(Uo),Go={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};Go.node;var Ko=Ti(Go),qo={name:`network`,size:24,node:[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]};qo.node;var Jo=Ti(qo),Yo={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};Yo.node;var Xo=Ti(Yo),Z=e(bi(),1),Q=yi(),Zo=Ri(),Qo=e(_i(),1),$o=vi(),es=`data-open`,ts=`data-closed`,ns=no,rs=ja,is=`data-anchor-hidden`,as={[Ta]:``},os={[Ta]:``,[uo]:``},ss={[es]:``},cs={[ts]:``},ls={[is]:``},us={open(e){return e?as:null}},ds={open(e){return e?os:null}},fs={open(e){return e?ss:cs},anchorHidden(e){return e?ls:null}},ps={...fs,...xo};function ms(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...ms(e,t.id,n)])}function hs(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function gs(e){e.preventDefault(),e.stopPropagation()}function _s(e){return`nativeEvent`in e}function vs(e){return e.pointerType===``&&e.isTrusted?!0:la&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function ys(e){return Ro?!1:!la&&e.width===0&&e.height===0||e.type===`pointerdown`&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`&&(la||e.buttons===0)||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function bs(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function xs(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}var Ss=Math.min,Cs=Math.max,ws=Math.round,Ts=Math.floor,Es=e=>({x:e,y:e}),Ds={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Os(e,t,n){return Cs(e,Ss(t,n))}function ks(e,t){return typeof e==`function`?e(t):e}function As(e){return e.split(`-`)[0]}function js(e){return e.split(`-`)[1]}function Ms(e){return e===`x`?`y`:`x`}function Ns(e){return e===`y`?`height`:`width`}function Ps(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Fs(e){return Ms(Ps(e))}function Is(e,t,n){n===void 0&&(n=!1);let r=js(e),i=Fs(e),a=Ns(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Gs(o)),[o,Gs(o)]}function Ls(e){let t=Gs(e);return[Rs(e),t,Rs(t)]}function Rs(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var zs=[`left`,`right`],Bs=[`right`,`left`],Vs=[`top`,`bottom`],Hs=[`bottom`,`top`];function Us(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Bs:zs:t?zs:Bs;case`left`:case`right`:return t?Vs:Hs;default:return[]}}function Ws(e,t,n,r){let i=js(e),a=Us(As(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Rs)))),a}function Gs(e){let t=As(e);return Ds[t]+e.slice(t.length)}function Ks(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function qs(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Ks(e)}function Js(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Ys(e){let t=bo(Xs,e).current;return t.next=e,Y(t.effect),t}function Xs(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Zs=0;function Qs(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(Zs);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),xa;let o=requestAnimationFrame(a);return Zs=o,()=>{Zs===o&&(cancelAnimationFrame(o),Zs=0)}}var $s=`data-base-ui-inert`,ec=new WeakMap,tc=new WeakSet,nc=new WeakMap,rc=0;function ic(e){return e?ca(e)?e.host:ic(e.parentNode):null}var ac=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=ic(t);return e.contains(n)?n:null}).filter(e=>e!=null),oc=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},sc=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{Ra(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function cc(e,t,n,{mark:r=!0}){let i=ac(t,e),a=r?sc(t,oc(i),new Set(i)):[],o=[],s=[];if(n){let e=ac(t,Array.from(t.querySelectorAll(`[aria-live]`))),n=i.concat(e);sc(t,oc(n),new Set(n)).forEach(e=>{let t=e.getAttribute(`aria-hidden`),n=t!==null&&t!==`false`,r=(ec.get(e)||0)+1;ec.set(e,r),o.push(e),r===1&&n&&tc.add(e),n||e.setAttribute(`aria-hidden`,`true`)})}return r&&a.forEach(e=>{let t=(nc.get(e)||0)+1;nc.set(e,t),s.push(e),t===1&&e.setAttribute($s,``)}),rc+=1,()=>{o.forEach(e=>{let t=(ec.get(e)||0)-1;ec.set(e,t),t||(tc.has(e)||e.removeAttribute(`aria-hidden`),tc.delete(e))}),r&&s.forEach(e=>{let t=(nc.get(e)||0)-1;nc.set(e,t),t||e.removeAttribute($s)}),--rc,rc||(ec=new WeakMap,tc=new WeakSet,nc=new WeakMap)}}function lc(e,t={}){let{ariaHidden:n=!1,mark:r=!0}=t,i=So(e[0]).body;return cc(e,i,n,{mark:r})}function uc(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var dc=class{nodesRef={current:[]};events=uc();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}},fc=Z.createContext(null),pc=Z.createContext(null),mc=()=>Z.useContext(fc)?.id||null,hc=e=>{let t=Z.useContext(pc);return e??t};function gc(e){let t=Oi(),n=hc(e),r=mc();return Y(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function _c(e){let{children:t,id:n}=e,r=mc();return(0,Q.jsx)(fc.Provider,{value:Z.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function vc(e){let{children:t,externalTree:n}=e,r=bo(()=>n??new dc).current;return(0,Q.jsx)(pc.Provider,{value:r,children:t})}function yc(e,t){let n=Va(ko(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||(vs(e)?`keyboard`:t||`mouse`):`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var bc=20,xc=[];function Sc(){xc=xc.filter(e=>e.deref()?.isConnected)}function Cc(e){Sc(),e&&Ra(e)!==`body`&&(xc.push(new WeakRef(e)),xc.length>bc&&(xc=xc.slice(-20)))}function wc(){return Sc(),xc[xc.length-1]?.deref()}function Tc(e){return e?fa(e)?e:ma(e)[0]||e:null}function Ec(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=aa(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return fa(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function Dc(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,explicitReturnFocus:o,restoreFocus:s=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:u=``,nextFocusableElement:d,previousFocusableElement:f,beforeContentFocusGuardRef:p,externalTree:m,getInsideElements:h}=e,g=t.useState(`open`),_=t.useState(`domReferenceElement`),v=t.useState(`floatingElement`),{events:y,dataRef:b}=t.context,x=X(()=>b.current.floatingContext?.nodeId),S=i===!1,C=co(_)&&S,w=Ys(i),T=Ys(a),E=Ys(o),D=Ys(u),O=Ys(g),k=hc(m),A=Ka(),j=Z.useRef(!1),M=Z.useRef(!1),ee=Z.useRef(!1),N=Z.useRef(null),P=Z.useRef(``),te=Z.useRef(``),F=Z.useRef(null),I=Z.useRef(null),ne=ia(F,p,A?.beforeInsideRef),L=ia(I,A?.afterInsideRef),re=Ii(),ie=Ii(),ae=Qi(),oe=A!=null,R=ba(v),z=X((e=R)=>e?ma(e):[]),se=X(()=>h?.().filter(e=>e!=null)??[]);Z.useEffect(()=>{if(r||!c)return;function e(e){e.key===`Tab`&&J(R,Ga(So(R)))&&z().length===0&&!C&&gs(e)}let t=So(R);return Yi(t,`keydown`,e)},[r,R,c,C,z]),Z.useEffect(()=>{if(r||!g)return;let e=So(R);function t(){ee.current=!1}function n(e){let t=ko(e),n=se(),r=J(v,t)||J(_,t)||J(A?.portalNode,t)||n.some(e=>e===t||J(e,t));ee.current=!r,te.current=e.pointerType||`keyboard`,Ha(t,`[data-base-ui-click-trigger]`)&&(M.current=!0,ie.start(0,()=>{M.current=!1}))}function i(){te.current=`keyboard`}return Wi(Yi(e,`pointerdown`,n,!0),Yi(e,`pointerup`,t,!0),Yi(e,`pointercancel`,t,!0),Yi(e,`keydown`,i,!0),t)},[r,v,_,R,g,A,ie,se]),Z.useEffect(()=>{if(r||!l)return;let e=So(R);function n(){M.current=!0,ie.start(0,()=>{M.current=!1})}function i(e){let t=ko(e);fa(t)&&(N.current=t)}function a(n){let r=n.relatedTarget,i=n.currentTarget,a=ko(n);c&&r==null&&a!=null&&J(v,a)&&Cc(a),queueMicrotask(()=>{let o=x(),l=t.context.triggerElements,u=se(),p=r?.hasAttribute(wa(`focus-guard`))&&[F.current,I.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,Ya(f),Ya(d)].includes(r),m=!(J(_,r)||J(v,r)||J(r,v)||J(A?.portalNode,r)||u.some(e=>e===r||J(e,r))||l.hasMatchingElement(e=>J(e,r))||p||k&&(ms(k.nodesRef.current,o).find(e=>J(e.context?.elements.floating,r)||J(e.context?.elements.domReference,r))||hs(k.nodesRef.current,o).find(e=>[e.context?.elements.floating,ba(e.context?.elements.floating)].includes(r)||e.context?.elements.domReference===r)));if(i===_&&R&&Ec(R),s&&i!==_&&!Ki(a)&&Ga(e)===e.body){if(Lo(R)&&(R.focus(),s===`popup`)){ae.request(()=>{R.focus()});return}let e=z(),t=N.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||R;Lo(n)&&n.focus()}b.current.insideReactTree?b.current.insideReactTree=!1:(C||!c)&&r&&m&&!M.current&&(C||r!==wc())&&(j.current=!0,t.setOpen(!1,No(eo,n)))})}function o(){ee.current||(b.current.insideReactTree=!0,re.start(0,()=>{b.current.insideReactTree=!1}))}let u=Lo(_)?_:null;if(v||u)return Wi(u&&Yi(u,`focusout`,a),u&&Yi(u,`pointerdown`,n),v&&Yi(v,`focusin`,i),v&&Yi(v,`focusout`,a),v&&A&&Yi(v,`focusout`,o,!0))},[r,_,v,R,c,k,A,t,l,s,z,C,x,b,re,ie,ae,d,f,se]),Z.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${wa(`portal`)}]`)||[]),t=(k?hs(k.nodesRef.current,x()):[]).find(e=>co(e.context?.elements.domReference||null))?.context?.elements.domReference,n=lc([v,...e,F.current,I.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...se(),t,Ya(f),Ya(d),C?_:null].filter(e=>e!=null),{ariaHidden:c||C,mark:!1}),i=lc([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,c,A,C,k,x,d,f,se]),Y(()=>{if(!g||r||!Lo(R))return;P.current=``,te.current=``;let e=So(R),t=Ga(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(D.current||``):n;if(r===void 0||r===!1||J(R,t))return;let i=null,a=()=>(i??=z(R),i[0]||R),o;o=r===!0||r===null?a():Ya(r),o||=a();let s=J(R,Ga(e)),c=b.current.openEvent,l=c?.type===`mousedown`&&vs(c);Qs(o,{sync:l,preventScroll:o===R,shouldFocus(){if(!O.current)return!1;if(s)return!0;let t=Ga(e);return!(t!==o&&J(R,t))}})})},[r,g,R,z,w,D,O,b]);let ce=Z.useRef(null);Y(()=>{if(r||!R){ce.current=null;return}ce.current&&=(ce.current.cancelled=!0,null);let e=So(R),t=Ga(e),n=D.current==null;Cc(t);function i(e){if(e.open||(P.current=yc(e.nativeEvent,te.current)),(e.reason===`focus-out`&&e.triggerElement?.hasAttribute(wa(`focus-guard`))||e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`)&&(j.current=!0),e.reason===`outside-press`){if(e.nested)j.current=!1;else if(vs(e.nativeEvent)||ys(e.nativeEvent))j.current=!1;else{let e=!1;So(R).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?j.current=!1:j.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&Ra(t)!==`body`?t:null,s=n?o||a:a||o;return s||=wc()||null,typeof i==`boolean`?s:Ya(i)||s||null}return()=>{y.off(`openchange`,i);let t=Ga(e),n=se(),r=J(v,t)||n.some(e=>e===t||J(e,t))||k&&ms(k.nodesRef.current,x(),!1).some(e=>J(e.context?.elements.floating,t)),o=T.current,s=P.current,c=a(s),l={cancelled:!1};ce.current=l,queueMicrotask(()=>{ce.current===l&&(ce.current=null);let n=Tc(c),i=E.current??typeof o!=`boolean`;if(!l.cancelled&&o&&!j.current&&Lo(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}j.current=!1})}},[r,v,R,T,E,D,y,k,_,x,se]),Y(()=>{if(!Fo||g||!v)return;let e=Ga(So(v));Lo(e)&&yo(e)&&J(v,e)&&e.blur()},[g,v]),Y(()=>{if(!r&&A)return A.setFocusManagerState({modal:c,closeOnFocusOut:l,open:g,onOpenChange:t.setOpen,domReference:_}),()=>{A.setFocusManagerState(null)}},[r,A,c,g,t,l,_]),Y(()=>{if(!r&&R)return Ec(R),()=>{queueMicrotask(Sc)}},[r,R]);let B=!r&&(!c||!C)&&(oe||c);return(0,Q.jsxs)(Z.Fragment,{children:[B&&(0,Q.jsx)(Li,{"data-type":`inside`,ref:ne,onFocus:e=>{if(c){let e=z();Qs(e[e.length-1])}else A?.portalNode&&(j.current=!1,Hi(e,A.portalNode)?zo(_)?.focus():Ya(f??A.beforeOutsideRef)?.focus())}}),n,B&&(0,Q.jsx)(Li,{"data-type":`inside`,ref:L,onFocus:e=>{c?Qs(z()[0]):A?.portalNode&&(l&&(j.current=!0),Hi(e,A.portalNode)?Di(_)?.focus():Ya(d??A.afterOutsideRef)?.focus())}})]})}function Oc(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=Ea}=t,l=e.context.dataRef,u=Z.useRef(void 0),d=Qi(),f=Ii(),p=Z.useMemo(()=>{function t(t,n,r,i){let a=No(c,n,r);t&&i===`touch`&&s>0?f.start(s,()=>{e.setOpen(!0,a)}):e.setOpen(t,a)}function n(t,n,r){let a=l.current.openEvent,s=e.select(`domReferenceElement`)!==n;return t&&s||!t||!i?!0:a&&(typeof o==`function`?o():o)?!r(a.type):!1}return{onPointerDown(e){u.current=bs(e.pointerType,!0)&&ys(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(i){let o=u.current,s=i.nativeEvent,c=e.select(`open`);if(i.button!==0||r===`click`||bs(o,!0)&&a)return;let l=n(c,i.currentTarget,e=>e===`click`||e===`mousedown`),f=ko(s),p=yo(f);if(p||o===`virtual`){t(l,s,p?f:i.currentTarget,o);return}let m=i.currentTarget;d.request(()=>{t(l,s,m,o)})},onClick(i){if(r===`mousedown-only`)return;let o=u.current;r===`mousedown`&&o?u.current=void 0:bs(o,!0)&&a||t(n(e.select(`open`),i.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),i.nativeEvent,i.currentTarget,o)},onKeyDown(){u.current=void 0}}},[l,r,a,c,e,o,i,d,f,s]);return Z.useMemo(()=>n?{reference:p}:_a,[n,p])}function kc(){return!1}function Ac(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function jc(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=kc,bubbles:s,externalTree:c}=t,l=e.useState(`open`),u=e.useState(`floatingElement`),{dataRef:d,events:f}=e.context,p=hc(c),m=X(typeof i==`function`?i:()=>!1),h=typeof i==`function`?m:i,g=h!==!1,_=X(()=>a),{escapeKey:v,outsidePress:y}=Ac(s),b=Z.useRef(!1),x=Z.useRef(!1),S=Z.useRef(!1),C=Z.useRef(!1),w=Z.useRef(!1),T=Z.useRef(``),E=Z.useRef(null),D=Ii(),O=Ii(),k=Ii(),A=X(()=>{O.clear(),d.current.insideReactTree=!1}),j=X(e=>{let t=d.current.floatingContext?.nodeId;return(p?ms(p.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),M=X(t=>ra(t,e.select(`floatingElement`))||ra(t,e.select(`domReferenceElement`))),ee=X(t=>{o()&&e.setOpen(!1,No(Ea,t.nativeEvent))}),N=X(t=>{if(!l||!n||!r||t.key!==`Escape`)return;let i=_s(t)?t.nativeEvent:t;if(w.current||i.isComposing||!v&&j(`__escapeKeyBubbles`))return;let a=No(ka,i);e.setOpen(!1,a),a.isCanceled||t.preventDefault(),!v&&!a.isPropagationAllowed&&t.stopPropagation()}),P=X(()=>{d.current.insideReactTree=!0,O.start(0,A)}),te=X(t=>{if(!l||!n||t.button!==0)return;let r=ko(t.nativeEvent);J(e.select(`floatingElement`),r)&&(b.current||(b.current=!0,x.current=!1))}),F=X(e=>{l&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&b.current&&(x.current=!0)});Z.useEffect(()=>{function e(e){e.open||(C.current=!1)}return f.on(`openchange`,e),()=>{f.off(`openchange`,e)}},[f]),Z.useEffect(()=>A,[A]),Z.useEffect(()=>{if(!l||!n)return l||(C.current=!1,w.current=!1,T.current=``,E.current=null),A;d.current.__escapeKeyBubbles=v,d.current.__outsidePressBubbles=y;let t=new da,i=So(u);function a(){k.clear(),w.current=!0}function o(){w.current=!0,k.start(Fo?5:0,()=>{w.current=!1})}function s(){S.current=!0,t.start(0,()=>{S.current=!1})}function c(){b.current=!1,x.current=!1}function f(){let e=T.current,t=e===`pen`||!e?`mouse`:e,n=_(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function m(e){let t=f();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function O(e){let t=d.current.floatingContext?.nodeId,n=p&&ms(p.nodesRef.current,t).some(t=>ra(e,t.context?.elements.floating));return M(e)||n}function ee(n){if(m(n)){n.type!==`click`&&!M(n)&&(t.clear(),S.current=!1),A();return}if(d.current.insideReactTree){A();return}let r=ko(n),i=`[${wa(`inert`)}]`,a=Oo(r)?r.getRootNode():null,o=Array.from((ca(a)?a:So(e.select(`floatingElement`))).querySelectorAll(i)),s=e.context.triggerElements;if(r&&(s.hasElement(r)||s.hasMatchingElement(e=>J(e,r))))return;let c=Oo(r)?r:null;for(;c&&!Da(c);){let e=Wa(c);if(Da(e)||!Oo(e))break;c=e}if(!(o.length&&Oo(r)&&!Ia(r)&&!J(r,e.select(`floatingElement`))&&o.every(e=>!J(c,e)))){if(Lo(r)&&!(`touches`in n)){let e=Da(r),t=Aa(r),i=/auto|scroll/,a=e||i.test(t.overflowX),o=e||i.test(t.overflowY),s=a&&r.clientWidth>0&&r.scrollWidth>r.clientWidth,c=o&&r.clientHeight>0&&r.scrollHeight>r.clientHeight,l=t.direction===`rtl`,u=c&&(l?n.offsetX<=r.offsetWidth-r.clientWidth:n.offsetX>r.clientWidth),d=s&&n.offsetY>r.clientHeight;if(u||d)return}if(!O(n)){if(f()===`intentional`){if(n.detail!==0&&!vs(n)&&!C.current)return;if(S.current){t.clear(),S.current=!1;return}}typeof h==`function`&&!h(n)||j(`__outsidePressBubbles`)||(e.setOpen(!1,No(Ua,n)),A())}}}function P(t){f()===`sloppy`&&t.pointerType!==`touch`&&e.select(`open`)&&n&&!M(t)&&ee(t)}function te(t){if(f()!==`sloppy`||!e.select(`open`)||!n||M(t))return;let r=t.touches[0];r&&(E.current={startTime:Date.now(),startX:r.clientX,startY:r.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},D.start(1e3,()=>{E.current&&(E.current.dismissOnTouchEnd=!1,E.current.dismissOnMouseDown=!1)}))}function F(e,t){let n=ko(e);if(!n)return;let r=Yi(n,e.type,()=>{t(e),r()})}function I(e){T.current=`touch`,F(e,te)}function ne(e){D.clear(),e.type===`pointerdown`&&(e.button===0&&(C.current=!0),T.current=e.pointerType),(e.type!==`mousedown`||!E.current||E.current.dismissOnMouseDown)&&F(e,e=>{e.type===`pointerdown`?P(e):ee(e)})}function L(e){if(e.type===`pointercancel`&&(C.current=!1),!b.current)return;let n=x.current;c(),f()===`intentional`&&(e.type===`pointercancel`?n&&s():O(e)||(n?s():(typeof h!=`function`||h(e))&&(t.clear(),S.current=!0,A())))}function re(e){if(f()!==`sloppy`||!E.current||M(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-E.current.startX),r=Math.abs(t.clientY-E.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(E.current.dismissOnTouchEnd=!0),i>10&&(ee(e),D.clear(),E.current=null)}function ie(e){F(e,re)}function ae(e){f()===`sloppy`&&E.current&&!M(e)&&(E.current.dismissOnTouchEnd&&ee(e),D.clear(),E.current=null)}function oe(e){F(e,ae)}let R=Wi(r&&Wi(Yi(i,`keydown`,N),Yi(i,`compositionstart`,a),Yi(i,`compositionend`,o)),g&&Wi(Yi(i,`click`,ne,!0),Yi(i,`pointerdown`,ne,!0),Yi(i,`pointerup`,L,!0),Yi(i,`pointercancel`,L,!0),Yi(i,`mousedown`,ne,!0),Yi(i,`mouseup`,L,!0),Yi(i,`touchstart`,I,{capture:!0,passive:!0}),Yi(i,`touchmove`,ie,{capture:!0,passive:!0}),Yi(i,`touchend`,oe,{capture:!0,passive:!0})));return()=>{R(),t.clear(),c(),S.current=!1}},[d,u,r,g,h,l,n,v,y,N,A,_,j,M,p,e,D,k]);let I=Z.useMemo(()=>({onKeyDown:N,onPointerDown:ee,onClick:ee}),[N,ee]),ne=Z.useMemo(()=>({onKeyDown:N,onPointerDown:F,onMouseDown:F,onClickCapture:P,onMouseDownCapture(e){P(),te(e)},onPointerDownCapture(e){P(),te(e)},onMouseUpCapture:P,onTouchEndCapture:P,onTouchMoveCapture:P}),[N,P,te,F]);return Z.useMemo(()=>n?{reference:I,floating:ne,trigger:I}:{},[n,I,ne])}function Mc(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=o;return t.useSyncedValue(`floatingId`,i),Y(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};Oo(c)&&(e.domReferenceElement=c),r.state.positionReference===r.state.referenceElement&&(e.positionReference=c),r.update(e)},[s,i,c,l,r]),r.context.onOpenChange=u,r.context.nested=a,r}function Nc(e,t=!1,n=!1,r=!1){let[i,a]=Z.useState(e&&t?`idle`:void 0),[o,s]=Z.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),Y(()=>{if(!e&&o&&i!==`ending`&&n){let e=Zi.request(()=>{a(`ending`)});return()=>{Zi.cancel(e)}}},[e,o,i,n]),Y(()=>{if(!e||t||i===void 0)return;let n=Zi.request(()=>{a(void 0)});return()=>{Zi.cancel(n)}},[t,e,i]),Y(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=Zi.request(()=>{a(`idle`)});return()=>{Zi.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}function Pc(e){let{open:t,ref:n,preventUnmountOnClose:r,setPreventUnmountOnClose:i,onUnmount:a,animateInitialOpen:o}=e,s=X(i),{mounted:c,setMounted:l,transitionStatus:u}=Nc(t,!1,!1,o),d=!t&&r;Y(()=>{t&&s(!1)},[t,s]);let f=Z.useRef(c),p=Z.useRef(!1),m=Ao(),h=()=>{f.current=!1,l(!1),a()};Y(()=>{f.current=c,p.current&&(p.current=!1,!t&&c&&h())});let g=X(()=>{f.current&&(t?(p.current=!0,m()):h())});return Za({enabled:c&&!t&&!d,open:t,ref:n,onComplete(){t||g()}}),{mounted:c,transitionStatus:u,preventUnmountingOnClose:d,forceUnmount:g}}var Fc={tabIndex:-1,[ao]:``};function Ic(e){return t=>t!==`touch`||e.current}function Lc(e,t=!1){let n=Oi(),r=mc()!=null,i=bo(()=>e(n,r)).current;return Mc({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function Rc({handle:e,store:t}){return Y(()=>e.attachStore(t),[e,t]),null}function zc(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function Bc(e,t){let n=Z.useRef(null);return X(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),zc(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),zc(t))})}function Vc(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);let a=n?.id??null,o=e.activeTriggerId,s=e.activeTriggerElement;return(a||t)&&(o=a,s=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:o,activeTriggerElement:s,openedWithoutTrigger:t?n==null:e.openedWithoutTrigger}}function Hc(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function Uc(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=Bc(e,n),o=X(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e)}else if(a==null&&i&&!n.state.openedWithoutTrigger){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=X(e=>{a(e),e&&o(e)});return Y(()=>(s(t.current),()=>s(null)),[s,t,n,e]),Y(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function Wc(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=Z.useRef(null),i=e.useState(`open`),a=e.useState(`triggerCount`),o=e.useState(`activeTriggerId`),s=e.useState(`activeTriggerElement`);Y(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0),e.state.openedWithoutTrigger&&e.set(`openedWithoutTrigger`,!1);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&!e.state.openedWithoutTrigger&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=No(ro);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,a,o,s,n])}function Gc(e,t,n,r){let{mounted:i,transitionStatus:a,forceUnmount:o}=Pc({open:e,ref:t.context.popupRef,preventUnmountOnClose:t.useState(`preventUnmountingOnClose`),setPreventUnmountOnClose:e=>t.set(`preventUnmountingOnClose`,e),animateInitialOpen:r,onUnmount(){t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}});return bo(()=>(t.set(`mounted`,i),null)),t.useSyncedValues({mounted:i,transitionStatus:a}),{forceUnmount:o,transitionStatus:a}}function Kc(e,t){e.useSyncedValues(t),Y(()=>()=>{e.update({activeTriggerProps:_a,inactiveTriggerProps:_a,popupProps:_a})},[e])}function qc(e,t){Y(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),Y(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var Jc=class{idMap=new Map;add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}},Yc={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},Xc=class extends Ni{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:uc(),nested:n,triggerElements:i},Yc),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&xs(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{this.syncOnly||this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function Zc(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new Xc({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,openedWithoutTrigger:!1,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:_a,inactiveTriggerProps:_a,popupProps:_a}}var Qc=e=>e.triggerIdProp??e.activeTriggerId,$c=e=>e.openProp??e.open,el=e=>(e.popupElement?.id??e.floatingId)||void 0;function tl(e,t){return t!==void 0&&$c(e)&&Qc(e)===t}function nl(e,t){return tl(e,t)?!0:t!==void 0&&$c(e)&&Qc(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}var rl={open:$c,mounted:e=>e.mounted,transitionStatus:e=>$c(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Qc,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:el,isTriggerActive:(e,t)=>t!==void 0&&Qc(e)===t,isOpenedByTrigger:(e,t)=>tl(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&Qc(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>nl(e,t)?el(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function il(e){let t=Z.useCallback(t=>e===void 0?xa:e.subscribeStore(t),[e]),n=Z.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,Zo.useSyncExternalStore)(t,n,()=>e?.serverStore)}var al=Mo&&Fo;function ol(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=Z.useRef(!1),s=Z.useRef(null),c=Z.useRef(!0),l=Ii();Z.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=Va(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&Lo(t)&&t===Ga(So(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return Wi(Yi(r,`blur`,i),al&&Yi(r,`keydown`,a,!0),al&&Yi(r,`pointerdown`,l,!0))},[e,n]),Z.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);Oo(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=Z.useMemo(()=>{function t(){o.current=!1,s.current=null}return{onMouseLeave(){t()},onFocus(n){let i=n.currentTarget;if(o.current){if(s.current===i)return;t()}let a=ko(n.nativeEvent);if(Oo(a)){if(al&&!n.relatedTarget){if(!c.current&&!yo(a))return}else if(!Ja(a))return}let u=Co(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;e.select(`open`)&&u||!r?e.setOpen(!0,No(Do,d,f)):l.start(r,()=>{o.current||e.setOpen(!0,No(Do,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=Oo(r)&&r.hasAttribute(wa(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=Ga(So(t));!r&&n===t||J(a.current.floatingContext?.refs.floating.current,n)||J(t,n)||o||Co(r??n,e.context.triggerElements)||e.setOpen(!1,No(Do,i))})}}},[a,r,e,l]);return Z.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}var sl=class e{pointerType=void 0;interactedInside=!1;handler=void 0;blockMouseMove=!0;performedPointerEventsMutation=!1;pointerEventsScopeElement=null;pointerEventsReferenceElement=null;pointerEventsFloatingElement=null;restTimeoutPending=!1;openChangeTimeout=new da;restTimeout=new da;handleCloseOptions=void 0;static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},cl=new WeakMap;function ll(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&cl.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),cl.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function ul(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=cl.get(n);a&&a!==e&&ll(a),ll(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,cl.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function dl(e){let t=e.context.dataRef.current,n=bo(()=>t.hoverInteractionState??sl.create()).current;return t.hoverInteractionState||=n,Ei(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function fl(e,t){return t!=null&&!bs(t)?0:typeof e==`function`?e():e}function pl(e,t,n){let r=fl(e,n);return typeof r==`number`?r:r?.[t]}function ml(e){return typeof e==`function`?e():e}function hl(e,t){return t||e===`click`||e===`mousedown`}function gl(e){return e?.includes(`mouse`)&&e!==`mousedown`}function _l(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=e.useState(`open`),o=e.useState(`floatingElement`),s=e.useState(`domReferenceElement`),{dataRef:c}=e.context,l=hc(),u=mc(),d=dl(e),f=Ii(),p=X(()=>hl(c.current.openEvent?.type,d.interactedInside)),m=X(()=>gl(c.current.openEvent?.type)),h=X(()=>{ll(d)});Y(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,h())},[a,d,h]),Z.useEffect(()=>h,[h]),Y(()=>{if(n&&a&&d.handleCloseOptions?.blockPointerEvents&&m()&&Oo(s)&&o){let e=s,t=o,n=So(o),r=l?.nodesRef.current.find(e=>e.id===u)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=d.pointerEventsScopeElement===t?null:d.pointerEventsScopeElement,a=r===t?null:r,c=d.handleCloseOptions?.getScope?.()??i??a??Ha(e,`[data-rootownerid]`)??n.body;return ul(d,{scopeElement:c,referenceElement:e,floatingElement:t}),()=>{h()}}},[n,a,s,o,d,m,l,u,h]),Z.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&ms(l.nodesRef.current,u).length>0)}function a(t){let n=pl(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,No(Io,t)),l?.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=ko(e);Si(t)?d.interactedInside=Ha(t,`[aria-haspopup]`)!=null:d.interactedInside=!1}function g(){d.openChangeTimeout.clear(),f.clear(),l?.events.off(`floating.closed`,v),h()}function _(n){if(t()&&l){l.events.on(`floating.closed`,v);return}if(Co(n.relatedTarget,e.context.triggerElements))return;let r=c.current.floatingContext?.nodeId??i,o=n.relatedTarget;l&&r&&Oo(o)&&ms(l.nodesRef.current,r,!1).some(e=>J(e.context?.elements.floating,o))||(d.handler?d.handler(n):(h(),m()&&!p()&&a(n)))}function v(n){l&&u&&!t()&&f.start(0,()=>{l.events.off(`floating.closed`,v),e.setOpen(!1,No(Io,n)),l.events.emit(`floating.closed`,n)})}let y=o;return Wi(y&&Yi(y,`mouseenter`,g),y&&Yi(y,`mouseleave`,_),y&&Yi(y,`pointerdown`,s,!0),()=>{l?.events.off(`floating.closed`,v)})},[n,o,e,c,r,i,m,p,h,d,l,u,f])}var vl={current:null};function yl(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=vl,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,{dataRef:h,events:g}=e.context,_=hc(l),v=dl(e),y=Z.useRef(!1),b=Ys(i),x=Ys(r),S=Ys(o),C=Ys(n),w=Ys(p),T=Ys(f),E=X(()=>hl(h.current.openEvent?.type,v.interactedInside)),D=X(()=>w.current?.()!==!1),O=X((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!J(t,n);if(!Oo(r))return!1;let a=r;return i.hasMatchingElement(e=>J(e,a))&&(!t||!J(t,a))}),k=X(()=>{v.handler&&=(So(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,v.handler),void 0)}),A=X(()=>{ll(v)});return u&&(v.handleCloseOptions=i?.__options),Z.useEffect(()=>k,[k]),Z.useEffect(()=>{if(!n)return;function e(e){e.open?y.current=!1:(y.current=e.reason===Io,k(),v.openChangeTimeout.clear(),v.restTimeout.clear(),v.blockMouseMove=!0,v.restTimeoutPending=!1)}return g.on(`openchange`,e),()=>{g.off(`openchange`,e)}},[n,g,v,k]),Z.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=pl(x.current,`close`,v.pointerType);r?v.openChangeTimeout.start(r,()=>{e.setOpen(!1,No(Io,t)),_?.events.emit(`floating.closed`,t)}):n&&(v.openChangeTimeout.clear(),e.setOpen(!1,No(Io,t)),_?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!Oo(r))return;function i(t){if(v.openChangeTimeout.clear(),v.blockMouseMove=!1,a&&!bs(v.pointerType))return;let n=ml(S.current),r=pl(x.current,`open`,v.pointerType),i=ko(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(Oo(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(J(t,i)){c=t;break}}Oo(o)&&Oo(s)&&!e.context.triggerElements.hasElement(o)&&J(o,s)&&(c=s);let l=c!=null&&O(s,c,i),u=e.select(`open`),d=T.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&y.current,p=!l&&Oo(c)&&Oo(s)&&J(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;h?D()&&e.setOpen(!0,No(Io,t,c)):m||(r?v.openChangeTimeout.start(r,()=>{g&&D()&&e.setOpen(!0,No(Io,t,c))}):g&&D()&&e.setOpen(!0,No(Io,t,c)))}function o(n){if(E()){A();return}k();let r=e.select(`domReferenceElement`),i=So(r);v.restTimeout.clear(),v.restTimeoutPending=!1;let a=h.current.floatingContext??d?.();if(!Co(n.relatedTarget,e.context.triggerElements)){if(b.current&&a){e.select(`open`)||v.openChangeTimeout.clear();let r=c.current;v.handler=b.current({...a,tree:_,x:n.clientX,y:n.clientY,onClose(){A(),k(),C.current&&!E()&&r===e.select(`domReferenceElement`)&&t(n,!0)}}),i.addEventListener(`mousemove`,v.handler),v.handler(n)}else v.pointerType===`touch`&&J(e.select(`floatingElement`),n.relatedTarget)||t(n)}}function l(e){J(r,e.relatedTarget)||(v.openChangeTimeout.clear(),v.restTimeout.clear(),v.restTimeoutPending=!1)}let f=m?Yi(r,`mouseout`,l):void 0;return s?Wi(Yi(r,`mousemove`,i,{once:!0}),Yi(r,`mouseenter`,i),Yi(r,`mouseleave`,o),f):Wi(Yi(r,`mouseenter`,i),Yi(r,`mouseleave`,o),f)},[k,A,h,x,e,n,b,v,u,O,E,a,s,S,c,_,C,d,T,D,m]),Z.useMemo(()=>{if(!n)return;function t(e){v.pointerType=e.pointerType}return{onPointerDown:t,onPointerEnter:t,onMouseMove(t){let{nativeEvent:n}=t,r=t.currentTarget,i=e.select(`domReferenceElement`),o=e.select(`open`),s=O(i,r,t.target);if(a&&!bs(v.pointerType))return;if(o&&s&&v.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=v.handleCloseOptions?.getScope?.()??r.ownerDocument.body;ul(v,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=ml(S.current);if(o&&!s||c===0||!s&&v.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;v.restTimeout.clear();function l(){if(v.restTimeoutPending=!1,E())return;let t=e.select(`open`);!v.blockMouseMove&&(!t||s)&&D()&&e.setOpen(!0,No(Io,n,r))}v.pointerType===`touch`?Qo.flushSync(()=>{l()}):s&&o?l():(v.restTimeoutPending=!0,v.restTimeout.start(c,l))}}},[n,v,E,O,a,e,S,D])}function bl(e){return Fo&&e.movementX===0&&e.movementY===0}function xl(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function Sl(e,t){return xl(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Cl(e,t,n){return xl(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function wl(e,t,n){return xl(t,n?e===Pa:e===za,e===Eo)}function Tl(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:xl(t,n?e===za:e===Pa,e===mo)}function El(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,triggerOrientation:_=g,parentOrientation:v,id:y,resetOnPointerLeave:b=!0,externalTree:x,nestedReturnFocusRef:S,grid:C}=t,w=C!=null,T=e.useState(`open`),E=e.useState(`floatingElement`),D=e.useState(`domReferenceElement`),O=e.context.dataRef,k=ba(E),A=co(D),j=Ys(k),M=mc(),ee=hc(x),N=Z.useRef(f),P=Z.useRef(o??-1),te=Z.useRef(null),F=Z.useRef(!0),I=X(e=>{i(P.current===-1?null:P.current,e)}),ne=Z.useRef(!!E),L=Z.useRef(T),re=Z.useRef(!1),ie=Z.useRef(!1),ae=Z.useRef(null),oe=Ys(h),R=Ys(T),z=Ys(o),se=Ys(b),ce=Qi(),B=Qi(),le=X(()=>{ce.cancel();function e(e){d||(ae.current=Qs(e,{sync:re.current,preventScroll:!0}))}let t=n.current[P.current],r=ie.current;t&&e(t),(re.current?e=>e():e=>ce.request(e))(()=>{let i=n.current[P.current]||t;i&&(t||e(i),me&&(r||!F.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});Y(()=>{O.current.orientation=g},[O,g]),Y(()=>{T||(te.current=null),T&&f===`auto`||(N.current=f)},[T,f]),Y(()=>{a&&(T&&E?(P.current=o??-1,N.current&&o!=null&&(ie.current=!0,I())):ne.current&&(P.current=-1,I()))},[a,T,E,o,I]),Y(()=>{if(a){if(!T)re.current=!1;else if(E){if(r==null){if(re.current=!1,z.current!=null)return;if(ne.current&&(P.current=-1,le()),(!L.current||!ne.current)&&N.current&&(te.current!=null||N.current===!0&&te.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>B.request(e):queueMicrotask)(t),e+=1):(P.current=te.current==null||Cl(te.current,_,u)||l?Ji(n):Bi(n),te.current=null,I())};t()}}else va(n.current,r)||(P.current=r,le(),ie.current=!1)}}},[a,T,E,r,z,l,n,_,u,I,le,B]),Y(()=>{if(!a||E||!ee||d||!ne.current)return;let e=ee.nodesRef.current,t=e.find(e=>e.id===M)?.context?.elements.floating,n=Ga(So(D??t??null)),r=e.some(e=>e.context&&J(e.context.elements.floating,n));t&&!r&&F.current&&t.focus({preventScroll:!0})},[a,E,D,ee,M,d]),Y(()=>{L.current=T,ne.current=!!E});let ue=r!=null,de=X(e=>{if(!R.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(P.current!==t||r!==t)&&(P.current=t,I(e))}),fe=X(()=>v??ee?.nodesRef.current.find(e=>e.id===M)?.context?.dataRef?.current.orientation),pe=X(()=>Ji(n,oe.current)),V=X(t=>{if(F.current=!1,re.current=!0,t.which===229||!R.current&&t.currentTarget===j.current)return;if(l&&Tl(t.key,g,u,w)){Sl(t.key,fe())||gs(t),e.setOpen(!1,No(fo,t.nativeEvent));let n=S?.current??D;Lo(n)&&n.focus();return}r!=null&&r!==P.current&&!va(n.current,r)&&(P.current=r);let i=P.current,a=Ji(n,h),o=Bi(n,h);if(A||(t.key===`Home`&&(gs(t),P.current=a,I(t)),t.key===`End`&&(gs(t),P.current=o,I(t))),C!=null){let e=C(t,P.current,n,g,c,u,h,a,o);if(e!=null&&e!==P.current&&(P.current=e,I(t)),g===`both`)return}if(Sl(t.key,g)){gs(t);let e=Ga(t.currentTarget.ownerDocument);if(T&&!d&&J(t.currentTarget,e)&&!n.current.some(t=>t!=null&&J(t,e))){P.current=Cl(t.key,g,u)?a:o,I(t),r===P.current&&le();return}let{index:l,wrapped:f}=ho(n.current,i,{decrement:!Cl(t.key,g,u),loopFocus:c,allowEscape:s,disabledIndices:h,minIndex:a,maxIndex:o});f&&(re.current=!1),P.current=l,I(t)}}),me=Z.useMemo(()=>({onFocus(e){re.current=!0,de(e)},onClick({currentTarget:e}){d||e.focus({preventScroll:!0})},onMouseMove(e){bl(e)||(re.current=!0,ie.current=!1,p&&de(e))},onPointerLeave(e){if(!R.current||!F.current||e.pointerType===`touch`)return;re.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&se.current&&(ae.current?.(),ae.current=null,P.current=-1,I(e),!d)){let e=j.current,t=Ga(So(e));e&&J(e,t)&&e.focus({preventScroll:!0})}}}),[de,R,j,p,n,I,se,d]),H=Z.useMemo(()=>d&&T&&ue&&{"aria-activedescendant":`${y}-${r}`},[d,T,ue,y,r]),he=Z.useMemo(()=>({...A?{}:H,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&T&&!d){let n=ko(t.nativeEvent);if(n&&!J(j.current,n))return;gs(t);let r=No(eo,t.nativeEvent);e.setOpen(!1,r);let i=S?.current??D;!r.isCanceled&&Lo(i)&&i.focus()}else V(t)},onPointerMove(e){bl(e)||(F.current=!0)}}),[H,V,j,A,e,T,d,D,S]),ge=Z.useMemo(()=>{function t(t){e.setOpen(!0,No(fo,t.nativeEvent,t.currentTarget))}function n(e){f===`auto`&&vs(e.nativeEvent)&&(N.current=!d)}function r(e){N.current=f,f===`auto`&&ys(e.nativeEvent)&&(N.current=!0)}return{onKeyDown(n){let r=e.select(`open`);F.current=!1;let i=n.key.startsWith(`Arrow`),a=wl(n.key,fe(),u),o=Sl(n.key,r?g:_),s=(l?a:o)||n.key===`Enter`||n.key.trim()===``;if(d&&r&&(!l||yo(n.currentTarget)))return V(n);if(r||m||!i){if(s){let e=Sl(n.key,fe());te.current=l&&e?null:n.key}l?a&&(gs(n),r?(P.current=pe(),I(n),d&&j.current?.focus()):t(n)):o&&(z.current!=null&&(P.current=z.current),gs(n),!r&&m?t(n):V(n),r&&I(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!d&&(P.current=-1,I(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[V,f,pe,l,I,e,m,g,_,fe,u,z,d,j]),_e=Z.useMemo(()=>({...H,...ge}),[H,ge]);return Z.useMemo(()=>a?{reference:_e,floating:he,item:me,trigger:ge}:{},[a,_e,he,ge,me])}function Dl(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=X(s),f=e.useState(`open`),p=Ii(),m=Z.useRef(``),h=Z.useRef(u??i??-1),g=Z.useRef(null),_=X(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!Ki(n)||n?.matches(`:disabled`)?!1:o==null||!ga(ya,e,o)}function c(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&s(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(gs(e),d?.(!0)),m.current.length>0&&m.current[0]!==` `&&c(_,m.current)===-1&&e.key!==` `&&d?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(gs(e),d?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&s(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,d?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=c(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,d?.(!1)):(a?.(b,e),g.current=b)}),v=X(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);J(r,n)||J(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});Y(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``,d?.(!1)))},[f,u,p,d]);let y=Z.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return Z.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var Ol=.1,kl=Ol*Ol,Al=.5;function jl(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function Ml(e,t,n,r,i,a,o,s,c,l){let u=!1;return jl(e,t,n,r,i,a)&&(u=!u),jl(e,t,i,a,o,s)&&(u=!u),jl(e,t,o,s,c,l)&&(u=!u),jl(e,t,c,l,n,r)&&(u=!u),u}function Nl(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function Pl(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function Fl(e={}){let{blockPointerEvents:t=!1}=e,n=new da,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*kl;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=ko(r),g=r.type===`mouseleave`,_=J(u,h),v=J(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&Oo(r.relatedTarget)&&J(u,r.relatedTarget))return;function y(){return!!(s&&ms(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=Pl(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=Pl(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=Pl(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=Pl(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Nl(d,f,x)||!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?Al/2:Al*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+Al+1,o=C||T?S.bottom-Al:S.top,s=C?T?S.bottom-Al:S.top:S.bottom-Al;M=Ml(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?Al/2:Al*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-Al,o=C||T?S.top+Al:S.bottom,s=C?T?S.top+Al:S.bottom:S.top+Al;M=Ml(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?Al/2:Al*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+Al+1,o=w||E?S.right-Al:S.left,s=w?E?S.right-Al:S.left:S.right-Al;M=Ml(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?Al/2:Al*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-Al,o=w||E?S.left+Al:S.right,s=w?E?S.left+Al:S.right:S.left+Al;M=Ml(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function Il(e,t,n){let{reference:r,floating:i}=e,a=Ps(t),o=Fs(t),s=Ns(o),c=As(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=js(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Ll(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=ks(t,e),p=qs(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Js(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Js(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Rl=50,zl=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Ll},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Il(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Rl&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Il(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Bl=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=ks(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=As(r),_=Ps(o),v=As(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Gs(o)]:Ls(o)),x=p!==`none`;!d&&x&&b.push(...Ws(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Is(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Ps(t)||T.every(e=>Ps(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Ps(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},Vl=new Set([`left`,`top`]);async function Hl(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=As(n),s=js(n),c=Ps(n)===`y`,l=Vl.has(o)?-1:1,u=a&&c?-1:1,d=ks(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Ul=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Hl(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Wl=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=ks(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Ps(i),p=Ms(f),m=u[p],h=u[f],g=(e,t)=>Os(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},Gl=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=ks(e,t),u={x:n,y:r},d=Ps(i),f=Ms(d),p=u[f],m=u[d],h=ks(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Vl.has(As(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Kl=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=ks(e,t),c=await i.detectOverflow(t,s),l=As(n),u=js(n),d=Ps(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Ss(p-c[m],g),y=Ss(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Cs(c.left,c.right):S=p-2*Cs(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function ql(e){let t=Aa(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Lo(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=ws(n)!==a||ws(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Jl(e){return Oo(e)?e:e.contextElement}function Yl(e){let t=Jl(e);if(!Lo(t))return Es(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=ql(t),o=(a?ws(n.width):n.width)/r,s=(a?ws(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var Xl=Es(0);function Zl(e){let t=Va(e);return!ua()||!t.visualViewport?Xl:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ql(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Va(e)}function $l(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Jl(e),o=Es(1);t&&(r?Oo(r)&&(o=Yl(r)):o=Yl(e));let s=Ql(a,n,r)?Zl(a):Es(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Va(a),t=Oo(r)?Va(r):r,n=e,i=Na(n);for(;i&&t!==n;){let e=Yl(i),t=i.getBoundingClientRect(),r=Aa(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Va(i),i=Na(n)}}return Js({width:u,height:d,x:c,y:l})}function eu(e,t){let n=po(e).scrollLeft;return t?t.left+n:$l(To(e)).left+n}function tu(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-eu(e,n),y:n.top+t.scrollTop}}function nu(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=To(r),s=t?jo(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Es(1),u=Es(0),d=Lo(r);if((d||!a)&&((Ra(r)!==`body`||Po(o))&&(c=po(r)),d)){let e=$l(r);l=Yl(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?tu(o,c):Es(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function ru(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function iu(e){let t=po(e),n=e.ownerDocument.body,r=Cs(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Cs(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+eu(e),o=-t.scrollTop;return Aa(n).direction===`rtl`&&(a+=Cs(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var au=25;function ou(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Va(e),a=To(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!ua()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(eu(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=au&&(s-=o)}return{width:s,height:c,x:l,y:u}}function su(e,t){let n=$l(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Yl(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function cu(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=ou(e,n,t);else if(t===`document`)r=iu(To(e));else if(Oo(t))r=su(t,n);else{let n=Zl(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Js(r)}function lu(e,t){let n=t.get(e);if(n)return n;let r=io(e,[],!1).filter(e=>Oo(e)&&Ra(e)!==`body`),i=null,a=Aa(e).position===`fixed`,o=a?Wa(e):e;for(;Oo(o)&&!Da(o);){let e=Aa(o),t=Ca(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Wa(o)}return t.set(e,r),r}function uu(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?jo(t)?[]:lu(t,this._c):[].concat(n),r],o=cu(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=cu(t,a[e],i);s=Cs(n.top,s),c=Ss(n.right,c),l=Ss(n.bottom,l),u=Cs(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function du(e){let{width:t,height:n}=ql(e);return{width:t,height:n}}function fu(e,t,n){let r=Lo(t),i=To(t),a=n===`fixed`,o=$l(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Es(0);if((r||!a)&&((Ra(t)!==`body`||Po(i))&&(s=po(t)),r)){let e=$l(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=eu(i));let l=i&&!r&&!a?tu(i,s):Es(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function pu(e){return Aa(e).position===`static`}function mu(e,t){if(!Lo(e)||Aa(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return To(e)===n&&(n=n.ownerDocument.body),n}function hu(e,t){let n=Va(e);if(jo(e))return n;if(!Lo(e)){let t=Wa(e);for(;t&&!Da(t);){if(Oo(t)&&!pu(t))return t;t=Wa(t)}return n}let r=mu(e,t);for(;r&&ki(r)&&pu(r);)r=mu(r,t);return r&&Da(r)&&pu(r)&&!Ca(r)?n:r||to(e)||n}var gu=async function(e){let t=this.getOffsetParent||hu,n=this.getDimensions,r=await n(e.floating);return{reference:fu(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function _u(e){return Aa(e).direction===`rtl`}var vu={convertOffsetParentRelativeRectToViewportRelativeRect:nu,getDocumentElement:To,getClippingRect:uu,getOffsetParent:hu,getElementRects:gu,getClientRects:ru,getDimensions:du,getScale:Yl,isElement:Oo,isRTL:_u};function yu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function bu(e,t,n){let r=null,i,a=To(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Ts(d),h=Ts(a.clientWidth-(u+f)),g=Ts(a.clientHeight-(d+p)),_=Ts(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Cs(0,Ss(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!yu(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Va(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function xu(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Jl(e),u=i||a?[...l?io(l):[],...t?io(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?bu(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?$l(e):null;c&&g();function g(){let t=$l(e);h&&!yu(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Su=Ul,Cu=Wl,wu=Bl,Tu=Kl,Eu=Gl,Du=(e,t,n)=>{let r=new Map,i=n??{},a={...vu,...i.platform,_c:r};return zl(e,t,{...i,platform:a})},Ou=typeof document<`u`?Z.useLayoutEffect:function(){};function ku(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ku(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!ku(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Au(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ju(e,t){let n=Au(e);return Math.round(t*n)/n}function Mu(e){let t=Z.useRef(e);return Ou(()=>{t.current=e}),t}function Nu(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=Z.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=Z.useState(r);ku(f,r)||p(r);let[m,h]=Z.useState(null),[g,_]=Z.useState(null),v=Z.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=Z.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=Z.useRef(null),C=Z.useRef(null),w=Z.useRef(u),T=c!=null,E=Mu(c),D=Mu(i),O=Mu(l),k=Z.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Du(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!ku(w.current,t)&&(w.current=t,Qo.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);Ou(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=Z.useRef(!1);Ou(()=>(A.current=!0,()=>{A.current=!1}),[]),Ou(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=Z.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=Z.useMemo(()=>({reference:b,floating:x}),[b,x]),ee=Z.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=ju(M.floating,u.x),r=ju(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Au(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return Z.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:ee}),[u,k,j,M,ee])}var Pu=(e,t)=>{let n=Su(e);return{name:n.name,fn:n.fn,options:[e,t]}},Fu=(e,t)=>{let n=Cu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Iu=(e,t)=>({fn:Eu(e).fn,options:[e,t]}),Lu=(e,t)=>{let n=wu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ru=(e,t)=>{let n=Tu(e);return{name:n.name,fn:n.fn,options:[e,t]}};function zu(e){let{nodeId:t,externalTree:n,rootContext:r}=e,i=r.useState(`referenceElement`),a=r.useState(`floatingElement`),o=r.useState(`domReferenceElement`),s=r.useState(`open`),c=r.useState(`floatingId`),[l,u]=Z.useState(null),d=Z.useRef(null),f=hc(n),p=Z.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=Nu({...e,elements:{...p,...l&&{reference:l}}}),h=Z.useCallback(e=>{let t=Oo(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=Z.useMemo(()=>({...m.refs,setPositionReference:h,domReference:d}),[m.refs,h]),_=Z.useMemo(()=>({...m.elements,domReference:o}),[m.elements,o]),v=Z.useMemo(()=>({...m,dataRef:r.context.dataRef,open:s,onOpenChange:r.setOpen,events:r.context.events,floatingId:c,refs:g,elements:_,nodeId:t,rootStore:r}),[m,g,_,t,r,s,c]);return Y(()=>{o&&(d.current=o)},[o]),Y(()=>{r.context.dataRef.current.floatingContext=v;let e=f?.nodesRef.current.find(e=>e.id===t);e&&(e.context=v)}),Z.useMemo(()=>({...m,context:v,refs:g,elements:_,rootStore:r}),[m,g,_,v,r])}var Bu=Z.createContext(void 0);function Vu(){return Z.useContext(Bu)?.direction??`ltr`}var Hu=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=ks(e,t)||{};if(l==null)return{};let d=qs(u),f={x:n,y:r},p=Fs(i),m=Ns(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=s.floating[y]||a.floating[m],C=b/2-x/2,w=S/2-h[m]/2-1,T=Math.min(d[_],w),E=Math.min(d[v],w),D=T,O=S-h[m]-E,k=S/2-h[m]/2+C,A=Os(D,k,O),j=!c.arrow&&js(i)!=null&&k!==A&&a.reference[m]/2-(k<D?T:E)-h[m]/2<0,M=j?k<D?k-D:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Uu=(e,t)=>{let{name:n,fn:r}=Hu(e);return{name:n,fn:r,options:[e,t]}},Wu={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},Gu={sideX:`left`,sideY:`top`},Ku=`--available-width`,qu=`--available-height`,Ju=`--anchor-width`,Yu=`--anchor-height`,Xu=`--transform-origin`,Zu=Ku,Qu=qu;function $u(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function ed(e,t,n){let{rects:r,placement:i}=e;return{side:$u(t,As(i),n),align:js(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function td(e){return nd(e,zu)}function nd(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,C=_.side||`flip`,w=_.align||`flip`,T=_.fallbackAxisSide||`end`,E=v?.crossAxis??!1,D=v?.rootBoundary,O=typeof n==`function`?n:void 0,k=X(O),A=O?k:n,j=Ys(n),M=Ys(g),ee=Vu()===`rtl`,[N,P]=Z.useState(null);!g&&N!==null&&P(null);let te=x===`placement`,F=N?As(N):null,I=N&&te?js(N)||`center`:null,ne=F||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":ee?`left`:`right`,"inline-start":ee?`right`:`left`}[i],L=I||o,re=L===`center`?ne:`${ne}-${L}`,ie=l;typeof ie==`number`?ie={top:ie,right:ie,bottom:ie,left:ie}:ie&&={top:ie.top||0,right:ie.right||0,bottom:ie.bottom||0,left:ie.left||0};let ae=+(i===`bottom`),oe=+(i===`top`),R=+(i===`right`),z=+(i===`left`),se={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:ie},ce=Z.useRef(null),B=Ys(a),le=Ys(s),ue=typeof a==`function`?0:a,de=typeof s==`function`?0:s,fe=[];p&&fe.push(p),fe.push(Pu(e=>{let t=ed(e,i,ee),n=typeof B.current==`function`?B.current(t):B.current,r=typeof le.current==`function`?le.current(t):le.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[ue,de,ee,i]));let pe=w===`none`&&C!==`shift`,V=!pe&&(u||E||C===`shift`),me=C===`none`?null:Lu({...se,padding:{top:ie.top+1+ae,right:ie.right+1+z,bottom:ie.bottom+1+oe,left:ie.left+1+R},mainAxis:!E&&C===`flip`,crossAxis:w===`flip`&&`alignment`,fallbackAxisSideDirection:T}),H=pe?null:Fu({...se,rootBoundary:D,mainAxis:w!==`none`,crossAxis:V,limiter:u||E?void 0:Iu(e=>{if(!ce.current)return{};let{width:t,height:n}=ce.current.getBoundingClientRect(),r=Ps(As(e.placement)),i=r===`y`?t:n,a=r===`y`?ie.left+ie.right:ie.top+ie.bottom;return{offset:i/2+a/2}})},[se,u,E,D,ie,w]);C===`shift`||w===`shift`||L===`center`?fe.push(H,me):fe.push(me,H),fe.push(Ru({...se,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!M.current)return;let i=e.style;i.setProperty(Zu,`${t}px`),i.setProperty(Qu,`${n}px`);let a=Va(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(Ju,`${u}px`),i.setProperty(Yu,`${d}px`)}}),Uu(e=>({element:ce.current||So(e.elements.floating).createElement(`div`),padding:ce.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=As(r),u=js(r),d=Ps(l)===`y`,f=ce.current,p=typeof a==`function`?a(ed(e,i,ee)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return V&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(Xu,d?`${m} ${h}`:`${h} ${m}`),{}}},Wu,b),Y(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let he=Z.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:ge,elements:_e,x:ve,y:ye,middlewareData:be,update:xe,placement:Se,context:Ce,isPositioned:we,floatingStyles:Te}=t({rootContext:h,open:m?g:void 0,placement:re,middleware:fe,strategy:r,whileElementsMounted:m?void 0:(...e)=>xu(...e,he),nodeId:y,externalTree:S}),{sideX:Ee,sideY:De}=be.adaptiveOrigin||Gu,Oe=we?r:`fixed`,ke=Z.useMemo(()=>{let e;return e=we?b?{position:Oe,[Ee]:ve,[De]:ye}:{...Te,position:Oe}:{position:Oe,top:0,left:0},e[Zu]=`100vw`,e[Qu]=`100vh`,we||(e.opacity=0),e},[b,Oe,Ee,ve,De,ye,Te,we]),Ae=Z.useRef(null);Y(()=>{if(!g)return;let e=j.current,t=typeof e==`function`?e():e,n=(rd(t)?t.current:t)||null;n!==Ae.current&&(ge.setPositionReference(n),Ae.current=n)},[g,ge,A,j]),Z.useEffect(()=>{if(!g)return;let e=j.current;typeof e!=`function`&&rd(e)&&e.current!==Ae.current&&(ge.setPositionReference(e.current),Ae.current=e.current)},[g,ge,A,j]),Z.useEffect(()=>{if(m&&g&&_e.reference&&_e.floating)return xu(_e.reference,_e.floating,xe,he)},[m,g,_e,xe,he]);let je=As(Se),Me=$u(i,je,ee),Ne=js(Se)||`center`,Pe=!!be.hide?.referenceHidden;Y(()=>{x&&g&&we&&(je!==ne||te&&Ne!==L)&&P(Se)},[x,te,g,we,Se,je,Ne,ne,L]);let Fe=Z.useMemo(()=>({position:`absolute`,top:be.arrow?.y,left:be.arrow?.x}),[be.arrow]),Ie=be.arrow?.centerOffset!==0;return Z.useMemo(()=>({positionerStyles:ke,arrowStyles:Fe,arrowRef:ce,arrowUncentered:Ie,side:Me,align:Ne,physicalSide:je,anchorHidden:Pe,refs:ge,context:Ce,isPositioned:we,update:xe}),[ke,Fe,ce,Ie,Me,Ne,je,Pe,ge,Ce,we,xe])}function rd(e){return e!=null&&`current`in e}function id(e){return e===`starting`?Pi:_a}function ad(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),qi(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},id(r),i],stateAttributesMapping:fs})}var od=e(xi(),1);function sd(e){let t=od.unstable_scheduleCallback(4,e);return()=>od.unstable_cancelCallback(t)}var cd=Z.createContext(Le({scheduleTask:sd,defaultIdleTTL:400})),ld=new WeakMap,ud=0,dd=new Set;function fd(e){ud++;try{return e()}finally{ud--}}function pd(e){if(ud===0)return e();dd.size===0&&queueMicrotask(md),dd.add(e)}function md(){for(let e of dd)dd.delete(e),e()}function hd(e,t){let n=ld.get(e);n===void 0&&(n=new WeakMap,ld.set(e,n));let r=n.get(t);if(r!==void 0)return r;let i=0,a,o={subscribe(n){i++;let r=e.subscribe(t,()=>pd(n));return()=>{i--,dd.delete(n),r()}},snapshot(){return fd(()=>e.get(t))},getServerSnapshot(){return(i===0||a===void 0)&&(a={value:fd(()=>ei(t,e))}),a.value}};return n.set(t,o),o}function gd(e,t){let n=hd(e,t);return Z.useEffect(md),Z.useSyncExternalStore(n.subscribe,n.snapshot,n.getServerSnapshot)}function _d(e,t,n){let r=hd(e,t),i=Z.useMemo(()=>{let e;return t=>(e!==void 0&&Object.is(e.source,t)||(e={source:t,value:n(t)}),e.value)},[n]);return Z.useEffect(md),Z.useSyncExternalStore(r.subscribe,()=>i(r.snapshot()),()=>i(r.getServerSnapshot()))}var vd=(e,t)=>{let n=Z.useContext(cd);return t?_d(n,e,t):gd(n,e)};function yd(e,t){Z.useEffect(()=>e.mount(t),[t,e])}function bd(e,t,n){return n?.mode===`promise`||n?.mode===`promiseExit`?Z.useCallback(r=>{e.set(t,r);let i=ri(ke(e,t,{suspendOnWaiting:!0}));return n.mode===`promise`?i.then(xd):i},[e,t,n.mode]):Z.useCallback(n=>{e.set(t,typeof n==`function`?n(e.get(t)):n)},[e,t])}var xd=e=>{if(Rn(e))return e.value;throw he(e.cause)},Sd=e=>{yd(Z.useContext(cd),e)},Cd=(e,t)=>{let n=Z.useContext(cd);return yd(n,e),bd(n,e,t)},wd=(e,t)=>{let n=Z.useContext(cd);return[gd(n,e),bd(n,e,t)]},Td={suspendOnWaiting:new WeakMap,default:new WeakMap};function Ed(e,t,n){let r=n?Td.suspendOnWaiting:Td.default,i=r.get(e);i===void 0&&(i=new WeakMap,r.set(e,i));let a=i.get(t);return a===void 0&&(a=new Promise(r=>{let a=e.subscribe(t,e=>{e._tag===`Initial`||n&&e.waiting||(setTimeout(a,1e3),r(),i.delete(t))})}),i.set(t,a)),a}function Dd(e,t,n){let r=gd(e,t);if(r._tag===`Initial`||n&&r.waiting)throw Ed(e,t,n);return r}var Od=(e,t)=>{let n=Dd(Z.useContext(cd),e,t?.suspendOnWaiting??!1);if(n._tag===`Failure`&&!t?.includeFailure)throw he(n.cause);return n};vr(`MachineSchemaEncodeError`);var kd=class extends vr(`MachineSchemaDecodeError`){},Ad=class extends vr(`InfiniteTransitionError`){},jd=class extends vr(`StartupError`){},Md=class extends vr(`ChildAlreadyExistsError`){};vr(`ProcessLocalError`);var Nd=class extends vr(`StoppedError`){},Pd=e=>e instanceof Ad||e instanceof kd,Fd=e=>Pd(e)?wr(e):mn(e),Id=e=>Pd(e)||e instanceof jd?e:new jd({cause:se(e)}),Ld=e=>e,Rd=`~effect/Machine/Target`,zd=Symbol(`effect/Machine/TargetSnapshot`),Bd=Symbol(`effect/Machine/StateInput`),Vd=Symbol(`effect/Machine/HistoryTarget`),Hd=Symbol(`effect/Machine/InitialTarget`),Ud=Symbol(`effect/Machine/ChoiceTarget`),Wd=Symbol(`effect/Machine/NoTarget`),Gd=Symbol(`effect/Machine/Declined`),Kd=Symbol(`effect/Machine/TargetSelection`),qd=Symbol(`effect/Machine/StateUpdate`),Jd=Symbol(`effect/Machine/CombinedTarget`),Yd=Symbol(`effect/Machine/SelectedBranch`),Xd=(e,t,n,r)=>Object.freeze({[Kd]:Kd,kind:e,scope:n,path:t,...r===void 0?{}:{updatePath:r}}),Zd=Xd(`none`,void 0,`local`),Qd=e=>H(e,Kd),$d=(e,t)=>Object.freeze({[qd]:qd,path:e,value:t}),ef=e=>H(e,qd),tf=(e,t)=>Object.freeze({[Jd]:Jd,target:e,update:t}),nf=e=>H(e,Jd),rf=(e,t,n,r)=>Object.freeze({[Yd]:Yd,owner:e,branchIndex:t,branchKey:n,result:r}),af=e=>H(e,Yd),of=Object.freeze({[Wd]:Wd}),sf=()=>of,cf=e=>H(e,Wd),lf=Object.freeze({[Gd]:Gd}),uf=()=>lf,df=e=>H(e,Gd),ff=(e,t)=>({[Vd]:Vd,path:e,parent:t}),pf=e=>H(e,Vd),mf=(e,t,n)=>({[Hd]:Hd,_tag:`InitialTarget`,path:e,value:t,...n===void 0?{}:{values:n}}),hf=e=>H(e,Hd),gf=(e,t,n)=>({[Ud]:Ud,path:e,parent:t,...n===void 0?{}:{values:n}}),_f=e=>H(e,Ud),vf=(e,t)=>{if(!mt(t)&&t.type===`history`)return{schema:void 0,output:void 0,annotations:t.annotations,type:`history`,history:t.history===`deep`?`deep`:`shallow`,initial:void 0,states:void 0};if(!mt(t)&&t.type===`choice`)return{schema:void 0,output:void 0,annotations:t.annotations,type:`choice`,history:void 0,initial:void 0,states:void 0};if(mt(t))return{schema:t,output:void 0,annotations:Pt(t),type:`atomic`,history:void 0,initial:void 0,states:void 0};let n=H(t,`schema`)&&mt(t.schema)?t.schema:void 0,r=n===void 0?t.annotations:Pt(n);if(t.type===`parallel`&&!H(t,`states`))throw Error(`Machine.make expected parallel state "${e}" to declare child regions`);if(H(t,`states`)){if(t.type===`final`)throw Error(`Machine.make expected compound state "${e}" to be active`);if(t.type===`parallel`)return{schema:n,output:mt(t.output)?t.output:void 0,annotations:r,type:`parallel`,history:void 0,initial:void 0,states:t.states};let i=`initial`in t?t.initial:void 0;if(typeof i!=`string`)throw Error(`Machine.make expected compound state "${e}" to declare an initial child`);return{schema:n,output:void 0,annotations:r,type:`compound`,history:void 0,initial:i,states:t.states}}let i=mt(t.output)?t.output:void 0;return t.type===`final`?{schema:n,output:i,annotations:r,type:`final`,history:void 0,initial:void 0,states:void 0}:{schema:n,output:void 0,annotations:r,type:`atomic`,history:void 0,initial:void 0,states:void 0}},yf=e=>{let t=new Map,n=0,r=(e,i)=>{let a=[];for(let o of Object.keys(e)){if(o.includes(`.`))throw Error(`Machine state keys cannot contain ".": "${o}"`);let s=i===void 0||i===``?o:`${i}.${o}`,c=vf(s,e[o]),l,u,d={path:s,key:o,annotations:c.annotations,order:n};switch(c.type){case`atomic`:l={...d,type:`atomic`,schema:c.schema,output:void 0,history:void 0,parent:i,children:[],initial:void 0};break;case`compound`:l={...d,type:`compound`,schema:c.schema,output:void 0,history:void 0,parent:i,children:[],initial:s===``?c.initial:`${s}.${c.initial}`},u=c.states;break;case`parallel`:l={...d,type:`parallel`,schema:c.schema,output:c.output,history:void 0,parent:i,children:[],initial:void 0},u=c.states;break;case`final`:l={...d,type:`final`,schema:c.schema,output:c.output,history:void 0,parent:i,children:[],initial:void 0};break;case`history`:if(i===void 0)throw Error(`Machine history state "${s}" must belong to a parent state`);l={...d,type:`history`,schema:void 0,output:void 0,history:c.history,parent:i,children:[],initial:void 0};break;case`choice`:if(i===void 0)throw Error(`Machine choice state "${s}" must belong to a parent state`);l={...d,type:`choice`,schema:void 0,output:void 0,history:void 0,parent:i,children:[],initial:void 0}}if(t.set(s,l),n+=1,c.type!==`history`&&c.type!==`choice`&&(a.push(s),u!==void 0)){let e=r(u,s);if(l.type===`compound`){if(!e.includes(l.initial)&&t.get(l.initial)?.type!==`choice`)throw Error(`Machine.make expected compound state "${s}" initial child to exist`);l={...l,children:e}}else if(l.type===`parallel`)l={...l,children:e};else throw Error(`Machine state "${s}" cannot declare child states`);t.set(s,l)}}return a};return{byPath:t,roots:r(e,void 0)}},bf=e=>typeof e==`object`&&e&&`branches`in e&&Array.isArray(e.branches)?Array.from(e.branches):[],xf=e=>typeof e==`object`&&e&&`declinable`in e&&e.declinable===!0?`declinable`:`required`,Sf=e=>{let t=[];for(let n of e.stateNodes.byPath.values()){let r=Ld(e).handlers[n.path];if(r===void 0)continue;if(n.type===`choice`){let e=r.choice;e!==void 0&&t.push({source:n.path,trigger:{type:`choice`},reenter:!1,acceptance:`required`,branches:bf(e)});continue}for(let e of Reflect.ownKeys(r.on??{})){let i=r.on?.[e];t.push({source:n.path,trigger:{type:`event`,event:e},reenter:H(i,`reenter`)&&i.reenter===!0,acceptance:xf(i),branches:bf(i)})}r.always!==void 0&&t.push({source:n.path,trigger:{type:`always`},reenter:!1,acceptance:xf(r.always),branches:bf(r.always)}),r.onDone!==void 0&&t.push({source:n.path,trigger:{type:`done`},reenter:!1,acceptance:xf(r.onDone),branches:bf(r.onDone)});let i=r.invoke===void 0?[]:Array.isArray(r.invoke)?r.invoke:[r.invoke];for(let e of i){let r=`child`in e?String(e.child.id):String(e.id);for(let i of[`element`,`done`,`failure`,`snapshot`]){let a=i===`element`?e.onElement:i===`done`?e.onDone:i===`failure`?e.onFailure:e.onSnapshot;a!==void 0&&t.push({source:n.path,trigger:{type:`invoke`,id:r,outcome:i},reenter:typeof a==`object`&&!!a&&a.reenter===!0,acceptance:xf(a),branches:bf(a)})}}}return t},Cf=(e,t,n)=>({[Rd]:Rd,[zd]:n?.snapshot,path:e,value:t,values:n?.values}),wf=e=>H(e,Rd),Tf=e=>({[Bd]:Bd,input:e}),Ef=e=>H(e,Bd),Df=e=>H(e,`path`)&&H(e,`value`),Of=(e,t,n)=>{if(e.path===t)return qe(e);if(e.path!==``&&!t.startsWith(`${e.path}.`))return z();if(n!==void 0&&e.value!==void 0&&(n[e.path]=e.value),H(e,`state`)&&Df(e.state))return Of(e.state,t,n);if(H(e,`states`)&&typeof e.states==`object`&&e.states!==null){for(let r of Object.values(e.states))if(Df(r)){let e=Of(r,t,n);if(we(e))return e}}return z()},$=(e,t)=>{let n=e.stateNodes.byPath.get(t);if(n===void 0)throw Error(`Machine expected state path "${t}" to exist`);return n},kf=e=>{if(e.schema===void 0)throw Error(`Machine state "${e.path}" has no value schema`);return e.schema},Af=new WeakMap,jf=Symbol(`effect/Machine/EventConstruction`),Mf=new WeakMap,Nf=new WeakMap,Pf=new WeakMap,Ff=e=>{let t=e,n=Nf.get(t);if(n!==void 0)return n;let r=F(Rt(e));return Nf.set(t,r),r},If=e=>{let t=e,n=Pf.get(t);if(n!==void 0)return n;let r=le(Rt(e));return Pf.set(t,r),r},Lf=Symbol.for(`effect/Machine/protocol`),Rf=e=>{let t=e[Lf];if(t===void 0)throw Error(`Machine protocol is unavailable`);return t},zf=(e,t)=>{Object.defineProperty(e,Lf,{value:t,enumerable:!1})},Bf=e=>{let t=new Set,n=e=>{let r=e;if(!t.has(r)&&(t.add(r),H(e,`cases`)&&typeof e.cases==`object`&&e.cases!==null))for(let t of Object.values(e.cases))(typeof t==`object`&&t||typeof t==`function`)&&H(t,`make`)&&n(t)};for(let t of e)n(t);return t},Vf=(e,t)=>{let n=Af.get(e);if(n===void 0)throw Error(`Machine expected an event protocol created with Machine.events, Machine.internalEvents, or Machine.emittedEvents`);if(t!==void 0&&n.kind!==t)throw Error(`Machine expected a ${t} event protocol`);return n},Hf=e=>Vf(e.events,`public`).schemas,Uf=e=>Vf(e.internalEvents,`internal`).schemas,Wf=e=>Vf(e.emittedEvents,`emitted`).schemas,Gf=e=>{let t=Hf(e),n=Uf(e),r=Wf(e),i=new Set(Reflect.ownKeys(e.events));for(let t of Reflect.ownKeys(e.internalEvents))if(i.has(t))throw Error(`Public and internal machine event tags must be disjoint: ${String(t)}`);let a=[...t,...n];zf(e,{event:Ne(a),emit:Ne(r),eventConstructors:Bf(a),emissionConstructors:Bf(r)})},Kf=(e,t)=>zf(t,Rf(e)),qf=e=>H(e,`_tag`)?String(e._tag):void 0,Jf=(e,t,n,r)=>{let i=r,a;if(typeof r==`object`&&r)try{i={...r}}catch(e){i=void 0,a=e}let o={[jf]:jf,_tag:n};return Mf.set(o,{kind:e,schema:t,input:i,...a===void 0?{}:{inputError:a}}),Object.freeze(o)},Yf=e=>typeof e==`object`&&!!e&&Mf.has(e),Xf=(e,t)=>{let n=[],r=e=>{if(H(e,`cases`)&&typeof e.cases==`object`&&e.cases!==null)for(let t of Reflect.ownKeys(e.cases))r(Reflect.get(e.cases,t));else if(H(e,`members`)&&Array.isArray(e.members))for(let t of e.members)r(t);else n.push(e)};for(let e of t)r(e);let i=Object.create(null),o=e=>fn(e)?typeof e.literal==`string`||typeof e.literal==`number`?[e.literal]:[]:Jn(e)?[e.symbol]:a(e)?e.enums.map(([,e])=>e):tn(e)?e.types.flatMap(o):qt(e)?o(e.thunk()):[],s=e=>{let t=Br(e.ast);if(ar(t)){let e=t.propertySignatures.find(({name:e})=>e===`_tag`),n=e===void 0?[]:o(e.type);if(n.length>0)return n}try{return Ne([e]).pipe(kt(`_tag`)).discriminants}catch{return[]}};for(let t of n){let n=s(t);if(n.length!==0)for(let r of n){if(H(i,r))throw Error(`Duplicate machine event constructor tag: ${String(r)}`);Object.defineProperty(i,r,{value:(...n)=>Jf(e,t,r,n.length===0?{}:n[0]),enumerable:!0})}}return i},Zf=(e,t)=>{let n=Object.freeze(Array.from(t)),r=Xf(e,n);return Af.set(r,{kind:e,schemas:n}),Object.freeze(r)},Qf=(e,t,n,r)=>Ff(t)(n).pipe(er(t=>new kd({machineId:e.id,boundary:r.boundary,cause:t,...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}}))),$f=(e,t,n,r)=>{let i=If(t)(n);if(Qe(i))throw new kd({machineId:e.id,boundary:r.boundary,cause:i.failure,...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}});return i.success},ep=(e,t,n,r)=>{try{return t.make(n)}catch(t){let n=t instanceof Error?t.cause:void 0;throw new kd({machineId:e.id,boundary:r.boundary,cause:Tt(t)?t:H(n,`~effect/SchemaIssue/Issue`)?new E(n):se(t),...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}})}},tp=(e,t,n)=>new kd({machineId:e.id,boundary:n,event:String(t._tag),cause:se(Error(`Constructed ${n} schema does not belong to the machine ${n} protocol`))}),np=(e,t)=>{if(t.inputError!==void 0)throw t.inputError;return typeof t.input==`object`&&t.input!==null?{...t.input,_tag:e._tag}:{_tag:e._tag}},rp=(e,t,n,r)=>new kd({machineId:e.id,boundary:n,event:String(t._tag),cause:se(r)}),ip=(e,t,n,r)=>{let i=Mf.get(n),a=r===`event`?t.eventConstructors:t.emissionConstructors;return i===void 0||(r===`emission`?i.kind!==`emitted`:i.kind===`emitted`)||!a.has(i.schema)?wr(tp(e,n,r)):Me({try:()=>np(n,i),catch:t=>rp(e,n,r,t)}).pipe(G(t=>i.schema.makeEffect(t).pipe(er(t=>new kd({machineId:e.id,boundary:r,event:String(n._tag),cause:new E(t)})))))},ap=(e,t,n,r)=>{let i=Mf.get(n),a=r===`event`?t.eventConstructors:t.emissionConstructors;if(i===void 0||(r===`emission`?i.kind!==`emitted`:i.kind===`emitted`)||!a.has(i.schema))throw tp(e,n,r);let o;try{o=np(n,i)}catch(t){throw rp(e,n,r,t)}return ep(e,i.schema,o,{boundary:r,event:String(n._tag)})},op=(e,t)=>{let n=Rf(e);if(Yf(t))return ip(e,n,t,`event`);let r=qf(t);return Qf(e,n.event,t,r===void 0?{boundary:`event`}:{boundary:`event`,event:r})},sp=(e,t)=>{let n=Rf(e);if(Yf(t))return ap(e,n,t,`event`);let r=qf(t);return $f(e,n.event,t,r===void 0?{boundary:`event`}:{boundary:`event`,event:r})},cp=(e,t)=>{let n=Rf(e);if(Yf(t))return ip(e,n,t,`emission`);let r=qf(t);return Qf(e,n.emit,t,r===void 0?{boundary:`emission`}:{boundary:`emission`,event:r})},lp=(e,t)=>{let n=Rf(e);if(Yf(t))return ap(e,n,t,`emission`);let r=qf(t);return $f(e,n.emit,t,r===void 0?{boundary:`emission`}:{boundary:`emission`,event:r})},up=(e,t,n)=>$f(e,t,n,{boundary:`input`}),dp=(e,t,n)=>Ef(n)?kf(t).makeEffect(n.input).pipe(er(n=>new kd({machineId:e.id,boundary:`state`,state:t.path,cause:new E(n)}))):Qf(e,kf(t),n,{boundary:`state`,state:t.path}),fp=(e,t,n)=>Ef(n)?ep(e,kf(t),n.input,{boundary:`state`,state:t.path}):$f(e,kf(t),n,{boundary:`state`,state:t.path}),pp=(e,t,n)=>t.output===void 0?T(n):Qf(e,t.output,n,{boundary:`output`,state:t.path}),mp=(e,t,n)=>t.output===void 0?n:$f(e,t.output,n,{boundary:`output`,state:t.path}),hp=(e,t)=>{let n=new Set(Tp(e,t.parent)),r=n=>{let i=$(e,n);if(i.type===`compound`){let e=i.children.filter(e=>t.active.has(e));if(e.length!==1)throw Error(`Machine history expected compound state "${n}" to retain one active child`);t.mode===`deep`&&r(e[0])}else if(i.type===`parallel`)for(let e of i.children){if(!t.active.has(e))throw Error(`Machine history expected parallel state "${n}" to retain region "${e}"`);t.mode===`deep`&&r(e)}};r(t.parent);for(let r of t.active){if(!n.has(r)&&!wp(r,t.parent))throw Error(`Machine history contains state "${r}" outside parent "${t.parent}"`);if(t.mode===`shallow`&&Cp(r,t.parent)&&$(e,r).parent!==t.parent)throw Error(`Machine shallow history contains deep descendant "${r}"`)}},gp=(e,t)=>{let n=new Map;for(let[r,i]of Object.entries(t.history??{})){let t=$(e,r);if(t.type!==`history`||t.parent===void 0||t.history!==i.mode)throw Error(`Machine snapshot contains invalid history record "${r}"`);let a=new Set,o=new Map;for(let n of i.active){if(a.has(n))throw Error(`Machine snapshot contains invalid remembered state "${n}"`);let r=$(e,n);if(r.type===`history`||r.type===`choice`||!(wp(n,t.parent)||Tp(e,t.parent).includes(n)))throw Error(`Machine snapshot contains invalid remembered value for "${n}"`);a.add(n);let s=Object.prototype.hasOwnProperty.call(i.values,n);if(r.schema===void 0){if(s)throw Error(`Machine snapshot contains a value for structural state "${n}"`)}else{if(!s)throw Error(`Machine snapshot omits remembered value for "${n}"`);o.set(n,fp(e,r,i.values[n]))}}if(!a.has(t.parent)||Object.keys(i.values).length!==o.size)throw Error(`Machine snapshot contains incomplete history record "${r}"`);n.set(r,{mode:i.mode,parent:t.parent,active:a,values:o}),hp(e,n.get(r))}return n},_p=dr(function*(e,t){let n=new Map;for(let[r,i]of Object.entries(t.history??{})){let t=e.stateNodes.byPath.get(r);if(t===void 0||t.type!==`history`||t.parent===void 0||t.history!==i.mode)return yield*wr(new kd({machineId:e.id,boundary:`history`,state:r,cause:se(Error(`Machine snapshot contains invalid history record "${r}"`))}));let a=new Set,o=new Map;for(let n of i.active){let r=e.stateNodes.byPath.get(n);if(a.has(n)||r===void 0||r.type===`history`||r.type===`choice`||!(wp(n,t.parent)||Tp(e,t.parent).includes(n)))return yield*wr(new kd({machineId:e.id,boundary:`history`,state:n,cause:se(Error(`Machine snapshot contains invalid remembered state "${n}"`))}));a.add(n);let s=Object.prototype.hasOwnProperty.call(i.values,n);if(r.schema===void 0){if(s)return yield*wr(new kd({machineId:e.id,boundary:`history`,state:n,cause:se(Error(`Machine snapshot contains a value for structural state "${n}"`))}))}else{if(!s)return yield*wr(new kd({machineId:e.id,boundary:`history`,state:n,cause:se(Error(`Machine snapshot omits remembered value for "${n}"`))}));o.set(n,yield*Qf(e,kf(r),i.values[n],{boundary:`history`,state:n}))}}if(!a.has(t.parent)||Object.keys(i.values).length!==o.size)return yield*wr(new kd({machineId:e.id,boundary:`history`,state:r,cause:se(Error(`Machine snapshot contains incomplete history record "${r}"`))}));n.set(r,{mode:i.mode,parent:t.parent,active:a,values:o});try{hp(e,n.get(r))}catch(t){return yield*wr(new kd({machineId:e.id,boundary:`history`,state:r,cause:se(t)}))}}return n}),vp=(e,t)=>{let n={};for(let[r,i]of t){let t=Array.from(i.active).sort((t,n)=>Dp(e,t,n));n[r]={mode:i.mode,active:t,values:Object.fromEntries(i.values)}}return n},yp=(e,t)=>({...e,machineReferences:{self:t.self,parent:t.parent}}),bp=e=>e.machineReferences,xp=new WeakMap,Sp=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Cp=(e,t)=>e!==t&&(t===``||e.startsWith(`${t}.`)),wp=(e,t)=>e===t||Cp(e,t),Tp=(e,t)=>{let n=xp.get(e.stateNodes);n===void 0&&(n=new Map,xp.set(e.stateNodes,n));let r=n.get(t);if(r!==void 0)return r;let i=[],a=t;for(;a!==void 0;)i.unshift(a),a=$(e,a).parent;return n.set(t,i),i},Ep=(e,t)=>Tp(e,t).length,Dp=(e,t,n)=>$(e,t).order-$(e,n).order,Op=(e,t,n)=>$(e,n).children.some(e=>t.active.has(e)),kp=(e,t)=>{let n=Array.from(t.active).filter(n=>!Op(e,t,n)).sort((t,n)=>Dp(e,t,n));if(n.length===0)throw Error(`Machine expected an active leaf state`);return n},Ap=(e,t)=>kp(e,t)[0],jp=(e,t,n)=>{let r=kp(e,t).filter(e=>wp(e,n));if(r.length===0)throw Error(`Machine expected state "${n}" to have an active leaf state`);return r[0]},Mp=(e,t)=>{for(let n of t.active)if($(e,n).parent===void 0)return n;throw Error(`Machine expected an active root state`)},Np=(e,t,n)=>{let r={},i=Tp(e,n);for(let e=0;e<i.length-1;e++){let n=i[e];t.values.has(n)&&(r[n]=t.values.get(n))}return r},Pp=(e,t,n)=>{let r=$(e,n).parent;return r===void 0?void 0:t.values.get(r)},Fp=(e,t)=>{let n=r=>t.active.has(r)?[r,...$(e,r).children.flatMap(n)]:[];return e.stateNodes.roots.flatMap(n)},Ip=(e,t,n)=>{let r=$(e,n),i={path:n,value:t.values.get(n)};if(r.type===`compound`){let a=r.children.find(e=>t.active.has(e));if(a===void 0)throw Error(`Machine expected compound state "${n}" to have an active child`);i.state=Ip(e,t,a)}if(r.type===`parallel`){let a={};for(let i of r.children){if(!t.active.has(i))throw Error(`Machine expected parallel state "${n}" to have active child region "${i}"`);let r=$(e,i);a[r.key]=Ip(e,t,i)}i.states=a}return i},Lp=(e,t)=>{let n=Ip(e,t,Mp(e,t)),r=Array.from(t.outputs).map(([e,t])=>({path:e,output:t}));return r.length>0&&(n.completed=r),t.history.size>0&&Object.assign(n,{history:vp(e,t.history)}),n},Rp=(e,t,n)=>{let r=Ip(e,t,n);return t.history.size>0&&Object.assign(r,{history:vp(e,t.history)}),r},zp=(e,t,n)=>{if(!H(n,`state`)||!Df(n.state))throw Error(`Machine expected compound snapshot "${t.path}" to include an active child state`);let r=$(e,String(n.state.path));if(r.parent!==t.path)throw Error(`Machine expected snapshot "${r.path}" to be a child of "${t.path}"`);return n.state},Bp=(e,t)=>{if(!H(t,`states`)||typeof t.states!=`object`||t.states===null)throw Error(`Machine expected parallel snapshot "${e.path}" to include active child regions`);return t.states},Vp=(e,t,n,r)=>{let i=$(e,n),a=r[i.key];if(!Sp(r,i.key)||!Df(a))throw Error(`Machine expected parallel snapshot "${t.path}" to include region "${i.key}"`);let o=$(e,String(a.path));if(o.path!==i.path)throw Error(`Machine expected snapshot "${o.path}" to be region "${i.path}"`);return a},Hp=(e,t)=>{let n=new Set,r=new Map,i=t.completed,a=t=>{let i=$(e,String(t.path));if(n.add(i.path),i.schema===void 0){if(t.value!==void 0)throw Error(`Machine structural snapshot "${i.path}" cannot contain a value`)}else r.set(i.path,fp(e,i,t.value));if(i.type===`compound`&&a(zp(e,i,t)),i.type===`parallel`){let n=Bp(i,t);for(let t of i.children)a(Vp(e,i,t,n))}};a(t);let o=new Map;if(i!==void 0)for(let{output:e,path:t}of i)n.has(t)&&o.set(t,e);return{active:n,values:r,outputs:o,history:gp(e,t)}},Up=(e,t)=>Hp(e,t),Wp=(e,t)=>{try{return Hp(e,t)}catch(t){throw t instanceof kd?t:new kd({machineId:e.id,boundary:`configuration`,cause:se(t)})}},Gp=dr(function*(e,t){let n=new Set,r=new Map,i=t.completed,a=dr(function*(t){let i=$(e,String(t.path));if(n.add(i.path),i.schema===void 0){if(t.value!==void 0)throw Error(`Machine structural snapshot "${i.path}" cannot contain a value`)}else r.set(i.path,yield*dp(e,i,t.value));if(i.type===`compound`&&(yield*a(zp(e,i,t))),i.type===`parallel`){let n=Bp(i,t);for(let t of i.children)yield*a(Vp(e,i,t,n))}});yield*a(t);let o=new Map;if(i!==void 0)for(let{output:e,path:t}of i)n.has(t)&&o.set(t,e);return{active:n,values:r,outputs:o,history:yield*_p(e,t)}}),Kp=(e,t)=>Gp(e,t).pipe(Dt(t=>{if(pi(t))return Fn(Ct(t,t=>t instanceof kd?t:new kd({machineId:e.id,boundary:`configuration`,cause:be(t)})));let n=Je(t);return we(n)&&n.value instanceof kd?wr(n.value):wr(new kd({machineId:e.id,boundary:`configuration`,cause:t}))})),qp=(e,t,n,r)=>{if(r.length===0)return n;let i=new Set(r),a=new Map(n.history);for(let n of e.stateNodes.byPath.values()){if(n.type!==`history`||n.parent===void 0||!i.has(n.parent))continue;let r=n.history===`deep`?`deep`:`shallow`,o=new Set;for(let r of Tp(e,n.parent))t.active.has(r)&&o.add(r);for(let i of t.active)(i===n.parent||r===`deep`&&Cp(i,n.parent)||r===`shallow`&&$(e,i).parent===n.parent)&&o.add(i);let s=new Map;for(let e of o)t.values.has(e)&&s.set(e,t.values.get(e));a.set(n.path,{mode:r,parent:n.parent,active:o,values:s})}return{active:n.active,values:n.values,outputs:n.outputs,history:a}},Jp=(e,t)=>e.history.get(t),Yp=(e,t,n)=>{let r=new Set(n.active),i=new Map(n.values),a=new Map,o=Tp(e,n.parent),s=new Set(o);for(let c of o){let o=$(e,c);if(o.type===`parallel`){for(let e of o.children)if(!(s.has(e)||n.active.has(e)||!t.active.has(e)))for(let n of t.active)wp(n,e)&&(r.add(n),t.values.has(n)&&i.set(n,t.values.get(n)),t.outputs.has(n)&&a.set(n,t.outputs.get(n)))}}return{active:r,values:i,outputs:a,history:t.history}};dr(function*(e,t,n,r,i){let a=$(e,n),o=new Set,s=new Map,c=new Map,l=Tp(e,a.path),u=new Set(l);for(let n of l){let c=$(e,n);if(o.add(n),c.schema===void 0){if((n===a.path?r:i!==void 0&&Sp(i,n)?i[n]:void 0)!==void 0)throw Error(`Machine structural target "${n}" cannot contain a value`)}else if(n===a.path)s.set(n,yield*dp(e,c,r));else if(i!==void 0&&Sp(i,n))s.set(n,yield*dp(e,c,i[n]));else if(t.values.has(n))s.set(n,t.values.get(n));else throw Error(`Machine target "${a.path}" requires a value for ancestor state "${n}"`)}for(let n of l){let r=$(e,n);if(r.type===`parallel`){for(let e of r.children)if(!u.has(e)&&t.active.has(e))for(let n of t.active)wp(n,e)&&(o.add(n),t.values.has(n)&&s.set(n,t.values.get(n)),t.outputs.has(n)&&c.set(n,t.outputs.get(n)))}}if(a.type===`compound`||a.type===`parallel`)throw Error(`Machine target "${a.path}" must include an active child state`);return{active:o,values:s,outputs:c,history:t.history}}),dr(function*(e,t,n,r){let i=yield*Gp(e,n),a=new Set(i.active),o=new Map(i.values),s=new Map(i.outputs),c=Tp(e,String(n.path)),l=new Set(c);for(let i of c.slice(0,-1)){let s=$(e,i);if(a.add(i),s.schema===void 0){if(r!==void 0&&Sp(r,i))throw Error(`Machine structural target "${i}" cannot contain a value`)}else if(r!==void 0&&Sp(r,i))o.set(i,yield*dp(e,s,r[i]));else if(t.values.has(i))o.set(i,t.values.get(i));else throw Error(`Machine target "${n.path}" requires a value for ancestor state "${i}"`)}for(let n of c.slice(0,-1)){let i=$(e,n);if(i.type===`parallel`){for(let n of i.children)if(!l.has(n)){if(t.active.has(n))for(let e of t.active)wp(e,n)&&(a.add(e),t.values.has(e)&&o.set(e,t.values.get(e)),t.outputs.has(e)&&s.set(e,t.outputs.get(e)));else if(r!==void 0&&Sp(r,n))for(let[t,i]of Object.entries(r)){if(!wp(t,n))continue;let r=$(e,t);if(a.add(t),r.schema===void 0)throw Error(`Machine structural target "${t}" cannot contain a value`);o.set(t,yield*dp(e,r,i))}}}}return{active:a,values:o,outputs:s,history:new Map([...t.history,...i.history])}});var Xp=(e,t,n,r,i,a=!1)=>{let o=$(e,n),s=new Set,c=new Map,l=new Map,u=Tp(e,o.path),d=new Set(u);for(let n of u){let a=$(e,n);if(s.add(n),a.schema===void 0){if((n===o.path?r:i!==void 0&&Sp(i,n)?i[n]:void 0)!==void 0)throw Error(`Machine structural target "${n}" cannot contain a value`)}else if(n===o.path)c.set(n,fp(e,a,r));else if(i!==void 0&&Sp(i,n))c.set(n,fp(e,a,i[n]));else if(t.values.has(n))c.set(n,t.values.get(n));else throw Error(`Machine target "${o.path}" requires a value for ancestor state "${n}"`)}for(let n of u){let r=$(e,n);if(r.type===`parallel`&&n!==o.path){for(let e of r.children)if(!d.has(e)&&t.active.has(e))for(let n of t.active)wp(n,e)&&(s.add(n),t.values.has(n)&&c.set(n,t.values.get(n)),t.outputs.has(n)&&l.set(n,t.outputs.get(n)))}}if(!a&&(o.type===`compound`||o.type===`parallel`))throw Error(`Machine target "${o.path}" must include an active child state`);return{active:s,values:c,outputs:l,history:t.history}},Zp=(e,t,n)=>{let r=Xp(e,t,n.path,n.value,n.values,!0);if(n.children===void 0)return r;let i=new Set(r.active),a=new Map(r.values);for(let[t,r]of n.children){let n=$(e,t);i.add(t),n.schema!==void 0&&a.set(t,fp(e,n,r))}return{...r,active:i,values:a}},Qp=(e,t,n,r)=>{let i=Hp(e,n),a=new Set(i.active),o=new Map(i.values),s=new Map(i.outputs),c=Tp(e,String(n.path)),l=new Set(c);for(let i of c.slice(0,-1)){let s=$(e,i);if(a.add(i),s.schema===void 0){if(r!==void 0&&Sp(r,i))throw Error(`Machine structural target "${i}" cannot contain a value`)}else if(r!==void 0&&Sp(r,i))o.set(i,fp(e,s,r[i]));else if(t.values.has(i))o.set(i,t.values.get(i));else throw Error(`Machine target "${n.path}" requires a value for ancestor state "${i}"`)}for(let n of c.slice(0,-1)){let i=$(e,n);if(i.type===`parallel`){for(let n of i.children)if(!l.has(n)){if(t.active.has(n))for(let e of t.active)wp(e,n)&&(a.add(e),t.values.has(e)&&o.set(e,t.values.get(e)),t.outputs.has(e)&&s.set(e,t.outputs.get(e)));else if(r!==void 0&&Sp(r,n))for(let[t,i]of Object.entries(r)){if(!wp(t,n))continue;let r=$(e,t);if(a.add(t),r.schema===void 0)throw Error(`Machine structural target "${t}" cannot contain a value`);o.set(t,fp(e,r,i))}}}}return{active:a,values:o,outputs:s,history:new Map([...t.history,...i.history])}},$p=(e,t,n)=>{if(wf(n)){let r=n[zd];if(r!==void 0){if(String(r.path)!==String(n.path))throw Error(`Machine expected target snapshot path to be "${n.path}"`);return Qp(e,t,r,n.values)}return Xp(e,t,n.path,n.value,n.values)}if(Df(n)){let r=Wp(e,n);return{...r,history:new Map([...t.history,...r.history])}}throw Error(`Machine expected transition target to be a snapshot or target builder result`)},em=(e,t)=>Ld(e).handlers[t],tm=(e,t,n)=>$(e,n).children.find(e=>t.active.has(e)),nm=(e,t)=>$(e,t).type===`final`,rm=(e,t)=>em(e,t)?.onDone!==void 0,im=(e,t,n)=>{if(!t.active.has(n))return!1;let r=$(e,n);if(r.type===`compound`){let r=tm(e,t,n);return r!==void 0&&(n===``?!rm(e,r)&&im(e,t,r):nm(e,r))}if(r.type===`parallel`){for(let n of r.children)if(!im(e,t,n))return!1;return!0}return nm(e,n)},am=(e,t)=>{let n=Mp(e,t);return im(e,t,n)&&!rm(e,n)},om=(e,t,n)=>e.has(t)?{path:t,output:e.get(t),isNew:!1}:(e.set(t,n),{path:t,output:n,isNew:!0}),sm=dr(function*(e,t,n,r,i){let a=$(e,n),o=em(e,n)?.output?.({state:t.values.get(n),containingState:Pp(e,t,n),ancestors:Np(e,t,n),event:r,outputs:i});return yield*pp(e,a,o)}),cm=dr(function*(e,t,n,r,i,a){if(!t.active.has(n))return;if(i.has(n))return{path:n,output:i.get(n),isNew:!1};let o=$(e,n);if(o.type===`compound`){let o=tm(e,t,n);if(o===void 0||(n===``?rm(e,o):!nm(e,o)))return;let s=yield*cm(e,t,o,r,i,a);if(s===void 0)return;let c=om(i,n,s.output);return c.isNew&&a.push(c),c}if(o.type===`parallel`){let s={},c=!0;for(let n of o.children){let o=yield*cm(e,t,n,r,i,a);o===void 0?c=!1:s[$(e,n).key]=o.output}if(!c)return;let l=om(i,n,yield*sm(e,t,n,r,s));return l.isNew&&a.push(l),l}if(!nm(e,n))return;let s=om(i,n,yield*sm(e,t,n,r));return s.isNew&&a.push(s),s}),lm=dr(function*(e,t,n){let r=new Map(t.outputs),i=[],a={active:t.active,values:t.values,outputs:r,history:t.history};for(let t of Array.from(a.active).sort((t,n)=>{let r=Ep(e,n)-Ep(e,t);return r===0?Dp(e,t,n):r}))yield*cm(e,a,t,n,r,i);return{configuration:a,completions:i}}),um=(e,t,n,r,i)=>{let a=$(e,n),o=em(e,n)?.output?.({state:t.values.get(n),containingState:Pp(e,t,n),ancestors:Np(e,t,n),event:r,outputs:i});return mp(e,a,o)},dm=(e,t,n,r,i,a)=>{if(!t.active.has(n))return;if(i.has(n))return{path:n,output:i.get(n),isNew:!1};let o=$(e,n);if(o.type===`compound`){let o=tm(e,t,n);if(o===void 0||(n===``?rm(e,o):!nm(e,o)))return;let s=dm(e,t,o,r,i,a);if(s===void 0)return;let c=om(i,n,s.output);return c.isNew&&a.push(c),c}if(o.type===`parallel`){let s={},c=!0;for(let n of o.children){let o=dm(e,t,n,r,i,a);o===void 0?c=!1:s[$(e,n).key]=o.output}if(!c)return;let l=om(i,n,um(e,t,n,r,s));return l.isNew&&a.push(l),l}if(!nm(e,n))return;let s=om(i,n,um(e,t,n,r));return s.isNew&&a.push(s),s},fm=(e,t,n)=>{let r=new Map(t.outputs),i=[],a={active:t.active,values:t.values,outputs:r,history:t.history};for(let t of Array.from(a.active).sort((t,n)=>{let r=Ep(e,n)-Ep(e,t);return r===0?Dp(e,t,n):r}))dm(e,a,t,n,r,i);return{configuration:a,completions:i}},pm=e=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine construction must be an object`);return e},mm=(e,t)=>{if(t.decoded!==void 0&&typeof t.decoded!=`boolean`)throw Error(`Machine decoded construction flag must be a boolean`);if(e.schema===void 0){if(Object.hasOwn(t,`data`)||Object.hasOwn(t,`decoded`))throw Error(`Machine structural state "${e.path}" cannot construct data`)}else{if(t.decoded===!0){if(!Object.hasOwn(t,`data`))throw Error(`Machine decoded construction requires data`);return t.data}return Tf(Object.hasOwn(t,`data`)?t.data:{})}},hm=(e,t,n={},r)=>{let i=e.byPath.get(t);if(i?.type===`atomic`||i?.type===`final`){let e=pm(n);if(Reflect.ownKeys(e).some(e=>e!==`data`&&e!==`decoded`))throw Error(`Machine leaf construction accepts only data and decoded`);return Cf(t,mm(i,e))}let a=new Map,o=(t,n)=>{let i=pm(n);if(Reflect.ownKeys(i).some(e=>e!==`data`&&e!==`decoded`&&e!==`states`))throw Error(`Machine state construction accepts only data, decoded, and states`);let s=e.byPath.get(t);if(s===void 0||s.type===`history`)throw Error(`Machine invalid construction state "${t}"`);let c=mm(s,i);if(Object.hasOwn(i,`states`)){if(s.type!==`compound`&&s.type!==`parallel`)throw Error(`Machine state "${t}" has no child construction`);let n=pm(i.states),c=Reflect.ownKeys(n),l=s.children.filter(t=>e.byPath.get(t)?.type!==`history`);if(s.type===`compound`?c.length!==1:c.length!==l.length&&(c.length!==1||r===void 0||r!==t&&!r.startsWith(`${t}.`)))throw Error(`Machine explicit states for "${t}" must select ${s.type===`compound`?`one child`:`every region`}`);for(let r of c){let i=t===``?String(r):`${t}.${String(r)}`;if(typeof r!=`string`||e.byPath.get(i)?.parent!==t||e.byPath.get(i)?.type===`history`)throw Error(`Machine unknown child "${String(r)}"`);a.set(i,o(i,n[r]))}}return c},s=o(t,n),c=new Map(a);c.set(t,s);let l=t,u=pm(n);for(;u.states!==void 0;){let t=e.byPath.get(l),n=pm(u.states),i=Object.keys(n);if(i.length!==1||t.type===`parallel`&&(r===void 0||r!==l&&!r.startsWith(`${l}.`)))break;let a=i[0];l=l===``?a:`${l}.${a}`,u=pm(n[a])}let d=e.byPath.get(l),f=c.get(l),p=Object.fromEntries([...c].filter(([e,t])=>t!==void 0&&e!==l&&!e.startsWith(`${l}.`)));if(d.type===`choice`)return gf(l,d.parent??``,p);if(d.type===`atomic`||d.type===`final`)return Cf(l,f,{values:p});let m=new Map([...a].filter(([e])=>e.startsWith(`${l}.`)));return{...mf(l,f,p),...m.size===0?{}:{children:m}}},gm=(e,t,n)=>{let r=pm(n);if(Reflect.ownKeys(r).some(e=>e!==`data`&&e!==`decoded`))throw Error(`Machine update construction accepts only data and decoded`);let i=e.byPath.get(t);if(i?.schema===void 0)throw Error(`Machine update requires a valued state`);return $d(t,mm(i,r))},_m=(e,t,n=``)=>{let r=pm(t),i=e.byPath.get(n);hm(e,n,r);let a=mm(i,r);if(i.type===`choice`)return gf(n,i.parent);if(i.type===`atomic`||i.type===`final`)return{path:n,value:a};if(r.states===void 0)throw Error(`Machine history fallback requires a complete explicit tree`);let o=pm(r.states),s=Object.fromEntries(Object.entries(o).map(([t,r])=>[t,_m(e,r,n===``?t:`${n}.${t}`)]));return i.type===`parallel`?{path:n,value:a,states:s}:{path:n,value:a,state:Object.values(s)[0]}},vm=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(t);return e},ym=`root`,bm=e=>{let t=new Map,n=(e,r)=>{let i=!mt(e)&&`type`in e?e.type:void 0;if(t.set(r,i===`history`||i===`choice`?i:`state`),!mt(e)&&`states`in e)for(let[t,i]of Object.entries(e.states))n(i,r===``?t:`${r}.${t}`)};if(n(e.node,``),t.has(`root`))throw Error(`Machine top-level state name "${ym}" is reserved for the root`);return t},xm=(e,t)=>{let n=bm(e),r=t.input!==void 0,i=new Map;for(let e of[`effects`,`streams`,`timers`,`logic`,`children`])if(t[e]!==void 0)for(let[n,r]of Object.entries(vm(t[e],`Machine ${e} must be a source map`))){if(i.has(n))throw Error(`Machine source name "${n}" is registered more than once`);i.set(n,Object.freeze({kind:e,value:r}))}let a=new Map;if(t.branches!==void 0)for(let[o,s]of Object.entries(vm(t.branches,`Machine branches must be a map`))){let t=vm(s,`Machine branches "${o}" must be a branch record`);for(let e of Reflect.ownKeys(t)){if(typeof e!=`string`)throw Error(`Machine branches cannot use symbol keys`);if(e.length===0||String(Number(e))===e)throw Error(`Machine branches require non-index string branch keys`)}let c=Object.entries(t);if(c.length===0)throw Error(`Machine branches "${o}" requires a branch`);a.set(o,Object.freeze(Object.fromEntries(c.map(([t,s])=>{let c={...vm(s,`Machine branch "${o}.${t}" must be a declaration`)};for(let e of Reflect.ownKeys(c))if(typeof e!=`string`||![`target`,`update`,`history`,`none`,`initialize`,`title`].includes(e))throw Error(`Machine branch "${o}.${t}" contains an unknown declaration field`);if(c.initialize!==void 0&&c.initialize!==!0)throw Error(`Machine branch "${o}.${t}" declares initialize: true; its resolver supplies input`);if(c.title!==void 0&&(typeof c.title!=`string`||c.title.length===0))throw Error(`Machine branch title must be a non-empty string`);return Cm({root:e,input:r,paths:n,sources:i,branches:a},c),[t,Object.freeze(c)]}))))}return{root:e,input:r,paths:n,sources:i,branches:a}},Sm=(e,t)=>{let n=e===`root`?``:typeof e==`string`&&e!==``?e:void 0,r=n===void 0?void 0:t.paths.get(n);if(n===void 0||r===void 0)throw Error(`Machine target ${String(e)} is not a declared state path`);return{path:n,kind:r}},Cm=(e,t)=>{let n=[`target`,`history`,`none`,`initialize`].filter(e=>t[e]!==void 0);if(n.length===0&&t.update!==void 0){let n=Sm(t.update,e);if(n.kind!==`state`)throw Error(`Machine update requires an active state reference`);return Xd(`update`,n.path,`branch`)}if(n.length!==1)throw Error(`Machine transition must declare exactly one destination operation`);let r=n[0];if(r===`none`){if(t.none!==!0||t.update!==void 0)throw Error(`Machine targetless transition requires none: true`);return Zd}if(r===`initialize`){if(t.update!==void 0)throw Error(`Machine initialize cannot update a retained owner`);return Xd(`state`,``,`branch`)}let i=Sm(t[r],e);if(r===`target`&&i.path===``)throw Error(`Machine root is not a destination; use initialize to reconstruct it from machine input`);if(r===`history`!=(i.kind===`history`))throw Error(`Machine history references require a history transition`);let a=t.update===void 0?void 0:Sm(t.update,e).path;if(a!==void 0&&r!==`target`)throw Error(`Machine owner updates require an ordinary destination`);return Xd(i.kind,i.path,r===`history`?`full`:`branch`,a)},wm=(e,t,n,r)=>{let i=vm(t,`Machine invocation for "${n}" must be an object`),a=typeof i.src==`string`?e.sources.get(i.src):void 0;if(a===void 0)throw Error(`Machine invocation for "${n}" names an unknown source`);let{src:o,input:s,...c}=i,l=typeof s==`function`?e=>s(r(e)):s;if(a.kind===`children`)return{...c,child:a.value,...l===void 0?{}:{input:l}};let u=typeof a.value==`function`&&!(a.kind===`effects`&&yn(a.value))&&!(a.kind===`streams`&&et(a.value));if(u!==(typeof l==`function`))throw Error(`Machine invocation "${o}" requires input exactly when its source takes an argument`);let d=u?e=>a.value(l(e)):()=>a.value,f={effects:`effect`,streams:`stream`,timers:`after`,logic:`logic`}[a.kind];return{...c,sourceName:o,id:c.id??o,[f]:!u&&(a.kind===`timers`||a.kind===`logic`)?a.value:d}},Tm=Symbol(`effect/Machine/InitialEvent`),Em=Symbol(`effect/Machine/SnapshotBuilderState`),Dm=Symbol(`effect/Machine/ChildMachineLogic`),Om=new WeakSet,km=e=>Om.has(e),Am=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine ${t} must be an object`);return e},jm=e=>typeof e==`function`?e:()=>e,Mm=e=>{if(typeof e==`object`&&e&&H(e,`decoded`)&&e.decoded===!0&&H(e,`data`)){let t=Am(e,`decoded construction`);if(Reflect.ownKeys(t).some(e=>e!==`decoded`&&e!==`data`))throw Error(`Machine decoded construction accepts only decoded and data`);return jm(t.data)}let t=jm(e);return n=>Tf(e===void 0?{}:t(n))},Nm=e=>{if(e.decoded!==void 0&&typeof e.decoded!=`boolean`)throw Error(`Machine decoded construction flag must be a boolean`);if(e.decoded===!0){if(!H(e,`data`))throw Error(`Machine decoded construction requires data`);return jm(e.data)}let t=jm(e.data);return n=>Tf(H(e,`data`)?t(n):{})},Pm=(e,t)=>{let n=(e,t,r)=>{if(H(t,`initialize`))throw Error(`Machine child construction belongs in initial declarations`);if(r!==``&&H(t,`root`))throw Error(`Machine root construction belongs at the root handler`);let{initial:i,root:a,states:o,...s}=t;if(mt(e)||!(`states`in e)){if(i!==void 0)throw Error(`Machine state "${r}" cannot declare initial children`);if(o!==void 0)throw Error(`Machine state "${r}" has no children`);return{node:e,handlers:s}}let c=o===void 0?{}:Am(o,`child handlers`);for(let t of Object.keys(c))if(!Object.prototype.hasOwnProperty.call(e.states,t))throw Error(`Machine unknown child "${t}"`);let l=Object.create(null),u=Object.create(null),d=Object.create(null),f=e.type===`parallel`,p;if(f){let t=i===void 0?{}:Am(i,`parallel initial regions`);for(let[n,r]of Object.entries(t)){let t=e.states[n];if(t===void 0||!mt(t)&&(t.type===`history`||t.type===`choice`))throw Error(`Machine invalid initial region "${n}"`);if(!mt(t)&&(!(`schema`in t)||t.schema===void 0))throw Error(`Machine schema-less region "${n}" cannot construct data`);d[n]=Mm(r)}}else{let t=Am(i,`initial edge for "${r}"`);if(Reflect.ownKeys(t).some(e=>![`target`,`data`,`decoded`].includes(String(e))))throw Error(`Machine initial edge accepts only target, data, and decoded`);let n=r===``?``:`${r}.`,a=typeof t.target==`string`&&t.target.startsWith(n)?t.target.slice(n.length):void 0,o=a===void 0||!Object.hasOwn(e.states,a)?void 0:e.states[a],s=o===void 0||mt(o)?`state`:o.type;if(a===void 0||o===void 0||s===`history`)throw Error(`Machine initial target must be a direct child of "${r===``?`root`:r}"`);if(p=a,s===`choice`&&(H(t,`data`)||H(t,`decoded`)))throw Error(`Machine choice initial edges cannot construct data`);let c=Nm(t),l=e.states[a];if(H(t,`data`)&&!mt(l)&&(!(`schema`in l)||l.schema===void 0))throw Error(`Machine schema-less initial child "${a}" cannot construct data`);H(t,`data`)&&(d[a]=c)}for(let[t,i]of Object.entries(e.states)){let e=r===``?t:`${r}.${t}`,a=n(i,c[t]===void 0?{}:Am(c[t],`state handler`),e);l[t]=a.node,(mt(i)||i.type!==`history`)&&(c[t]!==void 0||!mt(i)&&`states`in i)&&(u[t]=a.handlers)}let m=Object.freeze({...e,states:Object.freeze(l),...f?{}:{initial:p}}),h=Object.entries(d),g=e=>{let t=typeof e.ancestors==`object`&&e.ancestors!==null?e.ancestors:{},n={...e,root:r===``?e.state:t[``]},i=Object.fromEntries(h.map(([e,t])=>[e,t(n)]));return{[Em]:i}};return Om.add(g),{node:m,handlers:{...s,...h.length===0?{}:{initialize:g},states:u}}};return n(e.node,t,``)},Fm=(e,t)=>{let n=[`effect`,`stream`,`after`,`logic`,`child`].filter(t=>t in e);if(n.length!==1)throw Error(`Machine invocation for state "${t}" must define exactly one source`);if(n[0]!==`child`&&typeof e.id!=`string`)throw Error(`Machine invocation for state "${t}" requires a string id`);if((n[0]===`effect`||n[0]===`stream`)&&typeof e[n[0]]!=`function`)throw Error(`Machine invocation for state "${t}" requires a source callback`);return Object.freeze(e)},Im=e=>`child`in e?e.child.id:e.id,Lm=(e,t)=>{let n=new Set;for(let r of e){let e=Im(r);if(n.has(e))throw Error(`Machine invocations for state "${t}" must have distinct ids; "${e}" is declared twice`);n.add(e)}},Rm=e=>e===void 0?[]:Array.isArray(e)?e:[e],zm=e=>{let t=[],n=[],r=[];return{commands:t,raisedEvents:n,emittedEvents:r,enqueue:{raise:t=>{n.push(sp(e,t))},emit:t=>{r.push(lp(e,t))},sendTo:(e,n)=>{t.push({_tag:`SendTo`,target:e,event:n})},stop:e=>{t.push({_tag:`Stop`,child:e})}}}},Bm=(e,t)=>{let n=e.stateNodes.byPath.get(t);if(n===void 0)throw Error(`Machine expected state path "${t}" to exist`);return n},Vm=e=>{let t={};return Object.defineProperty(t,"decoded",{value:e,enumerable:!1}),Object.defineProperty(t,"from",{value:(...t)=>e(Tf(t.length===0?{}:t[0])),enumerable:!1}),t},Hm=e=>{let t={};return Object.defineProperty(t,Em,{value:e,enumerable:!1}),t},Um=(e,t,n)=>{let r=Hm(n);for(let i of t.children){let a=Bm(e,i);a.schema===void 0||H(n,a.key)||(r[a.key]=Vm(r=>{let i=Object.assign({},n);return i[a.key]=r,Um(e,t,i)}))}return r},Wm=(e,t)=>{let n=Bm(e,t);if(n.type===`parallel`)return Um(e,n,{});if(n.type!==`compound`)throw Error(`Machine state "${t}" cannot initialize child states`);let r=Bm(e,n.initial);if(r.schema===void 0)throw Error(`Machine state "${t}" has no schema-valued initial child`);return Vm(e=>Hm({[r.key]:e}))},Gm=(e,t)=>{if(typeof t!=`object`||!t||!H(t,Em))throw Error(`Machine initialize handler for "${e}" must return its builder result`);return t[Em]},Km=Symbol(`effect/Machine/InvocationEvent`),qm=(e,t,n)=>({[Km]:!0,path:e,id:t,type:`done`,output:n}),Jm=(e,t,n)=>({[Km]:!0,path:e,id:t,type:`element`,element:n}),Ym=(e,t,n)=>({[Km]:!0,path:e,id:t,type:`failure`,error:n}),Xm=(e,t,n)=>({[Km]:!0,path:e,id:t,type:`snapshot`,snapshot:n}),Zm=e=>typeof e==`object`&&!!e&&Km in e,Qm=new WeakMap,$m=new WeakMap,eh=(e,t)=>e.parent===void 0?{self:t.self}:{self:t.self,parent:t.parent},th=(e,t)=>{let n=Object.create(e);return $m.set(n,eh(e,t)),n},nh=(e,t)=>{let n=t.machineReferences;if(n!==void 0)return eh(e,n);let r=$m.get(e);if(r!==void 0)return r;let i=Qm.get(e);if(i!==void 0)return i;let a=eh(e,{self:{id:e.id??`Machine`,sessionId:`Machine.plan`,send:()=>wr(new Nd)},parent:void 0});return Qm.set(e,a),a},rh=e=>{if(e!==void 0)return typeof e==`function`?{reenter:!1,declinable:!1,targets:void 0,transition:e,evaluate:void 0}:{reenter:e.reenter===!0,declinable:e.declinable===!0,targets:e.targets,transition:e.transition,evaluate:e.evaluate}},ih=(e,t,n)=>{let r=zm(e);return t===void 0||t(n,r.enqueue),{commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents}},ah=(e,t,n,r)=>{let i=zm(e),a=r===void 0?{result:t(n,i.enqueue),branchIndex:0,branchKey:void 0}:r(n,i.enqueue);return df(a.result)?{declined:!0}:{declined:!1,state:cf(a.result)?void 0:a.result,branchIndex:a.branchIndex,branchKey:a.branchKey,commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents}},oh=(e,t,n)=>{let r=zm(e);return{value:t(n,r.enqueue),commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents}},sh=(e,t,n,r)=>{let i=new Set(t.active),a=new Map(t.values),o=[],s=[],c=[],l=[],u=!0;for(;u;){u=!1;for(let d of Array.from(i).sort((t,n)=>Dp(e,t,n))){let f=$(e,d);if(f.type===`compound`&&!f.children.some(e=>i.has(e))){if(f.initial===void 0)throw Error(`Machine shallow history expected compound state "${d}" to have an initial child`);let p=$(e,f.initial),m={active:i,values:a,outputs:t.outputs,history:t.history,machineReferences:t.machineReferences};if(p.type===`choice`){let t=Lh(e,m,gf(p.path,d,Object.fromEntries(a)),n),r=m;for(let i of[t.target,...t.additionalTargets]){if(i===void 0)throw Error(`Machine initial choice "${p.path}" must resolve to an active state target`);let t=hf(i)?lh(e,r,i,n):pf(i)?uh(e,r,i,n):void 0;r=$p(e,r,t?.target??i),t!==void 0&&(o.push(...t.commands),s.push(...t.raisedEvents),c.push(...t.emittedEvents),l.push(...t.transitions))}i.clear(),a.clear();for(let e of r.active)i.add(e);for(let[e,t]of r.values)a.set(e,t);o.push(...t.commands),s.push(...t.raisedEvents),c.push(...t.emittedEvents),l.push(...t.transitions),u=!0;continue}if(i.add(p.path),p.schema!==void 0){let t=Ld(e).handlers[d]?.initialize;if(t===void 0){a.set(p.path,fp(e,p,Tf({}))),u=!0;continue}let i=oh(e,t,{...nh(e,m),state:m.values.get(d),containingState:Pp(e,m,d),ancestors:Np(e,m,d),event:n,...d===``&&r!==void 0?{input:r.value}:{},...km(t)?{}:{builder:Wm(e,d)}}),l=Gm(d,i.value);a.set(p.path,fp(e,p,l[p.key])),o.push(...i.commands),s.push(...i.raisedEvents),c.push(...i.emittedEvents)}u=!0}if(f.type===`parallel`){let l=f.children.filter(e=>!i.has(e));if(l.length>0){let f=l.filter(t=>$(e,t).schema!==void 0),p={active:i,values:a,outputs:t.outputs,history:t.history,machineReferences:t.machineReferences},m=f.length===0?void 0:Ld(e).handlers[d]?.initialize,h=m===void 0?void 0:oh(e,m,{...nh(e,p),state:p.values.get(d),containingState:Pp(e,p,d),ancestors:Np(e,p,d),event:n,...d===``&&r!==void 0?{input:r.value}:{},...km(m)?{}:{builder:Wm(e,d)}}),g=h===void 0?void 0:Gm(d,h.value);for(let t of l){let n=$(e,t);if(i.add(n.path),n.schema!==void 0){if(h===void 0){a.set(n.path,fp(e,n,Tf({})));continue}if(g===void 0||!Object.prototype.hasOwnProperty.call(g,n.key)){if(m!==void 0&&km(m)){a.set(n.path,fp(e,n,Tf({})));continue}throw Error(`Machine parallel state initializer for "${d}" must return region "${n.key}"`)}a.set(n.path,fp(e,n,g[n.key]))}}h!==void 0&&(o.push(...h.commands),s.push(...h.raisedEvents),c.push(...h.emittedEvents)),u=!0}}}}return{configuration:{active:i,values:a,outputs:new Map,history:t.history},commands:o,raisedEvents:s,emittedEvents:c,transitions:l}};function ch(e,t,n,r){let i=Zp(e,t,n);if(n.children===void 0||![...n.children.keys()].some(t=>$(e,t).type===`choice`))return sh(e,i,r,n.input);let a=[],o=[],s=[],c=[];for(let t of n.children?.keys()??[]){let n=$(e,t);if(n.type!==`choice`)continue;let l=Lh(e,i,gf(t,n.parent),r);for(let t of[l.target,...l.additionalTargets]){let n=hf(t)?lh(e,i,t,r):pf(t)?uh(e,i,t,r):void 0;i=$p(e,i,n?.target??t),n!==void 0&&(a.push(...n.commands),o.push(...n.raisedEvents),s.push(...n.emittedEvents),c.push(...n.transitions))}a.push(...l.commands),o.push(...l.raisedEvents),s.push(...l.emittedEvents),c.push(...l.transitions)}let l=sh(e,i,r,n.input);return c.length===0?l:{...l,commands:[...a,...l.commands],raisedEvents:[...o,...l.raisedEvents],emittedEvents:[...s,...l.emittedEvents],transitions:[...c,...l.transitions]}}function lh(e,t,n,r){let i=ch(e,t,n,r),a=Rp(e,i.configuration,n.path);return{target:Cf(n.path,a.value,{snapshot:a,values:n.values}),commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents,transitions:i.transitions}}function uh(e,t,n,r){let i=$(e,n.path);if(i.type!==`history`||i.parent!==n.parent)throw Error(`Machine expected history target "${n.path}" to resolve to its declared parent`);let a=Jp(t,n.path);if(a!==void 0){let i=sh(e,Yp(e,t,a),r),o=Rp(e,i.configuration,n.parent),s=Object.fromEntries(i.configuration.values);return n.parent!==``&&t.active.has(``)&&delete s[``],{target:Cf(n.parent,o.value,{snapshot:o,values:s}),commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents,transitions:i.transitions}}let o=i.key,s=Ld(e).handlers[n.parent]?.history?.[o]?.default;if(s===void 0)throw Error(`Machine history state "${n.path}" requires a default implementation`);let c=ah(e,s,{event:r,target:t=>_m(e.stateNodes,t),owner:n.parent});if(c.state===void 0||pf(c.state)||!Df(c.state))throw Error(`Machine history default for "${n.path}" must return a complete snapshot containing its owner`);let l=Fh(c.state)===void 0?void 0:Lh(e,{active:new Set,values:new Map,outputs:new Map,history:t.history},c.state,r),u=l===void 0?Wp(e,c.state):$p(e,{active:new Set,values:new Map,outputs:new Map,history:t.history},l.target);for(let t of l?.additionalTargets??[])u=$p(e,u,t);if(!u.active.has(n.parent))throw Error(`Machine history default for "${n.path}" returned a configuration that does not contain owner state "${n.parent}"`);let d=Rp(e,u,n.parent),f=Object.fromEntries(u.values);return n.parent!==``&&t.active.has(``)&&delete f[``],{target:Cf(n.parent,d.value,{snapshot:d,values:f}),commands:[...c.commands,...l?.commands??[]],raisedEvents:[...c.raisedEvents,...l?.raisedEvents??[]],emittedEvents:[...c.emittedEvents,...l?.emittedEvents??[]],transitions:l?.transitions??[]}}var dh=(e,t)=>{if(!t.transition.declinable)return t;let n=ah(e,t.transition.transition,t.context,t.transition.evaluate);return n.declined?void 0:{...t,collected:n}},fh=(e,t)=>[...Tp(e,t)].reverse(),ph=(e,t,n)=>{let r=Tp(e,t),i=Tp(e,n),a,o=Math.min(r.length,i.length);for(let e=0;e<o&&r[e]===i[e];e++)a=r[e];return a},mh=(e,t)=>{if(e!==void 0&&t!==void 0)return e===t||Cp(e,t)?t:e},hh=(e,t,n)=>vh(e,Array.from(t.active).filter(e=>n===void 0||Cp(e,n))),gh=(e,t,n)=>yh(e,Array.from(t.active).filter(e=>n===void 0||Cp(e,n))),_h=(e,t)=>e.active.size===t.active.size&&Array.from(e.active).every(e=>t.active.has(e)),vh=(e,t)=>Array.from(new Set(t)).sort((t,n)=>{let r=Tp(e,n).length-Tp(e,t).length;return r===0?$(e,n).order-$(e,t).order:r}),yh=(e,t)=>Array.from(new Set(t)).sort((t,n)=>{let r=Tp(e,t).length-Tp(e,n).length;return r===0?Dp(e,t,n):r}),bh=(e,t,n,r)=>({...nh(e,t),state:t.values.get(n),containingState:Pp(e,t,n),ancestors:Np(e,t,n),event:r}),xh=(e,t,n,r,i)=>({...nh(e,t),state:t.values.get(n),containingState:Pp(e,t,n),ancestors:Np(e,t,n),event:r,snapshot:i}),Sh=(e,t,n,r,i,a)=>({...nh(e,t),state:t.values.get(n),containingState:Pp(e,t,n),ancestors:Np(e,t,n),event:r,output:i,snapshot:a}),Ch=(e,t,n,r,i)=>{let a=[],o=[],s=[];for(let c of n){let n=ih(e,Ld(e).handlers[c]?.[i],bh(e,t,c,r));a.push(...n.commands),o.push(...n.raisedEvents),s.push(...n.emittedEvents)}return{commands:a,emittedEvents:s,raisedEvents:o}},wh=(e,t,n)=>{let r=[],i=new Set,a=new Map,o,s=()=>o??=Lp(e,t);for(let o of kp(e,t))for(let c of fh(e,o)){let l=rh(Ld(e).handlers[c]?.always);if(l!==void 0){let u=a.get(c);if(a.has(c)||(u=dh(e,{sourcePath:c,leafPath:o,trigger:{type:`always`},transition:l,context:{...nh(e,t),state:t.values.get(c),containingState:Pp(e,t,c),ancestors:Np(e,t,c),event:n,snapshot:s()}}),a.set(c,u)),u===void 0)continue;i.has(c)||(i.add(c),r.push(u));break}}return r},Th=(e,t,n,r)=>{let i=[],a=new Set,o,s=()=>o??=Lp(e,t);for(let o of r){let r=rh(Ld(e).handlers[o.path]?.onDone);if(r!==void 0&&!a.has(o.path)){a.add(o.path);let c=dh(e,{sourcePath:o.path,leafPath:jp(e,t,o.path),trigger:{type:`done`},transition:r,context:Sh(e,t,o.path,n,o.output,s())});c!==void 0&&i.push(c)}}return i},Eh=(e,t,n)=>{let r=[],i=new Set,a=new Map,o,s=()=>o??=Lp(e,t);for(let o of kp(e,t))for(let c of fh(e,o)){let l=rh(Ld(e).handlers[c]?.on?.[n._tag]);if(l!==void 0){let u=a.get(c);if(a.has(c)||(u=dh(e,{sourcePath:c,leafPath:o,trigger:{type:`event`,event:n._tag},transition:l,context:xh(e,t,c,n,s())}),a.set(c,u)),u===void 0)continue;i.has(c)||(i.add(c),r.push(u));break}}return r},Dh=(e,t,n)=>{if(!t.active.has(n.path))return[];let r=Ld(e).handlers[n.path],i=Rm(r?.invoke).find(e=>{let t=`child`in e?e.child?.id:e.id;return String(t)===n.id});if(i===void 0)return[];let a=rh(n.type===`element`?i.onElement:n.type===`done`?i.onDone:n.type===`failure`?i.onFailure:i.onSnapshot);if(a===void 0)return[];let o=Lp(e,t),s={...nh(e,t),state:t.values.get(n.path),containingState:Pp(e,t,n.path),ancestors:Np(e,t,n.path),snapshot:o,id:n.id,...n.type===`element`?{element:n.element}:n.type===`done`?{output:n.output}:n.type===`failure`?{error:n.error}:{snapshot:n.snapshot}},c=dh(e,{sourcePath:n.path,leafPath:jp(e,t,n.path),trigger:{type:`invoke`,id:n.id,outcome:n.type},transition:a,context:s});return c===void 0?[]:[c]},Oh=e=>{if(pf(e)||_f(e)||wf(e)||Df(e))return String(e.path);throw Error(`Machine expected transition target to be a snapshot or target builder result`)},kh=(e,t,n,r)=>{if(n===void 0||r===void 0)return;let i=typeof r==`object`&&r&&`path`in r?String(r.path):`<unknown>`;if(!n.some(e=>i===e||e===``||i.startsWith(`${e}.`))){let r=t.type===`event`?String(t.event):t.type;throw Error(`Machine transition from "${e}" on "${r}" returned target "${i}" outside declared targets: ${n.length===0?`none`:n.map(e=>`"${e}"`).join(`, `)}`)}},Ah=(e,t)=>{for(let n of e)if(t.includes(n))return!0;return!1},jh=(e,t)=>Array.from(t).sort((t,n)=>Dp(e,t.selection.sourcePath,n.selection.sourcePath)),Mh=e=>e.filter(t=>!e.some(e=>e.sourcePath!==t.sourcePath&&Cp(e.sourcePath,t.sourcePath))),Nh=(e,t)=>{let n=[];for(let r of jh(e,t)){let e=!1,t=new Set;for(let i of n){let n=r.update!==void 0&&i.update!==void 0&&r.update.path===i.update.path;if(Ah(r.exitPaths,i.exitPaths)||n){if(Cp(r.selection.sourcePath,i.selection.sourcePath))t.add(i);else{e=!0;break}}}if(!e){for(let e of t){let t=n.indexOf(e);t>=0&&n.splice(t,1)}n.push(r)}}return n},Ph=(e,t={})=>{let n={...t},r=[],i=e=>{if(_f(e))Object.assign(n,e.values??{}),r.push(e);else if(typeof e==`object`&&e&&`path`in e&&`value`in e&&(e.value!==void 0&&(n[String(e.path)]=e.value),`state`in e&&i(e.state),`states`in e&&typeof e.states==`object`&&e.states!==null))for(let t of Object.values(e.states))i(t)};return i(e),r.map(e=>({target:gf(e.path,e.parent,n),values:n}))},Fh=(e,t={})=>Ph(e,t)[0],Ih=(e,t)=>{if(_f(e))return gf(e.path,e.parent,{...t,...e.values??{}});if(hf(e))return{...e,values:{...t,...e.values}};if(!wf(e)||Object.keys(t).length===0)return e;let n=e[zd];return Cf(e.path,e.value,{...n===void 0?{}:{snapshot:n},values:{...t,...e.values??{}}})};function Lh(e,t,n,r){let i=[n],a=[],o=[],s=[],c=[],l=[],u=0;for(;i.length>0;){let n=i.shift();for(;;){let a=Ph(n),d=a[0];if(d===void 0)break;if(i.unshift(...a.slice(1).map(({target:e})=>e)),u+=1,u>1e3)throw new Ad({machineId:e.id,state:d.target.path,maxIterations:zh});let f=$(e,d.target.path);if(f.type!==`choice`||f.parent!==d.target.parent)throw Error(`Machine expected choice target "${d.target.path}" to resolve to its declared parent`);let p=Ld(e).handlers[f.path]?.choice;if(p===void 0||typeof p.transition!=`function`)throw Error(`Machine choice state "${f.path}" requires an implementation`);let m=new Map(t.values);for(let[t,n]of Object.entries(d.values)){let r=$(e,t);r.schema!==void 0&&m.set(t,fp(e,r,n))}let h={active:new Set([...t.active,...Object.keys(d.values)]),values:m,outputs:t.outputs,history:t.history,...t.machineReferences===void 0?{}:{machineReferences:t.machineReferences}},g=ah(e,p.transition,{...nh(e,h),containingState:Pp(e,h,f.path),ancestors:Np(e,h,f.path),event:r},p.evaluate);if(g.state===void 0)throw Error(`Machine choice resolver for "${f.path}" must return a target`);kh(f.path,{type:`choice`},p.targets,g.state);let _=Oh(g.state);n=Ih(g.state,d.values);let v=Fh(n);l.push({source:f.path,trigger:{type:`choice`},reenter:!1,branchIndex:g.branchIndex,branchKey:g.branchKey,target:_,resolvedTarget:v?.target.path??_,updates:[]}),o.push(...g.commands),s.push(...g.raisedEvents),c.push(...g.emittedEvents)}if(!wf(n)&&!Df(n)&&!pf(n)&&!hf(n))throw Error(`Machine choice resolver must return a concrete typed target`);a.push(n)}return{target:a[0],additionalTargets:a.slice(1),commands:o,raisedEvents:s,emittedEvents:c,transitions:l}}var Rh=(e,t,n)=>{let r=n.leafPath,i=n.collected??ah(e,n.transition.transition,n.context,n.transition.evaluate);if(i.declined)throw Error(`Machine transition returned decline without declaring declinable: true`);let a=nf(i.state)?i.state:void 0,o=a?.target??i.state,s=o===void 0||ef(o)?void 0:o;kh(n.sourcePath,n.trigger,n.transition.targets,s);let c=a?.update??(ef(o)?o:void 0),l=c===void 0?void 0:(()=>{let n=$(e,c.path);if(!t.active.has(n.path)||n.schema===void 0)throw Error(`Machine state update owner "${n.path}" must be an active valued state`);return{path:n.path,value:fp(e,n,c.value)}})(),u=l!==void 0&&(hf(s)||_f(s))?{...t,values:new Map(t.values).set(l.path,l.value)}:t,d=s===void 0?void 0:Lh(e,u,s,n.context.event),f=d?.target??s,p=f!==void 0&&hf(f)?lh(e,u,f,n.context.event):void 0,m=p?.target??f,h,g=pf(m)&&n.transition.reenter&&t.active.has(m.parent)?m:void 0;if(m!==void 0&&pf(m)){let i=n.transition.reenter?$(e,n.sourcePath).parent:ph(e,r,m.parent),a=g===void 0?hh(e,t,i):vh(e,Array.from(t.active).filter(e=>wp(e,m.parent)));h=uh(e,a.includes(m.parent)?qp(e,t,t,a):t,m,n.context.event)}let _=h===void 0?m:h.target,v=[],y=[],b=[],x=[],S=[];for(let r of d?.additionalTargets??[]){if(hf(r)){let i=lh(e,t,r,n.context.event);S.push(i.target),v.push(...i.commands),y.push(...i.raisedEvents),b.push(...i.emittedEvents),x.push(...i.transitions);continue}if(!pf(r)){S.push(r);continue}let i=uh(e,t,r,n.context.event);S.push(i.target),v.push(...i.commands),y.push(...i.raisedEvents),b.push(...i.emittedEvents),x.push(...i.transitions)}let C=_===void 0?void 0:S.length===0||s===void 0?Oh(_):Oh(s),w=_===void 0?l===void 0?t:{...t,values:new Map(t.values).set(l.path,l.value)}:$p(e,t,_);for(let t of S)w=$p(e,w,t);if(a!==void 0&&l!==void 0&&!w.active.has(l.path))throw Error(`Machine combined target exited its updating owner "${l.path}"`);l!==void 0&&(w={...w,values:new Map(w.values).set(l.path,l.value)});let T=n.transition.reenter||!_h(t,w),E=T||l!==void 0;if(!T)return{selection:n,branchIndex:i.branchIndex,branchKey:i.branchKey,unresolvedTarget:s,target:_,update:l,commands:[...i.commands,...d?.commands??[],...p?.commands??[],...h?.commands??[],...v],raisedEvents:[...i.raisedEvents,...d?.raisedEvents??[],...p?.raisedEvents??[],...h?.raisedEvents??[],...y],emittedEvents:[...i.emittedEvents,...d?.emittedEvents??[],...p?.emittedEvents??[],...h?.emittedEvents??[],...b],changed:T,stabilize:E,exitPaths:[],entryPaths:[],choiceTransitions:[...d?.transitions??[],...p?.transitions??[],...h?.transitions??[],...x]};let D=C===void 0?$(e,n.sourcePath).parent:ph(e,r,C),O=$(e,n.sourcePath).parent,k=n.transition.reenter?mh(D,O):D;return{selection:n,branchIndex:i.branchIndex,branchKey:i.branchKey,unresolvedTarget:s,target:_,update:l,commands:[...i.commands,...d?.commands??[],...p?.commands??[],...h?.commands??[],...v],raisedEvents:[...i.raisedEvents,...d?.raisedEvents??[],...p?.raisedEvents??[],...h?.raisedEvents??[],...y],emittedEvents:[...i.emittedEvents,...d?.emittedEvents??[],...p?.emittedEvents??[],...h?.emittedEvents??[],...b],changed:T,stabilize:E,exitPaths:g===void 0?hh(e,t,k):vh(e,Array.from(t.active).filter(e=>wp(e,g.parent))),entryPaths:g===void 0?gh(e,w,k):yh(e,Array.from(w.active).filter(e=>wp(e,g.parent))),choiceTransitions:[...d?.transitions??[],...p?.transitions??[],...h?.transitions??[],...x]}},zh=1e3,Bh={_tag:Tm},Vh=(e,t)=>am(e,Up(e,t)),Hh=(e,t,n)=>Kp(e,t).pipe(G(t=>lm(e,t,n)),G(t=>{let n=Mp(e,t.configuration);return!am(e,t.configuration)||!t.configuration.outputs.has(n)?mn(Error(`Machine attempted to read terminal output from a non-terminal configuration`)):T(t.configuration.outputs.get(n))})),Uh=(e,...t)=>{let n=e.input===void 0?t:t.length===0?(up(e,e.input,void 0),t):[up(e,e.input,t[0])],r=e.initial(...n),i={active:new Set,values:new Map,outputs:new Map,history:new Map},a=lh(e,i,r,Bh),o=$p(e,i,a.target),s=Lp(e,o),c=Fp(e,o),l=a.commands,u=a.raisedEvents,d=a.emittedEvents,f=Ch(e,o,c,Bh,`entry`),p=Gh(e,o,Bh,[...f.commands],[...u,...f.raisedEvents],[...d,...f.emittedEvents],a.transitions.length===0?[]:[{next:o,event:Bh,transitions:a.transitions,commands:l,raisedEvents:[...u],emittedEvents:d,exitPaths:[],entryPaths:[],changed:!1,stabilize:!1}]),m={startingState:s,initialEntryPaths:c,state:Lp(e,p.next),commands:[...l,...p.commands],emittedEvents:p.emittedEvents,microsteps:p.microsteps.map(t=>({next:Lp(e,t.next),event:t.event,transitions:t.transitions,commands:t.commands,raisedEvents:t.raisedEvents,emittedEvents:t.emittedEvents,exitPaths:t.exitPaths,entryPaths:t.entryPaths,changed:t.changed}))};return p.done?{...m,done:!0,output:p.output}:{...m,done:!1,output:void 0}},Wh=(e,t,n,r)=>{if(r.length===0)return{next:t,event:n,transitions:[],commands:[],raisedEvents:[],emittedEvents:[],exitPaths:[],entryPaths:[],changed:!1,stabilize:!1};let i=Mh(r),a=[];for(let n of i)a.push(Rh(e,t,n));let o=Nh(e,a),s=jh(e,o),c=s.flatMap(e=>[{source:e.selection.sourcePath,trigger:e.selection.trigger,reenter:e.selection.transition.reenter,branchIndex:e.branchIndex,branchKey:e.branchKey,target:e.unresolvedTarget===void 0?void 0:Oh(e.unresolvedTarget),resolvedTarget:e.target===void 0?void 0:Oh(e.target),updates:e.update===void 0?[]:[e.update.path]},...e.choiceTransitions]),l=t;for(let e of s)e.update!==void 0&&(l={...l,values:new Map(l.values).set(e.update.path,e.update.value)});let u=[...s.filter(e=>!e.changed),...s.filter(e=>e.changed)];for(let t of u)t.target!==void 0&&(l=$p(e,l,t.target));let d=o.some(e=>e.changed),f=o.some(e=>e.stabilize),p=s.flatMap(e=>e.commands),m=s.flatMap(e=>e.raisedEvents),h=s.flatMap(e=>e.emittedEvents);if(!d)return{next:l,event:n,transitions:c,commands:p,raisedEvents:m,emittedEvents:h,exitPaths:[],entryPaths:[],changed:!1,stabilize:f};let g=vh(e,s.flatMap(e=>e.exitPaths)),_=yh(e,s.flatMap(e=>e.entryPaths));l=qp(e,t,l,g);let v=Ch(e,t,g,n,`exit`),y=Ch(e,l,_,n,`entry`);return{next:l,event:n,transitions:c,commands:[...v.commands,...p,...y.commands],raisedEvents:[...v.raisedEvents,...m,...y.raisedEvents],emittedEvents:[...v.emittedEvents,...h,...y.emittedEvents],exitPaths:g,entryPaths:_,changed:!0,stabilize:f}},Gh=(e,t,n,r,i,a,o)=>{let s=t,c=n,l=!0,u=0,d=0,f=!1,p,m=[];for(;;){if(u+=1,u>1e3)throw new Ad({machineId:e.id,state:String(Ap(e,s)),maxIterations:zh});let t=fm(e,s,c);for(s=t.configuration,m.push(...t.completions.filter(t=>Ld(e).handlers[t.path]?.onDone!==void 0));m.length>0&&!s.active.has(m[0].path);)m.shift();let n=Th(e,s,c,m.length===0?[]:[m.shift()]);if(n.length>0){let t=Wh(e,s,c,n);r.push(...t.commands),i.push(...t.raisedEvents),a.push(...t.emittedEvents),o.push(t),s=t.next,l=t.stabilize;continue}if(am(e,s)){let t=Mp(e,s);if(!s.outputs.has(t))throw Error(`Machine reached a terminal configuration without a completed root output`);f=!0,p=s.outputs.get(t);break}let h=l?wh(e,s,c):[];if(h.length>0){let t=Wh(e,s,c,h);r.push(...t.commands),i.push(...t.raisedEvents),a.push(...t.emittedEvents),o.push(t),s=t.next,l=t.stabilize;continue}let g=i[d];if(g===void 0)break;d+=1;let _=g;c=_;let v=Eh(e,s,_);if(v.length===0){l=!0;continue}let y=Wh(e,s,_,v);r.push(...y.commands),i.push(...y.raisedEvents),a.push(...y.emittedEvents),o.push(y),s=y.next,l=!0}let h={next:s,commands:r,emittedEvents:a,microsteps:o};return f?{...h,done:!0,output:p}:{...h,done:!1,output:void 0}},Kh=(e,t,n)=>{let r=Zm(n)?n:sp(e,n);if(am(e,t)){let n=fm(e,t,r),i=Mp(e,n.configuration);if(!n.configuration.outputs.has(i))throw Error(`Machine reached a terminal configuration without a completed root output`);return{event:r,next:n.configuration,commands:[],emittedEvents:[],microsteps:[],done:!0,output:n.configuration.outputs.get(i)}}let i=Zm(r)?Dh(e,t,r):Eh(e,t,r);if(i.length===0)return{event:r,next:t,commands:[],emittedEvents:[],microsteps:[],done:!1,output:void 0};let a=Wh(e,t,r,i),o=[...a.commands],s=[...a.raisedEvents],c=[...a.emittedEvents],l=[a];return{...Gh(e,a.next,r,o,s,c,l),event:r}},qh=(e,...t)=>Me({try:()=>Uh(e,...t),catch:Id}),Jh=(e,t)=>({raise:n=>op(e,n).pipe(G(e=>t.sendTo(t.self,e))),emit:n=>cp(e,n).pipe(G(e=>t.emit(e)))}),Yh=(e,t)=>kr(e,e=>e._tag===`SendTo`?t.sendTo(e.target,e.event):t.stopChild(e.child),{discard:!0}),Xh=(e,t)=>wt(Array.from(e,e=>t.emit(e)),{discard:!0}),Zh=new WeakMap,Qh=e=>{let t=Zh.get(e);if(t!==void 0)return t;let n={self:{id:e.id??`Machine`,sessionId:`Machine.plan`,send:()=>wr(new Nd)},parent:void 0};return Zh.set(e,n),n},$h=(e,t)=>{let n=t===void 0?Qh(e):t;return e.parent===void 0?{self:n.self}:{self:n.self,parent:n.parent}},eg=new Set([`initialize`,`invoke`,`on`,`output`]),tg=e=>{if(e===void 0)return!0;for(let t of Reflect.ownKeys(e))if(!eg.has(t))return!1;return!0},ng=e=>{let t=[],n=[],r=[],i=new Map;for(let a of e.stateNodes.byPath.values()){if(t.push(a),a.type===`choice`||a.type===`history`)return;(a.type===`atomic`||a.type===`final`)&&n.push(a.path),a.type===`final`&&r.push(a.path);let o=Ld(e).handlers[a.path];if(!tg(o))return;if(o?.on===void 0)continue;let s=new Map;for(let e of Reflect.ownKeys(o.on)){let t=rh(o.on[e]);if(t!==void 0){if(t.declinable)return;s.set(e,t)}}s.size>0&&i.set(a.path,s)}n.sort((t,n)=>Dp(e,t,n)),r.sort((t,n)=>Dp(e,t,n)),t.sort((e,t)=>e.order-t.order);let a=new Map(t.map((e,t)=>[e.path,t])),o=e=>{let t=a.get(e);if(t===void 0)throw Error(`Machine expected compiled state path "${e}"`);return t},s=n.map(o),c=t.map(e=>e.parent===void 0?-1:o(e.parent)),l=t.map(e=>e.children.map(o)),u=t.map(t=>Tp(e,t.path).slice(0,-1).map(o)),d=t.map(e=>i.get(e.path)),f=new Map;for(let e of s){let t=new Map,n=[e,...u[e].slice().reverse()];for(let e of n)for(let[n,r]of d[e]??[])t.has(n)||t.set(n,{sourceIndex:e,transition:r});f.set(e,t)}return{valued:Object.freeze(t.map(e=>e.schema!==void 0)),flat:t.every(e=>e.parent===void 0&&(e.type===`atomic`||e.type===`final`))||t[0]?.path===``&&t[0].type===`compound`&&t[0].schema===void 0&&(Ld(e).handlers[``]===void 0||Reflect.ownKeys(Ld(e).handlers[``]).every(e=>e===`initialize`))&&t.slice(1).every(e=>e.parent===``&&(e.type===`atomic`||e.type===`final`))&&[...i.values()].every(e=>[...e.values()].every(e=>e.targets!==void 0&&e.targets.every(e=>e!==``))),nodes:t,indexByPath:a,parentIndices:c,childIndices:l,ancestorIndices:u,rootIndices:t.flatMap((e,t)=>e.parent===void 0?[t]:[]),leafIndices:s,finalIndices:r.map(o),dispatchByLeaf:f}},rg=e=>({active:e.active.slice(),activeLeaves:e.activeLeaves.slice(),values:e.values.slice(),completed:e.completed.slice(),outputs:e.outputs.slice(),completedOrder:e.completedOrder.slice()}),ig=(e,t)=>t?{...e,next:rg(e.next)}:e,ag=(e,t,n)=>{e.values[t]=n},og=(e,t)=>{let n=new Uint8Array(e.nodes.length),r=Array(e.nodes.length),i=new Uint8Array(e.nodes.length),a=Array(e.nodes.length),o=[];for(let i of t.active){let a=e.indexByPath.get(i);if(a===void 0)throw Error(`Machine expected indexed active path "${i}"`);n[a]=1,e.valued[a]&&(r[a]=t.values.get(i))}for(let[n,r]of t.outputs){let t=e.indexByPath.get(n);if(t===void 0)throw Error(`Machine expected indexed completed path "${n}"`);i[t]=1,a[t]=r,o.push(t)}return{active:n,activeLeaves:e.leafIndices.filter(e=>n[e]===1),values:r,completed:i,outputs:a,completedOrder:o}},sg=(e,t)=>{let n=new Set,r=new Map,i=new Map;for(let i=0;i<e.nodes.length;i++){if(t.active[i]!==1)continue;let a=e.nodes[i].path;n.add(a),e.valued[i]&&r.set(a,t.values[i])}for(let n of t.completedOrder)t.completed[n]===1&&i.set(e.nodes[n].path,t.outputs[n]);return{active:n,values:r,outputs:i,history:new Map}},cg=(e,t,n)=>{let r=e.nodes[n],i={path:r.path,value:e.valued[n]?t.values[n]:void 0};if(r.type===`compound`){let a=e.childIndices[n].find(e=>t.active[e]===1);if(a===void 0)throw Error(`Machine expected indexed compound state "${r.path}" to have an active child`);i.state=cg(e,t,a)}else if(r.type===`parallel`){let a={};for(let i of e.childIndices[n]){if(t.active[i]!==1)throw Error(`Machine expected indexed parallel state "${r.path}" to have active region "${e.nodes[i].path}"`);a[e.nodes[i].key]=cg(e,t,i)}i.states=a}return i},lg=(e,t)=>{let n=e.rootIndices.find(e=>t.active[e]===1);if(n===void 0)throw Error(`Machine expected an active indexed root state`);let r=cg(e,t,n);return t.completedOrder.length>0&&(r.completed=t.completedOrder.map(n=>({path:e.nodes[n].path,output:t.outputs[n]}))),r},ug=(e,t,n,r,i,a)=>{let o=t.parentIndices[r],s={};for(let e of t.ancestorIndices[r])t.valued[e]&&(s[t.nodes[e].path]=n.values[e]);return{...$h(e,a),state:n.values[r],containingState:o<0?void 0:n.values[o],ancestors:s,event:i,snapshot:lg(t,n)}},dg=Object.freeze([]),fg=(e,t,n,r)=>{let i,a,o,s={raise:t=>{(a??=[]).push(sp(e,t))},emit:t=>{(o??=[]).push(lp(e,t))},sendTo:(e,t)=>{(i??=[]).push({_tag:`SendTo`,target:e,event:t})},stop:e=>{(i??=[]).push({_tag:`Stop`,child:e})}},c=r===void 0?{result:t(n,s),branchIndex:0,branchKey:void 0}:r(n,s);return{state:cf(c.result)?void 0:c.result,branchIndex:c.branchIndex,branchKey:c.branchKey,commands:i??dg,raisedEvents:a??dg,emittedEvents:o??dg}},pg=(e,t,n,r,i)=>{let a=[];for(let o of n.activeLeaves){let s=t.dispatchByLeaf.get(o).get(r._tag);if(s!==void 0){let{sourceIndex:c,transition:l}=s;if(!a.some(e=>e.sourceIndex===c)){let s=t.nodes[c].path;a.push({sourceIndex:c,leafIndex:o,sourcePath:s,leafPath:t.nodes[o].path,trigger:{type:`event`,event:r._tag},transition:l,context:ug(e,t,n,c,r,i)})}}}return a},mg=(e,t)=>{if(e.active===t.active)return!0;for(let n=0;n<e.active.length;n++)if(e.active[n]!==t.active[n])return!1;return!0},hg=(e,t,n,r,i)=>{if((wf(r)?t.indexByPath.get(String(r.path)):void 0)===i&&n.active[i]===1&&wf(r)&&r[zd]===void 0&&r.values===void 0&&n.completedOrder.length===0&&t.valued[i]){let a=n.values.slice();return a[i]=fp(e,t.nodes[i],r.value),{...n,values:a}}return og(t,$p(e,sg(t,n),r))},gg=(e,t,n,r)=>{let i=fg(e,r.transition.transition,r.context,r.transition.evaluate),a=nf(i.state)?i.state:void 0,o=a?.target??i.state,s=a?.update??(ef(o)?o:void 0),c=s===void 0?void 0:(()=>{let r=t.indexByPath.get(s.path),i=r===void 0?void 0:t.nodes[r];if(r===void 0||i===void 0||n.active[r]!==1||i.schema===void 0)throw Error(`Machine state update owner "${s.path}" must be an active valued state`);return{path:i.path,value:fp(e,i,s.value)}})(),l=o===void 0||ef(o)?void 0:o;kh(r.sourcePath,r.trigger,r.transition.targets,l);let u=l!==void 0&&hf(l)?lh(e,(()=>{let e=sg(t,n);return c===void 0?e:{...e,values:new Map(e.values).set(c.path,c.value)}})(),l,r.context.event):void 0,d=u?.target??l;if(d!==void 0&&!wf(d)&&!Df(d))throw Error(`Machine expected indexed transition target to be a snapshot or target builder result`);let f=d===void 0?c===void 0?n:(()=>{let e=rg(n);return e.values[t.indexByPath.get(c.path)]=c.value,e})():hg(e,t,n,d,r.leafIndex);if(a!==void 0&&c!==void 0){let e=t.indexByPath.get(c.path);if(f.active[e]!==1)throw Error(`Machine combined target exited its updating owner "${c.path}"`);let n=f.values.slice();n[e]=c.value,f={...f,values:n}}let p=r.transition.reenter||!mg(n,f),m=p||c!==void 0;if(!p)return{selection:r,branchIndex:i.branchIndex,branchKey:i.branchKey,unresolvedTarget:l,target:d,update:c,next:f,commands:[...i.commands,...u?.commands??[]],raisedEvents:[...i.raisedEvents,...u?.raisedEvents??[]],emittedEvents:[...i.emittedEvents,...u?.emittedEvents??[]],changed:!1,stabilize:m,exitPaths:[],entryPaths:[],choiceTransitions:u?.transitions??[]};let h=d===void 0?void 0:Oh(d),g=h===void 0?t.nodes[r.sourceIndex].parent:ph(e,r.leafPath,h),_=t.nodes[r.sourceIndex].parent,v=r.transition.reenter?mh(g,_):g;return{selection:r,branchIndex:i.branchIndex,branchKey:i.branchKey,unresolvedTarget:l,target:d,update:c,next:f,commands:[...i.commands,...u?.commands??[]],raisedEvents:[...i.raisedEvents,...u?.raisedEvents??[]],emittedEvents:[...i.emittedEvents,...u?.emittedEvents??[]],changed:!0,stabilize:m,exitPaths:hh(e,sg(t,n),v),entryPaths:gh(e,sg(t,f),v),choiceTransitions:u?.transitions??[]}},_g=(e,t,n,r,i,a)=>{let o=e=>({source:e.selection.sourcePath,trigger:e.selection.trigger,reenter:e.selection.transition.reenter,branchIndex:e.branchIndex,branchKey:e.branchKey,target:e.unresolvedTarget===void 0?void 0:Oh(e.unresolvedTarget),resolvedTarget:e.target===void 0?void 0:Oh(e.target),updates:e.update===void 0?[]:[e.update.path]});if(i.length===1){let s=gg(e,t,n,i[0]);return{next:s.next,event:r,...a?{transitions:[o(s)]}:void 0,commands:s.commands,raisedEvents:s.raisedEvents,emittedEvents:s.emittedEvents,exitPaths:s.exitPaths,entryPaths:s.entryPaths,changed:s.changed}}let s=jh(e,Nh(e,i.filter(e=>!i.some(t=>t.sourceIndex!==e.sourceIndex&&Cp(t.sourcePath,e.sourcePath))).map(r=>gg(e,t,n,r)))),c=n;if(s.length===1)c=s[0].next;else{for(let e of s)if(e.update!==void 0){let n=c.values.slice();n[t.indexByPath.get(e.update.path)]=e.update.value,c={...c,values:n}}let n=[...s.filter(e=>!e.changed),...s.filter(e=>e.changed)];for(let r of n)r.target!==void 0&&(c=hg(e,t,c,r.target,r.selection.leafIndex))}let l=s.flatMap(e=>e.commands),u=s.flatMap(e=>e.raisedEvents),d=s.flatMap(e=>e.emittedEvents),f=s.some(e=>e.changed);return{next:c,event:r,...a?{transitions:s.map(o)}:void 0,commands:l,raisedEvents:u,emittedEvents:d,exitPaths:f?vh(e,s.flatMap(e=>e.exitPaths)):[],entryPaths:f?yh(e,s.flatMap(e=>e.entryPaths)):[],changed:f}},vg=(e,t,n,r,i,a)=>{let o=n,s=r,c,l,u,d,f=0,p=0;for(;;){if(p+=1,p>1e3)throw new Ad({machineId:e.id,state:t.nodes[o.activeLeaves[0]].path,maxIterations:zh});let n=o.activeLeaves[0];if(n===void 0)throw Error(`Machine expected an active indexed root state`);if(t.nodes[n].type===`final`){let n=fm(e,sg(t,o),s).configuration,i=Mp(e,n);if(!n.outputs.has(i))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:r,next:og(t,n),commands:c??dg,emittedEvents:u??dg,microsteps:d??dg,done:!0,output:n.outputs.get(i)}}let m=t.nodes[n].path,h=rh(Ld(e).handlers[m]?.on?.[s._tag]);if(h!==void 0){let r=fg(e,h.transition,{...$h(e,a),state:o.values[n],containingState:void 0,ancestors:{},event:s,snapshot:lg(t,o)},h.evaluate),f=ef(r.state)?r.state:void 0,p=f===void 0?r.state:void 0;if(f!==void 0){let r=t.nodes[n];if(f.path!==m||r.schema===void 0)throw Error(`Machine state update owner "${f.path}" must be the active valued state`);ag(o,n,fp(e,r,f.value))}if(kh(m,{type:`event`,event:s._tag},h.targets,p),p!==void 0&&!wf(p)&&!Df(p))throw Error(`Machine expected indexed transition target to be a snapshot or target builder result`);let g=o;if(p!==void 0){let r=t.indexByPath.get(String(p.path)),i=wf(p)?p[zd]===void 0&&p.values===void 0:!(`state`in p)&&!(`states`in p)&&!(`completed`in p)&&!(`history`in p);r===n&&i&&o.completedOrder.length===0&&t.valued[n]?ag(o,n,fp(e,t.nodes[n],p.value)):g=hg(e,t,o,p,n)}let _=h.reenter||!mg(o,g),v=g.activeLeaves[0];if(v===void 0)throw Error(`Machine expected an active indexed transition target`);let y={next:g,event:s,...i?{transitions:[{source:m,trigger:{type:`event`,event:s._tag},reenter:h.reenter,branchIndex:r.branchIndex,branchKey:r.branchKey,target:p===void 0?void 0:Oh(p),resolvedTarget:p===void 0?void 0:Oh(p),updates:f===void 0?[]:[f.path]}]}:void 0,commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents,exitPaths:_?[m]:dg,entryPaths:_?[t.nodes[v].path]:dg,changed:_};o=g,(d??=[]).push(ig(y,i)),r.commands.length>0&&(c??=[]).push(...r.commands),r.raisedEvents.length>0&&(l??=[]).push(...r.raisedEvents),r.emittedEvents.length>0&&(u??=[]).push(...r.emittedEvents)}if(t.nodes[o.activeLeaves[0]].type===`final`)continue;let g=l?.[f];if(g===void 0)return{event:r,next:o,commands:c??dg,emittedEvents:u??dg,microsteps:d??dg,done:!1,output:void 0};f+=1,s=g}},yg=(e,t,n,r,i,a)=>{if(Zm(r)){let i=Kh(e,a===void 0?sg(t,n):yp(sg(t,n),a),r);return{event:i.event,next:og(t,i.next),commands:i.commands,emittedEvents:i.emittedEvents,microsteps:i.microsteps.map(e=>({next:og(t,e.next),event:e.event,transitions:e.transitions,commands:e.commands,raisedEvents:e.raisedEvents,emittedEvents:e.emittedEvents,exitPaths:e.exitPaths,entryPaths:e.entryPaths,changed:e.changed})),done:i.done,output:i.output}}let o=sp(e,r);if(t.flat)return vg(e,t,n,o,i,a);if(t.finalIndices.some(e=>n.active[e]===1)){let r=sg(t,n);if(am(e,r)){let n=fm(e,r,o).configuration,i=Mp(e,n);if(!n.outputs.has(i))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:o,next:og(t,n),commands:[],emittedEvents:[],microsteps:[],done:!0,output:n.outputs.get(i)}}}let s=pg(e,t,n,o,a);if(s.length===0)return{event:o,next:n,commands:[],emittedEvents:[],microsteps:[],done:!1,output:void 0};let c=_g(e,t,n,o,s,i),l=c.next,u=o,d=[...c.commands],f=[...c.raisedEvents],p=[...c.emittedEvents],m=[ig(c,i)],h=0,g=0;for(;;){if(g+=1,g>1e3)throw new Ad({machineId:e.id,state:t.nodes[t.leafIndices.find(e=>l.active[e]===1)].path,maxIterations:zh});if(t.finalIndices.some(e=>l.active[e]===1)){let n=fm(e,sg(t,l),u).configuration;if(l=og(t,n),am(e,n)){let t=Mp(e,n);if(!n.outputs.has(t))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:o,next:l,commands:d,emittedEvents:p,microsteps:m,done:!0,output:n.outputs.get(t)}}}let n=f[h];if(n===void 0)return{event:o,next:l,commands:d,emittedEvents:p,microsteps:m,done:!1,output:void 0};h+=1,u=n;let r=pg(e,t,l,n,a);if(r.length===0)continue;let s=_g(e,t,l,n,r,i);l=s.next,d.push(...s.commands),f.push(...s.raisedEvents),p.push(...s.emittedEvents),m.push(ig(s,i))}},bg=new WeakMap,xg=e=>({fromConfiguration:e=>e,toConfiguration:e=>e,snapshot:t=>Lp(e,t),plan:(t,n,r,i)=>Kh(e,i===void 0?t:yp(t,i),n)}),Sg=(e,t)=>({fromConfiguration:e=>og(t,e),toConfiguration:e=>sg(t,e),snapshot:e=>lg(t,e),plan:(n,r,i=!1,a)=>yg(e,t,n,r,i,a),...Object.values(Ld(e).handlers).some(e=>e.initialize!==void 0&&!km(e.initialize))?{}:{initial:(n,r)=>{let i=e.input===void 0?n:n.length===0?(up(e,e.input,void 0),n):[up(e,e.input,n[0])],a=e.initial(...i),o=hf(a)?ch(e,{active:new Set,values:new Map,outputs:new Map,history:new Map,...r===void 0?{}:{machineReferences:r}},a,Bh).configuration:Wp(e,a),s=fm(e,r===void 0?o:yp(o,r),Bh).configuration,c=og(t,s),l=lg(t,c);if(!am(e,s))return{state:l,configuration:c,activeConfiguration:s,initialEntryPaths:Fp(e,s),done:!1,output:void 0};let u=Mp(e,s);if(!s.outputs.has(u))throw Error(`Machine reached a terminal configuration without a completed root output`);return{state:l,configuration:c,activeConfiguration:s,initialEntryPaths:Fp(e,s),done:!0,output:s.outputs.get(u)}}}}),Cg=e=>{let t=bg.get(e);if(t!==void 0)return t;let n=ng(e),r=n===void 0?xg(e):Sg(e,n);return bg.set(e,r),r},wg=`Machine.invocation:`,Tg=e=>e.startsWith(wg),Eg=(e,t)=>{if(e.values===void 0?e.values=[t]:e.values.push(t),e.waiter!==void 0){let t=e.waiter;e.waiter=void 0,ti(t,B)}},Dg=e=>U(()=>{if(e.values!==void 0){let t=e.values;return e.values=void 0,T(t)}let t=at();return e.waiter=t,si(t).pipe(L(Dg(e)))}),Og=(e,t)=>e._tag===`Started`&&(typeof t==`string`||e.descriptor!==void 0&&e.descriptor.id===t.id&&e.descriptor.machine===t.machine),kg=(e,t,n)=>{if(e.closed)return z();let r=e.children.get(t);return r!==void 0&&Og(r,n)?qe(r.ref):z()},Ag=e=>{if(e.observers!==void 0)for(let t of e.observers)Eg(t,kg(e,t.id,t.child))},jg=(e,t,n)=>{let r=e.children.get(t);r!==void 0&&r.token===n&&(e.children.delete(t),typeof t==`string`&&Ag(e))},Mg=(e,t,n,r,i)=>{let a=e.children.get(t);if(e.closed||a===void 0||a._tag!==`Starting`||a.token!==n)return!1;e.children.delete(t);let o=a.ownerKey===void 0?{_tag:`Started`,token:n,descriptor:i,ref:r}:{_tag:`Started`,token:n,descriptor:i,ref:r,ownerKey:a.ownerKey,ownerPath:a.ownerPath,ownerActive:a.ownerActive===!0};return e.children.set(t,o),typeof t==`string`&&Ag(e),!0},Ng=e=>Vr(function*(){let t=yield*vt(),n=0,r=0,i=0,a=0;return{rootSessionId:e,stream:ni(t).pipe(w(K(()=>{n+=1})),Gr(K(()=>{--n}))),isActive:()=>n>0,nextDeliveryId:()=>i++,nextMacrostepId:()=>a++,publishUnsafe:i=>{n!==0&&xe(t,{...i,sequence:r++,rootSessionId:e})},close:Ye(t)}}),Pg=e=>({id:e.id,sessionId:e.sessionId}),Fg=e=>e.flatMap(e=>{if(typeof e!=`object`||!e||!(`_tag`in e))return[];if(e._tag===`SendTo`&&`target`in e&&`event`in e){let t=e.target;return typeof t==`object`&&t&&`id`in t?[{_tag:`SendTo`,target:`sessionId`in t?Pg(t):{id:String(t.id)},event:e.event}]:[]}if(e._tag===`Stop`&&`child`in e){let t=e.child;return typeof t==`string`?[{_tag:`Stop`,target:{id:t}}]:typeof t==`object`&&t&&`id`in t?[{_tag:`Stop`,target:`sessionId`in t?Pg(t):{id:String(t.id)}}]:[]}return[]}),Ig=e=>typeof e!=`object`||!e||!(`microsteps`in e)||!Array.isArray(e.microsteps)?[]:e.microsteps.map(e=>({event:e.event,transitions:Array.isArray(e.transitions)?e.transitions:[],raisedEvents:Array.isArray(e.raisedEvents)?e.raisedEvents:[],emittedEvents:Array.isArray(e.emittedEvents)?e.emittedEvents:[],commands:Fg(Array.isArray(e.commands)?e.commands:[]),exitPaths:Array.isArray(e.exitPaths)?e.exitPaths:[],entryPaths:Array.isArray(e.entryPaths)?e.entryPaths:[],changed:e.changed===!0})),Lg=Symbol.for(`effect/Machine/activeSnapshotObserver`),Rg=Symbol.for(`effect/Machine/snapshotObserver`),zg=e=>typeof e==`object`&&!!e&&Rg in e,Bg=Symbol.for(`effect/Machine/sendParentOverride`),Vg=Symbol.for(`effect/Machine/acknowledgedSend`),Hg=Symbol(`effect/Machine/AcknowledgedMessage`),Ug=e=>typeof e==`object`&&!!e&&Hg in e,Wg=e=>Ug(e)?e.event:e,Gg=(e,t)=>{e!==void 0&&Ug(e)&&(e.deferred!==void 0&&ti(e.deferred,T(t)),e.inspection?.complete(t))},Kg=(e,t)=>{e!==void 0&&Ug(e)&&e.deferred!==void 0&&ti(e.deferred,Fn(t))},qg=e=>{e!==void 0&&Ug(e)&&e.deferred!==void 0&&ti(e.deferred,wr(new Nd))},Jg=e=>typeof e==`object`&&!!e&&`send`in e&&typeof e.send==`function`,Yg=(e,t,n,r)=>`inspectionSubject`in e&&`sendInspected`in e&&typeof e.sendInspected==`function`?e.sendInspected(t,n,r):e.send(t),Xg=e=>e?._tag===`Childless`||e?.childless===!0,Zg=(e,t)=>{let n=e.items??[];e.items=n,n.push(t)},Qg=e=>{if(e.items===void 0)return z();let t=e.items[e.index];return e.index+=1,e.index===e.items.length&&(e.items=void 0,e.index=0),qe(t)},$g=e=>{if(e.items!==void 0)for(let t=e.index;t<e.items.length;t+=1)qg(e.items[t]);e.closed=!0,e.items=void 0,e.index=0},e_=()=>({items:void 0,index:0,closed:!1,receivers:new Set}),t_=(e,t,n)=>{if(e.closed)return!1;for(Zg(e,t),n?.();e.items!==void 0&&e.receivers.size>0;){let t=e.receivers.values().next().value;e.receivers.delete(t),t(B)}return!0},n_=e=>U(()=>{let t=Qg(e);return we(t)?T(t.value):e.closed?cn:Mt(t=>(e.receivers.add(t),K(()=>{e.receivers.delete(t)}))).pipe(L(n_(e)))}),r_=e=>{$g(e);let t=Array.from(e.receivers);e.receivers.clear();for(let e of t)e(cn)},i_=class extends jt()(`effect/Machine/MachineRuntime`){},a_=(e,t)=>Kr(e,i_,t),o_=e=>{switch(e.status){case`active`:return;case`done`:return{_tag:`Done`,output:e.output,snapshot:e};case`error`:{let t=e.cause.reasons.find(ie);if(t!==void 0)return{_tag:`Failure`,error:t.error,cause:e.cause,snapshot:e};let n=e.cause.reasons.find(_t);return n===void 0?e.cause.reasons.find(dt)===void 0?{_tag:`Cause`,cause:e.cause,snapshot:e}:{_tag:`Interrupted`,cause:e.cause,snapshot:e}:{_tag:`Defect`,defect:n.defect,cause:e.cause,snapshot:e}}case`stopped`:return{_tag:`Stopped`,snapshot:e}}},s_=(e,t)=>U(()=>e(t)).pipe(or,yr),c_=(e,t)=>{class n{nextSessionId;constructor(){let e=0;this.nextSessionId=K(()=>`machine:${e++}`)}get start(){return e}get startCompiledSync(){return t}}return K(()=>new n)},l_=(e,t,n)=>({id:t,sessionId:n,kind:e.inspection?.kind??`Logic`}),u_=(e,t)=>t?{_tag:`Initialization`}:e!==void 0&&Ug(e)&&e.inspection!==void 0?{_tag:`Macrostep`,macrostepId:e.inspection.macrostepId}:void 0,d_=(e,t,n,r,i,a)=>{let o=e.nextDeliveryId(),s=e.nextMacrostepId(),c={deliveryId:o,macrostepId:s,source:r,event:n,causedBy:i,complete:i=>{let a=Ig(i.plan);e.publishUnsafe({_tag:`EventProcessed`,subject:t,macrostepId:s,deliveryId:o,source:r,event:n,before:{status:`active`,state:i.before},after:{status:`active`,state:i.after},handled:a.some(e=>e.transitions.length>0),configurationChanged:a.some(e=>e.changed),microsteps:a})}};return{[Hg]:!0,event:n,...a===void 0?void 0:{deferred:a},inspection:c}},f_=(e,t,n)=>{if(!Ug(n)||n.inspection===void 0)return;let r=n.inspection;e.publishUnsafe({_tag:`EventSent`,subject:t,deliveryId:r.deliveryId,source:r.source,target:Pg(t),event:r.event,causedBy:r.causedBy})},p_=class{registry;self;runtime;services;sendAcknowledged;scopedServices;constructor(e,t,n,r,i){this.registry=e,this.self=t,this.runtime=n,this.services=r,this.sendAcknowledged=i}has(e){for(let t of this.registry.children.values())if(t.ownerActive&&t.ownerKey===e)return!0;return!1}stopEntry(e){return e.ownerActive=!1,e._tag===`Started`?e.ref.stop:B}spawn(e,t){let n=Symbol(),r,i=()=>{let e=this.registry.children.get(t.id);return e?.token===n&&e.ownerKey===t.key&&e.ownerActive===!0};return U(()=>{if(this.registry.closed)return cn;if(this.has(t.key)||this.registry.children.has(t.id))return wr(new Md({id:t.duplicateId}));let a=e(),o=this.registry.scope??=Bt(`parallel`);this.registry.children.set(t.id,{_tag:`Starting`,token:n,ownerKey:t.key,ownerPath:t.path,ownerActive:!0});let s={...this.self,send:e=>t.sendParent(i,e),sendInspected:(e,t,n)=>i()?Yg(this.self,e,t,n):B,...this.sendAcknowledged===void 0?void 0:{[Vg]:e=>i()?this.sendAcknowledged(e):cn}},c={detached:!0,id:t.id,sendParent:e=>t.sendParent(i,e),onOutcome:e=>t.onOutcome(i,e,r?.sessionId),...t.onSnapshot===void 0?void 0:{onSnapshot:e=>t.onSnapshot(i,e)},onReadySync:e=>(r=e,Mg(this.registry,t.id,n,e,t.descriptor)),onStopSync:()=>jg(this.registry,t.id,n),skipStoppedOutcome:!0,parent:s,runtime:this.runtime,origin:{_tag:`Invoke`,ownerPath:t.path,invokeId:t.duplicateId},...t.activityKind===void 0||this.runtime.inspection===void 0||this.self.inspectionSubject===void 0?void 0:{activity:{id:t.duplicateId,owner:this.self.inspectionSubject,ownerPath:t.path,kind:t.activityKind}}},l=a.execution,u=this.services!==void 0&&t.onSnapshot===void 0&&l?._tag===`Compiled`&&l.childless&&l.drain._tag===`Owned`&&l.initialSync!==void 0,d=(u?G(this.runtime.nextSessionId,e=>this.runtime.startCompiledSync(a,c,this.scopedServices??=Et(this.services,Qn,o),e)):this.runtime.start(a,c)).pipe(wn(e=>Rn(e)?B:(jg(this.registry,t.id,n),r===void 0?B:r.stop)));return(u?d:Wr(d,o)).pipe(yr)})}stopAll(){return U(()=>{let e=[];for(let t of this.registry.children.values())t.ownerActive&&e.push(this.stopEntry(t));return e.length===0?B:e.length===1?e[0]:wt(e,{concurrency:`unbounded`,discard:!0})})}stopPaths(e){if(e.length===0)return;let t=new Set(e),n=[];for(let e of this.registry.children.values())e.ownerActive&&e.ownerPath!==void 0&&t.has(e.ownerPath)&&n.push(this.stopEntry(e));return n.length===0?void 0:n.length===1?n[0]:wt(n,{concurrency:`unbounded`,discard:!0})}},m_=l(z()).pipe(Cn(A)),h_=e=>B,g_=(e,t)=>{},__=()=>void 0,v_=Symbol(`effect/Machine/EmissionsClosed`),y_=()=>{let e,t=U(()=>{let t=e;return t===v_?T(void 0):t===void 0?vt().pipe(G(t=>K(()=>{let n=e;return n===v_?[void 0,!0]:n===void 0?(e=t,[t,!1]):[n,!0]}).pipe(G(([e,n])=>n?Ye(t).pipe(ge(e)):T(e))))):T(t)});return{emit:t=>U(()=>e===void 0||e===v_?B:ce(e,t).pipe(yr)),close:()=>{let t=e;return e=v_,t===void 0||t===v_?B:Ye(t)},stream:je(t.pipe(hr(e=>e===void 0?Vt:ni(e))))}},b_={close:()=>B,spawn:(()=>mn(Error(`Childless machine logic cannot spawn a process`))),get:()=>T(z()),changes:()=>m_,sendTo:()=>B,stop:()=>B,owned:{spawn:()=>mn(Error(`Childless machine logic cannot spawn an owned process`)),stopAll:()=>B,stopPaths:()=>void 0}},x_=(e,t,n,r)=>{let i={closed:!1,children:new Map,observers:void 0,scope:void 0},a=e=>U(()=>{if(i.closed||(i.closed=!0,i.scope===void 0))return B;let t=Sn(i.scope,e),n,r;for(let e of i.children.values())e._tag===`Started`&&(n===void 0?n=e.ref.stop:(r??=[n],r.push(e.ref.stop)));t!==void 0&&(n===void 0?n=t:(r??=[n],r.push(t)));let a=r??n;return a===void 0?B:Array.isArray(a)?wt(a,{concurrency:`unbounded`,discard:!0}):a}),o=(e,t)=>K(()=>jg(i,e,t)),s=(e,t,n,r)=>K(()=>Mg(i,e,t,n,r)),l=e=>{let t=typeof e==`string`?e:e.id;return K(()=>{if(i.closed)return z();let n=i.children.get(t);return n!==void 0&&Og(n,e)?qe(n.ref):z()})},u=e=>{let t=typeof e==`string`?e:e.id;return Zt(P((n,r)=>K(()=>({child:e,id:t,values:void 0,waiter:void 0})).pipe(G(n=>{let a=K(()=>{i.observers!==void 0&&(i.observers.delete(n),i.observers.size===0&&(i.observers=void 0)),n.values=void 0,n.waiter=void 0});return Dn(r,a).pipe(L(K(()=>{!i.closed&&r.state._tag!==`Closed`&&(i.observers??=new Set,i.observers.add(n)),Eg(n,kg(i,t,e))})),ge(Dg(n)))}))))},d=(e,t,n,r)=>{let a=typeof e==`string`?e:e.id;return U(()=>{if(i.closed)return B;let o=i.children.get(a);return o!==void 0&&Og(o,e)?Yg(o.ref,t,n,r):B})},f=e=>{let t=typeof e==`string`?e:e.id;return U(()=>{if(i.closed)return B;let n=i.children.get(t);return n!==void 0&&Og(n,e)?n.ref.stop:B})};function p(n,r){let a=typeof n==`object`&&n&&Dm in n?n:void 0,l=a===void 0?n:a[Dm](r?.input),u=a===void 0?r:{id:a.id,descriptor:a},d=Symbol(),f=u?.id??d,p;return U(()=>i.closed?cn:typeof f==`string`&&(i.children.has(f)||Tg(f))?wr(new Md({id:f})):(i.scope??=Bt(`parallel`),i.children.set(f,{_tag:`Starting`,token:d}),t.start(l,{detached:!0,...u?.id===void 0?void 0:{id:u.id},...u?.onOutcome===void 0?void 0:{onOutcome:u.onOutcome},...u?.[Lg]===void 0?void 0:{onSnapshot:u[Lg]},...u?.[Bg]===void 0?void 0:{sendParent:u[Bg]},onReady:(e,t)=>K(()=>{p=e}).pipe(L(s(f,d,e,u?.descriptor)),G(e=>e?B:t)),onStop:o(f,d),parent:e,runtime:t,origin:{_tag:`Spawn`,address:u?.id}}).pipe(wn(e=>c(e)?o(f,d).pipe(L(p===void 0?B:p.stop)):B),Wr(i.scope))))}return{close:a,spawn:p,get:l,changes:u,sendTo:d,stop:f,owned:new p_(i,e,t,n,r)}},S_=(e,t,n,r)=>K(()=>x_(e,t,n,r)),C_=(e,t)=>`${e.length}:${e}${t}`,w_=(e,t)=>`${wg}${C_(e,t)}`,T_=e=>({initial:()=>B,run:()=>e}),E_=(e,t,n)=>({initial:()=>B,run:({parent:r})=>{let i=r?.[Vg];return i===void 0?mn(Error(`Stream invocation requires an acknowledged parent machine`)):Gn(e,e=>i(Jm(t,n,e)).pipe(yr,Dt(()=>cn)))}}),D_=(e,t)=>typeof e==`function`?e(t):e,O_=e=>({spawn:((t,n)=>e.spawn(t,n)),sendTo:((t,n)=>e.sendTo(t,n)),stop:(t=>e.stopChild(t))}),k_=(e,t,n)=>{if(`effect`in e)return{id:String(e.id),sourceName:e.sourceName,src:()=>T_(e.effect(t)),onDone:e.onDone,onFailure:e.onFailure,onSnapshot:e.onSnapshot,activityKind:`Effect`};if(`after`in e)return{id:String(e.id),sourceName:e.sourceName,src:()=>T_(j(D_(e.after,t))),onDone:e.onDone,activityKind:`Timer`};if(`stream`in e){let r=String(e.id);return{id:r,sourceName:e.sourceName,src:()=>E_(e.stream(t),n,r),onDone:e.onDone,onFailure:e.onFailure,activityKind:`Stream`}}if(`logic`in e)return{id:String(e.id),address:String(e.address),src:()=>D_(e.logic,t),onDone:e.onDone,onFailure:e.onFailure,onSnapshot:e.onSnapshot};if(`child`in e){let n=e.child;return{id:n.id,address:n.id,descriptor:n,src:()=>n[Dm](`input`in e?D_(e.input,t):void 0),onDone:e.onDone,onFailure:e.onFailure,onSnapshot:e.onSnapshot}}throw Error(`Unsupported captured machine invocation: ${String(e)}`)},A_=e=>e.length===0?B:e.length===1?e[0]:wt(e,{discard:!0}),j_=(e,t,n)=>(n===void 0||e.self.sendInspected===void 0?e.self.send(t):e.self.sendInspected(t,e.self.inspectionSubject,{_tag:`Activity`,activitySessionId:n})).pipe(We(`StoppedError`,()=>B)),M_=e=>e instanceof Ad||e instanceof kd||e instanceof Nd,N_=(e,t,n,r,i,a,o,s,c,l,u,d)=>U(()=>{let f=C_(n,r),p=u===void 0?o:()=>{let t=o();return{...t,run:i=>Xe(U(()=>t.run(i)),`Machine.invoke`,{attributes:{"machine.id":e.self.id,"machine.sessionId":e.self.sessionId,"machine.state.path":n,"machine.invoke.id":r,"machine.invoke.source":d??r,"machine.invoke.kind":u,"machine.invoke.sessionId":i.self.sessionId},captureStackTrace:!1})}};return t.spawn(p,{key:f,path:n,id:i,duplicateId:r,...a===void 0?void 0:{descriptor:a},...u===void 0?void 0:{activityKind:u},sendParent:(t,n)=>t()?e.self.send(n):B,onOutcome:(t,i,o)=>L(hi,U(()=>i._tag===`Stopped`||!t()?B:i._tag===`Done`?s===void 0?e.failCause(se(Error(`Invocation "${r}" completed without the required onDone handler`))):j_(e,qm(n,r,i.output),u===void 0?void 0:o):i._tag===`Failure`&&c!==void 0&&(a===void 0||!M_(i.error))?j_(e,Ym(n,r,i.error),u===void 0?void 0:o):e.failCause(i.cause))),...l===void 0?void 0:{onSnapshot:(t,i)=>t()?j_(e,Xm(n,r,i)):B}})}),P_=(e,t)=>Tg(e)?wr(new Md({id:t})):void 0,F_=(e,t,n,r)=>{let i=String(r.id),a=r.address===void 0?void 0:P_(String(r.address),i);return a===void 0?N_(e,t,n,i,r.address===void 0?w_(n,i):String(r.address),r.descriptor,r.src,r.onDone,r.onFailure,r.onSnapshot,r.activityKind,r.sourceName):a},I_=(e,t,n,r)=>{let i=r.child,a=P_(i.id,i.id);return a===void 0?N_(e,t,n,i.id,i.id,i,i[Dm],r.onDone,r.onFailure,r.onSnapshot,void 0):a},L_=(e,t,n,r,i,a)=>{let o=O_(t),s=yh(e,i).filter(e=>r.active.has(e)).flatMap(i=>{let s={...bp(r)??{self:t.self,parent:t.parent},children:o,state:r.values.get(i),containingState:Pp(e,r,i),ancestors:Np(e,r,i),event:a};return Rm(em(e,i)?.invoke).map(e=>`child`in e&&!(`input`in e)?I_(t,n,i,e):F_(t,n,i,k_(e,s,i)))});return s.length===0?void 0:A_(s)},R_=Symbol(`effect/Machine/CompiledStoppedCompletion`),z_=class{logic;options;services;id;sessionId;inspectionSubject;send;sendInspected(e,t,n){return this.offerEvent(e,t,n)}[Vg](e){return this.sendAcknowledgedEffect(e)}[Rg](e){let t=this.snapshotObservers??=new Set;return t.add(e),()=>{t.delete(e)}}mailbox={items:void 0,index:0,closed:!1};address;childRuntime=b_;processScope;processContext;compiledContext;current;lifecycle=`Active`;runState=`Initializing`;completion;waiter;termination;terminationSnapshot;worker;interruptRequested=!1;offerRevision=0;snapshotObservers;changesFlushScheduled=!1;inFlightMessage;externalEmissions;emissionsPubSub;activity;initialEntryPaths;initialMicrosteps;initializing;constructor(e,t,n,r){this.logic=e,this.options=t,this.services=n,this.sessionId=r,this.id=t.id??r;let i=t.runtime.inspection;i!==void 0&&(this.inspectionSubject=l_(e,this.id,r),this.initializing=!0,t.activity!==void 0&&(this.activity={...t.activity,sessionId:r})),this.externalEmissions=t.emissions,this.send=i===void 0?e=>this.offerMessage(e):e=>this.offerEvent(e,void 0,void 0),this.address={id:this.id,sessionId:r,stop:U(()=>this.stopFromProcess()),send:this.send,...i===void 0?void 0:{inspectionSubject:this.inspectionSubject,sendInspected:(e,t,n)=>this.offerEvent(e,t,n)}}}get inspector(){return this.options.runtime.inspection}causation(){return u_(this.inFlightMessage,this.initializing===!0)}publishCreated(){let e=this.inspector,t=this.inspectionSubject;e!==void 0&&t!==void 0&&e.publishUnsafe(this.activity===void 0?{_tag:`Created`,subject:t,parent:this.options.parent?.inspectionSubject,origin:this.options.origin??{_tag:`Root`},definition:this.logic.inspection?.definition}:{_tag:`ActivityStarted`,subject:this.activity.owner,activity:this.activity})}publishInitialized(e){if(this.initializing=!1,this.activity!==void 0)return;let t=this.inspector,n=this.inspectionSubject;t!==void 0&&n!==void 0&&t.publishUnsafe({_tag:`Initialized`,subject:n,snapshot:{status:`active`,state:e},initialEntryPaths:this.initialEntryPaths??[],microsteps:Ig({microsteps:this.initialMicrosteps??[]})})}publishStartFailed(e){this.initializing=!1;let t=this.inspector,n=this.inspectionSubject;t!==void 0&&n!==void 0&&t.publishUnsafe(this.activity===void 0?{_tag:`StartFailed`,subject:n,cause:e}:{_tag:`ActivityStopped`,subject:this.activity.owner,activity:this.activity,exit:Ie(e)})}get execution(){return this.logic.execution}initializeCompiledSync(){this.publishCreated(),this.execution.childless||(this.childRuntime=x_(this.address,this.options.runtime,this.services,e=>this.sendAcknowledgedEffect(e)));let e=this.options.parent,t=this.options.sendParent??(e===void 0?h_:this.inspector===void 0?e.send:t=>Yg(e,t,this.inspectionSubject,this.causation()));this.processScope={self:this.address,parent:e,spawn:this.childRuntime.spawn,sendParent:t,emit:e=>this.emitEvent(e),sendTo:((e,t)=>Jg(e)?this.inspector===void 0?e.send(t):Yg(e,t,this.inspectionSubject,this.causation()):this.childRuntime.sendTo(e,t,this.inspectionSubject,this.causation())),stopChild:this.childRuntime.stop,failCause:e=>this.failCause(e),inspectInitial:this.inspector===void 0?g_:(e,t=[])=>{this.initialEntryPaths=e,this.initialMicrosteps=t}};let n=this.execution.initialSync,r;try{r=n(this.processScope)}catch(e){return this.runState=`Idle`,this.publishStartFailed(be(e)),wr(e)}return this.runState=`Idle`,this.current={revision:0,terminalizing:!1,changes:void 0,snapshot:{status:`active`,state:r.state}},this.publishInitialized(r.state),this.compiledContext=new B_(this.processScope,this.childRuntime.owned,this),`executionState`in r&&(this.compiledContext.executionState=r.executionState),this.options.onReadySync!==void 0&&!this.options.onReadySync(this)&&this.requestTerminationSync({_tag:`Stopped`}),r.done===!0&&this.lifecycle===`Active`&&this.requestTerminationSync({_tag:`Done`,output:r.output}),r.done===!1&&this.execution.childless&&this.lifecycle===`Active`&&this.mailbox.items===void 0?T(this):(this.runState=`Draining`,Ht(this.drainRuntime(),this.services).pipe(ge(this)))}initialize(){let e=this;return Vr(function*(){e.publishCreated(),e.execution.childless||(e.childRuntime=yield*S_(e.address,e.options.runtime,e.services,t=>e.sendAcknowledgedEffect(t)));let t=e.options.parent,n=e.options.sendParent??(t===void 0?h_:e.inspector===void 0?t.send:n=>Yg(t,n,e.inspectionSubject,e.causation()));e.processScope={self:e.address,parent:t,spawn:e.childRuntime.spawn,sendParent:n,emit:t=>e.emitEvent(t),sendTo:((t,n)=>Jg(t)?e.inspector===void 0?t.send(n):Yg(t,n,e.inspectionSubject,e.causation()):e.childRuntime.sendTo(t,n,e.inspectionSubject,e.causation())),stopChild:e.childRuntime.stop,failCause:t=>e.failCause(t),inspectInitial:e.inspector===void 0?g_:(t,n=[])=>{e.initialEntryPaths=t,e.initialMicrosteps=n}};let r=t=>c(t)?e.childRuntime.close(t):B,i=e.execution.initial,a=yield*(i===void 0?e.logic.initial(e.processScope).pipe(hr(e=>({state:e,done:void 0,output:void 0}))):i(e.processScope)).pipe(wn(t=>(c(t)&&e.publishStartFailed(t.cause),r(t))),Ir(K(()=>{e.runState=`Idle`}))),o=a.state;return e.current={revision:0,terminalizing:!1,changes:void 0,snapshot:{status:`active`,state:o}},e.publishInitialized(o),e.execution.drain._tag===`Process`?e.processContext={...e.processScope,receive:kn,poll:K(()=>Re(Qg(e.mailbox),Wg)),receiveMessage:kn,pollMessage:K(()=>e.pollCompiledMessage()),completeMessage:t=>e.completeCompiledMessage(t),state:K(()=>e.current.snapshot.state),setState:t=>e.setActiveState(t),updateState:t=>e.updateState(t)}:(e.compiledContext=new B_(e.processScope,e.childRuntime.owned,e),`executionState`in a&&(e.compiledContext.executionState=a.executionState)),e.options.onReadySync!==void 0&&!e.options.onReadySync(e)?yield*e.requestTermination({_tag:`Stopped`}):e.options.onReady!==void 0&&(yield*e.options.onReady(e,e.requestTermination({_tag:`Stopped`}).pipe(yr))),e.options.onSnapshot!==void 0&&(yield*s_(e.options.onSnapshot,{status:`active`,state:o})),a.done===!0&&e.lifecycle===`Active`&&(yield*e.requestTermination({_tag:`Done`,output:a.output})),a.done===!1&&e.execution.childless&&e.lifecycle===`Active`&&e.mailbox.items===void 0||(e.runState=`Draining`,yield*e.drainRuntime()),e})}get state(){return K(()=>this.current.snapshot.state)}get snapshot(){return K(()=>this.current.snapshot)}get changes(){return this.changesStream()}get emissions(){return this.externalEmissions?.stream??this.emissionsStream()}get join(){return U(()=>this.lifecycle===`Completed`?this.resolveCompletion(this.completion):(this.waiter??=at(),si(this.waiter)))}get stop(){return Ve(this.stopEffect())}child(e){return this.childRuntime.get(e)}childChanges(e){return this.childRuntime.changes(e)}requestTermination(e){return K(()=>this.requestTerminationSync(e))}hasTerminationRequest(){return this.lifecycle===`TerminationRequested`}requestTerminationSync(e){return this.lifecycle===`Active`&&(this.lifecycle=`TerminationRequested`,this.termination=e,this.terminationSnapshot=this.reserveTermination(e),!0)}reserveTermination(e){let t=this.current;if(t===void 0||t.terminalizing||t.snapshot.status!==`active`)return;let n=e._tag===`Stopped`?{status:`stopped`,state:t.snapshot.state}:e._tag===`Done`?{status:`done`,state:t.snapshot.state,output:e.output}:{status:`error`,state:t.snapshot.state,cause:e.cause};return this.current={...t,terminalizing:!0},n}stopFromProcess(){let e=this.requestTermination({_tag:`Stopped`}).pipe(yr);return this.runState===`Initializing`?e:e.pipe(L(cn))}failCause(e){let t={_tag:`Failure`,cause:e};return this.requestTermination(t).pipe(G(e=>e?Yn(this.settleRequestedTermination()).pipe(yr):B))}sendAcknowledgedEffect(e){return te(t=>Xr().pipe(G(n=>this.offerEvent(e,void 0,void 0,n).pipe(L(t(si(n)))))))}offerEvent(e,t,n,r){return U(()=>{let i=this.inspector,a=this.inspectionSubject,o=i?.isActive()===!0&&a!==void 0?d_(i,a,e,t,n,r):r===void 0?e:{[Hg]:!0,event:e,deferred:r};return this.offerMessage(o)})}offerMessage(e){return Ve(Se(t=>{if(this.mailbox.closed||this.lifecycle!==`Active`)return wr(new Nd);let n=this.inspector,r=this.inspectionSubject;n!==void 0&&r!==void 0&&f_(n,r,e),this.offerRevision+=1;let i=this.execution.drain,a=this.compiledContext,o=this.runState===`Idle`&&a!==void 0&&i._tag===`Owned`?i.runSync:void 0;if(o===void 0&&Zg(this.mailbox,e),this.runState!==`Idle`)return B;if(this.runState=`Draining`,o!==void 0){let n;try{n=o(a,e)}catch(e){n=mn(e)}return n!==void 0||this.hasTerminationRequest()?this.startWorker(n):(this.runState=`Idle`,this.scheduleChangesFlush(t.currentDispatcher),B)}return this.startWorker(void 0)}))}startWorker(e){let t=Ht(this.drainRuntime(e),this.services);return(this.options.detached===!0?Yn(t,{startImmediately:!0}):nn(t,{startImmediately:!0})).pipe(G(e=>K(()=>(e.pollUnsafe()===void 0&&(this.worker=e),this.interruptRequested?(this.interruptRequested=!1,!0):!1)).pipe(G(t=>t?Yn(this.interruptAndFinish(e)):B))),yr)}stopEffect(){return U(()=>this.lifecycle===`Completed`||this.finishIdleChildlessStop()?B:this.requestTermination({_tag:`Stopped`}).pipe(G(e=>e?this.settleRequestedTermination():this.awaitCompletion())))}finishIdleChildlessStop(){if(!this.execution.childless||this.runState!==`Idle`||this.worker!==void 0||this.lifecycle!==`Active`||this.options.onOutcome!==void 0&&this.options.skipStoppedOutcome!==!0||this.options.onStop!==void 0||this.inspector!==void 0||this.current.changes!==void 0||this.externalEmissions!==void 0||this.emissionsPubSub!==void 0&&this.emissionsPubSub!==v_||this.current.terminalizing||this.current.snapshot.status!==`active`)return!1;this.emissionsPubSub=v_;let e={status:`stopped`,state:this.current.snapshot.state};return this.lifecycle=`TerminationRequested`,this.termination={_tag:`Stopped`},this.terminationSnapshot=e,$g(this.mailbox),this.current={revision:this.current.revision+1,terminalizing:!0,changes:void 0,snapshot:e},this.notifySnapshotObservers(),qg(this.inFlightMessage),this.inFlightMessage=void 0,this.interruptRequested=!1,this.compiledContext!==void 0&&(this.compiledContext.executionState=void 0),this.options.onStopSync?.(this),this.completion=R_,this.lifecycle=`Completed`,this.waiter!==void 0&&(ti(this.waiter,this.resolveCompletion(R_)),this.waiter=void 0),!0}settleRequestedTermination(){return U(()=>this.runState===`Draining`?this.worker===void 0?(this.interruptRequested=!0,this.awaitCompletion()):this.interruptAndFinish(this.worker).pipe(L(this.awaitCompletion())):this.finishRequestedTermination())}interruptAndFinish(e){return ae(e).pipe(L(U(()=>this.lifecycle===`Completed`?B:this.finishRequestedTermination())))}awaitCompletion(){return this.lifecycle===`Completed`?B:this.join.pipe(or,yr)}resolveCompletion(e){if(e!==R_)return e;let t=wr(new Nd);return this.completion=t,t}drainRuntime(e){let t=this;return te(n=>Vr(function*(){let r=t.offerRevision,i=e;for(;;){if(t.hasTerminationRequest())return yield*t.finishRequestedTermination();let e=yield*n(U(()=>{if(i!==void 0){let e=i;return i=void 0,e}let e=t.execution.drain;return e._tag===`Process`?e.run(t.processContext):e.run(t.compiledContext)})).pipe(or);if(t.flushPendingChanges(),c(e))return t.lifecycle===`Active`&&(yield*t.requestTermination({_tag:`Failure`,cause:e.cause})),yield*t.finishRequestedTermination();if(we(e.value))return yield*t.requestTermination({_tag:`Done`,output:e.value.value}),yield*t.finishRequestedTermination();if(t.hasTerminationRequest())return yield*t.finishRequestedTermination();if(t.offerRevision!==r)r=t.offerRevision;else{t.runState=`Idle`,t.worker=void 0;return}}}))}finishRequestedTermination(){return U(()=>{if(this.lifecycle!==`TerminationRequested`)return B;let e=this.termination;if(e===void 0)return B;let t=this.terminationSnapshot??this.reserveTermination(e);if(t===void 0)return this.awaitCompletion();let n=e._tag===`Stopped`?Ae:e._tag===`Done`?Te(e.output):Ie(e.cause),r=e._tag===`Stopped`?R_:e._tag===`Done`?T(e.output):Fn(e.cause),i=this.options.onOutcome===void 0||e._tag===`Stopped`&&this.options.skipStoppedOutcome===!0?B:U(()=>this.options.onOutcome(o_(t))).pipe(or,yr),a=this.inspector,o=this.inspectionSubject,s=a===void 0||o===void 0?this.closeEmissions():this.closeEmissions().pipe(L(K(()=>a.publishUnsafe(this.activity===void 0?{_tag:`Terminated`,subject:o,snapshot:t}:{_tag:`ActivityStopped`,subject:this.activity.owner,activity:this.activity,exit:t.status===`stopped`?Wn():n}))));return Ve(K(()=>{$g(this.mailbox)}).pipe(L(this.childRuntime.close(n)),L(this.setAndPublishSnapshot(t)),L(s),L(K(()=>{e._tag===`Failure`?Kg(this.inFlightMessage,e.cause):qg(this.inFlightMessage),this.inFlightMessage=void 0})),L(i),L(this.options.onStop??B),L(this.options.inspectionRoot===!0&&this.inspector!==void 0?this.inspector.close:B),L(K(()=>{this.options.onStopSync?.(this),this.runState=`Idle`,this.worker=void 0,this.interruptRequested=!1,this.compiledContext!==void 0&&(this.compiledContext.executionState=void 0),this.completion=r,this.lifecycle=`Completed`,this.waiter!==void 0&&(ti(this.waiter,this.resolveCompletion(r)),this.waiter=void 0)}))))})}publishSnapshot(e){let t=e.changes===void 0?T(e):ce(e.changes,[e]).pipe(ge(e)),n=e.snapshot;return this.options.onSnapshot===void 0||n.status!==`active`?t:t.pipe(u(()=>s_(this.options.onSnapshot,n)))}completeChanges(e){return e.changes===void 0?B:ce(e.changes,Te(void 0)).pipe(yr)}emitEvent(e){let t=this.externalEmissions===void 0?U(()=>this.emissionsPubSub===void 0||this.emissionsPubSub===v_?B:ce(this.emissionsPubSub,e).pipe(yr)):this.externalEmissions.emit(e),n=this.inspector,r=this.inspectionSubject;return n===void 0||r===void 0?t:t.pipe(u(()=>K(()=>n.publishUnsafe({_tag:`Emitted`,subject:r,emission:e,causedBy:this.causation()}))))}shutdownEmissions(){return this.closeEmissions()}closeEmissions(){if(this.externalEmissions!==void 0)return this.externalEmissions.close();let e=this.emissionsPubSub;return this.emissionsPubSub=v_,e===void 0||e===v_?B:Ye(e)}getOrCreateEmissions(){return U(()=>{let e=this.emissionsPubSub;return e===v_?T(void 0):e===void 0?vt().pipe(G(e=>K(()=>{let t=this.emissionsPubSub;return t===v_?[void 0,!0]:t===void 0?(this.emissionsPubSub=e,[e,!1]):[t,!0]}).pipe(G(([t,n])=>n?Ye(e).pipe(ge(t)):T(t))))):T(e)})}emissionsStream(){return je(this.getOrCreateEmissions().pipe(hr(e=>e===void 0?Vt:ni(e))))}setAndPublishSnapshot(e){return U(()=>{this.flushPendingChanges();let t={revision:this.current.revision+1,snapshot:e,terminalizing:!0,changes:this.current.changes};return this.current=t,this.notifySnapshotObservers(),this.publishSnapshot(t).pipe(G(e=>this.completeChanges(e)),yr)})}setActiveState(e){return U(()=>this.commitActiveState(e)??B)}pollCompiledMessage(){let e=Qg(this.mailbox);return we(e)&&(this.inFlightMessage=Ug(e.value)?e.value:void 0),e}beginCompiledMessage(e){this.inFlightMessage=Ug(e)?e:void 0}completeCompiledMessage(e){Gg(this.inFlightMessage,e),this.inFlightMessage=void 0}compiledState(){return this.current.snapshot.state}commitCompiledState(e){return this.commitActiveState(e,!0)}commitActiveState(e,t=!1){let n=this.current;if(n.terminalizing||n.snapshot.status!==`active`)return;let r=n.pendingChanges;r!==void 0&&(n.pendingChanges=void 0);let i={status:`active`,state:e},a={revision:n.revision+1,snapshot:i,terminalizing:!1,changes:n.changes};return this.current=a,a.changes!==void 0&&(r===void 0?t?a.pendingChanges=[a]:xe(a.changes,[a]):(r.push(a),t?a.pendingChanges=r:xe(a.changes,r))),this.notifySnapshotObservers(),this.options.onSnapshot===void 0?void 0:s_(this.options.onSnapshot,i)}notifySnapshotObservers(){if(this.snapshotObservers!==void 0)for(let e of this.snapshotObservers)e()}scheduleChangesFlush(e){this.changesFlushScheduled||this.current.pendingChanges===void 0||(this.changesFlushScheduled=!0,e.scheduleTask(()=>{this.changesFlushScheduled=!1,this.flushPendingChanges()},0))}flushPendingChanges(){let e=this.current,t=e?.pendingChanges;t!==void 0&&e.changes!==void 0&&(e.pendingChanges=void 0,xe(e.changes,t))}updateState(e){return U(()=>{let t=this.current;return t.terminalizing||t.snapshot.status!==`active`?B:e(t.snapshot.state).pipe(G(e=>{let n=this.current;return n.terminalizing||n.revision!==t.revision?B:this.setActiveState(e)}))})}getOrCreateChanges(){return U(()=>{let e=this.current;return e.snapshot.status===`active`?e.changes===void 0?vt({replay:1}).pipe(G(e=>K(()=>{let t=this.current;return t.snapshot.status===`active`?t.changes===void 0?(this.current={...t,changes:e},[e,!1]):[t.changes,!0]:[void 0,!0]}).pipe(G(([t,n])=>n?Ye(e).pipe(ge(t)):T(t))))):T(e.changes):T(void 0)})}changesStream(){let e=this;return je(Vr(function*(){let t=yield*e.getOrCreateChanges();if(t===void 0)return l(e.current.snapshot);let n=yield*mi(t),r=e.current;return r.snapshot.status===`active`?l(r.snapshot).pipe(Cn(Zt(Be(f(n))).pipe(ci(e=>e.revision>r.revision),Zr(e=>e.snapshot)))):l(r.snapshot)}))}},B_=class{scope;ownedChildren;process;executionState;constructor(e,t,n){this.scope=e,this.ownedChildren=t,this.process=n}poll(){return Re(this.process.pollCompiledMessage(),Wg)}pollMessage(){return this.process.pollCompiledMessage()}beginMessage(e){this.process.beginCompiledMessage(e)}state(){return this.process.compiledState()}completeMessage(e){this.process.completeCompiledMessage(e)}commit(e){return this.process.commitCompiledState(e)}runAfterChanges(e){return this.process.flushPendingChanges(),e}},V_=dr(function*(e,t){let n=t.sessionId??(yield*t.runtime.nextSessionId),i=yield*r(),a=e.execution,o=new z_(e,t,i,n);return yield*(a.initialSync!==void 0&&t.onReady===void 0&&t.onSnapshot===void 0?o.initializeCompiledSync():o.initialize()).pipe(wn(e=>c(e)?o.shutdownEmissions().pipe(L(t.inspectionRoot===!0&&t.runtime.inspection!==void 0?t.runtime.inspection.close:B)):B))}),H_=(e,t,n,r)=>new z_(e,t,n,r).initializeCompiledSync(),U_=dr(function*(e,t){let{detached:n,id:r,onOutcome:i,onReady:a,onReadySync:o,onSnapshot:s,onStop:d,onStopSync:p,parent:m,runtime:h,sendParent:g}=t,v=t.sessionId??(yield*h.nextSessionId),y=r??v,b=h.inspection,x=b===void 0?void 0:l_(e,y,v),S=b===void 0||t.activity===void 0?void 0:{...t.activity,sessionId:v},w,E,D=e_(),O=t.emissions??y_(),A=yield*Xr(),j=yield*Xr(),M=si(j).pipe(or,yr),ee=!0,N,P=C(A,{_tag:`Stopped`}).pipe(yr),F=(e,t)=>U(()=>t_(D,e,t)?B:wr(new Nd)),I=b===void 0?void 0:(e,t,n,r)=>U(()=>{let i=b.isActive()?d_(b,x,e,t,n,r):r===void 0?e:{[Hg]:!0,event:e,deferred:r};return F(i,()=>f_(b,x,i))}),ne=e.execution?._tag===`Compiled`?e=>te(t=>Xr().pipe(G(n=>(b===void 0?F({[Hg]:!0,event:e,deferred:n}):I(e,void 0,void 0,n)).pipe(L(t(si(n))))),hr(e=>e))):void 0,re={id:y,sessionId:v,stop:U(()=>ee?P:P.pipe(L(kn))),send:b===void 0?e=>F(e):e=>I(e,void 0,void 0),...b===void 0?void 0:{inspectionSubject:x,sendInspected:I}},{changes:ie,close:oe,get:R,owned:z,sendTo:se,spawn:le,stop:ue}=b_;Xg(e.execution)||({changes:ie,close:oe,get:R,owned:z,sendTo:se,spawn:le,stop:ue}=yield*S_(re,h,void 0,ne===void 0?void 0:e=>ne(e)));let de=e=>Rn(e)?B:(b!==void 0&&b.publishUnsafe(S===void 0?{_tag:`StartFailed`,subject:x,cause:e.cause}:{_tag:`ActivityStopped`,subject:S.owner,activity:S,exit:e}),oe(e).pipe(L(O.close()),L(t.inspectionRoot===!0&&b!==void 0?b.close:B))),fe=p===void 0?d??B:K(()=>p(Je)),pe=b===void 0?__:()=>u_(N,ee),V=g??(m===void 0?h_:b===void 0?m.send:e=>Yg(m,e,x,pe())),me=b===void 0?O.emit:e=>O.emit(e).pipe(u(()=>K(()=>b.publishUnsafe({_tag:`Emitted`,subject:x,emission:e,causedBy:pe()})))),H={self:re,parent:m,spawn:le,sendParent:V,emit:me,sendTo:b===void 0?((e,t)=>Jg(e)?e.send(t):se(e,t)):((e,t)=>Jg(e)?Yg(e,t,x,pe()):se(e,t,x,pe())),stopChild:ue,failCause:e=>C(A,{_tag:`Failure`,cause:e}).pipe(yr),inspectInitial:b===void 0?g_:(e,t=[])=>{w=e,E=t}};b!==void 0&&b.publishUnsafe(S===void 0?{_tag:`Created`,subject:x,parent:m?.inspectionSubject,origin:t.origin??{_tag:`Root`},definition:e.inspection?.definition}:{_tag:`ActivityStarted`,subject:S.owner,activity:S});let he=yield*e.initial(H).pipe(wn(de),Ir(K(()=>{ee=!1}))),_e=yield*nr({revision:0,terminalizing:!1,changes:void 0,snapshot:{status:`active`,state:he}});S===void 0&&b?.publishUnsafe({_tag:`Initialized`,subject:x,snapshot:{status:`active`,state:he},initialEntryPaths:w??[],microsteps:Ig({microsteps:E??[]})});let ve=s===void 0?e=>e.changes===void 0?T(e):ce(e.changes,[e]).pipe(ge(e)):e=>{let t=e.changes===void 0?T(e):ce(e.changes,[e]).pipe(ge(e)),n=e.snapshot;return n.status===`active`?t.pipe(u(()=>s_(s,n))):t},ye=e=>e.changes===void 0?B:ce(e.changes,Te(void 0)).pipe(yr),be=e=>e.snapshot.status===`active`?T(e):ye(e).pipe(ge(e)),xe=e=>jr(_e).pipe(G(t=>t.revision===e.revision?ve(e).pipe(G(be)):T(void 0))),Se=e=>jn(_e,t=>t.terminalizing?T([void 0,t]):hr(e(t.snapshot),e=>{if(e===void 0)return[void 0,t];let n={revision:t.revision+1,snapshot:e,terminalizing:!1,changes:t.changes};return[n,n]})).pipe(G(e=>e===void 0?T(void 0):xe(e)),hr(e=>e?.snapshot)),Ce=e=>br(_e,t=>t.terminalizing||t.snapshot.status!==`active`?[void 0,t]:[{revision:t.revision+1,snapshot:e(t.snapshot),terminalizing:!0,changes:t.changes},{...t,terminalizing:!0}]).pipe(hr(e=>e?.snapshot)),Ee=e=>Wt(_e,t=>({revision:t.revision+1,snapshot:e,terminalizing:!0,changes:t.changes})).pipe(G(ve),G(be),yr),De=b===void 0?e=>Se(t=>T(t.status===`active`?{status:`active`,state:e}:void 0)).pipe(yr):t=>jr(_e).pipe(G(n=>Se(e=>T(e.status===`active`?{status:`active`,state:t}:void 0)).pipe(u(r=>K(()=>{e.inspection?.kind!==`Machine`&&r!==void 0&&b.publishUnsafe({_tag:`StateChanged`,subject:x,before:n.snapshot.state,after:t,causedByDeliveryId:N!==void 0&&Ug(N)?N.inspection?.deliveryId:void 0})})))),yr),Oe=(e,n,r)=>{let a=i===void 0||e.status===`stopped`&&t.skipStoppedOutcome===!0?B:U(()=>i(o_(e))).pipe(or,yr),o=b===void 0?O.close():O.close().pipe(L(K(()=>b.publishUnsafe(S===void 0?{_tag:`Terminated`,subject:x,snapshot:e}:{_tag:`ActivityStopped`,subject:S.owner,activity:S,exit:e.status===`stopped`?Wn():n}))));return Ve(K(()=>r_(D)).pipe(L(oe(n)),L(Ee(e)),L(o),L(K(()=>{c(n)?Kg(N,n.cause):qg(N),N=void 0})),L(a),L(fe),L(t.inspectionRoot===!0&&b!==void 0?b.close:B),L(r)))},ke=Ce(e=>({status:`stopped`,state:e.state})),Me=e=>Ce(t=>({status:`error`,state:t.state,cause:e})),Ne=e=>Ce(t=>({status:`done`,state:t.state,output:e})),Pe=e=>Oe(e,Ae,$e(j,new Nd)),Fe=(e,t)=>{let n=Ie(t);return Oe(e,n,_(j,t))},W=(e,t)=>{let n=Te(t);return Oe(e,n,C(j,t))},Le=Ve(P.pipe(L(M))),ze=e.execution?._tag===`Compiled`?{receiveMessage:n_(D).pipe(u(e=>K(()=>{N=Ug(e)?e:void 0}))),pollMessage:K(()=>Qg(D)).pipe(u(e=>K(()=>{we(e)&&(N=Ug(e.value)?e.value:void 0)}))),completeMessage:e=>{Gg(N,e),N=void 0}}:void 0,He=b===void 0||e.execution?._tag===`Compiled`?n_(D).pipe(hr(Wg)):n_(D).pipe(u(e=>K(()=>{N=e})),hr(Wg)),Ue=b===void 0||e.execution?._tag===`Compiled`?K(()=>Qg(D)).pipe(hr(Re(Wg))):K(()=>Qg(D)).pipe(u(e=>K(()=>{we(e)&&(N=e.value)})),hr(Re(Wg))),We=b===void 0?e=>Se(t=>t.status===`active`?e(t.state).pipe(hr(e=>({status:`active`,state:e}))):T(void 0)).pipe(yr):t=>jr(_e).pipe(G(n=>Se(e=>e.status===`active`?t(e.state).pipe(hr(e=>({status:`active`,state:e}))):T(void 0)).pipe(u(t=>K(()=>{e.inspection?.kind!==`Machine`&&t?.status===`active`&&b.publishUnsafe({_tag:`StateChanged`,subject:x,before:n.snapshot.state,after:t.state,causedByDeliveryId:N!==void 0&&Ug(N)?N.inspection?.deliveryId:void 0})})))),yr),Ge={...H,...e.execution?._tag===`Compiled`&&!e.execution.childless?{ownedChildren:z}:void 0,...ze,receive:He,poll:Ue,state:jr(_e).pipe(hr(e=>e.snapshot.state)),setState:De,updateState:We},Ke=jn(_e,e=>e.snapshot.status===`active`?e.changes===void 0?vt({replay:1}).pipe(hr(t=>[t,{...e,changes:t}])):T([e.changes,e]):T([void 0,e])),qe=je(Vr(function*(){let e=yield*Ke;if(e===void 0)return l((yield*jr(_e)).snapshot);let t=yield*mi(e),n=yield*jr(_e);return n.snapshot.status===`active`?l(n.snapshot).pipe(Cn(Zt(Be(f(t))).pipe(ci(e=>e.revision>n.revision),Zr(e=>e.snapshot)))):l(n.snapshot)})),Je={id:y,sessionId:v,...b===void 0?void 0:{inspectionSubject:x,sendInspected:I},state:jr(_e).pipe(hr(e=>e.snapshot.state)),snapshot:jr(_e).pipe(hr(e=>e.snapshot)),changes:qe,emissions:O.stream,join:si(j),stop:Le,send:re.send,...ne===void 0?void 0:{[Vg]:ne},child:R,childChanges:ie};o!==void 0&&!o(Je)?yield*P:a!==void 0&&(yield*a(Je,P)),s!==void 0&&(yield*s_(s,{status:`active`,state:he}));let Ye=e=>{switch(e._tag){case`Stopped`:return ke;case`Done`:return Ne(e.output);case`Failure`:return Me(e.cause)}},Xe=(e,t)=>{switch(e._tag){case`Stopped`:return Pe(t);case`Done`:return W(t,e.output);case`Failure`:return Fe(t,e.cause)}},Ze=e=>n===!0?Yn(e,{startImmediately:!0}):nn(e,{startImmediately:!0}),Qe=yield*k(A),et=Ln(Qe)?yield*te(t=>t(U(()=>e.run(Ge))).pipe(or,G(e=>C(A,c(e)?{_tag:`Failure`,cause:e.cause}:{_tag:`Done`,output:e.value})))).pipe(Ze):void 0;return yield*Ze(te(e=>Vr(function*(){let t=we(Qe)?yield*Qe.value:yield*e(si(A)),n=yield*Ye(t);return et!==void 0&&(yield*ae(et)),n===void 0?yield*M:yield*Xe(t,n)}))),Je}),W_=((e,t)=>e.execution?._tag===`Compiled`?V_(e,t):U_(e,t)),G_=c_(W_,H_),K_=new WeakMap,q_=e=>U(()=>{e.closed=!0;let t=Array.from(e.live).reverse();return e.live.clear(),kr(t,e=>e.stop,{discard:!0})}),J_=()=>{let e=new Set,t={live:e,hooks:{onReadySync:n=>!t.closed&&(e.add(n),!0),onStopSync:t=>{e.delete(t)}},closed:!1};return t},Y_=e=>G(Qr,t=>{let n=K_.get(t);if(n!==void 0)return e(n.hooks);let r=J_();return K_.set(t,r),L(Dn(t,q_(r)),e(r.hooks))});dr(function*(e,t,n){let r=yield*G_,i=n===void 0?{detached:!0,runtime:r}:{...n,detached:!0,runtime:r};return t===`generic`?yield*Y_(t=>U_(e,{...i,...t})):t===`compiled`?e.execution?._tag===`Compiled`?yield*Y_(t=>V_(e,{...i,...t})):yield*mn(Error(`Machine cannot force the compiled runtime for generic process logic`)):yield*Y_(t=>W_(e,{...i,...t}))});var X_=dr(function*(e,t){let n=yield*G_;return yield*Y_(r=>W_(e,t===void 0?{detached:!0,runtime:n,...r}:{...t,detached:!0,runtime:n,...r}))}),Z_=dr(function*(e,t,n){let r=yield*G_,i=yield*r.nextSessionId,a=yield*Ng(i);r.inspection=a;let o=y_(),s=yield*Xr(),c=n===void 0?{detached:!0,emissions:o,runtime:r,sessionId:i,inspectionRoot:!0,origin:{_tag:`Root`}}:{...n,detached:!0,emissions:o,runtime:r,sessionId:i,inspectionRoot:!0,origin:{_tag:`Root`}},l=yield*fe(Y_(n=>{let r={...c,...n};return t===`generic`?U_(e,r):t===`compiled`?e.execution?._tag===`Compiled`?V_(e,r):mn(Error(`Machine cannot force the compiled runtime for generic process logic`)):W_(e,r)}).pipe(wn(e=>Xt(s,e))));return{id:n?.id??i,sessionId:i,changes:je(si(s).pipe(hr(e=>e.changes))),emissions:o.stream,inspection:a.stream,start:l}}),Q_=((e,t)=>Z_(e,`auto`,t));q({_tag:$t(`MachineSnapshot`),version:$t(2),active:tr(q({path:W,value:V(ui)})),completed:V(tr(q({path:W,output:V(ui)}))),history:V(M(W,q({mode:ii([`shallow`,`deep`]),active:tr(W),values:M(W,ui)})))});var $_=(e,t,n)=>{let r=$(e,n);if(r.type===`compound`){let r=tm(e,t,n);if(r===void 0)throw Error(`Machine expected completed state "${n}" to have an active child`);return $_(e,t,r)}return r.output},ev=(e,t)=>Vr(function*(){let n=yield*Kp(e,t),r=new Map,i=new Set,a=t.completed??[];if(!Array.isArray(a))throw Error(`Machine snapshot completion metadata must be an array`);for(let t of a){if(typeof t!=`object`||!t||typeof t.path!=`string`)throw Error(`Machine snapshot contains malformed completion metadata`);let a=t.path;if(i.has(a))throw Error(`Machine snapshot contains duplicate completion "${a}"`);if(!n.active.has(a)||!im(e,n,a))throw Error(`Machine snapshot contains invalid completion "${a}"`);i.add(a);let o=$_(e,n,a);if(o===void 0){if(t.output!==void 0)throw Error(`Machine snapshot contains an output for state "${a}" without an output schema`);r.set(a,void 0)}else r.set(a,yield*Qf(e,o,t.output,{boundary:`output`,state:a}))}return Lp(e,{...n,outputs:r})}).pipe(Dt(t=>tv(e,t))),tv=(e,t)=>{if(pi(t))return Fn(Ct(t,t=>t instanceof kd?t:new kd({machineId:e.id,boundary:`configuration`,cause:be(t)})));let n=Je(t);return we(n)&&n.value instanceof kd?wr(n.value):wr(new kd({machineId:e.id,boundary:`configuration`,cause:t}))},nv=e=>e.length===0?B:e.length===1?e[0]:wt(e,{discard:!0}),rv=(e,t)=>({event:e.event,next:t(e.next),commands:e.commands,emittedEvents:e.emittedEvents,microsteps:e.microsteps.map(e=>({...e,transitions:e.transitions??[],next:t(e.next)})),done:e.done,output:e.output}),iv=new WeakMap,av=e=>{let t=iv.get(e);if(t!==void 0)return t;let n=Object.values(Ld(e).handlers).some(e=>e.invoke!==void 0);return iv.set(e,n),n},ov=T(z()),sv=(e,t)=>{let n=Cg(e),r=new WeakMap,i=t=>{let n=r.get(t.scope);return n===void 0&&(n=Jh(e,t.scope),r.set(t.scope,n)),n},a=n=>{if(!t)return;let r=n.state();return Vh(e,r)?Hh(e,r,Bh).pipe(hr(qe)):void 0},o=e=>U(()=>c(e)??ov),s=(e,t,r,a,s)=>{let c=a.commands.length===0?void 0:Yh(a.commands,e.scope),l=a.emittedEvents.length===0?void 0:Xh(a.emittedEvents,i(e)),u=()=>{let i=U(()=>(t&&e.completeMessage({before:r,plan:rv(a,n.snapshot),after:s}),a.done?T(qe(a.output)):o(e)));return l===void 0?i:l.pipe(L(i))},d=()=>{let t=e.commit(s),n=u(),r=t===void 0?n:t.pipe(L(n));return t===void 0&&l===void 0?r:e.runAfterChanges(r)};return c===void 0?d():e.runAfterChanges(c.pipe(L(U(d))))},c=(t,r)=>{let i=r;for(;;){let r;if(i!==void 0)r=i,i=void 0,t.beginMessage(r);else{let e=t.pollMessage();if(Ln(e))return;r=e.value}let a=Ug(r),c=a?r.event:r,l=t.state(),u;try{u=n.plan(t.executionState??n.fromConfiguration(Wp(e,l)),c,a,t.scope)}catch(e){return Fd(e)}if(t.executionState=u.next,u.microsteps.length===0){a&&t.completeMessage({before:l,plan:rv(u,n.snapshot),after:l});continue}let d=n.snapshot(u.next);if(u.commands.length>0||u.emittedEvents.length>0||u.done)return s(t,a,l,u,d);let f=t.commit(d);if(f!==void 0)return t.runAfterChanges(f.pipe(L(U(()=>(a&&t.completeMessage({before:l,plan:rv(u,n.snapshot),after:d}),o(t))))));a&&t.completeMessage({before:l,plan:rv(u,n.snapshot),after:d})}};return{run:e=>a_(a(e)??o(e),e.scope),runSync:(e,t)=>{let n=a(e);n!==void 0&&e.beginMessage(t);let r=n??c(e,t);return r===void 0?void 0:a_(r,e.scope)}}},cv=class{initialized=!1;initial;constructor(e){this.initial=e}},lv=(e,t)=>{let n=Cg(e);return r=>{let i=r.state();if(t&&Vh(e,i))return Hh(e,i,Bh).pipe(hr(qe));let a=r.scope,o=r.executionState,s=o instanceof cv?o:new cv;r.executionState=s;let c,l,u;return u=U(()=>{let t=r.pollMessage();if(Ln(t))return l=void 0,T(z());let o=t.value,s=Ug(o),d=s?o.event:o,f=i,p;try{p=n.plan(l??n.fromConfiguration(Wp(e,i)),d,s,a)}catch(e){return Fd(e)}if(l=p.next,p.microsteps.length===0)return s&&r.completeMessage({before:f,plan:rv(p,n.snapshot),after:i}),u;let m=p.microsteps.some(e=>e.changed),h=m?p.microsteps.flatMap(e=>e.exitPaths):[],g=new Map;if(m){for(let e of p.microsteps)if(e.changed)for(let t of e.entryPaths)g.set(t,e.event)}let _=n.toConfiguration(p.next),v=n.snapshot(p.next),y=[];if(p.commands.length>0&&y.push(Yh(p.commands,a)),m){let e=r.ownedChildren.stopPaths(h);e!==void 0&&y.push(e)}let b=[];if(p.emittedEvents.length>0&&b.push(Xh(p.emittedEvents,c??=Jh(e,a))),p.done)b.push(r.ownedChildren.stopAll());else if(m)for(let[t,n]of g){let i=L_(e,a,r.ownedChildren,_,[t],n);i!==void 0&&b.push(i)}let x=()=>{let e=r.commit(v);return i=v,e},S=()=>{let e=U(()=>(s&&r.completeMessage({before:f,plan:rv(p,n.snapshot),after:v}),p.done?T(qe(p.output)):u));return b.length===0?e:nv(b).pipe(L(e))},C=()=>{let e=x(),t=S(),n=e===void 0?t:e.pipe(L(t));return e===void 0&&b.length===0?n:r.runAfterChanges(n)};return y.length===0?C():r.runAfterChanges(nv(y).pipe(L(U(C))))}),a_(U(()=>{if(s.initialized)return u;let t=s.initial,o=t?.activeConfiguration??Wp(e,i);l=t?.configuration??n.fromConfiguration(o);let c=L_(e,a,r.ownedChildren,o,t?.entryPaths??Fp(e,o),Bh);return s.initial=void 0,s.initialized=!0,c===void 0?u:c.pipe(L(u))}),a)}},uv=e=>e.done?{state:e.state,done:!0,output:e.output}:{state:e.state,done:!1,output:void 0},dv=(e,t)=>{let n=av(e),r=Cg(e),i=t._tag===`Initial`?t.args:[],a=t._tag===`Initial`?r.initial:void 0,o=a===void 0?void 0:e=>{try{let t=a(i,e);e.inspectInitial(t.initialEntryPaths);let r=uv(t);return n?{...r,executionState:new cv({configuration:t.configuration,activeConfiguration:t.activeConfiguration,entryPaths:t.initialEntryPaths})}:r}catch(e){throw Id(e)}},s=t=>a===void 0?a_(qh(th(e,t),...i).pipe(G(n=>{t.inspectInitial(n.initialEntryPaths,n.microsteps);let r=n.commands.length===0?void 0:Yh(n.commands,t),i=n.emittedEvents.length===0?void 0:Xh(n.emittedEvents,Jh(e,t)),a=T(uv(n));return r===void 0?i===void 0?a:i.pipe(L(a)):i===void 0?r.pipe(L(a)):r.pipe(L(i),L(a))})),t):Me({try:()=>o(t),catch:Id});return{inspection:{kind:`Machine`,definition:e},execution:{_tag:`Compiled`,childless:!n,...t._tag===`Initial`?{initial:s}:{},...o===void 0?{}:{initialSync:o},drain:n?{_tag:`Owned`,run:lv(e,t._tag===`Resume`)}:{_tag:`Owned`,...sv(e,t._tag===`Resume`)}},initial:n=>t._tag===`Resume`?a_(ev(e,t.snapshot),n):s(n).pipe(hr(e=>e.state)),run:t=>a_(Vr(function*(){let{completeMessage:r,pollMessage:i,receiveMessage:a,state:o,setState:s}=t;if(r===void 0||i===void 0||a===void 0)return yield*mn(Error(`Machine statechart started without acknowledged mailbox access`));let c,l=yield*o;if(Vh(e,l))return yield*Hh(e,l,Bh);if(!n){let n,o=z(),u;for(;c===void 0;){let d=we(o)?o.value:yield*a;o=z();let f=Ug(d),p=f?d.event:d,m=l,h;try{h=Kh(e,yp(n??Wp(e,l),t),p)}catch(e){return yield*Fd(e)}if(n=h.next,h.microsteps.length>0){let n=Lp(e,h.next);yield*Yh(h.commands,t),yield*s(n),l=n,h.emittedEvents.length>0&&(yield*Xh(h.emittedEvents,u??=Jh(e,t))),h.done&&(c={output:h.output})}f&&r({before:m,plan:rv(h,t=>Lp(e,t)),after:l}),c===void 0&&(o=yield*i,Ln(o)&&(n=void 0))}return c===void 0?yield*mn(Error(`Machine process stopped receiving events before reaching a terminal configuration`)):c.output}let u=t.ownedChildren;if(u===void 0)return yield*mn(Error(`Invoking statechart started without an owned child runtime`));let d=(n,r,i)=>L_(e,t,u,n,r,i)??B,f=e=>u.stopPaths(e)??B;return yield*Vr(function*(){let n=yield*Kp(e,l);yield*d(n,Fp(e,n),Bh),n=void 0;let o=z(),p;for(;c===void 0;){let m=we(o)?o.value:yield*a;o=z();let h=Ug(m),g=h?m.event:m,_=l,v;try{v=Kh(e,yp(n??Wp(e,l),t),g)}catch(e){return yield*Fd(e)}if(n=v.next,v.microsteps.length>0){let n=v.microsteps.some(e=>e.changed),r=v.microsteps.flatMap(e=>e.exitPaths),i=new Map;for(let e of v.microsteps)if(e.changed)for(let t of e.entryPaths)i.set(t,e.event);let a=Lp(e,v.next);if(yield*Yh(v.commands,t),n&&(yield*f(r)),yield*s(a),l=a,v.emittedEvents.length>0&&(yield*Xh(v.emittedEvents,p??=Jh(e,t))),v.done)c={output:v.output},yield*u.stopAll();else if(n)for(let[e,t]of i)yield*d(v.next,[e],t)}h&&r({before:_,plan:rv(v,t=>Lp(e,t)),after:l}),c===void 0&&(o=yield*i,Ln(o)&&(n=void 0))}return c===void 0?yield*mn(Error(`Machine process stopped receiving events before reaching a terminal configuration`)):c.output}).pipe(wn(()=>u.stopAll()))}),t)}},fv=new WeakMap,pv=(e,...t)=>{if(t.length>0)return dv(e,{_tag:`Initial`,args:t});let n=fv.get(e);if(n!==void 0)return n;let r=dv(e,{_tag:`Initial`,args:t});return fv.set(e,r),r},mv=(e,t)=>dv(e,{_tag:`Resume`,snapshot:t}),hv=(e,...t)=>Q_(pv(e,...t),e.id===void 0?void 0:{id:e.id}),gv=(e,t)=>X_(mv(e,t),e.id===void 0?void 0:{id:e.id}),_v={atomic:[`schema`,`type`,`annotations`],final:[`schema`,`type`,`output`,`annotations`],compound:[`schema`,`type`,`states`,`annotations`],parallel:[`schema`,`type`,`output`,`states`,`annotations`],history:[`type`,`history`,`annotations`],choice:[`type`,`annotations`]},vv=[`title`,`description`,`documentation`],yv=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),bv=(e,t)=>{let n=typeof t==`symbol`?`[${String(t)}]`:t===``?`<empty>`:String(t);return e===``?n:`${e}.${n}`},xv=(e,t,n)=>{throw Error(`${e} invalid state definition at "${t}": ${n}`)},Sv=e=>Number.isFinite(Number(e)),Cv=e=>e.length===0||e.some(e=>e===`untagged`)?`untagged`:e.every(e=>e===`tagged`)?`tagged`:`opaque`,wv=(e,t)=>{if(t.has(e))return`opaque`;if(Pn(e)||Pr(e)||ur(e)||Or(e)||Jn(e)||a(e))return`tagged`;if(fn(e))return typeof e.literal==`string`||typeof e.literal==`number`?`tagged`:`untagged`;let n=new Set(t).add(e);return tn(e)?Cv(e.types.map(e=>wv(e,n))):qt(e)?wv(e.thunk(),n):Ke(e)?`opaque`:`untagged`},Tv=(e,t=new Set)=>{if(t.has(e))return`opaque`;if(ar(e)){let n=e.propertySignatures.find(({name:e})=>e===`_tag`)?.type;return n===void 0||Cr(n)?`untagged`:wv(n,new Set(t).add(e))}let n=new Set(t).add(e);return tn(e)?Cv(e.types.map(e=>Tv(e,n))):qt(e)?Tv(e.thunk(),n):Ke(e)?`opaque`:`untagged`},Ev=e=>mt(e)&&Tv(Br(e.ast))!==`untagged`,Dv=(e,t,n)=>{let r=bv(t,n);return typeof n==`symbol`?xv(e,r,`state keys must be strings, not symbols`):typeof n==`number`?xv(e,r,`state keys cannot use numeric forms`):n===``?xv(e,r,`state keys cannot be empty`):n===`__proto__`?xv(e,r,`the state key "__proto__" is not allowed`):n.includes(`.`)?xv(e,r,`state keys cannot contain "."`):Sv(n)?xv(e,r,`state keys cannot use numeric forms`):r},Ov=(e,t,n,r)=>{(typeof n!=`object`||!n||Array.isArray(n))&&xv(e,t,`${r} must be a plain record`);let i=Object.getPrototypeOf(n);i!==Object.prototype&&i!==null&&xv(e,bv(t===`<root>`?``:t,`__proto__`),`${r} must not declare an implicit "__proto__" state key`)},kv=(e,t,n,r,i)=>{if(typeof n!=`object`||!n||Array.isArray(n)||!yv(n,r))return;let a=n[r];(typeof a!=`object`||!a||mt(a)||a.type!==`history`)&&xv(e,`${t}.${r}`,i)},Av=(e,t,n,r)=>{let i=_v[r];for(let a of Reflect.ownKeys(n))i.includes(a)||xv(e,t,`${r} states cannot declare property "${String(a)}"`)},jv=(e,t,n)=>{Ov(e,`${t}.annotations`,n,`schema-less state annotations`);for(let r of Reflect.ownKeys(n))vv.includes(r)||xv(e,`${t}.annotations`,`schema-less state annotations cannot declare property "${String(r)}"`),typeof n[r]!=`string`&&xv(e,`${t}.annotations.${String(r)}`,`schema-less state annotation values must be strings`)},Mv=(e,t,n,r,i=!1)=>{Ov(e,n===``?`<root>`:n,t,`state trees`);for(let a of Reflect.ownKeys(t)){let o=i&&a===``?``:Dv(e,n,a),s=t[a];if(mt(s)){Ev(s)||xv(e,o,`state schemas must decode to an object with a required PropertyKey _tag`);continue}Ov(e,o,s,`state nodes`);let c=s.type,l=c===`history`?`history`:c===`choice`?`choice`:c===`parallel`?`parallel`:c===`final`?`final`:yv(s,`states`)?`compound`:`atomic`;if(Av(e,o,s,l),l===`history`||l===`choice`){r||xv(e,o,`${l} states must be declared below an active parent state`),yv(s,`annotations`)&&jv(e,o,s.annotations),l===`history`&&yv(s,`history`)&&s.history!==`shallow`&&s.history!==`deep`&&xv(e,`${o}.history`,`history must be "shallow" or "deep"`);continue}let u=yv(s,`schema`);u&&!Ev(s.schema)&&xv(e,`${o}.schema`,`state schemas must decode to an object with a required PropertyKey _tag`),u&&yv(s,`annotations`)&&xv(e,`${o}.annotations`,`schema-backed states must declare annotations on their schema`),!u&&yv(s,`annotations`)&&jv(e,o,s.annotations),l===`atomic`&&yv(s,`type`)&&s.type!==`active`&&xv(e,`${o}.type`,`atomic state type must be "active"`),l===`final`&&s.type!==`final`&&xv(e,`${o}.type`,`final state type must be "final"`),l===`compound`&&yv(s,`type`)&&s.type!==`active`&&xv(e,`${o}.type`,`compound state type must be "active"`),l===`parallel`&&s.type!==`parallel`&&xv(e,`${o}.type`,`parallel state type must be "parallel"`),(l===`final`||l===`parallel`)&&yv(s,`output`)&&!mt(s.output)&&xv(e,`${o}.output`,`state output must be an Effect Schema`),l===`compound`?(kv(e,o,s.states,`initial`,`active and choice child states cannot use the reserved target selector key "initial"`),u&&kv(e,o,s.states,`with`,`schema-backed compound child states cannot use the reserved local target selector key "with"`),Mv(e,s.states,o,!0)):l===`parallel`&&(yv(s,`states`)||xv(e,`${o}.states`,`parallel states must declare child regions`),kv(e,o,s.states,`initial`,`active and choice child states cannot use the reserved target selector key "initial"`),Mv(e,s.states,o,!0))}},Nv=e=>typeof e==`object`&&e?Object.freeze({...e}):e,Pv=e=>{let t={};for(let n of Object.keys(e)){let r=e[n];if(mt(r)){Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!1,writable:!1});continue}let i=r,a={...i};`states`in i&&(a.states=Pv(i.states)),`annotations`in i&&(a.annotations=Nv(i.annotations)),Object.defineProperty(t,n,{value:Object.freeze(a),enumerable:!0,configurable:!1,writable:!1})}return Object.freeze(t)},Fv=e=>Pv(e),Iv=(e,t=``)=>{if(mt(e)||typeof e!=`object`||!e)return e;if(`~effect/Machine/State`in e&&e[`~effect/Machine/State`]===`~effect/Machine/State`&&`node`in e)return e.node;let n=e,r={...n};if(yv(n,`fields`)&&(yv(n,`schema`)&&xv(`Machine.state`,t,`declare fields or schema, not both`),Ov(`Machine.state`,t,n.fields,`state fields`),yv(n.fields,`_tag`)&&xv(`Machine.state`,t,`state fields cannot declare _tag`),r.schema=Vn(t,n.fields),delete r.fields),yv(n,`states`)){Ov(`Machine.state`,t,n.states,`child states`);let e=Object.create(null);for(let r of Reflect.ownKeys(n.states))Dv(`Machine.state`,t,r),e[r]=Iv(n.states[r],r);r.states=e}return t===``?(Mv(`Machine.state`,{"":r},``,!1,!0),Fv({"":r})[``]):r},Lv=`~effect/Machine`,Rv=`~effect/Machine/ChildMachine`,zv={...St,...Fr,[Lv]:Lv,toJSON(){return{_id:`Machine`}}},Bv=(e,t)=>{let n=Object.create(zv);return n.states=e.states,n.root=e.root,n.events=e.events,n.internalEvents=e.internalEvents,n.emittedEvents=e.emittedEvents,n.parent=e.parent,n.input=e.input,n.id=e.id,n.initial=e.initial,n.initialDefinition=e.initialDefinition,n.stateNodes=e.stateNodes,n.handlers=t,Kf(e,n),n},Vv=e=>e.kind===`none`?Zd:Xd(e.kind,e.path,e.scope,e.updatePath),Hv=e=>Object.freeze({path:e.path,kind:e.kind,scope:e.scope}),Uv=e=>e.updatePath===void 0?e.kind===`update`&&e.path!==void 0?[e.path]:[]:[e.updatePath],Wv=(e,t,n,r,i)=>{if(typeof e!=`object`||!e||!H(e,`target`)||typeof e.target!=`function`)throw Error(`Machine transition for state "${r}" on "${String(i)}" requires a target selector`);let a=e.target(t);if(!Qd(a))throw Error(`Machine transition for state "${r}" on "${String(i)}" must select exactly one target`);if(a.updatePath!==void 0){let e=n.byPath.get(a.updatePath);if(a.kind!==`state`&&a.kind!==`choice`||a.scope!==`local`&&a.scope!==`branch`||a.path===void 0||e===void 0||e.schema===void 0||e.type!==`compound`&&e.type!==`parallel`||!Cp(r,e.path)||!Cp(a.path,e.path))throw Error(`Machine updating owner "${a.updatePath}" must be a valued ancestor retained by source "${r}" and target "${a.path}"`)}return{...e,selection:a}},Gv=(e,t,n)=>{if(t.kind===`none`){if(e!==void 0)throw Error(`Machine targetless transition resolver must return undefined`);return}if(t.kind===`update`){if(!ef(e)||e.path!==t.path)throw Error(`Machine state update for "${t.path}" must return its selected update builder`);return}if(t.updatePath!==void 0){if(!nf(e)||e.update.path!==t.updatePath)throw Error(`Machine target updating "${t.updatePath}" must return target construction .update(...)`)}else if(nf(e))throw Error(`Machine combined target requires an updating owner declaration`);if(e===void 0)return;let r=nf(e)?e.target:e,i=typeof r==`object`&&r&&H(r,`path`)&&typeof r.path==`string`?r.path:void 0,a=t.path===void 0?void 0:n.byPath.get(t.path),o=(t.scope===`local`||t.scope===`branch`)&&(a?.type===`compound`||a?.type===`parallel`);if(i===void 0||i!==t.path&&!(o&&Cp(i,t.path)))throw Error(`Machine transition resolver selected "${t.path}" but constructed "${i??`<invalid>`}"`)},Kv=(e,t,n,r,i)=>{let a={...t,root:i===``?t.state:t.ancestors[``],decline:uf};delete a.target;let o=e.resolve(a,n);if(df(o)){if(e.declinable!==!0)throw Error(`Machine transition for state "${i}" returned decline without declaring declinable: true`);return o}return Gv(o,e.selection,r),o},qv=e=>e.kind===`update`?void 0:e.path,Jv=e=>{let t=Number(e);return Number.isInteger(t)&&t>=0&&t<4294967295&&String(t)===e},Yv=(e,t,n)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine branching transition for state "${t}" on "${String(n)}" requires a branch record`);if(Object.getOwnPropertySymbols(e).length>0)throw Error(`Machine branching transition for state "${t}" on "${String(n)}" cannot use symbol keys`);let r=Object.keys(e);if(r.length===0)throw Error(`Machine branching transition for state "${t}" on "${String(n)}" requires a branch`);return Object.freeze(r.map(r=>{if(r.length===0||Jv(r))throw Error(`Machine branching transition for state "${t}" on "${String(n)}" requires non-index string branch keys`);let i=e[r];if(typeof i!=`object`||!i||!H(i,`target`))throw Error(`Machine transition branch "${r}" requires a target selection`);let{target:a,title:o}=i;if(!Qd(a))throw Error(`Machine transition branch "${r}" must select exactly one target`);if(o!==void 0&&(typeof o!=`string`||o.length===0))throw Error(`Machine transition branch "${r}" title must be a non-empty string`);return Object.freeze({key:r,title:o??r,selection:Vv(a)})}))},Xv=(e,t,n,r={},i)=>{let a=pm(r);if(e.kind===`choice`&&e.updatePath!==void 0){let{update:n,...r}=a;if(Reflect.ownKeys(r).length>0)throw Error(`Machine pseudo-state construction accepts no data`);let i=t.byPath.get(e.path);return tf(gf(i.path,i.parent),gm(t,e.updatePath,n))}if(e.kind===`none`||e.kind===`history`||e.kind===`choice`){if(Reflect.ownKeys(a).length>0)throw Error(`Machine pseudo-state construction accepts no data`);if(e.kind===`none`)return;let n=t.byPath.get(e.path);return e.kind===`history`?ff(n.path,n.parent):gf(n.path,n.parent)}if(e.kind===`update`)return gm(t,e.path,a);if(e.path===``){if(Reflect.ownKeys(a).some(e=>e!==`input`))throw Error(`Machine initialize branches accept input only`);if(n.initialize===void 0)throw Error(`Machine root initialization is unavailable`);return n.initialize(a.input)}if(e.updatePath!==void 0){let{update:n,...r}=a;return tf(hm(t,e.path,r,i),gm(t,e.updatePath,n))}return hm(t,e.path,a,i)},Zv=(e,t,n,r,i)=>Object.freeze(Object.fromEntries(e.map((e,a)=>[e.key,o=>rf(t,a,e.key,e.selection.kind===`none`?sf():Xv(e.selection,n,r,o,i))]))),Qv=(e,t,n)=>{if(t.kind===`none`){if(!cf(e))throw Error(`Machine targetless branch must return its selected targetless builder`)}else{if(e===void 0)throw Error(`Machine transition branch selected "${t.path}" without constructing its target`);Gv(e,t,n)}},$v=(e,t)=>({...e,root:t===``?e.state:e.ancestors[``]}),ey=(e,t,n,r)=>{if(typeof e!=`object`||!e)throw Error(`Machine transition for "${n}" must be an object`);let i={...e},a=[`target`,`update`,`initialize`,`history`,`none`,`branches`,`data`,`decoded`,`resolve`,`guard`,`reenter`,`declinable`];for(let e of Reflect.ownKeys(i))if(typeof e!=`string`||!a.includes(e))throw Error(`Machine transition contains an unknown field`);for(let e of[`resolve`,`guard`])if(i[e]!==void 0&&typeof i[e]!=`function`)throw Error(`Machine transition ${e} must be a function`);let o=typeof i.guard==`function`?i.guard:void 0,s=typeof i.resolve==`function`?i.resolve:void 0;if(i.decoded!==void 0&&typeof i.decoded!=`boolean`)throw Error(`Machine decoded must be a boolean construction flag`);let c=Object.prototype.hasOwnProperty.call(i,`data`);if(i.decoded===!0&&!c)throw Error(`Machine decoded construction requires data`);if(c&&s!==void 0)throw Error(`Machine data and resolve are mutually exclusive`);let l=i.data,u=typeof l==`function`?l:()=>l,d=o!==void 0,f=d||i.declinable===!0;if(typeof i.branches==`string`){let e=t.branches.get(i.branches);if(e===void 0||s===void 0)throw Error(`Machine branching transition requires a registered group and resolver`);if([`target`,`update`,`initialize`,`history`,`none`,`data`,`decoded`].some(e=>i[e]!==void 0))throw Error(`Machine branching transition cannot redeclare its destination`);let a=Object.fromEntries(Object.entries(e).map(([e,i])=>[e,{title:i.title,target:Wv({target:()=>Cm(t,i)},void 0,r,n,e).selection}]));return{branches:()=>a,reenter:i.reenter,declinable:f,resolve:(e,t)=>d&&!o(e)?uf():s(e,t)}}let p=Cm(t,i);if(s!==void 0&&p.kind!==`none`)throw Error(`Machine advanced construction requires a declared branch group`);let m=i.initialize,h=m!==void 0;if(h&&(c||i.decoded!==void 0))throw Error(`Machine initialize accepts machine input instead of data`);if(h&&!t.input&&m!==!0)throw Error(`Machine initialize requires true when the machine declares no input`);let g=t.input?typeof m==`function`?m:()=>m:()=>void 0;return{target:()=>p,reenter:i.reenter,declinable:f,resolve:(e,a)=>{if(d&&!o(e))return uf();if(s!==void 0)return s(e,a);if(h)return Xv(p,r,t,{input:g(e)});let l=u(e);return Xv(p,r,t,p.updatePath===void 0?{...c?{data:l}:{},...i.decoded===void 0?{}:{decoded:i.decoded}}:p.kind===`choice`?{update:{data:l,decoded:i.decoded}}:{...l.target===void 0?{}:{data:l.target,decoded:i.decoded},update:{data:l.update,decoded:i.decoded}},n)}}},ty=(e,t,n,r,i)=>{let a=ey(e,r,n,t);if(typeof a!=`object`||!a)throw Error(`Machine transition for state "${n}" on "${String(i)}" must be an object`);let o=a,s=o.reenter===!0,c=o.declinable===!0;if(H(o,`branches`)){let e=o;if(typeof e.branches!=`function`||typeof e.resolve!=`function`)throw Error(`Machine branching transition for state "${n}" on "${String(i)}" requires branches and resolve`);let a=e.resolve,l=Yv(e.branches(),n,i),u=Object.freeze({}),d=(e,o)=>{let s={...e,root:n===``?e.state:e.ancestors[``],decline:uf};delete s.target,s.select=Zv(l,u,t,r,n);let d=a(s,o);if(df(d)){if(!c)throw Error(`Machine branching transition for state "${n}" on "${String(i)}" returned decline without declaring declinable: true`);return{result:d,branchIndex:-1,branchKey:void 0}}if(!af(d)||d.owner!==u)throw Error(`Machine branching transition for state "${n}" on "${String(i)}" must select one declared branch`);let f=l[d.branchIndex];if(f===void 0||d.branchKey!==f.key)throw Error(`Machine branching transition returned invalid branch evidence`);return Qv(d.result,f.selection,t),{result:d.result,branchIndex:d.branchIndex,branchKey:d.branchKey}};return{reenter:s,declinable:c,targets:[...new Set(l.flatMap(e=>qv(e.selection)===void 0?[]:[e.selection.path]))],branches:l.map(e=>Object.freeze({type:`branch`,key:e.key,title:e.title,target:qv(e.selection),selection:Hv(e.selection),updates:Uv(e.selection)})),evaluate:d,transition:(e,t)=>d(e,t).result}}let l=Wv(a,void 0,t,n,i),u=(e,r)=>({result:Kv(l,e,r,t,n),branchIndex:0,branchKey:void 0});return{reenter:s,declinable:c,targets:qv(l.selection)===void 0?[]:[l.selection.path],branches:[{type:`direct`,target:qv(l.selection),selection:Hv(l.selection),updates:Uv(l.selection)}],evaluate:u,transition:(e,t)=>u(e,t).result}},ny=(e,t,n,r)=>{let i=Object.create(null);for(let a of Reflect.ownKeys(e))i[a]=ty(e[a],t,n,r,a);return i},ry=(e,t,n,r)=>{let i=(Array.isArray(e)?e:[e]).map(e=>{let i=wm(r,e,n,e=>$v(e,n));for(let e of[`onElement`,`onDone`,`onFailure`,`onSnapshot`])i[e]!==void 0&&(i[e]=ty(i[e],t,n,r,e));return Fm(i,n)});return Lm(i,n),Array.isArray(e)?Object.freeze(i):i[0]},iy=(e,t,n,r,i,a)=>{for(let o of Object.keys(a)){let s=r===``?o:`${r}.${o}`;if(!H(n,o))throw Error(`Machine received handler for unknown state "${s}"`);let c=a[o];if(typeof c!=`object`||!c)throw Error(`Machine expected state "${s}" handler to be an object`);let{states:l,...u}=c;typeof u.history==`object`&&u.history!==null&&(u.history=Object.freeze(Object.fromEntries(Object.entries(u.history).map(([e,t])=>[e,typeof t==`object`&&t?Object.freeze({...t}):t]))));let d=u.on;if(typeof d==`object`&&d&&(u.on=ny(d,t,s,i)),u.always!==void 0&&(u.always=ty(u.always,t,s,i,`always`)),u.onDone!==void 0&&(u.onDone=ty(u.onDone,t,s,i,`done`)),u.choice!==void 0&&(u.choice=ty(u.choice,t,s,i,`choice`)),u.invoke!==void 0&&(u.invoke=ry(u.invoke,t,s,i)),t.byPath.get(s)?.type===`choice`&&(typeof u.choice!=`object`||u.choice===null||!H(u.choice,`transition`)||typeof u.choice.transition!=`function`||!H(u.choice,`targets`)||!Array.isArray(u.choice.targets)||u.choice.targets.length===0))throw Error(`Machine choice state "${s}" requires a transition`);if(e[s]=u,l!==void 0){let r=vf(s,n[o]);if(r.states===void 0)throw Error(`Machine expected state "${s}" to declare child states`);if(typeof l!=`object`||!l)throw Error(`Machine expected state "${s}" child handlers to be an object`);iy(e,t,r.states,s,i,l)}}},ay=e=>e===``?ym:e,oy=e=>{let t=!1;for(let n of e.stateNodes.byPath.values())if(n.type===`choice`){t=!0;break}if(!t)return;let n=Sf(e),r=new Map;for(let e of n)e.trigger.type===`choice`&&r.set(e.source,e);for(let e of n)for(let t of e.branches){let n=t.updates[0],i=t.selection.path;if(t.selection.kind!==`choice`||n===void 0||i===void 0)continue;let a=[i],o=new Set;for(;a.length>0;){let t=a.shift();if(!o.has(t)){o.add(t);for(let i of r.get(t)?.branches??[]){let{kind:r,path:o}=i.selection;if(o!==void 0&&r!==`none`&&r!==`update`){if(r===`choice`)a.push(o);else if(!Cp(o,n)){let r=i.type===`branch`?`branch "${i.key}"`:`transition`;throw Error(`Machine transition from "${ay(e.source)}" updates "${ay(n)}" before choice "${t}", whose ${r} targets "${ay(o)}" outside that owner`)}}}}}}},sy=(e,t)=>(n=>{let r=Pm(t.root,n),i=Object.assign(Object.create(zv),e);if(Kf(e,i),i.states=Object.freeze({"":r.node}),i.stateNodes=yf(i.states),i.stateNodes.byPath.get(``).schema===void 0&&n.root!==void 0)throw Error(`Machine schema-less root cannot construct data`);let a=i.stateNodes.byPath.get(``).schema===void 0?()=>void 0:Mm(n.root);i.initial=e=>({...mf(``,a({input:e})),input:{value:e}}),i.initialDefinition=Object.freeze({target:``,selection:Object.freeze({path:``,kind:`initial`,scope:`initial`})});let o=Object.create(null);iy(o,i.stateNodes,i.states,``,{...t,initialize:e=>i.initial(i.input===void 0?void 0:up(i,i.input,e))},{"":r.handlers});let s=Bv(i,o);return oy(s),s}),cy=e=>{let t=Iv(e),n=ly();return Object.freeze({...n,"~effect/Machine/State":`~effect/Machine/State`,node:t})},ly=()=>({path:(e=>e),get:((e,t)=>Of(e,t).pipe(Re(e=>e.value))),getWithParents:((e,t)=>{let n={};return Of(e,t,n).pipe(Re(e=>({value:e.value,parents:n})))}),getSnapshot:Of,matches:((e,t)=>we(Of(e,t)))}),uy=e=>{if(Object.hasOwn(e,`initial`)||Object.hasOwn(e,`initialConfiguration`))throw Error(`Machine initial edges and root data belong in handle`);let t=Object.freeze({"":e.root.node}),n=Object.create(Fr);return n.states=t,n.root=e.root,n.events=e.events,n.internalEvents=e.internalEvents??Zf(`internal`,[]),n.emittedEvents=e.emittedEvents??Zf(`emitted`,[]),n.parent=e.parent,n.input=e.input,n.id=e.id,n.handlers=Object.create(null),n.handle=sy(n,xm(e.root,e)),Gf(n),n},dy=e=>{for(let[t,n]of Object.entries(e))if(Object.hasOwn(n,`_tag`))throw Error(`Machine event "${t}" fields cannot declare _tag`);return Object.keys(e).length===0?[]:[Oe(e)]},fy=e=>Zf(`public`,dy(e)),py=(e,t)=>my(e,t,e=>t.input===void 0?pv(t):pv(t,e)),my=(e,t,n)=>({[Rv]:Rv,id:e,machine:t,[Dm]:n}),hy=hv,gy=gv,_y=(e,t)=>{try{let n=Uh(e,...t);return{machine:e,snapshot:n.done?{status:`done`,state:n.state,output:n.output}:{status:`active`,state:n.state}}}catch{return}},vy=(e,t)=>{try{let n=y(ev(e,t));if(n._tag===`Failure`)return;let r=n.value;if(!Vh(e,r))return{machine:e,snapshot:{status:`active`,state:r}};let i=y(Hh(e,r,Bh));return i._tag===`Success`?{machine:e,snapshot:{status:`done`,state:r,output:i.value}}:void 0}catch{return}},yy={spawn:()=>mn(Error(`Child operations are unavailable in a planned snapshot`)),sendTo:()=>wr(new Nd),stop:()=>B},by=(e,t)=>{if(e.snapshot.status!==`active`)return z();try{let n=e.machine,r=Wp(n,e.snapshot.state);for(let e of Fp(n,r)){let i=em(n,e);for(let a of Rm(i?.invoke)){if(!(`child`in a)||a.child.id!==t.id||a.child.machine!==t.machine)continue;let i=t.machine,o;`input`in a&&(o=typeof a.input==`function`?a.input({...bp(r)??nh(n,r),children:yy,state:r.values.get(e),containingState:Pp(n,r,e),ancestors:Np(n,r,e),event:Bh}):a.input);let s=_y(i,i.input===void 0?[]:[o]);return s===void 0?void 0:qe(s)}}return z()}catch{return}},xy=class extends vr(`ChildNotActiveError`){},Sy=new WeakMap,Cy=new WeakMap,wy=e=>typeof e==`object`&&!!e&&Cy.has(e),Ty=e=>{if(typeof WeakRef>`u`||typeof FinalizationRegistry>`u`)return ai(e);let t=p(),n=new FinalizationRegistry(({entry:e,key:n})=>{let r=yt(t,n);we(r)&&r.value===e&&oe(t,n)});return r=>{let i=yt(t,r);if(we(i)){let e=i.value.ref.deref();if(e!==void 0)return e}let a=e(r),o={ref:new WeakRef(a)};return pt(t,r,o),n.register(a,{key:r,entry:o}),a}},Ey=(e,t)=>st(ft(t,e=>e.stop).pipe(u(t=>K(()=>e.setSelf(I(t)))),G(()=>kn))),Dy=(e,t)=>Ey(e,e.result(t).pipe(G(e=>e.start))),Oy=(e,t,n)=>Ey(e,gy(t,n)),ky=(e,t)=>`~effect-atom/atom/Atom/ServerValue`in e?e[Ur](t):t(e),Ay=(e,t)=>{let n;return r=>{let i=e(r);return n!==void 0&&n.inputs.length===i.length&&n.inputs.every((e,t)=>Object.is(e,i[t]))||(n={inputs:i,value:t(...i)}),n.value}},jy=e=>{let t;return()=>(t===void 0&&(t={value:e()}),t.value)},My=e=>e.snapshot,Ny=rt(e=>e.registry).pipe(Ze),Py=e=>U(()=>{let t=e.pending.shift();return t===void 0?(e.draining=!1,B):L(t,Py(e))}),Fy=(e,t)=>{let n=e.get(t);return n===void 0&&(n={pending:[],draining:!1},e.set(t,n)),n},Iy=(e,t,n)=>Ce(n=>{let r=xt(n(e),()=>void 0),i=t.get(n.registry);return i===void 0||!i.draining?r:Un(Re(n.self(),me),()=>di(!0))},(r,i)=>{let a=r.get(e),o=r.get(Ny),s=Fy(t,o);ht(a)||s.draining?(r.setSelf(di(!0)),s.pending.push(ke(o,e).pipe(G(e=>n(e,i)),or,hr(e=>{let t=ye(e);r.setSelf(s.pending.length===0?t:me(t))}))),s.draining||(s.draining=!0,Qt(Py(s)))):d(a)?r.setSelf(xt(a,()=>void 0)):li(n(a.value,i),{onExit:e=>r.setSelf(ye(e))})}).pipe(In),Ly=e=>rt(t=>{let n=t(e);return ht(n)?di(n.waiting):d(n)?R(n.cause,{previous:t.self(),waiting:n.waiting}):n.value.status===`error`?R(n.value.cause,{previous:t.self(),waiting:n.waiting}):I(n.value.state,{waiting:n.waiting})}).pipe(Pe(ne),o(Ay(t=>[ky(e,t)],e=>xt(e,e=>e.state)))),Ry=e=>rt(t=>{let n=t(e);if(ht(n))return di(n.waiting);if(d(n))return R(n.cause,{previous:t.self(),waiting:n.waiting});if(Ln(n.value)){let e=t.self();return we(e)&&d(e.value)?e.value:I(z(),{waiting:n.waiting})}return n.value.value.status===`error`?R(n.value.value.cause,{previous:t.self(),waiting:n.waiting}):I(qe(n.value.value.state),{waiting:n.waiting})}).pipe(Pe(ne),o(Ay(t=>[ky(e,t)],e=>xt(e,Re(e=>e.state))))),zy=(e,t)=>rt(n=>{let r=n(e);if(ht(r))return di(r.waiting);if(d(r))return R(r.cause,{previous:n.self(),waiting:r.waiting});if(Ln(r.value))return I(z());let i=r.value.value,a=tt(i.child(t)),o=li(hi.pipe(L(i.childChanges(t).pipe(Gn(e=>K(()=>n.setSelf(I(e))))))));return n.addFinalizer(o),I(a)}).pipe(In),By=(e,t)=>zg(e)?e[Rg](()=>t(tt(e.snapshot))):li(e.changes.pipe(Gn(e=>K(()=>t(e))))),Vy=(e,t,n)=>{let r=rt(t=>{let n=t(e);if(ht(n))return di(n.waiting);if(d(n))return R(n.cause,{previous:t.self(),waiting:n.waiting});if(Ln(n.value))return I(z());let r=n.value.value;return t.addFinalizer(By(r,e=>t.setSelf(I(qe(e))))),I(qe(tt(r.snapshot)))}).pipe(o(Ay(()=>[],()=>{let e=n();return e===void 0?di(!0):I(Re(e,My),{waiting:!0})}))),i=new WeakMap,a=e=>we(e)?T(e.value):wr(new xy({id:t.id})),s=Iy(e,i,(e,t)=>G(a(e),e=>e.send(t))),c=Iy(e,i,(e,t)=>G(a(e),e=>e.stop)),l=Hy(e,n);return{ref:e,snapshot:r,result:Ry(r),send:s,stop:c,child:l}},Hy=(e,t)=>{let n=new WeakMap;return r=>{let i=n.get(r.machine);if(i===void 0){let a=r.machine,o=ai(n=>{let r=py(n,a);return Vy(zy(e,r),r,jy(()=>{let e=t();return e===void 0||Ln(e)?e:by(e.value,r)}))});i=e=>o(e),n.set(a,i)}return i(r.id)}},Uy=(e,t,n)=>{let r=In(e),i=rt(e=>{let t=e(r);if(ht(t))return di(t.waiting);if(d(t))return R(t.cause,{previous:e.self(),waiting:t.waiting});let n=t.value;e.addFinalizer(By(n,t=>e.setSelf(I(t,{waiting:t.status===`active`}))));let i=tt(n.snapshot);return I(i,{waiting:i.status===`active`})}).pipe(o(Ay(()=>[],()=>{let e=n();return e===void 0?di(!0):I(My(e),{waiting:!0})}))),a=new WeakMap,s=Iy(r,a,(e,t)=>e.send(t)),c=Iy(r,a,(e,t)=>e.stop),l=Hy(Jr(r,qe),()=>{let e=n();return e===void 0?void 0:qe(e)}),u={ref:r,snapshot:i,result:Ly(i),send:s,stop:c,child:l};return Cy.set(u,t),u},Wy=(e,t)=>Of(e,t).pipe(Re(e=>e.value)),Gy=(e,t)=>Of(e,t),Ky=(e,t)=>Jr(e,t).pipe(Pe(ne),o(Ay(t=>[ky(e,t)],e=>xt(e,t)))),qy=new WeakMap,Jy=(e,t,n,r)=>{let i=qy.get(e);i===void 0&&(i=new Map,qy.set(e,i));let a=i.get(t);a===void 0&&(a=new Map,i.set(t,a));let o=a.get(n);if(o!==void 0)return o;let s=r();return a.set(n,s),s},Yy=(e,t)=>Jy(e,`select`,t,()=>Ky(e.result,e=>Wy(e,t))),Xy=(e,t)=>Jy(e,`selectSnapshot`,t,()=>Ky(e.result,e=>Gy(e,t))),Zy=(e,t)=>Jy(e,`selectChild`,t,()=>Ky(e.result,O(e=>Wy(e,t)))),Qy=(e,t)=>Jy(e,`selectSnapshotChild`,t,()=>Ky(e.result,O(e=>Gy(e,t)))),$y=(e,t)=>Jy(e,`matches`,t,()=>Ky(e.result,e=>we(Of(e,t)))),eb=(e,t)=>Jy(e,`matchesChild`,t,()=>Ky(e.result,Yr(e=>we(Of(e,t))))),tb=(e,t,n)=>{let r=e.atom(()=>hy(t,...n)),i=Uy(e.atom(e=>Dy(e,r)),t,jy(()=>_y(t,n)));return Sy.set(i,r),i},nb=(e,t,n)=>Uy(e.atom(e=>Oy(e,t,n)),t,jy(()=>vy(t,n))),rb=(e,t,n)=>{let r={owner:e,source:t},i=x(t,e=>e(r.source),{initialValueTarget:t}).pipe(Pe((e,t)=>r.source.equals(e,t)),o(e=>ky(r.source,e)));return n!==void 0&&(i=i.pipe(Hn(n))),i},ib=(e,t)=>{let n=Ty(t=>({bridge:e(t)})),r={};for(let e of Object.keys(t.atoms)){let i=t.atoms[e];r[e]=Ty(r=>{let a=n(r);return rb(a,i(a.bridge),t.label?.(r,e))})}return r},ab=e=>{let t=((t,...n)=>tb(e,t,n));return{make:t,factory:(e=>(...n)=>t(e,...n)),resume:((t,n)=>nb(e,t,n)),family:((t,n)=>ib(n=>tb(e,t,[n]),n))}},ob=wy;n(2,Yy);var sb=n(2,Xy);n(2,Zy);var cb=n(2,Qy);n(2,$y),n(2,eb);var lb=ab;function ub(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Fi(`animate-pulse rounded-md bg-muted`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`skeleton`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function db(e){let t=(0,$o.c)(8),n=e.label,r;if(t[0]!==e.media||t[1]!==e.rows){let n;t[3]===e.media?n=t[4]:(n=t=>(0,Q.jsxs)(`div`,{"aria-hidden":!0,className:`flex h-8 items-center gap-3 border-b px-1 max-sm:h-11`,children:[e.media===!0&&(0,Q.jsx)(ub,{className:`size-5`}),(0,Q.jsx)(ub,{className:`h-4 w-1/3`})]},t),t[3]=e.media,t[4]=n),r=_n(Zn(1,e.rows),n),t[0]=e.media,t[1]=e.rows,t[2]=r}else r=t[2];let i;return t[5]!==e.label||t[6]!==r?(i=(0,Q.jsx)(`div`,{"aria-busy":`true`,"aria-label":n,role:`status`,children:r}),t[5]=e.label,t[6]=r,t[7]=i):i=t[7],i}var fb=Z.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return qi(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),pb=Mi(`group/field flex w-full gap-2 data-[invalid=true]:text-destructive`,{variants:{orientation:{vertical:`flex-col *:w-full [&>.sr-only]:w-auto`,horizontal:`flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`,responsive:`flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`}},defaultVariants:{orientation:`vertical`}});function mb(e){let t=(0,$o.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`vertical`:i,o;t[4]!==n||t[5]!==a?(o=Fi(pb({orientation:a}),n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,Q.jsx)(`div`,{role:`group`,"data-slot":`field`,"data-orientation":a,className:o,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function hb(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Fi(`flex w-fit items-center gap-2 text-xs/relaxed font-medium group-data-[disabled=true]/field:opacity-50`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`field-label`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function gb(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Fi(`text-left text-xs/relaxed leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5`,`last:mt-0 nth-last-2:-mt-1`,`[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`p`,{"data-slot":`field-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function _b(e){let t=(0,$o.c)(15),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,children:n,errors:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;bb0:{if(n){o=n;break bb0}if(!i?.length){o=null;break bb0}let e;t[5]===i?e=t[6]:(e=[...new Map(i.map(yb)).values()],t[5]=i,t[6]=e);let r=e;if(r?.length==1){o=r[0]?.message;break bb0}let a;t[7]===r?a=t[8]:(a=(0,Q.jsx)(`ul`,{className:`ml-4 flex list-disc flex-col gap-1`,children:r.map(vb)}),t[7]=r,t[8]=a),o=a}let s=o;if(!s)return null;let c;t[9]===r?c=t[10]:(c=Fi(`text-xs/relaxed font-normal text-destructive`,r),t[9]=r,t[10]=c);let l;return t[11]!==s||t[12]!==a||t[13]!==c?(l=(0,Q.jsx)(`div`,{role:`alert`,"data-slot":`field-error`,className:c,...a,children:s}),t[11]=s,t[12]=a,t[13]=c,t[14]=l):l=t[14],l}function vb(e,t){return e?.message&&(0,Q.jsx)(`li`,{children:e.message},t)}function yb(e){return[e?.message,e]}function bb(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Fi(`size-4 animate-spin`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Qa,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var xb=new Uint8Array(512),Sb=new Uint8Array(256);for(let e=0,t=1;e<255;e++)xb[e]=t,Sb[t]=e,t<<=1,256&t&&(t^=285);for(let e=255;e<512;e++)xb[e]=xb[e-255];var Cb=(e,t)=>e>0&&t>0?xb[Sb[e]+Sb[t]]:0,wb=(e,t)=>xb[t*Sb[e]%255],Tb=e=>{let t=new Uint8Array(e+2),n=new Uint8Array(e+1);n[0]=1;for(let r=0;r<e;r++){let e=wb(2,r);t.fill(0,0,r+2);for(let i=0;i<r+1;i++)t[i]^=n[i],t[i+1]^=Cb(n[i],e);for(let e=0;e<r+2;e++)n[e]=t[e]}return n},Eb=(e,t)=>{let n=Tb(t),r=new Uint8Array(e.byteLength+n.byteLength-1);r.set(e);for(let t=0;t<e.byteLength;t++){let e=r[t];if(e)for(let i=1;i<n.byteLength;i++)r[t+i]^=Cb(n[i],e)}return r.subarray(e.byteLength)},Db=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706],Ob=[[0,0,0,0],[10,7,17,13],[16,10,28,22],[26,15,44,36],[36,20,64,52],[48,26,88,72],[64,36,112,96],[72,40,130,108],[88,48,156,132],[110,60,192,160],[130,72,224,192],[150,80,264,224],[176,96,308,260],[198,104,352,288],[216,120,384,320],[240,132,432,360],[280,144,480,408],[308,168,532,448],[338,180,588,504],[364,196,650,546],[416,224,700,600],[442,224,750,644],[476,252,816,690],[504,270,900,750],[560,300,960,810],[588,312,1050,870],[644,336,1110,952],[700,360,1200,1020],[728,390,1260,1050],[784,420,1350,1140],[812,450,1440,1200],[868,480,1530,1290],[924,510,1620,1350],[980,540,1710,1440],[1036,570,1800,1530],[1064,570,1890,1590],[1120,600,1980,1680],[1204,630,2100,1770],[1260,660,2220,1860],[1316,720,2310,1950],[1372,750,2430,2040]],kb=[[0,0,0,0],[1,1,1,1],[1,1,1,1],[1,1,2,2],[2,1,4,2],[2,1,4,4],[4,2,4,4],[4,2,5,6],[4,2,6,6],[5,2,8,8],[5,4,8,8],[5,4,11,8],[8,4,11,10],[9,4,16,12],[9,4,16,16],[10,6,18,12],[10,6,16,17],[11,6,19,16],[13,6,21,18],[14,7,25,21],[16,8,25,20],[17,8,25,23],[17,9,34,23],[18,9,30,25],[20,10,32,27],[21,12,35,29],[23,12,37,34],[25,12,40,34],[26,13,42,35],[28,14,45,38],[29,15,48,40],[31,16,51,43],[33,17,54,45],[35,18,57,48],[37,19,60,51],[38,19,63,53],[40,20,66,56],[43,21,70,59],[45,22,74,62],[47,24,77,65],[49,25,81,68]],Ab=[0,21,25,29,33,37,41,45,49,53,57,61,65,69,73,77,81,85,89,93,97,101,105,109,113,117,121,125,129,133,137,141,145,149,153,157,161,165,169,173,177],jb=[[],[],[4,16],[4,20],[4,24],[4,28],[4,32],[4,20,36],[4,22,40],[4,24,44],[4,26,48],[4,28,52],[4,30,56],[4,32,60],[4,24,44,64],[4,24,46,68],[4,24,48,72],[4,28,52,76],[4,28,54,80],[4,28,56,84],[4,32,60,88],[4,26,48,70,92],[4,24,48,72,96],[4,28,52,76,100],[4,26,52,78,104],[4,30,56,82,108],[4,28,56,84,112],[4,32,60,88,116],[4,24,48,72,96,120],[4,28,52,76,100,124],[4,24,50,76,102,128],[4,28,54,80,106,132],[4,32,58,84,110,136],[4,28,56,84,112,140],[4,32,60,88,116,144],[4,28,52,76,100,124,148],[4,22,48,74,100,126,152],[4,26,52,78,104,130,156],[4,30,56,82,108,134,160],[4,24,52,80,108,136,164],[4,28,56,84,112,140,168]],Mb=(e,t,n)=>{let r=Db[t]-Ob[t][n],i=new Uint8Array(r),a=0,o=0;if(t>9){let t=65535&e.byteLength;i[0]=64|t>>>12&15,i[1]=t>>>4&255,a=(15&t)<<4,o=2}else{let t=255&e.byteLength;i[0]=64|t>>>4&15,a=(15&t)<<4,o=1}let s=0;for(;s+1<e.byteLength;){let t=e[s++]<<8|e[s++];i[o++]=a|t>>>12,i[o++]=t>>>4&255,a=t<<4&240}s<e.byteLength&&(i[o++]=a|e[s]>>>4,a=e[s]<<4&240),i[o++]=a;for(let e=0;o<r;e++)i[o++]=1&e?17:236;return i},Nb=(e,t)=>{for(let n=1;n<=40;n++){let r=Db[n]-Ob[n][t];if(r-=n>9?3:2,r>=e.byteLength)return n}throw RangeError(`Bytes exceed max length`)},Pb=(e,t,n)=>{let r=e.byteLength+Ob[t][n],i=kb[t][n],a=i-r%i,o=e.byteLength/i|0,s=(r/i|0)-o,c=e.byteLength,l=new Uint8Array(r);for(let t=0,n=0;t<i;t++){let r=t<a?o:o+1,u=Eb(e.subarray(n,n+r),s);for(let s=0;s<r;s++)l[s<o?s*i+t:o*i+(t-a)]=e[n+s];for(let e=0;e<s;e++)l[c+e*i+t]=u[e];n+=r}return l},Fb=(e,t,n,r,i)=>{let a=(n+i)*t;for(let o=n*t;o<a;o+=t)e.fill(1,o+r,o+r+i)},Ib=(e,t,n,r,i)=>{let a=n*t+r;for(let n=0;n<i;n++)for(let r=0;r<i;r++){let o=r<i-1-r?r:i-1-r,s=n<i-1-n?n:i-1-n;e[a+n*t+r]=(o<s?o:s)===1?0:1}},Lb=(e,t,n)=>{let r=n-7;Ib(e,n,0,0,7),Ib(e,n,r,0,7),Ib(e,n,0,r,7),Fb(t,n,0,0,8),Fb(t,n,r-1,0,8),Fb(t,n,0,r-1,8)},Rb=(e,t,n,r)=>{let i=jb[r];for(let r=0;r<i.length;r++){let a=i[r];for(let o=0;o<i.length;o++)if((r||o%(i.length-1))&&(o||r%(i.length-1))){let r=i[o];Ib(e,n,a,r,5),Fb(t,n,a,r,5)}}},zb=(e,t,n)=>{let r=n-7;for(let i=8;i<r;i++){let r=i*n+6;t[r]||(t[r]=1,e[r]=(i+1)%2);let a=6*n+i;t[a]||(t[a]=1,e[a]=(i+1)%2)}},Bb=(e,t)=>{let n=t-7-1;e[8*t+8]=1;for(let r=0;r<8;r++)e[r*t+8]=1,e[8*t+r]=1,e[(n+r)*t+8]=1,e[8*t+n+r]=1},Vb=(e,t,n)=>{if(n>=7){let n=t-7-4;for(let r=0;r<6;r++)for(let i=0;i<3;i++)e[(n+i)*t+r]=1,e[r*t+n+i]=1}},Hb=(e,t,n,r)=>{let i=0,a=n-1,o=-1,s=7;for(;i<r.byteLength;){a===6&&a--;for(let c=0;c<n;c++)for(let l=0;l<2;l++){let u=a-l,d=o===-1?n-c-1:c;if(!t[d*n+u]&&(e[d*n+u]=r[i]>>>s&1,s--===0&&(s=7,++i>=r.byteLength)))return}o=-o,a-=2}},Ub=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n)for(let a=0;a<n;a++){let n=i+a;t[n]||r+a&1||(e[n]^=1)}},Wb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n)for(let a=0;a<n;a++){let n=i+a;t[n]||1&r||(e[n]^=1)}},Gb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n)for(let r=0;r<n;r++){let n=i+r;!t[n]&&r%3==0&&(e[n]^=1)}},Kb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n)for(let a=0;a<n;a++){let n=i+a;!t[n]&&(r+a)%3==0&&(e[n]^=1)}},qb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n){let a=r/2|0;for(let r=0;r<n;r++){let n=i+r;t[n]||a+(r/3|0)&1||(e[n]^=1)}}},Jb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n)for(let a=0;a<n;a++){let n=i+a,o=r*a;!t[n]&&(1&o)+o%3==0&&(e[n]^=1)}},Yb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n)for(let a=0;a<n;a++){let n=i+a,o=r*a;!t[n]&&((1&o)+o%3)%2==0&&(e[n]^=1)}},Xb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n)for(let a=0;a<n;a++){let n=i+a;t[n]||r*a%3+(r+a&1)&1||(e[n]^=1)}},Zb=(e,t,n,r)=>{switch(r){case 0:return Ub(e,t,n);case 1:return Wb(e,t,n);case 2:return Gb(e,t,n);case 3:return Kb(e,t,n);case 4:return qb(e,t,n);case 5:return Jb(e,t,n);case 6:return Yb(e,t,n);case 7:return Xb(e,t,n)}},Qb=(e,t)=>{let n=0,r=0;for(let i=0;i<t;i++){let a=1,o=1,s=0,c=0;for(let l=0;l<t;l++){let u=i*t+l,d=l*t+i;r+=e[u],l>0&&(e[u-1]===e[u]?a++:(a>=5&&(n+=a-5+3),a=1),e[d-t]===e[d]?o++:(o>=5&&(n+=o-5+3),o=1)),i<t-1&&l<t-1&&e[u]===e[u+1]&&e[u]===e[u+t]&&e[u]===e[u+t+1]&&(n+=3),s=s<<1&2047|e[u],c=c<<1&2047|e[d],l>=10&&((s===1488||s===93)&&(n+=40),(c===1488||c===93)&&(n+=40))}a>=5&&(n+=a-5+3),o>=5&&(n+=o-5+3)}let i=100*Math.abs(r/e.byteLength-.5);return n+=10*Math.floor(i/5),n},$b=(e,t,n)=>{let r=0,i=0,a=new Uint8Array(e.byteLength);for(let o=0;o<=7;o+=1){a.set(e),Zb(a,t,n,o);let s=Qb(a,n);(o===0||s<r)&&(r=s,i=o)}return Zb(e,t,n,i),i},ex=(e,t)=>{let n=(e<<3|t)<<10,r=n;for(let e=0;e<5;e++)r&1<<14-e&&(r^=1335<<4-e);return 21522^(r|n)},tx=(e,t,n,r)=>{let i=ex(n,r),a=14;for(let n=0;n<6;n++)e[8*t+n]=i>>a--&1;e[8*t+7]=i>>a--&1,e[8*t+8]=i>>a--&1,e[7*t+8]=i>>a--&1;for(let n=0;n<6;n++)e[(5-n)*t+8]=i>>a--&1;a=14;for(let n=0;n<7;n++)e[(t-1-n)*t+8]=i>>a--&1;e[(t-8)*t+8]=1;for(let n=0;n<8;n++)e[8*t+t-8+n]=i>>a--&1},nx=e=>{let t=e<<12,n=t;for(let e=0;e<6;e++)n&1<<17-e&&(n^=7973<<5-e);return n|t},rx=(e,t,n)=>{if(n>=7){let r=nx(n);for(let n=0;n<6;n++)for(let i=0;i<3;i++){let a=r>>>3*n+i&1;e[(t-11+i)*t+n]=a,e[n*t+t-11+i]=a}}},ix=(e,t)=>{let n=Nb(e,t),r=Pb(Mb(e,n,t),n,t),i=Ab[n],a=new Uint8Array(i*i),o=new Uint8Array(i*i);return Lb(a,o,i),Rb(a,o,i,n),zb(a,o,i),Bb(o,i),Vb(o,i,n),Hb(a,o,i,r),tx(a,i,t,$b(a,o,i)),rx(a,i,n),a},ax=new TextEncoder,ox=(e,t=1)=>ix(typeof e==`string`?ax.encode(e):e,t);function sx(e){let t=(0,$o.c)(5),n=e.className,r;t[0]===e.result?r=t[1]:(r=s(Re(ee(e.result),cx)),t[0]=e.result,t[1]=r);let i;return t[2]!==e.className||t[3]!==r?(i=(0,Q.jsx)(_b,{className:n,children:r}),t[2]=e.className,t[3]=r,t[4]=i):i=t[4],i}function cx(e){return e.message}var lx=Mi(`inline-block size-1.5 shrink-0 rounded-full`,{defaultVariants:{status:`live`},variants:{status:{error:`bg-destructive`,live:`bg-primary`,off:`border-muted-foreground border`,quiet:`bg-muted-foreground/50`,warning:`bg-warning`}}});function ux(e){let t=(0,$o.c)(6),n;t[0]!==e.className||t[1]!==e.status||t[2]!==e.waiting?(n=Fi(lx({status:e.status}),e.waiting===!0&&`motion-safe:animate-pulse`,e.className),t[0]=e.className,t[1]=e.status,t[2]=e.waiting,t[3]=n):n=t[3];let r;return t[4]===n?r=t[5]:(r=(0,Q.jsx)(`span`,{"data-slot":`status-dot`,"aria-hidden":`true`,className:n}),t[4]=n,t[5]=r),r}var dx=Z.createContext(void 0);function fx(){let e=Z.useContext(dx);if(e===void 0)throw Error(vo(13));return e}var px={imageLoadingStatus:()=>null},mx=Z.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,[o,s]=Z.useState(`idle`),c={imageLoadingStatus:o},l=Z.useMemo(()=>({imageLoadingStatus:o,setImageLoadingStatus:s}),[o,s]),u=qi(`span`,e,{state:c,ref:t,props:a,stateAttributesMapping:px});return(0,Q.jsx)(dx.Provider,{value:l,children:u})});function hx(e,{referrerPolicy:t,crossOrigin:n,sizes:r,srcSet:i},a){let o=Z.useState(`idle`),s=o[1];return Y(()=>{if(!a)return xa;if(!e&&!i)return s(`error`),xa;let o=!0,c=new window.Image,l=e=>()=>{o&&s(e)};return s(`loading`),c.onload=l(`loaded`),c.onerror=l(`error`),t&&(c.referrerPolicy=t),c.crossOrigin=n??null,r&&(c.sizes=r),i&&(c.srcset=i),e&&(c.src=e),c.complete&&s(c.naturalWidth>0?`loaded`:`error`),()=>{o=!1}},[a,e,i,r,n,t,s]),o}var gx={...px,...xo},_x=Z.forwardRef(function(e,t){let{className:n,render:r,onLoadingStatusChange:i,keepMounted:a=!1,style:o,sizes:s,srcSet:c,src:l,...u}=e,{setImageLoadingStatus:d}=fx(),[f,p]=hx(l,e,!a),m=f===`loaded`,{mounted:h,transitionStatus:g,setMounted:_}=Nc(m),v=Z.useRef(null),y=Z.useRef(!0);Y(()=>{if(!a)return;let e=y.current;y.current=!1;let t=v.current;if(!t)return;if(!t.complete){p(`loading`);return}let n=t.naturalWidth>0?`loaded`:`error`;p(n),n===`loaded`&&e&&_(!0)},[a,l,c,s,u.crossOrigin,u.referrerPolicy,r,p,_]);let b=a?{"data-loading":f===`loading`?``:void 0,"data-error":f===`error`?``:void 0,"aria-hidden":f!==`loaded`||void 0,onLoad(){p(`loaded`)},onError(){p(`error`)}}:void 0,x=X(e=>{i?.(e),d(e)});Y(()=>{f!==`idle`&&x(f)},[f,x]),Y(()=>()=>d(`idle`),[d]),Za({enabled:!m,open:m,ref:v,onComplete(){m||_(!1)}});let S={imageLoadingStatus:f,transitionStatus:a&&g===`ending`?void 0:g},C=a||h,w={};s!==void 0&&(w.sizes=s),c!==void 0&&(w.srcSet=c),l!==void 0&&(w.src=l);let T=qi(`img`,e,{state:S,ref:[t,v],props:[b,u,w],stateAttributesMapping:gx,enabled:C});return C?T:null}),vx=Z.forwardRef(function(e,t){let{className:n,render:r,delay:i=0,style:a,...o}=e,{imageLoadingStatus:s}=fx(),[c,l]=Z.useState(i===0),u=Ii();return Z.useEffect(()=>(i>0?u.start(i,()=>l(!0)):l(!0),u.clear),[u,i]),qi(`span`,e,{state:{imageLoadingStatus:s},ref:t,props:o,stateAttributesMapping:px,enabled:s!==`loaded`&&(i===0||c)})});function yx(e){let t=(0,$o.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,size:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o;t[4]===n?o=t[5]:(o=Fi(`group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten`,n),t[4]=n,t[5]=o);let s;return t[6]!==r||t[7]!==a||t[8]!==o?(s=(0,Q.jsx)(mx,{"data-slot":`avatar`,"data-size":a,className:o,...r}),t[6]=r,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function bx(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Fi(`aspect-square size-full rounded-full object-cover`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(_x,{"data-slot":`avatar-image`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function xx(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Fi(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(vx,{"data-slot":`avatar-fallback`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Sx=Z.createContext(void 0);function Cx(e){let t=Z.useContext(Sx);if(t===void 0&&!e)throw Error(vo(33));return t}var wx=Z.createContext(void 0);function Tx(e){let t=Z.useContext(wx);if(t===void 0&&!e)throw Error(vo(36));return t}var Ex=Z.createContext(void 0);function Dx(e=!0){let t=Z.useContext(Ex);if(t===void 0&&!e)throw Error(vo(25));return t}var Ox=Z.createContext(null);function kx(e=`root`){let t=Z.useContext(Ox),n=Z.useContext(wx);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var Ax={visible:!0,ref:null};function jx(){return Ax}function Mx(e,t,n=`root`){let r=kx(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??jx)({label:e.label,children:e.children,render:e.render}),a=ia(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}function Nx(e){e.preventDefault()}function Px(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=Tx(),u=Dx(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return Z.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?Nx:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:Ma})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!Mo&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&Fa(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var Fx={type:`regular-item`};function Ix(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=Z.useRef(null),{getButtonProps:d,buttonRef:f}=Ci({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Px({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=Z.useCallback(e=>qa(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=ia(u,f);return Z.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Lx=Z.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Rx(){return Z.useContext(Lx)}function zx(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=Rx(),u=Z.useRef(-1),[d,f]=Z.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=Z.useRef(null),h=Z.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return Y(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}function Bx(e){return Oi(e,`base-ui`)}var Vx=Z.createContext(void 0);function Hx(){let e=Z.useContext(Vx);if(e===void 0)throw Error(vo(31));return e}var Ux=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Z.useState(void 0),c=qi(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,Q.jsx)(Vx.Provider,{value:s,children:c})}),Wx=Z.forwardRef(function(e,t){let n=kx()?.Group??Ux;return(0,Q.jsx)(n,{...e,ref:t})}),Gx=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Bx(a),c=Hx();return Y(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),qi(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),Kx=Z.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=Tx(),f=zx({guess:!0,label:a}),p=Bx(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=Ix({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:Fx});return qi(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),qx=Z.forwardRef(function(e,t){let n=Mx(e,t);return n.visible?(0,Q.jsx)(Kx,{...e,ref:n.ref}):null}),Jx=Z.createContext(void 0);function Yx(e){let t=Z.useContext(Jx);if(t===void 0&&!e)throw Error(vo(69));return t}var Xx=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),Zx=Z.createContext(void 0);function Qx(){return Z.useContext(Zx)}function $x(e,t){let n=go(e.render);if(Z.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function eS(e,t,n){let r=$x(e,t),i=r===t?void 0:r;return[r,Z.useCallback(e=>n?.(e?i:void 0),[i,n])]}function tS(e,t,n){let r=go(e.render),i=Z.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var nS=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=Tx(),m=Qx(),{side:h,align:g}=Cx(),_=Yx(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),S=l.useState(`instantType`),C=l.useState(`activeTriggerElement`),w=l.useState(`parent`),T=l.useState(`lastOpenChangeReason`),E=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),k=l.useState(`closeDelay`),A=l.useState(`hoverEnabled`),j=l.useState(`disabled`),M=l.useState(`openMethod`),ee=l.useState(`activeTriggerId`),N=l.useState(`listElement`),[P,te]=eS(e,u,d),F=tS(e,C,ee),I=w.type===`menu`?m:void 0,ne=w.type===`context-menu`,L=s??w.type!==`menu`;s===void 0&&N&&w.type!==`menu`&&(L=()=>l.state.activeIndex===null&&N),Za({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),Z.useEffect(()=>{function e(e){l.setOpen(!1,No(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),_l(D,{enabled:A&&!j&&!ne&&w.type!==`menubar`,closeDelay:k});let re=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:ie,handleFocus:ae}=(Z.useContext(Ox)?.useParentHandoff??iS)(l,w,v,f),oe={transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},R=qi(`div`,e,{state:oe,ref:[t,l.context.popupRef,re,te],stateAttributesMapping:ps,props:[b,{id:P,...N?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":F},onKeyDown(e){I?.onPopupKeyDown?.(e),_&&Xx.has(e.key)&&e.stopPropagation()},onFocus:ae},id(y),c,{"data-rootownerid":E}]}),z=w.type===void 0||ne;(C||w.type===`menubar`&&T!==`outside-press`)&&(z=!0);let se=I?.getReturnElement??ie;return(0,Q.jsx)(Dc,{context:D,openInteractionType:M,modal:ne,disabled:!x,returnFocus:a??se??z,explicitReturnFocus:a===void 0&&se?!1:void 0,initialFocus:L,restoreFocus:!0,getInsideElements:w.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:w.type===`menubar`?void 0:O,previousFocusableElement:C,nextFocusableElement:w.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:R})}),rS={parentVirtualFocusRef:void 0,handleFocus:void 0};function iS(){return rS}var aS=Z.forwardRef(function(e,t){let n=kx()?.Popup??nS;return(0,Q.jsx)(n,{...e,ref:t})}),oS=Z.createContext(void 0);function sS(){let e=Z.useContext(oS);if(e===void 0)throw Error(vo(32));return e}var cS=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=Tx();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Q.jsx)(oS.Provider,{value:n,children:(0,Q.jsx)(_o,{ref:t,...r,portalOwnerRole:o})})});function lS(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=X(i),[,o]=Z.useState(0),s=bo(dS).current,c=bo(uS).current,l=Z.useRef(0),u=Z.useRef(!0),d=Z.useRef(null),f=Z.useRef(null),p=X(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=X((e,t)=>{c.set(e,t),p()}),h=X(e=>{c.delete(e),p()}),g=X(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!mS(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&hS(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=pS(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=X(()=>{let[e,t]=fS(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});Y(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),Y(()=>{u.current&&v()}),Y(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=X(e=>(s.add(e),()=>{s.delete(e)})),b=Z.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,Q.jsx)(Lx.Provider,{value:b,children:t})}function uS(){return new Map}function dS(){return new Set}function fS(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>hS(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function pS(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function mS(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function hS(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var gS=Z.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,Q.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function _S(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=Z.useRef(null),o=Z.useRef(null),s=wi(r);Y(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),Y(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}var vS={},yS={},bS=``;function xS(e,t){return Po(e)?e:t}function SS(e,t,n){return/hidden|clip/.test(e.getComputedStyle(xS(t,n)).overflowY)}function CS(e){if(typeof document>`u`)return!1;let t=So(e);return Va(t).innerWidth-t.documentElement.clientWidth>0}function wS(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=So(e),n=t.documentElement,r=t.body,i=xS(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function TS(e){let t=So(e),n=t.documentElement,r=t.body,i=xS(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function ES(e){let t=So(e),n=t.documentElement,r=t.body,i=Va(n),a=0,o=0,s=!1,c=Zi.create();if(Fo&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,vS={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},bS=n.style.scrollBehavior,yS={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=xS(n,r);s=wS(e),s?(n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`):(Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`)}function u(){Object.assign(n.style,vS),Object.assign(r.style,yS),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=bS)}function d(){u(),c.request(l)}l();let f=Yi(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var DS=new class{lockCount=0;restore=null;timeoutLock=da.create();timeoutUnlock=da.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=So(e),n=t.documentElement,r=t.body,i=Va(n);if(SS(i,n,r)){let t=new i.MutationObserver(()=>{SS(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=Ai||!CS(e);this.restore=a?TS(e):ES(e)}};function OS(e=!0,t=null){Y(()=>{if(e)return DS.acquire(t)},[e,t])}var kS=20;function AS(e,t,n,r){let[i,a]=Z.useState(!1);Y(()=>{if(!e||!t||n==null){a(!1);return}let r=So(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-kS)},[e,t,n]),OS(e&&(!t||i),r)}var jS=Z.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=ji,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=Tx(),x=sS(),S=Dx(!0),C=v.useState(`parent`),w=v.useState(`floatingRootContext`),T=v.useState(`floatingTreeRoot`),E=v.useState(`mounted`),D=v.useState(`open`),O=v.useState(`modal`),k=v.useState(`openMethod`),A=v.useState(`activeTriggerElement`),j=v.useState(`transitionStatus`),M=v.useState(`positionerElement`),ee=v.useState(`instantType`),N=v.useState(`adaptiveOrigin`),P=v.useState(`lastOpenChangeReason`),te=v.useState(`floatingNodeId`),F=v.useState(`floatingParentNodeId`),I=w.useState(`domReferenceElement`),ne=n,L=c,re=l,ie=s,ae=h;C.type===`context-menu`&&(ne=n??C.context?.anchor,ie??=`start`,!o&&ie!==`center`&&(re=e.alignOffset??2,L=e.sideOffset??-5));let oe=o,R=ie;C.type===`menu`?(oe??=`inline-end`,R??=`start`,ae=e.collisionAvoidance??$i):C.type===`menubar`&&(oe??=C.context.orientation===`vertical`?`inline-end`:`bottom`,R??=`start`);let z=C.type===`context-menu`,se=td({anchor:ne,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:oe,sideOffset:L,align:R,alignOffset:re,arrowPadding:z?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:te,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:ae,shift:z?{crossAxis:!(`side`in ae&&ae.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:N,lazyFlip:y?`placement`:!1});Z.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===te&&v.set(`hoverEnabled`,!1),e.nodeId!==te&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,No(Sa)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,te]),Z.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,No(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let ce=Ii();Z.useEffect(()=>{D||ce.clear()},[D,ce]),Z.useEffect(()=>{function e(e){if(D&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&A&&A!==e.target){let e=v.select(`closeDelay`);e>0?ce.isStarted()||ce.start(e,()=>{v.setOpen(!1,No(Sa))}):v.setOpen(!1,No(Sa))}else ce.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,ce]),Z.useEffect(()=>{let e={open:D,nodeId:te,parentNodeId:F,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,te,F]),_S({store:v,domReference:I,positionerElement:M,open:D});let B={open:D,side:se.side,align:se.align,anchorHidden:se.anchorHidden,nested:C.type===`menu`,instant:ee},le=C.type===`menubar`&&C.context.modal;AS(D&&(le||O&&P!==`trigger-hover`),k===`touch`,M,A);let ue=ad(e,B,{styles:se.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),de=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&P!==`trigger-hover`||C.type===`menubar`&&C.context.modal),fe=null;return C.type===`menubar`?fe=C.context.contentElement:C.type===void 0&&(fe=A),(0,Q.jsxs)(Sx.Provider,{value:se,children:[de&&(0,Q.jsx)(gS,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:ta(!D),cutout:fe}),(0,Q.jsx)(_c,{id:te,children:(0,Q.jsx)(lS,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:ue})})]})}),MS=Z.createContext(null);function NS(e){let t=Z.useContext(MS);if(t===null&&!e)throw Error(vo(5));return t}function PS(e){let t=Z.useRef(``),n=Z.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:Z.useCallback(n=>{n.detail===0?e(n,`keyboard`):(`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``)},[e]),onPointerDown:n}}function FS(e,t){let n=Z.useRef(e),r=X(t);Y(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function IS(e,t){let{onClick:n,onPointerDown:r}=PS(X((n,r)=>{(typeof e==`function`?e():e)||t(r||(Ai?`touch`:``))}));return Z.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function LS(e){let[t,n]=Z.useState(null),r=IS(e,n);return FS(e,t=>{t&&!e&&n(null)}),Z.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function RS(e){return e==null?ro:e.type.startsWith(`key`)?La:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?Ba:ro}var zS={...rl,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=rl.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>Fo&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!rl.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},BS=class extends Ni{constructor(e,t,n=!1){let r=new Jc,i=HS(r,t,n,e);super(i,VS(r),zS),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function VS(e){return{positionerRef:Z.createRef(),popupRef:Z.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:Z.createRef(),beforeTriggerFocusGuardRef:Z.createRef(),beforeContentFocusGuardRef:Z.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function HS(e,t,n=!1,r){return{...Zc(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:_a,inputProps:_a,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new dc,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:_a,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var US=Z.createContext(null);function WS(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function GS(e,t){return e===`list-navigation`||WS(e,t)}var KS=ea(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:y,allowEscape:b=!0,resetOnPointerLeave:x=!0}=e,S=Dx(!0),C=Tx(!0),w=NS(!0),T=C?.store,E=C?.virtualFocus??!1,D=Z.useMemo(()=>_&&T?{type:`menu`,store:T}:w?{type:`menubar`,context:w}:S&&!T?{type:`context-menu`,context:S}:{type:void 0},[S,T,w,_]),O=Bx(),k=Bx(),[A,j]=Z.useState(void 0),M=(A??k)||void 0,ee=mc(),N=D.type===`menu`?D.store:void 0,P=(n??o)&&N?.state.transitionStatus===`starting`,te=bo(()=>P?N?.state.instantType:void 0).current,F=bo(()=>{let e=new BS({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:D,disabled:s,highlightItemOnHover:g,modal:D.type===void 0?c:void 0,rootId:O,instantType:te},M,ee!=null);return e.context.virtualFocusRef=y,e}).current;F.useControlledProp(`openProp`,n),F.useControlledProp(`triggerIdProp`,m),F.useContextCallback(`onOpenChangeComplete`,i);let I=F.useState(`floatingTreeRoot`),ne=gc(I),L=F.useState(`open`),re=F.useState(`activeTriggerElement`),ie=F.useState(`positionerElement`),ae=F.useState(`hoverEnabled`),oe=F.useState(`disabled`),R=F.useState(`lastOpenChangeReason`),z=F.useState(`parent`),se=F.useState(`activeIndex`),ce=F.useState(`keyboardOpen`),B=F.useState(`payload`),le=F.useState(`floatingParentNodeId`),ue=Z.useRef(null),de=Z.useRef(z.type!==`context-menu`),fe=Ii(),pe=Z.useRef(!0),V=Ii(),me=le!=null,{openMethod:H,triggerProps:he}=LS(L);F.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:z.type===void 0?c:void 0,openMethod:H,rootId:O}),Wc(F);let{forceUnmount:ge,transitionStatus:_e}=Gc(L,F,()=>{F.set(`allowMouseEnter`,!1)},P),ve=wi(F.context.popupRef);Z.useEffect(()=>{if(te===void 0)return;let e=()=>{F.state.instantType===te&&F.set(`instantType`,void 0)};if(!L){e();return}if(_e!==void 0)return;if(F.context.popupRef.current==null){e();return}let t=new AbortController;return ve(e,t.signal),()=>{t.abort()}},[te,L,_e,ve,F]),Y(()=>{S&&!C?F.update({parent:{type:`context-menu`,context:S},floatingNodeId:ne,floatingParentNodeId:ee}):(C||!F.select(`activeTriggerElement`))&&F.update({floatingNodeId:ne,floatingParentNodeId:ee})},[S,C,ne,ee,re,F]),Z.useEffect(()=>{L||(ue.current=null),z.type===`context-menu`&&(L?fe.start(500,()=>{de.current=!0}):(fe.clear(),de.current=!1))},[fe,L,z.type]),Y(()=>{!L&&!ae&&F.set(`hoverEnabled`,!0)},[L,ae,F]);let ye=X((e,t)=>{let n=t.reason;if(!e&&!F.select(`open`)||L===e&&t.trigger===re&&R===n)return;let i=Hc(t);if(!e&&t.trigger==null&&(t.trigger=re??void 0),r?.(e,t),t.isCanceled)return;F.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!pe.current)return;e&&n===`trigger-focus`?(pe.current=!1,V.start(300,()=>{pe.current=!0})):(pe.current=!0,V.clear());let o=!e&&(n===`escape-key`||n==null);ue.current=t.event;let s=Vc(F.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&GS(n,a),s.instantType=z.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:WS(n,a)?`click`:o?`dismiss`:void 0,F.update(s)}),be=Mc({popupStore:F,floatingRootContext:F.state.floatingRootContext,floatingId:M,nested:ee!=null,onOpenChange:ye}),xe=be.context.events;Y(()=>{let e=({open:e,eventDetails:t})=>ye(e,t);return xe.on(`setOpen`,e),()=>{xe?.off(`setOpen`,e)}},[xe,ye]),Y(()=>F.subscribeToParentMenu(),[F]);let Se=Z.useCallback(()=>{F.setOpen(!1,No(wo))},[F]);Z.useImperativeHandle(d,()=>({unmount:ge,close:Se}),[ge,Se]);let Ce;z.type===`context-menu`&&(Ce=z.context),Z.useImperativeHandle(Ce?.positionerRef,()=>ie,[ie]),Z.useImperativeHandle(Ce?.actionsRef,()=>({setOpen:ye}),[ye]);let we=jc(be,{enabled:!oe,bubbles:{escapeKey:f&&z.type===`menu`},outsidePress(){return z.type!==`context-menu`||ue.current?.type===`contextmenu`||de.current},externalTree:me?I:void 0}),Te=Vu(),Ee=El(be,{enabled:!oe,listRef:F.context.itemDomElements,activeIndex:se,virtual:v,nested:z.type===`menubar`||!v&&z.type!==void 0,parentOrientation:z.type===`menubar`?z.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?ce:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:Te===`rtl`,disabledIndices:ya,onNavigate(e,t){F.setActiveIndex(e,RS(t),t?.nativeEvent)},openOnArrowKeyDown:z.type!==`context-menu`&&!(v&&_),externalTree:!v&&me?I:void 0,nestedReturnFocusRef:N?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),De=Z.useCallback(e=>{F.context.typingRef.current=e},[F]),Oe=Dl(be,{enabled:!oe&&!v,listRef:F.context.itemLabels,elementsRef:F.context.itemDomElements,activeIndex:se,resetMs:500,onMatch:(e,t)=>{L&&e!==se&&F.setActiveIndex(e,La,t.nativeEvent)},onTyping:De}),ke=X(a),Ae=Z.useRef(-1),je=X(()=>{let e=F.state.activeIndex,t=e===null?void 0:F.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Ae.current===n&&F.context.reportedItem===t)return;Ae.current=n,F.context.reportedItem=t,v&&F.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=F.context;F.context.highlightReason=ro,F.context.highlightEvent=void 0,a&&ke(t,sa(r,i,{label:t===void 0?void 0:F.context.itemLabels.current[n]??void 0}))});Y(()=>{je()},[se,je]);let Me=Z.useMemo(()=>{if(!v)return Ee.reference;if(!Ee.trigger)return _a;let{onFocus:e,...t}=Ee.trigger;return t},[v,Ee.reference,Ee.trigger]);F.useSyncedValue(`inputProps`,v?Ee.reference??_a:_a);let Ne=Z.useMemo(()=>{let e=qa(Oe.reference,Me,we.reference,{onMouseMove(){F.set(`allowMouseEnter`,!0)}},he);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=L,e},[F,Oe.reference,Me,we.reference,he,L]),Pe=Z.useMemo(()=>{let e=qa(Ee.trigger,we.trigger,he);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Ee.trigger,we.trigger,he]);bo(()=>(F.update({inactiveTriggerProps:Pe}),null)),Kc(F,{floatingRootContext:be,activeTriggerProps:Ne,inactiveTriggerProps:Pe,popupProps:Z.useMemo(()=>qa(Fc,{onMouseMove(){F.set(`allowMouseEnter`,!0),z.type===`menu`&&F.set(`hoverEnabled`,!1)},onClick(){F.select(`hoverEnabled`)&&F.set(`hoverEnabled`,!1)},onKeyDown(e){let t=F.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Oe.floating,Ee.floating,we.floating),[z.type,F,Oe.floating,Ee.floating,we.floating]),itemProps:Ee.item??_a});let Fe=Z.useMemo(()=>({store:F,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:je}),[F,D,u,l,b,k,v,E,je]),Ie=typeof t==`function`?t({payload:B}):t,U=(0,Q.jsxs)(wx.Provider,{value:Fe,children:[p&&(0,Q.jsx)(Rc,{handle:p,store:F}),Ie]});return(z.type===void 0||z.type===`context-menu`)&&(U=(0,Q.jsx)(vc,{externalTree:I,children:U})),U});function qS(e){let t=Z.useContext(US);if(t===null)return(0,Q.jsx)(KS,{...e});let n=t.Root;return(0,Q.jsx)(US.Provider,{value:null,children:(0,Q.jsx)(n,{...t.options,...e})})}var JS={};function YS(e){Tx();let t=Z.useContext(US);if(t!==null){let n=t.SubmenuRoot;return(0,Q.jsx)(US.Provider,{value:null,children:(0,Q.jsx)(n,{...t.options,...e})})}return(0,Q.jsx)(Zx.Provider,{value:JS,children:(0,Q.jsx)(KS,{...e,isSubmenu:!0})})}var XS=5;function ZS(e,t){let n=QS(t);return e.clientX>=n.left-XS&&e.clientX<=n.right+XS&&e.clientY>=n.top-XS&&e.clientY<=n.bottom+XS}function QS(e){let t=e.getBoundingClientRect(),n=Va(e);if(Ro)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function $S(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=so(),{ref:i,index:a}=zx(e),o=n===a,s=Z.useRef(null),c=ia(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function eC(e){let{render:t,className:n,style:r,state:i=_a,props:a=ya,refs:o=ya,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=$S({metadata:s});return qi(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function tC(e){if(Lo(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Da(e))return tC(Wa(e))}function nC(e,t){function n(n,r,i){let a=n.currentTarget;Qo.flushSync(()=>{e.setOpen(!1,No(eo,n.nativeEvent,a))}),pa(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&Hi(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function rC(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=Z.useRef(!1);return Z.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,So(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:_a,[t,n,r])}var iC=$a(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=Tx(!0),h=il(d)??m?.store;if(!h)throw Error(vo(85));let g=Bx(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=Z.useRef(null),S=oC(),C=so(!0),w=hc(),T=Z.useMemo(()=>w??new dc,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=Uc(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:gc(T),floatingParentNodeId:mc(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=Ci({disabled:A,native:o});Z.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let ee=Z.useRef(null),N=Ii(),P=X(e=>{if(!ee.current)return;N.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;J(ee.current,t)||J(h.select(`positionerElement`),t)||t===ee.current||t!=null&&tC(t)===h.select(`rootId`)||ZS(e,ee.current)||T.events.emit(`close`,{domEvent:e,reason:lo})});Z.useEffect(()=>{let e=So(ee.current);if(y&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,P,{once:!0}),()=>{e.removeEventListener(`mouseup`,P)}},[y,P,h]);let te=O&&S.context.hasSubmenuOpen,F=yl(v,{enabled:(c??te)&&!A&&(!O||te&&!D),handleClose:Fl({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),I=aC(y,h.select(`lastOpenChangeReason`)),ne=Oc(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&I}),L=ol(v,{enabled:!A&&te}),re=rC({open:y,enabled:O,mouseDownAction:`open`}),ie=Z.useMemo(()=>qa(L.reference,ne.reference),[L.reference,ne.reference]),ae=h.useState(`triggerProps`,D),oe=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:R,handleFocusTargetFocus:z}=nC(h,x),se={disabled:A,open:y},ce=[ee,t,M,E,x],B=[ie,F??_a,ae,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(N.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),So(e.currentTarget).addEventListener(`mouseup`,P,{once:!0}))}},oe,O?{role:`menuitem`}:{},re,p,j],le=qi(`button`,e,{enabled:!O,stateAttributesMapping:ds,state:se,ref:ce,props:B});return O?(0,Q.jsx)(eC,{tag:`button`,render:n,className:r,style:i,state:se,refs:ce,props:B,stateAttributesMapping:ds}):y?(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(Li,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:R},`${g}-pre-focus-guard`),(0,Q.jsx)(Z.Fragment,{children:le},g),(0,Q.jsx)(Li,{ref:h.context.triggerFocusTargetRef,onFocus:z},`${g}-post-focus-guard`)]}):(0,Q.jsx)(Z.Fragment,{children:le},g)});function aC(e,t){let n=Ii(),[r,i]=Z.useState(!1);return Y(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function oC(){let e=NS(!0);return Z.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var sC={"aria-expanded":void 0},cC=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,label:a,id:o,nativeButton:s=!1,openOnHover:c=!0,delay:l=100,closeDelay:u=0,disabled:d=!1,...f}=e,p=Tx(!0);if(p?.parent.type!==`menu`)throw Error(vo(37));let m=Cx(),h=Qx(),{store:g,parentVirtualFocus:_}=p,v=p.parent.store,y=zx({guess:!0,label:a}),b=Bx(o),x=g.useState(`open`),S=Z.useRef(!1),C=g.useState(`positionerElement`),w=g.useState(`floatingRootContext`),T=g.useState(`floatingTreeRoot`),E=g.useState(`triggerPopupId`,b),D=Bc(b,g),O=X(e=>{D(e);let t=g.select(`activeTriggerElement`);e!==null&&g.select(`open`)&&(t===e||g.select(`activeTriggerId`)==null)&&g.update({activeTriggerId:b??null,activeTriggerElement:e,closeDelay:u})}),k=Z.useRef(null),A=Z.useCallback(e=>{k.current=e,g.set(`activeTriggerElement`,e)},[g]);Y(()=>(O(k.current),()=>O(null)),[O,b,g]),Y(()=>{if(!x||!C)return;function e(e){ko(e)===g.context.beforeContentFocusGuardRef.current&&(S.current=e.relatedTarget===k.current)}return C.addEventListener(`focusout`,e,!0),()=>{S.current=!1,C.removeEventListener(`focusout`,e,!0)}},[x,C,g]),g.useSyncedValue(`closeDelay`,u);let j=g.useState(`disabled`),M=v.useState(`disabled`),ee=d||j||M,N=v.useState(`itemProps`),P=v.useState(`isActive`,y.index),te=Z.useMemo(()=>({type:`submenu-trigger`,setActive(e){v.select(`highlightItemOnHover`)&&v.setActiveIndex(y.index,Ba,e)}}),[v,y.index]),{getItemProps:F,itemRef:I}=Ix({closeOnClick:!1,disabled:ee,highlighted:P,id:b,store:g,typingRef:v.context.typingRef,nativeButton:s,itemMetadata:te,nodeId:m?.context.nodeId}),ne=yl(w,{enabled:g.useState(`hoverEnabled`)&&c&&!ee,handleClose:Fl({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:l,delay:{open:l,close:u},shouldOpen:l>0?()=>v.select(`allowMouseEnter`):void 0,triggerElementRef:k,externalTree:T,isClosing:()=>g.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),L=Oc(w,{enabled:!ee,event:`mousedown`,toggle:!0,ignoreMouse:c,stickIfOpen:c}).reference??_a,re=g.useState(`triggerProps`,!0);delete re.id;let ie={disabled:ee,highlighted:P,open:x},ae=g.useState(`openMethod`),oe=g.useState(`lastOpenChangeReason`)===`list-navigation`||ae===`keyboard`,R=x&&oe&&Oa,z=h?.onTriggerKeyDown?{onKeyDown:h.onTriggerKeyDown}:void 0;return qi(`div`,e,{state:ie,stateAttributesMapping:us,props:[L,ne,re,z,N,R?sC:void 0,{"aria-controls":E,tabIndex:_||!(x||P)?-1:0,onFocus(e){g.select(`open`)&&S.current&&(S.current=!1,g.setOpen(!1,No(eo,e.nativeEvent)))},onBlur(){P&&v.setActiveIndex(null,ro)}},f,F],ref:[t,y.ref,I,O,A]})}),lC=Z.forwardRef(function(e,t){let n=Mx(e,t,`submenu-trigger`);if(!n.visible)return null;let r=n.props?qa(n.props,e):e;return(0,Q.jsx)(cC,{...r,ref:n.ref})});function uC(e){let t=(0,$o.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(qS,{"data-slot":`dropdown-menu`,...n}),t[2]=n,t[3]=r),r}function dC(e){let t=(0,$o.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(iC,{"data-slot":`dropdown-menu-trigger`,...n}),t[2]=n,t[3]=r),r}function fC(e){let t=(0,$o.c)(18),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({align:i,alignOffset:a,side:o,sideOffset:s,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=i===void 0?`start`:i,l=a===void 0?0:a,u=o===void 0?`bottom`:o,d=s===void 0?4:s,f;t[7]===n?f=t[8]:(f=Fi(`z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[7]=n,t[8]=f);let p;t[9]!==r||t[10]!==f?(p=(0,Q.jsx)(aS,{"data-slot":`dropdown-menu-content`,className:f,...r}),t[9]=r,t[10]=f,t[11]=p):p=t[11];let m;return t[12]!==c||t[13]!==l||t[14]!==u||t[15]!==d||t[16]!==p?(m=(0,Q.jsx)(cS,{children:(0,Q.jsx)(jS,{className:`isolate z-50 outline-none`,align:c,alignOffset:l,side:u,sideOffset:d,children:p})}),t[12]=c,t[13]=l,t[14]=u,t[15]=d,t[16]=p,t[17]=m):m=t[17],m}function pC(e){let t=(0,$o.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(Wx,{"data-slot":`dropdown-menu-group`,...n}),t[2]=n,t[3]=r),r}function mC(e){let t=(0,$o.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,inset:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=Fi(`px-2 py-1.5 text-xs text-muted-foreground data-inset:pl-7.5`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,Q.jsx)(Gx,{"data-slot":`dropdown-menu-label`,"data-inset":r,className:a,...i}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function hC(e){let t=(0,$o.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,inset:r,variant:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===n?s=t[6]:(s=Fi(`group/dropdown-menu-item relative flex min-h-7 cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs/relaxed outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7.5 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5 data-[variant=destructive]:*:[svg]:text-destructive`,n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o?(c=(0,Q.jsx)(qx,{"data-slot":`dropdown-menu-item`,"data-inset":r,"data-variant":o,className:s,...i}),t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=c):c=t[11],c}function gC(e){let t=(0,$o.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(YS,{"data-slot":`dropdown-menu-sub`,...n}),t[2]=n,t[3]=r),r}function _C(e){let t=(0,$o.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=Fi(`flex min-h-7 cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7.5 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(Wo,{className:`ml-auto`}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,Q.jsxs)(lC,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":i,className:o,...a,children:[n,s]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function vC(e){let t=(0,$o.c)(16),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({align:i,alignOffset:a,side:o,sideOffset:s,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=i===void 0?`start`:i,l=a===void 0?-3:a,u=o===void 0?`right`:o,d=s===void 0?0:s,f;t[7]===n?f=t[8]:(f=Fi(`w-auto min-w-32 rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[7]=n,t[8]=f);let p;return t[9]!==c||t[10]!==l||t[11]!==r||t[12]!==u||t[13]!==d||t[14]!==f?(p=(0,Q.jsx)(fC,{"data-slot":`dropdown-menu-sub-content`,className:f,align:c,alignOffset:l,side:u,sideOffset:d,...r}),t[9]=c,t[10]=l,t[11]=r,t[12]=u,t[13]=d,t[14]=f,t[15]=p):p=t[15],p}function yC(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Fi(`-mx-1 my-1 h-px bg-border/50`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(fb,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function bC(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Fi(`w-full caption-bottom text-xs`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,Q.jsx)(`table`,{"data-slot":`table`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function xC(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Fi(`[&_tr]:border-b`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`thead`,{"data-slot":`table-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function SC(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Fi(`[&_tr:last-child]:border-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`tbody`,{"data-slot":`table-body`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function CC(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Fi(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`tr`,{"data-slot":`table-row`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function wC(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Fi(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`th`,{"data-slot":`table-head`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function TC(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Fi(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`td`,{"data-slot":`table-cell`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var EC=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='256'%20height='150'%20preserveAspectRatio='xMidYMid'%20viewBox='0%200%20256%20150'%3e%3cpath%20fill='%2334a853'%20d='m255.3%20143.5-.3-1.6a128%20128%200%200%200-12.8-38.3%20129%20129%200%200%200-23.4-31.8%20129%20129%200%200%200-22.7-18l.1-.3%207.8-13.4%207.5-13%205.5-9.4a12%2012%200%200%200%20.6-10.5%2012%2012%200%200%200-4.8-5.5%2012%2012%200%200%200-5-1.7h-2.2a12%2012%200%200%200-9%205.9l-5.4%209.3-7.6%2013.1-7.7%2013.4-.9%201.5-1.2-.5a128%20128%200%200%200-45.8-8.4h-1.3q-21.7.3-41%207.1l-4.5%201.7-.7-1.4-7.8-13.4-7.6-13-5.4-9.4A12%2012%200%200%200%2048.5%200a12%2012%200%200%200-5%201.7%2012%2012%200%200%200-4%204q-.6.8-.8%201.5a12%2012%200%200%200-.4%208.2l1%202.3%205.5%209.4%207.5%2013%207.8%2013.4v.1a129%20129%200%200%200-14.8%2010.8%20130%20130%200%200%200-22.2%2024%20128%20128%200%200%200-9.3%2015.2%20128%20128%200%200%200-10.9%2028.8l-2%209.5-.2%201.6L0%20149h256z'/%3e%3cpath%20fill='%23202124'%20d='M194.6%20113.7c5.1-3.4%205.9-11.3%201.7-17.6s-11.8-8.7-17-5.3c-5%203.4-5.8%2011.3-1.6%2017.6s11.8%208.7%2016.9%205.3m-116-5.2c4.1-6.4%203.4-14.2-1.7-17.7-5.2-3.4-12.7-1-17%205.3-4.1%206.3-3.4%2014.2%201.7%2017.6%205.2%203.4%2012.7%201%2017-5.2'/%3e%3c/svg%3e`,DC=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%20width='209'%20height='256'%20viewBox='0%200%20814%201000'%3e%3cpath%20d='M788.1%20340.9c-5.8%204.5-108.2%2062.2-108.2%20190.5%200%20148.4%20130.3%20200.9%20134.2%20202.2-.6%203.2-20.7%2071.9-68.7%20141.9-42.8%2061.6-87.5%20123.1-155.5%20123.1s-85.5-39.5-164-39.5c-76.5%200-103.7%2040.8-165.9%2040.8s-105.6-57-155.5-127C46.7%20790.7%200%20663%200%20541.8c0-194.4%20126.4-297.5%20250.8-297.5%2066.1%200%20121.2%2043.4%20162.7%2043.4%2039.5%200%20101.1-46%20176.3-46%2028.5%200%20130.9%202.6%20198.3%2099.2m-234-181.5c31.1-36.9%2053.1-88.1%2053.1-139.3A96%2096%200%200%200%20605.3%200c-50.6%201.9-110.8%2033.7-147.1%2075.8-28.5%2032.4-55.1%2083.6-55.1%20135.5%200%207.8%201.3%2015.6%201.9%2018.1%203.2.6%208.4%201.3%2013.6%201.3%2045.4%200%20102.5-30.4%20135.5-71.3'/%3e%3c/svg%3e`,OC=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20preserveAspectRatio='xMidYMid'%20viewBox='0%200%20190.5%20190.5'%3e%3cpath%20fill='%23fff'%20d='M95.3%20142.9a47.6%2047.6%200%201%200%200-95.3%2047.6%2047.6%200%200%200%200%2095.3'/%3e%3cpath%20fill='%23229342'%20d='M54%20119%2012.8%2047.7a95%2095%200%200%200%200%2095.3%2095%2095%200%200%200%2082.5%2047.6l41.2-71.4a48%2048%200%200%201-17.4%2017.4%2048%2048%200%200%201-47.7%200A48%2048%200%200%201%2054%20119.1'/%3e%3cpath%20fill='%23fbc116'%20d='m136.5%20119-41.2%2071.5a95%2095%200%200%200%2082.4-47.6%2095%2095%200%200%200%2012.8-47.7%2095%2095%200%200%200-12.8-47.6H95.2a48%2048%200%200%201%2023.9%206.4%2048%2048%200%200%201%2017.4%2017.4%2048%2048%200%200%201%200%2047.7'/%3e%3cpath%20fill='%231a73e8'%20d='M95.3%20133a37.7%2037.7%200%201%200%200-75.4%2037.7%2037.7%200%200%200%200%2075.4'/%3e%3cpath%20fill='%23e33b2e'%20d='M95.3%2047.6h82.4A95%2095%200%200%200%20143%2012.8%2095%2095%200%200%200%2095.2%200a95%2095%200%200%200-47.6%2012.8%2095%2095%200%200%200-34.8%2034.8L54%20119.1a48%2048%200%200%201%200-47.7%2048%2048%200%200%201%2041.3-23.8'/%3e%3c/svg%3e`,kC=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='256'%20height='257'%20preserveAspectRatio='xMidYMid'%20viewBox='0%200%20256%20257'%3e%3cpath%20fill='%23d97757'%20d='m50.2%20170.3%2050.4-28.2.8-2.5-.8-1.4H98l-8.4-.5-28.8-.8-25-1-24.1-1.3-6.1-1.3-5.7-7.5.6-3.8%205.1-3.4%207.3.7%2016.2%201%2024.3%201.7%2017.7%201%2026%202.8h4.2l.6-1.7-1.4-1-1.1-1L74.3%20105%2047.1%2087%2033%2076.6l-8-5.2-3.8-5-1.7-10.7%207-7.7%209.4.6%202.4.7%209.5%207.3%2020.3%2015.7L94.8%2092l4%203.2%201.5-1%20.2-.8-1.8-3-14.4-26-15.5-26.6-6.8-11-2-6.8c-.6-2.7-1-5-1-7.8l8-10.8L71.3%200%2082%201.4l4.5%204%206.6%2015%2010.7%2023.8%2016.6%2032.3%204.9%209.6%202.6%209%201%202.6h1.6v-1.5L132%2078l2.5-22.4%202.5-28.8.8-8%204-9.8%208-5.2%206.2%203%205.2%207.3-.8%204.7-3%2019.8-6%2031-3.9%2020.7h2.3l2.6-2.6%2010.5-14%2017.6-22%207.8-8.7%209-9.7%206-4.6h11l8%2012-3.6%2012.5-11.3%2014.4-9.4%2012.2-13.5%2018.1-8.4%2014.5.7%201.2%202-.2%2030.5-6.5%2016.5-3%2019.6-3.3%208.9%204.1%201%204.2-3.5%208.7-21%205.1-24.7%205-36.7%208.7-.4.3.5.6L186%20139l7.1.4h17.3l32.2%202.4%208.4%205.5%205.1%206.9-.8%205.1-13%206.6-17.5-4.1-40.8-9.7-14-3.5h-2v1.1l11.7%2011.5%2021.4%2019.3%2026.7%2024.9%201.4%206.1-3.4%204.9-3.7-.5-23.5-17.7-9-8-20.6-17.3h-1.4v1.8l4.8%207%2025%2037.5%201.3%2011.6-1.8%203.7-6.5%202.3-7.1-1.3-14.7-20.6-15-23-12.3-20.8-1.5.8-7.2%2077.5-3.3%204-7.8%202.9-6.5-5-3.4-7.9%203.4-15.8%204.2-20.5%203.3-16.3%203-20.3%201.9-6.8-.1-.4-1.5.2-15.3%2021L87%20215.8l-18.4%2019.7-4.4%201.8-7.7-4%20.8-7%204.2-6.3L87%20187.6l15.4-20.1%209.9-11.6v-1.7h-.7l-67.6%2044-12%201.5-5.3-4.9.7-8%202.4-2.5z'/%3e%3c/svg%3e`,AC=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='1em'%20height='1em'%20fill='%23111'%20fill-rule='evenodd'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20d='M8%20.5a6%206%200%200%201%203.1-.5q2.1.3%203.6%201.7h.1a6%206%200%200%201%204%20.4h.1l.2.1a6%206%200%200%201%203.3%205.4l-.2%201.6v.2a6%206%200%200%201%201.7%202.8%206%206%200%200%201-1.2%205.2l-.2.2a6%206%200%200%201-3%201.9l-1%202a6%206%200%200%201-5%202.5%206%206%200%200%201-4.2-1.7h-.1l-1.6.1a6%206%200%200%201-2.6-.6A6%206%200%200%201%202.8%2020l-.5-.8-.5-1.3a6%206%200%200%201%200-3v-.1a6%206%200%200%201-1.5-2.3L0%2011l.2-2.1a6%206%200%200%201%204.2-4.3h.1a6%206%200%200%201%201.1-2.2A6%206%200%200%201%208.1.5m-.7%207.8a.8.8%200%200%200-1.5.8l1.7%203L5.8%2015a.8.8%200%200%200%201.5.8l2-3.2a1%201%200%200%200%200-.9zm5.4%206.2a.8.8%200%200%200%200%201.7h4.9a.8.8%200%200%200%200-1.7z'%20clip-rule='evenodd'/%3e%3c/svg%3e`,jC=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20256%20256'%3e%3cdefs%3e%3cradialGradient%20id='b'%20cx='161.8'%20cy='68.9'%20r='95.4'%20gradientTransform='matrix(1%200%200%20-.95%200%20248.8)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='.7'%20stop-opacity='0'/%3e%3cstop%20offset='.9'%20stop-opacity='.5'/%3e%3cstop%20offset='1'/%3e%3c/radialGradient%3e%3cradialGradient%20id='d'%20cx='-340.3'%20cy='63'%20r='143.2'%20gradientTransform='rotate(98.6%20142.3%2013.2)scale(-1%20.8)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='.8'%20stop-opacity='0'/%3e%3cstop%20offset='.9'%20stop-opacity='.5'/%3e%3cstop%20offset='1'/%3e%3c/radialGradient%3e%3cradialGradient%20id='e'%20cx='113.4'%20cy='570.2'%20r='202.4'%20gradientTransform='rotate(92.2%20-538%20-620.8)scale(1%20-2.13)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%2335c1f1'/%3e%3cstop%20offset='.1'%20stop-color='%2334c1ed'/%3e%3cstop%20offset='.2'%20stop-color='%232fc2df'/%3e%3cstop%20offset='.3'%20stop-color='%232bc3d2'/%3e%3cstop%20offset='.7'%20stop-color='%2336c752'/%3e%3c/radialGradient%3e%3cradialGradient%20id='f'%20cx='376.5'%20cy='568'%20r='97.3'%20gradientTransform='matrix(.28%20.96%20.78%20-.23%20-303.8%20-148.5)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%2366eb6e'/%3e%3cstop%20offset='1'%20stop-color='%2366eb6e'%20stop-opacity='0'/%3e%3c/radialGradient%3e%3clinearGradient%20id='a'%20x1='63.3'%20x2='241.7'%20y1='84'%20y2='84'%20gradientTransform='matrix(1%200%200%20-1%200%20266)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%230c59a4'/%3e%3cstop%20offset='1'%20stop-color='%23114a8b'/%3e%3c/linearGradient%3e%3clinearGradient%20id='c'%20x1='157.3'%20x2='46'%20y1='161.4'%20y2='40.1'%20gradientTransform='matrix(1%200%200%20-1%200%20266)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%231b9de2'/%3e%3cstop%20offset='.2'%20stop-color='%231595df'/%3e%3cstop%20offset='.7'%20stop-color='%230680d7'/%3e%3cstop%20offset='1'%20stop-color='%230078d4'/%3e%3c/linearGradient%3e%3c/defs%3e%3cpath%20fill='url(%23a)'%20d='M235.7%20195.5a94%2094%200%200%201-10.6%204.7%20102%20102%200%200%201-35.9%206.4c-47.3%200-88.5-32.5-88.5-74.3a32%2032%200%200%201%2016.4-27.3c-42.8%201.8-53.8%2046.4-53.8%2072.5%200%2074%2068.1%2081.4%2082.8%2081.4%207.9%200%2019.8-2.3%2027-4.6l1.3-.4a128%20128%200%200%200%2066.6-52.8%204%204%200%200%200-5.3-5.6'%20transform='translate(-4.6%20-5)'/%3e%3cpath%20fill='url(%23b)'%20d='M235.7%20195.5a94%2094%200%200%201-10.6%204.7%20102%20102%200%200%201-35.9%206.4c-47.3%200-88.5-32.5-88.5-74.3a32%2032%200%200%201%2016.4-27.3c-42.8%201.8-53.8%2046.4-53.8%2072.5%200%2074%2068.1%2081.4%2082.8%2081.4%207.9%200%2019.8-2.3%2027-4.6l1.3-.4a128%20128%200%200%200%2066.6-52.8%204%204%200%200%200-5.3-5.6'%20opacity='.3'%20style='isolation:isolate'%20transform='translate(-4.6%20-5)'/%3e%3cpath%20fill='url(%23c)'%20d='M110.3%20246.3A79%2079%200%200%201%2087.6%20225a80.7%2080.7%200%200%201%2029.5-120c3.2-1.5%208.5-4.1%2015.6-4a32%2032%200%200%201%2025.7%2013%2032%2032%200%200%201%206.3%2018.7c0-.2%2024.5-79.6-80-79.6-43.9%200-80%2041.6-80%2078.2a130%20130%200%200%200%2012.1%2056%20128%20128%200%200%200%20156.4%2067%2076%2076%200%200%201-62.8-8Z'%20transform='translate(-4.6%20-5)'/%3e%3cpath%20fill='url(%23d)'%20d='M110.3%20246.3A79%2079%200%200%201%2087.6%20225a80.7%2080.7%200%200%201%2029.5-120c3.2-1.5%208.5-4.1%2015.6-4a32%2032%200%200%201%2025.7%2013%2032%2032%200%200%201%206.3%2018.7c0-.2%2024.5-79.6-80-79.6-43.9%200-80%2041.6-80%2078.2a130%20130%200%200%200%2012.1%2056%20128%20128%200%200%200%20156.4%2067%2076%2076%200%200%201-62.8-8Z'%20opacity='.4'%20style='isolation:isolate'%20transform='translate(-4.6%20-5)'/%3e%3cpath%20fill='url(%23e)'%20d='M157%20153.8c-.9%201-3.4%202.5-3.4%205.6q0%204%204.8%207.3c14.3%2010%2041.4%208.6%2041.5%208.6a60%2060%200%200%200%2030.3-8.3%2061%2061%200%200%200%2030.4-52.9c.3-22.4-8-37.3-11.3-43.9C228%2028.8%20182.3%205%20132.6%205a128%20128%200%200%200-128%20126.2c.5-36.5%2036.8-66%2080-66%203.5%200%2023.5.3%2042%2010a73%2073%200%200%201%2030.9%2029.3c6.1%2010.6%207.2%2024.1%207.2%2029.5s-2.7%2013.3-7.8%2019.9Z'%20transform='translate(-4.6%20-5)'/%3e%3cpath%20fill='url(%23f)'%20d='M157%20153.8c-.9%201-3.4%202.5-3.4%205.6q0%204%204.8%207.3c14.3%2010%2041.4%208.6%2041.5%208.6a60%2060%200%200%200%2030.3-8.3%2061%2061%200%200%200%2030.4-52.9c.3-22.4-8-37.3-11.3-43.9C228%2028.8%20182.3%205%20132.6%205a128%20128%200%200%200-128%20126.2c.5-36.5%2036.8-66%2080-66%203.5%200%2023.5.3%2042%2010a73%2073%200%200%201%2030.9%2029.3c6.1%2010.6%207.2%2024.1%207.2%2029.5s-2.7%2013.3-7.8%2019.9Z'%20transform='translate(-4.6%20-5)'/%3e%3c/svg%3e`,MC=`/assets/firefox-5m8yovBp.svg`,NC=`/assets/safari-DgmPRf57.svg`;function PC(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function FC(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function IC(){return LC.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var LC={stubThis:e=>e};function RC(e){let{id:t}=e;return{...e,id:FC(t),transports:e.transports,type:e.type}}function zC(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var BC=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function VC({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new BC({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new BC({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new BC({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new BC({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new BC({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new BC({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new BC({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new BC({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!zC(t))return new BC({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new BC({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new BC({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new BC({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var HC=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},UC=[`cross-platform`,`platform`];function WC(e){if(e&&!(UC.indexOf(e)<0))return e}async function GC(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!IC())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:FC(t.challenge),user:{...t.user,id:FC(t.user.id)},excludeCredentials:t.excludeCredentials?.map(RC)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=HC.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw VC({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){KC(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=PC(e))}catch(e){KC(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=PC(c.getAuthenticatorData())}catch(e){KC(`getAuthenticatorData()`,e)}return{id:o,rawId:PC(s),response:{attestationObject:PC(c.attestationObject),clientDataJSON:PC(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:WC(a.authenticatorAttachment)}}function KC(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function qC(){if(!IC())return JC.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?JC.stubThis(new Promise(e=>e(!1))):JC.stubThis(e.isConditionalMediationAvailable())}var JC={stubThis:e=>e};function YC({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new BC({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new BC({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!zC(t))return new BC({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new BC({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new BC({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function XC(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!IC())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(RC));let a={...t,challenge:FC(t.challenge),allowCredentials:i},o={};if(n){if(!await qC())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=HC.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw YC({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=PC(u.userHandle)),{id:c,rawId:PC(l),response:{authenticatorData:PC(u.authenticatorData),clientDataJSON:PC(u.clientDataJSON),signature:PC(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:WC(s.authenticatorAttachment)}}var ZC=cy,QC=uy,$C=fy,ew=`https://auth.mp281x.xyz`,tw=Hr(ln(Xn(`AUTH_URL`)),Ln);Vr(function*(){let e=rn(W,`GITHUB_ADMINS`);return(yield*tw)?yield*bn(e,[`0`]):yield*e}),jt()(`@deslop/runtime/auth/lib/utils/CurrentUser`);var nw=class e extends Kn()(`@deslop/runtime/auth/lib/utils/RpcAuth`,{error:Gi}){static layerClient=t=>Rr(e,e=>Vr(function*(){return yield*e.next({...e.request,headers:sn(e.request.headers,`authorization`,`Bearer ${yield*t}`)})}))},rw=q({name:b,open:b,origin:zi}),iw=tr(rw);q({origin:zi});var aw=ii([`ble`,`cable`,`hybrid`,`internal`,`nfc`,`smart-card`,`usb`]),ow=$t(`public-key`),sw=ii([`required`,`preferred`,`discouraged`]),cw=q({id:W,transports:V(ve(tr(aw))),type:ow}),lw=q({attestation:V(ii([`direct`,`enterprise`,`indirect`,`none`])),authenticatorSelection:V(q({authenticatorAttachment:V(ii([`cross-platform`,`platform`])),requireResidentKey:V(An),residentKey:V(ii([`discouraged`,`preferred`,`required`])),userVerification:V(sw)})),challenge:W,excludeCredentials:V(ve(tr(cw))),pubKeyCredParams:ve(tr(q({alg:Ut,type:ow}))),rp:q({id:V(W),name:W}),timeout:V(Ut),user:q({displayName:W,id:W,name:W})}),uw=q({allowCredentials:V(ve(tr(cw))),challenge:W,rpId:V(W),timeout:V(Ut),userVerification:V(sw)}),dw=V(ii([`cross-platform`,`platform`])),fw=q({authenticatorAttachment:dw,clientExtensionResults:q({}),id:W,rawId:W,response:q({attestationObject:W,clientDataJSON:W,transports:V(tr(W))}),type:ow}),pw=q({authenticatorAttachment:dw,clientExtensionResults:q({}),id:W,rawId:W,response:q({authenticatorData:W,clientDataJSON:W,signature:W,userHandle:V(W)}),type:ow});q({challenge:W});var mw=q({addedFrom:W,counter:qr,createdAt:Ut,id:b,lastUsed:Ut,publicKey:b,synced:An,transports:tr(aw),user:oa});tr(mw);var hw=q({addedFrom:W,createdAt:Ut,id:b,lastUsed:Ut,synced:An}),gw=q({id:b}),_w=q({response:fw}),vw=q({next:V(b.check(m(2048))),response:pw}),yw=q({client_name:V(W.check(m(100))),redirect_uris:nt(b.check(m(200))).check(m(4)),token_endpoint_auth_method:V($t(`none`))});q({name:W,redirects:yw.fields.redirect_uris}),q({client_id:b.check(m(2048)),redirect_uri:V(W),state:V(W)}),q({code_challenge:V(b),code_challenge_method:V(W),resource:V(gr(W)),response_type:V(W),scope:V(W)});var bw=q({challenge:b,clientId:b,clientName:W,redirectUri:b,resources:nt(Xi),state:V(b)});q({grant_type:W});var xw=V(gr(Xi).check(bt(1)));Ne([q({client_id:b,code:b,code_verifier:b,grant_type:$t(`authorization_code`),redirect_uri:V(W),resource:xw}),q({client_id:V(W),grant_type:$t(`refresh_token`),refresh_token:b,resource:xw})]);var Sw=q({access_token:b,expires_in:Ut,refresh_token:b,scope:$t(`deslop`),token_type:$t(`Bearer`)});Oe({Granted:{tokens:Sw},Replayed:{message:W}});var Cw=q({address:V(W),userAgent:V(W)}),ww=q({expiresAt:Ut,hash:W,resources:tr(Xi)}),Tw=ii([`Code`,`GitHub`,`Passkey`]),Ew=q({client:W,createdAt:Ut,credential:Oe({App:{access:tr(ww),clientId:b,expiresAt:Ut,generation:qr,hash:W,replaced:V(W),resources:tr(Xi)},Browser:{expiresAt:Ut,hash:W,via:V(Tw)}}),device:W,lastActive:Ut,origin:Cw,user:oa});M(W,Ew);var Dw=q({address:V(W),client:W,createdAt:Ut,device:W,expiresAt:Ut,family:b,kind:ii([`App`,`Browser`]),lastActive:Ut,resources:tr(Xi)}),Ow=q({family:b});q({client_id:b,token:b}),q({resource:Xi});var kw=ii([`Admin`,`Member`,`Waiting`]),Aw=q({...oa.fields,fullName:V(W),role:kw}),jw=q({...Aw.fields,via:Tw}),Mw=q({...Aw.fields,since:Ut}),Nw=ii([`Waiting`,`Allowed`]),Pw=q({fullName:W,id:b,name:b,since:Ut,status:Nw});tr(Pw),q({id:qr,login:b,name:V($r(W))});var Fw=q({allow:An,id:b}),Iw=q({id:b}),Lw=ii([`App`,`Browser`]),Rw=q({address:V(W),clientName:W,createdAt:Ut,device:W,expiresAt:Ut,id:b,kind:Lw,resources:tr(Xi)}),zw=Oe({Decided:{},Expired:{},Waiting:{request:Rw}}),Bw=Oe({Browser:{next:V(W)},Client:{request:bw}});Oe({Redirect:{url:b},Session:{next:V(W),seconds:qr,token:b},Waiting:{}}),q({delivery:Bw,origin:Cw}),q({next:V(b.check(m(2048)))});var Vw=q({request:b.check(m(20))}),Hw=q({code:b.check(m(20))}),Uw=q({...Vw.fields,accept:An}),Ww=class extends an(Tn(`auth.lookup`,{error:Gi,payload:Hw,stream:!0,success:ct(Rw)}),Tn(`auth.answer`,{error:Gi,payload:Uw}),Tn(`auth.people`,{error:Gi,stream:!0,success:tr(Mw)}),Tn(`auth.admit`,{error:Gi,payload:Fw,success:Mw}),Tn(`auth.remove`,{error:Gi,payload:Iw,success:Mw}),Tn(`auth.apps`,{error:Gi,stream:!0,success:tr(Dw)}),Tn(`auth.catalog`,{error:Gi,stream:!0,success:iw}),Tn(`auth.disconnect`,{error:Gi,payload:Ow}),Tn(`auth.passkeys`,{error:Gi,stream:!0,success:tr(hw)}),Tn(`auth.passkeyOptions`,{error:Gi,success:lw}),Tn(`auth.addPasskey`,{error:Gi,payload:_w}),Tn(`auth.removePasskey`,{error:Gi,payload:gw})).middleware(nw).merge(an(Tn(`auth.account`,{error:Gi,stream:!0,success:jw}),Tn(`auth.wait`,{error:Gi,payload:Vw,stream:!0,success:zw}))){};function Gw(e){return lr(Nr(/[^a-z]/giu,``)(e))}function Kw(e){return it(Fe(e),Ot)}dr(function*(e,t,n){if(Ln(Kw(n.response_type)))return yield*Gi.make({message:`Send response_type=code`});if(n.response_type!==`code`)return yield*Gi.make({error:`unsupported_response_type`,message:`Only response_type=code is supported`});if(n.code_challenge===void 0||n.code_challenge_method!==`S256`)return yield*Gi.make({message:`Send a PKCE code_challenge with code_challenge_method=S256`});if(!rr(xr(Sr(n.scope??``,` `),Ot),e=>e===`deslop`||e===`offline_access`))return yield*Gi.make({error:`invalid_scope`,message:`Only the deslop scope is supported`});let r=yield*pn(F(nt(Xi))(n.resource??[]),er(e=>Gi.make({cause:e,error:`invalid_target`,message:`Name a Deslop app with the resource parameter`})));return bw.make({challenge:n.code_challenge,clientId:e.client_id,clientName:t.clientName,redirectUri:t.redirectUri,resources:r,...N(Kw(e.state),{onNone:()=>({}),onSome:e=>({state:e})})})});function qw(e){return pn(new URL(e).hostname,Sr(`.`),Mr(1),on(`.`))}function Jw(e,t){let n=qw(t);return g(Lr(e),{onFailure:()=>!1,onSuccess:e=>e.protocol===`https:`&&(e.hostname===n||pe(`.${n}`)(e.hostname))&&Nt(e.username)&&Nt(e.password)})}var Yw=D(_r),Xw=class extends gn()(`@deslop/auth/lib/utils/RpcClient`,{group:Ww,protocol:Xa(`@deslop/auth`)}){},Zw=Ze(Xw.runtime.atom(pn(Xw,hr(e=>e(`auth.account`,void 0)),je,na,Zr(qe),On(`AuthError`,()=>v(z()))))),Qw={accept:An,request:Rw},$w=lb(Xw.runtime).make(QC({branches:{looked:{found:{target:`Code.Found`},missing:{target:`Code.Missing`}}},events:$C({Answered:Qw,Typed:{typed:W}}),root:ZC({states:{Code:{fields:{code:W},states:{Failed:{fields:{message:W}},Found:{fields:{request:Rw}},Looking:{},Missing:{}}},Typing:{fields:{answered:V(q(Qw)),typed:W}}}}),streams:{lookup:e=>na(je(hr(Xw,t=>t(`auth.lookup`,{code:e}))))}}).handle({initial:{data:{typed:``},target:`Typing`},on:{Answered:{data:e=>({answered:{accept:e.event.accept,request:e.event.request},typed:``}),target:`Typing`},Typed:{data:e=>({typed:e.event.typed}),target:`Typing`}},states:{Code:{initial:{target:`Code.Looking`},invoke:{input:e=>e.state.code,onDone:{none:!0},onElement:{branches:`looked`,resolve:e=>N(e.element,{onNone:()=>e.select.missing(),onSome:t=>e.select.found({data:{request:t}})})},onFailure:{data:e=>({message:e.error.message}),target:`Code.Failed`},src:`lookup`},states:{Failed:{},Found:{},Looking:{},Missing:{}}},Typing:{always:{data:e=>({code:e.state.typed}),guard:e=>Lt(e.state.typed)>=8,target:`Code`}}}})),eT=h(e=>{e.set($w.send,{_tag:`Typed`,typed:Gw(new URLSearchParams(location.search).get(`code`)??``)})}),tT=Ze(Xw.runtime.atom(pn(Xw,hr(e=>e(`auth.people`,void 0)),je,na))),nT=Ze(Xw.runtime.atom(pn(Xw,hr(e=>e(`auth.apps`,void 0)),je,na)));function rT(e){return t=>Bn(t,t=>K(()=>oo.add({description:t.message,title:e,type:`error`})))}var iT=Xw.runtime.fn(e=>pn(G(Xw,t=>kr(e,e=>t(`auth.disconnect`,{family:e}),{concurrency:`unbounded`,discard:!0})),rT(`Cannot sign out`))),aT=ai(e=>Xw.runtime.fn(t=>G(Xw,n=>n(`auth.admit`,{allow:t,id:e})))),oT=ai(e=>Xw.runtime.fn(()=>G(Xw,t=>t(`auth.remove`,{id:e})))),sT=S(new URLSearchParams(location.search).get(`request`)),cT=ai(e=>Xw.runtime.atom(pn(Xw,hr(t=>t(`auth.wait`,{request:e})),je,na,zn(t=>pn(fr(t),Tr(`Decided`,()=>K(()=>location.assign(`/auth/continue?${new URLSearchParams({request:e})}`))),sr(()=>B))))));function lT(e){return`${ir(0,4)(e)}-${ir(4)(e)}`}function uT(e){return`${location.origin}/?code=${e}`}var dT=Ze(Xw.runtime.atom(pn(Xw,hr(e=>e(`auth.catalog`,void 0)),je,na)));function fT(e){return qn(e)?[`browser`]:un(_n(e,e=>new URL(e).origin))}function pT(e){return pn($n(e),mr({hour:`2-digit`,minute:`2-digit`}))}var mT=h(pn(Ee(`1 minute`),ot(()=>ze))),hT=h(pn(Ee(`1 second`),ot(()=>ze)));function gT(e,t){let n=Dr(0,Math.ceil((e-t)/1e3));return`${Math.floor(n/60)}:${i(2,`0`)(`${n%60}`)}`}var _T=Jt(e=>pn(De({catch:e=>Gi.make({cause:e,message:`Cannot copy the code; type it in instead`}),try:()=>navigator.clipboard.writeText(e)}),L(j(`1200 millis`))));function vT(e,t){return Math.floor(de(vn($n(e),$n(t))))}function yT(e){return e<1?`now`:e<60?`${e}m`:e<1440?`${Math.floor(e/60)}h`:`${Math.floor(e/1440)}d`}function bT(e,t){return`${e} · ${t}`}function xT(e){return En(e,0,(e,t)=>Dr(e,t.lastActive))}function ST(e){return pn($n(e),mr({day:`numeric`,month:`short`}))}function CT(e){return`https://avatars.githubusercontent.com/u/${dn(`github:`,``)(e)}?s=96`}var wT=Xw.runtime.fn((e,t)=>pn(Xw,G(t=>t(`auth.answer`,{accept:e.accept,request:e.request.id})),L(K(()=>t.set($w.send,{_tag:`Answered`,...e}))))),TT=S(new URLSearchParams(location.search).get(`next`));function ET(e){return H(e.cause,`name`)&&e.cause.name===`NotAllowedError`}var DT=dr(function*(e){return e.status===429?yield*Gi.make({message:`Too many tries; wait a minute and try again`}):yield*Gi.make({message:(yield*He(q({error_description:W}))(e)).error_description})}),OT=Yw.fn(()=>pn(Vr(function*(){let e=yield*ue,n=yield*e.get(`/auth/passkey`);if(n.status!==200)return yield*DT(n);let r=yield*He(uw)(n),i=yield*It(De({catch:e=>Gi.make({cause:e,message:`No passkey was used`}),try:()=>XC({optionsJSON:r})}),ET,()=>cn),a=yield*pn(t(`/auth/passkey`),hn(vw)({...N(TT,{onNone:()=>({}),onSome:e=>({next:e})}),response:i}),G(t=>e.execute(t)),G(dr(function*(e){return e.status===200?yield*He(q({next:V(W)}))(e):yield*DT(e)})));yield*K(()=>N(Fe(a.next),{onNone:()=>location.reload(),onSome:e=>location.assign(e)}))}),er(e=>gi(Gi)(e)?e:Gi.make({cause:e,message:`Cannot sign in with a passkey`})))),kT=Ze(Xw.runtime.atom(pn(Xw,hr(e=>e(`auth.passkeys`,void 0)),je,na))),AT=Ze(Xw.runtime.fn(dr(function*(){let e=yield*Xw,t=yield*e(`auth.passkeyOptions`,void 0);yield*e(`auth.addPasskey`,{response:yield*pn(De({catch:e=>Gi.make({cause:e,message:`No passkey was added`}),try:()=>GC({optionsJSON:t})}),It(ET,()=>cn),G(F(fw)))}),oo.add({title:`Passkey added`})},rT(`Cannot add a passkey`)))),jT=`adding-passkey`,MT=Jt(()=>Me({catch:e=>Gi.make({cause:e,message:`Cannot start GitHub sign-in`}),try:()=>{sessionStorage.setItem(jT,`true`),location.assign(`/auth/github`)}})),NT=Ze(Xw.runtime.fn(e=>pn(G(Xw,t=>t(`auth.removePasskey`,{id:e})),rT(`Cannot remove the passkey`)))),PT=Jt(()=>Me({catch:e=>Gi.make({cause:e,message:`Cannot start GitHub sign-in`}),try:()=>location.assign(`/auth/github${location.search}`)})),FT=Jt(()=>Me({catch:e=>Gi.make({cause:e,message:`Cannot start the sign-in`}),try:()=>location.assign(N(TT,{onNone:()=>`/auth/code`,onSome:e=>`/auth/code?${new URLSearchParams({next:e})}`}))})),IT=new URLSearchParams(location.search).has(`sign-out`),LT=pn(S(new URLSearchParams(location.search).get(`next`)),it(e=>Jw(e,ew)),Un(()=>location.pathname)),RT=pn(ue.use(e=>At(e).post(`/auth/sign-out`)),L(K(()=>location.replace(LT))),er(e=>Gi.make({cause:e,message:`Cannot sign out: ${e.message}`}))),zT=Yw.fn(()=>RT),BT=Yw.fn(()=>rT(`Cannot sign out`)(RT));function VT(e){let t=(0,$o.c)(17),n,r,i,a,o,s;if(t[0]!==e.className||t[1]!==e.text){let c=cr(ox(e.text)),l=Math.sqrt(c.length);r=`-2 -2 ${l+4} ${l+4}`,i=`crispEdges`,a=`currentColor`,o=e.className,s=`true`,n=pn(c,_n((e,t)=>({dark:e,x:t%l,y:Math.floor(t/l)})),xr(UT),_n(HT),on(``)),t[0]=e.className,t[1]=e.text,t[2]=n,t[3]=r,t[4]=i,t[5]=a,t[6]=o,t[7]=s}else n=t[2],r=t[3],i=t[4],a=t[5],o=t[6],s=t[7];let c;t[8]===n?c=t[9]:(c=(0,Q.jsx)(`path`,{d:n}),t[8]=n,t[9]=c);let l;return t[10]!==r||t[11]!==i||t[12]!==a||t[13]!==o||t[14]!==s||t[15]!==c?(l=(0,Q.jsx)(`svg`,{viewBox:r,shapeRendering:i,fill:a,className:o,"aria-hidden":s,children:c}),t[10]=r,t[11]=i,t[12]=a,t[13]=o,t[14]=s,t[15]=c,t[16]=l):l=t[16],l}function HT(e){return`M${e.x} ${e.y}h1v1h-1z`}function UT(e){return e.dark===1}function WT(e){let t=(0,$o.c)(12),n;t[0]===e.id?n=t[1]:(n=CT(e.id),t[0]=e.id,t[1]=n);let r;t[2]!==e.name||t[3]!==n?(r=(0,Q.jsx)(bx,{src:n,alt:e.name}),t[2]=e.name,t[3]=n,t[4]=r):r=t[4];let i;t[5]===e.name?i=t[6]:(i=lr(ir(0,1)(e.name)),t[5]=e.name,t[6]=i);let a;t[7]===i?a=t[8]:(a=(0,Q.jsx)(xx,{children:i}),t[7]=i,t[8]=a);let o;return t[9]!==r||t[10]!==a?(o=(0,Q.jsxs)(yx,{size:`sm`,children:[r,a]}),t[9]=r,t[10]=a,t[11]=o):o=t[11],o}function GT(e){let t=(0,$o.c)(11),[n,r]=(0,Z.useState)(`loading`),i;t[0]===e.small?i=t[1]:(i=Fi(`text-muted-foreground relative flex shrink-0 items-center justify-center`,Ft(e.small===!0,{onFalse:qT,onTrue:KT})),t[0]=e.small,t[1]=i);let a;t[2]===n?a=t[3]:(a=n!==`loaded`&&(0,Q.jsx)(Ho,{className:`size-4`}),t[2]=n,t[3]=a);let o;t[4]!==e.origin||t[5]!==n?(o=n!==`failed`&&(0,Q.jsx)(`img`,{src:`${e.origin}/icon`,alt:``,className:Fi(`pixelated absolute inset-0 size-full`,n===`loading`&&`invisible`),onLoad:()=>r(`loaded`),onError:()=>r(`failed`)}),t[4]=e.origin,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==i||t[8]!==a||t[9]!==o?(s=(0,Q.jsxs)(`span`,{className:i,children:[a,o]}),t[7]=i,t[8]=a,t[9]=o,t[10]=s):s=t[10],s}function KT(){return`size-4`}function qT(){return`size-5`}var JT={Chrome:OC,Edge:jC,Firefox:MC,Safari:NC};function YT(e){return e.kind===`Browser`?Re(oi(JT,e.name),e=>({mono:!1,src:e})):we(Ge(/claude/iu)(e.name))?qe({mono:!1,src:kC}):we(Ge(/codex/iu)(e.name))?qe({mono:!0,src:AC}):we(Ge(/gateway/iu)(e.name))?z():Ue([`iPhone`,`iPad`],e.device)?qe({mono:!0,src:DC}):e.device===`Android`?qe({mono:!1,src:EC}):z()}function XT(e){return N(YT(e.client),{onNone:()=>pn(fr(e.client),Ar({kind:`Browser`},()=>(0,Q.jsx)(Ko,{})),Ar(e=>we(Ge(/gateway/iu)(e.name)),()=>(0,Q.jsx)(Jo,{})),sr(()=>(0,Q.jsx)(Xo,{}))),onSome:e=>(0,Q.jsx)(`img`,{src:e.src,alt:``,className:Fi(`size-3.5`,e.mono&&`dark:invert`)})})}function ZT(e){return N(e.client.app,{onNone:()=>(0,Q.jsx)(XT,{client:e.client}),onSome:e=>(0,Q.jsx)(GT,{origin:e,small:!0})})}function QT(e){let t=(0,$o.c)(33),[n,r]=wd(iT),i;if(t[0]!==e.column.address||t[1]!==e.column.client||t[2]!==e.column.lastActive||t[3]!==e.column.pending||t[4]!==e.now){let n;t[6]!==e.column.lastActive||t[7]!==e.now?(n=()=>{let t=vT(e.column.lastActive,e.now);return`active ${Ft(t<1,{onFalse:()=>`${yT(t)} ago`,onTrue:eE})}`},t[6]=e.column.lastActive,t[7]=e.now,t[8]=n):n=t[8];let r;t[9]===e.column.client?r=t[10]:(r=t=>t!==e.column.client.device,t[9]=e.column.client,t[10]=r),i=on([Ft(e.column.pending,{onFalse:n,onTrue:$T}),...fi(it(e.column.address,r))],` · `),t[0]=e.column.address,t[1]=e.column.client,t[2]=e.column.lastActive,t[3]=e.column.pending,t[4]=e.now,t[5]=i}else i=t[5];let a=i,o=`${e.column.label}, ${a}`,s;if(t[11]!==a||t[12]!==r||t[13]!==n||t[14]!==o||t[15]!==e.column.client||t[16]!==e.column.families||t[17]!==e.column.label||t[18]!==e.column.pending){let i;t[20]!==a||t[21]!==r||t[22]!==n||t[23]!==o||t[24]!==e.column.client||t[25]!==e.column.families||t[26]!==e.column.label?(i=()=>(0,Q.jsxs)(uC,{children:[(0,Q.jsx)(dC,{render:(0,Q.jsx)(Vi,{variant:`ghost`,size:`icon-sm`,className:`max-sm:size-11`,title:o,"aria-label":o}),children:(0,Q.jsx)(ZT,{client:e.column.client})}),(0,Q.jsxs)(fC,{align:`end`,className:`w-auto min-w-48`,children:[(0,Q.jsx)(pC,{children:(0,Q.jsxs)(mC,{children:[(0,Q.jsx)(`span`,{className:`text-foreground block text-sm`,children:e.column.label}),(0,Q.jsx)(`span`,{className:`font-mono tabular-nums`,children:a})]})}),(0,Q.jsx)(hC,{variant:`destructive`,disabled:lt(n),onClick:()=>r(e.column.families),children:`Sign out`})]})]}),t[20]=a,t[21]=r,t[22]=n,t[23]=o,t[24]=e.column.client,t[25]=e.column.families,t[26]=e.column.label,t[27]=i):i=t[27];let c;t[28]!==o||t[29]!==e.column.client?(c=()=>(0,Q.jsx)(`span`,{title:o,"aria-label":o,role:`img`,className:`ring-primary flex size-7 items-center justify-center rounded-sm ring-1`,children:(0,Q.jsx)(ZT,{client:e.column.client})}),t[28]=o,t[29]=e.column.client,t[30]=c):c=t[30],s=Ft(e.column.pending,{onFalse:i,onTrue:c}),t[11]=a,t[12]=r,t[13]=n,t[14]=o,t[15]=e.column.client,t[16]=e.column.families,t[17]=e.column.label,t[18]=e.column.pending,t[19]=s}else s=t[19];let c;return t[31]===s?c=t[32]:(c=(0,Q.jsx)(wC,{className:`px-0.5`,children:(0,Q.jsx)(`span`,{className:`flex flex-col items-center gap-0.5`,children:s})}),t[31]=s,t[32]=c),c}function $T(){return`waiting for an answer`}function eE(){return`now`}function tE(e,t,n){let r=fT(e);return Ue(r,t)||Ue(r,`browser`)&&n}function nE(e,t){return xn(e.resources,e=>tE(e,t.origin,t.web))}function rE(e){let t=(0,$o.c)(21),n,r,i,a,o,s;if(t[0]!==e.column||t[1]!==e.row){let c=nE(e.column,e.row);n=TC,s=`w-7 px-0 max-sm:w-14`,a=`flex justify-center`;let l;t[8]===e.column.pending?l=t[9]:(l=()=>(0,Q.jsx)(ux,{waiting:e.column.pending}),t[8]=e.column.pending,t[9]=l),o=Ft(c,{onFalse:sE,onTrue:l}),r=`sr-only`,i=pn(fr({held:c,pending:e.column.pending}),Ar({held:!1},oE),Ar({pending:!0},aE),sr(iE)),t[0]=e.column,t[1]=e.row,t[2]=n,t[3]=r,t[4]=i,t[5]=a,t[6]=o,t[7]=s}else n=t[2],r=t[3],i=t[4],a=t[5],o=t[6],s=t[7];let c;t[10]!==r||t[11]!==i?(c=(0,Q.jsx)(`span`,{className:r,children:i}),t[10]=r,t[11]=i,t[12]=c):c=t[12];let l;t[13]!==a||t[14]!==o||t[15]!==c?(l=(0,Q.jsxs)(`span`,{className:a,children:[o,c]}),t[13]=a,t[14]=o,t[15]=c,t[16]=l):l=t[16];let u;return t[17]!==n||t[18]!==s||t[19]!==l?(u=(0,Q.jsx)(n,{className:s,children:l}),t[17]=n,t[18]=s,t[19]=l,t[20]=u):u=t[20],u}function iE(){return`signed in`}function aE(){return`asked for`}function oE(){return`not signed in`}function sE(){return(0,Q.jsx)(ux,{status:`off`})}function cE(e){let t=(0,$o.c)(60),[n,r]=wd(wT),[i,a]=(0,Z.useState)(),o,s,c,l,u,d,f,p,m,h;if(t[0]!==i||t[1]!==n||t[2]!==e.request||t[3]!==r){h=lt(n);let g;if(t[14]!==e.request.clientName||t[15]!==e.request.device||t[16]!==e.request.kind){let n,r;t[18]!==e.request.clientName||t[19]!==e.request.device?(r=()=>`${bT(e.request.clientName,e.request.device)} asks for the apps its column marks`,n=()=>`Signs in ${bT(e.request.clientName,e.request.device)} as you to every mp281x.xyz app for 30 days, including approving sign-ins`,t[18]=e.request.clientName,t[19]=e.request.device,t[20]=n,t[21]=r):(n=t[20],r=t[21]),g=Ft(e.request.kind===`Browser`,{onFalse:r,onTrue:n}),t[14]=e.request.clientName,t[15]=e.request.device,t[16]=e.request.kind,t[17]=g}else g=t[17];let _;t[22]===e.request.address?_=t[23]:(_=N(Fe(e.request.address),{onNone:mE,onSome:pE}),t[22]=e.request.address,t[23]=_),t[24]!==g||t[25]!==_?(p=(0,Q.jsxs)(gb,{children:[g,_,`. Approve only a code you started yourself.`]}),t[24]=g,t[25]=_,t[26]=p):p=t[26],t[27]===n?m=t[28]:(m=(0,Q.jsx)(sx,{result:n}),t[27]=n,t[28]=m),f=`grid grid-cols-2 gap-2`,o=Vi,s=`lg`;let v;t[29]!==e.request.clientName||t[30]!==e.request.device?(v=bT(e.request.clientName,e.request.device),t[29]=e.request.clientName,t[30]=e.request.device,t[31]=v):v=t[31],c=`Approve ${v}`,l=h,t[32]!==e.request||t[33]!==r?(u=()=>{a(!0),r({accept:!0,request:e.request})},t[32]=e.request,t[33]=r,t[34]=u):u=t[34],d=Ft(h&&i===!0,{onFalse:fE,onTrue:dE}),t[0]=i,t[1]=n,t[2]=e.request,t[3]=r,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13];let g;t[35]!==o||t[36]!==s||t[37]!==c||t[38]!==l||t[39]!==u||t[40]!==d?(g=(0,Q.jsxs)(o,{size:s,"aria-label":c,disabled:l,onClick:u,children:[d,`Approve`]}),t[35]=o,t[36]=s,t[37]=c,t[38]=l,t[39]=u,t[40]=d,t[41]=g):g=t[41];let _;t[42]!==e.request||t[43]!==r?(_=()=>{a(!1),r({accept:!1,request:e.request})},t[42]=e.request,t[43]=r,t[44]=_):_=t[44];let v;t[45]!==i||t[46]!==h?(v=Ft(h&&i===!1,{onFalse:uE,onTrue:lE}),t[45]=i,t[46]=h,t[47]=v):v=t[47];let y;t[48]!==v||t[49]!==_||t[50]!==h?(y=(0,Q.jsxs)(Vi,{size:`lg`,variant:`outline`,disabled:h,onClick:_,children:[v,`Deny`]}),t[48]=v,t[49]=_,t[50]=h,t[51]=y):y=t[51];let b;t[52]!==y||t[53]!==f||t[54]!==g?(b=(0,Q.jsxs)(`div`,{className:f,children:[g,y]}),t[52]=y,t[53]=f,t[54]=g,t[55]=b):b=t[55];let x;return t[56]!==b||t[57]!==p||t[58]!==m?(x=(0,Q.jsxs)(Q.Fragment,{children:[p,m,b]}),t[56]=b,t[57]=p,t[58]=m,t[59]=x):x=t[59],x}function lE(){return(0,Q.jsx)(bb,{})}function uE(){return null}function dE(){return(0,Q.jsx)(bb,{})}function fE(){return null}function pE(e){return` · from ${e}`}function mE(){return``}function hE(e,t,n){function r(e,t,r){return{app:Re(Mn(n,t=>r===`App`&&Kt(t.name)===Kt(e)),e=>e.origin),device:t,kind:r,name:e}}return[...N(e,{onNone:()=>[],onSome:e=>[{address:Fe(e.address),client:r(e.clientName,e.device,e.kind),families:[],key:`pending`,label:bT(e.clientName,e.device),lastActive:0,pending:!0,resources:[e.resources]}]}),...pn(Er(t,e=>bT(e.client,e.device)),Yt,xr(zr),zt(re(ut(gt,xT))),_n(e=>({address:pn(Mn(e,t=>t.lastActive===xT(e)),O(e=>Fe(e.address))),client:r(e[0].client,e[0].device,e[0].kind),families:_n(e,e=>e.family),key:bT(e[0].client,e[0].device),label:bT(e[0].client,e[0].device),lastActive:xT(e),pending:!1,resources:_n(e,e=>e.resources)})))]}function gE(e){let t=(0,$o.c)(17),n=Od(dT).value,r=Od(nT).value,i=Od(mT).value,a,o,s,c;if(t[0]!==n||t[1]!==i||t[2]!==e.pending||t[3]!==r){let l;t[8]===n?l=t[9]:(l=e=>e!==`browser`&&!xn(n,t=>t.origin===e),t[8]=n,t[9]=l);let u=[..._n(n,wE),...pn([...Gt(r,CE),...N(e.pending,{onNone:SE,onSome:xE})],un,xr(l),zt(_e),_n(bE))],d=xr(hE(e.pending,r,n),e=>xn(u,t=>nE(e,t)));a=`flex flex-1 flex-col gap-3`,o=`Apps`,t[10]===e.pending?s=t[11]:(s=N(e.pending,{onNone:yE,onSome:vE}),t[10]=e.pending,t[11]=s),c=pr(u,{onEmpty:_E,onNonEmpty:()=>(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Q.jsxs)(bC,{"aria-label":`Apps and the clients signed in to them`,className:`w-auto border-b`,children:[(0,Q.jsx)(xC,{children:(0,Q.jsxs)(CC,{className:`max-sm:h-11`,children:[(0,Q.jsx)(wC,{className:`bg-background sticky left-0 z-10 w-40`,children:(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`App`})}),_n(d,e=>(0,Q.jsx)(QT,{column:e,now:i},e.key))]})}),(0,Q.jsx)(SC,{children:_n(u,e=>(0,Q.jsxs)(CC,{className:`max-sm:h-11`,children:[(0,Q.jsx)(wC,{scope:`row`,className:`bg-background sticky left-0 z-10 w-40`,children:N(e.open,{onNone:()=>(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Q.jsx)(GT,{origin:e.origin}),e.name]}),onSome:t=>(0,Q.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`flex h-full w-full items-center gap-2 text-sm font-medium hover:underline`,children:[(0,Q.jsx)(GT,{origin:e.origin}),e.name]})})}),_n(d,t=>(0,Q.jsx)(rE,{column:t,row:e},t.key))]},e.origin))})]})})}),t[0]=n,t[1]=i,t[2]=e.pending,t[3]=r,t[4]=a,t[5]=o,t[6]=s,t[7]=c}else a=t[4],o=t[5],s=t[6],c=t[7];let l;return t[12]!==a||t[13]!==o||t[14]!==s||t[15]!==c?(l=(0,Q.jsxs)(`section`,{className:a,"aria-label":o,children:[s,c]}),t[12]=a,t[13]=o,t[14]=s,t[15]=c,t[16]=l):l=t[16],l}function _E(){return(0,Q.jsx)(Bo,{children:(0,Q.jsx)(Ui,{children:(0,Q.jsx)(ha,{children:`No apps yet`})})})}function vE(e){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(cE,{request:e}),(0,Q.jsxs)(`p`,{className:`text-muted-foreground font-mono text-xs`,children:[`open until `,pT(e.expiresAt)]})]})}function yE(){return null}function bE(e){return{name:Un(en(Sr(new URL(e).hostname,`.`)),()=>e),open:z(),origin:e,web:!1}}function xE(e){return fT(e.resources)}function SE(){return[]}function CE(e){return fT(e.resources)}function wE(e){return{name:e.name,open:qe(e.open),origin:e.origin,web:Nn(`https://`)(e.open)}}export{Bx as $,bT as A,Ic as At,gC as B,fs as Bt,oT as C,vd as Ct,sT as D,Jc as Dt,lT as E,rl as Et,fC as F,Lc as Ft,qS as G,es as Gt,_C as H,ds as Ht,pC as I,qc as It,gS as J,jS as K,ns as Kt,hC as L,jc as Lt,IT as M,Wc as Mt,Gw as N,Gc as Nt,hT as O,Fc as Ot,uC as P,Kc as Pt,qx as Q,mC as R,Dc as Rt,tT as S,Od as St,cT as T,Zc as Tt,dC as U,ts as Ut,vC as V,ps as Vt,tC as W,rs as Wt,aS as X,cS as Y,Xx as Z,gT as _,sb as _t,jT as a,xx as at,OT as b,Sd as bt,aT as c,sx as ct,$w as d,gb as dt,Ex as et,FT as f,_b as ft,ST as g,ob as gt,_T as h,ub as ht,VT as i,yx as it,zT as j,Vc as jt,PT as k,Rc as kt,uT as l,bb as lt,wT as m,db as mt,GT as n,wx as nt,Zw as o,bx as ot,MT as p,hb as pt,OS as q,Ho as qt,gE as r,Tx as rt,AT as s,ux as st,WT as t,Dx as tt,dT as u,mb as ut,eT as v,cb as vt,NT as w,cd as wt,kT as x,Cd as xt,BT as y,wd as yt,yC as z,gs as zt};
|