@deslop/auth 0.1.1244 → 0.1.1248
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/(home)-DHUWljGI.js +20 -0
- package/dist/client/assets/check-BOBAceOT.js +1 -0
- package/dist/client/assets/components-ChAYWt2_.js +1 -0
- package/dist/client/assets/dialog-DP3mNUWu.js +1 -0
- package/dist/client/assets/effect-BHGTxpcr.js +17 -0
- package/dist/client/assets/index-Bj3hDmy3.js +2 -0
- package/dist/client/assets/index-Bl4kPiWk.css +2 -0
- package/dist/client/assets/people-BjDSIbpy.js +1 -0
- package/dist/client/assets/route-MBpVwG3h.js +41 -0
- package/dist/client/assets/toast-nSmXyoKy.js +3 -0
- package/dist/client/index.html +4 -4
- package/dist/server.js +17 -0
- package/package.json +2 -2
- package/dist/client/assets/(home)-BGXsZG4J.js +0 -20
- package/dist/client/assets/badge-nWdL2b3k.js +0 -1
- package/dist/client/assets/components-DV4T0fPT.js +0 -1
- package/dist/client/assets/effect-CHiRDGLl.js +0 -17
- package/dist/client/assets/index-Cd20yGyq.css +0 -2
- package/dist/client/assets/index-DXaJ5Qfh.js +0 -2
- package/dist/client/assets/people-Ih_KuuYv.js +0 -1
- package/dist/client/assets/route-CruIEHrm.js +0 -1
- package/dist/client/assets/toast-B08W4mtG.js +0 -3
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{$ as t,$i as n,$n as r,$r as i,$t as a,A as o,Aa as s,Ai as c,An as l,Ar as u,B as d,Ba as f,Bi as p,Bn as m,Br as h,Bt as g,C as _,Ci as v,Cn as y,Cr as b,Ct as x,D as S,Da as C,Di as w,Dn as T,Dr as E,Dt as D,E as O,Ea as k,Ei as A,En as j,Er as M,Et as N,F as ee,Fi as P,Fn as te,Fr as F,Ft as ne,G as re,Ga as ie,Gi as ae,Gn as I,H as oe,Hn as se,Hr as L,I as R,Ia as ce,Ii as le,In as ue,Ir as z,It as de,J as fe,Ja as B,Ji as pe,Jn as me,Jr as he,Jt as V,K as ge,Ka as _e,Ki as ve,Kn as ye,Kr as be,Kt as xe,L as Se,La as Ce,Ln as we,Lr as Te,M as Ee,Ma as De,Mi as Oe,Mn as ke,Mr as Ae,Mt as je,N as Me,Na as Ne,Ni as Pe,Nn as Fe,Nr as Ie,Nt as Le,O as Re,Oa as ze,Oi as Be,Or as H,Ot as U,P as Ve,Pa as He,Pi as Ue,Pn as We,Pr as Ge,Q as Ke,Qi as qe,Qn as Je,Qr as Ye,Qt as Xe,Ra as Ze,Ri as Qe,Rn as $e,Rr as et,S as tt,Sa as nt,Si as rt,Sn as it,Sr as at,St as ot,T as st,Ta as W,Ti as ct,Tn as lt,Tr as ut,Tt as dt,U as ft,Ua as pt,Ui as mt,Un as ht,Ur as gt,Ut as _t,V as vt,Va as yt,Vi as bt,Vn as xt,Vr as St,Vt as Ct,W as wt,Wa as Tt,Wi as Et,Wn as Dt,Wt as Ot,X as kt,Xi as At,Xn as jt,Xr as Mt,Xt as Nt,Y as Pt,Yi as Ft,Yn as It,Yr as Lt,Yt as Rt,Z as zt,Zi as Bt,Zn as Vt,Zr as Ht,Zt as Ut,_a as Wt,_i as Gt,_n as Kt,_r as qt,_t as Jt,a as Yt,aa as Xt,ai as Zt,an as Qt,ar as $t,b as en,ba as tn,bi as nn,bn as rn,br as an,bt as on,ca as sn,ci as cn,cn as ln,cr as un,ct as dn,d as fn,da as pn,dn as mn,dr as hn,dt as gn,ea as _n,ei as vn,en as yn,er as bn,et as xn,f as Sn,fa as Cn,fn as wn,fr as Tn,ft as En,ga as Dn,gi as On,gn as kn,gr as An,h as jn,ha as Mn,hn as Nn,hr as Pn,ht as Fn,i as In,ia as Ln,ii as Rn,in as zn,ir as Bn,j as Vn,ja as Hn,ji as Un,jn as Wn,jr as Gn,jt as Kn,k as qn,ka as Jn,ki as Yn,kn as Xn,kr as G,kt as K,l as Zn,la as Qn,li as $n,ln as er,lr as tr,lt as nr,ma as rr,mn as ir,mr as ar,mt as or,n as sr,na as cr,ni as lr,nn as ur,no as dr,nr as fr,nt as pr,oa as mr,oi as hr,on as gr,or as _r,ot as vr,pa as yr,pn as br,pr as xr,pt as Sr,q as Cr,qa as wr,qn as Tr,r as Er,ra as Dr,ri as Or,rn as kr,ro as Ar,rr as jr,rt as Mr,sa as Nr,si as Pr,sn as Fr,sr as Ir,st as Lr,t as Rr,ti as zr,tn as Br,to as Vr,tr as Hr,tt as Ur,u as Wr,ua as Gr,un as Kr,ur as qr,ut as Jr,v as Yr,va as Xr,vi as Zr,vn as Qr,vr as $r,vt as ei,w as ti,wa as ni,wi as ri,wn as ii,wr as ai,wt as oi,x as si,xa as ci,xi as li,xn as ui,xr as di,xt as fi,y as pi,ya as mi,yi as hi,yn as gi,yr as _i,yt as vi,z as yi,zi as bi,zn as xi,zr as Si,zt as Ci}from"./effect-CHiRDGLl.js";import{a as wi,i as Ti,n as Ei,o as Di,s as Oi,t as ki}from"./react-BUjtWCUj.js";import{$ as Ai,$n as ji,$t as Mi,A as Ni,An as Pi,At as Fi,B as Ii,Bn as Li,Bt as Ri,C as zi,Cn as Bi,Ct as Vi,D as Hi,Dn as Ui,Dt as Wi,E as Gi,En as Ki,Et as qi,F as Ji,Fn as Yi,Ft as Xi,G as Zi,Gn as Qi,Gt as $i,H as ea,Hn as ta,Ht as na,I as ra,In as q,It as ia,J as aa,Jn as oa,Jt as sa,K as ca,Kn as la,Kt as ua,L as da,Ln as J,Lt as fa,M as pa,Mn as ma,Mt as ha,N as ga,Nn as _a,Nt as va,O as ya,On as ba,Ot as xa,P as Sa,Pn as Ca,Pt as wa,Q as Ta,Qn as Ea,Qt as Da,R as Oa,Rn as ka,Rt as Aa,S as ja,Sn as Ma,St as Na,T as Y,Tn as Pa,Tt as Fa,U as Ia,Un as La,Ut as Ra,V as za,Vn as Ba,Vt as Va,W as Ha,Wn as Ua,Wt as Wa,X as Ga,Xn as Ka,Xt as qa,Y as Ja,Yn as Ya,Yt as Xa,Z as Za,Zn as Qa,Zt as $a,_ as eo,_t as to,a as no,an as ro,ar as io,at as ao,b as oo,bt as so,c as co,cn as lo,ct as uo,d as fo,dn as po,dt as mo,en as ho,er as go,et as _o,f as vo,fn as yo,fr as bo,ft as xo,g as So,gn as Co,gt as wo,h as To,hn as Eo,ht as Do,i as Oo,in as ko,ir as Ao,it as jo,j as Mo,jn as No,jt as Po,kn as Fo,kt as Io,l as Lo,lt as Ro,m as zo,mn as Bo,mt as Vo,n as Ho,nn as Uo,nr as Wo,nt as Go,o as Ko,on as qo,ot as Jo,p as Yo,pn as Xo,pt as Zo,q as Qo,qn as $o,qt as X,r as es,rn as ts,rr as ns,rt as rs,s as is,sn as as,sr as os,st as ss,tn as cs,tr as ls,tt as us,u as ds,ut as fs,v as ps,vt as ms,w as hs,wn as gs,wt as _s,x as vs,xn as ys,xt as bs,y as xs,yn as Ss,yt as Cs,z as ws,zn as Ts,zt as Es}from"./toast-B08W4mtG.js";var Ds={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`}]]};Ds.node;var Os=os(Ds),ks={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};ks.node;var As=os(ks),js={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};js.node;var Ms=os(js),Ns={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Ns.node;var Ps=os(Ns),Fs={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`}]]};Fs.node;var Is=os(Fs),Ls={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`}]]};Ls.node;var Rs=os(Ls),zs={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};zs.node;var Bs=os(zs),Vs={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`}]]};Vs.node;var Hs=os(Vs),Z=e(Oi(),1),Q=Di(),Us=bo(),Ws=e(wi(),1),Gs=e(Ti(),1),Ks=Ei(),qs=`data-open`,Js=`data-closed`,Ys=`data-anchor-hidden`,Xs={[fa]:``},Zs={[fa]:``,[Aa]:``},Qs={[qs]:``},$s={[Js]:``},ec={[Ys]:``},tc={open(e){return e?Xs:null}},nc={open(e){return e?Zs:null}},rc={open(e){return e?Qs:$s},anchorHidden(e){return e?ec:null}},ic={...rc,...Es};function ac(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...ac(e,t.id,n)])}function oc(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 sc(e,t=!1){let{overflowY:n}=Ts(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}function cc(e){let t=ka(lc,e).current;return t.next=e,q(t.effect),t}function lc(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var uc=0;function dc(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(uc);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),ba;let o=requestAnimationFrame(a);return uc=o,()=>{uc===o&&(cancelAnimationFrame(o),uc=0)}}var fc=`data-base-ui-inert`,pc=new WeakMap,mc=new WeakSet,hc=new WeakMap,gc=0;function _c(e){return e?ji(e)?e.host:_c(e.parentNode):null}var vc=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=_c(t);return e.contains(n)?n:null}).filter(e=>e!=null),yc=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},bc=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{La(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function xc(e,t,n,{mark:r=!0}){let i=vc(t,e),a=r?bc(t,yc(i),new Set(i)):[],o=[],s=[];if(n){let e=vc(t,Array.from(t.querySelectorAll(`[aria-live]`))),n=i.concat(e);bc(t,yc(n),new Set(n)).forEach(e=>{let t=e.getAttribute(`aria-hidden`),n=t!==null&&t!==`false`,r=(pc.get(e)||0)+1;pc.set(e,r),o.push(e),r===1&&n&&mc.add(e),n||e.setAttribute(`aria-hidden`,`true`)})}return r&&a.forEach(e=>{let t=(hc.get(e)||0)+1;hc.set(e,t),s.push(e),t===1&&e.setAttribute(fc,``)}),gc+=1,()=>{o.forEach(e=>{let t=(pc.get(e)||0)-1;pc.set(e,t),t||(mc.has(e)||e.removeAttribute(`aria-hidden`),mc.delete(e))}),r&&s.forEach(e=>{let t=(hc.get(e)||0)-1;hc.set(e,t),t||e.removeAttribute(fc)}),--gc,gc||(pc=new WeakMap,mc=new WeakSet,hc=new WeakMap)}}function Sc(e,t={}){let{ariaHidden:n=!1,mark:r=!0}=t,i=ma(e[0]).body;return xc(e,i,n,{mark:r})}function Cc(){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 wc=class{nodesRef={current:[]};events=Cc();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)}},Tc=Z.createContext(null),Ec=Z.createContext(null),Dc=()=>Z.useContext(Tc)?.id||null,Oc=e=>{let t=Z.useContext(Ec);return e??t};function kc(e){let t=Hi(),n=Oc(e),r=Dc();return q(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function Ac(e){let{children:t,id:n}=e,r=Dc();return(0,Q.jsx)(Tc.Provider,{value:Z.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function jc(e){let{children:t,externalTree:n}=e,r=ka(()=>n??new wc).current;return(0,Q.jsx)(Ec.Provider,{value:r,children:t})}function Mc(e,t){let n=$o(sa(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||(qi(e)?`keyboard`:t||`mouse`):`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var Nc=20,Pc=[];function Fc(){Pc=Pc.filter(e=>e.deref()?.isConnected)}function Ic(e){Fc(),e&&La(e)!==`body`&&(Pc.push(new WeakRef(e)),Pc.length>Nc&&(Pc=Pc.slice(-20)))}function Lc(){return Fc(),Pc[Pc.length-1]?.deref()}function Rc(e){return e?Ja(e)?e:Ga(e)[0]||e:null}function zc(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=Ha(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return Ja(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 Bc(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,explicitReturnFocus:o,restoreFocus:s=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:u=``,nextFocusableElement:d,previousFocusableElement:f,beforeContentFocusGuardRef:p,externalTree:m,getInsideElements:h}=e,g=t.useState(`open`),_=t.useState(`domReferenceElement`),v=t.useState(`floatingElement`),{events:y,dataRef:b}=t.context,x=J(()=>b.current.floatingContext?.nodeId),S=i===!1,C=wa(_)&&S,w=cc(i),T=cc(a),E=cc(o),D=cc(u),O=cc(g),k=Oc(m),A=Oo(),j=Z.useRef(!1),M=Z.useRef(!1),N=Z.useRef(!1),ee=Z.useRef(null),P=Z.useRef(``),te=Z.useRef(``),F=Z.useRef(null),ne=Z.useRef(null),re=Fo(F,p,A?.beforeInsideRef),ie=Fo(ne,A?.afterInsideRef),ae=ts(),I=ts(),oe=da(),se=A!=null,L=Io(v),R=J((e=L)=>e?Ga(e):[]),ce=J(()=>h?.().filter(e=>e!=null)??[]);Z.useEffect(()=>{if(r||!c)return;function e(e){e.key===`Tab`&&X(L,$i(ma(L)))&&R().length===0&&!C&&xa(e)}let t=ma(L);return Ia(t,`keydown`,e)},[r,L,c,C,R]),Z.useEffect(()=>{if(r||!g)return;let e=ma(L);function t(){N.current=!1}function n(e){let t=sa(e),n=ce(),r=X(v,t)||X(_,t)||X(A?.portalNode,t)||n.some(e=>e===t||X(e,t));N.current=!r,te.current=e.pointerType||`keyboard`,ua(t,`[data-base-ui-click-trigger]`)&&(M.current=!0,I.start(0,()=>{M.current=!1}))}function i(){te.current=`keyboard`}return ea(Ia(e,`pointerdown`,n,!0),Ia(e,`pointerup`,t,!0),Ia(e,`pointercancel`,t,!0),Ia(e,`keydown`,i,!0),t)},[r,v,_,L,g,A,I,ce]),Z.useEffect(()=>{if(r||!l)return;let e=ma(L);function n(){M.current=!0,I.start(0,()=>{M.current=!1})}function i(e){let t=sa(e);Ja(t)&&(ee.current=t)}function a(n){let r=n.relatedTarget,i=n.currentTarget,a=sa(n);c&&r==null&&a!=null&&X(v,a)&&Ic(a),queueMicrotask(()=>{let o=x(),l=t.context.triggerElements,u=ce(),p=r?.hasAttribute(no(`focus-guard`))&&[F.current,ne.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,Ji(f),Ji(d)].includes(r),m=!(X(_,r)||X(v,r)||X(r,v)||X(A?.portalNode,r)||u.some(e=>e===r||X(e,r))||l.hasMatchingElement(e=>X(e,r))||p||k&&(ac(k.nodesRef.current,o).find(e=>X(e.context?.elements.floating,r)||X(e.context?.elements.domReference,r))||oc(k.nodesRef.current,o).find(e=>[e.context?.elements.floating,Io(e.context?.elements.floating)].includes(r)||e.context?.elements.domReference===r)));if(i===_&&L&&zc(L),s&&i!==_&&!us(a)&&$i(e)===e.body){if(Ka(L)&&(L.focus(),s===`popup`)){oe.request(()=>{L.focus()});return}let e=R(),t=ee.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||L;Ka(n)&&n.focus()}b.current.insideReactTree?b.current.insideReactTree=!1:(C||!c)&&r&&m&&!M.current&&(C||r!==Lc())&&(j.current=!0,t.setOpen(!1,Y(ds,n)))})}function o(){N.current||(b.current.insideReactTree=!0,ae.start(0,()=>{b.current.insideReactTree=!1}))}let u=Ka(_)?_:null;if(v||u)return ea(u&&Ia(u,`focusout`,a),u&&Ia(u,`pointerdown`,n),v&&Ia(v,`focusin`,i),v&&Ia(v,`focusout`,a),v&&A&&Ia(v,`focusout`,o,!0))},[r,_,v,L,c,k,A,t,l,s,R,C,x,b,ae,I,oe,d,f,ce]),Z.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${no(`portal`)}]`)||[]),t=(k?oc(k.nodesRef.current,x()):[]).find(e=>wa(e.context?.elements.domReference||null))?.context?.elements.domReference,n=Sc([v,...e,F.current,ne.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...ce(),t,Ji(f),Ji(d),C?_:null].filter(e=>e!=null),{ariaHidden:c||C,mark:!1}),i=Sc([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,c,A,C,k,x,d,f,ce]),q(()=>{if(!g||r||!Ka(L))return;P.current=``,te.current=``;let e=ma(L),t=$i(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(D.current||``):n;if(r===void 0||r===!1||X(L,t))return;let i=null,a=()=>(i??=R(L),i[0]||L),o;o=r===!0||r===null?a():Ji(r),o||=a();let s=X(L,$i(e)),c=b.current.openEvent,l=c?.type===`mousedown`&&qi(c);dc(o,{sync:l,preventScroll:o===L,shouldFocus(){if(!O.current)return!1;if(s)return!0;let t=$i(e);return!(t!==o&&X(L,t))}})})},[r,g,L,R,w,D,O,b]);let le=Z.useRef(null);q(()=>{if(r||!L){le.current=null;return}le.current&&=(le.current.cancelled=!0,null);let e=ma(L),t=$i(e),n=D.current==null;Ic(t);function i(e){if(e.open||(P.current=Mc(e.nativeEvent,te.current)),(e.reason===`focus-out`&&e.triggerElement?.hasAttribute(no(`focus-guard`))||e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`)&&(j.current=!0),e.reason===`outside-press`){if(e.nested)j.current=!1;else if(qi(e.nativeEvent)||Wi(e.nativeEvent))j.current=!1;else{let e=!1;ma(L).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?j.current=!1:j.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&La(t)!==`body`?t:null,s=n?o||a:a||o;return s||=Lc()||null,typeof i==`boolean`?s:Ji(i)||s||null}return()=>{y.off(`openchange`,i);let t=$i(e),n=ce(),r=X(v,t)||n.some(e=>e===t||X(e,t))||k&&ac(k.nodesRef.current,x(),!1).some(e=>X(e.context?.elements.floating,t)),o=T.current,s=P.current,c=a(s),l={cancelled:!1};le.current=l,queueMicrotask(()=>{le.current===l&&(le.current=null);let n=Rc(c),i=E.current??typeof o!=`boolean`;if(!l.cancelled&&o&&!j.current&&Ka(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}j.current=!1})}},[r,v,L,T,E,D,y,k,_,x,ce]),q(()=>{if(!Da||g||!v)return;let e=$i(ma(v));Ka(e)&&Xi(e)&&X(v,e)&&e.blur()},[g,v]),q(()=>{if(!r&&A)return A.setFocusManagerState({modal:c,closeOnFocusOut:l,open:g,onOpenChange:t.setOpen,domReference:_}),()=>{A.setFocusManagerState(null)}},[r,A,c,g,t,l,_]),q(()=>{if(!r&&L)return zc(L),()=>{queueMicrotask(Fc)}},[r,L]);let ue=!r&&(!c||!C)&&(se||c);return(0,Q.jsxs)(Z.Fragment,{children:[ue&&(0,Q.jsx)(ws,{"data-type":`inside`,ref:re,onFocus:e=>{if(c){let e=R();dc(e[e.length-1])}else A?.portalNode&&(j.current=!1,aa(e,A.portalNode)?Zi(_)?.focus():Ji(f??A.beforeOutsideRef)?.focus())}}),n,ue&&(0,Q.jsx)(ws,{"data-type":`inside`,ref:ie,onFocus:e=>{c?dc(R()[0]):A?.portalNode&&(l&&(j.current=!0),aa(e,A.portalNode)?ca(_)?.focus():Ji(d??A.afterOutsideRef)?.focus())}})]})}function Vc(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=hs}=t,l=e.context.dataRef,u=Z.useRef(void 0),d=da(),f=ts(),p=Z.useMemo(()=>{function t(t,n,r,i){let a=Y(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=_s(e.pointerType,!0)&&Wi(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(i){let o=u.current,s=i.nativeEvent,c=e.select(`open`);if(i.button!==0||r===`click`||_s(o,!0)&&a)return;let l=n(c,i.currentTarget,e=>e===`click`||e===`mousedown`),f=sa(s),p=Xi(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:_s(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}:Ui,[n,p])}function Hc(){return!1}function Uc(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function Wc(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=Hc,bubbles:s,externalTree:c}=t,l=e.useState(`open`),u=e.useState(`floatingElement`),{dataRef:d,events:f}=e.context,p=Oc(c),m=J(typeof i==`function`?i:()=>!1),h=typeof i==`function`?m:i,g=h!==!1,_=J(()=>a),{escapeKey:v,outsidePress:y}=Uc(s),b=Z.useRef(!1),x=Z.useRef(!1),S=Z.useRef(!1),C=Z.useRef(!1),w=Z.useRef(!1),T=Z.useRef(``),E=Z.useRef(null),D=ts(),O=ts(),k=ts(),A=J(()=>{O.clear(),d.current.insideReactTree=!1}),j=J(e=>{let t=d.current.floatingContext?.nodeId;return(p?ac(p.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),M=J(t=>Fi(t,e.select(`floatingElement`))||Fi(t,e.select(`domReferenceElement`))),N=J(t=>{o()&&e.setOpen(!1,Y(hs,t.nativeEvent))}),ee=J(t=>{if(!l||!n||!r||t.key!==`Escape`)return;let i=Fa(t)?t.nativeEvent:t;if(w.current||i.isComposing||!v&&j(`__escapeKeyBubbles`))return;let a=Y(Lo,i);e.setOpen(!1,a),a.isCanceled||t.preventDefault(),!v&&!a.isPropagationAllowed&&t.stopPropagation()}),P=J(()=>{d.current.insideReactTree=!0,O.start(0,A)}),te=J(t=>{if(!l||!n||t.button!==0)return;let r=sa(t.nativeEvent);X(e.select(`floatingElement`),r)&&(b.current||(b.current=!0,x.current=!1))}),F=J(e=>{l&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&b.current&&(x.current=!0)});Z.useEffect(()=>{function e(e){e.open||(C.current=!1)}return f.on(`openchange`,e),()=>{f.off(`openchange`,e)}},[f]),Z.useEffect(()=>A,[A]),Z.useEffect(()=>{if(!l||!n)return l||(C.current=!1,w.current=!1,T.current=``,E.current=null),A;d.current.__escapeKeyBubbles=v,d.current.__outsidePressBubbles=y;let t=new Uo,i=ma(u);function a(){k.clear(),w.current=!0}function o(){w.current=!0,k.start(Da?5:0,()=>{w.current=!1})}function s(){S.current=!0,t.start(0,()=>{S.current=!1})}function c(){b.current=!1,x.current=!1}function f(){let e=T.current,t=e===`pen`||!e?`mouse`:e,n=_(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function m(e){let t=f();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function O(e){let t=d.current.floatingContext?.nodeId,n=p&&ac(p.nodesRef.current,t).some(t=>Fi(e,t.context?.elements.floating));return M(e)||n}function N(n){if(m(n)){n.type!==`click`&&!M(n)&&(t.clear(),S.current=!1),A();return}if(d.current.insideReactTree){A();return}let r=sa(n),i=`[${no(`inert`)}]`,a=Ya(r)?r.getRootNode():null,o=Array.from((ji(a)?a:ma(e.select(`floatingElement`))).querySelectorAll(i)),s=e.context.triggerElements;if(r&&(s.hasElement(r)||s.hasMatchingElement(e=>X(e,r))))return;let c=Ya(r)?r:null;for(;c&&!Qa(c);){let e=la(c);if(Qa(e)||!Ya(e))break;c=e}if(!(o.length&&Ya(r)&&!ha(r)&&!X(r,e.select(`floatingElement`))&&o.every(e=>!X(c,e)))){if(Ka(r)&&!(`touches`in n)){let e=Qa(r),t=Ts(r),i=/auto|scroll/,a=e||i.test(t.overflowX),o=e||i.test(t.overflowY),s=a&&r.clientWidth>0&&r.scrollWidth>r.clientWidth,c=o&&r.clientHeight>0&&r.scrollHeight>r.clientHeight,l=t.direction===`rtl`,u=c&&(l?n.offsetX<=r.offsetWidth-r.clientWidth:n.offsetX>r.clientWidth),d=s&&n.offsetY>r.clientHeight;if(u||d)return}if(!O(n)){if(f()===`intentional`){if(n.detail!==0&&!qi(n)&&!C.current)return;if(S.current){t.clear(),S.current=!1;return}}typeof h==`function`&&!h(n)||j(`__outsidePressBubbles`)||(e.setOpen(!1,Y(xs,n)),A())}}}function P(t){f()===`sloppy`&&t.pointerType!==`touch`&&e.select(`open`)&&n&&!M(t)&&N(t)}function te(t){if(f()!==`sloppy`||!e.select(`open`)||!n||M(t))return;let r=t.touches[0];r&&(E.current={startTime:Date.now(),startX:r.clientX,startY:r.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},D.start(1e3,()=>{E.current&&(E.current.dismissOnTouchEnd=!1,E.current.dismissOnMouseDown=!1)}))}function F(e,t){let n=sa(e);if(!n)return;let r=Ia(n,e.type,()=>{t(e),r()})}function ne(e){T.current=`touch`,F(e,te)}function re(e){D.clear(),e.type===`pointerdown`&&(e.button===0&&(C.current=!0),T.current=e.pointerType),(e.type!==`mousedown`||!E.current||E.current.dismissOnMouseDown)&&F(e,e=>{e.type===`pointerdown`?P(e):N(e)})}function ie(e){if(e.type===`pointercancel`&&(C.current=!1),!b.current)return;let n=x.current;c(),f()===`intentional`&&(e.type===`pointercancel`?n&&s():O(e)||(n?s():(typeof h!=`function`||h(e))&&(t.clear(),S.current=!0,A())))}function ae(e){if(f()!==`sloppy`||!E.current||M(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-E.current.startX),r=Math.abs(t.clientY-E.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(E.current.dismissOnTouchEnd=!0),i>10&&(N(e),D.clear(),E.current=null)}function I(e){F(e,ae)}function oe(e){f()===`sloppy`&&E.current&&!M(e)&&(E.current.dismissOnTouchEnd&&N(e),D.clear(),E.current=null)}function se(e){F(e,oe)}let L=ea(r&&ea(Ia(i,`keydown`,ee),Ia(i,`compositionstart`,a),Ia(i,`compositionend`,o)),g&&ea(Ia(i,`click`,re,!0),Ia(i,`pointerdown`,re,!0),Ia(i,`pointerup`,ie,!0),Ia(i,`pointercancel`,ie,!0),Ia(i,`mousedown`,re,!0),Ia(i,`mouseup`,ie,!0),Ia(i,`touchstart`,ne,{capture:!0,passive:!0}),Ia(i,`touchmove`,I,{capture:!0,passive:!0}),Ia(i,`touchend`,se,{capture:!0,passive:!0})));return()=>{L(),t.clear(),c(),S.current=!1}},[d,u,r,g,h,l,n,v,y,ee,A,_,j,M,p,e,D,k]);let ne=Z.useMemo(()=>({onKeyDown:ee,onPointerDown:N,onClick:N}),[ee,N]),re=Z.useMemo(()=>({onKeyDown:ee,onPointerDown:F,onMouseDown:F,onClickCapture:P,onMouseDownCapture(e){P(),te(e)},onPointerDownCapture(e){P(),te(e)},onMouseUpCapture:P,onTouchEndCapture:P,onTouchMoveCapture:P}),[ee,P,te,F]);return Z.useMemo(()=>n?{reference:ne,floating:re,trigger:ne}:{},[n,ne,re])}function Gc(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),q(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};Ya(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 Kc(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),q(()=>{if(!e&&o&&i!==`ending`&&n){let e=ra.request(()=>{a(`ending`)});return()=>{ra.cancel(e)}}},[e,o,i,n]),q(()=>{if(!e||t||i===void 0)return;let n=ra.request(()=>{a(void 0)});return()=>{ra.cancel(n)}},[t,e,i]),q(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=ra.request(()=>{a(`idle`)});return()=>{ra.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}function qc(e){let{open:t,ref:n,preventUnmountOnClose:r,setPreventUnmountOnClose:i,onUnmount:a,animateInitialOpen:o}=e,s=J(i),{mounted:c,setMounted:l,transitionStatus:u}=Kc(t,!1,!1,o),d=!t&&r;q(()=>{t&&s(!1)},[t,s]);let f=Z.useRef(c),p=Z.useRef(!1),m=ya(),h=()=>{f.current=!1,l(!1),a()};q(()=>{f.current=c,p.current&&(p.current=!1,!t&&c&&h())});let g=J(()=>{f.current&&(t?(p.current=!0,m()):h())});return ga({enabled:c&&!t&&!d,open:t,ref:n,onComplete(){t||g()}}),{mounted:c,transitionStatus:u,preventUnmountingOnClose:d,forceUnmount:g}}var Jc={tabIndex:-1,[Wa]:``};function Yc({handle:e,store:t}){return q(()=>e.attachStore(t),[e,t]),null}function Xc(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function Zc(e,t){let n=Z.useRef(null);return J(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),Xc(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),Xc(t))})}function Qc(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 $c(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function el(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=Zc(e,n),o=J(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=J(e=>{a(e),e&&o(e)});return q(()=>(s(t.current),()=>s(null)),[s,t,n,e]),q(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function tl(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`);q(()=>{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=Y(ps);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,a,o,s,n])}function nl(e,t,n,r){let{mounted:i,transitionStatus:a,forceUnmount:o}=qc({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 ka(()=>(t.set(`mounted`,i),null)),t.useSyncedValues({mounted:i,transitionStatus:a}),{forceUnmount:o,transitionStatus:a}}function rl(e,t){e.useSyncedValues(t),q(()=>()=>{e.update({activeTriggerProps:Ui,inactiveTriggerProps:Ui,popupProps:Ui})},[e])}var il=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}},al={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},ol=class extends ko{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:Cc(),nested:n,triggerElements:i},al),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&Vi(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 sl(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new ol({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:Ui,inactiveTriggerProps:Ui,popupProps:Ui}}var cl=e=>e.triggerIdProp??e.activeTriggerId,ll=e=>e.openProp??e.open,ul=e=>(e.popupElement?.id??e.floatingId)||void 0;function dl(e,t){return t!==void 0&&ll(e)&&cl(e)===t}function fl(e,t){return dl(e,t)?!0:t!==void 0&&ll(e)&&cl(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}var pl={open:ll,mounted:e=>e.mounted,transitionStatus:e=>ll(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:cl,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:ul,isTriggerActive:(e,t)=>t!==void 0&&cl(e)===t,isOpenedByTrigger:(e,t)=>dl(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&cl(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>fl(e,t)?ul(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function ml(e){let t=Z.useCallback(t=>e===void 0?ba:e.subscribeStore(t),[e]),n=Z.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,Us.useSyncExternalStore)(t,n,()=>e?.serverStore)}function hl(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=Hi(),a=Dc()!=null,o=ka(()=>new ol({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new il,floatingId:i,syncOnly:!1,nested:a})).current;return q(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=Ya(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 gl=cs&&Da;function _l(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=ts();Z.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=$o(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&Ka(t)&&t===$i(ma(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return ea(Ia(r,`blur`,i),gl&&Ia(r,`keydown`,a,!0),gl&&Ia(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`);Ya(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=sa(n.nativeEvent);if(Ya(a)){if(gl&&!n.relatedTarget){if(!c.current&&!Xi(a))return}else if(!ia(a))return}let u=va(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;e.select(`open`)&&u||!r?e.setOpen(!0,Y(ja,d,f)):l.start(r,()=>{o.current||e.setOpen(!0,Y(ja,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=Ya(r)&&r.hasAttribute(no(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=$i(ma(t));!r&&n===t||X(a.current.floatingContext?.refs.floating.current,n)||X(t,n)||o||va(r??n,e.context.triggerElements)||e.setOpen(!1,Y(ja,i))})}}},[a,r,e,l]);return Z.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}var vl=class e{pointerType=void 0;interactedInside=!1;handler=void 0;blockMouseMove=!0;performedPointerEventsMutation=!1;pointerEventsScopeElement=null;pointerEventsReferenceElement=null;pointerEventsFloatingElement=null;restTimeoutPending=!1;openChangeTimeout=new Uo;restTimeout=new Uo;handleCloseOptions=void 0;static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},yl=new WeakMap;function bl(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&yl.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),yl.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function xl(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=yl.get(n);a&&a!==e&&bl(a),bl(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,yl.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function Sl(e){let t=e.context.dataRef.current,n=ka(()=>t.hoverInteractionState??vl.create()).current;return t.hoverInteractionState||=n,as(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function Cl(e,t){return t!=null&&!_s(t)?0:typeof e==`function`?e():e}function wl(e,t,n){let r=Cl(e,n);return typeof r==`number`?r:r?.[t]}function Tl(e){return typeof e==`function`?e():e}function El(e,t){return t||e===`click`||e===`mousedown`}function Dl(e){return e?.includes(`mouse`)&&e!==`mousedown`}function Ol(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=Oc(),u=Dc(),d=Sl(e),f=ts(),p=J(()=>El(c.current.openEvent?.type,d.interactedInside)),m=J(()=>Dl(c.current.openEvent?.type)),h=J(()=>{bl(d)});q(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,h())},[a,d,h]),Z.useEffect(()=>h,[h]),q(()=>{if(n&&a&&d.handleCloseOptions?.blockPointerEvents&&m()&&Ya(s)&&o){let e=s,t=o,n=ma(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??ua(e,`[data-rootownerid]`)??n.body;return xl(d,{scopeElement:c,referenceElement:e,floatingElement:t}),()=>{h()}}},[n,a,s,o,d,m,l,u,h]),Z.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&ac(l.nodesRef.current,u).length>0)}function a(t){let n=wl(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,Y(zi,t)),l?.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=sa(e);Po(t)?d.interactedInside=ua(t,`[aria-haspopup]`)!=null:d.interactedInside=!1}function g(){d.openChangeTimeout.clear(),f.clear(),l?.events.off(`floating.closed`,v),h()}function _(n){if(t()&&l){l.events.on(`floating.closed`,v);return}if(va(n.relatedTarget,e.context.triggerElements))return;let r=c.current.floatingContext?.nodeId??i,o=n.relatedTarget;l&&r&&Ya(o)&&ac(l.nodesRef.current,r,!1).some(e=>X(e.context?.elements.floating,o))||(d.handler?d.handler(n):(h(),m()&&!p()&&a(n)))}function v(n){l&&u&&!t()&&f.start(0,()=>{l.events.off(`floating.closed`,v),e.setOpen(!1,Y(zi,n)),l.events.emit(`floating.closed`,n)})}let y=o;return ea(y&&Ia(y,`mouseenter`,g),y&&Ia(y,`mouseleave`,_),y&&Ia(y,`pointerdown`,s,!0),()=>{l?.events.off(`floating.closed`,v)})},[n,o,e,c,r,i,m,p,h,d,l,u,f])}var kl={current:null};function Al(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=kl,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,{dataRef:h,events:g}=e.context,_=Oc(l),v=Sl(e),y=Z.useRef(!1),b=cc(i),x=cc(r),S=cc(o),C=cc(n),w=cc(p),T=cc(f),E=J(()=>El(h.current.openEvent?.type,v.interactedInside)),D=J(()=>w.current?.()!==!1),O=J((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!X(t,n);if(!Ya(r))return!1;let a=r;return i.hasMatchingElement(e=>X(e,a))&&(!t||!X(t,a))}),k=J(()=>{v.handler&&=(ma(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,v.handler),void 0)}),A=J(()=>{bl(v)});return u&&(v.handleCloseOptions=i?.__options),Z.useEffect(()=>k,[k]),Z.useEffect(()=>{if(!n)return;function e(e){e.open?y.current=!1:(y.current=e.reason===zi,k(),v.openChangeTimeout.clear(),v.restTimeout.clear(),v.blockMouseMove=!0,v.restTimeoutPending=!1)}return g.on(`openchange`,e),()=>{g.off(`openchange`,e)}},[n,g,v,k]),Z.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=wl(x.current,`close`,v.pointerType);r?v.openChangeTimeout.start(r,()=>{e.setOpen(!1,Y(zi,t)),_?.events.emit(`floating.closed`,t)}):n&&(v.openChangeTimeout.clear(),e.setOpen(!1,Y(zi,t)),_?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!Ya(r))return;function i(t){if(v.openChangeTimeout.clear(),v.blockMouseMove=!1,a&&!_s(v.pointerType))return;let n=Tl(S.current),r=wl(x.current,`open`,v.pointerType),i=sa(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(Ya(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(X(t,i)){c=t;break}}Ya(o)&&Ya(s)&&!e.context.triggerElements.hasElement(o)&&X(o,s)&&(c=s);let l=c!=null&&O(s,c,i),u=e.select(`open`),d=T.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&y.current,p=!l&&Ya(c)&&Ya(s)&&X(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;h?D()&&e.setOpen(!0,Y(zi,t,c)):m||(r?v.openChangeTimeout.start(r,()=>{g&&D()&&e.setOpen(!0,Y(zi,t,c))}):g&&D()&&e.setOpen(!0,Y(zi,t,c)))}function o(n){if(E()){A();return}k();let r=e.select(`domReferenceElement`),i=ma(r);v.restTimeout.clear(),v.restTimeoutPending=!1;let a=h.current.floatingContext??d?.();if(!va(n.relatedTarget,e.context.triggerElements)){if(b.current&&a){e.select(`open`)||v.openChangeTimeout.clear();let r=c.current;v.handler=b.current({...a,tree:_,x:n.clientX,y:n.clientY,onClose(){A(),k(),C.current&&!E()&&r===e.select(`domReferenceElement`)&&t(n,!0)}}),i.addEventListener(`mousemove`,v.handler),v.handler(n)}else v.pointerType===`touch`&&X(e.select(`floatingElement`),n.relatedTarget)||t(n)}}function l(e){X(r,e.relatedTarget)||(v.openChangeTimeout.clear(),v.restTimeout.clear(),v.restTimeoutPending=!1)}let f=m?Ia(r,`mouseout`,l):void 0;return s?ea(Ia(r,`mousemove`,i,{once:!0}),Ia(r,`mouseenter`,i),Ia(r,`mouseleave`,o),f):ea(Ia(r,`mouseenter`,i),Ia(r,`mouseleave`,o),f)},[k,A,h,x,e,n,b,v,u,O,E,a,s,S,c,_,C,d,T,D,m]),Z.useMemo(()=>{if(!n)return;function t(e){v.pointerType=e.pointerType}return{onPointerDown:t,onPointerEnter:t,onMouseMove(t){let{nativeEvent:n}=t,r=t.currentTarget,i=e.select(`domReferenceElement`),o=e.select(`open`),s=O(i,r,t.target);if(a&&!_s(v.pointerType))return;if(o&&s&&v.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=v.handleCloseOptions?.getScope?.()??r.ownerDocument.body;xl(v,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=Tl(S.current);if(o&&!s||c===0||!s&&v.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;v.restTimeout.clear();function l(){if(v.restTimeoutPending=!1,E())return;let t=e.select(`open`);!v.blockMouseMove&&(!t||s)&&D()&&e.setOpen(!0,Y(zi,n,r))}v.pointerType===`touch`?Gs.flushSync(()=>{l()}):s&&o?l():(v.restTimeoutPending=!0,v.restTimeout.start(c,l))}}},[n,v,E,O,a,e,S,D])}function jl(e){return Da&&e.movementX===0&&e.movementY===0}function Ml(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function Nl(e,t){return Ml(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Pl(e,t,n){return Ml(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Fl(e,t,n){return Ml(t,n?e===Va:e===na,e===Ri)}function Il(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:Ml(t,n?e===na:e===Va,e===Ra)}function Ll(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,triggerOrientation:_=g,parentOrientation:v,id:y,resetOnPointerLeave:b=!0,externalTree:x,nestedReturnFocusRef:S,grid:C}=t,w=C!=null,T=e.useState(`open`),E=e.useState(`floatingElement`),D=e.useState(`domReferenceElement`),O=e.context.dataRef,k=Io(E),A=wa(D),j=cc(k),M=Dc(),N=Oc(x),ee=Z.useRef(f),P=Z.useRef(o??-1),te=Z.useRef(null),F=Z.useRef(!0),ne=J(e=>{i(P.current===-1?null:P.current,e)}),re=Z.useRef(!!E),ie=Z.useRef(T),ae=Z.useRef(!1),I=Z.useRef(!1),oe=Z.useRef(null),se=cc(h),L=cc(T),R=cc(o),ce=cc(b),le=da(),ue=da(),z=J(()=>{le.cancel();function e(e){d||(oe.current=dc(e,{sync:ae.current,preventScroll:!0}))}let t=n.current[P.current],r=I.current;t&&e(t),(ae.current?e=>e():e=>le.request(e))(()=>{let i=n.current[P.current]||t;i&&(t||e(i),he&&(r||!F.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});q(()=>{O.current.orientation=g},[O,g]),q(()=>{T||(te.current=null),T&&f===`auto`||(ee.current=f)},[T,f]),q(()=>{a&&(T&&E?(P.current=o??-1,ee.current&&o!=null&&(I.current=!0,ne())):re.current&&(P.current=-1,ne()))},[a,T,E,o,ne]),q(()=>{if(a){if(!T)ae.current=!1;else if(E){if(r==null){if(ae.current=!1,R.current!=null)return;if(re.current&&(P.current=-1,z()),(!ie.current||!re.current)&&ee.current&&(te.current!=null||ee.current===!0&&te.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>ue.request(e):queueMicrotask)(t),e+=1):(P.current=te.current==null||Pl(te.current,_,u)||l?Ai(n):Ta(n),te.current=null,ne())};t()}}else Go(n.current,r)||(P.current=r,z(),I.current=!1)}}},[a,T,E,r,R,l,n,_,u,ne,z,ue]),q(()=>{if(!a||E||!N||d||!re.current)return;let e=N.nodesRef.current,t=e.find(e=>e.id===M)?.context?.elements.floating,n=$i(ma(D??t??null)),r=e.some(e=>e.context&&X(e.context.elements.floating,n));t&&!r&&F.current&&t.focus({preventScroll:!0})},[a,E,D,N,M,d]),q(()=>{ie.current=T,re.current=!!E});let de=r!=null,fe=J(e=>{if(!L.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(P.current!==t||r!==t)&&(P.current=t,ne(e))}),B=J(()=>v??N?.nodesRef.current.find(e=>e.id===M)?.context?.dataRef?.current.orientation),pe=J(()=>Ai(n,se.current)),me=J(t=>{if(F.current=!1,ae.current=!0,t.which===229||!L.current&&t.currentTarget===j.current)return;if(l&&Il(t.key,g,u,w)){Nl(t.key,B())||xa(t),e.setOpen(!1,Y(eo,t.nativeEvent));let n=S?.current??D;Ka(n)&&n.focus();return}r!=null&&r!==P.current&&!Go(n.current,r)&&(P.current=r);let i=P.current,a=Ai(n,h),o=Ta(n,h);if(A||(t.key===`Home`&&(xa(t),P.current=a,ne(t)),t.key===`End`&&(xa(t),P.current=o,ne(t))),C!=null){let e=C(t,P.current,n,g,c,u,h,a,o);if(e!=null&&e!==P.current&&(P.current=e,ne(t)),g===`both`)return}if(Nl(t.key,g)){xa(t);let e=$i(t.currentTarget.ownerDocument);if(T&&!d&&X(t.currentTarget,e)&&!n.current.some(t=>t!=null&&X(t,e))){P.current=Pl(t.key,g,u)?a:o,ne(t),r===P.current&&z();return}let{index:l,wrapped:f}=_o(n.current,i,{decrement:!Pl(t.key,g,u),loopFocus:c,allowEscape:s,disabledIndices:h,minIndex:a,maxIndex:o});f&&(ae.current=!1),P.current=l,ne(t)}}),he=Z.useMemo(()=>({onFocus(e){ae.current=!0,fe(e)},onClick({currentTarget:e}){d||e.focus({preventScroll:!0})},onMouseMove(e){jl(e)||(ae.current=!0,I.current=!1,p&&fe(e))},onPointerLeave(e){if(!L.current||!F.current||e.pointerType===`touch`)return;ae.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&ce.current&&(oe.current?.(),oe.current=null,P.current=-1,ne(e),!d)){let e=j.current,t=$i(ma(e));e&&X(e,t)&&e.focus({preventScroll:!0})}}}),[fe,L,j,p,n,ne,ce,d]),V=Z.useMemo(()=>d&&T&&de&&{"aria-activedescendant":`${y}-${r}`},[d,T,de,y,r]),ge=Z.useMemo(()=>({...A?{}:V,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&T&&!d){let n=sa(t.nativeEvent);if(n&&!X(j.current,n))return;xa(t);let r=Y(ds,t.nativeEvent);e.setOpen(!1,r);let i=S?.current??D;!r.isCanceled&&Ka(i)&&i.focus()}else me(t)},onPointerMove(e){jl(e)||(F.current=!0)}}),[V,me,j,A,e,T,d,D,S]),_e=Z.useMemo(()=>{function t(t){e.setOpen(!0,Y(eo,t.nativeEvent,t.currentTarget))}function n(e){f===`auto`&&qi(e.nativeEvent)&&(ee.current=!d)}function r(e){ee.current=f,f===`auto`&&Wi(e.nativeEvent)&&(ee.current=!0)}return{onKeyDown(n){let r=e.select(`open`);F.current=!1;let i=n.key.startsWith(`Arrow`),a=Fl(n.key,B(),u),o=Nl(n.key,r?g:_),s=(l?a:o)||n.key===`Enter`||n.key.trim()===``;if(d&&r&&(!l||Xi(n.currentTarget)))return me(n);if(r||m||!i){if(s){let e=Nl(n.key,B());te.current=l&&e?null:n.key}l?a&&(xa(n),r?(P.current=pe(),ne(n),d&&j.current?.focus()):t(n)):o&&(R.current!=null&&(P.current=R.current),xa(n),!r&&m?t(n):me(n),r&&ne(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!d&&(P.current=-1,ne(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[me,f,pe,l,ne,e,m,g,_,B,u,R,d,j]),ve=Z.useMemo(()=>({...V,..._e}),[V,_e]);return Z.useMemo(()=>a?{reference:ve,floating:ge,item:he,trigger:_e}:{},[a,ve,ge,_e,he])}function Rl(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=J(s),f=e.useState(`open`),p=ts(),m=Z.useRef(``),h=Z.useRef(u??i??-1),g=Z.useRef(null),_=J(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!us(n)||n?.matches(`:disabled`)?!1:o==null||!rs(Ki,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===` `&&(xa(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!==` `&&(xa(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=J(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);X(r,n)||X(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});q(()=>{(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 zl=.1,Bl=zl*zl,Vl=.5;function Hl(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function Ul(e,t,n,r,i,a,o,s,c,l){let u=!1;return Hl(e,t,n,r,i,a)&&(u=!u),Hl(e,t,i,a,o,s)&&(u=!u),Hl(e,t,o,s,c,l)&&(u=!u),Hl(e,t,c,l,n,r)&&(u=!u),u}function Wl(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function Gl(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 Kl(e={}){let{blockPointerEvents:t=!1}=e,n=new Uo,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*Bl;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=sa(r),g=r.type===`mouseleave`,_=X(u,h),v=X(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&Ya(r.relatedTarget)&&X(u,r.relatedTarget))return;function y(){return!!(s&&ac(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=Gl(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=Gl(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=Gl(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=Gl(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Wl(d,f,x)||!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?Vl/2:Vl*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+Vl+1,o=C||T?S.bottom-Vl:S.top,s=C?T?S.bottom-Vl:S.top:S.bottom-Vl;M=Ul(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?Vl/2:Vl*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-Vl,o=C||T?S.top+Vl:S.bottom,s=C?T?S.top+Vl:S.bottom:S.top+Vl;M=Ul(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?Vl/2:Vl*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+Vl+1,o=w||E?S.right-Vl:S.left,s=w?E?S.right-Vl:S.left:S.right-Vl;M=Ul(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?Vl/2:Vl*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-Vl,o=w||E?S.left+Vl:S.right,s=w?E?S.left+Vl:S.right:S.left+Vl;M=Ul(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 ql(e,t,n){let{reference:r,floating:i}=e,a=ms(t),o=Ro(t),s=mo(o),c=to(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=uo(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Jl(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}=Jo(t,e),p=wo(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=bs(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=bs(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 Yl=50,Xl=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Jl},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ql(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<Yl&&(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}=ql(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Zl=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}=Jo(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=to(r),_=ms(o),v=to(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Do(o)]:xo(o)),x=p!==`none`;!d&&x&&b.push(...Vo(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=fs(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`||_===ms(t)||T.every(e=>ms(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=ms(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{}}}},Ql=new Set([`left`,`top`]);async function $l(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=to(n),s=uo(n),c=ms(n)===`y`,l=Ql.has(o)?-1:1,u=a&&c?-1:1,d=Jo(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 eu=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 $l(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}}}}},tu=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}=Jo(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=ms(i),p=Zo(f),m=u[p],h=u[f],g=(e,t)=>jo(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}}}}}},nu=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}=Jo(e,t),u={x:n,y:r},d=ms(i),f=Zo(d),p=u[f],m=u[d],h=Jo(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=Ql.has(to(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}}}},ru=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}=Jo(e,t),c=await i.detectOverflow(t,s),l=to(n),u=uo(n),d=ms(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=so(p-c[m],g),y=so(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Cs(c.left,c.right):S=p-2*Cs(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function iu(e){let t=Ts(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Ka(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Na(n)!==a||Na(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function au(e){return Ya(e)?e:e.contextElement}function ou(e){let t=au(e);if(!Ka(t))return ao(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=iu(t),o=(a?Na(n.width):n.width)/r,s=(a?Na(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var su=ao(0);function cu(e){let t=$o(e);return!Wo()||!t.visualViewport?su:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function lu(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===$o(e)}function uu(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=au(e),o=ao(1);t&&(r?Ya(r)&&(o=ou(r)):o=ou(e));let s=lu(a,n,r)?cu(a):ao(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=$o(a),t=Ya(r)?$o(r):r,n=e,i=ta(n);for(;i&&t!==n;){let e=ou(i),t=i.getBoundingClientRect(),r=Ts(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=$o(i),i=ta(n)}}return bs({width:u,height:d,x:c,y:l})}function du(e,t){let n=Ua(e).scrollLeft;return t?t.left+n:uu(Ba(e)).left+n}function fu(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-du(e,n),y:n.top+t.scrollTop}}function pu(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Ba(r),s=t?ls(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=ao(1),u=ao(0),d=Ka(r);if((d||!a)&&((La(r)!==`body`||Ea(o))&&(c=Ua(r)),d)){let e=uu(r);l=ou(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?fu(o,c):ao(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function mu(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function hu(e){let t=Ua(e),n=e.ownerDocument.body,r=Cs(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Cs(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+du(e),o=-t.scrollTop;return Ts(n).direction===`rtl`&&(a+=Cs(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var gu=25;function _u(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=$o(e),a=Ba(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Wo()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(du(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<=gu&&(s-=o)}return{width:s,height:c,x:l,y:u}}function vu(e,t){let n=uu(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=ou(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function yu(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=_u(e,n,t);else if(t===`document`)r=hu(Ba(e));else if(Ya(t))r=vu(t,n);else{let n=cu(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return bs(r)}function bu(e,t){let n=t.get(e);if(n)return n;let r=Qi(e,[],!1).filter(e=>Ya(e)&&La(e)!==`body`),i=null,a=Ts(e).position===`fixed`,o=a?la(e):e;for(;Ya(o)&&!Qa(o);){let e=Ts(o),t=oa(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=la(o)}return t.set(e,r),r}function xu(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?ls(t)?[]:bu(t,this._c):[].concat(n),r],o=yu(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=yu(t,a[e],i);s=Cs(n.top,s),c=so(n.right,c),l=so(n.bottom,l),u=Cs(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Su(e){let{width:t,height:n}=iu(e);return{width:t,height:n}}function Cu(e,t,n){let r=Ka(t),i=Ba(t),a=n===`fixed`,o=uu(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=ao(0);if((r||!a)&&((La(t)!==`body`||Ea(i))&&(s=Ua(t)),r)){let e=uu(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=du(i));let l=i&&!r&&!a?fu(i,s):ao(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 wu(e){return Ts(e).position===`static`}function Tu(e,t){if(!Ka(e)||Ts(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Ba(e)===n&&(n=n.ownerDocument.body),n}function Eu(e,t){let n=$o(e);if(ls(e))return n;if(!Ka(e)){let t=la(e);for(;t&&!Qa(t);){if(Ya(t)&&!wu(t))return t;t=la(t)}return n}let r=Tu(e,t);for(;r&&go(r)&&wu(r);)r=Tu(r,t);return r&&Qa(r)&&wu(r)&&!oa(r)?n:r||Li(e)||n}var Du=async function(e){let t=this.getOffsetParent||Eu,n=this.getDimensions,r=await n(e.floating);return{reference:Cu(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ou(e){return Ts(e).direction===`rtl`}var ku={convertOffsetParentRelativeRectToViewportRelativeRect:pu,getDocumentElement:Ba,getClippingRect:xu,getOffsetParent:Eu,getElementRects:Du,getClientRects:mu,getDimensions:Su,getScale:ou,isElement:Ya,isRTL:Ou};function Au(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ju(e,t,n){let r=null,i,a=Ba(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=ss(d),h=ss(a.clientWidth-(u+f)),g=ss(a.clientHeight-(d+p)),_=ss(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Cs(0,so(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Au(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=$o(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Mu(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=au(e),u=i||a?[...l?Qi(l):[],...t?Qi(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?ju(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?uu(e):null;c&&g();function g(){let t=uu(e);h&&!Au(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 Nu=eu,Pu=tu,Fu=Zl,Iu=ru,Lu=nu,Ru=(e,t,n)=>{let r=new Map,i=n??{},a={...ku,...i.platform,_c:r};return Xl(e,t,{...i,platform:a})},zu=typeof document<`u`?Z.useLayoutEffect:function(){};function Bu(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(!Bu(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)&&!Bu(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Vu(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Hu(e,t){let n=Vu(e);return Math.round(t*n)/n}function Uu(e){let t=Z.useRef(e);return zu(()=>{t.current=e}),t}function Wu(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);Bu(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=Uu(c),D=Uu(i),O=Uu(l),k=Z.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Ru(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!Bu(w.current,t)&&(w.current=t,Gs.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);zu(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=Z.useRef(!1);zu(()=>(A.current=!0,()=>{A.current=!1}),[]),zu(()=>{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=Hu(M.floating,u.x),r=Hu(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Vu(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 Gu=(e,t)=>{let n=Nu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ku=(e,t)=>{let n=Pu(e);return{name:n.name,fn:n.fn,options:[e,t]}},qu=(e,t)=>({fn:Lu(e).fn,options:[e,t]}),Ju=(e,t)=>{let n=Fu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Yu=(e,t)=>{let n=Iu(e);return{name:n.name,fn:n.fn,options:[e,t]}};function Xu(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=Oc(n),p=Z.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=Wu({...e,elements:{...p,...l&&{reference:l}}}),h=Z.useCallback(e=>{let t=Ya(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 q(()=>{o&&(d.current=o)},[o]),q(()=>{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 Zu=Z.createContext(void 0);function Qu(){return Z.useContext(Zu)?.direction??`ltr`}var $u=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}=Jo(e,t)||{};if(l==null)return{};let d=wo(u),f={x:n,y:r},p=Ro(i),m=mo(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=jo(D,k,O),j=!c.arrow&&uo(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}}}),ed=(e,t)=>{let{name:n,fn:r}=$u(e);return{name:n,fn:r,options:[e,t]}},td={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}}}},nd={sideX:`left`,sideY:`top`},rd=`--available-width`,id=`--available-height`,ad=`--anchor-width`,od=`--anchor-height`,sd=`--transform-origin`,cd=rd,ld=id;function ud(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 dd(e,t,n){let{rects:r,placement:i}=e;return{side:ud(t,to(i),n),align:uo(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function fd(e){return pd(e,Xu)}function pd(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,C=_.side||`flip`,w=_.align||`flip`,T=_.fallbackAxisSide||`end`,E=v?.crossAxis??!1,D=v?.rootBoundary,O=typeof n==`function`?n:void 0,k=J(O),A=O?k:n,j=cc(n),M=cc(g),N=Qu()===`rtl`,[ee,P]=Z.useState(null);!g&&ee!==null&&P(null);let te=x===`placement`,F=ee?to(ee):null,ne=ee&&te?uo(ee)||`center`:null,re=F||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":N?`left`:`right`,"inline-start":N?`right`:`left`}[i],ie=ne||o,ae=ie===`center`?re:`${re}-${ie}`,I=l;typeof I==`number`?I={top:I,right:I,bottom:I,left:I}:I&&={top:I.top||0,right:I.right||0,bottom:I.bottom||0,left:I.left||0};let oe=+(i===`bottom`),se=+(i===`top`),L=+(i===`right`),R=+(i===`left`),ce={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:I},le=Z.useRef(null),ue=cc(a),z=cc(s),de=typeof a==`function`?0:a,fe=typeof s==`function`?0:s,B=[];p&&B.push(p),B.push(Gu(e=>{let t=dd(e,i,N),n=typeof ue.current==`function`?ue.current(t):ue.current,r=typeof z.current==`function`?z.current(t):z.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[de,fe,N,i]));let pe=w===`none`&&C!==`shift`,me=!pe&&(u||E||C===`shift`),he=C===`none`?null:Ju({...ce,padding:{top:I.top+1+oe,right:I.right+1+R,bottom:I.bottom+1+se,left:I.left+1+L},mainAxis:!E&&C===`flip`,crossAxis:w===`flip`&&`alignment`,fallbackAxisSideDirection:T}),V=pe?null:Ku({...ce,rootBoundary:D,mainAxis:w!==`none`,crossAxis:me,limiter:u||E?void 0:qu(e=>{if(!le.current)return{};let{width:t,height:n}=le.current.getBoundingClientRect(),r=ms(to(e.placement)),i=r===`y`?t:n,a=r===`y`?I.left+I.right:I.top+I.bottom;return{offset:i/2+a/2}})},[ce,u,E,D,I,w]);C===`shift`||w===`shift`||ie===`center`?B.push(V,he):B.push(he,V),B.push(Yu({...ce,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!M.current)return;let i=e.style;i.setProperty(cd,`${t}px`),i.setProperty(ld,`${n}px`);let a=$o(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(ad,`${u}px`),i.setProperty(od,`${d}px`)}}),ed(e=>({element:le.current||ma(e.elements.floating).createElement(`div`),padding:le.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=to(r),u=uo(r),d=ms(l)===`y`,f=le.current,p=typeof a==`function`?a(dd(e,i,N)):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 me&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(sd,d?`${m} ${h}`:`${h} ${m}`),{}}},td,b),q(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let ge=Z.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:_e,elements:ve,x:ye,y:be,middlewareData:xe,update:Se,placement:Ce,context:we,isPositioned:Te,floatingStyles:Ee}=t({rootContext:h,open:m?g:void 0,placement:ae,middleware:B,strategy:r,whileElementsMounted:m?void 0:(...e)=>Mu(...e,ge),nodeId:y,externalTree:S}),{sideX:De,sideY:Oe}=xe.adaptiveOrigin||nd,ke=Te?r:`fixed`,Ae=Z.useMemo(()=>{let e;return e=Te?b?{position:ke,[De]:ye,[Oe]:be}:{...Ee,position:ke}:{position:ke,top:0,left:0},e[cd]=`100vw`,e[ld]=`100vh`,Te||(e.opacity=0),e},[b,ke,De,ye,Oe,be,Ee,Te]),je=Z.useRef(null);q(()=>{if(!g)return;let e=j.current,t=typeof e==`function`?e():e,n=(md(t)?t.current:t)||null;n!==je.current&&(_e.setPositionReference(n),je.current=n)},[g,_e,A,j]),Z.useEffect(()=>{if(!g)return;let e=j.current;typeof e!=`function`&&md(e)&&e.current!==je.current&&(_e.setPositionReference(e.current),je.current=e.current)},[g,_e,A,j]),Z.useEffect(()=>{if(m&&g&&ve.reference&&ve.floating)return Mu(ve.reference,ve.floating,Se,ge)},[m,g,ve,Se,ge]);let Me=to(Ce),Ne=ud(i,Me,N),Pe=uo(Ce)||`center`,Fe=!!xe.hide?.referenceHidden;q(()=>{x&&g&&Te&&(Me!==re||te&&Pe!==ie)&&P(Ce)},[x,te,g,Te,Ce,Me,Pe,re,ie]);let Ie=Z.useMemo(()=>({position:`absolute`,top:xe.arrow?.y,left:xe.arrow?.x}),[xe.arrow]),Le=xe.arrow?.centerOffset!==0;return Z.useMemo(()=>({positionerStyles:Ae,arrowStyles:Ie,arrowRef:le,arrowUncentered:Le,side:Ne,align:Pe,physicalSide:Me,anchorHidden:Fe,refs:_e,context:we,isPositioned:Te,update:Se}),[Ae,Ie,le,Le,Ne,Pe,Me,Fe,_e,we,Te,Se])}function md(e){return e!=null&&`current`in e}function hd(e){return e===`starting`?Ni:Ui}function gd(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),Pa(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},hd(r),i],stateAttributesMapping:rc})}var _d=e(ki(),1);function vd(e){let t=_d.unstable_scheduleCallback(4,e);return()=>_d.unstable_cancelCallback(t)}var yd=Z.createContext(Ve({scheduleTask:vd,defaultIdleTTL:400})),bd=new WeakMap,xd=0,Sd=new Set;function Cd(e){xd++;try{return e()}finally{xd--}}function wd(e){if(xd===0)return e();Sd.size===0&&queueMicrotask(Td),Sd.add(e)}function Td(){for(let e of Sd)Sd.delete(e),e()}function Ed(e,t){let n=bd.get(e);n===void 0&&(n=new WeakMap,bd.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,()=>wd(n));return()=>{i--,Sd.delete(n),r()}},snapshot(){return Cd(()=>e.get(t))},getServerSnapshot(){return(i===0||a===void 0)&&(a={value:Cd(()=>si(t,e))}),a.value}};return n.set(t,o),o}function Dd(e,t){let n=Ed(e,t);return Z.useEffect(Td),Z.useSyncExternalStore(n.subscribe,n.snapshot,n.getServerSnapshot)}function Od(e,t,n){let r=Ed(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(Td),Z.useSyncExternalStore(r.subscribe,()=>i(r.snapshot()),()=>i(r.getServerSnapshot()))}var kd=(e,t)=>{let n=Z.useContext(yd);return t?Od(n,e,t):Dd(n,e)};function Ad(e,t){Z.useEffect(()=>e.mount(t),[t,e])}function jd(e,t,n){return n?.mode===`promise`||n?.mode===`promiseExit`?Z.useCallback(r=>{e.set(t,r);let i=di(Me(e,t,{suspendOnWaiting:!0}));return n.mode===`promise`?i.then(Md):i},[e,t,n.mode]):Z.useCallback(n=>{e.set(t,typeof n==`function`?n(e.get(t)):n)},[e,t])}var Md=e=>{if(Pe(e))return e.value;throw pe(e.cause)},Nd=e=>{Ad(Z.useContext(yd),e)},Pd=(e,t)=>{let n=Z.useContext(yd);return Ad(n,e),jd(n,e,t)},Fd=(e,t)=>{let n=Z.useContext(yd);return[Dd(n,e),jd(n,e,t)]},Id={suspendOnWaiting:new WeakMap,default:new WeakMap};function Ld(e,t,n){let r=n?Id.suspendOnWaiting:Id.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 Rd(e,t,n){let r=Dd(e,t);if(r._tag===`Initial`||n&&r.waiting)throw Ld(e,t,n);return r}var zd=(e,t)=>{let n=Rd(Z.useContext(yd),e,t?.suspendOnWaiting??!1);if(n._tag===`Failure`&&!t?.includeFailure)throw pe(n.cause);return n};Ft(`MachineSchemaEncodeError`);var Bd=class extends Ft(`MachineSchemaDecodeError`){},Vd=class extends Ft(`InfiniteTransitionError`){},Hd=class extends Ft(`StartupError`){},Ud=class extends Ft(`ChildAlreadyExistsError`){};Ft(`ProcessLocalError`);var Wd=class extends Ft(`StoppedError`){},Gd=e=>e instanceof Vd||e instanceof Bd,Kd=e=>Gd(e)?jr(e):bn(e),qd=e=>Gd(e)||e instanceof Hd?e:new Hd({cause:Qe(e)}),Jd=e=>e,Yd=`~effect/Machine/Target`,Xd=Symbol(`effect/Machine/TargetSnapshot`),Zd=Symbol(`effect/Machine/StateInput`),Qd=Symbol(`effect/Machine/HistoryTarget`),$d=Symbol(`effect/Machine/InitialTarget`),ef=Symbol(`effect/Machine/ChoiceTarget`),tf=Symbol(`effect/Machine/NoTarget`),nf=Symbol(`effect/Machine/Declined`),rf=Symbol(`effect/Machine/TargetSelection`),af=Symbol(`effect/Machine/StateUpdate`),of=Symbol(`effect/Machine/CombinedTarget`),sf=Symbol(`effect/Machine/SelectedBranch`),cf=(e,t,n,r)=>Object.freeze({[rf]:rf,kind:e,scope:n,path:t,...r===void 0?{}:{updatePath:r}}),lf=cf(`none`,void 0,`local`),uf=e=>B(e,rf),df=(e,t)=>Object.freeze({[af]:af,path:e,value:t}),ff=e=>B(e,af),pf=(e,t)=>Object.freeze({[of]:of,target:e,update:t}),mf=e=>B(e,of),hf=(e,t,n,r)=>Object.freeze({[sf]:sf,owner:e,branchIndex:t,branchKey:n,result:r}),gf=e=>B(e,sf),_f=Object.freeze({[tf]:tf}),vf=()=>_f,yf=e=>B(e,tf),bf=Object.freeze({[nf]:nf}),xf=()=>bf,Sf=e=>B(e,nf),Cf=(e,t)=>({[Qd]:Qd,path:e,parent:t}),wf=e=>B(e,Qd),Tf=(e,t,n)=>({[$d]:$d,_tag:`InitialTarget`,path:e,value:t,...n===void 0?{}:{values:n}}),Ef=e=>B(e,$d),Df=(e,t,n)=>({[ef]:ef,path:e,parent:t,...n===void 0?{}:{values:n}}),Of=e=>B(e,ef),kf=(e,t)=>{if(!_t(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(!_t(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(_t(t))return{schema:t,output:void 0,annotations:Rt(t),type:`atomic`,history:void 0,initial:void 0,states:void 0};let n=B(t,`schema`)&&_t(t.schema)?t.schema:void 0,r=n===void 0?t.annotations:Rt(n);if(t.type===`parallel`&&!B(t,`states`))throw Error(`Machine.make expected parallel state "${e}" to declare child regions`);if(B(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:_t(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=_t(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}},Af=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=kf(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)}},jf=e=>typeof e==`object`&&e&&`branches`in e&&Array.isArray(e.branches)?Array.from(e.branches):[],Mf=e=>typeof e==`object`&&e&&`declinable`in e&&e.declinable===!0?`declinable`:`required`,Nf=e=>{let t=[];for(let n of e.stateNodes.byPath.values()){let r=Jd(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:jf(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:B(i,`reenter`)&&i.reenter===!0,acceptance:Mf(i),branches:jf(i)})}r.always!==void 0&&t.push({source:n.path,trigger:{type:`always`},reenter:!1,acceptance:Mf(r.always),branches:jf(r.always)}),r.onDone!==void 0&&t.push({source:n.path,trigger:{type:`done`},reenter:!1,acceptance:Mf(r.onDone),branches:jf(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:Mf(a),branches:jf(a)})}}}return t},Pf=(e,t,n)=>({[Yd]:Yd,[Xd]:n?.snapshot,path:e,value:t,values:n?.values}),Ff=e=>B(e,Yd),If=e=>({[Zd]:Zd,input:e}),Lf=e=>B(e,Zd),Rf=e=>B(e,`path`)&&B(e,`value`),zf=(e,t,n)=>{if(e.path===t)return f(e);if(e.path!==``&&!t.startsWith(`${e.path}.`))return Ze();if(n!==void 0&&e.value!==void 0&&(n[e.path]=e.value),B(e,`state`)&&Rf(e.state))return zf(e.state,t,n);if(B(e,`states`)&&typeof e.states==`object`&&e.states!==null){for(let r of Object.values(e.states))if(Rf(r)){let e=zf(r,t,n);if(He(e))return e}}return Ze()},$=(e,t)=>{let n=e.stateNodes.byPath.get(t);if(n===void 0)throw Error(`Machine expected state path "${t}" to exist`);return n},Bf=e=>{if(e.schema===void 0)throw Error(`Machine state "${e.path}" has no value schema`);return e.schema},Vf=new WeakMap,Hf=Symbol(`effect/Machine/EventConstruction`),Uf=new WeakMap,Wf=new WeakMap,Gf=new WeakMap,Kf=e=>{let t=e,n=Wf.get(t);if(n!==void 0)return n;let r=ne(Ut(e));return Wf.set(t,r),r},qf=e=>{let t=e,n=Gf.get(t);if(n!==void 0)return n;let r=de(Ut(e));return Gf.set(t,r),r},Jf=Symbol.for(`effect/Machine/protocol`),Yf=e=>{let t=e[Jf];if(t===void 0)throw Error(`Machine protocol is unavailable`);return t},Xf=(e,t)=>{Object.defineProperty(e,Jf,{value:t,enumerable:!1})},Zf=e=>{let t=new Set,n=e=>{let r=e;if(!t.has(r)&&(t.add(r),B(e,`cases`)&&typeof e.cases==`object`&&e.cases!==null))for(let t of Object.values(e.cases))(typeof t==`object`&&t||typeof t==`function`)&&B(t,`make`)&&n(t)};for(let t of e)n(t);return t},Qf=(e,t)=>{let n=Vf.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},$f=e=>Qf(e.events,`public`).schemas,ep=e=>Qf(e.internalEvents,`internal`).schemas,tp=e=>Qf(e.emittedEvents,`emitted`).schemas,np=e=>{let t=$f(e),n=ep(e),r=tp(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];Xf(e,{event:Le(a),emit:Le(r),eventConstructors:Zf(a),emissionConstructors:Zf(r)})},rp=(e,t)=>Xf(t,Yf(e)),ip=e=>B(e,`_tag`)?String(e._tag):void 0,ap=(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={[Hf]:Hf,_tag:n};return Uf.set(o,{kind:e,schema:t,input:i,...a===void 0?{}:{inputError:a}}),Object.freeze(o)},op=e=>typeof e==`object`&&!!e&&Uf.has(e),sp=(e,t)=>{let n=[],r=e=>{if(B(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(B(e,`members`)&&Array.isArray(e.members))for(let t of e.members)r(t);else n.push(e)};for(let e of t)r(e);let i=Object.create(null),o=e=>yn(e)?typeof e.literal==`string`||typeof e.literal==`number`?[e.literal]:[]:er(e)?[e.symbol]:a(e)?e.enums.map(([,e])=>e):ln(e)?e.types.flatMap(o):Qt(e)?o(e.thunk()):[],s=e=>{let t=Kr(e.ast);if(ur(t)){let e=t.propertySignatures.find(({name:e})=>e===`_tag`),n=e===void 0?[]:o(e.type);if(n.length>0)return n}try{return Le([e]).pipe(Nt(`_tag`)).discriminants}catch{return[]}};for(let t of n){let n=s(t);if(n.length!==0)for(let r of n){if(B(i,r))throw Error(`Duplicate machine event constructor tag: ${String(r)}`);Object.defineProperty(i,r,{value:(...n)=>ap(e,t,r,n.length===0?{}:n[0]),enumerable:!0})}}return i},cp=(e,t)=>{let n=Object.freeze(Array.from(t)),r=sp(e,n);return Vf.set(r,{kind:e,schemas:n}),Object.freeze(r)},lp=(e,t,n,r)=>Kf(t)(n).pipe(ar(t=>new Bd({machineId:e.id,boundary:r.boundary,cause:t,...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}}))),up=(e,t,n,r)=>{let i=qf(t)(n);if(ni(i))throw new Bd({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},dp=(e,t,n,r)=>{try{return t.make(n)}catch(t){let n=t instanceof Error?t.cause:void 0;throw new Bd({machineId:e.id,boundary:r.boundary,cause:Ot(t)?t:B(n,`~effect/SchemaIssue/Issue`)?new D(n):Qe(t),...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}})}},fp=(e,t,n)=>new Bd({machineId:e.id,boundary:n,event:String(t._tag),cause:Qe(Error(`Constructed ${n} schema does not belong to the machine ${n} protocol`))}),pp=(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}},mp=(e,t,n,r)=>new Bd({machineId:e.id,boundary:n,event:String(t._tag),cause:Qe(r)}),hp=(e,t,n,r)=>{let i=Uf.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)?jr(fp(e,n,r)):Ie({try:()=>pp(n,i),catch:t=>mp(e,n,r,t)}).pipe($t(t=>i.schema.makeEffect(t).pipe(ar(t=>new Bd({machineId:e.id,boundary:r,event:String(n._tag),cause:new D(t)})))))},gp=(e,t,n,r)=>{let i=Uf.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 fp(e,n,r);let o;try{o=pp(n,i)}catch(t){throw mp(e,n,r,t)}return dp(e,i.schema,o,{boundary:r,event:String(n._tag)})},_p=(e,t)=>{let n=Yf(e);if(op(t))return hp(e,n,t,`event`);let r=ip(t);return lp(e,n.event,t,r===void 0?{boundary:`event`}:{boundary:`event`,event:r})},vp=(e,t)=>{let n=Yf(e);if(op(t))return gp(e,n,t,`event`);let r=ip(t);return up(e,n.event,t,r===void 0?{boundary:`event`}:{boundary:`event`,event:r})},yp=(e,t)=>{let n=Yf(e);if(op(t))return hp(e,n,t,`emission`);let r=ip(t);return lp(e,n.emit,t,r===void 0?{boundary:`emission`}:{boundary:`emission`,event:r})},bp=(e,t)=>{let n=Yf(e);if(op(t))return gp(e,n,t,`emission`);let r=ip(t);return up(e,n.emit,t,r===void 0?{boundary:`emission`}:{boundary:`emission`,event:r})},xp=(e,t,n)=>up(e,t,n,{boundary:`input`}),Sp=(e,t,n)=>Lf(n)?Bf(t).makeEffect(n.input).pipe(ar(n=>new Bd({machineId:e.id,boundary:`state`,state:t.path,cause:new D(n)}))):lp(e,Bf(t),n,{boundary:`state`,state:t.path}),Cp=(e,t,n)=>Lf(n)?dp(e,Bf(t),n.input,{boundary:`state`,state:t.path}):up(e,Bf(t),n,{boundary:`state`,state:t.path}),wp=(e,t,n)=>t.output===void 0?E(n):lp(e,t.output,n,{boundary:`output`,state:t.path}),Tp=(e,t,n)=>t.output===void 0?n:up(e,t.output,n,{boundary:`output`,state:t.path}),Ep=(e,t)=>{let n=new Set(Ip(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)&&!Fp(r,t.parent))throw Error(`Machine history contains state "${r}" outside parent "${t.parent}"`);if(t.mode===`shallow`&&Pp(r,t.parent)&&$(e,r).parent!==t.parent)throw Error(`Machine shallow history contains deep descendant "${r}"`)}},Dp=(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`||!(Fp(n,t.parent)||Ip(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,Cp(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}),Ep(e,n.get(r))}return n},Op=_r(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*jr(new Bd({machineId:e.id,boundary:`history`,state:r,cause:Qe(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`||!(Fp(n,t.parent)||Ip(e,t.parent).includes(n)))return yield*jr(new Bd({machineId:e.id,boundary:`history`,state:n,cause:Qe(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*jr(new Bd({machineId:e.id,boundary:`history`,state:n,cause:Qe(Error(`Machine snapshot contains a value for structural state "${n}"`))}))}else{if(!s)return yield*jr(new Bd({machineId:e.id,boundary:`history`,state:n,cause:Qe(Error(`Machine snapshot omits remembered value for "${n}"`))}));o.set(n,yield*lp(e,Bf(r),i.values[n],{boundary:`history`,state:n}))}}if(!a.has(t.parent)||Object.keys(i.values).length!==o.size)return yield*jr(new Bd({machineId:e.id,boundary:`history`,state:r,cause:Qe(Error(`Machine snapshot contains incomplete history record "${r}"`))}));n.set(r,{mode:i.mode,parent:t.parent,active:a,values:o});try{Ep(e,n.get(r))}catch(t){return yield*jr(new Bd({machineId:e.id,boundary:`history`,state:r,cause:Qe(t)}))}}return n}),kp=(e,t)=>{let n={};for(let[r,i]of t){let t=Array.from(i.active).sort((t,n)=>Rp(e,t,n));n[r]={mode:i.mode,active:t,values:Object.fromEntries(i.values)}}return n},Ap=(e,t)=>({...e,machineReferences:{self:t.self,parent:t.parent}}),jp=e=>e.machineReferences,Mp=new WeakMap,Np=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Pp=(e,t)=>e!==t&&(t===``||e.startsWith(`${t}.`)),Fp=(e,t)=>e===t||Pp(e,t),Ip=(e,t)=>{let n=Mp.get(e.stateNodes);n===void 0&&(n=new Map,Mp.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},Lp=(e,t)=>Ip(e,t).length,Rp=(e,t,n)=>$(e,t).order-$(e,n).order,zp=(e,t,n)=>$(e,n).children.some(e=>t.active.has(e)),Bp=(e,t)=>{let n=Array.from(t.active).filter(n=>!zp(e,t,n)).sort((t,n)=>Rp(e,t,n));if(n.length===0)throw Error(`Machine expected an active leaf state`);return n},Vp=(e,t)=>Bp(e,t)[0],Hp=(e,t,n)=>{let r=Bp(e,t).filter(e=>Fp(e,n));if(r.length===0)throw Error(`Machine expected state "${n}" to have an active leaf state`);return r[0]},Up=(e,t)=>{for(let n of t.active)if($(e,n).parent===void 0)return n;throw Error(`Machine expected an active root state`)},Wp=(e,t,n)=>{let r={},i=Ip(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},Gp=(e,t,n)=>{let r=$(e,n).parent;return r===void 0?void 0:t.values.get(r)},Kp=(e,t)=>{let n=r=>t.active.has(r)?[r,...$(e,r).children.flatMap(n)]:[];return e.stateNodes.roots.flatMap(n)},qp=(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=qp(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]=qp(e,t,i)}i.states=a}return i},Jp=(e,t)=>{let n=qp(e,t,Up(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:kp(e,t.history)}),n},Yp=(e,t,n)=>{let r=qp(e,t,n);return t.history.size>0&&Object.assign(r,{history:kp(e,t.history)}),r},Xp=(e,t,n)=>{if(!B(n,`state`)||!Rf(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},Zp=(e,t)=>{if(!B(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},Qp=(e,t,n,r)=>{let i=$(e,n),a=r[i.key];if(!Np(r,i.key)||!Rf(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},$p=(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,Cp(e,i,t.value));if(i.type===`compound`&&a(Xp(e,i,t)),i.type===`parallel`){let n=Zp(i,t);for(let t of i.children)a(Qp(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:Dp(e,t)}},em=(e,t)=>$p(e,t),tm=(e,t)=>{try{return $p(e,t)}catch(t){throw t instanceof Bd?t:new Bd({machineId:e.id,boundary:`configuration`,cause:Qe(t)})}},nm=_r(function*(e,t){let n=new Set,r=new Map,i=t.completed,a=_r(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*Sp(e,i,t.value));if(i.type===`compound`&&(yield*a(Xp(e,i,t))),i.type===`parallel`){let n=Zp(i,t);for(let t of i.children)yield*a(Qp(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*Op(e,t)}}),rm=(e,t)=>nm(e,t).pipe(jt(t=>{if(bt(t))return Bn(ve(t,t=>t instanceof Bd?t:new Bd({machineId:e.id,boundary:`configuration`,cause:bi(t)})));let n=p(t);return He(n)&&n.value instanceof Bd?jr(n.value):jr(new Bd({machineId:e.id,boundary:`configuration`,cause:t}))})),im=(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 Ip(e,n.parent))t.active.has(r)&&o.add(r);for(let i of t.active)(i===n.parent||r===`deep`&&Pp(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}},am=(e,t)=>e.history.get(t),om=(e,t,n)=>{let r=new Set(n.active),i=new Map(n.values),a=new Map,o=Ip(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)Fp(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}};_r(function*(e,t,n,r,i){let a=$(e,n),o=new Set,s=new Map,c=new Map,l=Ip(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&&Np(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*Sp(e,c,r));else if(i!==void 0&&Np(i,n))s.set(n,yield*Sp(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)Fp(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}}),_r(function*(e,t,n,r){let i=yield*nm(e,n),a=new Set(i.active),o=new Map(i.values),s=new Map(i.outputs),c=Ip(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&&Np(r,i))throw Error(`Machine structural target "${i}" cannot contain a value`)}else if(r!==void 0&&Np(r,i))o.set(i,yield*Sp(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)Fp(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&&Np(r,n))for(let[t,i]of Object.entries(r)){if(!Fp(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*Sp(e,r,i))}}}}return{active:a,values:o,outputs:s,history:new Map([...t.history,...i.history])}});var sm=(e,t,n,r,i,a=!1)=>{let o=$(e,n),s=new Set,c=new Map,l=new Map,u=Ip(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&&Np(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,Cp(e,a,r));else if(i!==void 0&&Np(i,n))c.set(n,Cp(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)Fp(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}},cm=(e,t,n)=>{let r=sm(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,Cp(e,n,r))}return{...r,active:i,values:a}},lm=(e,t,n,r)=>{let i=$p(e,n),a=new Set(i.active),o=new Map(i.values),s=new Map(i.outputs),c=Ip(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&&Np(r,i))throw Error(`Machine structural target "${i}" cannot contain a value`)}else if(r!==void 0&&Np(r,i))o.set(i,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)Fp(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&&Np(r,n))for(let[t,i]of Object.entries(r)){if(!Fp(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,Cp(e,r,i))}}}}return{active:a,values:o,outputs:s,history:new Map([...t.history,...i.history])}},um=(e,t,n)=>{if(Ff(n)){let r=n[Xd];if(r!==void 0){if(String(r.path)!==String(n.path))throw Error(`Machine expected target snapshot path to be "${n.path}"`);return lm(e,t,r,n.values)}return sm(e,t,n.path,n.value,n.values)}if(Rf(n)){let r=tm(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`)},dm=(e,t)=>Jd(e).handlers[t],fm=(e,t,n)=>$(e,n).children.find(e=>t.active.has(e)),pm=(e,t)=>$(e,t).type===`final`,mm=(e,t)=>dm(e,t)?.onDone!==void 0,hm=(e,t,n)=>{if(!t.active.has(n))return!1;let r=$(e,n);if(r.type===`compound`){let r=fm(e,t,n);return r!==void 0&&(n===``?!mm(e,r)&&hm(e,t,r):pm(e,r))}if(r.type===`parallel`){for(let n of r.children)if(!hm(e,t,n))return!1;return!0}return pm(e,n)},gm=(e,t)=>{let n=Up(e,t);return hm(e,t,n)&&!mm(e,n)},_m=(e,t,n)=>e.has(t)?{path:t,output:e.get(t),isNew:!1}:(e.set(t,n),{path:t,output:n,isNew:!0}),vm=_r(function*(e,t,n,r,i){let a=$(e,n),o=dm(e,n)?.output?.({state:t.values.get(n),containingState:Gp(e,t,n),ancestors:Wp(e,t,n),event:r,outputs:i});return yield*wp(e,a,o)}),ym=_r(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=fm(e,t,n);if(o===void 0||(n===``?mm(e,o):!pm(e,o)))return;let s=yield*ym(e,t,o,r,i,a);if(s===void 0)return;let c=_m(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*ym(e,t,n,r,i,a);o===void 0?c=!1:s[$(e,n).key]=o.output}if(!c)return;let l=_m(i,n,yield*vm(e,t,n,r,s));return l.isNew&&a.push(l),l}if(!pm(e,n))return;let s=_m(i,n,yield*vm(e,t,n,r));return s.isNew&&a.push(s),s}),bm=_r(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=Lp(e,n)-Lp(e,t);return r===0?Rp(e,t,n):r}))yield*ym(e,a,t,n,r,i);return{configuration:a,completions:i}}),xm=(e,t,n,r,i)=>{let a=$(e,n),o=dm(e,n)?.output?.({state:t.values.get(n),containingState:Gp(e,t,n),ancestors:Wp(e,t,n),event:r,outputs:i});return Tp(e,a,o)},Sm=(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=fm(e,t,n);if(o===void 0||(n===``?mm(e,o):!pm(e,o)))return;let s=Sm(e,t,o,r,i,a);if(s===void 0)return;let c=_m(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=Sm(e,t,n,r,i,a);o===void 0?c=!1:s[$(e,n).key]=o.output}if(!c)return;let l=_m(i,n,xm(e,t,n,r,s));return l.isNew&&a.push(l),l}if(!pm(e,n))return;let s=_m(i,n,xm(e,t,n,r));return s.isNew&&a.push(s),s},Cm=(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=Lp(e,n)-Lp(e,t);return r===0?Rp(e,t,n):r}))Sm(e,a,t,n,r,i);return{configuration:a,completions:i}},wm=e=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine construction must be an object`);return e},Tm=(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 If(Object.hasOwn(t,`data`)?t.data:{})}},Em=(e,t,n={},r)=>{let i=e.byPath.get(t);if(i?.type===`atomic`||i?.type===`final`){let e=wm(n);if(Reflect.ownKeys(e).some(e=>e!==`data`&&e!==`decoded`))throw Error(`Machine leaf construction accepts only data and decoded`);return Pf(t,Tm(i,e))}let a=new Map,o=(t,n)=>{let i=wm(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=Tm(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=wm(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=wm(n);for(;u.states!==void 0;){let t=e.byPath.get(l),n=wm(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=wm(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 Df(l,d.parent??``,p);if(d.type===`atomic`||d.type===`final`)return Pf(l,f,{values:p});let m=new Map([...a].filter(([e])=>e.startsWith(`${l}.`)));return{...Tf(l,f,p),...m.size===0?{}:{children:m}}},Dm=(e,t,n)=>{let r=wm(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 df(t,Tm(i,r))},Om=(e,t,n=``)=>{let r=wm(t),i=e.byPath.get(n);Em(e,n,r);let a=Tm(i,r);if(i.type===`choice`)return Df(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=wm(r.states),s=Object.fromEntries(Object.entries(o).map(([t,r])=>[t,Om(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]}},km=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(t);return e},Am=`root`,jm=e=>{let t=new Map,n=(e,r)=>{let i=!_t(e)&&`type`in e?e.type:void 0;if(t.set(r,i===`history`||i===`choice`?i:`state`),!_t(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 "${Am}" is reserved for the root`);return t},Mm=(e,t)=>{let n=jm(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(km(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(km(t.branches,`Machine branches must be a map`))){let t=km(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={...km(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 Pm({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}},Nm=(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}},Pm=(e,t)=>{let n=[`target`,`history`,`none`,`initialize`].filter(e=>t[e]!==void 0);if(n.length===0&&t.update!==void 0){let n=Nm(t.update,e);if(n.kind!==`state`)throw Error(`Machine update requires an active state reference`);return cf(`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 lf}if(r===`initialize`){if(t.update!==void 0)throw Error(`Machine initialize cannot update a retained owner`);return cf(`state`,``,`branch`)}let i=Nm(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:Nm(t.update,e).path;if(a!==void 0&&r!==`target`)throw Error(`Machine owner updates require an ordinary destination`);return cf(i.kind,i.path,r===`history`?`full`:`branch`,a)},Fm=(e,t,n,r)=>{let i=km(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`&&Tn(a.value))&&!(a.kind===`streams`&&it(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}},Im=Symbol(`effect/Machine/InitialEvent`),Lm=Symbol(`effect/Machine/SnapshotBuilderState`),Rm=Symbol(`effect/Machine/ChildMachineLogic`),zm=new WeakSet,Bm=e=>zm.has(e),Vm=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine ${t} must be an object`);return e},Hm=e=>typeof e==`function`?e:()=>e,Um=e=>{if(typeof e==`object`&&e&&B(e,`decoded`)&&e.decoded===!0&&B(e,`data`)){let t=Vm(e,`decoded construction`);if(Reflect.ownKeys(t).some(e=>e!==`decoded`&&e!==`data`))throw Error(`Machine decoded construction accepts only decoded and data`);return Hm(t.data)}let t=Hm(e);return n=>If(e===void 0?{}:t(n))},Wm=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(!B(e,`data`))throw Error(`Machine decoded construction requires data`);return Hm(e.data)}let t=Hm(e.data);return n=>If(B(e,`data`)?t(n):{})},Gm=(e,t)=>{let n=(e,t,r)=>{if(B(t,`initialize`))throw Error(`Machine child construction belongs in initial declarations`);if(r!==``&&B(t,`root`))throw Error(`Machine root construction belongs at the root handler`);let{initial:i,root:a,states:o,...s}=t;if(_t(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?{}:Vm(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?{}:Vm(i,`parallel initial regions`);for(let[n,r]of Object.entries(t)){let t=e.states[n];if(t===void 0||!_t(t)&&(t.type===`history`||t.type===`choice`))throw Error(`Machine invalid initial region "${n}"`);if(!_t(t)&&(!(`schema`in t)||t.schema===void 0))throw Error(`Machine schema-less region "${n}" cannot construct data`);d[n]=Um(r)}}else{let t=Vm(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||_t(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`&&(B(t,`data`)||B(t,`decoded`)))throw Error(`Machine choice initial edges cannot construct data`);let c=Wm(t),l=e.states[a];if(B(t,`data`)&&!_t(l)&&(!(`schema`in l)||l.schema===void 0))throw Error(`Machine schema-less initial child "${a}" cannot construct data`);B(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?{}:Vm(c[t],`state handler`),e);l[t]=a.node,(_t(i)||i.type!==`history`)&&(c[t]!==void 0||!_t(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{[Lm]:i}};return zm.add(g),{node:m,handlers:{...s,...h.length===0?{}:{initialize:g},states:u}}};return n(e.node,t,``)},Km=(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)},qm=e=>`child`in e?e.child.id:e.id,Jm=(e,t)=>{let n=new Set;for(let r of e){let e=qm(r);if(n.has(e))throw Error(`Machine invocations for state "${t}" must have distinct ids; "${e}" is declared twice`);n.add(e)}},Ym=e=>e===void 0?[]:Array.isArray(e)?e:[e],Xm=e=>{let t=[],n=[],r=[];return{commands:t,raisedEvents:n,emittedEvents:r,enqueue:{raise:t=>{n.push(vp(e,t))},emit:t=>{r.push(bp(e,t))},sendTo:(e,n)=>{t.push({_tag:`SendTo`,target:e,event:n})},stop:e=>{t.push({_tag:`Stop`,child:e})}}}},Zm=(e,t)=>{let n=e.stateNodes.byPath.get(t);if(n===void 0)throw Error(`Machine expected state path "${t}" to exist`);return n},Qm=e=>{let t={};return Object.defineProperty(t,"decoded",{value:e,enumerable:!1}),Object.defineProperty(t,"from",{value:(...t)=>e(If(t.length===0?{}:t[0])),enumerable:!1}),t},$m=e=>{let t={};return Object.defineProperty(t,Lm,{value:e,enumerable:!1}),t},eh=(e,t,n)=>{let r=$m(n);for(let i of t.children){let a=Zm(e,i);a.schema===void 0||B(n,a.key)||(r[a.key]=Qm(r=>{let i=Object.assign({},n);return i[a.key]=r,eh(e,t,i)}))}return r},th=(e,t)=>{let n=Zm(e,t);if(n.type===`parallel`)return eh(e,n,{});if(n.type!==`compound`)throw Error(`Machine state "${t}" cannot initialize child states`);let r=Zm(e,n.initial);if(r.schema===void 0)throw Error(`Machine state "${t}" has no schema-valued initial child`);return Qm(e=>$m({[r.key]:e}))},nh=(e,t)=>{if(typeof t!=`object`||!t||!B(t,Lm))throw Error(`Machine initialize handler for "${e}" must return its builder result`);return t[Lm]},rh=Symbol(`effect/Machine/InvocationEvent`),ih=(e,t,n)=>({[rh]:!0,path:e,id:t,type:`done`,output:n}),ah=(e,t,n)=>({[rh]:!0,path:e,id:t,type:`element`,element:n}),oh=(e,t,n)=>({[rh]:!0,path:e,id:t,type:`failure`,error:n}),sh=(e,t,n)=>({[rh]:!0,path:e,id:t,type:`snapshot`,snapshot:n}),ch=e=>typeof e==`object`&&!!e&&rh in e,lh=new WeakMap,uh=new WeakMap,dh=(e,t)=>e.parent===void 0?{self:t.self}:{self:t.self,parent:t.parent},fh=(e,t)=>{let n=Object.create(e);return uh.set(n,dh(e,t)),n},ph=(e,t)=>{let n=t.machineReferences;if(n!==void 0)return dh(e,n);let r=uh.get(e);if(r!==void 0)return r;let i=lh.get(e);if(i!==void 0)return i;let a=dh(e,{self:{id:e.id??`Machine`,sessionId:`Machine.plan`,send:()=>jr(new Wd)},parent:void 0});return lh.set(e,a),a},mh=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}},hh=(e,t,n)=>{let r=Xm(e);return t===void 0||t(n,r.enqueue),{commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents}},gh=(e,t,n,r)=>{let i=Xm(e),a=r===void 0?{result:t(n,i.enqueue),branchIndex:0,branchKey:void 0}:r(n,i.enqueue);return Sf(a.result)?{declined:!0}:{declined:!1,state:yf(a.result)?void 0:a.result,branchIndex:a.branchIndex,branchKey:a.branchKey,commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents}},_h=(e,t,n)=>{let r=Xm(e);return{value:t(n,r.enqueue),commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents}},vh=(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)=>Rp(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=Jh(e,m,Df(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=Ef(i)?bh(e,r,i,n):wf(i)?xh(e,r,i,n):void 0;r=um(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=Jd(e).handlers[d]?.initialize;if(t===void 0){a.set(p.path,Cp(e,p,If({}))),u=!0;continue}let i=_h(e,t,{...ph(e,m),state:m.values.get(d),containingState:Gp(e,m,d),ancestors:Wp(e,m,d),event:n,...d===``&&r!==void 0?{input:r.value}:{},...Bm(t)?{}:{builder:th(e,d)}}),l=nh(d,i.value);a.set(p.path,Cp(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:Jd(e).handlers[d]?.initialize,h=m===void 0?void 0:_h(e,m,{...ph(e,p),state:p.values.get(d),containingState:Gp(e,p,d),ancestors:Wp(e,p,d),event:n,...d===``&&r!==void 0?{input:r.value}:{},...Bm(m)?{}:{builder:th(e,d)}}),g=h===void 0?void 0:nh(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,Cp(e,n,If({})));continue}if(g===void 0||!Object.prototype.hasOwnProperty.call(g,n.key)){if(m!==void 0&&Bm(m)){a.set(n.path,Cp(e,n,If({})));continue}throw Error(`Machine parallel state initializer for "${d}" must return region "${n.key}"`)}a.set(n.path,Cp(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 yh(e,t,n,r){let i=cm(e,t,n);if(n.children===void 0||![...n.children.keys()].some(t=>$(e,t).type===`choice`))return vh(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=Jh(e,i,Df(t,n.parent),r);for(let t of[l.target,...l.additionalTargets]){let n=Ef(t)?bh(e,i,t,r):wf(t)?xh(e,i,t,r):void 0;i=um(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=vh(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 bh(e,t,n,r){let i=yh(e,t,n,r),a=Yp(e,i.configuration,n.path);return{target:Pf(n.path,a.value,{snapshot:a,values:n.values}),commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents,transitions:i.transitions}}function xh(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=am(t,n.path);if(a!==void 0){let i=vh(e,om(e,t,a),r),o=Yp(e,i.configuration,n.parent),s=Object.fromEntries(i.configuration.values);return n.parent!==``&&t.active.has(``)&&delete s[``],{target:Pf(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=Jd(e).handlers[n.parent]?.history?.[o]?.default;if(s===void 0)throw Error(`Machine history state "${n.path}" requires a default implementation`);let c=gh(e,s,{event:r,target:t=>Om(e.stateNodes,t),owner:n.parent});if(c.state===void 0||wf(c.state)||!Rf(c.state))throw Error(`Machine history default for "${n.path}" must return a complete snapshot containing its owner`);let l=Kh(c.state)===void 0?void 0:Jh(e,{active:new Set,values:new Map,outputs:new Map,history:t.history},c.state,r),u=l===void 0?tm(e,c.state):um(e,{active:new Set,values:new Map,outputs:new Map,history:t.history},l.target);for(let t of l?.additionalTargets??[])u=um(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=Yp(e,u,n.parent),f=Object.fromEntries(u.values);return n.parent!==``&&t.active.has(``)&&delete f[``],{target:Pf(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 Sh=(e,t)=>{if(!t.transition.declinable)return t;let n=gh(e,t.transition.transition,t.context,t.transition.evaluate);return n.declined?void 0:{...t,collected:n}},Ch=(e,t)=>[...Ip(e,t)].reverse(),wh=(e,t,n)=>{let r=Ip(e,t),i=Ip(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},Th=(e,t)=>{if(e!==void 0&&t!==void 0)return e===t||Pp(e,t)?t:e},Eh=(e,t,n)=>kh(e,Array.from(t.active).filter(e=>n===void 0||Pp(e,n))),Dh=(e,t,n)=>Ah(e,Array.from(t.active).filter(e=>n===void 0||Pp(e,n))),Oh=(e,t)=>e.active.size===t.active.size&&Array.from(e.active).every(e=>t.active.has(e)),kh=(e,t)=>Array.from(new Set(t)).sort((t,n)=>{let r=Ip(e,n).length-Ip(e,t).length;return r===0?$(e,n).order-$(e,t).order:r}),Ah=(e,t)=>Array.from(new Set(t)).sort((t,n)=>{let r=Ip(e,t).length-Ip(e,n).length;return r===0?Rp(e,t,n):r}),jh=(e,t,n,r)=>({...ph(e,t),state:t.values.get(n),containingState:Gp(e,t,n),ancestors:Wp(e,t,n),event:r}),Mh=(e,t,n,r,i)=>({...ph(e,t),state:t.values.get(n),containingState:Gp(e,t,n),ancestors:Wp(e,t,n),event:r,snapshot:i}),Nh=(e,t,n,r,i,a)=>({...ph(e,t),state:t.values.get(n),containingState:Gp(e,t,n),ancestors:Wp(e,t,n),event:r,output:i,snapshot:a}),Ph=(e,t,n,r,i)=>{let a=[],o=[],s=[];for(let c of n){let n=hh(e,Jd(e).handlers[c]?.[i],jh(e,t,c,r));a.push(...n.commands),o.push(...n.raisedEvents),s.push(...n.emittedEvents)}return{commands:a,emittedEvents:s,raisedEvents:o}},Fh=(e,t,n)=>{let r=[],i=new Set,a=new Map,o,s=()=>o??=Jp(e,t);for(let o of Bp(e,t))for(let c of Ch(e,o)){let l=mh(Jd(e).handlers[c]?.always);if(l!==void 0){let u=a.get(c);if(a.has(c)||(u=Sh(e,{sourcePath:c,leafPath:o,trigger:{type:`always`},transition:l,context:{...ph(e,t),state:t.values.get(c),containingState:Gp(e,t,c),ancestors:Wp(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},Ih=(e,t,n,r)=>{let i=[],a=new Set,o,s=()=>o??=Jp(e,t);for(let o of r){let r=mh(Jd(e).handlers[o.path]?.onDone);if(r!==void 0&&!a.has(o.path)){a.add(o.path);let c=Sh(e,{sourcePath:o.path,leafPath:Hp(e,t,o.path),trigger:{type:`done`},transition:r,context:Nh(e,t,o.path,n,o.output,s())});c!==void 0&&i.push(c)}}return i},Lh=(e,t,n)=>{let r=[],i=new Set,a=new Map,o,s=()=>o??=Jp(e,t);for(let o of Bp(e,t))for(let c of Ch(e,o)){let l=mh(Jd(e).handlers[c]?.on?.[n._tag]);if(l!==void 0){let u=a.get(c);if(a.has(c)||(u=Sh(e,{sourcePath:c,leafPath:o,trigger:{type:`event`,event:n._tag},transition:l,context:Mh(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},Rh=(e,t,n)=>{if(!t.active.has(n.path))return[];let r=Jd(e).handlers[n.path],i=Ym(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=mh(n.type===`element`?i.onElement:n.type===`done`?i.onDone:n.type===`failure`?i.onFailure:i.onSnapshot);if(a===void 0)return[];let o=Jp(e,t),s={...ph(e,t),state:t.values.get(n.path),containingState:Gp(e,t,n.path),ancestors:Wp(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=Sh(e,{sourcePath:n.path,leafPath:Hp(e,t,n.path),trigger:{type:`invoke`,id:n.id,outcome:n.type},transition:a,context:s});return c===void 0?[]:[c]},zh=e=>{if(wf(e)||Of(e)||Ff(e)||Rf(e))return String(e.path);throw Error(`Machine expected transition target to be a snapshot or target builder result`)},Bh=(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(`, `)}`)}},Vh=(e,t)=>{for(let n of e)if(t.includes(n))return!0;return!1},Hh=(e,t)=>Array.from(t).sort((t,n)=>Rp(e,t.selection.sourcePath,n.selection.sourcePath)),Uh=e=>e.filter(t=>!e.some(e=>e.sourcePath!==t.sourcePath&&Pp(e.sourcePath,t.sourcePath))),Wh=(e,t)=>{let n=[];for(let r of Hh(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(Vh(r.exitPaths,i.exitPaths)||n){if(Pp(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},Gh=(e,t={})=>{let n={...t},r=[],i=e=>{if(Of(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:Df(e.path,e.parent,n),values:n}))},Kh=(e,t={})=>Gh(e,t)[0],qh=(e,t)=>{if(Of(e))return Df(e.path,e.parent,{...t,...e.values??{}});if(Ef(e))return{...e,values:{...t,...e.values}};if(!Ff(e)||Object.keys(t).length===0)return e;let n=e[Xd];return Pf(e.path,e.value,{...n===void 0?{}:{snapshot:n},values:{...t,...e.values??{}}})};function Jh(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=Gh(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 Vd({machineId:e.id,state:d.target.path,maxIterations:Xh});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=Jd(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,Cp(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=gh(e,p.transition,{...ph(e,h),containingState:Gp(e,h,f.path),ancestors:Wp(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`);Bh(f.path,{type:`choice`},p.targets,g.state);let _=zh(g.state);n=qh(g.state,d.values);let v=Kh(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(!Ff(n)&&!Rf(n)&&!wf(n)&&!Ef(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 Yh=(e,t,n)=>{let r=n.leafPath,i=n.collected??gh(e,n.transition.transition,n.context,n.transition.evaluate);if(i.declined)throw Error(`Machine transition returned decline without declaring declinable: true`);let a=mf(i.state)?i.state:void 0,o=a?.target??i.state,s=o===void 0||ff(o)?void 0:o;Bh(n.sourcePath,n.trigger,n.transition.targets,s);let c=a?.update??(ff(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:Cp(e,n,c.value)}})(),u=l!==void 0&&(Ef(s)||Of(s))?{...t,values:new Map(t.values).set(l.path,l.value)}:t,d=s===void 0?void 0:Jh(e,u,s,n.context.event),f=d?.target??s,p=f!==void 0&&Ef(f)?bh(e,u,f,n.context.event):void 0,m=p?.target??f,h,g=wf(m)&&n.transition.reenter&&t.active.has(m.parent)?m:void 0;if(m!==void 0&&wf(m)){let i=n.transition.reenter?$(e,n.sourcePath).parent:wh(e,r,m.parent),a=g===void 0?Eh(e,t,i):kh(e,Array.from(t.active).filter(e=>Fp(e,m.parent)));h=xh(e,a.includes(m.parent)?im(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(Ef(r)){let i=bh(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(!wf(r)){S.push(r);continue}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)}let C=_===void 0?void 0:S.length===0||s===void 0?zh(_):zh(s),w=_===void 0?l===void 0?t:{...t,values:new Map(t.values).set(l.path,l.value)}:um(e,t,_);for(let t of S)w=um(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||!Oh(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:wh(e,r,C),O=$(e,n.sourcePath).parent,k=n.transition.reenter?Th(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?Eh(e,t,k):kh(e,Array.from(t.active).filter(e=>Fp(e,g.parent))),entryPaths:g===void 0?Dh(e,w,k):Ah(e,Array.from(w.active).filter(e=>Fp(e,g.parent))),choiceTransitions:[...d?.transitions??[],...p?.transitions??[],...h?.transitions??[],...x]}},Xh=1e3,Zh={_tag:Im},Qh=(e,t)=>gm(e,em(e,t)),$h=(e,t,n)=>rm(e,t).pipe($t(t=>bm(e,t,n)),$t(t=>{let n=Up(e,t.configuration);return!gm(e,t.configuration)||!t.configuration.outputs.has(n)?bn(Error(`Machine attempted to read terminal output from a non-terminal configuration`)):E(t.configuration.outputs.get(n))})),eg=(e,...t)=>{let n=e.input===void 0?t:t.length===0?(xp(e,e.input,void 0),t):[xp(e,e.input,t[0])],r=e.initial(...n),i={active:new Set,values:new Map,outputs:new Map,history:new Map},a=bh(e,i,r,Zh),o=um(e,i,a.target),s=Jp(e,o),c=Kp(e,o),l=a.commands,u=a.raisedEvents,d=a.emittedEvents,f=Ph(e,o,c,Zh,`entry`),p=ng(e,o,Zh,[...f.commands],[...u,...f.raisedEvents],[...d,...f.emittedEvents],a.transitions.length===0?[]:[{next:o,event:Zh,transitions:a.transitions,commands:l,raisedEvents:[...u],emittedEvents:d,exitPaths:[],entryPaths:[],changed:!1,stabilize:!1}]),m={startingState:s,initialEntryPaths:c,state:Jp(e,p.next),commands:[...l,...p.commands],emittedEvents:p.emittedEvents,microsteps:p.microsteps.map(t=>({next:Jp(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}},tg=(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=Uh(r),a=[];for(let n of i)a.push(Yh(e,t,n));let o=Wh(e,a),s=Hh(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:zh(e.unresolvedTarget),resolvedTarget:e.target===void 0?void 0:zh(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=um(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=kh(e,s.flatMap(e=>e.exitPaths)),_=Ah(e,s.flatMap(e=>e.entryPaths));l=im(e,t,l,g);let v=Ph(e,t,g,n,`exit`),y=Ph(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}},ng=(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 Vd({machineId:e.id,state:String(Vp(e,s)),maxIterations:Xh});let t=Cm(e,s,c);for(s=t.configuration,m.push(...t.completions.filter(t=>Jd(e).handlers[t.path]?.onDone!==void 0));m.length>0&&!s.active.has(m[0].path);)m.shift();let n=Ih(e,s,c,m.length===0?[]:[m.shift()]);if(n.length>0){let t=tg(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(gm(e,s)){let t=Up(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?Fh(e,s,c):[];if(h.length>0){let t=tg(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=Lh(e,s,_);if(v.length===0){l=!0;continue}let y=tg(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}},rg=(e,t,n)=>{let r=ch(n)?n:vp(e,n);if(gm(e,t)){let n=Cm(e,t,r),i=Up(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=ch(r)?Rh(e,t,r):Lh(e,t,r);if(i.length===0)return{event:r,next:t,commands:[],emittedEvents:[],microsteps:[],done:!1,output:void 0};let a=tg(e,t,r,i),o=[...a.commands],s=[...a.raisedEvents],c=[...a.emittedEvents],l=[a];return{...ng(e,a.next,r,o,s,c,l),event:r}},ig=(e,...t)=>Ie({try:()=>eg(e,...t),catch:qd}),ag=(e,t)=>({raise:n=>_p(e,n).pipe($t(e=>t.sendTo(t.self,e))),emit:n=>yp(e,n).pipe($t(e=>t.emit(e)))}),og=(e,t)=>Ir(e,e=>e._tag===`SendTo`?t.sendTo(e.target,e.event):t.stopChild(e.child),{discard:!0}),sg=(e,t)=>Dt(Array.from(e,e=>t.emit(e)),{discard:!0}),cg=new WeakMap,lg=e=>{let t=cg.get(e);if(t!==void 0)return t;let n={self:{id:e.id??`Machine`,sessionId:`Machine.plan`,send:()=>jr(new Wd)},parent:void 0};return cg.set(e,n),n},ug=(e,t)=>{let n=t===void 0?lg(e):t;return e.parent===void 0?{self:n.self}:{self:n.self,parent:n.parent}},dg=new Set([`initialize`,`invoke`,`on`,`output`]),fg=e=>{if(e===void 0)return!0;for(let t of Reflect.ownKeys(e))if(!dg.has(t))return!1;return!0},pg=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=Jd(e).handlers[a.path];if(!fg(o))return;if(o?.on===void 0)continue;let s=new Map;for(let e of Reflect.ownKeys(o.on)){let t=mh(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)=>Rp(e,t,n)),r.sort((t,n)=>Rp(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=>Ip(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&&(Jd(e).handlers[``]===void 0||Reflect.ownKeys(Jd(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}},mg=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()}),hg=(e,t)=>t?{...e,next:mg(e.next)}:e,gg=(e,t,n)=>{e.values[t]=n},_g=(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}},vg=(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}},yg=(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=yg(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]=yg(e,t,i)}i.states=a}return i},bg=(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=yg(e,t,n);return t.completedOrder.length>0&&(r.completed=t.completedOrder.map(n=>({path:e.nodes[n].path,output:t.outputs[n]}))),r},xg=(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{...ug(e,a),state:n.values[r],containingState:o<0?void 0:n.values[o],ancestors:s,event:i,snapshot:bg(t,n)}},Sg=Object.freeze([]),Cg=(e,t,n,r)=>{let i,a,o,s={raise:t=>{(a??=[]).push(vp(e,t))},emit:t=>{(o??=[]).push(bp(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:yf(c.result)?void 0:c.result,branchIndex:c.branchIndex,branchKey:c.branchKey,commands:i??Sg,raisedEvents:a??Sg,emittedEvents:o??Sg}},wg=(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:xg(e,t,n,c,r,i)})}}}return a},Tg=(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},Eg=(e,t,n,r,i)=>{if((Ff(r)?t.indexByPath.get(String(r.path)):void 0)===i&&n.active[i]===1&&Ff(r)&&r[Xd]===void 0&&r.values===void 0&&n.completedOrder.length===0&&t.valued[i]){let a=n.values.slice();return a[i]=Cp(e,t.nodes[i],r.value),{...n,values:a}}return _g(t,um(e,vg(t,n),r))},Dg=(e,t,n,r)=>{let i=Cg(e,r.transition.transition,r.context,r.transition.evaluate),a=mf(i.state)?i.state:void 0,o=a?.target??i.state,s=a?.update??(ff(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:Cp(e,i,s.value)}})(),l=o===void 0||ff(o)?void 0:o;Bh(r.sourcePath,r.trigger,r.transition.targets,l);let u=l!==void 0&&Ef(l)?bh(e,(()=>{let e=vg(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&&!Ff(d)&&!Rf(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=mg(n);return e.values[t.indexByPath.get(c.path)]=c.value,e})():Eg(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||!Tg(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:zh(d),g=h===void 0?t.nodes[r.sourceIndex].parent:wh(e,r.leafPath,h),_=t.nodes[r.sourceIndex].parent,v=r.transition.reenter?Th(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:Eh(e,vg(t,n),v),entryPaths:Dh(e,vg(t,f),v),choiceTransitions:u?.transitions??[]}},Og=(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:zh(e.unresolvedTarget),resolvedTarget:e.target===void 0?void 0:zh(e.target),updates:e.update===void 0?[]:[e.update.path]});if(i.length===1){let s=Dg(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=Hh(e,Wh(e,i.filter(e=>!i.some(t=>t.sourceIndex!==e.sourceIndex&&Pp(t.sourcePath,e.sourcePath))).map(r=>Dg(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=Eg(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?kh(e,s.flatMap(e=>e.exitPaths)):[],entryPaths:f?Ah(e,s.flatMap(e=>e.entryPaths)):[],changed:f}},kg=(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 Vd({machineId:e.id,state:t.nodes[o.activeLeaves[0]].path,maxIterations:Xh});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=Cm(e,vg(t,o),s).configuration,i=Up(e,n);if(!n.outputs.has(i))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:r,next:_g(t,n),commands:c??Sg,emittedEvents:u??Sg,microsteps:d??Sg,done:!0,output:n.outputs.get(i)}}let m=t.nodes[n].path,h=mh(Jd(e).handlers[m]?.on?.[s._tag]);if(h!==void 0){let r=Cg(e,h.transition,{...ug(e,a),state:o.values[n],containingState:void 0,ancestors:{},event:s,snapshot:bg(t,o)},h.evaluate),f=ff(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`);gg(o,n,Cp(e,r,f.value))}if(Bh(m,{type:`event`,event:s._tag},h.targets,p),p!==void 0&&!Ff(p)&&!Rf(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=Ff(p)?p[Xd]===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]?gg(o,n,Cp(e,t.nodes[n],p.value)):g=Eg(e,t,o,p,n)}let _=h.reenter||!Tg(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:zh(p),resolvedTarget:p===void 0?void 0:zh(p),updates:f===void 0?[]:[f.path]}]}:void 0,commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents,exitPaths:_?[m]:Sg,entryPaths:_?[t.nodes[v].path]:Sg,changed:_};o=g,(d??=[]).push(hg(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??Sg,emittedEvents:u??Sg,microsteps:d??Sg,done:!1,output:void 0};f+=1,s=g}},Ag=(e,t,n,r,i,a)=>{if(ch(r)){let i=rg(e,a===void 0?vg(t,n):Ap(vg(t,n),a),r);return{event:i.event,next:_g(t,i.next),commands:i.commands,emittedEvents:i.emittedEvents,microsteps:i.microsteps.map(e=>({next:_g(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=vp(e,r);if(t.flat)return kg(e,t,n,o,i,a);if(t.finalIndices.some(e=>n.active[e]===1)){let r=vg(t,n);if(gm(e,r)){let n=Cm(e,r,o).configuration,i=Up(e,n);if(!n.outputs.has(i))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:o,next:_g(t,n),commands:[],emittedEvents:[],microsteps:[],done:!0,output:n.outputs.get(i)}}}let s=wg(e,t,n,o,a);if(s.length===0)return{event:o,next:n,commands:[],emittedEvents:[],microsteps:[],done:!1,output:void 0};let c=Og(e,t,n,o,s,i),l=c.next,u=o,d=[...c.commands],f=[...c.raisedEvents],p=[...c.emittedEvents],m=[hg(c,i)],h=0,g=0;for(;;){if(g+=1,g>1e3)throw new Vd({machineId:e.id,state:t.nodes[t.leafIndices.find(e=>l.active[e]===1)].path,maxIterations:Xh});if(t.finalIndices.some(e=>l.active[e]===1)){let n=Cm(e,vg(t,l),u).configuration;if(l=_g(t,n),gm(e,n)){let t=Up(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=wg(e,t,l,n,a);if(r.length===0)continue;let s=Og(e,t,l,n,r,i);l=s.next,d.push(...s.commands),f.push(...s.raisedEvents),p.push(...s.emittedEvents),m.push(hg(s,i))}},jg=new WeakMap,Mg=e=>({fromConfiguration:e=>e,toConfiguration:e=>e,snapshot:t=>Jp(e,t),plan:(t,n,r,i)=>rg(e,i===void 0?t:Ap(t,i),n)}),Ng=(e,t)=>({fromConfiguration:e=>_g(t,e),toConfiguration:e=>vg(t,e),snapshot:e=>bg(t,e),plan:(n,r,i=!1,a)=>Ag(e,t,n,r,i,a),...Object.values(Jd(e).handlers).some(e=>e.initialize!==void 0&&!Bm(e.initialize))?{}:{initial:(n,r)=>{let i=e.input===void 0?n:n.length===0?(xp(e,e.input,void 0),n):[xp(e,e.input,n[0])],a=e.initial(...i),o=Ef(a)?yh(e,{active:new Set,values:new Map,outputs:new Map,history:new Map,...r===void 0?{}:{machineReferences:r}},a,Zh).configuration:tm(e,a),s=Cm(e,r===void 0?o:Ap(o,r),Zh).configuration,c=_g(t,s),l=bg(t,c);if(!gm(e,s))return{state:l,configuration:c,activeConfiguration:s,initialEntryPaths:Kp(e,s),done:!1,output:void 0};let u=Up(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:Kp(e,s),done:!0,output:s.outputs.get(u)}}}}),Pg=e=>{let t=jg.get(e);if(t!==void 0)return t;let n=pg(e),r=n===void 0?Mg(e):Ng(e,n);return jg.set(e,r),r},Fg=`Machine.invocation:`,Ig=e=>e.startsWith(Fg),Lg=(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,v(t,z)}},Rg=e=>H(()=>{if(e.values!==void 0){let t=e.values;return e.values=void 0,E(t)}let t=w();return e.waiter=t,li(t).pipe(I(Rg(e)))}),zg=(e,t)=>e._tag===`Started`&&(typeof t==`string`||e.descriptor!==void 0&&e.descriptor.id===t.id&&e.descriptor.machine===t.machine),Bg=(e,t,n)=>{if(e.closed)return Ze();let r=e.children.get(t);return r!==void 0&&zg(r,n)?f(r.ref):Ze()},Vg=e=>{if(e.observers!==void 0)for(let t of e.observers)Lg(t,Bg(e,t.id,t.child))},Hg=(e,t,n)=>{let r=e.children.get(t);r!==void 0&&r.token===n&&(e.children.delete(t),typeof t==`string`&&Vg(e))},Ug=(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`&&Vg(e),!0},Wg=e=>qr(function*(){let t=yield*xt(),n=0,r=0,i=0,a=0;return{rootSessionId:e,stream:ui(t).pipe(T(G(()=>{n+=1})),Qr(G(()=>{--n}))),isActive:()=>n>0,nextDeliveryId:()=>i++,nextMacrostepId:()=>a++,publishUnsafe:i=>{n!==0&&we(t,{...i,sequence:r++,rootSessionId:e})},close:$e(t)}}),Gg=e=>({id:e.id,sessionId:e.sessionId}),Kg=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?Gg(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?Gg(t):{id:String(t.id)}}]:[]}return[]}),qg=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:Kg(Array.isArray(e.commands)?e.commands:[]),exitPaths:Array.isArray(e.exitPaths)?e.exitPaths:[],entryPaths:Array.isArray(e.entryPaths)?e.entryPaths:[],changed:e.changed===!0})),Jg=Symbol.for(`effect/Machine/activeSnapshotObserver`),Yg=Symbol.for(`effect/Machine/snapshotObserver`),Xg=e=>typeof e==`object`&&!!e&&Yg in e,Zg=Symbol.for(`effect/Machine/sendParentOverride`),Qg=Symbol.for(`effect/Machine/acknowledgedSend`),$g=Symbol(`effect/Machine/AcknowledgedMessage`),e_=e=>typeof e==`object`&&!!e&&$g in e,t_=e=>e_(e)?e.event:e,n_=(e,t)=>{e!==void 0&&e_(e)&&(e.deferred!==void 0&&v(e.deferred,E(t)),e.inspection?.complete(t))},r_=(e,t)=>{e!==void 0&&e_(e)&&e.deferred!==void 0&&v(e.deferred,Bn(t))},i_=e=>{e!==void 0&&e_(e)&&e.deferred!==void 0&&v(e.deferred,jr(new Wd))},a_=e=>typeof e==`object`&&!!e&&`send`in e&&typeof e.send==`function`,o_=(e,t,n,r)=>`inspectionSubject`in e&&`sendInspected`in e&&typeof e.sendInspected==`function`?e.sendInspected(t,n,r):e.send(t),s_=e=>e?._tag===`Childless`||e?.childless===!0,c_=(e,t)=>{let n=e.items??[];e.items=n,n.push(t)},l_=e=>{if(e.items===void 0)return Ze();let t=e.items[e.index];return e.index+=1,e.index===e.items.length&&(e.items=void 0,e.index=0),f(t)},u_=e=>{if(e.items!==void 0)for(let t=e.index;t<e.items.length;t+=1)i_(e.items[t]);e.closed=!0,e.items=void 0,e.index=0},d_=()=>({items:void 0,index:0,closed:!1,receivers:new Set}),f_=(e,t,n)=>{if(e.closed)return!1;for(c_(e,t),n?.();e.items!==void 0&&e.receivers.size>0;){let t=e.receivers.values().next().value;e.receivers.delete(t),t(z)}return!0},p_=e=>H(()=>{let t=l_(e);return He(t)?E(t.value):e.closed?hn:It(t=>(e.receivers.add(t),G(()=>{e.receivers.delete(t)}))).pipe(I(p_(e)))}),m_=e=>{u_(e);let t=Array.from(e.receivers);e.receivers.clear();for(let e of t)e(hn)},h_=class extends Bt()(`effect/Machine/MachineRuntime`){},g_=(e,t)=>$r(e,h_,t),__=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(Et);if(t!==void 0)return{_tag:`Failure`,error:t.error,cause:e.cause,snapshot:e};let n=e.cause.reasons.find(mt);return n===void 0?e.cause.reasons.find(ae)===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}}},v_=(e,t)=>H(()=>e(t)).pipe(fr,Tr),y_=(e,t)=>{class n{nextSessionId;constructor(){let e=0;this.nextSessionId=G(()=>`machine:${e++}`)}get start(){return e}get startCompiledSync(){return t}}return G(()=>new n)},b_=(e,t,n)=>({id:t,sessionId:n,kind:e.inspection?.kind??`Logic`}),x_=(e,t)=>t?{_tag:`Initialization`}:e!==void 0&&e_(e)&&e.inspection!==void 0?{_tag:`Macrostep`,macrostepId:e.inspection.macrostepId}:void 0,S_=(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=qg(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{[$g]:!0,event:n,...a===void 0?void 0:{deferred:a},inspection:c}},C_=(e,t,n)=>{if(!e_(n)||n.inspection===void 0)return;let r=n.inspection;e.publishUnsafe({_tag:`EventSent`,subject:t,deliveryId:r.deliveryId,source:r.source,target:Gg(t),event:r.event,causedBy:r.causedBy})},w_=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:z}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 H(()=>{if(this.registry.closed)return hn;if(this.has(t.key)||this.registry.children.has(t.id))return jr(new Ud({id:t.duplicateId}));let a=e(),o=this.registry.scope??=hi(`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()?o_(this.self,e,t,n):z,...this.sendAcknowledged===void 0?void 0:{[Qg]:e=>i()?this.sendAcknowledged(e):hn}},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,Ug(this.registry,t.id,n,e,t.descriptor)),onStopSync:()=>Hg(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?$t(this.runtime.nextSessionId,e=>this.runtime.startCompiledSync(a,c,this.scopedServices??=qe(this.services,On,o),e)):this.runtime.start(a,c)).pipe(An(e=>Pe(e)?z:(Hg(this.registry,t.id,n),r===void 0?z:r.stop)));return(u?d:nn(d,o)).pipe(Tr)})}stopAll(){return H(()=>{let e=[];for(let t of this.registry.children.values())t.ownerActive&&e.push(this.stopEntry(t));return e.length===0?z:e.length===1?e[0]:Dt(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]:Dt(n,{concurrency:`unbounded`,discard:!0})}},T_=l(Ze()).pipe(kn(j)),E_=e=>z,D_=(e,t)=>{},O_=()=>void 0,k_=Symbol(`effect/Machine/EmissionsClosed`),A_=()=>{let e,t=H(()=>{let t=e;return t===k_?E(void 0):t===void 0?xt().pipe($t(t=>G(()=>{let n=e;return n===k_?[void 0,!0]:n===void 0?(e=t,[t,!1]):[n,!0]}).pipe($t(([e,n])=>n?$e(t).pipe(ye(e)):E(e))))):E(t)});return{emit:t=>H(()=>e===void 0||e===k_?z:ue(e,t).pipe(Tr)),close:()=>{let t=e;return e=k_,t===void 0||t===k_?z:$e(t)},stream:Fe(t.pipe(xr(e=>e===void 0?Kt:ui(e))))}},j_={close:()=>z,spawn:(()=>bn(Error(`Childless machine logic cannot spawn a process`))),get:()=>E(Ze()),changes:()=>T_,sendTo:()=>z,stop:()=>z,owned:{spawn:()=>bn(Error(`Childless machine logic cannot spawn an owned process`)),stopAll:()=>z,stopPaths:()=>void 0}},M_=(e,t,n,r)=>{let i={closed:!1,children:new Map,observers:void 0,scope:void 0},a=e=>H(()=>{if(i.closed||(i.closed=!0,i.scope===void 0))return z;let t=Zr(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?z:Array.isArray(a)?Dt(a,{concurrency:`unbounded`,discard:!0}):a}),o=(e,t)=>G(()=>Hg(i,e,t)),s=(e,t,n,r)=>G(()=>Ug(i,e,t,n,r)),c=e=>{let t=typeof e==`string`?e:e.id;return G(()=>{if(i.closed)return Ze();let n=i.children.get(t);return n!==void 0&&zg(n,e)?f(n.ref):Ze()})},l=e=>{let t=typeof e==`string`?e:e.id;return rn(te((n,r)=>G(()=>({child:e,id:t,values:void 0,waiter:void 0})).pipe($t(n=>{let a=G(()=>{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 Gt(r,a).pipe(I(G(()=>{!i.closed&&r.state._tag!==`Closed`&&(i.observers??=new Set,i.observers.add(n)),Lg(n,Bg(i,t,e))})),ye(Rg(n)))}))))},u=(e,t,n,r)=>{let a=typeof e==`string`?e:e.id;return H(()=>{if(i.closed)return z;let o=i.children.get(a);return o!==void 0&&zg(o,e)?o_(o.ref,t,n,r):z})},d=e=>{let t=typeof e==`string`?e:e.id;return H(()=>{if(i.closed)return z;let n=i.children.get(t);return n!==void 0&&zg(n,e)?n.ref.stop:z})};function p(n,r){let a=typeof n==`object`&&n&&Rm in n?n:void 0,c=a===void 0?n:a[Rm](r?.input),l=a===void 0?r:{id:a.id,descriptor:a},u=Symbol(),d=l?.id??u,f;return H(()=>i.closed?hn:typeof d==`string`&&(i.children.has(d)||Ig(d))?jr(new Ud({id:d})):(i.scope??=hi(`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?.[Jg]===void 0?void 0:{onSnapshot:l[Jg]},...l?.[Zg]===void 0?void 0:{sendParent:l[Zg]},onReady:(e,t)=>G(()=>{f=e}).pipe(I(s(d,u,e,l?.descriptor)),$t(e=>e?z:t)),onStop:o(d,u),parent:e,runtime:t,origin:{_tag:`Spawn`,address:l?.id}}).pipe(An(e=>Oe(e)?o(d,u).pipe(I(f===void 0?z:f.stop)):z),nn(i.scope))))}return{close:a,spawn:p,get:c,changes:l,sendTo:u,stop:d,owned:new w_(i,e,t,n,r)}},N_=(e,t,n,r)=>G(()=>M_(e,t,n,r)),P_=(e,t)=>`${e.length}:${e}${t}`,F_=(e,t)=>`${Fg}${P_(e,t)}`,I_=e=>({initial:()=>z,run:()=>e}),L_=(e,t,n)=>({initial:()=>z,run:({parent:r})=>{let i=r?.[Qg];return i===void 0?bn(Error(`Stream invocation requires an acknowledged parent machine`)):Xn(e,e=>i(ah(t,n,e)).pipe(Tr,jt(()=>hn)))}}),R_=(e,t)=>typeof e==`function`?e(t):e,z_=e=>({spawn:((t,n)=>e.spawn(t,n)),sendTo:((t,n)=>e.sendTo(t,n)),stop:(t=>e.stopChild(t))}),B_=(e,t,n)=>{if(`effect`in e)return{id:String(e.id),sourceName:e.sourceName,src:()=>I_(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:()=>I_(M(R_(e.after,t))),onDone:e.onDone,activityKind:`Timer`};if(`stream`in e){let r=String(e.id);return{id:r,sourceName:e.sourceName,src:()=>L_(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:()=>R_(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[Rm](`input`in e?R_(e.input,t):void 0),onDone:e.onDone,onFailure:e.onFailure,onSnapshot:e.onSnapshot}}throw Error(`Unsupported captured machine invocation: ${String(e)}`)},V_=e=>e.length===0?z:e.length===1?e[0]:Dt(e,{discard:!0}),H_=(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(Je(`StoppedError`,()=>z)),U_=e=>e instanceof Vd||e instanceof Bd||e instanceof Wd,W_=(e,t,n,r,i,a,o,s,c,l,u,d)=>H(()=>{let f=P_(n,r),p=u===void 0?o:()=>{let t=o();return{...t,run:i=>et(H(()=>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):z,onOutcome:(t,i,o)=>I(Si,H(()=>i._tag===`Stopped`||!t()?z:i._tag===`Done`?s===void 0?e.failCause(Qe(Error(`Invocation "${r}" completed without the required onDone handler`))):H_(e,ih(n,r,i.output),u===void 0?void 0:o):i._tag===`Failure`&&c!==void 0&&(a===void 0||!U_(i.error))?H_(e,oh(n,r,i.error),u===void 0?void 0:o):e.failCause(i.cause))),...l===void 0?void 0:{onSnapshot:(t,i)=>t()?H_(e,sh(n,r,i)):z}})}),G_=(e,t)=>Ig(e)?jr(new Ud({id:t})):void 0,K_=(e,t,n,r)=>{let i=String(r.id),a=r.address===void 0?void 0:G_(String(r.address),i);return a===void 0?W_(e,t,n,i,r.address===void 0?F_(n,i):String(r.address),r.descriptor,r.src,r.onDone,r.onFailure,r.onSnapshot,r.activityKind,r.sourceName):a},q_=(e,t,n,r)=>{let i=r.child,a=G_(i.id,i.id);return a===void 0?W_(e,t,n,i.id,i.id,i,i[Rm],r.onDone,r.onFailure,r.onSnapshot,void 0):a},J_=(e,t,n,r,i,a)=>{let o=z_(t),s=Ah(e,i).filter(e=>r.active.has(e)).flatMap(i=>{let s={...jp(r)??{self:t.self,parent:t.parent},children:o,state:r.values.get(i),containingState:Gp(e,r,i),ancestors:Wp(e,r,i),event:a};return Ym(dm(e,i)?.invoke).map(e=>`child`in e&&!(`input`in e)?q_(t,n,i,e):K_(t,n,i,B_(e,s,i)))});return s.length===0?void 0:V_(s)},Y_=Symbol(`effect/Machine/CompiledStoppedCompletion`),X_=class{logic;options;services;id;sessionId;inspectionSubject;send;sendInspected(e,t,n){return this.offerEvent(e,t,n)}[Qg](e){return this.sendAcknowledgedEffect(e)}[Yg](e){let t=this.snapshotObservers??=new Set;return t.add(e),()=>{t.delete(e)}}mailbox={items:void 0,index:0,closed:!1};address;childRuntime=j_;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=b_(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:H(()=>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 x_(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:qg({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:c(e)})}get execution(){return this.logic.execution}initializeCompiledSync(){this.publishCreated(),this.execution.childless||(this.childRuntime=M_(this.address,this.options.runtime,this.services,e=>this.sendAcknowledgedEffect(e)));let e=this.options.parent,t=this.options.sendParent??(e===void 0?E_:this.inspector===void 0?e.send:t=>o_(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)=>a_(e)?this.inspector===void 0?e.send(t):o_(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?D_:(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(bi(e)),jr(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 Z_(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?E(this):(this.runState=`Draining`,qt(this.drainRuntime(),this.services).pipe(ye(this)))}initialize(){let e=this;return qr(function*(){e.publishCreated(),e.execution.childless||(e.childRuntime=yield*N_(e.address,e.options.runtime,e.services,t=>e.sendAcknowledgedEffect(t)));let t=e.options.parent,n=e.options.sendParent??(t===void 0?E_:e.inspector===void 0?t.send:n=>o_(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)=>a_(t)?e.inspector===void 0?t.send(n):o_(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?D_:(t,n=[])=>{e.initialEntryPaths=t,e.initialMicrosteps=n}};let r=t=>Oe(t)?e.childRuntime.close(t):z,i=e.execution.initial,a=yield*(i===void 0?e.logic.initial(e.processScope).pipe(xr(e=>({state:e,done:void 0,output:void 0}))):i(e.processScope)).pipe(An(t=>(Oe(t)&&e.publishStartFailed(t.cause),r(t))),Hr(G(()=>{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:Pn,poll:G(()=>ce(l_(e.mailbox),t_)),receiveMessage:Pn,pollMessage:G(()=>e.pollCompiledMessage()),completeMessage:t=>e.completeCompiledMessage(t),state:G(()=>e.current.snapshot.state),setState:t=>e.setActiveState(t),updateState:t=>e.updateState(t)}:(e.compiledContext=new Z_(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(Tr))),e.options.onSnapshot!==void 0&&(yield*v_(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 G(()=>this.current.snapshot.state)}get snapshot(){return G(()=>this.current.snapshot)}get changes(){return this.changesStream()}get emissions(){return this.externalEmissions?.stream??this.emissionsStream()}get join(){return H(()=>this.lifecycle===`Completed`?this.resolveCompletion(this.completion):(this.waiter??=w(),li(this.waiter)))}get stop(){return Ge(this.stopEffect())}child(e){return this.childRuntime.get(e)}childChanges(e){return this.childRuntime.changes(e)}requestTermination(e){return G(()=>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(Tr);return this.runState===`Initializing`?e:e.pipe(I(hn))}failCause(e){let t={_tag:`Failure`,cause:e};return this.requestTermination(t).pipe($t(e=>e?tr(this.settleRequestedTermination()).pipe(Tr):z))}sendAcknowledgedEffect(e){return F(t=>A().pipe($t(n=>this.offerEvent(e,void 0,void 0,n).pipe(I(t(li(n)))))))}offerEvent(e,t,n,r){return H(()=>{let i=this.inspector,a=this.inspectionSubject,o=i?.isActive()===!0&&a!==void 0?S_(i,a,e,t,n,r):r===void 0?e:{[$g]:!0,event:e,deferred:r};return this.offerMessage(o)})}offerMessage(e){return Ge(Te(t=>{if(this.mailbox.closed||this.lifecycle!==`Active`)return jr(new Wd);let n=this.inspector,r=this.inspectionSubject;n!==void 0&&r!==void 0&&C_(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&&c_(this.mailbox,e),this.runState!==`Idle`)return z;if(this.runState=`Draining`,o!==void 0){let n;try{n=o(a,e)}catch(e){n=bn(e)}return n!==void 0||this.hasTerminationRequest()?this.startWorker(n):(this.runState=`Idle`,this.scheduleChangesFlush(t.currentDispatcher),z)}return this.startWorker(void 0)}))}startWorker(e){let t=qt(this.drainRuntime(e),this.services);return(this.options.detached===!0?tr(t,{startImmediately:!0}):un(t,{startImmediately:!0})).pipe($t(e=>G(()=>(e.pollUnsafe()===void 0&&(this.worker=e),this.interruptRequested?(this.interruptRequested=!1,!0):!1)).pipe($t(t=>t?tr(this.interruptAndFinish(e)):z))),Tr)}stopEffect(){return H(()=>this.lifecycle===`Completed`||this.finishIdleChildlessStop()?z:this.requestTermination({_tag:`Stopped`}).pipe($t(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!==k_||this.current.terminalizing||this.current.snapshot.status!==`active`)return!1;this.emissionsPubSub=k_;let e={status:`stopped`,state:this.current.snapshot.state};return this.lifecycle=`TerminationRequested`,this.termination={_tag:`Stopped`},this.terminationSnapshot=e,u_(this.mailbox),this.current={revision:this.current.revision+1,terminalizing:!0,changes:void 0,snapshot:e},this.notifySnapshotObservers(),i_(this.inFlightMessage),this.inFlightMessage=void 0,this.interruptRequested=!1,this.compiledContext!==void 0&&(this.compiledContext.executionState=void 0),this.options.onStopSync?.(this),this.completion=Y_,this.lifecycle=`Completed`,this.waiter!==void 0&&(v(this.waiter,this.resolveCompletion(Y_)),this.waiter=void 0),!0}settleRequestedTermination(){return H(()=>this.runState===`Draining`?this.worker===void 0?(this.interruptRequested=!0,this.awaitCompletion()):this.interruptAndFinish(this.worker).pipe(I(this.awaitCompletion())):this.finishRequestedTermination())}interruptAndFinish(e){return se(e).pipe(I(H(()=>this.lifecycle===`Completed`?z:this.finishRequestedTermination())))}awaitCompletion(){return this.lifecycle===`Completed`?z:this.join.pipe(fr,Tr)}resolveCompletion(e){if(e!==Y_)return e;let t=jr(new Wd);return this.completion=t,t}drainRuntime(e){let t=this;return F(n=>qr(function*(){let r=t.offerRevision,i=e;for(;;){if(t.hasTerminationRequest())return yield*t.finishRequestedTermination();let e=yield*n(H(()=>{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(fr);if(t.flushPendingChanges(),Oe(e))return t.lifecycle===`Active`&&(yield*t.requestTermination({_tag:`Failure`,cause:e.cause})),yield*t.finishRequestedTermination();if(He(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 H(()=>{if(this.lifecycle!==`TerminationRequested`)return z;let e=this.termination;if(e===void 0)return z;let t=this.terminationSnapshot??this.reserveTermination(e);if(t===void 0)return this.awaitCompletion();let n=e._tag===`Stopped`?P:e._tag===`Done`?Ue(e.output):c(e.cause),r=e._tag===`Stopped`?Y_:e._tag===`Done`?E(e.output):Bn(e.cause),i=this.options.onOutcome===void 0||e._tag===`Stopped`&&this.options.skipStoppedOutcome===!0?z:H(()=>this.options.onOutcome(__(t))).pipe(fr,Tr),a=this.inspector,o=this.inspectionSubject,s=a===void 0||o===void 0?this.closeEmissions():this.closeEmissions().pipe(I(G(()=>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`?Un():n}))));return Ge(G(()=>{u_(this.mailbox)}).pipe(I(this.childRuntime.close(n)),I(this.setAndPublishSnapshot(t)),I(s),I(G(()=>{e._tag===`Failure`?r_(this.inFlightMessage,e.cause):i_(this.inFlightMessage),this.inFlightMessage=void 0})),I(i),I(this.options.onStop??z),I(this.options.inspectionRoot===!0&&this.inspector!==void 0?this.inspector.close:z),I(G(()=>{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&&(v(this.waiter,this.resolveCompletion(r)),this.waiter=void 0)}))))})}publishSnapshot(e){let t=e.changes===void 0?E(e):ue(e.changes,[e]).pipe(ye(e)),n=e.snapshot;return this.options.onSnapshot===void 0||n.status!==`active`?t:t.pipe(u(()=>v_(this.options.onSnapshot,n)))}completeChanges(e){return e.changes===void 0?z:ue(e.changes,Ue(void 0)).pipe(Tr)}emitEvent(e){let t=this.externalEmissions===void 0?H(()=>this.emissionsPubSub===void 0||this.emissionsPubSub===k_?z:ue(this.emissionsPubSub,e).pipe(Tr)):this.externalEmissions.emit(e),n=this.inspector,r=this.inspectionSubject;return n===void 0||r===void 0?t:t.pipe(u(()=>G(()=>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=k_,e===void 0||e===k_?z:$e(e)}getOrCreateEmissions(){return H(()=>{let e=this.emissionsPubSub;return e===k_?E(void 0):e===void 0?xt().pipe($t(e=>G(()=>{let t=this.emissionsPubSub;return t===k_?[void 0,!0]:t===void 0?(this.emissionsPubSub=e,[e,!1]):[t,!0]}).pipe($t(([t,n])=>n?$e(e).pipe(ye(t)):E(t))))):E(e)})}emissionsStream(){return Fe(this.getOrCreateEmissions().pipe(xr(e=>e===void 0?Kt:ui(e))))}setAndPublishSnapshot(e){return H(()=>{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($t(e=>this.completeChanges(e)),Tr)})}setActiveState(e){return H(()=>this.commitActiveState(e)??z)}pollCompiledMessage(){let e=l_(this.mailbox);return He(e)&&(this.inFlightMessage=e_(e.value)?e.value:void 0),e}beginCompiledMessage(e){this.inFlightMessage=e_(e)?e:void 0}completeCompiledMessage(e){n_(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]:we(a.changes,[a]):(r.push(a),t?a.pendingChanges=r:we(a.changes,r))),this.notifySnapshotObservers(),this.options.onSnapshot===void 0?void 0:v_(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,we(e.changes,t))}updateState(e){return H(()=>{let t=this.current;return t.terminalizing||t.snapshot.status!==`active`?z:e(t.snapshot.state).pipe($t(e=>{let n=this.current;return n.terminalizing||n.revision!==t.revision?z:this.setActiveState(e)}))})}getOrCreateChanges(){return H(()=>{let e=this.current;return e.snapshot.status===`active`?e.changes===void 0?xt({replay:1}).pipe($t(e=>G(()=>{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($t(([t,n])=>n?$e(e).pipe(ye(t)):E(t))))):E(e.changes):E(void 0)})}changesStream(){let e=this;return Fe(qr(function*(){let t=yield*e.getOrCreateChanges();if(t===void 0)return l(e.current.snapshot);let n=yield*xi(t),r=e.current;return r.snapshot.status===`active`?l(r.snapshot).pipe(kn(rn(We(m(n))).pipe(gi(e=>e.revision>r.revision),ii(e=>e.snapshot)))):l(r.snapshot)}))}},Z_=class{scope;ownedChildren;process;executionState;constructor(e,t,n){this.scope=e,this.ownedChildren=t,this.process=n}poll(){return ce(this.process.pollCompiledMessage(),t_)}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}},Q_=_r(function*(e,t){let n=t.sessionId??(yield*t.runtime.nextSessionId),i=yield*r(),a=e.execution,o=new X_(e,t,i,n);return yield*(a.initialSync!==void 0&&t.onReady===void 0&&t.onSnapshot===void 0?o.initializeCompiledSync():o.initialize()).pipe(An(e=>Oe(e)?o.shutdownEmissions().pipe(I(t.inspectionRoot===!0&&t.runtime.inspection!==void 0?t.runtime.inspection.close:z)):z))}),$_=(e,t,n,r)=>new X_(e,t,n,r).initializeCompiledSync(),ev=_r(function*(e,t){let{detached:n,id:r,onOutcome:i,onReady:a,onReadySync:o,onSnapshot:s,onStop:d,onStopSync:f,parent:p,runtime:h,sendParent:g}=t,_=t.sessionId??(yield*h.nextSessionId),v=r??_,y=h.inspection,b=y===void 0?void 0:b_(e,v,_),x=y===void 0||t.activity===void 0?void 0:{...t.activity,sessionId:_},S,C,w=d_(),T=t.emissions??A_(),D=yield*A(),O=yield*A(),k=li(O).pipe(fr,Tr),j=!0,M,N=Yn(D,{_tag:`Stopped`}).pipe(Tr),ee=(e,t)=>H(()=>f_(w,e,t)?z:jr(new Wd)),te=y===void 0?void 0:(e,t,n,r)=>H(()=>{let i=y.isActive()?S_(y,b,e,t,n,r):r===void 0?e:{[$g]:!0,event:e,deferred:r};return ee(i,()=>C_(y,b,i))}),ne=e.execution?._tag===`Compiled`?e=>F(t=>A().pipe($t(n=>(y===void 0?ee({[$g]:!0,event:e,deferred:n}):te(e,void 0,void 0,n)).pipe(I(t(li(n))))),xr(e=>e))):void 0,re={id:v,sessionId:_,stop:H(()=>j?N:N.pipe(I(Pn))),send:y===void 0?e=>ee(e):e=>te(e,void 0,void 0),...y===void 0?void 0:{inspectionSubject:b,sendInspected:te}},{changes:ie,close:ae,get:oe,owned:L,sendTo:R,spawn:le,stop:de}=j_;s_(e.execution)||({changes:ie,close:ae,get:oe,owned:L,sendTo:R,spawn:le,stop:de}=yield*N_(re,h,void 0,ne===void 0?void 0:e=>ne(e)));let fe=e=>Pe(e)?z:(y!==void 0&&y.publishUnsafe(x===void 0?{_tag:`StartFailed`,subject:b,cause:e.cause}:{_tag:`ActivityStopped`,subject:x.owner,activity:x,exit:e}),ae(e).pipe(I(T.close()),I(t.inspectionRoot===!0&&y!==void 0?y.close:z))),B=f===void 0?d??z:G(()=>f(Xe)),pe=y===void 0?O_:()=>x_(M,j),me=g??(p===void 0?E_:y===void 0?p.send:e=>o_(p,e,b,pe())),he=y===void 0?T.emit:e=>T.emit(e).pipe(u(()=>G(()=>y.publishUnsafe({_tag:`Emitted`,subject:b,emission:e,causedBy:pe()})))),V={self:re,parent:p,spawn:le,sendParent:me,emit:he,sendTo:y===void 0?((e,t)=>a_(e)?e.send(t):R(e,t)):((e,t)=>a_(e)?o_(e,t,b,pe()):R(e,t,b,pe())),stopChild:de,failCause:e=>Yn(D,{_tag:`Failure`,cause:e}).pipe(Tr),inspectInitial:y===void 0?D_:(e,t=[])=>{S=e,C=t}};y!==void 0&&y.publishUnsafe(x===void 0?{_tag:`Created`,subject:b,parent:p?.inspectionSubject,origin:t.origin??{_tag:`Root`},definition:e.inspection?.definition}:{_tag:`ActivityStarted`,subject:x.owner,activity:x});let ge=yield*e.initial(V).pipe(An(fe),Hr(G(()=>{j=!1}))),_e=yield*sr({revision:0,terminalizing:!1,changes:void 0,snapshot:{status:`active`,state:ge}});x===void 0&&y?.publishUnsafe({_tag:`Initialized`,subject:b,snapshot:{status:`active`,state:ge},initialEntryPaths:S??[],microsteps:qg({microsteps:C??[]})});let ve=s===void 0?e=>e.changes===void 0?E(e):ue(e.changes,[e]).pipe(ye(e)):e=>{let t=e.changes===void 0?E(e):ue(e.changes,[e]).pipe(ye(e)),n=e.snapshot;return n.status===`active`?t.pipe(u(()=>v_(s,n))):t},be=e=>e.changes===void 0?z:ue(e.changes,Ue(void 0)).pipe(Tr),xe=e=>e.snapshot.status===`active`?E(e):be(e).pipe(ye(e)),Se=e=>Rr(_e).pipe($t(t=>t.revision===e.revision?ve(e).pipe($t(xe)):E(void 0))),Ce=e=>In(_e,t=>t.terminalizing?E([void 0,t]):xr(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($t(e=>e===void 0?E(void 0):Se(e)),xr(e=>e?.snapshot)),we=e=>Er(_e,t=>t.terminalizing||t.snapshot.status!==`active`?[void 0,t]:[{revision:t.revision+1,snapshot:e(t.snapshot),terminalizing:!0,changes:t.changes},{...t,terminalizing:!0}]).pipe(xr(e=>e?.snapshot)),Te=e=>Yt(_e,t=>({revision:t.revision+1,snapshot:e,terminalizing:!0,changes:t.changes})).pipe($t(ve),$t(xe),Tr),Ee=y===void 0?e=>Ce(t=>E(t.status===`active`?{status:`active`,state:e}:void 0)).pipe(Tr):t=>Rr(_e).pipe($t(n=>Ce(e=>E(e.status===`active`?{status:`active`,state:t}:void 0)).pipe(u(r=>G(()=>{e.inspection?.kind!==`Machine`&&r!==void 0&&y.publishUnsafe({_tag:`StateChanged`,subject:b,before:n.snapshot.state,after:t,causedByDeliveryId:M!==void 0&&e_(M)?M.inspection?.deliveryId:void 0})})))),Tr),De=(e,n,r)=>{let a=i===void 0||e.status===`stopped`&&t.skipStoppedOutcome===!0?z:H(()=>i(__(e))).pipe(fr,Tr),o=y===void 0?T.close():T.close().pipe(I(G(()=>y.publishUnsafe(x===void 0?{_tag:`Terminated`,subject:b,snapshot:e}:{_tag:`ActivityStopped`,subject:x.owner,activity:x,exit:e.status===`stopped`?Un():n}))));return Ge(G(()=>m_(w)).pipe(I(ae(n)),I(Te(e)),I(o),I(G(()=>{Oe(n)?r_(M,n.cause):i_(M),M=void 0})),I(a),I(B),I(t.inspectionRoot===!0&&y!==void 0?y.close:z),I(r)))},ke=we(e=>({status:`stopped`,state:e.state})),Ae=e=>we(t=>({status:`error`,state:t.state,cause:e})),je=e=>we(t=>({status:`done`,state:t.state,output:e})),Me=e=>De(e,P,ri(O,new Wd)),Ie=(e,t)=>{let n=c(t);return De(e,n,ct(O,t))},Le=(e,t)=>{let n=Ue(t);return De(e,n,Yn(O,t))},Re=Ge(N.pipe(I(k))),ze=e.execution?._tag===`Compiled`?{receiveMessage:p_(w).pipe(u(e=>G(()=>{M=e_(e)?e:void 0}))),pollMessage:G(()=>l_(w)).pipe(u(e=>G(()=>{He(e)&&(M=e_(e.value)?e.value:void 0)}))),completeMessage:e=>{n_(M,e),M=void 0}}:void 0,U=y===void 0||e.execution?._tag===`Compiled`?p_(w).pipe(xr(t_)):p_(w).pipe(u(e=>G(()=>{M=e})),xr(t_)),Ve=y===void 0||e.execution?._tag===`Compiled`?G(()=>l_(w)).pipe(xr(ce(t_))):G(()=>l_(w)).pipe(u(e=>G(()=>{He(e)&&(M=e.value)})),xr(ce(t_))),Ke=y===void 0?e=>Ce(t=>t.status===`active`?e(t.state).pipe(xr(e=>({status:`active`,state:e}))):E(void 0)).pipe(Tr):t=>Rr(_e).pipe($t(n=>Ce(e=>e.status===`active`?t(e.state).pipe(xr(e=>({status:`active`,state:e}))):E(void 0)).pipe(u(t=>G(()=>{e.inspection?.kind!==`Machine`&&t?.status===`active`&&y.publishUnsafe({_tag:`StateChanged`,subject:b,before:n.snapshot.state,after:t.state,causedByDeliveryId:M!==void 0&&e_(M)?M.inspection?.deliveryId:void 0})})))),Tr),qe={...V,...e.execution?._tag===`Compiled`&&!e.execution.childless?{ownedChildren:L}:void 0,...ze,receive:U,poll:Ve,state:Rr(_e).pipe(xr(e=>e.snapshot.state)),setState:Ee,updateState:Ke},Je=In(_e,e=>e.snapshot.status===`active`?e.changes===void 0?xt({replay:1}).pipe(xr(t=>[t,{...e,changes:t}])):E([e.changes,e]):E([void 0,e])),Ye=Fe(qr(function*(){let e=yield*Je;if(e===void 0)return l((yield*Rr(_e)).snapshot);let t=yield*xi(e),n=yield*Rr(_e);return n.snapshot.status===`active`?l(n.snapshot).pipe(kn(rn(We(m(t))).pipe(gi(e=>e.revision>n.revision),ii(e=>e.snapshot)))):l(n.snapshot)})),Xe={id:v,sessionId:_,...y===void 0?void 0:{inspectionSubject:b,sendInspected:te},state:Rr(_e).pipe(xr(e=>e.snapshot.state)),snapshot:Rr(_e).pipe(xr(e=>e.snapshot)),changes:Ye,emissions:T.stream,join:li(O),stop:Re,send:re.send,...ne===void 0?void 0:{[Qg]:ne},child:oe,childChanges:ie};o!==void 0&&!o(Xe)?yield*N:a!==void 0&&(yield*a(Xe,N)),s!==void 0&&(yield*v_(s,{status:`active`,state:ge}));let Ze=e=>{switch(e._tag){case`Stopped`:return ke;case`Done`:return je(e.output);case`Failure`:return Ae(e.cause)}},Qe=(e,t)=>{switch(e._tag){case`Stopped`:return Me(t);case`Done`:return Le(t,e.output);case`Failure`:return Ie(t,e.cause)}},$e=e=>n===!0?tr(e,{startImmediately:!0}):un(e,{startImmediately:!0}),et=yield*Be(D),tt=Ne(et)?yield*F(t=>t(H(()=>e.run(qe))).pipe(fr,$t(e=>Yn(D,Oe(e)?{_tag:`Failure`,cause:e.cause}:{_tag:`Done`,output:e.value})))).pipe($e):void 0;return yield*$e(F(e=>qr(function*(){let t=He(et)?yield*et.value:yield*e(li(D)),n=yield*Ze(t);return tt!==void 0&&(yield*se(tt)),n===void 0?yield*k:yield*Qe(t,n)}))),Xe}),tv=((e,t)=>e.execution?._tag===`Compiled`?Q_(e,t):ev(e,t)),nv=y_(tv,$_),rv=new WeakMap,iv=e=>H(()=>{e.closed=!0;let t=Array.from(e.live).reverse();return e.live.clear(),Ir(t,e=>e.stop,{discard:!0})}),av=()=>{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},ov=e=>$t(ai,t=>{let n=rv.get(t);if(n!==void 0)return e(n.hooks);let r=av();return rv.set(t,r),I(Gt(t,iv(r)),e(r.hooks))});_r(function*(e,t,n){let r=yield*nv,i=n===void 0?{detached:!0,runtime:r}:{...n,detached:!0,runtime:r};return t===`generic`?yield*ov(t=>ev(e,{...i,...t})):t===`compiled`?e.execution?._tag===`Compiled`?yield*ov(t=>Q_(e,{...i,...t})):yield*bn(Error(`Machine cannot force the compiled runtime for generic process logic`)):yield*ov(t=>tv(e,{...i,...t}))});var sv=_r(function*(e,t){let n=yield*nv;return yield*ov(r=>tv(e,t===void 0?{detached:!0,runtime:n,...r}:{...t,detached:!0,runtime:n,...r}))}),cv=_r(function*(e,t,n){let r=yield*nv,i=yield*r.nextSessionId,a=yield*Wg(i);r.inspection=a;let o=A_(),s=yield*A(),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*me(ov(n=>{let r={...c,...n};return t===`generic`?ev(e,r):t===`compiled`?e.execution?._tag===`Compiled`?Q_(e,r):bn(Error(`Machine cannot force the compiled runtime for generic process logic`)):tv(e,r)}).pipe(An(e=>rt(s,e))));return{id:n?.id??i,sessionId:i,changes:Fe(li(s).pipe(xr(e=>e.changes))),emissions:o.stream,inspection:a.stream,start:l}}),lv=((e,t)=>cv(e,`auto`,t));K({_tag:on(`MachineSnapshot`),version:on(2),active:or(K({path:U,value:V(vi)})),completed:V(or(K({path:U,output:V(vi)}))),history:V(N(U,K({mode:fi([`shallow`,`deep`]),active:or(U),values:N(U,vi)})))});var uv=(e,t,n)=>{let r=$(e,n);if(r.type===`compound`){let r=fm(e,t,n);if(r===void 0)throw Error(`Machine expected completed state "${n}" to have an active child`);return uv(e,t,r)}return r.output},dv=(e,t)=>qr(function*(){let n=yield*rm(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)||!hm(e,n,a))throw Error(`Machine snapshot contains invalid completion "${a}"`);i.add(a);let o=uv(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*lp(e,o,t.output,{boundary:`output`,state:a}))}return Jp(e,{...n,outputs:r})}).pipe(jt(t=>fv(e,t))),fv=(e,t)=>{if(bt(t))return Bn(ve(t,t=>t instanceof Bd?t:new Bd({machineId:e.id,boundary:`configuration`,cause:bi(t)})));let n=p(t);return He(n)&&n.value instanceof Bd?jr(n.value):jr(new Bd({machineId:e.id,boundary:`configuration`,cause:t}))},pv=e=>e.length===0?z:e.length===1?e[0]:Dt(e,{discard:!0}),mv=(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}),hv=new WeakMap,gv=e=>{let t=hv.get(e);if(t!==void 0)return t;let n=Object.values(Jd(e).handlers).some(e=>e.invoke!==void 0);return hv.set(e,n),n},_v=E(Ze()),vv=(e,t)=>{let n=Pg(e),r=new WeakMap,i=t=>{let n=r.get(t.scope);return n===void 0&&(n=ag(e,t.scope),r.set(t.scope,n)),n},a=n=>{if(!t)return;let r=n.state();return Qh(e,r)?$h(e,r,Zh).pipe(xr(f)):void 0},o=e=>H(()=>c(e)??_v),s=(e,t,r,a,s)=>{let c=a.commands.length===0?void 0:og(a.commands,e.scope),l=a.emittedEvents.length===0?void 0:sg(a.emittedEvents,i(e)),u=()=>{let i=H(()=>(t&&e.completeMessage({before:r,plan:mv(a,n.snapshot),after:s}),a.done?E(f(a.output)):o(e)));return l===void 0?i:l.pipe(I(i))},d=()=>{let t=e.commit(s),n=u(),r=t===void 0?n:t.pipe(I(n));return t===void 0&&l===void 0?r:e.runAfterChanges(r)};return c===void 0?d():e.runAfterChanges(c.pipe(I(H(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(Ne(e))return;r=e.value}let a=e_(r),c=a?r.event:r,l=t.state(),u;try{u=n.plan(t.executionState??n.fromConfiguration(tm(e,l)),c,a,t.scope)}catch(e){return Kd(e)}if(t.executionState=u.next,u.microsteps.length===0){a&&t.completeMessage({before:l,plan:mv(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(I(H(()=>(a&&t.completeMessage({before:l,plan:mv(u,n.snapshot),after:d}),o(t))))));a&&t.completeMessage({before:l,plan:mv(u,n.snapshot),after:d})}};return{run:e=>g_(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:g_(r,e.scope)}}},yv=class{initialized=!1;initial;constructor(e){this.initial=e}},bv=(e,t)=>{let n=Pg(e);return r=>{let i=r.state();if(t&&Qh(e,i))return $h(e,i,Zh).pipe(xr(f));let a=r.scope,o=r.executionState,s=o instanceof yv?o:new yv;r.executionState=s;let c,l,u;return u=H(()=>{let t=r.pollMessage();if(Ne(t))return l=void 0,E(Ze());let o=t.value,s=e_(o),d=s?o.event:o,p=i,m;try{m=n.plan(l??n.fromConfiguration(tm(e,i)),d,s,a)}catch(e){return Kd(e)}if(l=m.next,m.microsteps.length===0)return s&&r.completeMessage({before:p,plan:mv(m,n.snapshot),after:i}),u;let h=m.microsteps.some(e=>e.changed),g=h?m.microsteps.flatMap(e=>e.exitPaths):[],_=new Map;if(h){for(let e of m.microsteps)if(e.changed)for(let t of e.entryPaths)_.set(t,e.event)}let v=n.toConfiguration(m.next),y=n.snapshot(m.next),b=[];if(m.commands.length>0&&b.push(og(m.commands,a)),h){let e=r.ownedChildren.stopPaths(g);e!==void 0&&b.push(e)}let x=[];if(m.emittedEvents.length>0&&x.push(sg(m.emittedEvents,c??=ag(e,a))),m.done)x.push(r.ownedChildren.stopAll());else if(h)for(let[t,n]of _){let i=J_(e,a,r.ownedChildren,v,[t],n);i!==void 0&&x.push(i)}let S=()=>{let e=r.commit(y);return i=y,e},C=()=>{let e=H(()=>(s&&r.completeMessage({before:p,plan:mv(m,n.snapshot),after:y}),m.done?E(f(m.output)):u));return x.length===0?e:pv(x).pipe(I(e))},w=()=>{let e=S(),t=C(),n=e===void 0?t:e.pipe(I(t));return e===void 0&&x.length===0?n:r.runAfterChanges(n)};return b.length===0?w():r.runAfterChanges(pv(b).pipe(I(H(w))))}),g_(H(()=>{if(s.initialized)return u;let t=s.initial,o=t?.activeConfiguration??tm(e,i);l=t?.configuration??n.fromConfiguration(o);let c=J_(e,a,r.ownedChildren,o,t?.entryPaths??Kp(e,o),Zh);return s.initial=void 0,s.initialized=!0,c===void 0?u:c.pipe(I(u))}),a)}},xv=e=>e.done?{state:e.state,done:!0,output:e.output}:{state:e.state,done:!1,output:void 0},Sv=(e,t)=>{let n=gv(e),r=Pg(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=xv(t);return n?{...r,executionState:new yv({configuration:t.configuration,activeConfiguration:t.activeConfiguration,entryPaths:t.initialEntryPaths})}:r}catch(e){throw qd(e)}},s=t=>a===void 0?g_(ig(fh(e,t),...i).pipe($t(n=>{t.inspectInitial(n.initialEntryPaths,n.microsteps);let r=n.commands.length===0?void 0:og(n.commands,t),i=n.emittedEvents.length===0?void 0:sg(n.emittedEvents,ag(e,t)),a=E(xv(n));return r===void 0?i===void 0?a:i.pipe(I(a)):i===void 0?r.pipe(I(a)):r.pipe(I(i),I(a))})),t):Ie({try:()=>o(t),catch:qd});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:bv(e,t._tag===`Resume`)}:{_tag:`Owned`,...vv(e,t._tag===`Resume`)}},initial:n=>t._tag===`Resume`?g_(dv(e,t.snapshot),n):s(n).pipe(xr(e=>e.state)),run:t=>g_(qr(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*bn(Error(`Machine statechart started without acknowledged mailbox access`));let c,l=yield*o;if(Qh(e,l))return yield*$h(e,l,Zh);if(!n){let n,o=Ze(),u;for(;c===void 0;){let d=He(o)?o.value:yield*a;o=Ze();let f=e_(d),p=f?d.event:d,m=l,h;try{h=rg(e,Ap(n??tm(e,l),t),p)}catch(e){return yield*Kd(e)}if(n=h.next,h.microsteps.length>0){let n=Jp(e,h.next);yield*og(h.commands,t),yield*s(n),l=n,h.emittedEvents.length>0&&(yield*sg(h.emittedEvents,u??=ag(e,t))),h.done&&(c={output:h.output})}f&&r({before:m,plan:mv(h,t=>Jp(e,t)),after:l}),c===void 0&&(o=yield*i,Ne(o)&&(n=void 0))}return c===void 0?yield*bn(Error(`Machine process stopped receiving events before reaching a terminal configuration`)):c.output}let u=t.ownedChildren;if(u===void 0)return yield*bn(Error(`Invoking statechart started without an owned child runtime`));let d=(n,r,i)=>J_(e,t,u,n,r,i)??z,f=e=>u.stopPaths(e)??z;return yield*qr(function*(){let n=yield*rm(e,l);yield*d(n,Kp(e,n),Zh),n=void 0;let o=Ze(),p;for(;c===void 0;){let m=He(o)?o.value:yield*a;o=Ze();let h=e_(m),g=h?m.event:m,_=l,v;try{v=rg(e,Ap(n??tm(e,l),t),g)}catch(e){return yield*Kd(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=Jp(e,v.next);if(yield*og(v.commands,t),n&&(yield*f(r)),yield*s(a),l=a,v.emittedEvents.length>0&&(yield*sg(v.emittedEvents,p??=ag(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:mv(v,t=>Jp(e,t)),after:l}),c===void 0&&(o=yield*i,Ne(o)&&(n=void 0))}return c===void 0?yield*bn(Error(`Machine process stopped receiving events before reaching a terminal configuration`)):c.output}).pipe(An(()=>u.stopAll()))}),t)}},Cv=new WeakMap,wv=(e,...t)=>{if(t.length>0)return Sv(e,{_tag:`Initial`,args:t});let n=Cv.get(e);if(n!==void 0)return n;let r=Sv(e,{_tag:`Initial`,args:t});return Cv.set(e,r),r},Tv=(e,t)=>Sv(e,{_tag:`Resume`,snapshot:t}),Ev=(e,...t)=>lv(wv(e,...t),e.id===void 0?void 0:{id:e.id}),Dv=(e,t)=>sv(Tv(e,t),e.id===void 0?void 0:{id:e.id}),Ov={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`]},kv=[`title`,`description`,`documentation`],Av=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),jv=(e,t)=>{let n=typeof t==`symbol`?`[${String(t)}]`:t===``?`<empty>`:String(t);return e===``?n:`${e}.${n}`},Mv=(e,t,n)=>{throw Error(`${e} invalid state definition at "${t}": ${n}`)},Nv=e=>Number.isFinite(Number(e)),Pv=e=>e.length===0||e.some(e=>e===`untagged`)?`untagged`:e.every(e=>e===`tagged`)?`tagged`:`opaque`,Fv=(e,t)=>{if(t.has(e))return`opaque`;if(zn(e)||Br(e)||gr(e)||Fr(e)||er(e)||a(e))return`tagged`;if(yn(e))return typeof e.literal==`string`||typeof e.literal==`number`?`tagged`:`untagged`;let n=new Set(t).add(e);return ln(e)?Pv(e.types.map(e=>Fv(e,n))):Qt(e)?Fv(e.thunk(),n):Xe(e)?`opaque`:`untagged`},Iv=(e,t=new Set)=>{if(t.has(e))return`opaque`;if(ur(e)){let n=e.propertySignatures.find(({name:e})=>e===`_tag`)?.type;return n===void 0||kr(n)?`untagged`:Fv(n,new Set(t).add(e))}let n=new Set(t).add(e);return ln(e)?Pv(e.types.map(e=>Iv(e,n))):Qt(e)?Iv(e.thunk(),n):Xe(e)?`opaque`:`untagged`},Lv=e=>_t(e)&&Iv(Kr(e.ast))!==`untagged`,Rv=(e,t,n)=>{let r=jv(t,n);return typeof n==`symbol`?Mv(e,r,`state keys must be strings, not symbols`):typeof n==`number`?Mv(e,r,`state keys cannot use numeric forms`):n===``?Mv(e,r,`state keys cannot be empty`):n===`__proto__`?Mv(e,r,`the state key "__proto__" is not allowed`):n.includes(`.`)?Mv(e,r,`state keys cannot contain "."`):Nv(n)?Mv(e,r,`state keys cannot use numeric forms`):r},zv=(e,t,n,r)=>{(typeof n!=`object`||!n||Array.isArray(n))&&Mv(e,t,`${r} must be a plain record`);let i=Object.getPrototypeOf(n);i!==Object.prototype&&i!==null&&Mv(e,jv(t===`<root>`?``:t,`__proto__`),`${r} must not declare an implicit "__proto__" state key`)},Bv=(e,t,n,r,i)=>{if(typeof n!=`object`||!n||Array.isArray(n)||!Av(n,r))return;let a=n[r];(typeof a!=`object`||!a||_t(a)||a.type!==`history`)&&Mv(e,`${t}.${r}`,i)},Vv=(e,t,n,r)=>{let i=Ov[r];for(let a of Reflect.ownKeys(n))i.includes(a)||Mv(e,t,`${r} states cannot declare property "${String(a)}"`)},Hv=(e,t,n)=>{zv(e,`${t}.annotations`,n,`schema-less state annotations`);for(let r of Reflect.ownKeys(n))kv.includes(r)||Mv(e,`${t}.annotations`,`schema-less state annotations cannot declare property "${String(r)}"`),typeof n[r]!=`string`&&Mv(e,`${t}.annotations.${String(r)}`,`schema-less state annotation values must be strings`)},Uv=(e,t,n,r,i=!1)=>{zv(e,n===``?`<root>`:n,t,`state trees`);for(let a of Reflect.ownKeys(t)){let o=i&&a===``?``:Rv(e,n,a),s=t[a];if(_t(s)){Lv(s)||Mv(e,o,`state schemas must decode to an object with a required PropertyKey _tag`);continue}zv(e,o,s,`state nodes`);let c=s.type,l=c===`history`?`history`:c===`choice`?`choice`:c===`parallel`?`parallel`:c===`final`?`final`:Av(s,`states`)?`compound`:`atomic`;if(Vv(e,o,s,l),l===`history`||l===`choice`){r||Mv(e,o,`${l} states must be declared below an active parent state`),Av(s,`annotations`)&&Hv(e,o,s.annotations),l===`history`&&Av(s,`history`)&&s.history!==`shallow`&&s.history!==`deep`&&Mv(e,`${o}.history`,`history must be "shallow" or "deep"`);continue}let u=Av(s,`schema`);u&&!Lv(s.schema)&&Mv(e,`${o}.schema`,`state schemas must decode to an object with a required PropertyKey _tag`),u&&Av(s,`annotations`)&&Mv(e,`${o}.annotations`,`schema-backed states must declare annotations on their schema`),!u&&Av(s,`annotations`)&&Hv(e,o,s.annotations),l===`atomic`&&Av(s,`type`)&&s.type!==`active`&&Mv(e,`${o}.type`,`atomic state type must be "active"`),l===`final`&&s.type!==`final`&&Mv(e,`${o}.type`,`final state type must be "final"`),l===`compound`&&Av(s,`type`)&&s.type!==`active`&&Mv(e,`${o}.type`,`compound state type must be "active"`),l===`parallel`&&s.type!==`parallel`&&Mv(e,`${o}.type`,`parallel state type must be "parallel"`),(l===`final`||l===`parallel`)&&Av(s,`output`)&&!_t(s.output)&&Mv(e,`${o}.output`,`state output must be an Effect Schema`),l===`compound`?(Bv(e,o,s.states,`initial`,`active and choice child states cannot use the reserved target selector key "initial"`),u&&Bv(e,o,s.states,`with`,`schema-backed compound child states cannot use the reserved local target selector key "with"`),Uv(e,s.states,o,!0)):l===`parallel`&&(Av(s,`states`)||Mv(e,`${o}.states`,`parallel states must declare child regions`),Bv(e,o,s.states,`initial`,`active and choice child states cannot use the reserved target selector key "initial"`),Uv(e,s.states,o,!0))}},Wv=e=>typeof e==`object`&&e?Object.freeze({...e}):e,Gv=e=>{let t={};for(let n of Object.keys(e)){let r=e[n];if(_t(r)){Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!1,writable:!1});continue}let i=r,a={...i};`states`in i&&(a.states=Gv(i.states)),`annotations`in i&&(a.annotations=Wv(i.annotations)),Object.defineProperty(t,n,{value:Object.freeze(a),enumerable:!0,configurable:!1,writable:!1})}return Object.freeze(t)},Kv=e=>Gv(e),qv=(e,t=``)=>{if(_t(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(Av(n,`fields`)&&(Av(n,`schema`)&&Mv(`Machine.state`,t,`declare fields or schema, not both`),zv(`Machine.state`,t,n.fields,`state fields`),Av(n.fields,`_tag`)&&Mv(`Machine.state`,t,`state fields cannot declare _tag`),r.schema=Kn(t,n.fields),delete r.fields),Av(n,`states`)){zv(`Machine.state`,t,n.states,`child states`);let e=Object.create(null);for(let r of Reflect.ownKeys(n.states))Rv(`Machine.state`,t,r),e[r]=qv(n.states[r],r);r.states=e}return t===``?(Uv(`Machine.state`,{"":r},``,!1,!0),Kv({"":r})[``]):r},Jv=`~effect/Machine`,Yv=`~effect/Machine/ChildMachine`,Xv={..._e,...Ar,[Jv]:Jv,toJSON(){return{_id:`Machine`}}},Zv=(e,t)=>{let n=Object.create(Xv);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,rp(e,n),n},Qv=e=>e.kind===`none`?lf:cf(e.kind,e.path,e.scope,e.updatePath),$v=e=>Object.freeze({path:e.path,kind:e.kind,scope:e.scope}),ey=e=>e.updatePath===void 0?e.kind===`update`&&e.path!==void 0?[e.path]:[]:[e.updatePath],ty=(e,t,n,r,i)=>{if(typeof e!=`object`||!e||!B(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(!uf(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`||!Pp(r,e.path)||!Pp(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}},ny=(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(!ff(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(!mf(e)||e.update.path!==t.updatePath)throw Error(`Machine target updating "${t.updatePath}" must return target construction .update(...)`)}else if(mf(e))throw Error(`Machine combined target requires an updating owner declaration`);if(e===void 0)return;let r=mf(e)?e.target:e,i=typeof r==`object`&&r&&B(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&&Pp(i,t.path)))throw Error(`Machine transition resolver selected "${t.path}" but constructed "${i??`<invalid>`}"`)},ry=(e,t,n,r,i)=>{let a={...t,root:i===``?t.state:t.ancestors[``],decline:xf};delete a.target;let o=e.resolve(a,n);if(Sf(o)){if(e.declinable!==!0)throw Error(`Machine transition for state "${i}" returned decline without declaring declinable: true`);return o}return ny(o,e.selection,r),o},iy=e=>e.kind===`update`?void 0:e.path,ay=e=>{let t=Number(e);return Number.isInteger(t)&&t>=0&&t<4294967295&&String(t)===e},oy=(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||ay(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||!B(i,`target`))throw Error(`Machine transition branch "${r}" requires a target selection`);let{target:a,title:o}=i;if(!uf(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:Qv(a)})}))},sy=(e,t,n,r={},i)=>{let a=wm(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 pf(Df(i.path,i.parent),Dm(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`?Cf(n.path,n.parent):Df(n.path,n.parent)}if(e.kind===`update`)return Dm(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 pf(Em(t,e.path,r,i),Dm(t,e.updatePath,n))}return Em(t,e.path,a,i)},cy=(e,t,n,r,i)=>Object.freeze(Object.fromEntries(e.map((e,a)=>[e.key,o=>hf(t,a,e.key,e.selection.kind===`none`?vf():sy(e.selection,n,r,o,i))]))),ly=(e,t,n)=>{if(t.kind===`none`){if(!yf(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`);ny(e,t,n)}},uy=(e,t)=>({...e,root:t===``?e.state:e.ancestors[``]}),dy=(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:ty({target:()=>Pm(t,i)},void 0,r,n,e).selection}]));return{branches:()=>a,reenter:i.reenter,declinable:f,resolve:(e,t)=>d&&!o(e)?xf():s(e,t)}}let p=Pm(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 xf();if(s!==void 0)return s(e,a);if(h)return sy(p,r,t,{input:g(e)});let l=u(e);return sy(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)}}},fy=(e,t,n,r,i)=>{let a=dy(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(B(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=oy(e.branches(),n,i),u=Object.freeze({}),d=(e,o)=>{let s={...e,root:n===``?e.state:e.ancestors[``],decline:xf};delete s.target,s.select=cy(l,u,t,r,n);let d=a(s,o);if(Sf(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(!gf(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 ly(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=>iy(e.selection)===void 0?[]:[e.selection.path]))],branches:l.map(e=>Object.freeze({type:`branch`,key:e.key,title:e.title,target:iy(e.selection),selection:$v(e.selection),updates:ey(e.selection)})),evaluate:d,transition:(e,t)=>d(e,t).result}}let l=ty(a,void 0,t,n,i),u=(e,r)=>({result:ry(l,e,r,t,n),branchIndex:0,branchKey:void 0});return{reenter:s,declinable:c,targets:iy(l.selection)===void 0?[]:[l.selection.path],branches:[{type:`direct`,target:iy(l.selection),selection:$v(l.selection),updates:ey(l.selection)}],evaluate:u,transition:(e,t)=>u(e,t).result}},py=(e,t,n,r)=>{let i=Object.create(null);for(let a of Reflect.ownKeys(e))i[a]=fy(e[a],t,n,r,a);return i},my=(e,t,n,r)=>{let i=(Array.isArray(e)?e:[e]).map(e=>{let i=Fm(r,e,n,e=>uy(e,n));for(let e of[`onElement`,`onDone`,`onFailure`,`onSnapshot`])i[e]!==void 0&&(i[e]=fy(i[e],t,n,r,e));return Km(i,n)});return Jm(i,n),Array.isArray(e)?Object.freeze(i):i[0]},hy=(e,t,n,r,i,a)=>{for(let o of Object.keys(a)){let s=r===``?o:`${r}.${o}`;if(!B(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=py(d,t,s,i)),u.always!==void 0&&(u.always=fy(u.always,t,s,i,`always`)),u.onDone!==void 0&&(u.onDone=fy(u.onDone,t,s,i,`done`)),u.choice!==void 0&&(u.choice=fy(u.choice,t,s,i,`choice`)),u.invoke!==void 0&&(u.invoke=my(u.invoke,t,s,i)),t.byPath.get(s)?.type===`choice`&&(typeof u.choice!=`object`||u.choice===null||!B(u.choice,`transition`)||typeof u.choice.transition!=`function`||!B(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=kf(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`);hy(e,t,r.states,s,i,l)}}},gy=e=>e===``?Am:e,_y=e=>{let t=!1;for(let n of e.stateNodes.byPath.values())if(n.type===`choice`){t=!0;break}if(!t)return;let n=Nf(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(!Pp(o,n)){let r=i.type===`branch`?`branch "${i.key}"`:`transition`;throw Error(`Machine transition from "${gy(e.source)}" updates "${gy(n)}" before choice "${t}", whose ${r} targets "${gy(o)}" outside that owner`)}}}}}}},vy=(e,t)=>(n=>{let r=Gm(t.root,n),i=Object.assign(Object.create(Xv),e);if(rp(e,i),i.states=Object.freeze({"":r.node}),i.stateNodes=Af(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:Um(n.root);i.initial=e=>({...Tf(``,a({input:e})),input:{value:e}}),i.initialDefinition=Object.freeze({target:``,selection:Object.freeze({path:``,kind:`initial`,scope:`initial`})});let o=Object.create(null);hy(o,i.stateNodes,i.states,``,{...t,initialize:e=>i.initial(i.input===void 0?void 0:xp(i,i.input,e))},{"":r.handlers});let s=Zv(i,o);return _y(s),s}),yy=e=>{let t=qv(e),n=by();return Object.freeze({...n,"~effect/Machine/State":`~effect/Machine/State`,node:t})},by=()=>({path:(e=>e),get:((e,t)=>zf(e,t).pipe(ce(e=>e.value))),getWithParents:((e,t)=>{let n={};return zf(e,t,n).pipe(ce(e=>({value:e.value,parents:n})))}),getSnapshot:zf,matches:((e,t)=>He(zf(e,t)))}),xy=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(Ar);return n.states=t,n.root=e.root,n.events=e.events,n.internalEvents=e.internalEvents??cp(`internal`,[]),n.emittedEvents=e.emittedEvents??cp(`emitted`,[]),n.parent=e.parent,n.input=e.input,n.id=e.id,n.handlers=Object.create(null),n.handle=vy(n,Mm(e.root,e)),np(n),n},Sy=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?[]:[je(e)]},Cy=e=>cp(`public`,Sy(e)),wy=(e,t)=>Ty(e,t,e=>t.input===void 0?wv(t):wv(t,e)),Ty=(e,t,n)=>({[Yv]:Yv,id:e,machine:t,[Rm]:n}),Ey=Ev,Dy=Dv,Oy=(e,t)=>{try{let n=eg(e,...t);return{machine:e,snapshot:n.done?{status:`done`,state:n.state,output:n.output}:{status:`active`,state:n.state}}}catch{return}},ky=(e,t)=>{try{let n=b(dv(e,t));if(n._tag===`Failure`)return;let r=n.value;if(!Qh(e,r))return{machine:e,snapshot:{status:`active`,state:r}};let i=b($h(e,r,Zh));return i._tag===`Success`?{machine:e,snapshot:{status:`done`,state:r,output:i.value}}:void 0}catch{return}},Ay={spawn:()=>bn(Error(`Child operations are unavailable in a planned snapshot`)),sendTo:()=>jr(new Wd),stop:()=>z},jy=(e,t)=>{if(e.snapshot.status!==`active`)return Ze();try{let n=e.machine,r=tm(n,e.snapshot.state);for(let e of Kp(n,r)){let i=dm(n,e);for(let a of Ym(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({...jp(r)??ph(n,r),children:Ay,state:r.values.get(e),containingState:Gp(n,r,e),ancestors:Wp(n,r,e),event:Zh}):a.input);let s=Oy(i,i.input===void 0?[]:[o]);return s===void 0?void 0:f(s)}}return Ze()}catch{return}},My=class extends Ft(`ChildNotActiveError`){},Ny=new WeakMap,Py=new WeakMap,Fy=e=>typeof e==`object`&&!!e&&Py.has(e),Iy=e=>{if(typeof WeakRef>`u`||typeof FinalizationRegistry>`u`)return pi(e);let t=h(),n=new FinalizationRegistry(({entry:e,key:n})=>{let r=St(t,n);He(r)&&r.value===e&&L(t,n)});return r=>{let i=St(t,r);if(He(i)){let e=i.value.ref.deref();if(e!==void 0)return e}let a=e(r),o={ref:new WeakRef(a)};return gt(t,r,o),n.register(a,{key:r,entry:o}),a}},Ly=(e,t)=>ut(ht(t,e=>e.stop).pipe(u(t=>G(()=>e.setSelf(re(t)))),$t(()=>Pn))),Ry=(e,t)=>Ly(e,e.result(t).pipe($t(e=>e.start))),zy=(e,t,n)=>Ly(e,Dy(t,n)),By=(e,t)=>`~effect-atom/atom/Atom/ServerValue`in e?e[Yr](t):t(e),Vy=(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}},Hy=e=>{let t;return()=>(t===void 0&&(t={value:e()}),t.value)},Uy=e=>e.snapshot,Wy=st(e=>e.registry).pipe(tt),Gy=e=>H(()=>{let t=e.pending.shift();return t===void 0?(e.draining=!1,z):I(t,Gy(e))}),Ky=(e,t)=>{let n=e.get(t);return n===void 0&&(n={pending:[],draining:!1},e.set(t,n)),n},qy=(e,t,n)=>Ee(n=>{let r=wt(n(e),()=>void 0),i=t.get(n.registry);return i===void 0||!i.draining?r:Hn(ce(n.self(),ge),()=>yi(!0))},(r,i)=>{let a=r.get(e),o=r.get(Wy),s=Ky(t,o);vt(a)||s.draining?(r.setSelf(yi(!0)),s.pending.push(Me(o,e).pipe($t(e=>n(e,i)),fr,xr(e=>{let t=Se(e);r.setSelf(s.pending.length===0?t:ge(t))}))),s.draining||(s.draining=!0,an(Gy(s)))):d(a)?r.setSelf(wt(a,()=>void 0)):_i(n(a.value,i),{onExit:e=>r.setSelf(Se(e))})}).pipe(Vn),Jy=e=>st(t=>{let n=t(e);return vt(n)?yi(n.waiting):d(n)?R(n.cause,{previous:t.self(),waiting:n.waiting}):n.value.status===`error`?R(n.value.cause,{previous:t.self(),waiting:n.waiting}):re(n.value.state,{waiting:n.waiting})}).pipe(Re(wr),o(Vy(t=>[By(e,t)],e=>wt(e,e=>e.state)))),Yy=e=>st(t=>{let n=t(e);if(vt(n))return yi(n.waiting);if(d(n))return R(n.cause,{previous:t.self(),waiting:n.waiting});if(Ne(n.value)){let e=t.self();return He(e)&&d(e.value)?e.value:re(Ze(),{waiting:n.waiting})}return n.value.value.status===`error`?R(n.value.value.cause,{previous:t.self(),waiting:n.waiting}):re(f(n.value.value.state),{waiting:n.waiting})}).pipe(Re(wr),o(Vy(t=>[By(e,t)],e=>wt(e,ce(e=>e.state))))),Xy=(e,t)=>st(n=>{let r=n(e);if(vt(r))return yi(r.waiting);if(d(r))return R(r.cause,{previous:n.self(),waiting:r.waiting});if(Ne(r.value))return re(Ze());let i=r.value.value,a=at(i.child(t)),o=_i(Si.pipe(I(i.childChanges(t).pipe(Xn(e=>G(()=>n.setSelf(re(e))))))));return n.addFinalizer(o),re(a)}).pipe(Vn),Zy=(e,t)=>Xg(e)?e[Yg](()=>t(at(e.snapshot))):_i(e.changes.pipe(Xn(e=>G(()=>t(e))))),Qy=(e,t,n)=>{let r=st(t=>{let n=t(e);if(vt(n))return yi(n.waiting);if(d(n))return R(n.cause,{previous:t.self(),waiting:n.waiting});if(Ne(n.value))return re(Ze());let r=n.value.value;return t.addFinalizer(Zy(r,e=>t.setSelf(re(f(e))))),re(f(at(r.snapshot)))}).pipe(o(Vy(()=>[],()=>{let e=n();return e===void 0?yi(!0):re(ce(e,Uy),{waiting:!0})}))),i=new WeakMap,a=e=>He(e)?E(e.value):jr(new My({id:t.id})),s=qy(e,i,(e,t)=>$t(a(e),e=>e.send(t))),c=qy(e,i,(e,t)=>$t(a(e),e=>e.stop)),l=$y(e,n);return{ref:e,snapshot:r,result:Yy(r),send:s,stop:c,child:l}},$y=(e,t)=>{let n=new WeakMap;return r=>{let i=n.get(r.machine);if(i===void 0){let a=r.machine,o=pi(n=>{let r=wy(n,a);return Qy(Xy(e,r),r,Hy(()=>{let e=t();return e===void 0||Ne(e)?e:jy(e.value,r)}))});i=e=>o(e),n.set(a,i)}return i(r.id)}},eb=(e,t,n)=>{let r=Vn(e),i=st(e=>{let t=e(r);if(vt(t))return yi(t.waiting);if(d(t))return R(t.cause,{previous:e.self(),waiting:t.waiting});let n=t.value;e.addFinalizer(Zy(n,t=>e.setSelf(re(t,{waiting:t.status===`active`}))));let i=at(n.snapshot);return re(i,{waiting:i.status===`active`})}).pipe(o(Vy(()=>[],()=>{let e=n();return e===void 0?yi(!0):re(Uy(e),{waiting:!0})}))),a=new WeakMap,s=qy(r,a,(e,t)=>e.send(t)),c=qy(r,a,(e,t)=>e.stop),l=$y(ti(r,f),()=>{let e=n();return e===void 0?void 0:f(e)}),u={ref:r,snapshot:i,result:Jy(i),send:s,stop:c,child:l};return Py.set(u,t),u},tb=(e,t)=>zf(e,t).pipe(ce(e=>e.value)),nb=(e,t)=>zf(e,t),rb=(e,t)=>ti(e,t).pipe(Re(wr),o(Vy(t=>[By(e,t)],e=>wt(e,t)))),ib=new WeakMap,ab=(e,t,n,r)=>{let i=ib.get(e);i===void 0&&(i=new Map,ib.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},ob=(e,t)=>ab(e,`select`,t,()=>rb(e.result,e=>tb(e,t))),sb=(e,t)=>ab(e,`selectSnapshot`,t,()=>rb(e.result,e=>nb(e,t))),cb=(e,t)=>ab(e,`selectChild`,t,()=>rb(e.result,ze(e=>tb(e,t)))),lb=(e,t)=>ab(e,`selectSnapshotChild`,t,()=>rb(e.result,ze(e=>nb(e,t)))),ub=(e,t)=>ab(e,`matches`,t,()=>rb(e.result,e=>He(zf(e,t)))),db=(e,t)=>ab(e,`matchesChild`,t,()=>rb(e.result,k(e=>He(zf(e,t))))),fb=(e,t,n)=>{let r=e.atom(()=>Ey(t,...n)),i=eb(e.atom(e=>Ry(e,r)),t,Hy(()=>Oy(t,n)));return Ny.set(i,r),i},pb=(e,t,n)=>eb(e.atom(e=>zy(e,t,n)),t,Hy(()=>ky(t,n))),mb=(e,t,n)=>{let r={owner:e,source:t},i=S(t,e=>e(r.source),{initialValueTarget:t}).pipe(Re((e,t)=>r.source.equals(e,t)),o(e=>By(r.source,e)));return n!==void 0&&(i=i.pipe(qn(n))),i},hb=(e,t)=>{let n=Iy(t=>({bridge:e(t)})),r={};for(let e of Object.keys(t.atoms)){let i=t.atoms[e];r[e]=Iy(r=>{let a=n(r);return mb(a,i(a.bridge),t.label?.(r,e))})}return r},gb=e=>{let t=((t,...n)=>fb(e,t,n));return{make:t,factory:(e=>(...n)=>t(e,...n)),resume:((t,n)=>pb(e,t,n)),family:((t,n)=>hb(n=>fb(e,t,[n]),n))}},_b=Fy;Vr(2,ob);var vb=Vr(2,sb);Vr(2,cb);var yb=Vr(2,lb);Vr(2,ub),Vr(2,db);var bb=gb;function xb(e){let t=(0,Ks.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=ns(`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 Sb(e){let t=(0,Ks.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)(xb,{className:`size-5`}),(0,Q.jsx)(xb,{className:`h-4 w-1/3`})]},t),t[3]=e.media,t[4]=n),r=Mn(Wt(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 Cb=Z.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Pa(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});Ao(`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 wb(e){let t=(0,Ks.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=ns(`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 Tb(e){let t=(0,Ks.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(Db)).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(Eb)}),t[7]=r,t[8]=a),o=a}let s=o;if(!s)return null;let c;t[9]===r?c=t[10]:(c=ns(`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 Eb(e,t){return e?.message&&(0,Q.jsx)(`li`,{children:e.message},t)}function Db(e){return[e?.message,e]}var Ob=new Uint8Array(512),kb=new Uint8Array(256);for(let e=0,t=1;e<255;e++)Ob[e]=t,kb[t]=e,t<<=1,256&t&&(t^=285);for(let e=255;e<512;e++)Ob[e]=Ob[e-255];var Ab=(e,t)=>e>0&&t>0?Ob[kb[e]+kb[t]]:0,jb=(e,t)=>Ob[t*kb[e]%255],Mb=e=>{let t=new Uint8Array(e+2),n=new Uint8Array(e+1);n[0]=1;for(let r=0;r<e;r++){let e=jb(2,r);t.fill(0,0,r+2);for(let i=0;i<r+1;i++)t[i]^=n[i],t[i+1]^=Ab(n[i],e);for(let e=0;e<r+2;e++)n[e]=t[e]}return n},Nb=(e,t)=>{let n=Mb(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]^=Ab(n[i],e)}return r.subarray(e.byteLength)},Pb=[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],Fb=[[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]],Ib=[[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]],Lb=[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],Rb=[[],[],[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]],zb=(e,t,n)=>{let r=Pb[t]-Fb[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},Bb=(e,t)=>{for(let n=1;n<=40;n++){let r=Pb[n]-Fb[n][t];if(r-=n>9?3:2,r>=e.byteLength)return n}throw RangeError(`Bytes exceed max length`)},Vb=(e,t,n)=>{let r=e.byteLength+Fb[t][n],i=Ib[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=Nb(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},Hb=(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)},Ub=(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}},Wb=(e,t,n)=>{let r=n-7;Ub(e,n,0,0,7),Ub(e,n,r,0,7),Ub(e,n,0,r,7),Hb(t,n,0,0,8),Hb(t,n,r-1,0,8),Hb(t,n,0,r-1,8)},Gb=(e,t,n,r)=>{let i=Rb[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];Ub(e,n,a,r,5),Hb(t,n,a,r,5)}}},Kb=(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)}},qb=(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},Jb=(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}},Yb=(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}},Xb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n)for(let a=0;a<n;a++){let n=i+a;t[n]||r+a&1||(e[n]^=1)}},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]||1&r||(e[n]^=1)}},Qb=(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)}},$b=(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)}},ex=(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)}}},tx=(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)}},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)%2==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;t[n]||r*a%3+(r+a&1)&1||(e[n]^=1)}},ix=(e,t,n,r)=>{switch(r){case 0:return Xb(e,t,n);case 1:return Zb(e,t,n);case 2:return Qb(e,t,n);case 3:return $b(e,t,n);case 4:return ex(e,t,n);case 5:return tx(e,t,n);case 6:return nx(e,t,n);case 7:return rx(e,t,n)}},ax=(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},ox=(e,t,n)=>{let r=0,i=0,a=new Uint8Array(e.byteLength);for(let o=0;o<=7;o+=1){a.set(e),ix(a,t,n,o);let s=ax(a,n);(o===0||s<r)&&(r=s,i=o)}return ix(e,t,n,i),i},sx=(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)},cx=(e,t,n,r)=>{let i=sx(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},lx=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},ux=(e,t,n)=>{if(n>=7){let r=lx(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}}},dx=(e,t)=>{let n=Bb(e,t),r=Vb(zb(e,n,t),n,t),i=Lb[n],a=new Uint8Array(i*i),o=new Uint8Array(i*i);return Wb(a,o,i),Gb(a,o,i,n),Kb(a,o,i),qb(o,i),Jb(o,i,n),Yb(a,o,i,r),cx(a,i,t,ox(a,o,i)),ux(a,i,n),a},fx=new TextEncoder,px=(e,t=1)=>dx(typeof e==`string`?fx.encode(e):e,t);function mx(e){let t=Ws.unstable_scheduleCallback(4,e);return()=>Ws.unstable_cancelCallback(t)}var hx=Z.createContext(Ve({scheduleTask:mx,defaultIdleTTL:400})),gx=new WeakMap,_x=0,vx=new Set;function yx(e){_x++;try{return e()}finally{_x--}}function bx(e){if(_x===0)return e();vx.size===0&&queueMicrotask(xx),vx.add(e)}function xx(){for(let e of vx)vx.delete(e),e()}function Sx(e,t){let n=gx.get(e);n===void 0&&(n=new WeakMap,gx.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,()=>bx(n));return()=>{i--,vx.delete(n),r()}},snapshot(){return yx(()=>e.get(t))},getServerSnapshot(){return(i===0||a===void 0)&&(a={value:yx(()=>si(t,e))}),a.value}};return n.set(t,o),o}function Cx(e,t){let n=Sx(e,t);return Z.useEffect(xx),Z.useSyncExternalStore(n.subscribe,n.snapshot,n.getServerSnapshot)}function wx(e,t,n){let r=Sx(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(xx),Z.useSyncExternalStore(r.subscribe,()=>i(r.snapshot()),()=>i(r.getServerSnapshot()))}var Tx=(e,t)=>{let n=Z.useContext(hx);return t?wx(n,e,t):Cx(n,e)};function Ex(e,t,n){return n?.mode===`promise`||n?.mode===`promiseExit`?Z.useCallback(r=>{e.set(t,r);let i=di(Me(e,t,{suspendOnWaiting:!0}));return n.mode===`promise`?i.then(Dx):i},[e,t,n.mode]):Z.useCallback(n=>{e.set(t,typeof n==`function`?n(e.get(t)):n)},[e,t])}var Dx=e=>{if(Pe(e))return e.value;throw pe(e.cause)},Ox=(e,t)=>{let n=Z.useContext(hx);return[Cx(n,e),Ex(n,e,t)]};function kx({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 Ax(e){let t=Z.useRef(!0);t.current&&(t.current=!1,e())}function jx(e,t,n,r,i,a,o,s,c,l=2){let u=Za(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 Go(n.current,u)?void 0:u}function Mx(e){return e==null?ps:e.type.startsWith(`key`)?So:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?oo:ps}var Nx=Z.createContext(void 0),Px=Z.createContext(void 0),Fx=Z.createContext(void 0),Ix=Z.createContext(!1),Lx=Z.createContext(``);function Rx(){let e=Z.useContext(Nx);if(!e)throw Error(Ca(22));return e}function zx(){let e=Z.useContext(Px);if(!e)throw Error(Ca(23));return e}function Bx(){let e=Z.useContext(Fx);if(!e)throw Error(Ca(24));return e}function Vx(){return Z.useContext(Lx)}function Hx(){return Z.useContext(Ix)}function Ux(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 Wx=(e,t)=>Object.is(e,t);function Gx(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Kx(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!Ux(e,t,(e,t)=>Gx(e,t,n)):e!==t}function qx(e,t,n){return e?e.some(e=>e!==void 0&&Gx(t,e,n)):!1}function Jx(e,t,n){return e?e.findIndex(e=>e!==void 0&&Gx(e,t,n)):-1}function Yx(e,t){if(t!==Wx)return n=>qx(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 Xx(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(Yx(t,n)):Jx(e,t,n);return i===-1?null:i}function Zx(e,t,n,r,i,a){return qx(r,t,i)?a!=null&&e>a&&qx(r,n[a],i)?a:e:e===a?Xx(n,r,i,!0):a}function Qx(e,t,n){return e.filter(e=>!Gx(t,e,n))}function $x(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function eS(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function tS(e){return eS(e?.[0])}function nS(e){return tS(e)?e.flatMap(e=>e.items):e}function rS(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(tS(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 iS(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 $x(e)}function aS(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?$x(e.value):$x(e)}var oS={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?rS(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=>Gx(t,e,n)):Gx(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},sS=`data-valid`,cS=`data-invalid`,lS={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},uS={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},dS={disabled:!1,...uS},fS={valid(e){return e===null?null:e?{[sS]:``}:{[cS]:``}}},pS={invalid:void 0,name:void 0,validityData:{state:lS,errors:[],error:``,value:``,initialValue:null},setValidityData:ba,disabled:void 0,setTouched:ba,setDirty:ba,setFilled:ba,setFocused:ba,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:dS,registerFieldControl:ba,validation:{getValidationProps:(e,t=Ui)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:ba,getInputControl:()=>null,commit:async()=>{},change:ba}},mS=Z.createContext(pS);function hS(e=!0){let t=Z.useContext(mS);if(t.setValidityData===ba&&!e)throw Error(Ca(28));return t}function gS(e,t,n,r,i=!0,a){let{registerFieldControl:o}=hS(),s=ka(()=>Symbol());q(()=>{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]),q(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var _S=Z.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:ba,validationMode:`onSubmit`,submitCountRef:{current:0}});function vS(){return Z.useContext(_S)}function yS(e){return Hi(e,`base-ui`)}var bS=Z.createContext({controlId:void 0,registerControlId:ba,resetControlId:ba,labelId:void 0,setLabelId:ba,messageIds:[],setMessageIds:ba,getDescriptionProps:e=>e});function xS(){return Z.useContext(bS)}function SS(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=xS(),o=yS(),s=ka(()=>Symbol()),c=Z.useRef(!1),l=Z.useRef(!1),u=J(()=>{c.current&&i!==ba&&(c.current=!1,i(s.current,void 0))});return q(()=>{if(!n||i===ba){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]),q(()=>u,[u]),(n?r:void 0)??t??o}function CS(e){return e==null?void 0:`${e}-popup`}function wS(e,t){return(n,r)=>n!=null&&e.contains(n,r,t)}function TS(e){return Array.isArray(e)?e.map(e=>TS(e)).join(`,`):e==null?``:String(e)}var ES=new Map;function DS(e={}){let{locale:t,...n}=e,r={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...n},i=`${TS(t)}|${JSON.stringify(r)}`,a=ES.get(i);if(a)return a;let o=new Intl.Collator(t,r),s={contains(e,t,n){if(!t)return!0;let r=iS(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=iS(e,n);return o.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=iS(e,n),i=t.length;return r.length>=i&&o.compare(r.slice(r.length-i),t)===0}};return ES.set(i,s),s}var OS=DS;function kS(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 AS(e,t){let n=Z.useRef(e),r=J(t);q(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function jS(e,t){let{onClick:n,onPointerDown:r}=kS(J((n,r)=>{(typeof e==`function`?e():e)||t(r||(ho?`touch`:``))}));return Z.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function MS(e){let[t,n]=Z.useState(null),r=jS(e,n);return AS(e,t=>{t&&!e&&n(null)}),Z.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}var NS=Symbol(`none`),PS={value:NS,index:-1};function FS(e,t,n){let r=e.get(t);if(r!==void 0||n===Wx)return r;for(let[r,i]of e)if(Gx(r,t,n))return i}function IS(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:m=!1,readOnly:h=!1,required:g=!1,inputRef:_,grid:v=!1,items:y,filteredItems:b,filter:x,filterQuery:S,openOnInputClick:C=!0,autoHighlight:w=!1,keepHighlight:T=!1,highlightItemOnHover:E=!0,loopFocus:D=!0,itemToStringLabel:O,itemToStringValue:k,isItemEqualToValue:A=Wx,virtualized:j=!1,inline:M=!1,fillInputOnItemPress:N=!0,modal:ee=!1,limit:P=-1,autoComplete:te=`list`,formAutoComplete:F,locale:ne,submitOnItemClick:re=!1}=e,{clearErrors:ie}=vS(),{setDirty:ae,validityData:I,setFilled:oe,name:se,disabled:L,setTouched:R,setFocused:ce,validationMode:le,validation:ue}=hS(),z=Qu(),de=SS({id:t}),fe=OS({locale:ne}),B=Array.isArray(y)?null:y;if(B&&typeof B.label!=`function`)throw Error(Ca(100));let pe=B?B.data:y,me=B?.value,he=me?void 0:pe,V=Z.useMemo(()=>{if(!b||!me)return;let e=nS(b),t=e.map(me),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 FS(n,r,i)}}},[b,me]),ge=Z.useMemo(()=>B?e=>B.label(e,A,e=>{let t=V?.findItem(e,A);return t==null?iS(e,O):B.itemLabel(t)}):O,[B,O,V,A]),_e=Z.useMemo(()=>B?Object.assign(e=>B.itemLabel(e),{selected:e=>iS(e,ge)}):O,[B,ge,O]);function ve(e){return iS(e,ge)}let[ye,be]=Z.useState(!1),[xe,Se]=Z.useState(null),Ce=Z.useRef(xe),we=Z.useRef([]),Te=Z.useRef([]),Ee=Z.useRef(null),De=Z.useRef(null),Oe=Z.useRef(null),ke=Z.useRef(null),Ae=Z.useRef(null),je=Z.useRef(!1),Me=Z.useRef(null),Ne=Z.useRef(null),Pe=Z.useRef(null),Fe=Z.useRef(PS),Ie=Z.useRef(null),Le=Z.useRef([]),Re=Z.useRef(null),ze=L||m,Be=se??f,H=u===`multiple`,U=u===`single`,Ve=s!==void 0||o!==void 0,He=pe!==void 0,Ue=b!==void 0,We;We=w===`always`?`always`:w?`input-change`:!1;let[Ge,Ke]=kx({controlled:i,default:H?r??Ki:r,name:`Combobox`,state:`selectedValue`}),qe=Z.useMemo(()=>x===null?()=>!0:x===void 0?wS(fe,_e):x,[x,fe,_e]),Je=ka(()=>Ve?o??``:U?ve(Ge):``).current,[Ye,Xe]=kx({controlled:s,default:Je,name:`Combobox`,state:`inputValue`}),[Ze,Qe]=kx({controlled:c,default:l,name:`Combobox`,state:`open`}),$e=tS(pe),et=!Ze&&xe!==null?xe:String(Ye).trim(),tt=U?ve(Ge):``,nt=U&&!ye&&et!==``&&tt.length===et.length&&fe.contains(tt,et),rt=nt?``:S??et,it=He&&Ue&&nt&&(!B||B.hasValue(Ge,A)),at=Z.useMemo(()=>pe?nS(pe):Ki,[pe]),ot=Z.useMemo(()=>{if(b&&!it)return b;if(!pe)return Ki;if($e){let e=pe,t=[],n=0;for(let r of e){if(P>-1&&n>=P)break;let e=P>-1?P-n:1/0,i=rt===``?r.items.slice(0,e):[];if(rt!==``)for(let t of r.items){if(i.length>=e)break;qe(t,rt,_e)&&i.push(t)}if(i.length>0){let e={...r,items:i};t.push(e),n+=i.length}}return t}if(rt===``)return P>-1?at.slice(0,P):at;let e=[];for(let t of at){if(P>-1&&e.length>=P)break;qe(t,rt,_e)&&e.push(t)}return e},[b,it,pe,$e,rt,P,qe,_e,at]),st=Z.useMemo(()=>{if(V&&ot===b)return V.values;let e=nS(ot);return me?e.map(e=>me(e)):e},[ot,b,V,me]),W=ka(()=>{let e=null;return M&&Ze&&He&&u!==`none`&&(e=Xx(st,Ge,A,H)),new ko({id:de,labelId:void 0,selectedValue:Ge,open:Ze,items:he,selectionMode:u,name:Be,form:p,disabled:ze,readOnly:h,required:g,grid:v,virtualized:j,openOnInputClick:C,itemToStringLabel:ge,isItemEqualToValue:A,modal:ee,autoHighlight:We,submitOnItemClick:re,hasInputValue:Ve,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:M,activeIndex:null,selectedIndex:e,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemRoot:{props:Ui,id:de,selectionMode:u,disabled:ze,readOnly:h,isItemEqualToValue:A},positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:u===`none`},{onOpenChangeComplete:ba,setOpen:ba,setInputValue:ba,setSelectedValue:ba,setIndices:ba,handleSelection:ba,forceMount:ba,requestSubmit:ba,listRef:we,labelsRef:Te,popupRef:Ee,emptyRef:Ae,inputRef:De,startDismissRef:Oe,endDismissRef:ke,chipsContainerRef:Me,clearRef:Ne,valuesRef:Le,pointerDownItemRef:Re,selectionEventRef:Pe},oS)}).current,ct=u===`none`?Ye:Ge,lt=Z.useMemo(()=>u===`none`?ct:Array.isArray(Ge)?Ge.map(e=>aS(e,k)):aS(Ge,k),[ct,k,u,Ge]),ut=J(d),dt=J(n),ft=W.useState(`activeIndex`),pt=W.useState(`selectedIndex`),mt=W.useState(`positionerElement`),ht=W.useState(`listElement`),gt=W.useState(`triggerElement`),_t=W.useState(`inputElement`),vt=W.useState(`inputGroupElement`),yt=W.useState(`inline`),bt=W.useState(`inputInsidePopup`),xt=W.useState(`inputOwnsFormValue`),St=U&&!bt&&Ye===tt,Ct=cc(gt),{openMethod:wt,triggerProps:Tt}=MS(Ze),Et=J(()=>lt);gS(bt?Ct:De,de,ct,Et,!ze,f);let Dt=J(()=>{pe?Te.current=st.map(ve):W.set(`forceMounted`,!0)}),Ot=J((e,t,n,r)=>{if(t===-1){if(Fe.current===PS)return;Fe.current=PS}else Fe.current={value:e,index:t};ut(e,Gi(n,r,{index:t}))}),kt=J(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?Ot(void 0,-1,r,e.event):Ot(Le.current[n],n,r,e.event)}),At=J((t,n)=>{if(e.onInputValueChange?.(t,n),!n.isCanceled){if(je.current=n.reason===Yo,n.reason===`input-change`){Ze&&xe!==null&&Se(null);let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&be(!0),Ie.current={hasQuery:e};let n=W.state.listElement;if(!W.state.virtualized&&n){let e=Ee.current;for(let t of Qi(n.firstElementChild??n)){if(!Ka(t)||(e?!X(e,t):t.getAttribute(`role`)===`dialog`))break;if(sc(t)){t.scrollTop=0;break}}}e&&We&&W.state.activeIndex==null&&(Ze||yt)&&W.set(`activeIndex`,0)}}else n.reason===`input-clear`&&t===``&&W.state.inputInsidePopup&&(Ie.current={hasQuery:!1,selection:!0});Xe(t)}}),jt=J(e=>{let t=!e&&bt&&!yt&&Ye!==``&&(String(Ye).trim()===xe||Ye===tt);!e&&(t||Ye===``||St)&&be(!1),Se(null),t&&At(``,Y(Yo))}),[Mt,Nt]=Z.useState(!1),Pt=J((t,n)=>{if(Ze===t)return;n.reason===`escape-key`&&He&&st.length===0&&!Ae.current&&n.allowPropagation();let r=n,i=$c(r);if(e.onOpenChange?.(t,r),Ie.current?.hasQuery&&n.reason===`input-change`===n.isCanceled&&(Ie.current=null),!n.isCanceled&&(t&&xe!==null&&jt(n.reason===vo),!t&&ye&&(U?(yt||Se(et),et===``&&be(!1)):H&&(yt||Se(et),bt&&kt({activeIndex:null}),(!bt||yt)&&At(``,Y(Yo,n.event,void 0,{isItemPress:n.reason===To})))),t||Nt(i()),Qe(t),!t&&bt&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(R(!0),ce(!1),le===`onBlur`))){let e=u===`none`?Ye:Ge;ue.commit(e)}}),Ft=J((e,t)=>{a?.(e,t),!t.isCanceled&&(Ke(e),(u===`none`&&Ee.current&&N||U&&!W.state.inputInsidePopup)&&At(ve(e),Y(t.reason,t.event)))}),It=J((e,t)=>{let n=sa(e),r=Pe.current??e;Pe.current=null;let i=Y(To,r),a=ua(n,`a`)?.getAttribute(`href`);if(a)a.startsWith(`#`)&&Pt(!1,i);else if(H){let e=Array.isArray(Ge)?Ge:[],n=qx(e,t,A),r=n?Qx(e,t,A):[...e,t];if(Ft(r,i),i.isCanceled||!(De.current&&De.current.value.trim()!==``))return;if(W.state.inputInsidePopup){At(``,Y(Yo,i.event,void 0,{isItemPress:!0}));let e=Ie.current;e&&!n&&(e.toggledValue=t)}else Pt(!1,i)}else{if(Ft(t,i),i.isCanceled)return;Pt(!1,i)}}),Lt=J(()=>{let e=ue.inputRef.current?.form??W.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),Rt=J(()=>{if(dt?.(!1),be(!1),Se(null),kt(u===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),H&&De.current&&De.current.value!==``&&!je.current&&At(``,Y(Yo)),U){if(W.state.inputInsidePopup)De.current&&De.current.value!==``&&At(``,Y(Yo));else{let e=ve(Ge);De.current&&De.current.value!==e&&At(e,Y(e===``?Yo:ps))}}}),zt=Z.useMemo(()=>yt&&mt?{current:ua(mt,`[role="dialog"]`)}:Ee,[yt,mt]),{mounted:Bt,transitionStatus:Vt,forceUnmount:Ht}=qc({open:Ze,ref:zt,preventUnmountOnClose:Mt,setPreventUnmountOnClose:Nt,onUnmount:Rt});Z.useImperativeHandle(e.actionsRef,()=>({unmount:Ht,close:()=>Pt(!1,Y(fo))}),[Ht,Pt]),q(function(){let e=Ce.current!==null&&xe===null;if(Ce.current=xe,Ze&&(!e||!He)||(Ze||(Re.current=null),u===`none`))return;let t=He?st:Le.current;kt({selectedIndex:Xx(t,Ge,A,H)})},[Ze,xe,Ge,u,H,He,st,A,kt]),q(()=>{pe&&(Le.current=st,we.current.length=st.length)},[pe,st]),q(()=>{!Ze&&Ie.current?.hasQuery&&(Ie.current=null)},[Ze]),q(()=>{if(!Ze&&yt&&zt.current){Ie.current=null;return}let e=He||Ue?st:Le.current,t=Ie.current;if(t){let n=Ze||yt||W.state.positionerElement?.hidden===!1;if(t.hasQuery){let t=De.current;!We||String(Ye).trim()===``||yt&&We!==`always`&&(!t||$i(t.ownerDocument)!==t)?Ie.current=null:n&&(e[0]!==void 0||!He&&!Ue)&&(W.set(`activeIndex`,0),Ie.current=null)}else if(String(Ye).trim()===``&&(Ie.current=null,n)){let e=t.selection;We===`always`&&!e&&W.state.selectionMode===`none`&&W.set(`activeIndex`,0),queueMicrotask(()=>{if(!W.state.open&&(!W.state.inline||zt.current)||De.current&&De.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=He||Ue?st:Le.current,i=Jx(e,t.toggledValue,W.state.isItemEqualToValue);W.set(`activeIndex`,i===-1?Xx(e,n,W.state.isItemEqualToValue,r):i)}else e?W.set(`activeIndex`,null):We===`always`&&W.set(`activeIndex`,0)})}}if(!Ze&&!yt)return;let n=W.state.activeIndex;if(n==null){if(We===`always`&&e.length>0){W.set(`activeIndex`,0);return}Ot(void 0,-1,ps);return}if(n>=e.length){Ot(void 0,-1,ps),W.set(`activeIndex`,null);return}let r=e[n],i=Fe.current.value,a=i!==NS&&Gx(r,i,W.state.isItemEqualToValue);Fe.current.index===n&&a||Ot(r,n,ps)},[ft,We,Ot,Ue,He,st,yt,Ze,zt,W,Ye]),q(()=>{oe(u===`none`?String(Ye)!==``:H?Array.isArray(Ge)&&Ge.length>0:Ge!=null)},[oe,u,Ye,Ge,H]),Z.useEffect(()=>{He&&We&&st.length===0&&kt({activeIndex:null})},[He,We,st.length,kt]);function Ut(){Ze&&et!==``&&et!==String(Je)&&!St&&be(!0)}function Wt(){Ze&&xe!==null&&jt(!1)}let Gt=!1;function Kt(){!Gt&&Ye!==tt&&(Gt=!0,At(tt,Y(ps)))}function qt(){u!==`none`&&(ie(Be),ae(Kx(Ge,I.initialValue,A)),ue.change(Ge),U&&!Ve&&!bt&&Kt())}function Jt(){U&&!Ve&&!bt&&!ye&&Kt()}function Yt(){u===`none`&&(ie(Be),ae(Ye!==I.initialValue),ue.change(Ye))}AS(et,Ut),AS(Ze,Wt),AS(Ge,qt),AS(tt,Jt),AS(pe,Jt),AS(Ye,Yt);let Xt=hl({open:yt?!0:Ze,onOpenChange:Pt,elements:{reference:bt?gt:_t,floating:mt}}),Zt=v?`grid`:`listbox`,Qt=Ze||yt,$t=Qt?`true`:`false`,en=Z.useMemo(()=>{let e=_t?.tagName===`INPUT`,t=_t==null||e,n=t||Qt,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=$t,r[`aria-haspopup`]=Zt,r[`aria-controls`]=Qt?ht?.id:void 0,r[`aria-autocomplete`]=h?`none`:te),{reference:r,floating:{role:`presentation`}}},[_t,Qt,$t,Zt,ht?.id,te,h]),tn=Vc(Xt,{enabled:!ze&&C,event:`mousedown-only`,toggle:!1,touchOpenDelay:bt?0:100,reason:zo}),nn=Wc(Xt,{enabled:!ze&&!yt,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:yt?!0:void 0,outsidePress(e){let t=sa(e);return!X(gt,t)&&!X(Ne.current,t)&&!X(Me.current,t)&&!X(vt,t)}}),rn=Ll(Xt,{enabled:!ze,id:de,listRef:we,activeIndex:ft,selectedIndex:pt,virtual:!0,loopFocus:D,allowEscape:D&&!We,focusItemOnOpen:ye||u===`none`&&!We?!1:`auto`,focusItemOnHover:E,resetOnPointerLeave:!T,orientation:v?`horizontal`:void 0,rtl:z===`rtl`,disabledIndices:Ki,grid:v?jx:void 0,onNavigate(e,t){(t||Ze||yt&&e===null)&&Vt!==`ending`&&kt({activeIndex:e,type:Mx(t),event:t?.nativeEvent})}}),an=Z.useMemo(()=>Yi(rn.reference,{onKeyDown(e){v&&W.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},nn.reference,tn.reference,en.reference),[rn.reference,nn.reference,tn.reference,en.reference,v,W]),on=Z.useMemo(()=>Yi(Jc,nn.floating),[nn.floating]),sn=Z.useMemo(()=>Yi(rn.floating,en.floating),[rn.floating,en.floating]),cn=Z.useMemo(()=>{let e=rn.item;return{props:e?{...e,onFocus:void 0}:Ui,id:de,selectionMode:u,disabled:ze,readOnly:h,isItemEqualToValue:A}},[rn.item,de,u,ze,h,A]);W.useContextCallback(`setOpen`,Pt),W.useContextCallback(`setInputValue`,At),W.useContextCallback(`setSelectedValue`,Ft),W.useContextCallback(`setIndices`,kt),W.useContextCallback(`handleSelection`,It),W.useContextCallback(`forceMount`,Dt),W.useContextCallback(`requestSubmit`,Lt),W.useContextCallback(`onOpenChangeComplete`,n),Ax(()=>{W.update({inline:M,popupProps:on,listProps:sn,inputProps:an,triggerProps:Tt,itemRoot:cn})});let ln={id:de,selectedValue:Ge,open:Ze,mounted:Bt,transitionStatus:Vt,items:he,inline:M,popupProps:on,listProps:sn,inputProps:an,triggerProps:Tt,itemRoot:cn,openMethod:wt,selectionMode:u,name:Be,form:p,disabled:ze,readOnly:h,required:g,grid:v,virtualized:j,openOnInputClick:C,itemToStringLabel:ge,modal:ee,autoHighlight:We,isItemEqualToValue:A,submitOnItemClick:re,hasInputValue:Ve};q(()=>{W.update({...ln,inputOwnsFormValue:u===`none`&&(M||!W.state.inputInsidePopup)})},[W,...Object.values(ln)]);let un=Fo(_,ue.inputRef),dn=Z.useMemo(()=>({query:et,hasItems:He,filteredItems:ot,flatFilteredValues:st}),[et,He,ot,st]),fn=Z.useMemo(()=>Array.isArray(ct)?``:aS(ct,k),[ct,k]),pn=H&&Array.isArray(Ge)&&Ge.length>0,mn=H||u===`none`&&xt?void 0:Be,hn=Z.useMemo(()=>!H||!Array.isArray(Ge)||!Be?null:Ge.map(e=>{let t=aS(e,k);return(0,Q.jsx)(`input`,{type:`hidden`,form:p,name:Be,value:t,disabled:ze},t)}),[H,Ge,p,Be,k,ze]),gn=(0,Q.jsxs)(Z.Fragment,{children:[e.children,(0,Q.jsx)(`input`,{...ue.getValidationProps(ze,{onFocus(){bt?gt?.focus():(De.current||gt)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||ze||h)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=Y(ps,e.nativeEvent),i=()=>Le.current.findIndex(e=>aS(e,k).toLowerCase()===n||ve(e).toLowerCase()===n);function a(){if(H)return;if(u===`none`){At(t,r);return}let e=i();e===-1&&(e=Le.current.findIndex((e,t)=>{let r=Te.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:Le.current[e];a!=null&&Ft?.(a,r)}U&&(Dt(),pe&&i()===-1&&W.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:de&&mn==null?`${de}-hidden-input`:void 0,form:p,name:mn,autoComplete:F,disabled:ze,required:g&&!pn,readOnly:h,value:fn,ref:un,style:mn?za:Ii,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),hn]});return(0,Q.jsx)(Nx.Provider,{value:W,children:(0,Q.jsx)(Px.Provider,{value:Xt,children:(0,Q.jsx)(Ix.Provider,{value:He,children:(0,Q.jsx)(Fx.Provider,{value:dn,children:(0,Q.jsx)(Lx.Provider,{value:Ye,children:gn})})})})})}function LS(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=OS({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?iS(t,o):``)}return(0,Q.jsx)(IS,{...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 RS=`data-popup-side`,zS=`data-list-empty`,BS={...nc,...fS,popupSide:e=>e?{[RS]:e}:null,listEmpty:e=>e?{[zS]:``}:null};function VS(e,t,n){let{setFocused:r,focusOwnerRef:i}=hS(),a=J(t=>{(t?!e:i.current===a)&&(i.current=t&&a,n?.(t),r(t))});return q(()=>{let e=t.current;return e?.getRootNode()?.activeElement===e&&a(!0),()=>a(!1)},[e,t,a]),a}var HS=5;function US(e,t){let n=WS(t);return e.clientX>=n.left-HS&&e.clientX<=n.right+HS&&e.clientY>=n.top-HS&&e.clientY<=n.bottom+HS}function WS(e){let t=e.getBoundingClientRect(),n=$o(e);if(Xa)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 GS(e,t){return e??t}function KS(e){let t=e.useState(`mounted`),n=e.useState(`popupSide`),r=e.useState(`positionerElement`);return t&&r?n:null}function qS(){return Bx().filteredItems.length===0}function JS(e){return e===`rtl`?[`ArrowRight`,`ArrowLeft`]:[`ArrowLeft`,`ArrowRight`]}function YS(e,t,n){let r=e.context.listRef.current[t];r&&(e.context.selectionEventRef.current=n,r.click(),e.context.selectionEventRef.current=null)}var XS=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:f,validation:p}=hS(),{labelId:m}=xS(),h=Rx(),g=h.useState(`selectionMode`),_=h.useState(`disabled`),v=h.useState(`readOnly`),y=h.useState(`required`),b=h.useState(`positionerElement`),x=h.useState(`listElement`),S=h.useState(`popupId`),C=h.useState(`triggerProps`),w=h.useState(`inputInsidePopup`),T=h.useState(`id`),E=h.useState(`labelId`),D=h.useState(`open`),O=h.useState(`selectedValue`),k=h.useState(`activeIndex`),A=h.useState(`selectedIndex`),j=h.useState(`hasSelectedValue`),M=zx(),N=Vx(),ee=ts(),P=u||_||a,te=qS(),F=KS(h),ne=Z.useRef(null),re=VS(P,ne);SS({id:w?o:void 0});let ie=w?o??T:o,ae=GS(m,E),I;D&&w?I=S??CS(T):D&&(I=x?.id);let oe=Z.useRef(``);function se(e){oe.current=e.pointerType}let{reference:L}=Rl(M,{enabled:!D&&!v&&!_&&g===`single`,listRef:h.context.labelsRef,activeIndex:k,selectedIndex:A,onMatch(e){let t=h.context.valuesRef.current[e];t!==void 0&&h.context.setSelectedValue(t,Y(ps))}}),{reference:R}=Vc(M,{enabled:!_,event:`mousedown`}),{buttonRef:ce,getButtonProps:le}=Pi({native:i,disabled:P}),ue={...l,readOnly:v,open:D,disabled:P,popupSide:F,listEmpty:te,placeholder:g!==`none`&&!j},z=J(e=>{h.set(`triggerElement`,e)});return Pa(`button`,e,{ref:[t,ce,ne,z],state:ue,props:[C,R,L,{id:ie,tabIndex:w?0:-1,role:w?`combobox`:void 0,"aria-expanded":D,"aria-haspopup":w?`dialog`:`listbox`,"aria-controls":I,"aria-required":w&&y||void 0,"aria-readonly":w&&v||void 0,"aria-labelledby":ae,onPointerDown:se,onPointerEnter:se,onFocus(){re(!0),!P&&ee.start(0,h.context.forceMount)},onBlur(e){if(!X(b,e.relatedTarget)&&(d(!0),re(!1),f===`onBlur`)){let e=g===`none`?N:O;p.commit(e)}},onMouseDown(e){if(P||(w||M.set(`domReferenceElement`,e.currentTarget),h.context.forceMount(),oe.current!==`touch`&&(h.context.inputRef.current?.focus(),w||e.preventDefault()),D))return;let t=ma(e.currentTarget);function n(e){let t=h.state.triggerElement;if(!t)return;let n=sa(e),r=h.state.positionerElement,i=h.state.listElement;X(t,n)||X(r,n)||X(i,n)||US(e,t)||h.context.setOpen(!1,Y(Ko,e))}w&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(xa(e),h.context.setOpen(!0,Y(eo,e.nativeEvent)),h.context.inputRef.current?.focus())}},p.getValidationProps(P,c),le],stateAttributesMapping:BS})}),ZS=Z.createContext(void 0);function QS(){return Z.useContext(ZS)}var $S=Z.createContext(void 0);function eC(e){let t=Z.useContext($S);if(t===void 0&&!e)throw Error(Ca(21));return t}var tC=Z.forwardRef(function(e,t){let n=Rx(),{buttonRef:r,getButtonProps:i}=Pi({native:!1}),a=Fo(t,r);function o(e){n.context.setOpen(!1,Y(co,e.nativeEvent,e.currentTarget))}let s=i({onClick:o});return(0,Q.jsx)(`span`,{ref:a,...s,"aria-label":`Dismiss`,tabIndex:void 0,style:za})}),nC=Z.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...s}=e,{state:c,disabled:l,setTouched:u,validationMode:d,validation:f}=hS(),{labelId:p}=xS(),m=QS(),h=!!eC(!0),g=Rx(),_=Vx(),v=Qu(),y=g.useState(`required`),b=g.useState(`disabled`),x=g.useState(`readOnly`),S=g.useState(`name`),C=g.useState(`form`),w=g.useState(`selectionMode`),T=g.useState(`autoHighlight`),E=g.useState(`inputProps`),D=g.useState(`triggerProps`),O=g.useState(`open`),k=g.useState(`mounted`),A=g.useState(`selectedValue`),j=g.useState(`id`),M=g.useState(`inline`),N=g.useState(`modal`),ee=!!T,P=KS(g),te=l||b||i,F=qS(),ne=VS(te,g.context.inputRef),re=h||M,ie=!re||N,ae=yS(a??(re?void 0:j)),I=h?uS:c,[oe,se]=Z.useState(null),L=Z.useRef(!1),R=Z.useRef(null);q(()=>{O||(R.current=null)},[O]);let ce=w===`none`&&!h,le=J(e=>{let t=h||g.state.inline;t&&!g.state.hasInputValue&&g.context.setInputValue(``,Y(ps)),g.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:ce})}),ue=h?s:f.getValidationProps(te,s);function z(e){g.context.setIndices({activeIndex:null,selectedIndex:null,type:Mx(e),event:e})}let de={...I,open:O,disabled:te,readOnly:x,popupSide:P,listEmpty:F};function fe(e){if(!m)return;let t,n=m.chipsRef.current.length,[r]=JS(v);return e.key===r&&(e.currentTarget.selectionStart??0)===0&&A.length>0&&(e.preventDefault(),t=n>0?n-1:void 0),t}let B=Pa(`input`,e,{state:de,ref:[t,g.context.inputRef,le],props:[E,D,{value:oe??_,"aria-readonly":x||void 0,"aria-required":y||void 0,"aria-labelledby":p,disabled:te,readOnly:x,required:w===`none`?y:void 0,form:C,...ce&&S&&{name:S},id:ae,onFocus(){if(ne(!0),!M)return;let e=R.current;R.current=null,e!=null&&Object.hasOwn(g.context.valuesRef.current,e)&&g.context.setIndices({activeIndex:e})},onBlur(){u(!0),ne(!1);let e=g.state.activeIndex;if(M&&e!==null&&T!==`always`&&(R.current=e,g.context.setIndices({activeIndex:null})),d===`onBlur`){let e=w===`none`?_:A;f.commit(e)}},onCompositionStart(e){Mi||(L.current=!0,se(e.currentTarget.value))},onCompositionEnd(e){L.current=!1;let t=e.currentTarget.value;se(null),g.context.setInputValue(t,Y(vo,e.nativeEvent))},onChange(e){let t=e.nativeEvent,n=t.inputType,r=!n||n===`insertReplacementText`,i=L.current||!r;function a(e){!x&&!te&&e&&i&&(g.context.setOpen(!0,Y(vo,t)),ee||z(t))}if(L.current){let n=e.currentTarget.value;se(n),n===``&&!g.state.openOnInputClick&&!g.state.inputInsidePopup&&g.context.setOpen(!1,Y(Yo,t));let r=n.trim(),i=ee&&r!==``;a(r),O&&g.state.activeIndex!==null&&!i&&z(t);return}let o=Y(vo,t);if(g.context.setInputValue(e.currentTarget.value,o),o.isCanceled)return;let s=e.currentTarget.value===``,c=Y(Yo,t);s&&!g.state.inputInsidePopup&&(w===`single`&&g.context.setSelectedValue(null,c),g.state.openOnInputClick||g.context.setOpen(!1,c)),a(e.currentTarget.value.trim()),O&&g.state.activeIndex!==null&&!ee&&z(t)},onKeyDown(e){if(e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;if(te||x){x&&e.key===`Enter`&&O&&g.state.activeIndex!==null&&xa(e);return}let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=v===`rtl`;if(e.key===`Home`){xa(e);let n=$a&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){xa(e);let i=$a&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!k&&e.key===`Escape`){let t=w===`multiple`&&Array.isArray(A)?A.length===0:A===null,n=Y(Lo,e.nativeEvent),r=w===`multiple`?[]:null;g.context.setInputValue(``,n),g.context.setSelectedValue(r,n),t||g.state.inline||n.isPropagationAllowed||e.stopPropagation();return}if(m&&e.key===`Backspace`&&t.value===``&&Array.isArray(A)&&A.length>0){let t=m.chipsRef.current.length,n=t>0?t-1:A.length-1,r=A.filter((e,t)=>t!==n);z(e.nativeEvent),g.context.setSelectedValue(r,Y(ps,e.nativeEvent));return}let i=fe(e);if(i!==void 0&&m?.chipsRef.current[i]?.focus(),e.which!==229&&e.key===`Enter`&&O){let t=g.state.activeIndex,n=e.nativeEvent;if(t===null){if(M)return;g.context.setOpen(!1,Y(ps,n));return}xa(e),YS(g,t,n)}}},ue],stateAttributesMapping:BS}),pe=h?(0,Q.jsx)(mS.Provider,{value:pS,children:B}):B;return(0,Q.jsxs)(Z.Fragment,{children:[O&&ie&&(0,Q.jsx)(tC,{ref:g.context.startDismissRef}),pe]})}),rC={...Es,...tc},iC=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}=hS(),u=Rx(),d=u.useState(`selectionMode`),f=u.useState(`disabled`),p=u.useState(`readOnly`),m=u.useState(`open`),h=u.useState(`selectedValue`),g=u.useState(`hasSelectionChips`),_=Vx(),v=!1;v=d===`none`?_!==``:d===`single`?h!=null:g;let y=l||f||i,{buttonRef:b,getButtonProps:x}=Pi({native:a,disabled:y}),{mounted:S,transitionStatus:C,setMounted:w}=Kc(v),T={disabled:y,visible:v,open:m,transitionStatus:C};ga({open:v,ref:u.context.clearRef,onComplete(){v||w(!1)}});let E=Pa(`button`,e,{state:T,ref:[t,b,u.context.clearRef],props:[{tabIndex:-1,children:`x`,onMouseDown(e){e.preventDefault()},onClick(e){if(y||p)return;let t=Mx(e);u.context.setInputValue(``,Y(is,e.nativeEvent)),d===`none`?u.context.setIndices({activeIndex:null,type:t,event:e.nativeEvent}):(u.context.setSelectedValue(Array.isArray(h)?[]:null,Y(is,e.nativeEvent)),u.context.setIndices({activeIndex:null,selectedIndex:null,type:t,event:e.nativeEvent})),u.context.inputRef.current?.focus()}},c,x],stateAttributesMapping:rC});return o||S?E:null}),aC=Z.createContext(null);function oC(){return Z.useContext(aC)}function sC(e){let{children:t}=e,{filteredItems:n}=Bx(),r=oC(),i=r?r.items:n;return(0,Q.jsx)(Z.Fragment,{children:i.map(t)})}var cC=Z.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function lC(){return Z.useContext(cC)}function uC(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=J(i),[,o]=Z.useState(0),s=ka(fC).current,c=ka(dC).current,l=Z.useRef(0),u=Z.useRef(!0),d=Z.useRef(null),f=Z.useRef(null),p=J(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=J((e,t)=>{c.set(e,t),p()}),h=J(e=>{c.delete(e),p()}),g=J(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(!hC(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&gC(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=mC(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=J(()=>{let[e,t]=pC(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))});q(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),q(()=>{u.current&&v()}),q(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=J(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)(cC.Provider,{value:b,children:t})}function dC(){return new Map}function fC(){return new Set}function pC(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)=>gC(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 mC(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function hC(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 gC(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var _C=Z.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=Rx(),l=zx(),u=!!eC(!0),{filteredItems:d,hasItems:f}=Bx(),p=c.useState(`selectionMode`),m=c.useState(`grid`),h=c.useState(`readOnly`),g=c.useState(`listProps`),_=c.useState(`virtualized`),v=c.useState(`forceMounted`),y=p===`multiple`,b=d.length===0,x=J(e=>{c.set(`positionerElement`,e)}),S=J(e=>{c.set(`listElement`,e)}),C=Z.useMemo(()=>typeof o==`function`?n||=(0,Q.jsx)(sC,{children:o}):o,[o]),w={empty:b},T=l.useState(`floatingId`),E=Pa(`div`,e,{state:w,ref:[t,S,u?null:x],props:[g,{children:C,tabIndex:-1,id:T,role:m?`grid`:`listbox`,"aria-multiselectable":y?`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;xa(e),YS(c,t,e.nativeEvent)}}},s]});if(_)return E;let D=f&&!v?void 0:c.context.labelsRef;return(0,Q.jsx)(uC,{elementsRef:c.context.listRef,labelsRef:D,children:E})}),vC=Z.createContext(void 0);function yC(){let e=Z.useContext(vC);if(e===void 0)throw Error(Ca(20));return e}var bC=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=Rx(),a=i.useState(`mounted`),o=i.useState(`forceMounted`);return a||n||o?(0,Q.jsx)(vC.Provider,{value:n,children:(0,Q.jsx)(es,{ref:t,...r})}):null}),xC=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}})}),SC={},CC={},wC=``;function TC(e,t){return Ea(e)?e:t}function EC(e,t,n){return/hidden|clip/.test(e.getComputedStyle(TC(t,n)).overflowY)}function DC(e){if(typeof document>`u`)return!1;let t=ma(e);return $o(t).innerWidth-t.documentElement.clientWidth>0}function OC(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=ma(e),n=t.documentElement,r=t.body,i=TC(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 kC(e){let t=ma(e),n=t.documentElement,r=t.body,i=TC(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 AC(e){let t=ma(e),n=t.documentElement,r=t.body,i=$o(n),a=0,o=0,s=!1,c=ra.create();if(Da&&(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,SC={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},wC=n.style.scrollBehavior,CC={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=TC(n,r);s=OC(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,SC),Object.assign(r.style,CC),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=wC)}function d(){u(),c.request(l)}l();let f=Ia(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var jC=new class{lockCount=0;restore=null;timeoutLock=Uo.create();timeoutUnlock=Uo.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=ma(e),n=t.documentElement,r=t.body,i=$o(n);if(EC(i,n,r)){let t=new i.MutationObserver(()=>{EC(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=ho||!DC(e);this.restore=a?kC(e):AC(e)}};function MC(e=!0,t=null){q(()=>{if(e)return jC.acquire(t)},[e,t])}var NC=20;function PC(e,t,n,r){let[i,a]=Z.useState(!1);q(()=>{if(!e||!t||n==null){a(!1);return}let r=ma(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-NC)},[e,t,n]),MC(e&&(!t||i),r)}var FC=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=Mo,style:g,..._}=e,v=Rx(),y=zx(),b=yC(),x=v.useState(`modal`),S=v.useState(`open`),C=v.useState(`mounted`),w=v.useState(`openMethod`),T=v.useState(`positionerElement`),E=v.useState(`triggerElement`),D=v.useState(`inputElement`),O=v.useState(`inputGroupElement`),k=v.useState(`inputInsidePopup`),A=v.useState(`transitionStatus`),j=qS(),M=fd({anchor:i??(k?E:O??D),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});PC(S&&x,w===`touch`,T,E);let N={open:S,side:M.side,align:M.align,anchorHidden:M.anchorHidden,empty:j};q(()=>{v.set(`popupSide`,M.side)},[v,M.side]);let ee=J(e=>{v.set(`positionerElement`,e)}),P=gd(e,N,{styles:M.positionerStyles,transitionStatus:A,props:_,refs:[t,ee],hidden:!C,inert:!S});return(0,Q.jsxs)($S.Provider,{value:M,children:[C&&x&&(0,Q.jsx)(xC,{inert:Oa(!S),cutout:O??D??E}),P]})}),IC={...rc,...Es},LC=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=Rx(),l=eC(),u=zx(),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`),v=c.useState(`modal`),y=c.useState(`id`),b=qS(),x=s.id??(g?CS(y):void 0);q(()=>(c.set(`popupId`,c.context.popupRef.current?.id||x),()=>{c.set(`popupId`,void 0)}),[c,x]),ga({open:f,ref:c.context.popupRef,onComplete(){f&&c.context.onOpenChangeComplete(!0)}});let S={open:f,side:l.side,align:l.align,anchorHidden:l.anchorHidden,transitionStatus:h,empty:b},C=Pa(`div`,e,{state:S,ref:[t,c.context.popupRef],props:[m,{id:x,role:g?`dialog`:`presentation`,onFocus(e){let t=sa(e.nativeEvent);p!==`touch`&&(X(c.state.listElement,t)||t===e.currentTarget)&&c.context.inputRef.current?.focus()}},hd(h),s],stateAttributesMapping:IC}),w=a===void 0?g?e=>e===`touch`?c.context.popupRef.current:_:!1:a,T;T=o??(g?void 0:!1);let E=!g||v;return(0,Q.jsx)(Bc,{context:u,disabled:!d,modal:E,openInteractionType:p,initialFocus:w,returnFocus:T,getInsideElements:()=>[c.context.startDismissRef.current,c.context.endDismissRef.current],children:(0,Q.jsxs)(Z.Fragment,{children:[C,E&&(0,Q.jsx)(tC,{ref:c.context.endDismissRef})]})})});function RC(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=lC(),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 q(()=>{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 zC=Z.createContext(void 0);function BC(){let e=Z.useContext(zC);if(!e)throw Error(Ca(19));return e}var VC=Z.createContext(!1);function HC(){return Z.useContext(VC)}function UC(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=RC({guess:!0,index:l,textRef:p}),h=Rx(),g=HC(),_=Hx(),{props:v,id:y,selectionMode:b,disabled:x,readOnly:S,isItemEqualToValue:C}=h.useState(`itemRoot`),w=x||u,T=b!==`none`,E=l??i??m.index,D=E!==-1,O=h.useState(`isActive`,E),k=h.useState(`isSelected`,c),A=Z.useRef(null),j=y!=null&&D?`${y}-${E}`:void 0,M=k&&T;q(()=>{if(!D||!r&&l==null)return;let e=h.context.listRef.current;return e[E]=A.current,()=>{delete e[E]}},[D,r,E,l,h]),q(()=>{if(!D||_)return;let e=h.context.valuesRef.current;return e[E]=c,()=>{delete e[E]}},[D,_,E,c,h]),q(()=>{if(!D||_)return;let e=h.state.selectedValue,t=h.state.selectedIndex;h.state.selectionMode===`multiple`&&Array.isArray(e)?t=Zx(E,c,h.context.valuesRef.current,e,C,t):Gx(c,e,C)&&(t=E),h.set(`selectedIndex`,t)},[D,_,h,E,c,C]);let{getButtonProps:N,buttonRef:ee}=Pi({disabled:w,focusableWhenDisabled:!0,native:d,composite:!0}),P={disabled:w,selected:M,highlighted:O};function te(e){function t(){h.context.handleSelection(e,c)}h.state.submitOnItemClick?(Gs.flushSync(t),h.context.requestSubmit()):t()}let F={id:j,role:g?`gridcell`:`option`,"aria-selected":T?M:void 0,tabIndex:void 0,onPointerDownCapture(e){e.isPrimary&&(h.context.pointerDownItemRef.current=e.currentTarget),e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){w||S||te(e.nativeEvent)},onMouseUp(e){let t=h.context.pointerDownItemRef.current===e.currentTarget;h.context.pointerDownItemRef.current=null,!(w||S||e.button!==0||t||!O)&&te(e.nativeEvent)}},ne=Pa(`div`,t,{ref:[ee,n,m.ref,A],state:P,props:[v,F,f,N]}),re=Z.useMemo(()=>({selected:M,textRef:p}),[M,p]);return(0,Q.jsx)(zC.Provider,{value:re,children:ne})}function WC(e){let{componentProps:t,forwardedRef:n}=e,r=Rx().useState(`isItemEqualToValue`),{flatFilteredValues:i}=Bx(),a=Jx(i,t.value??null,r);return(0,Q.jsx)(UC,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:a})}var GC=Z.memo(Z.forwardRef(function(e,t){let n=Rx().useState(`virtualized`);return n&&e.index==null?(0,Q.jsx)(WC,{componentProps:e,forwardedRef:t}):(0,Q.jsx)(UC,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})}));function KC(e){return Pa(e.defaultTagName??`div`,e,e)}var qC=Z.createContext(void 0);function JC(){let e=Z.useContext(qC);if(e===void 0)throw Error(Ca(13));return e}var YC={imageLoadingStatus:()=>null},XC=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=Pa(`span`,e,{state:c,ref:t,props:a,stateAttributesMapping:YC});return(0,Q.jsx)(qC.Provider,{value:l,children:u})});function ZC(e,{referrerPolicy:t,crossOrigin:n,sizes:r,srcSet:i},a){let o=Z.useState(`idle`),s=o[1];return q(()=>{if(!a)return ba;if(!e&&!i)return s(`error`),ba;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 QC={...YC,...Es},$C=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}=JC(),[f,p]=ZC(l,e,!a),m=f===`loaded`,{mounted:h,transitionStatus:g,setMounted:_}=Kc(m),v=Z.useRef(null),y=Z.useRef(!0);q(()=>{if(!a)return;let e=y.current;y.current=!1;let t=v.current;if(!t)return;if(!t.complete){p(`loading`);return}let n=t.naturalWidth>0?`loaded`:`error`;p(n),n===`loaded`&&e&&_(!0)},[a,l,c,s,u.crossOrigin,u.referrerPolicy,r,p,_]);let b=a?{"data-loading":f===`loading`?``:void 0,"data-error":f===`error`?``:void 0,"aria-hidden":f!==`loaded`||void 0,onLoad(){p(`loaded`)},onError(){p(`error`)}}:void 0,x=J(e=>{i?.(e),d(e)});q(()=>{f!==`idle`&&x(f)},[f,x]),q(()=>()=>d(`idle`),[d]),ga({enabled:!m,open:m,ref:v,onComplete(){m||_(!1)}});let S={imageLoadingStatus:f,transitionStatus:a&&g===`ending`?void 0:g},C=a||h,w={};s!==void 0&&(w.sizes=s),c!==void 0&&(w.srcSet=c),l!==void 0&&(w.src=l);let T=Pa(`img`,e,{state:S,ref:[t,v],props:[b,u,w],stateAttributesMapping:QC,enabled:C});return C?T:null}),ew=Z.forwardRef(function(e,t){let{className:n,render:r,delay:i=0,style:a,...o}=e,{imageLoadingStatus:s}=JC(),[c,l]=Z.useState(i===0),u=ts();return Z.useEffect(()=>(i>0?u.start(i,()=>l(!0)):l(!0),u.clear),[u,i]),Pa(`span`,e,{state:{imageLoadingStatus:s},ref:t,props:o,stateAttributesMapping:YC,enabled:s!==`loaded`&&(i===0||c)})});function tw(e){let t=(0,Ks.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=ns(`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)(XC,{"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 nw(e){let t=(0,Ks.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=ns(`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)($C,{"data-slot":`avatar-image`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function rw(e){let t=(0,Ks.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=ns(`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)(ew,{"data-slot":`avatar-fallback`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var iw=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}=Kc(o),d=Pa(`span`,e,{ref:[t,c],state:{selected:o,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},s],stateAttributesMapping:Es});return ga({batch:!0,enabled:!o,open:o,ref:c,onComplete(){o||u(!1)}}),d})),aw=Z.forwardRef(function(e,t){let{selected:n}=BC();return e.keepMounted||n?(0,Q.jsx)(iw,{...e,selected:n,ref:t}):null}),ow=Z.createContext(void 0);function sw(e=!0){let t=Z.useContext(ow);if(t===void 0&&!e)throw Error(Ca(25));return t}var cw=Z.createContext(void 0);function lw(e){let t=Z.useContext(cw);if(t===void 0&&!e)throw Error(Ca(33));return t}var uw=Z.createContext(void 0);function dw(e){let t=Z.useContext(uw);if(t===void 0&&!e)throw Error(Ca(36));return t}var fw=Z.createContext(null);function pw(e=`root`){let t=Z.useContext(fw),n=Z.useContext(uw);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var mw={visible:!0,ref:null};function hw(){return mw}function gw(e,t,n=`root`){let r=pw(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??hw)({label:e.label,children:e.children,render:e.render}),a=Fo(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}function _w(e){e.preventDefault()}function vw(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=dw(),u=sw(!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?_w: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:To})},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&&!cs&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&No(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var yw={type:`regular-item`};function bw(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}=Pi({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=vw({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=Z.useCallback(e=>Yi(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=Fo(u,f);return Z.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var xw=Z.createContext(void 0);function Sw(){let e=Z.useContext(xw);if(e===void 0)throw Error(Ca(31));return e}var Cw=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Z.useState(void 0),c=Pa(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,Q.jsx)(xw.Provider,{value:s,children:c})}),ww=Z.forwardRef(function(e,t){let n=pw()?.Group??Cw;return(0,Q.jsx)(n,{...e,ref:t})}),Tw=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=yS(a),c=Sw();return q(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Pa(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),Ew=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}=dw(),f=RC({guess:!0,label:a}),p=yS(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=bw({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:yw});return Pa(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),Dw=Z.forwardRef(function(e,t){let n=gw(e,t);return n.visible?(0,Q.jsx)(Ew,{...e,ref:n.ref}):null}),Ow=Z.createContext(void 0);function kw(e){let t=Z.useContext(Ow);if(t===void 0&&!e)throw Error(Ca(69));return t}var Aw=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),jw=Z.createContext(void 0);function Mw(){return Z.useContext(jw)}function Nw(e,t){let n=gs(e.render);if(Z.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function Pw(e,t,n){let r=Nw(e,t),i=r===t?void 0:r;return[r,Z.useCallback(e=>n?.(e?i:void 0),[i,n])]}function Fw(e,t,n){let r=gs(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 Iw=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}=dw(),m=Mw(),{side:h,align:g}=lw(),_=kw(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),S=l.useState(`instantType`),C=l.useState(`activeTriggerElement`),w=l.useState(`parent`),T=l.useState(`lastOpenChangeReason`),E=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),k=l.useState(`closeDelay`),A=l.useState(`hoverEnabled`),j=l.useState(`disabled`),M=l.useState(`openMethod`),N=l.useState(`activeTriggerId`),ee=l.useState(`listElement`),[P,te]=Pw(e,u,d),F=Fw(e,C,N),ne=w.type===`menu`?m:void 0,re=w.type===`context-menu`,ie=s??w.type!==`menu`;s===void 0&&ee&&w.type!==`menu`&&(ie=()=>l.state.activeIndex===null&&ee),ga({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),Z.useEffect(()=>{function e(e){l.setOpen(!1,Y(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),Ol(D,{enabled:A&&!j&&!re&&w.type!==`menubar`,closeDelay:k});let ae=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:I,handleFocus:oe}=(Z.useContext(fw)?.useParentHandoff??Rw)(l,w,v,f),se={transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},L=Pa(`div`,e,{state:se,ref:[t,l.context.popupRef,ae,te],stateAttributesMapping:ic,props:[b,{id:P,...ee?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":F},onKeyDown(e){ne?.onPopupKeyDown?.(e),_&&Aw.has(e.key)&&e.stopPropagation()},onFocus:oe},hd(y),c,{"data-rootownerid":E}]}),R=w.type===void 0||re;(C||w.type===`menubar`&&T!==`outside-press`)&&(R=!0);let ce=ne?.getReturnElement??I;return(0,Q.jsx)(Bc,{context:D,openInteractionType:M,modal:re,disabled:!x,returnFocus:a??ce??R,explicitReturnFocus:a===void 0&&ce?!1:void 0,initialFocus:ie,restoreFocus:!0,getInsideElements:w.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:w.type===`menubar`?void 0:O,previousFocusableElement:C,nextFocusableElement:w.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:L})}),Lw={parentVirtualFocusRef:void 0,handleFocus:void 0};function Rw(){return Lw}var zw=Z.forwardRef(function(e,t){let n=pw()?.Popup??Iw;return(0,Q.jsx)(n,{...e,ref:t})}),Bw=Z.createContext(void 0);function Vw(){let e=Z.useContext(Bw);if(e===void 0)throw Error(Ca(32));return e}var Hw=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=dw();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Q.jsx)(Bw.Provider,{value:n,children:(0,Q.jsx)(es,{ref:t,...r,portalOwnerRole:o})})});function Uw(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=Z.useRef(null),o=Z.useRef(null),s=Sa(r);q(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),q(()=>{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 Ww=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=Mo,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=dw(),x=Vw(),S=sw(!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`),te=v.useState(`floatingNodeId`),F=v.useState(`floatingParentNodeId`),ne=w.useState(`domReferenceElement`),re=n,ie=c,ae=l,I=s,oe=h;C.type===`context-menu`&&(re=n??C.context?.anchor,I??=`start`,!o&&I!==`center`&&(ae=e.alignOffset??2,ie=e.sideOffset??-5));let se=o,L=I;C.type===`menu`?(se??=`inline-end`,L??=`start`,oe=e.collisionAvoidance??pa):C.type===`menubar`&&(se??=C.context.orientation===`vertical`?`inline-end`:`bottom`,L??=`start`);let R=C.type===`context-menu`,ce=fd({anchor:re,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:se,sideOffset:ie,align:L,alignOffset:ae,arrowPadding:R?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:te,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:oe,shift:R?{crossAxis:!(`side`in oe&&oe.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:ee,lazyFlip:y?`placement`:!1});Z.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===te&&v.set(`hoverEnabled`,!1),e.nodeId!==te&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,Y(vs)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,te]),Z.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,Y(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let le=ts();Z.useEffect(()=>{D||le.clear()},[D,le]),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?le.isStarted()||le.start(e,()=>{v.setOpen(!1,Y(vs))}):v.setOpen(!1,Y(vs))}else le.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,le]),Z.useEffect(()=>{let e={open:D,nodeId:te,parentNodeId:F,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,te,F]),Uw({store:v,domReference:ne,positionerElement:M,open:D});let ue={open:D,side:ce.side,align:ce.align,anchorHidden:ce.anchorHidden,nested:C.type===`menu`,instant:N},z=C.type===`menubar`&&C.context.modal;PC(D&&(z||O&&P!==`trigger-hover`),k===`touch`,M,A);let de=gd(e,ue,{styles:ce.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),B=null;return C.type===`menubar`?B=C.context.contentElement:C.type===void 0&&(B=A),(0,Q.jsxs)(cw.Provider,{value:ce,children:[fe&&(0,Q.jsx)(xC,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:Oa(!D),cutout:B}),(0,Q.jsx)(Ac,{id:te,children:(0,Q.jsx)(uC,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:de})})]})}),Gw=Z.createContext(null);function Kw(e){let t=Z.useContext(Gw);if(t===null&&!e)throw Error(Ca(5));return t}var qw={...pl,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=pl.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>Da&&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`&&!pl.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`)}},Jw=class extends ko{constructor(e,t,n=!1){let r=new il,i=Xw(r,t,n,e);super(i,Yw(r),qw),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 Yw(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 Xw(e,t,n=!1,r){return{...sl(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:Ui,inputProps:Ui,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new wc,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Ui,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var Zw=Z.createContext(null);function Qw(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function $w(e,t){return e===`list-navigation`||Qw(e,t)}var eT=ro(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=sw(!0),C=dw(!0),w=Kw(!0),T=C?.store,E=C?.virtualFocus??!1,D=Z.useMemo(()=>_&&T?{type:`menu`,store:T}:w?{type:`menubar`,context:w}:S&&!T?{type:`context-menu`,context:S}:{type:void 0},[S,T,w,_]),O=yS(),k=yS(),[A,j]=Z.useState(void 0),M=(A??k)||void 0,N=Dc(),ee=D.type===`menu`?D.store:void 0,P=(n??o)&&ee?.state.transitionStatus===`starting`,te=ka(()=>P?ee?.state.instantType:void 0).current,F=ka(()=>{let e=new Jw({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:D,disabled:s,highlightItemOnHover:g,modal:D.type===void 0?c:void 0,rootId:O,instantType:te},M,N!=null);return e.context.virtualFocusRef=y,e}).current;F.useControlledProp(`openProp`,n),F.useControlledProp(`triggerIdProp`,m),F.useContextCallback(`onOpenChangeComplete`,i);let ne=F.useState(`floatingTreeRoot`),re=kc(ne),ie=F.useState(`open`),ae=F.useState(`activeTriggerElement`),I=F.useState(`positionerElement`),oe=F.useState(`hoverEnabled`),se=F.useState(`disabled`),L=F.useState(`lastOpenChangeReason`),R=F.useState(`parent`),ce=F.useState(`activeIndex`),le=F.useState(`keyboardOpen`),ue=F.useState(`payload`),z=F.useState(`floatingParentNodeId`),de=Z.useRef(null),fe=Z.useRef(R.type!==`context-menu`),B=ts(),pe=Z.useRef(!0),me=ts(),he=z!=null,{openMethod:V,triggerProps:ge}=MS(ie);F.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:R.type===void 0?c:void 0,openMethod:V,rootId:O}),tl(F);let{forceUnmount:_e,transitionStatus:ve}=nl(ie,F,()=>{F.set(`allowMouseEnter`,!1)},P),ye=Sa(F.context.popupRef);Z.useEffect(()=>{if(te===void 0)return;let e=()=>{F.state.instantType===te&&F.set(`instantType`,void 0)};if(!ie){e();return}if(ve!==void 0)return;if(F.context.popupRef.current==null){e();return}let t=new AbortController;return ye(e,t.signal),()=>{t.abort()}},[te,ie,ve,ye,F]),q(()=>{S&&!C?F.update({parent:{type:`context-menu`,context:S},floatingNodeId:re,floatingParentNodeId:N}):(C||!F.select(`activeTriggerElement`))&&F.update({floatingNodeId:re,floatingParentNodeId:N})},[S,C,re,N,ae,F]),Z.useEffect(()=>{ie||(de.current=null),R.type===`context-menu`&&(ie?B.start(500,()=>{fe.current=!0}):(B.clear(),fe.current=!1))},[B,ie,R.type]),q(()=>{!ie&&!oe&&F.set(`hoverEnabled`,!0)},[ie,oe,F]);let be=J((e,t)=>{let n=t.reason;if(!e&&!F.select(`open`)||ie===e&&t.trigger===ae&&L===n)return;let i=$c(t);if(!e&&t.trigger==null&&(t.trigger=ae??void 0),r?.(e,t),t.isCanceled)return;F.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!pe.current)return;e&&n===`trigger-focus`?(pe.current=!1,me.start(300,()=>{pe.current=!0})):(pe.current=!0,me.clear());let o=!e&&(n===`escape-key`||n==null);de.current=t.event;let s=Qc(F.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&$w(n,a),s.instantType=R.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:Qw(n,a)?`click`:o?`dismiss`:void 0,F.update(s)}),xe=Gc({popupStore:F,floatingRootContext:F.state.floatingRootContext,floatingId:M,nested:N!=null,onOpenChange:be}),Se=xe.context.events;q(()=>{let e=({open:e,eventDetails:t})=>be(e,t);return Se.on(`setOpen`,e),()=>{Se?.off(`setOpen`,e)}},[Se,be]),q(()=>F.subscribeToParentMenu(),[F]);let Ce=Z.useCallback(()=>{F.setOpen(!1,Y(fo))},[F]);Z.useImperativeHandle(d,()=>({unmount:_e,close:Ce}),[_e,Ce]);let we;R.type===`context-menu`&&(we=R.context),Z.useImperativeHandle(we?.positionerRef,()=>I,[I]),Z.useImperativeHandle(we?.actionsRef,()=>({setOpen:be}),[be]);let Te=Wc(xe,{enabled:!se,bubbles:{escapeKey:f&&R.type===`menu`},outsidePress(){return R.type!==`context-menu`||de.current?.type===`contextmenu`||fe.current},externalTree:he?ne:void 0}),Ee=Qu(),De=Ll(xe,{enabled:!se,listRef:F.context.itemDomElements,activeIndex:ce,virtual:v,nested:R.type===`menubar`||!v&&R.type!==void 0,parentOrientation:R.type===`menubar`?R.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?le:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:Ee===`rtl`,disabledIndices:Ki,onNavigate(e,t){F.setActiveIndex(e,Mx(t),t?.nativeEvent)},openOnArrowKeyDown:R.type!==`context-menu`&&!(v&&_),externalTree:!v&&he?ne:void 0,nestedReturnFocusRef:ee?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),Oe=Z.useCallback(e=>{F.context.typingRef.current=e},[F]),ke=Rl(xe,{enabled:!se&&!v,listRef:F.context.itemLabels,elementsRef:F.context.itemDomElements,activeIndex:ce,resetMs:500,onMatch:(e,t)=>{ie&&e!==ce&&F.setActiveIndex(e,So,t.nativeEvent)},onTyping:Oe}),Ae=J(a),je=Z.useRef(-1),Me=J(()=>{let e=F.state.activeIndex,t=e===null?void 0:F.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(je.current===n&&F.context.reportedItem===t)return;je.current=n,F.context.reportedItem=t,v&&F.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=F.context;F.context.highlightReason=ps,F.context.highlightEvent=void 0,a&&Ae(t,Gi(r,i,{label:t===void 0?void 0:F.context.itemLabels.current[n]??void 0}))});q(()=>{Me()},[ce,Me]);let Ne=Z.useMemo(()=>{if(!v)return De.reference;if(!De.trigger)return Ui;let{onFocus:e,...t}=De.trigger;return t},[v,De.reference,De.trigger]);F.useSyncedValue(`inputProps`,v?De.reference??Ui:Ui);let Pe=Z.useMemo(()=>{let e=Yi(ke.reference,Ne,Te.reference,{onMouseMove(){F.set(`allowMouseEnter`,!0)}},ge);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=ie,e},[F,ke.reference,Ne,Te.reference,ge,ie]),Fe=Z.useMemo(()=>{let e=Yi(De.trigger,Te.trigger,ge);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[De.trigger,Te.trigger,ge]);ka(()=>(F.update({inactiveTriggerProps:Fe}),null)),rl(F,{floatingRootContext:xe,activeTriggerProps:Pe,inactiveTriggerProps:Fe,popupProps:Z.useMemo(()=>Yi(Jc,{onMouseMove(){F.set(`allowMouseEnter`,!0),R.type===`menu`&&F.set(`hoverEnabled`,!1)},onClick(){F.select(`hoverEnabled`)&&F.set(`hoverEnabled`,!1)},onKeyDown(e){let t=F.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},ke.floating,De.floating,Te.floating),[R.type,F,ke.floating,De.floating,Te.floating]),itemProps:De.item??Ui});let Ie=Z.useMemo(()=>({store:F,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:Me}),[F,D,u,l,b,k,v,E,Me]),Le=typeof t==`function`?t({payload:ue}):t,Re=(0,Q.jsxs)(uw.Provider,{value:Ie,children:[p&&(0,Q.jsx)(Yc,{handle:p,store:F}),Le]});return(R.type===void 0||R.type===`context-menu`)&&(Re=(0,Q.jsx)(jc,{externalTree:ne,children:Re})),Re});function tT(e){let t=Z.useContext(Zw);if(t===null)return(0,Q.jsx)(eT,{...e});let n=t.Root;return(0,Q.jsx)(Zw.Provider,{value:null,children:(0,Q.jsx)(n,{...t.options,...e})})}var nT={};function rT(e){dw();let t=Z.useContext(Zw);if(t!==null){let n=t.SubmenuRoot;return(0,Q.jsx)(Zw.Provider,{value:null,children:(0,Q.jsx)(n,{...t.options,...e})})}return(0,Q.jsx)(jw.Provider,{value:nT,children:(0,Q.jsx)(eT,{...e,isSubmenu:!0})})}function iT(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=_a(),{ref:i,index:a}=RC(e),o=n===a,s=Z.useRef(null),c=Fo(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 aT(e){let{render:t,className:n,style:r,state:i=Ui,props:a=Ki,refs:o=Ki,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=iT({metadata:s});return Pa(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function oT(e){if(Ka(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Qa(e))return oT(la(e))}function sT(e,t){function n(n,r,i){let a=n.currentTarget;Gs.flushSync(()=>{e.setOpen(!1,Y(ds,n.nativeEvent,a))}),Qo(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&&aa(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function cT(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,ma(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:Ui,[t,n,r])}var lT=qo(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=dw(!0),h=ml(d)??m?.store;if(!h)throw Error(Ca(85));let g=yS(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=Z.useRef(null),S=dT(),C=_a(!0),w=Oc(),T=Z.useMemo(()=>w??new wc,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=el(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:kc(T),floatingParentNodeId:Dc(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=Pi({disabled:A,native:o});Z.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=Z.useRef(null),ee=ts(),P=J(e=>{if(!N.current)return;ee.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;X(N.current,t)||X(h.select(`positionerElement`),t)||t===N.current||t!=null&&oT(t)===h.select(`rootId`)||US(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:Ko})});Z.useEffect(()=>{let e=ma(N.current);if(y&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,P,{once:!0}),()=>{e.removeEventListener(`mouseup`,P)}},[y,P,h]);let te=O&&S.context.hasSubmenuOpen,F=Al(v,{enabled:(c??te)&&!A&&(!O||te&&!D),handleClose:Kl({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),ne=uT(y,h.select(`lastOpenChangeReason`)),re=Vc(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&ne}),ie=_l(v,{enabled:!A&&te}),ae=cT({open:y,enabled:O,mouseDownAction:`open`}),I=Z.useMemo(()=>Yi(ie.reference,re.reference),[ie.reference,re.reference]),oe=h.useState(`triggerProps`,D),se=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:L,handleFocusTargetFocus:R}=sT(h,x),ce={disabled:A,open:y},le=[N,t,M,E,x],ue=[I,F??Ui,oe,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(ee.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),ma(e.currentTarget).addEventListener(`mouseup`,P,{once:!0}))}},se,O?{role:`menuitem`}:{},ae,p,j],z=Pa(`button`,e,{enabled:!O,stateAttributesMapping:nc,state:ce,ref:le,props:ue});return O?(0,Q.jsx)(aT,{tag:`button`,render:n,className:r,style:i,state:ce,refs:le,props:ue,stateAttributesMapping:nc}):y?(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(ws,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:L},`${g}-pre-focus-guard`),(0,Q.jsx)(Z.Fragment,{children:z},g),(0,Q.jsx)(ws,{ref:h.context.triggerFocusTargetRef,onFocus:R},`${g}-post-focus-guard`)]}):(0,Q.jsx)(Z.Fragment,{children:z},g)});function uT(e,t){let n=ts(),[r,i]=Z.useState(!1);return q(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function dT(){let e=Kw(!0);return Z.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var fT={"aria-expanded":void 0},pT=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=dw(!0);if(p?.parent.type!==`menu`)throw Error(Ca(37));let m=lw(),h=Mw(),{store:g,parentVirtualFocus:_}=p,v=p.parent.store,y=RC({guess:!0,label:a}),b=yS(o),x=g.useState(`open`),S=Z.useRef(!1),C=g.useState(`positionerElement`),w=g.useState(`floatingRootContext`),T=g.useState(`floatingTreeRoot`),E=g.useState(`triggerPopupId`,b),D=Zc(b,g),O=J(e=>{D(e);let t=g.select(`activeTriggerElement`);e!==null&&g.select(`open`)&&(t===e||g.select(`activeTriggerId`)==null)&&g.update({activeTriggerId:b??null,activeTriggerElement:e,closeDelay:u})}),k=Z.useRef(null),A=Z.useCallback(e=>{k.current=e,g.set(`activeTriggerElement`,e)},[g]);q(()=>(O(k.current),()=>O(null)),[O,b,g]),q(()=>{if(!x||!C)return;function e(e){sa(e)===g.context.beforeContentFocusGuardRef.current&&(S.current=e.relatedTarget===k.current)}return C.addEventListener(`focusout`,e,!0),()=>{S.current=!1,C.removeEventListener(`focusout`,e,!0)}},[x,C,g]),g.useSyncedValue(`closeDelay`,u);let j=g.useState(`disabled`),M=v.useState(`disabled`),N=d||j||M,ee=v.useState(`itemProps`),P=v.useState(`isActive`,y.index),te=Z.useMemo(()=>({type:`submenu-trigger`,setActive(e){v.select(`highlightItemOnHover`)&&v.setActiveIndex(y.index,oo,e)}}),[v,y.index]),{getItemProps:F,itemRef:ne}=bw({closeOnClick:!1,disabled:N,highlighted:P,id:b,store:g,typingRef:v.context.typingRef,nativeButton:s,itemMetadata:te,nodeId:m?.context.nodeId}),re=Al(w,{enabled:g.useState(`hoverEnabled`)&&c&&!N,handleClose:Kl({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:l,delay:{open:l,close:u},shouldOpen:l>0?()=>v.select(`allowMouseEnter`):void 0,triggerElementRef:k,externalTree:T,isClosing:()=>g.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),ie=Vc(w,{enabled:!N,event:`mousedown`,toggle:!0,ignoreMouse:c,stickIfOpen:c}).reference??Ui,ae=g.useState(`triggerProps`,!0);delete ae.id;let I={disabled:N,highlighted:P,open:x},oe=g.useState(`openMethod`),se=g.useState(`lastOpenChangeReason`)===`list-navigation`||oe===`keyboard`,L=x&&se&&qa,R=h?.onTriggerKeyDown?{onKeyDown:h.onTriggerKeyDown}:void 0;return Pa(`div`,e,{state:I,stateAttributesMapping:tc,props:[ie,re,ae,R,ee,L?fT:void 0,{"aria-controls":E,tabIndex:_||!(x||P)?-1:0,onFocus(e){g.select(`open`)&&S.current&&(S.current=!1,g.setOpen(!1,Y(ds,e.nativeEvent)))},onBlur(){P&&v.setActiveIndex(null,ps)}},f,F],ref:[t,y.ref,ne,O,A]})}),mT=Z.forwardRef(function(e,t){let n=gw(e,t,`submenu-trigger`);if(!n.visible)return null;let r=n.props?Yi(n.props,e):e;return(0,Q.jsx)(pT,{...r,ref:n.ref})}),hT=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:v,setFilled:y,validationMode:b,validation:x}=hS(),{clearErrors:S,elementRef:C,submitCountRef:w}=vS(),T=h||s,E=m??a,D={...p,disabled:T},{labelId:O}=xS(),k=SS({id:i}),A=o!==void 0,j=o==null?void 0:String(o),M=J(()=>x.inputRef.current?.value);gS(x.inputRef,k,j,M,!T,a),q(()=>{let e=j??x.inputRef.current?.value;e!==void 0&&y(e!==``)},[j,l,x.inputRef,y]),AS(j,()=>{j!==void 0&&(S(E),_(j!==(v.initialValue??``)),x.change(j))});let N=Z.useRef(null),ee=VS(T,N),P=ts();return Pa(`input`,e,{ref:[t,N],state:D,props:[{id:k,disabled:T,name:E,ref:x.inputRef,"aria-labelledby":O,autoFocus:u,...A?{value:o}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=Y(ps,e.nativeEvent);c?.(t,n),!A&&(_(t!==(v.initialValue??``)),y(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(S(E),x.change(t)))},onFocus(){ee(!0)},onBlur(e){if(g(!0),ee(!1),b===`onBlur`){let t=e.currentTarget.value;x.commit(t),A&&queueMicrotask(()=>{let e=x.inputRef.current?.value;e!==void 0&&e!==t&&e!==(v.initialValue??``)&&x.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===C.current&&!e.defaultPrevented){let t=e.currentTarget,n=w.current;P.start(0,()=>{w.current===n&&x.commit(t.value)})}else x.commit(t)}}},f,e=>x.getValidationProps(T,e)],stateAttributesMapping:fS})}),gT=Z.forwardRef(function(e,t){return(0,Q.jsx)(hT,{ref:t,...e})});function _T(e){let t=(0,Ks.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=ns(`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)(gT,{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 vT(e){let t=(0,Ks.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=ns(`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 yT=Ao(`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 bT(e){let t=(0,Ks.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=ns(yT({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:xT,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function xT(e){e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()}var ST=Ao(`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 CT(e){let t=(0,Ks.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=ns(ST({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)(Ma,{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 wT(e){let t=(0,Ks.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=ns(`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)(_T,{"data-slot":`input-group-control`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function TT(e){let t=(0,Ks.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=ns(`[&_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)(Ms,{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)(XS,{"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 ET(e){let t=(0,Ks.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)(CT,{variant:`ghost`,size:`icon-xs`}),t[3]=i):i=t[3];let a;t[4]===n?a=t[5]:(a=ns(n),t[4]=n,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(io,{className:`pointer-events-none`}),t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==a?(s=(0,Q.jsx)(iC,{"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 DT(e){let t=(0,Ks.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=ns(`w-auto`,r),t[7]=r,t[8]=d);let f;t[9]===c?f=t[10]:(f=(0,Q.jsx)(wT,{disabled:c}),t[9]=c,t[10]=f);let p;t[11]!==i||t[12]!==f?(p=(0,Q.jsx)(nC,{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)(CT,{size:`icon-xs`,variant:`ghost`,render:(0,Q.jsx)(TT,{}),"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)(ET,{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)(bT,{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)(vT,{className:d,children:[p,g,n]}),t[23]=n,t[24]=d,t[25]=p,t[26]=g,t[27]=_):_=t[27],_}function OT(e){let t=(0,Ks.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=ns(`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)(LC,{"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)(bC,{children:(0,Q.jsx)(FC,{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 kT(e){let t=(0,Ks.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=ns(`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)(_C,{"data-slot":`combobox-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function AT(e){let t=(0,Ks.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=ns(`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)(aw,{render:(0,Q.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`}),children:(0,Q.jsx)(As,{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)(GC,{"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 jT(e){let t=(0,Ks.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)(tT,{"data-slot":`dropdown-menu`,...n}),t[2]=n,t[3]=r),r}function MT(e){let t=(0,Ks.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)(lT,{"data-slot":`dropdown-menu-trigger`,...n}),t[2]=n,t[3]=r),r}function NT(e){let t=(0,Ks.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=ns(`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)(zw,{"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)(Hw,{children:(0,Q.jsx)(Ww,{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 PT(e){let t=(0,Ks.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)(ww,{"data-slot":`dropdown-menu-group`,...n}),t[2]=n,t[3]=r),r}function FT(e){let t=(0,Ks.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=ns(`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)(Tw,{"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 IT(e){let t=(0,Ks.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=ns(`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)(Dw,{"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 LT(e){let t=(0,Ks.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)(rT,{"data-slot":`dropdown-menu-sub`,...n}),t[2]=n,t[3]=r),r}function RT(e){let t=(0,Ks.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=ns(`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)(Ps,{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)(mT,{"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 zT(e){let t=(0,Ks.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=ns(`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)(NT,{"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 BT(e){let t=(0,Ks.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=ns(`-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)(Cb,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function VT(e){let t=(0,Ks.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=ns(`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 HT=K({id:U,name:U,signOut:Fn}),UT=O(Cr).atom(dr(kt(`/auth/user`),$t(zt),$t(Ke(HT)))),WT=tt(_(``));function GT(){return hr(cn(Tx(WT)))}function KT(){let e=(0,Ks.c)(27),t=Tx(UT);if(!oe(t))return null;let n;e[0]===t.value.id?n=e[1]:(n=zr(`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)(nw,{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=Pr(Or(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)(rw,{children:a}),e[7]=a,e[8]=o);let s;e[9]!==i||e[10]!==o?(s=(0,Q.jsx)(MT,{"aria-label":`Account`,children:(0,Q.jsxs)(tw,{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)(PT,{children:(0,Q.jsxs)(FT,{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)(BT,{}),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)(IT,{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)(NT,{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)(jT,{children:[s,h]}),e[24]=h,e[25]=s,e[26]=g):g=e[26],g}function qT(e){let t=(0,Ks.c)(66),[n,r]=Ox(WT),[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=>Lt(hr(cn(n)))(hr(e.label)),t[21]=n,t[22]=a),m=Xt(e.commands,a);let o,d;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{(0,Gs.flushSync)(()=>c(!0)),l.current?.focus()},d=(0,Q.jsx)(Bs,{}),t[23]=o,t[24]=d):(o=t[23],d=t[24]),t[25]===e.label?g=t[26]:(g=(0,Q.jsx)(Ma,{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=ns(`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=LS,_=m,v=null,y=JT,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&&pn(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&&pn(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)(bT,{children:(0,Q.jsx)(Bs,{})}),t[36]=D):D=t[36];let O;t[37]===n?O=t[38]:(O=n===``&&(0,Q.jsx)(bT,{align:`inline-end`,className:`max-sm:hidden`,children:(0,Q.jsx)(VT,{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)(DT,{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)(OT,{anchor:u,children:(0,Q.jsx)(kT,{children:e=>(0,Q.jsxs)(AT,{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)(Ma,{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 JT(e){return e.label}function YT(e){let t=(0,Ks.c)(11),r;t[0]===e.active?r=t[1]:(r=n(e.active,{onFalse:$T,onTrue:QT}),t[0]=e.active,t[1]=r);let i=e.children,a;t[2]===e.active?a=t[3]:(a=Bi({variant:n(e.active,{onFalse:ZT,onTrue:XT})}),t[2]=e.active,t[3]=a);let o;t[4]!==e.children||t[5]!==r||t[6]!==a?(o={"aria-current":r,children:i,className:a},t[4]=e.children,t[5]=r,t[6]=a,t[7]=o):o=t[7];let s;return t[8]!==e.render||t[9]!==o?(s={props:o,render:e.render},t[8]=e.render,t[9]=o,t[10]=s):s=t[10],KC(s)}function XT(){return`secondary`}function ZT(){return`ghost`}function QT(){return`page`}function $T(){}function eE(e){let t=(0,Ks.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)(qT,{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)(KT,{}),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 tE(e){let t=(0,Ks.c)(5),n=e.className,r;t[0]===e.result?r=t[1]:(r=De(ce(ee(e.result),nE)),t[0]=e.result,t[1]=r);let i;return t[2]!==e.className||t[3]!==r?(i=(0,Q.jsx)(Tb,{className:n,children:r}),t[2]=e.className,t[3]=r,t[4]=i):i=t[4],i}function nE(e){return e.message}var rE=Ao(`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 iE(e){let t=(0,Ks.c)(6),n;t[0]!==e.className||t[1]!==e.status||t[2]!==e.waiting?(n=ns(rE({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 aE(e){let t=(0,Ks.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=ns(`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 oE(e){let t=(0,Ks.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=ns(`[&_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 sE(e){let t=(0,Ks.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=ns(`[&_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 cE(e){let t=(0,Ks.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=ns(`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 lE(e){let t=(0,Ks.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=ns(`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 uE(e){let t=(0,Ks.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=ns(`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 dE=`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`,fE=`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`,pE=`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`,mE=`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`,hE=`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`,gE=`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`,_E=`/assets/firefox-5m8yovBp.svg`,vE=`/assets/safari-DgmPRf57.svg`;function yE(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 bE(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 xE(){return SE.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var SE={stubThis:e=>e};function CE(e){let{id:t}=e;return{...e,id:bE(t),transports:e.transports,type:e.type}}function wE(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 TE=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 EE({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 TE({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 TE({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 TE({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 TE({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 TE({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new TE({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 TE({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new TE({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(!wE(t))return new TE({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new TE({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 TE({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 TE({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 DE=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}}},OE=[`cross-platform`,`platform`];function kE(e){if(e&&!(OE.indexOf(e)<0))return e}async function AE(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(!xE())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:bE(t.challenge),user:{...t.user,id:bE(t.user.id)},excludeCredentials:t.excludeCredentials?.map(CE)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=DE.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw EE({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){jE(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=yE(e))}catch(e){jE(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=yE(c.getAuthenticatorData())}catch(e){jE(`getAuthenticatorData()`,e)}return{id:o,rawId:yE(s),response:{attestationObject:yE(c.attestationObject),clientDataJSON:yE(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:kE(a.authenticatorAttachment)}}function jE(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 ME(){if(!xE())return NE.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?NE.stubThis(new Promise(e=>e(!1))):NE.stubThis(e.isConditionalMediationAvailable())}var NE={stubThis:e=>e};function PE({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 TE({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new TE({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!wE(t))return new TE({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new TE({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 TE({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 FE(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(!xE())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(CE));let a={...t,challenge:bE(t.challenge),allowCredentials:i},o={};if(n){if(!await ME())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=DE.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw PE({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=yE(u.userHandle)),{id:c,rawId:yE(l),response:{authenticatorData:yE(u.authenticatorData),clientDataJSON:yE(u.clientDataJSON),signature:yE(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:kE(s.authenticatorAttachment)}}var IE=yy,LE=xy,RE=Cy,zE=`https://auth.mp281x.xyz`,BE=Jr(gn(nr(`AUTH_URL`)),Ne);qr(function*(){let e=dn(U,`GITHUB_ADMINS`);return(yield*BE)?yield*En(e,[`0`]):yield*e}),Bt()(`@deslop/runtime/auth/lib/utils/CurrentUser`);var VE=class e extends Zn()(`@deslop/runtime/auth/lib/utils/RpcAuth`,{error:Xo}){static layerClient=t=>Wr(e,e=>qr(function*(){return yield*e.next({...e.request,headers:mn(e.request.headers,`authorization`,`Bearer ${yield*t}`)})}))},HE=K({name:x,open:x,origin:yo}),UE=or(HE);K({origin:yo});var WE=fi([`ble`,`cable`,`hybrid`,`internal`,`nfc`,`smart-card`,`usb`]),GE=on(`public-key`),KE=fi([`required`,`preferred`,`discouraged`]),qE=K({id:U,transports:V(xe(or(WE))),type:GE}),JE=K({attestation:V(fi([`direct`,`enterprise`,`indirect`,`none`])),authenticatorSelection:V(K({authenticatorAttachment:V(fi([`cross-platform`,`platform`])),requireResidentKey:V(Fn),residentKey:V(fi([`discouraged`,`preferred`,`required`])),userVerification:V(KE)})),challenge:U,excludeCredentials:V(xe(or(qE))),pubKeyCredParams:xe(or(K({alg:Jt,type:GE}))),rp:K({id:V(U),name:U}),timeout:V(Jt),user:K({displayName:U,id:U,name:U})}),YE=K({allowCredentials:V(xe(or(qE))),challenge:U,rpId:V(U),timeout:V(Jt),userVerification:V(KE)}),XE=V(fi([`cross-platform`,`platform`])),ZE=K({authenticatorAttachment:XE,clientExtensionResults:K({}),id:U,rawId:U,response:K({attestationObject:U,clientDataJSON:U,transports:V(or(U))}),type:GE}),QE=K({authenticatorAttachment:XE,clientExtensionResults:K({}),id:U,rawId:U,response:K({authenticatorData:U,clientDataJSON:U,signature:U,userHandle:V(U)}),type:GE});K({challenge:U});var $E=K({addedFrom:U,counter:ei,createdAt:Jt,id:x,lastUsed:Jt,publicKey:x,synced:Fn,transports:or(WE),user:Eo});or($E);var eD=K({addedFrom:U,createdAt:Jt,id:x,lastUsed:Jt,synced:Fn}),tD=K({id:x}),nD=K({response:ZE}),rD=K({next:V(x.check(g(2048))),response:QE}),iD=K({client_name:V(U.check(g(100))),redirect_uris:ot(x.check(g(200))).check(g(4)),token_endpoint_auth_method:V(on(`none`))});K({name:U,redirects:iD.fields.redirect_uris}),K({client_id:x.check(g(2048)),redirect_uri:V(U),state:V(U)}),K({code_challenge:V(x),code_challenge_method:V(U),resource:V(Sr(U)),response_type:V(U),scope:V(U)});var aD=K({challenge:x,clientId:x,clientName:U,redirectUri:x,resources:ot(Bo),state:V(x)});K({grant_type:U});var oD=V(Sr(Bo).check(Ct(1)));Le([K({client_id:x,code:x,code_verifier:x,grant_type:on(`authorization_code`),redirect_uri:V(U),resource:oD}),K({client_id:V(U),grant_type:on(`refresh_token`),refresh_token:x,resource:oD})]);var sD=K({access_token:x,expires_in:Jt,refresh_token:x,scope:on(`deslop`),token_type:on(`Bearer`)});je({Granted:{tokens:sD},Replayed:{message:U}});var cD=K({address:V(U),userAgent:V(U)}),lD=K({expiresAt:Jt,hash:U,resources:or(Bo)}),uD=fi([`Code`,`GitHub`,`Passkey`]),dD=K({client:U,createdAt:Jt,credential:je({App:{access:or(lD),clientId:x,expiresAt:Jt,generation:ei,hash:U,replaced:V(U),resources:or(Bo)},Browser:{expiresAt:Jt,hash:U,via:V(uD)}}),device:U,lastActive:Jt,origin:cD,user:Eo});N(U,dD);var fD=K({address:V(U),client:U,device:U,family:x,kind:fi([`App`,`Browser`]),lastActive:Jt,resources:or(Bo)}),pD=K({family:x});K({client_id:x,token:x}),K({resource:Bo});var mD=fi([`Admin`,`Member`,`Waiting`]),hD=K({...Eo.fields,fullName:V(U),role:mD}),gD=K({...hD.fields,via:uD}),_D=K({...hD.fields,since:Jt}),vD=fi([`Waiting`,`Allowed`]),yD=K({fullName:U,id:x,name:x,since:Jt,status:vD});or(yD),K({id:ei,login:x,name:V(oi(U))});var bD=K({allow:Fn,id:x}),xD=K({id:x}),SD=fi([`App`,`Browser`]),CD=K({address:V(U),clientName:U,createdAt:Jt,device:U,expiresAt:Jt,id:x,kind:SD,resources:or(Bo)}),wD=je({Decided:{},Expired:{},Waiting:{request:CD}}),TD=je({Browser:{next:V(U)},Client:{request:aD}});je({Redirect:{url:x},Session:{next:V(U),seconds:ei,token:x},Waiting:{}}),K({delivery:TD,origin:cD}),K({next:V(x.check(g(2048)))});var ED=K({request:x.check(g(20))}),DD=K({code:x.check(g(20))}),OD=K({...ED.fields,accept:Fn}),kD=class extends fn(jn(`auth.lookup`,{error:Xo,payload:DD,stream:!0,success:dt(CD)}),jn(`auth.answer`,{error:Xo,payload:OD}),jn(`auth.people`,{error:Xo,stream:!0,success:or(_D)}),jn(`auth.admit`,{error:Xo,payload:bD,success:_D}),jn(`auth.remove`,{error:Xo,payload:xD,success:_D}),jn(`auth.apps`,{error:Xo,stream:!0,success:or(fD)}),jn(`auth.catalog`,{error:Xo,stream:!0,success:UE}),jn(`auth.disconnect`,{error:Xo,payload:pD}),jn(`auth.passkeys`,{error:Xo,stream:!0,success:or(eD)}),jn(`auth.passkeyOptions`,{error:Xo,success:JE}),jn(`auth.addPasskey`,{error:Xo,payload:nD}),jn(`auth.removePasskey`,{error:Xo,payload:tD})).middleware(VE).merge(fn(jn(`auth.account`,{error:Xo,stream:!0,success:gD}),jn(`auth.wait`,{error:Xo,payload:ED,stream:!0,success:wD}))){};function AD(e){return Pr(lr(/[^a-z]/giu,``)(e))}function jD(e){return C(s(e),Ht)}_r(function*(e,t,n){if(Ne(jD(n.response_type)))return yield*Xo.make({message:`Send response_type=code`});if(n.response_type!==`code`)return yield*Xo.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*Xo.make({message:`Send a PKCE code_challenge with code_challenge_method=S256`});if(!Ln(Xt(Rn(n.scope??``,` `),Ht),e=>e===`deslop`||e===`offline_access`))return yield*Xo.make({error:`invalid_scope`,message:`Only the deslop scope is supported`});let r=yield*dr(ne(ot(Bo))(n.resource??[]),ar(e=>Xo.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,...Ce(jD(e.state),{onNone:()=>({}),onSome:e=>({state:e})})})});function MD(e){return dr(new URL(e).hostname,Rn(`.`),Dr(1),rr(`.`))}function ND(e,t){let n=MD(t);return W(Ur(e),{onFailure:()=>!1,onSuccess:e=>e.protocol===`https:`&&(e.hostname===n||he(`.${n}`)(e.hostname))&&Mt(e.username)&&Mt(e.password)})}var PD=O(Cr),FD=class extends Sn()(`@deslop/auth/lib/utils/RpcClient`,{group:kD,protocol:lo(`@deslop/auth`)}){},ID=tt(FD.runtime.atom(dr(FD,xr(e=>e(`auth.account`,void 0)),Fe,po,ii(f),Nn(`AuthError`,()=>y(Ze()))))),LD={accept:Fn,request:CD},RD=bb(FD.runtime).make(LE({branches:{looked:{found:{target:`Code.Found`},missing:{target:`Code.Missing`}}},events:RE({Answered:LD,Typed:{typed:U}}),root:IE({states:{Code:{fields:{code:U},states:{Failed:{fields:{message:U}},Found:{fields:{request:CD}},Looking:{},Missing:{}}},Typing:{fields:{answered:V(K(LD)),typed:U}}}}),streams:{lookup:e=>po(Fe(xr(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=>Ce(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=>Ye(e.state.typed)>=8,target:`Code`}}}})),zD=_(e=>{e.set(RD.send,{_tag:`Typed`,typed:AD(new URLSearchParams(location.search).get(`code`)??``)})}),BD=tt(FD.runtime.atom(dr(FD,xr(e=>e(`auth.people`,void 0)),Fe,po))),VD=tt(FD.runtime.atom(dr(FD,xr(e=>e(`auth.apps`,void 0)),Fe,po)));function HD(e){return t=>Gn(t,t=>G(()=>Ho.add({description:t.message,title:e,type:`error`})))}var UD=FD.runtime.fn(e=>dr($t(FD,t=>Ir(e,e=>t(`auth.disconnect`,{family:e}),{concurrency:`unbounded`,discard:!0})),HD(`Cannot sign out`))),WD=pi(e=>FD.runtime.fn(t=>$t(FD,n=>n(`auth.admit`,{allow:t,id:e})))),GD=pi(e=>FD.runtime.fn(()=>$t(FD,t=>t(`auth.remove`,{id:e})))),KD=Jn(new URLSearchParams(location.search).get(`request`)),qD=pi(e=>FD.runtime.atom(dr(FD,xr(t=>t(`auth.wait`,{request:e})),Fe,po,Wn(t=>dr(vr(t),Mr(`Decided`,()=>G(()=>location.assign(`/auth/continue?${new URLSearchParams({request:e})}`))),pr(()=>z))))));function JD(e){return`${Or(0,4)(e)}-${Or(4)(e)}`}function YD(e){return`${location.origin}/?code=${e}`}var XD=tt(FD.runtime.atom(dr(FD,xr(e=>e(`auth.catalog`,void 0)),Fe,po)));function ZD(e){return Cn(e)?[`browser`]:cr(Mn(e,e=>new URL(e).origin))}function QD(e){return dr(ir(e),br({hour:`2-digit`,minute:`2-digit`}))}var $D=_(dr(ke(`1 minute`),lt(()=>le))),eO=_(dr(ke(`1 second`),lt(()=>le)));function tO(e,t){let n=$n(0,Math.ceil((e-t)/1e3));return`${Math.floor(n/60)}:${vn(2,`0`)(`${n%60}`)}`}var nO=en(e=>dr(Ae({catch:e=>Xo.make({cause:e,message:`Cannot copy the code; type it in instead`}),try:()=>navigator.clipboard.writeText(e)}),I(M(`1200 millis`))));function rO(e,t){return Math.floor(At(wn(ir(e),ir(t))))}function iO(e){return e<1?`now`:e<60?`${e}m`:e<1440?`${Math.floor(e/60)}h`:`${Math.floor(e/1440)}d`}function aO(e,t){return`${e} · ${t}`}function oO(e){return Xr(e,0,(e,t)=>$n(e,t.lastActive))}function sO(e){return dr(ir(e),br({day:`numeric`,month:`short`}))}function cO(e){return`https://avatars.githubusercontent.com/u/${zr(`github:`,``)(e)}?s=96`}var lO=FD.runtime.fn((e,t)=>dr(FD,$t(t=>t(`auth.answer`,{accept:e.accept,request:e.request.id})),I(G(()=>t.set(RD.send,{_tag:`Answered`,...e}))))),uO=Jn(new URLSearchParams(location.search).get(`next`));function dO(e){return B(e.cause,`name`)&&e.cause.name===`NotAllowedError`}var fO=_r(function*(e){return e.status===429?yield*Xo.make({message:`Too many tries; wait a minute and try again`}):yield*Xo.make({message:(yield*Ke(K({error_description:U}))(e)).error_description})}),pO=PD.fn(()=>dr(qr(function*(){let e=yield*fe,n=yield*e.get(`/auth/passkey`);if(n.status!==200)return yield*fO(n);let r=yield*Ke(YE)(n),i=yield*Vt(Ae({catch:e=>Xo.make({cause:e,message:`No passkey was used`}),try:()=>FE({optionsJSON:r})}),dO,()=>hn),a=yield*dr(t(`/auth/passkey`),xn(rD)({...Ce(uO,{onNone:()=>({}),onSome:e=>({next:e})}),response:i}),$t(t=>e.execute(t)),$t(_r(function*(e){return e.status===200?yield*Ke(K({next:V(U)}))(e):yield*fO(e)})));yield*G(()=>Ce(s(a.next),{onNone:()=>location.reload(),onSome:e=>location.assign(e)}))}),ar(e=>Ci(Xo)(e)?e:Xo.make({cause:e,message:`Cannot sign in with a passkey`})))),mO=tt(FD.runtime.atom(dr(FD,xr(e=>e(`auth.passkeys`,void 0)),Fe,po))),hO=tt(FD.runtime.fn(_r(function*(){let e=yield*FD,t=yield*e(`auth.passkeyOptions`,void 0);yield*e(`auth.addPasskey`,{response:yield*dr(Ae({catch:e=>Xo.make({cause:e,message:`No passkey was added`}),try:()=>AE({optionsJSON:t})}),Vt(dO,()=>hn),$t(ne(ZE)))}),Ho.add({title:`Passkey added`})},HD(`Cannot add a passkey`)))),gO=`adding-passkey`,_O=en(()=>Ie({catch:e=>Xo.make({cause:e,message:`Cannot start GitHub sign-in`}),try:()=>{sessionStorage.setItem(gO,`true`),location.assign(`/auth/github`)}})),vO=tt(FD.runtime.fn(e=>dr($t(FD,t=>t(`auth.removePasskey`,{id:e})),HD(`Cannot remove the passkey`)))),yO=en(()=>Ie({catch:e=>Xo.make({cause:e,message:`Cannot start GitHub sign-in`}),try:()=>location.assign(`/auth/github${location.search}`)})),bO=en(()=>Ie({catch:e=>Xo.make({cause:e,message:`Cannot start the sign-in`}),try:()=>location.assign(Ce(uO,{onNone:()=>`/auth/code`,onSome:e=>`/auth/code?${new URLSearchParams({next:e})}`}))})),xO=new URLSearchParams(location.search).has(`sign-out`),SO=dr(Jn(new URLSearchParams(location.search).get(`next`)),C(e=>ND(e,zE)),Hn(()=>location.pathname)),CO=dr(fe.use(e=>Pt(e).post(`/auth/sign-out`)),I(G(()=>location.replace(SO))),ar(e=>Xo.make({cause:e,message:`Cannot sign out: ${e.message}`}))),wO=PD.fn(()=>CO),TO=PD.fn(()=>HD(`Cannot sign out`)(CO));function EO(e){let t=(0,Ks.c)(17),n,r,i,a,o,s;if(t[0]!==e.className||t[1]!==e.text){let c=sn(px(e.text)),l=Math.sqrt(c.length);r=`-2 -2 ${l+4} ${l+4}`,i=`crispEdges`,a=`currentColor`,o=e.className,s=`true`,n=dr(c,Mn((e,t)=>({dark:e,x:t%l,y:Math.floor(t/l)})),Xt(OO),Mn(DO),rr(``)),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 DO(e){return`M${e.x} ${e.y}h1v1h-1z`}function OO(e){return e.dark===1}function kO(e){let t=(0,Ks.c)(12),n;t[0]===e.id?n=t[1]:(n=cO(e.id),t[0]=e.id,t[1]=n);let r;t[2]!==e.name||t[3]!==n?(r=(0,Q.jsx)(nw,{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=Pr(Or(0,1)(e.name)),t[5]=e.name,t[6]=i);let a;t[7]===i?a=t[8]:(a=(0,Q.jsx)(rw,{children:i}),t[7]=i,t[8]=a);let o;return t[9]!==r||t[10]!==a?(o=(0,Q.jsxs)(tw,{size:`sm`,children:[r,a]}),t[9]=r,t[10]=a,t[11]=o):o=t[11],o}function AO(e){let t=(0,Ks.c)(11),[r,i]=(0,Z.useState)(`loading`),a;t[0]===e.small?a=t[1]:(a=ns(`text-muted-foreground relative flex shrink-0 items-center justify-center`,n(e.small===!0,{onFalse:MO,onTrue:jO})),t[0]=e.small,t[1]=a);let o;t[2]===r?o=t[3]:(o=r!==`loaded`&&(0,Q.jsx)(Os,{className:`size-4`}),t[2]=r,t[3]=o);let s;t[4]!==e.origin||t[5]!==r?(s=r!==`failed`&&(0,Q.jsx)(`img`,{src:`${e.origin}/icon`,alt:``,className:ns(`pixelated absolute inset-0 size-full`,r===`loading`&&`invisible`),onLoad:()=>i(`loaded`),onError:()=>i(`failed`)}),t[4]=e.origin,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==o||t[9]!==s?(c=(0,Q.jsxs)(`span`,{className:a,children:[o,s]}),t[7]=a,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}function jO(){return`size-4`}function MO(){return`size-5`}var NO={Chrome:pE,Edge:gE,Firefox:_E,Safari:vE};function PO(e){return e.kind===`Browser`?ce(ci(NO,e.name),e=>({mono:!1,src:e})):He(i(/claude/iu)(e.name))?f({mono:!1,src:mE}):He(i(/codex/iu)(e.name))?f({mono:!0,src:hE}):He(i(/gateway/iu)(e.name))?Ze():_n([`iPhone`,`iPad`],e.device)?f({mono:!0,src:fE}):e.device===`Android`?f({mono:!1,src:dE}):Ze()}function FO(e){return Ce(PO(e.client),{onNone:()=>dr(vr(e.client),Lr({kind:`Browser`},()=>(0,Q.jsx)(Is,{})),Lr(e=>He(i(/gateway/iu)(e.name)),()=>(0,Q.jsx)(Rs,{})),pr(()=>(0,Q.jsx)(Hs,{}))),onSome:e=>(0,Q.jsx)(`img`,{src:e.src,alt:``,className:ns(`size-3.5`,e.mono&&`dark:invert`)})})}function IO(e){return Ce(e.client.app,{onNone:()=>(0,Q.jsx)(FO,{client:e.client}),onSome:e=>(0,Q.jsx)(AO,{origin:e,small:!0})})}function LO(e){let t=(0,Ks.c)(33),[r,i]=Fd(UD),a;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 r;t[6]!==e.column.lastActive||t[7]!==e.now?(r=()=>{let t=rO(e.column.lastActive,e.now);return`active ${n(t<1,{onFalse:()=>`${iO(t)} ago`,onTrue:zO})}`},t[6]=e.column.lastActive,t[7]=e.now,t[8]=r):r=t[8];let i;t[9]===e.column.client?i=t[10]:(i=t=>t!==e.column.client.device,t[9]=e.column.client,t[10]=i),a=rr([n(e.column.pending,{onFalse:r,onTrue:RO}),...yt(C(e.column.address,i))],` · `),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]=a}else a=t[5];let o=a,s=`${e.column.label}, ${o}`,c;if(t[11]!==o||t[12]!==i||t[13]!==r||t[14]!==s||t[15]!==e.column.client||t[16]!==e.column.families||t[17]!==e.column.label||t[18]!==e.column.pending){let a;t[20]!==o||t[21]!==i||t[22]!==r||t[23]!==s||t[24]!==e.column.client||t[25]!==e.column.families||t[26]!==e.column.label?(a=()=>(0,Q.jsxs)(jT,{children:[(0,Q.jsx)(MT,{render:(0,Q.jsx)(Ma,{variant:`ghost`,size:`icon-sm`,title:s,"aria-label":s}),children:(0,Q.jsx)(IO,{client:e.column.client})}),(0,Q.jsxs)(NT,{align:`end`,className:`w-auto min-w-48`,children:[(0,Q.jsx)(PT,{children:(0,Q.jsxs)(FT,{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:o})]})}),(0,Q.jsx)(IT,{variant:`destructive`,disabled:ft(r),onClick:()=>i(e.column.families),children:`Sign out`})]})]}),t[20]=o,t[21]=i,t[22]=r,t[23]=s,t[24]=e.column.client,t[25]=e.column.families,t[26]=e.column.label,t[27]=a):a=t[27];let l;t[28]!==s||t[29]!==e.column.client?(l=()=>(0,Q.jsx)(`span`,{title:s,"aria-label":s,role:`img`,className:`ring-primary flex size-7 items-center justify-center rounded-sm ring-1`,children:(0,Q.jsx)(IO,{client:e.column.client})}),t[28]=s,t[29]=e.column.client,t[30]=l):l=t[30],c=n(e.column.pending,{onFalse:a,onTrue:l}),t[11]=o,t[12]=i,t[13]=r,t[14]=s,t[15]=e.column.client,t[16]=e.column.families,t[17]=e.column.label,t[18]=e.column.pending,t[19]=c}else c=t[19];let l;return t[31]===c?l=t[32]:(l=(0,Q.jsx)(lE,{className:`px-0.5`,children:(0,Q.jsx)(`span`,{className:`flex justify-center`,children:c})}),t[31]=c,t[32]=l),l}function RO(){return`waiting for an answer`}function zO(){return`now`}function BO(e,t,n){let r=ZD(e);return _n(r,t)||_n(r,`browser`)&&n}function VO(e,t){return mi(e.resources,e=>BO(e,t.origin,t.web))}function HO(e){let t=(0,Ks.c)(21),r,i,a,o,s,c;if(t[0]!==e.column||t[1]!==e.row){let l=VO(e.column,e.row);r=uE,c=`w-7 px-0`,o=`flex justify-center`;let u;t[8]===e.column.pending?u=t[9]:(u=()=>(0,Q.jsx)(iE,{waiting:e.column.pending}),t[8]=e.column.pending,t[9]=u),s=n(l,{onFalse:KO,onTrue:u}),i=`sr-only`,a=dr(vr({held:l,pending:e.column.pending}),Lr({held:!1},GO),Lr({pending:!0},WO),pr(UO)),t[0]=e.column,t[1]=e.row,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c}else r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7];let l;t[10]!==i||t[11]!==a?(l=(0,Q.jsx)(`span`,{className:i,children:a}),t[10]=i,t[11]=a,t[12]=l):l=t[12];let u;t[13]!==o||t[14]!==s||t[15]!==l?(u=(0,Q.jsxs)(`span`,{className:o,children:[s,l]}),t[13]=o,t[14]=s,t[15]=l,t[16]=u):u=t[16];let d;return t[17]!==r||t[18]!==c||t[19]!==u?(d=(0,Q.jsx)(r,{className:c,children:u}),t[17]=r,t[18]=c,t[19]=u,t[20]=d):d=t[20],d}function UO(){return`signed in`}function WO(){return`asked for`}function GO(){return`not signed in`}function KO(){return(0,Q.jsx)(iE,{status:`off`})}function qO(e){let t=(0,Ks.c)(42),[r,i]=Fd(lO),a;if(t[0]!==e.request.clientName||t[1]!==e.request.device||t[2]!==e.request.kind){let r,i;t[4]!==e.request.clientName||t[5]!==e.request.device?(r=()=>`${aO(e.request.clientName,e.request.device)} asks for the apps its column marks`,i=()=>`Signs in ${aO(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]=r,t[7]=i):(r=t[6],i=t[7]),a=n(e.request.kind===`Browser`,{onFalse:r,onTrue:i}),t[0]=e.request.clientName,t[1]=e.request.device,t[2]=e.request.kind,t[3]=a}else a=t[3];let o;t[8]===e.request.address?o=t[9]:(o=Ce(s(e.request.address),{onNone:YO,onSome:JO}),t[8]=e.request.address,t[9]=o);let c;t[10]!==a||t[11]!==o?(c=(0,Q.jsxs)(wb,{children:[a,o,`. Approve only a code you started yourself.`]}),t[10]=a,t[11]=o,t[12]=c):c=t[12];let l;t[13]===r?l=t[14]:(l=(0,Q.jsx)(tE,{result:r}),t[13]=r,t[14]=l);let u;t[15]!==e.request.clientName||t[16]!==e.request.device?(u=aO(e.request.clientName,e.request.device),t[15]=e.request.clientName,t[16]=e.request.device,t[17]=u):u=t[17];let d=`Approve ${u}`,f;t[18]===r?f=t[19]:(f=ft(r),t[18]=r,t[19]=f);let p;t[20]!==e.request||t[21]!==i?(p=()=>i({accept:!0,request:e.request}),t[20]=e.request,t[21]=i,t[22]=p):p=t[22];let m;t[23]!==d||t[24]!==f||t[25]!==p?(m=(0,Q.jsx)(Ma,{size:`lg`,"aria-label":d,disabled:f,onClick:p,children:`Approve`}),t[23]=d,t[24]=f,t[25]=p,t[26]=m):m=t[26];let h;t[27]===r?h=t[28]:(h=ft(r),t[27]=r,t[28]=h);let g;t[29]!==e.request||t[30]!==i?(g=()=>i({accept:!1,request:e.request}),t[29]=e.request,t[30]=i,t[31]=g):g=t[31];let _;t[32]!==g||t[33]!==h?(_=(0,Q.jsx)(Ma,{size:`lg`,variant:`outline`,disabled:h,onClick:g,children:`Deny`}),t[32]=g,t[33]=h,t[34]=_):_=t[34];let v;t[35]!==_||t[36]!==m?(v=(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[m,_]}),t[35]=_,t[36]=m,t[37]=v):v=t[37];let y;return t[38]!==v||t[39]!==c||t[40]!==l?(y=(0,Q.jsxs)(Q.Fragment,{children:[c,l,v]}),t[38]=v,t[39]=c,t[40]=l,t[41]=y):y=t[41],y}function JO(e){return` · from ${e}`}function YO(){return``}function XO(e,t,n){function r(e,t,r){return{app:ce(mr(n,t=>r===`App`&&hr(t.name)===hr(e)),e=>e.origin),device:t,kind:r,name:e}}return[...Ce(e,{onNone:()=>[],onSome:e=>[{address:s(e.address),client:r(e.clientName,e.device,e.kind),families:[],key:`pending`,label:aO(e.clientName,e.device),lastActive:0,pending:!0,resources:[e.resources]}]}),...dr(Qn(t,e=>aO(e.client,e.device)),nt,Xt(yr),tn(Tt(ie(pt,oO))),Mn(e=>({address:dr(mr(e,t=>t.lastActive===oO(e)),ze(e=>s(e.address))),client:r(e[0].client,e[0].device,e[0].kind),families:Mn(e,e=>e.family),key:aO(e[0].client,e[0].device),label:aO(e[0].client,e[0].device),lastActive:oO(e),pending:!1,resources:Mn(e,e=>e.resources)})))]}function ZO(e){let t=(0,Ks.c)(26),r=zd(XD).value,i=zd(VD).value,a=zd($D).value,o=GT(),s;t[0]===o?s=t[1]:(s=function(e){return Lt(o)(hr(e))},t[0]=o,t[1]=s);let c=s,l,u,d,f;if(t[2]!==r||t[3]!==a||t[4]!==e.pending||t[5]!==o||t[6]!==c||t[7]!==i){let s;t[12]===c?s=t[13]:(s=e=>c(e.name),t[12]=c,t[13]=s);let p;t[14]!==r||t[15]!==c?(p=e=>e!==`browser`&&!mi(r,t=>t.origin===e)&&c(e),t[14]=r,t[15]=c,t[16]=p):p=t[16];let m=[...Mn(Xt(r,s),ak),...dr([...Nr(i,ik),...Ce(e.pending,{onNone:rk,onSome:nk})],cr,Xt(p),tn(be),Mn(tk))],h=Xt(XO(e.pending,i,r),e=>e.pending||mi(m,t=>VO(e,t)));l=`flex flex-1 flex-col gap-3`,u=`Apps`,t[17]===e.pending?d=t[18]:(d=Ce(e.pending,{onNone:ek,onSome:$O}),t[17]=e.pending,t[18]=d);let g;t[19]===o?g=t[20]:(g=()=>(0,Q.jsx)(Co,{children:(0,Q.jsx)(Ss,{children:(0,Q.jsx)(ys,{children:n(Mt(o),{onFalse:()=>`No app matches “${o}”`,onTrue:QO})})})}),t[19]=o,t[20]=g),f=Dn(m,{onEmpty:g,onNonEmpty:()=>(0,Q.jsxs)(aE,{"aria-label":`Apps and the clients signed in to them`,children:[(0,Q.jsx)(oE,{children:(0,Q.jsxs)(cE,{children:[(0,Q.jsx)(lE,{children:(0,Q.jsx)(`span`,{className:`sr-only`,children:`App`})}),Mn(h,e=>(0,Q.jsx)(LO,{column:e,now:a},e.key))]})}),(0,Q.jsx)(sE,{children:Mn(m,e=>(0,Q.jsxs)(cE,{children:[(0,Q.jsx)(lE,{scope:`row`,children:Ce(e.open,{onNone:()=>(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Q.jsx)(AO,{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)(AO,{origin:e.origin}),e.name]})})}),Mn(h,t=>(0,Q.jsx)(HO,{column:t,row:e},t.key))]},e.origin))})]})}),t[2]=r,t[3]=a,t[4]=e.pending,t[5]=o,t[6]=c,t[7]=i,t[8]=l,t[9]=u,t[10]=d,t[11]=f}else l=t[8],u=t[9],d=t[10],f=t[11];let p;return t[21]!==l||t[22]!==u||t[23]!==d||t[24]!==f?(p=(0,Q.jsxs)(`section`,{className:l,"aria-label":u,children:[d,f]}),t[21]=l,t[22]=u,t[23]=d,t[24]=f,t[25]=p):p=t[25],p}function QO(){return`No apps yet`}function $O(e){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qO,{request:e}),(0,Q.jsxs)(`p`,{className:`text-muted-foreground font-mono text-xs`,children:[`open until `,QD(e.expiresAt)]})]})}function ek(){return null}function tk(e){return{name:Hn(Gr(Rn(new URL(e).hostname,`.`)),()=>e),open:Ze(),origin:e,web:!1}}function nk(e){return ZD(e.resources)}function rk(){return[]}function ik(e){return ZD(e.resources)}function ak(e){return{name:e.name,open:f(e.open),origin:e.origin,web:Zt(`https://`)(e.open)}}export{uw as $,xO as A,IT as B,qD as C,yO as D,eO as E,YT as F,RT as G,BT as H,GT as I,tT as J,MT as K,jT as L,iE as M,tE as N,aO as O,eE as P,Dw as Q,NT as R,vO as S,KD as T,LT as U,FT as V,zT as W,Hw as X,Ww as Y,zw as Z,TO as _,ID as a,Sb as at,BD as b,YD as c,yb as ct,_O as d,Pd as dt,dw as et,lO as f,zd as ft,zD as g,As as gt,tO as h,nc as ht,gO as i,Tb as it,AD as j,wO as k,RD as l,Fd as lt,sO as m,yd as mt,ZO as n,sw as nt,hO as o,_b as ot,nO as p,kd as pt,oT as q,EO as r,KC as rt,WD as s,vb as st,kO as t,ow as tt,bO as u,Nd as ut,pO as v,JD as w,GD as x,mO as y,PT as z};
|