@deslop/auth 0.1.1238 → 0.1.1239

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.
@@ -1 +1 @@
1
- import{n as e,t}from"./rolldown-runtime-WkwZ5CU-.js";import{a as n,i as r,n as i,o as a,s as o,t as s}from"./react-BUjtWCUj.js";import{$ as c,$n as l,$t as u,A as d,An as f,At as p,B as m,Bn as h,Bt as g,C as _,Cn as v,Ct as y,D as b,Dn as x,Dt as S,E as C,En as w,Et as T,F as E,Fn as D,Ft as O,G as k,Gn as A,Gt as j,H as M,Hn as N,Ht as ee,I as P,In as F,It as I,J as te,Jn as ne,Jt as L,K as re,Kn as ie,Kt as ae,L as oe,Ln as R,Lt as z,M as se,Mn as B,Mt as ce,N as le,Nn as ue,Nt as de,O as fe,On as pe,Ot as me,P as he,Pn as V,Pt as ge,Q as _e,Qn as ve,Qt as ye,R as be,Rn as xe,Rt as Se,S as Ce,Sn as we,St as Te,T as H,Tn as Ee,Tt as De,U,Un as Oe,Ut as ke,V as Ae,Vn as je,Vt as Me,W as Ne,Wn as Pe,Wt as Fe,X as Ie,Xn as Le,Xt as Re,Y as ze,Yn as Be,Yt as Ve,Z as He,Zn as Ue,Zt as We,_ as Ge,_n as Ke,_t as qe,a as Je,an as Ye,ar as Xe,at as Ze,b as Qe,bn as $e,bt as et,c as tt,cn as nt,ct as rt,d as it,dn as at,dt as ot,en as st,er as ct,et as lt,f as ut,fn as dt,ft,g as pt,gt as mt,h as ht,ht as gt,i as _t,in as vt,it as yt,j as bt,jn as xt,jt as St,kn as Ct,kt as wt,l as Tt,lt as Et,m as Dt,mn as Ot,mt as kt,n as W,nn as At,nr as jt,nt as Mt,o as Nt,on as Pt,ot as Ft,p as It,pn as Lt,pt as Rt,q as zt,qn as Bt,qt as G,r as Vt,rn as Ht,rr as Ut,rt as Wt,s as Gt,sn as Kt,sr as qt,st as Jt,tn as Yt,tr as Xt,tt as Zt,u as Qt,un as $t,ut as en,v as tn,vt as nn,w as rn,wn as an,wt as on,x as sn,xn as cn,xt as ln,y as un,yn as dn,yt as fn,z as pn,zn as mn,zt as hn}from"./toast-D2hAfPD-.js";import{$ as gn,$a as _n,$n as vn,$r as yn,$t as bn,A as xn,Aa as Sn,Ai as Cn,An as wn,Ar as Tn,At as En,B as Dn,Ba as On,Bn as kn,Br as An,C as jn,Ca as Mn,Ci as Nn,Cn as Pn,Cr as Fn,Ct as In,D as Ln,Da as Rn,Di as zn,Dn as Bn,Dr as K,Dt as q,E as Vn,Ea as Hn,Ei as Un,En as Wn,Er as Gn,Et as J,F as Kn,Fn as qn,Fr as Jn,G as Yn,Gn as Xn,H as Zn,Ha as Qn,Hi as $n,Hn as er,Hr as tr,Ht as nr,I as rr,Ia as ir,Ii as ar,In as or,Ir as sr,J as cr,Ji as lr,Jn as ur,Jr as dr,Jt as fr,K as pr,Ki as mr,Kn as hr,Kr as gr,Kt as _r,L as vr,La as yr,Li as br,Ln as xr,Lr as Sr,Lt as Cr,M as wr,Ma as Tr,Mi as Er,Mn as Dr,Mr as Or,N as kr,Na as Ar,Ni as jr,Nn as Mr,Nr,Nt as Pr,O as Fr,Oa as Ir,Oi as Lr,On as Rr,Or as zr,P as Br,Pa as Vr,Pi as Hr,Pn as Ur,Pr as Y,Pt as Wr,Q as Gr,Qa as Kr,Qi as qr,Qn as Jr,Qr as Yr,Qt as Xr,Ri as Zr,Rn as Qr,Rr as $r,Rt as ei,S as ti,Sa as ni,Si as ri,Sn as ii,Sr as ai,St as oi,T as si,Ta as ci,Ti as li,Tn as ui,Tr as di,Tt as fi,U as pi,Ua as mi,Ui as hi,Un as X,Ur as gi,V as _i,Va as vi,Vi as yi,Vn as bi,Vr as xi,Vt as Si,W as Ci,Wa as wi,Wi as Ti,Wn as Ei,Wr as Di,Wt as Oi,X as ki,Xi as Ai,Xn as ji,Xr as Mi,Xt as Ni,Y as Pi,Yi as Fi,Yn as Ii,Yr as Li,Yt as Ri,Z as zi,Za as Bi,Zi as Vi,Zn as Hi,Zr as Ui,Zt as Wi,_a as Gi,_i as Ki,_n as qi,_r as Ji,_t as Yi,a as Xi,aa as Zi,ai as Qi,an as $i,ar as ea,b as ta,ba as na,bi as ra,bn as ia,br as aa,bt as oa,ca as sa,cn as ca,cr as la,ct as ua,d as da,da as fa,dn as pa,dr as ma,dt as ha,ea as ga,ei as _a,en as va,er as ya,et as ba,f as xa,fa as Sa,fn as Ca,fr as wa,ft as Ta,ga as Ea,gi as Da,gn as Oa,gr as ka,gt as Aa,h as ja,ha as Ma,hi as Na,hn as Pa,hr as Fa,ht as Ia,i as La,ia as Ra,ii as za,in as Ba,ir as Va,j as Ha,ja as Ua,ji as Wa,jn as Ga,jr as Ka,jt as qa,k as Ja,ka as Ya,ki as Xa,kn as Za,kr as Qa,kt as $a,l as eo,la as to,ln as no,lr as ro,lt as io,ma as ao,mi as oo,mn as so,mr as co,n as lo,na as uo,ni as fo,nn as po,nr as mo,nt as ho,oa as go,oi as _o,on as vo,or as yo,ot as bo,pa as xo,pn as So,pr as Co,pt as wo,q as To,qi as Eo,qn as Do,qr as Oo,qt as ko,r as Ao,ra as jo,ri as Mo,rn as No,rr as Po,rt as Fo,sa as Io,si as Lo,sn as Ro,sr as zo,st as Bo,t as Vo,ta as Ho,ti as Uo,tn as Wo,tr as Go,tt as Ko,u as qo,ua as Jo,un as Yo,ur as Xo,ut as Zo,v as Qo,va as $o,vi as es,vn as ts,vr as ns,vt as rs,w as is,wa as as,wi as os,wn as ss,wr as cs,wt as ls,x as us,xa as ds,xi as fs,xn as ps,xr as ms,xt as hs,y as gs,ya as _s,yi as vs,yn as ys,yr as bs,yt as xs,z as Ss,za as Cs,zi as ws,zn as Ts,zr as Es,zt as Ds}from"./effect-DksNtAHN.js";var Os={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`}]]};Os.node;var ks=Xe(Os),As={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};As.node;var js=Xe(As),Ms={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};Ms.node;var Ns=Xe(Ms),Ps={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Ps.node;var Fs=Xe(Ps),Is={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`}]]};Is.node;var Ls=Xe(Is),Rs={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`}]]};Rs.node;var zs=Xe(Rs),Bs={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Bs.node;var Vs=Xe(Bs),Hs={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`}]]};Hs.node;var Us=Xe(Hs),Z=e(o(),1),Q=a(),Ws=qt(),Gs=e(n(),1),Ks=e(r(),1),qs=i(),Js=`data-open`,Ys=`data-closed`,Xs=`data-anchor-hidden`,Zs={[z]:``},Qs={[z]:``,[Se]:``},$s={[Js]:``},ec={[Ys]:``},tc={[Xs]:``},nc={open(e){return e?Zs:null}},rc={open(e){return e?Qs:null}},ic={open(e){return e?$s:ec},anchorHidden(e){return e?tc:null}},ac={...ic,...hn};function oc(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...oc(e,t.id,n)])}function sc(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 cc(e,t=!1){let{overflowY:n}=R(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}function lc(e){let t=F(uc,e).current;return t.next=e,V(t.effect),t}function uc(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var dc=0;function fc(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(dc);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),w;let o=requestAnimationFrame(a);return dc=o,()=>{dc===o&&(cancelAnimationFrame(o),dc=0)}}var pc=`data-base-ui-inert`,mc=new WeakMap,hc=new WeakSet,gc=new WeakMap,_c=0;function vc(e){return e?Ue(e)?e.host:vc(e.parentNode):null}var yc=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=vc(t);return e.contains(n)?n:null}).filter(e=>e!=null),bc=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},xc=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{je(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function Sc(e,t,n,{mark:r=!0}){let i=yc(t,e),a=r?xc(t,bc(i),new Set(i)):[],o=[],s=[];if(n){let e=yc(t,Array.from(t.querySelectorAll(`[aria-live]`))),n=i.concat(e);xc(t,bc(n),new Set(n)).forEach(e=>{let t=e.getAttribute(`aria-hidden`),n=t!==null&&t!==`false`,r=(mc.get(e)||0)+1;mc.set(e,r),o.push(e),r===1&&n&&hc.add(e),n||e.setAttribute(`aria-hidden`,`true`)})}return r&&a.forEach(e=>{let t=(gc.get(e)||0)+1;gc.set(e,t),s.push(e),t===1&&e.setAttribute(pc,``)}),_c+=1,()=>{o.forEach(e=>{let t=(mc.get(e)||0)-1;mc.set(e,t),t||(hc.has(e)||e.removeAttribute(`aria-hidden`),hc.delete(e))}),r&&s.forEach(e=>{let t=(gc.get(e)||0)-1;gc.set(e,t),t||e.removeAttribute(pc)}),--_c,_c||(mc=new WeakMap,hc=new WeakSet,gc=new WeakMap)}}function Cc(e,t={}){let{ariaHidden:n=!1,mark:r=!0}=t,i=f(e[0]).body;return Sc(e,i,n,{mark:r})}function wc(){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 Tc=class{nodesRef={current:[]};events=wc();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)}},Ec=Z.createContext(null),Dc=Z.createContext(null),Oc=()=>Z.useContext(Ec)?.id||null,kc=e=>{let t=Z.useContext(Dc);return e??t};function Ac(e){let t=b(),n=kc(e),r=Oc();return V(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function jc(e){let{children:t,id:n}=e,r=Oc();return(0,Q.jsx)(Ec.Provider,{value:Z.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Mc(e){let{children:t,externalTree:n}=e,r=F(()=>n??new Tc).current;return(0,Q.jsx)(Dc.Provider,{value:r,children:t})}function Nc(e,t){let n=A(L(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||(T(e)?`keyboard`:t||`mouse`):`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var Pc=20,Fc=[];function Ic(){Fc=Fc.filter(e=>e.deref()?.isConnected)}function Lc(e){Ic(),e&&je(e)!==`body`&&(Fc.push(new WeakRef(e)),Fc.length>Pc&&(Fc=Fc.slice(-20)))}function Rc(){return Ic(),Fc[Fc.length-1]?.deref()}function zc(e){return e?ze(e)?e:Ie(e)[0]||e:null}function Bc(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=Ne(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return ze(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 Vc(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:p,beforeContentFocusGuardRef:m,externalTree:h,getInsideElements:g}=e,_=t.useState(`open`),v=t.useState(`domReferenceElement`),y=t.useState(`floatingElement`),{events:b,dataRef:C}=t.context,w=D(()=>C.current.floatingContext?.nodeId),A=i===!1,N=ge(v)&&A,ee=lc(i),P=lc(a),F=lc(o),I=lc(u),ie=lc(_),R=kc(h),z=_t(),se=Z.useRef(!1),B=Z.useRef(!1),ce=Z.useRef(!1),le=Z.useRef(null),ue=Z.useRef(``),de=Z.useRef(``),fe=Z.useRef(null),pe=Z.useRef(null),he=x(fe,m,z?.beforeInsideRef),_e=x(pe,z?.afterInsideRef),ve=Ht(),be=Ht(),xe=oe(),Se=z!=null,Ce=wt(y),we=D((e=Ce)=>e?Ie(e):[]),Te=D(()=>g?.().filter(e=>e!=null)??[]);Z.useEffect(()=>{if(r||!c)return;function e(e){e.key===`Tab`&&G(Ce,j(f(Ce)))&&we().length===0&&!N&&me(e)}let t=f(Ce);return U(t,`keydown`,e)},[r,Ce,c,N,we]),Z.useEffect(()=>{if(r||!_)return;let e=f(Ce);function t(){ce.current=!1}function n(e){let t=L(e),n=Te(),r=G(y,t)||G(v,t)||G(z?.portalNode,t)||n.some(e=>e===t||G(e,t));ce.current=!r,de.current=e.pointerType||`keyboard`,ae(t,`[data-base-ui-click-trigger]`)&&(B.current=!0,be.start(0,()=>{B.current=!1}))}function i(){de.current=`keyboard`}return M(U(e,`pointerdown`,n,!0),U(e,`pointerup`,t,!0),U(e,`pointercancel`,t,!0),U(e,`keydown`,i,!0),t)},[r,y,v,Ce,_,z,be,Te]),Z.useEffect(()=>{if(r||!l)return;let e=f(Ce);function n(){B.current=!0,be.start(0,()=>{B.current=!1})}function i(e){let t=L(e);ze(t)&&(le.current=t)}function a(n){let r=n.relatedTarget,i=n.currentTarget,a=L(n);c&&r==null&&a!=null&&G(y,a)&&Lc(a),queueMicrotask(()=>{let o=w(),l=t.context.triggerElements,u=Te(),f=r?.hasAttribute(Je(`focus-guard`))&&[fe.current,pe.current,z?.beforeInsideRef.current,z?.afterInsideRef.current,z?.beforeOutsideRef.current,z?.afterOutsideRef.current,E(p),E(d)].includes(r),m=!(G(v,r)||G(y,r)||G(r,y)||G(z?.portalNode,r)||u.some(e=>e===r||G(e,r))||l.hasMatchingElement(e=>G(e,r))||f||R&&(oc(R.nodesRef.current,o).find(e=>G(e.context?.elements.floating,r)||G(e.context?.elements.domReference,r))||sc(R.nodesRef.current,o).find(e=>[e.context?.elements.floating,wt(e.context?.elements.floating)].includes(r)||e.context?.elements.domReference===r)));if(i===v&&Ce&&Bc(Ce),s&&i!==v&&!Zt(a)&&j(e)===e.body){if(ne(Ce)&&(Ce.focus(),s===`popup`)){xe.request(()=>{Ce.focus()});return}let e=we(),t=le.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||Ce;ne(n)&&n.focus()}C.current.insideReactTree?C.current.insideReactTree=!1:(N||!c)&&r&&m&&!B.current&&(N||r!==Rc())&&(se.current=!0,t.setOpen(!1,H(Qt,n)))})}function o(){ce.current||(C.current.insideReactTree=!0,ve.start(0,()=>{C.current.insideReactTree=!1}))}let u=ne(v)?v:null;if(y||u)return M(u&&U(u,`focusout`,a),u&&U(u,`pointerdown`,n),y&&U(y,`focusin`,i),y&&U(y,`focusout`,a),y&&z&&U(y,`focusout`,o,!0))},[r,v,y,Ce,c,R,z,t,l,s,we,N,w,C,ve,be,xe,d,p,Te]),Z.useEffect(()=>{if(r||!y||!_)return;let e=Array.from(z?.portalNode?.querySelectorAll(`[${Je(`portal`)}]`)||[]),t=(R?sc(R.nodesRef.current,w()):[]).find(e=>ge(e.context?.elements.domReference||null))?.context?.elements.domReference,n=Cc([y,...e,fe.current,pe.current,z?.beforeOutsideRef.current,z?.afterOutsideRef.current,...Te(),t,E(p),E(d),N?v:null].filter(e=>e!=null),{ariaHidden:c||N,mark:!1}),i=Cc([y,...e].filter(e=>e!=null));return()=>{i(),n()}},[_,r,v,y,c,z,N,R,w,d,p,Te]),V(()=>{if(!_||r||!ne(Ce))return;ue.current=``,de.current=``;let e=f(Ce),t=j(e);queueMicrotask(()=>{let n=ee.current,r=typeof n==`function`?n(I.current||``):n;if(r===void 0||r===!1||G(Ce,t))return;let i=null,a=()=>(i??=we(Ce),i[0]||Ce),o;o=r===!0||r===null?a():E(r),o||=a();let s=G(Ce,j(e)),c=C.current.openEvent,l=c?.type===`mousedown`&&T(c);fc(o,{sync:l,preventScroll:o===Ce,shouldFocus(){if(!ie.current)return!1;if(s)return!0;let t=j(e);return!(t!==o&&G(Ce,t))}})})},[r,_,Ce,we,ee,I,ie,C]);let Ee=Z.useRef(null);V(()=>{if(r||!Ce){Ee.current=null;return}Ee.current&&=(Ee.current.cancelled=!0,null);let e=f(Ce),t=j(e),n=I.current==null;Lc(t);function i(e){if(e.open||(ue.current=Nc(e.nativeEvent,de.current)),(e.reason===`focus-out`&&e.triggerElement?.hasAttribute(Je(`focus-guard`))||e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`)&&(se.current=!0),e.reason===`outside-press`){if(e.nested)se.current=!1;else if(T(e.nativeEvent)||S(e.nativeEvent))se.current=!1;else{let e=!1;f(Ce).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?se.current=!1:se.current=!0}}}b.on(`openchange`,i);function a(e){let r=P.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=v?.isConnected?v:null,o=t?.isConnected&&je(t)!==`body`?t:null,s=n?o||a:a||o;return s||=Rc()||null,typeof i==`boolean`?s:E(i)||s||null}return()=>{b.off(`openchange`,i);let t=j(e),n=Te(),r=G(y,t)||n.some(e=>e===t||G(e,t))||R&&oc(R.nodesRef.current,w(),!1).some(e=>G(e.context?.elements.floating,t)),o=P.current,s=ue.current,c=a(s),l={cancelled:!1};Ee.current=l,queueMicrotask(()=>{Ee.current===l&&(Ee.current=null);let n=zc(c),i=F.current??typeof o!=`boolean`;if(!l.cancelled&&o&&!se.current&&ne(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}se.current=!1})}},[r,y,Ce,P,F,I,b,R,v,w,Te]),V(()=>{if(!ye||_||!y)return;let e=j(f(y));ne(e)&&O(e)&&G(y,e)&&e.blur()},[_,y]),V(()=>{if(!r&&z)return z.setFocusManagerState({modal:c,closeOnFocusOut:l,open:_,onOpenChange:t.setOpen,domReference:v}),()=>{z.setFocusManagerState(null)}},[r,z,c,_,t,l,v]),V(()=>{if(!r&&Ce)return Bc(Ce),()=>{queueMicrotask(Ic)}},[r,Ce]);let De=!r&&(!c||!N)&&(Se||c);return(0,Q.jsxs)(Z.Fragment,{children:[De&&(0,Q.jsx)(pn,{"data-type":`inside`,ref:he,onFocus:e=>{if(c){let e=we();fc(e[e.length-1])}else z?.portalNode&&(se.current=!1,te(e,z.portalNode)?k(v)?.focus():E(p??z.beforeOutsideRef)?.focus())}}),n,De&&(0,Q.jsx)(pn,{"data-type":`inside`,ref:_e,onFocus:e=>{c?fc(we()[0]):z?.portalNode&&(l&&(se.current=!0),te(e,z.portalNode)?re(v)?.focus():E(d??z.afterOutsideRef)?.focus())}})]})}function Hc(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=rn}=t,l=e.context.dataRef,u=Z.useRef(void 0),d=oe(),f=Ht(),p=Z.useMemo(()=>{function t(t,n,r,i){let a=H(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=on(e.pointerType,!0)&&S(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(i){let o=u.current,s=i.nativeEvent,c=e.select(`open`);if(i.button!==0||r===`click`||on(o,!0)&&a)return;let l=n(c,i.currentTarget,e=>e===`click`||e===`mousedown`),f=L(s),p=O(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:on(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}:Ee,[n,p])}function Uc(){return!1}function Wc(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function Gc(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=Uc,bubbles:s,externalTree:c}=t,l=e.useState(`open`),u=e.useState(`floatingElement`),{dataRef:d,events:m}=e.context,h=kc(c),g=D(typeof i==`function`?i:()=>!1),_=typeof i==`function`?g:i,v=_!==!1,y=D(()=>a),{escapeKey:b,outsidePress:x}=Wc(s),S=Z.useRef(!1),C=Z.useRef(!1),w=Z.useRef(!1),E=Z.useRef(!1),O=Z.useRef(!1),k=Z.useRef(``),A=Z.useRef(null),j=Ht(),N=Ht(),ee=Ht(),P=D(()=>{N.clear(),d.current.insideReactTree=!1}),F=D(e=>{let t=d.current.floatingContext?.nodeId;return(h?oc(h.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),I=D(t=>p(t,e.select(`floatingElement`))||p(t,e.select(`domReferenceElement`))),te=D(t=>{o()&&e.setOpen(!1,H(rn,t.nativeEvent))}),re=D(t=>{if(!l||!n||!r||t.key!==`Escape`)return;let i=De(t)?t.nativeEvent:t;if(O.current||i.isComposing||!b&&F(`__escapeKeyBubbles`))return;let a=H(Tt,i);e.setOpen(!1,a),a.isCanceled||t.preventDefault(),!b&&!a.isPropagationAllowed&&t.stopPropagation()}),ie=D(()=>{d.current.insideReactTree=!0,N.start(0,P)}),ae=D(t=>{if(!l||!n||t.button!==0)return;let r=L(t.nativeEvent);G(e.select(`floatingElement`),r)&&(S.current||(S.current=!0,C.current=!1))}),oe=D(e=>{l&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&S.current&&(C.current=!0)});Z.useEffect(()=>{function e(e){e.open||(E.current=!1)}return m.on(`openchange`,e),()=>{m.off(`openchange`,e)}},[m]),Z.useEffect(()=>P,[P]),Z.useEffect(()=>{if(!l||!n)return l||(E.current=!1,O.current=!1,k.current=``,A.current=null),P;d.current.__escapeKeyBubbles=b,d.current.__outsidePressBubbles=x;let t=new At,i=f(u);function a(){ee.clear(),O.current=!0}function o(){O.current=!0,ee.start(ye?5:0,()=>{O.current=!1})}function s(){w.current=!0,t.start(0,()=>{w.current=!1})}function c(){S.current=!1,C.current=!1}function m(){let e=k.current,t=e===`pen`||!e?`mouse`:e,n=y(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function g(e){let t=m();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function D(e){let t=d.current.floatingContext?.nodeId,n=h&&oc(h.nodesRef.current,t).some(t=>p(e,t.context?.elements.floating));return I(e)||n}function N(n){if(g(n)){n.type!==`click`&&!I(n)&&(t.clear(),w.current=!1),P();return}if(d.current.insideReactTree){P();return}let r=L(n),i=`[${Je(`inert`)}]`,a=Bt(r)?r.getRootNode():null,o=Array.from((Ue(a)?a:f(e.select(`floatingElement`))).querySelectorAll(i)),s=e.context.triggerElements;if(r&&(s.hasElement(r)||s.hasMatchingElement(e=>G(e,r))))return;let c=Bt(r)?r:null;for(;c&&!Be(c);){let e=Pe(c);if(Be(e)||!Bt(e))break;c=e}if(!(o.length&&Bt(r)&&!ce(r)&&!G(r,e.select(`floatingElement`))&&o.every(e=>!G(c,e)))){if(ne(r)&&!(`touches`in n)){let e=Be(r),t=R(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(!D(n)){if(m()===`intentional`){if(n.detail!==0&&!T(n)&&!E.current)return;if(w.current){t.clear(),w.current=!1;return}}typeof _==`function`&&!_(n)||F(`__outsidePressBubbles`)||(e.setOpen(!1,H(un,n)),P())}}}function te(t){m()===`sloppy`&&t.pointerType!==`touch`&&e.select(`open`)&&n&&!I(t)&&N(t)}function ie(t){if(m()!==`sloppy`||!e.select(`open`)||!n||I(t))return;let r=t.touches[0];r&&(A.current={startTime:Date.now(),startX:r.clientX,startY:r.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},j.start(1e3,()=>{A.current&&(A.current.dismissOnTouchEnd=!1,A.current.dismissOnMouseDown=!1)}))}function ae(e,t){let n=L(e);if(!n)return;let r=U(n,e.type,()=>{t(e),r()})}function oe(e){k.current=`touch`,ae(e,ie)}function z(e){j.clear(),e.type===`pointerdown`&&(e.button===0&&(E.current=!0),k.current=e.pointerType),(e.type!==`mousedown`||!A.current||A.current.dismissOnMouseDown)&&ae(e,e=>{e.type===`pointerdown`?te(e):N(e)})}function se(e){if(e.type===`pointercancel`&&(E.current=!1),!S.current)return;let n=C.current;c(),m()===`intentional`&&(e.type===`pointercancel`?n&&s():D(e)||(n?s():(typeof _!=`function`||_(e))&&(t.clear(),w.current=!0,P())))}function B(e){if(m()!==`sloppy`||!A.current||I(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-A.current.startX),r=Math.abs(t.clientY-A.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(A.current.dismissOnTouchEnd=!0),i>10&&(N(e),j.clear(),A.current=null)}function le(e){ae(e,B)}function ue(e){m()===`sloppy`&&A.current&&!I(e)&&(A.current.dismissOnTouchEnd&&N(e),j.clear(),A.current=null)}function de(e){ae(e,ue)}let fe=M(r&&M(U(i,`keydown`,re),U(i,`compositionstart`,a),U(i,`compositionend`,o)),v&&M(U(i,`click`,z,!0),U(i,`pointerdown`,z,!0),U(i,`pointerup`,se,!0),U(i,`pointercancel`,se,!0),U(i,`mousedown`,z,!0),U(i,`mouseup`,se,!0),U(i,`touchstart`,oe,{capture:!0,passive:!0}),U(i,`touchmove`,le,{capture:!0,passive:!0}),U(i,`touchend`,de,{capture:!0,passive:!0})));return()=>{fe(),t.clear(),c(),w.current=!1}},[d,u,r,v,_,l,n,b,x,re,P,y,F,I,h,e,j,ee]);let z=Z.useMemo(()=>({onKeyDown:re,onPointerDown:te,onClick:te}),[re,te]),se=Z.useMemo(()=>({onKeyDown:re,onPointerDown:oe,onMouseDown:oe,onClickCapture:ie,onMouseDownCapture(e){ie(),ae(e)},onPointerDownCapture(e){ie(),ae(e)},onMouseUpCapture:ie,onTouchEndCapture:ie,onTouchMoveCapture:ie}),[re,ie,ae,oe]);return Z.useMemo(()=>n?{reference:z,floating:se,trigger:z}:{},[n,z,se])}function Kc(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),V(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};Bt(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 qc(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),V(()=>{if(!e&&o&&i!==`ending`&&n){let e=P.request(()=>{a(`ending`)});return()=>{P.cancel(e)}}},[e,o,i,n]),V(()=>{if(!e||t||i===void 0)return;let n=P.request(()=>{a(void 0)});return()=>{P.cancel(n)}},[t,e,i]),V(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=P.request(()=>{a(`idle`)});return()=>{P.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}function Jc(e){let{open:t,ref:n,preventUnmountOnClose:r,setPreventUnmountOnClose:i,onUnmount:a,animateInitialOpen:o}=e,s=D(i),{mounted:c,setMounted:l,transitionStatus:u}=qc(t,!1,!1,o),d=!t&&r;V(()=>{t&&s(!1)},[t,s]);let f=Z.useRef(c),p=Z.useRef(!1),m=fe(),h=()=>{f.current=!1,l(!1),a()};V(()=>{f.current=c,p.current&&(p.current=!1,!t&&c&&h())});let g=D(()=>{f.current&&(t?(p.current=!0,m()):h())});return le({enabled:c&&!t&&!d,open:t,ref:n,onComplete(){t||g()}}),{mounted:c,transitionStatus:u,preventUnmountingOnClose:d,forceUnmount:g}}var Yc={tabIndex:-1,[Fe]:``};function Xc({handle:e,store:t}){return V(()=>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 Qc(e,t){let n=Z.useRef(null);return D(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 $c(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 el(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function tl(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=Qc(e,n),o=D(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=D(e=>{a(e),e&&o(e)});return V(()=>(s(t.current),()=>s(null)),[s,t,n,e]),V(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function nl(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`);V(()=>{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=H(tn);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,a,o,s,n])}function rl(e,t,n,r){let{mounted:i,transitionStatus:a,forceUnmount:o}=Jc({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 F(()=>(t.set(`mounted`,i),null)),t.useSyncedValues({mounted:i,transitionStatus:a}),{forceUnmount:o,transitionStatus:a}}function il(e,t){e.useSyncedValues(t),V(()=>()=>{e.update({activeTriggerProps:Ee,inactiveTriggerProps:Ee,popupProps:Ee})},[e])}var al=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}},ol={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},sl=class extends vt{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:wc(),nested:n,triggerElements:i},ol),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&y(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 cl(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new sl({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:Ee,inactiveTriggerProps:Ee,popupProps:Ee}}var ll=e=>e.triggerIdProp??e.activeTriggerId,ul=e=>e.openProp??e.open,dl=e=>(e.popupElement?.id??e.floatingId)||void 0;function fl(e,t){return t!==void 0&&ul(e)&&ll(e)===t}function pl(e,t){return fl(e,t)?!0:t!==void 0&&ul(e)&&ll(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}var ml={open:ul,mounted:e=>e.mounted,transitionStatus:e=>ul(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:ll,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:dl,isTriggerActive:(e,t)=>t!==void 0&&ll(e)===t,isOpenedByTrigger:(e,t)=>fl(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&ll(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>pl(e,t)?dl(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function hl(e){let t=Z.useCallback(t=>e===void 0?w:e.subscribeStore(t),[e]),n=Z.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,Ws.useSyncExternalStore)(t,n,()=>e?.serverStore)}function gl(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=b(),a=Oc()!=null,o=F(()=>new sl({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new al,floatingId:i,syncOnly:!1,nested:a})).current;return V(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=Bt(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}var _l=Yt&&ye;function vl(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=Ht();Z.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=A(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&ne(t)&&t===j(f(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return M(U(r,`blur`,i),_l&&U(r,`keydown`,a,!0),_l&&U(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`);Bt(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=L(n.nativeEvent);if(Bt(a)){if(_l&&!n.relatedTarget){if(!c.current&&!O(a))return}else if(!I(a))return}let u=de(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;e.select(`open`)&&u||!r?e.setOpen(!0,H(Ce,d,f)):l.start(r,()=>{o.current||e.setOpen(!0,H(Ce,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=Bt(r)&&r.hasAttribute(Je(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=j(f(t));!r&&n===t||G(a.current.floatingContext?.refs.floating.current,n)||G(t,n)||o||de(r??n,e.context.triggerElements)||e.setOpen(!1,H(Ce,i))})}}},[a,r,e,l]);return Z.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}var yl=class e{pointerType=void 0;interactedInside=!1;handler=void 0;blockMouseMove=!0;performedPointerEventsMutation=!1;pointerEventsScopeElement=null;pointerEventsReferenceElement=null;pointerEventsFloatingElement=null;restTimeoutPending=!1;openChangeTimeout=new At;restTimeout=new At;handleCloseOptions=void 0;static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},bl=new WeakMap;function xl(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&bl.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),bl.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function Sl(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=bl.get(n);a&&a!==e&&xl(a),xl(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,bl.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function Cl(e){let t=e.context.dataRef.current,n=F(()=>t.hoverInteractionState??yl.create()).current;return t.hoverInteractionState||=n,Kt(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function wl(e,t){return t!=null&&!on(t)?0:typeof e==`function`?e():e}function Tl(e,t,n){let r=wl(e,n);return typeof r==`number`?r:r?.[t]}function El(e){return typeof e==`function`?e():e}function Dl(e,t){return t||e===`click`||e===`mousedown`}function Ol(e){return e?.includes(`mouse`)&&e!==`mousedown`}function kl(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=kc(),u=Oc(),d=Cl(e),p=Ht(),m=D(()=>Dl(c.current.openEvent?.type,d.interactedInside)),h=D(()=>Ol(c.current.openEvent?.type)),g=D(()=>{xl(d)});V(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,g())},[a,d,g]),Z.useEffect(()=>g,[g]),V(()=>{if(n&&a&&d.handleCloseOptions?.blockPointerEvents&&h()&&Bt(s)&&o){let e=s,t=o,n=f(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??ae(e,`[data-rootownerid]`)??n.body;return Sl(d,{scopeElement:c,referenceElement:e,floatingElement:t}),()=>{g()}}},[n,a,s,o,d,h,l,u,g]),Z.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&oc(l.nodesRef.current,u).length>0)}function a(t){let n=Tl(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,H(_,t)),l?.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=L(e);St(t)?d.interactedInside=ae(t,`[aria-haspopup]`)!=null:d.interactedInside=!1}function f(){d.openChangeTimeout.clear(),p.clear(),l?.events.off(`floating.closed`,y),g()}function v(n){if(t()&&l){l.events.on(`floating.closed`,y);return}if(de(n.relatedTarget,e.context.triggerElements))return;let r=c.current.floatingContext?.nodeId??i,o=n.relatedTarget;l&&r&&Bt(o)&&oc(l.nodesRef.current,r,!1).some(e=>G(e.context?.elements.floating,o))||(d.handler?d.handler(n):(g(),h()&&!m()&&a(n)))}function y(n){l&&u&&!t()&&p.start(0,()=>{l.events.off(`floating.closed`,y),e.setOpen(!1,H(_,n)),l.events.emit(`floating.closed`,n)})}let b=o;return M(b&&U(b,`mouseenter`,f),b&&U(b,`mouseleave`,v),b&&U(b,`pointerdown`,s,!0),()=>{l?.events.off(`floating.closed`,y)})},[n,o,e,c,r,i,h,m,g,d,l,u,p])}var Al={current:null};function jl(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=Al,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:p,shouldOpen:m,guardStaleOpen:h=!1}=t,{dataRef:g,events:v}=e.context,y=kc(l),b=Cl(e),x=Z.useRef(!1),S=lc(i),C=lc(r),w=lc(o),T=lc(n),E=lc(m),O=lc(p),k=D(()=>Dl(g.current.openEvent?.type,b.interactedInside)),A=D(()=>E.current?.()!==!1),j=D((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!G(t,n);if(!Bt(r))return!1;let a=r;return i.hasMatchingElement(e=>G(e,a))&&(!t||!G(t,a))}),N=D(()=>{b.handler&&=(f(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,b.handler),void 0)}),ee=D(()=>{xl(b)});return u&&(b.handleCloseOptions=i?.__options),Z.useEffect(()=>N,[N]),Z.useEffect(()=>{if(!n)return;function e(e){e.open?x.current=!1:(x.current=e.reason===_,N(),b.openChangeTimeout.clear(),b.restTimeout.clear(),b.blockMouseMove=!0,b.restTimeoutPending=!1)}return v.on(`openchange`,e),()=>{v.off(`openchange`,e)}},[n,v,b,N]),Z.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=Tl(C.current,`close`,b.pointerType);r?b.openChangeTimeout.start(r,()=>{e.setOpen(!1,H(_,t)),y?.events.emit(`floating.closed`,t)}):n&&(b.openChangeTimeout.clear(),e.setOpen(!1,H(_,t)),y?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!Bt(r))return;function i(t){if(b.openChangeTimeout.clear(),b.blockMouseMove=!1,a&&!on(b.pointerType))return;let n=El(w.current),r=Tl(C.current,`open`,b.pointerType),i=L(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(Bt(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(G(t,i)){c=t;break}}Bt(o)&&Bt(s)&&!e.context.triggerElements.hasElement(o)&&G(o,s)&&(c=s);let l=c!=null&&j(s,c,i),u=e.select(`open`),d=O.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&x.current,p=!l&&Bt(c)&&Bt(s)&&G(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;h?A()&&e.setOpen(!0,H(_,t,c)):m||(r?b.openChangeTimeout.start(r,()=>{g&&A()&&e.setOpen(!0,H(_,t,c))}):g&&A()&&e.setOpen(!0,H(_,t,c)))}function o(n){if(k()){ee();return}N();let r=e.select(`domReferenceElement`),i=f(r);b.restTimeout.clear(),b.restTimeoutPending=!1;let a=g.current.floatingContext??d?.();if(!de(n.relatedTarget,e.context.triggerElements)){if(S.current&&a){e.select(`open`)||b.openChangeTimeout.clear();let r=c.current;b.handler=S.current({...a,tree:y,x:n.clientX,y:n.clientY,onClose(){ee(),N(),T.current&&!k()&&r===e.select(`domReferenceElement`)&&t(n,!0)}}),i.addEventListener(`mousemove`,b.handler),b.handler(n)}else b.pointerType===`touch`&&G(e.select(`floatingElement`),n.relatedTarget)||t(n)}}function l(e){G(r,e.relatedTarget)||(b.openChangeTimeout.clear(),b.restTimeout.clear(),b.restTimeoutPending=!1)}let p=h?U(r,`mouseout`,l):void 0;return s?M(U(r,`mousemove`,i,{once:!0}),U(r,`mouseenter`,i),U(r,`mouseleave`,o),p):M(U(r,`mouseenter`,i),U(r,`mouseleave`,o),p)},[N,ee,g,C,e,n,S,b,u,j,k,a,s,w,c,y,T,d,O,A,h]),Z.useMemo(()=>{if(!n)return;function t(e){b.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=j(i,r,t.target);if(a&&!on(b.pointerType))return;if(o&&s&&b.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=b.handleCloseOptions?.getScope?.()??r.ownerDocument.body;Sl(b,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=El(w.current);if(o&&!s||c===0||!s&&b.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;b.restTimeout.clear();function l(){if(b.restTimeoutPending=!1,k())return;let t=e.select(`open`);!b.blockMouseMove&&(!t||s)&&A()&&e.setOpen(!0,H(_,n,r))}b.pointerType===`touch`?Ks.flushSync(()=>{l()}):s&&o?l():(b.restTimeoutPending=!0,b.restTimeout.start(c,l))}}},[n,b,k,j,a,e,w,A])}function Ml(e){return ye&&e.movementX===0&&e.movementY===0}function Nl(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function Pl(e,t){return Nl(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Fl(e,t,n){return Nl(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Il(e,t,n){return Nl(t,n?e===Me:e===ee,e===g)}function Ll(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:Nl(t,n?e===ee:e===Me,e===ke)}function Rl(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:l=!1,nested:u=!1,rtl:d=!1,virtual:p=!1,focusItemOnOpen:m=`auto`,focusItemOnHover:h=!0,openOnArrowKeyDown:g=!0,disabledIndices:_=void 0,orientation:v=`vertical`,triggerOrientation:y=v,parentOrientation:b,id:x,resetOnPointerLeave:C=!0,externalTree:w,nestedReturnFocusRef:E,grid:k}=t,A=k!=null,M=e.useState(`open`),N=e.useState(`floatingElement`),ee=e.useState(`domReferenceElement`),P=e.context.dataRef,F=wt(N),I=ge(ee),te=lc(F),re=Oc(),ie=kc(w),ae=Z.useRef(m),R=Z.useRef(o??-1),z=Z.useRef(null),se=Z.useRef(!0),B=D(e=>{i(R.current===-1?null:R.current,e)}),ce=Z.useRef(!!N),le=Z.useRef(M),ue=Z.useRef(!1),de=Z.useRef(!1),fe=Z.useRef(null),pe=lc(_),he=lc(M),ve=lc(o),ye=lc(C),be=oe(),xe=oe(),Se=D(()=>{be.cancel();function e(e){p||(fe.current=fc(e,{sync:ue.current,preventScroll:!0}))}let t=n.current[R.current],r=de.current;t&&e(t),(ue.current?e=>e():e=>be.request(e))(()=>{let i=n.current[R.current]||t;i&&(t||e(i),U&&(r||!se.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});V(()=>{P.current.orientation=v},[P,v]),V(()=>{M||(z.current=null),M&&m===`auto`||(ae.current=m)},[M,m]),V(()=>{a&&(M&&N?(R.current=o??-1,ae.current&&o!=null&&(de.current=!0,B())):ce.current&&(R.current=-1,B()))},[a,M,N,o,B]),V(()=>{if(a){if(!M)ue.current=!1;else if(N){if(r==null){if(ue.current=!1,ve.current!=null)return;if(ce.current&&(R.current=-1,Se()),(!le.current||!ce.current)&&ae.current&&(z.current!=null||ae.current===!0&&z.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>xe.request(e):queueMicrotask)(t),e+=1):(R.current=z.current==null||Fl(z.current,y,d)||u?c(n):_e(n),z.current=null,B())};t()}}else Mt(n.current,r)||(R.current=r,Se(),de.current=!1)}}},[a,M,N,r,ve,u,n,y,d,B,Se,xe]),V(()=>{if(!a||N||!ie||p||!ce.current)return;let e=ie.nodesRef.current,t=e.find(e=>e.id===re)?.context?.elements.floating,n=j(f(ee??t??null)),r=e.some(e=>e.context&&G(e.context.elements.floating,n));t&&!r&&se.current&&t.focus({preventScroll:!0})},[a,N,ee,ie,re,p]),V(()=>{le.current=M,ce.current=!!N});let Ce=r!=null,we=D(e=>{if(!he.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(R.current!==t||r!==t)&&(R.current=t,B(e))}),Te=D(()=>b??ie?.nodesRef.current.find(e=>e.id===re)?.context?.dataRef?.current.orientation),Ee=D(()=>c(n,pe.current)),De=D(t=>{if(se.current=!1,ue.current=!0,t.which===229||!he.current&&t.currentTarget===te.current)return;if(u&&Ll(t.key,v,d,A)){Pl(t.key,Te())||me(t),e.setOpen(!1,H(Ge,t.nativeEvent));let n=E?.current??ee;ne(n)&&n.focus();return}r!=null&&r!==R.current&&!Mt(n.current,r)&&(R.current=r);let i=R.current,a=c(n,_),o=_e(n,_);if(I||(t.key===`Home`&&(me(t),R.current=a,B(t)),t.key===`End`&&(me(t),R.current=o,B(t))),k!=null){let e=k(t,R.current,n,v,l,d,_,a,o);if(e!=null&&e!==R.current&&(R.current=e,B(t)),v===`both`)return}if(Pl(t.key,v)){me(t);let e=j(t.currentTarget.ownerDocument);if(M&&!p&&G(t.currentTarget,e)&&!n.current.some(t=>t!=null&&G(t,e))){R.current=Fl(t.key,v,d)?a:o,B(t),r===R.current&&Se();return}let{index:c,wrapped:u}=lt(n.current,i,{decrement:!Fl(t.key,v,d),loopFocus:l,allowEscape:s,disabledIndices:_,minIndex:a,maxIndex:o});u&&(ue.current=!1),R.current=c,B(t)}}),U=Z.useMemo(()=>({onFocus(e){ue.current=!0,we(e)},onClick({currentTarget:e}){p||e.focus({preventScroll:!0})},onMouseMove(e){Ml(e)||(ue.current=!0,de.current=!1,h&&we(e))},onPointerLeave(e){if(!he.current||!se.current||e.pointerType===`touch`)return;ue.current=!0;let t=e.relatedTarget;if(h&&!n.current.includes(t)&&ye.current&&(fe.current?.(),fe.current=null,R.current=-1,B(e),!p)){let e=te.current,t=j(f(e));e&&G(e,t)&&e.focus({preventScroll:!0})}}}),[we,he,te,h,n,B,ye,p]),Oe=Z.useMemo(()=>p&&M&&Ce&&{"aria-activedescendant":`${x}-${r}`},[p,M,Ce,x,r]),ke=Z.useMemo(()=>({...I?{}:Oe,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&M&&!p){let n=L(t.nativeEvent);if(n&&!G(te.current,n))return;me(t);let r=H(Qt,t.nativeEvent);e.setOpen(!1,r);let i=E?.current??ee;!r.isCanceled&&ne(i)&&i.focus()}else De(t)},onPointerMove(e){Ml(e)||(se.current=!0)}}),[Oe,De,te,I,e,M,p,ee,E]),Ae=Z.useMemo(()=>{function t(t){e.setOpen(!0,H(Ge,t.nativeEvent,t.currentTarget))}function n(e){m===`auto`&&T(e.nativeEvent)&&(ae.current=!p)}function r(e){ae.current=m,m===`auto`&&S(e.nativeEvent)&&(ae.current=!0)}return{onKeyDown(n){let r=e.select(`open`);se.current=!1;let i=n.key.startsWith(`Arrow`),a=Il(n.key,Te(),d),o=Pl(n.key,r?v:y),s=(u?a:o)||n.key===`Enter`||n.key.trim()===``;if(p&&r&&(!u||O(n.currentTarget)))return De(n);if(r||g||!i){if(s){let e=Pl(n.key,Te());z.current=u&&e?null:n.key}u?a&&(me(n),r?(R.current=Ee(),B(n),p&&te.current?.focus()):t(n)):o&&(ve.current!=null&&(R.current=ve.current),me(n),!r&&g?t(n):De(n),r&&B(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!p&&(R.current=-1,B(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[De,m,Ee,u,B,e,g,v,y,Te,d,ve,p,te]),je=Z.useMemo(()=>({...Oe,...Ae}),[Oe,Ae]);return Z.useMemo(()=>a?{reference:je,floating:ke,item:U,trigger:Ae}:{},[a,je,ke,Ae,U])}function zl(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=D(s),f=e.useState(`open`),p=Ht(),m=Z.useRef(``),h=Z.useRef(u??i??-1),g=Z.useRef(null),_=D(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!Zt(n)||n?.matches(`:disabled`)?!1:o==null||!Wt(an,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===` `&&(me(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!==` `&&(me(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=D(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);G(r,n)||G(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});V(()=>{(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 Bl=.1,Vl=Bl*Bl,Hl=.5;function Ul(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function Wl(e,t,n,r,i,a,o,s,c,l){let u=!1;return Ul(e,t,n,r,i,a)&&(u=!u),Ul(e,t,i,a,o,s)&&(u=!u),Ul(e,t,o,s,c,l)&&(u=!u),Ul(e,t,c,l,n,r)&&(u=!u),u}function Gl(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function Kl(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 ql(e={}){let{blockPointerEvents:t=!1}=e,n=new At,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*Vl;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=L(r),g=r.type===`mouseleave`,_=G(u,h),v=G(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&Bt(r.relatedTarget)&&G(u,r.relatedTarget))return;function y(){return!!(s&&oc(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=Kl(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=Kl(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=Kl(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=Kl(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Gl(d,f,x)||!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?Hl/2:Hl*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+Hl+1,o=C||T?S.bottom-Hl:S.top,s=C?T?S.bottom-Hl:S.top:S.bottom-Hl;M=Wl(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?Hl/2:Hl*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-Hl,o=C||T?S.top+Hl:S.bottom,s=C?T?S.top+Hl:S.bottom:S.top+Hl;M=Wl(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?Hl/2:Hl*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+Hl+1,o=w||E?S.right-Hl:S.left,s=w?E?S.right-Hl:S.left:S.right-Hl;M=Wl(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?Hl/2:Hl*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-Hl,o=w||E?S.left+Hl:S.right,s=w?E?S.left+Hl:S.right:S.left+Hl;M=Wl(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 Jl(e,t,n){let{reference:r,floating:i}=e,a=nn(t),o=Et(t),s=ot(o),c=qe(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=rt(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Yl(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}=Ft(t,e),p=mt(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=ln(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=ln(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 Xl=50,Zl=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Yl},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Jl(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<Xl&&(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}=Jl(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Ql=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}=Ft(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=qe(r),_=nn(o),v=qe(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[gt(o)]:ft(o)),x=p!==`none`;!d&&x&&b.push(...kt(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=en(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`||_===nn(t)||T.every(e=>nn(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=nn(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{}}}},$l=new Set([`left`,`top`]);async function eu(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=qe(n),s=rt(n),c=nn(n)===`y`,l=$l.has(o)?-1:1,u=a&&c?-1:1,d=Ft(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 tu=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 eu(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}}}}},nu=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}=Ft(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=nn(i),p=Rt(f),m=u[p],h=u[f],g=(e,t)=>yt(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}}}}}},ru=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}=Ft(e,t),u={x:n,y:r},d=nn(i),f=Rt(d),p=u[f],m=u[d],h=Ft(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=$l.has(qe(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}}}},iu=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}=Ft(e,t),c=await i.detectOverflow(t,s),l=qe(n),u=rt(n),d=nn(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=et(p-c[m],g),y=et(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*fn(c.left,c.right):S=p-2*fn(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 au(e){let t=R(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ne(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Te(n)!==a||Te(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function ou(e){return Bt(e)?e:e.contextElement}function su(e){let t=ou(e);if(!ne(t))return Ze(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=au(t),o=(a?Te(n.width):n.width)/r,s=(a?Te(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var cu=Ze(0);function lu(e){let t=A(e);return!ct()||!t.visualViewport?cu:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function uu(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===A(e)}function du(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=ou(e),o=Ze(1);t&&(r?Bt(r)&&(o=su(r)):o=su(e));let s=uu(a,n,r)?lu(a):Ze(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=A(a),t=Bt(r)?A(r):r,n=e,i=h(n);for(;i&&t!==n;){let e=su(i),t=i.getBoundingClientRect(),r=R(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=A(i),i=h(n)}}return ln({width:u,height:d,x:c,y:l})}function fu(e,t){let n=N(e).scrollLeft;return t?t.left+n:du(mn(e)).left+n}function pu(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-fu(e,n),y:n.top+t.scrollTop}}function mu(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=mn(r),s=t?l(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},u=Ze(1),d=Ze(0),f=ne(r);if((f||!a)&&((je(r)!==`body`||Le(o))&&(c=N(r)),f)){let e=du(r);u=su(r),d.x=e.x+r.clientLeft,d.y=e.y+r.clientTop}let p=o&&!f&&!a?pu(o,c):Ze(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-c.scrollTop*u.y+d.y+p.y}}function hu(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function gu(e){let t=N(e),n=e.ownerDocument.body,r=fn(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=fn(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+fu(e),o=-t.scrollTop;return R(n).direction===`rtl`&&(a+=fn(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var _u=25;function vu(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=A(e),a=mn(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!ct()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(fu(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<=_u&&(s-=o)}return{width:s,height:c,x:l,y:u}}function yu(e,t){let n=du(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=su(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function bu(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=vu(e,n,t);else if(t===`document`)r=gu(mn(e));else if(Bt(t))r=yu(t,n);else{let n=lu(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return ln(r)}function xu(e,t){let n=t.get(e);if(n)return n;let r=Oe(e,[],!1).filter(e=>Bt(e)&&je(e)!==`body`),i=null,a=R(e).position===`fixed`,o=a?Pe(e):e;for(;Bt(o)&&!Be(o);){let e=R(o),t=ie(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Pe(o)}return t.set(e,r),r}function Su(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?l(t)?[]:xu(t,this._c):[].concat(n),r],o=bu(t,a[0],i),s=o.top,c=o.right,u=o.bottom,d=o.left;for(let e=1;e<a.length;e++){let n=bu(t,a[e],i);s=fn(n.top,s),c=et(n.right,c),u=et(n.bottom,u),d=fn(n.left,d)}return{width:c-d,height:u-s,x:d,y:s}}function Cu(e){let{width:t,height:n}=au(e);return{width:t,height:n}}function wu(e,t,n){let r=ne(t),i=mn(t),a=n===`fixed`,o=du(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Ze(0);if((r||!a)&&((je(t)!==`body`||Le(i))&&(s=N(t)),r)){let e=du(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=fu(i));let l=i&&!r&&!a?pu(i,s):Ze(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 Tu(e){return R(e).position===`static`}function Eu(e,t){if(!ne(e)||R(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return mn(e)===n&&(n=n.ownerDocument.body),n}function Du(e,t){let n=A(e);if(l(e))return n;if(!ne(e)){let t=Pe(e);for(;t&&!Be(t);){if(Bt(t)&&!Tu(t))return t;t=Pe(t)}return n}let r=Eu(e,t);for(;r&&ve(r)&&Tu(r);)r=Eu(r,t);return r&&Be(r)&&Tu(r)&&!ie(r)?n:r||xe(e)||n}var Ou=async function(e){let t=this.getOffsetParent||Du,n=this.getDimensions,r=await n(e.floating);return{reference:wu(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ku(e){return R(e).direction===`rtl`}var Au={convertOffsetParentRelativeRectToViewportRelativeRect:mu,getDocumentElement:mn,getClippingRect:Su,getOffsetParent:Du,getElementRects:Ou,getClientRects:hu,getDimensions:Cu,getScale:su,isElement:Bt,isRTL:ku};function ju(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Mu(e,t,n){let r=null,i,a=mn(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=Jt(d),h=Jt(a.clientWidth-(u+f)),g=Jt(a.clientHeight-(d+p)),_=Jt(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:fn(0,et(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!ju(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=A(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Nu(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=ou(e),u=i||a?[...l?Oe(l):[],...t?Oe(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Mu(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?du(e):null;c&&g();function g(){let t=du(e);h&&!ju(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 Pu=tu,Fu=nu,Iu=Ql,Lu=iu,Ru=ru,zu=(e,t,n)=>{let r=new Map,i=n??{},a={...Au,...i.platform,_c:r};return Zl(e,t,{...i,platform:a})},Bu=typeof document<`u`?Z.useLayoutEffect:function(){};function Vu(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(!Vu(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)&&!Vu(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Hu(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Uu(e,t){let n=Hu(e);return Math.round(t*n)/n}function Wu(e){let t=Z.useRef(e);return Bu(()=>{t.current=e}),t}function Gu(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);Vu(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=Wu(c),D=Wu(i),O=Wu(l),k=Z.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),zu(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!Vu(w.current,t)&&(w.current=t,Ks.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);Bu(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=Z.useRef(!1);Bu(()=>(A.current=!0,()=>{A.current=!1}),[]),Bu(()=>{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]),N=Z.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=Uu(M.floating,u.x),r=Uu(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Hu(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:N}),[u,k,j,M,N])}var Ku=(e,t)=>{let n=Pu(e);return{name:n.name,fn:n.fn,options:[e,t]}},qu=(e,t)=>{let n=Fu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ju=(e,t)=>({fn:Ru(e).fn,options:[e,t]}),Yu=(e,t)=>{let n=Iu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xu=(e,t)=>{let n=Lu(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=kc(n),p=Z.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=Gu({...e,elements:{...p,...l&&{reference:l}}}),h=Z.useCallback(e=>{let t=Bt(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 V(()=>{o&&(d.current=o)},[o]),V(()=>{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 Qu=Z.createContext(void 0);function $u(){return Z.useContext(Qu)?.direction??`ltr`}var ed=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}=Ft(e,t)||{};if(l==null)return{};let d=mt(u),f={x:n,y:r},p=Et(i),m=ot(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=yt(D,k,O),j=!c.arrow&&rt(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}}}),td=(e,t)=>{let{name:n,fn:r}=ed(e);return{name:n,fn:r,options:[e,t]}},nd={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}}}},rd={sideX:`left`,sideY:`top`},id=`--available-width`,ad=`--available-height`,od=`--anchor-width`,sd=`--anchor-height`,cd=`--transform-origin`,ld=id,ud=ad;function dd(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 fd(e,t,n){let{rects:r,placement:i}=e;return{side:dd(t,qe(i),n),align:rt(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function pd(e){return md(e,Zu)}function md(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:p=!1,inline:m,keepMounted:h=!1,floatingRootContext:g,mounted:_,collisionAvoidance:v,shift:y,nodeId:b,adaptiveOrigin:x,lazyFlip:S=!1,externalTree:C}=e,w=v.side||`flip`,T=v.align||`flip`,E=v.fallbackAxisSide||`end`,O=y?.crossAxis??!1,k=y?.rootBoundary,j=typeof n==`function`?n:void 0,M=D(j),N=j?M:n,ee=lc(n),P=lc(_),F=$u()===`rtl`,[I,te]=Z.useState(null);!_&&I!==null&&te(null);let ne=S===`placement`,L=I?qe(I):null,re=I&&ne?rt(I)||`center`:null,ie=L||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":F?`left`:`right`,"inline-start":F?`right`:`left`}[i],ae=re||o,oe=ae===`center`?ie:`${ie}-${ae}`,R=l;typeof R==`number`?R={top:R,right:R,bottom:R,left:R}:R&&={top:R.top||0,right:R.right||0,bottom:R.bottom||0,left:R.left||0};let z=+(i===`bottom`),se=+(i===`top`),B=+(i===`right`),ce=+(i===`left`),le={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:R},ue=Z.useRef(null),de=lc(a),fe=lc(s),pe=typeof a==`function`?0:a,me=typeof s==`function`?0:s,he=[];m&&he.push(m),he.push(Ku(e=>{let t=fd(e,i,F),n=typeof de.current==`function`?de.current(t):de.current,r=typeof fe.current==`function`?fe.current(t):fe.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[pe,me,F,i]));let ge=T===`none`&&w!==`shift`,_e=!ge&&(u||O||w===`shift`),ve=w===`none`?null:Yu({...le,padding:{top:R.top+1+z,right:R.right+1+ce,bottom:R.bottom+1+se,left:R.left+1+B},mainAxis:!O&&w===`flip`,crossAxis:T===`flip`&&`alignment`,fallbackAxisSideDirection:E}),ye=ge?null:qu({...le,rootBoundary:k,mainAxis:T!==`none`,crossAxis:_e,limiter:u||O?void 0:Ju(e=>{if(!ue.current)return{};let{width:t,height:n}=ue.current.getBoundingClientRect(),r=nn(qe(e.placement)),i=r===`y`?t:n,a=r===`y`?R.left+R.right:R.top+R.bottom;return{offset:i/2+a/2}})},[le,u,O,k,R,T]);w===`shift`||T===`shift`||ae===`center`?he.push(ye,ve):he.push(ve,ye),he.push(Xu({...le,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!P.current)return;let i=e.style;i.setProperty(ld,`${t}px`),i.setProperty(ud,`${n}px`);let a=A(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(od,`${u}px`),i.setProperty(sd,`${d}px`)}}),td(e=>({element:ue.current||f(e.elements.floating).createElement(`div`),padding:ue.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=qe(r),u=rt(r),d=nn(l)===`y`,f=ue.current,p=typeof a==`function`?a(fd(e,i,F)):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 _e&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(cd,d?`${m} ${h}`:`${h} ${m}`),{}}},nd,x),V(()=>{!_&&g&&g.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[_,g]);let be=Z.useMemo(()=>({ancestorScroll:!p,elementResize:!p&&typeof ResizeObserver<`u`,layoutShift:!p&&typeof IntersectionObserver<`u`}),[p]),{refs:xe,elements:Se,x:Ce,y:we,middlewareData:Te,update:H,placement:Ee,context:De,isPositioned:U,floatingStyles:Oe}=t({rootContext:g,open:h?_:void 0,placement:oe,middleware:he,strategy:r,whileElementsMounted:h?void 0:(...e)=>Nu(...e,be),nodeId:b,externalTree:C}),{sideX:ke,sideY:Ae}=Te.adaptiveOrigin||rd,je=U?r:`fixed`,Me=Z.useMemo(()=>{let e;return e=U?x?{position:je,[ke]:Ce,[Ae]:we}:{...Oe,position:je}:{position:je,top:0,left:0},e[ld]=`100vw`,e[ud]=`100vh`,U||(e.opacity=0),e},[x,je,ke,Ce,Ae,we,Oe,U]),Ne=Z.useRef(null);V(()=>{if(!_)return;let e=ee.current,t=typeof e==`function`?e():e,n=(hd(t)?t.current:t)||null;n!==Ne.current&&(xe.setPositionReference(n),Ne.current=n)},[_,xe,N,ee]),Z.useEffect(()=>{if(!_)return;let e=ee.current;typeof e!=`function`&&hd(e)&&e.current!==Ne.current&&(xe.setPositionReference(e.current),Ne.current=e.current)},[_,xe,N,ee]),Z.useEffect(()=>{if(h&&_&&Se.reference&&Se.floating)return Nu(Se.reference,Se.floating,H,be)},[h,_,Se,H,be]);let Pe=qe(Ee),Fe=dd(i,Pe,F),Ie=rt(Ee)||`center`,Le=!!Te.hide?.referenceHidden;V(()=>{S&&_&&U&&(Pe!==ie||ne&&Ie!==ae)&&te(Ee)},[S,ne,_,U,Ee,Pe,Ie,ie,ae]);let Re=Z.useMemo(()=>({position:`absolute`,top:Te.arrow?.y,left:Te.arrow?.x}),[Te.arrow]),ze=Te.arrow?.centerOffset!==0;return Z.useMemo(()=>({positionerStyles:Me,arrowStyles:Re,arrowRef:ue,arrowUncentered:ze,side:Fe,align:Ie,physicalSide:Pe,anchorHidden:Le,refs:xe,context:De,isPositioned:U,update:H}),[Me,Re,ue,ze,Fe,Ie,Pe,Le,xe,De,U,H])}function hd(e){return e!=null&&`current`in e}function gd(e){return e===`starting`?d:Ee}function _d(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),v(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},gd(r),i],stateAttributesMapping:ic})}var vd=e(s(),1);function yd(e){let t=vd.unstable_scheduleCallback(4,e);return()=>vd.unstable_cancelCallback(t)}var bd=Z.createContext(Br({scheduleTask:yd,defaultIdleTTL:400})),xd=new WeakMap,Sd=0,Cd=new Set;function wd(e){Sd++;try{return e()}finally{Sd--}}function Td(e){if(Sd===0)return e();Cd.size===0&&queueMicrotask(Ed),Cd.add(e)}function Ed(){for(let e of Cd)Cd.delete(e),e()}function Dd(e,t){let n=xd.get(e);n===void 0&&(n=new WeakMap,xd.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,()=>Td(n));return()=>{i--,Cd.delete(n),r()}},snapshot(){return wd(()=>e.get(t))},getServerSnapshot(){return(i===0||a===void 0)&&(a={value:wd(()=>us(t,e))}),a.value}};return n.set(t,o),o}function Od(e,t){let n=Dd(e,t);return Z.useEffect(Ed),Z.useSyncExternalStore(n.subscribe,n.snapshot,n.getServerSnapshot)}function kd(e,t,n){let r=Dd(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(Ed),Z.useSyncExternalStore(r.subscribe,()=>i(r.snapshot()),()=>i(r.getServerSnapshot()))}var Ad=(e,t)=>{let n=Z.useContext(bd);return t?kd(n,e,t):Od(n,e)};function jd(e,t){Z.useEffect(()=>e.mount(t),[t,e])}function Md(e,t,n){return n?.mode===`promise`||n?.mode===`promiseExit`?Z.useCallback(r=>{e.set(t,r);let i=bs(kr(e,t,{suspendOnWaiting:!0}));return n.mode===`promise`?i.then(Nd):i},[e,t,n.mode]):Z.useCallback(n=>{e.set(t,typeof n==`function`?n(e.get(t)):n)},[e,t])}var Nd=e=>{if(Wa(e))return e.value;throw mr(e.cause)},Pd=e=>{jd(Z.useContext(bd),e)},Fd=(e,t)=>{let n=Z.useContext(bd);return jd(n,e),Md(n,e,t)},Id=(e,t)=>{let n=Z.useContext(bd);return[Od(n,e),Md(n,e,t)]},Ld={suspendOnWaiting:new WeakMap,default:new WeakMap};function Rd(e,t,n){let r=n?Ld.suspendOnWaiting:Ld.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 zd(e,t,n){let r=Od(e,t);if(r._tag===`Initial`||n&&r.waiting)throw Rd(e,t,n);return r}var Bd=(e,t)=>{let n=zd(Z.useContext(bd),e,t?.suspendOnWaiting??!1);if(n._tag===`Failure`&&!t?.includeFailure)throw mr(n.cause);return n};Eo(`MachineSchemaEncodeError`);var Vd=class extends Eo(`MachineSchemaDecodeError`){},Hd=class extends Eo(`InfiniteTransitionError`){},Ud=class extends Eo(`StartupError`){},Wd=class extends Eo(`ChildAlreadyExistsError`){};Eo(`ProcessLocalError`);var Gd=class extends Eo(`StoppedError`){},Kd=e=>e instanceof Hd||e instanceof Vd,qd=e=>Kd(e)?Go(e):Jr(e),Jd=e=>Kd(e)||e instanceof Ud?e:new Ud({cause:ar(e)}),Yd=e=>e,Xd=`~effect/Machine/Target`,Zd=Symbol(`effect/Machine/TargetSnapshot`),Qd=Symbol(`effect/Machine/StateInput`),$d=Symbol(`effect/Machine/HistoryTarget`),ef=Symbol(`effect/Machine/InitialTarget`),tf=Symbol(`effect/Machine/ChoiceTarget`),nf=Symbol(`effect/Machine/NoTarget`),rf=Symbol(`effect/Machine/Declined`),af=Symbol(`effect/Machine/TargetSelection`),of=Symbol(`effect/Machine/StateUpdate`),sf=Symbol(`effect/Machine/CombinedTarget`),cf=Symbol(`effect/Machine/SelectedBranch`),lf=(e,t,n,r)=>Object.freeze({[af]:af,kind:e,scope:n,path:t,...r===void 0?{}:{updatePath:r}}),uf=lf(`none`,void 0,`local`),df=e=>wi(e,af),ff=(e,t)=>Object.freeze({[of]:of,path:e,value:t}),pf=e=>wi(e,of),mf=(e,t)=>Object.freeze({[sf]:sf,target:e,update:t}),hf=e=>wi(e,sf),gf=(e,t,n,r)=>Object.freeze({[cf]:cf,owner:e,branchIndex:t,branchKey:n,result:r}),_f=e=>wi(e,cf),vf=Object.freeze({[nf]:nf}),yf=()=>vf,bf=e=>wi(e,nf),xf=Object.freeze({[rf]:rf}),Sf=()=>xf,Cf=e=>wi(e,rf),wf=(e,t)=>({[$d]:$d,path:e,parent:t}),Tf=e=>wi(e,$d),Ef=(e,t,n)=>({[ef]:ef,_tag:`InitialTarget`,path:e,value:t,...n===void 0?{}:{values:n}}),Df=e=>wi(e,ef),Of=(e,t,n)=>({[tf]:tf,path:e,parent:t,...n===void 0?{}:{values:n}}),kf=e=>wi(e,tf),Af=(e,t)=>{if(!Si(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(!Si(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(Si(t))return{schema:t,output:void 0,annotations:ko(t),type:`atomic`,history:void 0,initial:void 0,states:void 0};let n=wi(t,`schema`)&&Si(t.schema)?t.schema:void 0,r=n===void 0?t.annotations:ko(n);if(t.type===`parallel`&&!wi(t,`states`))throw Error(`Machine.make expected parallel state "${e}" to declare child regions`);if(wi(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:Si(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=Si(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}},jf=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=Af(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)}},Mf=e=>typeof e==`object`&&e&&`branches`in e&&Array.isArray(e.branches)?Array.from(e.branches):[],Nf=e=>typeof e==`object`&&e&&`declinable`in e&&e.declinable===!0?`declinable`:`required`,Pf=e=>{let t=[];for(let n of e.stateNodes.byPath.values()){let r=Yd(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:Mf(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:wi(i,`reenter`)&&i.reenter===!0,acceptance:Nf(i),branches:Mf(i)})}r.always!==void 0&&t.push({source:n.path,trigger:{type:`always`},reenter:!1,acceptance:Nf(r.always),branches:Mf(r.always)}),r.onDone!==void 0&&t.push({source:n.path,trigger:{type:`done`},reenter:!1,acceptance:Nf(r.onDone),branches:Mf(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:Nf(a),branches:Mf(a)})}}}return t},Ff=(e,t,n)=>({[Xd]:Xd,[Zd]:n?.snapshot,path:e,value:t,values:n?.values}),If=e=>wi(e,Xd),Lf=e=>({[Qd]:Qd,input:e}),Rf=e=>wi(e,Qd),zf=e=>wi(e,`path`)&&wi(e,`value`),Bf=(e,t,n)=>{if(e.path===t)return ir(e);if(e.path!==``&&!t.startsWith(`${e.path}.`))return Vr();if(n!==void 0&&e.value!==void 0&&(n[e.path]=e.value),wi(e,`state`)&&zf(e.state))return Bf(e.state,t,n);if(wi(e,`states`)&&typeof e.states==`object`&&e.states!==null){for(let r of Object.values(e.states))if(zf(r)){let e=Bf(r,t,n);if(Ua(e))return e}}return Vr()},$=(e,t)=>{let n=e.stateNodes.byPath.get(t);if(n===void 0)throw Error(`Machine expected state path "${t}" to exist`);return n},Vf=e=>{if(e.schema===void 0)throw Error(`Machine state "${e.path}" has no value schema`);return e.schema},Hf=new WeakMap,Uf=Symbol(`effect/Machine/EventConstruction`),Wf=new WeakMap,Gf=new WeakMap,Kf=new WeakMap,qf=e=>{let t=e,n=Gf.get(t);if(n!==void 0)return n;let r=Pr(Ri(e));return Gf.set(t,r),r},Jf=e=>{let t=e,n=Kf.get(t);if(n!==void 0)return n;let r=Wr(Ri(e));return Kf.set(t,r),r},Yf=Symbol.for(`effect/Machine/protocol`),Xf=e=>{let t=e[Yf];if(t===void 0)throw Error(`Machine protocol is unavailable`);return t},Zf=(e,t)=>{Object.defineProperty(e,Yf,{value:t,enumerable:!1})},Qf=e=>{let t=new Set,n=e=>{let r=e;if(!t.has(r)&&(t.add(r),wi(e,`cases`)&&typeof e.cases==`object`&&e.cases!==null))for(let t of Object.values(e.cases))(typeof t==`object`&&t||typeof t==`function`)&&wi(t,`make`)&&n(t)};for(let t of e)n(t);return t},$f=(e,t)=>{let n=Hf.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},ep=e=>$f(e.events,`public`).schemas,tp=e=>$f(e.internalEvents,`internal`).schemas,np=e=>$f(e.emittedEvents,`emitted`).schemas,rp=e=>{let t=ep(e),n=tp(e),r=np(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:qa(a),emit:qa(r),eventConstructors:Qf(a),emissionConstructors:Qf(r)})},ip=(e,t)=>Zf(t,Xf(e)),ap=e=>wi(e,`_tag`)?String(e._tag):void 0,op=(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={[Uf]:Uf,_tag:n};return Wf.set(o,{kind:e,schema:t,input:i,...a===void 0?{}:{inputError:a}}),Object.freeze(o)},sp=e=>typeof e==`object`&&!!e&&Wf.has(e),cp=(e,t)=>{let n=[],r=e=>{if(wi(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(wi(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),a=e=>Xr(e)?typeof e.literal==`string`||typeof e.literal==`number`?[e.literal]:[]:Ro(e)?[e.symbol]:Wi(e)?e.enums.map(([,e])=>e):vo(e)?e.types.flatMap(a):No(e)?a(e.thunk()):[],o=e=>{let t=ca(e.ast);if(va(t)){let e=t.propertySignatures.find(({name:e})=>e===`_tag`),n=e===void 0?[]:a(e.type);if(n.length>0)return n}try{return qa([e]).pipe(fr(`_tag`)).discriminants}catch{return[]}};for(let t of n){let n=o(t);if(n.length!==0)for(let r of n){if(wi(i,r))throw Error(`Duplicate machine event constructor tag: ${String(r)}`);Object.defineProperty(i,r,{value:(...n)=>op(e,t,r,n.length===0?{}:n[0]),enumerable:!0})}}return i},lp=(e,t)=>{let n=Object.freeze(Array.from(t)),r=cp(e,n);return Hf.set(r,{kind:e,schemas:n}),Object.freeze(r)},up=(e,t,n,r)=>qf(t)(n).pipe(wa(t=>new Vd({machineId:e.id,boundary:r.boundary,cause:t,...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}}))),dp=(e,t,n,r)=>{let i=Jf(t)(n);if(ds(i))throw new Vd({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},fp=(e,t,n,r)=>{try{return t.make(n)}catch(t){let n=t instanceof Error?t.cause:void 0;throw new Vd({machineId:e.id,boundary:r.boundary,cause:nr(t)?t:wi(n,`~effect/SchemaIssue/Issue`)?new fi(n):ar(t),...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}})}},pp=(e,t,n)=>new Vd({machineId:e.id,boundary:n,event:String(t._tag),cause:ar(Error(`Constructed ${n} schema does not belong to the machine ${n} protocol`))}),mp=(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}},hp=(e,t,n,r)=>new Vd({machineId:e.id,boundary:n,event:String(t._tag),cause:ar(r)}),gp=(e,t,n,r)=>{let i=Wf.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)?Go(pp(e,n,r)):Ka({try:()=>mp(n,i),catch:t=>hp(e,n,r,t)}).pipe(Po(t=>i.schema.makeEffect(t).pipe(wa(t=>new Vd({machineId:e.id,boundary:r,event:String(n._tag),cause:new fi(t)})))))},_p=(e,t,n,r)=>{let i=Wf.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 pp(e,n,r);let o;try{o=mp(n,i)}catch(t){throw hp(e,n,r,t)}return fp(e,i.schema,o,{boundary:r,event:String(n._tag)})},vp=(e,t)=>{let n=Xf(e);if(sp(t))return gp(e,n,t,`event`);let r=ap(t);return up(e,n.event,t,r===void 0?{boundary:`event`}:{boundary:`event`,event:r})},yp=(e,t)=>{let n=Xf(e);if(sp(t))return _p(e,n,t,`event`);let r=ap(t);return dp(e,n.event,t,r===void 0?{boundary:`event`}:{boundary:`event`,event:r})},bp=(e,t)=>{let n=Xf(e);if(sp(t))return gp(e,n,t,`emission`);let r=ap(t);return up(e,n.emit,t,r===void 0?{boundary:`emission`}:{boundary:`emission`,event:r})},xp=(e,t)=>{let n=Xf(e);if(sp(t))return _p(e,n,t,`emission`);let r=ap(t);return dp(e,n.emit,t,r===void 0?{boundary:`emission`}:{boundary:`emission`,event:r})},Sp=(e,t,n)=>dp(e,t,n,{boundary:`input`}),Cp=(e,t,n)=>Rf(n)?Vf(t).makeEffect(n.input).pipe(wa(n=>new Vd({machineId:e.id,boundary:`state`,state:t.path,cause:new fi(n)}))):up(e,Vf(t),n,{boundary:`state`,state:t.path}),wp=(e,t,n)=>Rf(n)?fp(e,Vf(t),n.input,{boundary:`state`,state:t.path}):dp(e,Vf(t),n,{boundary:`state`,state:t.path}),Tp=(e,t,n)=>t.output===void 0?di(n):up(e,t.output,n,{boundary:`output`,state:t.path}),Ep=(e,t,n)=>t.output===void 0?n:dp(e,t.output,n,{boundary:`output`,state:t.path}),Dp=(e,t)=>{let n=new Set(Lp(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)&&!Ip(r,t.parent))throw Error(`Machine history contains state "${r}" outside parent "${t.parent}"`);if(t.mode===`shallow`&&Fp(r,t.parent)&&$(e,r).parent!==t.parent)throw Error(`Machine shallow history contains deep descendant "${r}"`)}},Op=(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`||!(Ip(n,t.parent)||Lp(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,wp(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}),Dp(e,n.get(r))}return n},kp=Va(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*Go(new Vd({machineId:e.id,boundary:`history`,state:r,cause:ar(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`||!(Ip(n,t.parent)||Lp(e,t.parent).includes(n)))return yield*Go(new Vd({machineId:e.id,boundary:`history`,state:n,cause:ar(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*Go(new Vd({machineId:e.id,boundary:`history`,state:n,cause:ar(Error(`Machine snapshot contains a value for structural state "${n}"`))}))}else{if(!s)return yield*Go(new Vd({machineId:e.id,boundary:`history`,state:n,cause:ar(Error(`Machine snapshot omits remembered value for "${n}"`))}));o.set(n,yield*up(e,Vf(r),i.values[n],{boundary:`history`,state:n}))}}if(!a.has(t.parent)||Object.keys(i.values).length!==o.size)return yield*Go(new Vd({machineId:e.id,boundary:`history`,state:r,cause:ar(Error(`Machine snapshot contains incomplete history record "${r}"`))}));n.set(r,{mode:i.mode,parent:t.parent,active:a,values:o});try{Dp(e,n.get(r))}catch(t){return yield*Go(new Vd({machineId:e.id,boundary:`history`,state:r,cause:ar(t)}))}}return n}),Ap=(e,t)=>{let n={};for(let[r,i]of t){let t=Array.from(i.active).sort((t,n)=>zp(e,t,n));n[r]={mode:i.mode,active:t,values:Object.fromEntries(i.values)}}return n},jp=(e,t)=>({...e,machineReferences:{self:t.self,parent:t.parent}}),Mp=e=>e.machineReferences,Np=new WeakMap,Pp=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Fp=(e,t)=>e!==t&&(t===``||e.startsWith(`${t}.`)),Ip=(e,t)=>e===t||Fp(e,t),Lp=(e,t)=>{let n=Np.get(e.stateNodes);n===void 0&&(n=new Map,Np.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},Rp=(e,t)=>Lp(e,t).length,zp=(e,t,n)=>$(e,t).order-$(e,n).order,Bp=(e,t,n)=>$(e,n).children.some(e=>t.active.has(e)),Vp=(e,t)=>{let n=Array.from(t.active).filter(n=>!Bp(e,t,n)).sort((t,n)=>zp(e,t,n));if(n.length===0)throw Error(`Machine expected an active leaf state`);return n},Hp=(e,t)=>Vp(e,t)[0],Up=(e,t,n)=>{let r=Vp(e,t).filter(e=>Ip(e,n));if(r.length===0)throw Error(`Machine expected state "${n}" to have an active leaf state`);return r[0]},Wp=(e,t)=>{for(let n of t.active)if($(e,n).parent===void 0)return n;throw Error(`Machine expected an active root state`)},Gp=(e,t,n)=>{let r={},i=Lp(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},Kp=(e,t,n)=>{let r=$(e,n).parent;return r===void 0?void 0:t.values.get(r)},qp=(e,t)=>{let n=r=>t.active.has(r)?[r,...$(e,r).children.flatMap(n)]:[];return e.stateNodes.roots.flatMap(n)},Jp=(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=Jp(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]=Jp(e,t,i)}i.states=a}return i},Yp=(e,t)=>{let n=Jp(e,t,Wp(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:Ap(e,t.history)}),n},Xp=(e,t,n)=>{let r=Jp(e,t,n);return t.history.size>0&&Object.assign(r,{history:Ap(e,t.history)}),r},Zp=(e,t,n)=>{if(!wi(n,`state`)||!zf(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},Qp=(e,t)=>{if(!wi(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},$p=(e,t,n,r)=>{let i=$(e,n),a=r[i.key];if(!Pp(r,i.key)||!zf(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},em=(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,wp(e,i,t.value));if(i.type===`compound`&&a(Zp(e,i,t)),i.type===`parallel`){let n=Qp(i,t);for(let t of i.children)a($p(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:Op(e,t)}},tm=(e,t)=>em(e,t),nm=(e,t)=>{try{return em(e,t)}catch(t){throw t instanceof Vd?t:new Vd({machineId:e.id,boundary:`configuration`,cause:ar(t)})}},rm=Va(function*(e,t){let n=new Set,r=new Map,i=t.completed,a=Va(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*Cp(e,i,t.value));if(i.type===`compound`&&(yield*a(Zp(e,i,t))),i.type===`parallel`){let n=Qp(i,t);for(let t of i.children)yield*a($p(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*kp(e,t)}}),im=(e,t)=>rm(e,t).pipe(ur(t=>{if(ws(t))return mo(Ti(t,t=>t instanceof Vd?t:new Vd({machineId:e.id,boundary:`configuration`,cause:br(t)})));let n=Zr(t);return Ua(n)&&n.value instanceof Vd?Go(n.value):Go(new Vd({machineId:e.id,boundary:`configuration`,cause:t}))})),am=(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 Lp(e,n.parent))t.active.has(r)&&o.add(r);for(let i of t.active)(i===n.parent||r===`deep`&&Fp(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}},om=(e,t)=>e.history.get(t),sm=(e,t,n)=>{let r=new Set(n.active),i=new Map(n.values),a=new Map,o=Lp(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)Ip(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}};Va(function*(e,t,n,r,i){let a=$(e,n),o=new Set,s=new Map,c=new Map,l=Lp(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&&Pp(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*Cp(e,c,r));else if(i!==void 0&&Pp(i,n))s.set(n,yield*Cp(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)Ip(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}}),Va(function*(e,t,n,r){let i=yield*rm(e,n),a=new Set(i.active),o=new Map(i.values),s=new Map(i.outputs),c=Lp(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&&Pp(r,i))throw Error(`Machine structural target "${i}" cannot contain a value`)}else if(r!==void 0&&Pp(r,i))o.set(i,yield*Cp(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)Ip(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&&Pp(r,n))for(let[t,i]of Object.entries(r)){if(!Ip(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*Cp(e,r,i))}}}}return{active:a,values:o,outputs:s,history:new Map([...t.history,...i.history])}});var cm=(e,t,n,r,i,a=!1)=>{let o=$(e,n),s=new Set,c=new Map,l=new Map,u=Lp(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&&Pp(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,wp(e,a,r));else if(i!==void 0&&Pp(i,n))c.set(n,wp(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)Ip(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}},lm=(e,t,n)=>{let r=cm(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,wp(e,n,r))}return{...r,active:i,values:a}},um=(e,t,n,r)=>{let i=em(e,n),a=new Set(i.active),o=new Map(i.values),s=new Map(i.outputs),c=Lp(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&&Pp(r,i))throw Error(`Machine structural target "${i}" cannot contain a value`)}else if(r!==void 0&&Pp(r,i))o.set(i,wp(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)Ip(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&&Pp(r,n))for(let[t,i]of Object.entries(r)){if(!Ip(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,wp(e,r,i))}}}}return{active:a,values:o,outputs:s,history:new Map([...t.history,...i.history])}},dm=(e,t,n)=>{if(If(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 um(e,t,r,n.values)}return cm(e,t,n.path,n.value,n.values)}if(zf(n)){let r=nm(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`)},fm=(e,t)=>Yd(e).handlers[t],pm=(e,t,n)=>$(e,n).children.find(e=>t.active.has(e)),mm=(e,t)=>$(e,t).type===`final`,hm=(e,t)=>fm(e,t)?.onDone!==void 0,gm=(e,t,n)=>{if(!t.active.has(n))return!1;let r=$(e,n);if(r.type===`compound`){let r=pm(e,t,n);return r!==void 0&&(n===``?!hm(e,r)&&gm(e,t,r):mm(e,r))}if(r.type===`parallel`){for(let n of r.children)if(!gm(e,t,n))return!1;return!0}return mm(e,n)},_m=(e,t)=>{let n=Wp(e,t);return gm(e,t,n)&&!hm(e,n)},vm=(e,t,n)=>e.has(t)?{path:t,output:e.get(t),isNew:!1}:(e.set(t,n),{path:t,output:n,isNew:!0}),ym=Va(function*(e,t,n,r,i){let a=$(e,n),o=fm(e,n)?.output?.({state:t.values.get(n),containingState:Kp(e,t,n),ancestors:Gp(e,t,n),event:r,outputs:i});return yield*Tp(e,a,o)}),bm=Va(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=pm(e,t,n);if(o===void 0||(n===``?hm(e,o):!mm(e,o)))return;let s=yield*bm(e,t,o,r,i,a);if(s===void 0)return;let c=vm(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*bm(e,t,n,r,i,a);o===void 0?c=!1:s[$(e,n).key]=o.output}if(!c)return;let l=vm(i,n,yield*ym(e,t,n,r,s));return l.isNew&&a.push(l),l}if(!mm(e,n))return;let s=vm(i,n,yield*ym(e,t,n,r));return s.isNew&&a.push(s),s}),xm=Va(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=Rp(e,n)-Rp(e,t);return r===0?zp(e,t,n):r}))yield*bm(e,a,t,n,r,i);return{configuration:a,completions:i}}),Sm=(e,t,n,r,i)=>{let a=$(e,n),o=fm(e,n)?.output?.({state:t.values.get(n),containingState:Kp(e,t,n),ancestors:Gp(e,t,n),event:r,outputs:i});return Ep(e,a,o)},Cm=(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=pm(e,t,n);if(o===void 0||(n===``?hm(e,o):!mm(e,o)))return;let s=Cm(e,t,o,r,i,a);if(s===void 0)return;let c=vm(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=Cm(e,t,n,r,i,a);o===void 0?c=!1:s[$(e,n).key]=o.output}if(!c)return;let l=vm(i,n,Sm(e,t,n,r,s));return l.isNew&&a.push(l),l}if(!mm(e,n))return;let s=vm(i,n,Sm(e,t,n,r));return s.isNew&&a.push(s),s},wm=(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=Rp(e,n)-Rp(e,t);return r===0?zp(e,t,n):r}))Cm(e,a,t,n,r,i);return{configuration:a,completions:i}},Tm=e=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine construction must be an object`);return e},Em=(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 Lf(Object.hasOwn(t,`data`)?t.data:{})}},Dm=(e,t,n={},r)=>{let i=e.byPath.get(t);if(i?.type===`atomic`||i?.type===`final`){let e=Tm(n);if(Reflect.ownKeys(e).some(e=>e!==`data`&&e!==`decoded`))throw Error(`Machine leaf construction accepts only data and decoded`);return Ff(t,Em(i,e))}let a=new Map,o=(t,n)=>{let i=Tm(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=Em(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=Tm(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=Tm(n);for(;u.states!==void 0;){let t=e.byPath.get(l),n=Tm(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=Tm(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 Of(l,d.parent??``,p);if(d.type===`atomic`||d.type===`final`)return Ff(l,f,{values:p});let m=new Map([...a].filter(([e])=>e.startsWith(`${l}.`)));return{...Ef(l,f,p),...m.size===0?{}:{children:m}}},Om=(e,t,n)=>{let r=Tm(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 ff(t,Em(i,r))},km=(e,t,n=``)=>{let r=Tm(t),i=e.byPath.get(n);Dm(e,n,r);let a=Em(i,r);if(i.type===`choice`)return Of(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=Tm(r.states),s=Object.fromEntries(Object.entries(o).map(([t,r])=>[t,km(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]}},Am=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(t);return e},jm=`root`,Mm=e=>{let t=new Map,n=(e,r)=>{let i=!Si(e)&&`type`in e?e.type:void 0;if(t.set(r,i===`history`||i===`choice`?i:`state`),!Si(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 "${jm}" is reserved for the root`);return t},Nm=(e,t)=>{let n=Mm(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(Am(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(Am(t.branches,`Machine branches must be a map`))){let t=Am(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={...Am(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 Fm({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}},Pm=(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}},Fm=(e,t)=>{let n=[`target`,`history`,`none`,`initialize`].filter(e=>t[e]!==void 0);if(n.length===0&&t.update!==void 0){let n=Pm(t.update,e);if(n.kind!==`state`)throw Error(`Machine update requires an active state reference`);return lf(`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 uf}if(r===`initialize`){if(t.update!==void 0)throw Error(`Machine initialize cannot update a retained owner`);return lf(`state`,``,`branch`)}let i=Pm(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:Pm(t.update,e).path;if(a!==void 0&&r!==`target`)throw Error(`Machine owner updates require an ordinary destination`);return lf(i.kind,i.path,r===`history`?`full`:`branch`,a)},Im=(e,t,n,r)=>{let i=Am(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`&&Xo(a.value))&&!(a.kind===`streams`&&ia(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}},Lm=Symbol(`effect/Machine/InitialEvent`),Rm=Symbol(`effect/Machine/SnapshotBuilderState`),zm=Symbol(`effect/Machine/ChildMachineLogic`),Bm=new WeakSet,Vm=e=>Bm.has(e),Hm=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine ${t} must be an object`);return e},Um=e=>typeof e==`function`?e:()=>e,Wm=e=>{if(typeof e==`object`&&e&&wi(e,`decoded`)&&e.decoded===!0&&wi(e,`data`)){let t=Hm(e,`decoded construction`);if(Reflect.ownKeys(t).some(e=>e!==`decoded`&&e!==`data`))throw Error(`Machine decoded construction accepts only decoded and data`);return Um(t.data)}let t=Um(e);return n=>Lf(e===void 0?{}:t(n))},Gm=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(!wi(e,`data`))throw Error(`Machine decoded construction requires data`);return Um(e.data)}let t=Um(e.data);return n=>Lf(wi(e,`data`)?t(n):{})},Km=(e,t)=>{let n=(e,t,r)=>{if(wi(t,`initialize`))throw Error(`Machine child construction belongs in initial declarations`);if(r!==``&&wi(t,`root`))throw Error(`Machine root construction belongs at the root handler`);let{initial:i,root:a,states:o,...s}=t;if(Si(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?{}:Hm(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?{}:Hm(i,`parallel initial regions`);for(let[n,r]of Object.entries(t)){let t=e.states[n];if(t===void 0||!Si(t)&&(t.type===`history`||t.type===`choice`))throw Error(`Machine invalid initial region "${n}"`);if(!Si(t)&&(!(`schema`in t)||t.schema===void 0))throw Error(`Machine schema-less region "${n}" cannot construct data`);d[n]=Wm(r)}}else{let t=Hm(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||Si(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`&&(wi(t,`data`)||wi(t,`decoded`)))throw Error(`Machine choice initial edges cannot construct data`);let c=Gm(t),l=e.states[a];if(wi(t,`data`)&&!Si(l)&&(!(`schema`in l)||l.schema===void 0))throw Error(`Machine schema-less initial child "${a}" cannot construct data`);wi(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?{}:Hm(c[t],`state handler`),e);l[t]=a.node,(Si(i)||i.type!==`history`)&&(c[t]!==void 0||!Si(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{[Rm]:i}};return Bm.add(g),{node:m,handlers:{...s,...h.length===0?{}:{initialize:g},states:u}}};return n(e.node,t,``)},qm=(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)},Jm=e=>`child`in e?e.child.id:e.id,Ym=(e,t)=>{let n=new Set;for(let r of e){let e=Jm(r);if(n.has(e))throw Error(`Machine invocations for state "${t}" must have distinct ids; "${e}" is declared twice`);n.add(e)}},Xm=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(yp(e,t))},emit:t=>{r.push(xp(e,t))},sendTo:(e,n)=>{t.push({_tag:`SendTo`,target:e,event:n})},stop:e=>{t.push({_tag:`Stop`,child:e})}}}},Qm=(e,t)=>{let n=e.stateNodes.byPath.get(t);if(n===void 0)throw Error(`Machine expected state path "${t}" to exist`);return n},$m=e=>{let t={};return Object.defineProperty(t,"decoded",{value:e,enumerable:!1}),Object.defineProperty(t,"from",{value:(...t)=>e(Lf(t.length===0?{}:t[0])),enumerable:!1}),t},eh=e=>{let t={};return Object.defineProperty(t,Rm,{value:e,enumerable:!1}),t},th=(e,t,n)=>{let r=eh(n);for(let i of t.children){let a=Qm(e,i);a.schema===void 0||wi(n,a.key)||(r[a.key]=$m(r=>{let i=Object.assign({},n);return i[a.key]=r,th(e,t,i)}))}return r},nh=(e,t)=>{let n=Qm(e,t);if(n.type===`parallel`)return th(e,n,{});if(n.type!==`compound`)throw Error(`Machine state "${t}" cannot initialize child states`);let r=Qm(e,n.initial);if(r.schema===void 0)throw Error(`Machine state "${t}" has no schema-valued initial child`);return $m(e=>eh({[r.key]:e}))},rh=(e,t)=>{if(typeof t!=`object`||!t||!wi(t,Rm))throw Error(`Machine initialize handler for "${e}" must return its builder result`);return t[Rm]},ih=Symbol(`effect/Machine/InvocationEvent`),ah=(e,t,n)=>({[ih]:!0,path:e,id:t,type:`done`,output:n}),oh=(e,t,n)=>({[ih]:!0,path:e,id:t,type:`element`,element:n}),sh=(e,t,n)=>({[ih]:!0,path:e,id:t,type:`failure`,error:n}),ch=(e,t,n)=>({[ih]:!0,path:e,id:t,type:`snapshot`,snapshot:n}),lh=e=>typeof e==`object`&&!!e&&ih in e,uh=new WeakMap,dh=new WeakMap,fh=(e,t)=>e.parent===void 0?{self:t.self}:{self:t.self,parent:t.parent},ph=(e,t)=>{let n=Object.create(e);return dh.set(n,fh(e,t)),n},mh=(e,t)=>{let n=t.machineReferences;if(n!==void 0)return fh(e,n);let r=dh.get(e);if(r!==void 0)return r;let i=uh.get(e);if(i!==void 0)return i;let a=fh(e,{self:{id:e.id??`Machine`,sessionId:`Machine.plan`,send:()=>Go(new Gd)},parent:void 0});return uh.set(e,a),a},hh=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}},gh=(e,t,n)=>{let r=Zm(e);return t===void 0||t(n,r.enqueue),{commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents}},_h=(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 Cf(a.result)?{declined:!0}:{declined:!1,state:bf(a.result)?void 0:a.result,branchIndex:a.branchIndex,branchKey:a.branchKey,commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents}},vh=(e,t,n)=>{let r=Zm(e);return{value:t(n,r.enqueue),commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents}},yh=(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)=>zp(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=Yh(e,m,Of(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=Df(i)?xh(e,r,i,n):Tf(i)?Sh(e,r,i,n):void 0;r=dm(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=Yd(e).handlers[d]?.initialize;if(t===void 0){a.set(p.path,wp(e,p,Lf({}))),u=!0;continue}let i=vh(e,t,{...mh(e,m),state:m.values.get(d),containingState:Kp(e,m,d),ancestors:Gp(e,m,d),event:n,...d===``&&r!==void 0?{input:r.value}:{},...Vm(t)?{}:{builder:nh(e,d)}}),l=rh(d,i.value);a.set(p.path,wp(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:Yd(e).handlers[d]?.initialize,h=m===void 0?void 0:vh(e,m,{...mh(e,p),state:p.values.get(d),containingState:Kp(e,p,d),ancestors:Gp(e,p,d),event:n,...d===``&&r!==void 0?{input:r.value}:{},...Vm(m)?{}:{builder:nh(e,d)}}),g=h===void 0?void 0:rh(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,wp(e,n,Lf({})));continue}if(g===void 0||!Object.prototype.hasOwnProperty.call(g,n.key)){if(m!==void 0&&Vm(m)){a.set(n.path,wp(e,n,Lf({})));continue}throw Error(`Machine parallel state initializer for "${d}" must return region "${n.key}"`)}a.set(n.path,wp(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 bh(e,t,n,r){let i=lm(e,t,n);if(n.children===void 0||![...n.children.keys()].some(t=>$(e,t).type===`choice`))return yh(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=Yh(e,i,Of(t,n.parent),r);for(let t of[l.target,...l.additionalTargets]){let n=Df(t)?xh(e,i,t,r):Tf(t)?Sh(e,i,t,r):void 0;i=dm(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=yh(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 xh(e,t,n,r){let i=bh(e,t,n,r),a=Xp(e,i.configuration,n.path);return{target:Ff(n.path,a.value,{snapshot:a,values:n.values}),commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents,transitions:i.transitions}}function Sh(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=om(t,n.path);if(a!==void 0){let i=yh(e,sm(e,t,a),r),o=Xp(e,i.configuration,n.parent),s=Object.fromEntries(i.configuration.values);return n.parent!==``&&t.active.has(``)&&delete s[``],{target:Ff(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=Yd(e).handlers[n.parent]?.history?.[o]?.default;if(s===void 0)throw Error(`Machine history state "${n.path}" requires a default implementation`);let c=_h(e,s,{event:r,target:t=>km(e.stateNodes,t),owner:n.parent});if(c.state===void 0||Tf(c.state)||!zf(c.state))throw Error(`Machine history default for "${n.path}" must return a complete snapshot containing its owner`);let l=qh(c.state)===void 0?void 0:Yh(e,{active:new Set,values:new Map,outputs:new Map,history:t.history},c.state,r),u=l===void 0?nm(e,c.state):dm(e,{active:new Set,values:new Map,outputs:new Map,history:t.history},l.target);for(let t of l?.additionalTargets??[])u=dm(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=Xp(e,u,n.parent),f=Object.fromEntries(u.values);return n.parent!==``&&t.active.has(``)&&delete f[``],{target:Ff(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 Ch=(e,t)=>{if(!t.transition.declinable)return t;let n=_h(e,t.transition.transition,t.context,t.transition.evaluate);return n.declined?void 0:{...t,collected:n}},wh=(e,t)=>[...Lp(e,t)].reverse(),Th=(e,t,n)=>{let r=Lp(e,t),i=Lp(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},Eh=(e,t)=>{if(e!==void 0&&t!==void 0)return e===t||Fp(e,t)?t:e},Dh=(e,t,n)=>Ah(e,Array.from(t.active).filter(e=>n===void 0||Fp(e,n))),Oh=(e,t,n)=>jh(e,Array.from(t.active).filter(e=>n===void 0||Fp(e,n))),kh=(e,t)=>e.active.size===t.active.size&&Array.from(e.active).every(e=>t.active.has(e)),Ah=(e,t)=>Array.from(new Set(t)).sort((t,n)=>{let r=Lp(e,n).length-Lp(e,t).length;return r===0?$(e,n).order-$(e,t).order:r}),jh=(e,t)=>Array.from(new Set(t)).sort((t,n)=>{let r=Lp(e,t).length-Lp(e,n).length;return r===0?zp(e,t,n):r}),Mh=(e,t,n,r)=>({...mh(e,t),state:t.values.get(n),containingState:Kp(e,t,n),ancestors:Gp(e,t,n),event:r}),Nh=(e,t,n,r,i)=>({...mh(e,t),state:t.values.get(n),containingState:Kp(e,t,n),ancestors:Gp(e,t,n),event:r,snapshot:i}),Ph=(e,t,n,r,i,a)=>({...mh(e,t),state:t.values.get(n),containingState:Kp(e,t,n),ancestors:Gp(e,t,n),event:r,output:i,snapshot:a}),Fh=(e,t,n,r,i)=>{let a=[],o=[],s=[];for(let c of n){let n=gh(e,Yd(e).handlers[c]?.[i],Mh(e,t,c,r));a.push(...n.commands),o.push(...n.raisedEvents),s.push(...n.emittedEvents)}return{commands:a,emittedEvents:s,raisedEvents:o}},Ih=(e,t,n)=>{let r=[],i=new Set,a=new Map,o,s=()=>o??=Yp(e,t);for(let o of Vp(e,t))for(let c of wh(e,o)){let l=hh(Yd(e).handlers[c]?.always);if(l!==void 0){let u=a.get(c);if(a.has(c)||(u=Ch(e,{sourcePath:c,leafPath:o,trigger:{type:`always`},transition:l,context:{...mh(e,t),state:t.values.get(c),containingState:Kp(e,t,c),ancestors:Gp(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},Lh=(e,t,n,r)=>{let i=[],a=new Set,o,s=()=>o??=Yp(e,t);for(let o of r){let r=hh(Yd(e).handlers[o.path]?.onDone);if(r!==void 0&&!a.has(o.path)){a.add(o.path);let c=Ch(e,{sourcePath:o.path,leafPath:Up(e,t,o.path),trigger:{type:`done`},transition:r,context:Ph(e,t,o.path,n,o.output,s())});c!==void 0&&i.push(c)}}return i},Rh=(e,t,n)=>{let r=[],i=new Set,a=new Map,o,s=()=>o??=Yp(e,t);for(let o of Vp(e,t))for(let c of wh(e,o)){let l=hh(Yd(e).handlers[c]?.on?.[n._tag]);if(l!==void 0){let u=a.get(c);if(a.has(c)||(u=Ch(e,{sourcePath:c,leafPath:o,trigger:{type:`event`,event:n._tag},transition:l,context:Nh(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},zh=(e,t,n)=>{if(!t.active.has(n.path))return[];let r=Yd(e).handlers[n.path],i=Xm(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=hh(n.type===`element`?i.onElement:n.type===`done`?i.onDone:n.type===`failure`?i.onFailure:i.onSnapshot);if(a===void 0)return[];let o=Yp(e,t),s={...mh(e,t),state:t.values.get(n.path),containingState:Kp(e,t,n.path),ancestors:Gp(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=Ch(e,{sourcePath:n.path,leafPath:Up(e,t,n.path),trigger:{type:`invoke`,id:n.id,outcome:n.type},transition:a,context:s});return c===void 0?[]:[c]},Bh=e=>{if(Tf(e)||kf(e)||If(e)||zf(e))return String(e.path);throw Error(`Machine expected transition target to be a snapshot or target builder result`)},Vh=(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(`, `)}`)}},Hh=(e,t)=>{for(let n of e)if(t.includes(n))return!0;return!1},Uh=(e,t)=>Array.from(t).sort((t,n)=>zp(e,t.selection.sourcePath,n.selection.sourcePath)),Wh=e=>e.filter(t=>!e.some(e=>e.sourcePath!==t.sourcePath&&Fp(e.sourcePath,t.sourcePath))),Gh=(e,t)=>{let n=[];for(let r of Uh(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(Hh(r.exitPaths,i.exitPaths)||n){if(Fp(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},Kh=(e,t={})=>{let n={...t},r=[],i=e=>{if(kf(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:Of(e.path,e.parent,n),values:n}))},qh=(e,t={})=>Kh(e,t)[0],Jh=(e,t)=>{if(kf(e))return Of(e.path,e.parent,{...t,...e.values??{}});if(Df(e))return{...e,values:{...t,...e.values}};if(!If(e)||Object.keys(t).length===0)return e;let n=e[Zd];return Ff(e.path,e.value,{...n===void 0?{}:{snapshot:n},values:{...t,...e.values??{}}})};function Yh(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=Kh(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 Hd({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=Yd(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,wp(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=_h(e,p.transition,{...mh(e,h),containingState:Kp(e,h,f.path),ancestors:Gp(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`);Vh(f.path,{type:`choice`},p.targets,g.state);let _=Bh(g.state);n=Jh(g.state,d.values);let v=qh(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(!If(n)&&!zf(n)&&!Tf(n)&&!Df(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 Xh=(e,t,n)=>{let r=n.leafPath,i=n.collected??_h(e,n.transition.transition,n.context,n.transition.evaluate);if(i.declined)throw Error(`Machine transition returned decline without declaring declinable: true`);let a=hf(i.state)?i.state:void 0,o=a?.target??i.state,s=o===void 0||pf(o)?void 0:o;Vh(n.sourcePath,n.trigger,n.transition.targets,s);let c=a?.update??(pf(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:wp(e,n,c.value)}})(),u=l!==void 0&&(Df(s)||kf(s))?{...t,values:new Map(t.values).set(l.path,l.value)}:t,d=s===void 0?void 0:Yh(e,u,s,n.context.event),f=d?.target??s,p=f!==void 0&&Df(f)?xh(e,u,f,n.context.event):void 0,m=p?.target??f,h,g=Tf(m)&&n.transition.reenter&&t.active.has(m.parent)?m:void 0;if(m!==void 0&&Tf(m)){let i=n.transition.reenter?$(e,n.sourcePath).parent:Th(e,r,m.parent),a=g===void 0?Dh(e,t,i):Ah(e,Array.from(t.active).filter(e=>Ip(e,m.parent)));h=Sh(e,a.includes(m.parent)?am(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(Df(r)){let i=xh(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(!Tf(r)){S.push(r);continue}let i=Sh(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?Bh(_):Bh(s),w=_===void 0?l===void 0?t:{...t,values:new Map(t.values).set(l.path,l.value)}:dm(e,t,_);for(let t of S)w=dm(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||!kh(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:Th(e,r,C),O=$(e,n.sourcePath).parent,k=n.transition.reenter?Eh(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?Dh(e,t,k):Ah(e,Array.from(t.active).filter(e=>Ip(e,g.parent))),entryPaths:g===void 0?Oh(e,w,k):jh(e,Array.from(w.active).filter(e=>Ip(e,g.parent))),choiceTransitions:[...d?.transitions??[],...p?.transitions??[],...h?.transitions??[],...x]}},Zh=1e3,Qh={_tag:Lm},$h=(e,t)=>_m(e,tm(e,t)),eg=(e,t,n)=>im(e,t).pipe(Po(t=>xm(e,t,n)),Po(t=>{let n=Wp(e,t.configuration);return!_m(e,t.configuration)||!t.configuration.outputs.has(n)?Jr(Error(`Machine attempted to read terminal output from a non-terminal configuration`)):di(t.configuration.outputs.get(n))})),tg=(e,...t)=>{let n=e.input===void 0?t:t.length===0?(Sp(e,e.input,void 0),t):[Sp(e,e.input,t[0])],r=e.initial(...n),i={active:new Set,values:new Map,outputs:new Map,history:new Map},a=xh(e,i,r,Qh),o=dm(e,i,a.target),s=Yp(e,o),c=qp(e,o),l=a.commands,u=a.raisedEvents,d=a.emittedEvents,f=Fh(e,o,c,Qh,`entry`),p=rg(e,o,Qh,[...f.commands],[...u,...f.raisedEvents],[...d,...f.emittedEvents],a.transitions.length===0?[]:[{next:o,event:Qh,transitions:a.transitions,commands:l,raisedEvents:[...u],emittedEvents:d,exitPaths:[],entryPaths:[],changed:!1,stabilize:!1}]),m={startingState:s,initialEntryPaths:c,state:Yp(e,p.next),commands:[...l,...p.commands],emittedEvents:p.emittedEvents,microsteps:p.microsteps.map(t=>({next:Yp(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}},ng=(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=Wh(r),a=[];for(let n of i)a.push(Xh(e,t,n));let o=Gh(e,a),s=Uh(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:Bh(e.unresolvedTarget),resolvedTarget:e.target===void 0?void 0:Bh(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=dm(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=Ah(e,s.flatMap(e=>e.exitPaths)),_=jh(e,s.flatMap(e=>e.entryPaths));l=am(e,t,l,g);let v=Fh(e,t,g,n,`exit`),y=Fh(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}},rg=(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 Hd({machineId:e.id,state:String(Hp(e,s)),maxIterations:Zh});let t=wm(e,s,c);for(s=t.configuration,m.push(...t.completions.filter(t=>Yd(e).handlers[t.path]?.onDone!==void 0));m.length>0&&!s.active.has(m[0].path);)m.shift();let n=Lh(e,s,c,m.length===0?[]:[m.shift()]);if(n.length>0){let t=ng(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(_m(e,s)){let t=Wp(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?Ih(e,s,c):[];if(h.length>0){let t=ng(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=Rh(e,s,_);if(v.length===0){l=!0;continue}let y=ng(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}},ig=(e,t,n)=>{let r=lh(n)?n:yp(e,n);if(_m(e,t)){let n=wm(e,t,r),i=Wp(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=lh(r)?zh(e,t,r):Rh(e,t,r);if(i.length===0)return{event:r,next:t,commands:[],emittedEvents:[],microsteps:[],done:!1,output:void 0};let a=ng(e,t,r,i),o=[...a.commands],s=[...a.raisedEvents],c=[...a.emittedEvents],l=[a];return{...rg(e,a.next,r,o,s,c,l),event:r}},ag=(e,...t)=>Ka({try:()=>tg(e,...t),catch:Jd}),og=(e,t)=>({raise:n=>vp(e,n).pipe(Po(e=>t.sendTo(t.self,e))),emit:n=>bp(e,n).pipe(Po(e=>t.emit(e)))}),sg=(e,t)=>ea(e,e=>e._tag===`SendTo`?t.sendTo(e.target,e.event):t.stopChild(e.child),{discard:!0}),cg=(e,t)=>er(Array.from(e,e=>t.emit(e)),{discard:!0}),lg=new WeakMap,ug=e=>{let t=lg.get(e);if(t!==void 0)return t;let n={self:{id:e.id??`Machine`,sessionId:`Machine.plan`,send:()=>Go(new Gd)},parent:void 0};return lg.set(e,n),n},dg=(e,t)=>{let n=t===void 0?ug(e):t;return e.parent===void 0?{self:n.self}:{self:n.self,parent:n.parent}},fg=new Set([`initialize`,`invoke`,`on`,`output`]),pg=e=>{if(e===void 0)return!0;for(let t of Reflect.ownKeys(e))if(!fg.has(t))return!1;return!0},mg=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=Yd(e).handlers[a.path];if(!pg(o))return;if(o?.on===void 0)continue;let s=new Map;for(let e of Reflect.ownKeys(o.on)){let t=hh(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)=>zp(e,t,n)),r.sort((t,n)=>zp(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=>Lp(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&&(Yd(e).handlers[``]===void 0||Reflect.ownKeys(Yd(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}},hg=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()}),gg=(e,t)=>t?{...e,next:hg(e.next)}:e,_g=(e,t,n)=>{e.values[t]=n},vg=(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}},yg=(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}},bg=(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=bg(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]=bg(e,t,i)}i.states=a}return i},xg=(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=bg(e,t,n);return t.completedOrder.length>0&&(r.completed=t.completedOrder.map(n=>({path:e.nodes[n].path,output:t.outputs[n]}))),r},Sg=(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{...dg(e,a),state:n.values[r],containingState:o<0?void 0:n.values[o],ancestors:s,event:i,snapshot:xg(t,n)}},Cg=Object.freeze([]),wg=(e,t,n,r)=>{let i,a,o,s={raise:t=>{(a??=[]).push(yp(e,t))},emit:t=>{(o??=[]).push(xp(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:bf(c.result)?void 0:c.result,branchIndex:c.branchIndex,branchKey:c.branchKey,commands:i??Cg,raisedEvents:a??Cg,emittedEvents:o??Cg}},Tg=(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:Sg(e,t,n,c,r,i)})}}}return a},Eg=(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},Dg=(e,t,n,r,i)=>{if((If(r)?t.indexByPath.get(String(r.path)):void 0)===i&&n.active[i]===1&&If(r)&&r[Zd]===void 0&&r.values===void 0&&n.completedOrder.length===0&&t.valued[i]){let a=n.values.slice();return a[i]=wp(e,t.nodes[i],r.value),{...n,values:a}}return vg(t,dm(e,yg(t,n),r))},Og=(e,t,n,r)=>{let i=wg(e,r.transition.transition,r.context,r.transition.evaluate),a=hf(i.state)?i.state:void 0,o=a?.target??i.state,s=a?.update??(pf(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:wp(e,i,s.value)}})(),l=o===void 0||pf(o)?void 0:o;Vh(r.sourcePath,r.trigger,r.transition.targets,l);let u=l!==void 0&&Df(l)?xh(e,(()=>{let e=yg(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&&!If(d)&&!zf(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=hg(n);return e.values[t.indexByPath.get(c.path)]=c.value,e})():Dg(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||!Eg(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:Bh(d),g=h===void 0?t.nodes[r.sourceIndex].parent:Th(e,r.leafPath,h),_=t.nodes[r.sourceIndex].parent,v=r.transition.reenter?Eh(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:Dh(e,yg(t,n),v),entryPaths:Oh(e,yg(t,f),v),choiceTransitions:u?.transitions??[]}},kg=(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:Bh(e.unresolvedTarget),resolvedTarget:e.target===void 0?void 0:Bh(e.target),updates:e.update===void 0?[]:[e.update.path]});if(i.length===1){let s=Og(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=Uh(e,Gh(e,i.filter(e=>!i.some(t=>t.sourceIndex!==e.sourceIndex&&Fp(t.sourcePath,e.sourcePath))).map(r=>Og(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=Dg(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?Ah(e,s.flatMap(e=>e.exitPaths)):[],entryPaths:f?jh(e,s.flatMap(e=>e.entryPaths)):[],changed:f}},Ag=(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 Hd({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=wm(e,yg(t,o),s).configuration,i=Wp(e,n);if(!n.outputs.has(i))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:r,next:vg(t,n),commands:c??Cg,emittedEvents:u??Cg,microsteps:d??Cg,done:!0,output:n.outputs.get(i)}}let m=t.nodes[n].path,h=hh(Yd(e).handlers[m]?.on?.[s._tag]);if(h!==void 0){let r=wg(e,h.transition,{...dg(e,a),state:o.values[n],containingState:void 0,ancestors:{},event:s,snapshot:xg(t,o)},h.evaluate),f=pf(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`);_g(o,n,wp(e,r,f.value))}if(Vh(m,{type:`event`,event:s._tag},h.targets,p),p!==void 0&&!If(p)&&!zf(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=If(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]?_g(o,n,wp(e,t.nodes[n],p.value)):g=Dg(e,t,o,p,n)}let _=h.reenter||!Eg(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:Bh(p),resolvedTarget:p===void 0?void 0:Bh(p),updates:f===void 0?[]:[f.path]}]}:void 0,commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents,exitPaths:_?[m]:Cg,entryPaths:_?[t.nodes[v].path]:Cg,changed:_};o=g,(d??=[]).push(gg(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??Cg,emittedEvents:u??Cg,microsteps:d??Cg,done:!1,output:void 0};f+=1,s=g}},jg=(e,t,n,r,i,a)=>{if(lh(r)){let i=ig(e,a===void 0?yg(t,n):jp(yg(t,n),a),r);return{event:i.event,next:vg(t,i.next),commands:i.commands,emittedEvents:i.emittedEvents,microsteps:i.microsteps.map(e=>({next:vg(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=yp(e,r);if(t.flat)return Ag(e,t,n,o,i,a);if(t.finalIndices.some(e=>n.active[e]===1)){let r=yg(t,n);if(_m(e,r)){let n=wm(e,r,o).configuration,i=Wp(e,n);if(!n.outputs.has(i))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:o,next:vg(t,n),commands:[],emittedEvents:[],microsteps:[],done:!0,output:n.outputs.get(i)}}}let s=Tg(e,t,n,o,a);if(s.length===0)return{event:o,next:n,commands:[],emittedEvents:[],microsteps:[],done:!1,output:void 0};let c=kg(e,t,n,o,s,i),l=c.next,u=o,d=[...c.commands],f=[...c.raisedEvents],p=[...c.emittedEvents],m=[gg(c,i)],h=0,g=0;for(;;){if(g+=1,g>1e3)throw new Hd({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=wm(e,yg(t,l),u).configuration;if(l=vg(t,n),_m(e,n)){let t=Wp(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=Tg(e,t,l,n,a);if(r.length===0)continue;let s=kg(e,t,l,n,r,i);l=s.next,d.push(...s.commands),f.push(...s.raisedEvents),p.push(...s.emittedEvents),m.push(gg(s,i))}},Mg=new WeakMap,Ng=e=>({fromConfiguration:e=>e,toConfiguration:e=>e,snapshot:t=>Yp(e,t),plan:(t,n,r,i)=>ig(e,i===void 0?t:jp(t,i),n)}),Pg=(e,t)=>({fromConfiguration:e=>vg(t,e),toConfiguration:e=>yg(t,e),snapshot:e=>xg(t,e),plan:(n,r,i=!1,a)=>jg(e,t,n,r,i,a),...Object.values(Yd(e).handlers).some(e=>e.initialize!==void 0&&!Vm(e.initialize))?{}:{initial:(n,r)=>{let i=e.input===void 0?n:n.length===0?(Sp(e,e.input,void 0),n):[Sp(e,e.input,n[0])],a=e.initial(...i),o=Df(a)?bh(e,{active:new Set,values:new Map,outputs:new Map,history:new Map,...r===void 0?{}:{machineReferences:r}},a,Qh).configuration:nm(e,a),s=wm(e,r===void 0?o:jp(o,r),Qh).configuration,c=vg(t,s),l=xg(t,c);if(!_m(e,s))return{state:l,configuration:c,activeConfiguration:s,initialEntryPaths:qp(e,s),done:!1,output:void 0};let u=Wp(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:qp(e,s),done:!0,output:s.outputs.get(u)}}}}),Fg=e=>{let t=Mg.get(e);if(t!==void 0)return t;let n=mg(e),r=n===void 0?Ng(e):Pg(e,n);return Mg.set(e,r),r},Ig=`Machine.invocation:`,Lg=e=>e.startsWith(Ig),Rg=(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,fs(t,Y)}},zg=e=>Gn(()=>{if(e.values!==void 0){let t=e.values;return e.values=void 0,di(t)}let t=li();return e.waiter=t,vs(t).pipe(X(zg(e)))}),Bg=(e,t)=>e._tag===`Started`&&(typeof t==`string`||e.descriptor!==void 0&&e.descriptor.id===t.id&&e.descriptor.machine===t.machine),Vg=(e,t,n)=>{if(e.closed)return Vr();let r=e.children.get(t);return r!==void 0&&Bg(r,n)?ir(r.ref):Vr()},Hg=e=>{if(e.observers!==void 0)for(let t of e.observers)Rg(t,Vg(e,t.id,t.child))},Ug=(e,t,n)=>{let r=e.children.get(t);r!==void 0&&r.token===n&&(e.children.delete(t),typeof t==`string`&&Hg(e))},Wg=(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`&&Hg(e),!0},Gg=e=>la(function*(){let t=yield*Ts(),n=0,r=0,i=0,a=0;return{rootSessionId:e,stream:ys(t).pipe(ui(K(()=>{n+=1})),Oa(K(()=>{--n}))),isActive:()=>n>0,nextDeliveryId:()=>i++,nextMacrostepId:()=>a++,publishUnsafe:i=>{n!==0&&qn(t,{...i,sequence:r++,rootSessionId:e})},close:or(t)}}),Kg=e=>({id:e.id,sessionId:e.sessionId}),qg=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?Kg(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?Kg(t):{id:String(t.id)}}]:[]}return[]}),Jg=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:qg(Array.isArray(e.commands)?e.commands:[]),exitPaths:Array.isArray(e.exitPaths)?e.exitPaths:[],entryPaths:Array.isArray(e.entryPaths)?e.entryPaths:[],changed:e.changed===!0})),Yg=Symbol.for(`effect/Machine/activeSnapshotObserver`),Xg=Symbol.for(`effect/Machine/snapshotObserver`),Zg=e=>typeof e==`object`&&!!e&&Xg in e,Qg=Symbol.for(`effect/Machine/sendParentOverride`),$g=Symbol.for(`effect/Machine/acknowledgedSend`),e_=Symbol(`effect/Machine/AcknowledgedMessage`),t_=e=>typeof e==`object`&&!!e&&e_ in e,n_=e=>t_(e)?e.event:e,r_=(e,t)=>{e!==void 0&&t_(e)&&(e.deferred!==void 0&&fs(e.deferred,di(t)),e.inspection?.complete(t))},i_=(e,t)=>{e!==void 0&&t_(e)&&e.deferred!==void 0&&fs(e.deferred,mo(t))},a_=e=>{e!==void 0&&t_(e)&&e.deferred!==void 0&&fs(e.deferred,Go(new Gd))},o_=e=>typeof e==`object`&&!!e&&`send`in e&&typeof e.send==`function`,s_=(e,t,n,r)=>`inspectionSubject`in e&&`sendInspected`in e&&typeof e.sendInspected==`function`?e.sendInspected(t,n,r):e.send(t),c_=e=>e?._tag===`Childless`||e?.childless===!0,l_=(e,t)=>{let n=e.items??[];e.items=n,n.push(t)},u_=e=>{if(e.items===void 0)return Vr();let t=e.items[e.index];return e.index+=1,e.index===e.items.length&&(e.items=void 0,e.index=0),ir(t)},d_=e=>{if(e.items!==void 0)for(let t=e.index;t<e.items.length;t+=1)a_(e.items[t]);e.closed=!0,e.items=void 0,e.index=0},f_=()=>({items:void 0,index:0,closed:!1,receivers:new Set}),p_=(e,t,n)=>{if(e.closed)return!1;for(l_(e,t),n?.();e.items!==void 0&&e.receivers.size>0;){let t=e.receivers.values().next().value;e.receivers.delete(t),t(Y)}return!0},m_=e=>Gn(()=>{let t=u_(e);return Ua(t)?di(t.value):e.closed?ro:Do(t=>(e.receivers.add(t),K(()=>{e.receivers.delete(t)}))).pipe(X(m_(e)))}),h_=e=>{d_(e);let t=Array.from(e.receivers);e.receivers.clear();for(let e of t)e(ro)},g_=class extends Fi()(`effect/Machine/MachineRuntime`){},__=(e,t)=>ka(e,g_,t),v_=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($n);if(t!==void 0)return{_tag:`Failure`,error:t.error,cause:e.cause,snapshot:e};let n=e.cause.reasons.find(yi);return n===void 0?e.cause.reasons.find(hi)===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}}},y_=(e,t)=>Gn(()=>e(t)).pipe(ya,Xn),b_=(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)},x_=(e,t,n)=>({id:t,sessionId:n,kind:e.inspection?.kind??`Logic`}),S_=(e,t)=>t?{_tag:`Initialization`}:e!==void 0&&t_(e)&&e.inspection!==void 0?{_tag:`Macrostep`,macrostepId:e.inspection.macrostepId}:void 0,C_=(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=Jg(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{[e_]:!0,event:n,...a===void 0?void 0:{deferred:a},inspection:c}},w_=(e,t,n)=>{if(!t_(n)||n.inspection===void 0)return;let r=n.inspection;e.publishUnsafe({_tag:`EventSent`,subject:t,deliveryId:r.deliveryId,source:r.source,target:Kg(t),event:r.event,causedBy:r.causedBy})},T_=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:Y}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 Gn(()=>{if(this.registry.closed)return ro;if(this.has(t.key)||this.registry.children.has(t.id))return Go(new Wd({id:t.duplicateId}));let a=e(),o=this.registry.scope??=Ki(`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()?s_(this.self,e,t,n):Y,...this.sendAcknowledged===void 0?void 0:{[$g]:e=>i()?this.sendAcknowledged(e):ro}},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,Wg(this.registry,t.id,n,e,t.descriptor)),onStopSync:()=>Ug(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?Po(this.runtime.nextSessionId,e=>this.runtime.startCompiledSync(a,c,this.scopedServices??=Ai(this.services,oo,o),e)):this.runtime.start(a,c)).pipe(co(e=>Wa(e)?Y:(Ug(this.registry,t.id,n),r===void 0?Y:r.stop)));return(u?d:es(d,o)).pipe(Xn)})}stopAll(){return Gn(()=>{let e=[];for(let t of this.registry.children.values())t.ownerActive&&e.push(this.stopEntry(t));return e.length===0?Y:e.length===1?e[0]:er(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]:er(n,{concurrency:`unbounded`,discard:!0})}},E_=Rr(Vr()).pipe(so(ss)),D_=e=>Y,O_=(e,t)=>{},k_=()=>void 0,A_=Symbol(`effect/Machine/EmissionsClosed`),j_=()=>{let e,t=Gn(()=>{let t=e;return t===A_?di(void 0):t===void 0?Ts().pipe(Po(t=>K(()=>{let n=e;return n===A_?[void 0,!0]:n===void 0?(e=t,[t,!1]):[n,!0]}).pipe(Po(([e,n])=>n?or(t).pipe(Ei(e)):di(e))))):di(t)});return{emit:t=>Gn(()=>e===void 0||e===A_?Y:Ur(e,t).pipe(Xn)),close:()=>{let t=e;return e=A_,t===void 0||t===A_?Y:or(t)},stream:Ga(t.pipe(ma(e=>e===void 0?Pa:ys(e))))}},M_={close:()=>Y,spawn:(()=>Jr(Error(`Childless machine logic cannot spawn a process`))),get:()=>di(Vr()),changes:()=>E_,sendTo:()=>Y,stop:()=>Y,owned:{spawn:()=>Jr(Error(`Childless machine logic cannot spawn an owned process`)),stopAll:()=>Y,stopPaths:()=>void 0}},N_=(e,t,n,r)=>{let i={closed:!1,children:new Map,observers:void 0,scope:void 0},a=e=>Gn(()=>{if(i.closed||(i.closed=!0,i.scope===void 0))return Y;let t=Da(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?Y:Array.isArray(a)?er(a,{concurrency:`unbounded`,discard:!0}):a}),o=(e,t)=>K(()=>Ug(i,e,t)),s=(e,t,n,r)=>K(()=>Wg(i,e,t,n,r)),c=e=>{let t=typeof e==`string`?e:e.id;return K(()=>{if(i.closed)return Vr();let n=i.children.get(t);return n!==void 0&&Bg(n,e)?ir(n.ref):Vr()})},l=e=>{let t=typeof e==`string`?e:e.id;return ts(Mr((n,r)=>K(()=>({child:e,id:t,values:void 0,waiter:void 0})).pipe(Po(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 Na(r,a).pipe(X(K(()=>{!i.closed&&r.state._tag!==`Closed`&&(i.observers??=new Set,i.observers.add(n)),Rg(n,Vg(i,t,e))})),Ei(zg(n)))}))))},u=(e,t,n,r)=>{let a=typeof e==`string`?e:e.id;return Gn(()=>{if(i.closed)return Y;let o=i.children.get(a);return o!==void 0&&Bg(o,e)?s_(o.ref,t,n,r):Y})},d=e=>{let t=typeof e==`string`?e:e.id;return Gn(()=>{if(i.closed)return Y;let n=i.children.get(t);return n!==void 0&&Bg(n,e)?n.ref.stop:Y})};function f(n,r){let a=typeof n==`object`&&n&&zm in n?n:void 0,c=a===void 0?n:a[zm](r?.input),l=a===void 0?r:{id:a.id,descriptor:a},u=Symbol(),d=l?.id??u,f;return Gn(()=>i.closed?ro:typeof d==`string`&&(i.children.has(d)||Lg(d))?Go(new Wd({id:d})):(i.scope??=Ki(`parallel`),i.children.set(d,{_tag:`Starting`,token:u}),t.start(c,{detached:!0,...l?.id===void 0?void 0:{id:l.id},...l?.onOutcome===void 0?void 0:{onOutcome:l.onOutcome},...l?.[Yg]===void 0?void 0:{onSnapshot:l[Yg]},...l?.[Qg]===void 0?void 0:{sendParent:l[Qg]},onReady:(e,t)=>K(()=>{f=e}).pipe(X(s(d,u,e,l?.descriptor)),Po(e=>e?Y:t)),onStop:o(d,u),parent:e,runtime:t,origin:{_tag:`Spawn`,address:l?.id}}).pipe(co(e=>Cn(e)?o(d,u).pipe(X(f===void 0?Y:f.stop)):Y),es(i.scope))))}return{close:a,spawn:f,get:c,changes:l,sendTo:u,stop:d,owned:new T_(i,e,t,n,r)}},P_=(e,t,n,r)=>K(()=>N_(e,t,n,r)),F_=(e,t)=>`${e.length}:${e}${t}`,I_=(e,t)=>`${Ig}${F_(e,t)}`,L_=e=>({initial:()=>Y,run:()=>e}),R_=(e,t,n)=>({initial:()=>Y,run:({parent:r})=>{let i=r?.[$g];return i===void 0?Jr(Error(`Stream invocation requires an acknowledged parent machine`)):Bn(e,e=>i(oh(t,n,e)).pipe(Xn,ur(()=>ro)))}}),z_=(e,t)=>typeof e==`function`?e(t):e,B_=e=>({spawn:((t,n)=>e.spawn(t,n)),sendTo:((t,n)=>e.sendTo(t,n)),stop:(t=>e.stopChild(t))}),V_=(e,t,n)=>{if(`effect`in e)return{id:String(e.id),sourceName:e.sourceName,src:()=>L_(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:()=>L_(cs(z_(e.after,t))),onDone:e.onDone,activityKind:`Timer`};if(`stream`in e){let r=String(e.id);return{id:r,sourceName:e.sourceName,src:()=>R_(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:()=>z_(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[zm](`input`in e?z_(e.input,t):void 0),onDone:e.onDone,onFailure:e.onFailure,onSnapshot:e.onSnapshot}}throw Error(`Unsupported captured machine invocation: ${String(e)}`)},H_=e=>e.length===0?Y:e.length===1?e[0]:er(e,{discard:!0}),U_=(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(ji(`StoppedError`,()=>Y)),W_=e=>e instanceof Hd||e instanceof Vd||e instanceof Gd,G_=(e,t,n,r,i,a,o,s,c,l,u,d)=>Gn(()=>{let f=F_(n,r),p=u===void 0?o:()=>{let t=o();return{...t,run:i=>sr(Gn(()=>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):Y,onOutcome:(t,i,o)=>X(Sr,Gn(()=>i._tag===`Stopped`||!t()?Y:i._tag===`Done`?s===void 0?e.failCause(ar(Error(`Invocation "${r}" completed without the required onDone handler`))):U_(e,ah(n,r,i.output),u===void 0?void 0:o):i._tag===`Failure`&&c!==void 0&&(a===void 0||!W_(i.error))?U_(e,sh(n,r,i.error),u===void 0?void 0:o):e.failCause(i.cause))),...l===void 0?void 0:{onSnapshot:(t,i)=>t()?U_(e,ch(n,r,i)):Y}})}),K_=(e,t)=>Lg(e)?Go(new Wd({id:t})):void 0,q_=(e,t,n,r)=>{let i=String(r.id),a=r.address===void 0?void 0:K_(String(r.address),i);return a===void 0?G_(e,t,n,i,r.address===void 0?I_(n,i):String(r.address),r.descriptor,r.src,r.onDone,r.onFailure,r.onSnapshot,r.activityKind,r.sourceName):a},J_=(e,t,n,r)=>{let i=r.child,a=K_(i.id,i.id);return a===void 0?G_(e,t,n,i.id,i.id,i,i[zm],r.onDone,r.onFailure,r.onSnapshot,void 0):a},Y_=(e,t,n,r,i,a)=>{let o=B_(t),s=jh(e,i).filter(e=>r.active.has(e)).flatMap(i=>{let s={...Mp(r)??{self:t.self,parent:t.parent},children:o,state:r.values.get(i),containingState:Kp(e,r,i),ancestors:Gp(e,r,i),event:a};return Xm(fm(e,i)?.invoke).map(e=>`child`in e&&!(`input`in e)?J_(t,n,i,e):q_(t,n,i,V_(e,s,i)))});return s.length===0?void 0:H_(s)},X_=Symbol(`effect/Machine/CompiledStoppedCompletion`),Z_=class{logic;options;services;id;sessionId;inspectionSubject;send;sendInspected(e,t,n){return this.offerEvent(e,t,n)}[$g](e){return this.sendAcknowledgedEffect(e)}[Xg](e){let t=this.snapshotObservers??=new Set;return t.add(e),()=>{t.delete(e)}}mailbox={items:void 0,index:0,closed:!1};address;childRuntime=M_;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=x_(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:Gn(()=>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 S_(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:Jg({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:Lr(e)})}get execution(){return this.logic.execution}initializeCompiledSync(){this.publishCreated(),this.execution.childless||(this.childRuntime=N_(this.address,this.options.runtime,this.services,e=>this.sendAcknowledgedEffect(e)));let e=this.options.parent,t=this.options.sendParent??(e===void 0?D_:this.inspector===void 0?e.send:t=>s_(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)=>o_(e)?this.inspector===void 0?e.send(t):s_(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?O_:(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(br(e)),Go(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 Q_(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?di(this):(this.runState=`Draining`,Fa(this.drainRuntime(),this.services).pipe(Ei(this)))}initialize(){let e=this;return la(function*(){e.publishCreated(),e.execution.childless||(e.childRuntime=yield*P_(e.address,e.options.runtime,e.services,t=>e.sendAcknowledgedEffect(t)));let t=e.options.parent,n=e.options.sendParent??(t===void 0?D_:e.inspector===void 0?t.send:n=>s_(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)=>o_(t)?e.inspector===void 0?t.send(n):s_(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?O_:(t,n=[])=>{e.initialEntryPaths=t,e.initialMicrosteps=n}};let r=t=>Cn(t)?e.childRuntime.close(t):Y,i=e.execution.initial,a=yield*(i===void 0?e.logic.initial(e.processScope).pipe(ma(e=>({state:e,done:void 0,output:void 0}))):i(e.processScope)).pipe(co(t=>(Cn(t)&&e.publishStartFailed(t.cause),r(t))),vn(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:Co,poll:K(()=>Tr(u_(e.mailbox),n_)),receiveMessage:Co,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 Q_(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(Xn))),e.options.onSnapshot!==void 0&&(yield*y_(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 Gn(()=>this.lifecycle===`Completed`?this.resolveCompletion(this.completion):(this.waiter??=li(),vs(this.waiter)))}get stop(){return Or(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(Xn);return this.runState===`Initializing`?e:e.pipe(X(ro))}failCause(e){let t={_tag:`Failure`,cause:e};return this.requestTermination(t).pipe(Po(e=>e?zo(this.settleRequestedTermination()).pipe(Xn):Y))}sendAcknowledgedEffect(e){return Nr(t=>os().pipe(Po(n=>this.offerEvent(e,void 0,void 0,n).pipe(X(t(vs(n)))))))}offerEvent(e,t,n,r){return Gn(()=>{let i=this.inspector,a=this.inspectionSubject,o=i?.isActive()===!0&&a!==void 0?C_(i,a,e,t,n,r):r===void 0?e:{[e_]:!0,event:e,deferred:r};return this.offerMessage(o)})}offerMessage(e){return Or(Jn(t=>{if(this.mailbox.closed||this.lifecycle!==`Active`)return Go(new Gd);let n=this.inspector,r=this.inspectionSubject;n!==void 0&&r!==void 0&&w_(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&&l_(this.mailbox,e),this.runState!==`Idle`)return Y;if(this.runState=`Draining`,o!==void 0){let n;try{n=o(a,e)}catch(e){n=Jr(e)}return n!==void 0||this.hasTerminationRequest()?this.startWorker(n):(this.runState=`Idle`,this.scheduleChangesFlush(t.currentDispatcher),Y)}return this.startWorker(void 0)}))}startWorker(e){let t=Fa(this.drainRuntime(e),this.services);return(this.options.detached===!0?zo(t,{startImmediately:!0}):yo(t,{startImmediately:!0})).pipe(Po(e=>K(()=>(e.pollUnsafe()===void 0&&(this.worker=e),this.interruptRequested?(this.interruptRequested=!1,!0):!1)).pipe(Po(t=>t?zo(this.interruptAndFinish(e)):Y))),Xn)}stopEffect(){return Gn(()=>this.lifecycle===`Completed`||this.finishIdleChildlessStop()?Y:this.requestTermination({_tag:`Stopped`}).pipe(Po(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!==A_||this.current.terminalizing||this.current.snapshot.status!==`active`)return!1;this.emissionsPubSub=A_;let e={status:`stopped`,state:this.current.snapshot.state};return this.lifecycle=`TerminationRequested`,this.termination={_tag:`Stopped`},this.terminationSnapshot=e,d_(this.mailbox),this.current={revision:this.current.revision+1,terminalizing:!0,changes:void 0,snapshot:e},this.notifySnapshotObservers(),a_(this.inFlightMessage),this.inFlightMessage=void 0,this.interruptRequested=!1,this.compiledContext!==void 0&&(this.compiledContext.executionState=void 0),this.options.onStopSync?.(this),this.completion=X_,this.lifecycle=`Completed`,this.waiter!==void 0&&(fs(this.waiter,this.resolveCompletion(X_)),this.waiter=void 0),!0}settleRequestedTermination(){return Gn(()=>this.runState===`Draining`?this.worker===void 0?(this.interruptRequested=!0,this.awaitCompletion()):this.interruptAndFinish(this.worker).pipe(X(this.awaitCompletion())):this.finishRequestedTermination())}interruptAndFinish(e){return kn(e).pipe(X(Gn(()=>this.lifecycle===`Completed`?Y:this.finishRequestedTermination())))}awaitCompletion(){return this.lifecycle===`Completed`?Y:this.join.pipe(ya,Xn)}resolveCompletion(e){if(e!==X_)return e;let t=Go(new Gd);return this.completion=t,t}drainRuntime(e){let t=this;return Nr(n=>la(function*(){let r=t.offerRevision,i=e;for(;;){if(t.hasTerminationRequest())return yield*t.finishRequestedTermination();let e=yield*n(Gn(()=>{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(ya);if(t.flushPendingChanges(),Cn(e))return t.lifecycle===`Active`&&(yield*t.requestTermination({_tag:`Failure`,cause:e.cause})),yield*t.finishRequestedTermination();if(Ua(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 Gn(()=>{if(this.lifecycle!==`TerminationRequested`)return Y;let e=this.termination;if(e===void 0)return Y;let t=this.terminationSnapshot??this.reserveTermination(e);if(t===void 0)return this.awaitCompletion();let n=e._tag===`Stopped`?jr:e._tag===`Done`?Er(e.output):Lr(e.cause),r=e._tag===`Stopped`?X_:e._tag===`Done`?di(e.output):mo(e.cause),i=this.options.onOutcome===void 0||e._tag===`Stopped`&&this.options.skipStoppedOutcome===!0?Y:Gn(()=>this.options.onOutcome(v_(t))).pipe(ya,Xn),a=this.inspector,o=this.inspectionSubject,s=a===void 0||o===void 0?this.closeEmissions():this.closeEmissions().pipe(X(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`?Xa():n}))));return Or(K(()=>{d_(this.mailbox)}).pipe(X(this.childRuntime.close(n)),X(this.setAndPublishSnapshot(t)),X(s),X(K(()=>{e._tag===`Failure`?i_(this.inFlightMessage,e.cause):a_(this.inFlightMessage),this.inFlightMessage=void 0})),X(i),X(this.options.onStop??Y),X(this.options.inspectionRoot===!0&&this.inspector!==void 0?this.inspector.close:Y),X(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&&(fs(this.waiter,this.resolveCompletion(r)),this.waiter=void 0)}))))})}publishSnapshot(e){let t=e.changes===void 0?di(e):Ur(e.changes,[e]).pipe(Ei(e)),n=e.snapshot;return this.options.onSnapshot===void 0||n.status!==`active`?t:t.pipe(zr(()=>y_(this.options.onSnapshot,n)))}completeChanges(e){return e.changes===void 0?Y:Ur(e.changes,Er(void 0)).pipe(Xn)}emitEvent(e){let t=this.externalEmissions===void 0?Gn(()=>this.emissionsPubSub===void 0||this.emissionsPubSub===A_?Y:Ur(this.emissionsPubSub,e).pipe(Xn)):this.externalEmissions.emit(e),n=this.inspector,r=this.inspectionSubject;return n===void 0||r===void 0?t:t.pipe(zr(()=>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=A_,e===void 0||e===A_?Y:or(e)}getOrCreateEmissions(){return Gn(()=>{let e=this.emissionsPubSub;return e===A_?di(void 0):e===void 0?Ts().pipe(Po(e=>K(()=>{let t=this.emissionsPubSub;return t===A_?[void 0,!0]:t===void 0?(this.emissionsPubSub=e,[e,!1]):[t,!0]}).pipe(Po(([t,n])=>n?or(e).pipe(Ei(t)):di(t))))):di(e)})}emissionsStream(){return Ga(this.getOrCreateEmissions().pipe(ma(e=>e===void 0?Pa:ys(e))))}setAndPublishSnapshot(e){return Gn(()=>{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(Po(e=>this.completeChanges(e)),Xn)})}setActiveState(e){return Gn(()=>this.commitActiveState(e)??Y)}pollCompiledMessage(){let e=u_(this.mailbox);return Ua(e)&&(this.inFlightMessage=t_(e.value)?e.value:void 0),e}beginCompiledMessage(e){this.inFlightMessage=t_(e)?e:void 0}completeCompiledMessage(e){r_(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]:qn(a.changes,[a]):(r.push(a),t?a.pendingChanges=r:qn(a.changes,r))),this.notifySnapshotObservers(),this.options.onSnapshot===void 0?void 0:y_(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,qn(e.changes,t))}updateState(e){return Gn(()=>{let t=this.current;return t.terminalizing||t.snapshot.status!==`active`?Y:e(t.snapshot.state).pipe(Po(e=>{let n=this.current;return n.terminalizing||n.revision!==t.revision?Y:this.setActiveState(e)}))})}getOrCreateChanges(){return Gn(()=>{let e=this.current;return e.snapshot.status===`active`?e.changes===void 0?Ts({replay:1}).pipe(Po(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(Po(([t,n])=>n?or(e).pipe(Ei(t)):di(t))))):di(e.changes):di(void 0)})}changesStream(){let e=this;return Ga(la(function*(){let t=yield*e.getOrCreateChanges();if(t===void 0)return Rr(e.current.snapshot);let n=yield*xr(t),r=e.current;return r.snapshot.status===`active`?Rr(r.snapshot).pipe(so(ts(Dr(Qr(n))).pipe(qi(e=>e.revision>r.revision),ii(e=>e.snapshot)))):Rr(r.snapshot)}))}},Q_=class{scope;ownedChildren;process;executionState;constructor(e,t,n){this.scope=e,this.ownedChildren=t,this.process=n}poll(){return Tr(this.process.pollCompiledMessage(),n_)}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}},$_=Va(function*(e,t){let n=t.sessionId??(yield*t.runtime.nextSessionId),r=yield*Hi(),i=e.execution,a=new Z_(e,t,r,n);return yield*(i.initialSync!==void 0&&t.onReady===void 0&&t.onSnapshot===void 0?a.initializeCompiledSync():a.initialize()).pipe(co(e=>Cn(e)?a.shutdownEmissions().pipe(X(t.inspectionRoot===!0&&t.runtime.inspection!==void 0?t.runtime.inspection.close:Y)):Y))}),ev=(e,t,n,r)=>new Z_(e,t,n,r).initializeCompiledSync(),tv=Va(function*(e,t){let{detached:n,id:r,onOutcome:i,onReady:a,onReadySync:o,onSnapshot:s,onStop:c,onStopSync:l,parent:u,runtime:d,sendParent:f}=t,p=t.sessionId??(yield*d.nextSessionId),m=r??p,h=d.inspection,g=h===void 0?void 0:x_(e,m,p),_=h===void 0||t.activity===void 0?void 0:{...t.activity,sessionId:p},v,y,b=f_(),x=t.emissions??j_(),S=yield*os(),C=yield*os(),w=vs(C).pipe(ya,Xn),T=!0,E,D=zn(S,{_tag:`Stopped`}).pipe(Xn),O=(e,t)=>Gn(()=>p_(b,e,t)?Y:Go(new Gd)),k=h===void 0?void 0:(e,t,n,r)=>Gn(()=>{let i=h.isActive()?C_(h,g,e,t,n,r):r===void 0?e:{[e_]:!0,event:e,deferred:r};return O(i,()=>w_(h,g,i))}),A=e.execution?._tag===`Compiled`?e=>Nr(t=>os().pipe(Po(n=>(h===void 0?O({[e_]:!0,event:e,deferred:n}):k(e,void 0,void 0,n)).pipe(X(t(vs(n))))),ma(e=>e))):void 0,j={id:m,sessionId:p,stop:Gn(()=>T?D:D.pipe(X(Co))),send:h===void 0?e=>O(e):e=>k(e,void 0,void 0),...h===void 0?void 0:{inspectionSubject:g,sendInspected:k}},{changes:M,close:N,get:ee,owned:P,sendTo:F,spawn:I,stop:te}=M_;c_(e.execution)||({changes:M,close:N,get:ee,owned:P,sendTo:F,spawn:I,stop:te}=yield*P_(j,d,void 0,A===void 0?void 0:e=>A(e)));let ne=e=>Wa(e)?Y:(h!==void 0&&h.publishUnsafe(_===void 0?{_tag:`StartFailed`,subject:g,cause:e.cause}:{_tag:`ActivityStopped`,subject:_.owner,activity:_,exit:e}),N(e).pipe(X(x.close()),X(t.inspectionRoot===!0&&h!==void 0?h.close:Y))),L=l===void 0?c??Y:K(()=>l(De)),re=h===void 0?k_:()=>S_(E,T),ie=f??(u===void 0?D_:h===void 0?u.send:e=>s_(u,e,g,re())),ae=h===void 0?x.emit:e=>x.emit(e).pipe(zr(()=>K(()=>h.publishUnsafe({_tag:`Emitted`,subject:g,emission:e,causedBy:re()})))),oe={self:j,parent:u,spawn:I,sendParent:ie,emit:ae,sendTo:h===void 0?((e,t)=>o_(e)?e.send(t):F(e,t)):((e,t)=>o_(e)?s_(e,t,g,re()):F(e,t,g,re())),stopChild:te,failCause:e=>zn(S,{_tag:`Failure`,cause:e}).pipe(Xn),inspectInitial:h===void 0?O_:(e,t=[])=>{v=e,y=t}};h!==void 0&&h.publishUnsafe(_===void 0?{_tag:`Created`,subject:g,parent:u?.inspectionSubject,origin:t.origin??{_tag:`Root`},definition:e.inspection?.definition}:{_tag:`ActivityStarted`,subject:_.owner,activity:_});let R=yield*e.initial(oe).pipe(co(ne),vn(K(()=>{T=!1}))),z=yield*lo({revision:0,terminalizing:!1,changes:void 0,snapshot:{status:`active`,state:R}});_===void 0&&h?.publishUnsafe({_tag:`Initialized`,subject:g,snapshot:{status:`active`,state:R},initialEntryPaths:v??[],microsteps:Jg({microsteps:y??[]})});let se=s===void 0?e=>e.changes===void 0?di(e):Ur(e.changes,[e]).pipe(Ei(e)):e=>{let t=e.changes===void 0?di(e):Ur(e.changes,[e]).pipe(Ei(e)),n=e.snapshot;return n.status===`active`?t.pipe(zr(()=>y_(s,n))):t},B=e=>e.changes===void 0?Y:Ur(e.changes,Er(void 0)).pipe(Xn),ce=e=>e.snapshot.status===`active`?di(e):B(e).pipe(Ei(e)),le=e=>Vo(z).pipe(Po(t=>t.revision===e.revision?se(e).pipe(Po(ce)):di(void 0))),ue=e=>La(z,t=>t.terminalizing?di([void 0,t]):ma(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(Po(e=>e===void 0?di(void 0):le(e)),ma(e=>e?.snapshot)),de=e=>Ao(z,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(ma(e=>e?.snapshot)),fe=e=>Xi(z,t=>({revision:t.revision+1,snapshot:e,terminalizing:!0,changes:t.changes})).pipe(Po(se),Po(ce),Xn),pe=h===void 0?e=>ue(t=>di(t.status===`active`?{status:`active`,state:e}:void 0)).pipe(Xn):t=>Vo(z).pipe(Po(n=>ue(e=>di(e.status===`active`?{status:`active`,state:t}:void 0)).pipe(zr(r=>K(()=>{e.inspection?.kind!==`Machine`&&r!==void 0&&h.publishUnsafe({_tag:`StateChanged`,subject:g,before:n.snapshot.state,after:t,causedByDeliveryId:E!==void 0&&t_(E)?E.inspection?.deliveryId:void 0})})))),Xn),me=(e,n,r)=>{let a=i===void 0||e.status===`stopped`&&t.skipStoppedOutcome===!0?Y:Gn(()=>i(v_(e))).pipe(ya,Xn),o=h===void 0?x.close():x.close().pipe(X(K(()=>h.publishUnsafe(_===void 0?{_tag:`Terminated`,subject:g,snapshot:e}:{_tag:`ActivityStopped`,subject:_.owner,activity:_,exit:e.status===`stopped`?Xa():n}))));return Or(K(()=>h_(b)).pipe(X(N(n)),X(fe(e)),X(o),X(K(()=>{Cn(n)?i_(E,n.cause):a_(E),E=void 0})),X(a),X(L),X(t.inspectionRoot===!0&&h!==void 0?h.close:Y),X(r)))},he=de(e=>({status:`stopped`,state:e.state})),V=e=>de(t=>({status:`error`,state:t.state,cause:e})),ge=e=>de(t=>({status:`done`,state:t.state,output:e})),_e=e=>me(e,jr,ri(C,new Gd)),ve=(e,t)=>{let n=Lr(t);return me(e,n,Nn(C,t))},ye=(e,t)=>{let n=Er(t);return me(e,n,zn(C,t))},be=Or(D.pipe(X(w))),xe=e.execution?._tag===`Compiled`?{receiveMessage:m_(b).pipe(zr(e=>K(()=>{E=t_(e)?e:void 0}))),pollMessage:K(()=>u_(b)).pipe(zr(e=>K(()=>{Ua(e)&&(E=t_(e.value)?e.value:void 0)}))),completeMessage:e=>{r_(E,e),E=void 0}}:void 0,Se=h===void 0||e.execution?._tag===`Compiled`?m_(b).pipe(ma(n_)):m_(b).pipe(zr(e=>K(()=>{E=e})),ma(n_)),Ce=h===void 0||e.execution?._tag===`Compiled`?K(()=>u_(b)).pipe(ma(Tr(n_))):K(()=>u_(b)).pipe(zr(e=>K(()=>{Ua(e)&&(E=e.value)})),ma(Tr(n_))),we=h===void 0?e=>ue(t=>t.status===`active`?e(t.state).pipe(ma(e=>({status:`active`,state:e}))):di(void 0)).pipe(Xn):t=>Vo(z).pipe(Po(n=>ue(e=>e.status===`active`?t(e.state).pipe(ma(e=>({status:`active`,state:e}))):di(void 0)).pipe(zr(t=>K(()=>{e.inspection?.kind!==`Machine`&&t?.status===`active`&&h.publishUnsafe({_tag:`StateChanged`,subject:g,before:n.snapshot.state,after:t.state,causedByDeliveryId:E!==void 0&&t_(E)?E.inspection?.deliveryId:void 0})})))),Xn),Te={...oe,...e.execution?._tag===`Compiled`&&!e.execution.childless?{ownedChildren:P}:void 0,...xe,receive:Se,poll:Ce,state:Vo(z).pipe(ma(e=>e.snapshot.state)),setState:pe,updateState:we},H=La(z,e=>e.snapshot.status===`active`?e.changes===void 0?Ts({replay:1}).pipe(ma(t=>[t,{...e,changes:t}])):di([e.changes,e]):di([void 0,e])),Ee=Ga(la(function*(){let e=yield*H;if(e===void 0)return Rr((yield*Vo(z)).snapshot);let t=yield*xr(e),n=yield*Vo(z);return n.snapshot.status===`active`?Rr(n.snapshot).pipe(so(ts(Dr(Qr(t))).pipe(qi(e=>e.revision>n.revision),ii(e=>e.snapshot)))):Rr(n.snapshot)})),De={id:m,sessionId:p,...h===void 0?void 0:{inspectionSubject:g,sendInspected:k},state:Vo(z).pipe(ma(e=>e.snapshot.state)),snapshot:Vo(z).pipe(ma(e=>e.snapshot)),changes:Ee,emissions:x.stream,join:vs(C),stop:be,send:j.send,...A===void 0?void 0:{[$g]:A},child:ee,childChanges:M};o!==void 0&&!o(De)?yield*D:a!==void 0&&(yield*a(De,D)),s!==void 0&&(yield*y_(s,{status:`active`,state:R}));let U=e=>{switch(e._tag){case`Stopped`:return he;case`Done`:return ge(e.output);case`Failure`:return V(e.cause)}},Oe=(e,t)=>{switch(e._tag){case`Stopped`:return _e(t);case`Done`:return ye(t,e.output);case`Failure`:return ve(t,e.cause)}},ke=e=>n===!0?zo(e,{startImmediately:!0}):yo(e,{startImmediately:!0}),Ae=yield*Un(S),je=Sn(Ae)?yield*Nr(t=>t(Gn(()=>e.run(Te))).pipe(ya,Po(e=>zn(S,Cn(e)?{_tag:`Failure`,cause:e.cause}:{_tag:`Done`,output:e.value})))).pipe(ke):void 0;return yield*ke(Nr(e=>la(function*(){let t=Ua(Ae)?yield*Ae.value:yield*e(vs(S)),n=yield*U(t);return je!==void 0&&(yield*kn(je)),n===void 0?yield*w:yield*Oe(t,n)}))),De}),nv=((e,t)=>e.execution?._tag===`Compiled`?$_(e,t):tv(e,t)),rv=b_(nv,ev),iv=new WeakMap,av=e=>Gn(()=>{e.closed=!0;let t=Array.from(e.live).reverse();return e.live.clear(),ea(t,e=>e.stop,{discard:!0})}),ov=()=>{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},sv=e=>Po(ai,t=>{let n=iv.get(t);if(n!==void 0)return e(n.hooks);let r=ov();return iv.set(t,r),X(Na(t,av(r)),e(r.hooks))});Va(function*(e,t,n){let r=yield*rv,i=n===void 0?{detached:!0,runtime:r}:{...n,detached:!0,runtime:r};return t===`generic`?yield*sv(t=>tv(e,{...i,...t})):t===`compiled`?e.execution?._tag===`Compiled`?yield*sv(t=>$_(e,{...i,...t})):yield*Jr(Error(`Machine cannot force the compiled runtime for generic process logic`)):yield*sv(t=>nv(e,{...i,...t}))});var cv=Va(function*(e,t){let n=yield*rv;return yield*sv(r=>nv(e,t===void 0?{detached:!0,runtime:n,...r}:{...t,detached:!0,runtime:n,...r}))}),lv=Va(function*(e,t,n){let r=yield*rv,i=yield*r.nextSessionId,a=yield*Gg(i);r.inspection=a;let o=j_(),s=yield*os(),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*hr(sv(n=>{let r={...c,...n};return t===`generic`?tv(e,r):t===`compiled`?e.execution?._tag===`Compiled`?$_(e,r):Jr(Error(`Machine cannot force the compiled runtime for generic process logic`)):nv(e,r)}).pipe(co(e=>ra(s,e))));return{id:n?.id??i,sessionId:i,changes:Ga(vs(s).pipe(ma(e=>e.changes))),emissions:o.stream,inspection:a.stream,start:l}}),uv=((e,t)=>lv(e,`auto`,t));q({_tag:rs(`MachineSnapshot`),version:rs(2),active:Ta(q({path:J,value:_r(Yi)})),completed:_r(Ta(q({path:J,output:_r(Yi)}))),history:_r(ls(J,q({mode:xs([`shallow`,`deep`]),active:Ta(J),values:ls(J,Yi)})))});var dv=(e,t,n)=>{let r=$(e,n);if(r.type===`compound`){let r=pm(e,t,n);if(r===void 0)throw Error(`Machine expected completed state "${n}" to have an active child`);return dv(e,t,r)}return r.output},fv=(e,t)=>la(function*(){let n=yield*im(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)||!gm(e,n,a))throw Error(`Machine snapshot contains invalid completion "${a}"`);i.add(a);let o=dv(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*up(e,o,t.output,{boundary:`output`,state:a}))}return Yp(e,{...n,outputs:r})}).pipe(ur(t=>pv(e,t))),pv=(e,t)=>{if(ws(t))return mo(Ti(t,t=>t instanceof Vd?t:new Vd({machineId:e.id,boundary:`configuration`,cause:br(t)})));let n=Zr(t);return Ua(n)&&n.value instanceof Vd?Go(n.value):Go(new Vd({machineId:e.id,boundary:`configuration`,cause:t}))},mv=e=>e.length===0?Y:e.length===1?e[0]:er(e,{discard:!0}),hv=(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}),gv=new WeakMap,_v=e=>{let t=gv.get(e);if(t!==void 0)return t;let n=Object.values(Yd(e).handlers).some(e=>e.invoke!==void 0);return gv.set(e,n),n},vv=di(Vr()),yv=(e,t)=>{let n=Fg(e),r=new WeakMap,i=t=>{let n=r.get(t.scope);return n===void 0&&(n=og(e,t.scope),r.set(t.scope,n)),n},a=n=>{if(!t)return;let r=n.state();return $h(e,r)?eg(e,r,Qh).pipe(ma(ir)):void 0},o=e=>Gn(()=>c(e)??vv),s=(e,t,r,a,s)=>{let c=a.commands.length===0?void 0:sg(a.commands,e.scope),l=a.emittedEvents.length===0?void 0:cg(a.emittedEvents,i(e)),u=()=>{let i=Gn(()=>(t&&e.completeMessage({before:r,plan:hv(a,n.snapshot),after:s}),a.done?di(ir(a.output)):o(e)));return l===void 0?i:l.pipe(X(i))},d=()=>{let t=e.commit(s),n=u(),r=t===void 0?n:t.pipe(X(n));return t===void 0&&l===void 0?r:e.runAfterChanges(r)};return c===void 0?d():e.runAfterChanges(c.pipe(X(Gn(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(Sn(e))return;r=e.value}let a=t_(r),c=a?r.event:r,l=t.state(),u;try{u=n.plan(t.executionState??n.fromConfiguration(nm(e,l)),c,a,t.scope)}catch(e){return qd(e)}if(t.executionState=u.next,u.microsteps.length===0){a&&t.completeMessage({before:l,plan:hv(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(X(Gn(()=>(a&&t.completeMessage({before:l,plan:hv(u,n.snapshot),after:d}),o(t))))));a&&t.completeMessage({before:l,plan:hv(u,n.snapshot),after:d})}};return{run:e=>__(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:__(r,e.scope)}}},bv=class{initialized=!1;initial;constructor(e){this.initial=e}},xv=(e,t)=>{let n=Fg(e);return r=>{let i=r.state();if(t&&$h(e,i))return eg(e,i,Qh).pipe(ma(ir));let a=r.scope,o=r.executionState,s=o instanceof bv?o:new bv;r.executionState=s;let c,l,u;return u=Gn(()=>{let t=r.pollMessage();if(Sn(t))return l=void 0,di(Vr());let o=t.value,s=t_(o),d=s?o.event:o,f=i,p;try{p=n.plan(l??n.fromConfiguration(nm(e,i)),d,s,a)}catch(e){return qd(e)}if(l=p.next,p.microsteps.length===0)return s&&r.completeMessage({before:f,plan:hv(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(sg(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(cg(p.emittedEvents,c??=og(e,a))),p.done)b.push(r.ownedChildren.stopAll());else if(m)for(let[t,n]of g){let i=Y_(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=Gn(()=>(s&&r.completeMessage({before:f,plan:hv(p,n.snapshot),after:v}),p.done?di(ir(p.output)):u));return b.length===0?e:mv(b).pipe(X(e))},C=()=>{let e=x(),t=S(),n=e===void 0?t:e.pipe(X(t));return e===void 0&&b.length===0?n:r.runAfterChanges(n)};return y.length===0?C():r.runAfterChanges(mv(y).pipe(X(Gn(C))))}),__(Gn(()=>{if(s.initialized)return u;let t=s.initial,o=t?.activeConfiguration??nm(e,i);l=t?.configuration??n.fromConfiguration(o);let c=Y_(e,a,r.ownedChildren,o,t?.entryPaths??qp(e,o),Qh);return s.initial=void 0,s.initialized=!0,c===void 0?u:c.pipe(X(u))}),a)}},Sv=e=>e.done?{state:e.state,done:!0,output:e.output}:{state:e.state,done:!1,output:void 0},Cv=(e,t)=>{let n=_v(e),r=Fg(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=Sv(t);return n?{...r,executionState:new bv({configuration:t.configuration,activeConfiguration:t.activeConfiguration,entryPaths:t.initialEntryPaths})}:r}catch(e){throw Jd(e)}},s=t=>a===void 0?__(ag(ph(e,t),...i).pipe(Po(n=>{t.inspectInitial(n.initialEntryPaths,n.microsteps);let r=n.commands.length===0?void 0:sg(n.commands,t),i=n.emittedEvents.length===0?void 0:cg(n.emittedEvents,og(e,t)),a=di(Sv(n));return r===void 0?i===void 0?a:i.pipe(X(a)):i===void 0?r.pipe(X(a)):r.pipe(X(i),X(a))})),t):Ka({try:()=>o(t),catch:Jd});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:xv(e,t._tag===`Resume`)}:{_tag:`Owned`,...yv(e,t._tag===`Resume`)}},initial:n=>t._tag===`Resume`?__(fv(e,t.snapshot),n):s(n).pipe(ma(e=>e.state)),run:t=>__(la(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*Jr(Error(`Machine statechart started without acknowledged mailbox access`));let c,l=yield*o;if($h(e,l))return yield*eg(e,l,Qh);if(!n){let n,o=Vr(),u;for(;c===void 0;){let d=Ua(o)?o.value:yield*a;o=Vr();let f=t_(d),p=f?d.event:d,m=l,h;try{h=ig(e,jp(n??nm(e,l),t),p)}catch(e){return yield*qd(e)}if(n=h.next,h.microsteps.length>0){let n=Yp(e,h.next);yield*sg(h.commands,t),yield*s(n),l=n,h.emittedEvents.length>0&&(yield*cg(h.emittedEvents,u??=og(e,t))),h.done&&(c={output:h.output})}f&&r({before:m,plan:hv(h,t=>Yp(e,t)),after:l}),c===void 0&&(o=yield*i,Sn(o)&&(n=void 0))}return c===void 0?yield*Jr(Error(`Machine process stopped receiving events before reaching a terminal configuration`)):c.output}let u=t.ownedChildren;if(u===void 0)return yield*Jr(Error(`Invoking statechart started without an owned child runtime`));let d=(n,r,i)=>Y_(e,t,u,n,r,i)??Y,f=e=>u.stopPaths(e)??Y;return yield*la(function*(){let n=yield*im(e,l);yield*d(n,qp(e,n),Qh),n=void 0;let o=Vr(),p;for(;c===void 0;){let m=Ua(o)?o.value:yield*a;o=Vr();let h=t_(m),g=h?m.event:m,_=l,v;try{v=ig(e,jp(n??nm(e,l),t),g)}catch(e){return yield*qd(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=Yp(e,v.next);if(yield*sg(v.commands,t),n&&(yield*f(r)),yield*s(a),l=a,v.emittedEvents.length>0&&(yield*cg(v.emittedEvents,p??=og(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:hv(v,t=>Yp(e,t)),after:l}),c===void 0&&(o=yield*i,Sn(o)&&(n=void 0))}return c===void 0?yield*Jr(Error(`Machine process stopped receiving events before reaching a terminal configuration`)):c.output}).pipe(co(()=>u.stopAll()))}),t)}},wv=new WeakMap,Tv=(e,...t)=>{if(t.length>0)return Cv(e,{_tag:`Initial`,args:t});let n=wv.get(e);if(n!==void 0)return n;let r=Cv(e,{_tag:`Initial`,args:t});return wv.set(e,r),r},Ev=(e,t)=>Cv(e,{_tag:`Resume`,snapshot:t}),Dv=(e,...t)=>uv(Tv(e,...t),e.id===void 0?void 0:{id:e.id}),Ov=(e,t)=>cv(Ev(e,t),e.id===void 0?void 0:{id:e.id}),kv={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`]},Av=[`title`,`description`,`documentation`],jv=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Mv=(e,t)=>{let n=typeof t==`symbol`?`[${String(t)}]`:t===``?`<empty>`:String(t);return e===``?n:`${e}.${n}`},Nv=(e,t,n)=>{throw Error(`${e} invalid state definition at "${t}": ${n}`)},Pv=e=>Number.isFinite(Number(e)),Fv=e=>e.length===0||e.some(e=>e===`untagged`)?`untagged`:e.every(e=>e===`tagged`)?`tagged`:`opaque`,Iv=(e,t)=>{if(t.has(e))return`opaque`;if(po(e)||bn(e)||Ba(e)||$i(e)||Ro(e)||Wi(e))return`tagged`;if(Xr(e))return typeof e.literal==`string`||typeof e.literal==`number`?`tagged`:`untagged`;let n=new Set(t).add(e);return vo(e)?Fv(e.types.map(e=>Iv(e,n))):No(e)?Iv(e.thunk(),n):Ni(e)?`opaque`:`untagged`},Lv=(e,t=new Set)=>{if(t.has(e))return`opaque`;if(va(e)){let n=e.propertySignatures.find(({name:e})=>e===`_tag`)?.type;return n===void 0||Wo(n)?`untagged`:Iv(n,new Set(t).add(e))}let n=new Set(t).add(e);return vo(e)?Fv(e.types.map(e=>Lv(e,n))):No(e)?Lv(e.thunk(),n):Ni(e)?`opaque`:`untagged`},Rv=e=>Si(e)&&Lv(ca(e.ast))!==`untagged`,zv=(e,t,n)=>{let r=Mv(t,n);return typeof n==`symbol`?Nv(e,r,`state keys must be strings, not symbols`):typeof n==`number`?Nv(e,r,`state keys cannot use numeric forms`):n===``?Nv(e,r,`state keys cannot be empty`):n===`__proto__`?Nv(e,r,`the state key "__proto__" is not allowed`):n.includes(`.`)?Nv(e,r,`state keys cannot contain "."`):Pv(n)?Nv(e,r,`state keys cannot use numeric forms`):r},Bv=(e,t,n,r)=>{(typeof n!=`object`||!n||Array.isArray(n))&&Nv(e,t,`${r} must be a plain record`);let i=Object.getPrototypeOf(n);i!==Object.prototype&&i!==null&&Nv(e,Mv(t===`<root>`?``:t,`__proto__`),`${r} must not declare an implicit "__proto__" state key`)},Vv=(e,t,n,r,i)=>{if(typeof n!=`object`||!n||Array.isArray(n)||!jv(n,r))return;let a=n[r];(typeof a!=`object`||!a||Si(a)||a.type!==`history`)&&Nv(e,`${t}.${r}`,i)},Hv=(e,t,n,r)=>{let i=kv[r];for(let a of Reflect.ownKeys(n))i.includes(a)||Nv(e,t,`${r} states cannot declare property "${String(a)}"`)},Uv=(e,t,n)=>{Bv(e,`${t}.annotations`,n,`schema-less state annotations`);for(let r of Reflect.ownKeys(n))Av.includes(r)||Nv(e,`${t}.annotations`,`schema-less state annotations cannot declare property "${String(r)}"`),typeof n[r]!=`string`&&Nv(e,`${t}.annotations.${String(r)}`,`schema-less state annotation values must be strings`)},Wv=(e,t,n,r,i=!1)=>{Bv(e,n===``?`<root>`:n,t,`state trees`);for(let a of Reflect.ownKeys(t)){let o=i&&a===``?``:zv(e,n,a),s=t[a];if(Si(s)){Rv(s)||Nv(e,o,`state schemas must decode to an object with a required PropertyKey _tag`);continue}Bv(e,o,s,`state nodes`);let c=s.type,l=c===`history`?`history`:c===`choice`?`choice`:c===`parallel`?`parallel`:c===`final`?`final`:jv(s,`states`)?`compound`:`atomic`;if(Hv(e,o,s,l),l===`history`||l===`choice`){r||Nv(e,o,`${l} states must be declared below an active parent state`),jv(s,`annotations`)&&Uv(e,o,s.annotations),l===`history`&&jv(s,`history`)&&s.history!==`shallow`&&s.history!==`deep`&&Nv(e,`${o}.history`,`history must be "shallow" or "deep"`);continue}let u=jv(s,`schema`);u&&!Rv(s.schema)&&Nv(e,`${o}.schema`,`state schemas must decode to an object with a required PropertyKey _tag`),u&&jv(s,`annotations`)&&Nv(e,`${o}.annotations`,`schema-backed states must declare annotations on their schema`),!u&&jv(s,`annotations`)&&Uv(e,o,s.annotations),l===`atomic`&&jv(s,`type`)&&s.type!==`active`&&Nv(e,`${o}.type`,`atomic state type must be "active"`),l===`final`&&s.type!==`final`&&Nv(e,`${o}.type`,`final state type must be "final"`),l===`compound`&&jv(s,`type`)&&s.type!==`active`&&Nv(e,`${o}.type`,`compound state type must be "active"`),l===`parallel`&&s.type!==`parallel`&&Nv(e,`${o}.type`,`parallel state type must be "parallel"`),(l===`final`||l===`parallel`)&&jv(s,`output`)&&!Si(s.output)&&Nv(e,`${o}.output`,`state output must be an Effect Schema`),l===`compound`?(Vv(e,o,s.states,`initial`,`active and choice child states cannot use the reserved target selector key "initial"`),u&&Vv(e,o,s.states,`with`,`schema-backed compound child states cannot use the reserved local target selector key "with"`),Wv(e,s.states,o,!0)):l===`parallel`&&(jv(s,`states`)||Nv(e,`${o}.states`,`parallel states must declare child regions`),Vv(e,o,s.states,`initial`,`active and choice child states cannot use the reserved target selector key "initial"`),Wv(e,s.states,o,!0))}},Gv=e=>typeof e==`object`&&e?Object.freeze({...e}):e,Kv=e=>{let t={};for(let n of Object.keys(e)){let r=e[n];if(Si(r)){Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!1,writable:!1});continue}let i=r,a={...i};`states`in i&&(a.states=Kv(i.states)),`annotations`in i&&(a.annotations=Gv(i.annotations)),Object.defineProperty(t,n,{value:Object.freeze(a),enumerable:!0,configurable:!1,writable:!1})}return Object.freeze(t)},qv=e=>Kv(e),Jv=(e,t=``)=>{if(Si(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(jv(n,`fields`)&&(jv(n,`schema`)&&Nv(`Machine.state`,t,`declare fields or schema, not both`),Bv(`Machine.state`,t,n.fields,`state fields`),jv(n.fields,`_tag`)&&Nv(`Machine.state`,t,`state fields cannot declare _tag`),r.schema=$a(t,n.fields),delete r.fields),jv(n,`states`)){Bv(`Machine.state`,t,n.states,`child states`);let e=Object.create(null);for(let r of Reflect.ownKeys(n.states))zv(`Machine.state`,t,r),e[r]=Jv(n.states[r],r);r.states=e}return t===``?(Wv(`Machine.state`,{"":r},``,!1,!0),qv({"":r})[``]):r},Yv=`~effect/Machine`,Xv=`~effect/Machine/ChildMachine`,Zv={...Qn,..._n,[Yv]:Yv,toJSON(){return{_id:`Machine`}}},Qv=(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,ip(e,n),n},$v=e=>e.kind===`none`?uf:lf(e.kind,e.path,e.scope,e.updatePath),ey=e=>Object.freeze({path:e.path,kind:e.kind,scope:e.scope}),ty=e=>e.updatePath===void 0?e.kind===`update`&&e.path!==void 0?[e.path]:[]:[e.updatePath],ny=(e,t,n,r,i)=>{if(typeof e!=`object`||!e||!wi(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(!df(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`||!Fp(r,e.path)||!Fp(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}},ry=(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(!pf(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(!hf(e)||e.update.path!==t.updatePath)throw Error(`Machine target updating "${t.updatePath}" must return target construction .update(...)`)}else if(hf(e))throw Error(`Machine combined target requires an updating owner declaration`);if(e===void 0)return;let r=hf(e)?e.target:e,i=typeof r==`object`&&r&&wi(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&&Fp(i,t.path)))throw Error(`Machine transition resolver selected "${t.path}" but constructed "${i??`<invalid>`}"`)},iy=(e,t,n,r,i)=>{let a={...t,root:i===``?t.state:t.ancestors[``],decline:Sf};delete a.target;let o=e.resolve(a,n);if(Cf(o)){if(e.declinable!==!0)throw Error(`Machine transition for state "${i}" returned decline without declaring declinable: true`);return o}return ry(o,e.selection,r),o},ay=e=>e.kind===`update`?void 0:e.path,oy=e=>{let t=Number(e);return Number.isInteger(t)&&t>=0&&t<4294967295&&String(t)===e},sy=(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||oy(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||!wi(i,`target`))throw Error(`Machine transition branch "${r}" requires a target selection`);let{target:a,title:o}=i;if(!df(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:$v(a)})}))},cy=(e,t,n,r={},i)=>{let a=Tm(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 mf(Of(i.path,i.parent),Om(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`?wf(n.path,n.parent):Of(n.path,n.parent)}if(e.kind===`update`)return Om(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 mf(Dm(t,e.path,r,i),Om(t,e.updatePath,n))}return Dm(t,e.path,a,i)},ly=(e,t,n,r,i)=>Object.freeze(Object.fromEntries(e.map((e,a)=>[e.key,o=>gf(t,a,e.key,e.selection.kind===`none`?yf():cy(e.selection,n,r,o,i))]))),uy=(e,t,n)=>{if(t.kind===`none`){if(!bf(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`);ry(e,t,n)}},dy=(e,t)=>({...e,root:t===``?e.state:e.ancestors[``]}),fy=(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:ny({target:()=>Fm(t,i)},void 0,r,n,e).selection}]));return{branches:()=>a,reenter:i.reenter,declinable:f,resolve:(e,t)=>d&&!o(e)?Sf():s(e,t)}}let p=Fm(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 Sf();if(s!==void 0)return s(e,a);if(h)return cy(p,r,t,{input:g(e)});let l=u(e);return cy(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)}}},py=(e,t,n,r,i)=>{let a=fy(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(wi(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=sy(e.branches(),n,i),u=Object.freeze({}),d=(e,o)=>{let s={...e,root:n===``?e.state:e.ancestors[``],decline:Sf};delete s.target,s.select=ly(l,u,t,r,n);let d=a(s,o);if(Cf(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(!_f(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 uy(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=>ay(e.selection)===void 0?[]:[e.selection.path]))],branches:l.map(e=>Object.freeze({type:`branch`,key:e.key,title:e.title,target:ay(e.selection),selection:ey(e.selection),updates:ty(e.selection)})),evaluate:d,transition:(e,t)=>d(e,t).result}}let l=ny(a,void 0,t,n,i),u=(e,r)=>({result:iy(l,e,r,t,n),branchIndex:0,branchKey:void 0});return{reenter:s,declinable:c,targets:ay(l.selection)===void 0?[]:[l.selection.path],branches:[{type:`direct`,target:ay(l.selection),selection:ey(l.selection),updates:ty(l.selection)}],evaluate:u,transition:(e,t)=>u(e,t).result}},my=(e,t,n,r)=>{let i=Object.create(null);for(let a of Reflect.ownKeys(e))i[a]=py(e[a],t,n,r,a);return i},hy=(e,t,n,r)=>{let i=(Array.isArray(e)?e:[e]).map(e=>{let i=Im(r,e,n,e=>dy(e,n));for(let e of[`onElement`,`onDone`,`onFailure`,`onSnapshot`])i[e]!==void 0&&(i[e]=py(i[e],t,n,r,e));return qm(i,n)});return Ym(i,n),Array.isArray(e)?Object.freeze(i):i[0]},gy=(e,t,n,r,i,a)=>{for(let o of Object.keys(a)){let s=r===``?o:`${r}.${o}`;if(!wi(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=my(d,t,s,i)),u.always!==void 0&&(u.always=py(u.always,t,s,i,`always`)),u.onDone!==void 0&&(u.onDone=py(u.onDone,t,s,i,`done`)),u.choice!==void 0&&(u.choice=py(u.choice,t,s,i,`choice`)),u.invoke!==void 0&&(u.invoke=hy(u.invoke,t,s,i)),t.byPath.get(s)?.type===`choice`&&(typeof u.choice!=`object`||u.choice===null||!wi(u.choice,`transition`)||typeof u.choice.transition!=`function`||!wi(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=Af(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`);gy(e,t,r.states,s,i,l)}}},_y=e=>e===``?jm:e,vy=e=>{let t=!1;for(let n of e.stateNodes.byPath.values())if(n.type===`choice`){t=!0;break}if(!t)return;let n=Pf(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(!Fp(o,n)){let r=i.type===`branch`?`branch "${i.key}"`:`transition`;throw Error(`Machine transition from "${_y(e.source)}" updates "${_y(n)}" before choice "${t}", whose ${r} targets "${_y(o)}" outside that owner`)}}}}}}},yy=(e,t)=>(n=>{let r=Km(t.root,n),i=Object.assign(Object.create(Zv),e);if(ip(e,i),i.states=Object.freeze({"":r.node}),i.stateNodes=jf(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:Wm(n.root);i.initial=e=>({...Ef(``,a({input:e})),input:{value:e}}),i.initialDefinition=Object.freeze({target:``,selection:Object.freeze({path:``,kind:`initial`,scope:`initial`})});let o=Object.create(null);gy(o,i.stateNodes,i.states,``,{...t,initialize:e=>i.initial(i.input===void 0?void 0:Sp(i,i.input,e))},{"":r.handlers});let s=Qv(i,o);return vy(s),s}),by=e=>{let t=Jv(e),n=xy();return Object.freeze({...n,"~effect/Machine/State":`~effect/Machine/State`,node:t})},xy=()=>({path:(e=>e),get:((e,t)=>Bf(e,t).pipe(Tr(e=>e.value))),getWithParents:((e,t)=>{let n={};return Bf(e,t,n).pipe(Tr(e=>({value:e.value,parents:n})))}),getSnapshot:Bf,matches:((e,t)=>Ua(Bf(e,t)))}),Sy=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(_n);return n.states=t,n.root=e.root,n.events=e.events,n.internalEvents=e.internalEvents??lp(`internal`,[]),n.emittedEvents=e.emittedEvents??lp(`emitted`,[]),n.parent=e.parent,n.input=e.input,n.id=e.id,n.handlers=Object.create(null),n.handle=yy(n,Nm(e.root,e)),rp(n),n},Cy=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?[]:[En(e)]},wy=e=>lp(`public`,Cy(e)),Ty=(e,t)=>Ey(e,t,e=>t.input===void 0?Tv(t):Tv(t,e)),Ey=(e,t,n)=>({[Xv]:Xv,id:e,machine:t,[zm]:n}),Dy=Dv,Oy=Ov,ky=(e,t)=>{try{let n=tg(e,...t);return{machine:e,snapshot:n.done?{status:`done`,state:n.state,output:n.output}:{status:`active`,state:n.state}}}catch{return}},Ay=(e,t)=>{try{let n=ms(fv(e,t));if(n._tag===`Failure`)return;let r=n.value;if(!$h(e,r))return{machine:e,snapshot:{status:`active`,state:r}};let i=ms(eg(e,r,Qh));return i._tag===`Success`?{machine:e,snapshot:{status:`done`,state:r,output:i.value}}:void 0}catch{return}},jy={spawn:()=>Jr(Error(`Child operations are unavailable in a planned snapshot`)),sendTo:()=>Go(new Gd),stop:()=>Y},My=(e,t)=>{if(e.snapshot.status!==`active`)return Vr();try{let n=e.machine,r=nm(n,e.snapshot.state);for(let e of qp(n,r)){let i=fm(n,e);for(let a of Xm(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({...Mp(r)??mh(n,r),children:jy,state:r.values.get(e),containingState:Kp(n,r,e),ancestors:Gp(n,r,e),event:Qh}):a.input);let s=ky(i,i.input===void 0?[]:[o]);return s===void 0?void 0:ir(s)}}return Vr()}catch{return}},Ny=class extends Eo(`ChildNotActiveError`){},Py=new WeakMap,Fy=new WeakMap,Iy=e=>typeof e==`object`&&!!e&&Fy.has(e),Ly=e=>{if(typeof WeakRef>`u`||typeof FinalizationRegistry>`u`)return gs(e);let t=$r(),n=new FinalizationRegistry(({entry:e,key:n})=>{let r=Es(t,n);Ua(r)&&r.value===e&&An(t,n)});return r=>{let i=Es(t,r);if(Ua(i)){let e=i.value.ref.deref();if(e!==void 0)return e}let a=e(r),o={ref:new WeakRef(a)};return xi(t,r,o),n.register(a,{key:r,entry:o}),a}},Ry=(e,t)=>Fn(bi(t,e=>e.stop).pipe(zr(t=>K(()=>e.setSelf(Yn(t)))),Po(()=>Co))),zy=(e,t)=>Ry(e,e.result(t).pipe(Po(e=>e.start))),By=(e,t,n)=>Ry(e,Oy(t,n)),Vy=(e,t)=>`~effect-atom/atom/Atom/ServerValue`in e?e[Qo](t):t(e),Hy=(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}},Uy=e=>{let t;return()=>(t===void 0&&(t={value:e()}),t.value)},Wy=e=>e.snapshot,Gy=si(e=>e.registry).pipe(ti),Ky=e=>Gn(()=>{let t=e.pending.shift();return t===void 0?(e.draining=!1,Y):X(t,Ky(e))}),qy=(e,t)=>{let n=e.get(t);return n===void 0&&(n={pending:[],draining:!1},e.set(t,n)),n},Jy=(e,t,n)=>wr(n=>{let r=Ci(n(e),()=>void 0),i=t.get(n.registry);return i===void 0||!i.draining?r:Ir(Tr(n.self(),pr),()=>Ss(!0))},(r,i)=>{let a=r.get(e),o=r.get(Gy),s=qy(t,o);_i(a)||s.draining?(r.setSelf(Ss(!0)),s.pending.push(kr(o,e).pipe(Po(e=>n(e,i)),ya,ma(e=>{let t=vr(e);r.setSelf(s.pending.length===0?t:pr(t))}))),s.draining||(s.draining=!0,ns(Ky(s)))):Dn(a)?r.setSelf(Ci(a,()=>void 0)):Ji(n(a.value,i),{onExit:e=>r.setSelf(vr(e))})}).pipe(Ha),Yy=e=>si(t=>{let n=t(e);return _i(n)?Ss(n.waiting):Dn(n)?rr(n.cause,{previous:t.self(),waiting:n.waiting}):n.value.status===`error`?rr(n.value.cause,{previous:t.self(),waiting:n.waiting}):Yn(n.value.state,{waiting:n.waiting})}).pipe(Fr(mi),xn(Hy(t=>[Vy(e,t)],e=>Ci(e,e=>e.state)))),Xy=e=>si(t=>{let n=t(e);if(_i(n))return Ss(n.waiting);if(Dn(n))return rr(n.cause,{previous:t.self(),waiting:n.waiting});if(Sn(n.value)){let e=t.self();return Ua(e)&&Dn(e.value)?e.value:Yn(Vr(),{waiting:n.waiting})}return n.value.value.status===`error`?rr(n.value.value.cause,{previous:t.self(),waiting:n.waiting}):Yn(ir(n.value.value.state),{waiting:n.waiting})}).pipe(Fr(mi),xn(Hy(t=>[Vy(e,t)],e=>Ci(e,Tr(e=>e.state))))),Zy=(e,t)=>si(n=>{let r=n(e);if(_i(r))return Ss(r.waiting);if(Dn(r))return rr(r.cause,{previous:n.self(),waiting:r.waiting});if(Sn(r.value))return Yn(Vr());let i=r.value.value,a=aa(i.child(t)),o=Ji(Sr.pipe(X(i.childChanges(t).pipe(Bn(e=>K(()=>n.setSelf(Yn(e))))))));return n.addFinalizer(o),Yn(a)}).pipe(Ha),Qy=(e,t)=>Zg(e)?e[Xg](()=>t(aa(e.snapshot))):Ji(e.changes.pipe(Bn(e=>K(()=>t(e))))),$y=(e,t,n)=>{let r=si(t=>{let n=t(e);if(_i(n))return Ss(n.waiting);if(Dn(n))return rr(n.cause,{previous:t.self(),waiting:n.waiting});if(Sn(n.value))return Yn(Vr());let r=n.value.value;return t.addFinalizer(Qy(r,e=>t.setSelf(Yn(ir(e))))),Yn(ir(aa(r.snapshot)))}).pipe(xn(Hy(()=>[],()=>{let e=n();return e===void 0?Ss(!0):Yn(Tr(e,Wy),{waiting:!0})}))),i=new WeakMap,a=e=>Ua(e)?di(e.value):Go(new Ny({id:t.id})),o=Jy(e,i,(e,t)=>Po(a(e),e=>e.send(t))),s=Jy(e,i,(e,t)=>Po(a(e),e=>e.stop)),c=eb(e,n);return{ref:e,snapshot:r,result:Xy(r),send:o,stop:s,child:c}},eb=(e,t)=>{let n=new WeakMap;return r=>{let i=n.get(r.machine);if(i===void 0){let a=r.machine,o=gs(n=>{let r=Ty(n,a);return $y(Zy(e,r),r,Uy(()=>{let e=t();return e===void 0||Sn(e)?e:My(e.value,r)}))});i=e=>o(e),n.set(a,i)}return i(r.id)}},tb=(e,t,n)=>{let r=Ha(e),i=si(e=>{let t=e(r);if(_i(t))return Ss(t.waiting);if(Dn(t))return rr(t.cause,{previous:e.self(),waiting:t.waiting});let n=t.value;e.addFinalizer(Qy(n,t=>e.setSelf(Yn(t,{waiting:t.status===`active`}))));let i=aa(n.snapshot);return Yn(i,{waiting:i.status===`active`})}).pipe(xn(Hy(()=>[],()=>{let e=n();return e===void 0?Ss(!0):Yn(Wy(e),{waiting:!0})}))),a=new WeakMap,o=Jy(r,a,(e,t)=>e.send(t)),s=Jy(r,a,(e,t)=>e.stop),c=eb(is(r,ir),()=>{let e=n();return e===void 0?void 0:ir(e)}),l={ref:r,snapshot:i,result:Yy(i),send:o,stop:s,child:c};return Fy.set(l,t),l},nb=(e,t)=>Bf(e,t).pipe(Tr(e=>e.value)),rb=(e,t)=>Bf(e,t),ib=(e,t)=>is(e,t).pipe(Fr(mi),xn(Hy(t=>[Vy(e,t)],e=>Ci(e,t)))),ab=new WeakMap,ob=(e,t,n,r)=>{let i=ab.get(e);i===void 0&&(i=new Map,ab.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},sb=(e,t)=>ob(e,`select`,t,()=>ib(e.result,e=>nb(e,t))),cb=(e,t)=>ob(e,`selectSnapshot`,t,()=>ib(e.result,e=>rb(e,t))),lb=(e,t)=>ob(e,`selectChild`,t,()=>ib(e.result,ci(e=>nb(e,t)))),ub=(e,t)=>ob(e,`selectSnapshotChild`,t,()=>ib(e.result,ci(e=>rb(e,t)))),db=(e,t)=>ob(e,`matches`,t,()=>ib(e.result,e=>Ua(Bf(e,t)))),fb=(e,t)=>ob(e,`matchesChild`,t,()=>ib(e.result,Mn(e=>Ua(Bf(e,t))))),pb=(e,t,n)=>{let r=e.atom(()=>Dy(t,...n)),i=tb(e.atom(e=>zy(e,r)),t,Uy(()=>ky(t,n)));return Py.set(i,r),i},mb=(e,t,n)=>tb(e.atom(e=>By(e,t,n)),t,Uy(()=>Ay(t,n))),hb=(e,t,n)=>{let r={owner:e,source:t},i=Ln(t,e=>e(r.source),{initialValueTarget:t}).pipe(Fr((e,t)=>r.source.equals(e,t)),xn(e=>Vy(r.source,e)));return n!==void 0&&(i=i.pipe(Ja(n))),i},gb=(e,t)=>{let n=Ly(t=>({bridge:e(t)})),r={};for(let e of Object.keys(t.atoms)){let i=t.atoms[e];r[e]=Ly(r=>{let a=n(r);return hb(a,i(a.bridge),t.label?.(r,e))})}return r},_b=e=>{let t=((t,...n)=>pb(e,t,n));return{make:t,factory:(e=>(...n)=>t(e,...n)),resume:((t,n)=>mb(e,t,n)),family:((t,n)=>gb(n=>pb(e,t,[n]),n))}},vb=Iy;Bi(2,sb);var yb=Bi(2,cb);Bi(2,lb);var bb=Bi(2,ub);Bi(2,db),Bi(2,fb);var xb=_b;function Sb(e){let t=(0,qs.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=Xt(`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 Cb(e){let t=(0,qs.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-10 items-center gap-3 border-b px-1`,children:[e.media===!0&&(0,Q.jsx)(Sb,{className:`size-5`}),(0,Q.jsx)(Sb,{className:`h-4 w-1/3`})]},t),t[3]=e.media,t[4]=n),r=xo(Ma(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 wb=Z.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return v(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});jt(`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 Tb(e){let t=(0,qs.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=Xt(`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 Eb(e){let t=(0,qs.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(Ob)).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(Db)}),t[7]=r,t[8]=a),o=a}let s=o;if(!s)return null;let c;t[9]===r?c=t[10]:(c=Xt(`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 Db(e,t){return e?.message&&(0,Q.jsx)(`li`,{children:e.message},t)}function Ob(e){return[e?.message,e]}var kb=new Uint8Array(512),Ab=new Uint8Array(256);for(let e=0,t=1;e<255;e++)kb[e]=t,Ab[t]=e,t<<=1,256&t&&(t^=285);for(let e=255;e<512;e++)kb[e]=kb[e-255];var jb=(e,t)=>e>0&&t>0?kb[Ab[e]+Ab[t]]:0,Mb=(e,t)=>kb[t*Ab[e]%255],Nb=e=>{let t=new Uint8Array(e+2),n=new Uint8Array(e+1);n[0]=1;for(let r=0;r<e;r++){let e=Mb(2,r);t.fill(0,0,r+2);for(let i=0;i<r+1;i++)t[i]^=n[i],t[i+1]^=jb(n[i],e);for(let e=0;e<r+2;e++)n[e]=t[e]}return n},Pb=(e,t)=>{let n=Nb(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]^=jb(n[i],e)}return r.subarray(e.byteLength)},Fb=[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],Ib=[[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]],Lb=[[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]],Rb=[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],zb=[[],[],[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]],Bb=(e,t,n)=>{let r=Fb[t]-Ib[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},Vb=(e,t)=>{for(let n=1;n<=40;n++){let r=Fb[n]-Ib[n][t];if(r-=n>9?3:2,r>=e.byteLength)return n}throw RangeError(`Bytes exceed max length`)},Hb=(e,t,n)=>{let r=e.byteLength+Ib[t][n],i=Lb[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=Pb(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},Ub=(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)},Wb=(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}},Gb=(e,t,n)=>{let r=n-7;Wb(e,n,0,0,7),Wb(e,n,r,0,7),Wb(e,n,0,r,7),Ub(t,n,0,0,8),Ub(t,n,r-1,0,8),Ub(t,n,0,r-1,8)},Kb=(e,t,n,r)=>{let i=zb[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];Wb(e,n,a,r,5),Ub(t,n,a,r,5)}}},qb=(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)}},Jb=(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},Yb=(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}},Xb=(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}},Zb=(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)}},Qb=(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)}},$b=(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)}},ex=(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)}},tx=(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)}}},nx=(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)}},rx=(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)}},ix=(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)}},ax=(e,t,n,r)=>{switch(r){case 0:return Zb(e,t,n);case 1:return Qb(e,t,n);case 2:return $b(e,t,n);case 3:return ex(e,t,n);case 4:return tx(e,t,n);case 5:return nx(e,t,n);case 6:return rx(e,t,n);case 7:return ix(e,t,n)}},ox=(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},sx=(e,t,n)=>{let r=0,i=0,a=new Uint8Array(e.byteLength);for(let o=0;o<=7;o+=1){a.set(e),ax(a,t,n,o);let s=ox(a,n);(o===0||s<r)&&(r=s,i=o)}return ax(e,t,n,i),i},cx=(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)},lx=(e,t,n,r)=>{let i=cx(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},ux=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},dx=(e,t,n)=>{if(n>=7){let r=ux(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}}},fx=(e,t)=>{let n=Vb(e,t),r=Hb(Bb(e,n,t),n,t),i=Rb[n],a=new Uint8Array(i*i),o=new Uint8Array(i*i);return Gb(a,o,i),Kb(a,o,i,n),qb(a,o,i),Jb(o,i),Yb(o,i,n),Xb(a,o,i,r),lx(a,i,t,sx(a,o,i)),dx(a,i,n),a},px=new TextEncoder,mx=(e,t=1)=>fx(typeof e==`string`?px.encode(e):e,t);function hx(e){let t=Gs.unstable_scheduleCallback(4,e);return()=>Gs.unstable_cancelCallback(t)}var gx=Z.createContext(Br({scheduleTask:hx,defaultIdleTTL:400})),_x=new WeakMap,vx=0,yx=new Set;function bx(e){vx++;try{return e()}finally{vx--}}function xx(e){if(vx===0)return e();yx.size===0&&queueMicrotask(Sx),yx.add(e)}function Sx(){for(let e of yx)yx.delete(e),e()}function Cx(e,t){let n=_x.get(e);n===void 0&&(n=new WeakMap,_x.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,()=>xx(n));return()=>{i--,yx.delete(n),r()}},snapshot(){return bx(()=>e.get(t))},getServerSnapshot(){return(i===0||a===void 0)&&(a={value:bx(()=>us(t,e))}),a.value}};return n.set(t,o),o}function wx(e,t){let n=Cx(e,t);return Z.useEffect(Sx),Z.useSyncExternalStore(n.subscribe,n.snapshot,n.getServerSnapshot)}function Tx(e,t,n){let r=Cx(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(Sx),Z.useSyncExternalStore(r.subscribe,()=>i(r.snapshot()),()=>i(r.getServerSnapshot()))}var Ex=(e,t)=>{let n=Z.useContext(gx);return t?Tx(n,e,t):wx(n,e)};function Dx(e,t,n){return n?.mode===`promise`||n?.mode===`promiseExit`?Z.useCallback(r=>{e.set(t,r);let i=bs(kr(e,t,{suspendOnWaiting:!0}));return n.mode===`promise`?i.then(Ox):i},[e,t,n.mode]):Z.useCallback(n=>{e.set(t,typeof n==`function`?n(e.get(t)):n)},[e,t])}var Ox=e=>{if(Wa(e))return e.value;throw mr(e.cause)},kx=(e,t)=>{let n=Z.useContext(gx);return[wx(n,e),Dx(n,e,t)]};function Ax({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=Z.useRef(e!==void 0),[a,o]=Z.useState(()=>t);return[i&&e!==void 0?e:a,Z.useCallback(e=>{i||o(e)},[])]}function jx(e){let t=Z.useRef(!0);t.current&&(t.current=!1,e())}function Mx(e,t,n,r,i,a,o,s,c,l=2){let u=He(n.current,{event:e,orientation:r,loopFocus:i,rtl:a,cols:l,disabledIndices:o,minIndex:s,maxIndex:c,prevIndex:t>c?s:t,stopEvent:!0});return Mt(n.current,u)?void 0:u}function Nx(e){return e==null?tn:e.type.startsWith(`key`)?pt:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?Qe:tn}var Px=Z.createContext(void 0),Fx=Z.createContext(void 0),Ix=Z.createContext(void 0),Lx=Z.createContext(!1),Rx=Z.createContext(``);function zx(){let e=Z.useContext(Px);if(!e)throw Error(B(22));return e}function Bx(){let e=Z.useContext(Fx);if(!e)throw Error(B(23));return e}function Vx(){let e=Z.useContext(Ix);if(!e)throw Error(B(24));return e}function Hx(){return Z.useContext(Rx)}function Ux(){return Z.useContext(Lx)}function Wx(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var Gx=(e,t)=>Object.is(e,t);function Kx(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function qx(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!Wx(e,t,(e,t)=>Kx(e,t,n)):e!==t}function Jx(e,t,n){return e?e.some(e=>e!==void 0&&Kx(t,e,n)):!1}function Yx(e,t,n){return e?e.findIndex(e=>e!==void 0&&Kx(e,t,n)):-1}function Xx(e,t){if(t!==Gx)return n=>Jx(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function Zx(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(Xx(t,n)):Yx(e,t,n);return i===-1?null:i}function Qx(e,t,n,r,i,a){return Jx(r,t,i)?a!=null&&e>a&&Jx(r,n[a],i)?a:e:e===a?Zx(n,r,i,!0):a}function $x(e,t,n){return e.filter(e=>!Kx(t,e,n))}function eS(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function tS(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function nS(e){return tS(e?.[0])}function rS(e){return nS(e)?e.flatMap(e=>e.items):e}function iS(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(nS(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function aS(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return eS(e)}function oS(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?eS(e.value):eS(e)}var sS={id:e=>e.id,labelId:e=>e.labelId,items:e=>e.items,selectedValue:e=>e.selectedValue,hasSelectionChips:e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0},hasSelectedValue:e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0},hasNullItemLabel:(e,t)=>t?iS(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMounted:e=>e.forceMounted,inline:e=>e.inline,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>Kx(t,e,n)):Kx(t,r,n)},transitionStatus:e=>e.transitionStatus,popupProps:e=>e.popupProps,listProps:e=>e.listProps,inputProps:e=>e.inputProps,triggerProps:e=>e.triggerProps,itemRoot:e=>e.itemRoot,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupId:e=>e.popupId,triggerElement:e=>e.triggerElement,inputElement:e=>e.inputElement,inputGroupElement:e=>e.inputGroupElement,popupSide:e=>e.popupSide,openMethod:e=>e.openMethod,inputInsidePopup:e=>e.inputInsidePopup,inputOwnsFormValue:e=>e.inputOwnsFormValue,selectionMode:e=>e.selectionMode,name:e=>e.name,form:e=>e.form,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,grid:e=>e.grid,virtualized:e=>e.virtualized,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,modal:e=>e.modal,autoHighlight:e=>e.autoHighlight},cS=`data-valid`,lS=`data-invalid`,uS={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},dS={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},fS={disabled:!1,...dS},pS={valid(e){return e===null?null:e?{[cS]:``}:{[lS]:``}}},mS={invalid:void 0,name:void 0,validityData:{state:uS,errors:[],error:``,value:``,initialValue:null},setValidityData:w,disabled:void 0,setTouched:w,setDirty:w,setFilled:w,setFocused:w,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:fS,registerFieldControl:w,validation:{getValidationProps:(e,t=Ee)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:w,getInputControl:()=>null,commit:async()=>{},change:w}},hS=Z.createContext(mS);function gS(e=!0){let t=Z.useContext(hS);if(t.setValidityData===w&&!e)throw Error(B(28));return t}function _S(e,t,n,r,i=!0,a){let{registerFieldControl:o}=gS(),s=F(()=>Symbol());V(()=>{let c=s.current;i?o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}):o(c,void 0)},[e,i,r,t,a,o,s,n]),V(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var vS=Z.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:w,validationMode:`onSubmit`,submitCountRef:{current:0}});function yS(){return Z.useContext(vS)}function bS(e){return b(e,`base-ui`)}var xS=Z.createContext({controlId:void 0,registerControlId:w,resetControlId:w,labelId:void 0,setLabelId:w,messageIds:[],setMessageIds:w,getDescriptionProps:e=>e});function SS(){return Z.useContext(xS)}function CS(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=SS(),o=bS(),s=F(()=>Symbol()),c=Z.useRef(!1),l=Z.useRef(!1),u=D(()=>{c.current&&i!==w&&(c.current=!1,i(s.current,void 0))});return V(()=>{if(!n||i===w){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}e===void 0?u():(c.current=!0,i(s.current,e))},[t,n,i,a,o,s,u]),V(()=>u,[u]),(n?r:void 0)??t??o}function wS(e){return e==null?void 0:`${e}-popup`}function TS(e,t){return(n,r)=>n!=null&&e.contains(n,r,t)}function ES(e){return Array.isArray(e)?e.map(e=>ES(e)).join(`,`):e==null?``:String(e)}var DS=new Map;function OS(e={}){let{locale:t,...n}=e,r={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...n},i=`${ES(t)}|${JSON.stringify(r)}`,a=DS.get(i);if(a)return a;let o=new Intl.Collator(t,r),s={contains(e,t,n){if(!t)return!0;let r=aS(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(o.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=aS(e,n);return o.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=aS(e,n),i=t.length;return r.length>=i&&o.compare(r.slice(r.length-i),t)===0}};return DS.set(i,s),s}var kS=OS;function AS(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 jS(e,t){let n=Z.useRef(e),r=D(t);V(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function MS(e,t){let{onClick:n,onPointerDown:r}=AS(D((n,r)=>{(typeof e==`function`?e():e)||t(r||(st?`touch`:``))}));return Z.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function NS(e){let[t,n]=Z.useState(null),r=MS(e,n);return jS(e,t=>{t&&!e&&n(null)}),Z.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}var PS=Symbol(`none`),FS={value:PS,index:-1};function IS(e,t,n){let r=e.get(t);if(r!==void 0||n===Gx)return r;for(let[r,i]of e)if(Kx(r,t,n))return i}function LS(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:a,defaultInputValue:o,inputValue:s,open:c,defaultOpen:l=!1,selectionMode:u,onItemHighlighted:d,name:f,form:p,disabled:h=!1,readOnly:g=!1,required:_=!1,inputRef:v,grid:y=!1,items:b,filteredItems:S,filter:T,filterQuery:E,openOnInputClick:O=!0,autoHighlight:k=!1,keepHighlight:A=!1,highlightItemOnHover:M=!0,loopFocus:N=!0,itemToStringLabel:ee,itemToStringValue:P,isItemEqualToValue:I=Gx,virtualized:te=!1,inline:re=!1,fillInputOnItemPress:ie=!0,modal:oe=!1,limit:R=-1,autoComplete:z=`list`,formAutoComplete:se,locale:ce,submitOnItemClick:le=!1}=e,{clearErrors:de}=yS(),{setDirty:fe,validityData:pe,setFilled:me,name:he,disabled:ge,setTouched:_e,setFocused:ve,validationMode:ye,validation:be}=gS(),xe=$u(),Se=CS({id:t}),Ce=kS({locale:ce}),we=Array.isArray(b)?null:b;if(we&&typeof we.label!=`function`)throw Error(B(100));let Te=we?we.data:b,De=we?.value,U=De?void 0:Te,ke=Z.useMemo(()=>{if(!S||!De)return;let e=rS(S),t=e.map(De),n;return{values:t,findItem(r,i){if(!n){n=new Map;for(let r=0;r<t.length;r+=1)n.has(t[r])||n.set(t[r],e[r])}return IS(n,r,i)}}},[S,De]),je=Z.useMemo(()=>we?e=>we.label(e,I,e=>{let t=ke?.findItem(e,I);return t==null?aS(e,ee):we.itemLabel(t)}):ee,[we,ee,ke,I]),Me=Z.useMemo(()=>we?Object.assign(e=>we.itemLabel(e),{selected:e=>aS(e,je)}):ee,[we,je,ee]);function Ne(e){return aS(e,je)}let[Pe,Fe]=Z.useState(!1),[Ie,Le]=Z.useState(null),Re=Z.useRef(Ie),ze=Z.useRef([]),Be=Z.useRef([]),Ve=Z.useRef(null),He=Z.useRef(null),Ue=Z.useRef(null),We=Z.useRef(null),Ge=Z.useRef(null),Ke=Z.useRef(!1),qe=Z.useRef(null),Je=Z.useRef(null),Ye=Z.useRef(null),Xe=Z.useRef(FS),Ze=Z.useRef(null),Qe=Z.useRef([]),$e=Z.useRef(null),et=ge||h,tt=he??f,nt=u===`multiple`,rt=u===`single`,at=s!==void 0||o!==void 0,ot=Te!==void 0,st=S!==void 0,ct;ct=k===`always`?`always`:k?`input-change`:!1;let[lt,dt]=Ax({controlled:i,default:nt?r??an:r,name:`Combobox`,state:`selectedValue`}),ft=Z.useMemo(()=>T===null?()=>!0:T===void 0?TS(Ce,Me):T,[T,Ce,Me]),pt=F(()=>at?o??``:rt?Ne(lt):``).current,[mt,gt]=Ax({controlled:s,default:pt,name:`Combobox`,state:`inputValue`}),[_t,yt]=Ax({controlled:c,default:l,name:`Combobox`,state:`open`}),bt=nS(Te),xt=!_t&&Ie!==null?Ie:String(mt).trim(),St=rt?Ne(lt):``,Ct=rt&&!Pe&&xt!==``&&St.length===xt.length&&Ce.contains(St,xt),wt=Ct?``:E??xt,Tt=ot&&st&&Ct&&(!we||we.hasValue(lt,I)),Et=Z.useMemo(()=>Te?rS(Te):an,[Te]),Ot=Z.useMemo(()=>{if(S&&!Tt)return S;if(!Te)return an;if(bt){let e=Te,t=[],n=0;for(let r of e){if(R>-1&&n>=R)break;let e=R>-1?R-n:1/0,i=wt===``?r.items.slice(0,e):[];if(wt!==``)for(let t of r.items){if(i.length>=e)break;ft(t,wt,Me)&&i.push(t)}if(i.length>0){let e={...r,items:i};t.push(e),n+=i.length}}return t}if(wt===``)return R>-1?Et.slice(0,R):Et;let e=[];for(let t of Et){if(R>-1&&e.length>=R)break;ft(t,wt,Me)&&e.push(t)}return e},[S,Tt,Te,bt,wt,R,ft,Me,Et]),kt=Z.useMemo(()=>{if(ke&&Ot===S)return ke.values;let e=rS(Ot);return De?e.map(e=>De(e)):e},[Ot,S,ke,De]),W=F(()=>{let e=null;return re&&_t&&ot&&u!==`none`&&(e=Zx(kt,lt,I,nt)),new vt({id:Se,labelId:void 0,selectedValue:lt,open:_t,items:U,selectionMode:u,name:tt,form:p,disabled:et,readOnly:g,required:_,grid:y,virtualized:te,openOnInputClick:O,itemToStringLabel:je,isItemEqualToValue:I,modal:oe,autoHighlight:ct,submitOnItemClick:le,hasInputValue:at,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:re,activeIndex:null,selectedIndex:e,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemRoot:{props:Ee,id:Se,selectionMode:u,disabled:et,readOnly:g,isItemEqualToValue:I},positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:u===`none`},{onOpenChangeComplete:w,setOpen:w,setInputValue:w,setSelectedValue:w,setIndices:w,handleSelection:w,forceMount:w,requestSubmit:w,listRef:ze,labelsRef:Be,popupRef:Ve,emptyRef:Ge,inputRef:He,startDismissRef:Ue,endDismissRef:We,chipsContainerRef:qe,clearRef:Je,valuesRef:Qe,pointerDownItemRef:$e,selectionEventRef:Ye},sS)}).current,At=u===`none`?mt:lt,jt=Z.useMemo(()=>u===`none`?At:Array.isArray(lt)?lt.map(e=>oS(e,P)):oS(lt,P),[At,P,u,lt]),Mt=D(d),Nt=D(n),Pt=W.useState(`activeIndex`),Ft=W.useState(`selectedIndex`),Lt=W.useState(`positionerElement`),Rt=W.useState(`listElement`),zt=W.useState(`triggerElement`),Bt=W.useState(`inputElement`),Vt=W.useState(`inputGroupElement`),Ht=W.useState(`inline`),Ut=W.useState(`inputInsidePopup`),Wt=W.useState(`inputOwnsFormValue`),Gt=rt&&!Ut&&mt===St,Kt=lc(zt),{openMethod:qt,triggerProps:Jt}=NS(_t),Yt=D(()=>jt);_S(Ut?Kt:He,Se,At,Yt,!et,f);let Xt=D(()=>{Te?Be.current=kt.map(Ne):W.set(`forceMounted`,!0)}),Zt=D((e,t,n,r)=>{if(t===-1){if(Xe.current===FS)return;Xe.current=FS}else Xe.current={value:e,index:t};Mt(e,C(n,r,{index:t}))}),Qt=D(e=>{let t={};e.activeIndex!==void 0&&(t.activeIndex=e.activeIndex),e.selectedIndex!==void 0&&(t.selectedIndex=e.selectedIndex),W.update(t);let n=e.activeIndex;if(n===void 0)return;let r=e.type||`none`;n===null?Zt(void 0,-1,r,e.event):Zt(Qe.current[n],n,r,e.event)}),$t=D((t,n)=>{if(e.onInputValueChange?.(t,n),!n.isCanceled){if(Ke.current=n.reason===It,n.reason===`input-change`){_t&&Ie!==null&&Le(null);let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&Fe(!0),Ze.current={hasQuery:e};let n=W.state.listElement;if(!W.state.virtualized&&n){let e=Ve.current;for(let t of Oe(n.firstElementChild??n)){if(!ne(t)||(e?!G(e,t):t.getAttribute(`role`)===`dialog`))break;if(cc(t)){t.scrollTop=0;break}}}e&&ct&&W.state.activeIndex==null&&(_t||Ht)&&W.set(`activeIndex`,0)}}else n.reason===`input-clear`&&t===``&&W.state.inputInsidePopup&&(Ze.current={hasQuery:!1,selection:!0});gt(t)}}),en=D(e=>{let t=!e&&Ut&&!Ht&&mt!==``&&(String(mt).trim()===Ie||mt===St);!e&&(t||mt===``||Gt)&&Fe(!1),Le(null),t&&$t(``,H(It))}),[nn,rn]=Z.useState(!1),on=D((t,n)=>{if(_t===t)return;n.reason===`escape-key`&&ot&&kt.length===0&&!Ge.current&&n.allowPropagation();let r=n,i=el(r);if(e.onOpenChange?.(t,r),Ze.current?.hasQuery&&n.reason===`input-change`===n.isCanceled&&(Ze.current=null),!n.isCanceled&&(t&&Ie!==null&&en(n.reason===ut),!t&&Pe&&(rt?(Ht||Le(xt),xt===``&&Fe(!1)):nt&&(Ht||Le(xt),Ut&&Qt({activeIndex:null}),(!Ut||Ht)&&$t(``,H(It,n.event,void 0,{isItemPress:n.reason===ht})))),t||rn(i()),yt(t),!t&&Ut&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(_e(!0),ve(!1),ye===`onBlur`))){let e=u===`none`?mt:lt;be.commit(e)}}),sn=D((e,t)=>{a?.(e,t),!t.isCanceled&&(dt(e),(u===`none`&&Ve.current&&ie||rt&&!W.state.inputInsidePopup)&&$t(Ne(e),H(t.reason,t.event)))}),cn=D((e,t)=>{let n=L(e),r=Ye.current??e;Ye.current=null;let i=H(ht,r),a=ae(n,`a`)?.getAttribute(`href`);if(a)a.startsWith(`#`)&&on(!1,i);else if(nt){let e=Array.isArray(lt)?lt:[],n=Jx(e,t,I),r=n?$x(e,t,I):[...e,t];if(sn(r,i),i.isCanceled||!(He.current&&He.current.value.trim()!==``))return;if(W.state.inputInsidePopup){$t(``,H(It,i.event,void 0,{isItemPress:!0}));let e=Ze.current;e&&!n&&(e.toggledValue=t)}else on(!1,i)}else{if(sn(t,i),i.isCanceled)return;on(!1,i)}}),ln=D(()=>{let e=be.inputRef.current?.form??W.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),un=D(()=>{if(Nt?.(!1),Fe(!1),Le(null),Qt(u===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),nt&&He.current&&He.current.value!==``&&!Ke.current&&$t(``,H(It)),rt){if(W.state.inputInsidePopup)He.current&&He.current.value!==``&&$t(``,H(It));else{let e=Ne(lt);He.current&&He.current.value!==e&&$t(e,H(e===``?It:tn))}}}),dn=Z.useMemo(()=>Ht&&Lt?{current:ae(Lt,`[role="dialog"]`)}:Ve,[Ht,Lt]),{mounted:fn,transitionStatus:pn,forceUnmount:mn}=Jc({open:_t,ref:dn,preventUnmountOnClose:nn,setPreventUnmountOnClose:rn,onUnmount:un});Z.useImperativeHandle(e.actionsRef,()=>({unmount:mn,close:()=>on(!1,H(it))}),[mn,on]),V(function(){let e=Re.current!==null&&Ie===null;if(Re.current=Ie,_t&&(!e||!ot)||(_t||($e.current=null),u===`none`))return;let t=ot?kt:Qe.current;Qt({selectedIndex:Zx(t,lt,I,nt)})},[_t,Ie,lt,u,nt,ot,kt,I,Qt]),V(()=>{Te&&(Qe.current=kt,ze.current.length=kt.length)},[Te,kt]),V(()=>{!_t&&Ze.current?.hasQuery&&(Ze.current=null)},[_t]),V(()=>{if(!_t&&Ht&&dn.current){Ze.current=null;return}let e=ot||st?kt:Qe.current,t=Ze.current;if(t){let n=_t||Ht||W.state.positionerElement?.hidden===!1;if(t.hasQuery){let t=He.current;!ct||String(mt).trim()===``||Ht&&ct!==`always`&&(!t||j(t.ownerDocument)!==t)?Ze.current=null:n&&(e[0]!==void 0||!ot&&!st)&&(W.set(`activeIndex`,0),Ze.current=null)}else if(String(mt).trim()===``&&(Ze.current=null,n)){let e=t.selection;ct===`always`&&!e&&W.state.selectionMode===`none`&&W.set(`activeIndex`,0),queueMicrotask(()=>{if(!W.state.open&&(!W.state.inline||dn.current)||He.current&&He.current.value.trim()!==``)return;let n=W.state.selectedValue,r=W.state.selectionMode===`multiple`;if(r&&Array.isArray(n)?n.length>0:W.state.selectionMode!==`none`&&n!=null){let e=ot||st?kt:Qe.current,i=Yx(e,t.toggledValue,W.state.isItemEqualToValue);W.set(`activeIndex`,i===-1?Zx(e,n,W.state.isItemEqualToValue,r):i)}else e?W.set(`activeIndex`,null):ct===`always`&&W.set(`activeIndex`,0)})}}if(!_t&&!Ht)return;let n=W.state.activeIndex;if(n==null){if(ct===`always`&&e.length>0){W.set(`activeIndex`,0);return}Zt(void 0,-1,tn);return}if(n>=e.length){Zt(void 0,-1,tn),W.set(`activeIndex`,null);return}let r=e[n],i=Xe.current.value,a=i!==PS&&Kx(r,i,W.state.isItemEqualToValue);Xe.current.index===n&&a||Zt(r,n,tn)},[Pt,ct,Zt,st,ot,kt,Ht,_t,dn,W,mt]),V(()=>{me(u===`none`?String(mt)!==``:nt?Array.isArray(lt)&&lt.length>0:lt!=null)},[me,u,mt,lt,nt]),Z.useEffect(()=>{ot&&ct&&kt.length===0&&Qt({activeIndex:null})},[ot,ct,kt.length,Qt]);function hn(){_t&&xt!==``&&xt!==String(pt)&&!Gt&&Fe(!0)}function gn(){_t&&Ie!==null&&en(!1)}let _n=!1;function vn(){!_n&&mt!==St&&(_n=!0,$t(St,H(tn)))}function yn(){u!==`none`&&(de(tt),fe(qx(lt,pe.initialValue,I)),be.change(lt),rt&&!at&&!Ut&&vn())}function bn(){rt&&!at&&!Ut&&!Pe&&vn()}function xn(){u===`none`&&(de(tt),fe(mt!==pe.initialValue),be.change(mt))}jS(xt,hn),jS(_t,gn),jS(lt,yn),jS(St,bn),jS(Te,bn),jS(mt,xn);let Sn=gl({open:Ht?!0:_t,onOpenChange:on,elements:{reference:Ut?zt:Bt,floating:Lt}}),Cn=y?`grid`:`listbox`,wn=_t||Ht,Tn=wn?`true`:`false`,En=Z.useMemo(()=>{let e=Bt?.tagName===`INPUT`,t=Bt==null||e,n=t||wn,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=Tn,r[`aria-haspopup`]=Cn,r[`aria-controls`]=wn?Rt?.id:void 0,r[`aria-autocomplete`]=g?`none`:z),{reference:r,floating:{role:`presentation`}}},[Bt,wn,Tn,Cn,Rt?.id,z,g]),Dn=Hc(Sn,{enabled:!et&&O,event:`mousedown-only`,toggle:!1,touchOpenDelay:Ut?0:100,reason:Dt}),On=Gc(Sn,{enabled:!et&&!Ht,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:Ht?!0:void 0,outsidePress(e){let t=L(e);return!G(zt,t)&&!G(Je.current,t)&&!G(qe.current,t)&&!G(Vt,t)}}),kn=Rl(Sn,{enabled:!et,id:Se,listRef:ze,activeIndex:Pt,selectedIndex:Ft,virtual:!0,loopFocus:N,allowEscape:N&&!ct,focusItemOnOpen:Pe||u===`none`&&!ct?!1:`auto`,focusItemOnHover:M,resetOnPointerLeave:!A,orientation:y?`horizontal`:void 0,rtl:xe===`rtl`,disabledIndices:an,grid:y?Mx:void 0,onNavigate(e,t){(t||_t||Ht&&e===null)&&pn!==`ending`&&Qt({activeIndex:e,type:Nx(t),event:t?.nativeEvent})}}),An=Z.useMemo(()=>ue(kn.reference,{onKeyDown(e){y&&W.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},On.reference,Dn.reference,En.reference),[kn.reference,On.reference,Dn.reference,En.reference,y,W]),jn=Z.useMemo(()=>ue(Yc,On.floating),[On.floating]),Mn=Z.useMemo(()=>ue(kn.floating,En.floating),[kn.floating,En.floating]),Nn=Z.useMemo(()=>{let e=kn.item;return{props:e?{...e,onFocus:void 0}:Ee,id:Se,selectionMode:u,disabled:et,readOnly:g,isItemEqualToValue:I}},[kn.item,Se,u,et,g,I]);W.useContextCallback(`setOpen`,on),W.useContextCallback(`setInputValue`,$t),W.useContextCallback(`setSelectedValue`,sn),W.useContextCallback(`setIndices`,Qt),W.useContextCallback(`handleSelection`,cn),W.useContextCallback(`forceMount`,Xt),W.useContextCallback(`requestSubmit`,ln),W.useContextCallback(`onOpenChangeComplete`,n),jx(()=>{W.update({inline:re,popupProps:jn,listProps:Mn,inputProps:An,triggerProps:Jt,itemRoot:Nn})});let Pn={id:Se,selectedValue:lt,open:_t,mounted:fn,transitionStatus:pn,items:U,inline:re,popupProps:jn,listProps:Mn,inputProps:An,triggerProps:Jt,itemRoot:Nn,openMethod:qt,selectionMode:u,name:tt,form:p,disabled:et,readOnly:g,required:_,grid:y,virtualized:te,openOnInputClick:O,itemToStringLabel:je,modal:oe,autoHighlight:ct,isItemEqualToValue:I,submitOnItemClick:le,hasInputValue:at};V(()=>{W.update({...Pn,inputOwnsFormValue:u===`none`&&(re||!W.state.inputInsidePopup)})},[W,...Object.values(Pn)]);let Fn=x(v,be.inputRef),In=Z.useMemo(()=>({query:xt,hasItems:ot,filteredItems:Ot,flatFilteredValues:kt}),[xt,ot,Ot,kt]),Ln=Z.useMemo(()=>Array.isArray(At)?``:oS(At,P),[At,P]),Rn=nt&&Array.isArray(lt)&&lt.length>0,zn=nt||u===`none`&&Wt?void 0:tt,Bn=Z.useMemo(()=>!nt||!Array.isArray(lt)||!tt?null:lt.map(e=>{let t=oS(e,P);return(0,Q.jsx)(`input`,{type:`hidden`,form:p,name:tt,value:t,disabled:et},t)}),[nt,lt,p,tt,P,et]),K=(0,Q.jsxs)(Z.Fragment,{children:[e.children,(0,Q.jsx)(`input`,{...be.getValidationProps(et,{onFocus(){Ut?zt?.focus():(He.current||zt)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||et||g)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=H(tn,e.nativeEvent),i=()=>Qe.current.findIndex(e=>oS(e,P).toLowerCase()===n||Ne(e).toLowerCase()===n);function a(){if(nt)return;if(u===`none`){$t(t,r);return}let e=i();e===-1&&(e=Qe.current.findIndex((e,t)=>{let r=Be.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:Qe.current[e];a!=null&&sn?.(a,r)}rt&&(Xt(),Te&&i()===-1&&W.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:Se&&zn==null?`${Se}-hidden-input`:void 0,form:p,name:zn,autoComplete:se,disabled:et,required:_&&!Rn,readOnly:g,value:Ln,ref:Fn,style:zn?Ae:m,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Bn]});return(0,Q.jsx)(Px.Provider,{value:W,children:(0,Q.jsx)(Fx.Provider,{value:Sn,children:(0,Q.jsx)(Lx.Provider,{value:ot,children:(0,Q.jsx)(Ix.Provider,{value:In,children:(0,Q.jsx)(Rx.Provider,{value:mt,children:K})})})})})}function RS(e){let{openOnInputClick:t=!1,value:n,defaultValue:r,onValueChange:i,mode:a=`list`,itemToStringValue:o,...s}=e,c=(a===`inline`||a===`both`)&&!e.readOnly,l=a===`inline`||a===`none`,u=n!==void 0,[d,f]=Z.useState(r??``),[p,m]=Z.useState(``);Z.useEffect(()=>{(u||!c)&&m(``)},[n,u,c]);let h;h=c&&p!==``?p:u?n??``:d;let g=kS({locale:s.locale}),_=String((u?n:d)??``).trim(),v=l||s.filter===null?null:s.filter??g.contains;function y(e,t){m(``),u||f(e),i?.(e,t)}function b(t,n){e.onItemHighlighted?.(t,n),n.reason!==`pointer`&&m(c&&t!=null?aS(t,o):``)}return(0,Q.jsx)(LS,{...s,itemToStringLabel:o,openOnInputClick:t,selectionMode:`none`,fillInputOnItemPress:!0,filter:v,filterQuery:a===`both`?_:void 0,autoComplete:a,inputValue:h,defaultInputValue:r,onInputValueChange:y,onItemHighlighted:b})}var zS=`data-popup-side`,BS=`data-list-empty`,VS={...rc,...pS,popupSide:e=>e?{[zS]:e}:null,listEmpty:e=>e?{[BS]:``}:null};function HS(e,t,n){let{setFocused:r,focusOwnerRef:i}=gS(),a=D(t=>{(t?!e:i.current===a)&&(i.current=t&&a,n?.(t),r(t))});return V(()=>{let e=t.current;return e?.getRootNode()?.activeElement===e&&a(!0),()=>a(!1)},[e,t,a]),a}var US=5;function WS(e,t){let n=GS(t);return e.clientX>=n.left-US&&e.clientX<=n.right+US&&e.clientY>=n.top-US&&e.clientY<=n.bottom+US}function GS(e){let t=e.getBoundingClientRect(),n=A(e);if(Ve)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 KS(e,t){return e??t}function qS(e){let t=e.useState(`mounted`),n=e.useState(`popupSide`),r=e.useState(`positionerElement`);return t&&r?n:null}function JS(){return Vx().filteredItems.length===0}function YS(e){return e===`rtl`?[`ArrowRight`,`ArrowLeft`]:[`ArrowLeft`,`ArrowRight`]}function XS(e,t,n){let r=e.context.listRef.current[t];r&&(e.context.selectionEventRef.current=n,r.click(),e.context.selectionEventRef.current=null)}var ZS=Z.forwardRef(function(e,t){let{render:n,className:r,nativeButton:i=!0,disabled:a=!1,id:o,style:s,...c}=e,{state:l,disabled:u,setTouched:d,validationMode:p,validation:m}=gS(),{labelId:h}=SS(),g=zx(),_=g.useState(`selectionMode`),y=g.useState(`disabled`),b=g.useState(`readOnly`),x=g.useState(`required`),S=g.useState(`positionerElement`),C=g.useState(`listElement`),w=g.useState(`popupId`),T=g.useState(`triggerProps`),E=g.useState(`inputInsidePopup`),O=g.useState(`id`),k=g.useState(`labelId`),A=g.useState(`open`),j=g.useState(`selectedValue`),M=g.useState(`activeIndex`),N=g.useState(`selectedIndex`),ee=g.useState(`hasSelectedValue`),P=Bx(),F=Hx(),I=Ht(),te=u||y||a,ne=JS(),re=qS(g),ie=Z.useRef(null),ae=HS(te,ie);CS({id:E?o:void 0});let oe=E?o??O:o,R=KS(h,k),z;A&&E?z=w??wS(O):A&&(z=C?.id);let se=Z.useRef(``);function B(e){se.current=e.pointerType}let{reference:ce}=zl(P,{enabled:!A&&!b&&!y&&_===`single`,listRef:g.context.labelsRef,activeIndex:M,selectedIndex:N,onMatch(e){let t=g.context.valuesRef.current[e];t!==void 0&&g.context.setSelectedValue(t,H(tn))}}),{reference:le}=Hc(P,{enabled:!y,event:`mousedown`}),{buttonRef:ue,getButtonProps:de}=pe({native:i,disabled:te}),fe={...l,readOnly:b,open:A,disabled:te,popupSide:re,listEmpty:ne,placeholder:_!==`none`&&!ee},he=D(e=>{g.set(`triggerElement`,e)});return v(`button`,e,{ref:[t,ue,ie,he],state:fe,props:[T,le,ce,{id:oe,tabIndex:E?0:-1,role:E?`combobox`:void 0,"aria-expanded":A,"aria-haspopup":E?`dialog`:`listbox`,"aria-controls":z,"aria-required":E&&x||void 0,"aria-readonly":E&&b||void 0,"aria-labelledby":R,onPointerDown:B,onPointerEnter:B,onFocus(){ae(!0),!te&&I.start(0,g.context.forceMount)},onBlur(e){if(!G(S,e.relatedTarget)&&(d(!0),ae(!1),p===`onBlur`)){let e=_===`none`?F:j;m.commit(e)}},onMouseDown(e){if(te||(E||P.set(`domReferenceElement`,e.currentTarget),g.context.forceMount(),se.current!==`touch`&&(g.context.inputRef.current?.focus(),E||e.preventDefault()),A))return;let t=f(e.currentTarget);function n(e){let t=g.state.triggerElement;if(!t)return;let n=L(e),r=g.state.positionerElement,i=g.state.listElement;G(t,n)||G(r,n)||G(i,n)||WS(e,t)||g.context.setOpen(!1,H(Nt,e))}E&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(me(e),g.context.setOpen(!0,H(Ge,e.nativeEvent)),g.context.inputRef.current?.focus())}},m.getValidationProps(te,c),de],stateAttributesMapping:VS})}),QS=Z.createContext(void 0);function $S(){return Z.useContext(QS)}var eC=Z.createContext(void 0);function tC(e){let t=Z.useContext(eC);if(t===void 0&&!e)throw Error(B(21));return t}var nC=Z.forwardRef(function(e,t){let n=zx(),{buttonRef:r,getButtonProps:i}=pe({native:!1}),a=x(t,r);function o(e){n.context.setOpen(!1,H(tt,e.nativeEvent,e.currentTarget))}let s=i({onClick:o});return(0,Q.jsx)(`span`,{ref:a,...s,"aria-label":`Dismiss`,tabIndex:void 0,style:Ae})}),rC=Z.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...s}=e,{state:c,disabled:l,setTouched:d,validationMode:f,validation:p}=gS(),{labelId:m}=SS(),h=$S(),g=!!tC(!0),_=zx(),y=Hx(),b=$u(),x=_.useState(`required`),S=_.useState(`disabled`),C=_.useState(`readOnly`),w=_.useState(`name`),T=_.useState(`form`),E=_.useState(`selectionMode`),O=_.useState(`autoHighlight`),k=_.useState(`inputProps`),A=_.useState(`triggerProps`),j=_.useState(`open`),M=_.useState(`mounted`),N=_.useState(`selectedValue`),ee=_.useState(`id`),P=_.useState(`inline`),F=_.useState(`modal`),I=!!O,te=qS(_),ne=l||S||i,L=JS(),re=HS(ne,_.context.inputRef),ie=g||P,ae=!ie||F,oe=bS(a??(ie?void 0:ee)),R=g?dS:c,[z,se]=Z.useState(null),B=Z.useRef(!1),ce=Z.useRef(null);V(()=>{j||(ce.current=null)},[j]);let le=E===`none`&&!g,ue=D(e=>{let t=g||_.state.inline;t&&!_.state.hasInputValue&&_.context.setInputValue(``,H(tn)),_.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:le})}),de=g?s:p.getValidationProps(ne,s);function fe(e){_.context.setIndices({activeIndex:null,selectedIndex:null,type:Nx(e),event:e})}let pe={...R,open:j,disabled:ne,readOnly:C,popupSide:te,listEmpty:L};function he(e){if(!h)return;let t,n=h.chipsRef.current.length,[r]=YS(b);return e.key===r&&(e.currentTarget.selectionStart??0)===0&&N.length>0&&(e.preventDefault(),t=n>0?n-1:void 0),t}let ge=v(`input`,e,{state:pe,ref:[t,_.context.inputRef,ue],props:[k,A,{value:z??y,"aria-readonly":C||void 0,"aria-required":x||void 0,"aria-labelledby":m,disabled:ne,readOnly:C,required:E===`none`?x:void 0,form:T,...le&&w&&{name:w},id:oe,onFocus(){if(re(!0),!P)return;let e=ce.current;ce.current=null,e!=null&&Object.hasOwn(_.context.valuesRef.current,e)&&_.context.setIndices({activeIndex:e})},onBlur(){d(!0),re(!1);let e=_.state.activeIndex;if(P&&e!==null&&O!==`always`&&(ce.current=e,_.context.setIndices({activeIndex:null})),f===`onBlur`){let e=E===`none`?y:N;p.commit(e)}},onCompositionStart(e){u||(B.current=!0,se(e.currentTarget.value))},onCompositionEnd(e){B.current=!1;let t=e.currentTarget.value;se(null),_.context.setInputValue(t,H(ut,e.nativeEvent))},onChange(e){let t=e.nativeEvent,n=t.inputType,r=!n||n===`insertReplacementText`,i=B.current||!r;function a(e){!C&&!ne&&e&&i&&(_.context.setOpen(!0,H(ut,t)),I||fe(t))}if(B.current){let n=e.currentTarget.value;se(n),n===``&&!_.state.openOnInputClick&&!_.state.inputInsidePopup&&_.context.setOpen(!1,H(It,t));let r=n.trim(),i=I&&r!==``;a(r),j&&_.state.activeIndex!==null&&!i&&fe(t);return}let o=H(ut,t);if(_.context.setInputValue(e.currentTarget.value,o),o.isCanceled)return;let s=e.currentTarget.value===``,c=H(It,t);s&&!_.state.inputInsidePopup&&(E===`single`&&_.context.setSelectedValue(null,c),_.state.openOnInputClick||_.context.setOpen(!1,c)),a(e.currentTarget.value.trim()),j&&_.state.activeIndex!==null&&!I&&fe(t)},onKeyDown(e){if(e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;if(ne||C){C&&e.key===`Enter`&&j&&_.state.activeIndex!==null&&me(e);return}let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=b===`rtl`;if(e.key===`Home`){me(e);let n=We&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){me(e);let i=We&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!M&&e.key===`Escape`){let t=E===`multiple`&&Array.isArray(N)?N.length===0:N===null,n=H(Tt,e.nativeEvent),r=E===`multiple`?[]:null;_.context.setInputValue(``,n),_.context.setSelectedValue(r,n),t||_.state.inline||n.isPropagationAllowed||e.stopPropagation();return}if(h&&e.key===`Backspace`&&t.value===``&&Array.isArray(N)&&N.length>0){let t=h.chipsRef.current.length,n=t>0?t-1:N.length-1,r=N.filter((e,t)=>t!==n);fe(e.nativeEvent),_.context.setSelectedValue(r,H(tn,e.nativeEvent));return}let i=he(e);if(i!==void 0&&h?.chipsRef.current[i]?.focus(),e.which!==229&&e.key===`Enter`&&j){let t=_.state.activeIndex,n=e.nativeEvent;if(t===null){if(P)return;_.context.setOpen(!1,H(tn,n));return}me(e),XS(_,t,n)}}},de],stateAttributesMapping:VS}),_e=g?(0,Q.jsx)(hS.Provider,{value:mS,children:ge}):ge;return(0,Q.jsxs)(Z.Fragment,{children:[j&&ae&&(0,Q.jsx)(nC,{ref:_.context.startDismissRef}),_e]})}),iC={...hn,...nc},aC=Z.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,keepMounted:o=!1,style:s,...c}=e,{disabled:l}=gS(),u=zx(),d=u.useState(`selectionMode`),f=u.useState(`disabled`),p=u.useState(`readOnly`),m=u.useState(`open`),h=u.useState(`selectedValue`),g=u.useState(`hasSelectionChips`),_=Hx(),y=!1;y=d===`none`?_!==``:d===`single`?h!=null:g;let b=l||f||i,{buttonRef:x,getButtonProps:S}=pe({native:a,disabled:b}),{mounted:C,transitionStatus:w,setMounted:T}=qc(y),E={disabled:b,visible:y,open:m,transitionStatus:w};le({open:y,ref:u.context.clearRef,onComplete(){y||T(!1)}});let D=v(`button`,e,{state:E,ref:[t,x,u.context.clearRef],props:[{tabIndex:-1,children:`x`,onMouseDown(e){e.preventDefault()},onClick(e){if(b||p)return;let t=Nx(e);u.context.setInputValue(``,H(Gt,e.nativeEvent)),d===`none`?u.context.setIndices({activeIndex:null,type:t,event:e.nativeEvent}):(u.context.setSelectedValue(Array.isArray(h)?[]:null,H(Gt,e.nativeEvent)),u.context.setIndices({activeIndex:null,selectedIndex:null,type:t,event:e.nativeEvent})),u.context.inputRef.current?.focus()}},c,S],stateAttributesMapping:iC});return o||C?D:null}),oC=Z.createContext(null);function sC(){return Z.useContext(oC)}function cC(e){let{children:t}=e,{filteredItems:n}=Vx(),r=sC(),i=r?r.items:n;return(0,Q.jsx)(Z.Fragment,{children:i.map(t)})}var lC=Z.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function uC(){return Z.useContext(lC)}function dC(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=D(i),[,o]=Z.useState(0),s=F(pC).current,c=F(fC).current,l=Z.useRef(0),u=Z.useRef(!0),d=Z.useRef(null),f=Z.useRef(null),p=D(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=D((e,t)=>{c.set(e,t),p()}),h=D(e=>{c.delete(e),p()}),g=D(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(!gC(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&_C(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=hC(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=D(()=>{let[e,t]=mC(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))});V(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),V(()=>{u.current&&v()}),V(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=D(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)(lC.Provider,{value:b,children:t})}function fC(){return new Map}function pC(){return new Set}function mC(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)=>_C(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 hC(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function gC(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 _C(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var vC=Z.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=zx(),l=Bx(),u=!!tC(!0),{filteredItems:d,hasItems:f}=Vx(),p=c.useState(`selectionMode`),m=c.useState(`grid`),h=c.useState(`readOnly`),g=c.useState(`listProps`),_=c.useState(`virtualized`),y=c.useState(`forceMounted`),b=p===`multiple`,x=d.length===0,S=D(e=>{c.set(`positionerElement`,e)}),C=D(e=>{c.set(`listElement`,e)}),w=Z.useMemo(()=>typeof o==`function`?n||=(0,Q.jsx)(cC,{children:o}):o,[o]),T={empty:x},E=l.useState(`floatingId`),O=v(`div`,e,{state:T,ref:[t,C,u?null:S],props:[g,{children:w,tabIndex:-1,id:E,role:m?`grid`:`listbox`,"aria-multiselectable":b?`true`:void 0,"aria-readonly":!m&&h?!0:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;me(e),XS(c,t,e.nativeEvent)}}},s]});if(_)return O;let k=f&&!y?void 0:c.context.labelsRef;return(0,Q.jsx)(dC,{elementsRef:c.context.listRef,labelsRef:k,children:O})}),yC=Z.createContext(void 0);function bC(){let e=Z.useContext(yC);if(e===void 0)throw Error(B(20));return e}var xC=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=zx(),a=i.useState(`mounted`),o=i.useState(`forceMounted`);return a||n||o?(0,Q.jsx)(yC.Provider,{value:n,children:(0,Q.jsx)(Vt,{ref:t,...r})}):null}),SC=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}})}),CC={},wC={},TC=``;function EC(e,t){return Le(e)?e:t}function DC(e,t,n){return/hidden|clip/.test(e.getComputedStyle(EC(t,n)).overflowY)}function OC(e){if(typeof document>`u`)return!1;let t=f(e);return A(t).innerWidth-t.documentElement.clientWidth>0}function kC(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=f(e),n=t.documentElement,r=t.body,i=EC(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 AC(e){let t=f(e),n=t.documentElement,r=t.body,i=EC(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 jC(e){let t=f(e),n=t.documentElement,r=t.body,i=A(n),a=0,o=0,s=!1,c=P.create();if(ye&&(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,CC={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},TC=n.style.scrollBehavior,wC={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=EC(n,r);s=kC(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,CC),Object.assign(r.style,wC),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=TC)}function d(){u(),c.request(l)}l();let p=U(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&p()}}var MC=new class{lockCount=0;restore=null;timeoutLock=At.create();timeoutUnlock=At.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=f(e),n=t.documentElement,r=t.body,i=A(n);if(DC(i,n,r)){let t=new i.MutationObserver(()=>{DC(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=st||!OC(e);this.restore=a?AC(e):jC(e)}};function NC(e=!0,t=null){V(()=>{if(e)return MC.acquire(t)},[e,t])}var PC=20;function FC(e,t,n,r){let[i,a]=Z.useState(!1);V(()=>{if(!e||!t||n==null){a(!1);return}let r=f(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-PC)},[e,t,n]),NC(e&&(!t||i),r)}var IC=Z.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m=!1,collisionAvoidance:h=bt,style:g,..._}=e,v=zx(),y=Bx(),b=bC(),x=v.useState(`modal`),S=v.useState(`open`),C=v.useState(`mounted`),w=v.useState(`openMethod`),T=v.useState(`positionerElement`),E=v.useState(`triggerElement`),O=v.useState(`inputElement`),k=v.useState(`inputGroupElement`),A=v.useState(`inputInsidePopup`),j=v.useState(`transitionStatus`),M=JS(),N=pd({anchor:i??(A?E:k??O),floatingRootContext:y,positionMethod:a,mounted:C,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,lazyFlip:!0});FC(S&&x,w===`touch`,T,E);let ee={open:S,side:N.side,align:N.align,anchorHidden:N.anchorHidden,empty:M};V(()=>{v.set(`popupSide`,N.side)},[v,N.side]);let P=D(e=>{v.set(`positionerElement`,e)}),F=_d(e,ee,{styles:N.positionerStyles,transitionStatus:j,props:_,refs:[t,P],hidden:!C,inert:!S});return(0,Q.jsxs)(eC.Provider,{value:N,children:[C&&x&&(0,Q.jsx)(SC,{inert:be(!S),cutout:k??O??E}),F]})}),LC={...ic,...hn},RC=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=zx(),l=tC(),u=Bx(),d=c.useState(`mounted`),f=c.useState(`open`),p=c.useState(`openMethod`),m=c.useState(`popupProps`),h=c.useState(`transitionStatus`),g=c.useState(`inputInsidePopup`),_=c.useState(`inputElement`),y=c.useState(`modal`),b=c.useState(`id`),x=JS(),S=s.id??(g?wS(b):void 0);V(()=>(c.set(`popupId`,c.context.popupRef.current?.id||S),()=>{c.set(`popupId`,void 0)}),[c,S]),le({open:f,ref:c.context.popupRef,onComplete(){f&&c.context.onOpenChangeComplete(!0)}});let C={open:f,side:l.side,align:l.align,anchorHidden:l.anchorHidden,transitionStatus:h,empty:x},w=v(`div`,e,{state:C,ref:[t,c.context.popupRef],props:[m,{id:S,role:g?`dialog`:`presentation`,onFocus(e){let t=L(e.nativeEvent);p!==`touch`&&(G(c.state.listElement,t)||t===e.currentTarget)&&c.context.inputRef.current?.focus()}},gd(h),s],stateAttributesMapping:LC}),T=a===void 0?g?e=>e===`touch`?c.context.popupRef.current:_:!1:a,E;E=o??(g?void 0:!1);let D=!g||y;return(0,Q.jsx)(Vc,{context:u,disabled:!d,modal:D,openInteractionType:p,initialFocus:T,returnFocus:E,getInsideElements:()=>[c.context.startDismissRef.current,c.context.endDismissRef.current],children:(0,Q.jsxs)(Z.Fragment,{children:[w,D&&(0,Q.jsx)(nC,{ref:c.context.endDismissRef})]})})});function zC(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=uC(),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 V(()=>{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}}var BC=Z.createContext(void 0);function VC(){let e=Z.useContext(BC);if(!e)throw Error(B(19));return e}var HC=Z.createContext(!1);function UC(){return Z.useContext(HC)}function WC(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:c=null,index:l,disabled:u=!1,nativeButton:d=!1,...f}=t,p=Z.useRef(null),m=zC({guess:!0,index:l,textRef:p}),h=zx(),g=UC(),_=Ux(),{props:y,id:b,selectionMode:x,disabled:S,readOnly:C,isItemEqualToValue:w}=h.useState(`itemRoot`),T=S||u,E=x!==`none`,D=l??i??m.index,O=D!==-1,k=h.useState(`isActive`,D),A=h.useState(`isSelected`,c),j=Z.useRef(null),M=b!=null&&O?`${b}-${D}`:void 0,N=A&&E;V(()=>{if(!O||!r&&l==null)return;let e=h.context.listRef.current;return e[D]=j.current,()=>{delete e[D]}},[O,r,D,l,h]),V(()=>{if(!O||_)return;let e=h.context.valuesRef.current;return e[D]=c,()=>{delete e[D]}},[O,_,D,c,h]),V(()=>{if(!O||_)return;let e=h.state.selectedValue,t=h.state.selectedIndex;h.state.selectionMode===`multiple`&&Array.isArray(e)?t=Qx(D,c,h.context.valuesRef.current,e,w,t):Kx(c,e,w)&&(t=D),h.set(`selectedIndex`,t)},[O,_,h,D,c,w]);let{getButtonProps:ee,buttonRef:P}=pe({disabled:T,focusableWhenDisabled:!0,native:d,composite:!0}),F={disabled:T,selected:N,highlighted:k};function I(e){function t(){h.context.handleSelection(e,c)}h.state.submitOnItemClick?(Ks.flushSync(t),h.context.requestSubmit()):t()}let te={id:M,role:g?`gridcell`:`option`,"aria-selected":E?N:void 0,tabIndex:void 0,onPointerDownCapture(e){e.isPrimary&&(h.context.pointerDownItemRef.current=e.currentTarget),e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){T||C||I(e.nativeEvent)},onMouseUp(e){let t=h.context.pointerDownItemRef.current===e.currentTarget;h.context.pointerDownItemRef.current=null,!(T||C||e.button!==0||t||!k)&&I(e.nativeEvent)}},ne=v(`div`,t,{ref:[P,n,m.ref,j],state:F,props:[y,te,f,ee]}),L=Z.useMemo(()=>({selected:N,textRef:p}),[N,p]);return(0,Q.jsx)(BC.Provider,{value:L,children:ne})}function GC(e){let{componentProps:t,forwardedRef:n}=e,r=zx().useState(`isItemEqualToValue`),{flatFilteredValues:i}=Vx(),a=Yx(i,t.value??null,r);return(0,Q.jsx)(WC,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:a})}var KC=Z.memo(Z.forwardRef(function(e,t){let n=zx().useState(`virtualized`);return n&&e.index==null?(0,Q.jsx)(GC,{componentProps:e,forwardedRef:t}):(0,Q.jsx)(WC,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})}));function qC(e){return v(e.defaultTagName??`div`,e,e)}var JC=Z.createContext(void 0);function YC(){let e=Z.useContext(JC);if(e===void 0)throw Error(B(13));return e}var XC={imageLoadingStatus:()=>null},ZC=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=v(`span`,e,{state:c,ref:t,props:a,stateAttributesMapping:XC});return(0,Q.jsx)(JC.Provider,{value:l,children:u})});function QC(e,{referrerPolicy:t,crossOrigin:n,sizes:r,srcSet:i},a){let o=Z.useState(`idle`),s=o[1];return V(()=>{if(!a)return w;if(!e&&!i)return s(`error`),w;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 $C={...XC,...hn},ew=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}=YC(),[f,p]=QC(l,e,!a),m=f===`loaded`,{mounted:h,transitionStatus:g,setMounted:_}=qc(m),y=Z.useRef(null),b=Z.useRef(!0);V(()=>{if(!a)return;let e=b.current;b.current=!1;let t=y.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 x=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,S=D(e=>{i?.(e),d(e)});V(()=>{f!==`idle`&&S(f)},[f,S]),V(()=>()=>d(`idle`),[d]),le({enabled:!m,open:m,ref:y,onComplete(){m||_(!1)}});let C={imageLoadingStatus:f,transitionStatus:a&&g===`ending`?void 0:g},w=a||h,T={};s!==void 0&&(T.sizes=s),c!==void 0&&(T.srcSet=c),l!==void 0&&(T.src=l);let E=v(`img`,e,{state:C,ref:[t,y],props:[x,u,T],stateAttributesMapping:$C,enabled:w});return w?E:null}),tw=Z.forwardRef(function(e,t){let{className:n,render:r,delay:i=0,style:a,...o}=e,{imageLoadingStatus:s}=YC(),[c,l]=Z.useState(i===0),u=Ht();return Z.useEffect(()=>(i>0?u.start(i,()=>l(!0)):l(!0),u.clear),[u,i]),v(`span`,e,{state:{imageLoadingStatus:s},ref:t,props:o,stateAttributesMapping:XC,enabled:s!==`loaded`&&(i===0||c)})});function nw(e){let t=(0,qs.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=Xt(`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)(ZC,{"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 rw(e){let t=(0,qs.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=Xt(`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)(ew,{"data-slot":`avatar-image`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function iw(e){let t=(0,qs.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=Xt(`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)(tw,{"data-slot":`avatar-fallback`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var aw=Z.memo(Z.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a,selected:o,...s}=e,c=Z.useRef(null),{transitionStatus:l,setMounted:u}=qc(o),d=v(`span`,e,{ref:[t,c],state:{selected:o,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},s],stateAttributesMapping:hn});return le({batch:!0,enabled:!o,open:o,ref:c,onComplete(){o||u(!1)}}),d})),ow=Z.forwardRef(function(e,t){let{selected:n}=VC();return e.keepMounted||n?(0,Q.jsx)(aw,{...e,selected:n,ref:t}):null}),sw=Z.createContext(void 0);function cw(e=!0){let t=Z.useContext(sw);if(t===void 0&&!e)throw Error(B(25));return t}var lw=Z.createContext(void 0);function uw(e){let t=Z.useContext(lw);if(t===void 0&&!e)throw Error(B(33));return t}var dw=Z.createContext(void 0);function fw(e){let t=Z.useContext(dw);if(t===void 0&&!e)throw Error(B(36));return t}var pw=Z.createContext(null);function mw(e=`root`){let t=Z.useContext(pw),n=Z.useContext(dw);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var hw={visible:!0,ref:null};function gw(){return hw}function _w(e,t,n=`root`){let r=mw(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??gw)({label:e.label,children:e.children,render:e.render}),a=x(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}function vw(e){e.preventDefault()}function yw(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=fw(),u=cw(!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?vw: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:ht})},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&&!Yt&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&Ct(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var bw={type:`regular-item`};function xw(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}=pe({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=yw({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=Z.useCallback(e=>ue(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=x(u,f);return Z.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Sw=Z.createContext(void 0);function Cw(){let e=Z.useContext(Sw);if(e===void 0)throw Error(B(31));return e}var ww=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Z.useState(void 0),c=v(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,Q.jsx)(Sw.Provider,{value:s,children:c})}),Tw=Z.forwardRef(function(e,t){let n=mw()?.Group??ww;return(0,Q.jsx)(n,{...e,ref:t})}),Ew=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=bS(a),c=Cw();return V(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),v(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),Dw=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}=fw(),f=zC({guess:!0,label:a}),p=bS(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),y=s||m,{getItemProps:b,itemRef:x}=xw({closeOnClick:c,disabled:y,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:bw});return v(`div`,e,{state:{disabled:y,highlighted:h},props:[_,u,b],ref:[x,t,f.ref]})}),Ow=Z.forwardRef(function(e,t){let n=_w(e,t);return n.visible?(0,Q.jsx)(Dw,{...e,ref:n.ref}):null}),kw=Z.createContext(void 0);function Aw(e){let t=Z.useContext(kw);if(t===void 0&&!e)throw Error(B(69));return t}var jw=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),Mw=Z.createContext(void 0);function Nw(){return Z.useContext(Mw)}function Pw(e,t){let n=we(e.render);if(Z.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function Fw(e,t,n){let r=Pw(e,t),i=r===t?void 0:r;return[r,Z.useCallback(e=>n?.(e?i:void 0),[i,n])]}function Iw(e,t,n){let r=we(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 Lw=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}=fw(),m=Nw(),{side:h,align:g}=uw(),_=Aw(!0)!=null,y=l.useState(`open`),b=l.useState(`transitionStatus`),x=l.useState(`popupProps`),S=l.useState(`mounted`),C=l.useState(`instantType`),w=l.useState(`activeTriggerElement`),T=l.useState(`parent`),E=l.useState(`lastOpenChangeReason`),D=l.useState(`rootId`),O=l.useState(`floatingRootContext`),k=l.useState(`floatingTreeRoot`),A=l.useState(`closeDelay`),j=l.useState(`hoverEnabled`),M=l.useState(`disabled`),N=l.useState(`openMethod`),ee=l.useState(`activeTriggerId`),P=l.useState(`listElement`),[F,I]=Fw(e,u,d),te=Iw(e,w,ee),ne=T.type===`menu`?m:void 0,L=T.type===`context-menu`,re=s??T.type!==`menu`;s===void 0&&P&&T.type!==`menu`&&(re=()=>l.state.activeIndex===null&&P),le({open:y,ref:l.context.popupRef,onComplete(){y&&l.context.onOpenChangeComplete?.(!0)}}),Z.useEffect(()=>{function e(e){l.setOpen(!1,H(e.reason,e.domEvent))}return k.events.on(`close`,e),()=>{k.events.off(`close`,e)}},[k.events,l]),kl(O,{enabled:j&&!M&&!L&&T.type!==`menubar`,closeDelay:A});let ie=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:ae,handleFocus:oe}=(Z.useContext(pw)?.useParentHandoff??zw)(l,T,y,f),R={transitionStatus:b,side:h,align:g,open:y,nested:T.type===`menu`,instant:C},z=v(`div`,e,{state:R,ref:[t,l.context.popupRef,ie,I],stateAttributesMapping:ac,props:[x,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":te},onKeyDown(e){ne?.onPopupKeyDown?.(e),_&&jw.has(e.key)&&e.stopPropagation()},onFocus:oe},gd(b),c,{"data-rootownerid":D}]}),se=T.type===void 0||L;(w||T.type===`menubar`&&E!==`outside-press`)&&(se=!0);let B=ne?.getReturnElement??ae;return(0,Q.jsx)(Vc,{context:O,openInteractionType:N,modal:L,disabled:!S,returnFocus:a??B??se,explicitReturnFocus:a===void 0&&B?!1:void 0,initialFocus:re,restoreFocus:!0,getInsideElements:T.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:T.type===`menubar`?void 0:k,previousFocusableElement:w,nextFocusableElement:T.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:z})}),Rw={parentVirtualFocusRef:void 0,handleFocus:void 0};function zw(){return Rw}var Bw=Z.forwardRef(function(e,t){let n=mw()?.Popup??Lw;return(0,Q.jsx)(n,{...e,ref:t})}),Vw=Z.createContext(void 0);function Hw(){let e=Z.useContext(Vw);if(e===void 0)throw Error(B(32));return e}var Uw=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=fw();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Q.jsx)(Vw.Provider,{value:n,children:(0,Q.jsx)(Vt,{ref:t,...r,portalOwnerRole:o})})});function Ww(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=Z.useRef(null),o=Z.useRef(null),s=he(r);V(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),V(()=>{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 Gw=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=bt,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=fw(),x=Hw(),S=cw(!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`),N=v.useState(`instantType`),ee=v.useState(`adaptiveOrigin`),P=v.useState(`lastOpenChangeReason`),F=v.useState(`floatingNodeId`),I=v.useState(`floatingParentNodeId`),te=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??se):C.type===`menubar`&&(oe??=C.context.orientation===`vertical`?`inline-end`:`bottom`,R??=`start`);let z=C.type===`context-menu`,B=pd({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:F,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:ae,shift:z?{crossAxis:!(`side`in ae&&ae.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:ee,lazyFlip:y?`placement`:!1});Z.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===F&&v.set(`hoverEnabled`,!1),e.nodeId!==F&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,H(sn)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,F]),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,H(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let ce=Ht();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,H(sn))}):v.setOpen(!1,H(sn))}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:F,parentNodeId:I,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,F,I]),Ww({store:v,domReference:te,positionerElement:M,open:D});let le={open:D,side:B.side,align:B.align,anchorHidden:B.anchorHidden,nested:C.type===`menu`,instant:N},ue=C.type===`menubar`&&C.context.modal;FC(D&&(ue||O&&P!==`trigger-hover`),k===`touch`,M,A);let de=_d(e,le,{styles:B.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),fe=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&P!==`trigger-hover`||C.type===`menubar`&&C.context.modal),pe=null;return C.type===`menubar`?pe=C.context.contentElement:C.type===void 0&&(pe=A),(0,Q.jsxs)(lw.Provider,{value:B,children:[fe&&(0,Q.jsx)(SC,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:be(!D),cutout:pe}),(0,Q.jsx)(jc,{id:F,children:(0,Q.jsx)(dC,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:de})})]})}),Kw=Z.createContext(null);function qw(e){let t=Z.useContext(Kw);if(t===null&&!e)throw Error(B(5));return t}var Jw={...ml,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=ml.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>ye&&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`&&!ml.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`)}},Yw=class extends vt{constructor(e,t,n=!1){let r=new al,i=Zw(r,t,n,e);super(i,Xw(r),Jw),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 Xw(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 Zw(e,t,n=!1,r){return{...cl(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:Ee,inputProps:Ee,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new Tc,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Ee,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var Qw=Z.createContext(null);function $w(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function eT(e,t){return e===`list-navigation`||$w(e,t)}var tT=Ye(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=cw(!0),w=fw(!0),T=qw(!0),E=w?.store,O=w?.virtualFocus??!1,k=Z.useMemo(()=>_&&E?{type:`menu`,store:E}:T?{type:`menubar`,context:T}:S&&!E?{type:`context-menu`,context:S}:{type:void 0},[S,E,T,_]),A=bS(),j=bS(),[M,N]=Z.useState(void 0),ee=(M??j)||void 0,P=Oc(),I=k.type===`menu`?k.store:void 0,te=(n??o)&&I?.state.transitionStatus===`starting`,ne=F(()=>te?I?.state.instantType:void 0).current,L=F(()=>{let e=new Yw({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:k,disabled:s,highlightItemOnHover:g,modal:k.type===void 0?c:void 0,rootId:A,instantType:ne},ee,P!=null);return e.context.virtualFocusRef=y,e}).current;L.useControlledProp(`openProp`,n),L.useControlledProp(`triggerIdProp`,m),L.useContextCallback(`onOpenChangeComplete`,i);let re=L.useState(`floatingTreeRoot`),ie=Ac(re),ae=L.useState(`open`),oe=L.useState(`activeTriggerElement`),R=L.useState(`positionerElement`),z=L.useState(`hoverEnabled`),se=L.useState(`disabled`),B=L.useState(`lastOpenChangeReason`),ce=L.useState(`parent`),le=L.useState(`activeIndex`),de=L.useState(`keyboardOpen`),fe=L.useState(`payload`),pe=L.useState(`floatingParentNodeId`),me=Z.useRef(null),ge=Z.useRef(ce.type!==`context-menu`),_e=Ht(),ve=Z.useRef(!0),ye=Ht(),be=pe!=null,{openMethod:xe,triggerProps:Se}=NS(ae);L.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:ce.type===void 0?c:void 0,openMethod:xe,rootId:A}),nl(L);let{forceUnmount:Ce,transitionStatus:we}=rl(ae,L,()=>{L.set(`allowMouseEnter`,!1)},te),Te=he(L.context.popupRef);Z.useEffect(()=>{if(ne===void 0)return;let e=()=>{L.state.instantType===ne&&L.set(`instantType`,void 0)};if(!ae){e();return}if(we!==void 0)return;if(L.context.popupRef.current==null){e();return}let t=new AbortController;return Te(e,t.signal),()=>{t.abort()}},[ne,ae,we,Te,L]),V(()=>{S&&!w?L.update({parent:{type:`context-menu`,context:S},floatingNodeId:ie,floatingParentNodeId:P}):(w||!L.select(`activeTriggerElement`))&&L.update({floatingNodeId:ie,floatingParentNodeId:P})},[S,w,ie,P,oe,L]),Z.useEffect(()=>{ae||(me.current=null),ce.type===`context-menu`&&(ae?_e.start(500,()=>{ge.current=!0}):(_e.clear(),ge.current=!1))},[_e,ae,ce.type]),V(()=>{!ae&&!z&&L.set(`hoverEnabled`,!0)},[ae,z,L]);let De=D((e,t)=>{let n=t.reason;if(!e&&!L.select(`open`)||ae===e&&t.trigger===oe&&B===n)return;let i=el(t);if(!e&&t.trigger==null&&(t.trigger=oe??void 0),r?.(e,t),t.isCanceled)return;L.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!ve.current)return;e&&n===`trigger-focus`?(ve.current=!1,ye.start(300,()=>{ve.current=!0})):(ve.current=!0,ye.clear());let o=!e&&(n===`escape-key`||n==null);me.current=t.event;let s=$c(L.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&eT(n,a),s.instantType=ce.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:$w(n,a)?`click`:o?`dismiss`:void 0,L.update(s)}),U=Kc({popupStore:L,floatingRootContext:L.state.floatingRootContext,floatingId:ee,nested:P!=null,onOpenChange:De}),Oe=U.context.events;V(()=>{let e=({open:e,eventDetails:t})=>De(e,t);return Oe.on(`setOpen`,e),()=>{Oe?.off(`setOpen`,e)}},[Oe,De]),V(()=>L.subscribeToParentMenu(),[L]);let ke=Z.useCallback(()=>{L.setOpen(!1,H(it))},[L]);Z.useImperativeHandle(d,()=>({unmount:Ce,close:ke}),[Ce,ke]);let Ae;ce.type===`context-menu`&&(Ae=ce.context),Z.useImperativeHandle(Ae?.positionerRef,()=>R,[R]),Z.useImperativeHandle(Ae?.actionsRef,()=>({setOpen:De}),[De]);let je=Gc(U,{enabled:!se,bubbles:{escapeKey:f&&ce.type===`menu`},outsidePress(){return ce.type!==`context-menu`||me.current?.type===`contextmenu`||ge.current},externalTree:be?re:void 0}),Me=$u(),Ne=Rl(U,{enabled:!se,listRef:L.context.itemDomElements,activeIndex:le,virtual:v,nested:ce.type===`menubar`||!v&&ce.type!==void 0,parentOrientation:ce.type===`menubar`?ce.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?de:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:Me===`rtl`,disabledIndices:an,onNavigate(e,t){L.setActiveIndex(e,Nx(t),t?.nativeEvent)},openOnArrowKeyDown:ce.type!==`context-menu`&&!(v&&_),externalTree:!v&&be?re:void 0,nestedReturnFocusRef:I?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),Pe=Z.useCallback(e=>{L.context.typingRef.current=e},[L]),Fe=zl(U,{enabled:!se&&!v,listRef:L.context.itemLabels,elementsRef:L.context.itemDomElements,activeIndex:le,resetMs:500,onMatch:(e,t)=>{ae&&e!==le&&L.setActiveIndex(e,pt,t.nativeEvent)},onTyping:Pe}),Ie=D(a),Le=Z.useRef(-1),Re=D(()=>{let e=L.state.activeIndex,t=e===null?void 0:L.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Le.current===n&&L.context.reportedItem===t)return;Le.current=n,L.context.reportedItem=t,v&&L.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=L.context;L.context.highlightReason=tn,L.context.highlightEvent=void 0,a&&Ie(t,C(r,i,{label:t===void 0?void 0:L.context.itemLabels.current[n]??void 0}))});V(()=>{Re()},[le,Re]);let ze=Z.useMemo(()=>{if(!v)return Ne.reference;if(!Ne.trigger)return Ee;let{onFocus:e,...t}=Ne.trigger;return t},[v,Ne.reference,Ne.trigger]);L.useSyncedValue(`inputProps`,v?Ne.reference??Ee:Ee);let Be=Z.useMemo(()=>{let e=ue(Fe.reference,ze,je.reference,{onMouseMove(){L.set(`allowMouseEnter`,!0)}},Se);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=ae,e},[L,Fe.reference,ze,je.reference,Se,ae]),Ve=Z.useMemo(()=>{let e=ue(Ne.trigger,je.trigger,Se);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Ne.trigger,je.trigger,Se]);F(()=>(L.update({inactiveTriggerProps:Ve}),null)),il(L,{floatingRootContext:U,activeTriggerProps:Be,inactiveTriggerProps:Ve,popupProps:Z.useMemo(()=>ue(Yc,{onMouseMove(){L.set(`allowMouseEnter`,!0),ce.type===`menu`&&L.set(`hoverEnabled`,!1)},onClick(){L.select(`hoverEnabled`)&&L.set(`hoverEnabled`,!1)},onKeyDown(e){let t=L.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Fe.floating,Ne.floating,je.floating),[ce.type,L,Fe.floating,Ne.floating,je.floating]),itemProps:Ne.item??Ee});let He=Z.useMemo(()=>({store:L,parent:k,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:j,setRenderedFloatingId:N,virtualFocus:v,parentVirtualFocus:O,syncHighlightedItem:Re}),[L,k,u,l,b,j,v,O,Re]),Ue=typeof t==`function`?t({payload:fe}):t,We=(0,Q.jsxs)(dw.Provider,{value:He,children:[p&&(0,Q.jsx)(Xc,{handle:p,store:L}),Ue]});return(ce.type===void 0||ce.type===`context-menu`)&&(We=(0,Q.jsx)(Mc,{externalTree:re,children:We})),We});function nT(e){let t=Z.useContext(Qw);if(t===null)return(0,Q.jsx)(tT,{...e});let n=t.Root;return(0,Q.jsx)(Qw.Provider,{value:null,children:(0,Q.jsx)(n,{...t.options,...e})})}var rT={};function iT(e){fw();let t=Z.useContext(Qw);if(t!==null){let n=t.SubmenuRoot;return(0,Q.jsx)(Qw.Provider,{value:null,children:(0,Q.jsx)(n,{...t.options,...e})})}return(0,Q.jsx)(Mw.Provider,{value:rT,children:(0,Q.jsx)(tT,{...e,isSubmenu:!0})})}function aT(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=xt(),{ref:i,index:a}=zC(e),o=n===a,s=Z.useRef(null),c=x(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 oT(e){let{render:t,className:n,style:r,state:i=Ee,props:a=an,refs:o=an,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=aT({metadata:s});return v(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function sT(e){if(ne(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Be(e))return sT(Pe(e))}function cT(e,t){function n(n,r,i){let a=n.currentTarget;Ks.flushSync(()=>{e.setOpen(!1,H(Qt,n.nativeEvent,a))}),zt(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&&te(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function lT(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,f(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:Ee,[t,n,r])}var uT=Pt(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:p,...m}=e,h=fw(!0),g=hl(d)??h?.store;if(!g)throw Error(B(85));let _=bS(s),y=g.useState(`isTriggerActive`,_),b=g.useState(`floatingRootContext`),x=g.useState(`isOpenedByTrigger`,_),S=g.useState(`triggerControlsId`,_),C=Z.useRef(null),w=fT(),T=xt(!0),E=kc(),O=Z.useMemo(()=>E??new Tc,[E]),{registerTrigger:k,isMountedByThisTrigger:A}=tl(_,C,g,{payload:p,closeDelay:u,parent:w,floatingTreeRoot:O,floatingNodeId:Ac(O),floatingParentNodeId:Oc(),keyboardEventRelay:T?.relayKeyboardEvent}),j=w.type===`menubar`,M=g.useState(`disabled`),N=a||M||j&&w.context.disabled,{getButtonProps:ee,buttonRef:P}=pe({disabled:N,native:o});Z.useEffect(()=>{!x&&w.type===void 0&&(g.context.allowMouseUpTriggerRef.current=!1)},[g,x,w.type]);let F=Z.useRef(null),I=Ht(),te=D(e=>{if(!F.current)return;I.clear(),g.context.allowMouseUpTriggerRef.current=!1;let t=e.target;G(F.current,t)||G(g.select(`positionerElement`),t)||t===F.current||t!=null&&sT(t)===g.select(`rootId`)||WS(e,F.current)||O.events.emit(`close`,{domEvent:e,reason:Nt})});Z.useEffect(()=>{let e=f(F.current);if(x&&g.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,te,{once:!0}),()=>{e.removeEventListener(`mouseup`,te)}},[x,te,g]);let ne=j&&w.context.hasSubmenuOpen,L=jl(b,{enabled:(c??ne)&&!N&&(!j||ne&&!A),handleClose:ql({blockPointerEvents:!j}),mouseOnly:!0,move:!1,restMs:w.type===void 0?l:void 0,delay:{close:u},triggerElementRef:C,externalTree:O,isActiveTrigger:y,isClosing:()=>g.select(`transitionStatus`)===`ending`}),re=dT(x,g.select(`lastOpenChangeReason`)),ie=Hc(b,{enabled:!N,event:x&&j?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:w.type===void 0&&re}),ae=vl(b,{enabled:!N&&ne}),oe=lT({open:x,enabled:j,mouseDownAction:`open`}),R=Z.useMemo(()=>ue(ae.reference,ie.reference),[ae.reference,ie.reference]),z=g.useState(`triggerProps`,A),se=g.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:ce,handleFocusTargetFocus:le}=cT(g,C),de={disabled:N,open:x},fe=[F,t,P,k,C],me=[R,L??Ee,z,{"aria-haspopup":`menu`,"aria-controls":S,id:_,onMouseDown:e=>{g.select(`open`)||(I.start(200,()=>{g.context.allowMouseUpTriggerRef.current=!0}),f(e.currentTarget).addEventListener(`mouseup`,te,{once:!0}))}},se,j?{role:`menuitem`}:{},oe,m,ee],he=v(`button`,e,{enabled:!j,stateAttributesMapping:rc,state:de,ref:fe,props:me});return j?(0,Q.jsx)(oT,{tag:`button`,render:n,className:r,style:i,state:de,refs:fe,props:me,stateAttributesMapping:rc}):x?(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(pn,{ref:g.context.beforeTriggerFocusGuardRef,onFocus:ce},`${_}-pre-focus-guard`),(0,Q.jsx)(Z.Fragment,{children:he},_),(0,Q.jsx)(pn,{ref:g.context.triggerFocusTargetRef,onFocus:le},`${_}-post-focus-guard`)]}):(0,Q.jsx)(Z.Fragment,{children:he},_)});function dT(e,t){let n=Ht(),[r,i]=Z.useState(!1);return V(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function fT(){let e=qw(!0);return Z.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var pT={"aria-expanded":void 0},mT=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=fw(!0);if(p?.parent.type!==`menu`)throw Error(B(37));let m=uw(),h=Nw(),{store:g,parentVirtualFocus:_}=p,y=p.parent.store,b=zC({guess:!0,label:a}),x=bS(o),S=g.useState(`open`),C=Z.useRef(!1),w=g.useState(`positionerElement`),T=g.useState(`floatingRootContext`),E=g.useState(`floatingTreeRoot`),O=g.useState(`triggerPopupId`,x),k=Qc(x,g),A=D(e=>{k(e);let t=g.select(`activeTriggerElement`);e!==null&&g.select(`open`)&&(t===e||g.select(`activeTriggerId`)==null)&&g.update({activeTriggerId:x??null,activeTriggerElement:e,closeDelay:u})}),j=Z.useRef(null),M=Z.useCallback(e=>{j.current=e,g.set(`activeTriggerElement`,e)},[g]);V(()=>(A(j.current),()=>A(null)),[A,x,g]),V(()=>{if(!S||!w)return;function e(e){L(e)===g.context.beforeContentFocusGuardRef.current&&(C.current=e.relatedTarget===j.current)}return w.addEventListener(`focusout`,e,!0),()=>{C.current=!1,w.removeEventListener(`focusout`,e,!0)}},[S,w,g]),g.useSyncedValue(`closeDelay`,u);let N=g.useState(`disabled`),ee=y.useState(`disabled`),P=d||N||ee,F=y.useState(`itemProps`),I=y.useState(`isActive`,b.index),te=Z.useMemo(()=>({type:`submenu-trigger`,setActive(e){y.select(`highlightItemOnHover`)&&y.setActiveIndex(b.index,Qe,e)}}),[y,b.index]),{getItemProps:ne,itemRef:re}=xw({closeOnClick:!1,disabled:P,highlighted:I,id:x,store:g,typingRef:y.context.typingRef,nativeButton:s,itemMetadata:te,nodeId:m?.context.nodeId}),ie=jl(T,{enabled:g.useState(`hoverEnabled`)&&c&&!P,handleClose:ql({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:l,delay:{open:l,close:u},shouldOpen:l>0?()=>y.select(`allowMouseEnter`):void 0,triggerElementRef:j,externalTree:E,isClosing:()=>g.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),ae=Hc(T,{enabled:!P,event:`mousedown`,toggle:!0,ignoreMouse:c,stickIfOpen:c}).reference??Ee,oe=g.useState(`triggerProps`,!0);delete oe.id;let R={disabled:P,highlighted:I,open:S},z=g.useState(`openMethod`),se=g.useState(`lastOpenChangeReason`)===`list-navigation`||z===`keyboard`,ce=S&&se&&Re,le=h?.onTriggerKeyDown?{onKeyDown:h.onTriggerKeyDown}:void 0;return v(`div`,e,{state:R,stateAttributesMapping:nc,props:[ae,ie,oe,le,F,ce?pT:void 0,{"aria-controls":O,tabIndex:_||!(S||I)?-1:0,onFocus(e){g.select(`open`)&&C.current&&(C.current=!1,g.setOpen(!1,H(Qt,e.nativeEvent)))},onBlur(){I&&y.setActiveIndex(null,tn)}},f,ne],ref:[t,b.ref,re,A,M]})}),hT=Z.forwardRef(function(e,t){let n=_w(e,t,`submenu-trigger`);if(!n.visible)return null;let r=n.props?ue(n.props,e):e;return(0,Q.jsx)(mT,{...r,ref:n.ref})}),gT=Z.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:y,setFilled:b,validationMode:x,validation:S}=gS(),{clearErrors:C,elementRef:w,submitCountRef:T}=yS(),E=h||s,O=m??a,k={...p,disabled:E},{labelId:A}=SS(),j=CS({id:i}),M=o!==void 0,N=o==null?void 0:String(o),ee=D(()=>S.inputRef.current?.value);_S(S.inputRef,j,N,ee,!E,a),V(()=>{let e=N??S.inputRef.current?.value;e!==void 0&&b(e!==``)},[N,l,S.inputRef,b]),jS(N,()=>{N!==void 0&&(C(O),_(N!==(y.initialValue??``)),S.change(N))});let P=Z.useRef(null),F=HS(E,P),I=Ht();return v(`input`,e,{ref:[t,P],state:k,props:[{id:j,disabled:E,name:O,ref:S.inputRef,"aria-labelledby":A,autoFocus:u,...M?{value:o}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=H(tn,e.nativeEvent);c?.(t,n),!M&&(_(t!==(y.initialValue??``)),b(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(C(O),S.change(t)))},onFocus(){F(!0)},onBlur(e){if(g(!0),F(!1),x===`onBlur`){let t=e.currentTarget.value;S.commit(t),M&&queueMicrotask(()=>{let e=S.inputRef.current?.value;e!==void 0&&e!==t&&e!==(y.initialValue??``)&&S.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){g(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===w.current&&!e.defaultPrevented){let t=e.currentTarget,n=T.current;I.start(0,()=>{T.current===n&&S.commit(t.value)})}else S.commit(t)}}},f,e=>S.getValidationProps(E,e)],stateAttributesMapping:pS})}),_T=Z.forwardRef(function(e,t){return(0,Q.jsx)(gT,{ref:t,...e})});function vT(e){let t=(0,qs.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,type:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=Xt(`h-7 w-full min-w-0 rounded-md border border-input bg-input/20 px-2 py-0.5 text-sm transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-xs/relaxed file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-xs/relaxed dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==a||t[8]!==i?(o=(0,Q.jsx)(_T,{type:i,"data-slot":`input`,className:a,...r}),t[6]=r,t[7]=a,t[8]=i,t[9]=o):o=t[9],o}function yT(e){let t=(0,qs.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=Xt(`group/input-group relative flex h-7 w-full min-w-0 items-center rounded-md border border-input bg-input/20 transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-data-[align=block-end]:rounded-md has-data-[align=block-start]:rounded-md has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-2 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/30 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-2 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[textarea]:rounded-md has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var bT=jt(`flex h-auto cursor-text items-center justify-center gap-1 py-2 text-xs/relaxed font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 **:data-[slot=kbd]:rounded-[calc(var(--radius-sm)-2px)] **:data-[slot=kbd]:bg-muted-foreground/10 **:data-[slot=kbd]:px-1 **:data-[slot=kbd]:text-[0.625rem] [&>svg:not([class*='size-'])]:size-3.5`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.275rem] has-[>kbd]:ml-[-0.275rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.275rem] has-[>kbd]:mr-[-0.275rem]`,"block-start":`order-first w-full justify-start px-2 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function xT(e){let t=(0,qs.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,o;t[4]!==a||t[5]!==n?(o=Xt(bT({align:a}),n),t[4]=a,t[5]=n,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":`input-group-addon`,"data-align":a,className:o,onClick:ST,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function ST(e){e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()}var CT=jt(`flex items-center gap-2 rounded-md text-xs/relaxed shadow-none`,{variants:{size:{xs:`h-5 gap-1 rounded-[calc(var(--radius-sm)-2px)] px-1 [&>svg:not([class*='size-'])]:size-3`,sm:`gap-1`,"icon-xs":`size-6 p-0 has-[>svg]:p-0`,"icon-sm":`size-7 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function wT(e){let t=(0,qs.c)(15),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:n,type:i,variant:a,size:o,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=i===void 0?`button`:i,c=a===void 0?`ghost`:a,l=o===void 0?`xs`:o,u;t[6]!==n||t[7]!==l?(u=Xt(CT({size:l}),n),t[6]=n,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==r||t[10]!==l||t[11]!==u||t[12]!==s||t[13]!==c?(d=(0,Q.jsx)($e,{type:s,"data-size":l,variant:c,className:u,...r}),t[9]=r,t[10]=l,t[11]=u,t[12]=s,t[13]=c,t[14]=d):d=t[14],d}function TT(e){let t=(0,qs.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=Xt(`flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(vT,{"data-slot":`input-group-control`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ET(e){let t=(0,qs.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=Xt(`[&_svg:not([class*='size-'])]:size-3.5`,r),t[4]=r,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(Ns,{className:`pointer-events-none size-3.5 text-muted-foreground`}),t[6]=o):o=t[6];let s;return t[7]!==n||t[8]!==i||t[9]!==a?(s=(0,Q.jsxs)(ZS,{"data-slot":`combobox-trigger`,className:a,...i,children:[n,o]}),t[7]=n,t[8]=i,t[9]=a,t[10]=s):s=t[10],s}function DT(e){let t=(0,qs.c)(10),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]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(wT,{variant:`ghost`,size:`icon-xs`}),t[3]=i):i=t[3];let a;t[4]===n?a=t[5]:(a=Xt(n),t[4]=n,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(Ut,{className:`pointer-events-none`}),t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==a?(s=(0,Q.jsx)(aC,{"data-slot":`combobox-clear`,render:i,className:a,...r,children:o}),t[7]=r,t[8]=a,t[9]=s):s=t[9],s}function OT(e){let t=(0,qs.c)(28),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]):({className:r,children:n,disabled:a,showTrigger:o,showClear:s,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a!==void 0&&a,l=o===void 0||o,u=s!==void 0&&s,d;t[7]===r?d=t[8]:(d=Xt(`w-auto`,r),t[7]=r,t[8]=d);let f;t[9]===c?f=t[10]:(f=(0,Q.jsx)(TT,{disabled:c}),t[9]=c,t[10]=f);let p;t[11]!==i||t[12]!==f?(p=(0,Q.jsx)(rC,{render:f,...i}),t[11]=i,t[12]=f,t[13]=p):p=t[13];let m;t[14]!==c||t[15]!==l?(m=l&&(0,Q.jsx)(wT,{size:`icon-xs`,variant:`ghost`,render:(0,Q.jsx)(ET,{}),"data-slot":`input-group-button`,className:`group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent`,disabled:c}),t[14]=c,t[15]=l,t[16]=m):m=t[16];let h;t[17]!==c||t[18]!==u?(h=u&&(0,Q.jsx)(DT,{disabled:c}),t[17]=c,t[18]=u,t[19]=h):h=t[19];let g;t[20]!==m||t[21]!==h?(g=(0,Q.jsxs)(xT,{align:`inline-end`,children:[m,h]}),t[20]=m,t[21]=h,t[22]=g):g=t[22];let _;return t[23]!==n||t[24]!==d||t[25]!==p||t[26]!==g?(_=(0,Q.jsxs)(yT,{className:d,children:[p,g,n]}),t[23]=n,t[24]=d,t[25]=p,t[26]=g,t[27]=_):_=t[27],_}function kT(e){let t=(0,qs.c)(21),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({className:r,side:a,sideOffset:o,align:s,alignOffset:c,anchor:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=a===void 0?`bottom`:a,u=o===void 0?6:o,d=s===void 0?`start`:s,f=c===void 0?0:c,p=!!n,m;t[8]===r?m=t[9]:(m=Xt(`group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) 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-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-7 *:data-[slot=input-group]:border-none *:data-[slot=input-group]:bg-input/20 *:data-[slot=input-group]:shadow-none dark:bg-popover 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`,r),t[8]=r,t[9]=m);let h;t[10]!==i||t[11]!==p||t[12]!==m?(h=(0,Q.jsx)(RC,{"data-slot":`combobox-content`,"data-chips":p,className:m,...i}),t[10]=i,t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;return t[14]!==d||t[15]!==f||t[16]!==n||t[17]!==l||t[18]!==u||t[19]!==h?(g=(0,Q.jsx)(xC,{children:(0,Q.jsx)(IC,{side:l,sideOffset:u,align:d,alignOffset:f,anchor:n,className:`isolate z-50`,children:h})}),t[14]=d,t[15]=f,t[16]=n,t[17]=l,t[18]=u,t[19]=h,t[20]=g):g=t[20],g}function AT(e){let t=(0,qs.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=Xt(`no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(vC,{"data-slot":`combobox-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function jT(e){let t=(0,qs.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=Xt(`relative flex min-h-7 w-full cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs/relaxed outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,r),t[4]=r,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(ow,{render:(0,Q.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`}),children:(0,Q.jsx)(js,{className:`pointer-events-none`})}),t[6]=o):o=t[6];let s;return t[7]!==n||t[8]!==i||t[9]!==a?(s=(0,Q.jsxs)(KC,{"data-slot":`combobox-item`,className:a,...i,children:[n,o]}),t[7]=n,t[8]=i,t[9]=a,t[10]=s):s=t[10],s}function MT(e){let t=(0,qs.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)(nT,{"data-slot":`dropdown-menu`,...n}),t[2]=n,t[3]=r),r}function NT(e){let t=(0,qs.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)(uT,{"data-slot":`dropdown-menu-trigger`,...n}),t[2]=n,t[3]=r),r}function PT(e){let t=(0,qs.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=Xt(`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)(Bw,{"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)(Uw,{children:(0,Q.jsx)(Gw,{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 FT(e){let t=(0,qs.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)(Tw,{"data-slot":`dropdown-menu-group`,...n}),t[2]=n,t[3]=r),r}function IT(e){let t=(0,qs.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=Xt(`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)(Ew,{"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 LT(e){let t=(0,qs.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=Xt(`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)(Ow,{"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 RT(e){let t=(0,qs.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)(iT,{"data-slot":`dropdown-menu-sub`,...n}),t[2]=n,t[3]=r),r}function zT(e){let t=(0,qs.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=Xt(`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)(Fs,{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)(hT,{"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 BT(e){let t=(0,qs.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=Xt(`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)(PT,{"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 VT(e){let t=(0,qs.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=Xt(`-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)(wb,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function HT(e){let t=(0,qs.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=Xt(`pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-xs bg-muted px-1 font-sans text-[0.625rem] font-medium text-muted-foreground select-none in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 [&_svg:not([class*='size-'])]:size-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`kbd`,{"data-slot":`kbd`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var UT=q({id:J,name:J,signOut:wo}),WT=Vn(To).atom(Kr(ki(`/auth/user`),Po(zi),Po(Gr(UT)))),GT=ti(jn(``));function KT(){return za(_o(Ex(GT)))}function qT(){let e=(0,qs.c)(27),t=Ex(WT);if(!Zn(t))return null;let n;e[0]===t.value.id?n=e[1]:(n=yn(`github:`,``)(t.value.id),e[0]=t.value.id,e[1]=n);let r=`https://avatars.githubusercontent.com/u/${n}?s=96`,i;e[2]!==t.value.name||e[3]!==r?(i=(0,Q.jsx)(rw,{src:r,alt:t.value.name}),e[2]=t.value.name,e[3]=r,e[4]=i):i=e[4];let a;e[5]===t.value.name?a=e[6]:(a=Qi(Uo(0,1)(t.value.name)),e[5]=t.value.name,e[6]=a);let o;e[7]===a?o=e[8]:(o=(0,Q.jsx)(iw,{children:a}),e[7]=a,e[8]=o);let s;e[9]!==i||e[10]!==o?(s=(0,Q.jsx)(NT,{"aria-label":`Account`,children:(0,Q.jsxs)(nw,{size:`sm`,children:[i,o]})}),e[9]=i,e[10]=o,e[11]=s):s=e[11];let c;e[12]===t.value.name?c=e[13]:(c=(0,Q.jsx)(FT,{children:(0,Q.jsxs)(IT,{children:[`@`,t.value.name]})}),e[12]=t.value.name,e[13]=c);let l;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(VT,{}),e[14]=l):l=e[14];let u=!t.value.signOut,d;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(d=new URLSearchParams({next:location.href}),e[15]=d):d=e[15];let f=`/auth/sign-out?${d}`,p;e[16]===f?p=e[17]:(p=(0,Q.jsx)(`a`,{"aria-label":`Sign out`,href:f}),e[16]=f,e[17]=p);let m;e[18]!==p||e[19]!==u?(m=(0,Q.jsx)(LT,{variant:`destructive`,disabled:u,render:p,children:`Sign out`}),e[18]=p,e[19]=u,e[20]=m):m=e[20];let h;e[21]!==m||e[22]!==c?(h=(0,Q.jsxs)(PT,{align:`end`,className:`w-auto min-w-48`,children:[c,l,m]}),e[21]=m,e[22]=c,e[23]=h):h=e[23];let g;return e[24]!==h||e[25]!==s?(g=(0,Q.jsxs)(MT,{children:[s,h]}),e[24]=h,e[25]=s,e[26]=g):g=e[26],g}function JT(e){let t=(0,qs.c)(66),[n,r]=kx(GT),[i,a]=(0,Z.useState)(!1),o;t[0]===n?o=t[1]:(o=()=>n!==``,t[0]=n,t[1]=o);let[s,c]=(0,Z.useState)(o),l=(0,Z.useRef)(null),u=(0,Z.useRef)(null),d,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=function(e){e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),c(!0),l.current?.focus())};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},f=[],t[2]=d,t[3]=f):(d=t[2],f=t[3]),(0,Z.useEffect)(d,f);let p,m,h,g,_,v,y,b,x,S,C;if(t[4]!==i||t[5]!==e.commands||t[6]!==e.label||t[7]!==n||t[8]!==s||t[9]!==r){let a;t[21]===n?a=t[22]:(a=e=>Oo(za(_o(n)))(za(e.label)),t[21]=n,t[22]=a),m=jo(e.commands,a);let o,d;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{(0,Ks.flushSync)(()=>c(!0)),l.current?.focus()},d=(0,Q.jsx)(Vs,{}),t[23]=o,t[24]=d):(o=t[23],d=t[24]),t[25]===e.label?g=t[26]:(g=(0,Q.jsx)($e,{variant:`ghost`,size:`icon-sm`,"aria-label":e.label,className:`ml-auto sm:hidden`,onClick:o,children:d}),t[25]=e.label,t[26]=g),C=u;let f=s&&`max-sm:bg-background max-sm:absolute max-sm:inset-0 max-sm:z-10 max-sm:flex max-sm:max-w-none max-sm:items-center max-sm:gap-2 max-sm:px-3`;t[27]===f?h=t[28]:(h=Xt(`mx-auto hidden w-full max-w-sm sm:flex lg:absolute lg:left-1/2 lg:-translate-x-1/2`,f),t[27]=f,t[28]=h),p=RS,_=m,v=null,y=YT,b=n,t[29]===r?x=t[30]:(x=(e,t)=>{t.reason!==`item-press`&&r(e)},t[29]=r,t[30]=x),S=i&&to(m),t[4]=i,t[5]=e.commands,t[6]=e.label,t[7]=n,t[8]=s,t[9]=r,t[10]=p,t[11]=m,t[12]=h,t[13]=g,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S,t[20]=C}else p=t[10],m=t[11],h=t[12],g=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18],S=t[19],C=t[20];let w=n!==``,T;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>a(!0),t[31]=T):T=t[31];let E;t[32]!==m||t[33]!==i||t[34]!==r?(E=e=>{e.key!==`Escape`||i&&to(m)||(r(``),c(!1),e.currentTarget.blur())},t[32]=m,t[33]=i,t[34]=r,t[35]=E):E=t[35];let D;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Q.jsx)(xT,{children:(0,Q.jsx)(Vs,{})}),t[36]=D):D=t[36];let O;t[37]===n?O=t[38]:(O=n===``&&(0,Q.jsx)(xT,{align:`inline-end`,className:`max-sm:hidden`,children:(0,Q.jsx)(HT,{children:`⌘K`})}),t[37]=n,t[38]=O);let k;t[39]!==e.label||t[40]!==w||t[41]!==E||t[42]!==O?(k=(0,Q.jsxs)(OT,{ref:l,"aria-label":e.label,placeholder:`Search or run a command`,showTrigger:!1,showClear:w,className:`w-full`,onFocus:T,onKeyDown:E,children:[D,O]}),t[39]=e.label,t[40]=w,t[41]=E,t[42]=O,t[43]=k):k=t[43];let A;t[44]===r?A=t[45]:(A=(0,Q.jsx)(kT,{anchor:u,children:(0,Q.jsx)(AT,{children:e=>(0,Q.jsxs)(jT,{value:e,onClick:()=>{r(``),c(!1),e.run()},children:[e.icon,e.label]},e.label)})}),t[44]=r,t[45]=A);let j;t[46]!==p||t[47]!==k||t[48]!==A||t[49]!==_||t[50]!==v||t[51]!==y||t[52]!==b||t[53]!==x||t[54]!==S?(j=(0,Q.jsxs)(p,{items:_,filter:v,itemToStringValue:y,value:b,onValueChange:x,open:S,onOpenChange:a,autoHighlight:!0,children:[k,A]}),t[46]=p,t[47]=k,t[48]=A,t[49]=_,t[50]=v,t[51]=y,t[52]=b,t[53]=x,t[54]=S,t[55]=j):j=t[55];let M;t[56]===r?M=t[57]:(M=(0,Q.jsx)($e,{variant:`ghost`,size:`sm`,className:`sm:hidden`,onClick:()=>{r(``),c(!1)},children:`Cancel`}),t[56]=r,t[57]=M);let N;t[58]!==h||t[59]!==j||t[60]!==M||t[61]!==C?(N=(0,Q.jsxs)(`div`,{ref:C,className:h,children:[j,M]}),t[58]=h,t[59]=j,t[60]=M,t[61]=C,t[62]=N):N=t[62];let ee;return t[63]!==g||t[64]!==N?(ee=(0,Q.jsxs)(Q.Fragment,{children:[g,N]}),t[63]=g,t[64]=N,t[65]=ee):ee=t[65],ee}function YT(e){return e.label}function XT(e){let t=(0,qs.c)(11),n;t[0]===e.active?n=t[1]:(n=Vi(e.active,{onFalse:eE,onTrue:$T}),t[0]=e.active,t[1]=n);let r=e.children,i;t[2]===e.active?i=t[3]:(i=cn({variant:Vi(e.active,{onFalse:QT,onTrue:ZT})}),t[2]=e.active,t[3]=i);let a;t[4]!==e.children||t[5]!==n||t[6]!==i?(a={"aria-current":n,children:r,className:i},t[4]=e.children,t[5]=n,t[6]=i,t[7]=a):a=t[7];let o;return t[8]!==e.render||t[9]!==a?(o={props:a,render:e.render},t[8]=e.render,t[9]=a,t[10]=o):o=t[10],qC(o)}function ZT(){return`secondary`}function QT(){return`ghost`}function $T(){return`page`}function eE(){}function tE(e){let t=(0,qs.c)(25),n;t[0]===e.icon?n=t[1]:(n=(0,Q.jsx)(`img`,{src:e.icon,alt:``,className:`pixelated size-8`}),t[0]=e.icon,t[1]=n);let r;t[2]===e.name?r=t[3]:(r=(0,Q.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.name}),t[2]=e.name,t[3]=r);let i;t[4]!==n||t[5]!==r?(i=(0,Q.jsxs)(`a`,{href:`/`,className:`-ml-1 flex shrink-0 items-center gap-1.5`,children:[n,r]}),t[4]=n,t[5]=r,t[6]=i):i=t[6];let a;t[7]===e.tabs?a=t[8]:(a=e.tabs!==void 0&&(0,Q.jsx)(`nav`,{"aria-label":`Sections`,className:`ml-2 flex items-center gap-1`,children:e.tabs}),t[7]=e.tabs,t[8]=a);let o;t[9]===e.commands?o=t[10]:(o=e.commands===void 0&&(0,Q.jsx)(`span`,{className:`flex-1`}),t[9]=e.commands,t[10]=o);let s;t[11]!==e.commands||t[12]!==e.name?(s=e.commands!==void 0&&(0,Q.jsx)(JT,{commands:e.commands,label:`Search ${e.name}`}),t[11]=e.commands,t[12]=e.name,t[13]=s):s=t[13];let c;t[14]===e.account?c=t[15]:(c=e.account??(0,Q.jsx)(qT,{}),t[14]=e.account,t[15]=c);let l;t[16]!==e.action||t[17]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 lg:ml-auto`,children:[e.action,c]}),t[16]=e.action,t[17]=c,t[18]=l):l=t[18];let u;return t[19]!==i||t[20]!==a||t[21]!==o||t[22]!==s||t[23]!==l?(u=(0,Q.jsxs)(`header`,{className:`bg-background border-border sticky top-0 z-30 flex h-12 shrink-0 items-center gap-2 border-b px-4`,children:[i,a,o,s,l]}),t[19]=i,t[20]=a,t[21]=o,t[22]=s,t[23]=l,t[24]=u):u=t[24],u}function nE(e){let t=(0,qs.c)(5),n=e.className,r;t[0]===e.result?r=t[1]:(r=Ya(Tr(Kn(e.result),rE)),t[0]=e.result,t[1]=r);let i;return t[2]!==e.className||t[3]!==r?(i=(0,Q.jsx)(Eb,{className:n,children:r}),t[2]=e.className,t[3]=r,t[4]=i):i=t[4],i}function rE(e){return e.message}var iE=jt(`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 aE(e){let t=(0,qs.c)(6),n;t[0]!==e.className||t[1]!==e.status||t[2]!==e.waiting?(n=Xt(iE({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}function oE(e){let t=(0,qs.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=Xt(`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 sE(e){let t=(0,qs.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=Xt(`[&_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 cE(e){let t=(0,qs.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=Xt(`[&_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 lE(e){let t=(0,qs.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=Xt(`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 uE(e){let t=(0,qs.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=Xt(`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 dE(e){let t=(0,qs.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=Xt(`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 fE=`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`,pE=`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`,mE=`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`,hE=`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`,gE=`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`,_E=`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`,vE=`/assets/firefox-5m8yovBp.svg`,yE=`/assets/safari-DgmPRf57.svg`;function bE(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 xE(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 SE(){return CE.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var CE={stubThis:e=>e};function wE(e){let{id:t}=e;return{...e,id:xE(t),transports:e.transports,type:e.type}}function TE(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 EE=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 DE({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 EE({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 EE({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 EE({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 EE({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 EE({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new EE({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 EE({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new EE({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(!TE(t))return new EE({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new EE({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 EE({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 EE({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 OE=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}}},kE=[`cross-platform`,`platform`];function AE(e){if(e&&!(kE.indexOf(e)<0))return e}async function jE(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(!SE())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:xE(t.challenge),user:{...t.user,id:xE(t.user.id)},excludeCredentials:t.excludeCredentials?.map(wE)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=OE.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw DE({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){ME(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=bE(e))}catch(e){ME(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=bE(c.getAuthenticatorData())}catch(e){ME(`getAuthenticatorData()`,e)}return{id:o,rawId:bE(s),response:{attestationObject:bE(c.attestationObject),clientDataJSON:bE(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:AE(a.authenticatorAttachment)}}function ME(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 NE(){if(!SE())return PE.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?PE.stubThis(new Promise(e=>e(!1))):PE.stubThis(e.isConditionalMediationAvailable())}var PE={stubThis:e=>e};function FE({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 EE({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new EE({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!TE(t))return new EE({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new EE({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 EE({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 IE(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(!SE())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(wE));let a={...t,challenge:xE(t.challenge),allowCredentials:i},o={};if(n){if(!await NE())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=OE.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw FE({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=bE(u.userHandle)),{id:c,rawId:bE(l),response:{authenticatorData:bE(u.authenticatorData),clientDataJSON:bE(u.clientDataJSON),signature:bE(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:AE(s.authenticatorAttachment)}}var LE=by,RE=Sy,zE=wy,BE=`https://auth.mp281x.xyz`;io(Zo(ua(`AUTH_URL`)),Sn),Fi()(`@deslop/runtime/auth/lib/utils/CurrentUser`);var VE=class e extends eo()(`@deslop/runtime/auth/lib/utils/RpcAuth`,{error:at}){static layerClient=t=>qo(e,e=>la(function*(){return yield*e.next({...e.request,headers:no(e.request.headers,`authorization`,`Bearer ${yield*t}`)})}))},HE=q({name:hs,open:hs,origin:$t}),UE=Ta(HE);q({origin:$t});var WE=xs([`ble`,`cable`,`hybrid`,`internal`,`nfc`,`smart-card`,`usb`]),GE=rs(`public-key`),KE=xs([`required`,`preferred`,`discouraged`]),qE=q({id:J,transports:_r(Oi(Ta(WE))),type:GE}),JE=q({attestation:_r(xs([`direct`,`enterprise`,`indirect`,`none`])),authenticatorSelection:_r(q({authenticatorAttachment:_r(xs([`cross-platform`,`platform`])),requireResidentKey:_r(wo),residentKey:_r(xs([`discouraged`,`preferred`,`required`])),userVerification:_r(KE)})),challenge:J,excludeCredentials:_r(Oi(Ta(qE))),pubKeyCredParams:Oi(Ta(q({alg:Ia,type:GE}))),rp:q({id:_r(J),name:J}),timeout:_r(Ia),user:q({displayName:J,id:J,name:J})}),YE=q({allowCredentials:_r(Oi(Ta(qE))),challenge:J,rpId:_r(J),timeout:_r(Ia),userVerification:_r(KE)}),XE=_r(xs([`cross-platform`,`platform`])),ZE=q({authenticatorAttachment:XE,clientExtensionResults:q({}),id:J,rawId:J,response:q({attestationObject:J,clientDataJSON:J,transports:_r(Ta(J))}),type:GE}),QE=q({authenticatorAttachment:XE,clientExtensionResults:q({}),id:J,rawId:J,response:q({authenticatorData:J,clientDataJSON:J,signature:J,userHandle:_r(J)}),type:GE});q({challenge:J});var $E=q({addedFrom:J,counter:Aa,createdAt:Ia,id:hs,lastUsed:Ia,publicKey:hs,synced:wo,transports:Ta(WE),user:Lt});Ta($E);var eD=q({addedFrom:J,createdAt:Ia,id:hs,lastUsed:Ia,synced:wo}),tD=q({id:hs}),nD=q({response:ZE}),rD=q({next:_r(hs.check(ei(2048))),response:QE}),iD=q({client_name:_r(J.check(ei(100))),redirect_uris:oa(hs.check(ei(200))).check(ei(4)),token_endpoint_auth_method:_r(rs(`none`))});q({name:J,redirects:iD.fields.redirect_uris}),q({client_id:hs.check(ei(2048)),redirect_uri:_r(J),state:_r(J)}),q({code_challenge:_r(hs),code_challenge_method:_r(J),resource:_r(ha(J)),response_type:_r(J),scope:_r(J)});var aD=q({challenge:hs,clientId:hs,clientName:J,redirectUri:hs,resources:oa(dt),state:_r(hs)});q({grant_type:J});var oD=_r(ha(dt).check(Ds(1)));qa([q({client_id:hs,code:hs,code_verifier:hs,grant_type:rs(`authorization_code`),redirect_uri:_r(J),resource:oD}),q({client_id:_r(J),grant_type:rs(`refresh_token`),refresh_token:hs,resource:oD})]);var sD=q({access_token:hs,expires_in:Ia,refresh_token:hs,scope:rs(`deslop`),token_type:rs(`Bearer`)});En({Granted:{tokens:sD},Replayed:{message:J}});var cD=q({address:_r(J),userAgent:_r(J)}),lD=q({expiresAt:Ia,hash:J,resources:Ta(dt)}),uD=xs([`Code`,`GitHub`,`Passkey`]),dD=q({client:J,createdAt:Ia,credential:En({App:{access:Ta(lD),clientId:hs,expiresAt:Ia,generation:Aa,hash:J,replaced:_r(J),resources:Ta(dt)},Browser:{expiresAt:Ia,hash:J,via:_r(uD)}}),device:J,lastActive:Ia,origin:cD,user:Lt});ls(J,dD);var fD=q({address:_r(J),client:J,device:J,family:hs,kind:xs([`App`,`Browser`]),lastActive:Ia,resources:Ta(dt)}),pD=q({family:hs});q({client_id:hs,token:hs}),q({resource:dt});var mD=xs([`Admin`,`Member`,`Waiting`]),hD=q({...Lt.fields,fullName:_r(J),role:mD}),gD=q({...hD.fields,via:uD}),_D=q({...hD.fields,since:Ia}),vD=xs([`Waiting`,`Allowed`]),yD=q({fullName:J,id:hs,name:hs,since:Ia,status:vD});Ta(yD),q({id:Aa,login:hs,name:_r(oi(J))});var bD=q({allow:wo,id:hs}),xD=q({id:hs}),SD=xs([`App`,`Browser`]),CD=q({address:_r(J),clientName:J,createdAt:Ia,device:J,expiresAt:Ia,id:hs,kind:SD,resources:Ta(dt)}),wD=En({Decided:{},Expired:{},Waiting:{request:CD}}),TD=En({Browser:{next:_r(J)},Client:{request:aD}});En({Redirect:{url:hs},Session:{next:_r(J),seconds:Aa,token:hs},Waiting:{}}),q({delivery:TD,origin:cD}),q({next:_r(hs.check(ei(2048)))});var ED=q({request:hs.check(ei(20))}),DD=q({code:hs.check(ei(20))}),OD=q({...ED.fields,accept:wo}),kD=class extends da(ja(`auth.lookup`,{error:at,payload:DD,stream:!0,success:In(CD)}),ja(`auth.answer`,{error:at,payload:OD}),ja(`auth.people`,{error:at,stream:!0,success:Ta(_D)}),ja(`auth.admit`,{error:at,payload:bD,success:_D}),ja(`auth.remove`,{error:at,payload:xD,success:_D}),ja(`auth.apps`,{error:at,stream:!0,success:Ta(fD)}),ja(`auth.catalog`,{error:at,stream:!0,success:UE}),ja(`auth.disconnect`,{error:at,payload:pD}),ja(`auth.passkeys`,{error:at,stream:!0,success:Ta(eD)}),ja(`auth.passkeyOptions`,{error:at,success:JE}),ja(`auth.addPasskey`,{error:at,payload:nD}),ja(`auth.removePasskey`,{error:at,payload:tD})).middleware(VE).merge(da(ja(`auth.account`,{error:at,stream:!0,success:gD}),ja(`auth.wait`,{error:at,payload:ED,stream:!0,success:wD}))){};function AD(e){return Qi(_a(/[^a-z]/giu,``)(e))}t(((e,t,n)=>{(function(e){let n=`(0?\\d+|0x[a-f0-9]+)`,r={fourOctet:RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,`i`),threeOctet:RegExp(`^${n}\\.${n}\\.${n}$`,`i`),twoOctet:RegExp(`^${n}\\.${n}$`,`i`),longValue:RegExp(`^${n}$`,`i`)},i=RegExp(`^0[0-7]+$`,`i`),a=RegExp(`^0x[a-f0-9]+$`,`i`),o=`%[0-9a-z]{1,}`,s=`(?:[0-9a-f]+::?)+`,c={zoneIndex:RegExp(o,`i`),native:RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,`i`),deprecatedTransitional:RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,`i`),transitional:RegExp(`^((?:${s})|(?:::)(?:${s})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,`i`)};function l(e,t){if(e.indexOf(`::`)!==e.lastIndexOf(`::`))return null;let n=0,r=-1,i=(e.match(c.zoneIndex)||[])[0],a,o;for(i&&(i=i.substring(1),e=e.replace(/%.+$/,``));(r=e.indexOf(`:`,r+1))>=0;)n++;if(e.substr(0,2)===`::`&&n--,e.substr(-2,2)===`::`&&n--,n>=t)return null;for(o=t-n,a=`:`;o--;)a+=`0:`;return e=e.replace(`::`,a),e[0]===`:`&&(e=e.slice(1)),e[e.length-1]===`:`&&(e=e.slice(0,-1)),t=(function(){let t=e.split(`:`),n=[];for(let e=0;e<t.length;e++)n.push(t[e].length>4?NaN:parseInt(t[e],16));return n})(),{parts:t,zoneId:i}}function u(e,t,n,r){if(e.length!==t.length)throw Error(`ipaddr: cannot match CIDR for objects with different lengths`);let i=0,a;for(;r>0;){if(a=n-r,a<0&&(a=0),e[i]>>a!==t[i]>>a)return!1;r-=n,i+=1}return!0}function d(e){if(a.test(e))return parseInt(e,16);if(e[0]===`0`&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function f(e,t){for(;e.length<t;)e=`0${e}`;return e}let p={};p.IPv4=(function(){function e(e){if(e.length!==4)throw Error(`ipaddr: ipv4 octet count should be 4`);let t,n;for(t=0;t<e.length;t++)if(n=e[t],!(0<=n&&n<=255))throw Error(`ipaddr: ipv4 octet should fit in 8 bits`);this.octets=e}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]],as112:[[new e([192,175,48,0]),24],[new e([192,31,196,0]),24]],amt:[[new e([192,52,193,0]),24]]},e.prototype.kind=function(){return`ipv4`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv4`)throw Error(`ipaddr: cannot match ipv4 address with non-ipv4 one`);return u(this.octets,e.octets,8,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},r,i,a;for(r=3;r>=0;--r)if(i=this.octets[r],i in n){if(a=n[i],t&&a!==0)return null;a!==8&&(t=!0),e+=a}else return null;return 32-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(`.`)},e})(),p.IPv4.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<4;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.isIPv4=function(e){return this.parser(e)!==null},p.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch{return!1}},p.IPv4.isValidCIDR=function(e){try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(e){return!!(p.IPv4.isValid(e)&&e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.isValidCIDRFourPartDecimal=function(e){let t=e.match(/^(.+)\/(\d+)$/);return!p.IPv4.isValidCIDR(e)||!t?!1:p.IPv4.isValidFourPartDecimal(t[1])},p.IPv4.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv4 Address`);return new this(t)},p.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){let e=parseInt(t[2]);if(e>=0&&e<=32){let n=[this.parse(t[1]),e];return Object.defineProperty(n,"toString",{value:function(){return this.join(`/`)}}),n}}throw Error(`ipaddr: string is not formatted like an IPv4 CIDR range`)},p.IPv4.parser=function(e){let t,n,i;if(t=e.match(r.fourOctet))return(function(){let e=t.slice(1,6),r=[];for(let t=0;t<e.length;t++)n=e[t],r.push(d(n));return r})();if(t=e.match(r.longValue)){if(i=d(t[1]),i>4294967295||i<0)throw Error(`ipaddr: address outside defined range`);return(function(){let e=[],t=0;for(;t<=24;t+=8)e.push(i>>t&255);return e})().reverse()}return(t=e.match(r.twoOctet))?(function(){let e=t.slice(1,4),n=[];if(i=d(e[1]),i>16777215||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(i>>16&255),n.push(i>>8&255),n.push(i&255),n})():(t=e.match(r.threeOctet))?(function(){let e=t.slice(1,5),n=[];if(i=d(e[2]),i>65535||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(d(e[1])),n.push(i>>8&255),n.push(i&255),n})():null},p.IPv4.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>32)throw Error(`ipaddr: invalid IPv4 prefix length`);let t=[0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<4&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.IPv6=(function(){function e(e,t){let n,r;if(e.length===16)for(this.parts=[],n=0;n<=14;n+=2)this.parts.push(e[n]<<8|e[n+1]);else if(e.length===8)this.parts=e;else throw Error(`ipaddr: ipv6 part count should be 8 or 16`);for(n=0;n<this.parts.length;n++)if(r=this.parts[n],!(0<=r&&r<=65535))throw Error(`ipaddr: ipv6 part should fit in 16 bits`);t&&(this.zoneId=t)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],deprecatedSiteLocal:[new e([65216,0,0,0,0,0,0,0]),10],discard:[new e([256,0,0,0,0,0,0,0]),64],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[[new e([100,65435,0,0,0,0,0,0]),96],[new e([100,65435,1,0,0,0,0,0]),48]],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[[new e([8193,4,274,0,0,0,0,0]),48],[new e([9760,79,32768,0,0,0,0,0]),48]],deprecatedOrchid:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new e([8193,48,0,0,0,0,0,0]),28],segmentRouting:[new e([24320,0,0,0,0,0,0,0]),16],reserved:[[new e([8193,0,0,0,0,0,0,0]),23],[new e([8193,3512,0,0,0,0,0,0]),32],[new e([16383,0,0,0,0,0,0,0]),20]]},e.prototype.isIPv4MappedAddress=function(){return this.range()===`ipv4Mapped`},e.prototype.kind=function(){return`ipv6`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv6`)throw Error(`ipaddr: cannot match ipv6 address with non-ipv6 one`);return u(this.parts,e.parts,16,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},r,i;for(let a=7;a>=0;--a)if(r=this.parts[a],r in n){if(i=n[r],t&&i!==0)return null;i!==16&&(t=!0),e+=i}else return null;return 128-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e,t=[],n=this.parts;for(let r=0;r<n.length;r++)e=n[r],t.push(e>>8),t.push(e&255);return t},e.prototype.toFixedLengthString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(f(this.parts[t].toString(16),4));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw Error(`ipaddr: trying to convert a generic ipv6 address to ipv4`);let e=this.parts.slice(-2),t=e[0],n=e[1];return new p.IPv4([t>>8,t&255,n>>8,n&255])},e.prototype.toNormalizedString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(this.parts[t].toString(16));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toRFC5952String=function(){let e=/((^|:)(0(:|$)){2,})/g,t=``;this.zoneId&&(t=`%${this.zoneId}`);let n=this.toNormalizedString(),r=n.slice(0,n.length-t.length),i=0,a=-1,o=-1,s;for(;s=e.exec(r);){let e=(s[0].match(/0/g)||[]).length;e>o&&(o=e,i=s.index,a=s[0].length)}return a<0?r+t:`${r.substring(0,i)}::${r.substring(i+a)}${t}`},e.prototype.toString=function(){return this.toRFC5952String()},e})(),p.IPv6.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<16;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.isIPv6=function(e){return this.parser(e)!==null},p.IPv6.isValid=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{let t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch{return!1}},p.IPv6.isValidCIDR=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<16;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv6 Address`);return new this(t.parts,t.zoneId)},p.IPv6.parseCIDR=function(e){let t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=128))return r=[this.parse(n[1]),t],Object.defineProperty(r,"toString",{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv6 CIDR range`)},p.IPv6.parser=function(e){let t,n,r,i,a,o;if(r=e.match(c.deprecatedTransitional))return this.parser(`::ffff:${r[1]}`);if(c.native.test(e))return l(e,8);if((r=e.match(c.transitional))&&(o=r[6]||``,t=r[1],r[1].endsWith(`::`)||(t=t.slice(0,-1)),t=l(t+o,6),t&&t.parts)){for(a=[parseInt(r[2]),parseInt(r[3]),parseInt(r[4]),parseInt(r[5])],n=0;n<a.length;n++)if(i=a[n],!(0<=i&&i<=255))return null;return t.parts.push(a[0]<<8|a[1]),t.parts.push(a[2]<<8|a[3]),{parts:t.parts,zoneId:t.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>128)throw Error(`ipaddr: invalid IPv6 prefix length`);let t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<16&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.fromByteArray=function(e){let t=e.length;if(t===4)return new p.IPv4(e);if(t===16)return new p.IPv6(e);throw Error(`ipaddr: the binary input is neither an IPv6 nor IPv4 address`)},p.isValid=function(e){return p.IPv6.isValid(e)||p.IPv4.isValid(e)},p.isValidCIDR=function(e){return p.IPv6.isValidCIDR(e)||p.IPv4.isValidCIDR(e)},p.parse=function(e){if(p.IPv6.isValid(e))return p.IPv6.parse(e);if(p.IPv4.isValid(e))return p.IPv4.parse(e);throw Error(`ipaddr: the address has neither IPv6 nor IPv4 format`)},p.parseCIDR=function(e){try{return p.IPv6.parseCIDR(e)}catch{try{return p.IPv4.parseCIDR(e)}catch(e){throw Error(`ipaddr: the address has neither IPv6 nor IPv4 CIDR format`,{cause:e})}}},p.process=function(e){let t=this.parse(e);return t.kind()===`ipv6`&&t.isIPv4MappedAddress()?t.toIPv4Address():t},p.subnetMatch=function(e,t,n){let r,i,a,o;for(i in n??=`unicast`,t)if(Object.prototype.hasOwnProperty.call(t,i)){for(a=t[i],a[0]&&!(a[0]instanceof Array)&&(a=[a]),r=0;r<a.length;r++)if(o=a[r],e.kind()===o[0].kind()&&e.match.apply(e,o))return i}return n},t!==void 0&&t.exports?t.exports=p:e.ipaddr=p})(n)}))();function jD(e){return as(Rn(e),Li)}Va(function*(e,t,n){if(Sn(jD(n.response_type)))return yield*at.make({message:`Send response_type=code`});if(n.response_type!==`code`)return yield*at.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*at.make({message:`Send a PKCE code_challenge with code_challenge_method=S256`});if(!uo(jo(fo(n.scope??``,` `),Li),e=>e===`deslop`||e===`offline_access`))return yield*at.make({error:`invalid_scope`,message:`Only the deslop scope is supported`});let r=yield*Kr(Pr(oa(dt))(n.resource??[]),wa(e=>at.make({cause:e,error:`invalid_target`,message:`Name a Deslop app with the resource parameter`})));return aD.make({challenge:n.code_challenge,clientId:e.client_id,clientName:t.clientName,redirectUri:t.redirectUri,resources:r,...Ar(jD(e.state),{onNone:()=>({}),onSome:e=>({state:e})})})});function MD(e){return Kr(new URL(e).hostname,fo(`.`),Ho(1),Sa(`.`))}function ND(e,t){let n=MD(t);return ni(Ko(e),{onFailure:()=>!1,onSuccess:e=>e.protocol===`https:`&&(e.hostname===n||gr(`.${n}`)(e.hostname))&&dr(e.username)&&dr(e.password)})}var PD=Vn(To),FD=class extends xa()(`@deslop/auth/lib/utils/RpcClient`,{group:kD,protocol:nt(`@deslop/auth`)}){};function ID(e){return Wn(e,e=>Kr(e(tr(`1 second`)),gi(e=>e.input._tag===`RpcClientError`)))}var LD=ti(FD.runtime.atom(Kr(FD,ma(e=>e(`auth.account`,void 0)),Ga,ID,ii(ir),So(`AuthError`,()=>ps(Vr()))))),RD={accept:wo,request:CD},zD=xb(FD.runtime).make(RE({branches:{looked:{found:{target:`Code.Found`},missing:{target:`Code.Missing`}}},events:zE({Answered:RD,Typed:{typed:J}}),root:LE({states:{Code:{fields:{code:J},states:{Failed:{fields:{message:J}},Found:{fields:{request:CD}},Looking:{},Missing:{}}},Typing:{fields:{answered:_r(q(RD)),typed:J}}}}),streams:{lookup:e=>ID(Ga(ma(FD,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=>Ar(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=>Mi(e.state.typed)>=8,target:`Code`}}}})),BD=jn(e=>{e.set(zD.send,{_tag:`Typed`,typed:AD(new URLSearchParams(location.search).get(`code`)??``)})}),VD=ti(FD.runtime.atom(Kr(FD,ma(e=>e(`auth.people`,void 0)),Ga,ID))),HD=ti(FD.runtime.atom(Kr(FD,ma(e=>e(`auth.apps`,void 0)),Ga,ID)));function UD(e){return t=>Qa(t,t=>K(()=>W.add({description:t.message,title:e,type:`error`})))}var WD=FD.runtime.fn(e=>Kr(Po(FD,t=>ea(e,e=>t(`auth.disconnect`,{family:e}),{concurrency:`unbounded`,discard:!0})),UD(`Cannot sign out`))),GD=gs(e=>FD.runtime.fn(t=>Po(FD,n=>n(`auth.admit`,{allow:t,id:e})))),KD=gs(e=>FD.runtime.fn(()=>Po(FD,t=>t(`auth.remove`,{id:e})))),qD=Hn(new URLSearchParams(location.search).get(`request`)),JD=gs(e=>FD.runtime.atom(Kr(FD,ma(t=>t(`auth.wait`,{request:e})),Ga,ID,Za(t=>Kr(bo(t),Fo(`Decided`,()=>K(()=>location.assign(`/auth/continue?${new URLSearchParams({request:e})}`))),ho(()=>Y))))));function YD(e){return`${Uo(0,4)(e)}-${Uo(4)(e)}`}function XD(e){return`${location.origin}/?code=${e}`}var ZD=ti(FD.runtime.atom(Kr(FD,ma(e=>e(`auth.catalog`,void 0)),Ga,ID)));function QD(e){return Jo(e)?[`browser`]:ga(xo(e,e=>new URL(e).origin))}function $D(e){return Kr(Ca(e),pa({hour:`2-digit`,minute:`2-digit`}))}var eO=jn(Kr(wn(`1 minute`),Pn(()=>Hr))),tO=jn(Kr(wn(`1 second`),Pn(()=>Hr)));function nO(e,t){let n=Lo(0,Math.ceil((e-t)/1e3));return`${Math.floor(n/60)}:${Yr(2,`0`)(`${n%60}`)}`}var rO=ta(e=>Kr(Tn({catch:e=>at.make({cause:e,message:`Cannot copy the code; type it in instead`}),try:()=>navigator.clipboard.writeText(e)}),X(cs(`1200 millis`))));function iO(e,t){return Math.floor(lr(Yo(Ca(e),Ca(t))))}function aO(e){return e<1?`now`:e<60?`${e}m`:e<1440?`${Math.floor(e/60)}h`:`${Math.floor(e/1440)}d`}function oO(e,t){return`${e} · ${t}`}function sO(e){return Ea(e,0,(e,t)=>Lo(e,t.lastActive))}function cO(e){return Kr(Ca(e),pa({day:`numeric`,month:`short`}))}function lO(e){return`https://avatars.githubusercontent.com/u/${yn(`github:`,``)(e)}?s=96`}var uO=FD.runtime.fn((e,t)=>Kr(FD,Po(t=>t(`auth.answer`,{accept:e.accept,request:e.request.id})),X(K(()=>t.set(zD.send,{_tag:`Answered`,...e}))))),dO=Hn(new URLSearchParams(location.search).get(`next`));function fO(e){return wi(e.cause,`name`)&&e.cause.name===`NotAllowedError`}var pO=Va(function*(e){return e.status===429?yield*at.make({message:`Too many tries; wait a minute and try again`}):yield*at.make({message:(yield*Gr(q({error_description:J}))(e)).error_description})}),mO=PD.fn(()=>Kr(la(function*(){let e=yield*cr,t=yield*e.get(`/auth/passkey`);if(t.status!==200)return yield*pO(t);let n=yield*Gr(YE)(t),r=yield*Ii(Tn({catch:e=>at.make({cause:e,message:`No passkey was used`}),try:()=>IE({optionsJSON:n})}),fO,()=>ro),i=yield*Kr(gn(`/auth/passkey`),ba(rD)({...Ar(dO,{onNone:()=>({}),onSome:e=>({next:e})}),response:r}),Po(t=>e.execute(t)),Po(Va(function*(e){return e.status===200?yield*Gr(q({next:_r(J)}))(e):yield*pO(e)})));yield*K(()=>Ar(Rn(i.next),{onNone:()=>location.reload(),onSome:e=>location.assign(e)}))}),wa(e=>Cr(at)(e)?e:at.make({cause:e,message:`Cannot sign in with a passkey`})))),hO=ti(FD.runtime.atom(Kr(FD,ma(e=>e(`auth.passkeys`,void 0)),Ga,ID))),gO=ti(FD.runtime.fn(Va(function*(){let e=yield*FD,t=yield*e(`auth.passkeyOptions`,void 0);yield*e(`auth.addPasskey`,{response:yield*Kr(Tn({catch:e=>at.make({cause:e,message:`No passkey was added`}),try:()=>jE({optionsJSON:t})}),Ii(fO,()=>ro),Po(Pr(ZE)))}),W.add({title:`Passkey added`})},UD(`Cannot add a passkey`)))),_O=`adding-passkey`,vO=ta(()=>Ka({catch:e=>at.make({cause:e,message:`Cannot start GitHub sign-in`}),try:()=>{sessionStorage.setItem(_O,`true`),location.assign(`/auth/github`)}})),yO=ti(FD.runtime.fn(e=>Kr(Po(FD,t=>t(`auth.removePasskey`,{id:e})),UD(`Cannot remove the passkey`)))),bO=ta(()=>Ka({catch:e=>at.make({cause:e,message:`Cannot start GitHub sign-in`}),try:()=>location.assign(`/auth/github${location.search}`)})),xO=ta(()=>Ka({catch:e=>at.make({cause:e,message:`Cannot start the sign-in`}),try:()=>location.assign(Ar(dO,{onNone:()=>`/auth/code`,onSome:e=>`/auth/code?${new URLSearchParams({next:e})}`}))})),SO=new URLSearchParams(location.search).has(`sign-out`),CO=Kr(Hn(new URLSearchParams(location.search).get(`next`)),as(e=>ND(e,BE)),Ir(()=>location.pathname)),wO=Kr(cr.use(e=>Pi(e).post(`/auth/sign-out`)),X(K(()=>location.replace(CO))),wa(e=>at.make({cause:e,message:`Cannot sign out: ${e.message}`}))),TO=PD.fn(()=>wO),EO=PD.fn(()=>UD(`Cannot sign out`)(wO));function DO(e){let t=(0,qs.c)(17),n,r,i,a,o,s;if(t[0]!==e.className||t[1]!==e.text){let c=go(mx(e.text)),l=Math.sqrt(c.length);r=`-2 -2 ${l+4} ${l+4}`,i=`crispEdges`,a=`currentColor`,o=e.className,s=`true`,n=Kr(c,xo((e,t)=>({dark:e,x:t%l,y:Math.floor(t/l)})),jo(kO),xo(OO),Sa(``)),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 OO(e){return`M${e.x} ${e.y}h1v1h-1z`}function kO(e){return e.dark===1}function AO(e){let t=(0,qs.c)(12),n;t[0]===e.id?n=t[1]:(n=lO(e.id),t[0]=e.id,t[1]=n);let r;t[2]!==e.name||t[3]!==n?(r=(0,Q.jsx)(rw,{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=Qi(Uo(0,1)(e.name)),t[5]=e.name,t[6]=i);let a;t[7]===i?a=t[8]:(a=(0,Q.jsx)(iw,{children:i}),t[7]=i,t[8]=a);let o;return t[9]!==r||t[10]!==a?(o=(0,Q.jsxs)(nw,{size:`sm`,children:[r,a]}),t[9]=r,t[10]=a,t[11]=o):o=t[11],o}function jO(e){let t=(0,qs.c)(11),[n,r]=(0,Z.useState)(`loading`),i;t[0]===e.small?i=t[1]:(i=Xt(`text-muted-foreground relative flex shrink-0 items-center justify-center`,Vi(e.small===!0,{onFalse:NO,onTrue:MO})),t[0]=e.small,t[1]=i);let a;t[2]===n?a=t[3]:(a=n!==`loaded`&&(0,Q.jsx)(ks,{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:Xt(`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 MO(){return`size-4`}function NO(){return`size-5`}var PO={Chrome:mE,Edge:_E,Firefox:vE,Safari:yE};function FO(e){return e.kind===`Browser`?Tr(_s(PO,e.name),e=>({mono:!1,src:e})):Ua(Ui(/claude/iu)(e.name))?ir({mono:!1,src:hE}):Ua(Ui(/codex/iu)(e.name))?ir({mono:!0,src:gE}):Ua(Ui(/gateway/iu)(e.name))?Vr():qr([`iPhone`,`iPad`],e.device)?ir({mono:!0,src:pE}):e.device===`Android`?ir({mono:!1,src:fE}):Vr()}function IO(e){return Ar(FO(e.client),{onNone:()=>Kr(bo(e.client),Bo({kind:`Browser`},()=>(0,Q.jsx)(Ls,{})),Bo(e=>Ua(Ui(/gateway/iu)(e.name)),()=>(0,Q.jsx)(zs,{})),ho(()=>(0,Q.jsx)(Us,{}))),onSome:e=>(0,Q.jsx)(`img`,{src:e.src,alt:``,className:Xt(`size-3.5`,e.mono&&`dark:invert`)})})}function LO(e){return Ar(e.client.app,{onNone:()=>(0,Q.jsx)(IO,{client:e.client}),onSome:e=>(0,Q.jsx)(jO,{origin:e,small:!0})})}function RO(e){let t=(0,qs.c)(33),[n,r]=Id(WD),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=iO(e.column.lastActive,e.now);return`active ${Vi(t<1,{onFalse:()=>`${aO(t)} ago`,onTrue:BO})}`},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=Sa([Vi(e.column.pending,{onFalse:n,onTrue:zO}),...yr(as(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)(MT,{children:[(0,Q.jsx)(NT,{render:(0,Q.jsx)($e,{variant:`ghost`,size:`icon-sm`,title:o,"aria-label":o}),children:(0,Q.jsx)(LO,{client:e.column.client})}),(0,Q.jsxs)(PT,{align:`end`,className:`w-auto min-w-48`,children:[(0,Q.jsx)(FT,{children:(0,Q.jsxs)(IT,{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)(LT,{variant:`destructive`,disabled:pi(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)(LO,{client:e.column.client})}),t[28]=o,t[29]=e.column.client,t[30]=c):c=t[30],s=Vi(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)(uE,{className:`px-0.5`,children:(0,Q.jsx)(`span`,{className:`flex justify-center`,children:s})}),t[31]=s,t[32]=c),c}function zO(){return`waiting for an answer`}function BO(){return`now`}function VO(e,t,n){let r=QD(e);return qr(r,t)||qr(r,`browser`)&&n}function HO(e,t){return Gi(e.resources,e=>VO(e,t.origin,t.web))}function UO(e){let t=(0,qs.c)(21),n,r,i,a,o,s;if(t[0]!==e.column||t[1]!==e.row){let c=HO(e.column,e.row);n=dE,s=`w-7 px-0`,a=`flex justify-center`;let l;t[8]===e.column.pending?l=t[9]:(l=()=>(0,Q.jsx)(aE,{waiting:e.column.pending}),t[8]=e.column.pending,t[9]=l),o=Vi(c,{onFalse:qO,onTrue:l}),r=`sr-only`,i=Kr(bo({held:c,pending:e.column.pending}),Bo({held:!1},KO),Bo({pending:!0},GO),ho(WO)),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 WO(){return`signed in`}function GO(){return`asked for`}function KO(){return`not signed in`}function qO(){return(0,Q.jsx)(aE,{status:`off`})}function JO(e){let t=(0,qs.c)(42),[n,r]=Id(uO),i;if(t[0]!==e.request.clientName||t[1]!==e.request.device||t[2]!==e.request.kind){let n,r;t[4]!==e.request.clientName||t[5]!==e.request.device?(n=()=>`${oO(e.request.clientName,e.request.device)} asks for the apps its column marks`,r=()=>`Signs in ${oO(e.request.clientName,e.request.device)} as you to every mp281x.xyz app for 30 days, including approving sign-ins`,t[4]=e.request.clientName,t[5]=e.request.device,t[6]=n,t[7]=r):(n=t[6],r=t[7]),i=Vi(e.request.kind===`Browser`,{onFalse:n,onTrue:r}),t[0]=e.request.clientName,t[1]=e.request.device,t[2]=e.request.kind,t[3]=i}else i=t[3];let a;t[8]===e.request.address?a=t[9]:(a=Ar(Rn(e.request.address),{onNone:XO,onSome:YO}),t[8]=e.request.address,t[9]=a);let o;t[10]!==i||t[11]!==a?(o=(0,Q.jsxs)(Tb,{children:[i,a,`. Approve only a code you started yourself.`]}),t[10]=i,t[11]=a,t[12]=o):o=t[12];let s;t[13]===n?s=t[14]:(s=(0,Q.jsx)(nE,{result:n}),t[13]=n,t[14]=s);let c;t[15]!==e.request.clientName||t[16]!==e.request.device?(c=oO(e.request.clientName,e.request.device),t[15]=e.request.clientName,t[16]=e.request.device,t[17]=c):c=t[17];let l=`Approve ${c}`,u;t[18]===n?u=t[19]:(u=pi(n),t[18]=n,t[19]=u);let d;t[20]!==e.request||t[21]!==r?(d=()=>r({accept:!0,request:e.request}),t[20]=e.request,t[21]=r,t[22]=d):d=t[22];let f;t[23]!==l||t[24]!==u||t[25]!==d?(f=(0,Q.jsx)($e,{size:`lg`,"aria-label":l,disabled:u,onClick:d,children:`Approve`}),t[23]=l,t[24]=u,t[25]=d,t[26]=f):f=t[26];let p;t[27]===n?p=t[28]:(p=pi(n),t[27]=n,t[28]=p);let m;t[29]!==e.request||t[30]!==r?(m=()=>r({accept:!1,request:e.request}),t[29]=e.request,t[30]=r,t[31]=m):m=t[31];let h;t[32]!==m||t[33]!==p?(h=(0,Q.jsx)($e,{size:`lg`,variant:`outline`,disabled:p,onClick:m,children:`Deny`}),t[32]=m,t[33]=p,t[34]=h):h=t[34];let g;t[35]!==h||t[36]!==f?(g=(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[f,h]}),t[35]=h,t[36]=f,t[37]=g):g=t[37];let _;return t[38]!==g||t[39]!==o||t[40]!==s?(_=(0,Q.jsxs)(Q.Fragment,{children:[o,s,g]}),t[38]=g,t[39]=o,t[40]=s,t[41]=_):_=t[41],_}function YO(e){return` · from ${e}`}function XO(){return``}function ZO(e,t,n){function r(e,t,r){return{app:Tr(Ra(n,t=>r===`App`&&za(t.name)===za(e)),e=>e.origin),device:t,kind:r,name:e}}return[...Ar(e,{onNone:()=>[],onSome:e=>[{address:Rn(e.address),client:r(e.clientName,e.device,e.kind),families:[],key:`pending`,label:oO(e.clientName,e.device),lastActive:0,pending:!0,resources:[e.resources]}]}),...Kr(Io(t,e=>oO(e.client,e.device)),na,jo(fa),$o(On(vi(Cs,sO))),xo(e=>({address:Kr(Ra(e,t=>t.lastActive===sO(e)),ci(e=>Rn(e.address))),client:r(e[0].client,e[0].device,e[0].kind),families:xo(e,e=>e.family),key:oO(e[0].client,e[0].device),label:oO(e[0].client,e[0].device),lastActive:sO(e),pending:!1,resources:xo(e,e=>e.resources)})))]}function QO(e){let t=(0,qs.c)(26),n=Bd(ZD).value,r=Bd(HD).value,i=Bd(eO).value,a=KT(),o;t[0]===a?o=t[1]:(o=function(e){return Oo(a)(za(e))},t[0]=a,t[1]=o);let s=o,c,l,u,d;if(t[2]!==n||t[3]!==i||t[4]!==e.pending||t[5]!==a||t[6]!==s||t[7]!==r){let o;t[12]===s?o=t[13]:(o=e=>s(e.name),t[12]=s,t[13]=o);let f;t[14]!==n||t[15]!==s?(f=e=>e!==`browser`&&!Gi(n,t=>t.origin===e)&&s(e),t[14]=n,t[15]=s,t[16]=f):f=t[16];let p=[...xo(jo(n,o),ok),...Kr([...Zi(r,ak),...Ar(e.pending,{onNone:ik,onSome:rk})],ga,jo(f),$o(Di),xo(nk))],m=jo(ZO(e.pending,r,n),e=>e.pending||Gi(p,t=>HO(e,t)));c=`flex flex-1 flex-col gap-3`,l=`Apps`,t[17]===e.pending?u=t[18]:(u=Ar(e.pending,{onNone:tk,onSome:ek}),t[17]=e.pending,t[18]=u);let h;t[19]===a?h=t[20]:(h=()=>(0,Q.jsx)(Ot,{children:(0,Q.jsx)(Ke,{children:(0,Q.jsx)(dn,{children:Vi(dr(a),{onFalse:()=>`No app matches “${a}”`,onTrue:$O})})})}),t[19]=a,t[20]=h),d=ao(p,{onEmpty:h,onNonEmpty:()=>(0,Q.jsxs)(oE,{"aria-label":`Apps and the clients signed in to them`,children:[(0,Q.jsx)(sE,{children:(0,Q.jsxs)(lE,{children:[(0,Q.jsx)(uE,{children:(0,Q.jsx)(`span`,{className:`sr-only`,children:`App`})}),xo(m,e=>(0,Q.jsx)(RO,{column:e,now:i},e.key))]})}),(0,Q.jsx)(cE,{children:xo(p,e=>(0,Q.jsxs)(lE,{children:[(0,Q.jsx)(uE,{scope:`row`,children:Ar(e.open,{onNone:()=>(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Q.jsx)(jO,{origin:e.origin}),e.name]}),onSome:t=>(0,Q.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,title:`Open ${e.name}`,className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Q.jsx)(jO,{origin:e.origin}),e.name]})})}),xo(m,t=>(0,Q.jsx)(UO,{column:t,row:e},t.key))]},e.origin))})]})}),t[2]=n,t[3]=i,t[4]=e.pending,t[5]=a,t[6]=s,t[7]=r,t[8]=c,t[9]=l,t[10]=u,t[11]=d}else c=t[8],l=t[9],u=t[10],d=t[11];let f;return t[21]!==c||t[22]!==l||t[23]!==u||t[24]!==d?(f=(0,Q.jsxs)(`section`,{className:c,"aria-label":l,children:[u,d]}),t[21]=c,t[22]=l,t[23]=u,t[24]=d,t[25]=f):f=t[25],f}function $O(){return`No apps yet`}function ek(e){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(JO,{request:e}),(0,Q.jsxs)(`p`,{className:`text-muted-foreground font-mono text-xs`,children:[`open until `,$D(e.expiresAt)]})]})}function tk(){return null}function nk(e){return{name:Ir(sa(fo(new URL(e).hostname,`.`)),()=>e),open:Vr(),origin:e,web:!1}}function rk(e){return QD(e.resources)}function ik(){return[]}function ak(e){return QD(e.resources)}function ok(e){return{name:e.name,open:ir(e.open),origin:e.origin,web:Mo(`https://`)(e.open)}}export{dw as $,SO as A,LT as B,JD as C,bO as D,tO as E,XT as F,zT as G,VT as H,KT as I,nT as J,NT as K,MT as L,aE as M,nE as N,oO as O,tE as P,Ow as Q,PT as R,yO as S,qD as T,RT as U,IT as V,BT as W,Uw as X,Gw as Y,Bw as Z,EO as _,LD as a,Cb as at,VD as b,XD as c,bb as ct,vO as d,Fd as dt,fw as et,uO as f,Bd as ft,BD as g,js as gt,nO as h,rc as ht,_O as i,Eb as it,AD as j,TO as k,zD as l,Id as lt,cO as m,bd as mt,QO as n,cw as nt,gO as o,vb as ot,rO as p,Ad as pt,sT as q,DO as r,qC as rt,GD as s,yb as st,AO as t,sw as tt,xO as u,Pd as ut,mO as v,YD as w,KD as x,hO as y,FT as z};
1
+ import{n as e,t}from"./rolldown-runtime-WkwZ5CU-.js";import{a as n,i as r,n as i,o as a,s as o,t as s}from"./react-BUjtWCUj.js";import{$ as c,$n as l,$t as u,A as d,An as f,At as p,B as m,Bn as h,Bt as g,C as _,Cn as v,Ct as y,D as b,Dn as x,Dt as S,E as C,En as w,Et as T,F as E,Fn as D,Ft as O,G as k,Gn as A,Gt as j,H as M,Hn as N,Ht as ee,I as P,In as F,It as I,J as te,Jn as ne,Jt as L,K as re,Kn as ie,Kt as ae,L as oe,Ln as R,Lt as z,M as se,Mn as B,Mt as ce,N as le,Nn as ue,Nt as de,O as fe,On as pe,Ot as me,P as he,Pn as V,Pt as ge,Q as _e,Qn as ve,Qt as ye,R as be,Rn as xe,Rt as Se,S as Ce,Sn as we,St as Te,T as H,Tn as Ee,Tt as De,U,Un as Oe,Ut as ke,V as Ae,Vn as je,Vt as Me,W as Ne,Wn as Pe,Wt as Fe,X as Ie,Xn as Le,Xt as Re,Y as ze,Yn as Be,Yt as Ve,Z as He,Zn as Ue,Zt as We,_ as Ge,_n as Ke,_t as qe,a as Je,an as Ye,ar as Xe,at as Ze,b as Qe,bn as $e,bt as et,c as tt,cn as nt,ct as rt,d as it,dn as at,dt as ot,en as st,er as ct,et as lt,f as ut,fn as dt,ft,g as pt,gt as mt,h as ht,ht as gt,i as _t,in as vt,it as yt,j as bt,jn as xt,jt as St,kn as Ct,kt as wt,l as Tt,lt as Et,m as Dt,mn as Ot,mt as kt,n as W,nn as At,nr as jt,nt as Mt,o as Nt,on as Pt,ot as Ft,p as It,pn as Lt,pt as Rt,q as zt,qn as Bt,qt as G,r as Vt,rn as Ht,rr as Ut,rt as Wt,s as Gt,sn as Kt,sr as qt,st as Jt,tn as Yt,tr as Xt,tt as Zt,u as Qt,un as $t,ut as en,v as tn,vt as nn,w as rn,wn as an,wt as on,x as sn,xn as cn,xt as ln,y as un,yn as dn,yt as fn,z as pn,zn as mn,zt as hn}from"./toast-jmpTfttq.js";import{$ as gn,$a as _n,$n as vn,$r as yn,$t as bn,A as xn,Aa as Sn,Ai as Cn,An as wn,Ar as Tn,At as En,B as Dn,Ba as On,Bn as kn,Br as An,C as jn,Ca as Mn,Ci as Nn,Cn as Pn,Cr as Fn,Ct as In,D as Ln,Da as Rn,Di as zn,Dn as Bn,Dr as K,Dt as q,E as Vn,Ea as Hn,Ei as Un,En as Wn,Er as Gn,Et as J,F as Kn,Fa as qn,Fn as Jn,Fr as Yn,G as Xn,Ga as Zn,Gn as Qn,H as $n,Ha as er,Hi as tr,Hn as nr,Hr as rr,Ht as ir,I as ar,Ii as or,In as sr,Ir as cr,J as lr,Ji as ur,Jn as dr,Jr as fr,Jt as pr,K as mr,Ki as hr,Kn as gr,Kr as _r,Kt as vr,L as yr,La as br,Li as xr,Ln as Sr,Lr as Cr,Lt as wr,M as Tr,Mi as Er,Mn as Dr,Mr as Or,N as kr,Na as Ar,Ni as jr,Nn as Mr,Nr,Nt as Pr,O as Fr,Oa as Ir,Oi as Lr,On as Rr,Or as zr,P as Br,Pa as Vr,Pi as Hr,Pn as Ur,Pr as Y,Pt as Wr,Q as Gr,Qa as Kr,Qi as qr,Qn as Jr,Qr as Yr,Qt as Xr,Ra as Zr,Ri as Qr,Rn as $r,Rr as ei,Rt as ti,S as ni,Sa as ri,Si as ii,Sn as ai,Sr as oi,St as si,T as ci,Ta as li,Ti as ui,Tn as di,Tr as fi,Tt as pi,U as mi,Ua as hi,Ui as gi,Un as X,Ur as _i,V as vi,Va as yi,Vi as bi,Vn as xi,Vr as Si,Vt as Ci,W as wi,Wa as Ti,Wi as Ei,Wn as Di,Wr as Oi,Wt as ki,X as Ai,Xi as ji,Xn as Mi,Xr as Ni,Xt as Pi,Y as Fi,Yi as Ii,Yn as Li,Yr as Ri,Yt as zi,Z as Bi,Zi as Vi,Zn as Hi,Zr as Ui,Zt as Wi,_a as Gi,_i as Ki,_n as qi,_r as Ji,_t as Yi,a as Xi,aa as Zi,ai as Qi,an as $i,ar as ea,b as ta,ba as na,bi as ra,bn as ia,br as aa,bt as oa,ca as sa,cn as ca,cr as la,ct as ua,d as da,da as fa,dn as pa,dr as ma,dt as ha,ea as ga,ei as _a,en as va,eo as ya,er as ba,et as xa,f as Sa,fa as Ca,fn as wa,fr as Ta,ft as Ea,ga as Da,gi as Oa,gn as ka,gr as Aa,gt as ja,h as Ma,ha as Na,hi as Pa,hn as Fa,hr as Ia,ht as La,i as Ra,ia as za,ii as Ba,in as Va,ir as Ha,j as Ua,ja as Wa,ji as Ga,jn as Ka,jr as qa,jt as Ja,k as Ya,ka as Xa,ki as Za,kn as Qa,kr as $a,kt as eo,l as to,la as no,ln as ro,lr as io,lt as ao,ma as oo,mi as so,mn as co,mr as lo,n as uo,na as fo,ni as po,nn as mo,nr as ho,nt as go,oa as _o,oi as vo,on as yo,or as bo,ot as xo,pa as So,pn as Co,pr as wo,pt as To,q as Eo,qi as Do,qn as Oo,qr as ko,qt as Ao,r as jo,ra as Mo,ri as No,rn as Po,rr as Fo,rt as Io,sa as Lo,si as Ro,sn as zo,sr as Bo,st as Vo,t as Ho,ta as Uo,ti as Wo,tn as Go,tr as Ko,tt as qo,u as Jo,ua as Yo,un as Xo,ur as Zo,ut as Qo,v as $o,va as es,vi as ts,vn as ns,vr as rs,vt as is,w as as,wa as os,wi as ss,wn as cs,wr as ls,wt as us,x as ds,xa as fs,xi as ps,xn as ms,xr as hs,xt as gs,y as _s,ya as vs,yi as ys,yn as bs,yr as xs,yt as Ss,z as Cs,zi as ws,zn as Ts,zr as Es,zt as Ds}from"./effect--GriK3-G.js";var Os={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`}]]};Os.node;var ks=Xe(Os),As={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};As.node;var js=Xe(As),Ms={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};Ms.node;var Ns=Xe(Ms),Ps={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Ps.node;var Fs=Xe(Ps),Is={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`}]]};Is.node;var Ls=Xe(Is),Rs={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`}]]};Rs.node;var zs=Xe(Rs),Bs={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Bs.node;var Vs=Xe(Bs),Hs={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`}]]};Hs.node;var Us=Xe(Hs),Z=e(o(),1),Q=a(),Ws=qt(),Gs=e(n(),1),Ks=e(r(),1),qs=i(),Js=`data-open`,Ys=`data-closed`,Xs=`data-anchor-hidden`,Zs={[z]:``},Qs={[z]:``,[Se]:``},$s={[Js]:``},ec={[Ys]:``},tc={[Xs]:``},nc={open(e){return e?Zs:null}},rc={open(e){return e?Qs:null}},ic={open(e){return e?$s:ec},anchorHidden(e){return e?tc:null}},ac={...ic,...hn};function oc(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...oc(e,t.id,n)])}function sc(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 cc(e,t=!1){let{overflowY:n}=R(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}function lc(e){let t=F(uc,e).current;return t.next=e,V(t.effect),t}function uc(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var dc=0;function fc(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(dc);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),w;let o=requestAnimationFrame(a);return dc=o,()=>{dc===o&&(cancelAnimationFrame(o),dc=0)}}var pc=`data-base-ui-inert`,mc=new WeakMap,hc=new WeakSet,gc=new WeakMap,_c=0;function vc(e){return e?Ue(e)?e.host:vc(e.parentNode):null}var yc=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=vc(t);return e.contains(n)?n:null}).filter(e=>e!=null),bc=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},xc=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{je(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function Sc(e,t,n,{mark:r=!0}){let i=yc(t,e),a=r?xc(t,bc(i),new Set(i)):[],o=[],s=[];if(n){let e=yc(t,Array.from(t.querySelectorAll(`[aria-live]`))),n=i.concat(e);xc(t,bc(n),new Set(n)).forEach(e=>{let t=e.getAttribute(`aria-hidden`),n=t!==null&&t!==`false`,r=(mc.get(e)||0)+1;mc.set(e,r),o.push(e),r===1&&n&&hc.add(e),n||e.setAttribute(`aria-hidden`,`true`)})}return r&&a.forEach(e=>{let t=(gc.get(e)||0)+1;gc.set(e,t),s.push(e),t===1&&e.setAttribute(pc,``)}),_c+=1,()=>{o.forEach(e=>{let t=(mc.get(e)||0)-1;mc.set(e,t),t||(hc.has(e)||e.removeAttribute(`aria-hidden`),hc.delete(e))}),r&&s.forEach(e=>{let t=(gc.get(e)||0)-1;gc.set(e,t),t||e.removeAttribute(pc)}),--_c,_c||(mc=new WeakMap,hc=new WeakSet,gc=new WeakMap)}}function Cc(e,t={}){let{ariaHidden:n=!1,mark:r=!0}=t,i=f(e[0]).body;return Sc(e,i,n,{mark:r})}function wc(){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 Tc=class{nodesRef={current:[]};events=wc();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)}},Ec=Z.createContext(null),Dc=Z.createContext(null),Oc=()=>Z.useContext(Ec)?.id||null,kc=e=>{let t=Z.useContext(Dc);return e??t};function Ac(e){let t=b(),n=kc(e),r=Oc();return V(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function jc(e){let{children:t,id:n}=e,r=Oc();return(0,Q.jsx)(Ec.Provider,{value:Z.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Mc(e){let{children:t,externalTree:n}=e,r=F(()=>n??new Tc).current;return(0,Q.jsx)(Dc.Provider,{value:r,children:t})}function Nc(e,t){let n=A(L(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||(T(e)?`keyboard`:t||`mouse`):`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var Pc=20,Fc=[];function Ic(){Fc=Fc.filter(e=>e.deref()?.isConnected)}function Lc(e){Ic(),e&&je(e)!==`body`&&(Fc.push(new WeakRef(e)),Fc.length>Pc&&(Fc=Fc.slice(-20)))}function Rc(){return Ic(),Fc[Fc.length-1]?.deref()}function zc(e){return e?ze(e)?e:Ie(e)[0]||e:null}function Bc(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=Ne(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return ze(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 Vc(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:p,beforeContentFocusGuardRef:m,externalTree:h,getInsideElements:g}=e,_=t.useState(`open`),v=t.useState(`domReferenceElement`),y=t.useState(`floatingElement`),{events:b,dataRef:C}=t.context,w=D(()=>C.current.floatingContext?.nodeId),A=i===!1,N=ge(v)&&A,ee=lc(i),P=lc(a),F=lc(o),I=lc(u),ie=lc(_),R=kc(h),z=_t(),se=Z.useRef(!1),B=Z.useRef(!1),ce=Z.useRef(!1),le=Z.useRef(null),ue=Z.useRef(``),de=Z.useRef(``),fe=Z.useRef(null),pe=Z.useRef(null),he=x(fe,m,z?.beforeInsideRef),_e=x(pe,z?.afterInsideRef),ve=Ht(),be=Ht(),xe=oe(),Se=z!=null,Ce=wt(y),we=D((e=Ce)=>e?Ie(e):[]),Te=D(()=>g?.().filter(e=>e!=null)??[]);Z.useEffect(()=>{if(r||!c)return;function e(e){e.key===`Tab`&&G(Ce,j(f(Ce)))&&we().length===0&&!N&&me(e)}let t=f(Ce);return U(t,`keydown`,e)},[r,Ce,c,N,we]),Z.useEffect(()=>{if(r||!_)return;let e=f(Ce);function t(){ce.current=!1}function n(e){let t=L(e),n=Te(),r=G(y,t)||G(v,t)||G(z?.portalNode,t)||n.some(e=>e===t||G(e,t));ce.current=!r,de.current=e.pointerType||`keyboard`,ae(t,`[data-base-ui-click-trigger]`)&&(B.current=!0,be.start(0,()=>{B.current=!1}))}function i(){de.current=`keyboard`}return M(U(e,`pointerdown`,n,!0),U(e,`pointerup`,t,!0),U(e,`pointercancel`,t,!0),U(e,`keydown`,i,!0),t)},[r,y,v,Ce,_,z,be,Te]),Z.useEffect(()=>{if(r||!l)return;let e=f(Ce);function n(){B.current=!0,be.start(0,()=>{B.current=!1})}function i(e){let t=L(e);ze(t)&&(le.current=t)}function a(n){let r=n.relatedTarget,i=n.currentTarget,a=L(n);c&&r==null&&a!=null&&G(y,a)&&Lc(a),queueMicrotask(()=>{let o=w(),l=t.context.triggerElements,u=Te(),f=r?.hasAttribute(Je(`focus-guard`))&&[fe.current,pe.current,z?.beforeInsideRef.current,z?.afterInsideRef.current,z?.beforeOutsideRef.current,z?.afterOutsideRef.current,E(p),E(d)].includes(r),m=!(G(v,r)||G(y,r)||G(r,y)||G(z?.portalNode,r)||u.some(e=>e===r||G(e,r))||l.hasMatchingElement(e=>G(e,r))||f||R&&(oc(R.nodesRef.current,o).find(e=>G(e.context?.elements.floating,r)||G(e.context?.elements.domReference,r))||sc(R.nodesRef.current,o).find(e=>[e.context?.elements.floating,wt(e.context?.elements.floating)].includes(r)||e.context?.elements.domReference===r)));if(i===v&&Ce&&Bc(Ce),s&&i!==v&&!Zt(a)&&j(e)===e.body){if(ne(Ce)&&(Ce.focus(),s===`popup`)){xe.request(()=>{Ce.focus()});return}let e=we(),t=le.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||Ce;ne(n)&&n.focus()}C.current.insideReactTree?C.current.insideReactTree=!1:(N||!c)&&r&&m&&!B.current&&(N||r!==Rc())&&(se.current=!0,t.setOpen(!1,H(Qt,n)))})}function o(){ce.current||(C.current.insideReactTree=!0,ve.start(0,()=>{C.current.insideReactTree=!1}))}let u=ne(v)?v:null;if(y||u)return M(u&&U(u,`focusout`,a),u&&U(u,`pointerdown`,n),y&&U(y,`focusin`,i),y&&U(y,`focusout`,a),y&&z&&U(y,`focusout`,o,!0))},[r,v,y,Ce,c,R,z,t,l,s,we,N,w,C,ve,be,xe,d,p,Te]),Z.useEffect(()=>{if(r||!y||!_)return;let e=Array.from(z?.portalNode?.querySelectorAll(`[${Je(`portal`)}]`)||[]),t=(R?sc(R.nodesRef.current,w()):[]).find(e=>ge(e.context?.elements.domReference||null))?.context?.elements.domReference,n=Cc([y,...e,fe.current,pe.current,z?.beforeOutsideRef.current,z?.afterOutsideRef.current,...Te(),t,E(p),E(d),N?v:null].filter(e=>e!=null),{ariaHidden:c||N,mark:!1}),i=Cc([y,...e].filter(e=>e!=null));return()=>{i(),n()}},[_,r,v,y,c,z,N,R,w,d,p,Te]),V(()=>{if(!_||r||!ne(Ce))return;ue.current=``,de.current=``;let e=f(Ce),t=j(e);queueMicrotask(()=>{let n=ee.current,r=typeof n==`function`?n(I.current||``):n;if(r===void 0||r===!1||G(Ce,t))return;let i=null,a=()=>(i??=we(Ce),i[0]||Ce),o;o=r===!0||r===null?a():E(r),o||=a();let s=G(Ce,j(e)),c=C.current.openEvent,l=c?.type===`mousedown`&&T(c);fc(o,{sync:l,preventScroll:o===Ce,shouldFocus(){if(!ie.current)return!1;if(s)return!0;let t=j(e);return!(t!==o&&G(Ce,t))}})})},[r,_,Ce,we,ee,I,ie,C]);let Ee=Z.useRef(null);V(()=>{if(r||!Ce){Ee.current=null;return}Ee.current&&=(Ee.current.cancelled=!0,null);let e=f(Ce),t=j(e),n=I.current==null;Lc(t);function i(e){if(e.open||(ue.current=Nc(e.nativeEvent,de.current)),(e.reason===`focus-out`&&e.triggerElement?.hasAttribute(Je(`focus-guard`))||e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`)&&(se.current=!0),e.reason===`outside-press`){if(e.nested)se.current=!1;else if(T(e.nativeEvent)||S(e.nativeEvent))se.current=!1;else{let e=!1;f(Ce).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?se.current=!1:se.current=!0}}}b.on(`openchange`,i);function a(e){let r=P.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=v?.isConnected?v:null,o=t?.isConnected&&je(t)!==`body`?t:null,s=n?o||a:a||o;return s||=Rc()||null,typeof i==`boolean`?s:E(i)||s||null}return()=>{b.off(`openchange`,i);let t=j(e),n=Te(),r=G(y,t)||n.some(e=>e===t||G(e,t))||R&&oc(R.nodesRef.current,w(),!1).some(e=>G(e.context?.elements.floating,t)),o=P.current,s=ue.current,c=a(s),l={cancelled:!1};Ee.current=l,queueMicrotask(()=>{Ee.current===l&&(Ee.current=null);let n=zc(c),i=F.current??typeof o!=`boolean`;if(!l.cancelled&&o&&!se.current&&ne(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}se.current=!1})}},[r,y,Ce,P,F,I,b,R,v,w,Te]),V(()=>{if(!ye||_||!y)return;let e=j(f(y));ne(e)&&O(e)&&G(y,e)&&e.blur()},[_,y]),V(()=>{if(!r&&z)return z.setFocusManagerState({modal:c,closeOnFocusOut:l,open:_,onOpenChange:t.setOpen,domReference:v}),()=>{z.setFocusManagerState(null)}},[r,z,c,_,t,l,v]),V(()=>{if(!r&&Ce)return Bc(Ce),()=>{queueMicrotask(Ic)}},[r,Ce]);let De=!r&&(!c||!N)&&(Se||c);return(0,Q.jsxs)(Z.Fragment,{children:[De&&(0,Q.jsx)(pn,{"data-type":`inside`,ref:he,onFocus:e=>{if(c){let e=we();fc(e[e.length-1])}else z?.portalNode&&(se.current=!1,te(e,z.portalNode)?k(v)?.focus():E(p??z.beforeOutsideRef)?.focus())}}),n,De&&(0,Q.jsx)(pn,{"data-type":`inside`,ref:_e,onFocus:e=>{c?fc(we()[0]):z?.portalNode&&(l&&(se.current=!0),te(e,z.portalNode)?re(v)?.focus():E(d??z.afterOutsideRef)?.focus())}})]})}function Hc(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=rn}=t,l=e.context.dataRef,u=Z.useRef(void 0),d=oe(),f=Ht(),p=Z.useMemo(()=>{function t(t,n,r,i){let a=H(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=on(e.pointerType,!0)&&S(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(i){let o=u.current,s=i.nativeEvent,c=e.select(`open`);if(i.button!==0||r===`click`||on(o,!0)&&a)return;let l=n(c,i.currentTarget,e=>e===`click`||e===`mousedown`),f=L(s),p=O(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:on(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}:Ee,[n,p])}function Uc(){return!1}function Wc(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function Gc(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=Uc,bubbles:s,externalTree:c}=t,l=e.useState(`open`),u=e.useState(`floatingElement`),{dataRef:d,events:m}=e.context,h=kc(c),g=D(typeof i==`function`?i:()=>!1),_=typeof i==`function`?g:i,v=_!==!1,y=D(()=>a),{escapeKey:b,outsidePress:x}=Wc(s),S=Z.useRef(!1),C=Z.useRef(!1),w=Z.useRef(!1),E=Z.useRef(!1),O=Z.useRef(!1),k=Z.useRef(``),A=Z.useRef(null),j=Ht(),N=Ht(),ee=Ht(),P=D(()=>{N.clear(),d.current.insideReactTree=!1}),F=D(e=>{let t=d.current.floatingContext?.nodeId;return(h?oc(h.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),I=D(t=>p(t,e.select(`floatingElement`))||p(t,e.select(`domReferenceElement`))),te=D(t=>{o()&&e.setOpen(!1,H(rn,t.nativeEvent))}),re=D(t=>{if(!l||!n||!r||t.key!==`Escape`)return;let i=De(t)?t.nativeEvent:t;if(O.current||i.isComposing||!b&&F(`__escapeKeyBubbles`))return;let a=H(Tt,i);e.setOpen(!1,a),a.isCanceled||t.preventDefault(),!b&&!a.isPropagationAllowed&&t.stopPropagation()}),ie=D(()=>{d.current.insideReactTree=!0,N.start(0,P)}),ae=D(t=>{if(!l||!n||t.button!==0)return;let r=L(t.nativeEvent);G(e.select(`floatingElement`),r)&&(S.current||(S.current=!0,C.current=!1))}),oe=D(e=>{l&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&S.current&&(C.current=!0)});Z.useEffect(()=>{function e(e){e.open||(E.current=!1)}return m.on(`openchange`,e),()=>{m.off(`openchange`,e)}},[m]),Z.useEffect(()=>P,[P]),Z.useEffect(()=>{if(!l||!n)return l||(E.current=!1,O.current=!1,k.current=``,A.current=null),P;d.current.__escapeKeyBubbles=b,d.current.__outsidePressBubbles=x;let t=new At,i=f(u);function a(){ee.clear(),O.current=!0}function o(){O.current=!0,ee.start(ye?5:0,()=>{O.current=!1})}function s(){w.current=!0,t.start(0,()=>{w.current=!1})}function c(){S.current=!1,C.current=!1}function m(){let e=k.current,t=e===`pen`||!e?`mouse`:e,n=y(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function g(e){let t=m();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function D(e){let t=d.current.floatingContext?.nodeId,n=h&&oc(h.nodesRef.current,t).some(t=>p(e,t.context?.elements.floating));return I(e)||n}function N(n){if(g(n)){n.type!==`click`&&!I(n)&&(t.clear(),w.current=!1),P();return}if(d.current.insideReactTree){P();return}let r=L(n),i=`[${Je(`inert`)}]`,a=Bt(r)?r.getRootNode():null,o=Array.from((Ue(a)?a:f(e.select(`floatingElement`))).querySelectorAll(i)),s=e.context.triggerElements;if(r&&(s.hasElement(r)||s.hasMatchingElement(e=>G(e,r))))return;let c=Bt(r)?r:null;for(;c&&!Be(c);){let e=Pe(c);if(Be(e)||!Bt(e))break;c=e}if(!(o.length&&Bt(r)&&!ce(r)&&!G(r,e.select(`floatingElement`))&&o.every(e=>!G(c,e)))){if(ne(r)&&!(`touches`in n)){let e=Be(r),t=R(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(!D(n)){if(m()===`intentional`){if(n.detail!==0&&!T(n)&&!E.current)return;if(w.current){t.clear(),w.current=!1;return}}typeof _==`function`&&!_(n)||F(`__outsidePressBubbles`)||(e.setOpen(!1,H(un,n)),P())}}}function te(t){m()===`sloppy`&&t.pointerType!==`touch`&&e.select(`open`)&&n&&!I(t)&&N(t)}function ie(t){if(m()!==`sloppy`||!e.select(`open`)||!n||I(t))return;let r=t.touches[0];r&&(A.current={startTime:Date.now(),startX:r.clientX,startY:r.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},j.start(1e3,()=>{A.current&&(A.current.dismissOnTouchEnd=!1,A.current.dismissOnMouseDown=!1)}))}function ae(e,t){let n=L(e);if(!n)return;let r=U(n,e.type,()=>{t(e),r()})}function oe(e){k.current=`touch`,ae(e,ie)}function z(e){j.clear(),e.type===`pointerdown`&&(e.button===0&&(E.current=!0),k.current=e.pointerType),(e.type!==`mousedown`||!A.current||A.current.dismissOnMouseDown)&&ae(e,e=>{e.type===`pointerdown`?te(e):N(e)})}function se(e){if(e.type===`pointercancel`&&(E.current=!1),!S.current)return;let n=C.current;c(),m()===`intentional`&&(e.type===`pointercancel`?n&&s():D(e)||(n?s():(typeof _!=`function`||_(e))&&(t.clear(),w.current=!0,P())))}function B(e){if(m()!==`sloppy`||!A.current||I(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-A.current.startX),r=Math.abs(t.clientY-A.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(A.current.dismissOnTouchEnd=!0),i>10&&(N(e),j.clear(),A.current=null)}function le(e){ae(e,B)}function ue(e){m()===`sloppy`&&A.current&&!I(e)&&(A.current.dismissOnTouchEnd&&N(e),j.clear(),A.current=null)}function de(e){ae(e,ue)}let fe=M(r&&M(U(i,`keydown`,re),U(i,`compositionstart`,a),U(i,`compositionend`,o)),v&&M(U(i,`click`,z,!0),U(i,`pointerdown`,z,!0),U(i,`pointerup`,se,!0),U(i,`pointercancel`,se,!0),U(i,`mousedown`,z,!0),U(i,`mouseup`,se,!0),U(i,`touchstart`,oe,{capture:!0,passive:!0}),U(i,`touchmove`,le,{capture:!0,passive:!0}),U(i,`touchend`,de,{capture:!0,passive:!0})));return()=>{fe(),t.clear(),c(),w.current=!1}},[d,u,r,v,_,l,n,b,x,re,P,y,F,I,h,e,j,ee]);let z=Z.useMemo(()=>({onKeyDown:re,onPointerDown:te,onClick:te}),[re,te]),se=Z.useMemo(()=>({onKeyDown:re,onPointerDown:oe,onMouseDown:oe,onClickCapture:ie,onMouseDownCapture(e){ie(),ae(e)},onPointerDownCapture(e){ie(),ae(e)},onMouseUpCapture:ie,onTouchEndCapture:ie,onTouchMoveCapture:ie}),[re,ie,ae,oe]);return Z.useMemo(()=>n?{reference:z,floating:se,trigger:z}:{},[n,z,se])}function Kc(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),V(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};Bt(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 qc(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),V(()=>{if(!e&&o&&i!==`ending`&&n){let e=P.request(()=>{a(`ending`)});return()=>{P.cancel(e)}}},[e,o,i,n]),V(()=>{if(!e||t||i===void 0)return;let n=P.request(()=>{a(void 0)});return()=>{P.cancel(n)}},[t,e,i]),V(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=P.request(()=>{a(`idle`)});return()=>{P.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}function Jc(e){let{open:t,ref:n,preventUnmountOnClose:r,setPreventUnmountOnClose:i,onUnmount:a,animateInitialOpen:o}=e,s=D(i),{mounted:c,setMounted:l,transitionStatus:u}=qc(t,!1,!1,o),d=!t&&r;V(()=>{t&&s(!1)},[t,s]);let f=Z.useRef(c),p=Z.useRef(!1),m=fe(),h=()=>{f.current=!1,l(!1),a()};V(()=>{f.current=c,p.current&&(p.current=!1,!t&&c&&h())});let g=D(()=>{f.current&&(t?(p.current=!0,m()):h())});return le({enabled:c&&!t&&!d,open:t,ref:n,onComplete(){t||g()}}),{mounted:c,transitionStatus:u,preventUnmountingOnClose:d,forceUnmount:g}}var Yc={tabIndex:-1,[Fe]:``};function Xc({handle:e,store:t}){return V(()=>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 Qc(e,t){let n=Z.useRef(null);return D(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 $c(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 el(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function tl(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=Qc(e,n),o=D(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=D(e=>{a(e),e&&o(e)});return V(()=>(s(t.current),()=>s(null)),[s,t,n,e]),V(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function nl(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`);V(()=>{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=H(tn);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,a,o,s,n])}function rl(e,t,n,r){let{mounted:i,transitionStatus:a,forceUnmount:o}=Jc({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 F(()=>(t.set(`mounted`,i),null)),t.useSyncedValues({mounted:i,transitionStatus:a}),{forceUnmount:o,transitionStatus:a}}function il(e,t){e.useSyncedValues(t),V(()=>()=>{e.update({activeTriggerProps:Ee,inactiveTriggerProps:Ee,popupProps:Ee})},[e])}var al=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}},ol={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},sl=class extends vt{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:wc(),nested:n,triggerElements:i},ol),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&y(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 cl(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new sl({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:Ee,inactiveTriggerProps:Ee,popupProps:Ee}}var ll=e=>e.triggerIdProp??e.activeTriggerId,ul=e=>e.openProp??e.open,dl=e=>(e.popupElement?.id??e.floatingId)||void 0;function fl(e,t){return t!==void 0&&ul(e)&&ll(e)===t}function pl(e,t){return fl(e,t)?!0:t!==void 0&&ul(e)&&ll(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}var ml={open:ul,mounted:e=>e.mounted,transitionStatus:e=>ul(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:ll,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:dl,isTriggerActive:(e,t)=>t!==void 0&&ll(e)===t,isOpenedByTrigger:(e,t)=>fl(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&ll(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>pl(e,t)?dl(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function hl(e){let t=Z.useCallback(t=>e===void 0?w:e.subscribeStore(t),[e]),n=Z.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,Ws.useSyncExternalStore)(t,n,()=>e?.serverStore)}function gl(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=b(),a=Oc()!=null,o=F(()=>new sl({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new al,floatingId:i,syncOnly:!1,nested:a})).current;return V(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=Bt(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}var _l=Yt&&ye;function vl(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=Ht();Z.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=A(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&ne(t)&&t===j(f(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return M(U(r,`blur`,i),_l&&U(r,`keydown`,a,!0),_l&&U(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`);Bt(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=L(n.nativeEvent);if(Bt(a)){if(_l&&!n.relatedTarget){if(!c.current&&!O(a))return}else if(!I(a))return}let u=de(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;e.select(`open`)&&u||!r?e.setOpen(!0,H(Ce,d,f)):l.start(r,()=>{o.current||e.setOpen(!0,H(Ce,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=Bt(r)&&r.hasAttribute(Je(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=j(f(t));!r&&n===t||G(a.current.floatingContext?.refs.floating.current,n)||G(t,n)||o||de(r??n,e.context.triggerElements)||e.setOpen(!1,H(Ce,i))})}}},[a,r,e,l]);return Z.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}var yl=class e{pointerType=void 0;interactedInside=!1;handler=void 0;blockMouseMove=!0;performedPointerEventsMutation=!1;pointerEventsScopeElement=null;pointerEventsReferenceElement=null;pointerEventsFloatingElement=null;restTimeoutPending=!1;openChangeTimeout=new At;restTimeout=new At;handleCloseOptions=void 0;static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},bl=new WeakMap;function xl(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&bl.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),bl.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function Sl(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=bl.get(n);a&&a!==e&&xl(a),xl(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,bl.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function Cl(e){let t=e.context.dataRef.current,n=F(()=>t.hoverInteractionState??yl.create()).current;return t.hoverInteractionState||=n,Kt(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function wl(e,t){return t!=null&&!on(t)?0:typeof e==`function`?e():e}function Tl(e,t,n){let r=wl(e,n);return typeof r==`number`?r:r?.[t]}function El(e){return typeof e==`function`?e():e}function Dl(e,t){return t||e===`click`||e===`mousedown`}function Ol(e){return e?.includes(`mouse`)&&e!==`mousedown`}function kl(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=kc(),u=Oc(),d=Cl(e),p=Ht(),m=D(()=>Dl(c.current.openEvent?.type,d.interactedInside)),h=D(()=>Ol(c.current.openEvent?.type)),g=D(()=>{xl(d)});V(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,g())},[a,d,g]),Z.useEffect(()=>g,[g]),V(()=>{if(n&&a&&d.handleCloseOptions?.blockPointerEvents&&h()&&Bt(s)&&o){let e=s,t=o,n=f(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??ae(e,`[data-rootownerid]`)??n.body;return Sl(d,{scopeElement:c,referenceElement:e,floatingElement:t}),()=>{g()}}},[n,a,s,o,d,h,l,u,g]),Z.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&oc(l.nodesRef.current,u).length>0)}function a(t){let n=Tl(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,H(_,t)),l?.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=L(e);St(t)?d.interactedInside=ae(t,`[aria-haspopup]`)!=null:d.interactedInside=!1}function f(){d.openChangeTimeout.clear(),p.clear(),l?.events.off(`floating.closed`,y),g()}function v(n){if(t()&&l){l.events.on(`floating.closed`,y);return}if(de(n.relatedTarget,e.context.triggerElements))return;let r=c.current.floatingContext?.nodeId??i,o=n.relatedTarget;l&&r&&Bt(o)&&oc(l.nodesRef.current,r,!1).some(e=>G(e.context?.elements.floating,o))||(d.handler?d.handler(n):(g(),h()&&!m()&&a(n)))}function y(n){l&&u&&!t()&&p.start(0,()=>{l.events.off(`floating.closed`,y),e.setOpen(!1,H(_,n)),l.events.emit(`floating.closed`,n)})}let b=o;return M(b&&U(b,`mouseenter`,f),b&&U(b,`mouseleave`,v),b&&U(b,`pointerdown`,s,!0),()=>{l?.events.off(`floating.closed`,y)})},[n,o,e,c,r,i,h,m,g,d,l,u,p])}var Al={current:null};function jl(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=Al,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:p,shouldOpen:m,guardStaleOpen:h=!1}=t,{dataRef:g,events:v}=e.context,y=kc(l),b=Cl(e),x=Z.useRef(!1),S=lc(i),C=lc(r),w=lc(o),T=lc(n),E=lc(m),O=lc(p),k=D(()=>Dl(g.current.openEvent?.type,b.interactedInside)),A=D(()=>E.current?.()!==!1),j=D((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!G(t,n);if(!Bt(r))return!1;let a=r;return i.hasMatchingElement(e=>G(e,a))&&(!t||!G(t,a))}),N=D(()=>{b.handler&&=(f(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,b.handler),void 0)}),ee=D(()=>{xl(b)});return u&&(b.handleCloseOptions=i?.__options),Z.useEffect(()=>N,[N]),Z.useEffect(()=>{if(!n)return;function e(e){e.open?x.current=!1:(x.current=e.reason===_,N(),b.openChangeTimeout.clear(),b.restTimeout.clear(),b.blockMouseMove=!0,b.restTimeoutPending=!1)}return v.on(`openchange`,e),()=>{v.off(`openchange`,e)}},[n,v,b,N]),Z.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=Tl(C.current,`close`,b.pointerType);r?b.openChangeTimeout.start(r,()=>{e.setOpen(!1,H(_,t)),y?.events.emit(`floating.closed`,t)}):n&&(b.openChangeTimeout.clear(),e.setOpen(!1,H(_,t)),y?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!Bt(r))return;function i(t){if(b.openChangeTimeout.clear(),b.blockMouseMove=!1,a&&!on(b.pointerType))return;let n=El(w.current),r=Tl(C.current,`open`,b.pointerType),i=L(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(Bt(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(G(t,i)){c=t;break}}Bt(o)&&Bt(s)&&!e.context.triggerElements.hasElement(o)&&G(o,s)&&(c=s);let l=c!=null&&j(s,c,i),u=e.select(`open`),d=O.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&x.current,p=!l&&Bt(c)&&Bt(s)&&G(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;h?A()&&e.setOpen(!0,H(_,t,c)):m||(r?b.openChangeTimeout.start(r,()=>{g&&A()&&e.setOpen(!0,H(_,t,c))}):g&&A()&&e.setOpen(!0,H(_,t,c)))}function o(n){if(k()){ee();return}N();let r=e.select(`domReferenceElement`),i=f(r);b.restTimeout.clear(),b.restTimeoutPending=!1;let a=g.current.floatingContext??d?.();if(!de(n.relatedTarget,e.context.triggerElements)){if(S.current&&a){e.select(`open`)||b.openChangeTimeout.clear();let r=c.current;b.handler=S.current({...a,tree:y,x:n.clientX,y:n.clientY,onClose(){ee(),N(),T.current&&!k()&&r===e.select(`domReferenceElement`)&&t(n,!0)}}),i.addEventListener(`mousemove`,b.handler),b.handler(n)}else b.pointerType===`touch`&&G(e.select(`floatingElement`),n.relatedTarget)||t(n)}}function l(e){G(r,e.relatedTarget)||(b.openChangeTimeout.clear(),b.restTimeout.clear(),b.restTimeoutPending=!1)}let p=h?U(r,`mouseout`,l):void 0;return s?M(U(r,`mousemove`,i,{once:!0}),U(r,`mouseenter`,i),U(r,`mouseleave`,o),p):M(U(r,`mouseenter`,i),U(r,`mouseleave`,o),p)},[N,ee,g,C,e,n,S,b,u,j,k,a,s,w,c,y,T,d,O,A,h]),Z.useMemo(()=>{if(!n)return;function t(e){b.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=j(i,r,t.target);if(a&&!on(b.pointerType))return;if(o&&s&&b.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=b.handleCloseOptions?.getScope?.()??r.ownerDocument.body;Sl(b,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=El(w.current);if(o&&!s||c===0||!s&&b.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;b.restTimeout.clear();function l(){if(b.restTimeoutPending=!1,k())return;let t=e.select(`open`);!b.blockMouseMove&&(!t||s)&&A()&&e.setOpen(!0,H(_,n,r))}b.pointerType===`touch`?Ks.flushSync(()=>{l()}):s&&o?l():(b.restTimeoutPending=!0,b.restTimeout.start(c,l))}}},[n,b,k,j,a,e,w,A])}function Ml(e){return ye&&e.movementX===0&&e.movementY===0}function Nl(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function Pl(e,t){return Nl(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Fl(e,t,n){return Nl(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Il(e,t,n){return Nl(t,n?e===Me:e===ee,e===g)}function Ll(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:Nl(t,n?e===ee:e===Me,e===ke)}function Rl(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:l=!1,nested:u=!1,rtl:d=!1,virtual:p=!1,focusItemOnOpen:m=`auto`,focusItemOnHover:h=!0,openOnArrowKeyDown:g=!0,disabledIndices:_=void 0,orientation:v=`vertical`,triggerOrientation:y=v,parentOrientation:b,id:x,resetOnPointerLeave:C=!0,externalTree:w,nestedReturnFocusRef:E,grid:k}=t,A=k!=null,M=e.useState(`open`),N=e.useState(`floatingElement`),ee=e.useState(`domReferenceElement`),P=e.context.dataRef,F=wt(N),I=ge(ee),te=lc(F),re=Oc(),ie=kc(w),ae=Z.useRef(m),R=Z.useRef(o??-1),z=Z.useRef(null),se=Z.useRef(!0),B=D(e=>{i(R.current===-1?null:R.current,e)}),ce=Z.useRef(!!N),le=Z.useRef(M),ue=Z.useRef(!1),de=Z.useRef(!1),fe=Z.useRef(null),pe=lc(_),he=lc(M),ve=lc(o),ye=lc(C),be=oe(),xe=oe(),Se=D(()=>{be.cancel();function e(e){p||(fe.current=fc(e,{sync:ue.current,preventScroll:!0}))}let t=n.current[R.current],r=de.current;t&&e(t),(ue.current?e=>e():e=>be.request(e))(()=>{let i=n.current[R.current]||t;i&&(t||e(i),U&&(r||!se.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});V(()=>{P.current.orientation=v},[P,v]),V(()=>{M||(z.current=null),M&&m===`auto`||(ae.current=m)},[M,m]),V(()=>{a&&(M&&N?(R.current=o??-1,ae.current&&o!=null&&(de.current=!0,B())):ce.current&&(R.current=-1,B()))},[a,M,N,o,B]),V(()=>{if(a){if(!M)ue.current=!1;else if(N){if(r==null){if(ue.current=!1,ve.current!=null)return;if(ce.current&&(R.current=-1,Se()),(!le.current||!ce.current)&&ae.current&&(z.current!=null||ae.current===!0&&z.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>xe.request(e):queueMicrotask)(t),e+=1):(R.current=z.current==null||Fl(z.current,y,d)||u?c(n):_e(n),z.current=null,B())};t()}}else Mt(n.current,r)||(R.current=r,Se(),de.current=!1)}}},[a,M,N,r,ve,u,n,y,d,B,Se,xe]),V(()=>{if(!a||N||!ie||p||!ce.current)return;let e=ie.nodesRef.current,t=e.find(e=>e.id===re)?.context?.elements.floating,n=j(f(ee??t??null)),r=e.some(e=>e.context&&G(e.context.elements.floating,n));t&&!r&&se.current&&t.focus({preventScroll:!0})},[a,N,ee,ie,re,p]),V(()=>{le.current=M,ce.current=!!N});let Ce=r!=null,we=D(e=>{if(!he.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(R.current!==t||r!==t)&&(R.current=t,B(e))}),Te=D(()=>b??ie?.nodesRef.current.find(e=>e.id===re)?.context?.dataRef?.current.orientation),Ee=D(()=>c(n,pe.current)),De=D(t=>{if(se.current=!1,ue.current=!0,t.which===229||!he.current&&t.currentTarget===te.current)return;if(u&&Ll(t.key,v,d,A)){Pl(t.key,Te())||me(t),e.setOpen(!1,H(Ge,t.nativeEvent));let n=E?.current??ee;ne(n)&&n.focus();return}r!=null&&r!==R.current&&!Mt(n.current,r)&&(R.current=r);let i=R.current,a=c(n,_),o=_e(n,_);if(I||(t.key===`Home`&&(me(t),R.current=a,B(t)),t.key===`End`&&(me(t),R.current=o,B(t))),k!=null){let e=k(t,R.current,n,v,l,d,_,a,o);if(e!=null&&e!==R.current&&(R.current=e,B(t)),v===`both`)return}if(Pl(t.key,v)){me(t);let e=j(t.currentTarget.ownerDocument);if(M&&!p&&G(t.currentTarget,e)&&!n.current.some(t=>t!=null&&G(t,e))){R.current=Fl(t.key,v,d)?a:o,B(t),r===R.current&&Se();return}let{index:c,wrapped:u}=lt(n.current,i,{decrement:!Fl(t.key,v,d),loopFocus:l,allowEscape:s,disabledIndices:_,minIndex:a,maxIndex:o});u&&(ue.current=!1),R.current=c,B(t)}}),U=Z.useMemo(()=>({onFocus(e){ue.current=!0,we(e)},onClick({currentTarget:e}){p||e.focus({preventScroll:!0})},onMouseMove(e){Ml(e)||(ue.current=!0,de.current=!1,h&&we(e))},onPointerLeave(e){if(!he.current||!se.current||e.pointerType===`touch`)return;ue.current=!0;let t=e.relatedTarget;if(h&&!n.current.includes(t)&&ye.current&&(fe.current?.(),fe.current=null,R.current=-1,B(e),!p)){let e=te.current,t=j(f(e));e&&G(e,t)&&e.focus({preventScroll:!0})}}}),[we,he,te,h,n,B,ye,p]),Oe=Z.useMemo(()=>p&&M&&Ce&&{"aria-activedescendant":`${x}-${r}`},[p,M,Ce,x,r]),ke=Z.useMemo(()=>({...I?{}:Oe,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&M&&!p){let n=L(t.nativeEvent);if(n&&!G(te.current,n))return;me(t);let r=H(Qt,t.nativeEvent);e.setOpen(!1,r);let i=E?.current??ee;!r.isCanceled&&ne(i)&&i.focus()}else De(t)},onPointerMove(e){Ml(e)||(se.current=!0)}}),[Oe,De,te,I,e,M,p,ee,E]),Ae=Z.useMemo(()=>{function t(t){e.setOpen(!0,H(Ge,t.nativeEvent,t.currentTarget))}function n(e){m===`auto`&&T(e.nativeEvent)&&(ae.current=!p)}function r(e){ae.current=m,m===`auto`&&S(e.nativeEvent)&&(ae.current=!0)}return{onKeyDown(n){let r=e.select(`open`);se.current=!1;let i=n.key.startsWith(`Arrow`),a=Il(n.key,Te(),d),o=Pl(n.key,r?v:y),s=(u?a:o)||n.key===`Enter`||n.key.trim()===``;if(p&&r&&(!u||O(n.currentTarget)))return De(n);if(r||g||!i){if(s){let e=Pl(n.key,Te());z.current=u&&e?null:n.key}u?a&&(me(n),r?(R.current=Ee(),B(n),p&&te.current?.focus()):t(n)):o&&(ve.current!=null&&(R.current=ve.current),me(n),!r&&g?t(n):De(n),r&&B(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!p&&(R.current=-1,B(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[De,m,Ee,u,B,e,g,v,y,Te,d,ve,p,te]),je=Z.useMemo(()=>({...Oe,...Ae}),[Oe,Ae]);return Z.useMemo(()=>a?{reference:je,floating:ke,item:U,trigger:Ae}:{},[a,je,ke,Ae,U])}function zl(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=D(s),f=e.useState(`open`),p=Ht(),m=Z.useRef(``),h=Z.useRef(u??i??-1),g=Z.useRef(null),_=D(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!Zt(n)||n?.matches(`:disabled`)?!1:o==null||!Wt(an,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===` `&&(me(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!==` `&&(me(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=D(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);G(r,n)||G(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});V(()=>{(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 Bl=.1,Vl=Bl*Bl,Hl=.5;function Ul(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function Wl(e,t,n,r,i,a,o,s,c,l){let u=!1;return Ul(e,t,n,r,i,a)&&(u=!u),Ul(e,t,i,a,o,s)&&(u=!u),Ul(e,t,o,s,c,l)&&(u=!u),Ul(e,t,c,l,n,r)&&(u=!u),u}function Gl(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function Kl(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 ql(e={}){let{blockPointerEvents:t=!1}=e,n=new At,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*Vl;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=L(r),g=r.type===`mouseleave`,_=G(u,h),v=G(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&Bt(r.relatedTarget)&&G(u,r.relatedTarget))return;function y(){return!!(s&&oc(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=Kl(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=Kl(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=Kl(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=Kl(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Gl(d,f,x)||!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?Hl/2:Hl*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+Hl+1,o=C||T?S.bottom-Hl:S.top,s=C?T?S.bottom-Hl:S.top:S.bottom-Hl;M=Wl(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?Hl/2:Hl*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-Hl,o=C||T?S.top+Hl:S.bottom,s=C?T?S.top+Hl:S.bottom:S.top+Hl;M=Wl(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?Hl/2:Hl*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+Hl+1,o=w||E?S.right-Hl:S.left,s=w?E?S.right-Hl:S.left:S.right-Hl;M=Wl(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?Hl/2:Hl*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-Hl,o=w||E?S.left+Hl:S.right,s=w?E?S.left+Hl:S.right:S.left+Hl;M=Wl(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 Jl(e,t,n){let{reference:r,floating:i}=e,a=nn(t),o=Et(t),s=ot(o),c=qe(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=rt(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Yl(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}=Ft(t,e),p=mt(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=ln(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=ln(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 Xl=50,Zl=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Yl},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Jl(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<Xl&&(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}=Jl(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Ql=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}=Ft(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=qe(r),_=nn(o),v=qe(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[gt(o)]:ft(o)),x=p!==`none`;!d&&x&&b.push(...kt(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=en(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`||_===nn(t)||T.every(e=>nn(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=nn(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{}}}},$l=new Set([`left`,`top`]);async function eu(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=qe(n),s=rt(n),c=nn(n)===`y`,l=$l.has(o)?-1:1,u=a&&c?-1:1,d=Ft(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 tu=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 eu(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}}}}},nu=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}=Ft(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=nn(i),p=Rt(f),m=u[p],h=u[f],g=(e,t)=>yt(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}}}}}},ru=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}=Ft(e,t),u={x:n,y:r},d=nn(i),f=Rt(d),p=u[f],m=u[d],h=Ft(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=$l.has(qe(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}}}},iu=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}=Ft(e,t),c=await i.detectOverflow(t,s),l=qe(n),u=rt(n),d=nn(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=et(p-c[m],g),y=et(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*fn(c.left,c.right):S=p-2*fn(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 au(e){let t=R(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ne(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Te(n)!==a||Te(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function ou(e){return Bt(e)?e:e.contextElement}function su(e){let t=ou(e);if(!ne(t))return Ze(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=au(t),o=(a?Te(n.width):n.width)/r,s=(a?Te(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var cu=Ze(0);function lu(e){let t=A(e);return!ct()||!t.visualViewport?cu:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function uu(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===A(e)}function du(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=ou(e),o=Ze(1);t&&(r?Bt(r)&&(o=su(r)):o=su(e));let s=uu(a,n,r)?lu(a):Ze(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=A(a),t=Bt(r)?A(r):r,n=e,i=h(n);for(;i&&t!==n;){let e=su(i),t=i.getBoundingClientRect(),r=R(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=A(i),i=h(n)}}return ln({width:u,height:d,x:c,y:l})}function fu(e,t){let n=N(e).scrollLeft;return t?t.left+n:du(mn(e)).left+n}function pu(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-fu(e,n),y:n.top+t.scrollTop}}function mu(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=mn(r),s=t?l(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},u=Ze(1),d=Ze(0),f=ne(r);if((f||!a)&&((je(r)!==`body`||Le(o))&&(c=N(r)),f)){let e=du(r);u=su(r),d.x=e.x+r.clientLeft,d.y=e.y+r.clientTop}let p=o&&!f&&!a?pu(o,c):Ze(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-c.scrollTop*u.y+d.y+p.y}}function hu(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function gu(e){let t=N(e),n=e.ownerDocument.body,r=fn(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=fn(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+fu(e),o=-t.scrollTop;return R(n).direction===`rtl`&&(a+=fn(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var _u=25;function vu(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=A(e),a=mn(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!ct()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(fu(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<=_u&&(s-=o)}return{width:s,height:c,x:l,y:u}}function yu(e,t){let n=du(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=su(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function bu(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=vu(e,n,t);else if(t===`document`)r=gu(mn(e));else if(Bt(t))r=yu(t,n);else{let n=lu(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return ln(r)}function xu(e,t){let n=t.get(e);if(n)return n;let r=Oe(e,[],!1).filter(e=>Bt(e)&&je(e)!==`body`),i=null,a=R(e).position===`fixed`,o=a?Pe(e):e;for(;Bt(o)&&!Be(o);){let e=R(o),t=ie(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Pe(o)}return t.set(e,r),r}function Su(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?l(t)?[]:xu(t,this._c):[].concat(n),r],o=bu(t,a[0],i),s=o.top,c=o.right,u=o.bottom,d=o.left;for(let e=1;e<a.length;e++){let n=bu(t,a[e],i);s=fn(n.top,s),c=et(n.right,c),u=et(n.bottom,u),d=fn(n.left,d)}return{width:c-d,height:u-s,x:d,y:s}}function Cu(e){let{width:t,height:n}=au(e);return{width:t,height:n}}function wu(e,t,n){let r=ne(t),i=mn(t),a=n===`fixed`,o=du(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Ze(0);if((r||!a)&&((je(t)!==`body`||Le(i))&&(s=N(t)),r)){let e=du(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=fu(i));let l=i&&!r&&!a?pu(i,s):Ze(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 Tu(e){return R(e).position===`static`}function Eu(e,t){if(!ne(e)||R(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return mn(e)===n&&(n=n.ownerDocument.body),n}function Du(e,t){let n=A(e);if(l(e))return n;if(!ne(e)){let t=Pe(e);for(;t&&!Be(t);){if(Bt(t)&&!Tu(t))return t;t=Pe(t)}return n}let r=Eu(e,t);for(;r&&ve(r)&&Tu(r);)r=Eu(r,t);return r&&Be(r)&&Tu(r)&&!ie(r)?n:r||xe(e)||n}var Ou=async function(e){let t=this.getOffsetParent||Du,n=this.getDimensions,r=await n(e.floating);return{reference:wu(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ku(e){return R(e).direction===`rtl`}var Au={convertOffsetParentRelativeRectToViewportRelativeRect:mu,getDocumentElement:mn,getClippingRect:Su,getOffsetParent:Du,getElementRects:Ou,getClientRects:hu,getDimensions:Cu,getScale:su,isElement:Bt,isRTL:ku};function ju(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Mu(e,t,n){let r=null,i,a=mn(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=Jt(d),h=Jt(a.clientWidth-(u+f)),g=Jt(a.clientHeight-(d+p)),_=Jt(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:fn(0,et(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!ju(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=A(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Nu(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=ou(e),u=i||a?[...l?Oe(l):[],...t?Oe(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Mu(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?du(e):null;c&&g();function g(){let t=du(e);h&&!ju(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 Pu=tu,Fu=nu,Iu=Ql,Lu=iu,Ru=ru,zu=(e,t,n)=>{let r=new Map,i=n??{},a={...Au,...i.platform,_c:r};return Zl(e,t,{...i,platform:a})},Bu=typeof document<`u`?Z.useLayoutEffect:function(){};function Vu(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(!Vu(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)&&!Vu(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Hu(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Uu(e,t){let n=Hu(e);return Math.round(t*n)/n}function Wu(e){let t=Z.useRef(e);return Bu(()=>{t.current=e}),t}function Gu(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);Vu(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=Wu(c),D=Wu(i),O=Wu(l),k=Z.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),zu(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!Vu(w.current,t)&&(w.current=t,Ks.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);Bu(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=Z.useRef(!1);Bu(()=>(A.current=!0,()=>{A.current=!1}),[]),Bu(()=>{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]),N=Z.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=Uu(M.floating,u.x),r=Uu(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Hu(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:N}),[u,k,j,M,N])}var Ku=(e,t)=>{let n=Pu(e);return{name:n.name,fn:n.fn,options:[e,t]}},qu=(e,t)=>{let n=Fu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ju=(e,t)=>({fn:Ru(e).fn,options:[e,t]}),Yu=(e,t)=>{let n=Iu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xu=(e,t)=>{let n=Lu(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=kc(n),p=Z.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=Gu({...e,elements:{...p,...l&&{reference:l}}}),h=Z.useCallback(e=>{let t=Bt(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 V(()=>{o&&(d.current=o)},[o]),V(()=>{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 Qu=Z.createContext(void 0);function $u(){return Z.useContext(Qu)?.direction??`ltr`}var ed=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}=Ft(e,t)||{};if(l==null)return{};let d=mt(u),f={x:n,y:r},p=Et(i),m=ot(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=yt(D,k,O),j=!c.arrow&&rt(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}}}),td=(e,t)=>{let{name:n,fn:r}=ed(e);return{name:n,fn:r,options:[e,t]}},nd={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}}}},rd={sideX:`left`,sideY:`top`},id=`--available-width`,ad=`--available-height`,od=`--anchor-width`,sd=`--anchor-height`,cd=`--transform-origin`,ld=id,ud=ad;function dd(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 fd(e,t,n){let{rects:r,placement:i}=e;return{side:dd(t,qe(i),n),align:rt(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function pd(e){return md(e,Zu)}function md(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:p=!1,inline:m,keepMounted:h=!1,floatingRootContext:g,mounted:_,collisionAvoidance:v,shift:y,nodeId:b,adaptiveOrigin:x,lazyFlip:S=!1,externalTree:C}=e,w=v.side||`flip`,T=v.align||`flip`,E=v.fallbackAxisSide||`end`,O=y?.crossAxis??!1,k=y?.rootBoundary,j=typeof n==`function`?n:void 0,M=D(j),N=j?M:n,ee=lc(n),P=lc(_),F=$u()===`rtl`,[I,te]=Z.useState(null);!_&&I!==null&&te(null);let ne=S===`placement`,L=I?qe(I):null,re=I&&ne?rt(I)||`center`:null,ie=L||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":F?`left`:`right`,"inline-start":F?`right`:`left`}[i],ae=re||o,oe=ae===`center`?ie:`${ie}-${ae}`,R=l;typeof R==`number`?R={top:R,right:R,bottom:R,left:R}:R&&={top:R.top||0,right:R.right||0,bottom:R.bottom||0,left:R.left||0};let z=+(i===`bottom`),se=+(i===`top`),B=+(i===`right`),ce=+(i===`left`),le={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:R},ue=Z.useRef(null),de=lc(a),fe=lc(s),pe=typeof a==`function`?0:a,me=typeof s==`function`?0:s,he=[];m&&he.push(m),he.push(Ku(e=>{let t=fd(e,i,F),n=typeof de.current==`function`?de.current(t):de.current,r=typeof fe.current==`function`?fe.current(t):fe.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[pe,me,F,i]));let ge=T===`none`&&w!==`shift`,_e=!ge&&(u||O||w===`shift`),ve=w===`none`?null:Yu({...le,padding:{top:R.top+1+z,right:R.right+1+ce,bottom:R.bottom+1+se,left:R.left+1+B},mainAxis:!O&&w===`flip`,crossAxis:T===`flip`&&`alignment`,fallbackAxisSideDirection:E}),ye=ge?null:qu({...le,rootBoundary:k,mainAxis:T!==`none`,crossAxis:_e,limiter:u||O?void 0:Ju(e=>{if(!ue.current)return{};let{width:t,height:n}=ue.current.getBoundingClientRect(),r=nn(qe(e.placement)),i=r===`y`?t:n,a=r===`y`?R.left+R.right:R.top+R.bottom;return{offset:i/2+a/2}})},[le,u,O,k,R,T]);w===`shift`||T===`shift`||ae===`center`?he.push(ye,ve):he.push(ve,ye),he.push(Xu({...le,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!P.current)return;let i=e.style;i.setProperty(ld,`${t}px`),i.setProperty(ud,`${n}px`);let a=A(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(od,`${u}px`),i.setProperty(sd,`${d}px`)}}),td(e=>({element:ue.current||f(e.elements.floating).createElement(`div`),padding:ue.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=qe(r),u=rt(r),d=nn(l)===`y`,f=ue.current,p=typeof a==`function`?a(fd(e,i,F)):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 _e&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(cd,d?`${m} ${h}`:`${h} ${m}`),{}}},nd,x),V(()=>{!_&&g&&g.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[_,g]);let be=Z.useMemo(()=>({ancestorScroll:!p,elementResize:!p&&typeof ResizeObserver<`u`,layoutShift:!p&&typeof IntersectionObserver<`u`}),[p]),{refs:xe,elements:Se,x:Ce,y:we,middlewareData:Te,update:H,placement:Ee,context:De,isPositioned:U,floatingStyles:Oe}=t({rootContext:g,open:h?_:void 0,placement:oe,middleware:he,strategy:r,whileElementsMounted:h?void 0:(...e)=>Nu(...e,be),nodeId:b,externalTree:C}),{sideX:ke,sideY:Ae}=Te.adaptiveOrigin||rd,je=U?r:`fixed`,Me=Z.useMemo(()=>{let e;return e=U?x?{position:je,[ke]:Ce,[Ae]:we}:{...Oe,position:je}:{position:je,top:0,left:0},e[ld]=`100vw`,e[ud]=`100vh`,U||(e.opacity=0),e},[x,je,ke,Ce,Ae,we,Oe,U]),Ne=Z.useRef(null);V(()=>{if(!_)return;let e=ee.current,t=typeof e==`function`?e():e,n=(hd(t)?t.current:t)||null;n!==Ne.current&&(xe.setPositionReference(n),Ne.current=n)},[_,xe,N,ee]),Z.useEffect(()=>{if(!_)return;let e=ee.current;typeof e!=`function`&&hd(e)&&e.current!==Ne.current&&(xe.setPositionReference(e.current),Ne.current=e.current)},[_,xe,N,ee]),Z.useEffect(()=>{if(h&&_&&Se.reference&&Se.floating)return Nu(Se.reference,Se.floating,H,be)},[h,_,Se,H,be]);let Pe=qe(Ee),Fe=dd(i,Pe,F),Ie=rt(Ee)||`center`,Le=!!Te.hide?.referenceHidden;V(()=>{S&&_&&U&&(Pe!==ie||ne&&Ie!==ae)&&te(Ee)},[S,ne,_,U,Ee,Pe,Ie,ie,ae]);let Re=Z.useMemo(()=>({position:`absolute`,top:Te.arrow?.y,left:Te.arrow?.x}),[Te.arrow]),ze=Te.arrow?.centerOffset!==0;return Z.useMemo(()=>({positionerStyles:Me,arrowStyles:Re,arrowRef:ue,arrowUncentered:ze,side:Fe,align:Ie,physicalSide:Pe,anchorHidden:Le,refs:xe,context:De,isPositioned:U,update:H}),[Me,Re,ue,ze,Fe,Ie,Pe,Le,xe,De,U,H])}function hd(e){return e!=null&&`current`in e}function gd(e){return e===`starting`?d:Ee}function _d(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),v(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},gd(r),i],stateAttributesMapping:ic})}var vd=e(s(),1);function yd(e){let t=vd.unstable_scheduleCallback(4,e);return()=>vd.unstable_cancelCallback(t)}var bd=Z.createContext(Br({scheduleTask:yd,defaultIdleTTL:400})),xd=new WeakMap,Sd=0,Cd=new Set;function wd(e){Sd++;try{return e()}finally{Sd--}}function Td(e){if(Sd===0)return e();Cd.size===0&&queueMicrotask(Ed),Cd.add(e)}function Ed(){for(let e of Cd)Cd.delete(e),e()}function Dd(e,t){let n=xd.get(e);n===void 0&&(n=new WeakMap,xd.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,()=>Td(n));return()=>{i--,Cd.delete(n),r()}},snapshot(){return wd(()=>e.get(t))},getServerSnapshot(){return(i===0||a===void 0)&&(a={value:wd(()=>ds(t,e))}),a.value}};return n.set(t,o),o}function Od(e,t){let n=Dd(e,t);return Z.useEffect(Ed),Z.useSyncExternalStore(n.subscribe,n.snapshot,n.getServerSnapshot)}function kd(e,t,n){let r=Dd(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(Ed),Z.useSyncExternalStore(r.subscribe,()=>i(r.snapshot()),()=>i(r.getServerSnapshot()))}var Ad=(e,t)=>{let n=Z.useContext(bd);return t?kd(n,e,t):Od(n,e)};function jd(e,t){Z.useEffect(()=>e.mount(t),[t,e])}function Md(e,t,n){return n?.mode===`promise`||n?.mode===`promiseExit`?Z.useCallback(r=>{e.set(t,r);let i=xs(kr(e,t,{suspendOnWaiting:!0}));return n.mode===`promise`?i.then(Nd):i},[e,t,n.mode]):Z.useCallback(n=>{e.set(t,typeof n==`function`?n(e.get(t)):n)},[e,t])}var Nd=e=>{if(Ga(e))return e.value;throw hr(e.cause)},Pd=e=>{jd(Z.useContext(bd),e)},Fd=(e,t)=>{let n=Z.useContext(bd);return jd(n,e),Md(n,e,t)},Id=(e,t)=>{let n=Z.useContext(bd);return[Od(n,e),Md(n,e,t)]},Ld={suspendOnWaiting:new WeakMap,default:new WeakMap};function Rd(e,t,n){let r=n?Ld.suspendOnWaiting:Ld.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 zd(e,t,n){let r=Od(e,t);if(r._tag===`Initial`||n&&r.waiting)throw Rd(e,t,n);return r}var Bd=(e,t)=>{let n=zd(Z.useContext(bd),e,t?.suspendOnWaiting??!1);if(n._tag===`Failure`&&!t?.includeFailure)throw hr(n.cause);return n};Do(`MachineSchemaEncodeError`);var Vd=class extends Do(`MachineSchemaDecodeError`){},Hd=class extends Do(`InfiniteTransitionError`){},Ud=class extends Do(`StartupError`){},Wd=class extends Do(`ChildAlreadyExistsError`){};Do(`ProcessLocalError`);var Gd=class extends Do(`StoppedError`){},Kd=e=>e instanceof Hd||e instanceof Vd,qd=e=>Kd(e)?Ko(e):Jr(e),Jd=e=>Kd(e)||e instanceof Ud?e:new Ud({cause:or(e)}),Yd=e=>e,Xd=`~effect/Machine/Target`,Zd=Symbol(`effect/Machine/TargetSnapshot`),Qd=Symbol(`effect/Machine/StateInput`),$d=Symbol(`effect/Machine/HistoryTarget`),ef=Symbol(`effect/Machine/InitialTarget`),tf=Symbol(`effect/Machine/ChoiceTarget`),nf=Symbol(`effect/Machine/NoTarget`),rf=Symbol(`effect/Machine/Declined`),af=Symbol(`effect/Machine/TargetSelection`),of=Symbol(`effect/Machine/StateUpdate`),sf=Symbol(`effect/Machine/CombinedTarget`),cf=Symbol(`effect/Machine/SelectedBranch`),lf=(e,t,n,r)=>Object.freeze({[af]:af,kind:e,scope:n,path:t,...r===void 0?{}:{updatePath:r}}),uf=lf(`none`,void 0,`local`),df=e=>Zn(e,af),ff=(e,t)=>Object.freeze({[of]:of,path:e,value:t}),pf=e=>Zn(e,of),mf=(e,t)=>Object.freeze({[sf]:sf,target:e,update:t}),hf=e=>Zn(e,sf),gf=(e,t,n,r)=>Object.freeze({[cf]:cf,owner:e,branchIndex:t,branchKey:n,result:r}),_f=e=>Zn(e,cf),vf=Object.freeze({[nf]:nf}),yf=()=>vf,bf=e=>Zn(e,nf),xf=Object.freeze({[rf]:rf}),Sf=()=>xf,Cf=e=>Zn(e,rf),wf=(e,t)=>({[$d]:$d,path:e,parent:t}),Tf=e=>Zn(e,$d),Ef=(e,t,n)=>({[ef]:ef,_tag:`InitialTarget`,path:e,value:t,...n===void 0?{}:{values:n}}),Df=e=>Zn(e,ef),Of=(e,t,n)=>({[tf]:tf,path:e,parent:t,...n===void 0?{}:{values:n}}),kf=e=>Zn(e,tf),Af=(e,t)=>{if(!Ci(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(!Ci(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(Ci(t))return{schema:t,output:void 0,annotations:Ao(t),type:`atomic`,history:void 0,initial:void 0,states:void 0};let n=Zn(t,`schema`)&&Ci(t.schema)?t.schema:void 0,r=n===void 0?t.annotations:Ao(n);if(t.type===`parallel`&&!Zn(t,`states`))throw Error(`Machine.make expected parallel state "${e}" to declare child regions`);if(Zn(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:Ci(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=Ci(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}},jf=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=Af(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)}},Mf=e=>typeof e==`object`&&e&&`branches`in e&&Array.isArray(e.branches)?Array.from(e.branches):[],Nf=e=>typeof e==`object`&&e&&`declinable`in e&&e.declinable===!0?`declinable`:`required`,Pf=e=>{let t=[];for(let n of e.stateNodes.byPath.values()){let r=Yd(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:Mf(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:Zn(i,`reenter`)&&i.reenter===!0,acceptance:Nf(i),branches:Mf(i)})}r.always!==void 0&&t.push({source:n.path,trigger:{type:`always`},reenter:!1,acceptance:Nf(r.always),branches:Mf(r.always)}),r.onDone!==void 0&&t.push({source:n.path,trigger:{type:`done`},reenter:!1,acceptance:Nf(r.onDone),branches:Mf(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:Nf(a),branches:Mf(a)})}}}return t},Ff=(e,t,n)=>({[Xd]:Xd,[Zd]:n?.snapshot,path:e,value:t,values:n?.values}),If=e=>Zn(e,Xd),Lf=e=>({[Qd]:Qd,input:e}),Rf=e=>Zn(e,Qd),zf=e=>Zn(e,`path`)&&Zn(e,`value`),Bf=(e,t,n)=>{if(e.path===t)return br(e);if(e.path!==``&&!t.startsWith(`${e.path}.`))return qn();if(n!==void 0&&e.value!==void 0&&(n[e.path]=e.value),Zn(e,`state`)&&zf(e.state))return Bf(e.state,t,n);if(Zn(e,`states`)&&typeof e.states==`object`&&e.states!==null){for(let r of Object.values(e.states))if(zf(r)){let e=Bf(r,t,n);if(Wa(e))return e}}return qn()},$=(e,t)=>{let n=e.stateNodes.byPath.get(t);if(n===void 0)throw Error(`Machine expected state path "${t}" to exist`);return n},Vf=e=>{if(e.schema===void 0)throw Error(`Machine state "${e.path}" has no value schema`);return e.schema},Hf=new WeakMap,Uf=Symbol(`effect/Machine/EventConstruction`),Wf=new WeakMap,Gf=new WeakMap,Kf=new WeakMap,qf=e=>{let t=e,n=Gf.get(t);if(n!==void 0)return n;let r=Pr(zi(e));return Gf.set(t,r),r},Jf=e=>{let t=e,n=Kf.get(t);if(n!==void 0)return n;let r=Wr(zi(e));return Kf.set(t,r),r},Yf=Symbol.for(`effect/Machine/protocol`),Xf=e=>{let t=e[Yf];if(t===void 0)throw Error(`Machine protocol is unavailable`);return t},Zf=(e,t)=>{Object.defineProperty(e,Yf,{value:t,enumerable:!1})},Qf=e=>{let t=new Set,n=e=>{let r=e;if(!t.has(r)&&(t.add(r),Zn(e,`cases`)&&typeof e.cases==`object`&&e.cases!==null))for(let t of Object.values(e.cases))(typeof t==`object`&&t||typeof t==`function`)&&Zn(t,`make`)&&n(t)};for(let t of e)n(t);return t},$f=(e,t)=>{let n=Hf.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},ep=e=>$f(e.events,`public`).schemas,tp=e=>$f(e.internalEvents,`internal`).schemas,np=e=>$f(e.emittedEvents,`emitted`).schemas,rp=e=>{let t=ep(e),n=tp(e),r=np(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:Ja(a),emit:Ja(r),eventConstructors:Qf(a),emissionConstructors:Qf(r)})},ip=(e,t)=>Zf(t,Xf(e)),ap=e=>Zn(e,`_tag`)?String(e._tag):void 0,op=(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={[Uf]:Uf,_tag:n};return Wf.set(o,{kind:e,schema:t,input:i,...a===void 0?{}:{inputError:a}}),Object.freeze(o)},sp=e=>typeof e==`object`&&!!e&&Wf.has(e),cp=(e,t)=>{let n=[],r=e=>{if(Zn(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(Zn(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),a=e=>Xr(e)?typeof e.literal==`string`||typeof e.literal==`number`?[e.literal]:[]:zo(e)?[e.symbol]:Wi(e)?e.enums.map(([,e])=>e):yo(e)?e.types.flatMap(a):Po(e)?a(e.thunk()):[],o=e=>{let t=ca(e.ast);if(va(t)){let e=t.propertySignatures.find(({name:e})=>e===`_tag`),n=e===void 0?[]:a(e.type);if(n.length>0)return n}try{return Ja([e]).pipe(pr(`_tag`)).discriminants}catch{return[]}};for(let t of n){let n=o(t);if(n.length!==0)for(let r of n){if(Zn(i,r))throw Error(`Duplicate machine event constructor tag: ${String(r)}`);Object.defineProperty(i,r,{value:(...n)=>op(e,t,r,n.length===0?{}:n[0]),enumerable:!0})}}return i},lp=(e,t)=>{let n=Object.freeze(Array.from(t)),r=cp(e,n);return Hf.set(r,{kind:e,schemas:n}),Object.freeze(r)},up=(e,t,n,r)=>qf(t)(n).pipe(Ta(t=>new Vd({machineId:e.id,boundary:r.boundary,cause:t,...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}}))),dp=(e,t,n,r)=>{let i=Jf(t)(n);if(fs(i))throw new Vd({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},fp=(e,t,n,r)=>{try{return t.make(n)}catch(t){let n=t instanceof Error?t.cause:void 0;throw new Vd({machineId:e.id,boundary:r.boundary,cause:ir(t)?t:Zn(n,`~effect/SchemaIssue/Issue`)?new pi(n):or(t),...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}})}},pp=(e,t,n)=>new Vd({machineId:e.id,boundary:n,event:String(t._tag),cause:or(Error(`Constructed ${n} schema does not belong to the machine ${n} protocol`))}),mp=(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}},hp=(e,t,n,r)=>new Vd({machineId:e.id,boundary:n,event:String(t._tag),cause:or(r)}),gp=(e,t,n,r)=>{let i=Wf.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)?Ko(pp(e,n,r)):qa({try:()=>mp(n,i),catch:t=>hp(e,n,r,t)}).pipe(Fo(t=>i.schema.makeEffect(t).pipe(Ta(t=>new Vd({machineId:e.id,boundary:r,event:String(n._tag),cause:new pi(t)})))))},_p=(e,t,n,r)=>{let i=Wf.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 pp(e,n,r);let o;try{o=mp(n,i)}catch(t){throw hp(e,n,r,t)}return fp(e,i.schema,o,{boundary:r,event:String(n._tag)})},vp=(e,t)=>{let n=Xf(e);if(sp(t))return gp(e,n,t,`event`);let r=ap(t);return up(e,n.event,t,r===void 0?{boundary:`event`}:{boundary:`event`,event:r})},yp=(e,t)=>{let n=Xf(e);if(sp(t))return _p(e,n,t,`event`);let r=ap(t);return dp(e,n.event,t,r===void 0?{boundary:`event`}:{boundary:`event`,event:r})},bp=(e,t)=>{let n=Xf(e);if(sp(t))return gp(e,n,t,`emission`);let r=ap(t);return up(e,n.emit,t,r===void 0?{boundary:`emission`}:{boundary:`emission`,event:r})},xp=(e,t)=>{let n=Xf(e);if(sp(t))return _p(e,n,t,`emission`);let r=ap(t);return dp(e,n.emit,t,r===void 0?{boundary:`emission`}:{boundary:`emission`,event:r})},Sp=(e,t,n)=>dp(e,t,n,{boundary:`input`}),Cp=(e,t,n)=>Rf(n)?Vf(t).makeEffect(n.input).pipe(Ta(n=>new Vd({machineId:e.id,boundary:`state`,state:t.path,cause:new pi(n)}))):up(e,Vf(t),n,{boundary:`state`,state:t.path}),wp=(e,t,n)=>Rf(n)?fp(e,Vf(t),n.input,{boundary:`state`,state:t.path}):dp(e,Vf(t),n,{boundary:`state`,state:t.path}),Tp=(e,t,n)=>t.output===void 0?fi(n):up(e,t.output,n,{boundary:`output`,state:t.path}),Ep=(e,t,n)=>t.output===void 0?n:dp(e,t.output,n,{boundary:`output`,state:t.path}),Dp=(e,t)=>{let n=new Set(Lp(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)&&!Ip(r,t.parent))throw Error(`Machine history contains state "${r}" outside parent "${t.parent}"`);if(t.mode===`shallow`&&Fp(r,t.parent)&&$(e,r).parent!==t.parent)throw Error(`Machine shallow history contains deep descendant "${r}"`)}},Op=(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`||!(Ip(n,t.parent)||Lp(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,wp(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}),Dp(e,n.get(r))}return n},kp=Ha(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*Ko(new Vd({machineId:e.id,boundary:`history`,state:r,cause:or(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`||!(Ip(n,t.parent)||Lp(e,t.parent).includes(n)))return yield*Ko(new Vd({machineId:e.id,boundary:`history`,state:n,cause:or(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*Ko(new Vd({machineId:e.id,boundary:`history`,state:n,cause:or(Error(`Machine snapshot contains a value for structural state "${n}"`))}))}else{if(!s)return yield*Ko(new Vd({machineId:e.id,boundary:`history`,state:n,cause:or(Error(`Machine snapshot omits remembered value for "${n}"`))}));o.set(n,yield*up(e,Vf(r),i.values[n],{boundary:`history`,state:n}))}}if(!a.has(t.parent)||Object.keys(i.values).length!==o.size)return yield*Ko(new Vd({machineId:e.id,boundary:`history`,state:r,cause:or(Error(`Machine snapshot contains incomplete history record "${r}"`))}));n.set(r,{mode:i.mode,parent:t.parent,active:a,values:o});try{Dp(e,n.get(r))}catch(t){return yield*Ko(new Vd({machineId:e.id,boundary:`history`,state:r,cause:or(t)}))}}return n}),Ap=(e,t)=>{let n={};for(let[r,i]of t){let t=Array.from(i.active).sort((t,n)=>zp(e,t,n));n[r]={mode:i.mode,active:t,values:Object.fromEntries(i.values)}}return n},jp=(e,t)=>({...e,machineReferences:{self:t.self,parent:t.parent}}),Mp=e=>e.machineReferences,Np=new WeakMap,Pp=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Fp=(e,t)=>e!==t&&(t===``||e.startsWith(`${t}.`)),Ip=(e,t)=>e===t||Fp(e,t),Lp=(e,t)=>{let n=Np.get(e.stateNodes);n===void 0&&(n=new Map,Np.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},Rp=(e,t)=>Lp(e,t).length,zp=(e,t,n)=>$(e,t).order-$(e,n).order,Bp=(e,t,n)=>$(e,n).children.some(e=>t.active.has(e)),Vp=(e,t)=>{let n=Array.from(t.active).filter(n=>!Bp(e,t,n)).sort((t,n)=>zp(e,t,n));if(n.length===0)throw Error(`Machine expected an active leaf state`);return n},Hp=(e,t)=>Vp(e,t)[0],Up=(e,t,n)=>{let r=Vp(e,t).filter(e=>Ip(e,n));if(r.length===0)throw Error(`Machine expected state "${n}" to have an active leaf state`);return r[0]},Wp=(e,t)=>{for(let n of t.active)if($(e,n).parent===void 0)return n;throw Error(`Machine expected an active root state`)},Gp=(e,t,n)=>{let r={},i=Lp(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},Kp=(e,t,n)=>{let r=$(e,n).parent;return r===void 0?void 0:t.values.get(r)},qp=(e,t)=>{let n=r=>t.active.has(r)?[r,...$(e,r).children.flatMap(n)]:[];return e.stateNodes.roots.flatMap(n)},Jp=(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=Jp(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]=Jp(e,t,i)}i.states=a}return i},Yp=(e,t)=>{let n=Jp(e,t,Wp(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:Ap(e,t.history)}),n},Xp=(e,t,n)=>{let r=Jp(e,t,n);return t.history.size>0&&Object.assign(r,{history:Ap(e,t.history)}),r},Zp=(e,t,n)=>{if(!Zn(n,`state`)||!zf(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},Qp=(e,t)=>{if(!Zn(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},$p=(e,t,n,r)=>{let i=$(e,n),a=r[i.key];if(!Pp(r,i.key)||!zf(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},em=(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,wp(e,i,t.value));if(i.type===`compound`&&a(Zp(e,i,t)),i.type===`parallel`){let n=Qp(i,t);for(let t of i.children)a($p(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:Op(e,t)}},tm=(e,t)=>em(e,t),nm=(e,t)=>{try{return em(e,t)}catch(t){throw t instanceof Vd?t:new Vd({machineId:e.id,boundary:`configuration`,cause:or(t)})}},rm=Ha(function*(e,t){let n=new Set,r=new Map,i=t.completed,a=Ha(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*Cp(e,i,t.value));if(i.type===`compound`&&(yield*a(Zp(e,i,t))),i.type===`parallel`){let n=Qp(i,t);for(let t of i.children)yield*a($p(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*kp(e,t)}}),im=(e,t)=>rm(e,t).pipe(dr(t=>{if(ws(t))return ho(Ei(t,t=>t instanceof Vd?t:new Vd({machineId:e.id,boundary:`configuration`,cause:xr(t)})));let n=Qr(t);return Wa(n)&&n.value instanceof Vd?Ko(n.value):Ko(new Vd({machineId:e.id,boundary:`configuration`,cause:t}))})),am=(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 Lp(e,n.parent))t.active.has(r)&&o.add(r);for(let i of t.active)(i===n.parent||r===`deep`&&Fp(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}},om=(e,t)=>e.history.get(t),sm=(e,t,n)=>{let r=new Set(n.active),i=new Map(n.values),a=new Map,o=Lp(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)Ip(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}};Ha(function*(e,t,n,r,i){let a=$(e,n),o=new Set,s=new Map,c=new Map,l=Lp(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&&Pp(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*Cp(e,c,r));else if(i!==void 0&&Pp(i,n))s.set(n,yield*Cp(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)Ip(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}}),Ha(function*(e,t,n,r){let i=yield*rm(e,n),a=new Set(i.active),o=new Map(i.values),s=new Map(i.outputs),c=Lp(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&&Pp(r,i))throw Error(`Machine structural target "${i}" cannot contain a value`)}else if(r!==void 0&&Pp(r,i))o.set(i,yield*Cp(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)Ip(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&&Pp(r,n))for(let[t,i]of Object.entries(r)){if(!Ip(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*Cp(e,r,i))}}}}return{active:a,values:o,outputs:s,history:new Map([...t.history,...i.history])}});var cm=(e,t,n,r,i,a=!1)=>{let o=$(e,n),s=new Set,c=new Map,l=new Map,u=Lp(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&&Pp(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,wp(e,a,r));else if(i!==void 0&&Pp(i,n))c.set(n,wp(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)Ip(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}},lm=(e,t,n)=>{let r=cm(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,wp(e,n,r))}return{...r,active:i,values:a}},um=(e,t,n,r)=>{let i=em(e,n),a=new Set(i.active),o=new Map(i.values),s=new Map(i.outputs),c=Lp(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&&Pp(r,i))throw Error(`Machine structural target "${i}" cannot contain a value`)}else if(r!==void 0&&Pp(r,i))o.set(i,wp(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)Ip(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&&Pp(r,n))for(let[t,i]of Object.entries(r)){if(!Ip(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,wp(e,r,i))}}}}return{active:a,values:o,outputs:s,history:new Map([...t.history,...i.history])}},dm=(e,t,n)=>{if(If(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 um(e,t,r,n.values)}return cm(e,t,n.path,n.value,n.values)}if(zf(n)){let r=nm(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`)},fm=(e,t)=>Yd(e).handlers[t],pm=(e,t,n)=>$(e,n).children.find(e=>t.active.has(e)),mm=(e,t)=>$(e,t).type===`final`,hm=(e,t)=>fm(e,t)?.onDone!==void 0,gm=(e,t,n)=>{if(!t.active.has(n))return!1;let r=$(e,n);if(r.type===`compound`){let r=pm(e,t,n);return r!==void 0&&(n===``?!hm(e,r)&&gm(e,t,r):mm(e,r))}if(r.type===`parallel`){for(let n of r.children)if(!gm(e,t,n))return!1;return!0}return mm(e,n)},_m=(e,t)=>{let n=Wp(e,t);return gm(e,t,n)&&!hm(e,n)},vm=(e,t,n)=>e.has(t)?{path:t,output:e.get(t),isNew:!1}:(e.set(t,n),{path:t,output:n,isNew:!0}),ym=Ha(function*(e,t,n,r,i){let a=$(e,n),o=fm(e,n)?.output?.({state:t.values.get(n),containingState:Kp(e,t,n),ancestors:Gp(e,t,n),event:r,outputs:i});return yield*Tp(e,a,o)}),bm=Ha(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=pm(e,t,n);if(o===void 0||(n===``?hm(e,o):!mm(e,o)))return;let s=yield*bm(e,t,o,r,i,a);if(s===void 0)return;let c=vm(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*bm(e,t,n,r,i,a);o===void 0?c=!1:s[$(e,n).key]=o.output}if(!c)return;let l=vm(i,n,yield*ym(e,t,n,r,s));return l.isNew&&a.push(l),l}if(!mm(e,n))return;let s=vm(i,n,yield*ym(e,t,n,r));return s.isNew&&a.push(s),s}),xm=Ha(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=Rp(e,n)-Rp(e,t);return r===0?zp(e,t,n):r}))yield*bm(e,a,t,n,r,i);return{configuration:a,completions:i}}),Sm=(e,t,n,r,i)=>{let a=$(e,n),o=fm(e,n)?.output?.({state:t.values.get(n),containingState:Kp(e,t,n),ancestors:Gp(e,t,n),event:r,outputs:i});return Ep(e,a,o)},Cm=(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=pm(e,t,n);if(o===void 0||(n===``?hm(e,o):!mm(e,o)))return;let s=Cm(e,t,o,r,i,a);if(s===void 0)return;let c=vm(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=Cm(e,t,n,r,i,a);o===void 0?c=!1:s[$(e,n).key]=o.output}if(!c)return;let l=vm(i,n,Sm(e,t,n,r,s));return l.isNew&&a.push(l),l}if(!mm(e,n))return;let s=vm(i,n,Sm(e,t,n,r));return s.isNew&&a.push(s),s},wm=(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=Rp(e,n)-Rp(e,t);return r===0?zp(e,t,n):r}))Cm(e,a,t,n,r,i);return{configuration:a,completions:i}},Tm=e=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine construction must be an object`);return e},Em=(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 Lf(Object.hasOwn(t,`data`)?t.data:{})}},Dm=(e,t,n={},r)=>{let i=e.byPath.get(t);if(i?.type===`atomic`||i?.type===`final`){let e=Tm(n);if(Reflect.ownKeys(e).some(e=>e!==`data`&&e!==`decoded`))throw Error(`Machine leaf construction accepts only data and decoded`);return Ff(t,Em(i,e))}let a=new Map,o=(t,n)=>{let i=Tm(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=Em(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=Tm(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=Tm(n);for(;u.states!==void 0;){let t=e.byPath.get(l),n=Tm(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=Tm(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 Of(l,d.parent??``,p);if(d.type===`atomic`||d.type===`final`)return Ff(l,f,{values:p});let m=new Map([...a].filter(([e])=>e.startsWith(`${l}.`)));return{...Ef(l,f,p),...m.size===0?{}:{children:m}}},Om=(e,t,n)=>{let r=Tm(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 ff(t,Em(i,r))},km=(e,t,n=``)=>{let r=Tm(t),i=e.byPath.get(n);Dm(e,n,r);let a=Em(i,r);if(i.type===`choice`)return Of(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=Tm(r.states),s=Object.fromEntries(Object.entries(o).map(([t,r])=>[t,km(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]}},Am=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(t);return e},jm=`root`,Mm=e=>{let t=new Map,n=(e,r)=>{let i=!Ci(e)&&`type`in e?e.type:void 0;if(t.set(r,i===`history`||i===`choice`?i:`state`),!Ci(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 "${jm}" is reserved for the root`);return t},Nm=(e,t)=>{let n=Mm(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(Am(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(Am(t.branches,`Machine branches must be a map`))){let t=Am(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={...Am(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 Fm({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}},Pm=(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}},Fm=(e,t)=>{let n=[`target`,`history`,`none`,`initialize`].filter(e=>t[e]!==void 0);if(n.length===0&&t.update!==void 0){let n=Pm(t.update,e);if(n.kind!==`state`)throw Error(`Machine update requires an active state reference`);return lf(`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 uf}if(r===`initialize`){if(t.update!==void 0)throw Error(`Machine initialize cannot update a retained owner`);return lf(`state`,``,`branch`)}let i=Pm(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:Pm(t.update,e).path;if(a!==void 0&&r!==`target`)throw Error(`Machine owner updates require an ordinary destination`);return lf(i.kind,i.path,r===`history`?`full`:`branch`,a)},Im=(e,t,n,r)=>{let i=Am(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`&&Zo(a.value))&&!(a.kind===`streams`&&ia(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}},Lm=Symbol(`effect/Machine/InitialEvent`),Rm=Symbol(`effect/Machine/SnapshotBuilderState`),zm=Symbol(`effect/Machine/ChildMachineLogic`),Bm=new WeakSet,Vm=e=>Bm.has(e),Hm=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine ${t} must be an object`);return e},Um=e=>typeof e==`function`?e:()=>e,Wm=e=>{if(typeof e==`object`&&e&&Zn(e,`decoded`)&&e.decoded===!0&&Zn(e,`data`)){let t=Hm(e,`decoded construction`);if(Reflect.ownKeys(t).some(e=>e!==`decoded`&&e!==`data`))throw Error(`Machine decoded construction accepts only decoded and data`);return Um(t.data)}let t=Um(e);return n=>Lf(e===void 0?{}:t(n))},Gm=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(!Zn(e,`data`))throw Error(`Machine decoded construction requires data`);return Um(e.data)}let t=Um(e.data);return n=>Lf(Zn(e,`data`)?t(n):{})},Km=(e,t)=>{let n=(e,t,r)=>{if(Zn(t,`initialize`))throw Error(`Machine child construction belongs in initial declarations`);if(r!==``&&Zn(t,`root`))throw Error(`Machine root construction belongs at the root handler`);let{initial:i,root:a,states:o,...s}=t;if(Ci(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?{}:Hm(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?{}:Hm(i,`parallel initial regions`);for(let[n,r]of Object.entries(t)){let t=e.states[n];if(t===void 0||!Ci(t)&&(t.type===`history`||t.type===`choice`))throw Error(`Machine invalid initial region "${n}"`);if(!Ci(t)&&(!(`schema`in t)||t.schema===void 0))throw Error(`Machine schema-less region "${n}" cannot construct data`);d[n]=Wm(r)}}else{let t=Hm(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||Ci(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`&&(Zn(t,`data`)||Zn(t,`decoded`)))throw Error(`Machine choice initial edges cannot construct data`);let c=Gm(t),l=e.states[a];if(Zn(t,`data`)&&!Ci(l)&&(!(`schema`in l)||l.schema===void 0))throw Error(`Machine schema-less initial child "${a}" cannot construct data`);Zn(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?{}:Hm(c[t],`state handler`),e);l[t]=a.node,(Ci(i)||i.type!==`history`)&&(c[t]!==void 0||!Ci(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{[Rm]:i}};return Bm.add(g),{node:m,handlers:{...s,...h.length===0?{}:{initialize:g},states:u}}};return n(e.node,t,``)},qm=(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)},Jm=e=>`child`in e?e.child.id:e.id,Ym=(e,t)=>{let n=new Set;for(let r of e){let e=Jm(r);if(n.has(e))throw Error(`Machine invocations for state "${t}" must have distinct ids; "${e}" is declared twice`);n.add(e)}},Xm=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(yp(e,t))},emit:t=>{r.push(xp(e,t))},sendTo:(e,n)=>{t.push({_tag:`SendTo`,target:e,event:n})},stop:e=>{t.push({_tag:`Stop`,child:e})}}}},Qm=(e,t)=>{let n=e.stateNodes.byPath.get(t);if(n===void 0)throw Error(`Machine expected state path "${t}" to exist`);return n},$m=e=>{let t={};return Object.defineProperty(t,"decoded",{value:e,enumerable:!1}),Object.defineProperty(t,"from",{value:(...t)=>e(Lf(t.length===0?{}:t[0])),enumerable:!1}),t},eh=e=>{let t={};return Object.defineProperty(t,Rm,{value:e,enumerable:!1}),t},th=(e,t,n)=>{let r=eh(n);for(let i of t.children){let a=Qm(e,i);a.schema===void 0||Zn(n,a.key)||(r[a.key]=$m(r=>{let i=Object.assign({},n);return i[a.key]=r,th(e,t,i)}))}return r},nh=(e,t)=>{let n=Qm(e,t);if(n.type===`parallel`)return th(e,n,{});if(n.type!==`compound`)throw Error(`Machine state "${t}" cannot initialize child states`);let r=Qm(e,n.initial);if(r.schema===void 0)throw Error(`Machine state "${t}" has no schema-valued initial child`);return $m(e=>eh({[r.key]:e}))},rh=(e,t)=>{if(typeof t!=`object`||!t||!Zn(t,Rm))throw Error(`Machine initialize handler for "${e}" must return its builder result`);return t[Rm]},ih=Symbol(`effect/Machine/InvocationEvent`),ah=(e,t,n)=>({[ih]:!0,path:e,id:t,type:`done`,output:n}),oh=(e,t,n)=>({[ih]:!0,path:e,id:t,type:`element`,element:n}),sh=(e,t,n)=>({[ih]:!0,path:e,id:t,type:`failure`,error:n}),ch=(e,t,n)=>({[ih]:!0,path:e,id:t,type:`snapshot`,snapshot:n}),lh=e=>typeof e==`object`&&!!e&&ih in e,uh=new WeakMap,dh=new WeakMap,fh=(e,t)=>e.parent===void 0?{self:t.self}:{self:t.self,parent:t.parent},ph=(e,t)=>{let n=Object.create(e);return dh.set(n,fh(e,t)),n},mh=(e,t)=>{let n=t.machineReferences;if(n!==void 0)return fh(e,n);let r=dh.get(e);if(r!==void 0)return r;let i=uh.get(e);if(i!==void 0)return i;let a=fh(e,{self:{id:e.id??`Machine`,sessionId:`Machine.plan`,send:()=>Ko(new Gd)},parent:void 0});return uh.set(e,a),a},hh=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}},gh=(e,t,n)=>{let r=Zm(e);return t===void 0||t(n,r.enqueue),{commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents}},_h=(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 Cf(a.result)?{declined:!0}:{declined:!1,state:bf(a.result)?void 0:a.result,branchIndex:a.branchIndex,branchKey:a.branchKey,commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents}},vh=(e,t,n)=>{let r=Zm(e);return{value:t(n,r.enqueue),commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents}},yh=(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)=>zp(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=Yh(e,m,Of(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=Df(i)?xh(e,r,i,n):Tf(i)?Sh(e,r,i,n):void 0;r=dm(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=Yd(e).handlers[d]?.initialize;if(t===void 0){a.set(p.path,wp(e,p,Lf({}))),u=!0;continue}let i=vh(e,t,{...mh(e,m),state:m.values.get(d),containingState:Kp(e,m,d),ancestors:Gp(e,m,d),event:n,...d===``&&r!==void 0?{input:r.value}:{},...Vm(t)?{}:{builder:nh(e,d)}}),l=rh(d,i.value);a.set(p.path,wp(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:Yd(e).handlers[d]?.initialize,h=m===void 0?void 0:vh(e,m,{...mh(e,p),state:p.values.get(d),containingState:Kp(e,p,d),ancestors:Gp(e,p,d),event:n,...d===``&&r!==void 0?{input:r.value}:{},...Vm(m)?{}:{builder:nh(e,d)}}),g=h===void 0?void 0:rh(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,wp(e,n,Lf({})));continue}if(g===void 0||!Object.prototype.hasOwnProperty.call(g,n.key)){if(m!==void 0&&Vm(m)){a.set(n.path,wp(e,n,Lf({})));continue}throw Error(`Machine parallel state initializer for "${d}" must return region "${n.key}"`)}a.set(n.path,wp(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 bh(e,t,n,r){let i=lm(e,t,n);if(n.children===void 0||![...n.children.keys()].some(t=>$(e,t).type===`choice`))return yh(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=Yh(e,i,Of(t,n.parent),r);for(let t of[l.target,...l.additionalTargets]){let n=Df(t)?xh(e,i,t,r):Tf(t)?Sh(e,i,t,r):void 0;i=dm(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=yh(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 xh(e,t,n,r){let i=bh(e,t,n,r),a=Xp(e,i.configuration,n.path);return{target:Ff(n.path,a.value,{snapshot:a,values:n.values}),commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents,transitions:i.transitions}}function Sh(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=om(t,n.path);if(a!==void 0){let i=yh(e,sm(e,t,a),r),o=Xp(e,i.configuration,n.parent),s=Object.fromEntries(i.configuration.values);return n.parent!==``&&t.active.has(``)&&delete s[``],{target:Ff(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=Yd(e).handlers[n.parent]?.history?.[o]?.default;if(s===void 0)throw Error(`Machine history state "${n.path}" requires a default implementation`);let c=_h(e,s,{event:r,target:t=>km(e.stateNodes,t),owner:n.parent});if(c.state===void 0||Tf(c.state)||!zf(c.state))throw Error(`Machine history default for "${n.path}" must return a complete snapshot containing its owner`);let l=qh(c.state)===void 0?void 0:Yh(e,{active:new Set,values:new Map,outputs:new Map,history:t.history},c.state,r),u=l===void 0?nm(e,c.state):dm(e,{active:new Set,values:new Map,outputs:new Map,history:t.history},l.target);for(let t of l?.additionalTargets??[])u=dm(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=Xp(e,u,n.parent),f=Object.fromEntries(u.values);return n.parent!==``&&t.active.has(``)&&delete f[``],{target:Ff(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 Ch=(e,t)=>{if(!t.transition.declinable)return t;let n=_h(e,t.transition.transition,t.context,t.transition.evaluate);return n.declined?void 0:{...t,collected:n}},wh=(e,t)=>[...Lp(e,t)].reverse(),Th=(e,t,n)=>{let r=Lp(e,t),i=Lp(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},Eh=(e,t)=>{if(e!==void 0&&t!==void 0)return e===t||Fp(e,t)?t:e},Dh=(e,t,n)=>Ah(e,Array.from(t.active).filter(e=>n===void 0||Fp(e,n))),Oh=(e,t,n)=>jh(e,Array.from(t.active).filter(e=>n===void 0||Fp(e,n))),kh=(e,t)=>e.active.size===t.active.size&&Array.from(e.active).every(e=>t.active.has(e)),Ah=(e,t)=>Array.from(new Set(t)).sort((t,n)=>{let r=Lp(e,n).length-Lp(e,t).length;return r===0?$(e,n).order-$(e,t).order:r}),jh=(e,t)=>Array.from(new Set(t)).sort((t,n)=>{let r=Lp(e,t).length-Lp(e,n).length;return r===0?zp(e,t,n):r}),Mh=(e,t,n,r)=>({...mh(e,t),state:t.values.get(n),containingState:Kp(e,t,n),ancestors:Gp(e,t,n),event:r}),Nh=(e,t,n,r,i)=>({...mh(e,t),state:t.values.get(n),containingState:Kp(e,t,n),ancestors:Gp(e,t,n),event:r,snapshot:i}),Ph=(e,t,n,r,i,a)=>({...mh(e,t),state:t.values.get(n),containingState:Kp(e,t,n),ancestors:Gp(e,t,n),event:r,output:i,snapshot:a}),Fh=(e,t,n,r,i)=>{let a=[],o=[],s=[];for(let c of n){let n=gh(e,Yd(e).handlers[c]?.[i],Mh(e,t,c,r));a.push(...n.commands),o.push(...n.raisedEvents),s.push(...n.emittedEvents)}return{commands:a,emittedEvents:s,raisedEvents:o}},Ih=(e,t,n)=>{let r=[],i=new Set,a=new Map,o,s=()=>o??=Yp(e,t);for(let o of Vp(e,t))for(let c of wh(e,o)){let l=hh(Yd(e).handlers[c]?.always);if(l!==void 0){let u=a.get(c);if(a.has(c)||(u=Ch(e,{sourcePath:c,leafPath:o,trigger:{type:`always`},transition:l,context:{...mh(e,t),state:t.values.get(c),containingState:Kp(e,t,c),ancestors:Gp(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},Lh=(e,t,n,r)=>{let i=[],a=new Set,o,s=()=>o??=Yp(e,t);for(let o of r){let r=hh(Yd(e).handlers[o.path]?.onDone);if(r!==void 0&&!a.has(o.path)){a.add(o.path);let c=Ch(e,{sourcePath:o.path,leafPath:Up(e,t,o.path),trigger:{type:`done`},transition:r,context:Ph(e,t,o.path,n,o.output,s())});c!==void 0&&i.push(c)}}return i},Rh=(e,t,n)=>{let r=[],i=new Set,a=new Map,o,s=()=>o??=Yp(e,t);for(let o of Vp(e,t))for(let c of wh(e,o)){let l=hh(Yd(e).handlers[c]?.on?.[n._tag]);if(l!==void 0){let u=a.get(c);if(a.has(c)||(u=Ch(e,{sourcePath:c,leafPath:o,trigger:{type:`event`,event:n._tag},transition:l,context:Nh(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},zh=(e,t,n)=>{if(!t.active.has(n.path))return[];let r=Yd(e).handlers[n.path],i=Xm(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=hh(n.type===`element`?i.onElement:n.type===`done`?i.onDone:n.type===`failure`?i.onFailure:i.onSnapshot);if(a===void 0)return[];let o=Yp(e,t),s={...mh(e,t),state:t.values.get(n.path),containingState:Kp(e,t,n.path),ancestors:Gp(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=Ch(e,{sourcePath:n.path,leafPath:Up(e,t,n.path),trigger:{type:`invoke`,id:n.id,outcome:n.type},transition:a,context:s});return c===void 0?[]:[c]},Bh=e=>{if(Tf(e)||kf(e)||If(e)||zf(e))return String(e.path);throw Error(`Machine expected transition target to be a snapshot or target builder result`)},Vh=(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(`, `)}`)}},Hh=(e,t)=>{for(let n of e)if(t.includes(n))return!0;return!1},Uh=(e,t)=>Array.from(t).sort((t,n)=>zp(e,t.selection.sourcePath,n.selection.sourcePath)),Wh=e=>e.filter(t=>!e.some(e=>e.sourcePath!==t.sourcePath&&Fp(e.sourcePath,t.sourcePath))),Gh=(e,t)=>{let n=[];for(let r of Uh(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(Hh(r.exitPaths,i.exitPaths)||n){if(Fp(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},Kh=(e,t={})=>{let n={...t},r=[],i=e=>{if(kf(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:Of(e.path,e.parent,n),values:n}))},qh=(e,t={})=>Kh(e,t)[0],Jh=(e,t)=>{if(kf(e))return Of(e.path,e.parent,{...t,...e.values??{}});if(Df(e))return{...e,values:{...t,...e.values}};if(!If(e)||Object.keys(t).length===0)return e;let n=e[Zd];return Ff(e.path,e.value,{...n===void 0?{}:{snapshot:n},values:{...t,...e.values??{}}})};function Yh(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=Kh(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 Hd({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=Yd(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,wp(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=_h(e,p.transition,{...mh(e,h),containingState:Kp(e,h,f.path),ancestors:Gp(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`);Vh(f.path,{type:`choice`},p.targets,g.state);let _=Bh(g.state);n=Jh(g.state,d.values);let v=qh(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(!If(n)&&!zf(n)&&!Tf(n)&&!Df(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 Xh=(e,t,n)=>{let r=n.leafPath,i=n.collected??_h(e,n.transition.transition,n.context,n.transition.evaluate);if(i.declined)throw Error(`Machine transition returned decline without declaring declinable: true`);let a=hf(i.state)?i.state:void 0,o=a?.target??i.state,s=o===void 0||pf(o)?void 0:o;Vh(n.sourcePath,n.trigger,n.transition.targets,s);let c=a?.update??(pf(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:wp(e,n,c.value)}})(),u=l!==void 0&&(Df(s)||kf(s))?{...t,values:new Map(t.values).set(l.path,l.value)}:t,d=s===void 0?void 0:Yh(e,u,s,n.context.event),f=d?.target??s,p=f!==void 0&&Df(f)?xh(e,u,f,n.context.event):void 0,m=p?.target??f,h,g=Tf(m)&&n.transition.reenter&&t.active.has(m.parent)?m:void 0;if(m!==void 0&&Tf(m)){let i=n.transition.reenter?$(e,n.sourcePath).parent:Th(e,r,m.parent),a=g===void 0?Dh(e,t,i):Ah(e,Array.from(t.active).filter(e=>Ip(e,m.parent)));h=Sh(e,a.includes(m.parent)?am(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(Df(r)){let i=xh(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(!Tf(r)){S.push(r);continue}let i=Sh(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?Bh(_):Bh(s),w=_===void 0?l===void 0?t:{...t,values:new Map(t.values).set(l.path,l.value)}:dm(e,t,_);for(let t of S)w=dm(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||!kh(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:Th(e,r,C),O=$(e,n.sourcePath).parent,k=n.transition.reenter?Eh(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?Dh(e,t,k):Ah(e,Array.from(t.active).filter(e=>Ip(e,g.parent))),entryPaths:g===void 0?Oh(e,w,k):jh(e,Array.from(w.active).filter(e=>Ip(e,g.parent))),choiceTransitions:[...d?.transitions??[],...p?.transitions??[],...h?.transitions??[],...x]}},Zh=1e3,Qh={_tag:Lm},$h=(e,t)=>_m(e,tm(e,t)),eg=(e,t,n)=>im(e,t).pipe(Fo(t=>xm(e,t,n)),Fo(t=>{let n=Wp(e,t.configuration);return!_m(e,t.configuration)||!t.configuration.outputs.has(n)?Jr(Error(`Machine attempted to read terminal output from a non-terminal configuration`)):fi(t.configuration.outputs.get(n))})),tg=(e,...t)=>{let n=e.input===void 0?t:t.length===0?(Sp(e,e.input,void 0),t):[Sp(e,e.input,t[0])],r=e.initial(...n),i={active:new Set,values:new Map,outputs:new Map,history:new Map},a=xh(e,i,r,Qh),o=dm(e,i,a.target),s=Yp(e,o),c=qp(e,o),l=a.commands,u=a.raisedEvents,d=a.emittedEvents,f=Fh(e,o,c,Qh,`entry`),p=rg(e,o,Qh,[...f.commands],[...u,...f.raisedEvents],[...d,...f.emittedEvents],a.transitions.length===0?[]:[{next:o,event:Qh,transitions:a.transitions,commands:l,raisedEvents:[...u],emittedEvents:d,exitPaths:[],entryPaths:[],changed:!1,stabilize:!1}]),m={startingState:s,initialEntryPaths:c,state:Yp(e,p.next),commands:[...l,...p.commands],emittedEvents:p.emittedEvents,microsteps:p.microsteps.map(t=>({next:Yp(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}},ng=(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=Wh(r),a=[];for(let n of i)a.push(Xh(e,t,n));let o=Gh(e,a),s=Uh(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:Bh(e.unresolvedTarget),resolvedTarget:e.target===void 0?void 0:Bh(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=dm(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=Ah(e,s.flatMap(e=>e.exitPaths)),_=jh(e,s.flatMap(e=>e.entryPaths));l=am(e,t,l,g);let v=Fh(e,t,g,n,`exit`),y=Fh(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}},rg=(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 Hd({machineId:e.id,state:String(Hp(e,s)),maxIterations:Zh});let t=wm(e,s,c);for(s=t.configuration,m.push(...t.completions.filter(t=>Yd(e).handlers[t.path]?.onDone!==void 0));m.length>0&&!s.active.has(m[0].path);)m.shift();let n=Lh(e,s,c,m.length===0?[]:[m.shift()]);if(n.length>0){let t=ng(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(_m(e,s)){let t=Wp(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?Ih(e,s,c):[];if(h.length>0){let t=ng(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=Rh(e,s,_);if(v.length===0){l=!0;continue}let y=ng(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}},ig=(e,t,n)=>{let r=lh(n)?n:yp(e,n);if(_m(e,t)){let n=wm(e,t,r),i=Wp(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=lh(r)?zh(e,t,r):Rh(e,t,r);if(i.length===0)return{event:r,next:t,commands:[],emittedEvents:[],microsteps:[],done:!1,output:void 0};let a=ng(e,t,r,i),o=[...a.commands],s=[...a.raisedEvents],c=[...a.emittedEvents],l=[a];return{...rg(e,a.next,r,o,s,c,l),event:r}},ag=(e,...t)=>qa({try:()=>tg(e,...t),catch:Jd}),og=(e,t)=>({raise:n=>vp(e,n).pipe(Fo(e=>t.sendTo(t.self,e))),emit:n=>bp(e,n).pipe(Fo(e=>t.emit(e)))}),sg=(e,t)=>ea(e,e=>e._tag===`SendTo`?t.sendTo(e.target,e.event):t.stopChild(e.child),{discard:!0}),cg=(e,t)=>nr(Array.from(e,e=>t.emit(e)),{discard:!0}),lg=new WeakMap,ug=e=>{let t=lg.get(e);if(t!==void 0)return t;let n={self:{id:e.id??`Machine`,sessionId:`Machine.plan`,send:()=>Ko(new Gd)},parent:void 0};return lg.set(e,n),n},dg=(e,t)=>{let n=t===void 0?ug(e):t;return e.parent===void 0?{self:n.self}:{self:n.self,parent:n.parent}},fg=new Set([`initialize`,`invoke`,`on`,`output`]),pg=e=>{if(e===void 0)return!0;for(let t of Reflect.ownKeys(e))if(!fg.has(t))return!1;return!0},mg=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=Yd(e).handlers[a.path];if(!pg(o))return;if(o?.on===void 0)continue;let s=new Map;for(let e of Reflect.ownKeys(o.on)){let t=hh(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)=>zp(e,t,n)),r.sort((t,n)=>zp(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=>Lp(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&&(Yd(e).handlers[``]===void 0||Reflect.ownKeys(Yd(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}},hg=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()}),gg=(e,t)=>t?{...e,next:hg(e.next)}:e,_g=(e,t,n)=>{e.values[t]=n},vg=(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}},yg=(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}},bg=(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=bg(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]=bg(e,t,i)}i.states=a}return i},xg=(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=bg(e,t,n);return t.completedOrder.length>0&&(r.completed=t.completedOrder.map(n=>({path:e.nodes[n].path,output:t.outputs[n]}))),r},Sg=(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{...dg(e,a),state:n.values[r],containingState:o<0?void 0:n.values[o],ancestors:s,event:i,snapshot:xg(t,n)}},Cg=Object.freeze([]),wg=(e,t,n,r)=>{let i,a,o,s={raise:t=>{(a??=[]).push(yp(e,t))},emit:t=>{(o??=[]).push(xp(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:bf(c.result)?void 0:c.result,branchIndex:c.branchIndex,branchKey:c.branchKey,commands:i??Cg,raisedEvents:a??Cg,emittedEvents:o??Cg}},Tg=(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:Sg(e,t,n,c,r,i)})}}}return a},Eg=(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},Dg=(e,t,n,r,i)=>{if((If(r)?t.indexByPath.get(String(r.path)):void 0)===i&&n.active[i]===1&&If(r)&&r[Zd]===void 0&&r.values===void 0&&n.completedOrder.length===0&&t.valued[i]){let a=n.values.slice();return a[i]=wp(e,t.nodes[i],r.value),{...n,values:a}}return vg(t,dm(e,yg(t,n),r))},Og=(e,t,n,r)=>{let i=wg(e,r.transition.transition,r.context,r.transition.evaluate),a=hf(i.state)?i.state:void 0,o=a?.target??i.state,s=a?.update??(pf(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:wp(e,i,s.value)}})(),l=o===void 0||pf(o)?void 0:o;Vh(r.sourcePath,r.trigger,r.transition.targets,l);let u=l!==void 0&&Df(l)?xh(e,(()=>{let e=yg(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&&!If(d)&&!zf(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=hg(n);return e.values[t.indexByPath.get(c.path)]=c.value,e})():Dg(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||!Eg(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:Bh(d),g=h===void 0?t.nodes[r.sourceIndex].parent:Th(e,r.leafPath,h),_=t.nodes[r.sourceIndex].parent,v=r.transition.reenter?Eh(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:Dh(e,yg(t,n),v),entryPaths:Oh(e,yg(t,f),v),choiceTransitions:u?.transitions??[]}},kg=(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:Bh(e.unresolvedTarget),resolvedTarget:e.target===void 0?void 0:Bh(e.target),updates:e.update===void 0?[]:[e.update.path]});if(i.length===1){let s=Og(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=Uh(e,Gh(e,i.filter(e=>!i.some(t=>t.sourceIndex!==e.sourceIndex&&Fp(t.sourcePath,e.sourcePath))).map(r=>Og(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=Dg(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?Ah(e,s.flatMap(e=>e.exitPaths)):[],entryPaths:f?jh(e,s.flatMap(e=>e.entryPaths)):[],changed:f}},Ag=(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 Hd({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=wm(e,yg(t,o),s).configuration,i=Wp(e,n);if(!n.outputs.has(i))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:r,next:vg(t,n),commands:c??Cg,emittedEvents:u??Cg,microsteps:d??Cg,done:!0,output:n.outputs.get(i)}}let m=t.nodes[n].path,h=hh(Yd(e).handlers[m]?.on?.[s._tag]);if(h!==void 0){let r=wg(e,h.transition,{...dg(e,a),state:o.values[n],containingState:void 0,ancestors:{},event:s,snapshot:xg(t,o)},h.evaluate),f=pf(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`);_g(o,n,wp(e,r,f.value))}if(Vh(m,{type:`event`,event:s._tag},h.targets,p),p!==void 0&&!If(p)&&!zf(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=If(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]?_g(o,n,wp(e,t.nodes[n],p.value)):g=Dg(e,t,o,p,n)}let _=h.reenter||!Eg(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:Bh(p),resolvedTarget:p===void 0?void 0:Bh(p),updates:f===void 0?[]:[f.path]}]}:void 0,commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents,exitPaths:_?[m]:Cg,entryPaths:_?[t.nodes[v].path]:Cg,changed:_};o=g,(d??=[]).push(gg(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??Cg,emittedEvents:u??Cg,microsteps:d??Cg,done:!1,output:void 0};f+=1,s=g}},jg=(e,t,n,r,i,a)=>{if(lh(r)){let i=ig(e,a===void 0?yg(t,n):jp(yg(t,n),a),r);return{event:i.event,next:vg(t,i.next),commands:i.commands,emittedEvents:i.emittedEvents,microsteps:i.microsteps.map(e=>({next:vg(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=yp(e,r);if(t.flat)return Ag(e,t,n,o,i,a);if(t.finalIndices.some(e=>n.active[e]===1)){let r=yg(t,n);if(_m(e,r)){let n=wm(e,r,o).configuration,i=Wp(e,n);if(!n.outputs.has(i))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:o,next:vg(t,n),commands:[],emittedEvents:[],microsteps:[],done:!0,output:n.outputs.get(i)}}}let s=Tg(e,t,n,o,a);if(s.length===0)return{event:o,next:n,commands:[],emittedEvents:[],microsteps:[],done:!1,output:void 0};let c=kg(e,t,n,o,s,i),l=c.next,u=o,d=[...c.commands],f=[...c.raisedEvents],p=[...c.emittedEvents],m=[gg(c,i)],h=0,g=0;for(;;){if(g+=1,g>1e3)throw new Hd({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=wm(e,yg(t,l),u).configuration;if(l=vg(t,n),_m(e,n)){let t=Wp(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=Tg(e,t,l,n,a);if(r.length===0)continue;let s=kg(e,t,l,n,r,i);l=s.next,d.push(...s.commands),f.push(...s.raisedEvents),p.push(...s.emittedEvents),m.push(gg(s,i))}},Mg=new WeakMap,Ng=e=>({fromConfiguration:e=>e,toConfiguration:e=>e,snapshot:t=>Yp(e,t),plan:(t,n,r,i)=>ig(e,i===void 0?t:jp(t,i),n)}),Pg=(e,t)=>({fromConfiguration:e=>vg(t,e),toConfiguration:e=>yg(t,e),snapshot:e=>xg(t,e),plan:(n,r,i=!1,a)=>jg(e,t,n,r,i,a),...Object.values(Yd(e).handlers).some(e=>e.initialize!==void 0&&!Vm(e.initialize))?{}:{initial:(n,r)=>{let i=e.input===void 0?n:n.length===0?(Sp(e,e.input,void 0),n):[Sp(e,e.input,n[0])],a=e.initial(...i),o=Df(a)?bh(e,{active:new Set,values:new Map,outputs:new Map,history:new Map,...r===void 0?{}:{machineReferences:r}},a,Qh).configuration:nm(e,a),s=wm(e,r===void 0?o:jp(o,r),Qh).configuration,c=vg(t,s),l=xg(t,c);if(!_m(e,s))return{state:l,configuration:c,activeConfiguration:s,initialEntryPaths:qp(e,s),done:!1,output:void 0};let u=Wp(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:qp(e,s),done:!0,output:s.outputs.get(u)}}}}),Fg=e=>{let t=Mg.get(e);if(t!==void 0)return t;let n=mg(e),r=n===void 0?Ng(e):Pg(e,n);return Mg.set(e,r),r},Ig=`Machine.invocation:`,Lg=e=>e.startsWith(Ig),Rg=(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,ps(t,Y)}},zg=e=>Gn(()=>{if(e.values!==void 0){let t=e.values;return e.values=void 0,fi(t)}let t=ui();return e.waiter=t,ys(t).pipe(X(zg(e)))}),Bg=(e,t)=>e._tag===`Started`&&(typeof t==`string`||e.descriptor!==void 0&&e.descriptor.id===t.id&&e.descriptor.machine===t.machine),Vg=(e,t,n)=>{if(e.closed)return qn();let r=e.children.get(t);return r!==void 0&&Bg(r,n)?br(r.ref):qn()},Hg=e=>{if(e.observers!==void 0)for(let t of e.observers)Rg(t,Vg(e,t.id,t.child))},Ug=(e,t,n)=>{let r=e.children.get(t);r!==void 0&&r.token===n&&(e.children.delete(t),typeof t==`string`&&Hg(e))},Wg=(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`&&Hg(e),!0},Gg=e=>la(function*(){let t=yield*Ts(),n=0,r=0,i=0,a=0;return{rootSessionId:e,stream:bs(t).pipe(di(K(()=>{n+=1})),ka(K(()=>{--n}))),isActive:()=>n>0,nextDeliveryId:()=>i++,nextMacrostepId:()=>a++,publishUnsafe:i=>{n!==0&&Jn(t,{...i,sequence:r++,rootSessionId:e})},close:sr(t)}}),Kg=e=>({id:e.id,sessionId:e.sessionId}),qg=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?Kg(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?Kg(t):{id:String(t.id)}}]:[]}return[]}),Jg=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:qg(Array.isArray(e.commands)?e.commands:[]),exitPaths:Array.isArray(e.exitPaths)?e.exitPaths:[],entryPaths:Array.isArray(e.entryPaths)?e.entryPaths:[],changed:e.changed===!0})),Yg=Symbol.for(`effect/Machine/activeSnapshotObserver`),Xg=Symbol.for(`effect/Machine/snapshotObserver`),Zg=e=>typeof e==`object`&&!!e&&Xg in e,Qg=Symbol.for(`effect/Machine/sendParentOverride`),$g=Symbol.for(`effect/Machine/acknowledgedSend`),e_=Symbol(`effect/Machine/AcknowledgedMessage`),t_=e=>typeof e==`object`&&!!e&&e_ in e,n_=e=>t_(e)?e.event:e,r_=(e,t)=>{e!==void 0&&t_(e)&&(e.deferred!==void 0&&ps(e.deferred,fi(t)),e.inspection?.complete(t))},i_=(e,t)=>{e!==void 0&&t_(e)&&e.deferred!==void 0&&ps(e.deferred,ho(t))},a_=e=>{e!==void 0&&t_(e)&&e.deferred!==void 0&&ps(e.deferred,Ko(new Gd))},o_=e=>typeof e==`object`&&!!e&&`send`in e&&typeof e.send==`function`,s_=(e,t,n,r)=>`inspectionSubject`in e&&`sendInspected`in e&&typeof e.sendInspected==`function`?e.sendInspected(t,n,r):e.send(t),c_=e=>e?._tag===`Childless`||e?.childless===!0,l_=(e,t)=>{let n=e.items??[];e.items=n,n.push(t)},u_=e=>{if(e.items===void 0)return qn();let t=e.items[e.index];return e.index+=1,e.index===e.items.length&&(e.items=void 0,e.index=0),br(t)},d_=e=>{if(e.items!==void 0)for(let t=e.index;t<e.items.length;t+=1)a_(e.items[t]);e.closed=!0,e.items=void 0,e.index=0},f_=()=>({items:void 0,index:0,closed:!1,receivers:new Set}),p_=(e,t,n)=>{if(e.closed)return!1;for(l_(e,t),n?.();e.items!==void 0&&e.receivers.size>0;){let t=e.receivers.values().next().value;e.receivers.delete(t),t(Y)}return!0},m_=e=>Gn(()=>{let t=u_(e);return Wa(t)?fi(t.value):e.closed?io:Oo(t=>(e.receivers.add(t),K(()=>{e.receivers.delete(t)}))).pipe(X(m_(e)))}),h_=e=>{d_(e);let t=Array.from(e.receivers);e.receivers.clear();for(let e of t)e(io)},g_=class extends Ii()(`effect/Machine/MachineRuntime`){},__=(e,t)=>Aa(e,g_,t),v_=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(tr);if(t!==void 0)return{_tag:`Failure`,error:t.error,cause:e.cause,snapshot:e};let n=e.cause.reasons.find(bi);return n===void 0?e.cause.reasons.find(gi)===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}}},y_=(e,t)=>Gn(()=>e(t)).pipe(ba,Qn),b_=(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)},x_=(e,t,n)=>({id:t,sessionId:n,kind:e.inspection?.kind??`Logic`}),S_=(e,t)=>t?{_tag:`Initialization`}:e!==void 0&&t_(e)&&e.inspection!==void 0?{_tag:`Macrostep`,macrostepId:e.inspection.macrostepId}:void 0,C_=(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=Jg(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{[e_]:!0,event:n,...a===void 0?void 0:{deferred:a},inspection:c}},w_=(e,t,n)=>{if(!t_(n)||n.inspection===void 0)return;let r=n.inspection;e.publishUnsafe({_tag:`EventSent`,subject:t,deliveryId:r.deliveryId,source:r.source,target:Kg(t),event:r.event,causedBy:r.causedBy})},T_=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:Y}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 Gn(()=>{if(this.registry.closed)return io;if(this.has(t.key)||this.registry.children.has(t.id))return Ko(new Wd({id:t.duplicateId}));let a=e(),o=this.registry.scope??=Ki(`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()?s_(this.self,e,t,n):Y,...this.sendAcknowledged===void 0?void 0:{[$g]:e=>i()?this.sendAcknowledged(e):io}},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,Wg(this.registry,t.id,n,e,t.descriptor)),onStopSync:()=>Ug(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?Fo(this.runtime.nextSessionId,e=>this.runtime.startCompiledSync(a,c,this.scopedServices??=ji(this.services,so,o),e)):this.runtime.start(a,c)).pipe(lo(e=>Ga(e)?Y:(Ug(this.registry,t.id,n),r===void 0?Y:r.stop)));return(u?d:ts(d,o)).pipe(Qn)})}stopAll(){return Gn(()=>{let e=[];for(let t of this.registry.children.values())t.ownerActive&&e.push(this.stopEntry(t));return e.length===0?Y:e.length===1?e[0]:nr(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]:nr(n,{concurrency:`unbounded`,discard:!0})}},E_=Rr(qn()).pipe(co(cs)),D_=e=>Y,O_=(e,t)=>{},k_=()=>void 0,A_=Symbol(`effect/Machine/EmissionsClosed`),j_=()=>{let e,t=Gn(()=>{let t=e;return t===A_?fi(void 0):t===void 0?Ts().pipe(Fo(t=>K(()=>{let n=e;return n===A_?[void 0,!0]:n===void 0?(e=t,[t,!1]):[n,!0]}).pipe(Fo(([e,n])=>n?sr(t).pipe(Di(e)):fi(e))))):fi(t)});return{emit:t=>Gn(()=>e===void 0||e===A_?Y:Ur(e,t).pipe(Qn)),close:()=>{let t=e;return e=A_,t===void 0||t===A_?Y:sr(t)},stream:Ka(t.pipe(ma(e=>e===void 0?Fa:bs(e))))}},M_={close:()=>Y,spawn:(()=>Jr(Error(`Childless machine logic cannot spawn a process`))),get:()=>fi(qn()),changes:()=>E_,sendTo:()=>Y,stop:()=>Y,owned:{spawn:()=>Jr(Error(`Childless machine logic cannot spawn an owned process`)),stopAll:()=>Y,stopPaths:()=>void 0}},N_=(e,t,n,r)=>{let i={closed:!1,children:new Map,observers:void 0,scope:void 0},a=e=>Gn(()=>{if(i.closed||(i.closed=!0,i.scope===void 0))return Y;let t=Oa(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?Y:Array.isArray(a)?nr(a,{concurrency:`unbounded`,discard:!0}):a}),o=(e,t)=>K(()=>Ug(i,e,t)),s=(e,t,n,r)=>K(()=>Wg(i,e,t,n,r)),c=e=>{let t=typeof e==`string`?e:e.id;return K(()=>{if(i.closed)return qn();let n=i.children.get(t);return n!==void 0&&Bg(n,e)?br(n.ref):qn()})},l=e=>{let t=typeof e==`string`?e:e.id;return ns(Mr((n,r)=>K(()=>({child:e,id:t,values:void 0,waiter:void 0})).pipe(Fo(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 Pa(r,a).pipe(X(K(()=>{!i.closed&&r.state._tag!==`Closed`&&(i.observers??=new Set,i.observers.add(n)),Rg(n,Vg(i,t,e))})),Di(zg(n)))}))))},u=(e,t,n,r)=>{let a=typeof e==`string`?e:e.id;return Gn(()=>{if(i.closed)return Y;let o=i.children.get(a);return o!==void 0&&Bg(o,e)?s_(o.ref,t,n,r):Y})},d=e=>{let t=typeof e==`string`?e:e.id;return Gn(()=>{if(i.closed)return Y;let n=i.children.get(t);return n!==void 0&&Bg(n,e)?n.ref.stop:Y})};function f(n,r){let a=typeof n==`object`&&n&&zm in n?n:void 0,c=a===void 0?n:a[zm](r?.input),l=a===void 0?r:{id:a.id,descriptor:a},u=Symbol(),d=l?.id??u,f;return Gn(()=>i.closed?io:typeof d==`string`&&(i.children.has(d)||Lg(d))?Ko(new Wd({id:d})):(i.scope??=Ki(`parallel`),i.children.set(d,{_tag:`Starting`,token:u}),t.start(c,{detached:!0,...l?.id===void 0?void 0:{id:l.id},...l?.onOutcome===void 0?void 0:{onOutcome:l.onOutcome},...l?.[Yg]===void 0?void 0:{onSnapshot:l[Yg]},...l?.[Qg]===void 0?void 0:{sendParent:l[Qg]},onReady:(e,t)=>K(()=>{f=e}).pipe(X(s(d,u,e,l?.descriptor)),Fo(e=>e?Y:t)),onStop:o(d,u),parent:e,runtime:t,origin:{_tag:`Spawn`,address:l?.id}}).pipe(lo(e=>Cn(e)?o(d,u).pipe(X(f===void 0?Y:f.stop)):Y),ts(i.scope))))}return{close:a,spawn:f,get:c,changes:l,sendTo:u,stop:d,owned:new T_(i,e,t,n,r)}},P_=(e,t,n,r)=>K(()=>N_(e,t,n,r)),F_=(e,t)=>`${e.length}:${e}${t}`,I_=(e,t)=>`${Ig}${F_(e,t)}`,L_=e=>({initial:()=>Y,run:()=>e}),R_=(e,t,n)=>({initial:()=>Y,run:({parent:r})=>{let i=r?.[$g];return i===void 0?Jr(Error(`Stream invocation requires an acknowledged parent machine`)):Bn(e,e=>i(oh(t,n,e)).pipe(Qn,dr(()=>io)))}}),z_=(e,t)=>typeof e==`function`?e(t):e,B_=e=>({spawn:((t,n)=>e.spawn(t,n)),sendTo:((t,n)=>e.sendTo(t,n)),stop:(t=>e.stopChild(t))}),V_=(e,t,n)=>{if(`effect`in e)return{id:String(e.id),sourceName:e.sourceName,src:()=>L_(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:()=>L_(ls(z_(e.after,t))),onDone:e.onDone,activityKind:`Timer`};if(`stream`in e){let r=String(e.id);return{id:r,sourceName:e.sourceName,src:()=>R_(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:()=>z_(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[zm](`input`in e?z_(e.input,t):void 0),onDone:e.onDone,onFailure:e.onFailure,onSnapshot:e.onSnapshot}}throw Error(`Unsupported captured machine invocation: ${String(e)}`)},H_=e=>e.length===0?Y:e.length===1?e[0]:nr(e,{discard:!0}),U_=(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(Mi(`StoppedError`,()=>Y)),W_=e=>e instanceof Hd||e instanceof Vd||e instanceof Gd,G_=(e,t,n,r,i,a,o,s,c,l,u,d)=>Gn(()=>{let f=F_(n,r),p=u===void 0?o:()=>{let t=o();return{...t,run:i=>cr(Gn(()=>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):Y,onOutcome:(t,i,o)=>X(Cr,Gn(()=>i._tag===`Stopped`||!t()?Y:i._tag===`Done`?s===void 0?e.failCause(or(Error(`Invocation "${r}" completed without the required onDone handler`))):U_(e,ah(n,r,i.output),u===void 0?void 0:o):i._tag===`Failure`&&c!==void 0&&(a===void 0||!W_(i.error))?U_(e,sh(n,r,i.error),u===void 0?void 0:o):e.failCause(i.cause))),...l===void 0?void 0:{onSnapshot:(t,i)=>t()?U_(e,ch(n,r,i)):Y}})}),K_=(e,t)=>Lg(e)?Ko(new Wd({id:t})):void 0,q_=(e,t,n,r)=>{let i=String(r.id),a=r.address===void 0?void 0:K_(String(r.address),i);return a===void 0?G_(e,t,n,i,r.address===void 0?I_(n,i):String(r.address),r.descriptor,r.src,r.onDone,r.onFailure,r.onSnapshot,r.activityKind,r.sourceName):a},J_=(e,t,n,r)=>{let i=r.child,a=K_(i.id,i.id);return a===void 0?G_(e,t,n,i.id,i.id,i,i[zm],r.onDone,r.onFailure,r.onSnapshot,void 0):a},Y_=(e,t,n,r,i,a)=>{let o=B_(t),s=jh(e,i).filter(e=>r.active.has(e)).flatMap(i=>{let s={...Mp(r)??{self:t.self,parent:t.parent},children:o,state:r.values.get(i),containingState:Kp(e,r,i),ancestors:Gp(e,r,i),event:a};return Xm(fm(e,i)?.invoke).map(e=>`child`in e&&!(`input`in e)?J_(t,n,i,e):q_(t,n,i,V_(e,s,i)))});return s.length===0?void 0:H_(s)},X_=Symbol(`effect/Machine/CompiledStoppedCompletion`),Z_=class{logic;options;services;id;sessionId;inspectionSubject;send;sendInspected(e,t,n){return this.offerEvent(e,t,n)}[$g](e){return this.sendAcknowledgedEffect(e)}[Xg](e){let t=this.snapshotObservers??=new Set;return t.add(e),()=>{t.delete(e)}}mailbox={items:void 0,index:0,closed:!1};address;childRuntime=M_;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=x_(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:Gn(()=>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 S_(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:Jg({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:Lr(e)})}get execution(){return this.logic.execution}initializeCompiledSync(){this.publishCreated(),this.execution.childless||(this.childRuntime=N_(this.address,this.options.runtime,this.services,e=>this.sendAcknowledgedEffect(e)));let e=this.options.parent,t=this.options.sendParent??(e===void 0?D_:this.inspector===void 0?e.send:t=>s_(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)=>o_(e)?this.inspector===void 0?e.send(t):s_(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?O_:(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(xr(e)),Ko(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 Q_(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?fi(this):(this.runState=`Draining`,Ia(this.drainRuntime(),this.services).pipe(Di(this)))}initialize(){let e=this;return la(function*(){e.publishCreated(),e.execution.childless||(e.childRuntime=yield*P_(e.address,e.options.runtime,e.services,t=>e.sendAcknowledgedEffect(t)));let t=e.options.parent,n=e.options.sendParent??(t===void 0?D_:e.inspector===void 0?t.send:n=>s_(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)=>o_(t)?e.inspector===void 0?t.send(n):s_(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?O_:(t,n=[])=>{e.initialEntryPaths=t,e.initialMicrosteps=n}};let r=t=>Cn(t)?e.childRuntime.close(t):Y,i=e.execution.initial,a=yield*(i===void 0?e.logic.initial(e.processScope).pipe(ma(e=>({state:e,done:void 0,output:void 0}))):i(e.processScope)).pipe(lo(t=>(Cn(t)&&e.publishStartFailed(t.cause),r(t))),vn(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:wo,poll:K(()=>Ar(u_(e.mailbox),n_)),receiveMessage:wo,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 Q_(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(Qn))),e.options.onSnapshot!==void 0&&(yield*y_(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 Gn(()=>this.lifecycle===`Completed`?this.resolveCompletion(this.completion):(this.waiter??=ui(),ys(this.waiter)))}get stop(){return Or(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(Qn);return this.runState===`Initializing`?e:e.pipe(X(io))}failCause(e){let t={_tag:`Failure`,cause:e};return this.requestTermination(t).pipe(Fo(e=>e?Bo(this.settleRequestedTermination()).pipe(Qn):Y))}sendAcknowledgedEffect(e){return Nr(t=>ss().pipe(Fo(n=>this.offerEvent(e,void 0,void 0,n).pipe(X(t(ys(n)))))))}offerEvent(e,t,n,r){return Gn(()=>{let i=this.inspector,a=this.inspectionSubject,o=i?.isActive()===!0&&a!==void 0?C_(i,a,e,t,n,r):r===void 0?e:{[e_]:!0,event:e,deferred:r};return this.offerMessage(o)})}offerMessage(e){return Or(Yn(t=>{if(this.mailbox.closed||this.lifecycle!==`Active`)return Ko(new Gd);let n=this.inspector,r=this.inspectionSubject;n!==void 0&&r!==void 0&&w_(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&&l_(this.mailbox,e),this.runState!==`Idle`)return Y;if(this.runState=`Draining`,o!==void 0){let n;try{n=o(a,e)}catch(e){n=Jr(e)}return n!==void 0||this.hasTerminationRequest()?this.startWorker(n):(this.runState=`Idle`,this.scheduleChangesFlush(t.currentDispatcher),Y)}return this.startWorker(void 0)}))}startWorker(e){let t=Ia(this.drainRuntime(e),this.services);return(this.options.detached===!0?Bo(t,{startImmediately:!0}):bo(t,{startImmediately:!0})).pipe(Fo(e=>K(()=>(e.pollUnsafe()===void 0&&(this.worker=e),this.interruptRequested?(this.interruptRequested=!1,!0):!1)).pipe(Fo(t=>t?Bo(this.interruptAndFinish(e)):Y))),Qn)}stopEffect(){return Gn(()=>this.lifecycle===`Completed`||this.finishIdleChildlessStop()?Y:this.requestTermination({_tag:`Stopped`}).pipe(Fo(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!==A_||this.current.terminalizing||this.current.snapshot.status!==`active`)return!1;this.emissionsPubSub=A_;let e={status:`stopped`,state:this.current.snapshot.state};return this.lifecycle=`TerminationRequested`,this.termination={_tag:`Stopped`},this.terminationSnapshot=e,d_(this.mailbox),this.current={revision:this.current.revision+1,terminalizing:!0,changes:void 0,snapshot:e},this.notifySnapshotObservers(),a_(this.inFlightMessage),this.inFlightMessage=void 0,this.interruptRequested=!1,this.compiledContext!==void 0&&(this.compiledContext.executionState=void 0),this.options.onStopSync?.(this),this.completion=X_,this.lifecycle=`Completed`,this.waiter!==void 0&&(ps(this.waiter,this.resolveCompletion(X_)),this.waiter=void 0),!0}settleRequestedTermination(){return Gn(()=>this.runState===`Draining`?this.worker===void 0?(this.interruptRequested=!0,this.awaitCompletion()):this.interruptAndFinish(this.worker).pipe(X(this.awaitCompletion())):this.finishRequestedTermination())}interruptAndFinish(e){return kn(e).pipe(X(Gn(()=>this.lifecycle===`Completed`?Y:this.finishRequestedTermination())))}awaitCompletion(){return this.lifecycle===`Completed`?Y:this.join.pipe(ba,Qn)}resolveCompletion(e){if(e!==X_)return e;let t=Ko(new Gd);return this.completion=t,t}drainRuntime(e){let t=this;return Nr(n=>la(function*(){let r=t.offerRevision,i=e;for(;;){if(t.hasTerminationRequest())return yield*t.finishRequestedTermination();let e=yield*n(Gn(()=>{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(ba);if(t.flushPendingChanges(),Cn(e))return t.lifecycle===`Active`&&(yield*t.requestTermination({_tag:`Failure`,cause:e.cause})),yield*t.finishRequestedTermination();if(Wa(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 Gn(()=>{if(this.lifecycle!==`TerminationRequested`)return Y;let e=this.termination;if(e===void 0)return Y;let t=this.terminationSnapshot??this.reserveTermination(e);if(t===void 0)return this.awaitCompletion();let n=e._tag===`Stopped`?jr:e._tag===`Done`?Er(e.output):Lr(e.cause),r=e._tag===`Stopped`?X_:e._tag===`Done`?fi(e.output):ho(e.cause),i=this.options.onOutcome===void 0||e._tag===`Stopped`&&this.options.skipStoppedOutcome===!0?Y:Gn(()=>this.options.onOutcome(v_(t))).pipe(ba,Qn),a=this.inspector,o=this.inspectionSubject,s=a===void 0||o===void 0?this.closeEmissions():this.closeEmissions().pipe(X(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`?Za():n}))));return Or(K(()=>{d_(this.mailbox)}).pipe(X(this.childRuntime.close(n)),X(this.setAndPublishSnapshot(t)),X(s),X(K(()=>{e._tag===`Failure`?i_(this.inFlightMessage,e.cause):a_(this.inFlightMessage),this.inFlightMessage=void 0})),X(i),X(this.options.onStop??Y),X(this.options.inspectionRoot===!0&&this.inspector!==void 0?this.inspector.close:Y),X(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&&(ps(this.waiter,this.resolveCompletion(r)),this.waiter=void 0)}))))})}publishSnapshot(e){let t=e.changes===void 0?fi(e):Ur(e.changes,[e]).pipe(Di(e)),n=e.snapshot;return this.options.onSnapshot===void 0||n.status!==`active`?t:t.pipe(zr(()=>y_(this.options.onSnapshot,n)))}completeChanges(e){return e.changes===void 0?Y:Ur(e.changes,Er(void 0)).pipe(Qn)}emitEvent(e){let t=this.externalEmissions===void 0?Gn(()=>this.emissionsPubSub===void 0||this.emissionsPubSub===A_?Y:Ur(this.emissionsPubSub,e).pipe(Qn)):this.externalEmissions.emit(e),n=this.inspector,r=this.inspectionSubject;return n===void 0||r===void 0?t:t.pipe(zr(()=>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=A_,e===void 0||e===A_?Y:sr(e)}getOrCreateEmissions(){return Gn(()=>{let e=this.emissionsPubSub;return e===A_?fi(void 0):e===void 0?Ts().pipe(Fo(e=>K(()=>{let t=this.emissionsPubSub;return t===A_?[void 0,!0]:t===void 0?(this.emissionsPubSub=e,[e,!1]):[t,!0]}).pipe(Fo(([t,n])=>n?sr(e).pipe(Di(t)):fi(t))))):fi(e)})}emissionsStream(){return Ka(this.getOrCreateEmissions().pipe(ma(e=>e===void 0?Fa:bs(e))))}setAndPublishSnapshot(e){return Gn(()=>{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(Fo(e=>this.completeChanges(e)),Qn)})}setActiveState(e){return Gn(()=>this.commitActiveState(e)??Y)}pollCompiledMessage(){let e=u_(this.mailbox);return Wa(e)&&(this.inFlightMessage=t_(e.value)?e.value:void 0),e}beginCompiledMessage(e){this.inFlightMessage=t_(e)?e:void 0}completeCompiledMessage(e){r_(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]:Jn(a.changes,[a]):(r.push(a),t?a.pendingChanges=r:Jn(a.changes,r))),this.notifySnapshotObservers(),this.options.onSnapshot===void 0?void 0:y_(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,Jn(e.changes,t))}updateState(e){return Gn(()=>{let t=this.current;return t.terminalizing||t.snapshot.status!==`active`?Y:e(t.snapshot.state).pipe(Fo(e=>{let n=this.current;return n.terminalizing||n.revision!==t.revision?Y:this.setActiveState(e)}))})}getOrCreateChanges(){return Gn(()=>{let e=this.current;return e.snapshot.status===`active`?e.changes===void 0?Ts({replay:1}).pipe(Fo(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(Fo(([t,n])=>n?sr(e).pipe(Di(t)):fi(t))))):fi(e.changes):fi(void 0)})}changesStream(){let e=this;return Ka(la(function*(){let t=yield*e.getOrCreateChanges();if(t===void 0)return Rr(e.current.snapshot);let n=yield*Sr(t),r=e.current;return r.snapshot.status===`active`?Rr(r.snapshot).pipe(co(ns(Dr($r(n))).pipe(qi(e=>e.revision>r.revision),ai(e=>e.snapshot)))):Rr(r.snapshot)}))}},Q_=class{scope;ownedChildren;process;executionState;constructor(e,t,n){this.scope=e,this.ownedChildren=t,this.process=n}poll(){return Ar(this.process.pollCompiledMessage(),n_)}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}},$_=Ha(function*(e,t){let n=t.sessionId??(yield*t.runtime.nextSessionId),r=yield*Hi(),i=e.execution,a=new Z_(e,t,r,n);return yield*(i.initialSync!==void 0&&t.onReady===void 0&&t.onSnapshot===void 0?a.initializeCompiledSync():a.initialize()).pipe(lo(e=>Cn(e)?a.shutdownEmissions().pipe(X(t.inspectionRoot===!0&&t.runtime.inspection!==void 0?t.runtime.inspection.close:Y)):Y))}),ev=(e,t,n,r)=>new Z_(e,t,n,r).initializeCompiledSync(),tv=Ha(function*(e,t){let{detached:n,id:r,onOutcome:i,onReady:a,onReadySync:o,onSnapshot:s,onStop:c,onStopSync:l,parent:u,runtime:d,sendParent:f}=t,p=t.sessionId??(yield*d.nextSessionId),m=r??p,h=d.inspection,g=h===void 0?void 0:x_(e,m,p),_=h===void 0||t.activity===void 0?void 0:{...t.activity,sessionId:p},v,y,b=f_(),x=t.emissions??j_(),S=yield*ss(),C=yield*ss(),w=ys(C).pipe(ba,Qn),T=!0,E,D=zn(S,{_tag:`Stopped`}).pipe(Qn),O=(e,t)=>Gn(()=>p_(b,e,t)?Y:Ko(new Gd)),k=h===void 0?void 0:(e,t,n,r)=>Gn(()=>{let i=h.isActive()?C_(h,g,e,t,n,r):r===void 0?e:{[e_]:!0,event:e,deferred:r};return O(i,()=>w_(h,g,i))}),A=e.execution?._tag===`Compiled`?e=>Nr(t=>ss().pipe(Fo(n=>(h===void 0?O({[e_]:!0,event:e,deferred:n}):k(e,void 0,void 0,n)).pipe(X(t(ys(n))))),ma(e=>e))):void 0,j={id:m,sessionId:p,stop:Gn(()=>T?D:D.pipe(X(wo))),send:h===void 0?e=>O(e):e=>k(e,void 0,void 0),...h===void 0?void 0:{inspectionSubject:g,sendInspected:k}},{changes:M,close:N,get:ee,owned:P,sendTo:F,spawn:I,stop:te}=M_;c_(e.execution)||({changes:M,close:N,get:ee,owned:P,sendTo:F,spawn:I,stop:te}=yield*P_(j,d,void 0,A===void 0?void 0:e=>A(e)));let ne=e=>Ga(e)?Y:(h!==void 0&&h.publishUnsafe(_===void 0?{_tag:`StartFailed`,subject:g,cause:e.cause}:{_tag:`ActivityStopped`,subject:_.owner,activity:_,exit:e}),N(e).pipe(X(x.close()),X(t.inspectionRoot===!0&&h!==void 0?h.close:Y))),L=l===void 0?c??Y:K(()=>l(De)),re=h===void 0?k_:()=>S_(E,T),ie=f??(u===void 0?D_:h===void 0?u.send:e=>s_(u,e,g,re())),ae=h===void 0?x.emit:e=>x.emit(e).pipe(zr(()=>K(()=>h.publishUnsafe({_tag:`Emitted`,subject:g,emission:e,causedBy:re()})))),oe={self:j,parent:u,spawn:I,sendParent:ie,emit:ae,sendTo:h===void 0?((e,t)=>o_(e)?e.send(t):F(e,t)):((e,t)=>o_(e)?s_(e,t,g,re()):F(e,t,g,re())),stopChild:te,failCause:e=>zn(S,{_tag:`Failure`,cause:e}).pipe(Qn),inspectInitial:h===void 0?O_:(e,t=[])=>{v=e,y=t}};h!==void 0&&h.publishUnsafe(_===void 0?{_tag:`Created`,subject:g,parent:u?.inspectionSubject,origin:t.origin??{_tag:`Root`},definition:e.inspection?.definition}:{_tag:`ActivityStarted`,subject:_.owner,activity:_});let R=yield*e.initial(oe).pipe(lo(ne),vn(K(()=>{T=!1}))),z=yield*uo({revision:0,terminalizing:!1,changes:void 0,snapshot:{status:`active`,state:R}});_===void 0&&h?.publishUnsafe({_tag:`Initialized`,subject:g,snapshot:{status:`active`,state:R},initialEntryPaths:v??[],microsteps:Jg({microsteps:y??[]})});let se=s===void 0?e=>e.changes===void 0?fi(e):Ur(e.changes,[e]).pipe(Di(e)):e=>{let t=e.changes===void 0?fi(e):Ur(e.changes,[e]).pipe(Di(e)),n=e.snapshot;return n.status===`active`?t.pipe(zr(()=>y_(s,n))):t},B=e=>e.changes===void 0?Y:Ur(e.changes,Er(void 0)).pipe(Qn),ce=e=>e.snapshot.status===`active`?fi(e):B(e).pipe(Di(e)),le=e=>Ho(z).pipe(Fo(t=>t.revision===e.revision?se(e).pipe(Fo(ce)):fi(void 0))),ue=e=>Ra(z,t=>t.terminalizing?fi([void 0,t]):ma(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(Fo(e=>e===void 0?fi(void 0):le(e)),ma(e=>e?.snapshot)),de=e=>jo(z,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(ma(e=>e?.snapshot)),fe=e=>Xi(z,t=>({revision:t.revision+1,snapshot:e,terminalizing:!0,changes:t.changes})).pipe(Fo(se),Fo(ce),Qn),pe=h===void 0?e=>ue(t=>fi(t.status===`active`?{status:`active`,state:e}:void 0)).pipe(Qn):t=>Ho(z).pipe(Fo(n=>ue(e=>fi(e.status===`active`?{status:`active`,state:t}:void 0)).pipe(zr(r=>K(()=>{e.inspection?.kind!==`Machine`&&r!==void 0&&h.publishUnsafe({_tag:`StateChanged`,subject:g,before:n.snapshot.state,after:t,causedByDeliveryId:E!==void 0&&t_(E)?E.inspection?.deliveryId:void 0})})))),Qn),me=(e,n,r)=>{let a=i===void 0||e.status===`stopped`&&t.skipStoppedOutcome===!0?Y:Gn(()=>i(v_(e))).pipe(ba,Qn),o=h===void 0?x.close():x.close().pipe(X(K(()=>h.publishUnsafe(_===void 0?{_tag:`Terminated`,subject:g,snapshot:e}:{_tag:`ActivityStopped`,subject:_.owner,activity:_,exit:e.status===`stopped`?Za():n}))));return Or(K(()=>h_(b)).pipe(X(N(n)),X(fe(e)),X(o),X(K(()=>{Cn(n)?i_(E,n.cause):a_(E),E=void 0})),X(a),X(L),X(t.inspectionRoot===!0&&h!==void 0?h.close:Y),X(r)))},he=de(e=>({status:`stopped`,state:e.state})),V=e=>de(t=>({status:`error`,state:t.state,cause:e})),ge=e=>de(t=>({status:`done`,state:t.state,output:e})),_e=e=>me(e,jr,ii(C,new Gd)),ve=(e,t)=>{let n=Lr(t);return me(e,n,Nn(C,t))},ye=(e,t)=>{let n=Er(t);return me(e,n,zn(C,t))},be=Or(D.pipe(X(w))),xe=e.execution?._tag===`Compiled`?{receiveMessage:m_(b).pipe(zr(e=>K(()=>{E=t_(e)?e:void 0}))),pollMessage:K(()=>u_(b)).pipe(zr(e=>K(()=>{Wa(e)&&(E=t_(e.value)?e.value:void 0)}))),completeMessage:e=>{r_(E,e),E=void 0}}:void 0,Se=h===void 0||e.execution?._tag===`Compiled`?m_(b).pipe(ma(n_)):m_(b).pipe(zr(e=>K(()=>{E=e})),ma(n_)),Ce=h===void 0||e.execution?._tag===`Compiled`?K(()=>u_(b)).pipe(ma(Ar(n_))):K(()=>u_(b)).pipe(zr(e=>K(()=>{Wa(e)&&(E=e.value)})),ma(Ar(n_))),we=h===void 0?e=>ue(t=>t.status===`active`?e(t.state).pipe(ma(e=>({status:`active`,state:e}))):fi(void 0)).pipe(Qn):t=>Ho(z).pipe(Fo(n=>ue(e=>e.status===`active`?t(e.state).pipe(ma(e=>({status:`active`,state:e}))):fi(void 0)).pipe(zr(t=>K(()=>{e.inspection?.kind!==`Machine`&&t?.status===`active`&&h.publishUnsafe({_tag:`StateChanged`,subject:g,before:n.snapshot.state,after:t.state,causedByDeliveryId:E!==void 0&&t_(E)?E.inspection?.deliveryId:void 0})})))),Qn),Te={...oe,...e.execution?._tag===`Compiled`&&!e.execution.childless?{ownedChildren:P}:void 0,...xe,receive:Se,poll:Ce,state:Ho(z).pipe(ma(e=>e.snapshot.state)),setState:pe,updateState:we},H=Ra(z,e=>e.snapshot.status===`active`?e.changes===void 0?Ts({replay:1}).pipe(ma(t=>[t,{...e,changes:t}])):fi([e.changes,e]):fi([void 0,e])),Ee=Ka(la(function*(){let e=yield*H;if(e===void 0)return Rr((yield*Ho(z)).snapshot);let t=yield*Sr(e),n=yield*Ho(z);return n.snapshot.status===`active`?Rr(n.snapshot).pipe(co(ns(Dr($r(t))).pipe(qi(e=>e.revision>n.revision),ai(e=>e.snapshot)))):Rr(n.snapshot)})),De={id:m,sessionId:p,...h===void 0?void 0:{inspectionSubject:g,sendInspected:k},state:Ho(z).pipe(ma(e=>e.snapshot.state)),snapshot:Ho(z).pipe(ma(e=>e.snapshot)),changes:Ee,emissions:x.stream,join:ys(C),stop:be,send:j.send,...A===void 0?void 0:{[$g]:A},child:ee,childChanges:M};o!==void 0&&!o(De)?yield*D:a!==void 0&&(yield*a(De,D)),s!==void 0&&(yield*y_(s,{status:`active`,state:R}));let U=e=>{switch(e._tag){case`Stopped`:return he;case`Done`:return ge(e.output);case`Failure`:return V(e.cause)}},Oe=(e,t)=>{switch(e._tag){case`Stopped`:return _e(t);case`Done`:return ye(t,e.output);case`Failure`:return ve(t,e.cause)}},ke=e=>n===!0?Bo(e,{startImmediately:!0}):bo(e,{startImmediately:!0}),Ae=yield*Un(S),je=Sn(Ae)?yield*Nr(t=>t(Gn(()=>e.run(Te))).pipe(ba,Fo(e=>zn(S,Cn(e)?{_tag:`Failure`,cause:e.cause}:{_tag:`Done`,output:e.value})))).pipe(ke):void 0;return yield*ke(Nr(e=>la(function*(){let t=Wa(Ae)?yield*Ae.value:yield*e(ys(S)),n=yield*U(t);return je!==void 0&&(yield*kn(je)),n===void 0?yield*w:yield*Oe(t,n)}))),De}),nv=((e,t)=>e.execution?._tag===`Compiled`?$_(e,t):tv(e,t)),rv=b_(nv,ev),iv=new WeakMap,av=e=>Gn(()=>{e.closed=!0;let t=Array.from(e.live).reverse();return e.live.clear(),ea(t,e=>e.stop,{discard:!0})}),ov=()=>{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},sv=e=>Fo(oi,t=>{let n=iv.get(t);if(n!==void 0)return e(n.hooks);let r=ov();return iv.set(t,r),X(Pa(t,av(r)),e(r.hooks))});Ha(function*(e,t,n){let r=yield*rv,i=n===void 0?{detached:!0,runtime:r}:{...n,detached:!0,runtime:r};return t===`generic`?yield*sv(t=>tv(e,{...i,...t})):t===`compiled`?e.execution?._tag===`Compiled`?yield*sv(t=>$_(e,{...i,...t})):yield*Jr(Error(`Machine cannot force the compiled runtime for generic process logic`)):yield*sv(t=>nv(e,{...i,...t}))});var cv=Ha(function*(e,t){let n=yield*rv;return yield*sv(r=>nv(e,t===void 0?{detached:!0,runtime:n,...r}:{...t,detached:!0,runtime:n,...r}))}),lv=Ha(function*(e,t,n){let r=yield*rv,i=yield*r.nextSessionId,a=yield*Gg(i);r.inspection=a;let o=j_(),s=yield*ss(),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*gr(sv(n=>{let r={...c,...n};return t===`generic`?tv(e,r):t===`compiled`?e.execution?._tag===`Compiled`?$_(e,r):Jr(Error(`Machine cannot force the compiled runtime for generic process logic`)):nv(e,r)}).pipe(lo(e=>ra(s,e))));return{id:n?.id??i,sessionId:i,changes:Ka(ys(s).pipe(ma(e=>e.changes))),emissions:o.stream,inspection:a.stream,start:l}}),uv=((e,t)=>lv(e,`auto`,t));q({_tag:is(`MachineSnapshot`),version:is(2),active:Ea(q({path:J,value:vr(Yi)})),completed:vr(Ea(q({path:J,output:vr(Yi)}))),history:vr(us(J,q({mode:Ss([`shallow`,`deep`]),active:Ea(J),values:us(J,Yi)})))});var dv=(e,t,n)=>{let r=$(e,n);if(r.type===`compound`){let r=pm(e,t,n);if(r===void 0)throw Error(`Machine expected completed state "${n}" to have an active child`);return dv(e,t,r)}return r.output},fv=(e,t)=>la(function*(){let n=yield*im(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)||!gm(e,n,a))throw Error(`Machine snapshot contains invalid completion "${a}"`);i.add(a);let o=dv(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*up(e,o,t.output,{boundary:`output`,state:a}))}return Yp(e,{...n,outputs:r})}).pipe(dr(t=>pv(e,t))),pv=(e,t)=>{if(ws(t))return ho(Ei(t,t=>t instanceof Vd?t:new Vd({machineId:e.id,boundary:`configuration`,cause:xr(t)})));let n=Qr(t);return Wa(n)&&n.value instanceof Vd?Ko(n.value):Ko(new Vd({machineId:e.id,boundary:`configuration`,cause:t}))},mv=e=>e.length===0?Y:e.length===1?e[0]:nr(e,{discard:!0}),hv=(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}),gv=new WeakMap,_v=e=>{let t=gv.get(e);if(t!==void 0)return t;let n=Object.values(Yd(e).handlers).some(e=>e.invoke!==void 0);return gv.set(e,n),n},vv=fi(qn()),yv=(e,t)=>{let n=Fg(e),r=new WeakMap,i=t=>{let n=r.get(t.scope);return n===void 0&&(n=og(e,t.scope),r.set(t.scope,n)),n},a=n=>{if(!t)return;let r=n.state();return $h(e,r)?eg(e,r,Qh).pipe(ma(br)):void 0},o=e=>Gn(()=>c(e)??vv),s=(e,t,r,a,s)=>{let c=a.commands.length===0?void 0:sg(a.commands,e.scope),l=a.emittedEvents.length===0?void 0:cg(a.emittedEvents,i(e)),u=()=>{let i=Gn(()=>(t&&e.completeMessage({before:r,plan:hv(a,n.snapshot),after:s}),a.done?fi(br(a.output)):o(e)));return l===void 0?i:l.pipe(X(i))},d=()=>{let t=e.commit(s),n=u(),r=t===void 0?n:t.pipe(X(n));return t===void 0&&l===void 0?r:e.runAfterChanges(r)};return c===void 0?d():e.runAfterChanges(c.pipe(X(Gn(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(Sn(e))return;r=e.value}let a=t_(r),c=a?r.event:r,l=t.state(),u;try{u=n.plan(t.executionState??n.fromConfiguration(nm(e,l)),c,a,t.scope)}catch(e){return qd(e)}if(t.executionState=u.next,u.microsteps.length===0){a&&t.completeMessage({before:l,plan:hv(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(X(Gn(()=>(a&&t.completeMessage({before:l,plan:hv(u,n.snapshot),after:d}),o(t))))));a&&t.completeMessage({before:l,plan:hv(u,n.snapshot),after:d})}};return{run:e=>__(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:__(r,e.scope)}}},bv=class{initialized=!1;initial;constructor(e){this.initial=e}},xv=(e,t)=>{let n=Fg(e);return r=>{let i=r.state();if(t&&$h(e,i))return eg(e,i,Qh).pipe(ma(br));let a=r.scope,o=r.executionState,s=o instanceof bv?o:new bv;r.executionState=s;let c,l,u;return u=Gn(()=>{let t=r.pollMessage();if(Sn(t))return l=void 0,fi(qn());let o=t.value,s=t_(o),d=s?o.event:o,f=i,p;try{p=n.plan(l??n.fromConfiguration(nm(e,i)),d,s,a)}catch(e){return qd(e)}if(l=p.next,p.microsteps.length===0)return s&&r.completeMessage({before:f,plan:hv(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(sg(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(cg(p.emittedEvents,c??=og(e,a))),p.done)b.push(r.ownedChildren.stopAll());else if(m)for(let[t,n]of g){let i=Y_(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=Gn(()=>(s&&r.completeMessage({before:f,plan:hv(p,n.snapshot),after:v}),p.done?fi(br(p.output)):u));return b.length===0?e:mv(b).pipe(X(e))},C=()=>{let e=x(),t=S(),n=e===void 0?t:e.pipe(X(t));return e===void 0&&b.length===0?n:r.runAfterChanges(n)};return y.length===0?C():r.runAfterChanges(mv(y).pipe(X(Gn(C))))}),__(Gn(()=>{if(s.initialized)return u;let t=s.initial,o=t?.activeConfiguration??nm(e,i);l=t?.configuration??n.fromConfiguration(o);let c=Y_(e,a,r.ownedChildren,o,t?.entryPaths??qp(e,o),Qh);return s.initial=void 0,s.initialized=!0,c===void 0?u:c.pipe(X(u))}),a)}},Sv=e=>e.done?{state:e.state,done:!0,output:e.output}:{state:e.state,done:!1,output:void 0},Cv=(e,t)=>{let n=_v(e),r=Fg(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=Sv(t);return n?{...r,executionState:new bv({configuration:t.configuration,activeConfiguration:t.activeConfiguration,entryPaths:t.initialEntryPaths})}:r}catch(e){throw Jd(e)}},s=t=>a===void 0?__(ag(ph(e,t),...i).pipe(Fo(n=>{t.inspectInitial(n.initialEntryPaths,n.microsteps);let r=n.commands.length===0?void 0:sg(n.commands,t),i=n.emittedEvents.length===0?void 0:cg(n.emittedEvents,og(e,t)),a=fi(Sv(n));return r===void 0?i===void 0?a:i.pipe(X(a)):i===void 0?r.pipe(X(a)):r.pipe(X(i),X(a))})),t):qa({try:()=>o(t),catch:Jd});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:xv(e,t._tag===`Resume`)}:{_tag:`Owned`,...yv(e,t._tag===`Resume`)}},initial:n=>t._tag===`Resume`?__(fv(e,t.snapshot),n):s(n).pipe(ma(e=>e.state)),run:t=>__(la(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*Jr(Error(`Machine statechart started without acknowledged mailbox access`));let c,l=yield*o;if($h(e,l))return yield*eg(e,l,Qh);if(!n){let n,o=qn(),u;for(;c===void 0;){let d=Wa(o)?o.value:yield*a;o=qn();let f=t_(d),p=f?d.event:d,m=l,h;try{h=ig(e,jp(n??nm(e,l),t),p)}catch(e){return yield*qd(e)}if(n=h.next,h.microsteps.length>0){let n=Yp(e,h.next);yield*sg(h.commands,t),yield*s(n),l=n,h.emittedEvents.length>0&&(yield*cg(h.emittedEvents,u??=og(e,t))),h.done&&(c={output:h.output})}f&&r({before:m,plan:hv(h,t=>Yp(e,t)),after:l}),c===void 0&&(o=yield*i,Sn(o)&&(n=void 0))}return c===void 0?yield*Jr(Error(`Machine process stopped receiving events before reaching a terminal configuration`)):c.output}let u=t.ownedChildren;if(u===void 0)return yield*Jr(Error(`Invoking statechart started without an owned child runtime`));let d=(n,r,i)=>Y_(e,t,u,n,r,i)??Y,f=e=>u.stopPaths(e)??Y;return yield*la(function*(){let n=yield*im(e,l);yield*d(n,qp(e,n),Qh),n=void 0;let o=qn(),p;for(;c===void 0;){let m=Wa(o)?o.value:yield*a;o=qn();let h=t_(m),g=h?m.event:m,_=l,v;try{v=ig(e,jp(n??nm(e,l),t),g)}catch(e){return yield*qd(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=Yp(e,v.next);if(yield*sg(v.commands,t),n&&(yield*f(r)),yield*s(a),l=a,v.emittedEvents.length>0&&(yield*cg(v.emittedEvents,p??=og(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:hv(v,t=>Yp(e,t)),after:l}),c===void 0&&(o=yield*i,Sn(o)&&(n=void 0))}return c===void 0?yield*Jr(Error(`Machine process stopped receiving events before reaching a terminal configuration`)):c.output}).pipe(lo(()=>u.stopAll()))}),t)}},wv=new WeakMap,Tv=(e,...t)=>{if(t.length>0)return Cv(e,{_tag:`Initial`,args:t});let n=wv.get(e);if(n!==void 0)return n;let r=Cv(e,{_tag:`Initial`,args:t});return wv.set(e,r),r},Ev=(e,t)=>Cv(e,{_tag:`Resume`,snapshot:t}),Dv=(e,...t)=>uv(Tv(e,...t),e.id===void 0?void 0:{id:e.id}),Ov=(e,t)=>cv(Ev(e,t),e.id===void 0?void 0:{id:e.id}),kv={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`]},Av=[`title`,`description`,`documentation`],jv=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Mv=(e,t)=>{let n=typeof t==`symbol`?`[${String(t)}]`:t===``?`<empty>`:String(t);return e===``?n:`${e}.${n}`},Nv=(e,t,n)=>{throw Error(`${e} invalid state definition at "${t}": ${n}`)},Pv=e=>Number.isFinite(Number(e)),Fv=e=>e.length===0||e.some(e=>e===`untagged`)?`untagged`:e.every(e=>e===`tagged`)?`tagged`:`opaque`,Iv=(e,t)=>{if(t.has(e))return`opaque`;if(mo(e)||bn(e)||Va(e)||$i(e)||zo(e)||Wi(e))return`tagged`;if(Xr(e))return typeof e.literal==`string`||typeof e.literal==`number`?`tagged`:`untagged`;let n=new Set(t).add(e);return yo(e)?Fv(e.types.map(e=>Iv(e,n))):Po(e)?Iv(e.thunk(),n):Pi(e)?`opaque`:`untagged`},Lv=(e,t=new Set)=>{if(t.has(e))return`opaque`;if(va(e)){let n=e.propertySignatures.find(({name:e})=>e===`_tag`)?.type;return n===void 0||Go(n)?`untagged`:Iv(n,new Set(t).add(e))}let n=new Set(t).add(e);return yo(e)?Fv(e.types.map(e=>Lv(e,n))):Po(e)?Lv(e.thunk(),n):Pi(e)?`opaque`:`untagged`},Rv=e=>Ci(e)&&Lv(ca(e.ast))!==`untagged`,zv=(e,t,n)=>{let r=Mv(t,n);return typeof n==`symbol`?Nv(e,r,`state keys must be strings, not symbols`):typeof n==`number`?Nv(e,r,`state keys cannot use numeric forms`):n===``?Nv(e,r,`state keys cannot be empty`):n===`__proto__`?Nv(e,r,`the state key "__proto__" is not allowed`):n.includes(`.`)?Nv(e,r,`state keys cannot contain "."`):Pv(n)?Nv(e,r,`state keys cannot use numeric forms`):r},Bv=(e,t,n,r)=>{(typeof n!=`object`||!n||Array.isArray(n))&&Nv(e,t,`${r} must be a plain record`);let i=Object.getPrototypeOf(n);i!==Object.prototype&&i!==null&&Nv(e,Mv(t===`<root>`?``:t,`__proto__`),`${r} must not declare an implicit "__proto__" state key`)},Vv=(e,t,n,r,i)=>{if(typeof n!=`object`||!n||Array.isArray(n)||!jv(n,r))return;let a=n[r];(typeof a!=`object`||!a||Ci(a)||a.type!==`history`)&&Nv(e,`${t}.${r}`,i)},Hv=(e,t,n,r)=>{let i=kv[r];for(let a of Reflect.ownKeys(n))i.includes(a)||Nv(e,t,`${r} states cannot declare property "${String(a)}"`)},Uv=(e,t,n)=>{Bv(e,`${t}.annotations`,n,`schema-less state annotations`);for(let r of Reflect.ownKeys(n))Av.includes(r)||Nv(e,`${t}.annotations`,`schema-less state annotations cannot declare property "${String(r)}"`),typeof n[r]!=`string`&&Nv(e,`${t}.annotations.${String(r)}`,`schema-less state annotation values must be strings`)},Wv=(e,t,n,r,i=!1)=>{Bv(e,n===``?`<root>`:n,t,`state trees`);for(let a of Reflect.ownKeys(t)){let o=i&&a===``?``:zv(e,n,a),s=t[a];if(Ci(s)){Rv(s)||Nv(e,o,`state schemas must decode to an object with a required PropertyKey _tag`);continue}Bv(e,o,s,`state nodes`);let c=s.type,l=c===`history`?`history`:c===`choice`?`choice`:c===`parallel`?`parallel`:c===`final`?`final`:jv(s,`states`)?`compound`:`atomic`;if(Hv(e,o,s,l),l===`history`||l===`choice`){r||Nv(e,o,`${l} states must be declared below an active parent state`),jv(s,`annotations`)&&Uv(e,o,s.annotations),l===`history`&&jv(s,`history`)&&s.history!==`shallow`&&s.history!==`deep`&&Nv(e,`${o}.history`,`history must be "shallow" or "deep"`);continue}let u=jv(s,`schema`);u&&!Rv(s.schema)&&Nv(e,`${o}.schema`,`state schemas must decode to an object with a required PropertyKey _tag`),u&&jv(s,`annotations`)&&Nv(e,`${o}.annotations`,`schema-backed states must declare annotations on their schema`),!u&&jv(s,`annotations`)&&Uv(e,o,s.annotations),l===`atomic`&&jv(s,`type`)&&s.type!==`active`&&Nv(e,`${o}.type`,`atomic state type must be "active"`),l===`final`&&s.type!==`final`&&Nv(e,`${o}.type`,`final state type must be "final"`),l===`compound`&&jv(s,`type`)&&s.type!==`active`&&Nv(e,`${o}.type`,`compound state type must be "active"`),l===`parallel`&&s.type!==`parallel`&&Nv(e,`${o}.type`,`parallel state type must be "parallel"`),(l===`final`||l===`parallel`)&&jv(s,`output`)&&!Ci(s.output)&&Nv(e,`${o}.output`,`state output must be an Effect Schema`),l===`compound`?(Vv(e,o,s.states,`initial`,`active and choice child states cannot use the reserved target selector key "initial"`),u&&Vv(e,o,s.states,`with`,`schema-backed compound child states cannot use the reserved local target selector key "with"`),Wv(e,s.states,o,!0)):l===`parallel`&&(jv(s,`states`)||Nv(e,`${o}.states`,`parallel states must declare child regions`),Vv(e,o,s.states,`initial`,`active and choice child states cannot use the reserved target selector key "initial"`),Wv(e,s.states,o,!0))}},Gv=e=>typeof e==`object`&&e?Object.freeze({...e}):e,Kv=e=>{let t={};for(let n of Object.keys(e)){let r=e[n];if(Ci(r)){Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!1,writable:!1});continue}let i=r,a={...i};`states`in i&&(a.states=Kv(i.states)),`annotations`in i&&(a.annotations=Gv(i.annotations)),Object.defineProperty(t,n,{value:Object.freeze(a),enumerable:!0,configurable:!1,writable:!1})}return Object.freeze(t)},qv=e=>Kv(e),Jv=(e,t=``)=>{if(Ci(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(jv(n,`fields`)&&(jv(n,`schema`)&&Nv(`Machine.state`,t,`declare fields or schema, not both`),Bv(`Machine.state`,t,n.fields,`state fields`),jv(n.fields,`_tag`)&&Nv(`Machine.state`,t,`state fields cannot declare _tag`),r.schema=eo(t,n.fields),delete r.fields),jv(n,`states`)){Bv(`Machine.state`,t,n.states,`child states`);let e=Object.create(null);for(let r of Reflect.ownKeys(n.states))zv(`Machine.state`,t,r),e[r]=Jv(n.states[r],r);r.states=e}return t===``?(Wv(`Machine.state`,{"":r},``,!1,!0),qv({"":r})[``]):r},Yv=`~effect/Machine`,Xv=`~effect/Machine/ChildMachine`,Zv={...hi,...ya,[Yv]:Yv,toJSON(){return{_id:`Machine`}}},Qv=(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,ip(e,n),n},$v=e=>e.kind===`none`?uf:lf(e.kind,e.path,e.scope,e.updatePath),ey=e=>Object.freeze({path:e.path,kind:e.kind,scope:e.scope}),ty=e=>e.updatePath===void 0?e.kind===`update`&&e.path!==void 0?[e.path]:[]:[e.updatePath],ny=(e,t,n,r,i)=>{if(typeof e!=`object`||!e||!Zn(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(!df(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`||!Fp(r,e.path)||!Fp(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}},ry=(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(!pf(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(!hf(e)||e.update.path!==t.updatePath)throw Error(`Machine target updating "${t.updatePath}" must return target construction .update(...)`)}else if(hf(e))throw Error(`Machine combined target requires an updating owner declaration`);if(e===void 0)return;let r=hf(e)?e.target:e,i=typeof r==`object`&&r&&Zn(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&&Fp(i,t.path)))throw Error(`Machine transition resolver selected "${t.path}" but constructed "${i??`<invalid>`}"`)},iy=(e,t,n,r,i)=>{let a={...t,root:i===``?t.state:t.ancestors[``],decline:Sf};delete a.target;let o=e.resolve(a,n);if(Cf(o)){if(e.declinable!==!0)throw Error(`Machine transition for state "${i}" returned decline without declaring declinable: true`);return o}return ry(o,e.selection,r),o},ay=e=>e.kind===`update`?void 0:e.path,oy=e=>{let t=Number(e);return Number.isInteger(t)&&t>=0&&t<4294967295&&String(t)===e},sy=(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||oy(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||!Zn(i,`target`))throw Error(`Machine transition branch "${r}" requires a target selection`);let{target:a,title:o}=i;if(!df(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:$v(a)})}))},cy=(e,t,n,r={},i)=>{let a=Tm(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 mf(Of(i.path,i.parent),Om(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`?wf(n.path,n.parent):Of(n.path,n.parent)}if(e.kind===`update`)return Om(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 mf(Dm(t,e.path,r,i),Om(t,e.updatePath,n))}return Dm(t,e.path,a,i)},ly=(e,t,n,r,i)=>Object.freeze(Object.fromEntries(e.map((e,a)=>[e.key,o=>gf(t,a,e.key,e.selection.kind===`none`?yf():cy(e.selection,n,r,o,i))]))),uy=(e,t,n)=>{if(t.kind===`none`){if(!bf(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`);ry(e,t,n)}},dy=(e,t)=>({...e,root:t===``?e.state:e.ancestors[``]}),fy=(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:ny({target:()=>Fm(t,i)},void 0,r,n,e).selection}]));return{branches:()=>a,reenter:i.reenter,declinable:f,resolve:(e,t)=>d&&!o(e)?Sf():s(e,t)}}let p=Fm(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 Sf();if(s!==void 0)return s(e,a);if(h)return cy(p,r,t,{input:g(e)});let l=u(e);return cy(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)}}},py=(e,t,n,r,i)=>{let a=fy(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(Zn(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=sy(e.branches(),n,i),u=Object.freeze({}),d=(e,o)=>{let s={...e,root:n===``?e.state:e.ancestors[``],decline:Sf};delete s.target,s.select=ly(l,u,t,r,n);let d=a(s,o);if(Cf(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(!_f(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 uy(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=>ay(e.selection)===void 0?[]:[e.selection.path]))],branches:l.map(e=>Object.freeze({type:`branch`,key:e.key,title:e.title,target:ay(e.selection),selection:ey(e.selection),updates:ty(e.selection)})),evaluate:d,transition:(e,t)=>d(e,t).result}}let l=ny(a,void 0,t,n,i),u=(e,r)=>({result:iy(l,e,r,t,n),branchIndex:0,branchKey:void 0});return{reenter:s,declinable:c,targets:ay(l.selection)===void 0?[]:[l.selection.path],branches:[{type:`direct`,target:ay(l.selection),selection:ey(l.selection),updates:ty(l.selection)}],evaluate:u,transition:(e,t)=>u(e,t).result}},my=(e,t,n,r)=>{let i=Object.create(null);for(let a of Reflect.ownKeys(e))i[a]=py(e[a],t,n,r,a);return i},hy=(e,t,n,r)=>{let i=(Array.isArray(e)?e:[e]).map(e=>{let i=Im(r,e,n,e=>dy(e,n));for(let e of[`onElement`,`onDone`,`onFailure`,`onSnapshot`])i[e]!==void 0&&(i[e]=py(i[e],t,n,r,e));return qm(i,n)});return Ym(i,n),Array.isArray(e)?Object.freeze(i):i[0]},gy=(e,t,n,r,i,a)=>{for(let o of Object.keys(a)){let s=r===``?o:`${r}.${o}`;if(!Zn(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=my(d,t,s,i)),u.always!==void 0&&(u.always=py(u.always,t,s,i,`always`)),u.onDone!==void 0&&(u.onDone=py(u.onDone,t,s,i,`done`)),u.choice!==void 0&&(u.choice=py(u.choice,t,s,i,`choice`)),u.invoke!==void 0&&(u.invoke=hy(u.invoke,t,s,i)),t.byPath.get(s)?.type===`choice`&&(typeof u.choice!=`object`||u.choice===null||!Zn(u.choice,`transition`)||typeof u.choice.transition!=`function`||!Zn(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=Af(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`);gy(e,t,r.states,s,i,l)}}},_y=e=>e===``?jm:e,vy=e=>{let t=!1;for(let n of e.stateNodes.byPath.values())if(n.type===`choice`){t=!0;break}if(!t)return;let n=Pf(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(!Fp(o,n)){let r=i.type===`branch`?`branch "${i.key}"`:`transition`;throw Error(`Machine transition from "${_y(e.source)}" updates "${_y(n)}" before choice "${t}", whose ${r} targets "${_y(o)}" outside that owner`)}}}}}}},yy=(e,t)=>(n=>{let r=Km(t.root,n),i=Object.assign(Object.create(Zv),e);if(ip(e,i),i.states=Object.freeze({"":r.node}),i.stateNodes=jf(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:Wm(n.root);i.initial=e=>({...Ef(``,a({input:e})),input:{value:e}}),i.initialDefinition=Object.freeze({target:``,selection:Object.freeze({path:``,kind:`initial`,scope:`initial`})});let o=Object.create(null);gy(o,i.stateNodes,i.states,``,{...t,initialize:e=>i.initial(i.input===void 0?void 0:Sp(i,i.input,e))},{"":r.handlers});let s=Qv(i,o);return vy(s),s}),by=e=>{let t=Jv(e),n=xy();return Object.freeze({...n,"~effect/Machine/State":`~effect/Machine/State`,node:t})},xy=()=>({path:(e=>e),get:((e,t)=>Bf(e,t).pipe(Ar(e=>e.value))),getWithParents:((e,t)=>{let n={};return Bf(e,t,n).pipe(Ar(e=>({value:e.value,parents:n})))}),getSnapshot:Bf,matches:((e,t)=>Wa(Bf(e,t)))}),Sy=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(ya);return n.states=t,n.root=e.root,n.events=e.events,n.internalEvents=e.internalEvents??lp(`internal`,[]),n.emittedEvents=e.emittedEvents??lp(`emitted`,[]),n.parent=e.parent,n.input=e.input,n.id=e.id,n.handlers=Object.create(null),n.handle=yy(n,Nm(e.root,e)),rp(n),n},Cy=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?[]:[En(e)]},wy=e=>lp(`public`,Cy(e)),Ty=(e,t)=>Ey(e,t,e=>t.input===void 0?Tv(t):Tv(t,e)),Ey=(e,t,n)=>({[Xv]:Xv,id:e,machine:t,[zm]:n}),Dy=Dv,Oy=Ov,ky=(e,t)=>{try{let n=tg(e,...t);return{machine:e,snapshot:n.done?{status:`done`,state:n.state,output:n.output}:{status:`active`,state:n.state}}}catch{return}},Ay=(e,t)=>{try{let n=hs(fv(e,t));if(n._tag===`Failure`)return;let r=n.value;if(!$h(e,r))return{machine:e,snapshot:{status:`active`,state:r}};let i=hs(eg(e,r,Qh));return i._tag===`Success`?{machine:e,snapshot:{status:`done`,state:r,output:i.value}}:void 0}catch{return}},jy={spawn:()=>Jr(Error(`Child operations are unavailable in a planned snapshot`)),sendTo:()=>Ko(new Gd),stop:()=>Y},My=(e,t)=>{if(e.snapshot.status!==`active`)return qn();try{let n=e.machine,r=nm(n,e.snapshot.state);for(let e of qp(n,r)){let i=fm(n,e);for(let a of Xm(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({...Mp(r)??mh(n,r),children:jy,state:r.values.get(e),containingState:Kp(n,r,e),ancestors:Gp(n,r,e),event:Qh}):a.input);let s=ky(i,i.input===void 0?[]:[o]);return s===void 0?void 0:br(s)}}return qn()}catch{return}},Ny=class extends Do(`ChildNotActiveError`){},Py=new WeakMap,Fy=new WeakMap,Iy=e=>typeof e==`object`&&!!e&&Fy.has(e),Ly=e=>{if(typeof WeakRef>`u`||typeof FinalizationRegistry>`u`)return _s(e);let t=ei(),n=new FinalizationRegistry(({entry:e,key:n})=>{let r=Es(t,n);Wa(r)&&r.value===e&&An(t,n)});return r=>{let i=Es(t,r);if(Wa(i)){let e=i.value.ref.deref();if(e!==void 0)return e}let a=e(r),o={ref:new WeakRef(a)};return Si(t,r,o),n.register(a,{key:r,entry:o}),a}},Ry=(e,t)=>Fn(xi(t,e=>e.stop).pipe(zr(t=>K(()=>e.setSelf(Xn(t)))),Fo(()=>wo))),zy=(e,t)=>Ry(e,e.result(t).pipe(Fo(e=>e.start))),By=(e,t,n)=>Ry(e,Oy(t,n)),Vy=(e,t)=>`~effect-atom/atom/Atom/ServerValue`in e?e[$o](t):t(e),Hy=(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}},Uy=e=>{let t;return()=>(t===void 0&&(t={value:e()}),t.value)},Wy=e=>e.snapshot,Gy=ci(e=>e.registry).pipe(ni),Ky=e=>Gn(()=>{let t=e.pending.shift();return t===void 0?(e.draining=!1,Y):X(t,Ky(e))}),qy=(e,t)=>{let n=e.get(t);return n===void 0&&(n={pending:[],draining:!1},e.set(t,n)),n},Jy=(e,t,n)=>Tr(n=>{let r=wi(n(e),()=>void 0),i=t.get(n.registry);return i===void 0||!i.draining?r:Ir(Ar(n.self(),mr),()=>Cs(!0))},(r,i)=>{let a=r.get(e),o=r.get(Gy),s=qy(t,o);vi(a)||s.draining?(r.setSelf(Cs(!0)),s.pending.push(kr(o,e).pipe(Fo(e=>n(e,i)),ba,ma(e=>{let t=yr(e);r.setSelf(s.pending.length===0?t:mr(t))}))),s.draining||(s.draining=!0,rs(Ky(s)))):Dn(a)?r.setSelf(wi(a,()=>void 0)):Ji(n(a.value,i),{onExit:e=>r.setSelf(yr(e))})}).pipe(Ua),Yy=e=>ci(t=>{let n=t(e);return vi(n)?Cs(n.waiting):Dn(n)?ar(n.cause,{previous:t.self(),waiting:n.waiting}):n.value.status===`error`?ar(n.value.cause,{previous:t.self(),waiting:n.waiting}):Xn(n.value.state,{waiting:n.waiting})}).pipe(Fr(Ti),xn(Hy(t=>[Vy(e,t)],e=>wi(e,e=>e.state)))),Xy=e=>ci(t=>{let n=t(e);if(vi(n))return Cs(n.waiting);if(Dn(n))return ar(n.cause,{previous:t.self(),waiting:n.waiting});if(Sn(n.value)){let e=t.self();return Wa(e)&&Dn(e.value)?e.value:Xn(qn(),{waiting:n.waiting})}return n.value.value.status===`error`?ar(n.value.value.cause,{previous:t.self(),waiting:n.waiting}):Xn(br(n.value.value.state),{waiting:n.waiting})}).pipe(Fr(Ti),xn(Hy(t=>[Vy(e,t)],e=>wi(e,Ar(e=>e.state))))),Zy=(e,t)=>ci(n=>{let r=n(e);if(vi(r))return Cs(r.waiting);if(Dn(r))return ar(r.cause,{previous:n.self(),waiting:r.waiting});if(Sn(r.value))return Xn(qn());let i=r.value.value,a=aa(i.child(t)),o=Ji(Cr.pipe(X(i.childChanges(t).pipe(Bn(e=>K(()=>n.setSelf(Xn(e))))))));return n.addFinalizer(o),Xn(a)}).pipe(Ua),Qy=(e,t)=>Zg(e)?e[Xg](()=>t(aa(e.snapshot))):Ji(e.changes.pipe(Bn(e=>K(()=>t(e))))),$y=(e,t,n)=>{let r=ci(t=>{let n=t(e);if(vi(n))return Cs(n.waiting);if(Dn(n))return ar(n.cause,{previous:t.self(),waiting:n.waiting});if(Sn(n.value))return Xn(qn());let r=n.value.value;return t.addFinalizer(Qy(r,e=>t.setSelf(Xn(br(e))))),Xn(br(aa(r.snapshot)))}).pipe(xn(Hy(()=>[],()=>{let e=n();return e===void 0?Cs(!0):Xn(Ar(e,Wy),{waiting:!0})}))),i=new WeakMap,a=e=>Wa(e)?fi(e.value):Ko(new Ny({id:t.id})),o=Jy(e,i,(e,t)=>Fo(a(e),e=>e.send(t))),s=Jy(e,i,(e,t)=>Fo(a(e),e=>e.stop)),c=eb(e,n);return{ref:e,snapshot:r,result:Xy(r),send:o,stop:s,child:c}},eb=(e,t)=>{let n=new WeakMap;return r=>{let i=n.get(r.machine);if(i===void 0){let a=r.machine,o=_s(n=>{let r=Ty(n,a);return $y(Zy(e,r),r,Uy(()=>{let e=t();return e===void 0||Sn(e)?e:My(e.value,r)}))});i=e=>o(e),n.set(a,i)}return i(r.id)}},tb=(e,t,n)=>{let r=Ua(e),i=ci(e=>{let t=e(r);if(vi(t))return Cs(t.waiting);if(Dn(t))return ar(t.cause,{previous:e.self(),waiting:t.waiting});let n=t.value;e.addFinalizer(Qy(n,t=>e.setSelf(Xn(t,{waiting:t.status===`active`}))));let i=aa(n.snapshot);return Xn(i,{waiting:i.status===`active`})}).pipe(xn(Hy(()=>[],()=>{let e=n();return e===void 0?Cs(!0):Xn(Wy(e),{waiting:!0})}))),a=new WeakMap,o=Jy(r,a,(e,t)=>e.send(t)),s=Jy(r,a,(e,t)=>e.stop),c=eb(as(r,br),()=>{let e=n();return e===void 0?void 0:br(e)}),l={ref:r,snapshot:i,result:Yy(i),send:o,stop:s,child:c};return Fy.set(l,t),l},nb=(e,t)=>Bf(e,t).pipe(Ar(e=>e.value)),rb=(e,t)=>Bf(e,t),ib=(e,t)=>as(e,t).pipe(Fr(Ti),xn(Hy(t=>[Vy(e,t)],e=>wi(e,t)))),ab=new WeakMap,ob=(e,t,n,r)=>{let i=ab.get(e);i===void 0&&(i=new Map,ab.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},sb=(e,t)=>ob(e,`select`,t,()=>ib(e.result,e=>nb(e,t))),cb=(e,t)=>ob(e,`selectSnapshot`,t,()=>ib(e.result,e=>rb(e,t))),lb=(e,t)=>ob(e,`selectChild`,t,()=>ib(e.result,li(e=>nb(e,t)))),ub=(e,t)=>ob(e,`selectSnapshotChild`,t,()=>ib(e.result,li(e=>rb(e,t)))),db=(e,t)=>ob(e,`matches`,t,()=>ib(e.result,e=>Wa(Bf(e,t)))),fb=(e,t)=>ob(e,`matchesChild`,t,()=>ib(e.result,Mn(e=>Wa(Bf(e,t))))),pb=(e,t,n)=>{let r=e.atom(()=>Dy(t,...n)),i=tb(e.atom(e=>zy(e,r)),t,Uy(()=>ky(t,n)));return Py.set(i,r),i},mb=(e,t,n)=>tb(e.atom(e=>By(e,t,n)),t,Uy(()=>Ay(t,n))),hb=(e,t,n)=>{let r={owner:e,source:t},i=Ln(t,e=>e(r.source),{initialValueTarget:t}).pipe(Fr((e,t)=>r.source.equals(e,t)),xn(e=>Vy(r.source,e)));return n!==void 0&&(i=i.pipe(Ya(n))),i},gb=(e,t)=>{let n=Ly(t=>({bridge:e(t)})),r={};for(let e of Object.keys(t.atoms)){let i=t.atoms[e];r[e]=Ly(r=>{let a=n(r);return hb(a,i(a.bridge),t.label?.(r,e))})}return r},_b=e=>{let t=((t,...n)=>pb(e,t,n));return{make:t,factory:(e=>(...n)=>t(e,...n)),resume:((t,n)=>mb(e,t,n)),family:((t,n)=>gb(n=>pb(e,t,[n]),n))}},vb=Iy;Kr(2,sb);var yb=Kr(2,cb);Kr(2,lb);var bb=Kr(2,ub);Kr(2,db),Kr(2,fb);var xb=_b;function Sb(e){let t=(0,qs.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=Xt(`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 Cb(e){let t=(0,qs.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-10 items-center gap-3 border-b px-1`,children:[e.media===!0&&(0,Q.jsx)(Sb,{className:`size-5`}),(0,Q.jsx)(Sb,{className:`h-4 w-1/3`})]},t),t[3]=e.media,t[4]=n),r=So(Na(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 wb=Z.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return v(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});jt(`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 Tb(e){let t=(0,qs.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=Xt(`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 Eb(e){let t=(0,qs.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(Ob)).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(Db)}),t[7]=r,t[8]=a),o=a}let s=o;if(!s)return null;let c;t[9]===r?c=t[10]:(c=Xt(`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 Db(e,t){return e?.message&&(0,Q.jsx)(`li`,{children:e.message},t)}function Ob(e){return[e?.message,e]}var kb=new Uint8Array(512),Ab=new Uint8Array(256);for(let e=0,t=1;e<255;e++)kb[e]=t,Ab[t]=e,t<<=1,256&t&&(t^=285);for(let e=255;e<512;e++)kb[e]=kb[e-255];var jb=(e,t)=>e>0&&t>0?kb[Ab[e]+Ab[t]]:0,Mb=(e,t)=>kb[t*Ab[e]%255],Nb=e=>{let t=new Uint8Array(e+2),n=new Uint8Array(e+1);n[0]=1;for(let r=0;r<e;r++){let e=Mb(2,r);t.fill(0,0,r+2);for(let i=0;i<r+1;i++)t[i]^=n[i],t[i+1]^=jb(n[i],e);for(let e=0;e<r+2;e++)n[e]=t[e]}return n},Pb=(e,t)=>{let n=Nb(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]^=jb(n[i],e)}return r.subarray(e.byteLength)},Fb=[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],Ib=[[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]],Lb=[[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]],Rb=[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],zb=[[],[],[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]],Bb=(e,t,n)=>{let r=Fb[t]-Ib[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},Vb=(e,t)=>{for(let n=1;n<=40;n++){let r=Fb[n]-Ib[n][t];if(r-=n>9?3:2,r>=e.byteLength)return n}throw RangeError(`Bytes exceed max length`)},Hb=(e,t,n)=>{let r=e.byteLength+Ib[t][n],i=Lb[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=Pb(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},Ub=(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)},Wb=(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}},Gb=(e,t,n)=>{let r=n-7;Wb(e,n,0,0,7),Wb(e,n,r,0,7),Wb(e,n,0,r,7),Ub(t,n,0,0,8),Ub(t,n,r-1,0,8),Ub(t,n,0,r-1,8)},Kb=(e,t,n,r)=>{let i=zb[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];Wb(e,n,a,r,5),Ub(t,n,a,r,5)}}},qb=(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)}},Jb=(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},Yb=(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}},Xb=(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}},Zb=(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)}},Qb=(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)}},$b=(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)}},ex=(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)}},tx=(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)}}},nx=(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)}},rx=(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)}},ix=(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)}},ax=(e,t,n,r)=>{switch(r){case 0:return Zb(e,t,n);case 1:return Qb(e,t,n);case 2:return $b(e,t,n);case 3:return ex(e,t,n);case 4:return tx(e,t,n);case 5:return nx(e,t,n);case 6:return rx(e,t,n);case 7:return ix(e,t,n)}},ox=(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},sx=(e,t,n)=>{let r=0,i=0,a=new Uint8Array(e.byteLength);for(let o=0;o<=7;o+=1){a.set(e),ax(a,t,n,o);let s=ox(a,n);(o===0||s<r)&&(r=s,i=o)}return ax(e,t,n,i),i},cx=(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)},lx=(e,t,n,r)=>{let i=cx(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},ux=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},dx=(e,t,n)=>{if(n>=7){let r=ux(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}}},fx=(e,t)=>{let n=Vb(e,t),r=Hb(Bb(e,n,t),n,t),i=Rb[n],a=new Uint8Array(i*i),o=new Uint8Array(i*i);return Gb(a,o,i),Kb(a,o,i,n),qb(a,o,i),Jb(o,i),Yb(o,i,n),Xb(a,o,i,r),lx(a,i,t,sx(a,o,i)),dx(a,i,n),a},px=new TextEncoder,mx=(e,t=1)=>fx(typeof e==`string`?px.encode(e):e,t);function hx(e){let t=Gs.unstable_scheduleCallback(4,e);return()=>Gs.unstable_cancelCallback(t)}var gx=Z.createContext(Br({scheduleTask:hx,defaultIdleTTL:400})),_x=new WeakMap,vx=0,yx=new Set;function bx(e){vx++;try{return e()}finally{vx--}}function xx(e){if(vx===0)return e();yx.size===0&&queueMicrotask(Sx),yx.add(e)}function Sx(){for(let e of yx)yx.delete(e),e()}function Cx(e,t){let n=_x.get(e);n===void 0&&(n=new WeakMap,_x.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,()=>xx(n));return()=>{i--,yx.delete(n),r()}},snapshot(){return bx(()=>e.get(t))},getServerSnapshot(){return(i===0||a===void 0)&&(a={value:bx(()=>ds(t,e))}),a.value}};return n.set(t,o),o}function wx(e,t){let n=Cx(e,t);return Z.useEffect(Sx),Z.useSyncExternalStore(n.subscribe,n.snapshot,n.getServerSnapshot)}function Tx(e,t,n){let r=Cx(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(Sx),Z.useSyncExternalStore(r.subscribe,()=>i(r.snapshot()),()=>i(r.getServerSnapshot()))}var Ex=(e,t)=>{let n=Z.useContext(gx);return t?Tx(n,e,t):wx(n,e)};function Dx(e,t,n){return n?.mode===`promise`||n?.mode===`promiseExit`?Z.useCallback(r=>{e.set(t,r);let i=xs(kr(e,t,{suspendOnWaiting:!0}));return n.mode===`promise`?i.then(Ox):i},[e,t,n.mode]):Z.useCallback(n=>{e.set(t,typeof n==`function`?n(e.get(t)):n)},[e,t])}var Ox=e=>{if(Ga(e))return e.value;throw hr(e.cause)},kx=(e,t)=>{let n=Z.useContext(gx);return[wx(n,e),Dx(n,e,t)]};function Ax({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=Z.useRef(e!==void 0),[a,o]=Z.useState(()=>t);return[i&&e!==void 0?e:a,Z.useCallback(e=>{i||o(e)},[])]}function jx(e){let t=Z.useRef(!0);t.current&&(t.current=!1,e())}function Mx(e,t,n,r,i,a,o,s,c,l=2){let u=He(n.current,{event:e,orientation:r,loopFocus:i,rtl:a,cols:l,disabledIndices:o,minIndex:s,maxIndex:c,prevIndex:t>c?s:t,stopEvent:!0});return Mt(n.current,u)?void 0:u}function Nx(e){return e==null?tn:e.type.startsWith(`key`)?pt:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?Qe:tn}var Px=Z.createContext(void 0),Fx=Z.createContext(void 0),Ix=Z.createContext(void 0),Lx=Z.createContext(!1),Rx=Z.createContext(``);function zx(){let e=Z.useContext(Px);if(!e)throw Error(B(22));return e}function Bx(){let e=Z.useContext(Fx);if(!e)throw Error(B(23));return e}function Vx(){let e=Z.useContext(Ix);if(!e)throw Error(B(24));return e}function Hx(){return Z.useContext(Rx)}function Ux(){return Z.useContext(Lx)}function Wx(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var Gx=(e,t)=>Object.is(e,t);function Kx(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function qx(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!Wx(e,t,(e,t)=>Kx(e,t,n)):e!==t}function Jx(e,t,n){return e?e.some(e=>e!==void 0&&Kx(t,e,n)):!1}function Yx(e,t,n){return e?e.findIndex(e=>e!==void 0&&Kx(e,t,n)):-1}function Xx(e,t){if(t!==Gx)return n=>Jx(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function Zx(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(Xx(t,n)):Yx(e,t,n);return i===-1?null:i}function Qx(e,t,n,r,i,a){return Jx(r,t,i)?a!=null&&e>a&&Jx(r,n[a],i)?a:e:e===a?Zx(n,r,i,!0):a}function $x(e,t,n){return e.filter(e=>!Kx(t,e,n))}function eS(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function tS(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function nS(e){return tS(e?.[0])}function rS(e){return nS(e)?e.flatMap(e=>e.items):e}function iS(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(nS(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function aS(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return eS(e)}function oS(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?eS(e.value):eS(e)}var sS={id:e=>e.id,labelId:e=>e.labelId,items:e=>e.items,selectedValue:e=>e.selectedValue,hasSelectionChips:e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0},hasSelectedValue:e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0},hasNullItemLabel:(e,t)=>t?iS(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMounted:e=>e.forceMounted,inline:e=>e.inline,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>Kx(t,e,n)):Kx(t,r,n)},transitionStatus:e=>e.transitionStatus,popupProps:e=>e.popupProps,listProps:e=>e.listProps,inputProps:e=>e.inputProps,triggerProps:e=>e.triggerProps,itemRoot:e=>e.itemRoot,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupId:e=>e.popupId,triggerElement:e=>e.triggerElement,inputElement:e=>e.inputElement,inputGroupElement:e=>e.inputGroupElement,popupSide:e=>e.popupSide,openMethod:e=>e.openMethod,inputInsidePopup:e=>e.inputInsidePopup,inputOwnsFormValue:e=>e.inputOwnsFormValue,selectionMode:e=>e.selectionMode,name:e=>e.name,form:e=>e.form,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,grid:e=>e.grid,virtualized:e=>e.virtualized,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,modal:e=>e.modal,autoHighlight:e=>e.autoHighlight},cS=`data-valid`,lS=`data-invalid`,uS={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},dS={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},fS={disabled:!1,...dS},pS={valid(e){return e===null?null:e?{[cS]:``}:{[lS]:``}}},mS={invalid:void 0,name:void 0,validityData:{state:uS,errors:[],error:``,value:``,initialValue:null},setValidityData:w,disabled:void 0,setTouched:w,setDirty:w,setFilled:w,setFocused:w,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:fS,registerFieldControl:w,validation:{getValidationProps:(e,t=Ee)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:w,getInputControl:()=>null,commit:async()=>{},change:w}},hS=Z.createContext(mS);function gS(e=!0){let t=Z.useContext(hS);if(t.setValidityData===w&&!e)throw Error(B(28));return t}function _S(e,t,n,r,i=!0,a){let{registerFieldControl:o}=gS(),s=F(()=>Symbol());V(()=>{let c=s.current;i?o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}):o(c,void 0)},[e,i,r,t,a,o,s,n]),V(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var vS=Z.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:w,validationMode:`onSubmit`,submitCountRef:{current:0}});function yS(){return Z.useContext(vS)}function bS(e){return b(e,`base-ui`)}var xS=Z.createContext({controlId:void 0,registerControlId:w,resetControlId:w,labelId:void 0,setLabelId:w,messageIds:[],setMessageIds:w,getDescriptionProps:e=>e});function SS(){return Z.useContext(xS)}function CS(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=SS(),o=bS(),s=F(()=>Symbol()),c=Z.useRef(!1),l=Z.useRef(!1),u=D(()=>{c.current&&i!==w&&(c.current=!1,i(s.current,void 0))});return V(()=>{if(!n||i===w){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}e===void 0?u():(c.current=!0,i(s.current,e))},[t,n,i,a,o,s,u]),V(()=>u,[u]),(n?r:void 0)??t??o}function wS(e){return e==null?void 0:`${e}-popup`}function TS(e,t){return(n,r)=>n!=null&&e.contains(n,r,t)}function ES(e){return Array.isArray(e)?e.map(e=>ES(e)).join(`,`):e==null?``:String(e)}var DS=new Map;function OS(e={}){let{locale:t,...n}=e,r={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...n},i=`${ES(t)}|${JSON.stringify(r)}`,a=DS.get(i);if(a)return a;let o=new Intl.Collator(t,r),s={contains(e,t,n){if(!t)return!0;let r=aS(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(o.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=aS(e,n);return o.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=aS(e,n),i=t.length;return r.length>=i&&o.compare(r.slice(r.length-i),t)===0}};return DS.set(i,s),s}var kS=OS;function AS(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 jS(e,t){let n=Z.useRef(e),r=D(t);V(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function MS(e,t){let{onClick:n,onPointerDown:r}=AS(D((n,r)=>{(typeof e==`function`?e():e)||t(r||(st?`touch`:``))}));return Z.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function NS(e){let[t,n]=Z.useState(null),r=MS(e,n);return jS(e,t=>{t&&!e&&n(null)}),Z.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}var PS=Symbol(`none`),FS={value:PS,index:-1};function IS(e,t,n){let r=e.get(t);if(r!==void 0||n===Gx)return r;for(let[r,i]of e)if(Kx(r,t,n))return i}function LS(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:a,defaultInputValue:o,inputValue:s,open:c,defaultOpen:l=!1,selectionMode:u,onItemHighlighted:d,name:f,form:p,disabled:h=!1,readOnly:g=!1,required:_=!1,inputRef:v,grid:y=!1,items:b,filteredItems:S,filter:T,filterQuery:E,openOnInputClick:O=!0,autoHighlight:k=!1,keepHighlight:A=!1,highlightItemOnHover:M=!0,loopFocus:N=!0,itemToStringLabel:ee,itemToStringValue:P,isItemEqualToValue:I=Gx,virtualized:te=!1,inline:re=!1,fillInputOnItemPress:ie=!0,modal:oe=!1,limit:R=-1,autoComplete:z=`list`,formAutoComplete:se,locale:ce,submitOnItemClick:le=!1}=e,{clearErrors:de}=yS(),{setDirty:fe,validityData:pe,setFilled:me,name:he,disabled:ge,setTouched:_e,setFocused:ve,validationMode:ye,validation:be}=gS(),xe=$u(),Se=CS({id:t}),Ce=kS({locale:ce}),we=Array.isArray(b)?null:b;if(we&&typeof we.label!=`function`)throw Error(B(100));let Te=we?we.data:b,De=we?.value,U=De?void 0:Te,ke=Z.useMemo(()=>{if(!S||!De)return;let e=rS(S),t=e.map(De),n;return{values:t,findItem(r,i){if(!n){n=new Map;for(let r=0;r<t.length;r+=1)n.has(t[r])||n.set(t[r],e[r])}return IS(n,r,i)}}},[S,De]),je=Z.useMemo(()=>we?e=>we.label(e,I,e=>{let t=ke?.findItem(e,I);return t==null?aS(e,ee):we.itemLabel(t)}):ee,[we,ee,ke,I]),Me=Z.useMemo(()=>we?Object.assign(e=>we.itemLabel(e),{selected:e=>aS(e,je)}):ee,[we,je,ee]);function Ne(e){return aS(e,je)}let[Pe,Fe]=Z.useState(!1),[Ie,Le]=Z.useState(null),Re=Z.useRef(Ie),ze=Z.useRef([]),Be=Z.useRef([]),Ve=Z.useRef(null),He=Z.useRef(null),Ue=Z.useRef(null),We=Z.useRef(null),Ge=Z.useRef(null),Ke=Z.useRef(!1),qe=Z.useRef(null),Je=Z.useRef(null),Ye=Z.useRef(null),Xe=Z.useRef(FS),Ze=Z.useRef(null),Qe=Z.useRef([]),$e=Z.useRef(null),et=ge||h,tt=he??f,nt=u===`multiple`,rt=u===`single`,at=s!==void 0||o!==void 0,ot=Te!==void 0,st=S!==void 0,ct;ct=k===`always`?`always`:k?`input-change`:!1;let[lt,dt]=Ax({controlled:i,default:nt?r??an:r,name:`Combobox`,state:`selectedValue`}),ft=Z.useMemo(()=>T===null?()=>!0:T===void 0?TS(Ce,Me):T,[T,Ce,Me]),pt=F(()=>at?o??``:rt?Ne(lt):``).current,[mt,gt]=Ax({controlled:s,default:pt,name:`Combobox`,state:`inputValue`}),[_t,yt]=Ax({controlled:c,default:l,name:`Combobox`,state:`open`}),bt=nS(Te),xt=!_t&&Ie!==null?Ie:String(mt).trim(),St=rt?Ne(lt):``,Ct=rt&&!Pe&&xt!==``&&St.length===xt.length&&Ce.contains(St,xt),wt=Ct?``:E??xt,Tt=ot&&st&&Ct&&(!we||we.hasValue(lt,I)),Et=Z.useMemo(()=>Te?rS(Te):an,[Te]),Ot=Z.useMemo(()=>{if(S&&!Tt)return S;if(!Te)return an;if(bt){let e=Te,t=[],n=0;for(let r of e){if(R>-1&&n>=R)break;let e=R>-1?R-n:1/0,i=wt===``?r.items.slice(0,e):[];if(wt!==``)for(let t of r.items){if(i.length>=e)break;ft(t,wt,Me)&&i.push(t)}if(i.length>0){let e={...r,items:i};t.push(e),n+=i.length}}return t}if(wt===``)return R>-1?Et.slice(0,R):Et;let e=[];for(let t of Et){if(R>-1&&e.length>=R)break;ft(t,wt,Me)&&e.push(t)}return e},[S,Tt,Te,bt,wt,R,ft,Me,Et]),kt=Z.useMemo(()=>{if(ke&&Ot===S)return ke.values;let e=rS(Ot);return De?e.map(e=>De(e)):e},[Ot,S,ke,De]),W=F(()=>{let e=null;return re&&_t&&ot&&u!==`none`&&(e=Zx(kt,lt,I,nt)),new vt({id:Se,labelId:void 0,selectedValue:lt,open:_t,items:U,selectionMode:u,name:tt,form:p,disabled:et,readOnly:g,required:_,grid:y,virtualized:te,openOnInputClick:O,itemToStringLabel:je,isItemEqualToValue:I,modal:oe,autoHighlight:ct,submitOnItemClick:le,hasInputValue:at,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:re,activeIndex:null,selectedIndex:e,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemRoot:{props:Ee,id:Se,selectionMode:u,disabled:et,readOnly:g,isItemEqualToValue:I},positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:u===`none`},{onOpenChangeComplete:w,setOpen:w,setInputValue:w,setSelectedValue:w,setIndices:w,handleSelection:w,forceMount:w,requestSubmit:w,listRef:ze,labelsRef:Be,popupRef:Ve,emptyRef:Ge,inputRef:He,startDismissRef:Ue,endDismissRef:We,chipsContainerRef:qe,clearRef:Je,valuesRef:Qe,pointerDownItemRef:$e,selectionEventRef:Ye},sS)}).current,At=u===`none`?mt:lt,jt=Z.useMemo(()=>u===`none`?At:Array.isArray(lt)?lt.map(e=>oS(e,P)):oS(lt,P),[At,P,u,lt]),Mt=D(d),Nt=D(n),Pt=W.useState(`activeIndex`),Ft=W.useState(`selectedIndex`),Lt=W.useState(`positionerElement`),Rt=W.useState(`listElement`),zt=W.useState(`triggerElement`),Bt=W.useState(`inputElement`),Vt=W.useState(`inputGroupElement`),Ht=W.useState(`inline`),Ut=W.useState(`inputInsidePopup`),Wt=W.useState(`inputOwnsFormValue`),Gt=rt&&!Ut&&mt===St,Kt=lc(zt),{openMethod:qt,triggerProps:Jt}=NS(_t),Yt=D(()=>jt);_S(Ut?Kt:He,Se,At,Yt,!et,f);let Xt=D(()=>{Te?Be.current=kt.map(Ne):W.set(`forceMounted`,!0)}),Zt=D((e,t,n,r)=>{if(t===-1){if(Xe.current===FS)return;Xe.current=FS}else Xe.current={value:e,index:t};Mt(e,C(n,r,{index:t}))}),Qt=D(e=>{let t={};e.activeIndex!==void 0&&(t.activeIndex=e.activeIndex),e.selectedIndex!==void 0&&(t.selectedIndex=e.selectedIndex),W.update(t);let n=e.activeIndex;if(n===void 0)return;let r=e.type||`none`;n===null?Zt(void 0,-1,r,e.event):Zt(Qe.current[n],n,r,e.event)}),$t=D((t,n)=>{if(e.onInputValueChange?.(t,n),!n.isCanceled){if(Ke.current=n.reason===It,n.reason===`input-change`){_t&&Ie!==null&&Le(null);let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&Fe(!0),Ze.current={hasQuery:e};let n=W.state.listElement;if(!W.state.virtualized&&n){let e=Ve.current;for(let t of Oe(n.firstElementChild??n)){if(!ne(t)||(e?!G(e,t):t.getAttribute(`role`)===`dialog`))break;if(cc(t)){t.scrollTop=0;break}}}e&&ct&&W.state.activeIndex==null&&(_t||Ht)&&W.set(`activeIndex`,0)}}else n.reason===`input-clear`&&t===``&&W.state.inputInsidePopup&&(Ze.current={hasQuery:!1,selection:!0});gt(t)}}),en=D(e=>{let t=!e&&Ut&&!Ht&&mt!==``&&(String(mt).trim()===Ie||mt===St);!e&&(t||mt===``||Gt)&&Fe(!1),Le(null),t&&$t(``,H(It))}),[nn,rn]=Z.useState(!1),on=D((t,n)=>{if(_t===t)return;n.reason===`escape-key`&&ot&&kt.length===0&&!Ge.current&&n.allowPropagation();let r=n,i=el(r);if(e.onOpenChange?.(t,r),Ze.current?.hasQuery&&n.reason===`input-change`===n.isCanceled&&(Ze.current=null),!n.isCanceled&&(t&&Ie!==null&&en(n.reason===ut),!t&&Pe&&(rt?(Ht||Le(xt),xt===``&&Fe(!1)):nt&&(Ht||Le(xt),Ut&&Qt({activeIndex:null}),(!Ut||Ht)&&$t(``,H(It,n.event,void 0,{isItemPress:n.reason===ht})))),t||rn(i()),yt(t),!t&&Ut&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(_e(!0),ve(!1),ye===`onBlur`))){let e=u===`none`?mt:lt;be.commit(e)}}),sn=D((e,t)=>{a?.(e,t),!t.isCanceled&&(dt(e),(u===`none`&&Ve.current&&ie||rt&&!W.state.inputInsidePopup)&&$t(Ne(e),H(t.reason,t.event)))}),cn=D((e,t)=>{let n=L(e),r=Ye.current??e;Ye.current=null;let i=H(ht,r),a=ae(n,`a`)?.getAttribute(`href`);if(a)a.startsWith(`#`)&&on(!1,i);else if(nt){let e=Array.isArray(lt)?lt:[],n=Jx(e,t,I),r=n?$x(e,t,I):[...e,t];if(sn(r,i),i.isCanceled||!(He.current&&He.current.value.trim()!==``))return;if(W.state.inputInsidePopup){$t(``,H(It,i.event,void 0,{isItemPress:!0}));let e=Ze.current;e&&!n&&(e.toggledValue=t)}else on(!1,i)}else{if(sn(t,i),i.isCanceled)return;on(!1,i)}}),ln=D(()=>{let e=be.inputRef.current?.form??W.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),un=D(()=>{if(Nt?.(!1),Fe(!1),Le(null),Qt(u===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),nt&&He.current&&He.current.value!==``&&!Ke.current&&$t(``,H(It)),rt){if(W.state.inputInsidePopup)He.current&&He.current.value!==``&&$t(``,H(It));else{let e=Ne(lt);He.current&&He.current.value!==e&&$t(e,H(e===``?It:tn))}}}),dn=Z.useMemo(()=>Ht&&Lt?{current:ae(Lt,`[role="dialog"]`)}:Ve,[Ht,Lt]),{mounted:fn,transitionStatus:pn,forceUnmount:mn}=Jc({open:_t,ref:dn,preventUnmountOnClose:nn,setPreventUnmountOnClose:rn,onUnmount:un});Z.useImperativeHandle(e.actionsRef,()=>({unmount:mn,close:()=>on(!1,H(it))}),[mn,on]),V(function(){let e=Re.current!==null&&Ie===null;if(Re.current=Ie,_t&&(!e||!ot)||(_t||($e.current=null),u===`none`))return;let t=ot?kt:Qe.current;Qt({selectedIndex:Zx(t,lt,I,nt)})},[_t,Ie,lt,u,nt,ot,kt,I,Qt]),V(()=>{Te&&(Qe.current=kt,ze.current.length=kt.length)},[Te,kt]),V(()=>{!_t&&Ze.current?.hasQuery&&(Ze.current=null)},[_t]),V(()=>{if(!_t&&Ht&&dn.current){Ze.current=null;return}let e=ot||st?kt:Qe.current,t=Ze.current;if(t){let n=_t||Ht||W.state.positionerElement?.hidden===!1;if(t.hasQuery){let t=He.current;!ct||String(mt).trim()===``||Ht&&ct!==`always`&&(!t||j(t.ownerDocument)!==t)?Ze.current=null:n&&(e[0]!==void 0||!ot&&!st)&&(W.set(`activeIndex`,0),Ze.current=null)}else if(String(mt).trim()===``&&(Ze.current=null,n)){let e=t.selection;ct===`always`&&!e&&W.state.selectionMode===`none`&&W.set(`activeIndex`,0),queueMicrotask(()=>{if(!W.state.open&&(!W.state.inline||dn.current)||He.current&&He.current.value.trim()!==``)return;let n=W.state.selectedValue,r=W.state.selectionMode===`multiple`;if(r&&Array.isArray(n)?n.length>0:W.state.selectionMode!==`none`&&n!=null){let e=ot||st?kt:Qe.current,i=Yx(e,t.toggledValue,W.state.isItemEqualToValue);W.set(`activeIndex`,i===-1?Zx(e,n,W.state.isItemEqualToValue,r):i)}else e?W.set(`activeIndex`,null):ct===`always`&&W.set(`activeIndex`,0)})}}if(!_t&&!Ht)return;let n=W.state.activeIndex;if(n==null){if(ct===`always`&&e.length>0){W.set(`activeIndex`,0);return}Zt(void 0,-1,tn);return}if(n>=e.length){Zt(void 0,-1,tn),W.set(`activeIndex`,null);return}let r=e[n],i=Xe.current.value,a=i!==PS&&Kx(r,i,W.state.isItemEqualToValue);Xe.current.index===n&&a||Zt(r,n,tn)},[Pt,ct,Zt,st,ot,kt,Ht,_t,dn,W,mt]),V(()=>{me(u===`none`?String(mt)!==``:nt?Array.isArray(lt)&&lt.length>0:lt!=null)},[me,u,mt,lt,nt]),Z.useEffect(()=>{ot&&ct&&kt.length===0&&Qt({activeIndex:null})},[ot,ct,kt.length,Qt]);function hn(){_t&&xt!==``&&xt!==String(pt)&&!Gt&&Fe(!0)}function gn(){_t&&Ie!==null&&en(!1)}let _n=!1;function vn(){!_n&&mt!==St&&(_n=!0,$t(St,H(tn)))}function yn(){u!==`none`&&(de(tt),fe(qx(lt,pe.initialValue,I)),be.change(lt),rt&&!at&&!Ut&&vn())}function bn(){rt&&!at&&!Ut&&!Pe&&vn()}function xn(){u===`none`&&(de(tt),fe(mt!==pe.initialValue),be.change(mt))}jS(xt,hn),jS(_t,gn),jS(lt,yn),jS(St,bn),jS(Te,bn),jS(mt,xn);let Sn=gl({open:Ht?!0:_t,onOpenChange:on,elements:{reference:Ut?zt:Bt,floating:Lt}}),Cn=y?`grid`:`listbox`,wn=_t||Ht,Tn=wn?`true`:`false`,En=Z.useMemo(()=>{let e=Bt?.tagName===`INPUT`,t=Bt==null||e,n=t||wn,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=Tn,r[`aria-haspopup`]=Cn,r[`aria-controls`]=wn?Rt?.id:void 0,r[`aria-autocomplete`]=g?`none`:z),{reference:r,floating:{role:`presentation`}}},[Bt,wn,Tn,Cn,Rt?.id,z,g]),Dn=Hc(Sn,{enabled:!et&&O,event:`mousedown-only`,toggle:!1,touchOpenDelay:Ut?0:100,reason:Dt}),On=Gc(Sn,{enabled:!et&&!Ht,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:Ht?!0:void 0,outsidePress(e){let t=L(e);return!G(zt,t)&&!G(Je.current,t)&&!G(qe.current,t)&&!G(Vt,t)}}),kn=Rl(Sn,{enabled:!et,id:Se,listRef:ze,activeIndex:Pt,selectedIndex:Ft,virtual:!0,loopFocus:N,allowEscape:N&&!ct,focusItemOnOpen:Pe||u===`none`&&!ct?!1:`auto`,focusItemOnHover:M,resetOnPointerLeave:!A,orientation:y?`horizontal`:void 0,rtl:xe===`rtl`,disabledIndices:an,grid:y?Mx:void 0,onNavigate(e,t){(t||_t||Ht&&e===null)&&pn!==`ending`&&Qt({activeIndex:e,type:Nx(t),event:t?.nativeEvent})}}),An=Z.useMemo(()=>ue(kn.reference,{onKeyDown(e){y&&W.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},On.reference,Dn.reference,En.reference),[kn.reference,On.reference,Dn.reference,En.reference,y,W]),jn=Z.useMemo(()=>ue(Yc,On.floating),[On.floating]),Mn=Z.useMemo(()=>ue(kn.floating,En.floating),[kn.floating,En.floating]),Nn=Z.useMemo(()=>{let e=kn.item;return{props:e?{...e,onFocus:void 0}:Ee,id:Se,selectionMode:u,disabled:et,readOnly:g,isItemEqualToValue:I}},[kn.item,Se,u,et,g,I]);W.useContextCallback(`setOpen`,on),W.useContextCallback(`setInputValue`,$t),W.useContextCallback(`setSelectedValue`,sn),W.useContextCallback(`setIndices`,Qt),W.useContextCallback(`handleSelection`,cn),W.useContextCallback(`forceMount`,Xt),W.useContextCallback(`requestSubmit`,ln),W.useContextCallback(`onOpenChangeComplete`,n),jx(()=>{W.update({inline:re,popupProps:jn,listProps:Mn,inputProps:An,triggerProps:Jt,itemRoot:Nn})});let Pn={id:Se,selectedValue:lt,open:_t,mounted:fn,transitionStatus:pn,items:U,inline:re,popupProps:jn,listProps:Mn,inputProps:An,triggerProps:Jt,itemRoot:Nn,openMethod:qt,selectionMode:u,name:tt,form:p,disabled:et,readOnly:g,required:_,grid:y,virtualized:te,openOnInputClick:O,itemToStringLabel:je,modal:oe,autoHighlight:ct,isItemEqualToValue:I,submitOnItemClick:le,hasInputValue:at};V(()=>{W.update({...Pn,inputOwnsFormValue:u===`none`&&(re||!W.state.inputInsidePopup)})},[W,...Object.values(Pn)]);let Fn=x(v,be.inputRef),In=Z.useMemo(()=>({query:xt,hasItems:ot,filteredItems:Ot,flatFilteredValues:kt}),[xt,ot,Ot,kt]),Ln=Z.useMemo(()=>Array.isArray(At)?``:oS(At,P),[At,P]),Rn=nt&&Array.isArray(lt)&&lt.length>0,zn=nt||u===`none`&&Wt?void 0:tt,Bn=Z.useMemo(()=>!nt||!Array.isArray(lt)||!tt?null:lt.map(e=>{let t=oS(e,P);return(0,Q.jsx)(`input`,{type:`hidden`,form:p,name:tt,value:t,disabled:et},t)}),[nt,lt,p,tt,P,et]),K=(0,Q.jsxs)(Z.Fragment,{children:[e.children,(0,Q.jsx)(`input`,{...be.getValidationProps(et,{onFocus(){Ut?zt?.focus():(He.current||zt)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||et||g)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=H(tn,e.nativeEvent),i=()=>Qe.current.findIndex(e=>oS(e,P).toLowerCase()===n||Ne(e).toLowerCase()===n);function a(){if(nt)return;if(u===`none`){$t(t,r);return}let e=i();e===-1&&(e=Qe.current.findIndex((e,t)=>{let r=Be.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:Qe.current[e];a!=null&&sn?.(a,r)}rt&&(Xt(),Te&&i()===-1&&W.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:Se&&zn==null?`${Se}-hidden-input`:void 0,form:p,name:zn,autoComplete:se,disabled:et,required:_&&!Rn,readOnly:g,value:Ln,ref:Fn,style:zn?Ae:m,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Bn]});return(0,Q.jsx)(Px.Provider,{value:W,children:(0,Q.jsx)(Fx.Provider,{value:Sn,children:(0,Q.jsx)(Lx.Provider,{value:ot,children:(0,Q.jsx)(Ix.Provider,{value:In,children:(0,Q.jsx)(Rx.Provider,{value:mt,children:K})})})})})}function RS(e){let{openOnInputClick:t=!1,value:n,defaultValue:r,onValueChange:i,mode:a=`list`,itemToStringValue:o,...s}=e,c=(a===`inline`||a===`both`)&&!e.readOnly,l=a===`inline`||a===`none`,u=n!==void 0,[d,f]=Z.useState(r??``),[p,m]=Z.useState(``);Z.useEffect(()=>{(u||!c)&&m(``)},[n,u,c]);let h;h=c&&p!==``?p:u?n??``:d;let g=kS({locale:s.locale}),_=String((u?n:d)??``).trim(),v=l||s.filter===null?null:s.filter??g.contains;function y(e,t){m(``),u||f(e),i?.(e,t)}function b(t,n){e.onItemHighlighted?.(t,n),n.reason!==`pointer`&&m(c&&t!=null?aS(t,o):``)}return(0,Q.jsx)(LS,{...s,itemToStringLabel:o,openOnInputClick:t,selectionMode:`none`,fillInputOnItemPress:!0,filter:v,filterQuery:a===`both`?_:void 0,autoComplete:a,inputValue:h,defaultInputValue:r,onInputValueChange:y,onItemHighlighted:b})}var zS=`data-popup-side`,BS=`data-list-empty`,VS={...rc,...pS,popupSide:e=>e?{[zS]:e}:null,listEmpty:e=>e?{[BS]:``}:null};function HS(e,t,n){let{setFocused:r,focusOwnerRef:i}=gS(),a=D(t=>{(t?!e:i.current===a)&&(i.current=t&&a,n?.(t),r(t))});return V(()=>{let e=t.current;return e?.getRootNode()?.activeElement===e&&a(!0),()=>a(!1)},[e,t,a]),a}var US=5;function WS(e,t){let n=GS(t);return e.clientX>=n.left-US&&e.clientX<=n.right+US&&e.clientY>=n.top-US&&e.clientY<=n.bottom+US}function GS(e){let t=e.getBoundingClientRect(),n=A(e);if(Ve)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 KS(e,t){return e??t}function qS(e){let t=e.useState(`mounted`),n=e.useState(`popupSide`),r=e.useState(`positionerElement`);return t&&r?n:null}function JS(){return Vx().filteredItems.length===0}function YS(e){return e===`rtl`?[`ArrowRight`,`ArrowLeft`]:[`ArrowLeft`,`ArrowRight`]}function XS(e,t,n){let r=e.context.listRef.current[t];r&&(e.context.selectionEventRef.current=n,r.click(),e.context.selectionEventRef.current=null)}var ZS=Z.forwardRef(function(e,t){let{render:n,className:r,nativeButton:i=!0,disabled:a=!1,id:o,style:s,...c}=e,{state:l,disabled:u,setTouched:d,validationMode:p,validation:m}=gS(),{labelId:h}=SS(),g=zx(),_=g.useState(`selectionMode`),y=g.useState(`disabled`),b=g.useState(`readOnly`),x=g.useState(`required`),S=g.useState(`positionerElement`),C=g.useState(`listElement`),w=g.useState(`popupId`),T=g.useState(`triggerProps`),E=g.useState(`inputInsidePopup`),O=g.useState(`id`),k=g.useState(`labelId`),A=g.useState(`open`),j=g.useState(`selectedValue`),M=g.useState(`activeIndex`),N=g.useState(`selectedIndex`),ee=g.useState(`hasSelectedValue`),P=Bx(),F=Hx(),I=Ht(),te=u||y||a,ne=JS(),re=qS(g),ie=Z.useRef(null),ae=HS(te,ie);CS({id:E?o:void 0});let oe=E?o??O:o,R=KS(h,k),z;A&&E?z=w??wS(O):A&&(z=C?.id);let se=Z.useRef(``);function B(e){se.current=e.pointerType}let{reference:ce}=zl(P,{enabled:!A&&!b&&!y&&_===`single`,listRef:g.context.labelsRef,activeIndex:M,selectedIndex:N,onMatch(e){let t=g.context.valuesRef.current[e];t!==void 0&&g.context.setSelectedValue(t,H(tn))}}),{reference:le}=Hc(P,{enabled:!y,event:`mousedown`}),{buttonRef:ue,getButtonProps:de}=pe({native:i,disabled:te}),fe={...l,readOnly:b,open:A,disabled:te,popupSide:re,listEmpty:ne,placeholder:_!==`none`&&!ee},he=D(e=>{g.set(`triggerElement`,e)});return v(`button`,e,{ref:[t,ue,ie,he],state:fe,props:[T,le,ce,{id:oe,tabIndex:E?0:-1,role:E?`combobox`:void 0,"aria-expanded":A,"aria-haspopup":E?`dialog`:`listbox`,"aria-controls":z,"aria-required":E&&x||void 0,"aria-readonly":E&&b||void 0,"aria-labelledby":R,onPointerDown:B,onPointerEnter:B,onFocus(){ae(!0),!te&&I.start(0,g.context.forceMount)},onBlur(e){if(!G(S,e.relatedTarget)&&(d(!0),ae(!1),p===`onBlur`)){let e=_===`none`?F:j;m.commit(e)}},onMouseDown(e){if(te||(E||P.set(`domReferenceElement`,e.currentTarget),g.context.forceMount(),se.current!==`touch`&&(g.context.inputRef.current?.focus(),E||e.preventDefault()),A))return;let t=f(e.currentTarget);function n(e){let t=g.state.triggerElement;if(!t)return;let n=L(e),r=g.state.positionerElement,i=g.state.listElement;G(t,n)||G(r,n)||G(i,n)||WS(e,t)||g.context.setOpen(!1,H(Nt,e))}E&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(me(e),g.context.setOpen(!0,H(Ge,e.nativeEvent)),g.context.inputRef.current?.focus())}},m.getValidationProps(te,c),de],stateAttributesMapping:VS})}),QS=Z.createContext(void 0);function $S(){return Z.useContext(QS)}var eC=Z.createContext(void 0);function tC(e){let t=Z.useContext(eC);if(t===void 0&&!e)throw Error(B(21));return t}var nC=Z.forwardRef(function(e,t){let n=zx(),{buttonRef:r,getButtonProps:i}=pe({native:!1}),a=x(t,r);function o(e){n.context.setOpen(!1,H(tt,e.nativeEvent,e.currentTarget))}let s=i({onClick:o});return(0,Q.jsx)(`span`,{ref:a,...s,"aria-label":`Dismiss`,tabIndex:void 0,style:Ae})}),rC=Z.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...s}=e,{state:c,disabled:l,setTouched:d,validationMode:f,validation:p}=gS(),{labelId:m}=SS(),h=$S(),g=!!tC(!0),_=zx(),y=Hx(),b=$u(),x=_.useState(`required`),S=_.useState(`disabled`),C=_.useState(`readOnly`),w=_.useState(`name`),T=_.useState(`form`),E=_.useState(`selectionMode`),O=_.useState(`autoHighlight`),k=_.useState(`inputProps`),A=_.useState(`triggerProps`),j=_.useState(`open`),M=_.useState(`mounted`),N=_.useState(`selectedValue`),ee=_.useState(`id`),P=_.useState(`inline`),F=_.useState(`modal`),I=!!O,te=qS(_),ne=l||S||i,L=JS(),re=HS(ne,_.context.inputRef),ie=g||P,ae=!ie||F,oe=bS(a??(ie?void 0:ee)),R=g?dS:c,[z,se]=Z.useState(null),B=Z.useRef(!1),ce=Z.useRef(null);V(()=>{j||(ce.current=null)},[j]);let le=E===`none`&&!g,ue=D(e=>{let t=g||_.state.inline;t&&!_.state.hasInputValue&&_.context.setInputValue(``,H(tn)),_.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:le})}),de=g?s:p.getValidationProps(ne,s);function fe(e){_.context.setIndices({activeIndex:null,selectedIndex:null,type:Nx(e),event:e})}let pe={...R,open:j,disabled:ne,readOnly:C,popupSide:te,listEmpty:L};function he(e){if(!h)return;let t,n=h.chipsRef.current.length,[r]=YS(b);return e.key===r&&(e.currentTarget.selectionStart??0)===0&&N.length>0&&(e.preventDefault(),t=n>0?n-1:void 0),t}let ge=v(`input`,e,{state:pe,ref:[t,_.context.inputRef,ue],props:[k,A,{value:z??y,"aria-readonly":C||void 0,"aria-required":x||void 0,"aria-labelledby":m,disabled:ne,readOnly:C,required:E===`none`?x:void 0,form:T,...le&&w&&{name:w},id:oe,onFocus(){if(re(!0),!P)return;let e=ce.current;ce.current=null,e!=null&&Object.hasOwn(_.context.valuesRef.current,e)&&_.context.setIndices({activeIndex:e})},onBlur(){d(!0),re(!1);let e=_.state.activeIndex;if(P&&e!==null&&O!==`always`&&(ce.current=e,_.context.setIndices({activeIndex:null})),f===`onBlur`){let e=E===`none`?y:N;p.commit(e)}},onCompositionStart(e){u||(B.current=!0,se(e.currentTarget.value))},onCompositionEnd(e){B.current=!1;let t=e.currentTarget.value;se(null),_.context.setInputValue(t,H(ut,e.nativeEvent))},onChange(e){let t=e.nativeEvent,n=t.inputType,r=!n||n===`insertReplacementText`,i=B.current||!r;function a(e){!C&&!ne&&e&&i&&(_.context.setOpen(!0,H(ut,t)),I||fe(t))}if(B.current){let n=e.currentTarget.value;se(n),n===``&&!_.state.openOnInputClick&&!_.state.inputInsidePopup&&_.context.setOpen(!1,H(It,t));let r=n.trim(),i=I&&r!==``;a(r),j&&_.state.activeIndex!==null&&!i&&fe(t);return}let o=H(ut,t);if(_.context.setInputValue(e.currentTarget.value,o),o.isCanceled)return;let s=e.currentTarget.value===``,c=H(It,t);s&&!_.state.inputInsidePopup&&(E===`single`&&_.context.setSelectedValue(null,c),_.state.openOnInputClick||_.context.setOpen(!1,c)),a(e.currentTarget.value.trim()),j&&_.state.activeIndex!==null&&!I&&fe(t)},onKeyDown(e){if(e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;if(ne||C){C&&e.key===`Enter`&&j&&_.state.activeIndex!==null&&me(e);return}let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=b===`rtl`;if(e.key===`Home`){me(e);let n=We&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){me(e);let i=We&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!M&&e.key===`Escape`){let t=E===`multiple`&&Array.isArray(N)?N.length===0:N===null,n=H(Tt,e.nativeEvent),r=E===`multiple`?[]:null;_.context.setInputValue(``,n),_.context.setSelectedValue(r,n),t||_.state.inline||n.isPropagationAllowed||e.stopPropagation();return}if(h&&e.key===`Backspace`&&t.value===``&&Array.isArray(N)&&N.length>0){let t=h.chipsRef.current.length,n=t>0?t-1:N.length-1,r=N.filter((e,t)=>t!==n);fe(e.nativeEvent),_.context.setSelectedValue(r,H(tn,e.nativeEvent));return}let i=he(e);if(i!==void 0&&h?.chipsRef.current[i]?.focus(),e.which!==229&&e.key===`Enter`&&j){let t=_.state.activeIndex,n=e.nativeEvent;if(t===null){if(P)return;_.context.setOpen(!1,H(tn,n));return}me(e),XS(_,t,n)}}},de],stateAttributesMapping:VS}),_e=g?(0,Q.jsx)(hS.Provider,{value:mS,children:ge}):ge;return(0,Q.jsxs)(Z.Fragment,{children:[j&&ae&&(0,Q.jsx)(nC,{ref:_.context.startDismissRef}),_e]})}),iC={...hn,...nc},aC=Z.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,keepMounted:o=!1,style:s,...c}=e,{disabled:l}=gS(),u=zx(),d=u.useState(`selectionMode`),f=u.useState(`disabled`),p=u.useState(`readOnly`),m=u.useState(`open`),h=u.useState(`selectedValue`),g=u.useState(`hasSelectionChips`),_=Hx(),y=!1;y=d===`none`?_!==``:d===`single`?h!=null:g;let b=l||f||i,{buttonRef:x,getButtonProps:S}=pe({native:a,disabled:b}),{mounted:C,transitionStatus:w,setMounted:T}=qc(y),E={disabled:b,visible:y,open:m,transitionStatus:w};le({open:y,ref:u.context.clearRef,onComplete(){y||T(!1)}});let D=v(`button`,e,{state:E,ref:[t,x,u.context.clearRef],props:[{tabIndex:-1,children:`x`,onMouseDown(e){e.preventDefault()},onClick(e){if(b||p)return;let t=Nx(e);u.context.setInputValue(``,H(Gt,e.nativeEvent)),d===`none`?u.context.setIndices({activeIndex:null,type:t,event:e.nativeEvent}):(u.context.setSelectedValue(Array.isArray(h)?[]:null,H(Gt,e.nativeEvent)),u.context.setIndices({activeIndex:null,selectedIndex:null,type:t,event:e.nativeEvent})),u.context.inputRef.current?.focus()}},c,S],stateAttributesMapping:iC});return o||C?D:null}),oC=Z.createContext(null);function sC(){return Z.useContext(oC)}function cC(e){let{children:t}=e,{filteredItems:n}=Vx(),r=sC(),i=r?r.items:n;return(0,Q.jsx)(Z.Fragment,{children:i.map(t)})}var lC=Z.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function uC(){return Z.useContext(lC)}function dC(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=D(i),[,o]=Z.useState(0),s=F(pC).current,c=F(fC).current,l=Z.useRef(0),u=Z.useRef(!0),d=Z.useRef(null),f=Z.useRef(null),p=D(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=D((e,t)=>{c.set(e,t),p()}),h=D(e=>{c.delete(e),p()}),g=D(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(!gC(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&_C(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=hC(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=D(()=>{let[e,t]=mC(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))});V(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),V(()=>{u.current&&v()}),V(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=D(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)(lC.Provider,{value:b,children:t})}function fC(){return new Map}function pC(){return new Set}function mC(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)=>_C(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 hC(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function gC(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 _C(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var vC=Z.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=zx(),l=Bx(),u=!!tC(!0),{filteredItems:d,hasItems:f}=Vx(),p=c.useState(`selectionMode`),m=c.useState(`grid`),h=c.useState(`readOnly`),g=c.useState(`listProps`),_=c.useState(`virtualized`),y=c.useState(`forceMounted`),b=p===`multiple`,x=d.length===0,S=D(e=>{c.set(`positionerElement`,e)}),C=D(e=>{c.set(`listElement`,e)}),w=Z.useMemo(()=>typeof o==`function`?n||=(0,Q.jsx)(cC,{children:o}):o,[o]),T={empty:x},E=l.useState(`floatingId`),O=v(`div`,e,{state:T,ref:[t,C,u?null:S],props:[g,{children:w,tabIndex:-1,id:E,role:m?`grid`:`listbox`,"aria-multiselectable":b?`true`:void 0,"aria-readonly":!m&&h?!0:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;me(e),XS(c,t,e.nativeEvent)}}},s]});if(_)return O;let k=f&&!y?void 0:c.context.labelsRef;return(0,Q.jsx)(dC,{elementsRef:c.context.listRef,labelsRef:k,children:O})}),yC=Z.createContext(void 0);function bC(){let e=Z.useContext(yC);if(e===void 0)throw Error(B(20));return e}var xC=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=zx(),a=i.useState(`mounted`),o=i.useState(`forceMounted`);return a||n||o?(0,Q.jsx)(yC.Provider,{value:n,children:(0,Q.jsx)(Vt,{ref:t,...r})}):null}),SC=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}})}),CC={},wC={},TC=``;function EC(e,t){return Le(e)?e:t}function DC(e,t,n){return/hidden|clip/.test(e.getComputedStyle(EC(t,n)).overflowY)}function OC(e){if(typeof document>`u`)return!1;let t=f(e);return A(t).innerWidth-t.documentElement.clientWidth>0}function kC(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=f(e),n=t.documentElement,r=t.body,i=EC(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 AC(e){let t=f(e),n=t.documentElement,r=t.body,i=EC(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 jC(e){let t=f(e),n=t.documentElement,r=t.body,i=A(n),a=0,o=0,s=!1,c=P.create();if(ye&&(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,CC={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},TC=n.style.scrollBehavior,wC={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=EC(n,r);s=kC(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,CC),Object.assign(r.style,wC),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=TC)}function d(){u(),c.request(l)}l();let p=U(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&p()}}var MC=new class{lockCount=0;restore=null;timeoutLock=At.create();timeoutUnlock=At.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=f(e),n=t.documentElement,r=t.body,i=A(n);if(DC(i,n,r)){let t=new i.MutationObserver(()=>{DC(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=st||!OC(e);this.restore=a?AC(e):jC(e)}};function NC(e=!0,t=null){V(()=>{if(e)return MC.acquire(t)},[e,t])}var PC=20;function FC(e,t,n,r){let[i,a]=Z.useState(!1);V(()=>{if(!e||!t||n==null){a(!1);return}let r=f(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-PC)},[e,t,n]),NC(e&&(!t||i),r)}var IC=Z.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m=!1,collisionAvoidance:h=bt,style:g,..._}=e,v=zx(),y=Bx(),b=bC(),x=v.useState(`modal`),S=v.useState(`open`),C=v.useState(`mounted`),w=v.useState(`openMethod`),T=v.useState(`positionerElement`),E=v.useState(`triggerElement`),O=v.useState(`inputElement`),k=v.useState(`inputGroupElement`),A=v.useState(`inputInsidePopup`),j=v.useState(`transitionStatus`),M=JS(),N=pd({anchor:i??(A?E:k??O),floatingRootContext:y,positionMethod:a,mounted:C,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,lazyFlip:!0});FC(S&&x,w===`touch`,T,E);let ee={open:S,side:N.side,align:N.align,anchorHidden:N.anchorHidden,empty:M};V(()=>{v.set(`popupSide`,N.side)},[v,N.side]);let P=D(e=>{v.set(`positionerElement`,e)}),F=_d(e,ee,{styles:N.positionerStyles,transitionStatus:j,props:_,refs:[t,P],hidden:!C,inert:!S});return(0,Q.jsxs)(eC.Provider,{value:N,children:[C&&x&&(0,Q.jsx)(SC,{inert:be(!S),cutout:k??O??E}),F]})}),LC={...ic,...hn},RC=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=zx(),l=tC(),u=Bx(),d=c.useState(`mounted`),f=c.useState(`open`),p=c.useState(`openMethod`),m=c.useState(`popupProps`),h=c.useState(`transitionStatus`),g=c.useState(`inputInsidePopup`),_=c.useState(`inputElement`),y=c.useState(`modal`),b=c.useState(`id`),x=JS(),S=s.id??(g?wS(b):void 0);V(()=>(c.set(`popupId`,c.context.popupRef.current?.id||S),()=>{c.set(`popupId`,void 0)}),[c,S]),le({open:f,ref:c.context.popupRef,onComplete(){f&&c.context.onOpenChangeComplete(!0)}});let C={open:f,side:l.side,align:l.align,anchorHidden:l.anchorHidden,transitionStatus:h,empty:x},w=v(`div`,e,{state:C,ref:[t,c.context.popupRef],props:[m,{id:S,role:g?`dialog`:`presentation`,onFocus(e){let t=L(e.nativeEvent);p!==`touch`&&(G(c.state.listElement,t)||t===e.currentTarget)&&c.context.inputRef.current?.focus()}},gd(h),s],stateAttributesMapping:LC}),T=a===void 0?g?e=>e===`touch`?c.context.popupRef.current:_:!1:a,E;E=o??(g?void 0:!1);let D=!g||y;return(0,Q.jsx)(Vc,{context:u,disabled:!d,modal:D,openInteractionType:p,initialFocus:T,returnFocus:E,getInsideElements:()=>[c.context.startDismissRef.current,c.context.endDismissRef.current],children:(0,Q.jsxs)(Z.Fragment,{children:[w,D&&(0,Q.jsx)(nC,{ref:c.context.endDismissRef})]})})});function zC(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=uC(),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 V(()=>{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}}var BC=Z.createContext(void 0);function VC(){let e=Z.useContext(BC);if(!e)throw Error(B(19));return e}var HC=Z.createContext(!1);function UC(){return Z.useContext(HC)}function WC(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:c=null,index:l,disabled:u=!1,nativeButton:d=!1,...f}=t,p=Z.useRef(null),m=zC({guess:!0,index:l,textRef:p}),h=zx(),g=UC(),_=Ux(),{props:y,id:b,selectionMode:x,disabled:S,readOnly:C,isItemEqualToValue:w}=h.useState(`itemRoot`),T=S||u,E=x!==`none`,D=l??i??m.index,O=D!==-1,k=h.useState(`isActive`,D),A=h.useState(`isSelected`,c),j=Z.useRef(null),M=b!=null&&O?`${b}-${D}`:void 0,N=A&&E;V(()=>{if(!O||!r&&l==null)return;let e=h.context.listRef.current;return e[D]=j.current,()=>{delete e[D]}},[O,r,D,l,h]),V(()=>{if(!O||_)return;let e=h.context.valuesRef.current;return e[D]=c,()=>{delete e[D]}},[O,_,D,c,h]),V(()=>{if(!O||_)return;let e=h.state.selectedValue,t=h.state.selectedIndex;h.state.selectionMode===`multiple`&&Array.isArray(e)?t=Qx(D,c,h.context.valuesRef.current,e,w,t):Kx(c,e,w)&&(t=D),h.set(`selectedIndex`,t)},[O,_,h,D,c,w]);let{getButtonProps:ee,buttonRef:P}=pe({disabled:T,focusableWhenDisabled:!0,native:d,composite:!0}),F={disabled:T,selected:N,highlighted:k};function I(e){function t(){h.context.handleSelection(e,c)}h.state.submitOnItemClick?(Ks.flushSync(t),h.context.requestSubmit()):t()}let te={id:M,role:g?`gridcell`:`option`,"aria-selected":E?N:void 0,tabIndex:void 0,onPointerDownCapture(e){e.isPrimary&&(h.context.pointerDownItemRef.current=e.currentTarget),e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){T||C||I(e.nativeEvent)},onMouseUp(e){let t=h.context.pointerDownItemRef.current===e.currentTarget;h.context.pointerDownItemRef.current=null,!(T||C||e.button!==0||t||!k)&&I(e.nativeEvent)}},ne=v(`div`,t,{ref:[P,n,m.ref,j],state:F,props:[y,te,f,ee]}),L=Z.useMemo(()=>({selected:N,textRef:p}),[N,p]);return(0,Q.jsx)(BC.Provider,{value:L,children:ne})}function GC(e){let{componentProps:t,forwardedRef:n}=e,r=zx().useState(`isItemEqualToValue`),{flatFilteredValues:i}=Vx(),a=Yx(i,t.value??null,r);return(0,Q.jsx)(WC,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:a})}var KC=Z.memo(Z.forwardRef(function(e,t){let n=zx().useState(`virtualized`);return n&&e.index==null?(0,Q.jsx)(GC,{componentProps:e,forwardedRef:t}):(0,Q.jsx)(WC,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})}));function qC(e){return v(e.defaultTagName??`div`,e,e)}var JC=Z.createContext(void 0);function YC(){let e=Z.useContext(JC);if(e===void 0)throw Error(B(13));return e}var XC={imageLoadingStatus:()=>null},ZC=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=v(`span`,e,{state:c,ref:t,props:a,stateAttributesMapping:XC});return(0,Q.jsx)(JC.Provider,{value:l,children:u})});function QC(e,{referrerPolicy:t,crossOrigin:n,sizes:r,srcSet:i},a){let o=Z.useState(`idle`),s=o[1];return V(()=>{if(!a)return w;if(!e&&!i)return s(`error`),w;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 $C={...XC,...hn},ew=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}=YC(),[f,p]=QC(l,e,!a),m=f===`loaded`,{mounted:h,transitionStatus:g,setMounted:_}=qc(m),y=Z.useRef(null),b=Z.useRef(!0);V(()=>{if(!a)return;let e=b.current;b.current=!1;let t=y.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 x=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,S=D(e=>{i?.(e),d(e)});V(()=>{f!==`idle`&&S(f)},[f,S]),V(()=>()=>d(`idle`),[d]),le({enabled:!m,open:m,ref:y,onComplete(){m||_(!1)}});let C={imageLoadingStatus:f,transitionStatus:a&&g===`ending`?void 0:g},w=a||h,T={};s!==void 0&&(T.sizes=s),c!==void 0&&(T.srcSet=c),l!==void 0&&(T.src=l);let E=v(`img`,e,{state:C,ref:[t,y],props:[x,u,T],stateAttributesMapping:$C,enabled:w});return w?E:null}),tw=Z.forwardRef(function(e,t){let{className:n,render:r,delay:i=0,style:a,...o}=e,{imageLoadingStatus:s}=YC(),[c,l]=Z.useState(i===0),u=Ht();return Z.useEffect(()=>(i>0?u.start(i,()=>l(!0)):l(!0),u.clear),[u,i]),v(`span`,e,{state:{imageLoadingStatus:s},ref:t,props:o,stateAttributesMapping:XC,enabled:s!==`loaded`&&(i===0||c)})});function nw(e){let t=(0,qs.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=Xt(`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)(ZC,{"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 rw(e){let t=(0,qs.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=Xt(`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)(ew,{"data-slot":`avatar-image`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function iw(e){let t=(0,qs.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=Xt(`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)(tw,{"data-slot":`avatar-fallback`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var aw=Z.memo(Z.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a,selected:o,...s}=e,c=Z.useRef(null),{transitionStatus:l,setMounted:u}=qc(o),d=v(`span`,e,{ref:[t,c],state:{selected:o,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},s],stateAttributesMapping:hn});return le({batch:!0,enabled:!o,open:o,ref:c,onComplete(){o||u(!1)}}),d})),ow=Z.forwardRef(function(e,t){let{selected:n}=VC();return e.keepMounted||n?(0,Q.jsx)(aw,{...e,selected:n,ref:t}):null}),sw=Z.createContext(void 0);function cw(e=!0){let t=Z.useContext(sw);if(t===void 0&&!e)throw Error(B(25));return t}var lw=Z.createContext(void 0);function uw(e){let t=Z.useContext(lw);if(t===void 0&&!e)throw Error(B(33));return t}var dw=Z.createContext(void 0);function fw(e){let t=Z.useContext(dw);if(t===void 0&&!e)throw Error(B(36));return t}var pw=Z.createContext(null);function mw(e=`root`){let t=Z.useContext(pw),n=Z.useContext(dw);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var hw={visible:!0,ref:null};function gw(){return hw}function _w(e,t,n=`root`){let r=mw(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??gw)({label:e.label,children:e.children,render:e.render}),a=x(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}function vw(e){e.preventDefault()}function yw(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=fw(),u=cw(!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?vw: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:ht})},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&&!Yt&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&Ct(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var bw={type:`regular-item`};function xw(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}=pe({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=yw({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=Z.useCallback(e=>ue(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=x(u,f);return Z.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Sw=Z.createContext(void 0);function Cw(){let e=Z.useContext(Sw);if(e===void 0)throw Error(B(31));return e}var ww=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Z.useState(void 0),c=v(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,Q.jsx)(Sw.Provider,{value:s,children:c})}),Tw=Z.forwardRef(function(e,t){let n=mw()?.Group??ww;return(0,Q.jsx)(n,{...e,ref:t})}),Ew=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=bS(a),c=Cw();return V(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),v(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),Dw=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}=fw(),f=zC({guess:!0,label:a}),p=bS(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),y=s||m,{getItemProps:b,itemRef:x}=xw({closeOnClick:c,disabled:y,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:bw});return v(`div`,e,{state:{disabled:y,highlighted:h},props:[_,u,b],ref:[x,t,f.ref]})}),Ow=Z.forwardRef(function(e,t){let n=_w(e,t);return n.visible?(0,Q.jsx)(Dw,{...e,ref:n.ref}):null}),kw=Z.createContext(void 0);function Aw(e){let t=Z.useContext(kw);if(t===void 0&&!e)throw Error(B(69));return t}var jw=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),Mw=Z.createContext(void 0);function Nw(){return Z.useContext(Mw)}function Pw(e,t){let n=we(e.render);if(Z.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function Fw(e,t,n){let r=Pw(e,t),i=r===t?void 0:r;return[r,Z.useCallback(e=>n?.(e?i:void 0),[i,n])]}function Iw(e,t,n){let r=we(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 Lw=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}=fw(),m=Nw(),{side:h,align:g}=uw(),_=Aw(!0)!=null,y=l.useState(`open`),b=l.useState(`transitionStatus`),x=l.useState(`popupProps`),S=l.useState(`mounted`),C=l.useState(`instantType`),w=l.useState(`activeTriggerElement`),T=l.useState(`parent`),E=l.useState(`lastOpenChangeReason`),D=l.useState(`rootId`),O=l.useState(`floatingRootContext`),k=l.useState(`floatingTreeRoot`),A=l.useState(`closeDelay`),j=l.useState(`hoverEnabled`),M=l.useState(`disabled`),N=l.useState(`openMethod`),ee=l.useState(`activeTriggerId`),P=l.useState(`listElement`),[F,I]=Fw(e,u,d),te=Iw(e,w,ee),ne=T.type===`menu`?m:void 0,L=T.type===`context-menu`,re=s??T.type!==`menu`;s===void 0&&P&&T.type!==`menu`&&(re=()=>l.state.activeIndex===null&&P),le({open:y,ref:l.context.popupRef,onComplete(){y&&l.context.onOpenChangeComplete?.(!0)}}),Z.useEffect(()=>{function e(e){l.setOpen(!1,H(e.reason,e.domEvent))}return k.events.on(`close`,e),()=>{k.events.off(`close`,e)}},[k.events,l]),kl(O,{enabled:j&&!M&&!L&&T.type!==`menubar`,closeDelay:A});let ie=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:ae,handleFocus:oe}=(Z.useContext(pw)?.useParentHandoff??zw)(l,T,y,f),R={transitionStatus:b,side:h,align:g,open:y,nested:T.type===`menu`,instant:C},z=v(`div`,e,{state:R,ref:[t,l.context.popupRef,ie,I],stateAttributesMapping:ac,props:[x,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":te},onKeyDown(e){ne?.onPopupKeyDown?.(e),_&&jw.has(e.key)&&e.stopPropagation()},onFocus:oe},gd(b),c,{"data-rootownerid":D}]}),se=T.type===void 0||L;(w||T.type===`menubar`&&E!==`outside-press`)&&(se=!0);let B=ne?.getReturnElement??ae;return(0,Q.jsx)(Vc,{context:O,openInteractionType:N,modal:L,disabled:!S,returnFocus:a??B??se,explicitReturnFocus:a===void 0&&B?!1:void 0,initialFocus:re,restoreFocus:!0,getInsideElements:T.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:T.type===`menubar`?void 0:k,previousFocusableElement:w,nextFocusableElement:T.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:z})}),Rw={parentVirtualFocusRef:void 0,handleFocus:void 0};function zw(){return Rw}var Bw=Z.forwardRef(function(e,t){let n=mw()?.Popup??Lw;return(0,Q.jsx)(n,{...e,ref:t})}),Vw=Z.createContext(void 0);function Hw(){let e=Z.useContext(Vw);if(e===void 0)throw Error(B(32));return e}var Uw=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=fw();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Q.jsx)(Vw.Provider,{value:n,children:(0,Q.jsx)(Vt,{ref:t,...r,portalOwnerRole:o})})});function Ww(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=Z.useRef(null),o=Z.useRef(null),s=he(r);V(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),V(()=>{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 Gw=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=bt,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=fw(),x=Hw(),S=cw(!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`),N=v.useState(`instantType`),ee=v.useState(`adaptiveOrigin`),P=v.useState(`lastOpenChangeReason`),F=v.useState(`floatingNodeId`),I=v.useState(`floatingParentNodeId`),te=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??se):C.type===`menubar`&&(oe??=C.context.orientation===`vertical`?`inline-end`:`bottom`,R??=`start`);let z=C.type===`context-menu`,B=pd({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:F,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:ae,shift:z?{crossAxis:!(`side`in ae&&ae.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:ee,lazyFlip:y?`placement`:!1});Z.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===F&&v.set(`hoverEnabled`,!1),e.nodeId!==F&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,H(sn)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,F]),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,H(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let ce=Ht();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,H(sn))}):v.setOpen(!1,H(sn))}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:F,parentNodeId:I,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,F,I]),Ww({store:v,domReference:te,positionerElement:M,open:D});let le={open:D,side:B.side,align:B.align,anchorHidden:B.anchorHidden,nested:C.type===`menu`,instant:N},ue=C.type===`menubar`&&C.context.modal;FC(D&&(ue||O&&P!==`trigger-hover`),k===`touch`,M,A);let de=_d(e,le,{styles:B.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),fe=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&P!==`trigger-hover`||C.type===`menubar`&&C.context.modal),pe=null;return C.type===`menubar`?pe=C.context.contentElement:C.type===void 0&&(pe=A),(0,Q.jsxs)(lw.Provider,{value:B,children:[fe&&(0,Q.jsx)(SC,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:be(!D),cutout:pe}),(0,Q.jsx)(jc,{id:F,children:(0,Q.jsx)(dC,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:de})})]})}),Kw=Z.createContext(null);function qw(e){let t=Z.useContext(Kw);if(t===null&&!e)throw Error(B(5));return t}var Jw={...ml,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=ml.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>ye&&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`&&!ml.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`)}},Yw=class extends vt{constructor(e,t,n=!1){let r=new al,i=Zw(r,t,n,e);super(i,Xw(r),Jw),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 Xw(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 Zw(e,t,n=!1,r){return{...cl(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:Ee,inputProps:Ee,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new Tc,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Ee,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var Qw=Z.createContext(null);function $w(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function eT(e,t){return e===`list-navigation`||$w(e,t)}var tT=Ye(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=cw(!0),w=fw(!0),T=qw(!0),E=w?.store,O=w?.virtualFocus??!1,k=Z.useMemo(()=>_&&E?{type:`menu`,store:E}:T?{type:`menubar`,context:T}:S&&!E?{type:`context-menu`,context:S}:{type:void 0},[S,E,T,_]),A=bS(),j=bS(),[M,N]=Z.useState(void 0),ee=(M??j)||void 0,P=Oc(),I=k.type===`menu`?k.store:void 0,te=(n??o)&&I?.state.transitionStatus===`starting`,ne=F(()=>te?I?.state.instantType:void 0).current,L=F(()=>{let e=new Yw({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:k,disabled:s,highlightItemOnHover:g,modal:k.type===void 0?c:void 0,rootId:A,instantType:ne},ee,P!=null);return e.context.virtualFocusRef=y,e}).current;L.useControlledProp(`openProp`,n),L.useControlledProp(`triggerIdProp`,m),L.useContextCallback(`onOpenChangeComplete`,i);let re=L.useState(`floatingTreeRoot`),ie=Ac(re),ae=L.useState(`open`),oe=L.useState(`activeTriggerElement`),R=L.useState(`positionerElement`),z=L.useState(`hoverEnabled`),se=L.useState(`disabled`),B=L.useState(`lastOpenChangeReason`),ce=L.useState(`parent`),le=L.useState(`activeIndex`),de=L.useState(`keyboardOpen`),fe=L.useState(`payload`),pe=L.useState(`floatingParentNodeId`),me=Z.useRef(null),ge=Z.useRef(ce.type!==`context-menu`),_e=Ht(),ve=Z.useRef(!0),ye=Ht(),be=pe!=null,{openMethod:xe,triggerProps:Se}=NS(ae);L.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:ce.type===void 0?c:void 0,openMethod:xe,rootId:A}),nl(L);let{forceUnmount:Ce,transitionStatus:we}=rl(ae,L,()=>{L.set(`allowMouseEnter`,!1)},te),Te=he(L.context.popupRef);Z.useEffect(()=>{if(ne===void 0)return;let e=()=>{L.state.instantType===ne&&L.set(`instantType`,void 0)};if(!ae){e();return}if(we!==void 0)return;if(L.context.popupRef.current==null){e();return}let t=new AbortController;return Te(e,t.signal),()=>{t.abort()}},[ne,ae,we,Te,L]),V(()=>{S&&!w?L.update({parent:{type:`context-menu`,context:S},floatingNodeId:ie,floatingParentNodeId:P}):(w||!L.select(`activeTriggerElement`))&&L.update({floatingNodeId:ie,floatingParentNodeId:P})},[S,w,ie,P,oe,L]),Z.useEffect(()=>{ae||(me.current=null),ce.type===`context-menu`&&(ae?_e.start(500,()=>{ge.current=!0}):(_e.clear(),ge.current=!1))},[_e,ae,ce.type]),V(()=>{!ae&&!z&&L.set(`hoverEnabled`,!0)},[ae,z,L]);let De=D((e,t)=>{let n=t.reason;if(!e&&!L.select(`open`)||ae===e&&t.trigger===oe&&B===n)return;let i=el(t);if(!e&&t.trigger==null&&(t.trigger=oe??void 0),r?.(e,t),t.isCanceled)return;L.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!ve.current)return;e&&n===`trigger-focus`?(ve.current=!1,ye.start(300,()=>{ve.current=!0})):(ve.current=!0,ye.clear());let o=!e&&(n===`escape-key`||n==null);me.current=t.event;let s=$c(L.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&eT(n,a),s.instantType=ce.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:$w(n,a)?`click`:o?`dismiss`:void 0,L.update(s)}),U=Kc({popupStore:L,floatingRootContext:L.state.floatingRootContext,floatingId:ee,nested:P!=null,onOpenChange:De}),Oe=U.context.events;V(()=>{let e=({open:e,eventDetails:t})=>De(e,t);return Oe.on(`setOpen`,e),()=>{Oe?.off(`setOpen`,e)}},[Oe,De]),V(()=>L.subscribeToParentMenu(),[L]);let ke=Z.useCallback(()=>{L.setOpen(!1,H(it))},[L]);Z.useImperativeHandle(d,()=>({unmount:Ce,close:ke}),[Ce,ke]);let Ae;ce.type===`context-menu`&&(Ae=ce.context),Z.useImperativeHandle(Ae?.positionerRef,()=>R,[R]),Z.useImperativeHandle(Ae?.actionsRef,()=>({setOpen:De}),[De]);let je=Gc(U,{enabled:!se,bubbles:{escapeKey:f&&ce.type===`menu`},outsidePress(){return ce.type!==`context-menu`||me.current?.type===`contextmenu`||ge.current},externalTree:be?re:void 0}),Me=$u(),Ne=Rl(U,{enabled:!se,listRef:L.context.itemDomElements,activeIndex:le,virtual:v,nested:ce.type===`menubar`||!v&&ce.type!==void 0,parentOrientation:ce.type===`menubar`?ce.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?de:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:Me===`rtl`,disabledIndices:an,onNavigate(e,t){L.setActiveIndex(e,Nx(t),t?.nativeEvent)},openOnArrowKeyDown:ce.type!==`context-menu`&&!(v&&_),externalTree:!v&&be?re:void 0,nestedReturnFocusRef:I?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),Pe=Z.useCallback(e=>{L.context.typingRef.current=e},[L]),Fe=zl(U,{enabled:!se&&!v,listRef:L.context.itemLabels,elementsRef:L.context.itemDomElements,activeIndex:le,resetMs:500,onMatch:(e,t)=>{ae&&e!==le&&L.setActiveIndex(e,pt,t.nativeEvent)},onTyping:Pe}),Ie=D(a),Le=Z.useRef(-1),Re=D(()=>{let e=L.state.activeIndex,t=e===null?void 0:L.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Le.current===n&&L.context.reportedItem===t)return;Le.current=n,L.context.reportedItem=t,v&&L.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=L.context;L.context.highlightReason=tn,L.context.highlightEvent=void 0,a&&Ie(t,C(r,i,{label:t===void 0?void 0:L.context.itemLabels.current[n]??void 0}))});V(()=>{Re()},[le,Re]);let ze=Z.useMemo(()=>{if(!v)return Ne.reference;if(!Ne.trigger)return Ee;let{onFocus:e,...t}=Ne.trigger;return t},[v,Ne.reference,Ne.trigger]);L.useSyncedValue(`inputProps`,v?Ne.reference??Ee:Ee);let Be=Z.useMemo(()=>{let e=ue(Fe.reference,ze,je.reference,{onMouseMove(){L.set(`allowMouseEnter`,!0)}},Se);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=ae,e},[L,Fe.reference,ze,je.reference,Se,ae]),Ve=Z.useMemo(()=>{let e=ue(Ne.trigger,je.trigger,Se);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Ne.trigger,je.trigger,Se]);F(()=>(L.update({inactiveTriggerProps:Ve}),null)),il(L,{floatingRootContext:U,activeTriggerProps:Be,inactiveTriggerProps:Ve,popupProps:Z.useMemo(()=>ue(Yc,{onMouseMove(){L.set(`allowMouseEnter`,!0),ce.type===`menu`&&L.set(`hoverEnabled`,!1)},onClick(){L.select(`hoverEnabled`)&&L.set(`hoverEnabled`,!1)},onKeyDown(e){let t=L.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Fe.floating,Ne.floating,je.floating),[ce.type,L,Fe.floating,Ne.floating,je.floating]),itemProps:Ne.item??Ee});let He=Z.useMemo(()=>({store:L,parent:k,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:j,setRenderedFloatingId:N,virtualFocus:v,parentVirtualFocus:O,syncHighlightedItem:Re}),[L,k,u,l,b,j,v,O,Re]),Ue=typeof t==`function`?t({payload:fe}):t,We=(0,Q.jsxs)(dw.Provider,{value:He,children:[p&&(0,Q.jsx)(Xc,{handle:p,store:L}),Ue]});return(ce.type===void 0||ce.type===`context-menu`)&&(We=(0,Q.jsx)(Mc,{externalTree:re,children:We})),We});function nT(e){let t=Z.useContext(Qw);if(t===null)return(0,Q.jsx)(tT,{...e});let n=t.Root;return(0,Q.jsx)(Qw.Provider,{value:null,children:(0,Q.jsx)(n,{...t.options,...e})})}var rT={};function iT(e){fw();let t=Z.useContext(Qw);if(t!==null){let n=t.SubmenuRoot;return(0,Q.jsx)(Qw.Provider,{value:null,children:(0,Q.jsx)(n,{...t.options,...e})})}return(0,Q.jsx)(Mw.Provider,{value:rT,children:(0,Q.jsx)(tT,{...e,isSubmenu:!0})})}function aT(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=xt(),{ref:i,index:a}=zC(e),o=n===a,s=Z.useRef(null),c=x(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 oT(e){let{render:t,className:n,style:r,state:i=Ee,props:a=an,refs:o=an,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=aT({metadata:s});return v(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function sT(e){if(ne(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Be(e))return sT(Pe(e))}function cT(e,t){function n(n,r,i){let a=n.currentTarget;Ks.flushSync(()=>{e.setOpen(!1,H(Qt,n.nativeEvent,a))}),zt(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&&te(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function lT(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,f(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:Ee,[t,n,r])}var uT=Pt(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:p,...m}=e,h=fw(!0),g=hl(d)??h?.store;if(!g)throw Error(B(85));let _=bS(s),y=g.useState(`isTriggerActive`,_),b=g.useState(`floatingRootContext`),x=g.useState(`isOpenedByTrigger`,_),S=g.useState(`triggerControlsId`,_),C=Z.useRef(null),w=fT(),T=xt(!0),E=kc(),O=Z.useMemo(()=>E??new Tc,[E]),{registerTrigger:k,isMountedByThisTrigger:A}=tl(_,C,g,{payload:p,closeDelay:u,parent:w,floatingTreeRoot:O,floatingNodeId:Ac(O),floatingParentNodeId:Oc(),keyboardEventRelay:T?.relayKeyboardEvent}),j=w.type===`menubar`,M=g.useState(`disabled`),N=a||M||j&&w.context.disabled,{getButtonProps:ee,buttonRef:P}=pe({disabled:N,native:o});Z.useEffect(()=>{!x&&w.type===void 0&&(g.context.allowMouseUpTriggerRef.current=!1)},[g,x,w.type]);let F=Z.useRef(null),I=Ht(),te=D(e=>{if(!F.current)return;I.clear(),g.context.allowMouseUpTriggerRef.current=!1;let t=e.target;G(F.current,t)||G(g.select(`positionerElement`),t)||t===F.current||t!=null&&sT(t)===g.select(`rootId`)||WS(e,F.current)||O.events.emit(`close`,{domEvent:e,reason:Nt})});Z.useEffect(()=>{let e=f(F.current);if(x&&g.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,te,{once:!0}),()=>{e.removeEventListener(`mouseup`,te)}},[x,te,g]);let ne=j&&w.context.hasSubmenuOpen,L=jl(b,{enabled:(c??ne)&&!N&&(!j||ne&&!A),handleClose:ql({blockPointerEvents:!j}),mouseOnly:!0,move:!1,restMs:w.type===void 0?l:void 0,delay:{close:u},triggerElementRef:C,externalTree:O,isActiveTrigger:y,isClosing:()=>g.select(`transitionStatus`)===`ending`}),re=dT(x,g.select(`lastOpenChangeReason`)),ie=Hc(b,{enabled:!N,event:x&&j?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:w.type===void 0&&re}),ae=vl(b,{enabled:!N&&ne}),oe=lT({open:x,enabled:j,mouseDownAction:`open`}),R=Z.useMemo(()=>ue(ae.reference,ie.reference),[ae.reference,ie.reference]),z=g.useState(`triggerProps`,A),se=g.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:ce,handleFocusTargetFocus:le}=cT(g,C),de={disabled:N,open:x},fe=[F,t,P,k,C],me=[R,L??Ee,z,{"aria-haspopup":`menu`,"aria-controls":S,id:_,onMouseDown:e=>{g.select(`open`)||(I.start(200,()=>{g.context.allowMouseUpTriggerRef.current=!0}),f(e.currentTarget).addEventListener(`mouseup`,te,{once:!0}))}},se,j?{role:`menuitem`}:{},oe,m,ee],he=v(`button`,e,{enabled:!j,stateAttributesMapping:rc,state:de,ref:fe,props:me});return j?(0,Q.jsx)(oT,{tag:`button`,render:n,className:r,style:i,state:de,refs:fe,props:me,stateAttributesMapping:rc}):x?(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(pn,{ref:g.context.beforeTriggerFocusGuardRef,onFocus:ce},`${_}-pre-focus-guard`),(0,Q.jsx)(Z.Fragment,{children:he},_),(0,Q.jsx)(pn,{ref:g.context.triggerFocusTargetRef,onFocus:le},`${_}-post-focus-guard`)]}):(0,Q.jsx)(Z.Fragment,{children:he},_)});function dT(e,t){let n=Ht(),[r,i]=Z.useState(!1);return V(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function fT(){let e=qw(!0);return Z.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var pT={"aria-expanded":void 0},mT=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=fw(!0);if(p?.parent.type!==`menu`)throw Error(B(37));let m=uw(),h=Nw(),{store:g,parentVirtualFocus:_}=p,y=p.parent.store,b=zC({guess:!0,label:a}),x=bS(o),S=g.useState(`open`),C=Z.useRef(!1),w=g.useState(`positionerElement`),T=g.useState(`floatingRootContext`),E=g.useState(`floatingTreeRoot`),O=g.useState(`triggerPopupId`,x),k=Qc(x,g),A=D(e=>{k(e);let t=g.select(`activeTriggerElement`);e!==null&&g.select(`open`)&&(t===e||g.select(`activeTriggerId`)==null)&&g.update({activeTriggerId:x??null,activeTriggerElement:e,closeDelay:u})}),j=Z.useRef(null),M=Z.useCallback(e=>{j.current=e,g.set(`activeTriggerElement`,e)},[g]);V(()=>(A(j.current),()=>A(null)),[A,x,g]),V(()=>{if(!S||!w)return;function e(e){L(e)===g.context.beforeContentFocusGuardRef.current&&(C.current=e.relatedTarget===j.current)}return w.addEventListener(`focusout`,e,!0),()=>{C.current=!1,w.removeEventListener(`focusout`,e,!0)}},[S,w,g]),g.useSyncedValue(`closeDelay`,u);let N=g.useState(`disabled`),ee=y.useState(`disabled`),P=d||N||ee,F=y.useState(`itemProps`),I=y.useState(`isActive`,b.index),te=Z.useMemo(()=>({type:`submenu-trigger`,setActive(e){y.select(`highlightItemOnHover`)&&y.setActiveIndex(b.index,Qe,e)}}),[y,b.index]),{getItemProps:ne,itemRef:re}=xw({closeOnClick:!1,disabled:P,highlighted:I,id:x,store:g,typingRef:y.context.typingRef,nativeButton:s,itemMetadata:te,nodeId:m?.context.nodeId}),ie=jl(T,{enabled:g.useState(`hoverEnabled`)&&c&&!P,handleClose:ql({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:l,delay:{open:l,close:u},shouldOpen:l>0?()=>y.select(`allowMouseEnter`):void 0,triggerElementRef:j,externalTree:E,isClosing:()=>g.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),ae=Hc(T,{enabled:!P,event:`mousedown`,toggle:!0,ignoreMouse:c,stickIfOpen:c}).reference??Ee,oe=g.useState(`triggerProps`,!0);delete oe.id;let R={disabled:P,highlighted:I,open:S},z=g.useState(`openMethod`),se=g.useState(`lastOpenChangeReason`)===`list-navigation`||z===`keyboard`,ce=S&&se&&Re,le=h?.onTriggerKeyDown?{onKeyDown:h.onTriggerKeyDown}:void 0;return v(`div`,e,{state:R,stateAttributesMapping:nc,props:[ae,ie,oe,le,F,ce?pT:void 0,{"aria-controls":O,tabIndex:_||!(S||I)?-1:0,onFocus(e){g.select(`open`)&&C.current&&(C.current=!1,g.setOpen(!1,H(Qt,e.nativeEvent)))},onBlur(){I&&y.setActiveIndex(null,tn)}},f,ne],ref:[t,b.ref,re,A,M]})}),hT=Z.forwardRef(function(e,t){let n=_w(e,t,`submenu-trigger`);if(!n.visible)return null;let r=n.props?ue(n.props,e):e;return(0,Q.jsx)(mT,{...r,ref:n.ref})}),gT=Z.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:y,setFilled:b,validationMode:x,validation:S}=gS(),{clearErrors:C,elementRef:w,submitCountRef:T}=yS(),E=h||s,O=m??a,k={...p,disabled:E},{labelId:A}=SS(),j=CS({id:i}),M=o!==void 0,N=o==null?void 0:String(o),ee=D(()=>S.inputRef.current?.value);_S(S.inputRef,j,N,ee,!E,a),V(()=>{let e=N??S.inputRef.current?.value;e!==void 0&&b(e!==``)},[N,l,S.inputRef,b]),jS(N,()=>{N!==void 0&&(C(O),_(N!==(y.initialValue??``)),S.change(N))});let P=Z.useRef(null),F=HS(E,P),I=Ht();return v(`input`,e,{ref:[t,P],state:k,props:[{id:j,disabled:E,name:O,ref:S.inputRef,"aria-labelledby":A,autoFocus:u,...M?{value:o}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=H(tn,e.nativeEvent);c?.(t,n),!M&&(_(t!==(y.initialValue??``)),b(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(C(O),S.change(t)))},onFocus(){F(!0)},onBlur(e){if(g(!0),F(!1),x===`onBlur`){let t=e.currentTarget.value;S.commit(t),M&&queueMicrotask(()=>{let e=S.inputRef.current?.value;e!==void 0&&e!==t&&e!==(y.initialValue??``)&&S.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){g(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===w.current&&!e.defaultPrevented){let t=e.currentTarget,n=T.current;I.start(0,()=>{T.current===n&&S.commit(t.value)})}else S.commit(t)}}},f,e=>S.getValidationProps(E,e)],stateAttributesMapping:pS})}),_T=Z.forwardRef(function(e,t){return(0,Q.jsx)(gT,{ref:t,...e})});function vT(e){let t=(0,qs.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,type:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=Xt(`h-7 w-full min-w-0 rounded-md border border-input bg-input/20 px-2 py-0.5 text-sm transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-xs/relaxed file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-xs/relaxed dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==a||t[8]!==i?(o=(0,Q.jsx)(_T,{type:i,"data-slot":`input`,className:a,...r}),t[6]=r,t[7]=a,t[8]=i,t[9]=o):o=t[9],o}function yT(e){let t=(0,qs.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=Xt(`group/input-group relative flex h-7 w-full min-w-0 items-center rounded-md border border-input bg-input/20 transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-data-[align=block-end]:rounded-md has-data-[align=block-start]:rounded-md has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-2 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/30 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-2 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[textarea]:rounded-md has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var bT=jt(`flex h-auto cursor-text items-center justify-center gap-1 py-2 text-xs/relaxed font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 **:data-[slot=kbd]:rounded-[calc(var(--radius-sm)-2px)] **:data-[slot=kbd]:bg-muted-foreground/10 **:data-[slot=kbd]:px-1 **:data-[slot=kbd]:text-[0.625rem] [&>svg:not([class*='size-'])]:size-3.5`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.275rem] has-[>kbd]:ml-[-0.275rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.275rem] has-[>kbd]:mr-[-0.275rem]`,"block-start":`order-first w-full justify-start px-2 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function xT(e){let t=(0,qs.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,o;t[4]!==a||t[5]!==n?(o=Xt(bT({align:a}),n),t[4]=a,t[5]=n,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":`input-group-addon`,"data-align":a,className:o,onClick:ST,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function ST(e){e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()}var CT=jt(`flex items-center gap-2 rounded-md text-xs/relaxed shadow-none`,{variants:{size:{xs:`h-5 gap-1 rounded-[calc(var(--radius-sm)-2px)] px-1 [&>svg:not([class*='size-'])]:size-3`,sm:`gap-1`,"icon-xs":`size-6 p-0 has-[>svg]:p-0`,"icon-sm":`size-7 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function wT(e){let t=(0,qs.c)(15),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:n,type:i,variant:a,size:o,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=i===void 0?`button`:i,c=a===void 0?`ghost`:a,l=o===void 0?`xs`:o,u;t[6]!==n||t[7]!==l?(u=Xt(CT({size:l}),n),t[6]=n,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==r||t[10]!==l||t[11]!==u||t[12]!==s||t[13]!==c?(d=(0,Q.jsx)($e,{type:s,"data-size":l,variant:c,className:u,...r}),t[9]=r,t[10]=l,t[11]=u,t[12]=s,t[13]=c,t[14]=d):d=t[14],d}function TT(e){let t=(0,qs.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=Xt(`flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(vT,{"data-slot":`input-group-control`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ET(e){let t=(0,qs.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=Xt(`[&_svg:not([class*='size-'])]:size-3.5`,r),t[4]=r,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(Ns,{className:`pointer-events-none size-3.5 text-muted-foreground`}),t[6]=o):o=t[6];let s;return t[7]!==n||t[8]!==i||t[9]!==a?(s=(0,Q.jsxs)(ZS,{"data-slot":`combobox-trigger`,className:a,...i,children:[n,o]}),t[7]=n,t[8]=i,t[9]=a,t[10]=s):s=t[10],s}function DT(e){let t=(0,qs.c)(10),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]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(wT,{variant:`ghost`,size:`icon-xs`}),t[3]=i):i=t[3];let a;t[4]===n?a=t[5]:(a=Xt(n),t[4]=n,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(Ut,{className:`pointer-events-none`}),t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==a?(s=(0,Q.jsx)(aC,{"data-slot":`combobox-clear`,render:i,className:a,...r,children:o}),t[7]=r,t[8]=a,t[9]=s):s=t[9],s}function OT(e){let t=(0,qs.c)(28),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]):({className:r,children:n,disabled:a,showTrigger:o,showClear:s,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a!==void 0&&a,l=o===void 0||o,u=s!==void 0&&s,d;t[7]===r?d=t[8]:(d=Xt(`w-auto`,r),t[7]=r,t[8]=d);let f;t[9]===c?f=t[10]:(f=(0,Q.jsx)(TT,{disabled:c}),t[9]=c,t[10]=f);let p;t[11]!==i||t[12]!==f?(p=(0,Q.jsx)(rC,{render:f,...i}),t[11]=i,t[12]=f,t[13]=p):p=t[13];let m;t[14]!==c||t[15]!==l?(m=l&&(0,Q.jsx)(wT,{size:`icon-xs`,variant:`ghost`,render:(0,Q.jsx)(ET,{}),"data-slot":`input-group-button`,className:`group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent`,disabled:c}),t[14]=c,t[15]=l,t[16]=m):m=t[16];let h;t[17]!==c||t[18]!==u?(h=u&&(0,Q.jsx)(DT,{disabled:c}),t[17]=c,t[18]=u,t[19]=h):h=t[19];let g;t[20]!==m||t[21]!==h?(g=(0,Q.jsxs)(xT,{align:`inline-end`,children:[m,h]}),t[20]=m,t[21]=h,t[22]=g):g=t[22];let _;return t[23]!==n||t[24]!==d||t[25]!==p||t[26]!==g?(_=(0,Q.jsxs)(yT,{className:d,children:[p,g,n]}),t[23]=n,t[24]=d,t[25]=p,t[26]=g,t[27]=_):_=t[27],_}function kT(e){let t=(0,qs.c)(21),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({className:r,side:a,sideOffset:o,align:s,alignOffset:c,anchor:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=a===void 0?`bottom`:a,u=o===void 0?6:o,d=s===void 0?`start`:s,f=c===void 0?0:c,p=!!n,m;t[8]===r?m=t[9]:(m=Xt(`group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) 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-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-7 *:data-[slot=input-group]:border-none *:data-[slot=input-group]:bg-input/20 *:data-[slot=input-group]:shadow-none dark:bg-popover 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`,r),t[8]=r,t[9]=m);let h;t[10]!==i||t[11]!==p||t[12]!==m?(h=(0,Q.jsx)(RC,{"data-slot":`combobox-content`,"data-chips":p,className:m,...i}),t[10]=i,t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;return t[14]!==d||t[15]!==f||t[16]!==n||t[17]!==l||t[18]!==u||t[19]!==h?(g=(0,Q.jsx)(xC,{children:(0,Q.jsx)(IC,{side:l,sideOffset:u,align:d,alignOffset:f,anchor:n,className:`isolate z-50`,children:h})}),t[14]=d,t[15]=f,t[16]=n,t[17]=l,t[18]=u,t[19]=h,t[20]=g):g=t[20],g}function AT(e){let t=(0,qs.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=Xt(`no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(vC,{"data-slot":`combobox-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function jT(e){let t=(0,qs.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=Xt(`relative flex min-h-7 w-full cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs/relaxed outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,r),t[4]=r,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(ow,{render:(0,Q.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`}),children:(0,Q.jsx)(js,{className:`pointer-events-none`})}),t[6]=o):o=t[6];let s;return t[7]!==n||t[8]!==i||t[9]!==a?(s=(0,Q.jsxs)(KC,{"data-slot":`combobox-item`,className:a,...i,children:[n,o]}),t[7]=n,t[8]=i,t[9]=a,t[10]=s):s=t[10],s}function MT(e){let t=(0,qs.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)(nT,{"data-slot":`dropdown-menu`,...n}),t[2]=n,t[3]=r),r}function NT(e){let t=(0,qs.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)(uT,{"data-slot":`dropdown-menu-trigger`,...n}),t[2]=n,t[3]=r),r}function PT(e){let t=(0,qs.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=Xt(`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)(Bw,{"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)(Uw,{children:(0,Q.jsx)(Gw,{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 FT(e){let t=(0,qs.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)(Tw,{"data-slot":`dropdown-menu-group`,...n}),t[2]=n,t[3]=r),r}function IT(e){let t=(0,qs.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=Xt(`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)(Ew,{"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 LT(e){let t=(0,qs.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=Xt(`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)(Ow,{"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 RT(e){let t=(0,qs.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)(iT,{"data-slot":`dropdown-menu-sub`,...n}),t[2]=n,t[3]=r),r}function zT(e){let t=(0,qs.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=Xt(`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)(Fs,{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)(hT,{"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 BT(e){let t=(0,qs.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=Xt(`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)(PT,{"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 VT(e){let t=(0,qs.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=Xt(`-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)(wb,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function HT(e){let t=(0,qs.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=Xt(`pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-xs bg-muted px-1 font-sans text-[0.625rem] font-medium text-muted-foreground select-none in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 [&_svg:not([class*='size-'])]:size-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`kbd`,{"data-slot":`kbd`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var UT=q({id:J,name:J,signOut:To}),WT=Vn(Eo).atom(_n(Ai(`/auth/user`),Fo(Bi),Fo(Gr(UT)))),GT=ni(jn(``));function KT(){return Ba(vo(Ex(GT)))}function qT(){let e=(0,qs.c)(27),t=Ex(WT);if(!$n(t))return null;let n;e[0]===t.value.id?n=e[1]:(n=yn(`github:`,``)(t.value.id),e[0]=t.value.id,e[1]=n);let r=`https://avatars.githubusercontent.com/u/${n}?s=96`,i;e[2]!==t.value.name||e[3]!==r?(i=(0,Q.jsx)(rw,{src:r,alt:t.value.name}),e[2]=t.value.name,e[3]=r,e[4]=i):i=e[4];let a;e[5]===t.value.name?a=e[6]:(a=Qi(Wo(0,1)(t.value.name)),e[5]=t.value.name,e[6]=a);let o;e[7]===a?o=e[8]:(o=(0,Q.jsx)(iw,{children:a}),e[7]=a,e[8]=o);let s;e[9]!==i||e[10]!==o?(s=(0,Q.jsx)(NT,{"aria-label":`Account`,children:(0,Q.jsxs)(nw,{size:`sm`,children:[i,o]})}),e[9]=i,e[10]=o,e[11]=s):s=e[11];let c;e[12]===t.value.name?c=e[13]:(c=(0,Q.jsx)(FT,{children:(0,Q.jsxs)(IT,{children:[`@`,t.value.name]})}),e[12]=t.value.name,e[13]=c);let l;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(VT,{}),e[14]=l):l=e[14];let u=!t.value.signOut,d;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(d=new URLSearchParams({next:location.href}),e[15]=d):d=e[15];let f=`/auth/sign-out?${d}`,p;e[16]===f?p=e[17]:(p=(0,Q.jsx)(`a`,{"aria-label":`Sign out`,href:f}),e[16]=f,e[17]=p);let m;e[18]!==p||e[19]!==u?(m=(0,Q.jsx)(LT,{variant:`destructive`,disabled:u,render:p,children:`Sign out`}),e[18]=p,e[19]=u,e[20]=m):m=e[20];let h;e[21]!==m||e[22]!==c?(h=(0,Q.jsxs)(PT,{align:`end`,className:`w-auto min-w-48`,children:[c,l,m]}),e[21]=m,e[22]=c,e[23]=h):h=e[23];let g;return e[24]!==h||e[25]!==s?(g=(0,Q.jsxs)(MT,{children:[s,h]}),e[24]=h,e[25]=s,e[26]=g):g=e[26],g}function JT(e){let t=(0,qs.c)(66),[n,r]=kx(GT),[i,a]=(0,Z.useState)(!1),o;t[0]===n?o=t[1]:(o=()=>n!==``,t[0]=n,t[1]=o);let[s,c]=(0,Z.useState)(o),l=(0,Z.useRef)(null),u=(0,Z.useRef)(null),d,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=function(e){e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),c(!0),l.current?.focus())};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},f=[],t[2]=d,t[3]=f):(d=t[2],f=t[3]),(0,Z.useEffect)(d,f);let p,m,h,g,_,v,y,b,x,S,C;if(t[4]!==i||t[5]!==e.commands||t[6]!==e.label||t[7]!==n||t[8]!==s||t[9]!==r){let a;t[21]===n?a=t[22]:(a=e=>ko(Ba(vo(n)))(Ba(e.label)),t[21]=n,t[22]=a),m=Mo(e.commands,a);let o,d;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{(0,Ks.flushSync)(()=>c(!0)),l.current?.focus()},d=(0,Q.jsx)(Vs,{}),t[23]=o,t[24]=d):(o=t[23],d=t[24]),t[25]===e.label?g=t[26]:(g=(0,Q.jsx)($e,{variant:`ghost`,size:`icon-sm`,"aria-label":e.label,className:`ml-auto sm:hidden`,onClick:o,children:d}),t[25]=e.label,t[26]=g),C=u;let f=s&&`max-sm:bg-background max-sm:absolute max-sm:inset-0 max-sm:z-10 max-sm:flex max-sm:max-w-none max-sm:items-center max-sm:gap-2 max-sm:px-3`;t[27]===f?h=t[28]:(h=Xt(`mx-auto hidden w-full max-w-sm sm:flex lg:absolute lg:left-1/2 lg:-translate-x-1/2`,f),t[27]=f,t[28]=h),p=RS,_=m,v=null,y=YT,b=n,t[29]===r?x=t[30]:(x=(e,t)=>{t.reason!==`item-press`&&r(e)},t[29]=r,t[30]=x),S=i&&no(m),t[4]=i,t[5]=e.commands,t[6]=e.label,t[7]=n,t[8]=s,t[9]=r,t[10]=p,t[11]=m,t[12]=h,t[13]=g,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S,t[20]=C}else p=t[10],m=t[11],h=t[12],g=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18],S=t[19],C=t[20];let w=n!==``,T;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>a(!0),t[31]=T):T=t[31];let E;t[32]!==m||t[33]!==i||t[34]!==r?(E=e=>{e.key!==`Escape`||i&&no(m)||(r(``),c(!1),e.currentTarget.blur())},t[32]=m,t[33]=i,t[34]=r,t[35]=E):E=t[35];let D;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Q.jsx)(xT,{children:(0,Q.jsx)(Vs,{})}),t[36]=D):D=t[36];let O;t[37]===n?O=t[38]:(O=n===``&&(0,Q.jsx)(xT,{align:`inline-end`,className:`max-sm:hidden`,children:(0,Q.jsx)(HT,{children:`⌘K`})}),t[37]=n,t[38]=O);let k;t[39]!==e.label||t[40]!==w||t[41]!==E||t[42]!==O?(k=(0,Q.jsxs)(OT,{ref:l,"aria-label":e.label,placeholder:`Search or run a command`,showTrigger:!1,showClear:w,className:`w-full`,onFocus:T,onKeyDown:E,children:[D,O]}),t[39]=e.label,t[40]=w,t[41]=E,t[42]=O,t[43]=k):k=t[43];let A;t[44]===r?A=t[45]:(A=(0,Q.jsx)(kT,{anchor:u,children:(0,Q.jsx)(AT,{children:e=>(0,Q.jsxs)(jT,{value:e,onClick:()=>{r(``),c(!1),e.run()},children:[e.icon,e.label]},e.label)})}),t[44]=r,t[45]=A);let j;t[46]!==p||t[47]!==k||t[48]!==A||t[49]!==_||t[50]!==v||t[51]!==y||t[52]!==b||t[53]!==x||t[54]!==S?(j=(0,Q.jsxs)(p,{items:_,filter:v,itemToStringValue:y,value:b,onValueChange:x,open:S,onOpenChange:a,autoHighlight:!0,children:[k,A]}),t[46]=p,t[47]=k,t[48]=A,t[49]=_,t[50]=v,t[51]=y,t[52]=b,t[53]=x,t[54]=S,t[55]=j):j=t[55];let M;t[56]===r?M=t[57]:(M=(0,Q.jsx)($e,{variant:`ghost`,size:`sm`,className:`sm:hidden`,onClick:()=>{r(``),c(!1)},children:`Cancel`}),t[56]=r,t[57]=M);let N;t[58]!==h||t[59]!==j||t[60]!==M||t[61]!==C?(N=(0,Q.jsxs)(`div`,{ref:C,className:h,children:[j,M]}),t[58]=h,t[59]=j,t[60]=M,t[61]=C,t[62]=N):N=t[62];let ee;return t[63]!==g||t[64]!==N?(ee=(0,Q.jsxs)(Q.Fragment,{children:[g,N]}),t[63]=g,t[64]=N,t[65]=ee):ee=t[65],ee}function YT(e){return e.label}function XT(e){let t=(0,qs.c)(11),n;t[0]===e.active?n=t[1]:(n=Vi(e.active,{onFalse:eE,onTrue:$T}),t[0]=e.active,t[1]=n);let r=e.children,i;t[2]===e.active?i=t[3]:(i=cn({variant:Vi(e.active,{onFalse:QT,onTrue:ZT})}),t[2]=e.active,t[3]=i);let a;t[4]!==e.children||t[5]!==n||t[6]!==i?(a={"aria-current":n,children:r,className:i},t[4]=e.children,t[5]=n,t[6]=i,t[7]=a):a=t[7];let o;return t[8]!==e.render||t[9]!==a?(o={props:a,render:e.render},t[8]=e.render,t[9]=a,t[10]=o):o=t[10],qC(o)}function ZT(){return`secondary`}function QT(){return`ghost`}function $T(){return`page`}function eE(){}function tE(e){let t=(0,qs.c)(25),n;t[0]===e.icon?n=t[1]:(n=(0,Q.jsx)(`img`,{src:e.icon,alt:``,className:`pixelated size-8`}),t[0]=e.icon,t[1]=n);let r;t[2]===e.name?r=t[3]:(r=(0,Q.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.name}),t[2]=e.name,t[3]=r);let i;t[4]!==n||t[5]!==r?(i=(0,Q.jsxs)(`a`,{href:`/`,className:`-ml-1 flex shrink-0 items-center gap-1.5`,children:[n,r]}),t[4]=n,t[5]=r,t[6]=i):i=t[6];let a;t[7]===e.tabs?a=t[8]:(a=e.tabs!==void 0&&(0,Q.jsx)(`nav`,{"aria-label":`Sections`,className:`ml-2 flex items-center gap-1`,children:e.tabs}),t[7]=e.tabs,t[8]=a);let o;t[9]===e.commands?o=t[10]:(o=e.commands===void 0&&(0,Q.jsx)(`span`,{className:`flex-1`}),t[9]=e.commands,t[10]=o);let s;t[11]!==e.commands||t[12]!==e.name?(s=e.commands!==void 0&&(0,Q.jsx)(JT,{commands:e.commands,label:`Search ${e.name}`}),t[11]=e.commands,t[12]=e.name,t[13]=s):s=t[13];let c;t[14]===e.account?c=t[15]:(c=e.account??(0,Q.jsx)(qT,{}),t[14]=e.account,t[15]=c);let l;t[16]!==e.action||t[17]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 lg:ml-auto`,children:[e.action,c]}),t[16]=e.action,t[17]=c,t[18]=l):l=t[18];let u;return t[19]!==i||t[20]!==a||t[21]!==o||t[22]!==s||t[23]!==l?(u=(0,Q.jsxs)(`header`,{className:`bg-background border-border sticky top-0 z-30 flex h-12 shrink-0 items-center gap-2 border-b px-4`,children:[i,a,o,s,l]}),t[19]=i,t[20]=a,t[21]=o,t[22]=s,t[23]=l,t[24]=u):u=t[24],u}function nE(e){let t=(0,qs.c)(5),n=e.className,r;t[0]===e.result?r=t[1]:(r=Xa(Ar(Kn(e.result),rE)),t[0]=e.result,t[1]=r);let i;return t[2]!==e.className||t[3]!==r?(i=(0,Q.jsx)(Eb,{className:n,children:r}),t[2]=e.className,t[3]=r,t[4]=i):i=t[4],i}function rE(e){return e.message}var iE=jt(`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 aE(e){let t=(0,qs.c)(6),n;t[0]!==e.className||t[1]!==e.status||t[2]!==e.waiting?(n=Xt(iE({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}function oE(e){let t=(0,qs.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=Xt(`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 sE(e){let t=(0,qs.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=Xt(`[&_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 cE(e){let t=(0,qs.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=Xt(`[&_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 lE(e){let t=(0,qs.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=Xt(`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 uE(e){let t=(0,qs.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=Xt(`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 dE(e){let t=(0,qs.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=Xt(`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 fE=`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`,pE=`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`,mE=`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`,hE=`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`,gE=`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`,_E=`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`,vE=`/assets/firefox-5m8yovBp.svg`,yE=`/assets/safari-DgmPRf57.svg`;function bE(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 xE(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 SE(){return CE.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var CE={stubThis:e=>e};function wE(e){let{id:t}=e;return{...e,id:xE(t),transports:e.transports,type:e.type}}function TE(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 EE=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 DE({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 EE({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 EE({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 EE({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 EE({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 EE({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new EE({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 EE({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new EE({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(!TE(t))return new EE({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new EE({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 EE({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 EE({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 OE=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}}},kE=[`cross-platform`,`platform`];function AE(e){if(e&&!(kE.indexOf(e)<0))return e}async function jE(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(!SE())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:xE(t.challenge),user:{...t.user,id:xE(t.user.id)},excludeCredentials:t.excludeCredentials?.map(wE)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=OE.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw DE({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){ME(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=bE(e))}catch(e){ME(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=bE(c.getAuthenticatorData())}catch(e){ME(`getAuthenticatorData()`,e)}return{id:o,rawId:bE(s),response:{attestationObject:bE(c.attestationObject),clientDataJSON:bE(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:AE(a.authenticatorAttachment)}}function ME(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 NE(){if(!SE())return PE.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?PE.stubThis(new Promise(e=>e(!1))):PE.stubThis(e.isConditionalMediationAvailable())}var PE={stubThis:e=>e};function FE({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 EE({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new EE({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!TE(t))return new EE({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new EE({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 EE({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 IE(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(!SE())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(wE));let a={...t,challenge:xE(t.challenge),allowCredentials:i},o={};if(n){if(!await NE())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=OE.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw FE({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=bE(u.userHandle)),{id:c,rawId:bE(l),response:{authenticatorData:bE(u.authenticatorData),clientDataJSON:bE(u.clientDataJSON),signature:bE(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:AE(s.authenticatorAttachment)}}var LE=by,RE=Sy,zE=wy,BE=`https://auth.mp281x.xyz`;ao(Qo(ua(`AUTH_URL`)),Sn),Ii()(`@deslop/runtime/auth/lib/utils/CurrentUser`);var VE=class e extends to()(`@deslop/runtime/auth/lib/utils/RpcAuth`,{error:at}){static layerClient=t=>Jo(e,e=>la(function*(){return yield*e.next({...e.request,headers:ro(e.request.headers,`authorization`,`Bearer ${yield*t}`)})}))},HE=q({name:gs,open:gs,origin:$t}),UE=Ea(HE);q({origin:$t});var WE=Ss([`ble`,`cable`,`hybrid`,`internal`,`nfc`,`smart-card`,`usb`]),GE=is(`public-key`),KE=Ss([`required`,`preferred`,`discouraged`]),qE=q({id:J,transports:vr(ki(Ea(WE))),type:GE}),JE=q({attestation:vr(Ss([`direct`,`enterprise`,`indirect`,`none`])),authenticatorSelection:vr(q({authenticatorAttachment:vr(Ss([`cross-platform`,`platform`])),requireResidentKey:vr(To),residentKey:vr(Ss([`discouraged`,`preferred`,`required`])),userVerification:vr(KE)})),challenge:J,excludeCredentials:vr(ki(Ea(qE))),pubKeyCredParams:ki(Ea(q({alg:La,type:GE}))),rp:q({id:vr(J),name:J}),timeout:vr(La),user:q({displayName:J,id:J,name:J})}),YE=q({allowCredentials:vr(ki(Ea(qE))),challenge:J,rpId:vr(J),timeout:vr(La),userVerification:vr(KE)}),XE=vr(Ss([`cross-platform`,`platform`])),ZE=q({authenticatorAttachment:XE,clientExtensionResults:q({}),id:J,rawId:J,response:q({attestationObject:J,clientDataJSON:J,transports:vr(Ea(J))}),type:GE}),QE=q({authenticatorAttachment:XE,clientExtensionResults:q({}),id:J,rawId:J,response:q({authenticatorData:J,clientDataJSON:J,signature:J,userHandle:vr(J)}),type:GE});q({challenge:J});var $E=q({addedFrom:J,counter:ja,createdAt:La,id:gs,lastUsed:La,publicKey:gs,synced:To,transports:Ea(WE),user:Lt});Ea($E);var eD=q({addedFrom:J,createdAt:La,id:gs,lastUsed:La,synced:To}),tD=q({id:gs}),nD=q({response:ZE}),rD=q({next:vr(gs.check(ti(2048))),response:QE}),iD=q({client_name:vr(J.check(ti(100))),redirect_uris:oa(gs.check(ti(200))).check(ti(4)),token_endpoint_auth_method:vr(is(`none`))});q({name:J,redirects:iD.fields.redirect_uris}),q({client_id:gs.check(ti(2048)),redirect_uri:vr(J),state:vr(J)}),q({code_challenge:vr(gs),code_challenge_method:vr(J),resource:vr(ha(J)),response_type:vr(J),scope:vr(J)});var aD=q({challenge:gs,clientId:gs,clientName:J,redirectUri:gs,resources:oa(dt),state:vr(gs)});q({grant_type:J});var oD=vr(ha(dt).check(Ds(1)));Ja([q({client_id:gs,code:gs,code_verifier:gs,grant_type:is(`authorization_code`),redirect_uri:vr(J),resource:oD}),q({client_id:vr(J),grant_type:is(`refresh_token`),refresh_token:gs,resource:oD})]);var sD=q({access_token:gs,expires_in:La,refresh_token:gs,scope:is(`deslop`),token_type:is(`Bearer`)});En({Granted:{tokens:sD},Replayed:{message:J}});var cD=q({address:vr(J),userAgent:vr(J)}),lD=q({expiresAt:La,hash:J,resources:Ea(dt)}),uD=Ss([`Code`,`GitHub`,`Passkey`]),dD=q({client:J,createdAt:La,credential:En({App:{access:Ea(lD),clientId:gs,expiresAt:La,generation:ja,hash:J,replaced:vr(J),resources:Ea(dt)},Browser:{expiresAt:La,hash:J,via:vr(uD)}}),device:J,lastActive:La,origin:cD,user:Lt});us(J,dD);var fD=q({address:vr(J),client:J,device:J,family:gs,kind:Ss([`App`,`Browser`]),lastActive:La,resources:Ea(dt)}),pD=q({family:gs});q({client_id:gs,token:gs}),q({resource:dt});var mD=Ss([`Admin`,`Member`,`Waiting`]),hD=q({...Lt.fields,fullName:vr(J),role:mD}),gD=q({...hD.fields,via:uD}),_D=q({...hD.fields,since:La}),vD=Ss([`Waiting`,`Allowed`]),yD=q({fullName:J,id:gs,name:gs,since:La,status:vD});Ea(yD),q({id:ja,login:gs,name:vr(si(J))});var bD=q({allow:To,id:gs}),xD=q({id:gs}),SD=Ss([`App`,`Browser`]),CD=q({address:vr(J),clientName:J,createdAt:La,device:J,expiresAt:La,id:gs,kind:SD,resources:Ea(dt)}),wD=En({Decided:{},Expired:{},Waiting:{request:CD}}),TD=En({Browser:{next:vr(J)},Client:{request:aD}});En({Redirect:{url:gs},Session:{next:vr(J),seconds:ja,token:gs},Waiting:{}}),q({delivery:TD,origin:cD}),q({next:vr(gs.check(ti(2048)))});var ED=q({request:gs.check(ti(20))}),DD=q({code:gs.check(ti(20))}),OD=q({...ED.fields,accept:To}),kD=class extends da(Ma(`auth.lookup`,{error:at,payload:DD,stream:!0,success:In(CD)}),Ma(`auth.answer`,{error:at,payload:OD}),Ma(`auth.people`,{error:at,stream:!0,success:Ea(_D)}),Ma(`auth.admit`,{error:at,payload:bD,success:_D}),Ma(`auth.remove`,{error:at,payload:xD,success:_D}),Ma(`auth.apps`,{error:at,stream:!0,success:Ea(fD)}),Ma(`auth.catalog`,{error:at,stream:!0,success:UE}),Ma(`auth.disconnect`,{error:at,payload:pD}),Ma(`auth.passkeys`,{error:at,stream:!0,success:Ea(eD)}),Ma(`auth.passkeyOptions`,{error:at,success:JE}),Ma(`auth.addPasskey`,{error:at,payload:nD}),Ma(`auth.removePasskey`,{error:at,payload:tD})).middleware(VE).merge(da(Ma(`auth.account`,{error:at,stream:!0,success:gD}),Ma(`auth.wait`,{error:at,payload:ED,stream:!0,success:wD}))){};function AD(e){return Qi(_a(/[^a-z]/giu,``)(e))}t(((e,t,n)=>{(function(e){let n=`(0?\\d+|0x[a-f0-9]+)`,r={fourOctet:RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,`i`),threeOctet:RegExp(`^${n}\\.${n}\\.${n}$`,`i`),twoOctet:RegExp(`^${n}\\.${n}$`,`i`),longValue:RegExp(`^${n}$`,`i`)},i=RegExp(`^0[0-7]+$`,`i`),a=RegExp(`^0x[a-f0-9]+$`,`i`),o=`%[0-9a-z]{1,}`,s=`(?:[0-9a-f]+::?)+`,c={zoneIndex:RegExp(o,`i`),native:RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,`i`),deprecatedTransitional:RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,`i`),transitional:RegExp(`^((?:${s})|(?:::)(?:${s})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,`i`)};function l(e,t){if(e.indexOf(`::`)!==e.lastIndexOf(`::`))return null;let n=0,r=-1,i=(e.match(c.zoneIndex)||[])[0],a,o;for(i&&(i=i.substring(1),e=e.replace(/%.+$/,``));(r=e.indexOf(`:`,r+1))>=0;)n++;if(e.substr(0,2)===`::`&&n--,e.substr(-2,2)===`::`&&n--,n>=t)return null;for(o=t-n,a=`:`;o--;)a+=`0:`;return e=e.replace(`::`,a),e[0]===`:`&&(e=e.slice(1)),e[e.length-1]===`:`&&(e=e.slice(0,-1)),t=(function(){let t=e.split(`:`),n=[];for(let e=0;e<t.length;e++)n.push(t[e].length>4?NaN:parseInt(t[e],16));return n})(),{parts:t,zoneId:i}}function u(e,t,n,r){if(e.length!==t.length)throw Error(`ipaddr: cannot match CIDR for objects with different lengths`);let i=0,a;for(;r>0;){if(a=n-r,a<0&&(a=0),e[i]>>a!==t[i]>>a)return!1;r-=n,i+=1}return!0}function d(e){if(a.test(e))return parseInt(e,16);if(e[0]===`0`&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function f(e,t){for(;e.length<t;)e=`0${e}`;return e}let p={};p.IPv4=(function(){function e(e){if(e.length!==4)throw Error(`ipaddr: ipv4 octet count should be 4`);let t,n;for(t=0;t<e.length;t++)if(n=e[t],!(0<=n&&n<=255))throw Error(`ipaddr: ipv4 octet should fit in 8 bits`);this.octets=e}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]],as112:[[new e([192,175,48,0]),24],[new e([192,31,196,0]),24]],amt:[[new e([192,52,193,0]),24]]},e.prototype.kind=function(){return`ipv4`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv4`)throw Error(`ipaddr: cannot match ipv4 address with non-ipv4 one`);return u(this.octets,e.octets,8,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},r,i,a;for(r=3;r>=0;--r)if(i=this.octets[r],i in n){if(a=n[i],t&&a!==0)return null;a!==8&&(t=!0),e+=a}else return null;return 32-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(`.`)},e})(),p.IPv4.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<4;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.isIPv4=function(e){return this.parser(e)!==null},p.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch{return!1}},p.IPv4.isValidCIDR=function(e){try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(e){return!!(p.IPv4.isValid(e)&&e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.isValidCIDRFourPartDecimal=function(e){let t=e.match(/^(.+)\/(\d+)$/);return!p.IPv4.isValidCIDR(e)||!t?!1:p.IPv4.isValidFourPartDecimal(t[1])},p.IPv4.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv4 Address`);return new this(t)},p.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){let e=parseInt(t[2]);if(e>=0&&e<=32){let n=[this.parse(t[1]),e];return Object.defineProperty(n,"toString",{value:function(){return this.join(`/`)}}),n}}throw Error(`ipaddr: string is not formatted like an IPv4 CIDR range`)},p.IPv4.parser=function(e){let t,n,i;if(t=e.match(r.fourOctet))return(function(){let e=t.slice(1,6),r=[];for(let t=0;t<e.length;t++)n=e[t],r.push(d(n));return r})();if(t=e.match(r.longValue)){if(i=d(t[1]),i>4294967295||i<0)throw Error(`ipaddr: address outside defined range`);return(function(){let e=[],t=0;for(;t<=24;t+=8)e.push(i>>t&255);return e})().reverse()}return(t=e.match(r.twoOctet))?(function(){let e=t.slice(1,4),n=[];if(i=d(e[1]),i>16777215||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(i>>16&255),n.push(i>>8&255),n.push(i&255),n})():(t=e.match(r.threeOctet))?(function(){let e=t.slice(1,5),n=[];if(i=d(e[2]),i>65535||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(d(e[1])),n.push(i>>8&255),n.push(i&255),n})():null},p.IPv4.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>32)throw Error(`ipaddr: invalid IPv4 prefix length`);let t=[0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<4&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.IPv6=(function(){function e(e,t){let n,r;if(e.length===16)for(this.parts=[],n=0;n<=14;n+=2)this.parts.push(e[n]<<8|e[n+1]);else if(e.length===8)this.parts=e;else throw Error(`ipaddr: ipv6 part count should be 8 or 16`);for(n=0;n<this.parts.length;n++)if(r=this.parts[n],!(0<=r&&r<=65535))throw Error(`ipaddr: ipv6 part should fit in 16 bits`);t&&(this.zoneId=t)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],deprecatedSiteLocal:[new e([65216,0,0,0,0,0,0,0]),10],discard:[new e([256,0,0,0,0,0,0,0]),64],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[[new e([100,65435,0,0,0,0,0,0]),96],[new e([100,65435,1,0,0,0,0,0]),48]],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[[new e([8193,4,274,0,0,0,0,0]),48],[new e([9760,79,32768,0,0,0,0,0]),48]],deprecatedOrchid:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new e([8193,48,0,0,0,0,0,0]),28],segmentRouting:[new e([24320,0,0,0,0,0,0,0]),16],reserved:[[new e([8193,0,0,0,0,0,0,0]),23],[new e([8193,3512,0,0,0,0,0,0]),32],[new e([16383,0,0,0,0,0,0,0]),20]]},e.prototype.isIPv4MappedAddress=function(){return this.range()===`ipv4Mapped`},e.prototype.kind=function(){return`ipv6`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv6`)throw Error(`ipaddr: cannot match ipv6 address with non-ipv6 one`);return u(this.parts,e.parts,16,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},r,i;for(let a=7;a>=0;--a)if(r=this.parts[a],r in n){if(i=n[r],t&&i!==0)return null;i!==16&&(t=!0),e+=i}else return null;return 128-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e,t=[],n=this.parts;for(let r=0;r<n.length;r++)e=n[r],t.push(e>>8),t.push(e&255);return t},e.prototype.toFixedLengthString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(f(this.parts[t].toString(16),4));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw Error(`ipaddr: trying to convert a generic ipv6 address to ipv4`);let e=this.parts.slice(-2),t=e[0],n=e[1];return new p.IPv4([t>>8,t&255,n>>8,n&255])},e.prototype.toNormalizedString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(this.parts[t].toString(16));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toRFC5952String=function(){let e=/((^|:)(0(:|$)){2,})/g,t=``;this.zoneId&&(t=`%${this.zoneId}`);let n=this.toNormalizedString(),r=n.slice(0,n.length-t.length),i=0,a=-1,o=-1,s;for(;s=e.exec(r);){let e=(s[0].match(/0/g)||[]).length;e>o&&(o=e,i=s.index,a=s[0].length)}return a<0?r+t:`${r.substring(0,i)}::${r.substring(i+a)}${t}`},e.prototype.toString=function(){return this.toRFC5952String()},e})(),p.IPv6.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<16;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.isIPv6=function(e){return this.parser(e)!==null},p.IPv6.isValid=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{let t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch{return!1}},p.IPv6.isValidCIDR=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<16;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv6 Address`);return new this(t.parts,t.zoneId)},p.IPv6.parseCIDR=function(e){let t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=128))return r=[this.parse(n[1]),t],Object.defineProperty(r,"toString",{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv6 CIDR range`)},p.IPv6.parser=function(e){let t,n,r,i,a,o;if(r=e.match(c.deprecatedTransitional))return this.parser(`::ffff:${r[1]}`);if(c.native.test(e))return l(e,8);if((r=e.match(c.transitional))&&(o=r[6]||``,t=r[1],r[1].endsWith(`::`)||(t=t.slice(0,-1)),t=l(t+o,6),t&&t.parts)){for(a=[parseInt(r[2]),parseInt(r[3]),parseInt(r[4]),parseInt(r[5])],n=0;n<a.length;n++)if(i=a[n],!(0<=i&&i<=255))return null;return t.parts.push(a[0]<<8|a[1]),t.parts.push(a[2]<<8|a[3]),{parts:t.parts,zoneId:t.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>128)throw Error(`ipaddr: invalid IPv6 prefix length`);let t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<16&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.fromByteArray=function(e){let t=e.length;if(t===4)return new p.IPv4(e);if(t===16)return new p.IPv6(e);throw Error(`ipaddr: the binary input is neither an IPv6 nor IPv4 address`)},p.isValid=function(e){return p.IPv6.isValid(e)||p.IPv4.isValid(e)},p.isValidCIDR=function(e){return p.IPv6.isValidCIDR(e)||p.IPv4.isValidCIDR(e)},p.parse=function(e){if(p.IPv6.isValid(e))return p.IPv6.parse(e);if(p.IPv4.isValid(e))return p.IPv4.parse(e);throw Error(`ipaddr: the address has neither IPv6 nor IPv4 format`)},p.parseCIDR=function(e){try{return p.IPv6.parseCIDR(e)}catch{try{return p.IPv4.parseCIDR(e)}catch(e){throw Error(`ipaddr: the address has neither IPv6 nor IPv4 CIDR format`,{cause:e})}}},p.process=function(e){let t=this.parse(e);return t.kind()===`ipv6`&&t.isIPv4MappedAddress()?t.toIPv4Address():t},p.subnetMatch=function(e,t,n){let r,i,a,o;for(i in n??=`unicast`,t)if(Object.prototype.hasOwnProperty.call(t,i)){for(a=t[i],a[0]&&!(a[0]instanceof Array)&&(a=[a]),r=0;r<a.length;r++)if(o=a[r],e.kind()===o[0].kind()&&e.match.apply(e,o))return i}return n},t!==void 0&&t.exports?t.exports=p:e.ipaddr=p})(n)}))();function jD(e){return os(Rn(e),Ri)}Ha(function*(e,t,n){if(Sn(jD(n.response_type)))return yield*at.make({message:`Send response_type=code`});if(n.response_type!==`code`)return yield*at.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*at.make({message:`Send a PKCE code_challenge with code_challenge_method=S256`});if(!fo(Mo(po(n.scope??``,` `),Ri),e=>e===`deslop`||e===`offline_access`))return yield*at.make({error:`invalid_scope`,message:`Only the deslop scope is supported`});let r=yield*_n(Pr(oa(dt))(n.resource??[]),Ta(e=>at.make({cause:e,error:`invalid_target`,message:`Name a Deslop app with the resource parameter`})));return aD.make({challenge:n.code_challenge,clientId:e.client_id,clientName:t.clientName,redirectUri:t.redirectUri,resources:r,...Vr(jD(e.state),{onNone:()=>({}),onSome:e=>({state:e})})})});function MD(e){return _n(new URL(e).hostname,po(`.`),Uo(1),Ca(`.`))}function ND(e,t){let n=MD(t);return ri(qo(e),{onFailure:()=>!1,onSuccess:e=>e.protocol===`https:`&&(e.hostname===n||_r(`.${n}`)(e.hostname))&&fr(e.username)&&fr(e.password)})}var PD=Vn(Eo),FD=class extends Sa()(`@deslop/auth/lib/utils/RpcClient`,{group:kD,protocol:nt(`@deslop/auth`)}){};function ID(e){return Wn(e,e=>_n(e(rr(`1 second`)),_i(e=>e.input._tag===`RpcClientError`)))}var LD=ni(FD.runtime.atom(_n(FD,ma(e=>e(`auth.account`,void 0)),Ka,ID,ai(br),Co(`AuthError`,()=>ms(qn()))))),RD={accept:To,request:CD},zD=xb(FD.runtime).make(RE({branches:{looked:{found:{target:`Code.Found`},missing:{target:`Code.Missing`}}},events:zE({Answered:RD,Typed:{typed:J}}),root:LE({states:{Code:{fields:{code:J},states:{Failed:{fields:{message:J}},Found:{fields:{request:CD}},Looking:{},Missing:{}}},Typing:{fields:{answered:vr(q(RD)),typed:J}}}}),streams:{lookup:e=>ID(Ka(ma(FD,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=>Vr(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=>Ni(e.state.typed)>=8,target:`Code`}}}})),BD=jn(e=>{e.set(zD.send,{_tag:`Typed`,typed:AD(new URLSearchParams(location.search).get(`code`)??``)})}),VD=ni(FD.runtime.atom(_n(FD,ma(e=>e(`auth.people`,void 0)),Ka,ID))),HD=ni(FD.runtime.atom(_n(FD,ma(e=>e(`auth.apps`,void 0)),Ka,ID)));function UD(e){return t=>$a(t,t=>K(()=>W.add({description:t.message,title:e,type:`error`})))}var WD=FD.runtime.fn(e=>_n(Fo(FD,t=>ea(e,e=>t(`auth.disconnect`,{family:e}),{concurrency:`unbounded`,discard:!0})),UD(`Cannot sign out`))),GD=_s(e=>FD.runtime.fn(t=>Fo(FD,n=>n(`auth.admit`,{allow:t,id:e})))),KD=_s(e=>FD.runtime.fn(()=>Fo(FD,t=>t(`auth.remove`,{id:e})))),qD=Hn(new URLSearchParams(location.search).get(`request`)),JD=_s(e=>FD.runtime.atom(_n(FD,ma(t=>t(`auth.wait`,{request:e})),Ka,ID,Qa(t=>_n(xo(t),Io(`Decided`,()=>K(()=>location.assign(`/auth/continue?${new URLSearchParams({request:e})}`))),go(()=>Y))))));function YD(e){return`${Wo(0,4)(e)}-${Wo(4)(e)}`}function XD(e){return`${location.origin}/?code=${e}`}var ZD=ni(FD.runtime.atom(_n(FD,ma(e=>e(`auth.catalog`,void 0)),Ka,ID)));function QD(e){return Yo(e)?[`browser`]:ga(So(e,e=>new URL(e).origin))}function $D(e){return _n(wa(e),pa({hour:`2-digit`,minute:`2-digit`}))}var eO=jn(_n(wn(`1 minute`),Pn(()=>Hr))),tO=jn(_n(wn(`1 second`),Pn(()=>Hr)));function nO(e,t){let n=Ro(0,Math.ceil((e-t)/1e3));return`${Math.floor(n/60)}:${Yr(2,`0`)(`${n%60}`)}`}var rO=ta(e=>_n(Tn({catch:e=>at.make({cause:e,message:`Cannot copy the code; type it in instead`}),try:()=>navigator.clipboard.writeText(e)}),X(ls(`1200 millis`))));function iO(e,t){return Math.floor(ur(Xo(wa(e),wa(t))))}function aO(e){return e<1?`now`:e<60?`${e}m`:e<1440?`${Math.floor(e/60)}h`:`${Math.floor(e/1440)}d`}function oO(e,t){return`${e} · ${t}`}function sO(e){return Da(e,0,(e,t)=>Ro(e,t.lastActive))}function cO(e){return _n(wa(e),pa({day:`numeric`,month:`short`}))}function lO(e){return`https://avatars.githubusercontent.com/u/${yn(`github:`,``)(e)}?s=96`}var uO=FD.runtime.fn((e,t)=>_n(FD,Fo(t=>t(`auth.answer`,{accept:e.accept,request:e.request.id})),X(K(()=>t.set(zD.send,{_tag:`Answered`,...e}))))),dO=Hn(new URLSearchParams(location.search).get(`next`));function fO(e){return Zn(e.cause,`name`)&&e.cause.name===`NotAllowedError`}var pO=Ha(function*(e){return e.status===429?yield*at.make({message:`Too many tries; wait a minute and try again`}):yield*at.make({message:(yield*Gr(q({error_description:J}))(e)).error_description})}),mO=PD.fn(()=>_n(la(function*(){let e=yield*lr,t=yield*e.get(`/auth/passkey`);if(t.status!==200)return yield*pO(t);let n=yield*Gr(YE)(t),r=yield*Li(Tn({catch:e=>at.make({cause:e,message:`No passkey was used`}),try:()=>IE({optionsJSON:n})}),fO,()=>io),i=yield*_n(gn(`/auth/passkey`),xa(rD)({...Vr(dO,{onNone:()=>({}),onSome:e=>({next:e})}),response:r}),Fo(t=>e.execute(t)),Fo(Ha(function*(e){return e.status===200?yield*Gr(q({next:vr(J)}))(e):yield*pO(e)})));yield*K(()=>Vr(Rn(i.next),{onNone:()=>location.reload(),onSome:e=>location.assign(e)}))}),Ta(e=>wr(at)(e)?e:at.make({cause:e,message:`Cannot sign in with a passkey`})))),hO=ni(FD.runtime.atom(_n(FD,ma(e=>e(`auth.passkeys`,void 0)),Ka,ID))),gO=ni(FD.runtime.fn(Ha(function*(){let e=yield*FD,t=yield*e(`auth.passkeyOptions`,void 0);yield*e(`auth.addPasskey`,{response:yield*_n(Tn({catch:e=>at.make({cause:e,message:`No passkey was added`}),try:()=>jE({optionsJSON:t})}),Li(fO,()=>io),Fo(Pr(ZE)))}),W.add({title:`Passkey added`})},UD(`Cannot add a passkey`)))),_O=`adding-passkey`,vO=ta(()=>qa({catch:e=>at.make({cause:e,message:`Cannot start GitHub sign-in`}),try:()=>{sessionStorage.setItem(_O,`true`),location.assign(`/auth/github`)}})),yO=ni(FD.runtime.fn(e=>_n(Fo(FD,t=>t(`auth.removePasskey`,{id:e})),UD(`Cannot remove the passkey`)))),bO=ta(()=>qa({catch:e=>at.make({cause:e,message:`Cannot start GitHub sign-in`}),try:()=>location.assign(`/auth/github${location.search}`)})),xO=ta(()=>qa({catch:e=>at.make({cause:e,message:`Cannot start the sign-in`}),try:()=>location.assign(Vr(dO,{onNone:()=>`/auth/code`,onSome:e=>`/auth/code?${new URLSearchParams({next:e})}`}))})),SO=new URLSearchParams(location.search).has(`sign-out`),CO=_n(Hn(new URLSearchParams(location.search).get(`next`)),os(e=>ND(e,BE)),Ir(()=>location.pathname)),wO=_n(lr.use(e=>Fi(e).post(`/auth/sign-out`)),X(K(()=>location.replace(CO))),Ta(e=>at.make({cause:e,message:`Cannot sign out: ${e.message}`}))),TO=PD.fn(()=>wO),EO=PD.fn(()=>UD(`Cannot sign out`)(wO));function DO(e){let t=(0,qs.c)(17),n,r,i,a,o,s;if(t[0]!==e.className||t[1]!==e.text){let c=_o(mx(e.text)),l=Math.sqrt(c.length);r=`-2 -2 ${l+4} ${l+4}`,i=`crispEdges`,a=`currentColor`,o=e.className,s=`true`,n=_n(c,So((e,t)=>({dark:e,x:t%l,y:Math.floor(t/l)})),Mo(kO),So(OO),Ca(``)),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 OO(e){return`M${e.x} ${e.y}h1v1h-1z`}function kO(e){return e.dark===1}function AO(e){let t=(0,qs.c)(12),n;t[0]===e.id?n=t[1]:(n=lO(e.id),t[0]=e.id,t[1]=n);let r;t[2]!==e.name||t[3]!==n?(r=(0,Q.jsx)(rw,{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=Qi(Wo(0,1)(e.name)),t[5]=e.name,t[6]=i);let a;t[7]===i?a=t[8]:(a=(0,Q.jsx)(iw,{children:i}),t[7]=i,t[8]=a);let o;return t[9]!==r||t[10]!==a?(o=(0,Q.jsxs)(nw,{size:`sm`,children:[r,a]}),t[9]=r,t[10]=a,t[11]=o):o=t[11],o}function jO(e){let t=(0,qs.c)(11),[n,r]=(0,Z.useState)(`loading`),i;t[0]===e.small?i=t[1]:(i=Xt(`text-muted-foreground relative flex shrink-0 items-center justify-center`,Vi(e.small===!0,{onFalse:NO,onTrue:MO})),t[0]=e.small,t[1]=i);let a;t[2]===n?a=t[3]:(a=n!==`loaded`&&(0,Q.jsx)(ks,{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:Xt(`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 MO(){return`size-4`}function NO(){return`size-5`}var PO={Chrome:mE,Edge:_E,Firefox:vE,Safari:yE};function FO(e){return e.kind===`Browser`?Ar(vs(PO,e.name),e=>({mono:!1,src:e})):Wa(Ui(/claude/iu)(e.name))?br({mono:!1,src:hE}):Wa(Ui(/codex/iu)(e.name))?br({mono:!0,src:gE}):Wa(Ui(/gateway/iu)(e.name))?qn():qr([`iPhone`,`iPad`],e.device)?br({mono:!0,src:pE}):e.device===`Android`?br({mono:!1,src:fE}):qn()}function IO(e){return Vr(FO(e.client),{onNone:()=>_n(xo(e.client),Vo({kind:`Browser`},()=>(0,Q.jsx)(Ls,{})),Vo(e=>Wa(Ui(/gateway/iu)(e.name)),()=>(0,Q.jsx)(zs,{})),go(()=>(0,Q.jsx)(Us,{}))),onSome:e=>(0,Q.jsx)(`img`,{src:e.src,alt:``,className:Xt(`size-3.5`,e.mono&&`dark:invert`)})})}function LO(e){return Vr(e.client.app,{onNone:()=>(0,Q.jsx)(IO,{client:e.client}),onSome:e=>(0,Q.jsx)(jO,{origin:e,small:!0})})}function RO(e){let t=(0,qs.c)(33),[n,r]=Id(WD),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=iO(e.column.lastActive,e.now);return`active ${Vi(t<1,{onFalse:()=>`${aO(t)} ago`,onTrue:BO})}`},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=Ca([Vi(e.column.pending,{onFalse:n,onTrue:zO}),...Zr(os(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)(MT,{children:[(0,Q.jsx)(NT,{render:(0,Q.jsx)($e,{variant:`ghost`,size:`icon-sm`,title:o,"aria-label":o}),children:(0,Q.jsx)(LO,{client:e.column.client})}),(0,Q.jsxs)(PT,{align:`end`,className:`w-auto min-w-48`,children:[(0,Q.jsx)(FT,{children:(0,Q.jsxs)(IT,{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)(LT,{variant:`destructive`,disabled:mi(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)(LO,{client:e.column.client})}),t[28]=o,t[29]=e.column.client,t[30]=c):c=t[30],s=Vi(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)(uE,{className:`px-0.5`,children:(0,Q.jsx)(`span`,{className:`flex justify-center`,children:s})}),t[31]=s,t[32]=c),c}function zO(){return`waiting for an answer`}function BO(){return`now`}function VO(e,t,n){let r=QD(e);return qr(r,t)||qr(r,`browser`)&&n}function HO(e,t){return Gi(e.resources,e=>VO(e,t.origin,t.web))}function UO(e){let t=(0,qs.c)(21),n,r,i,a,o,s;if(t[0]!==e.column||t[1]!==e.row){let c=HO(e.column,e.row);n=dE,s=`w-7 px-0`,a=`flex justify-center`;let l;t[8]===e.column.pending?l=t[9]:(l=()=>(0,Q.jsx)(aE,{waiting:e.column.pending}),t[8]=e.column.pending,t[9]=l),o=Vi(c,{onFalse:qO,onTrue:l}),r=`sr-only`,i=_n(xo({held:c,pending:e.column.pending}),Vo({held:!1},KO),Vo({pending:!0},GO),go(WO)),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 WO(){return`signed in`}function GO(){return`asked for`}function KO(){return`not signed in`}function qO(){return(0,Q.jsx)(aE,{status:`off`})}function JO(e){let t=(0,qs.c)(42),[n,r]=Id(uO),i;if(t[0]!==e.request.clientName||t[1]!==e.request.device||t[2]!==e.request.kind){let n,r;t[4]!==e.request.clientName||t[5]!==e.request.device?(n=()=>`${oO(e.request.clientName,e.request.device)} asks for the apps its column marks`,r=()=>`Signs in ${oO(e.request.clientName,e.request.device)} as you to every mp281x.xyz app for 30 days, including approving sign-ins`,t[4]=e.request.clientName,t[5]=e.request.device,t[6]=n,t[7]=r):(n=t[6],r=t[7]),i=Vi(e.request.kind===`Browser`,{onFalse:n,onTrue:r}),t[0]=e.request.clientName,t[1]=e.request.device,t[2]=e.request.kind,t[3]=i}else i=t[3];let a;t[8]===e.request.address?a=t[9]:(a=Vr(Rn(e.request.address),{onNone:XO,onSome:YO}),t[8]=e.request.address,t[9]=a);let o;t[10]!==i||t[11]!==a?(o=(0,Q.jsxs)(Tb,{children:[i,a,`. Approve only a code you started yourself.`]}),t[10]=i,t[11]=a,t[12]=o):o=t[12];let s;t[13]===n?s=t[14]:(s=(0,Q.jsx)(nE,{result:n}),t[13]=n,t[14]=s);let c;t[15]!==e.request.clientName||t[16]!==e.request.device?(c=oO(e.request.clientName,e.request.device),t[15]=e.request.clientName,t[16]=e.request.device,t[17]=c):c=t[17];let l=`Approve ${c}`,u;t[18]===n?u=t[19]:(u=mi(n),t[18]=n,t[19]=u);let d;t[20]!==e.request||t[21]!==r?(d=()=>r({accept:!0,request:e.request}),t[20]=e.request,t[21]=r,t[22]=d):d=t[22];let f;t[23]!==l||t[24]!==u||t[25]!==d?(f=(0,Q.jsx)($e,{size:`lg`,"aria-label":l,disabled:u,onClick:d,children:`Approve`}),t[23]=l,t[24]=u,t[25]=d,t[26]=f):f=t[26];let p;t[27]===n?p=t[28]:(p=mi(n),t[27]=n,t[28]=p);let m;t[29]!==e.request||t[30]!==r?(m=()=>r({accept:!1,request:e.request}),t[29]=e.request,t[30]=r,t[31]=m):m=t[31];let h;t[32]!==m||t[33]!==p?(h=(0,Q.jsx)($e,{size:`lg`,variant:`outline`,disabled:p,onClick:m,children:`Deny`}),t[32]=m,t[33]=p,t[34]=h):h=t[34];let g;t[35]!==h||t[36]!==f?(g=(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[f,h]}),t[35]=h,t[36]=f,t[37]=g):g=t[37];let _;return t[38]!==g||t[39]!==o||t[40]!==s?(_=(0,Q.jsxs)(Q.Fragment,{children:[o,s,g]}),t[38]=g,t[39]=o,t[40]=s,t[41]=_):_=t[41],_}function YO(e){return` · from ${e}`}function XO(){return``}function ZO(e,t,n){function r(e,t,r){return{app:Ar(za(n,t=>r===`App`&&Ba(t.name)===Ba(e)),e=>e.origin),device:t,kind:r,name:e}}return[...Vr(e,{onNone:()=>[],onSome:e=>[{address:Rn(e.address),client:r(e.clientName,e.device,e.kind),families:[],key:`pending`,label:oO(e.clientName,e.device),lastActive:0,pending:!0,resources:[e.resources]}]}),..._n(Lo(t,e=>oO(e.client,e.device)),na,Mo(fa),es(yi(er(On,sO))),So(e=>({address:_n(za(e,t=>t.lastActive===sO(e)),li(e=>Rn(e.address))),client:r(e[0].client,e[0].device,e[0].kind),families:So(e,e=>e.family),key:oO(e[0].client,e[0].device),label:oO(e[0].client,e[0].device),lastActive:sO(e),pending:!1,resources:So(e,e=>e.resources)})))]}function QO(e){let t=(0,qs.c)(26),n=Bd(ZD).value,r=Bd(HD).value,i=Bd(eO).value,a=KT(),o;t[0]===a?o=t[1]:(o=function(e){return ko(a)(Ba(e))},t[0]=a,t[1]=o);let s=o,c,l,u,d;if(t[2]!==n||t[3]!==i||t[4]!==e.pending||t[5]!==a||t[6]!==s||t[7]!==r){let o;t[12]===s?o=t[13]:(o=e=>s(e.name),t[12]=s,t[13]=o);let f;t[14]!==n||t[15]!==s?(f=e=>e!==`browser`&&!Gi(n,t=>t.origin===e)&&s(e),t[14]=n,t[15]=s,t[16]=f):f=t[16];let p=[...So(Mo(n,o),ok),..._n([...Zi(r,ak),...Vr(e.pending,{onNone:ik,onSome:rk})],ga,Mo(f),es(Oi),So(nk))],m=Mo(ZO(e.pending,r,n),e=>e.pending||Gi(p,t=>HO(e,t)));c=`flex flex-1 flex-col gap-3`,l=`Apps`,t[17]===e.pending?u=t[18]:(u=Vr(e.pending,{onNone:tk,onSome:ek}),t[17]=e.pending,t[18]=u);let h;t[19]===a?h=t[20]:(h=()=>(0,Q.jsx)(Ot,{children:(0,Q.jsx)(Ke,{children:(0,Q.jsx)(dn,{children:Vi(fr(a),{onFalse:()=>`No app matches “${a}”`,onTrue:$O})})})}),t[19]=a,t[20]=h),d=oo(p,{onEmpty:h,onNonEmpty:()=>(0,Q.jsxs)(oE,{"aria-label":`Apps and the clients signed in to them`,children:[(0,Q.jsx)(sE,{children:(0,Q.jsxs)(lE,{children:[(0,Q.jsx)(uE,{children:(0,Q.jsx)(`span`,{className:`sr-only`,children:`App`})}),So(m,e=>(0,Q.jsx)(RO,{column:e,now:i},e.key))]})}),(0,Q.jsx)(cE,{children:So(p,e=>(0,Q.jsxs)(lE,{children:[(0,Q.jsx)(uE,{scope:`row`,children:Vr(e.open,{onNone:()=>(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Q.jsx)(jO,{origin:e.origin}),e.name]}),onSome:t=>(0,Q.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,title:`Open ${e.name}`,className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Q.jsx)(jO,{origin:e.origin}),e.name]})})}),So(m,t=>(0,Q.jsx)(UO,{column:t,row:e},t.key))]},e.origin))})]})}),t[2]=n,t[3]=i,t[4]=e.pending,t[5]=a,t[6]=s,t[7]=r,t[8]=c,t[9]=l,t[10]=u,t[11]=d}else c=t[8],l=t[9],u=t[10],d=t[11];let f;return t[21]!==c||t[22]!==l||t[23]!==u||t[24]!==d?(f=(0,Q.jsxs)(`section`,{className:c,"aria-label":l,children:[u,d]}),t[21]=c,t[22]=l,t[23]=u,t[24]=d,t[25]=f):f=t[25],f}function $O(){return`No apps yet`}function ek(e){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(JO,{request:e}),(0,Q.jsxs)(`p`,{className:`text-muted-foreground font-mono text-xs`,children:[`open until `,$D(e.expiresAt)]})]})}function tk(){return null}function nk(e){return{name:Ir(sa(po(new URL(e).hostname,`.`)),()=>e),open:qn(),origin:e,web:!1}}function rk(e){return QD(e.resources)}function ik(){return[]}function ak(e){return QD(e.resources)}function ok(e){return{name:e.name,open:br(e.open),origin:e.origin,web:No(`https://`)(e.open)}}export{dw as $,SO as A,LT as B,JD as C,bO as D,tO as E,XT as F,zT as G,VT as H,KT as I,nT as J,NT as K,MT as L,aE as M,nE as N,oO as O,tE as P,Ow as Q,PT as R,yO as S,qD as T,RT as U,IT as V,BT as W,Uw as X,Gw as Y,Bw as Z,EO as _,LD as a,Cb as at,VD as b,XD as c,bb as ct,vO as d,Fd as dt,fw as et,uO as f,Bd as ft,BD as g,js as gt,nO as h,rc as ht,_O as i,Eb as it,AD as j,TO as k,zD as l,Id as lt,cO as m,bd as mt,QO as n,cw as nt,gO as o,vb as ot,rO as p,Ad as pt,sT as q,DO as r,qC as rt,GD as s,yb as st,AO as t,sw as tt,xO as u,Pd as ut,mO as v,YD as w,KD as x,hO as y,FT as z};