@deslop/auth 0.1.1232 → 0.1.1233
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/apple-touch-icon.png +0 -0
- package/dist/client/assets/(home)-DGkpAbto.js +20 -0
- package/dist/client/assets/badge-BZyO-IMU.js +1 -0
- package/dist/client/assets/client-sCUiygGT.js +3 -0
- package/dist/client/assets/components-DfiHr7mH.js +1 -0
- package/dist/client/assets/effect-BhsQyU3F.js +17 -0
- package/dist/client/assets/icon-3Ql0zGr9.svg +1 -0
- package/dist/client/assets/index-CSiVAR-F.js +2 -0
- package/dist/client/assets/index-JDesZTgz.css +2 -0
- package/dist/client/assets/people-CED21lpE.js +1 -0
- package/dist/client/assets/route-a1N8Et11.js +1 -0
- package/dist/client/index.html +5 -6
- package/dist/server.js +3 -5
- package/package.json +2 -2
- package/dist/client/assets/(home)-z5DgkqYX.js +0 -20
- package/dist/client/assets/client-ClOiXUNj.js +0 -3
- package/dist/client/assets/components-DTFf2XAX.js +0 -1
- package/dist/client/assets/effect-CP5U-98U.js +0 -17
- package/dist/client/assets/icon-Dd-FeRxo.svg +0 -1
- package/dist/client/assets/icon-dark-zztc3HXC.svg +0 -1
- package/dist/client/assets/index-BAY46bLf.js +0 -2
- package/dist/client/assets/index-C0ARHuy4.css +0 -2
- package/dist/client/assets/people-BDrchAkk.js +0 -1
- package/dist/client/assets/route-BTMqZrJS.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./rolldown-runtime-WkwZ5CU-.js";import{a as n,i as r,n as i,o as a,s as o,t as s}from"./react-BUjtWCUj.js";import{A as c,B as l,C as u,D as d,E as f,F as p,G as m,H as h,I as g,J as _,K as v,L as y,M as b,N as x,O as S,P as C,Q as w,R as T,S as E,T as D,U as O,V as k,W as A,X as j,Y as M,Z as N,_ as P,a as F,b as I,c as L,d as R,f as ee,g as z,h as B,i as V,j as te,k as ne,m as H,o as re,p as ie,q as ae,r as U,s as oe,t as se,u as ce,v as le,w as ue,x as de,y as fe,z as pe}from"./client-sCUiygGT.js";import{$ as me,$i as he,$n as ge,$t as _e,A as ve,Aa as ye,Ai as be,An as xe,Ar as Se,At as Ce,B as we,Ba as Te,Bi as Ee,Bn as De,Br as Oe,C as ke,Ca as Ae,Ci as je,Cn as Me,Cr as Ne,Ct as W,D as Pe,Da as Fe,Di as Ie,Dn as Le,Dr as Re,Dt as ze,E as Be,En as Ve,Er as G,Et as He,F as Ue,Fi as We,Fn as Ge,Fr as Ke,Ft as qe,G as Je,Gi as Ye,Gn as Xe,Gr as Ze,Gt as Qe,H as $e,Ha as et,Hi as tt,Hn as nt,Hr as rt,Ht as it,I as at,In as ot,Ir as st,J as ct,Ji as lt,Jn as ut,Jr as dt,Jt as ft,K as pt,Ki as mt,Kn as ht,Kr as gt,Kt as K,L as _t,Li as vt,Ln as yt,Lt as bt,M as xt,Ma as St,Mi as Ct,Mn as wt,Mr as Tt,N as Et,Na as Dt,Ni as Ot,Nn as kt,Nr as At,O as jt,Oi as Mt,On as Nt,Or as Pt,Ot as Ft,P as It,Pa as q,Pi as Lt,Pn as Rt,Pr as zt,Pt as Bt,Q as Vt,Qi as Ht,Qn as Ut,Qr as Wt,Qt as Gt,R as Kt,Ri as qt,Rn as J,Rr as Jt,Rt as Yt,S as Xt,Sa as Zt,Si as Qt,Sn as $t,Sr as en,St as tn,T as nn,Ta as rn,Ti as an,Tn as on,Tr as sn,U as cn,Ui as ln,Un as un,Ur as dn,Ut as fn,V as pn,Va as mn,Vi as hn,Vn as gn,Vr as _n,Vt as vn,W as yn,Wi as bn,Wn as xn,Wr as Sn,Wt as Cn,X as wn,Xi as Tn,Xn as En,Xr as Dn,Xt as On,Y as kn,Yi as An,Yn as jn,Yr as Mn,Yt as Nn,Z as Pn,Zi as Fn,Zn as In,Zr as Ln,Zt as Rn,_a as zn,_i as Bn,_n as Vn,_r as Hn,_t as Un,a as Wn,aa as Gn,ai as Kn,an as qn,ar as Jn,at as Yn,b as Xn,ba as Zn,bi as Qn,bn as $n,br as er,bt as tr,ca as nr,ci as rr,cn as ir,cr as ar,ct as or,d as sr,da as cr,di as lr,dn as ur,dr,ea as fr,en as pr,er as mr,et as hr,f as gr,fa as _r,fi as vr,fn as yr,fr as br,ft as xr,ga as Sr,gi as Cr,gn as wr,gr as Tr,gt as Er,h as Dr,ha as Or,hi as kr,hn as Ar,hr as jr,ht as Mr,i as Nr,ia as Pr,in as Fr,ir as Ir,it as Lr,j as Rr,ja as zr,jn as Br,jr as Vr,jt as Hr,k as Ur,ka as Wr,ki as Gr,kn as Kr,kr as qr,l as Jr,la as Yr,li as Xr,ln as Zr,lr as Qr,lt as $r,ma as ei,mi as ti,mn as ni,mr as ri,mt as ii,n as ai,na as oi,nn as si,nr as ci,oa as li,oi as ui,on as di,or as fi,ot as pi,pa as mi,pi as hi,pn as gi,pr as _i,pt as vi,q as yi,qi as bi,qn as xi,qr as Si,qt as Ci,r as wi,ra as Ti,rn as Ei,rr as Di,rt as Oi,sa as ki,si as Ai,sn as ji,sr as Mi,st as Ni,t as Pi,ta as Fi,tn as Ii,tr as Li,u as Ri,ua as zi,ui as Bi,un as Vi,ur as Hi,ut as Ui,v as Wi,va as Gi,vi as Ki,vn as qi,vr as Ji,vt as Yi,w as Xi,wa as Zi,wi as Qi,wn as $i,wr as ea,wt as ta,x as na,xa as ra,xi as ia,xn as aa,xr as oa,xt as sa,y as ca,ya as la,yi as ua,yn as da,yr as fa,yt as pa,z as ma,zi as ha,zn as ga,zr as _a}from"./effect-BhsQyU3F.js";var va={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`}]]};va.node;var ya=j(va),ba={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};ba.node;var xa=j(ba),Sa={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};Sa.node;var Ca=j(Sa),wa={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`}]]};wa.node;var Ta=j(wa),Ea={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`}]]};Ea.node;var Da=j(Ea),Oa={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Oa.node;var ka=j(Oa),Aa={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`}]]};Aa.node;var ja=j(Aa),Ma={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};Ma.node;var Na=j(Ma),Y=e(o(),1),X=a(),Pa=w(),Fa=N(),Ia=e(n(),1),La=i();function Ra(e){return e?.ownerDocument||document}var za=e(s(),1);function Ba(e){let t=za.unstable_scheduleCallback(4,e);return()=>za.unstable_cancelCallback(t)}var Va=Y.createContext(It({scheduleTask:Ba,defaultIdleTTL:400})),Ha=new WeakMap,Ua=0,Wa=new Set;function Ga(e){Ua++;try{return e()}finally{Ua--}}function Ka(e){if(Ua===0)return e();Wa.size===0&&queueMicrotask(qa),Wa.add(e)}function qa(){for(let e of Wa)Wa.delete(e),e()}function Ja(e,t){let n=Ha.get(e);n===void 0&&(n=new WeakMap,Ha.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,()=>Ka(n));return()=>{i--,Wa.delete(n),r()}},snapshot(){return Ga(()=>e.get(t))},getServerSnapshot(){return(i===0||a===void 0)&&(a={value:Ga(()=>na(t,e))}),a.value}};return n.set(t,o),o}function Ya(e,t){let n=Ja(e,t);return Y.useEffect(qa),Y.useSyncExternalStore(n.subscribe,n.snapshot,n.getServerSnapshot)}function Xa(e,t){Y.useEffect(()=>e.mount(t),[t,e])}function Za(e,t,n){return n?.mode===`promise`||n?.mode===`promiseExit`?Y.useCallback(r=>{e.set(t,r);let i=_i(Et(e,t,{suspendOnWaiting:!0}));return n.mode===`promise`?i.then(Qa):i},[e,t,n.mode]):Y.useCallback(n=>{e.set(t,typeof n==`function`?n(e.get(t)):n)},[e,t])}var Qa=e=>{if(Qt(e))return e.value;throw vt(e.cause)},$a=e=>{Xa(Y.useContext(Va),e)},eo=(e,t)=>{let n=Y.useContext(Va);return Xa(n,e),Za(n,e,t)},to=(e,t)=>{let n=Y.useContext(Va);return[Ya(n,e),Za(n,e,t)]},no={suspendOnWaiting:new WeakMap,default:new WeakMap};function ro(e,t,n){let r=n?no.suspendOnWaiting:no.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 io(e,t,n){let r=Ya(e,t);if(r._tag===`Initial`||n&&r.waiting)throw ro(e,t,n);return r}var ao=(e,t)=>{let n=io(Y.useContext(Va),e,t?.suspendOnWaiting??!1);if(n._tag===`Failure`&&!t?.includeFailure)throw vt(n.cause);return n};qt(`MachineSchemaEncodeError`);var oo=class extends qt(`MachineSchemaDecodeError`){},so=class extends qt(`InfiniteTransitionError`){},co=class extends qt(`StartupError`){},lo=class extends qt(`ChildAlreadyExistsError`){};qt(`ProcessLocalError`);var uo=class extends qt(`StoppedError`){},fo=e=>e instanceof so||e instanceof oo,po=e=>fo(e)?jn(e):ht(e),mo=e=>fo(e)||e instanceof co?e:new co({cause:Ie(e)}),ho=e=>e,go=`~effect/Machine/Target`,_o=Symbol(`effect/Machine/TargetSnapshot`),vo=Symbol(`effect/Machine/StateInput`),yo=Symbol(`effect/Machine/HistoryTarget`),bo=Symbol(`effect/Machine/InitialTarget`),xo=Symbol(`effect/Machine/ChoiceTarget`),So=Symbol(`effect/Machine/NoTarget`),Co=Symbol(`effect/Machine/Declined`),wo=Symbol(`effect/Machine/TargetSelection`),To=Symbol(`effect/Machine/StateUpdate`),Eo=Symbol(`effect/Machine/CombinedTarget`),Do=Symbol(`effect/Machine/SelectedBranch`),Oo=(e,t,n,r)=>Object.freeze({[wo]:wo,kind:e,scope:n,path:t,...r===void 0?{}:{updatePath:r}}),ko=Oo(`none`,void 0,`local`),Ao=e=>q(e,wo),jo=(e,t)=>Object.freeze({[To]:To,path:e,value:t}),Mo=e=>q(e,To),No=(e,t)=>Object.freeze({[Eo]:Eo,target:e,update:t}),Po=e=>q(e,Eo),Fo=(e,t,n,r)=>Object.freeze({[Do]:Do,owner:e,branchIndex:t,branchKey:n,result:r}),Io=e=>q(e,Do),Lo=Object.freeze({[So]:So}),Ro=()=>Lo,zo=e=>q(e,So),Bo=Object.freeze({[Co]:Co}),Vo=()=>Bo,Ho=e=>q(e,Co),Uo=(e,t)=>({[yo]:yo,path:e,parent:t}),Wo=e=>q(e,yo),Go=(e,t,n)=>({[bo]:bo,_tag:`InitialTarget`,path:e,value:t,...n===void 0?{}:{values:n}}),Ko=e=>q(e,bo),qo=(e,t,n)=>({[xo]:xo,path:e,parent:t,...n===void 0?{}:{values:n}}),Jo=e=>q(e,xo),Yo=(e,t)=>{if(!bt(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(!bt(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(bt(t))return{schema:t,output:void 0,annotations:it(t),type:`atomic`,history:void 0,initial:void 0,states:void 0};let n=q(t,`schema`)&&bt(t.schema)?t.schema:void 0,r=n===void 0?t.annotations:it(n);if(t.type===`parallel`&&!q(t,`states`))throw Error(`Machine.make expected parallel state "${e}" to declare child regions`);if(q(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:bt(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=bt(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}},Xo=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=Yo(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)}},Zo=e=>typeof e==`object`&&e&&`branches`in e&&Array.isArray(e.branches)?Array.from(e.branches):[],Qo=e=>typeof e==`object`&&e&&`declinable`in e&&e.declinable===!0?`declinable`:`required`,$o=e=>{let t=[];for(let n of e.stateNodes.byPath.values()){let r=ho(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:Zo(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:q(i,`reenter`)&&i.reenter===!0,acceptance:Qo(i),branches:Zo(i)})}r.always!==void 0&&t.push({source:n.path,trigger:{type:`always`},reenter:!1,acceptance:Qo(r.always),branches:Zo(r.always)}),r.onDone!==void 0&&t.push({source:n.path,trigger:{type:`done`},reenter:!1,acceptance:Qo(r.onDone),branches:Zo(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:Qo(a),branches:Zo(a)})}}}return t},es=(e,t,n)=>({[go]:go,[_o]:n?.snapshot,path:e,value:t,values:n?.values}),ts=e=>q(e,go),ns=e=>({[vo]:vo,input:e}),rs=e=>q(e,vo),is=e=>q(e,`path`)&&q(e,`value`),as=(e,t,n)=>{if(e.path===t)return Fe(e);if(e.path!==``&&!t.startsWith(`${e.path}.`))return rn();if(n!==void 0&&e.value!==void 0&&(n[e.path]=e.value),q(e,`state`)&&is(e.state))return as(e.state,t,n);if(q(e,`states`)&&typeof e.states==`object`&&e.states!==null){for(let r of Object.values(e.states))if(is(r)){let e=as(r,t,n);if(Zt(e))return e}}return rn()},Z=(e,t)=>{let n=e.stateNodes.byPath.get(t);if(n===void 0)throw Error(`Machine expected state path "${t}" to exist`);return n},os=e=>{if(e.schema===void 0)throw Error(`Machine state "${e.path}" has no value schema`);return e.schema},ss=new WeakMap,cs=Symbol(`effect/Machine/EventConstruction`),ls=new WeakMap,us=new WeakMap,ds=new WeakMap,fs=e=>{let t=e,n=us.get(t);if(n!==void 0)return n;let r=Ce(Cn(e));return us.set(t,r),r},ps=e=>{let t=e,n=ds.get(t);if(n!==void 0)return n;let r=Hr(Cn(e));return ds.set(t,r),r},ms=Symbol.for(`effect/Machine/protocol`),hs=e=>{let t=e[ms];if(t===void 0)throw Error(`Machine protocol is unavailable`);return t},gs=(e,t)=>{Object.defineProperty(e,ms,{value:t,enumerable:!1})},_s=e=>{let t=new Set,n=e=>{let r=e;if(!t.has(r)&&(t.add(r),q(e,`cases`)&&typeof e.cases==`object`&&e.cases!==null))for(let t of Object.values(e.cases))(typeof t==`object`&&t||typeof t==`function`)&&q(t,`make`)&&n(t)};for(let t of e)n(t);return t},vs=(e,t)=>{let n=ss.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},ys=e=>vs(e.events,`public`).schemas,bs=e=>vs(e.internalEvents,`internal`).schemas,xs=e=>vs(e.emittedEvents,`emitted`).schemas,Ss=e=>{let t=ys(e),n=bs(e),r=xs(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];gs(e,{event:Ft(a),emit:Ft(r),eventConstructors:_s(a),emissionConstructors:_s(r)})},Cs=(e,t)=>gs(t,hs(e)),ws=e=>q(e,`_tag`)?String(e._tag):void 0,Ts=(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={[cs]:cs,_tag:n};return ls.set(o,{kind:e,schema:t,input:i,...a===void 0?{}:{inputError:a}}),Object.freeze(o)},Es=e=>typeof e==`object`&&!!e&&ls.has(e),Ds=(e,t)=>{let n=[],r=e=>{if(q(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(q(e,`members`)&&Array.isArray(e.members))for(let t of e.members)r(t);else n.push(e)};for(let e of t)r(e);let i=Object.create(null),a=e=>Ci(e)?typeof e.literal==`string`||typeof e.literal==`number`?[e.literal]:[]:si(e)?[e.symbol]:K(e)?e.enums.map(([,e])=>e):Ii(e)?e.types.flatMap(a):Gt(e)?a(e.thunk()):[],o=e=>{let t=Ei(e.ast);if(Nn(t)){let e=t.propertySignatures.find(({name:e})=>e===`_tag`),n=e===void 0?[]:a(e.type);if(n.length>0)return n}try{return Ft([e]).pipe(fn(`_tag`)).discriminants}catch{return[]}};for(let t of n){let n=o(t);if(n.length!==0)for(let r of n){if(q(i,r))throw Error(`Duplicate machine event constructor tag: ${String(r)}`);Object.defineProperty(i,r,{value:(...n)=>Ts(e,t,r,n.length===0?{}:n[0]),enumerable:!0})}}return i},Os=(e,t)=>{let n=Object.freeze(Array.from(t)),r=Ds(e,n);return ss.set(r,{kind:e,schemas:n}),Object.freeze(r)},ks=(e,t,n,r)=>fs(t)(n).pipe(fi(t=>new oo({machineId:e.id,boundary:r.boundary,cause:t,...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}}))),As=(e,t,n,r)=>{let i=ps(t)(n);if(_r(i))throw new oo({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},js=(e,t,n,r)=>{try{return t.make(n)}catch(t){let n=t instanceof Error?t.cause:void 0;throw new oo({machineId:e.id,boundary:r.boundary,cause:Yt(t)?t:q(n,`~effect/SchemaIssue/Issue`)?new tn(n):Ie(t),...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}})}},Ms=(e,t,n)=>new oo({machineId:e.id,boundary:n,event:String(t._tag),cause:Ie(Error(`Constructed ${n} schema does not belong to the machine ${n} protocol`))}),Ns=(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}},Ps=(e,t,n,r)=>new oo({machineId:e.id,boundary:n,event:String(t._tag),cause:Ie(r)}),Fs=(e,t,n,r)=>{let i=ls.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)?jn(Ms(e,n,r)):Ne({try:()=>Ns(n,i),catch:t=>Ps(e,n,r,t)}).pipe(In(t=>i.schema.makeEffect(t).pipe(fi(t=>new oo({machineId:e.id,boundary:r,event:String(n._tag),cause:new tn(t)})))))},Is=(e,t,n,r)=>{let i=ls.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 Ms(e,n,r);let o;try{o=Ns(n,i)}catch(t){throw Ps(e,n,r,t)}return js(e,i.schema,o,{boundary:r,event:String(n._tag)})},Ls=(e,t)=>{let n=hs(e);if(Es(t))return Fs(e,n,t,`event`);let r=ws(t);return ks(e,n.event,t,r===void 0?{boundary:`event`}:{boundary:`event`,event:r})},Rs=(e,t)=>{let n=hs(e);if(Es(t))return Is(e,n,t,`event`);let r=ws(t);return As(e,n.event,t,r===void 0?{boundary:`event`}:{boundary:`event`,event:r})},zs=(e,t)=>{let n=hs(e);if(Es(t))return Fs(e,n,t,`emission`);let r=ws(t);return ks(e,n.emit,t,r===void 0?{boundary:`emission`}:{boundary:`emission`,event:r})},Bs=(e,t)=>{let n=hs(e);if(Es(t))return Is(e,n,t,`emission`);let r=ws(t);return As(e,n.emit,t,r===void 0?{boundary:`emission`}:{boundary:`emission`,event:r})},Vs=(e,t,n)=>As(e,t,n,{boundary:`input`}),Hs=(e,t,n)=>rs(n)?os(t).makeEffect(n.input).pipe(fi(n=>new oo({machineId:e.id,boundary:`state`,state:t.path,cause:new tn(n)}))):ks(e,os(t),n,{boundary:`state`,state:t.path}),Us=(e,t,n)=>rs(n)?js(e,os(t),n.input,{boundary:`state`,state:t.path}):As(e,os(t),n,{boundary:`state`,state:t.path}),Ws=(e,t,n)=>t.output===void 0?fa(n):ks(e,t.output,n,{boundary:`output`,state:t.path}),Gs=(e,t,n)=>t.output===void 0?n:As(e,t.output,n,{boundary:`output`,state:t.path}),Ks=(e,t)=>{let n=new Set(nc(e,t.parent)),r=n=>{let i=Z(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)&&!tc(r,t.parent))throw Error(`Machine history contains state "${r}" outside parent "${t.parent}"`);if(t.mode===`shallow`&&ec(r,t.parent)&&Z(e,r).parent!==t.parent)throw Error(`Machine shallow history contains deep descendant "${r}"`)}},qs=(e,t)=>{let n=new Map;for(let[r,i]of Object.entries(t.history??{})){let t=Z(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=Z(e,n);if(r.type===`history`||r.type===`choice`||!(tc(n,t.parent)||nc(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,Us(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}),Ks(e,n.get(r))}return n},Js=Ut(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*jn(new oo({machineId:e.id,boundary:`history`,state:r,cause:Ie(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`||!(tc(n,t.parent)||nc(e,t.parent).includes(n)))return yield*jn(new oo({machineId:e.id,boundary:`history`,state:n,cause:Ie(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*jn(new oo({machineId:e.id,boundary:`history`,state:n,cause:Ie(Error(`Machine snapshot contains a value for structural state "${n}"`))}))}else{if(!s)return yield*jn(new oo({machineId:e.id,boundary:`history`,state:n,cause:Ie(Error(`Machine snapshot omits remembered value for "${n}"`))}));o.set(n,yield*ks(e,os(r),i.values[n],{boundary:`history`,state:n}))}}if(!a.has(t.parent)||Object.keys(i.values).length!==o.size)return yield*jn(new oo({machineId:e.id,boundary:`history`,state:r,cause:Ie(Error(`Machine snapshot contains incomplete history record "${r}"`))}));n.set(r,{mode:i.mode,parent:t.parent,active:a,values:o});try{Ks(e,n.get(r))}catch(t){return yield*jn(new oo({machineId:e.id,boundary:`history`,state:r,cause:Ie(t)}))}}return n}),Ys=(e,t)=>{let n={};for(let[r,i]of t){let t=Array.from(i.active).sort((t,n)=>ic(e,t,n));n[r]={mode:i.mode,active:t,values:Object.fromEntries(i.values)}}return n},Xs=(e,t)=>({...e,machineReferences:{self:t.self,parent:t.parent}}),Zs=e=>e.machineReferences,Qs=new WeakMap,$s=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ec=(e,t)=>e!==t&&(t===``||e.startsWith(`${t}.`)),tc=(e,t)=>e===t||ec(e,t),nc=(e,t)=>{let n=Qs.get(e.stateNodes);n===void 0&&(n=new Map,Qs.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=Z(e,a).parent;return n.set(t,i),i},rc=(e,t)=>nc(e,t).length,ic=(e,t,n)=>Z(e,t).order-Z(e,n).order,ac=(e,t,n)=>Z(e,n).children.some(e=>t.active.has(e)),oc=(e,t)=>{let n=Array.from(t.active).filter(n=>!ac(e,t,n)).sort((t,n)=>ic(e,t,n));if(n.length===0)throw Error(`Machine expected an active leaf state`);return n},sc=(e,t)=>oc(e,t)[0],cc=(e,t,n)=>{let r=oc(e,t).filter(e=>tc(e,n));if(r.length===0)throw Error(`Machine expected state "${n}" to have an active leaf state`);return r[0]},lc=(e,t)=>{for(let n of t.active)if(Z(e,n).parent===void 0)return n;throw Error(`Machine expected an active root state`)},uc=(e,t,n)=>{let r={},i=nc(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},dc=(e,t,n)=>{let r=Z(e,n).parent;return r===void 0?void 0:t.values.get(r)},fc=(e,t)=>{let n=r=>t.active.has(r)?[r,...Z(e,r).children.flatMap(n)]:[];return e.stateNodes.roots.flatMap(n)},pc=(e,t,n)=>{let r=Z(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=pc(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=Z(e,i);a[r.key]=pc(e,t,i)}i.states=a}return i},mc=(e,t)=>{let n=pc(e,t,lc(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:Ys(e,t.history)}),n},hc=(e,t,n)=>{let r=pc(e,t,n);return t.history.size>0&&Object.assign(r,{history:Ys(e,t.history)}),r},gc=(e,t,n)=>{if(!q(n,`state`)||!is(n.state))throw Error(`Machine expected compound snapshot "${t.path}" to include an active child state`);let r=Z(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},_c=(e,t)=>{if(!q(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},vc=(e,t,n,r)=>{let i=Z(e,n),a=r[i.key];if(!$s(r,i.key)||!is(a))throw Error(`Machine expected parallel snapshot "${t.path}" to include region "${i.key}"`);let o=Z(e,String(a.path));if(o.path!==i.path)throw Error(`Machine expected snapshot "${o.path}" to be region "${i.path}"`);return a},yc=(e,t)=>{let n=new Set,r=new Map,i=t.completed,a=t=>{let i=Z(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,Us(e,i,t.value));if(i.type===`compound`&&a(gc(e,i,t)),i.type===`parallel`){let n=_c(i,t);for(let t of i.children)a(vc(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:qs(e,t)}},bc=(e,t)=>yc(e,t),xc=(e,t)=>{try{return yc(e,t)}catch(t){throw t instanceof oo?t:new oo({machineId:e.id,boundary:`configuration`,cause:Ie(t)})}},Sc=Ut(function*(e,t){let n=new Set,r=new Map,i=t.completed,a=Ut(function*(t){let i=Z(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*Hs(e,i,t.value));if(i.type===`compound`&&(yield*a(gc(e,i,t))),i.type===`parallel`){let n=_c(i,t);for(let t of i.children)yield*a(vc(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*Js(e,t)}}),Cc=(e,t)=>Sc(e,t).pipe(un(t=>{if(be(t))return En(We(t,t=>t instanceof oo?t:new oo({machineId:e.id,boundary:`configuration`,cause:Mt(t)})));let n=Gr(t);return Zt(n)&&n.value instanceof oo?jn(n.value):jn(new oo({machineId:e.id,boundary:`configuration`,cause:t}))})),wc=(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 nc(e,n.parent))t.active.has(r)&&o.add(r);for(let i of t.active)(i===n.parent||r===`deep`&&ec(i,n.parent)||r===`shallow`&&Z(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}},Tc=(e,t)=>e.history.get(t),Ec=(e,t,n)=>{let r=new Set(n.active),i=new Map(n.values),a=new Map,o=nc(e,n.parent),s=new Set(o);for(let c of o){let o=Z(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)tc(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}};Ut(function*(e,t,n,r,i){let a=Z(e,n),o=new Set,s=new Map,c=new Map,l=nc(e,a.path),u=new Set(l);for(let n of l){let c=Z(e,n);if(o.add(n),c.schema===void 0){if((n===a.path?r:i!==void 0&&$s(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*Hs(e,c,r));else if(i!==void 0&&$s(i,n))s.set(n,yield*Hs(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=Z(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)tc(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}}),Ut(function*(e,t,n,r){let i=yield*Sc(e,n),a=new Set(i.active),o=new Map(i.values),s=new Map(i.outputs),c=nc(e,String(n.path)),l=new Set(c);for(let i of c.slice(0,-1)){let s=Z(e,i);if(a.add(i),s.schema===void 0){if(r!==void 0&&$s(r,i))throw Error(`Machine structural target "${i}" cannot contain a value`)}else if(r!==void 0&&$s(r,i))o.set(i,yield*Hs(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=Z(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)tc(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&&$s(r,n))for(let[t,i]of Object.entries(r)){if(!tc(t,n))continue;let r=Z(e,t);if(a.add(t),r.schema===void 0)throw Error(`Machine structural target "${t}" cannot contain a value`);o.set(t,yield*Hs(e,r,i))}}}}return{active:a,values:o,outputs:s,history:new Map([...t.history,...i.history])}});var Dc=(e,t,n,r,i,a=!1)=>{let o=Z(e,n),s=new Set,c=new Map,l=new Map,u=nc(e,o.path),d=new Set(u);for(let n of u){let a=Z(e,n);if(s.add(n),a.schema===void 0){if((n===o.path?r:i!==void 0&&$s(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,Us(e,a,r));else if(i!==void 0&&$s(i,n))c.set(n,Us(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=Z(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)tc(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}},Oc=(e,t,n)=>{let r=Dc(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=Z(e,t);i.add(t),n.schema!==void 0&&a.set(t,Us(e,n,r))}return{...r,active:i,values:a}},kc=(e,t,n,r)=>{let i=yc(e,n),a=new Set(i.active),o=new Map(i.values),s=new Map(i.outputs),c=nc(e,String(n.path)),l=new Set(c);for(let i of c.slice(0,-1)){let s=Z(e,i);if(a.add(i),s.schema===void 0){if(r!==void 0&&$s(r,i))throw Error(`Machine structural target "${i}" cannot contain a value`)}else if(r!==void 0&&$s(r,i))o.set(i,Us(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=Z(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)tc(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&&$s(r,n))for(let[t,i]of Object.entries(r)){if(!tc(t,n))continue;let r=Z(e,t);if(a.add(t),r.schema===void 0)throw Error(`Machine structural target "${t}" cannot contain a value`);o.set(t,Us(e,r,i))}}}}return{active:a,values:o,outputs:s,history:new Map([...t.history,...i.history])}},Ac=(e,t,n)=>{if(ts(n)){let r=n[_o];if(r!==void 0){if(String(r.path)!==String(n.path))throw Error(`Machine expected target snapshot path to be "${n.path}"`);return kc(e,t,r,n.values)}return Dc(e,t,n.path,n.value,n.values)}if(is(n)){let r=xc(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`)},jc=(e,t)=>ho(e).handlers[t],Mc=(e,t,n)=>Z(e,n).children.find(e=>t.active.has(e)),Nc=(e,t)=>Z(e,t).type===`final`,Pc=(e,t)=>jc(e,t)?.onDone!==void 0,Fc=(e,t,n)=>{if(!t.active.has(n))return!1;let r=Z(e,n);if(r.type===`compound`){let r=Mc(e,t,n);return r!==void 0&&(n===``?!Pc(e,r)&&Fc(e,t,r):Nc(e,r))}if(r.type===`parallel`){for(let n of r.children)if(!Fc(e,t,n))return!1;return!0}return Nc(e,n)},Ic=(e,t)=>{let n=lc(e,t);return Fc(e,t,n)&&!Pc(e,n)},Lc=(e,t,n)=>e.has(t)?{path:t,output:e.get(t),isNew:!1}:(e.set(t,n),{path:t,output:n,isNew:!0}),Rc=Ut(function*(e,t,n,r,i){let a=Z(e,n),o=jc(e,n)?.output?.({state:t.values.get(n),containingState:dc(e,t,n),ancestors:uc(e,t,n),event:r,outputs:i});return yield*Ws(e,a,o)}),zc=Ut(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=Z(e,n);if(o.type===`compound`){let o=Mc(e,t,n);if(o===void 0||(n===``?Pc(e,o):!Nc(e,o)))return;let s=yield*zc(e,t,o,r,i,a);if(s===void 0)return;let c=Lc(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*zc(e,t,n,r,i,a);o===void 0?c=!1:s[Z(e,n).key]=o.output}if(!c)return;let l=Lc(i,n,yield*Rc(e,t,n,r,s));return l.isNew&&a.push(l),l}if(!Nc(e,n))return;let s=Lc(i,n,yield*Rc(e,t,n,r));return s.isNew&&a.push(s),s}),Bc=Ut(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=rc(e,n)-rc(e,t);return r===0?ic(e,t,n):r}))yield*zc(e,a,t,n,r,i);return{configuration:a,completions:i}}),Vc=(e,t,n,r,i)=>{let a=Z(e,n),o=jc(e,n)?.output?.({state:t.values.get(n),containingState:dc(e,t,n),ancestors:uc(e,t,n),event:r,outputs:i});return Gs(e,a,o)},Hc=(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=Z(e,n);if(o.type===`compound`){let o=Mc(e,t,n);if(o===void 0||(n===``?Pc(e,o):!Nc(e,o)))return;let s=Hc(e,t,o,r,i,a);if(s===void 0)return;let c=Lc(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=Hc(e,t,n,r,i,a);o===void 0?c=!1:s[Z(e,n).key]=o.output}if(!c)return;let l=Lc(i,n,Vc(e,t,n,r,s));return l.isNew&&a.push(l),l}if(!Nc(e,n))return;let s=Lc(i,n,Vc(e,t,n,r));return s.isNew&&a.push(s),s},Uc=(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=rc(e,n)-rc(e,t);return r===0?ic(e,t,n):r}))Hc(e,a,t,n,r,i);return{configuration:a,completions:i}},Wc=e=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine construction must be an object`);return e},Gc=(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 ns(Object.hasOwn(t,`data`)?t.data:{})}},Kc=(e,t,n={},r)=>{let i=e.byPath.get(t);if(i?.type===`atomic`||i?.type===`final`){let e=Wc(n);if(Reflect.ownKeys(e).some(e=>e!==`data`&&e!==`decoded`))throw Error(`Machine leaf construction accepts only data and decoded`);return es(t,Gc(i,e))}let a=new Map,o=(t,n)=>{let i=Wc(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=Gc(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=Wc(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=Wc(n);for(;u.states!==void 0;){let t=e.byPath.get(l),n=Wc(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=Wc(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 qo(l,d.parent??``,p);if(d.type===`atomic`||d.type===`final`)return es(l,f,{values:p});let m=new Map([...a].filter(([e])=>e.startsWith(`${l}.`)));return{...Go(l,f,p),...m.size===0?{}:{children:m}}},qc=(e,t,n)=>{let r=Wc(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 jo(t,Gc(i,r))},Jc=(e,t,n=``)=>{let r=Wc(t),i=e.byPath.get(n);Kc(e,n,r);let a=Gc(i,r);if(i.type===`choice`)return qo(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=Wc(r.states),s=Object.fromEntries(Object.entries(o).map(([t,r])=>[t,Jc(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]}},Yc=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(t);return e},Xc=`root`,Zc=e=>{let t=new Map,n=(e,r)=>{let i=!bt(e)&&`type`in e?e.type:void 0;if(t.set(r,i===`history`||i===`choice`?i:`state`),!bt(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 "${Xc}" is reserved for the root`);return t},Qc=(e,t)=>{let n=Zc(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(Yc(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(Yc(t.branches,`Machine branches must be a map`))){let t=Yc(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={...Yc(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 el({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}},$c=(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}},el=(e,t)=>{let n=[`target`,`history`,`none`,`initialize`].filter(e=>t[e]!==void 0);if(n.length===0&&t.update!==void 0){let n=$c(t.update,e);if(n.kind!==`state`)throw Error(`Machine update requires an active state reference`);return Oo(`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 ko}if(r===`initialize`){if(t.update!==void 0)throw Error(`Machine initialize cannot update a retained owner`);return Oo(`state`,``,`branch`)}let i=$c(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:$c(t.update,e).path;if(a!==void 0&&r!==`target`)throw Error(`Machine owner updates require an ordinary destination`);return Oo(i.kind,i.path,r===`history`?`full`:`branch`,a)},tl=(e,t,n,r)=>{let i=Yc(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`&&Ir(a.value))&&!(a.kind===`streams`&&Ar(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}},nl=Symbol(`effect/Machine/InitialEvent`),rl=Symbol(`effect/Machine/SnapshotBuilderState`),il=Symbol(`effect/Machine/ChildMachineLogic`),al=new WeakSet,ol=e=>al.has(e),sl=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine ${t} must be an object`);return e},cl=e=>typeof e==`function`?e:()=>e,ll=e=>{if(typeof e==`object`&&e&&q(e,`decoded`)&&e.decoded===!0&&q(e,`data`)){let t=sl(e,`decoded construction`);if(Reflect.ownKeys(t).some(e=>e!==`decoded`&&e!==`data`))throw Error(`Machine decoded construction accepts only decoded and data`);return cl(t.data)}let t=cl(e);return n=>ns(e===void 0?{}:t(n))},ul=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(!q(e,`data`))throw Error(`Machine decoded construction requires data`);return cl(e.data)}let t=cl(e.data);return n=>ns(q(e,`data`)?t(n):{})},dl=(e,t)=>{let n=(e,t,r)=>{if(q(t,`initialize`))throw Error(`Machine child construction belongs in initial declarations`);if(r!==``&&q(t,`root`))throw Error(`Machine root construction belongs at the root handler`);let{initial:i,root:a,states:o,...s}=t;if(bt(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?{}:sl(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?{}:sl(i,`parallel initial regions`);for(let[n,r]of Object.entries(t)){let t=e.states[n];if(t===void 0||!bt(t)&&(t.type===`history`||t.type===`choice`))throw Error(`Machine invalid initial region "${n}"`);if(!bt(t)&&(!(`schema`in t)||t.schema===void 0))throw Error(`Machine schema-less region "${n}" cannot construct data`);d[n]=ll(r)}}else{let t=sl(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||bt(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`&&(q(t,`data`)||q(t,`decoded`)))throw Error(`Machine choice initial edges cannot construct data`);let c=ul(t),l=e.states[a];if(q(t,`data`)&&!bt(l)&&(!(`schema`in l)||l.schema===void 0))throw Error(`Machine schema-less initial child "${a}" cannot construct data`);q(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?{}:sl(c[t],`state handler`),e);l[t]=a.node,(bt(i)||i.type!==`history`)&&(c[t]!==void 0||!bt(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{[rl]:i}};return al.add(g),{node:m,handlers:{...s,...h.length===0?{}:{initialize:g},states:u}}};return n(e.node,t,``)},fl=(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)},pl=e=>`child`in e?e.child.id:e.id,ml=(e,t)=>{let n=new Set;for(let r of e){let e=pl(r);if(n.has(e))throw Error(`Machine invocations for state "${t}" must have distinct ids; "${e}" is declared twice`);n.add(e)}},hl=e=>e===void 0?[]:Array.isArray(e)?e:[e],gl=e=>{let t=[],n=[],r=[];return{commands:t,raisedEvents:n,emittedEvents:r,enqueue:{raise:t=>{n.push(Rs(e,t))},emit:t=>{r.push(Bs(e,t))},sendTo:(e,n)=>{t.push({_tag:`SendTo`,target:e,event:n})},stop:e=>{t.push({_tag:`Stop`,child:e})}}}},_l=(e,t)=>{let n=e.stateNodes.byPath.get(t);if(n===void 0)throw Error(`Machine expected state path "${t}" to exist`);return n},vl=e=>{let t={};return Object.defineProperty(t,"decoded",{value:e,enumerable:!1}),Object.defineProperty(t,"from",{value:(...t)=>e(ns(t.length===0?{}:t[0])),enumerable:!1}),t},yl=e=>{let t={};return Object.defineProperty(t,rl,{value:e,enumerable:!1}),t},bl=(e,t,n)=>{let r=yl(n);for(let i of t.children){let a=_l(e,i);a.schema===void 0||q(n,a.key)||(r[a.key]=vl(r=>{let i=Object.assign({},n);return i[a.key]=r,bl(e,t,i)}))}return r},xl=(e,t)=>{let n=_l(e,t);if(n.type===`parallel`)return bl(e,n,{});if(n.type!==`compound`)throw Error(`Machine state "${t}" cannot initialize child states`);let r=_l(e,n.initial);if(r.schema===void 0)throw Error(`Machine state "${t}" has no schema-valued initial child`);return vl(e=>yl({[r.key]:e}))},Sl=(e,t)=>{if(typeof t!=`object`||!t||!q(t,rl))throw Error(`Machine initialize handler for "${e}" must return its builder result`);return t[rl]},Cl=Symbol(`effect/Machine/InvocationEvent`),wl=(e,t,n)=>({[Cl]:!0,path:e,id:t,type:`done`,output:n}),Tl=(e,t,n)=>({[Cl]:!0,path:e,id:t,type:`element`,element:n}),El=(e,t,n)=>({[Cl]:!0,path:e,id:t,type:`failure`,error:n}),Dl=(e,t,n)=>({[Cl]:!0,path:e,id:t,type:`snapshot`,snapshot:n}),Ol=e=>typeof e==`object`&&!!e&&Cl in e,kl=new WeakMap,Al=new WeakMap,jl=(e,t)=>e.parent===void 0?{self:t.self}:{self:t.self,parent:t.parent},Ml=(e,t)=>{let n=Object.create(e);return Al.set(n,jl(e,t)),n},Nl=(e,t)=>{let n=t.machineReferences;if(n!==void 0)return jl(e,n);let r=Al.get(e);if(r!==void 0)return r;let i=kl.get(e);if(i!==void 0)return i;let a=jl(e,{self:{id:e.id??`Machine`,sessionId:`Machine.plan`,send:()=>jn(new uo)},parent:void 0});return kl.set(e,a),a},Pl=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}},Fl=(e,t,n)=>{let r=gl(e);return t===void 0||t(n,r.enqueue),{commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents}},Il=(e,t,n,r)=>{let i=gl(e),a=r===void 0?{result:t(n,i.enqueue),branchIndex:0,branchKey:void 0}:r(n,i.enqueue);return Ho(a.result)?{declined:!0}:{declined:!1,state:zo(a.result)?void 0:a.result,branchIndex:a.branchIndex,branchKey:a.branchKey,commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents}},Ll=(e,t,n)=>{let r=gl(e);return{value:t(n,r.enqueue),commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents}},Rl=(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)=>ic(e,t,n))){let f=Z(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=Z(e,f.initial),m={active:i,values:a,outputs:t.outputs,history:t.history,machineReferences:t.machineReferences};if(p.type===`choice`){let t=mu(e,m,qo(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=Ko(i)?Bl(e,r,i,n):Wo(i)?Vl(e,r,i,n):void 0;r=Ac(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=ho(e).handlers[d]?.initialize;if(t===void 0){a.set(p.path,Us(e,p,ns({}))),u=!0;continue}let i=Ll(e,t,{...Nl(e,m),state:m.values.get(d),containingState:dc(e,m,d),ancestors:uc(e,m,d),event:n,...d===``&&r!==void 0?{input:r.value}:{},...ol(t)?{}:{builder:xl(e,d)}}),l=Sl(d,i.value);a.set(p.path,Us(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=>Z(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:ho(e).handlers[d]?.initialize,h=m===void 0?void 0:Ll(e,m,{...Nl(e,p),state:p.values.get(d),containingState:dc(e,p,d),ancestors:uc(e,p,d),event:n,...d===``&&r!==void 0?{input:r.value}:{},...ol(m)?{}:{builder:xl(e,d)}}),g=h===void 0?void 0:Sl(d,h.value);for(let t of l){let n=Z(e,t);if(i.add(n.path),n.schema!==void 0){if(h===void 0){a.set(n.path,Us(e,n,ns({})));continue}if(g===void 0||!Object.prototype.hasOwnProperty.call(g,n.key)){if(m!==void 0&&ol(m)){a.set(n.path,Us(e,n,ns({})));continue}throw Error(`Machine parallel state initializer for "${d}" must return region "${n.key}"`)}a.set(n.path,Us(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 zl(e,t,n,r){let i=Oc(e,t,n);if(n.children===void 0||![...n.children.keys()].some(t=>Z(e,t).type===`choice`))return Rl(e,i,r,n.input);let a=[],o=[],s=[],c=[];for(let t of n.children?.keys()??[]){let n=Z(e,t);if(n.type!==`choice`)continue;let l=mu(e,i,qo(t,n.parent),r);for(let t of[l.target,...l.additionalTargets]){let n=Ko(t)?Bl(e,i,t,r):Wo(t)?Vl(e,i,t,r):void 0;i=Ac(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=Rl(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 Bl(e,t,n,r){let i=zl(e,t,n,r),a=hc(e,i.configuration,n.path);return{target:es(n.path,a.value,{snapshot:a,values:n.values}),commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents,transitions:i.transitions}}function Vl(e,t,n,r){let i=Z(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=Tc(t,n.path);if(a!==void 0){let i=Rl(e,Ec(e,t,a),r),o=hc(e,i.configuration,n.parent),s=Object.fromEntries(i.configuration.values);return n.parent!==``&&t.active.has(``)&&delete s[``],{target:es(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=ho(e).handlers[n.parent]?.history?.[o]?.default;if(s===void 0)throw Error(`Machine history state "${n.path}" requires a default implementation`);let c=Il(e,s,{event:r,target:t=>Jc(e.stateNodes,t),owner:n.parent});if(c.state===void 0||Wo(c.state)||!is(c.state))throw Error(`Machine history default for "${n.path}" must return a complete snapshot containing its owner`);let l=fu(c.state)===void 0?void 0:mu(e,{active:new Set,values:new Map,outputs:new Map,history:t.history},c.state,r),u=l===void 0?xc(e,c.state):Ac(e,{active:new Set,values:new Map,outputs:new Map,history:t.history},l.target);for(let t of l?.additionalTargets??[])u=Ac(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=hc(e,u,n.parent),f=Object.fromEntries(u.values);return n.parent!==``&&t.active.has(``)&&delete f[``],{target:es(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 Hl=(e,t)=>{if(!t.transition.declinable)return t;let n=Il(e,t.transition.transition,t.context,t.transition.evaluate);return n.declined?void 0:{...t,collected:n}},Ul=(e,t)=>[...nc(e,t)].reverse(),Wl=(e,t,n)=>{let r=nc(e,t),i=nc(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},Gl=(e,t)=>{if(e!==void 0&&t!==void 0)return e===t||ec(e,t)?t:e},Kl=(e,t,n)=>Yl(e,Array.from(t.active).filter(e=>n===void 0||ec(e,n))),ql=(e,t,n)=>Xl(e,Array.from(t.active).filter(e=>n===void 0||ec(e,n))),Jl=(e,t)=>e.active.size===t.active.size&&Array.from(e.active).every(e=>t.active.has(e)),Yl=(e,t)=>Array.from(new Set(t)).sort((t,n)=>{let r=nc(e,n).length-nc(e,t).length;return r===0?Z(e,n).order-Z(e,t).order:r}),Xl=(e,t)=>Array.from(new Set(t)).sort((t,n)=>{let r=nc(e,t).length-nc(e,n).length;return r===0?ic(e,t,n):r}),Zl=(e,t,n,r)=>({...Nl(e,t),state:t.values.get(n),containingState:dc(e,t,n),ancestors:uc(e,t,n),event:r}),Ql=(e,t,n,r,i)=>({...Nl(e,t),state:t.values.get(n),containingState:dc(e,t,n),ancestors:uc(e,t,n),event:r,snapshot:i}),$l=(e,t,n,r,i,a)=>({...Nl(e,t),state:t.values.get(n),containingState:dc(e,t,n),ancestors:uc(e,t,n),event:r,output:i,snapshot:a}),eu=(e,t,n,r,i)=>{let a=[],o=[],s=[];for(let c of n){let n=Fl(e,ho(e).handlers[c]?.[i],Zl(e,t,c,r));a.push(...n.commands),o.push(...n.raisedEvents),s.push(...n.emittedEvents)}return{commands:a,emittedEvents:s,raisedEvents:o}},tu=(e,t,n)=>{let r=[],i=new Set,a=new Map,o,s=()=>o??=mc(e,t);for(let o of oc(e,t))for(let c of Ul(e,o)){let l=Pl(ho(e).handlers[c]?.always);if(l!==void 0){let u=a.get(c);if(a.has(c)||(u=Hl(e,{sourcePath:c,leafPath:o,trigger:{type:`always`},transition:l,context:{...Nl(e,t),state:t.values.get(c),containingState:dc(e,t,c),ancestors:uc(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},nu=(e,t,n,r)=>{let i=[],a=new Set,o,s=()=>o??=mc(e,t);for(let o of r){let r=Pl(ho(e).handlers[o.path]?.onDone);if(r!==void 0&&!a.has(o.path)){a.add(o.path);let c=Hl(e,{sourcePath:o.path,leafPath:cc(e,t,o.path),trigger:{type:`done`},transition:r,context:$l(e,t,o.path,n,o.output,s())});c!==void 0&&i.push(c)}}return i},ru=(e,t,n)=>{let r=[],i=new Set,a=new Map,o,s=()=>o??=mc(e,t);for(let o of oc(e,t))for(let c of Ul(e,o)){let l=Pl(ho(e).handlers[c]?.on?.[n._tag]);if(l!==void 0){let u=a.get(c);if(a.has(c)||(u=Hl(e,{sourcePath:c,leafPath:o,trigger:{type:`event`,event:n._tag},transition:l,context:Ql(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},iu=(e,t,n)=>{if(!t.active.has(n.path))return[];let r=ho(e).handlers[n.path],i=hl(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=Pl(n.type===`element`?i.onElement:n.type===`done`?i.onDone:n.type===`failure`?i.onFailure:i.onSnapshot);if(a===void 0)return[];let o=mc(e,t),s={...Nl(e,t),state:t.values.get(n.path),containingState:dc(e,t,n.path),ancestors:uc(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=Hl(e,{sourcePath:n.path,leafPath:cc(e,t,n.path),trigger:{type:`invoke`,id:n.id,outcome:n.type},transition:a,context:s});return c===void 0?[]:[c]},au=e=>{if(Wo(e)||Jo(e)||ts(e)||is(e))return String(e.path);throw Error(`Machine expected transition target to be a snapshot or target builder result`)},ou=(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(`, `)}`)}},su=(e,t)=>{for(let n of e)if(t.includes(n))return!0;return!1},cu=(e,t)=>Array.from(t).sort((t,n)=>ic(e,t.selection.sourcePath,n.selection.sourcePath)),lu=e=>e.filter(t=>!e.some(e=>e.sourcePath!==t.sourcePath&&ec(e.sourcePath,t.sourcePath))),uu=(e,t)=>{let n=[];for(let r of cu(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(su(r.exitPaths,i.exitPaths)||n){if(ec(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},du=(e,t={})=>{let n={...t},r=[],i=e=>{if(Jo(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:qo(e.path,e.parent,n),values:n}))},fu=(e,t={})=>du(e,t)[0],pu=(e,t)=>{if(Jo(e))return qo(e.path,e.parent,{...t,...e.values??{}});if(Ko(e))return{...e,values:{...t,...e.values}};if(!ts(e)||Object.keys(t).length===0)return e;let n=e[_o];return es(e.path,e.value,{...n===void 0?{}:{snapshot:n},values:{...t,...e.values??{}}})};function mu(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=du(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 so({machineId:e.id,state:d.target.path,maxIterations:gu});let f=Z(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=ho(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=Z(e,t);r.schema!==void 0&&m.set(t,Us(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=Il(e,p.transition,{...Nl(e,h),containingState:dc(e,h,f.path),ancestors:uc(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`);ou(f.path,{type:`choice`},p.targets,g.state);let _=au(g.state);n=pu(g.state,d.values);let v=fu(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(!ts(n)&&!is(n)&&!Wo(n)&&!Ko(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 hu=(e,t,n)=>{let r=n.leafPath,i=n.collected??Il(e,n.transition.transition,n.context,n.transition.evaluate);if(i.declined)throw Error(`Machine transition returned decline without declaring declinable: true`);let a=Po(i.state)?i.state:void 0,o=a?.target??i.state,s=o===void 0||Mo(o)?void 0:o;ou(n.sourcePath,n.trigger,n.transition.targets,s);let c=a?.update??(Mo(o)?o:void 0),l=c===void 0?void 0:(()=>{let n=Z(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:Us(e,n,c.value)}})(),u=l!==void 0&&(Ko(s)||Jo(s))?{...t,values:new Map(t.values).set(l.path,l.value)}:t,d=s===void 0?void 0:mu(e,u,s,n.context.event),f=d?.target??s,p=f!==void 0&&Ko(f)?Bl(e,u,f,n.context.event):void 0,m=p?.target??f,h,g=Wo(m)&&n.transition.reenter&&t.active.has(m.parent)?m:void 0;if(m!==void 0&&Wo(m)){let i=n.transition.reenter?Z(e,n.sourcePath).parent:Wl(e,r,m.parent),a=g===void 0?Kl(e,t,i):Yl(e,Array.from(t.active).filter(e=>tc(e,m.parent)));h=Vl(e,a.includes(m.parent)?wc(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(Ko(r)){let i=Bl(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(!Wo(r)){S.push(r);continue}let i=Vl(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?au(_):au(s),w=_===void 0?l===void 0?t:{...t,values:new Map(t.values).set(l.path,l.value)}:Ac(e,t,_);for(let t of S)w=Ac(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||!Jl(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?Z(e,n.sourcePath).parent:Wl(e,r,C),O=Z(e,n.sourcePath).parent,k=n.transition.reenter?Gl(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?Kl(e,t,k):Yl(e,Array.from(t.active).filter(e=>tc(e,g.parent))),entryPaths:g===void 0?ql(e,w,k):Xl(e,Array.from(w.active).filter(e=>tc(e,g.parent))),choiceTransitions:[...d?.transitions??[],...p?.transitions??[],...h?.transitions??[],...x]}},gu=1e3,_u={_tag:nl},vu=(e,t)=>Ic(e,bc(e,t)),yu=(e,t,n)=>Cc(e,t).pipe(In(t=>Bc(e,t,n)),In(t=>{let n=lc(e,t.configuration);return!Ic(e,t.configuration)||!t.configuration.outputs.has(n)?ht(Error(`Machine attempted to read terminal output from a non-terminal configuration`)):fa(t.configuration.outputs.get(n))})),bu=(e,...t)=>{let n=e.input===void 0?t:t.length===0?(Vs(e,e.input,void 0),t):[Vs(e,e.input,t[0])],r=e.initial(...n),i={active:new Set,values:new Map,outputs:new Map,history:new Map},a=Bl(e,i,r,_u),o=Ac(e,i,a.target),s=mc(e,o),c=fc(e,o),l=a.commands,u=a.raisedEvents,d=a.emittedEvents,f=eu(e,o,c,_u,`entry`),p=Su(e,o,_u,[...f.commands],[...u,...f.raisedEvents],[...d,...f.emittedEvents],a.transitions.length===0?[]:[{next:o,event:_u,transitions:a.transitions,commands:l,raisedEvents:[...u],emittedEvents:d,exitPaths:[],entryPaths:[],changed:!1,stabilize:!1}]),m={startingState:s,initialEntryPaths:c,state:mc(e,p.next),commands:[...l,...p.commands],emittedEvents:p.emittedEvents,microsteps:p.microsteps.map(t=>({next:mc(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}},xu=(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=lu(r),a=[];for(let n of i)a.push(hu(e,t,n));let o=uu(e,a),s=cu(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:au(e.unresolvedTarget),resolvedTarget:e.target===void 0?void 0:au(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=Ac(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=Yl(e,s.flatMap(e=>e.exitPaths)),_=Xl(e,s.flatMap(e=>e.entryPaths));l=wc(e,t,l,g);let v=eu(e,t,g,n,`exit`),y=eu(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}},Su=(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 so({machineId:e.id,state:String(sc(e,s)),maxIterations:gu});let t=Uc(e,s,c);for(s=t.configuration,m.push(...t.completions.filter(t=>ho(e).handlers[t.path]?.onDone!==void 0));m.length>0&&!s.active.has(m[0].path);)m.shift();let n=nu(e,s,c,m.length===0?[]:[m.shift()]);if(n.length>0){let t=xu(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(Ic(e,s)){let t=lc(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?tu(e,s,c):[];if(h.length>0){let t=xu(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=ru(e,s,_);if(v.length===0){l=!0;continue}let y=xu(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}},Cu=(e,t,n)=>{let r=Ol(n)?n:Rs(e,n);if(Ic(e,t)){let n=Uc(e,t,r),i=lc(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=Ol(r)?iu(e,t,r):ru(e,t,r);if(i.length===0)return{event:r,next:t,commands:[],emittedEvents:[],microsteps:[],done:!1,output:void 0};let a=xu(e,t,r,i),o=[...a.commands],s=[...a.raisedEvents],c=[...a.emittedEvents],l=[a];return{...Su(e,a.next,r,o,s,c,l),event:r}},wu=(e,...t)=>Ne({try:()=>bu(e,...t),catch:mo}),Tu=(e,t)=>({raise:n=>Ls(e,n).pipe(In(e=>t.sendTo(t.self,e))),emit:n=>zs(e,n).pipe(In(e=>t.emit(e)))}),Eu=(e,t)=>ge(e,e=>e._tag===`SendTo`?t.sendTo(e.target,e.event):t.stopChild(e.child),{discard:!0}),Du=(e,t)=>yt(Array.from(e,e=>t.emit(e)),{discard:!0}),Ou=new WeakMap,ku=e=>{let t=Ou.get(e);if(t!==void 0)return t;let n={self:{id:e.id??`Machine`,sessionId:`Machine.plan`,send:()=>jn(new uo)},parent:void 0};return Ou.set(e,n),n},Au=(e,t)=>{let n=t===void 0?ku(e):t;return e.parent===void 0?{self:n.self}:{self:n.self,parent:n.parent}},ju=new Set([`initialize`,`invoke`,`on`,`output`]),Mu=e=>{if(e===void 0)return!0;for(let t of Reflect.ownKeys(e))if(!ju.has(t))return!1;return!0},Nu=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=ho(e).handlers[a.path];if(!Mu(o))return;if(o?.on===void 0)continue;let s=new Map;for(let e of Reflect.ownKeys(o.on)){let t=Pl(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)=>ic(e,t,n)),r.sort((t,n)=>ic(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=>nc(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&&(ho(e).handlers[``]===void 0||Reflect.ownKeys(ho(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}},Pu=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()}),Fu=(e,t)=>t?{...e,next:Pu(e.next)}:e,Iu=(e,t,n)=>{e.values[t]=n},Lu=(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}},Ru=(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}},zu=(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=zu(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]=zu(e,t,i)}i.states=a}return i},Bu=(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=zu(e,t,n);return t.completedOrder.length>0&&(r.completed=t.completedOrder.map(n=>({path:e.nodes[n].path,output:t.outputs[n]}))),r},Vu=(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{...Au(e,a),state:n.values[r],containingState:o<0?void 0:n.values[o],ancestors:s,event:i,snapshot:Bu(t,n)}},Hu=Object.freeze([]),Uu=(e,t,n,r)=>{let i,a,o,s={raise:t=>{(a??=[]).push(Rs(e,t))},emit:t=>{(o??=[]).push(Bs(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:zo(c.result)?void 0:c.result,branchIndex:c.branchIndex,branchKey:c.branchKey,commands:i??Hu,raisedEvents:a??Hu,emittedEvents:o??Hu}},Wu=(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:Vu(e,t,n,c,r,i)})}}}return a},Gu=(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},Ku=(e,t,n,r,i)=>{if((ts(r)?t.indexByPath.get(String(r.path)):void 0)===i&&n.active[i]===1&&ts(r)&&r[_o]===void 0&&r.values===void 0&&n.completedOrder.length===0&&t.valued[i]){let a=n.values.slice();return a[i]=Us(e,t.nodes[i],r.value),{...n,values:a}}return Lu(t,Ac(e,Ru(t,n),r))},qu=(e,t,n,r)=>{let i=Uu(e,r.transition.transition,r.context,r.transition.evaluate),a=Po(i.state)?i.state:void 0,o=a?.target??i.state,s=a?.update??(Mo(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:Us(e,i,s.value)}})(),l=o===void 0||Mo(o)?void 0:o;ou(r.sourcePath,r.trigger,r.transition.targets,l);let u=l!==void 0&&Ko(l)?Bl(e,(()=>{let e=Ru(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&&!ts(d)&&!is(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=Pu(n);return e.values[t.indexByPath.get(c.path)]=c.value,e})():Ku(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||!Gu(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:au(d),g=h===void 0?t.nodes[r.sourceIndex].parent:Wl(e,r.leafPath,h),_=t.nodes[r.sourceIndex].parent,v=r.transition.reenter?Gl(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:Kl(e,Ru(t,n),v),entryPaths:ql(e,Ru(t,f),v),choiceTransitions:u?.transitions??[]}},Ju=(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:au(e.unresolvedTarget),resolvedTarget:e.target===void 0?void 0:au(e.target),updates:e.update===void 0?[]:[e.update.path]});if(i.length===1){let s=qu(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=cu(e,uu(e,i.filter(e=>!i.some(t=>t.sourceIndex!==e.sourceIndex&&ec(t.sourcePath,e.sourcePath))).map(r=>qu(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=Ku(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?Yl(e,s.flatMap(e=>e.exitPaths)):[],entryPaths:f?Xl(e,s.flatMap(e=>e.entryPaths)):[],changed:f}},Yu=(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 so({machineId:e.id,state:t.nodes[o.activeLeaves[0]].path,maxIterations:gu});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=Uc(e,Ru(t,o),s).configuration,i=lc(e,n);if(!n.outputs.has(i))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:r,next:Lu(t,n),commands:c??Hu,emittedEvents:u??Hu,microsteps:d??Hu,done:!0,output:n.outputs.get(i)}}let m=t.nodes[n].path,h=Pl(ho(e).handlers[m]?.on?.[s._tag]);if(h!==void 0){let r=Uu(e,h.transition,{...Au(e,a),state:o.values[n],containingState:void 0,ancestors:{},event:s,snapshot:Bu(t,o)},h.evaluate),f=Mo(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`);Iu(o,n,Us(e,r,f.value))}if(ou(m,{type:`event`,event:s._tag},h.targets,p),p!==void 0&&!ts(p)&&!is(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=ts(p)?p[_o]===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]?Iu(o,n,Us(e,t.nodes[n],p.value)):g=Ku(e,t,o,p,n)}let _=h.reenter||!Gu(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:au(p),resolvedTarget:p===void 0?void 0:au(p),updates:f===void 0?[]:[f.path]}]}:void 0,commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents,exitPaths:_?[m]:Hu,entryPaths:_?[t.nodes[v].path]:Hu,changed:_};o=g,(d??=[]).push(Fu(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??Hu,emittedEvents:u??Hu,microsteps:d??Hu,done:!1,output:void 0};f+=1,s=g}},Xu=(e,t,n,r,i,a)=>{if(Ol(r)){let i=Cu(e,a===void 0?Ru(t,n):Xs(Ru(t,n),a),r);return{event:i.event,next:Lu(t,i.next),commands:i.commands,emittedEvents:i.emittedEvents,microsteps:i.microsteps.map(e=>({next:Lu(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=Rs(e,r);if(t.flat)return Yu(e,t,n,o,i,a);if(t.finalIndices.some(e=>n.active[e]===1)){let r=Ru(t,n);if(Ic(e,r)){let n=Uc(e,r,o).configuration,i=lc(e,n);if(!n.outputs.has(i))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:o,next:Lu(t,n),commands:[],emittedEvents:[],microsteps:[],done:!0,output:n.outputs.get(i)}}}let s=Wu(e,t,n,o,a);if(s.length===0)return{event:o,next:n,commands:[],emittedEvents:[],microsteps:[],done:!1,output:void 0};let c=Ju(e,t,n,o,s,i),l=c.next,u=o,d=[...c.commands],f=[...c.raisedEvents],p=[...c.emittedEvents],m=[Fu(c,i)],h=0,g=0;for(;;){if(g+=1,g>1e3)throw new so({machineId:e.id,state:t.nodes[t.leafIndices.find(e=>l.active[e]===1)].path,maxIterations:gu});if(t.finalIndices.some(e=>l.active[e]===1)){let n=Uc(e,Ru(t,l),u).configuration;if(l=Lu(t,n),Ic(e,n)){let t=lc(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=Wu(e,t,l,n,a);if(r.length===0)continue;let s=Ju(e,t,l,n,r,i);l=s.next,d.push(...s.commands),f.push(...s.raisedEvents),p.push(...s.emittedEvents),m.push(Fu(s,i))}},Zu=new WeakMap,Qu=e=>({fromConfiguration:e=>e,toConfiguration:e=>e,snapshot:t=>mc(e,t),plan:(t,n,r,i)=>Cu(e,i===void 0?t:Xs(t,i),n)}),$u=(e,t)=>({fromConfiguration:e=>Lu(t,e),toConfiguration:e=>Ru(t,e),snapshot:e=>Bu(t,e),plan:(n,r,i=!1,a)=>Xu(e,t,n,r,i,a),...Object.values(ho(e).handlers).some(e=>e.initialize!==void 0&&!ol(e.initialize))?{}:{initial:(n,r)=>{let i=e.input===void 0?n:n.length===0?(Vs(e,e.input,void 0),n):[Vs(e,e.input,n[0])],a=e.initial(...i),o=Ko(a)?zl(e,{active:new Set,values:new Map,outputs:new Map,history:new Map,...r===void 0?{}:{machineReferences:r}},a,_u).configuration:xc(e,a),s=Uc(e,r===void 0?o:Xs(o,r),_u).configuration,c=Lu(t,s),l=Bu(t,c);if(!Ic(e,s))return{state:l,configuration:c,activeConfiguration:s,initialEntryPaths:fc(e,s),done:!1,output:void 0};let u=lc(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:fc(e,s),done:!0,output:s.outputs.get(u)}}}}),ed=e=>{let t=Zu.get(e);if(t!==void 0)return t;let n=Nu(e),r=n===void 0?Qu(e):$u(e,n);return Zu.set(e,r),r},td=`Machine.invocation:`,nd=e=>e.startsWith(td),rd=(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,vr(t,G)}},id=e=>er(()=>{if(e.values!==void 0){let t=e.values;return e.values=void 0,fa(t)}let t=Cr();return e.waiter=t,Bi(t).pipe(J(id(e)))}),ad=(e,t)=>e._tag===`Started`&&(typeof t==`string`||e.descriptor!==void 0&&e.descriptor.id===t.id&&e.descriptor.machine===t.machine),od=(e,t,n)=>{if(e.closed)return rn();let r=e.children.get(t);return r!==void 0&&ad(r,n)?Fe(r.ref):rn()},sd=e=>{if(e.observers!==void 0)for(let t of e.observers)rd(t,od(e,t.id,t.child))},cd=(e,t,n)=>{let r=e.children.get(t);r!==void 0&&r.token===n&&(e.children.delete(t),typeof t==`string`&&sd(e))},ld=(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`&&sd(e),!0},ud=e=>ci(function*(){let t=yield*Rt(),n=0,r=0,i=0,a=0;return{rootSessionId:e,stream:ni(t).pipe($n(oa(()=>{n+=1})),ur(oa(()=>{--n}))),isActive:()=>n>0,nextDeliveryId:()=>i++,nextMacrostepId:()=>a++,publishUnsafe:i=>{n!==0&&xe(t,{...i,sequence:r++,rootSessionId:e})},close:Br(t)}}),dd=e=>({id:e.id,sessionId:e.sessionId}),fd=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?dd(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?dd(t):{id:String(t.id)}}]:[]}return[]}),pd=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:fd(Array.isArray(e.commands)?e.commands:[]),exitPaths:Array.isArray(e.exitPaths)?e.exitPaths:[],entryPaths:Array.isArray(e.entryPaths)?e.entryPaths:[],changed:e.changed===!0})),md=Symbol.for(`effect/Machine/activeSnapshotObserver`),hd=Symbol.for(`effect/Machine/snapshotObserver`),gd=e=>typeof e==`object`&&!!e&&hd in e,_d=Symbol.for(`effect/Machine/sendParentOverride`),vd=Symbol.for(`effect/Machine/acknowledgedSend`),yd=Symbol(`effect/Machine/AcknowledgedMessage`),bd=e=>typeof e==`object`&&!!e&&yd in e,xd=e=>bd(e)?e.event:e,Sd=(e,t)=>{e!==void 0&&bd(e)&&(e.deferred!==void 0&&vr(e.deferred,fa(t)),e.inspection?.complete(t))},Cd=(e,t)=>{e!==void 0&&bd(e)&&e.deferred!==void 0&&vr(e.deferred,En(t))},wd=e=>{e!==void 0&&bd(e)&&e.deferred!==void 0&&vr(e.deferred,jn(new uo))},Td=e=>typeof e==`object`&&!!e&&`send`in e&&typeof e.send==`function`,Ed=(e,t,n,r)=>`inspectionSubject`in e&&`sendInspected`in e&&typeof e.sendInspected==`function`?e.sendInspected(t,n,r):e.send(t),Dd=e=>e?._tag===`Childless`||e?.childless===!0,Od=(e,t)=>{let n=e.items??[];e.items=n,n.push(t)},kd=e=>{if(e.items===void 0)return rn();let t=e.items[e.index];return e.index+=1,e.index===e.items.length&&(e.items=void 0,e.index=0),Fe(t)},Ad=e=>{if(e.items!==void 0)for(let t=e.index;t<e.items.length;t+=1)wd(e.items[t]);e.closed=!0,e.items=void 0,e.index=0},jd=()=>({items:void 0,index:0,closed:!1,receivers:new Set}),Md=(e,t,n)=>{if(e.closed)return!1;for(Od(e,t),n?.();e.items!==void 0&&e.receivers.size>0;){let t=e.receivers.values().next().value;e.receivers.delete(t),t(G)}return!0},Nd=e=>er(()=>{let t=kd(e);return Zt(t)?fa(t.value):e.closed?Di:nt(t=>(e.receivers.add(t),oa(()=>{e.receivers.delete(t)}))).pipe(J(Nd(e)))}),Pd=e=>{Ad(e);let t=Array.from(e.receivers);e.receivers.clear();for(let e of t)e(Di)},Fd=class extends Ee()(`effect/Machine/MachineRuntime`){},Id=(e,t)=>Hi(e,Fd,t),Ld=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(Ot);if(t!==void 0)return{_tag:`Failure`,error:t.error,cause:e.cause,snapshot:e};let n=e.cause.reasons.find(Ct);return n===void 0?e.cause.reasons.find(Lt)===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}}},Rd=(e,t)=>er(()=>e(t)).pipe(ut,De),zd=(e,t)=>{class n{nextSessionId;constructor(){let e=0;this.nextSessionId=oa(()=>`machine:${e++}`)}get start(){return e}get startCompiledSync(){return t}}return oa(()=>new n)},Bd=(e,t,n)=>({id:t,sessionId:n,kind:e.inspection?.kind??`Logic`}),Vd=(e,t)=>t?{_tag:`Initialization`}:e!==void 0&&bd(e)&&e.inspection!==void 0?{_tag:`Macrostep`,macrostepId:e.inspection.macrostepId}:void 0,Hd=(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=pd(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{[yd]:!0,event:n,...a===void 0?void 0:{deferred:a},inspection:c}},Ud=(e,t,n)=>{if(!bd(n)||n.inspection===void 0)return;let r=n.inspection;e.publishUnsafe({_tag:`EventSent`,subject:t,deliveryId:r.deliveryId,source:r.source,target:dd(t),event:r.event,causedBy:r.causedBy})},Wd=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:G}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 er(()=>{if(this.registry.closed)return Di;if(this.has(t.key)||this.registry.children.has(t.id))return jn(new lo({id:t.duplicateId}));let a=e(),o=this.registry.scope??=rr(`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()?Ed(this.self,e,t,n):G,...this.sendAcknowledged===void 0?void 0:{[vd]:e=>i()?this.sendAcknowledged(e):Di}},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,ld(this.registry,t.id,n,e,t.descriptor)),onStopSync:()=>cd(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?In(this.runtime.nextSessionId,e=>this.runtime.startCompiledSync(a,c,this.scopedServices??=hn(this.services,Kn,o),e)):this.runtime.start(a,c)).pipe(ar(e=>Qt(e)?G:(cd(this.registry,t.id,n),r===void 0?G:r.stop)));return(u?d:Xr(d,o)).pipe(De)})}stopAll(){return er(()=>{let e=[];for(let t of this.registry.children.values())t.ownerActive&&e.push(this.stopEntry(t));return e.length===0?G:e.length===1?e[0]:yt(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]:yt(n,{concurrency:`unbounded`,discard:!0})}},Gd=Me(rn()).pipe(Zr(da)),Kd=e=>G,qd=(e,t)=>{},Jd=()=>void 0,Yd=Symbol(`effect/Machine/EmissionsClosed`),Xd=()=>{let e,t=er(()=>{let t=e;return t===Yd?fa(void 0):t===void 0?Rt().pipe(In(t=>oa(()=>{let n=e;return n===Yd?[void 0,!0]:n===void 0?(e=t,[t,!1]):[n,!0]}).pipe(In(([e,n])=>n?Br(t).pipe(ga(e)):fa(e))))):fa(t)});return{emit:t=>er(()=>e===void 0||e===Yd?G:Kr(e,t).pipe(De)),close:()=>{let t=e;return e=Yd,t===void 0||t===Yd?G:Br(t)},stream:Ve(t.pipe(Jn(e=>e===void 0?Vi:ni(e))))}},Zd={close:()=>G,spawn:(()=>ht(Error(`Childless machine logic cannot spawn a process`))),get:()=>fa(rn()),changes:()=>Gd,sendTo:()=>G,stop:()=>G,owned:{spawn:()=>ht(Error(`Childless machine logic cannot spawn an owned process`)),stopAll:()=>G,stopPaths:()=>void 0}},Qd=(e,t,n,r)=>{let i={closed:!1,children:new Map,observers:void 0,scope:void 0},a=e=>er(()=>{if(i.closed||(i.closed=!0,i.scope===void 0))return G;let t=Ai(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?G:Array.isArray(a)?yt(a,{concurrency:`unbounded`,discard:!0}):a}),o=(e,t)=>oa(()=>cd(i,e,t)),s=(e,t,n,r)=>oa(()=>ld(i,e,t,n,r)),c=e=>{let t=typeof e==`string`?e:e.id;return oa(()=>{if(i.closed)return rn();let n=i.children.get(t);return n!==void 0&&ad(n,e)?Fe(n.ref):rn()})},l=e=>{let t=typeof e==`string`?e:e.id;return gi(Nt((n,r)=>oa(()=>({child:e,id:t,values:void 0,waiter:void 0})).pipe(In(n=>{let a=oa(()=>{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 ui(r,a).pipe(J(oa(()=>{!i.closed&&r.state._tag!==`Closed`&&(i.observers??=new Set,i.observers.add(n)),rd(n,od(i,t,e))})),ga(id(n)))}))))},u=(e,t,n,r)=>{let a=typeof e==`string`?e:e.id;return er(()=>{if(i.closed)return G;let o=i.children.get(a);return o!==void 0&&ad(o,e)?Ed(o.ref,t,n,r):G})},d=e=>{let t=typeof e==`string`?e:e.id;return er(()=>{if(i.closed)return G;let n=i.children.get(t);return n!==void 0&&ad(n,e)?n.ref.stop:G})};function f(n,r){let a=typeof n==`object`&&n&&il in n?n:void 0,c=a===void 0?n:a[il](r?.input),l=a===void 0?r:{id:a.id,descriptor:a},u=Symbol(),d=l?.id??u,f;return er(()=>i.closed?Di:typeof d==`string`&&(i.children.has(d)||nd(d))?jn(new lo({id:d})):(i.scope??=rr(`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?.[md]===void 0?void 0:{onSnapshot:l[md]},...l?.[_d]===void 0?void 0:{sendParent:l[_d]},onReady:(e,t)=>oa(()=>{f=e}).pipe(J(s(d,u,e,l?.descriptor)),In(e=>e?G:t)),onStop:o(d,u),parent:e,runtime:t,origin:{_tag:`Spawn`,address:l?.id}}).pipe(ar(e=>ia(e)?o(d,u).pipe(J(f===void 0?G:f.stop)):G),Xr(i.scope))))}return{close:a,spawn:f,get:c,changes:l,sendTo:u,stop:d,owned:new Wd(i,e,t,n,r)}},$d=(e,t,n,r)=>oa(()=>Qd(e,t,n,r)),ef=(e,t)=>`${e.length}:${e}${t}`,tf=(e,t)=>`${td}${ef(e,t)}`,nf=e=>({initial:()=>G,run:()=>e}),rf=(e,t,n)=>({initial:()=>G,run:({parent:r})=>{let i=r?.[vd];return i===void 0?ht(Error(`Stream invocation requires an acknowledged parent machine`)):$t(e,e=>i(Tl(t,n,e)).pipe(De,un(()=>Di)))}}),af=(e,t)=>typeof e==`function`?e(t):e,of=e=>({spawn:((t,n)=>e.spawn(t,n)),sendTo:((t,n)=>e.sendTo(t,n)),stop:(t=>e.stopChild(t))}),sf=(e,t,n)=>{if(`effect`in e)return{id:String(e.id),sourceName:e.sourceName,src:()=>nf(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:()=>nf(Ji(af(e.after,t))),onDone:e.onDone,activityKind:`Timer`};if(`stream`in e){let r=String(e.id);return{id:r,sourceName:e.sourceName,src:()=>rf(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:()=>af(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[il](`input`in e?af(e.input,t):void 0),onDone:e.onDone,onFailure:e.onFailure,onSnapshot:e.onSnapshot}}throw Error(`Unsupported captured machine invocation: ${String(e)}`)},cf=e=>e.length===0?G:e.length===1?e[0]:yt(e,{discard:!0}),lf=(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(xn(`StoppedError`,()=>G)),uf=e=>e instanceof so||e instanceof oo||e instanceof uo,df=(e,t,n,r,i,a,o,s,c,l,u,d)=>er(()=>{let f=ef(n,r),p=u===void 0?o:()=>{let t=o();return{...t,run:i=>Pt(er(()=>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):G,onOutcome:(t,i,o)=>J(qr,er(()=>i._tag===`Stopped`||!t()?G:i._tag===`Done`?s===void 0?e.failCause(Ie(Error(`Invocation "${r}" completed without the required onDone handler`))):lf(e,wl(n,r,i.output),u===void 0?void 0:o):i._tag===`Failure`&&c!==void 0&&(a===void 0||!uf(i.error))?lf(e,El(n,r,i.error),u===void 0?void 0:o):e.failCause(i.cause))),...l===void 0?void 0:{onSnapshot:(t,i)=>t()?lf(e,Dl(n,r,i)):G}})}),ff=(e,t)=>nd(e)?jn(new lo({id:t})):void 0,pf=(e,t,n,r)=>{let i=String(r.id),a=r.address===void 0?void 0:ff(String(r.address),i);return a===void 0?df(e,t,n,i,r.address===void 0?tf(n,i):String(r.address),r.descriptor,r.src,r.onDone,r.onFailure,r.onSnapshot,r.activityKind,r.sourceName):a},mf=(e,t,n,r)=>{let i=r.child,a=ff(i.id,i.id);return a===void 0?df(e,t,n,i.id,i.id,i,i[il],r.onDone,r.onFailure,r.onSnapshot,void 0):a},hf=(e,t,n,r,i,a)=>{let o=of(t),s=Xl(e,i).filter(e=>r.active.has(e)).flatMap(i=>{let s={...Zs(r)??{self:t.self,parent:t.parent},children:o,state:r.values.get(i),containingState:dc(e,r,i),ancestors:uc(e,r,i),event:a};return hl(jc(e,i)?.invoke).map(e=>`child`in e&&!(`input`in e)?mf(t,n,i,e):pf(t,n,i,sf(e,s,i)))});return s.length===0?void 0:cf(s)},gf=Symbol(`effect/Machine/CompiledStoppedCompletion`),_f=class{logic;options;services;id;sessionId;inspectionSubject;send;sendInspected(e,t,n){return this.offerEvent(e,t,n)}[vd](e){return this.sendAcknowledgedEffect(e)}[hd](e){let t=this.snapshotObservers??=new Set;return t.add(e),()=>{t.delete(e)}}mailbox={items:void 0,index:0,closed:!1};address;childRuntime=Zd;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=Bd(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:er(()=>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 Vd(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:pd({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:ua(e)})}get execution(){return this.logic.execution}initializeCompiledSync(){this.publishCreated(),this.execution.childless||(this.childRuntime=Qd(this.address,this.options.runtime,this.services,e=>this.sendAcknowledgedEffect(e)));let e=this.options.parent,t=this.options.sendParent??(e===void 0?Kd:this.inspector===void 0?e.send:t=>Ed(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)=>Td(e)?this.inspector===void 0?e.send(t):Ed(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?qd:(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(Mt(e)),jn(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 vf(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?fa(this):(this.runState=`Draining`,Qr(this.drainRuntime(),this.services).pipe(ga(this)))}initialize(){let e=this;return ci(function*(){e.publishCreated(),e.execution.childless||(e.childRuntime=yield*$d(e.address,e.options.runtime,e.services,t=>e.sendAcknowledgedEffect(t)));let t=e.options.parent,n=e.options.sendParent??(t===void 0?Kd:e.inspector===void 0?t.send:n=>Ed(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)=>Td(t)?e.inspector===void 0?t.send(n):Ed(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?qd:(t,n=[])=>{e.initialEntryPaths=t,e.initialMicrosteps=n}};let r=t=>ia(t)?e.childRuntime.close(t):G,i=e.execution.initial,a=yield*(i===void 0?e.logic.initial(e.processScope).pipe(Jn(e=>({state:e,done:void 0,output:void 0}))):i(e.processScope)).pipe(ar(t=>(ia(t)&&e.publishStartFailed(t.cause),r(t))),xi(oa(()=>{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:Mi,poll:oa(()=>Ae(kd(e.mailbox),xd)),receiveMessage:Mi,pollMessage:oa(()=>e.pollCompiledMessage()),completeMessage:t=>e.completeCompiledMessage(t),state:oa(()=>e.current.snapshot.state),setState:t=>e.setActiveState(t),updateState:t=>e.updateState(t)}:(e.compiledContext=new vf(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(De))),e.options.onSnapshot!==void 0&&(yield*Rd(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 oa(()=>this.current.snapshot.state)}get snapshot(){return oa(()=>this.current.snapshot)}get changes(){return this.changesStream()}get emissions(){return this.externalEmissions?.stream??this.emissionsStream()}get join(){return er(()=>this.lifecycle===`Completed`?this.resolveCompletion(this.completion):(this.waiter??=Cr(),Bi(this.waiter)))}get stop(){return ea(this.stopEffect())}child(e){return this.childRuntime.get(e)}childChanges(e){return this.childRuntime.changes(e)}requestTermination(e){return oa(()=>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(De);return this.runState===`Initializing`?e:e.pipe(J(Di))}failCause(e){let t={_tag:`Failure`,cause:e};return this.requestTermination(t).pipe(In(e=>e?Li(this.settleRequestedTermination()).pipe(De):G))}sendAcknowledgedEffect(e){return sn(t=>kr().pipe(In(n=>this.offerEvent(e,void 0,void 0,n).pipe(J(t(Bi(n)))))))}offerEvent(e,t,n,r){return er(()=>{let i=this.inspector,a=this.inspectionSubject,o=i?.isActive()===!0&&a!==void 0?Hd(i,a,e,t,n,r):r===void 0?e:{[yd]:!0,event:e,deferred:r};return this.offerMessage(o)})}offerMessage(e){return ea(Re(t=>{if(this.mailbox.closed||this.lifecycle!==`Active`)return jn(new uo);let n=this.inspector,r=this.inspectionSubject;n!==void 0&&r!==void 0&&Ud(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&&Od(this.mailbox,e),this.runState!==`Idle`)return G;if(this.runState=`Draining`,o!==void 0){let n;try{n=o(a,e)}catch(e){n=ht(e)}return n!==void 0||this.hasTerminationRequest()?this.startWorker(n):(this.runState=`Idle`,this.scheduleChangesFlush(t.currentDispatcher),G)}return this.startWorker(void 0)}))}startWorker(e){let t=Qr(this.drainRuntime(e),this.services);return(this.options.detached===!0?Li(t,{startImmediately:!0}):mr(t,{startImmediately:!0})).pipe(In(e=>oa(()=>(e.pollUnsafe()===void 0&&(this.worker=e),this.interruptRequested?(this.interruptRequested=!1,!0):!1)).pipe(In(t=>t?Li(this.interruptAndFinish(e)):G))),De)}stopEffect(){return er(()=>this.lifecycle===`Completed`||this.finishIdleChildlessStop()?G:this.requestTermination({_tag:`Stopped`}).pipe(In(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!==Yd||this.current.terminalizing||this.current.snapshot.status!==`active`)return!1;this.emissionsPubSub=Yd;let e={status:`stopped`,state:this.current.snapshot.state};return this.lifecycle=`TerminationRequested`,this.termination={_tag:`Stopped`},this.terminationSnapshot=e,Ad(this.mailbox),this.current={revision:this.current.revision+1,terminalizing:!0,changes:void 0,snapshot:e},this.notifySnapshotObservers(),wd(this.inFlightMessage),this.inFlightMessage=void 0,this.interruptRequested=!1,this.compiledContext!==void 0&&(this.compiledContext.executionState=void 0),this.options.onStopSync?.(this),this.completion=gf,this.lifecycle=`Completed`,this.waiter!==void 0&&(vr(this.waiter,this.resolveCompletion(gf)),this.waiter=void 0),!0}settleRequestedTermination(){return er(()=>this.runState===`Draining`?this.worker===void 0?(this.interruptRequested=!0,this.awaitCompletion()):this.interruptAndFinish(this.worker).pipe(J(this.awaitCompletion())):this.finishRequestedTermination())}interruptAndFinish(e){return Ge(e).pipe(J(er(()=>this.lifecycle===`Completed`?G:this.finishRequestedTermination())))}awaitCompletion(){return this.lifecycle===`Completed`?G:this.join.pipe(ut,De)}resolveCompletion(e){if(e!==gf)return e;let t=jn(new uo);return this.completion=t,t}drainRuntime(e){let t=this;return sn(n=>ci(function*(){let r=t.offerRevision,i=e;for(;;){if(t.hasTerminationRequest())return yield*t.finishRequestedTermination();let e=yield*n(er(()=>{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(ut);if(t.flushPendingChanges(),ia(e))return t.lifecycle===`Active`&&(yield*t.requestTermination({_tag:`Failure`,cause:e.cause})),yield*t.finishRequestedTermination();if(Zt(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 er(()=>{if(this.lifecycle!==`TerminationRequested`)return G;let e=this.termination;if(e===void 0)return G;let t=this.terminationSnapshot??this.reserveTermination(e);if(t===void 0)return this.awaitCompletion();let n=e._tag===`Stopped`?Qi:e._tag===`Done`?je(e.output):ua(e.cause),r=e._tag===`Stopped`?gf:e._tag===`Done`?fa(e.output):En(e.cause),i=this.options.onOutcome===void 0||e._tag===`Stopped`&&this.options.skipStoppedOutcome===!0?G:er(()=>this.options.onOutcome(Ld(t))).pipe(ut,De),a=this.inspector,o=this.inspectionSubject,s=a===void 0||o===void 0?this.closeEmissions():this.closeEmissions().pipe(J(oa(()=>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`?Qn():n}))));return ea(oa(()=>{Ad(this.mailbox)}).pipe(J(this.childRuntime.close(n)),J(this.setAndPublishSnapshot(t)),J(s),J(oa(()=>{e._tag===`Failure`?Cd(this.inFlightMessage,e.cause):wd(this.inFlightMessage),this.inFlightMessage=void 0})),J(i),J(this.options.onStop??G),J(this.options.inspectionRoot===!0&&this.inspector!==void 0?this.inspector.close:G),J(oa(()=>{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&&(vr(this.waiter,this.resolveCompletion(r)),this.waiter=void 0)}))))})}publishSnapshot(e){let t=e.changes===void 0?fa(e):Kr(e.changes,[e]).pipe(ga(e)),n=e.snapshot;return this.options.onSnapshot===void 0||n.status!==`active`?t:t.pipe(en(()=>Rd(this.options.onSnapshot,n)))}completeChanges(e){return e.changes===void 0?G:Kr(e.changes,je(void 0)).pipe(De)}emitEvent(e){let t=this.externalEmissions===void 0?er(()=>this.emissionsPubSub===void 0||this.emissionsPubSub===Yd?G:Kr(this.emissionsPubSub,e).pipe(De)):this.externalEmissions.emit(e),n=this.inspector,r=this.inspectionSubject;return n===void 0||r===void 0?t:t.pipe(en(()=>oa(()=>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=Yd,e===void 0||e===Yd?G:Br(e)}getOrCreateEmissions(){return er(()=>{let e=this.emissionsPubSub;return e===Yd?fa(void 0):e===void 0?Rt().pipe(In(e=>oa(()=>{let t=this.emissionsPubSub;return t===Yd?[void 0,!0]:t===void 0?(this.emissionsPubSub=e,[e,!1]):[t,!0]}).pipe(In(([t,n])=>n?Br(e).pipe(ga(t)):fa(t))))):fa(e)})}emissionsStream(){return Ve(this.getOrCreateEmissions().pipe(Jn(e=>e===void 0?Vi:ni(e))))}setAndPublishSnapshot(e){return er(()=>{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(In(e=>this.completeChanges(e)),De)})}setActiveState(e){return er(()=>this.commitActiveState(e)??G)}pollCompiledMessage(){let e=kd(this.mailbox);return Zt(e)&&(this.inFlightMessage=bd(e.value)?e.value:void 0),e}beginCompiledMessage(e){this.inFlightMessage=bd(e)?e:void 0}completeCompiledMessage(e){Sd(this.inFlightMessage,e),this.inFlightMessage=void 0}compiledState(){return this.current.snapshot.state}commitCompiledState(e){return this.commitActiveState(e,!0)}commitActiveState(e,t=!1){let n=this.current;if(n.terminalizing||n.snapshot.status!==`active`)return;let r=n.pendingChanges;r!==void 0&&(n.pendingChanges=void 0);let i={status:`active`,state:e},a={revision:n.revision+1,snapshot:i,terminalizing:!1,changes:n.changes};return this.current=a,a.changes!==void 0&&(r===void 0?t?a.pendingChanges=[a]:xe(a.changes,[a]):(r.push(a),t?a.pendingChanges=r:xe(a.changes,r))),this.notifySnapshotObservers(),this.options.onSnapshot===void 0?void 0:Rd(this.options.onSnapshot,i)}notifySnapshotObservers(){if(this.snapshotObservers!==void 0)for(let e of this.snapshotObservers)e()}scheduleChangesFlush(e){this.changesFlushScheduled||this.current.pendingChanges===void 0||(this.changesFlushScheduled=!0,e.scheduleTask(()=>{this.changesFlushScheduled=!1,this.flushPendingChanges()},0))}flushPendingChanges(){let e=this.current,t=e?.pendingChanges;t!==void 0&&e.changes!==void 0&&(e.pendingChanges=void 0,xe(e.changes,t))}updateState(e){return er(()=>{let t=this.current;return t.terminalizing||t.snapshot.status!==`active`?G:e(t.snapshot.state).pipe(In(e=>{let n=this.current;return n.terminalizing||n.revision!==t.revision?G:this.setActiveState(e)}))})}getOrCreateChanges(){return er(()=>{let e=this.current;return e.snapshot.status===`active`?e.changes===void 0?Rt({replay:1}).pipe(In(e=>oa(()=>{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(In(([t,n])=>n?Br(e).pipe(ga(t)):fa(t))))):fa(e.changes):fa(void 0)})}changesStream(){let e=this;return Ve(ci(function*(){let t=yield*e.getOrCreateChanges();if(t===void 0)return Me(e.current.snapshot);let n=yield*wt(t),r=e.current;return r.snapshot.status===`active`?Me(r.snapshot).pipe(Zr(gi(Le(kt(n))).pipe(yr(e=>e.revision>r.revision),Vn(e=>e.snapshot)))):Me(r.snapshot)}))}},vf=class{scope;ownedChildren;process;executionState;constructor(e,t,n){this.scope=e,this.ownedChildren=t,this.process=n}poll(){return Ae(this.process.pollCompiledMessage(),xd)}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}},yf=Ut(function*(e,t){let n=t.sessionId??(yield*t.runtime.nextSessionId),r=yield*Xe(),i=e.execution,a=new _f(e,t,r,n);return yield*(i.initialSync!==void 0&&t.onReady===void 0&&t.onSnapshot===void 0?a.initializeCompiledSync():a.initialize()).pipe(ar(e=>ia(e)?a.shutdownEmissions().pipe(J(t.inspectionRoot===!0&&t.runtime.inspection!==void 0?t.runtime.inspection.close:G)):G))}),bf=(e,t,n,r)=>new _f(e,t,n,r).initializeCompiledSync(),xf=Ut(function*(e,t){let{detached:n,id:r,onOutcome:i,onReady:a,onReadySync:o,onSnapshot:s,onStop:c,onStopSync:l,parent:u,runtime:d,sendParent:f}=t,p=t.sessionId??(yield*d.nextSessionId),m=r??p,h=d.inspection,g=h===void 0?void 0:Bd(e,m,p),_=h===void 0||t.activity===void 0?void 0:{...t.activity,sessionId:p},v,y,b=jd(),x=t.emissions??Xd(),S=yield*kr(),C=yield*kr(),w=Bi(C).pipe(ut,De),T=!0,E,D=Ki(S,{_tag:`Stopped`}).pipe(De),O=(e,t)=>er(()=>Md(b,e,t)?G:jn(new uo)),k=h===void 0?void 0:(e,t,n,r)=>er(()=>{let i=h.isActive()?Hd(h,g,e,t,n,r):r===void 0?e:{[yd]:!0,event:e,deferred:r};return O(i,()=>Ud(h,g,i))}),A=e.execution?._tag===`Compiled`?e=>sn(t=>kr().pipe(In(n=>(h===void 0?O({[yd]:!0,event:e,deferred:n}):k(e,void 0,void 0,n)).pipe(J(t(Bi(n))))),Jn(e=>e))):void 0,j={id:m,sessionId:p,stop:er(()=>T?D:D.pipe(J(Mi))),send:h===void 0?e=>O(e):e=>k(e,void 0,void 0),...h===void 0?void 0:{inspectionSubject:g,sendInspected:k}},{changes:M,close:N,get:P,owned:F,sendTo:I,spawn:L,stop:R}=Zd;Dd(e.execution)||({changes:M,close:N,get:P,owned:F,sendTo:I,spawn:L,stop:R}=yield*$d(j,d,void 0,A===void 0?void 0:e=>A(e)));let ee=e=>Qt(e)?G:(h!==void 0&&h.publishUnsafe(_===void 0?{_tag:`StartFailed`,subject:g,cause:e.cause}:{_tag:`ActivityStopped`,subject:_.owner,activity:_,exit:e}),N(e).pipe(J(x.close()),J(t.inspectionRoot===!0&&h!==void 0?h.close:G))),z=l===void 0?c??G:oa(()=>l(Ee)),B=h===void 0?Jd:()=>Vd(E,T),V=f??(u===void 0?Kd:h===void 0?u.send:e=>Ed(u,e,g,B())),te=h===void 0?x.emit:e=>x.emit(e).pipe(en(()=>oa(()=>h.publishUnsafe({_tag:`Emitted`,subject:g,emission:e,causedBy:B()})))),ne={self:j,parent:u,spawn:L,sendParent:V,emit:te,sendTo:h===void 0?((e,t)=>Td(e)?e.send(t):I(e,t)):((e,t)=>Td(e)?Ed(e,t,g,B()):I(e,t,g,B())),stopChild:R,failCause:e=>Ki(S,{_tag:`Failure`,cause:e}).pipe(De),inspectInitial:h===void 0?qd:(e,t=[])=>{v=e,y=t}};h!==void 0&&h.publishUnsafe(_===void 0?{_tag:`Created`,subject:g,parent:u?.inspectionSubject,origin:t.origin??{_tag:`Root`},definition:e.inspection?.definition}:{_tag:`ActivityStarted`,subject:_.owner,activity:_});let H=yield*e.initial(ne).pipe(ar(ee),xi(oa(()=>{T=!1}))),re=yield*ai({revision:0,terminalizing:!1,changes:void 0,snapshot:{status:`active`,state:H}});_===void 0&&h?.publishUnsafe({_tag:`Initialized`,subject:g,snapshot:{status:`active`,state:H},initialEntryPaths:v??[],microsteps:pd({microsteps:y??[]})});let ie=s===void 0?e=>e.changes===void 0?fa(e):Kr(e.changes,[e]).pipe(ga(e)):e=>{let t=e.changes===void 0?fa(e):Kr(e.changes,[e]).pipe(ga(e)),n=e.snapshot;return n.status===`active`?t.pipe(en(()=>Rd(s,n))):t},ae=e=>e.changes===void 0?G:Kr(e.changes,je(void 0)).pipe(De),U=e=>e.snapshot.status===`active`?fa(e):ae(e).pipe(ga(e)),oe=e=>Pi(re).pipe(In(t=>t.revision===e.revision?ie(e).pipe(In(U)):fa(void 0))),se=e=>Nr(re,t=>t.terminalizing?fa([void 0,t]):Jn(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(In(e=>e===void 0?fa(void 0):oe(e)),Jn(e=>e?.snapshot)),ce=e=>wi(re,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(Jn(e=>e?.snapshot)),le=e=>Wn(re,t=>({revision:t.revision+1,snapshot:e,terminalizing:!0,changes:t.changes})).pipe(In(ie),In(U),De),ue=h===void 0?e=>se(t=>fa(t.status===`active`?{status:`active`,state:e}:void 0)).pipe(De):t=>Pi(re).pipe(In(n=>se(e=>fa(e.status===`active`?{status:`active`,state:t}:void 0)).pipe(en(r=>oa(()=>{e.inspection?.kind!==`Machine`&&r!==void 0&&h.publishUnsafe({_tag:`StateChanged`,subject:g,before:n.snapshot.state,after:t,causedByDeliveryId:E!==void 0&&bd(E)?E.inspection?.deliveryId:void 0})})))),De),de=(e,n,r)=>{let a=i===void 0||e.status===`stopped`&&t.skipStoppedOutcome===!0?G:er(()=>i(Ld(e))).pipe(ut,De),o=h===void 0?x.close():x.close().pipe(J(oa(()=>h.publishUnsafe(_===void 0?{_tag:`Terminated`,subject:g,snapshot:e}:{_tag:`ActivityStopped`,subject:_.owner,activity:_,exit:e.status===`stopped`?Qn():n}))));return ea(oa(()=>Pd(b)).pipe(J(N(n)),J(le(e)),J(o),J(oa(()=>{ia(n)?Cd(E,n.cause):wd(E),E=void 0})),J(a),J(z),J(t.inspectionRoot===!0&&h!==void 0?h.close:G),J(r)))},fe=ce(e=>({status:`stopped`,state:e.state})),pe=e=>ce(t=>({status:`error`,state:t.state,cause:e})),me=e=>ce(t=>({status:`done`,state:t.state,output:e})),he=e=>de(e,Qi,hi(C,new uo)),ge=(e,t)=>{let n=ua(t);return de(e,n,ti(C,t))},_e=(e,t)=>{let n=je(t);return de(e,n,Ki(C,t))},ve=ea(D.pipe(J(w))),ye=e.execution?._tag===`Compiled`?{receiveMessage:Nd(b).pipe(en(e=>oa(()=>{E=bd(e)?e:void 0}))),pollMessage:oa(()=>kd(b)).pipe(en(e=>oa(()=>{Zt(e)&&(E=bd(e.value)?e.value:void 0)}))),completeMessage:e=>{Sd(E,e),E=void 0}}:void 0,be=h===void 0||e.execution?._tag===`Compiled`?Nd(b).pipe(Jn(xd)):Nd(b).pipe(en(e=>oa(()=>{E=e})),Jn(xd)),xe=h===void 0||e.execution?._tag===`Compiled`?oa(()=>kd(b)).pipe(Jn(Ae(xd))):oa(()=>kd(b)).pipe(en(e=>oa(()=>{Zt(e)&&(E=e.value)})),Jn(Ae(xd))),Se=h===void 0?e=>se(t=>t.status===`active`?e(t.state).pipe(Jn(e=>({status:`active`,state:e}))):fa(void 0)).pipe(De):t=>Pi(re).pipe(In(n=>se(e=>e.status===`active`?t(e.state).pipe(Jn(e=>({status:`active`,state:e}))):fa(void 0)).pipe(en(t=>oa(()=>{e.inspection?.kind!==`Machine`&&t?.status===`active`&&h.publishUnsafe({_tag:`StateChanged`,subject:g,before:n.snapshot.state,after:t.state,causedByDeliveryId:E!==void 0&&bd(E)?E.inspection?.deliveryId:void 0})})))),De),Ce={...ne,...e.execution?._tag===`Compiled`&&!e.execution.childless?{ownedChildren:F}:void 0,...ye,receive:be,poll:xe,state:Pi(re).pipe(Jn(e=>e.snapshot.state)),setState:ue,updateState:Se},we=Nr(re,e=>e.snapshot.status===`active`?e.changes===void 0?Rt({replay:1}).pipe(Jn(t=>[t,{...e,changes:t}])):fa([e.changes,e]):fa([void 0,e])),Te=Ve(ci(function*(){let e=yield*we;if(e===void 0)return Me((yield*Pi(re)).snapshot);let t=yield*wt(e),n=yield*Pi(re);return n.snapshot.status===`active`?Me(n.snapshot).pipe(Zr(gi(Le(kt(t))).pipe(yr(e=>e.revision>n.revision),Vn(e=>e.snapshot)))):Me(n.snapshot)})),Ee={id:m,sessionId:p,...h===void 0?void 0:{inspectionSubject:g,sendInspected:k},state:Pi(re).pipe(Jn(e=>e.snapshot.state)),snapshot:Pi(re).pipe(Jn(e=>e.snapshot)),changes:Te,emissions:x.stream,join:Bi(C),stop:ve,send:j.send,...A===void 0?void 0:{[vd]:A},child:P,childChanges:M};o!==void 0&&!o(Ee)?yield*D:a!==void 0&&(yield*a(Ee,D)),s!==void 0&&(yield*Rd(s,{status:`active`,state:H}));let Oe=e=>{switch(e._tag){case`Stopped`:return fe;case`Done`:return me(e.output);case`Failure`:return pe(e.cause)}},ke=(e,t)=>{switch(e._tag){case`Stopped`:return he(t);case`Done`:return _e(t,e.output);case`Failure`:return ge(t,e.cause)}},Ne=e=>n===!0?Li(e,{startImmediately:!0}):mr(e,{startImmediately:!0}),W=yield*Bn(S),Pe=ra(W)?yield*sn(t=>t(er(()=>e.run(Ce))).pipe(ut,In(e=>Ki(S,ia(e)?{_tag:`Failure`,cause:e.cause}:{_tag:`Done`,output:e.value})))).pipe(Ne):void 0;return yield*Ne(sn(e=>ci(function*(){let t=Zt(W)?yield*W.value:yield*e(Bi(S)),n=yield*Oe(t);return Pe!==void 0&&(yield*Ge(Pe)),n===void 0?yield*w:yield*ke(t,n)}))),Ee}),Sf=((e,t)=>e.execution?._tag===`Compiled`?yf(e,t):xf(e,t)),Cf=zd(Sf,bf),wf=new WeakMap,Tf=e=>er(()=>{e.closed=!0;let t=Array.from(e.live).reverse();return e.live.clear(),ge(t,e=>e.stop,{discard:!0})}),Ef=()=>{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},Df=e=>In(Tr,t=>{let n=wf.get(t);if(n!==void 0)return e(n.hooks);let r=Ef();return wf.set(t,r),J(ui(t,Tf(r)),e(r.hooks))});Ut(function*(e,t,n){let r=yield*Cf,i=n===void 0?{detached:!0,runtime:r}:{...n,detached:!0,runtime:r};return t===`generic`?yield*Df(t=>xf(e,{...i,...t})):t===`compiled`?e.execution?._tag===`Compiled`?yield*Df(t=>yf(e,{...i,...t})):yield*ht(Error(`Machine cannot force the compiled runtime for generic process logic`)):yield*Df(t=>Sf(e,{...i,...t}))});var Of=Ut(function*(e,t){let n=yield*Cf;return yield*Df(r=>Sf(e,t===void 0?{detached:!0,runtime:n,...r}:{...t,detached:!0,runtime:n,...r}))}),kf=Ut(function*(e,t,n){let r=yield*Cf,i=yield*r.nextSessionId,a=yield*ud(i);r.inspection=a;let o=Xd(),s=yield*kr(),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*gn(Df(n=>{let r={...c,...n};return t===`generic`?xf(e,r):t===`compiled`?e.execution?._tag===`Compiled`?yf(e,r):ht(Error(`Machine cannot force the compiled runtime for generic process logic`)):Sf(e,r)}).pipe(ar(e=>lr(s,e))));return{id:n?.id??i,sessionId:i,changes:Ve(Bi(s).pipe(Jn(e=>e.changes))),emissions:o.stream,inspection:a.stream,start:l}}),Af=((e,t)=>kf(e,`auto`,t));ta({_tag:Mr(`MachineSnapshot`),version:Mr(2),active:$r(ta({path:W,value:vn(ii)})),completed:vn($r(ta({path:W,output:vn(ii)}))),history:vn(sa(W,ta({mode:Er([`shallow`,`deep`]),active:$r(W),values:sa(W,ii)})))});var jf=(e,t,n)=>{let r=Z(e,n);if(r.type===`compound`){let r=Mc(e,t,n);if(r===void 0)throw Error(`Machine expected completed state "${n}" to have an active child`);return jf(e,t,r)}return r.output},Mf=(e,t)=>ci(function*(){let n=yield*Cc(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)||!Fc(e,n,a))throw Error(`Machine snapshot contains invalid completion "${a}"`);i.add(a);let o=jf(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*ks(e,o,t.output,{boundary:`output`,state:a}))}return mc(e,{...n,outputs:r})}).pipe(un(t=>Nf(e,t))),Nf=(e,t)=>{if(be(t))return En(We(t,t=>t instanceof oo?t:new oo({machineId:e.id,boundary:`configuration`,cause:Mt(t)})));let n=Gr(t);return Zt(n)&&n.value instanceof oo?jn(n.value):jn(new oo({machineId:e.id,boundary:`configuration`,cause:t}))},Pf=e=>e.length===0?G:e.length===1?e[0]:yt(e,{discard:!0}),Ff=(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}),If=new WeakMap,Lf=e=>{let t=If.get(e);if(t!==void 0)return t;let n=Object.values(ho(e).handlers).some(e=>e.invoke!==void 0);return If.set(e,n),n},Rf=fa(rn()),zf=(e,t)=>{let n=ed(e),r=new WeakMap,i=t=>{let n=r.get(t.scope);return n===void 0&&(n=Tu(e,t.scope),r.set(t.scope,n)),n},a=n=>{if(!t)return;let r=n.state();return vu(e,r)?yu(e,r,_u).pipe(Jn(Fe)):void 0},o=e=>er(()=>c(e)??Rf),s=(e,t,r,a,s)=>{let c=a.commands.length===0?void 0:Eu(a.commands,e.scope),l=a.emittedEvents.length===0?void 0:Du(a.emittedEvents,i(e)),u=()=>{let i=er(()=>(t&&e.completeMessage({before:r,plan:Ff(a,n.snapshot),after:s}),a.done?fa(Fe(a.output)):o(e)));return l===void 0?i:l.pipe(J(i))},d=()=>{let t=e.commit(s),n=u(),r=t===void 0?n:t.pipe(J(n));return t===void 0&&l===void 0?r:e.runAfterChanges(r)};return c===void 0?d():e.runAfterChanges(c.pipe(J(er(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(ra(e))return;r=e.value}let a=bd(r),c=a?r.event:r,l=t.state(),u;try{u=n.plan(t.executionState??n.fromConfiguration(xc(e,l)),c,a,t.scope)}catch(e){return po(e)}if(t.executionState=u.next,u.microsteps.length===0){a&&t.completeMessage({before:l,plan:Ff(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(J(er(()=>(a&&t.completeMessage({before:l,plan:Ff(u,n.snapshot),after:d}),o(t))))));a&&t.completeMessage({before:l,plan:Ff(u,n.snapshot),after:d})}};return{run:e=>Id(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:Id(r,e.scope)}}},Bf=class{initialized=!1;initial;constructor(e){this.initial=e}},Vf=(e,t)=>{let n=ed(e);return r=>{let i=r.state();if(t&&vu(e,i))return yu(e,i,_u).pipe(Jn(Fe));let a=r.scope,o=r.executionState,s=o instanceof Bf?o:new Bf;r.executionState=s;let c,l,u;return u=er(()=>{let t=r.pollMessage();if(ra(t))return l=void 0,fa(rn());let o=t.value,s=bd(o),d=s?o.event:o,f=i,p;try{p=n.plan(l??n.fromConfiguration(xc(e,i)),d,s,a)}catch(e){return po(e)}if(l=p.next,p.microsteps.length===0)return s&&r.completeMessage({before:f,plan:Ff(p,n.snapshot),after:i}),u;let m=p.microsteps.some(e=>e.changed),h=m?p.microsteps.flatMap(e=>e.exitPaths):[],g=new Map;if(m){for(let e of p.microsteps)if(e.changed)for(let t of e.entryPaths)g.set(t,e.event)}let _=n.toConfiguration(p.next),v=n.snapshot(p.next),y=[];if(p.commands.length>0&&y.push(Eu(p.commands,a)),m){let e=r.ownedChildren.stopPaths(h);e!==void 0&&y.push(e)}let b=[];if(p.emittedEvents.length>0&&b.push(Du(p.emittedEvents,c??=Tu(e,a))),p.done)b.push(r.ownedChildren.stopAll());else if(m)for(let[t,n]of g){let i=hf(e,a,r.ownedChildren,_,[t],n);i!==void 0&&b.push(i)}let x=()=>{let e=r.commit(v);return i=v,e},S=()=>{let e=er(()=>(s&&r.completeMessage({before:f,plan:Ff(p,n.snapshot),after:v}),p.done?fa(Fe(p.output)):u));return b.length===0?e:Pf(b).pipe(J(e))},C=()=>{let e=x(),t=S(),n=e===void 0?t:e.pipe(J(t));return e===void 0&&b.length===0?n:r.runAfterChanges(n)};return y.length===0?C():r.runAfterChanges(Pf(y).pipe(J(er(C))))}),Id(er(()=>{if(s.initialized)return u;let t=s.initial,o=t?.activeConfiguration??xc(e,i);l=t?.configuration??n.fromConfiguration(o);let c=hf(e,a,r.ownedChildren,o,t?.entryPaths??fc(e,o),_u);return s.initial=void 0,s.initialized=!0,c===void 0?u:c.pipe(J(u))}),a)}},Hf=e=>e.done?{state:e.state,done:!0,output:e.output}:{state:e.state,done:!1,output:void 0},Uf=(e,t)=>{let n=Lf(e),r=ed(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=Hf(t);return n?{...r,executionState:new Bf({configuration:t.configuration,activeConfiguration:t.activeConfiguration,entryPaths:t.initialEntryPaths})}:r}catch(e){throw mo(e)}},s=t=>a===void 0?Id(wu(Ml(e,t),...i).pipe(In(n=>{t.inspectInitial(n.initialEntryPaths,n.microsteps);let r=n.commands.length===0?void 0:Eu(n.commands,t),i=n.emittedEvents.length===0?void 0:Du(n.emittedEvents,Tu(e,t)),a=fa(Hf(n));return r===void 0?i===void 0?a:i.pipe(J(a)):i===void 0?r.pipe(J(a)):r.pipe(J(i),J(a))})),t):Ne({try:()=>o(t),catch:mo});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:Vf(e,t._tag===`Resume`)}:{_tag:`Owned`,...zf(e,t._tag===`Resume`)}},initial:n=>t._tag===`Resume`?Id(Mf(e,t.snapshot),n):s(n).pipe(Jn(e=>e.state)),run:t=>Id(ci(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*ht(Error(`Machine statechart started without acknowledged mailbox access`));let c,l=yield*o;if(vu(e,l))return yield*yu(e,l,_u);if(!n){let n,o=rn(),u;for(;c===void 0;){let d=Zt(o)?o.value:yield*a;o=rn();let f=bd(d),p=f?d.event:d,m=l,h;try{h=Cu(e,Xs(n??xc(e,l),t),p)}catch(e){return yield*po(e)}if(n=h.next,h.microsteps.length>0){let n=mc(e,h.next);yield*Eu(h.commands,t),yield*s(n),l=n,h.emittedEvents.length>0&&(yield*Du(h.emittedEvents,u??=Tu(e,t))),h.done&&(c={output:h.output})}f&&r({before:m,plan:Ff(h,t=>mc(e,t)),after:l}),c===void 0&&(o=yield*i,ra(o)&&(n=void 0))}return c===void 0?yield*ht(Error(`Machine process stopped receiving events before reaching a terminal configuration`)):c.output}let u=t.ownedChildren;if(u===void 0)return yield*ht(Error(`Invoking statechart started without an owned child runtime`));let d=(n,r,i)=>hf(e,t,u,n,r,i)??G,f=e=>u.stopPaths(e)??G;return yield*ci(function*(){let n=yield*Cc(e,l);yield*d(n,fc(e,n),_u),n=void 0;let o=rn(),p;for(;c===void 0;){let m=Zt(o)?o.value:yield*a;o=rn();let h=bd(m),g=h?m.event:m,_=l,v;try{v=Cu(e,Xs(n??xc(e,l),t),g)}catch(e){return yield*po(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=mc(e,v.next);if(yield*Eu(v.commands,t),n&&(yield*f(r)),yield*s(a),l=a,v.emittedEvents.length>0&&(yield*Du(v.emittedEvents,p??=Tu(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:Ff(v,t=>mc(e,t)),after:l}),c===void 0&&(o=yield*i,ra(o)&&(n=void 0))}return c===void 0?yield*ht(Error(`Machine process stopped receiving events before reaching a terminal configuration`)):c.output}).pipe(ar(()=>u.stopAll()))}),t)}},Wf=new WeakMap,Gf=(e,...t)=>{if(t.length>0)return Uf(e,{_tag:`Initial`,args:t});let n=Wf.get(e);if(n!==void 0)return n;let r=Uf(e,{_tag:`Initial`,args:t});return Wf.set(e,r),r},Kf=(e,t)=>Uf(e,{_tag:`Resume`,snapshot:t}),qf=(e,...t)=>Af(Gf(e,...t),e.id===void 0?void 0:{id:e.id}),Jf=(e,t)=>Of(Kf(e,t),e.id===void 0?void 0:{id:e.id}),Yf={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`]},Xf=[`title`,`description`,`documentation`],Zf=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Qf=(e,t)=>{let n=typeof t==`symbol`?`[${String(t)}]`:t===``?`<empty>`:String(t);return e===``?n:`${e}.${n}`},$f=(e,t,n)=>{throw Error(`${e} invalid state definition at "${t}": ${n}`)},ep=e=>Number.isFinite(Number(e)),tp=e=>e.length===0||e.some(e=>e===`untagged`)?`untagged`:e.every(e=>e===`tagged`)?`tagged`:`opaque`,np=(e,t)=>{if(t.has(e))return`opaque`;if(Rn(e)||ft(e)||_e(e)||pr(e)||si(e)||K(e))return`tagged`;if(Ci(e))return typeof e.literal==`string`||typeof e.literal==`number`?`tagged`:`untagged`;let n=new Set(t).add(e);return Ii(e)?tp(e.types.map(e=>np(e,n))):Gt(e)?np(e.thunk(),n):Qe(e)?`opaque`:`untagged`},rp=(e,t=new Set)=>{if(t.has(e))return`opaque`;if(Nn(e)){let n=e.propertySignatures.find(({name:e})=>e===`_tag`)?.type;return n===void 0||On(n)?`untagged`:np(n,new Set(t).add(e))}let n=new Set(t).add(e);return Ii(e)?tp(e.types.map(e=>rp(e,n))):Gt(e)?rp(e.thunk(),n):Qe(e)?`opaque`:`untagged`},ip=e=>bt(e)&&rp(Ei(e.ast))!==`untagged`,ap=(e,t,n)=>{let r=Qf(t,n);return typeof n==`symbol`?$f(e,r,`state keys must be strings, not symbols`):typeof n==`number`?$f(e,r,`state keys cannot use numeric forms`):n===``?$f(e,r,`state keys cannot be empty`):n===`__proto__`?$f(e,r,`the state key "__proto__" is not allowed`):n.includes(`.`)?$f(e,r,`state keys cannot contain "."`):ep(n)?$f(e,r,`state keys cannot use numeric forms`):r},op=(e,t,n,r)=>{(typeof n!=`object`||!n||Array.isArray(n))&&$f(e,t,`${r} must be a plain record`);let i=Object.getPrototypeOf(n);i!==Object.prototype&&i!==null&&$f(e,Qf(t===`<root>`?``:t,`__proto__`),`${r} must not declare an implicit "__proto__" state key`)},sp=(e,t,n,r,i)=>{if(typeof n!=`object`||!n||Array.isArray(n)||!Zf(n,r))return;let a=n[r];(typeof a!=`object`||!a||bt(a)||a.type!==`history`)&&$f(e,`${t}.${r}`,i)},cp=(e,t,n,r)=>{let i=Yf[r];for(let a of Reflect.ownKeys(n))i.includes(a)||$f(e,t,`${r} states cannot declare property "${String(a)}"`)},lp=(e,t,n)=>{op(e,`${t}.annotations`,n,`schema-less state annotations`);for(let r of Reflect.ownKeys(n))Xf.includes(r)||$f(e,`${t}.annotations`,`schema-less state annotations cannot declare property "${String(r)}"`),typeof n[r]!=`string`&&$f(e,`${t}.annotations.${String(r)}`,`schema-less state annotation values must be strings`)},up=(e,t,n,r,i=!1)=>{op(e,n===``?`<root>`:n,t,`state trees`);for(let a of Reflect.ownKeys(t)){let o=i&&a===``?``:ap(e,n,a),s=t[a];if(bt(s)){ip(s)||$f(e,o,`state schemas must decode to an object with a required PropertyKey _tag`);continue}op(e,o,s,`state nodes`);let c=s.type,l=c===`history`?`history`:c===`choice`?`choice`:c===`parallel`?`parallel`:c===`final`?`final`:Zf(s,`states`)?`compound`:`atomic`;if(cp(e,o,s,l),l===`history`||l===`choice`){r||$f(e,o,`${l} states must be declared below an active parent state`),Zf(s,`annotations`)&&lp(e,o,s.annotations),l===`history`&&Zf(s,`history`)&&s.history!==`shallow`&&s.history!==`deep`&&$f(e,`${o}.history`,`history must be "shallow" or "deep"`);continue}let u=Zf(s,`schema`);u&&!ip(s.schema)&&$f(e,`${o}.schema`,`state schemas must decode to an object with a required PropertyKey _tag`),u&&Zf(s,`annotations`)&&$f(e,`${o}.annotations`,`schema-backed states must declare annotations on their schema`),!u&&Zf(s,`annotations`)&&lp(e,o,s.annotations),l===`atomic`&&Zf(s,`type`)&&s.type!==`active`&&$f(e,`${o}.type`,`atomic state type must be "active"`),l===`final`&&s.type!==`final`&&$f(e,`${o}.type`,`final state type must be "final"`),l===`compound`&&Zf(s,`type`)&&s.type!==`active`&&$f(e,`${o}.type`,`compound state type must be "active"`),l===`parallel`&&s.type!==`parallel`&&$f(e,`${o}.type`,`parallel state type must be "parallel"`),(l===`final`||l===`parallel`)&&Zf(s,`output`)&&!bt(s.output)&&$f(e,`${o}.output`,`state output must be an Effect Schema`),l===`compound`?(sp(e,o,s.states,`initial`,`active and choice child states cannot use the reserved target selector key "initial"`),u&&sp(e,o,s.states,`with`,`schema-backed compound child states cannot use the reserved local target selector key "with"`),up(e,s.states,o,!0)):l===`parallel`&&(Zf(s,`states`)||$f(e,`${o}.states`,`parallel states must declare child regions`),sp(e,o,s.states,`initial`,`active and choice child states cannot use the reserved target selector key "initial"`),up(e,s.states,o,!0))}},dp=e=>typeof e==`object`&&e?Object.freeze({...e}):e,fp=e=>{let t={};for(let n of Object.keys(e)){let r=e[n];if(bt(r)){Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!1,writable:!1});continue}let i=r,a={...i};`states`in i&&(a.states=fp(i.states)),`annotations`in i&&(a.annotations=dp(i.annotations)),Object.defineProperty(t,n,{value:Object.freeze(a),enumerable:!0,configurable:!1,writable:!1})}return Object.freeze(t)},pp=e=>fp(e),mp=(e,t=``)=>{if(bt(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(Zf(n,`fields`)&&(Zf(n,`schema`)&&$f(`Machine.state`,t,`declare fields or schema, not both`),op(`Machine.state`,t,n.fields,`state fields`),Zf(n.fields,`_tag`)&&$f(`Machine.state`,t,`state fields cannot declare _tag`),r.schema=He(t,n.fields),delete r.fields),Zf(n,`states`)){op(`Machine.state`,t,n.states,`child states`);let e=Object.create(null);for(let r of Reflect.ownKeys(n.states))ap(`Machine.state`,t,r),e[r]=mp(n.states[r],r);r.states=e}return t===``?(up(`Machine.state`,{"":r},``,!1,!0),pp({"":r})[``]):r},hp=`~effect/Machine`,gp=`~effect/Machine/ChildMachine`,_p={...St,...et,[hp]:hp,toJSON(){return{_id:`Machine`}}},vp=(e,t)=>{let n=Object.create(_p);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,Cs(e,n),n},yp=e=>e.kind===`none`?ko:Oo(e.kind,e.path,e.scope,e.updatePath),bp=e=>Object.freeze({path:e.path,kind:e.kind,scope:e.scope}),xp=e=>e.updatePath===void 0?e.kind===`update`&&e.path!==void 0?[e.path]:[]:[e.updatePath],Sp=(e,t,n,r,i)=>{if(typeof e!=`object`||!e||!q(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(!Ao(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`||!ec(r,e.path)||!ec(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}},Cp=(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(!Mo(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(!Po(e)||e.update.path!==t.updatePath)throw Error(`Machine target updating "${t.updatePath}" must return target construction .update(...)`)}else if(Po(e))throw Error(`Machine combined target requires an updating owner declaration`);if(e===void 0)return;let r=Po(e)?e.target:e,i=typeof r==`object`&&r&&q(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&&ec(i,t.path)))throw Error(`Machine transition resolver selected "${t.path}" but constructed "${i??`<invalid>`}"`)},wp=(e,t,n,r,i)=>{let a={...t,root:i===``?t.state:t.ancestors[``],decline:Vo};delete a.target;let o=e.resolve(a,n);if(Ho(o)){if(e.declinable!==!0)throw Error(`Machine transition for state "${i}" returned decline without declaring declinable: true`);return o}return Cp(o,e.selection,r),o},Tp=e=>e.kind===`update`?void 0:e.path,Ep=e=>{let t=Number(e);return Number.isInteger(t)&&t>=0&&t<4294967295&&String(t)===e},Dp=(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||Ep(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||!q(i,`target`))throw Error(`Machine transition branch "${r}" requires a target selection`);let{target:a,title:o}=i;if(!Ao(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:yp(a)})}))},Op=(e,t,n,r={},i)=>{let a=Wc(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 No(qo(i.path,i.parent),qc(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`?Uo(n.path,n.parent):qo(n.path,n.parent)}if(e.kind===`update`)return qc(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 No(Kc(t,e.path,r,i),qc(t,e.updatePath,n))}return Kc(t,e.path,a,i)},kp=(e,t,n,r,i)=>Object.freeze(Object.fromEntries(e.map((e,a)=>[e.key,o=>Fo(t,a,e.key,e.selection.kind===`none`?Ro():Op(e.selection,n,r,o,i))]))),Ap=(e,t,n)=>{if(t.kind===`none`){if(!zo(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`);Cp(e,t,n)}},jp=(e,t)=>({...e,root:t===``?e.state:e.ancestors[``]}),Mp=(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:Sp({target:()=>el(t,i)},void 0,r,n,e).selection}]));return{branches:()=>a,reenter:i.reenter,declinable:f,resolve:(e,t)=>d&&!o(e)?Vo():s(e,t)}}let p=el(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 Vo();if(s!==void 0)return s(e,a);if(h)return Op(p,r,t,{input:g(e)});let l=u(e);return Op(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)}}},Np=(e,t,n,r,i)=>{let a=Mp(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(q(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=Dp(e.branches(),n,i),u=Object.freeze({}),d=(e,o)=>{let s={...e,root:n===``?e.state:e.ancestors[``],decline:Vo};delete s.target,s.select=kp(l,u,t,r,n);let d=a(s,o);if(Ho(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(!Io(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 Ap(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=>Tp(e.selection)===void 0?[]:[e.selection.path]))],branches:l.map(e=>Object.freeze({type:`branch`,key:e.key,title:e.title,target:Tp(e.selection),selection:bp(e.selection),updates:xp(e.selection)})),evaluate:d,transition:(e,t)=>d(e,t).result}}let l=Sp(a,void 0,t,n,i),u=(e,r)=>({result:wp(l,e,r,t,n),branchIndex:0,branchKey:void 0});return{reenter:s,declinable:c,targets:Tp(l.selection)===void 0?[]:[l.selection.path],branches:[{type:`direct`,target:Tp(l.selection),selection:bp(l.selection),updates:xp(l.selection)}],evaluate:u,transition:(e,t)=>u(e,t).result}},Pp=(e,t,n,r)=>{let i=Object.create(null);for(let a of Reflect.ownKeys(e))i[a]=Np(e[a],t,n,r,a);return i},Fp=(e,t,n,r)=>{let i=(Array.isArray(e)?e:[e]).map(e=>{let i=tl(r,e,n,e=>jp(e,n));for(let e of[`onElement`,`onDone`,`onFailure`,`onSnapshot`])i[e]!==void 0&&(i[e]=Np(i[e],t,n,r,e));return fl(i,n)});return ml(i,n),Array.isArray(e)?Object.freeze(i):i[0]},Ip=(e,t,n,r,i,a)=>{for(let o of Object.keys(a)){let s=r===``?o:`${r}.${o}`;if(!q(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=Pp(d,t,s,i)),u.always!==void 0&&(u.always=Np(u.always,t,s,i,`always`)),u.onDone!==void 0&&(u.onDone=Np(u.onDone,t,s,i,`done`)),u.choice!==void 0&&(u.choice=Np(u.choice,t,s,i,`choice`)),u.invoke!==void 0&&(u.invoke=Fp(u.invoke,t,s,i)),t.byPath.get(s)?.type===`choice`&&(typeof u.choice!=`object`||u.choice===null||!q(u.choice,`transition`)||typeof u.choice.transition!=`function`||!q(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=Yo(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`);Ip(e,t,r.states,s,i,l)}}},Lp=e=>e===``?Xc:e,Rp=e=>{let t=!1;for(let n of e.stateNodes.byPath.values())if(n.type===`choice`){t=!0;break}if(!t)return;let n=$o(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(!ec(o,n)){let r=i.type===`branch`?`branch "${i.key}"`:`transition`;throw Error(`Machine transition from "${Lp(e.source)}" updates "${Lp(n)}" before choice "${t}", whose ${r} targets "${Lp(o)}" outside that owner`)}}}}}}},zp=(e,t)=>(n=>{let r=dl(t.root,n),i=Object.assign(Object.create(_p),e);if(Cs(e,i),i.states=Object.freeze({"":r.node}),i.stateNodes=Xo(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:ll(n.root);i.initial=e=>({...Go(``,a({input:e})),input:{value:e}}),i.initialDefinition=Object.freeze({target:``,selection:Object.freeze({path:``,kind:`initial`,scope:`initial`})});let o=Object.create(null);Ip(o,i.stateNodes,i.states,``,{...t,initialize:e=>i.initial(i.input===void 0?void 0:Vs(i,i.input,e))},{"":r.handlers});let s=vp(i,o);return Rp(s),s}),Bp=e=>{let t=mp(e),n=Vp();return Object.freeze({...n,"~effect/Machine/State":`~effect/Machine/State`,node:t})},Vp=()=>({path:(e=>e),get:((e,t)=>as(e,t).pipe(Ae(e=>e.value))),getWithParents:((e,t)=>{let n={};return as(e,t,n).pipe(Ae(e=>({value:e.value,parents:n})))}),getSnapshot:as,matches:((e,t)=>Zt(as(e,t)))}),Hp=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(et);return n.states=t,n.root=e.root,n.events=e.events,n.internalEvents=e.internalEvents??Os(`internal`,[]),n.emittedEvents=e.emittedEvents??Os(`emitted`,[]),n.parent=e.parent,n.input=e.input,n.id=e.id,n.handlers=Object.create(null),n.handle=zp(n,Qc(e.root,e)),Ss(n),n},Up=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?[]:[ze(e)]},Wp=e=>Os(`public`,Up(e)),Gp=(e,t)=>Kp(e,t,e=>t.input===void 0?Gf(t):Gf(t,e)),Kp=(e,t,n)=>({[gp]:gp,id:e,machine:t,[il]:n}),qp=qf,Jp=Jf,Yp=(e,t)=>{try{let n=bu(e,...t);return{machine:e,snapshot:n.done?{status:`done`,state:n.state,output:n.output}:{status:`active`,state:n.state}}}catch{return}},Xp=(e,t)=>{try{let n=jr(Mf(e,t));if(n._tag===`Failure`)return;let r=n.value;if(!vu(e,r))return{machine:e,snapshot:{status:`active`,state:r}};let i=jr(yu(e,r,_u));return i._tag===`Success`?{machine:e,snapshot:{status:`done`,state:r,output:i.value}}:void 0}catch{return}},Zp={spawn:()=>ht(Error(`Child operations are unavailable in a planned snapshot`)),sendTo:()=>jn(new uo),stop:()=>G},Qp=(e,t)=>{if(e.snapshot.status!==`active`)return rn();try{let n=e.machine,r=xc(n,e.snapshot.state);for(let e of fc(n,r)){let i=jc(n,e);for(let a of hl(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({...Zs(r)??Nl(n,r),children:Zp,state:r.values.get(e),containingState:dc(n,r,e),ancestors:uc(n,r,e),event:_u}):a.input);let s=Yp(i,i.input===void 0?[]:[o]);return s===void 0?void 0:Fe(s)}}return rn()}catch{return}},$p=class extends qt(`ChildNotActiveError`){},em=new WeakMap,tm=new WeakMap,nm=e=>typeof e==`object`&&!!e&&tm.has(e),rm=e=>{if(typeof WeakRef>`u`||typeof FinalizationRegistry>`u`)return ca(e);let t=Se(),n=new FinalizationRegistry(({entry:e,key:n})=>{let r=Vr(t,n);Zt(r)&&r.value===e&&Tt(t,n)});return r=>{let i=Vr(t,r);if(Zt(i)){let e=i.value.ref.deref();if(e!==void 0)return e}let a=e(r),o={ref:new WeakRef(a)};return At(t,r,o),n.register(a,{key:r,entry:o}),a}},im=(e,t)=>Hn(ot(t,e=>e.stop).pipe(en(t=>oa(()=>e.setSelf(yn(t)))),In(()=>Mi))),am=(e,t)=>im(e,e.result(t).pipe(In(e=>e.start))),om=(e,t,n)=>im(e,Jp(t,n)),sm=(e,t)=>`~effect-atom/atom/Atom/ServerValue`in e?e[Wi](t):t(e),cm=(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}},lm=e=>{let t;return()=>(t===void 0&&(t={value:e()}),t.value)},um=e=>e.snapshot,dm=nn(e=>e.registry).pipe(Xt),fm=e=>er(()=>{let t=e.pending.shift();return t===void 0?(e.draining=!1,G):J(t,fm(e))}),pm=(e,t)=>{let n=e.get(t);return n===void 0&&(n={pending:[],draining:!1},e.set(t,n)),n},mm=(e,t,n)=>xt(n=>{let r=cn(n(e),()=>void 0),i=t.get(n.registry);return i===void 0||!i.draining?r:la(Ae(n.self(),Je),()=>Kt(!0))},(r,i)=>{let a=r.get(e),o=r.get(dm),s=pm(t,o);we(a)||s.draining?(r.setSelf(Kt(!0)),s.pending.push(Et(o,e).pipe(In(e=>n(e,i)),ut,Jn(e=>{let t=_t(e);r.setSelf(s.pending.length===0?t:Je(t))}))),s.draining||(s.draining=!0,br(fm(s)))):ma(a)?r.setSelf(cn(a,()=>void 0)):dr(n(a.value,i),{onExit:e=>r.setSelf(_t(e))})}).pipe(Rr),hm=e=>nn(t=>{let n=t(e);return we(n)?Kt(n.waiting):ma(n)?at(n.cause,{previous:t.self(),waiting:n.waiting}):n.value.status===`error`?at(n.value.cause,{previous:t.self(),waiting:n.waiting}):yn(n.value.state,{waiting:n.waiting})}).pipe(jt(Dt),ve(cm(t=>[sm(e,t)],e=>cn(e,e=>e.state)))),gm=e=>nn(t=>{let n=t(e);if(we(n))return Kt(n.waiting);if(ma(n))return at(n.cause,{previous:t.self(),waiting:n.waiting});if(ra(n.value)){let e=t.self();return Zt(e)&&ma(e.value)?e.value:yn(rn(),{waiting:n.waiting})}return n.value.value.status===`error`?at(n.value.value.cause,{previous:t.self(),waiting:n.waiting}):yn(Fe(n.value.value.state),{waiting:n.waiting})}).pipe(jt(Dt),ve(cm(t=>[sm(e,t)],e=>cn(e,Ae(e=>e.state))))),_m=(e,t)=>nn(n=>{let r=n(e);if(we(r))return Kt(r.waiting);if(ma(r))return at(r.cause,{previous:n.self(),waiting:r.waiting});if(ra(r.value))return yn(rn());let i=r.value.value,a=ri(i.child(t)),o=dr(qr.pipe(J(i.childChanges(t).pipe($t(e=>oa(()=>n.setSelf(yn(e))))))));return n.addFinalizer(o),yn(a)}).pipe(Rr),vm=(e,t)=>gd(e)?e[hd](()=>t(ri(e.snapshot))):dr(e.changes.pipe($t(e=>oa(()=>t(e))))),ym=(e,t,n)=>{let r=nn(t=>{let n=t(e);if(we(n))return Kt(n.waiting);if(ma(n))return at(n.cause,{previous:t.self(),waiting:n.waiting});if(ra(n.value))return yn(rn());let r=n.value.value;return t.addFinalizer(vm(r,e=>t.setSelf(yn(Fe(e))))),yn(Fe(ri(r.snapshot)))}).pipe(ve(cm(()=>[],()=>{let e=n();return e===void 0?Kt(!0):yn(Ae(e,um),{waiting:!0})}))),i=new WeakMap,a=e=>Zt(e)?fa(e.value):jn(new $p({id:t.id})),o=mm(e,i,(e,t)=>In(a(e),e=>e.send(t))),s=mm(e,i,(e,t)=>In(a(e),e=>e.stop)),c=bm(e,n);return{ref:e,snapshot:r,result:gm(r),send:o,stop:s,child:c}},bm=(e,t)=>{let n=new WeakMap;return r=>{let i=n.get(r.machine);if(i===void 0){let a=r.machine,o=ca(n=>{let r=Gp(n,a);return ym(_m(e,r),r,lm(()=>{let e=t();return e===void 0||ra(e)?e:Qp(e.value,r)}))});i=e=>o(e),n.set(a,i)}return i(r.id)}},xm=(e,t,n)=>{let r=Rr(e),i=nn(e=>{let t=e(r);if(we(t))return Kt(t.waiting);if(ma(t))return at(t.cause,{previous:e.self(),waiting:t.waiting});let n=t.value;e.addFinalizer(vm(n,t=>e.setSelf(yn(t,{waiting:t.status===`active`}))));let i=ri(n.snapshot);return yn(i,{waiting:i.status===`active`})}).pipe(ve(cm(()=>[],()=>{let e=n();return e===void 0?Kt(!0):yn(um(e),{waiting:!0})}))),a=new WeakMap,o=mm(r,a,(e,t)=>e.send(t)),s=mm(r,a,(e,t)=>e.stop),c=bm(Xi(r,Fe),()=>{let e=n();return e===void 0?void 0:Fe(e)}),l={ref:r,snapshot:i,result:hm(i),send:o,stop:s,child:c};return tm.set(l,t),l},Sm=(e,t)=>as(e,t).pipe(Ae(e=>e.value)),Cm=(e,t)=>as(e,t),wm=(e,t)=>Xi(e,t).pipe(jt(Dt),ve(cm(t=>[sm(e,t)],e=>cn(e,t)))),Tm=new WeakMap,Em=(e,t,n,r)=>{let i=Tm.get(e);i===void 0&&(i=new Map,Tm.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},Dm=(e,t)=>Em(e,`select`,t,()=>wm(e.result,e=>Sm(e,t))),Om=(e,t)=>Em(e,`selectSnapshot`,t,()=>wm(e.result,e=>Cm(e,t))),km=(e,t)=>Em(e,`selectChild`,t,()=>wm(e.result,Sr(e=>Sm(e,t)))),Am=(e,t)=>Em(e,`selectSnapshotChild`,t,()=>wm(e.result,Sr(e=>Cm(e,t)))),jm=(e,t)=>Em(e,`matches`,t,()=>wm(e.result,e=>Zt(as(e,t)))),Mm=(e,t)=>Em(e,`matchesChild`,t,()=>wm(e.result,ei(e=>Zt(as(e,t))))),Nm=(e,t,n)=>{let r=e.atom(()=>qp(t,...n)),i=xm(e.atom(e=>am(e,r)),t,lm(()=>Yp(t,n)));return em.set(i,r),i},Pm=(e,t,n)=>xm(e.atom(e=>om(e,t,n)),t,lm(()=>Xp(t,n))),Fm=(e,t,n)=>{let r={owner:e,source:t},i=Pe(t,e=>e(r.source),{initialValueTarget:t}).pipe(jt((e,t)=>r.source.equals(e,t)),ve(e=>sm(r.source,e)));return n!==void 0&&(i=i.pipe(Ur(n))),i},Im=(e,t)=>{let n=rm(t=>({bridge:e(t)})),r={};for(let e of Object.keys(t.atoms)){let i=t.atoms[e];r[e]=rm(r=>{let a=n(r);return Fm(a,i(a.bridge),t.label?.(r,e))})}return r},Lm=e=>{let t=((t,...n)=>Nm(e,t,n));return{make:t,factory:(e=>(...n)=>t(e,...n)),resume:((t,n)=>Pm(e,t,n)),family:((t,n)=>Im(n=>Nm(e,t,[n]),n))}},Rm=nm;Te(2,Dm);var zm=Te(2,Om);Te(2,km);var Bm=Te(2,Am);Te(2,jm),Te(2,Mm);var Vm=Lm;function Hm(e){let t=(0,La.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=_(`animate-pulse rounded-md bg-muted`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`div`,{"data-slot":`skeleton`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Um(e){let t=(0,La.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,X.jsxs)(`div`,{"aria-hidden":!0,className:`flex h-10 items-center gap-3 border-b px-1`,children:[e.media===!0&&(0,X.jsx)(Hm,{className:`size-5`}),(0,X.jsx)(Hm,{className:`h-4 w-1/3`})]},t),t[3]=e.media,t[4]=n),r=Pr(li(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,X.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 Wm=e(r(),1);function Gm(e){let t=(0,La.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=_(`flex items-center gap-2 text-xs/relaxed leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`label`,{"data-slot":`label`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Km=Y.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return H(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});M(`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 qm(e){let t=(0,La.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=_(`group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-input/40 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-2 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/30 *:data-[slot=field]:p-2 dark:has-data-checked:bg-primary/10`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(Gm,{"data-slot":`field-label`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Jm(e){let t=(0,La.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=_(`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,X.jsx)(`p`,{"data-slot":`field-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ym(e){let t=(0,La.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(Zm)).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,X.jsx)(`ul`,{className:`ml-4 flex list-disc flex-col gap-1`,children:r.map(Xm)}),t[7]=r,t[8]=a),o=a}let s=o;if(!s)return null;let c;t[9]===r?c=t[10]:(c=_(`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,X.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 Xm(e,t){return e?.message&&(0,X.jsx)(`li`,{children:e.message},t)}function Zm(e){return[e?.message,e]}var Qm=new Uint8Array(512),$m=new Uint8Array(256);for(let e=0,t=1;e<255;e++)Qm[e]=t,$m[t]=e,t<<=1,256&t&&(t^=285);for(let e=255;e<512;e++)Qm[e]=Qm[e-255];var eh=(e,t)=>e>0&&t>0?Qm[$m[e]+$m[t]]:0,th=(e,t)=>Qm[t*$m[e]%255],nh=e=>{let t=new Uint8Array(e+2),n=new Uint8Array(e+1);n[0]=1;for(let r=0;r<e;r++){let e=th(2,r);t.fill(0,0,r+2);for(let i=0;i<r+1;i++)t[i]^=n[i],t[i+1]^=eh(n[i],e);for(let e=0;e<r+2;e++)n[e]=t[e]}return n},rh=(e,t)=>{let n=nh(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]^=eh(n[i],e)}return r.subarray(e.byteLength)},ih=[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],ah=[[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]],oh=[[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]],sh=[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],ch=[[],[],[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]],lh=(e,t,n)=>{let r=ih[t]-ah[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},uh=(e,t)=>{for(let n=1;n<=40;n++){let r=ih[n]-ah[n][t];if(r-=n>9?3:2,r>=e.byteLength)return n}throw RangeError(`Bytes exceed max length`)},dh=(e,t,n)=>{let r=e.byteLength+ah[t][n],i=oh[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=rh(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},fh=(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)},ph=(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}},mh=(e,t,n)=>{let r=n-7;ph(e,n,0,0,7),ph(e,n,r,0,7),ph(e,n,0,r,7),fh(t,n,0,0,8),fh(t,n,r-1,0,8),fh(t,n,0,r-1,8)},hh=(e,t,n,r)=>{let i=ch[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];ph(e,n,a,r,5),fh(t,n,a,r,5)}}},gh=(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)}},_h=(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},vh=(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}},yh=(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}},bh=(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)}},xh=(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)}},Sh=(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)}},Ch=(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)}},wh=(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)}}},Th=(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)}},Eh=(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)}},Dh=(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)}},Oh=(e,t,n,r)=>{switch(r){case 0:return bh(e,t,n);case 1:return xh(e,t,n);case 2:return Sh(e,t,n);case 3:return Ch(e,t,n);case 4:return wh(e,t,n);case 5:return Th(e,t,n);case 6:return Eh(e,t,n);case 7:return Dh(e,t,n)}},kh=(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},Ah=(e,t,n)=>{let r=0,i=0,a=new Uint8Array(e.byteLength);for(let o=0;o<=7;o+=1){a.set(e),Oh(a,t,n,o);let s=kh(a,n);(o===0||s<r)&&(r=s,i=o)}return Oh(e,t,n,i),i},jh=(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)},Mh=(e,t,n,r)=>{let i=jh(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},Nh=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},Ph=(e,t,n)=>{if(n>=7){let r=Nh(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}}},Fh=(e,t)=>{let n=uh(e,t),r=dh(lh(e,n,t),n,t),i=sh[n],a=new Uint8Array(i*i),o=new Uint8Array(i*i);return mh(a,o,i),hh(a,o,i,n),gh(a,o,i),_h(o,i),vh(o,i,n),yh(a,o,i,r),Mh(a,i,t,Ah(a,o,i)),Ph(a,i,n),a},Ih=new TextEncoder,Lh=(e,t=1)=>Fh(typeof e==`string`?Ih.encode(e):e,t);function Rh(e){let t=Ia.unstable_scheduleCallback(4,e);return()=>Ia.unstable_cancelCallback(t)}var zh=Y.createContext(It({scheduleTask:Rh,defaultIdleTTL:400})),Bh=new WeakMap,Vh=0,Hh=new Set;function Uh(e){Vh++;try{return e()}finally{Vh--}}function Wh(e){if(Vh===0)return e();Hh.size===0&&queueMicrotask(Gh),Hh.add(e)}function Gh(){for(let e of Hh)Hh.delete(e),e()}function Kh(e,t){let n=Bh.get(e);n===void 0&&(n=new WeakMap,Bh.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,()=>Wh(n));return()=>{i--,Hh.delete(n),r()}},snapshot(){return Uh(()=>e.get(t))},getServerSnapshot(){return(i===0||a===void 0)&&(a={value:Uh(()=>na(t,e))}),a.value}};return n.set(t,o),o}function qh(e,t){let n=Kh(e,t);return Y.useEffect(Gh),Y.useSyncExternalStore(n.subscribe,n.snapshot,n.getServerSnapshot)}function Jh(e,t,n){let r=Kh(e,t),i=Y.useMemo(()=>{let e;return t=>(e!==void 0&&Object.is(e.source,t)||(e={source:t,value:n(t)}),e.value)},[n]);return Y.useEffect(Gh),Y.useSyncExternalStore(r.subscribe,()=>i(r.snapshot()),()=>i(r.getServerSnapshot()))}var Yh=(e,t)=>{let n=Y.useContext(zh);return t?Jh(n,e,t):qh(n,e)};function Xh(e,t,n){return n?.mode===`promise`||n?.mode===`promiseExit`?Y.useCallback(r=>{e.set(t,r);let i=_i(Et(e,t,{suspendOnWaiting:!0}));return n.mode===`promise`?i.then(Zh):i},[e,t,n.mode]):Y.useCallback(n=>{e.set(t,typeof n==`function`?n(e.get(t)):n)},[e,t])}var Zh=e=>{if(Qt(e))return e.value;throw vt(e.cause)},Qh=(e,t)=>{let n=Y.useContext(zh);return[qh(n,e),Xh(n,e,t)]};function $h({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=Y.useRef(e!==void 0),[a,o]=Y.useState(()=>t);return[i&&e!==void 0?e:a,Y.useCallback(e=>{i||o(e)},[])]}function eg(e){let t=Y.useRef(!0);t.current&&(t.current=!1,e())}function tg(e){let t=d(ng,e).current;return t.next=e,D(t.effect),t}function ng(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var rg={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},ig={...rg,position:`fixed`,margin:0,top:0,left:0},ag={...rg,position:`absolute`},og=[],sg=void 0;function cg(){return sg}function lg(e){og.push(e)}function ug(e){let t=(t,n)=>{let r=d(fg).current,i;try{sg=r;for(let e of og)e.before(r);i=e(t,n);for(let e of og)e.after(r);r.didInitialize=!0}finally{sg=void 0}return i};return t.displayName=e.displayName||e.name,t}function dg(e){return Y.forwardRef(ug(e))}function fg(){return{didInitialize:!1}}var pg=le(19)?gg:_g;function mg(e,t,n,r,i){return pg(e,t,n,r,i)}function hg(e,t,n,r,i){let a=Y.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,Pa.useSyncExternalStore)(e.subscribe,a,a)}lg({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,Pa.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function gg(e,t,n,r,i){let a=cg();if(!a)return hg(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],s.store===e&&s.selector===t&&Object.is(s.a1,n)&&Object.is(s.a2,r)&&Object.is(s.a3,i)||(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function _g(e,t,n,r,i){return(0,Fa.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var vg=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return mg(this,e,t,n,r)}},yg=class extends vg{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){Y.useDebugValue(e);let n=this;D(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;D(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this,n=Object.values(e);D(()=>{t.update(e)},[t,...n])}useControlledProp(e,t){Y.useDebugValue(e);let n=this,r=t!==void 0;D(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return Y.useDebugValue(e),mg(this,this.selectors[e],t,n,r)}useContextCallback(e,t){Y.useDebugValue(e);let n=f(t??P);this.context[e]=n}useStateSetter(e){let t=Y.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}};function bg(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function xg(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function Sg(e){Y.useEffect(e,B)}var Cg=0,wg=class e{static create(){return new e}currentId=Cg;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Cg,t()},e)}isStarted(){return this.currentId!==Cg}clear=()=>{this.currentId!==Cg&&(clearTimeout(this.currentId),this.currentId=Cg)};disposeEffect=()=>this.clear};function Tg(){let e=d(wg.create).current;return Sg(e.disposeEffect),e}function Eg(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:Dg,platform:Og,maxTouchPoints:kg}=Eg(),Ag=Dg.toLowerCase(),jg=Og.toLowerCase(),Mg=/^i(os$|p)/.test(jg)||jg===`macintel`&&kg>1,Ng=`android`,Pg=jg===Ng||Ag.includes(Ng),Fg=!Mg&&jg.startsWith(`mac`);jg.startsWith(`win`),!Pg&&/^(linux|chrome os)/.test(jg);var Ig=Fg||Mg,Lg=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`),Rg=!Lg&&Ag.includes(`firefox`);!Lg&&Ag.includes(`chrom`);var zg=Ig,Bg=/jsdom|happydom/.test(Ag),Vg=null;globalThis.requestAnimationFrame;var Hg=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}},Ug=class e{static create(){return new e}static request(e){return Hg.request(e)}static cancel(e){return Hg.cancel(e)}currentId=Vg;request(e){this.cancel(),this.currentId=Hg.request(()=>{this.currentId=Vg,e()})}cancel=()=>{this.currentId!==Vg&&(Hg.cancel(this.currentId),this.currentId=Vg)};disposeEffect=()=>this.cancel};function Wg(){let e=d(Ug.create).current;return Sg(e.disposeEffect),e}var Gg=Y.forwardRef(function(e,t){let[n,r]=Y.useState();D(()=>{zg&&Lg&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,X.jsx)(`span`,{...e,ref:t,style:ig,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})});function Kg(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Q(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&A(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function qg(e,t){let n=e;for(;n;){if(pe(n)&&n.matches(t))return n;n=n.assignedSlot??n.parentNode??(A(n)?n.host:null)}return null}function Jg(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}var Yg=`data-base-ui-focusable`,Xg=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,Zg=`ArrowLeft`,Qg=`ArrowRight`,$g=`ArrowUp`,e_=`ArrowDown`,t_=`data-starting-style`,n_=`data-ending-style`,r_={[t_]:``},i_={[n_]:``},a_={transitionStatus(e){return e===`starting`?r_:e===`ending`?i_:null}},o_=`data-open`,s_=`data-closed`,c_=`data-anchor-hidden`,l_=`data-popup-open`,u_=`data-pressed`,d_={[l_]:``},f_={[l_]:``,[u_]:``},p_={[o_]:``},m_={[s_]:``},h_={[c_]:``},g_={open(e){return e?d_:null}},__={open(e){return e?f_:null}},v_={open(e){return e?p_:m_},anchorHidden(e){return e?h_:null}},y_={...v_,...a_},b_=`data-trigger-disabled`;function x_(e,t){if(!pe(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(b_);for(let[,e]of t.entries())if(Q(e,n))return!e.hasAttribute(b_);return!1}function S_(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function C_(e){return e.matches(`html,body`)}function w_(e){return l(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function T_(e){return qg(e,`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${Xg}`)!=null}function E_(e){return e?e.getAttribute(`role`)===`combobox`&&w_(e):!1}function D_(e){if(!e||Bg)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function O_(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function k_(e){e.preventDefault(),e.stopPropagation()}function A_(e){return`nativeEvent`in e}function j_(e){return e.pointerType===``&&e.isTrusted?!0:Pg&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function M_(e){return Bg?!1:!Pg&&e.width===0&&e.height===0||e.type===`pointerdown`&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`&&(Pg||e.buttons===0)||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function N_(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function P_(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}var F_=Math.min,I_=Math.max,L_=Math.round,R_=Math.floor,z_=e=>({x:e,y:e}),B_={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function V_(e,t,n){return I_(e,F_(t,n))}function H_(e,t){return typeof e==`function`?e(t):e}function U_(e){return e.split(`-`)[0]}function W_(e){return e.split(`-`)[1]}function G_(e){return e===`x`?`y`:`x`}function K_(e){return e===`y`?`height`:`width`}function q_(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function J_(e){return G_(q_(e))}function Y_(e,t,n){n===void 0&&(n=!1);let r=W_(e),i=J_(e),a=K_(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=iv(o)),[o,iv(o)]}function X_(e){let t=iv(e);return[Z_(e),t,Z_(t)]}function Z_(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Q_=[`left`,`right`],$_=[`right`,`left`],ev=[`top`,`bottom`],tv=[`bottom`,`top`];function nv(e,t,n){switch(e){case`top`:case`bottom`:return n?t?$_:Q_:t?Q_:$_;case`left`:case`right`:return t?ev:tv;default:return[]}}function rv(e,t,n,r){let i=W_(e),a=nv(U_(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Z_)))),a}function iv(e){let t=U_(e);return B_[t]+e.slice(t.length)}function av(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function ov(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:av(e)}function sv(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function cv(e,t,n){return Math.floor(e/t)!==n}function lv(e,t){return t<0||t>=e.length}function uv(e,t){return pv(e.current,{disabledIndices:t})}function dv(e,t){return pv(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function fv(e,t,n){let{decrement:r,loopFocus:i,allowEscape:a,disabledIndices:o,minIndex:s,maxIndex:c}=n,l=()=>pv(e,{startingIndex:t,decrement:r,disabledIndices:o}),u,d=!1;if(!i)u=r?Math.max(s,l()):Math.min(c,l());else if(r?t<=s:t>=c){let n=r?-1:e.length;a&&t!==n?u=-1:(u=r?c:s,d=!0)}else u=l();return{index:lv(e,u)?-1:u,wrapped:d}}function pv(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&hv(e,a,r));return a}function mv(e,{event:t,orientation:n,loopFocus:r,onLoop:i,rtl:a,cols:o,disabledIndices:s,minIndex:c,maxIndex:l,prevIndex:u,stopEvent:d=!1}){let f=u,p;if(t.key===`ArrowUp`?p=`up`:t.key===`ArrowDown`&&(p=`down`),p){let n=[],a=[],m=!1,h=0;{let t=null,r=-1;e.forEach((e,i)=>{if(e==null)return;h+=1;let o=qg(e,`[role="row"]`);o&&(m=!0),(o!==t||r===-1)&&(t=o,r+=1,n[r]=[]),n[r].push(i),a[i]=r})}let g=!1,_=0;if(m)for(let e of n){let t=e.length;t>_&&(_=t),t!==o&&(g=!0)}let v=g&&h<e.length,y=_||o,b=o=>{if(!g||u===-1)return;let c=a[u];if(c==null)return;let l=n[c].indexOf(u),d=o===`up`?-1:1;for(let o=c+d,f=0;f<n.length;f+=1,o+=d){if(o<0||o>=n.length){if(!r||v)return;if(o=o<0?n.length-1:0,i){let e=Math.min(l,n[o].length-1),r=i(t,u,n[o][e]??n[o][0]);o=a[r]??o}}let c=n[o];for(let t=Math.min(l,c.length-1);t>=0;--t){let n=c[t];if(!hv(e,n,s))return n}}},x=t=>{if(!v||u===-1)return;let n=u%y,i=t===`up`?-y:y,a=l-l%y,o=R_(l/y)+1;for(let t=u-n+i,c=0;c<o;c+=1,t+=i){if(t<0||t>l){if(!r)return;t=t<0?a:0}let i=Math.min(t+y-1,l);for(let r=Math.min(t+n,i);r>=t;--r)if(!hv(e,r,s))return r}};d&&k_(t);let S=b(p)??x(p);if(S!==void 0)f=S;else if(u===-1)f=p===`up`?l:c;else if(f=pv(e,{startingIndex:u,amount:y,decrement:p===`up`,disabledIndices:s}),r){if(p===`up`&&(u-y<c||f<0)){let e=u%y,n=l%y,r=l-(n-e);f=n===e?l:n>e?r:r-y,i&&(f=i(t,u,f))}p===`down`&&u+y>l&&(f=pv(e,{startingIndex:u%y-y,amount:y,disabledIndices:s}),i&&(f=i(t,u,f)))}lv(e,f)&&(f=u)}if(n===`both`){let n=R_(u/o);t.key===(a?`ArrowLeft`:`ArrowRight`)&&(d&&k_(t),u%o===o-1?r&&(f=pv(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):(f=pv(e,{startingIndex:u,disabledIndices:s}),r&&cv(f,o,n)&&(f=pv(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f)))),cv(f,o,n)&&(f=u)),t.key===(a?`ArrowRight`:`ArrowLeft`)&&(d&&k_(t),u%o===0?r&&(f=pv(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f))):(f=pv(e,{startingIndex:u,decrement:!0,disabledIndices:s}),r&&cv(f,o,n)&&(f=pv(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f)))),cv(f,o,n)&&(f=u));let c=R_(l/o)===n;lv(e,f)&&(r&&c?(f=t.key===(a?`ArrowRight`:`ArrowLeft`)?l:pv(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):f=u)}return f}function hv(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!_v(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function gv(e){return e.visibility===`hidden`||e.visibility===`collapse`}function _v(e,t=e?ne(e):null){return!e||!e.isConnected||!t||gv(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var vv=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function yv(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return A(n)?n.host:null}function bv(e){for(let t of Array.from(e.children))if(x(t)===`summary`)return t;return null}function xv(e,t){let n=bv(t);return!!n&&(e===n||Q(n,e))}function Sv(e){let t=e?x(e):``;return e!=null&&e.matches(vv)&&(t!==`summary`||e.parentElement!=null&&x(e.parentElement)===`details`&&bv(e.parentElement)===e)&&(t!==`details`||bv(e)==null)&&(t!==`input`||e.type!==`hidden`)}function Cv(e){if(!Sv(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=yv(t)){let n=t!==e,r=x(t)===`slot`;if(t.hasAttribute(`inert`)||n&&x(t)===`details`&&!t.open&&!xv(e,t)||t.hasAttribute(`hidden`)||!r&&!wv(t,n))return!1}return!0}function wv(e,t){let n=ne(e);return t?n.display!==`none`:_v(e,n)}function Tv(e){let t=e.tabIndex;if(t<0){let t=x(e);if(t===`details`||t===`audio`||t===`video`||l(e)&&e.isContentEditable)return 0}return t}function Ev(e){if(x(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function Dv(e,t){let n=Ev(e);if(!n)return!0;let r=t.find(e=>{let t=Ev(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=Ev(e);return t?.name===n.name&&t.form===n.form})===n}function Ov(e){if(l(e)&&x(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return l(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function kv(e,t){Ov(e).forEach(e=>{Sv(e)&&t.push(e),kv(e,t)})}function Av(e,t,n){Ov(e).forEach(e=>{l(e)&&e.matches(t)&&n.push(e),Av(e,t,n)})}function jv(e){return Cv(e)&&Tv(e)>=0}function Mv(e){let t=[];return kv(e,t),t.filter(Cv)}function Nv(e){let t=Mv(e);return t.filter(e=>Tv(e)>=0&&Dv(e,t))}function Pv(e,t){let n=Nv(e),r=n.length;if(r===0)return;let i=Kg(Ra(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function Fv(e){return Pv(Ra(e).body,1)||e}function Iv(e){return Pv(Ra(e).body,-1)||e}function Lv(e,t,n){if(!e)return null;let r=[];kv(Ra(e).body,r);let i=r.indexOf(e);if(i===-1)return null;let a=r.filter(Cv);for(let e=1;e<r.length;e+=1){let o=r[(i+t*e+r.length)%r.length];if(!Q(n,o)&&jv(o)&&Dv(o,a))return o}return r[i]}function Rv(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!Q(n,r)}function zv(e){Nv(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function Bv(e){let t=[];Av(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function Vv(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...Vv(e,t.id,n)])}function Hv(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 $(e,t,n,r){let i=!1,a=!1,o=r??z;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function Uv(e,t,n){let r=n??z;return{reason:e,event:t??new Event(`base-ui`),...r}}var Wv=`none`,Gv=`trigger-press`,Kv=`trigger-hover`,qv=`trigger-focus`,Jv=`outside-press`,Yv=`item-press`,Xv=`close-press`,Zv=`clear-press`,Qv=`input-change`,$v=`input-clear`,ey=`input-press`,ty=`focus-out`,ny=`escape-key`,ry=`list-navigation`,iy=`keyboard`,ay=`pointer`,oy=`cancel-open`,sy=`sibling-open`,cy=`imperative-action`;function ly(e){return`data-base-ui-${e}`}var uy=0;function dy(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(uy);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),P;let o=requestAnimationFrame(a);return uy=o,()=>{uy===o&&(cancelAnimationFrame(o),uy=0)}}var fy=`data-base-ui-inert`,py=new WeakMap,my=new WeakSet,hy=new WeakMap,gy=0;function _y(e){return e?A(e)?e.host:_y(e.parentNode):null}var vy=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=_y(t);return e.contains(n)?n:null}).filter(e=>e!=null),yy=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},by=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{x(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function xy(e,t,n,{mark:r=!0}){let i=vy(t,e),a=r?by(t,yy(i),new Set(i)):[],o=[],s=[];if(n){let e=vy(t,Array.from(t.querySelectorAll(`[aria-live]`))),n=i.concat(e);by(t,yy(n),new Set(n)).forEach(e=>{let t=e.getAttribute(`aria-hidden`),n=t!==null&&t!==`false`,r=(py.get(e)||0)+1;py.set(e,r),o.push(e),r===1&&n&&my.add(e),n||e.setAttribute(`aria-hidden`,`true`)})}return r&&a.forEach(e=>{let t=(hy.get(e)||0)+1;hy.set(e,t),s.push(e),t===1&&e.setAttribute(fy,``)}),gy+=1,()=>{o.forEach(e=>{let t=(py.get(e)||0)-1;py.set(e,t),t||(my.has(e)||e.removeAttribute(`aria-hidden`),my.delete(e))}),r&&s.forEach(e=>{let t=(hy.get(e)||0)-1;hy.set(e,t),t||e.removeAttribute(fy)}),--gy,gy||(py=new WeakMap,my=new WeakSet,hy=new WeakMap)}}function Sy(e,t={}){let{ariaHidden:n=!1,mark:r=!0}=t,i=Ra(e[0]).body;return xy(e,i,n,{mark:r})}function Cy(){let[,e]=Y.useState({});return Y.useCallback(()=>{e({})},[])}var wy=0;function Ty(e,t=`mui`){let n=Y.useRef(void 0),r=Cy(),i=e??n.current;return Y.useEffect(()=>{n.current??(wy+=1,n.current=`${t}-${wy}`,e??r())},[e,t,r]),i}var Ey=S.useId;function Dy(e,t){if(Ey!==void 0){let n=Ey();return e??(t?`${t}-${n}`:n)}return Ty(e,t)}var Oy={style:{transition:`none`}},ky={fallbackAxisSide:`none`},Ay={fallbackAxisSide:`end`},jy={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},My=Y.createContext(null),Ny=()=>Y.useContext(My),Py=ly(`portal`);function Fy(e={}){let{ref:t,container:n,componentProps:r=z,elementProps:i}=e,a=Dy(),o=Ny()?.portalNode,[s,c]=Y.useState(null),[l,u]=Y.useState(null),d=f(e=>{e!==null&&u(e)}),p=Y.useRef(null);D(()=>{if(n===null){p.current&&(p.current=null,u(null),c(null));return}let e=(n&&(h(n)?n:n.current))??o??document.body;e==null?p.current&&(p.current=null,u(null),c(null)):p.current!==e&&(p.current=e,u(null),c(e))},[n,o]);let m=H(`div`,r,{ref:[t,d],props:[{id:a,[Py]:``},i]}),g=s&&m?Wm.createPortal(m,s):null;return{node:l,nodeId:Y.isValidElement(m)?m.props.id:void 0,subtree:g}}var Iy=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:o,portalOwnerRole:s,...c}=e,{node:l,nodeId:u,subtree:d}=Fy({container:o,ref:t,componentProps:e,elementProps:c}),f=Y.useRef(null),p=Y.useRef(null),m=Y.useRef(null),h=Y.useRef(null),[g,_]=Y.useState(null),v=Y.useRef(!1),y=g?.modal,b=g?.open,x=!!g&&!g.modal&&g.open&&!!l;Y.useEffect(()=>{if(!l||y)return;function e(e){l&&e.relatedTarget&&Rv(e)&&(e.type===`focusin`?v.current&&=(Bv(l),!1):(zv(l),v.current=!0))}return xg(bg(l,`focusin`,e,!0),bg(l,`focusout`,e,!0))},[l,y]),D(()=>{l&&b===!0&&v.current&&(Bv(l),v.current=!1)},[b,l]);let S=Y.useMemo(()=>({beforeOutsideRef:f,afterOutsideRef:p,beforeInsideRef:m,afterInsideRef:h,portalNode:l,setFocusManagerState:_}),[l]);return(0,X.jsxs)(Y.Fragment,{children:[d,(0,X.jsxs)(My.Provider,{value:S,children:[x&&l&&(0,X.jsx)(Gg,{"data-type":`outside`,ref:f,onFocus:e=>{Rv(e,l)?m.current?.focus():Iv(g?g.domReference:null)?.focus()}}),x&&l&&(0,X.jsx)(`span`,{role:s,"aria-owns":u,style:jy}),l&&Wm.createPortal(a,l),x&&l&&(0,X.jsx)(Gg,{"data-type":`outside`,ref:p,onFocus:e=>{Rv(e,l)?h.current?.focus():(Fv(g?g.domReference:null)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,$(`focus-out`,e.nativeEvent)))}})]})]})});function Ly(){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 Ry=class{nodesRef={current:[]};events=Ly();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)}},zy=Y.createContext(null),By=Y.createContext(null),Vy=()=>Y.useContext(zy)?.id||null,Hy=e=>{let t=Y.useContext(By);return e??t};function Uy(e){let t=Dy(),n=Hy(e),r=Vy();return D(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function Wy(e){let{children:t,id:n}=e,r=Vy();return(0,X.jsx)(zy.Provider,{value:Y.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Gy(e){let{children:t,externalTree:n}=e,r=d(()=>n??new Ry).current;return(0,X.jsx)(By.Provider,{value:r,children:t})}function Ky(e){return e==null?e:`current`in e?e.current:e}function qy(e,t){let n=y(Jg(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||(j_(e)?`keyboard`:t||`mouse`):`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var Jy=20,Yy=[];function Xy(){Yy=Yy.filter(e=>e.deref()?.isConnected)}function Zy(e){Xy(),e&&x(e)!==`body`&&(Yy.push(new WeakRef(e)),Yy.length>Jy&&(Yy=Yy.slice(-20)))}function Qy(){return Xy(),Yy[Yy.length-1]?.deref()}function $y(e){return e?jv(e)?e:Nv(e)[0]||e:null}function eb(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=Mv(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return jv(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 tb(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,explicitReturnFocus:o,restoreFocus:s=!1,modal:c=!0,closeOnFocusOut:u=!0,openInteractionType:d=``,nextFocusableElement:p,previousFocusableElement:m,beforeContentFocusGuardRef:h,externalTree:g,getInsideElements:_}=e,v=t.useState(`open`),y=t.useState(`domReferenceElement`),b=t.useState(`floatingElement`),{events:S,dataRef:C}=t.context,w=f(()=>C.current.floatingContext?.nodeId),T=i===!1,E=E_(y)&&T,O=tg(i),k=tg(a),A=tg(o),j=tg(d),M=tg(v),N=Hy(g),P=Ny(),F=Y.useRef(!1),I=Y.useRef(!1),L=Y.useRef(!1),R=Y.useRef(null),ee=Y.useRef(``),z=Y.useRef(``),B=Y.useRef(null),V=Y.useRef(null),te=fe(B,h,P?.beforeInsideRef),ne=fe(V,P?.afterInsideRef),H=Tg(),re=Tg(),ie=Wg(),ae=P!=null,U=O_(b),oe=f((e=U)=>e?Nv(e):[]),se=f(()=>_?.().filter(e=>e!=null)??[]);Y.useEffect(()=>{if(r||!c)return;function e(e){e.key===`Tab`&&Q(U,Kg(Ra(U)))&&oe().length===0&&!E&&k_(e)}return bg(Ra(U),`keydown`,e)},[r,U,c,E,oe]),Y.useEffect(()=>{if(r||!v)return;let e=Ra(U);function t(){L.current=!1}function n(e){let t=Jg(e),n=se(),r=Q(b,t)||Q(y,t)||Q(P?.portalNode,t)||n.some(e=>e===t||Q(e,t));L.current=!r,z.current=e.pointerType||`keyboard`,qg(t,`[data-base-ui-click-trigger]`)&&(I.current=!0,re.start(0,()=>{I.current=!1}))}function i(){z.current=`keyboard`}return xg(bg(e,`pointerdown`,n,!0),bg(e,`pointerup`,t,!0),bg(e,`pointercancel`,t,!0),bg(e,`keydown`,i,!0),t)},[r,b,y,U,v,P,re,se]),Y.useEffect(()=>{if(r||!u)return;let e=Ra(U);function n(){I.current=!0,re.start(0,()=>{I.current=!1})}function i(e){let t=Jg(e);jv(t)&&(R.current=t)}function a(n){let r=n.relatedTarget,i=n.currentTarget,a=Jg(n);c&&r==null&&a!=null&&Q(b,a)&&Zy(a),queueMicrotask(()=>{let o=w(),u=t.context.triggerElements,d=se(),f=r?.hasAttribute(ly(`focus-guard`))&&[B.current,V.current,P?.beforeInsideRef.current,P?.afterInsideRef.current,P?.beforeOutsideRef.current,P?.afterOutsideRef.current,Ky(m),Ky(p)].includes(r),h=!(Q(y,r)||Q(b,r)||Q(r,b)||Q(P?.portalNode,r)||d.some(e=>e===r||Q(e,r))||u.hasMatchingElement(e=>Q(e,r))||f||N&&(Vv(N.nodesRef.current,o).find(e=>Q(e.context?.elements.floating,r)||Q(e.context?.elements.domReference,r))||Hv(N.nodesRef.current,o).find(e=>[e.context?.elements.floating,O_(e.context?.elements.floating)].includes(r)||e.context?.elements.domReference===r)));if(i===y&&U&&eb(U),s&&i!==y&&!_v(a)&&Kg(e)===e.body){if(l(U)&&(U.focus(),s===`popup`)){ie.request(()=>{U.focus()});return}let e=oe(),t=R.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||U;l(n)&&n.focus()}C.current.insideReactTree?C.current.insideReactTree=!1:(E||!c)&&r&&h&&!I.current&&(E||r!==Qy())&&(F.current=!0,t.setOpen(!1,$(ty,n)))})}function o(){L.current||(C.current.insideReactTree=!0,H.start(0,()=>{C.current.insideReactTree=!1}))}let d=l(y)?y:null;if(b||d)return xg(d&&bg(d,`focusout`,a),d&&bg(d,`pointerdown`,n),b&&bg(b,`focusin`,i),b&&bg(b,`focusout`,a),b&&P&&bg(b,`focusout`,o,!0))},[r,y,b,U,c,N,P,t,u,s,oe,E,w,C,H,re,ie,p,m,se]),Y.useEffect(()=>{if(r||!b||!v)return;let e=Array.from(P?.portalNode?.querySelectorAll(`[${ly(`portal`)}]`)||[]),t=(N?Hv(N.nodesRef.current,w()):[]).find(e=>E_(e.context?.elements.domReference||null))?.context?.elements.domReference,n=Sy([b,...e,B.current,V.current,P?.beforeOutsideRef.current,P?.afterOutsideRef.current,...se(),t,Ky(m),Ky(p),E?y:null].filter(e=>e!=null),{ariaHidden:c||E,mark:!1}),i=Sy([b,...e].filter(e=>e!=null));return()=>{i(),n()}},[v,r,y,b,c,P,E,N,w,p,m,se]),D(()=>{if(!v||r||!l(U))return;ee.current=``,z.current=``;let e=Ra(U),t=Kg(e);queueMicrotask(()=>{let n=O.current,r=typeof n==`function`?n(j.current||``):n;if(r===void 0||r===!1||Q(U,t))return;let i=null,a=()=>(i??=oe(U),i[0]||U),o;o=r===!0||r===null?a():Ky(r),o||=a();let s=Q(U,Kg(e)),c=C.current.openEvent,l=c?.type===`mousedown`&&j_(c);dy(o,{sync:l,preventScroll:o===U,shouldFocus(){if(!M.current)return!1;if(s)return!0;let t=Kg(e);return!(t!==o&&Q(U,t))}})})},[r,v,U,oe,O,j,M,C]);let ce=Y.useRef(null);D(()=>{if(r||!U){ce.current=null;return}ce.current&&=(ce.current.cancelled=!0,null);let e=Ra(U),t=Kg(e),n=j.current==null;Zy(t);function i(e){if(e.open||(ee.current=qy(e.nativeEvent,z.current)),(e.reason===`focus-out`&&e.triggerElement?.hasAttribute(ly(`focus-guard`))||e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`)&&(F.current=!0),e.reason===`outside-press`){if(e.nested)F.current=!1;else if(j_(e.nativeEvent)||M_(e.nativeEvent))F.current=!1;else{let e=!1;Ra(U).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?F.current=!1:F.current=!0}}}S.on(`openchange`,i);function a(e){let r=k.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=y?.isConnected?y:null,o=t?.isConnected&&x(t)!==`body`?t:null,s=n?o||a:a||o;return s||=Qy()||null,typeof i==`boolean`?s:Ky(i)||s||null}return()=>{S.off(`openchange`,i);let t=Kg(e),n=se(),r=Q(b,t)||n.some(e=>e===t||Q(e,t))||N&&Vv(N.nodesRef.current,w(),!1).some(e=>Q(e.context?.elements.floating,t)),o=k.current,s=ee.current,c=a(s),u={cancelled:!1};ce.current=u,queueMicrotask(()=>{ce.current===u&&(ce.current=null);let n=$y(c),i=A.current??typeof o!=`boolean`;if(!u.cancelled&&o&&!F.current&&l(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}F.current=!1})}},[r,b,U,k,A,j,S,N,y,w,se]),D(()=>{if(!Lg||v||!b)return;let e=Kg(Ra(b));l(e)&&w_(e)&&Q(b,e)&&e.blur()},[v,b]),D(()=>{if(!r&&P)return P.setFocusManagerState({modal:c,closeOnFocusOut:u,open:v,onOpenChange:t.setOpen,domReference:y}),()=>{P.setFocusManagerState(null)}},[r,P,c,v,t,u,y]),D(()=>{if(!r&&U)return eb(U),()=>{queueMicrotask(Xy)}},[r,U]);let le=!r&&(!c||!E)&&(ae||c);return(0,X.jsxs)(Y.Fragment,{children:[le&&(0,X.jsx)(Gg,{"data-type":`inside`,ref:te,onFocus:e=>{if(c){let e=oe();dy(e[e.length-1])}else P?.portalNode&&(F.current=!1,Rv(e,P.portalNode)?Fv(y)?.focus():Ky(m??P.beforeOutsideRef)?.focus())}}),n,le&&(0,X.jsx)(Gg,{"data-type":`inside`,ref:ne,onFocus:e=>{c?dy(oe()[0]):P?.portalNode&&(u&&(F.current=!0),Rv(e,P.portalNode)?Iv(y)?.focus():Ky(p??P.afterOutsideRef)?.focus())}})]})}function nb(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=Gv}=t,l=e.context.dataRef,u=Y.useRef(void 0),d=Wg(),f=Tg(),p=Y.useMemo(()=>{function t(t,n,r,i){let a=$(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=N_(e.pointerType,!0)&&M_(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(i){let o=u.current,s=i.nativeEvent,c=e.select(`open`);if(i.button!==0||r===`click`||N_(o,!0)&&a)return;let l=n(c,i.currentTarget,e=>e===`click`||e===`mousedown`),f=Jg(s),p=w_(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:N_(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 Y.useMemo(()=>n?{reference:p}:z,[n,p])}function rb(){return!1}function ib(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function ab(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=rb,bubbles:s,externalTree:c}=t,u=e.useState(`open`),d=e.useState(`floatingElement`),{dataRef:p,events:m}=e.context,h=Hy(c),_=f(typeof i==`function`?i:()=>!1),v=typeof i==`function`?_:i,y=v!==!1,b=f(()=>a),{escapeKey:x,outsidePress:S}=ib(s),C=Y.useRef(!1),w=Y.useRef(!1),T=Y.useRef(!1),E=Y.useRef(!1),D=Y.useRef(!1),O=Y.useRef(``),j=Y.useRef(null),M=Tg(),N=Tg(),P=Tg(),F=f(()=>{N.clear(),p.current.insideReactTree=!1}),I=f(e=>{let t=p.current.floatingContext?.nodeId;return(h?Vv(h.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),L=f(t=>S_(t,e.select(`floatingElement`))||S_(t,e.select(`domReferenceElement`))),R=f(t=>{o()&&e.setOpen(!1,$(Gv,t.nativeEvent))}),ee=f(t=>{if(!u||!n||!r||t.key!==`Escape`)return;let i=A_(t)?t.nativeEvent:t;if(D.current||i.isComposing||!x&&I(`__escapeKeyBubbles`))return;let a=$(ny,i);e.setOpen(!1,a),a.isCanceled||t.preventDefault(),!x&&!a.isPropagationAllowed&&t.stopPropagation()}),z=f(()=>{p.current.insideReactTree=!0,N.start(0,F)}),B=f(t=>{if(!u||!n||t.button!==0)return;let r=Jg(t.nativeEvent);Q(e.select(`floatingElement`),r)&&(C.current||(C.current=!0,w.current=!1))}),V=f(e=>{u&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&C.current&&(w.current=!0)});Y.useEffect(()=>{function e(e){e.open||(E.current=!1)}return m.on(`openchange`,e),()=>{m.off(`openchange`,e)}},[m]),Y.useEffect(()=>F,[F]),Y.useEffect(()=>{if(!u||!n)return u||(E.current=!1,D.current=!1,O.current=``,j.current=null),F;p.current.__escapeKeyBubbles=x,p.current.__outsidePressBubbles=S;let t=new wg,i=Ra(d);function a(){P.clear(),D.current=!0}function o(){D.current=!0,P.start(Lg?5:0,()=>{D.current=!1})}function s(){T.current=!0,t.start(0,()=>{T.current=!1})}function c(){C.current=!1,w.current=!1}function f(){let e=O.current,t=e===`pen`||!e?`mouse`:e,n=b(),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 _(e){let t=p.current.floatingContext?.nodeId,n=h&&Vv(h.nodesRef.current,t).some(t=>S_(e,t.context?.elements.floating));return L(e)||n}function N(n){if(m(n)){n.type!==`click`&&!L(n)&&(t.clear(),T.current=!1),F();return}if(p.current.insideReactTree){F();return}let r=Jg(n),i=`[${ly(`inert`)}]`,a=pe(r)?r.getRootNode():null,o=Array.from((A(a)?a:Ra(e.select(`floatingElement`))).querySelectorAll(i)),s=e.context.triggerElements;if(r&&(s.hasElement(r)||s.hasMatchingElement(e=>Q(e,r))))return;let c=pe(r)?r:null;for(;c&&!k(c);){let e=g(c);if(k(e)||!pe(e))break;c=e}if(!(o.length&&pe(r)&&!C_(r)&&!Q(r,e.select(`floatingElement`))&&o.every(e=>!Q(c,e)))){if(l(r)&&!(`touches`in n)){let e=k(r),t=ne(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(!_(n)){if(f()===`intentional`){if(n.detail!==0&&!j_(n)&&!E.current)return;if(T.current){t.clear(),T.current=!1;return}}typeof v==`function`&&!v(n)||I(`__outsidePressBubbles`)||(e.setOpen(!1,$(Jv,n)),F())}}}function R(t){f()===`sloppy`&&t.pointerType!==`touch`&&e.select(`open`)&&n&&!L(t)&&N(t)}function z(t){if(f()!==`sloppy`||!e.select(`open`)||!n||L(t))return;let r=t.touches[0];r&&(j.current={startTime:Date.now(),startX:r.clientX,startY:r.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},M.start(1e3,()=>{j.current&&(j.current.dismissOnTouchEnd=!1,j.current.dismissOnMouseDown=!1)}))}function B(e,t){let n=Jg(e);if(!n)return;let r=bg(n,e.type,()=>{t(e),r()})}function V(e){O.current=`touch`,B(e,z)}function te(e){M.clear(),e.type===`pointerdown`&&(e.button===0&&(E.current=!0),O.current=e.pointerType),(e.type!==`mousedown`||!j.current||j.current.dismissOnMouseDown)&&B(e,e=>{e.type===`pointerdown`?R(e):N(e)})}function H(e){if(e.type===`pointercancel`&&(E.current=!1),!C.current)return;let n=w.current;c(),f()===`intentional`&&(e.type===`pointercancel`?n&&s():_(e)||(n?s():(typeof v!=`function`||v(e))&&(t.clear(),T.current=!0,F())))}function re(e){if(f()!==`sloppy`||!j.current||L(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-j.current.startX),r=Math.abs(t.clientY-j.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(j.current.dismissOnTouchEnd=!0),i>10&&(N(e),M.clear(),j.current=null)}function ie(e){B(e,re)}function ae(e){f()===`sloppy`&&j.current&&!L(e)&&(j.current.dismissOnTouchEnd&&N(e),M.clear(),j.current=null)}function U(e){B(e,ae)}let oe=xg(r&&xg(bg(i,`keydown`,ee),bg(i,`compositionstart`,a),bg(i,`compositionend`,o)),y&&xg(bg(i,`click`,te,!0),bg(i,`pointerdown`,te,!0),bg(i,`pointerup`,H,!0),bg(i,`pointercancel`,H,!0),bg(i,`mousedown`,te,!0),bg(i,`mouseup`,H,!0),bg(i,`touchstart`,V,{capture:!0,passive:!0}),bg(i,`touchmove`,ie,{capture:!0,passive:!0}),bg(i,`touchend`,U,{capture:!0,passive:!0})));return()=>{oe(),t.clear(),c(),T.current=!1}},[p,d,r,y,v,u,n,x,S,ee,F,b,I,L,h,e,M,P]);let te=Y.useMemo(()=>({onKeyDown:ee,onPointerDown:R,onClick:R}),[ee,R]),H=Y.useMemo(()=>({onKeyDown:ee,onPointerDown:V,onMouseDown:V,onClickCapture:z,onMouseDownCapture(e){z(),B(e)},onPointerDownCapture(e){z(),B(e)},onMouseUpCapture:z,onTouchEndCapture:z,onTouchMoveCapture:z}),[ee,z,B,V]);return Y.useMemo(()=>n?{reference:te,floating:H,trigger:te}:{},[n,te,H])}function ob(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),D(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};pe(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 sb(e,t=!1,n=!1,r=!1){let[i,a]=Y.useState(e&&t?`idle`:void 0),[o,s]=Y.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),D(()=>{if(!e&&o&&i!==`ending`&&n){let e=Ug.request(()=>{a(`ending`)});return()=>{Ug.cancel(e)}}},[e,o,i,n]),D(()=>{if(!e||t||i===void 0)return;let n=Ug.request(()=>{a(void 0)});return()=>{Ug.cancel(n)}},[t,e,i]),D(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=Ug.request(()=>{a(`idle`)});return()=>{Ug.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}function cb(e,t){return e.getAnimations(t).filter(e=>{let t=e.effect?.getTiming();return t?.duration!==1/0&&t?.iterations!==1/0})}var lb=null;function ub(e){if(!lb){let e=[];lb=e,queueMicrotask(()=>{lb=null,Wm.flushSync(()=>{for(let t of e)t()})})}lb.push(e)}function db(e,t=!1,n=!1){let r=Wg();return f((i,a=null)=>{r.cancel();let o=Ky(e);if(o==null)return;let s=o,c=()=>{n?ub(()=>{a?.aborted||i()}):Wm.flushSync(i)};if(typeof s.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function l(){Promise.all(cb(s).map(e=>e.finished.then(P))).then(()=>{a?.aborted||c()},()=>{a?.aborted||(cb(s).some(e=>e.pending||e.playState!==`finished`)?l():c())})}if(t){let e=t_;if(!s.hasAttribute(e)){r.request(l);return}let t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),l())});t.observe(s,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0})}else r.request(l)})}function fb(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=f(a),s=db(r,n,i);Y.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}function pb(e){let{open:t,ref:n,preventUnmountOnClose:r,setPreventUnmountOnClose:i,onUnmount:a,animateInitialOpen:o}=e,s=f(i),{mounted:c,setMounted:l,transitionStatus:u}=sb(t,!1,!1,o),d=!t&&r;D(()=>{t&&s(!1)},[t,s]);let p=Y.useRef(c),m=Y.useRef(!1),h=Cy(),g=()=>{p.current=!1,l(!1),a()};D(()=>{p.current=c,m.current&&(m.current=!1,!t&&c&&g())});let _=f(()=>{p.current&&(t?(m.current=!0,h()):g())});return fb({enabled:c&&!t&&!d,open:t,ref:n,onComplete(){t||_()}}),{mounted:c,transitionStatus:u,preventUnmountingOnClose:d,forceUnmount:_}}var mb={tabIndex:-1,[Yg]:``};function hb({handle:e,store:t}){return D(()=>e.attachStore(t),[e,t]),null}function gb(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function _b(e,t){let n=Y.useRef(null);return f(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),gb(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),gb(t))})}function vb(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 yb(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function bb(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=_b(e,n),o=f(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=f(e=>{a(e),e&&o(e)});return D(()=>(s(t.current),()=>s(null)),[s,t,n,e]),D(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function xb(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=Y.useRef(null),i=e.useState(`open`),a=e.useState(`triggerCount`),o=e.useState(`activeTriggerId`),s=e.useState(`activeTriggerElement`);D(()=>{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=$(Wv);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,a,o,s,n])}function Sb(e,t,n,r){let{mounted:i,transitionStatus:a,forceUnmount:o}=pb({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 d(()=>(t.set(`mounted`,i),null)),t.useSyncedValues({mounted:i,transitionStatus:a}),{forceUnmount:o,transitionStatus:a}}function Cb(e,t){e.useSyncedValues(t),D(()=>()=>{e.update({activeTriggerProps:z,inactiveTriggerProps:z,popupProps:z})},[e])}var wb=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}},Tb={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},Eb=class extends yg{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:Ly(),nested:n,triggerElements:i},Tb),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&P_(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 Db(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new Eb({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:z,inactiveTriggerProps:z,popupProps:z}}var Ob=e=>e.triggerIdProp??e.activeTriggerId,kb=e=>e.openProp??e.open,Ab=e=>(e.popupElement?.id??e.floatingId)||void 0;function jb(e,t){return t!==void 0&&kb(e)&&Ob(e)===t}function Mb(e,t){return jb(e,t)?!0:t!==void 0&&kb(e)&&Ob(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}var Nb={open:kb,mounted:e=>e.mounted,transitionStatus:e=>kb(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Ob,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Ab,isTriggerActive:(e,t)=>t!==void 0&&Ob(e)===t,isOpenedByTrigger:(e,t)=>jb(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&Ob(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>Mb(e,t)?Ab(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function Pb(e){let t=Y.useCallback(t=>e===void 0?P:e.subscribeStore(t),[e]),n=Y.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,Pa.useSyncExternalStore)(t,n,()=>e?.serverStore)}function Fb(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=Dy(),a=Vy()!=null,o=d(()=>new Eb({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new wb,floatingId:i,syncOnly:!1,nested:a})).current;return D(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=pe(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 Ib=Fg&&Lg;function Lb(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=Y.useRef(!1),s=Y.useRef(null),c=Y.useRef(!0),u=Tg();Y.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=y(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&l(t)&&t===Kg(Ra(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function u(){c.current=!1}return xg(bg(r,`blur`,i),Ib&&bg(r,`keydown`,a,!0),Ib&&bg(r,`pointerdown`,u,!0))},[e,n]),Y.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);pe(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let d=Y.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=Jg(n.nativeEvent);if(pe(a)){if(Ib&&!n.relatedTarget){if(!c.current&&!w_(a))return}else if(!D_(a))return}let l=x_(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;e.select(`open`)&&l||!r?e.setOpen(!0,$(qv,d,f)):u.start(r,()=>{o.current||e.setOpen(!0,$(qv,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=pe(r)&&r.hasAttribute(ly(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;u.start(0,()=>{let t=e.select(`domReferenceElement`),n=Kg(Ra(t));!r&&n===t||Q(a.current.floatingContext?.refs.floating.current,n)||Q(t,n)||o||x_(r??n,e.context.triggerElements)||e.setOpen(!1,$(qv,i))})}}},[a,r,e,u]);return Y.useMemo(()=>n?{reference:d,trigger:d}:{},[n,d])}var Rb=class e{pointerType=void 0;interactedInside=!1;handler=void 0;blockMouseMove=!0;performedPointerEventsMutation=!1;pointerEventsScopeElement=null;pointerEventsReferenceElement=null;pointerEventsFloatingElement=null;restTimeoutPending=!1;openChangeTimeout=new wg;restTimeout=new wg;handleCloseOptions=void 0;static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},zb=new WeakMap;function Bb(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&zb.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),zb.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function Vb(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=zb.get(n);a&&a!==e&&Bb(a),Bb(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,zb.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function Hb(e){let t=e.context.dataRef.current,n=d(()=>t.hoverInteractionState??Rb.create()).current;return t.hoverInteractionState||=n,Sg(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function Ub(e,t){return t!=null&&!N_(t)?0:typeof e==`function`?e():e}function Wb(e,t,n){let r=Ub(e,n);return typeof r==`number`?r:r?.[t]}function Gb(e){return typeof e==`function`?e():e}function Kb(e,t){return t||e===`click`||e===`mousedown`}function qb(e){return e?.includes(`mouse`)&&e!==`mousedown`}function Jb(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=Hy(),u=Vy(),d=Hb(e),p=Tg(),m=f(()=>Kb(c.current.openEvent?.type,d.interactedInside)),h=f(()=>qb(c.current.openEvent?.type)),g=f(()=>{Bb(d)});D(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,g())},[a,d,g]),Y.useEffect(()=>g,[g]),D(()=>{if(n&&a&&d.handleCloseOptions?.blockPointerEvents&&h()&&pe(s)&&o){let e=s,t=o,n=Ra(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??qg(e,`[data-rootownerid]`)??n.body;return Vb(d,{scopeElement:c,referenceElement:e,floatingElement:t}),()=>{g()}}},[n,a,s,o,d,h,l,u,g]),Y.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&Vv(l.nodesRef.current,u).length>0)}function a(t){let n=Wb(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,$(Kv,t)),l?.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=Jg(e);T_(t)?d.interactedInside=qg(t,`[aria-haspopup]`)!=null:d.interactedInside=!1}function f(){d.openChangeTimeout.clear(),p.clear(),l?.events.off(`floating.closed`,v),g()}function _(n){if(t()&&l){l.events.on(`floating.closed`,v);return}if(x_(n.relatedTarget,e.context.triggerElements))return;let r=c.current.floatingContext?.nodeId??i,o=n.relatedTarget;l&&r&&pe(o)&&Vv(l.nodesRef.current,r,!1).some(e=>Q(e.context?.elements.floating,o))||(d.handler?d.handler(n):(g(),h()&&!m()&&a(n)))}function v(n){l&&u&&!t()&&p.start(0,()=>{l.events.off(`floating.closed`,v),e.setOpen(!1,$(Kv,n)),l.events.emit(`floating.closed`,n)})}let y=o;return xg(y&&bg(y,`mouseenter`,f),y&&bg(y,`mouseleave`,_),y&&bg(y,`pointerdown`,s,!0),()=>{l?.events.off(`floating.closed`,v)})},[n,o,e,c,r,i,h,m,g,d,l,u,p])}var Yb={current:null};function Xb(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=Yb,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:p,shouldOpen:m,guardStaleOpen:h=!1}=t,{dataRef:g,events:_}=e.context,v=Hy(l),y=Hb(e),b=Y.useRef(!1),x=tg(i),S=tg(r),C=tg(o),w=tg(n),T=tg(m),E=tg(p),D=f(()=>Kb(g.current.openEvent?.type,y.interactedInside)),O=f(()=>T.current?.()!==!1),k=f((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!Q(t,n);if(!pe(r))return!1;let a=r;return i.hasMatchingElement(e=>Q(e,a))&&(!t||!Q(t,a))}),A=f(()=>{y.handler&&=(Ra(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,y.handler),void 0)}),j=f(()=>{Bb(y)});return u&&(y.handleCloseOptions=i?.__options),Y.useEffect(()=>A,[A]),Y.useEffect(()=>{if(!n)return;function e(e){e.open?b.current=!1:(b.current=e.reason===Kv,A(),y.openChangeTimeout.clear(),y.restTimeout.clear(),y.blockMouseMove=!0,y.restTimeoutPending=!1)}return _.on(`openchange`,e),()=>{_.off(`openchange`,e)}},[n,_,y,A]),Y.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=Wb(S.current,`close`,y.pointerType);r?y.openChangeTimeout.start(r,()=>{e.setOpen(!1,$(Kv,t)),v?.events.emit(`floating.closed`,t)}):n&&(y.openChangeTimeout.clear(),e.setOpen(!1,$(Kv,t)),v?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!pe(r))return;function i(t){if(y.openChangeTimeout.clear(),y.blockMouseMove=!1,a&&!N_(y.pointerType))return;let n=Gb(C.current),r=Wb(S.current,`open`,y.pointerType),i=Jg(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(pe(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(Q(t,i)){c=t;break}}pe(o)&&pe(s)&&!e.context.triggerElements.hasElement(o)&&Q(o,s)&&(c=s);let l=c!=null&&k(s,c,i),u=e.select(`open`),d=E.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&b.current,p=!l&&pe(c)&&pe(s)&&Q(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;h?O()&&e.setOpen(!0,$(Kv,t,c)):m||(r?y.openChangeTimeout.start(r,()=>{g&&O()&&e.setOpen(!0,$(Kv,t,c))}):g&&O()&&e.setOpen(!0,$(Kv,t,c)))}function o(n){if(D()){j();return}A();let r=Ra(e.select(`domReferenceElement`));y.restTimeout.clear(),y.restTimeoutPending=!1;let i=g.current.floatingContext??d?.();if(!x_(n.relatedTarget,e.context.triggerElements)){if(x.current&&i){e.select(`open`)||y.openChangeTimeout.clear();let a=c.current;y.handler=x.current({...i,tree:v,x:n.clientX,y:n.clientY,onClose(){j(),A(),w.current&&!D()&&a===e.select(`domReferenceElement`)&&t(n,!0)}}),r.addEventListener(`mousemove`,y.handler),y.handler(n)}else y.pointerType===`touch`&&Q(e.select(`floatingElement`),n.relatedTarget)||t(n)}}function l(e){Q(r,e.relatedTarget)||(y.openChangeTimeout.clear(),y.restTimeout.clear(),y.restTimeoutPending=!1)}let f=h?bg(r,`mouseout`,l):void 0;return s?xg(bg(r,`mousemove`,i,{once:!0}),bg(r,`mouseenter`,i),bg(r,`mouseleave`,o),f):xg(bg(r,`mouseenter`,i),bg(r,`mouseleave`,o),f)},[A,j,g,S,e,n,x,y,u,k,D,a,s,C,c,v,w,d,E,O,h]),Y.useMemo(()=>{if(!n)return;function t(e){y.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=k(i,r,t.target);if(a&&!N_(y.pointerType))return;if(o&&s&&y.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=y.handleCloseOptions?.getScope?.()??r.ownerDocument.body;Vb(y,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=Gb(C.current);if(o&&!s||c===0||!s&&y.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;y.restTimeout.clear();function l(){if(y.restTimeoutPending=!1,D())return;let t=e.select(`open`);!y.blockMouseMove&&(!t||s)&&O()&&e.setOpen(!0,$(Kv,n,r))}y.pointerType===`touch`?Wm.flushSync(()=>{l()}):s&&o?l():(y.restTimeoutPending=!0,y.restTimeout.start(c,l))}}},[n,y,D,k,a,e,C,O])}function Zb(e){return Lg&&e.movementX===0&&e.movementY===0}function Qb(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function $b(e,t){return Qb(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function ex(e,t,n){return Qb(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function tx(e,t,n){return Qb(t,n?e===Zg:e===Qg,e===e_)}function nx(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:Qb(t,n?e===Qg:e===Zg,e===$g)}function rx(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:u=!1,rtl:d=!1,virtual:p=!1,focusItemOnOpen:m=`auto`,focusItemOnHover:h=!0,openOnArrowKeyDown:g=!0,disabledIndices:_=void 0,orientation:v=`vertical`,triggerOrientation:y=v,parentOrientation:b,id:x,resetOnPointerLeave:S=!0,externalTree:C,nestedReturnFocusRef:w,grid:T}=t,E=T!=null,O=e.useState(`open`),k=e.useState(`floatingElement`),A=e.useState(`domReferenceElement`),j=e.context.dataRef,M=O_(k),N=E_(A),P=tg(M),F=Vy(),I=Hy(C),L=Y.useRef(m),R=Y.useRef(o??-1),ee=Y.useRef(null),z=Y.useRef(!0),B=f(e=>{i(R.current===-1?null:R.current,e)}),V=Y.useRef(!!k),te=Y.useRef(O),ne=Y.useRef(!1),H=Y.useRef(!1),re=Y.useRef(null),ie=tg(_),ae=tg(O),U=tg(o),oe=tg(S),se=Wg(),ce=Wg(),le=f(()=>{se.cancel();function e(e){p||(re.current=dy(e,{sync:ne.current,preventScroll:!0}))}let t=n.current[R.current],r=H.current;t&&e(t),(ne.current?e=>e():e=>se.request(e))(()=>{let i=n.current[R.current]||t;i&&(t||e(i),he&&(r||!z.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});D(()=>{j.current.orientation=v},[j,v]),D(()=>{O||(ee.current=null),O&&m===`auto`||(L.current=m)},[O,m]),D(()=>{a&&(O&&k?(R.current=o??-1,L.current&&o!=null&&(H.current=!0,B())):V.current&&(R.current=-1,B()))},[a,O,k,o,B]),D(()=>{if(a){if(!O)ne.current=!1;else if(k){if(r==null){if(ne.current=!1,U.current!=null)return;if(V.current&&(R.current=-1,le()),(!te.current||!V.current)&&L.current&&(ee.current!=null||L.current===!0&&ee.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>ce.request(e):queueMicrotask)(t),e+=1):(R.current=ee.current==null||ex(ee.current,y,d)||u?uv(n):dv(n),ee.current=null,B())};t()}}else lv(n.current,r)||(R.current=r,le(),H.current=!1)}}},[a,O,k,r,U,u,n,y,d,B,le,ce]),D(()=>{if(!a||k||!I||p||!V.current)return;let e=I.nodesRef.current,t=e.find(e=>e.id===F)?.context?.elements.floating,n=Kg(Ra(A??t??null)),r=e.some(e=>e.context&&Q(e.context.elements.floating,n));t&&!r&&z.current&&t.focus({preventScroll:!0})},[a,k,A,I,F,p]),D(()=>{te.current=O,V.current=!!k});let ue=r!=null,de=f(e=>{if(!ae.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(R.current!==t||r!==t)&&(R.current=t,B(e))}),fe=f(()=>b??I?.nodesRef.current.find(e=>e.id===F)?.context?.dataRef?.current.orientation),pe=f(()=>uv(n,ie.current)),me=f(t=>{if(z.current=!1,ne.current=!0,t.which===229||!ae.current&&t.currentTarget===P.current)return;if(u&&nx(t.key,v,d,E)){$b(t.key,fe())||k_(t),e.setOpen(!1,$(ry,t.nativeEvent));let n=w?.current??A;l(n)&&n.focus();return}r!=null&&r!==R.current&&!lv(n.current,r)&&(R.current=r);let i=R.current,a=uv(n,_),o=dv(n,_);if(N||(t.key===`Home`&&(k_(t),R.current=a,B(t)),t.key===`End`&&(k_(t),R.current=o,B(t))),T!=null){let e=T(t,R.current,n,v,c,d,_,a,o);if(e!=null&&e!==R.current&&(R.current=e,B(t)),v===`both`)return}if($b(t.key,v)){k_(t);let e=Kg(t.currentTarget.ownerDocument);if(O&&!p&&Q(t.currentTarget,e)&&!n.current.some(t=>t!=null&&Q(t,e))){R.current=ex(t.key,v,d)?a:o,B(t),r===R.current&&le();return}let{index:l,wrapped:u}=fv(n.current,i,{decrement:!ex(t.key,v,d),loopFocus:c,allowEscape:s,disabledIndices:_,minIndex:a,maxIndex:o});u&&(ne.current=!1),R.current=l,B(t)}}),he=Y.useMemo(()=>({onFocus(e){ne.current=!0,de(e)},onClick({currentTarget:e}){p||e.focus({preventScroll:!0})},onMouseMove(e){Zb(e)||(ne.current=!0,H.current=!1,h&&de(e))},onPointerLeave(e){if(!ae.current||!z.current||e.pointerType===`touch`)return;ne.current=!0;let t=e.relatedTarget;if(h&&!n.current.includes(t)&&oe.current&&(re.current?.(),re.current=null,R.current=-1,B(e),!p)){let e=P.current,t=Kg(Ra(e));e&&Q(e,t)&&e.focus({preventScroll:!0})}}}),[de,ae,P,h,n,B,oe,p]),ge=Y.useMemo(()=>p&&O&&ue&&{"aria-activedescendant":`${x}-${r}`},[p,O,ue,x,r]),_e=Y.useMemo(()=>({...N?{}:ge,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&O&&!p){let n=Jg(t.nativeEvent);if(n&&!Q(P.current,n))return;k_(t);let r=$(ty,t.nativeEvent);e.setOpen(!1,r);let i=w?.current??A;!r.isCanceled&&l(i)&&i.focus()}else me(t)},onPointerMove(e){Zb(e)||(z.current=!0)}}),[ge,me,P,N,e,O,p,A,w]),ve=Y.useMemo(()=>{function t(t){e.setOpen(!0,$(ry,t.nativeEvent,t.currentTarget))}function n(e){m===`auto`&&j_(e.nativeEvent)&&(L.current=!p)}function r(e){L.current=m,m===`auto`&&M_(e.nativeEvent)&&(L.current=!0)}return{onKeyDown(n){let r=e.select(`open`);z.current=!1;let i=n.key.startsWith(`Arrow`),a=tx(n.key,fe(),d),o=$b(n.key,r?v:y),s=(u?a:o)||n.key===`Enter`||n.key.trim()===``;if(p&&r&&(!u||w_(n.currentTarget)))return me(n);if(r||g||!i){if(s){let e=$b(n.key,fe());ee.current=u&&e?null:n.key}u?a&&(k_(n),r?(R.current=pe(),B(n),p&&P.current?.focus()):t(n)):o&&(U.current!=null&&(R.current=U.current),k_(n),!r&&g?t(n):me(n),r&&B(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!p&&(R.current=-1,B(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[me,m,pe,u,B,e,g,v,y,fe,d,U,p,P]),ye=Y.useMemo(()=>({...ge,...ve}),[ge,ve]);return Y.useMemo(()=>a?{reference:ye,floating:_e,item:he,trigger:ve}:{},[a,ye,_e,ve,he])}function ix(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=f(s),p=e.useState(`open`),m=Tg(),h=Y.useRef(``),g=Y.useRef(u??i??-1),_=Y.useRef(null),v=f(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!_v(n)||n?.matches(`:disabled`)?!1:o==null||!hv(B,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 f=n.current;if(h.current.length>0&&e.key===` `&&(k_(e),d?.(!0)),h.current.length>0&&h.current[0]!==` `&&c(f,h.current)===-1&&e.key!==` `&&d?.(!1),f==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;p&&e.key!==` `&&(k_(e),d?.(!0));let v=h.current===``;v&&(g.current=u??i??-1),f.every((e,t)=>e&&s(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&h.current===e.key&&(h.current=``,g.current=_.current),h.current+=e.key,m.start(l,()=>{h.current=``,g.current=_.current,d?.(!1)});let y=((v?u??i??-1:g.current)??0)+1,b=c(f,h.current,y);b===-1?e.key!==` `&&(h.current=``,d?.(!1)):(a?.(b,e),_.current=b)}),y=f(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);Q(r,n)||Q(i,n)||(m.clear(),h.current=``,g.current=_.current,d?.(!1))});D(()=>{(p||u===null)&&(m.clear(),_.current=null,h.current!==``&&(h.current=``,d?.(!1)))},[p,u,m,d]);let b=Y.useMemo(()=>({onKeyDown:v,onBlur:y}),[v,y]);return Y.useMemo(()=>c?{reference:b,floating:b}:{},[c,b])}var ax=.1,ox=ax*ax,sx=.5;function cx(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function lx(e,t,n,r,i,a,o,s,c,l){let u=!1;return cx(e,t,n,r,i,a)&&(u=!u),cx(e,t,i,a,o,s)&&(u=!u),cx(e,t,o,s,c,l)&&(u=!u),cx(e,t,c,l,n,r)&&(u=!u),u}function ux(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function dx(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 fx(e={}){let{blockPointerEvents:t=!1}=e,n=new wg,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*ox;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=Jg(r),g=r.type===`mouseleave`,_=Q(u,h),v=Q(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&pe(r.relatedTarget)&&Q(u,r.relatedTarget))return;function y(){return!!(s&&Vv(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=dx(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=dx(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=dx(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=dx(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!ux(d,f,x)||!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?sx/2:sx*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+sx+1,o=C||T?S.bottom-sx:S.top,s=C?T?S.bottom-sx:S.top:S.bottom-sx;M=lx(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?sx/2:sx*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-sx,o=C||T?S.top+sx:S.bottom,s=C?T?S.top+sx:S.bottom:S.top+sx;M=lx(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?sx/2:sx*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+sx+1,o=w||E?S.right-sx:S.left,s=w?E?S.right-sx:S.left:S.right-sx;M=lx(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?sx/2:sx*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-sx,o=w||E?S.left+sx:S.right,s=w?E?S.left+sx:S.right:S.left+sx;M=lx(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 px(e,t,n){let{reference:r,floating:i}=e,a=q_(t),o=J_(t),s=K_(o),c=U_(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=W_(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function mx(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}=H_(t,e),p=ov(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=sv(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=sv(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 hx=50,gx=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:mx},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=px(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<hx&&(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}=px(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},_x=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}=H_(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=U_(r),_=q_(o),v=U_(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[iv(o)]:X_(o)),x=p!==`none`;!d&&x&&b.push(...rv(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=Y_(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`||_===q_(t)||T.every(e=>q_(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=q_(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{}}}},vx=new Set([`left`,`top`]);async function yx(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=U_(n),s=W_(n),c=q_(n)===`y`,l=vx.has(o)?-1:1,u=a&&c?-1:1,d=H_(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 bx=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 yx(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}}}}},xx=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}=H_(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=q_(i),p=G_(f),m=u[p],h=u[f],g=(e,t)=>V_(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}}}}}},Sx=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}=H_(e,t),u={x:n,y:r},d=q_(i),f=G_(d),p=u[f],m=u[d],h=H_(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=vx.has(U_(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}}}},Cx=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}=H_(e,t),c=await i.detectOverflow(t,s),l=U_(n),u=W_(n),d=q_(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=F_(p-c[m],g),y=F_(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*I_(c.left,c.right):S=p-2*I_(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 wx(e){let t=ne(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=l(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=L_(n)!==a||L_(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Tx(e){return pe(e)?e:e.contextElement}function Ex(e){let t=Tx(e);if(!l(t))return z_(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=wx(t),o=(a?L_(n.width):n.width)/r,s=(a?L_(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var Dx=z_(0);function Ox(e){let t=y(e);return!ae()||!t.visualViewport?Dx:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function kx(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===y(e)}function Ax(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Tx(e),o=z_(1);t&&(r?pe(r)&&(o=Ex(r)):o=Ex(e));let s=kx(a,n,r)?Ox(a):z_(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=y(a),t=pe(r)?y(r):r,n=e,i=b(n);for(;i&&t!==n;){let e=Ex(i),t=i.getBoundingClientRect(),r=ne(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=y(i),i=b(n)}}return sv({width:u,height:d,x:c,y:l})}function jx(e,t){let n=C(e).scrollLeft;return t?t.left+n:Ax(te(e)).left+n}function Mx(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-jx(e,n),y:n.top+t.scrollTop}}function Nx(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=te(r),s=t?v(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},u=z_(1),d=z_(0),f=l(r);if((f||!a)&&((x(r)!==`body`||O(o))&&(c=C(r)),f)){let e=Ax(r);u=Ex(r),d.x=e.x+r.clientLeft,d.y=e.y+r.clientTop}let p=o&&!f&&!a?Mx(o,c):z_(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-c.scrollTop*u.y+d.y+p.y}}function Px(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Fx(e){let t=C(e),n=e.ownerDocument.body,r=I_(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=I_(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+jx(e),o=-t.scrollTop;return ne(n).direction===`rtl`&&(a+=I_(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var Ix=25;function Lx(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=y(e),a=te(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!ae()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(jx(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<=Ix&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Rx(e,t){let n=Ax(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Ex(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function zx(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Lx(e,n,t);else if(t===`document`)r=Fx(te(e));else if(pe(t))r=Rx(t,n);else{let n=Ox(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return sv(r)}function Bx(e,t){let n=t.get(e);if(n)return n;let r=p(e,[],!1).filter(e=>pe(e)&&x(e)!==`body`),i=null,a=ne(e).position===`fixed`,o=a?g(e):e;for(;pe(o)&&!k(o);){let e=ne(o),t=T(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=g(o)}return t.set(e,r),r}function Vx(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?v(t)?[]:Bx(t,this._c):[].concat(n),r],o=zx(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=zx(t,a[e],i);s=I_(n.top,s),c=F_(n.right,c),l=F_(n.bottom,l),u=I_(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Hx(e){let{width:t,height:n}=wx(e);return{width:t,height:n}}function Ux(e,t,n){let r=l(t),i=te(t),a=n===`fixed`,o=Ax(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=z_(0);if((r||!a)&&((x(t)!==`body`||O(i))&&(s=C(t)),r)){let e=Ax(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=jx(i));let u=i&&!r&&!a?Mx(i,s):z_(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Wx(e){return ne(e).position===`static`}function Gx(e,t){if(!l(e)||ne(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return te(e)===n&&(n=n.ownerDocument.body),n}function Kx(e,t){let n=y(e);if(v(e))return n;if(!l(e)){let t=g(e);for(;t&&!k(t);){if(pe(t)&&!Wx(t))return t;t=g(t)}return n}let r=Gx(e,t);for(;r&&m(r)&&Wx(r);)r=Gx(r,t);return r&&k(r)&&Wx(r)&&!T(r)?n:r||c(e)||n}var qx=async function(e){let t=this.getOffsetParent||Kx,n=this.getDimensions,r=await n(e.floating);return{reference:Ux(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Jx(e){return ne(e).direction===`rtl`}var Yx={convertOffsetParentRelativeRectToViewportRelativeRect:Nx,getDocumentElement:te,getClippingRect:Vx,getOffsetParent:Kx,getElementRects:qx,getClientRects:Px,getDimensions:Hx,getScale:Ex,isElement:pe,isRTL:Jx};function Xx(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Zx(e,t,n){let r=null,i,a=te(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=R_(d),h=R_(a.clientWidth-(u+f)),g=R_(a.clientHeight-(d+p)),_=R_(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:I_(0,F_(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Xx(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=y(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Qx(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=Tx(e),u=i||a?[...l?p(l):[],...t?p(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Zx(l,n,a):null,f=-1,m=null;o&&(m=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&m&&t&&(m.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=m)==null||e.observe(t)})),n()}),l&&!c&&m.observe(l),t&&m.observe(t));let h,g=c?Ax(e):null;c&&_();function _(){let t=Ax(e);g&&!Xx(g,t)&&n(),g=t,h=requestAnimationFrame(_)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=m)==null||e.disconnect(),m=null,c&&cancelAnimationFrame(h)}}var $x=bx,eS=xx,tS=_x,nS=Cx,rS=Sx,iS=(e,t,n)=>{let r=new Map,i=n??{},a={...Yx,...i.platform,_c:r};return gx(e,t,{...i,platform:a})},aS=typeof document<`u`?Y.useLayoutEffect:function(){};function oS(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(!oS(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)&&!oS(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function sS(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function cS(e,t){let n=sS(e);return Math.round(t*n)/n}function lS(e){let t=Y.useRef(e);return aS(()=>{t.current=e}),t}function uS(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]=Y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=Y.useState(r);oS(f,r)||p(r);let[m,h]=Y.useState(null),[g,_]=Y.useState(null),v=Y.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=Y.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=Y.useRef(null),C=Y.useRef(null),w=Y.useRef(u),T=c!=null,E=lS(c),D=lS(i),O=lS(l),k=Y.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),iS(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!oS(w.current,t)&&(w.current=t,Wm.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);aS(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=Y.useRef(!1);aS(()=>(A.current=!0,()=>{A.current=!1}),[]),aS(()=>{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=Y.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=Y.useMemo(()=>({reference:b,floating:x}),[b,x]),N=Y.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=cS(M.floating,u.x),r=cS(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...sS(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return Y.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var dS=(e,t)=>{let n=$x(e);return{name:n.name,fn:n.fn,options:[e,t]}},fS=(e,t)=>{let n=eS(e);return{name:n.name,fn:n.fn,options:[e,t]}},pS=(e,t)=>({fn:rS(e).fn,options:[e,t]}),mS=(e,t)=>{let n=tS(e);return{name:n.name,fn:n.fn,options:[e,t]}},hS=(e,t)=>{let n=nS(e);return{name:n.name,fn:n.fn,options:[e,t]}};function gS(e,t,n,r,i,a,o,s,c,l=2){let u=mv(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 lv(n.current,u)?void 0:u}function _S(e){return e==null?Wv:e.type.startsWith(`key`)?iy:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?ay:Wv}var vS=Y.createContext(void 0),yS=Y.createContext(void 0),bS=Y.createContext(void 0),xS=Y.createContext(!1),SS=Y.createContext(``);function CS(){let e=Y.useContext(vS);if(!e)throw Error(u(22));return e}function wS(){let e=Y.useContext(yS);if(!e)throw Error(u(23));return e}function TS(){let e=Y.useContext(bS);if(!e)throw Error(u(24));return e}function ES(){return Y.useContext(SS)}function DS(){return Y.useContext(xS)}function OS(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 kS=(e,t)=>Object.is(e,t);function AS(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function jS(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!OS(e,t,(e,t)=>AS(e,t,n)):e!==t}function MS(e,t,n){return e?e.some(e=>e!==void 0&&AS(t,e,n)):!1}function NS(e,t,n){return e?e.findIndex(e=>e!==void 0&&AS(e,t,n)):-1}function PS(e,t){if(t!==kS)return n=>MS(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 FS(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(PS(t,n)):NS(e,t,n);return i===-1?null:i}function IS(e,t,n,r,i,a){return MS(r,t,i)?a!=null&&e>a&&MS(r,n[a],i)?a:e:e===a?FS(n,r,i,!0):a}function LS(e,t,n){return e.filter(e=>!AS(t,e,n))}function RS(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function zS(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function BS(e){return zS(e?.[0])}function VS(e){return BS(e)?e.flatMap(e=>e.items):e}function HS(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(BS(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 US(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 RS(e)}function WS(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?RS(e.value):RS(e)}var GS={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?HS(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=>AS(t,e,n)):AS(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},KS=`data-valid`,qS=`data-invalid`,JS={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},YS={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},XS={disabled:!1,...YS},ZS={valid(e){return e===null?null:e?{[KS]:``}:{[qS]:``}}},QS={invalid:void 0,name:void 0,validityData:{state:JS,errors:[],error:``,value:``,initialValue:null},setValidityData:P,disabled:void 0,setTouched:P,setDirty:P,setFilled:P,setFocused:P,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:XS,registerFieldControl:P,validation:{getValidationProps:(e,t=z)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:P,getInputControl:()=>null,commit:async()=>{},change:P}},$S=Y.createContext(QS);function eC(e=!0){let t=Y.useContext($S);if(t.setValidityData===P&&!e)throw Error(u(28));return t}function tC(e,t,n,r,i=!0,a){let{registerFieldControl:o}=eC(),s=d(()=>Symbol());D(()=>{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]),D(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var nC=Y.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:P,validationMode:`onSubmit`,submitCountRef:{current:0}});function rC(){return Y.useContext(nC)}function iC(e){return Dy(e,`base-ui`)}var aC=Y.createContext({controlId:void 0,registerControlId:P,resetControlId:P,labelId:void 0,setLabelId:P,messageIds:[],setMessageIds:P,getDescriptionProps:e=>e});function oC(){return Y.useContext(aC)}function sC(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=oC(),o=iC(),s=d(()=>Symbol()),c=Y.useRef(!1),l=Y.useRef(!1),u=f(()=>{c.current&&i!==P&&(c.current=!1,i(s.current,void 0))});return D(()=>{if(!n||i===P){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]),D(()=>u,[u]),(n?r:void 0)??t??o}function cC(e){return e==null?void 0:`${e}-popup`}function lC(e,t){return(n,r)=>n!=null&&e.contains(n,r,t)}function uC(e){return Array.isArray(e)?e.map(e=>uC(e)).join(`,`):e==null?``:String(e)}var dC=new Map;function fC(e={}){let{locale:t,...n}=e,r={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...n},i=`${uC(t)}|${JSON.stringify(r)}`,a=dC.get(i);if(a)return a;let o=new Intl.Collator(t,r),s={contains(e,t,n){if(!t)return!0;let r=US(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=US(e,n);return o.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=US(e,n),i=t.length;return r.length>=i&&o.compare(r.slice(r.length-i),t)===0}};return dC.set(i,s),s}var pC=fC;function mC(e){let t=Y.useRef(``),n=Y.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:Y.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 hC(e,t){let n=Y.useRef(e),r=f(t);D(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function gC(e,t){let{onClick:n,onPointerDown:r}=mC(f((n,r)=>{(typeof e==`function`?e():e)||t(r||(Mg?`touch`:``))}));return Y.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function _C(e){let[t,n]=Y.useState(null),r=gC(e,n);return hC(e,t=>{t&&!e&&n(null)}),Y.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function vC(e,t=!1){let{overflowY:n}=ne(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}var yC=Symbol(`none`),bC={value:yC,index:-1},xC=Y.createContext(void 0);function SC(){return Y.useContext(xC)?.direction??`ltr`}function CC(e,t,n){let r=e.get(t);if(r!==void 0||n===kS)return r;for(let[r,i]of e)if(AS(r,t,n))return i}function wC(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:a,defaultInputValue:o,inputValue:s,open:c,defaultOpen:m=!1,selectionMode:h,onItemHighlighted:g,name:_,form:v,disabled:y=!1,readOnly:b=!1,required:x=!1,inputRef:S,grid:C=!1,items:w,filteredItems:T,filter:E,filterQuery:O,openOnInputClick:k=!0,autoHighlight:A=!1,keepHighlight:j=!1,highlightItemOnHover:M=!0,loopFocus:N=!0,itemToStringLabel:F,itemToStringValue:I,isItemEqualToValue:L=kS,virtualized:R=!1,inline:ee=!1,fillInputOnItemPress:V=!0,modal:te=!1,limit:ne=-1,autoComplete:H=`list`,formAutoComplete:re,locale:ie,submitOnItemClick:ae=!1}=e,{clearErrors:U}=rC(),{setDirty:oe,validityData:se,setFilled:ce,name:le,disabled:de,setTouched:pe,setFocused:me,validationMode:he,validation:ge}=eC(),_e=SC(),ve=sC({id:t}),ye=pC({locale:ie}),be=Array.isArray(w)?null:w;if(be&&typeof be.label!=`function`)throw Error(u(100));let xe=be?be.data:w,Se=be?.value,Ce=Se?void 0:xe,we=Y.useMemo(()=>{if(!T||!Se)return;let e=VS(T),t=e.map(Se),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 CC(n,r,i)}}},[T,Se]),Te=Y.useMemo(()=>be?e=>be.label(e,L,e=>{let t=we?.findItem(e,L);return t==null?US(e,F):be.itemLabel(t)}):F,[be,F,we,L]),Ee=Y.useMemo(()=>be?Object.assign(e=>be.itemLabel(e),{selected:e=>US(e,Te)}):F,[be,Te,F]);function De(e){return US(e,Te)}let[Oe,ke]=Y.useState(!1),[Ae,je]=Y.useState(null),Me=Y.useRef(Ae),Ne=Y.useRef([]),W=Y.useRef([]),Pe=Y.useRef(null),Fe=Y.useRef(null),Ie=Y.useRef(null),Le=Y.useRef(null),Re=Y.useRef(null),ze=Y.useRef(!1),Be=Y.useRef(null),Ve=Y.useRef(null),G=Y.useRef(null),He=Y.useRef(bC),Ue=Y.useRef(null),We=Y.useRef([]),Ge=Y.useRef(null),Ke=de||y,qe=le??_,Je=h===`multiple`,Ye=h===`single`,Xe=s!==void 0||o!==void 0,Ze=xe!==void 0,Qe=T!==void 0,$e;$e=A===`always`?`always`:A?`input-change`:!1;let[et,tt]=$h({controlled:i,default:Je?r??B:r,name:`Combobox`,state:`selectedValue`}),nt=Y.useMemo(()=>E===null?()=>!0:E===void 0?lC(ye,Ee):E,[E,ye,Ee]),rt=d(()=>Xe?o??``:Ye?De(et):``).current,[it,at]=$h({controlled:s,default:rt,name:`Combobox`,state:`inputValue`}),[ot,st]=$h({controlled:c,default:m,name:`Combobox`,state:`open`}),ct=BS(xe),lt=!ot&&Ae!==null?Ae:String(it).trim(),ut=Ye?De(et):``,dt=Ye&&!Oe&<!==``&&ut.length===lt.length&&ye.contains(ut,lt),ft=dt?``:O??lt,pt=Ze&&Qe&&dt&&(!be||be.hasValue(et,L)),mt=Y.useMemo(()=>xe?VS(xe):B,[xe]),ht=Y.useMemo(()=>{if(T&&!pt)return T;if(!xe)return B;if(ct){let e=xe,t=[],n=0;for(let r of e){if(ne>-1&&n>=ne)break;let e=ne>-1?ne-n:1/0,i=ft===``?r.items.slice(0,e):[];if(ft!==``)for(let t of r.items){if(i.length>=e)break;nt(t,ft,Ee)&&i.push(t)}if(i.length>0){let e={...r,items:i};t.push(e),n+=i.length}}return t}if(ft===``)return ne>-1?mt.slice(0,ne):mt;let e=[];for(let t of mt){if(ne>-1&&e.length>=ne)break;nt(t,ft,Ee)&&e.push(t)}return e},[T,pt,xe,ct,ft,ne,nt,Ee,mt]),gt=Y.useMemo(()=>{if(we&&ht===T)return we.values;let e=VS(ht);return Se?e.map(e=>Se(e)):e},[ht,T,we,Se]),K=d(()=>{let e=null;return ee&&ot&&Ze&&h!==`none`&&(e=FS(gt,et,L,Je)),new yg({id:ve,labelId:void 0,selectedValue:et,open:ot,items:Ce,selectionMode:h,name:qe,form:v,disabled:Ke,readOnly:b,required:x,grid:C,virtualized:R,openOnInputClick:k,itemToStringLabel:Te,isItemEqualToValue:L,modal:te,autoHighlight:$e,submitOnItemClick:ae,hasInputValue:Xe,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:ee,activeIndex:null,selectedIndex:e,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemRoot:{props:z,id:ve,selectionMode:h,disabled:Ke,readOnly:b,isItemEqualToValue:L},positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:h===`none`},{onOpenChangeComplete:P,setOpen:P,setInputValue:P,setSelectedValue:P,setIndices:P,handleSelection:P,forceMount:P,requestSubmit:P,listRef:Ne,labelsRef:W,popupRef:Pe,emptyRef:Re,inputRef:Fe,startDismissRef:Ie,endDismissRef:Le,chipsContainerRef:Be,clearRef:Ve,valuesRef:We,pointerDownItemRef:Ge,selectionEventRef:G},GS)}).current,_t=h===`none`?it:et,vt=Y.useMemo(()=>h===`none`?_t:Array.isArray(et)?et.map(e=>WS(e,I)):WS(et,I),[_t,I,h,et]),yt=f(g),bt=f(n),xt=K.useState(`activeIndex`),St=K.useState(`selectedIndex`),Ct=K.useState(`positionerElement`),wt=K.useState(`listElement`),Tt=K.useState(`triggerElement`),Et=K.useState(`inputElement`),Dt=K.useState(`inputGroupElement`),Ot=K.useState(`inline`),kt=K.useState(`inputInsidePopup`),At=K.useState(`inputOwnsFormValue`),jt=Ye&&!kt&&it===ut,Mt=tg(Tt),{openMethod:Nt,triggerProps:Pt}=_C(ot),Ft=f(()=>vt);tC(kt?Mt:Fe,ve,_t,Ft,!Ke,_);let It=f(()=>{xe?W.current=gt.map(De):K.set(`forceMounted`,!0)}),q=f((e,t,n,r)=>{if(t===-1){if(He.current===bC)return;He.current=bC}else He.current={value:e,index:t};yt(e,Uv(n,r,{index:t}))}),Lt=f(e=>{let t={};e.activeIndex!==void 0&&(t.activeIndex=e.activeIndex),e.selectedIndex!==void 0&&(t.selectedIndex=e.selectedIndex),K.update(t);let n=e.activeIndex;if(n===void 0)return;let r=e.type||`none`;n===null?q(void 0,-1,r,e.event):q(We.current[n],n,r,e.event)}),Rt=f((t,n)=>{if(e.onInputValueChange?.(t,n),!n.isCanceled){if(ze.current=n.reason===$v,n.reason===`input-change`){ot&&Ae!==null&&je(null);let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&ke(!0),Ue.current={hasQuery:e};let n=K.state.listElement;if(!K.state.virtualized&&n){let e=Pe.current;for(let t of p(n.firstElementChild??n)){if(!l(t)||(e?!Q(e,t):t.getAttribute(`role`)===`dialog`))break;if(vC(t)){t.scrollTop=0;break}}}e&&$e&&K.state.activeIndex==null&&(ot||Ot)&&K.set(`activeIndex`,0)}}else n.reason===`input-clear`&&t===``&&K.state.inputInsidePopup&&(Ue.current={hasQuery:!1,selection:!0});at(t)}}),zt=f(e=>{let t=!e&&kt&&!Ot&&it!==``&&(String(it).trim()===Ae||it===ut);!e&&(t||it===``||jt)&&ke(!1),je(null),t&&Rt(``,$($v))}),[Bt,Vt]=Y.useState(!1),Ht=f((t,n)=>{if(ot===t)return;n.reason===`escape-key`&&Ze&>.length===0&&!Re.current&&n.allowPropagation();let r=n,i=yb(r);if(e.onOpenChange?.(t,r),Ue.current?.hasQuery&&n.reason===`input-change`===n.isCanceled&&(Ue.current=null),!n.isCanceled&&(t&&Ae!==null&&zt(n.reason===Qv),!t&&Oe&&(Ye?(Ot||je(lt),lt===``&&ke(!1)):Je&&(Ot||je(lt),kt&&Lt({activeIndex:null}),(!kt||Ot)&&Rt(``,$($v,n.event,void 0,{isItemPress:n.reason===Yv})))),t||Vt(i()),st(t),!t&&kt&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(pe(!0),me(!1),he===`onBlur`))){let e=h===`none`?it:et;ge.commit(e)}}),Ut=f((e,t)=>{a?.(e,t),!t.isCanceled&&(tt(e),(h===`none`&&Pe.current&&V||Ye&&!K.state.inputInsidePopup)&&Rt(De(e),$(t.reason,t.event)))}),Wt=f((e,t)=>{let n=Jg(e),r=G.current??e;G.current=null;let i=$(Yv,r),a=qg(n,`a`)?.getAttribute(`href`);if(a)a.startsWith(`#`)&&Ht(!1,i);else if(Je){let e=Array.isArray(et)?et:[],n=MS(e,t,L),r=n?LS(e,t,L):[...e,t];if(Ut(r,i),i.isCanceled||!(Fe.current&&Fe.current.value.trim()!==``))return;if(K.state.inputInsidePopup){Rt(``,$($v,i.event,void 0,{isItemPress:!0}));let e=Ue.current;e&&!n&&(e.toggledValue=t)}else Ht(!1,i)}else{if(Ut(t,i),i.isCanceled)return;Ht(!1,i)}}),Gt=f(()=>{let e=ge.inputRef.current?.form??K.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),Kt=f(()=>{if(bt?.(!1),ke(!1),je(null),Lt(h===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),Je&&Fe.current&&Fe.current.value!==``&&!ze.current&&Rt(``,$($v)),Ye){if(K.state.inputInsidePopup)Fe.current&&Fe.current.value!==``&&Rt(``,$($v));else{let e=De(et);Fe.current&&Fe.current.value!==e&&Rt(e,$(e===``?$v:Wv))}}}),qt=Y.useMemo(()=>Ot&&Ct?{current:qg(Ct,`[role="dialog"]`)}:Pe,[Ot,Ct]),{mounted:J,transitionStatus:Jt,forceUnmount:Yt}=pb({open:ot,ref:qt,preventUnmountOnClose:Bt,setPreventUnmountOnClose:Vt,onUnmount:Kt});Y.useImperativeHandle(e.actionsRef,()=>({unmount:Yt,close:()=>Ht(!1,$(cy))}),[Yt,Ht]),D(function(){let e=Me.current!==null&&Ae===null;if(Me.current=Ae,ot&&(!e||!Ze)||(ot||(Ge.current=null),h===`none`))return;let t=Ze?gt:We.current;Lt({selectedIndex:FS(t,et,L,Je)})},[ot,Ae,et,h,Je,Ze,gt,L,Lt]),D(()=>{xe&&(We.current=gt,Ne.current.length=gt.length)},[xe,gt]),D(()=>{!ot&&Ue.current?.hasQuery&&(Ue.current=null)},[ot]),D(()=>{if(!ot&&Ot&&qt.current){Ue.current=null;return}let e=Ze||Qe?gt:We.current,t=Ue.current;if(t){let n=ot||Ot||K.state.positionerElement?.hidden===!1;if(t.hasQuery){let t=Fe.current;!$e||String(it).trim()===``||Ot&&$e!==`always`&&(!t||Kg(t.ownerDocument)!==t)?Ue.current=null:n&&(e[0]!==void 0||!Ze&&!Qe)&&(K.set(`activeIndex`,0),Ue.current=null)}else if(String(it).trim()===``&&(Ue.current=null,n)){let e=t.selection;$e===`always`&&!e&&K.state.selectionMode===`none`&&K.set(`activeIndex`,0),queueMicrotask(()=>{if(!K.state.open&&(!K.state.inline||qt.current)||Fe.current&&Fe.current.value.trim()!==``)return;let n=K.state.selectedValue,r=K.state.selectionMode===`multiple`;if(r&&Array.isArray(n)?n.length>0:K.state.selectionMode!==`none`&&n!=null){let e=Ze||Qe?gt:We.current,i=NS(e,t.toggledValue,K.state.isItemEqualToValue);K.set(`activeIndex`,i===-1?FS(e,n,K.state.isItemEqualToValue,r):i)}else e?K.set(`activeIndex`,null):$e===`always`&&K.set(`activeIndex`,0)})}}if(!ot&&!Ot)return;let n=K.state.activeIndex;if(n==null){if($e===`always`&&e.length>0){K.set(`activeIndex`,0);return}q(void 0,-1,Wv);return}if(n>=e.length){q(void 0,-1,Wv),K.set(`activeIndex`,null);return}let r=e[n],i=He.current.value,a=i!==yC&&AS(r,i,K.state.isItemEqualToValue);He.current.index===n&&a||q(r,n,Wv)},[xt,$e,q,Qe,Ze,gt,Ot,ot,qt,K,it]),D(()=>{ce(h===`none`?String(it)!==``:Je?Array.isArray(et)&&et.length>0:et!=null)},[ce,h,it,et,Je]),Y.useEffect(()=>{Ze&&$e&>.length===0&&Lt({activeIndex:null})},[Ze,$e,gt.length,Lt]);function Xt(){ot&<!==``&<!==String(rt)&&!jt&&ke(!0)}function Zt(){ot&&Ae!==null&&zt(!1)}let Qt=!1;function $t(){!Qt&&it!==ut&&(Qt=!0,Rt(ut,$(Wv)))}function en(){h!==`none`&&(U(qe),oe(jS(et,se.initialValue,L)),ge.change(et),Ye&&!Xe&&!kt&&$t())}function tn(){Ye&&!Xe&&!kt&&!Oe&&$t()}function nn(){h===`none`&&(U(qe),oe(it!==se.initialValue),ge.change(it))}hC(lt,Xt),hC(ot,Zt),hC(et,en),hC(ut,tn),hC(xe,tn),hC(it,nn);let rn=Fb({open:Ot?!0:ot,onOpenChange:Ht,elements:{reference:kt?Tt:Et,floating:Ct}}),an=C?`grid`:`listbox`,on=ot||Ot,sn=on?`true`:`false`,cn=Y.useMemo(()=>{let e=Et?.tagName===`INPUT`,t=Et==null||e,n=t||on,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=sn,r[`aria-haspopup`]=an,r[`aria-controls`]=on?wt?.id:void 0,r[`aria-autocomplete`]=b?`none`:H),{reference:r,floating:{role:`presentation`}}},[Et,on,sn,an,wt?.id,H,b]),ln=nb(rn,{enabled:!Ke&&k,event:`mousedown-only`,toggle:!1,touchOpenDelay:kt?0:100,reason:ey}),un=ab(rn,{enabled:!Ke&&!Ot,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:Ot?!0:void 0,outsidePress(e){let t=Jg(e);return!Q(Tt,t)&&!Q(Ve.current,t)&&!Q(Be.current,t)&&!Q(Dt,t)}}),dn=rx(rn,{enabled:!Ke,id:ve,listRef:Ne,activeIndex:xt,selectedIndex:St,virtual:!0,loopFocus:N,allowEscape:N&&!$e,focusItemOnOpen:Oe||h===`none`&&!$e?!1:`auto`,focusItemOnHover:M,resetOnPointerLeave:!j,orientation:C?`horizontal`:void 0,rtl:_e===`rtl`,disabledIndices:B,grid:C?gS:void 0,onNavigate(e,t){(t||ot||Ot&&e===null)&&Jt!==`ending`&&Lt({activeIndex:e,type:_S(t),event:t?.nativeEvent})}}),fn=Y.useMemo(()=>ue(dn.reference,{onKeyDown(e){C&&K.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},un.reference,ln.reference,cn.reference),[dn.reference,un.reference,ln.reference,cn.reference,C,K]),pn=Y.useMemo(()=>ue(mb,un.floating),[un.floating]),mn=Y.useMemo(()=>ue(dn.floating,cn.floating),[dn.floating,cn.floating]),hn=Y.useMemo(()=>{let e=dn.item;return{props:e?{...e,onFocus:void 0}:z,id:ve,selectionMode:h,disabled:Ke,readOnly:b,isItemEqualToValue:L}},[dn.item,ve,h,Ke,b,L]);K.useContextCallback(`setOpen`,Ht),K.useContextCallback(`setInputValue`,Rt),K.useContextCallback(`setSelectedValue`,Ut),K.useContextCallback(`setIndices`,Lt),K.useContextCallback(`handleSelection`,Wt),K.useContextCallback(`forceMount`,It),K.useContextCallback(`requestSubmit`,Gt),K.useContextCallback(`onOpenChangeComplete`,n),eg(()=>{K.update({inline:ee,popupProps:pn,listProps:mn,inputProps:fn,triggerProps:Pt,itemRoot:hn})});let gn={id:ve,selectedValue:et,open:ot,mounted:J,transitionStatus:Jt,items:Ce,inline:ee,popupProps:pn,listProps:mn,inputProps:fn,triggerProps:Pt,itemRoot:hn,openMethod:Nt,selectionMode:h,name:qe,form:v,disabled:Ke,readOnly:b,required:x,grid:C,virtualized:R,openOnInputClick:k,itemToStringLabel:Te,modal:te,autoHighlight:$e,isItemEqualToValue:L,submitOnItemClick:ae,hasInputValue:Xe};D(()=>{K.update({...gn,inputOwnsFormValue:h===`none`&&(ee||!K.state.inputInsidePopup)})},[K,...Object.values(gn)]);let _n=fe(S,ge.inputRef),vn=Y.useMemo(()=>({query:lt,hasItems:Ze,filteredItems:ht,flatFilteredValues:gt}),[lt,Ze,ht,gt]),yn=Y.useMemo(()=>Array.isArray(_t)?``:WS(_t,I),[_t,I]),bn=Je&&Array.isArray(et)&&et.length>0,xn=Je||h===`none`&&At?void 0:qe,Sn=Y.useMemo(()=>!Je||!Array.isArray(et)||!qe?null:et.map(e=>{let t=WS(e,I);return(0,X.jsx)(`input`,{type:`hidden`,form:v,name:qe,value:t,disabled:Ke},t)}),[Je,et,v,qe,I,Ke]),Cn=(0,X.jsxs)(Y.Fragment,{children:[e.children,(0,X.jsx)(`input`,{...ge.getValidationProps(Ke,{onFocus(){kt?Tt?.focus():(Fe.current||Tt)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||Ke||b)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=$(Wv,e.nativeEvent),i=()=>We.current.findIndex(e=>WS(e,I).toLowerCase()===n||De(e).toLowerCase()===n);function a(){if(Je)return;if(h===`none`){Rt(t,r);return}let e=i();e===-1&&(e=We.current.findIndex((e,t)=>{let r=W.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:We.current[e];a!=null&&Ut?.(a,r)}Ye&&(It(),xe&&i()===-1&&K.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:ve&&xn==null?`${ve}-hidden-input`:void 0,form:v,name:xn,autoComplete:re,disabled:Ke,required:x&&!bn,readOnly:b,value:yn,ref:_n,style:xn?ag:ig,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Sn]});return(0,X.jsx)(vS.Provider,{value:K,children:(0,X.jsx)(yS.Provider,{value:rn,children:(0,X.jsx)(xS.Provider,{value:Ze,children:(0,X.jsx)(bS.Provider,{value:vn,children:(0,X.jsx)(SS.Provider,{value:it,children:Cn})})})})})}function TC(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]=Y.useState(r??``),[p,m]=Y.useState(``);Y.useEffect(()=>{(u||!c)&&m(``)},[n,u,c]);let h;h=c&&p!==``?p:u?n??``:d;let g=pC({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?US(t,o):``)}return(0,X.jsx)(wC,{...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 EC=`data-popup-side`,DC=`data-list-empty`,OC={...__,...ZS,popupSide:e=>e?{[EC]:e}:null,listEmpty:e=>e?{[DC]:``}:null};function kC(e,t,n){let{setFocused:r,focusOwnerRef:i}=eC(),a=f(t=>{(t?!e:i.current===a)&&(i.current=t&&a,n?.(t),r(t))});return D(()=>{let e=t.current;return e?.getRootNode()?.activeElement===e&&a(!0),()=>a(!1)},[e,t,a]),a}var AC=5;function jC(e,t){let n=MC(t);return e.clientX>=n.left-AC&&e.clientX<=n.right+AC&&e.clientY>=n.top-AC&&e.clientY<=n.bottom+AC}function MC(e){let t=e.getBoundingClientRect(),n=y(e);if(Bg)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 NC(e,t){return e??t}function PC(e){let t=e.useState(`mounted`),n=e.useState(`popupSide`),r=e.useState(`positionerElement`);return t&&r?n:null}function FC(){return TS().filteredItems.length===0}function IC(e){return e===`rtl`?[`ArrowRight`,`ArrowLeft`]:[`ArrowLeft`,`ArrowRight`]}function LC(e,t,n){let r=e.context.listRef.current[t];r&&(e.context.selectionEventRef.current=n,r.click(),e.context.selectionEventRef.current=null)}var RC=Y.forwardRef(function(e,t){let{render:n,className:r,nativeButton:i=!0,disabled:a=!1,id:o,style:s,...c}=e,{state:l,disabled:u,setTouched:d,validationMode:p,validation:m}=eC(),{labelId:h}=oC(),g=CS(),_=g.useState(`selectionMode`),v=g.useState(`disabled`),y=g.useState(`readOnly`),b=g.useState(`required`),x=g.useState(`positionerElement`),S=g.useState(`listElement`),C=g.useState(`popupId`),w=g.useState(`triggerProps`),T=g.useState(`inputInsidePopup`),E=g.useState(`id`),D=g.useState(`labelId`),O=g.useState(`open`),k=g.useState(`selectedValue`),A=g.useState(`activeIndex`),j=g.useState(`selectedIndex`),M=g.useState(`hasSelectedValue`),N=wS(),P=ES(),F=Tg(),L=u||v||a,R=FC(),ee=PC(g),z=Y.useRef(null),B=kC(L,z);sC({id:T?o:void 0});let V=T?o??E:o,te=NC(h,D),ne;O&&T?ne=C??cC(E):O&&(ne=S?.id);let re=Y.useRef(``);function ie(e){re.current=e.pointerType}let{reference:ae}=ix(N,{enabled:!O&&!y&&!v&&_===`single`,listRef:g.context.labelsRef,activeIndex:A,selectedIndex:j,onMatch(e){let t=g.context.valuesRef.current[e];t!==void 0&&g.context.setSelectedValue(t,$(Wv))}}),{reference:U}=nb(N,{enabled:!v,event:`mousedown`}),{buttonRef:oe,getButtonProps:se}=I({native:i,disabled:L}),ce={...l,readOnly:y,open:O,disabled:L,popupSide:ee,listEmpty:R,placeholder:_!==`none`&&!M},le=f(e=>{g.set(`triggerElement`,e)});return H(`button`,e,{ref:[t,oe,z,le],state:ce,props:[w,U,ae,{id:V,tabIndex:T?0:-1,role:T?`combobox`:void 0,"aria-expanded":O,"aria-haspopup":T?`dialog`:`listbox`,"aria-controls":ne,"aria-required":T&&b||void 0,"aria-readonly":T&&y||void 0,"aria-labelledby":te,onPointerDown:ie,onPointerEnter:ie,onFocus(){B(!0),!L&&F.start(0,g.context.forceMount)},onBlur(e){if(!Q(x,e.relatedTarget)&&(d(!0),B(!1),p===`onBlur`)){let e=_===`none`?P:k;m.commit(e)}},onMouseDown(e){if(L||(T||N.set(`domReferenceElement`,e.currentTarget),g.context.forceMount(),re.current!==`touch`&&(g.context.inputRef.current?.focus(),T||e.preventDefault()),O))return;let t=Ra(e.currentTarget);function n(e){let t=g.state.triggerElement;if(!t)return;let n=Jg(e),r=g.state.positionerElement,i=g.state.listElement;Q(t,n)||Q(r,n)||Q(i,n)||jC(e,t)||g.context.setOpen(!1,$(oy,e))}T&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(k_(e),g.context.setOpen(!0,$(ry,e.nativeEvent)),g.context.inputRef.current?.focus())}},m.getValidationProps(L,c),se],stateAttributesMapping:OC})}),zC=Y.createContext(void 0);function BC(){return Y.useContext(zC)}var VC=Y.createContext(void 0);function HC(e){let t=Y.useContext(VC);if(t===void 0&&!e)throw Error(u(21));return t}var UC=Y.forwardRef(function(e,t){let n=CS(),{buttonRef:r,getButtonProps:i}=I({native:!1}),a=fe(t,r);function o(e){n.context.setOpen(!1,$(Xv,e.nativeEvent,e.currentTarget))}let s=i({onClick:o});return(0,X.jsx)(`span`,{ref:a,...s,"aria-label":`Dismiss`,tabIndex:void 0,style:ag})}),WC=Y.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:p}=eC(),{labelId:m}=oC(),h=BC(),g=!!HC(!0),_=CS(),v=ES(),y=SC(),b=_.useState(`required`),x=_.useState(`disabled`),S=_.useState(`readOnly`),C=_.useState(`name`),w=_.useState(`form`),T=_.useState(`selectionMode`),E=_.useState(`autoHighlight`),O=_.useState(`inputProps`),k=_.useState(`triggerProps`),A=_.useState(`open`),j=_.useState(`mounted`),M=_.useState(`selectedValue`),N=_.useState(`id`),P=_.useState(`inline`),F=_.useState(`modal`),I=!!E,L=PC(_),R=l||x||i,ee=FC(),z=kC(R,_.context.inputRef),B=g||P,V=!B||F,te=iC(a??(B?void 0:N)),ne=g?YS:c,[re,ie]=Y.useState(null),ae=Y.useRef(!1),U=Y.useRef(null);D(()=>{A||(U.current=null)},[A]);let oe=T===`none`&&!g,se=f(e=>{let t=g||_.state.inline;t&&!_.state.hasInputValue&&_.context.setInputValue(``,$(Wv)),_.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:oe})}),ce=g?s:p.getValidationProps(R,s);function le(e){_.context.setIndices({activeIndex:null,selectedIndex:null,type:_S(e),event:e})}let ue={...ne,open:A,disabled:R,readOnly:S,popupSide:L,listEmpty:ee};function de(e){if(!h)return;let t,n=h.chipsRef.current.length,[r]=IC(y);return e.key===r&&(e.currentTarget.selectionStart??0)===0&&M.length>0&&(e.preventDefault(),t=n>0?n-1:void 0),t}let fe=H(`input`,e,{state:ue,ref:[t,_.context.inputRef,se],props:[O,k,{value:re??v,"aria-readonly":S||void 0,"aria-required":b||void 0,"aria-labelledby":m,disabled:R,readOnly:S,required:T===`none`?b:void 0,form:w,...oe&&C&&{name:C},id:te,onFocus(){if(z(!0),!P)return;let e=U.current;U.current=null,e!=null&&Object.hasOwn(_.context.valuesRef.current,e)&&_.context.setIndices({activeIndex:e})},onBlur(){u(!0),z(!1);let e=_.state.activeIndex;if(P&&e!==null&&E!==`always`&&(U.current=e,_.context.setIndices({activeIndex:null})),d===`onBlur`){let e=T===`none`?v:M;p.commit(e)}},onCompositionStart(e){Pg||(ae.current=!0,ie(e.currentTarget.value))},onCompositionEnd(e){ae.current=!1;let t=e.currentTarget.value;ie(null),_.context.setInputValue(t,$(Qv,e.nativeEvent))},onChange(e){let t=e.nativeEvent,n=t.inputType,r=!n||n===`insertReplacementText`,i=ae.current||!r;function a(e){!S&&!R&&e&&i&&(_.context.setOpen(!0,$(Qv,t)),I||le(t))}if(ae.current){let n=e.currentTarget.value;ie(n),n===``&&!_.state.openOnInputClick&&!_.state.inputInsidePopup&&_.context.setOpen(!1,$($v,t));let r=n.trim(),i=I&&r!==``;a(r),A&&_.state.activeIndex!==null&&!i&&le(t);return}let o=$(Qv,t);if(_.context.setInputValue(e.currentTarget.value,o),o.isCanceled)return;let s=e.currentTarget.value===``,c=$($v,t);s&&!_.state.inputInsidePopup&&(T===`single`&&_.context.setSelectedValue(null,c),_.state.openOnInputClick||_.context.setOpen(!1,c)),a(e.currentTarget.value.trim()),A&&_.state.activeIndex!==null&&!I&&le(t)},onKeyDown(e){if(e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;if(R||S){S&&e.key===`Enter`&&A&&_.state.activeIndex!==null&&k_(e);return}let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=y===`rtl`;if(e.key===`Home`){k_(e);let n=Rg&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){k_(e);let i=Rg&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!j&&e.key===`Escape`){let t=T===`multiple`&&Array.isArray(M)?M.length===0:M===null,n=$(ny,e.nativeEvent),r=T===`multiple`?[]:null;_.context.setInputValue(``,n),_.context.setSelectedValue(r,n),t||_.state.inline||n.isPropagationAllowed||e.stopPropagation();return}if(h&&e.key===`Backspace`&&t.value===``&&Array.isArray(M)&&M.length>0){let t=h.chipsRef.current.length,n=t>0?t-1:M.length-1,r=M.filter((e,t)=>t!==n);le(e.nativeEvent),_.context.setSelectedValue(r,$(Wv,e.nativeEvent));return}let i=de(e);if(i!==void 0&&h?.chipsRef.current[i]?.focus(),e.which!==229&&e.key===`Enter`&&A){let t=_.state.activeIndex,n=e.nativeEvent;if(t===null){if(P)return;_.context.setOpen(!1,$(Wv,n));return}k_(e),LC(_,t,n)}}},ce],stateAttributesMapping:OC}),pe=g?(0,X.jsx)($S.Provider,{value:QS,children:fe}):fe;return(0,X.jsxs)(Y.Fragment,{children:[A&&V&&(0,X.jsx)(UC,{ref:_.context.startDismissRef}),pe]})}),GC={...a_,...g_},KC=Y.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,keepMounted:o=!1,style:s,...c}=e,{disabled:l}=eC(),u=CS(),d=u.useState(`selectionMode`),f=u.useState(`disabled`),p=u.useState(`readOnly`),m=u.useState(`open`),h=u.useState(`selectedValue`),g=u.useState(`hasSelectionChips`),_=ES(),v=!1;v=d===`none`?_!==``:d===`single`?h!=null:g;let y=l||f||i,{buttonRef:b,getButtonProps:x}=I({native:a,disabled:y}),{mounted:S,transitionStatus:C,setMounted:w}=sb(v),T={disabled:y,visible:v,open:m,transitionStatus:C};fb({open:v,ref:u.context.clearRef,onComplete(){v||w(!1)}});let E=H(`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=_S(e);u.context.setInputValue(``,$(Zv,e.nativeEvent)),d===`none`?u.context.setIndices({activeIndex:null,type:t,event:e.nativeEvent}):(u.context.setSelectedValue(Array.isArray(h)?[]:null,$(Zv,e.nativeEvent)),u.context.setIndices({activeIndex:null,selectedIndex:null,type:t,event:e.nativeEvent})),u.context.inputRef.current?.focus()}},c,x],stateAttributesMapping:GC});return o||S?E:null}),qC=Y.createContext(null);function JC(){return Y.useContext(qC)}function YC(e){let{children:t}=e,{filteredItems:n}=TS(),r=JC(),i=r?r.items:n;return(0,X.jsx)(Y.Fragment,{children:i.map(t)})}var XC=Y.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function ZC(){return Y.useContext(XC)}function QC(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=f(i),[,o]=Y.useState(0),s=d(ew).current,c=d($C).current,l=Y.useRef(0),u=Y.useRef(!0),p=Y.useRef(null),m=Y.useRef(null),h=f(()=>{u.current||(u.current=!0,o(e=>e+1))}),g=f((e,t)=>{c.set(e,t),h()}),_=f(e=>{c.delete(e),h()}),v=f(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 y(e){if(m.current?.disconnect(),m.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!rw(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&iw(r,n)>0){t.disconnect(),h();return}r=n}});m.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=nw(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let b=f(()=>{let[e,t]=tw(c),n=v(e),r=p.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});y(t),p.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});D(()=>(!u.current&&p.current&&v(p.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,v]),D(()=>{u.current&&b()}),D(()=>()=>{m.current?.disconnect(),u.current=!0},[]);let x=f(e=>(s.add(e),()=>{s.delete(e)})),S=Y.useMemo(()=>({register:g,unregister:_,subscribeMapChange:x,nextIndexRef:l}),[g,_,x,l]);return(0,X.jsx)(XC.Provider,{value:S,children:t})}function $C(){return new Map}function ew(){return new Set}function tw(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)=>iw(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 nw(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function rw(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 iw(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var aw=Y.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=CS(),l=wS(),u=!!HC(!0),{filteredItems:d,hasItems:p}=TS(),m=c.useState(`selectionMode`),h=c.useState(`grid`),g=c.useState(`readOnly`),_=c.useState(`listProps`),v=c.useState(`virtualized`),y=c.useState(`forceMounted`),b=m===`multiple`,x=d.length===0,S=f(e=>{c.set(`positionerElement`,e)}),C=f(e=>{c.set(`listElement`,e)}),w=Y.useMemo(()=>typeof o==`function`?n||=(0,X.jsx)(YC,{children:o}):o,[o]),T={empty:x},E=l.useState(`floatingId`),D=H(`div`,e,{state:T,ref:[t,C,u?null:S],props:[_,{children:w,tabIndex:-1,id:E,role:h?`grid`:`listbox`,"aria-multiselectable":b?`true`:void 0,"aria-readonly":!h&&g?!0:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;k_(e),LC(c,t,e.nativeEvent)}}},s]});if(v)return D;let O=p&&!y?void 0:c.context.labelsRef;return(0,X.jsx)(QC,{elementsRef:c.context.listRef,labelsRef:O,children:D})}),ow=Y.createContext(void 0);function sw(){let e=Y.useContext(ow);if(e===void 0)throw Error(u(20));return e}var cw=Y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=CS(),a=i.useState(`mounted`),o=i.useState(`forceMounted`);return a||n||o?(0,X.jsx)(ow.Provider,{value:n,children:(0,X.jsx)(Iy,{ref:t,...r})}):null});function lw(e){return le(19)?e:e?`true`:void 0}function uw(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]=Y.useState(null),d=Y.useRef(null),f=Hy(n),p=Y.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=uS({...e,elements:{...p,...l&&{reference:l}}}),h=Y.useCallback(e=>{let t=pe(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=Y.useMemo(()=>({...m.refs,setPositionReference:h,domReference:d}),[m.refs,h]),_=Y.useMemo(()=>({...m.elements,domReference:o}),[m.elements,o]),v=Y.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 D(()=>{o&&(d.current=o)},[o]),D(()=>{r.context.dataRef.current.floatingContext=v;let e=f?.nodesRef.current.find(e=>e.id===t);e&&(e.context=v)}),Y.useMemo(()=>({...m,context:v,refs:g,elements:_,rootStore:r}),[m,g,_,v,r])}var dw=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}=H_(e,t)||{};if(l==null)return{};let d=ov(u),f={x:n,y:r},p=J_(i),m=K_(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=V_(D,k,O),j=!c.arrow&&W_(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}}}),fw=(e,t)=>{let{name:n,fn:r}=dw(e);return{name:n,fn:r,options:[e,t]}},pw={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}}}},mw={sideX:`left`,sideY:`top`},hw=`--available-width`,gw=`--available-height`,_w=`--anchor-width`,vw=`--anchor-height`,yw=`--transform-origin`,bw=hw,xw=gw;function Sw(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 Cw(e,t,n){let{rects:r,placement:i}=e;return{side:Sw(t,U_(i),n),align:W_(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function ww(e){return Tw(e,uw)}function Tw(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:p=!1,inline:m,keepMounted:h=!1,floatingRootContext:g,mounted:_,collisionAvoidance:v,shift:b,nodeId:x,adaptiveOrigin:S,lazyFlip:C=!1,externalTree:w}=e,T=v.side||`flip`,E=v.align||`flip`,O=v.fallbackAxisSide||`end`,k=b?.crossAxis??!1,A=b?.rootBoundary,j=typeof n==`function`?n:void 0,M=f(j),N=j?M:n,P=tg(n),F=tg(_),I=SC()===`rtl`,[L,R]=Y.useState(null);!_&&L!==null&&R(null);let ee=C===`placement`,z=L?U_(L):null,B=L&&ee?W_(L)||`center`:null,V=z||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":I?`left`:`right`,"inline-start":I?`right`:`left`}[i],te=B||o,ne=te===`center`?V:`${V}-${te}`,H=l;typeof H==`number`?H={top:H,right:H,bottom:H,left:H}:H&&={top:H.top||0,right:H.right||0,bottom:H.bottom||0,left:H.left||0};let re=+(i===`bottom`),ie=+(i===`top`),ae=+(i===`right`),U=+(i===`left`),oe={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:H},se=Y.useRef(null),ce=tg(a),le=tg(s),ue=typeof a==`function`?0:a,de=typeof s==`function`?0:s,fe=[];m&&fe.push(m),fe.push(dS(e=>{let t=Cw(e,i,I),n=typeof ce.current==`function`?ce.current(t):ce.current,r=typeof le.current==`function`?le.current(t):le.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[ue,de,I,i]));let pe=E===`none`&&T!==`shift`,me=!pe&&(u||k||T===`shift`),he=T===`none`?null:mS({...oe,padding:{top:H.top+1+re,right:H.right+1+U,bottom:H.bottom+1+ie,left:H.left+1+ae},mainAxis:!k&&T===`flip`,crossAxis:E===`flip`&&`alignment`,fallbackAxisSideDirection:O}),ge=pe?null:fS({...oe,rootBoundary:A,mainAxis:E!==`none`,crossAxis:me,limiter:u||k?void 0:pS(e=>{if(!se.current)return{};let{width:t,height:n}=se.current.getBoundingClientRect(),r=q_(U_(e.placement)),i=r===`y`?t:n,a=r===`y`?H.left+H.right:H.top+H.bottom;return{offset:i/2+a/2}})},[oe,u,k,A,H,E]);T===`shift`||E===`shift`||te===`center`?fe.push(ge,he):fe.push(he,ge),fe.push(hS({...oe,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!F.current)return;let i=e.style;i.setProperty(bw,`${t}px`),i.setProperty(xw,`${n}px`);let a=y(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(_w,`${u}px`),i.setProperty(vw,`${d}px`)}}),fw(e=>({element:se.current||Ra(e.elements.floating).createElement(`div`),padding:se.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=U_(r),u=W_(r),d=q_(l)===`y`,f=se.current,p=typeof a==`function`?a(Cw(e,i,I)):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(yw,d?`${m} ${h}`:`${h} ${m}`),{}}},pw,S),D(()=>{!_&&g&&g.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[_,g]);let _e=Y.useMemo(()=>({ancestorScroll:!p,elementResize:!p&&typeof ResizeObserver<`u`,layoutShift:!p&&typeof IntersectionObserver<`u`}),[p]),{refs:ve,elements:ye,x:be,y:xe,middlewareData:Se,update:Ce,placement:we,context:Te,isPositioned:Ee,floatingStyles:De}=t({rootContext:g,open:h?_:void 0,placement:ne,middleware:fe,strategy:r,whileElementsMounted:h?void 0:(...e)=>Qx(...e,_e),nodeId:x,externalTree:w}),{sideX:Oe,sideY:ke}=Se.adaptiveOrigin||mw,Ae=Ee?r:`fixed`,je=Y.useMemo(()=>{let e;return e=Ee?S?{position:Ae,[Oe]:be,[ke]:xe}:{...De,position:Ae}:{position:Ae,top:0,left:0},e[bw]=`100vw`,e[xw]=`100vh`,Ee||(e.opacity=0),e},[S,Ae,Oe,be,ke,xe,De,Ee]),Me=Y.useRef(null);D(()=>{if(!_)return;let e=P.current,t=typeof e==`function`?e():e,n=(Ew(t)?t.current:t)||null;n!==Me.current&&(ve.setPositionReference(n),Me.current=n)},[_,ve,N,P]),Y.useEffect(()=>{if(!_)return;let e=P.current;typeof e!=`function`&&Ew(e)&&e.current!==Me.current&&(ve.setPositionReference(e.current),Me.current=e.current)},[_,ve,N,P]),Y.useEffect(()=>{if(h&&_&&ye.reference&&ye.floating)return Qx(ye.reference,ye.floating,Ce,_e)},[h,_,ye,Ce,_e]);let Ne=U_(we),W=Sw(i,Ne,I),Pe=W_(we)||`center`,Fe=!!Se.hide?.referenceHidden;D(()=>{C&&_&&Ee&&(Ne!==V||ee&&Pe!==te)&&R(we)},[C,ee,_,Ee,we,Ne,Pe,V,te]);let Ie=Y.useMemo(()=>({position:`absolute`,top:Se.arrow?.y,left:Se.arrow?.x}),[Se.arrow]),Le=Se.arrow?.centerOffset!==0;return Y.useMemo(()=>({positionerStyles:je,arrowStyles:Ie,arrowRef:se,arrowUncentered:Le,side:W,align:Pe,physicalSide:Ne,anchorHidden:Fe,refs:ve,context:Te,isPositioned:Ee,update:Ce}),[je,Ie,se,Le,W,Pe,Ne,Fe,ve,Te,Ee,Ce])}function Ew(e){return e!=null&&`current`in e}var Dw=Y.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,X.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function Ow(e){return e===`starting`?Oy:z}function kw(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),H(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},Ow(r),i],stateAttributesMapping:v_})}var Aw={},jw={},Mw=``;function Nw(e,t){return O(e)?e:t}function Pw(e,t,n){return/hidden|clip/.test(e.getComputedStyle(Nw(t,n)).overflowY)}function Fw(e){if(typeof document>`u`)return!1;let t=Ra(e);return y(t).innerWidth-t.documentElement.clientWidth>0}function Iw(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=Ra(e),n=t.documentElement,r=t.body,i=Nw(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 Lw(e){let t=Ra(e),n=t.documentElement,r=t.body,i=Nw(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 Rw(e){let t=Ra(e),n=t.documentElement,r=t.body,i=y(n),a=0,o=0,s=!1,c=Ug.create();if(Lg&&(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,Aw={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Mw=n.style.scrollBehavior,jw={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=Nw(n,r);s=Iw(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,Aw),Object.assign(r.style,jw),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=Mw)}function d(){u(),c.request(l)}l();let f=bg(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var zw=new class{lockCount=0;restore=null;timeoutLock=wg.create();timeoutUnlock=wg.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=Ra(e),n=t.documentElement,r=t.body,i=y(n);if(Pw(i,n,r)){let t=new i.MutationObserver(()=>{Pw(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=Mg||!Fw(e);this.restore=a?Lw(e):Rw(e)}};function Bw(e=!0,t=null){D(()=>{if(e)return zw.acquire(t)},[e,t])}var Vw=20;function Hw(e,t,n,r){let[i,a]=Y.useState(!1);D(()=>{if(!e||!t||n==null){a(!1);return}let r=Ra(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-Vw)},[e,t,n]),Bw(e&&(!t||i),r)}var Uw=Y.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:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=ky,style:_,...v}=e,y=CS(),b=wS(),x=sw(),S=y.useState(`modal`),C=y.useState(`open`),w=y.useState(`mounted`),T=y.useState(`openMethod`),E=y.useState(`positionerElement`),O=y.useState(`triggerElement`),k=y.useState(`inputElement`),A=y.useState(`inputGroupElement`),j=y.useState(`inputInsidePopup`),M=y.useState(`transitionStatus`),N=FC(),P=ww({anchor:i??(j?O:A??k),floatingRootContext:b,positionMethod:a,mounted:w,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:p,collisionBoundary:u,collisionPadding:d,sticky:m,disableAnchorTracking:h,keepMounted:x,collisionAvoidance:g,lazyFlip:!0});Hw(C&&S,T===`touch`,E,O);let F={open:C,side:P.side,align:P.align,anchorHidden:P.anchorHidden,empty:N};D(()=>{y.set(`popupSide`,P.side)},[y,P.side]);let I=f(e=>{y.set(`positionerElement`,e)}),L=kw(e,F,{styles:P.positionerStyles,transitionStatus:M,props:v,refs:[t,I],hidden:!w,inert:!C});return(0,X.jsxs)(VC.Provider,{value:P,children:[w&&S&&(0,X.jsx)(Dw,{inert:lw(!C),cutout:A??k??O}),L]})}),Ww={...v_,...a_},Gw=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=CS(),l=HC(),u=wS(),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=FC(),x=s.id??(g?cC(y):void 0);D(()=>(c.set(`popupId`,c.context.popupRef.current?.id||x),()=>{c.set(`popupId`,void 0)}),[c,x]),fb({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=H(`div`,e,{state:S,ref:[t,c.context.popupRef],props:[m,{id:x,role:g?`dialog`:`presentation`,onFocus(e){let t=Jg(e.nativeEvent);p!==`touch`&&(Q(c.state.listElement,t)||t===e.currentTarget)&&c.context.inputRef.current?.focus()}},Ow(h),s],stateAttributesMapping:Ww}),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,X.jsx)(tb,{context:u,disabled:!d,modal:E,openInteractionType:p,initialFocus:w,returnFocus:T,getInsideElements:()=>[c.context.startDismissRef.current,c.context.endDismissRef.current],children:(0,X.jsxs)(Y.Fragment,{children:[C,E&&(0,X.jsx)(UC,{ref:c.context.endDismissRef})]})})});function Kw(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=ZC(),u=Y.useRef(-1),[d,f]=Y.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=Y.useRef(null),h=Y.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 D(()=>{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 qw=Y.createContext(void 0);function Jw(){let e=Y.useContext(qw);if(!e)throw Error(u(19));return e}var Yw=Y.createContext(!1);function Xw(){return Y.useContext(Yw)}function Zw(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=Y.useRef(null),m=Kw({guess:!0,index:l,textRef:p}),h=CS(),g=Xw(),_=DS(),{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,O=E!==-1,k=h.useState(`isActive`,E),A=h.useState(`isSelected`,c),j=Y.useRef(null),M=y!=null&&O?`${y}-${E}`:void 0,N=A&&T;D(()=>{if(!O||!r&&l==null)return;let e=h.context.listRef.current;return e[E]=j.current,()=>{delete e[E]}},[O,r,E,l,h]),D(()=>{if(!O||_)return;let e=h.context.valuesRef.current;return e[E]=c,()=>{delete e[E]}},[O,_,E,c,h]),D(()=>{if(!O||_)return;let e=h.state.selectedValue,t=h.state.selectedIndex;h.state.selectionMode===`multiple`&&Array.isArray(e)?t=IS(E,c,h.context.valuesRef.current,e,C,t):AS(c,e,C)&&(t=E),h.set(`selectedIndex`,t)},[O,_,h,E,c,C]);let{getButtonProps:P,buttonRef:F}=I({disabled:w,focusableWhenDisabled:!0,native:d,composite:!0}),L={disabled:w,selected:N,highlighted:k};function R(e){function t(){h.context.handleSelection(e,c)}h.state.submitOnItemClick?(Wm.flushSync(t),h.context.requestSubmit()):t()}let ee={id:M,role:g?`gridcell`:`option`,"aria-selected":T?N: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||R(e.nativeEvent)},onMouseUp(e){let t=h.context.pointerDownItemRef.current===e.currentTarget;h.context.pointerDownItemRef.current=null,!(w||S||e.button!==0||t||!k)&&R(e.nativeEvent)}},z=H(`div`,t,{ref:[F,n,m.ref,j],state:L,props:[v,ee,f,P]}),B=Y.useMemo(()=>({selected:N,textRef:p}),[N,p]);return(0,X.jsx)(qw.Provider,{value:B,children:z})}function Qw(e){let{componentProps:t,forwardedRef:n}=e,r=CS().useState(`isItemEqualToValue`),{flatFilteredValues:i}=TS(),a=NS(i,t.value??null,r);return(0,X.jsx)(Zw,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:a})}var $w=Y.memo(Y.forwardRef(function(e,t){let n=CS().useState(`virtualized`);return n&&e.index==null?(0,X.jsx)(Qw,{componentProps:e,forwardedRef:t}):(0,X.jsx)(Zw,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})}));function eT(e){return H(e.defaultTagName??`div`,e,e)}var tT=Y.createContext(void 0);function nT(){let e=Y.useContext(tT);if(e===void 0)throw Error(u(13));return e}var rT={imageLoadingStatus:()=>null},iT=Y.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,[o,s]=Y.useState(`idle`),c={imageLoadingStatus:o},l=Y.useMemo(()=>({imageLoadingStatus:o,setImageLoadingStatus:s}),[o,s]),u=H(`span`,e,{state:c,ref:t,props:a,stateAttributesMapping:rT});return(0,X.jsx)(tT.Provider,{value:l,children:u})});function aT(e,{referrerPolicy:t,crossOrigin:n,sizes:r,srcSet:i},a){let o=Y.useState(`idle`),s=o[1];return D(()=>{if(!a)return P;if(!e&&!i)return s(`error`),P;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 oT={...rT,...a_},sT=Y.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}=nT(),[p,m]=aT(l,e,!a),h=p===`loaded`,{mounted:g,transitionStatus:_,setMounted:v}=sb(h),y=Y.useRef(null),b=Y.useRef(!0);D(()=>{if(!a)return;let e=b.current;b.current=!1;let t=y.current;if(!t)return;if(!t.complete){m(`loading`);return}let n=t.naturalWidth>0?`loaded`:`error`;m(n),n===`loaded`&&e&&v(!0)},[a,l,c,s,u.crossOrigin,u.referrerPolicy,r,m,v]);let x=a?{"data-loading":p===`loading`?``:void 0,"data-error":p===`error`?``:void 0,"aria-hidden":p!==`loaded`||void 0,onLoad(){m(`loaded`)},onError(){m(`error`)}}:void 0,S=f(e=>{i?.(e),d(e)});D(()=>{p!==`idle`&&S(p)},[p,S]),D(()=>()=>d(`idle`),[d]),fb({enabled:!h,open:h,ref:y,onComplete(){h||v(!1)}});let C={imageLoadingStatus:p,transitionStatus:a&&_===`ending`?void 0:_},w=a||g,T={};s!==void 0&&(T.sizes=s),c!==void 0&&(T.srcSet=c),l!==void 0&&(T.src=l);let E=H(`img`,e,{state:C,ref:[t,y],props:[x,u,T],stateAttributesMapping:oT,enabled:w});return w?E:null}),cT=Y.forwardRef(function(e,t){let{className:n,render:r,delay:i=0,style:a,...o}=e,{imageLoadingStatus:s}=nT(),[c,l]=Y.useState(i===0),u=Tg();return Y.useEffect(()=>(i>0?u.start(i,()=>l(!0)):l(!0),u.clear),[u,i]),H(`span`,e,{state:{imageLoadingStatus:s},ref:t,props:o,stateAttributesMapping:rT,enabled:s!==`loaded`&&(i===0||c)})});function lT(e){let t=(0,La.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=_(`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,X.jsx)(iT,{"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 uT(e){let t=(0,La.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=_(`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,X.jsx)(sT,{"data-slot":`avatar-image`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function dT(e){let t=(0,La.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=_(`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,X.jsx)(cT,{"data-slot":`avatar-fallback`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var fT=Y.memo(Y.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a,selected:o,...s}=e,c=Y.useRef(null),{transitionStatus:l,setMounted:u}=sb(o),d=H(`span`,e,{ref:[t,c],state:{selected:o,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},s],stateAttributesMapping:a_});return fb({batch:!0,enabled:!o,open:o,ref:c,onComplete(){o||u(!1)}}),d})),pT=Y.forwardRef(function(e,t){let{selected:n}=Jw();return e.keepMounted||n?(0,X.jsx)(fT,{...e,selected:n,ref:t}):null}),mT=Y.createContext(void 0);function hT(e=!0){let t=Y.useContext(mT);if(t===void 0&&!e)throw Error(u(25));return t}var gT=Y.createContext(void 0);function _T(e){let t=Y.useContext(gT);if(t===void 0&&!e)throw Error(u(33));return t}var vT=Y.createContext(void 0);function yT(e){let t=Y.useContext(vT);if(t===void 0&&!e)throw Error(u(36));return t}var bT=Y.createContext(null);function xT(e=`root`){let t=Y.useContext(bT),n=Y.useContext(vT);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var ST={visible:!0,ref:null};function CT(){return ST}function wT(e,t,n=`root`){let r=xT(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??CT)({label:e.label,children:e.children,render:e.render}),a=fe(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}function TT(e){e.preventDefault()}function ET(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=yT(),u=hT(!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 Y.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?TT: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:Yv})},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&&!Fg&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&de(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var DT={type:`regular-item`};function OT(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=Y.useRef(null),{getButtonProps:d,buttonRef:f}=I({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=ET({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=Y.useCallback(e=>ue(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=fe(u,f);return Y.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var kT=Y.createContext(void 0);function AT(){let e=Y.useContext(kT);if(e===void 0)throw Error(u(31));return e}var jT=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Y.useState(void 0),c=H(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,X.jsx)(kT.Provider,{value:s,children:c})}),MT=Y.forwardRef(function(e,t){let n=xT()?.Group??jT;return(0,X.jsx)(n,{...e,ref:t})}),NT=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=iC(a),c=AT();return D(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),H(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),PT=Y.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}=yT(),f=Kw({guess:!0,label:a}),p=iC(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}=OT({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:DT});return H(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),FT=Y.forwardRef(function(e,t){let n=wT(e,t);return n.visible?(0,X.jsx)(PT,{...e,ref:n.ref}):null}),IT=Y.createContext(void 0);function LT(e){let t=Y.useContext(IT);if(t===void 0&&!e)throw Error(u(69));return t}var RT=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),zT=Y.createContext(void 0);function BT(){return Y.useContext(zT)}function VT(e,t){let n=ie(e.render);if(Y.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function HT(e,t,n){let r=VT(e,t),i=r===t?void 0:r;return[r,Y.useCallback(e=>n?.(e?i:void 0),[i,n])]}function UT(e,t,n){let r=ie(e.render),i=Y.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 WT=Y.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}=yT(),m=BT(),{side:h,align:g}=_T(),_=LT(!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`),P=l.useState(`listElement`),[F,I]=HT(e,u,d),L=UT(e,C,N),R=w.type===`menu`?m:void 0,ee=w.type===`context-menu`,z=s??w.type!==`menu`;s===void 0&&P&&w.type!==`menu`&&(z=()=>l.state.activeIndex===null&&P),fb({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),Y.useEffect(()=>{function e(e){l.setOpen(!1,$(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),Jb(D,{enabled:A&&!j&&!ee&&w.type!==`menubar`,closeDelay:k});let B=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:V,handleFocus:te}=(Y.useContext(bT)?.useParentHandoff??KT)(l,w,v,f),ne={transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},re=H(`div`,e,{state:ne,ref:[t,l.context.popupRef,B,I],stateAttributesMapping:y_,props:[b,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":L},onKeyDown(e){R?.onPopupKeyDown?.(e),_&&RT.has(e.key)&&e.stopPropagation()},onFocus:te},Ow(y),c,{"data-rootownerid":E}]}),ie=w.type===void 0||ee;(C||w.type===`menubar`&&T!==`outside-press`)&&(ie=!0);let ae=R?.getReturnElement??V;return(0,X.jsx)(tb,{context:D,openInteractionType:M,modal:ee,disabled:!x,returnFocus:a??ae??ie,explicitReturnFocus:a===void 0&&ae?!1:void 0,initialFocus:z,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:re})}),GT={parentVirtualFocusRef:void 0,handleFocus:void 0};function KT(){return GT}var qT=Y.forwardRef(function(e,t){let n=xT()?.Popup??WT;return(0,X.jsx)(n,{...e,ref:t})}),JT=Y.createContext(void 0);function YT(){let e=Y.useContext(JT);if(e===void 0)throw Error(u(32));return e}var XT=Y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=yT();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,X.jsx)(JT.Provider,{value:n,children:(0,X.jsx)(Iy,{ref:t,...r,portalOwnerRole:o})})});function ZT(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=Y.useRef(null),o=Y.useRef(null),s=db(r);D(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),D(()=>{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 QT=Y.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=ky,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=yT(),x=YT(),S=hT(!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`),P=v.useState(`adaptiveOrigin`),F=v.useState(`lastOpenChangeReason`),I=v.useState(`floatingNodeId`),L=v.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),ee=n,z=c,B=l,V=s,te=h;C.type===`context-menu`&&(ee=n??C.context?.anchor,V??=`start`,!o&&V!==`center`&&(B=e.alignOffset??2,z=e.sideOffset??-5));let ne=o,H=V;C.type===`menu`?(ne??=`inline-end`,H??=`start`,te=e.collisionAvoidance??Ay):C.type===`menubar`&&(ne??=C.context.orientation===`vertical`?`inline-end`:`bottom`,H??=`start`);let re=C.type===`context-menu`,ie=ww({anchor:ee,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:ne,sideOffset:z,align:H,alignOffset:B,arrowPadding:re?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:I,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:te,shift:re?{crossAxis:!(`side`in te&&te.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P,lazyFlip:y?`placement`:!1});Y.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&v.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,$(sy)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,I]),Y.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,$(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let ae=Tg();Y.useEffect(()=>{D||ae.clear()},[D,ae]),Y.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?ae.isStarted()||ae.start(e,()=>{v.setOpen(!1,$(sy))}):v.setOpen(!1,$(sy))}else ae.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,ae]),Y.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,I,L]),ZT({store:v,domReference:R,positionerElement:M,open:D});let U={open:D,side:ie.side,align:ie.align,anchorHidden:ie.anchorHidden,nested:C.type===`menu`,instant:N},oe=C.type===`menubar`&&C.context.modal;Hw(D&&(oe||O&&F!==`trigger-hover`),k===`touch`,M,A);let se=kw(e,U,{styles:ie.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),ce=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),le=null;return C.type===`menubar`?le=C.context.contentElement:C.type===void 0&&(le=A),(0,X.jsxs)(gT.Provider,{value:ie,children:[ce&&(0,X.jsx)(Dw,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:lw(!D),cutout:le}),(0,X.jsx)(Wy,{id:I,children:(0,X.jsx)(QC,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:se})})]})}),$T=Y.createContext(null);function eE(e){let t=Y.useContext($T);if(t===null&&!e)throw Error(u(5));return t}var tE={...Nb,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=Nb.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>Lg&&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`&&!Nb.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`)}},nE=class extends yg{constructor(e,t,n=!1){let r=new wb,i=iE(r,t,n,e);super(i,rE(r),tE),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 rE(e){return{positionerRef:Y.createRef(),popupRef:Y.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:Y.createRef(),beforeTriggerFocusGuardRef:Y.createRef(),beforeContentFocusGuardRef:Y.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function iE(e,t,n=!1,r){return{...Db(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:z,inputProps:z,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new Ry,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:z,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var aE=Y.createContext(null);function oE(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function sE(e,t){return e===`list-navigation`||oE(e,t)}var cE=ug(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:p,closeParentOnEsc:m=!1,handle:h,triggerId:g,defaultTriggerId:_=null,highlightItemOnHover:v=!0,isSubmenu:y=!1,virtualFocus:b=!1,virtualFocusRef:x,allowEscape:S=!0,resetOnPointerLeave:C=!0}=e,w=hT(!0),T=yT(!0),E=eE(!0),O=T?.store,k=T?.virtualFocus??!1,A=Y.useMemo(()=>y&&O?{type:`menu`,store:O}:E?{type:`menubar`,context:E}:w&&!O?{type:`context-menu`,context:w}:{type:void 0},[w,O,E,y]),j=iC(),M=iC(),[N,P]=Y.useState(void 0),F=(N??M)||void 0,I=Vy(),L=A.type===`menu`?A.store:void 0,R=(n??o)&&L?.state.transitionStatus===`starting`,ee=d(()=>R?L?.state.instantType:void 0).current,V=d(()=>{let e=new nE({open:o,openProp:n,activeTriggerId:_,triggerIdProp:g,parent:A,disabled:s,highlightItemOnHover:v,modal:A.type===void 0?c:void 0,rootId:j,instantType:ee},F,I!=null);return e.context.virtualFocusRef=x,e}).current;V.useControlledProp(`openProp`,n),V.useControlledProp(`triggerIdProp`,g),V.useContextCallback(`onOpenChangeComplete`,i);let te=V.useState(`floatingTreeRoot`),ne=Uy(te),H=V.useState(`open`),re=V.useState(`activeTriggerElement`),ie=V.useState(`positionerElement`),ae=V.useState(`hoverEnabled`),U=V.useState(`disabled`),oe=V.useState(`lastOpenChangeReason`),se=V.useState(`parent`),ce=V.useState(`activeIndex`),le=V.useState(`keyboardOpen`),de=V.useState(`payload`),fe=V.useState(`floatingParentNodeId`),pe=Y.useRef(null),me=Y.useRef(se.type!==`context-menu`),he=Tg(),ge=Y.useRef(!0),_e=Tg(),ve=fe!=null,{openMethod:ye,triggerProps:be}=_C(H);V.useSyncedValues({disabled:s,highlightItemOnHover:v,modal:se.type===void 0?c:void 0,openMethod:ye,rootId:j}),xb(V);let{forceUnmount:xe,transitionStatus:Se}=Sb(H,V,()=>{V.set(`allowMouseEnter`,!1)},R),Ce=db(V.context.popupRef);Y.useEffect(()=>{if(ee===void 0)return;let e=()=>{V.state.instantType===ee&&V.set(`instantType`,void 0)};if(!H){e();return}if(Se!==void 0)return;if(V.context.popupRef.current==null){e();return}let t=new AbortController;return Ce(e,t.signal),()=>{t.abort()}},[ee,H,Se,Ce,V]),D(()=>{w&&!T?V.update({parent:{type:`context-menu`,context:w},floatingNodeId:ne,floatingParentNodeId:I}):(T||!V.select(`activeTriggerElement`))&&V.update({floatingNodeId:ne,floatingParentNodeId:I})},[w,T,ne,I,re,V]),Y.useEffect(()=>{H||(pe.current=null),se.type===`context-menu`&&(H?he.start(500,()=>{me.current=!0}):(he.clear(),me.current=!1))},[he,H,se.type]),D(()=>{!H&&!ae&&V.set(`hoverEnabled`,!0)},[H,ae,V]);let we=f((e,t)=>{let n=t.reason;if(!e&&!V.select(`open`)||H===e&&t.trigger===re&&oe===n)return;let i=yb(t);if(!e&&t.trigger==null&&(t.trigger=re??void 0),r?.(e,t),t.isCanceled)return;V.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!ge.current)return;e&&n===`trigger-focus`?(ge.current=!1,_e.start(300,()=>{ge.current=!0})):(ge.current=!0,_e.clear());let o=!e&&(n===`escape-key`||n==null);pe.current=t.event;let s=vb(V.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&sE(n,a),s.instantType=se.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:oE(n,a)?`click`:o?`dismiss`:void 0,V.update(s)}),Te=ob({popupStore:V,floatingRootContext:V.state.floatingRootContext,floatingId:F,nested:I!=null,onOpenChange:we}),Ee=Te.context.events;D(()=>{let e=({open:e,eventDetails:t})=>we(e,t);return Ee.on(`setOpen`,e),()=>{Ee?.off(`setOpen`,e)}},[Ee,we]),D(()=>V.subscribeToParentMenu(),[V]);let De=Y.useCallback(()=>{V.setOpen(!1,$(cy))},[V]);Y.useImperativeHandle(p,()=>({unmount:xe,close:De}),[xe,De]);let Oe;se.type===`context-menu`&&(Oe=se.context),Y.useImperativeHandle(Oe?.positionerRef,()=>ie,[ie]),Y.useImperativeHandle(Oe?.actionsRef,()=>({setOpen:we}),[we]);let ke=ab(Te,{enabled:!U,bubbles:{escapeKey:m&&se.type===`menu`},outsidePress(){return se.type!==`context-menu`||pe.current?.type===`contextmenu`||me.current},externalTree:ve?te:void 0}),Ae=SC(),je=rx(Te,{enabled:!U,listRef:V.context.itemDomElements,activeIndex:ce,virtual:b,nested:se.type===`menubar`||!b&&se.type!==void 0,parentOrientation:se.type===`menubar`?se.context.orientation:void 0,loopFocus:l,focusItemOnOpen:b?le:void 0,allowEscape:b&&l&&S,orientation:u,triggerOrientation:b?`vertical`:u,rtl:Ae===`rtl`,disabledIndices:B,onNavigate(e,t){V.setActiveIndex(e,_S(t),t?.nativeEvent)},openOnArrowKeyDown:se.type!==`context-menu`&&!(b&&y),externalTree:!b&&ve?te:void 0,nestedReturnFocusRef:L?.context.virtualFocusRef,focusItemOnHover:v,resetOnPointerLeave:C}),Me=Y.useCallback(e=>{V.context.typingRef.current=e},[V]),Ne=ix(Te,{enabled:!U&&!b,listRef:V.context.itemLabels,elementsRef:V.context.itemDomElements,activeIndex:ce,resetMs:500,onMatch:(e,t)=>{H&&e!==ce&&V.setActiveIndex(e,iy,t.nativeEvent)},onTyping:Me}),W=f(a),Pe=Y.useRef(-1),Fe=f(()=>{let e=V.state.activeIndex,t=e===null?void 0:V.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Pe.current===n&&V.context.reportedItem===t)return;Pe.current=n,V.context.reportedItem=t,b&&V.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=V.context;V.context.highlightReason=Wv,V.context.highlightEvent=void 0,a&&W(t,Uv(r,i,{label:t===void 0?void 0:V.context.itemLabels.current[n]??void 0}))});D(()=>{Fe()},[ce,Fe]);let Ie=Y.useMemo(()=>{if(!b)return je.reference;if(!je.trigger)return z;let{onFocus:e,...t}=je.trigger;return t},[b,je.reference,je.trigger]);V.useSyncedValue(`inputProps`,b?je.reference??z:z);let Le=Y.useMemo(()=>{let e=ue(Ne.reference,Ie,ke.reference,{onMouseMove(){V.set(`allowMouseEnter`,!0)}},be);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=H,e},[V,Ne.reference,Ie,ke.reference,be,H]),Re=Y.useMemo(()=>{let e=ue(je.trigger,ke.trigger,be);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[je.trigger,ke.trigger,be]);d(()=>(V.update({inactiveTriggerProps:Re}),null)),Cb(V,{floatingRootContext:Te,activeTriggerProps:Le,inactiveTriggerProps:Re,popupProps:Y.useMemo(()=>ue(mb,{onMouseMove(){V.set(`allowMouseEnter`,!0),se.type===`menu`&&V.set(`hoverEnabled`,!1)},onClick(){V.select(`hoverEnabled`)&&V.set(`hoverEnabled`,!1)},onKeyDown(e){let t=V.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Ne.floating,je.floating,ke.floating),[se.type,V,Ne.floating,je.floating,ke.floating]),itemProps:je.item??z});let ze=Y.useMemo(()=>({store:V,parent:A,orientation:u,loopFocus:l,allowEscape:S,defaultFloatingId:M,setRenderedFloatingId:P,virtualFocus:b,parentVirtualFocus:k,syncHighlightedItem:Fe}),[V,A,u,l,S,M,b,k,Fe]),Be=typeof t==`function`?t({payload:de}):t,Ve=(0,X.jsxs)(vT.Provider,{value:ze,children:[h&&(0,X.jsx)(hb,{handle:h,store:V}),Be]});return(se.type===void 0||se.type===`context-menu`)&&(Ve=(0,X.jsx)(Gy,{externalTree:te,children:Ve})),Ve});function lE(e){let t=Y.useContext(aE);if(t===null)return(0,X.jsx)(cE,{...e});let n=t.Root;return(0,X.jsx)(aE.Provider,{value:null,children:(0,X.jsx)(n,{...t.options,...e})})}function uE(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=E(),{ref:i,index:a}=Kw(e),o=n===a,s=Y.useRef(null),c=fe(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 dE(e){let{render:t,className:n,style:r,state:i=z,props:a=B,refs:o=B,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=uE({metadata:s});return H(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function fE(e){if(l(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!k(e))return fE(g(e))}function pE(e,t){function n(n,r,i){let a=n.currentTarget;Wm.flushSync(()=>{e.setOpen(!1,$(ty,n.nativeEvent,a))}),Lv(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&&Rv(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function mE(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=Y.useRef(!1);return Y.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,Ra(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:z,[t,n,r])}var hE=dg(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:d=0,handle:p,payload:m,...h}=e,g=yT(!0),_=Pb(p)??g?.store;if(!_)throw Error(u(85));let v=iC(s),y=_.useState(`isTriggerActive`,v),b=_.useState(`floatingRootContext`),x=_.useState(`isOpenedByTrigger`,v),S=_.useState(`triggerControlsId`,v),C=Y.useRef(null),w=_E(),T=E(!0),D=Hy(),O=Y.useMemo(()=>D??new Ry,[D]),{registerTrigger:k,isMountedByThisTrigger:A}=bb(v,C,_,{payload:m,closeDelay:d,parent:w,floatingTreeRoot:O,floatingNodeId:Uy(O),floatingParentNodeId:Vy(),keyboardEventRelay:T?.relayKeyboardEvent}),j=w.type===`menubar`,M=_.useState(`disabled`),N=a||M||j&&w.context.disabled,{getButtonProps:P,buttonRef:F}=I({disabled:N,native:o});Y.useEffect(()=>{!x&&w.type===void 0&&(_.context.allowMouseUpTriggerRef.current=!1)},[_,x,w.type]);let L=Y.useRef(null),R=Tg(),ee=f(e=>{if(!L.current)return;R.clear(),_.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Q(L.current,t)||Q(_.select(`positionerElement`),t)||t===L.current||t!=null&&fE(t)===_.select(`rootId`)||jC(e,L.current)||O.events.emit(`close`,{domEvent:e,reason:oy})});Y.useEffect(()=>{let e=Ra(L.current);if(x&&_.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,ee,{once:!0}),()=>{e.removeEventListener(`mouseup`,ee)}},[x,ee,_]);let B=j&&w.context.hasSubmenuOpen,V=Xb(b,{enabled:(c??B)&&!N&&(!j||B&&!A),handleClose:fx({blockPointerEvents:!j}),mouseOnly:!0,move:!1,restMs:w.type===void 0?l:void 0,delay:{close:d},triggerElementRef:C,externalTree:O,isActiveTrigger:y,isClosing:()=>_.select(`transitionStatus`)===`ending`}),te=gE(x,_.select(`lastOpenChangeReason`)),ne=nb(b,{enabled:!N,event:x&&j?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:w.type===void 0&&te}),re=Lb(b,{enabled:!N&&B}),ie=mE({open:x,enabled:j,mouseDownAction:`open`}),ae=Y.useMemo(()=>ue(re.reference,ne.reference),[re.reference,ne.reference]),U=_.useState(`triggerProps`,A),oe=_.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:se,handleFocusTargetFocus:ce}=pE(_,C),le={disabled:N,open:x},de=[L,t,F,k,C],fe=[ae,V??z,U,{"aria-haspopup":`menu`,"aria-controls":S,id:v,onMouseDown:e=>{_.select(`open`)||(R.start(200,()=>{_.context.allowMouseUpTriggerRef.current=!0}),Ra(e.currentTarget).addEventListener(`mouseup`,ee,{once:!0}))}},oe,j?{role:`menuitem`}:{},ie,h,P],pe=H(`button`,e,{enabled:!j,stateAttributesMapping:__,state:le,ref:de,props:fe});return j?(0,X.jsx)(dE,{tag:`button`,render:n,className:r,style:i,state:le,refs:de,props:fe,stateAttributesMapping:__}):x?(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsx)(Gg,{ref:_.context.beforeTriggerFocusGuardRef,onFocus:se},`${v}-pre-focus-guard`),(0,X.jsx)(Y.Fragment,{children:pe},v),(0,X.jsx)(Gg,{ref:_.context.triggerFocusTargetRef,onFocus:ce},`${v}-post-focus-guard`)]}):(0,X.jsx)(Y.Fragment,{children:pe},v)});function gE(e,t){let n=Tg(),[r,i]=Y.useState(!1);return D(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function _E(){let e=eE(!0);return Y.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var vE=Y.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,...p}=e,{state:m,name:h,disabled:g,setTouched:_,setDirty:v,validityData:y,setFilled:b,validationMode:x,validation:S}=eC(),{clearErrors:C,elementRef:w,submitCountRef:T}=rC(),E=g||s,O=h??a,k={...m,disabled:E},{labelId:A}=oC(),j=sC({id:i}),M=o!==void 0,N=o==null?void 0:String(o),P=f(()=>S.inputRef.current?.value);tC(S.inputRef,j,N,P,!E,a),D(()=>{let e=N??S.inputRef.current?.value;e!==void 0&&b(e!==``)},[N,l,S.inputRef,b]),hC(N,()=>{N!==void 0&&(C(O),v(N!==(y.initialValue??``)),S.change(N))});let F=Y.useRef(null),I=kC(E,F),L=Tg();return H(`input`,e,{ref:[t,F],state:k,props:[{id:j,disabled:E,name:O,ref:S.inputRef,"aria-labelledby":A,autoFocus:u,...M?{value:o}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=$(Wv,e.nativeEvent);c?.(t,n),!M&&(v(t!==(y.initialValue??``)),b(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(C(O),S.change(t)))},onFocus(){I(!0)},onBlur(e){if(_(!0),I(!1),x===`onBlur`){let t=e.currentTarget.value;S.commit(t),M&&queueMicrotask(()=>{let e=S.inputRef.current?.value;e!==void 0&&e!==t&&e!==(y.initialValue??``)&&S.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){_(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===w.current&&!e.defaultPrevented){let t=e.currentTarget,n=T.current;L.start(0,()=>{T.current===n&&S.commit(t.value)})}else S.commit(t)}}},p,e=>S.getValidationProps(E,e)],stateAttributesMapping:ZS})}),yE=Y.forwardRef(function(e,t){return(0,X.jsx)(vE,{ref:t,...e})});function bE(e){let t=(0,La.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=_(`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,X.jsx)(yE,{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 xE(e){let t=(0,La.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=_(`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,X.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 SE=M(`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 CE(e){let t=(0,La.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=_(SE({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,X.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":a,className:o,onClick:wE,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function wE(e){e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()}var TE=M(`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 EE(e){let t=(0,La.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=_(TE({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,X.jsx)(R,{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 DE(e){let t=(0,La.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=_(`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,X.jsx)(bE,{"data-slot":`input-group-control`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function OE(e){let t=(0,La.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=_(`[&_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,X.jsx)(Ca,{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,X.jsxs)(RC,{"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 kE(e){let t=(0,La.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,X.jsx)(EE,{variant:`ghost`,size:`icon-xs`}),t[3]=i):i=t[3];let a;t[4]===n?a=t[5]:(a=_(n),t[4]=n,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,X.jsx)(Na,{className:`pointer-events-none`}),t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==a?(s=(0,X.jsx)(KC,{"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 AE(e){let t=(0,La.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=_(`w-auto`,r),t[7]=r,t[8]=d);let f;t[9]===c?f=t[10]:(f=(0,X.jsx)(DE,{disabled:c}),t[9]=c,t[10]=f);let p;t[11]!==i||t[12]!==f?(p=(0,X.jsx)(WC,{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,X.jsx)(EE,{size:`icon-xs`,variant:`ghost`,render:(0,X.jsx)(OE,{}),"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,X.jsx)(kE,{disabled:c}),t[17]=c,t[18]=u,t[19]=h):h=t[19];let g;t[20]!==m||t[21]!==h?(g=(0,X.jsxs)(CE,{align:`inline-end`,children:[m,h]}),t[20]=m,t[21]=h,t[22]=g):g=t[22];let v;return t[23]!==n||t[24]!==d||t[25]!==p||t[26]!==g?(v=(0,X.jsxs)(xE,{className:d,children:[p,g,n]}),t[23]=n,t[24]=d,t[25]=p,t[26]=g,t[27]=v):v=t[27],v}function jE(e){let t=(0,La.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=_(`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,X.jsx)(Gw,{"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,X.jsx)(cw,{children:(0,X.jsx)(Uw,{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 ME(e){let t=(0,La.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=_(`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,X.jsx)(aw,{"data-slot":`combobox-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function NE(e){let t=(0,La.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=_(`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,X.jsx)(pT,{render:(0,X.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`}),children:(0,X.jsx)(xa,{className:`pointer-events-none`})}),t[6]=o):o=t[6];let s;return t[7]!==n||t[8]!==i||t[9]!==a?(s=(0,X.jsxs)($w,{"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 PE(e){let t=(0,La.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,X.jsx)(lE,{"data-slot":`dropdown-menu`,...n}),t[2]=n,t[3]=r),r}function FE(e){let t=(0,La.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,X.jsx)(hE,{"data-slot":`dropdown-menu-trigger`,...n}),t[2]=n,t[3]=r),r}function IE(e){let t=(0,La.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=_(`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,X.jsx)(qT,{"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,X.jsx)(XT,{children:(0,X.jsx)(QT,{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 LE(e){let t=(0,La.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,X.jsx)(MT,{"data-slot":`dropdown-menu-group`,...n}),t[2]=n,t[3]=r),r}function RE(e){let t=(0,La.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=_(`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,X.jsx)(NT,{"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 zE(e){let t=(0,La.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=_(`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,X.jsx)(FT,{"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 BE(e){let t=(0,La.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=_(`-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,X.jsx)(Km,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function VE(e){let t=(0,La.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=_(`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,X.jsx)(`kbd`,{"data-slot":`kbd`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var HE=ta({id:W,name:W,signOut:Ui}),UE=Be(pt).atom(mn(kn(`/auth/user`),In(wn),In(Pn(HE)))),WE=Xt(ke(``));function GE(){return Mn(Ln(Yh(WE)))}function KE(){let e=(0,La.c)(27),t=Yh(UE);if(!pn(t))return null;let n;e[0]===t.value.id?n=e[1]:(n=Sn(`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,X.jsx)(uT,{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=Dn(gt(0,1)(t.value.name)),e[5]=t.value.name,e[6]=a);let o;e[7]===a?o=e[8]:(o=(0,X.jsx)(dT,{children:a}),e[7]=a,e[8]=o);let s;e[9]!==i||e[10]!==o?(s=(0,X.jsx)(FE,{"aria-label":`Account`,children:(0,X.jsxs)(lT,{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,X.jsx)(LE,{children:(0,X.jsxs)(RE,{children:[`@`,t.value.name]})}),e[12]=t.value.name,e[13]=c);let l;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(BE,{}),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,X.jsx)(`a`,{"aria-label":`Sign out`,href:f}),e[16]=f,e[17]=p);let m;e[18]!==p||e[19]!==u?(m=(0,X.jsx)(zE,{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,X.jsxs)(IE,{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,X.jsxs)(PE,{children:[s,h]}),e[24]=h,e[25]=s,e[26]=g):g=e[26],g}function qE(e){let t=(0,La.c)(66),[n,r]=Qh(WE),[i,a]=(0,Y.useState)(!1),o;t[0]===n?o=t[1]:(o=()=>n!==``,t[0]=n,t[1]=o);let[s,c]=(0,Y.useState)(o),l=(0,Y.useRef)(null),u=(0,Y.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,Y.useEffect)(d,f);let p,m,h,g,v,y,b,x,S,C,w;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=>_a(Mn(Ln(n)))(Mn(e.label)),t[21]=n,t[22]=a),m=lt(e.commands,a);let o,d;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{(0,Wm.flushSync)(()=>c(!0)),l.current?.focus()},d=(0,X.jsx)(ka,{}),t[23]=o,t[24]=d):(o=t[23],d=t[24]),t[25]===e.label?g=t[26]:(g=(0,X.jsx)(R,{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),w=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=_(`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=TC,v=m,y=null,b=JE,x=n,t[29]===r?S=t[30]:(S=(e,t)=>{t.reason!==`item-press`&&r(e)},t[29]=r,t[30]=S),C=i&&fr(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]=v,t[15]=y,t[16]=b,t[17]=x,t[18]=S,t[19]=C,t[20]=w}else p=t[10],m=t[11],h=t[12],g=t[13],v=t[14],y=t[15],b=t[16],x=t[17],S=t[18],C=t[19],w=t[20];let T=n!==``,E;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>a(!0),t[31]=E):E=t[31];let D;t[32]!==m||t[33]!==i||t[34]!==r?(D=e=>{e.key!==`Escape`||i&&fr(m)||(r(``),c(!1),e.currentTarget.blur())},t[32]=m,t[33]=i,t[34]=r,t[35]=D):D=t[35];let O;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,X.jsx)(CE,{children:(0,X.jsx)(ka,{})}),t[36]=O):O=t[36];let k;t[37]===n?k=t[38]:(k=n===``&&(0,X.jsx)(CE,{align:`inline-end`,className:`max-sm:hidden`,children:(0,X.jsx)(VE,{children:`⌘K`})}),t[37]=n,t[38]=k);let A;t[39]!==e.label||t[40]!==T||t[41]!==D||t[42]!==k?(A=(0,X.jsxs)(AE,{ref:l,"aria-label":e.label,placeholder:`Search or run a command`,showTrigger:!1,showClear:T,className:`w-full`,onFocus:E,onKeyDown:D,children:[O,k]}),t[39]=e.label,t[40]=T,t[41]=D,t[42]=k,t[43]=A):A=t[43];let j;t[44]===r?j=t[45]:(j=(0,X.jsx)(jE,{anchor:u,children:(0,X.jsx)(ME,{children:e=>(0,X.jsxs)(NE,{value:e,onClick:()=>{r(``),c(!1),e.run()},children:[e.icon,e.label]},e.label)})}),t[44]=r,t[45]=j);let M;t[46]!==p||t[47]!==A||t[48]!==j||t[49]!==v||t[50]!==y||t[51]!==b||t[52]!==x||t[53]!==S||t[54]!==C?(M=(0,X.jsxs)(p,{items:v,filter:y,itemToStringValue:b,value:x,onValueChange:S,open:C,onOpenChange:a,autoHighlight:!0,children:[A,j]}),t[46]=p,t[47]=A,t[48]=j,t[49]=v,t[50]=y,t[51]=b,t[52]=x,t[53]=S,t[54]=C,t[55]=M):M=t[55];let N;t[56]===r?N=t[57]:(N=(0,X.jsx)(R,{variant:`ghost`,size:`sm`,className:`sm:hidden`,onClick:()=>{r(``),c(!1)},children:`Cancel`}),t[56]=r,t[57]=N);let P;t[58]!==h||t[59]!==M||t[60]!==N||t[61]!==w?(P=(0,X.jsxs)(`div`,{ref:w,className:h,children:[M,N]}),t[58]=h,t[59]=M,t[60]=N,t[61]=w,t[62]=P):P=t[62];let F;return t[63]!==g||t[64]!==P?(F=(0,X.jsxs)(X.Fragment,{children:[g,P]}),t[63]=g,t[64]=P,t[65]=F):F=t[65],F}function JE(e){return e.label}function YE(e){let t=(0,La.c)(11),n;t[0]===e.active?n=t[1]:(n=tt(e.active,{onFalse:$E,onTrue:QE}),t[0]=e.active,t[1]=n);let r=e.children,i;t[2]===e.active?i=t[3]:(i=ee({variant:tt(e.active,{onFalse:ZE,onTrue:XE})}),t[2]=e.active,t[3]=i);let a;t[4]!==e.children||t[5]!==n||t[6]!==i?(a={"aria-current":n,children:r,className:i},t[4]=e.children,t[5]=n,t[6]=i,t[7]=a):a=t[7];let o;return t[8]!==e.render||t[9]!==a?(o={props:a,render:e.render},t[8]=e.render,t[9]=a,t[10]=o):o=t[10],eT(o)}function XE(){return`secondary`}function ZE(){return`ghost`}function QE(){return`page`}function $E(){}function eD(e){let t=(0,La.c)(25),n;t[0]===e.icon?n=t[1]:(n=(0,X.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,X.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,X.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,X.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,X.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,X.jsx)(qE,{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,X.jsx)(KE,{}),t[14]=e.account,t[15]=c);let l;t[16]!==e.action||t[17]!==c?(l=(0,X.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,X.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 tD(e){let t=(0,La.c)(5),n=e.className,r;t[0]===e.result?r=t[1]:(r=Zn(Ae(Ue(e.result),nD)),t[0]=e.result,t[1]=r);let i;return t[2]!==e.className||t[3]!==r?(i=(0,X.jsx)(Ym,{className:n,children:r}),t[2]=e.className,t[3]=r,t[4]=i):i=t[4],i}function nD(e){return e.message}var rD=M(`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 iD(e){let t=(0,La.c)(6),n;t[0]!==e.className||t[1]!==e.status||t[2]!==e.waiting?(n=_(rD({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,X.jsx)(`span`,{"data-slot":`status-dot`,"aria-hidden":`true`,className:n}),t[4]=n,t[5]=r),r}function aD(e){let t=(0,La.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=_(`w-full caption-bottom text-xs`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,X.jsx)(`table`,{"data-slot":`table`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function oD(e){let t=(0,La.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=_(`[&_tr]:border-b`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`thead`,{"data-slot":`table-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function sD(e){let t=(0,La.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=_(`[&_tr:last-child]:border-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`tbody`,{"data-slot":`table-body`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function cD(e){let t=(0,La.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=_(`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,X.jsx)(`tr`,{"data-slot":`table-row`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function lD(e){let t=(0,La.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=_(`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,X.jsx)(`th`,{"data-slot":`table-head`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function uD(e){let t=(0,La.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=_(`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,X.jsx)(`td`,{"data-slot":`table-cell`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var dD=`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`,fD=`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`,pD=`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`,mD=`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`,hD=`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`,gD=`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`,_D=`/assets/firefox-5m8yovBp.svg`,vD=`/assets/safari-DgmPRf57.svg`,yD=Bp,bD=Hp,xD=Wp,SD=`https://auth.mp281x.xyz`;pi(Ni(Yn(`AUTH_URL`)),ra),Ee()(`@deslop/runtime/auth/lib/utils/CurrentUser`);var CD=class e extends Jr()(`@deslop/runtime/auth/lib/utils/RpcAuth`,{error:V}){static layerClient=t=>Ri(e,e=>ci(function*(){return yield*e.next({...e.request,headers:Fr(e.request.headers,`authorization`,`Bearer ${yield*t}`)})}))},wD=ta({name:Yi,open:Yi,origin:U}),TD=$r(wD);ta({origin:U});var ED=Er([`Admin`,`Member`,`Waiting`]),DD=ta({...re.fields,fullName:vn(W),role:ED}),OD=ta({...DD.fields,since:xr}),kD=Er([`Waiting`,`Allowed`]),AD=ta({fullName:W,id:Yi,name:Yi,since:xr,status:kD});$r(AD),ta({id:vi,login:Yi,name:vn(pa(W))});var jD=ta({allow:Ui,id:Yi}),MD=ta({id:Yi}),ND=ta({client_name:vn(W.check(Bt(100))),redirect_uris:Un(Yi.check(Bt(200))).check(Bt(4)),token_endpoint_auth_method:vn(Mr(`none`))});ta({name:W,redirects:ND.fields.redirect_uris}),ta({client_id:Yi.check(Bt(2048)),redirect_uri:vn(W),state:vn(W)}),ta({code_challenge:vn(Yi),code_challenge_method:vn(W),resource:vn(or(W)),response_type:vn(W),scope:vn(W)});var PD=ta({challenge:Yi,clientId:Yi,clientName:W,redirectUri:Yi,resources:Un(F),state:vn(Yi)});ta({grant_type:W});var FD=vn(or(F).check(qe(1)));Ft([ta({client_id:Yi,code:Yi,code_verifier:Yi,grant_type:Mr(`authorization_code`),redirect_uri:vn(W),resource:FD}),ta({client_id:vn(W),grant_type:Mr(`refresh_token`),refresh_token:Yi,resource:FD})]);var ID=ta({access_token:Yi,expires_in:xr,refresh_token:Yi,scope:Mr(`deslop`),token_type:Mr(`Bearer`)});ze({Granted:{tokens:ID},Replayed:{message:W}});var LD=ta({address:vn(W),userAgent:vn(W)}),RD=ta({expiresAt:xr,hash:W,resources:$r(F)}),zD=ta({client:W,createdAt:xr,credential:ze({App:{access:$r(RD),clientId:Yi,expiresAt:xr,generation:vi,hash:W,replaced:vn(W),resources:$r(F)},Browser:{expiresAt:xr,hash:W}}),device:W,lastActive:xr,origin:LD,user:re});sa(W,zD);var BD=ta({address:vn(W),client:W,device:W,family:Yi,kind:Er([`App`,`Browser`]),lastActive:xr,resources:$r(F)}),VD=ta({family:Yi});ta({client_id:Yi,token:Yi}),ta({resource:F});var HD=Er([`App`,`Browser`]),UD=ta({address:vn(W),clientName:W,createdAt:xr,device:W,expiresAt:xr,id:Yi,kind:HD,resources:$r(F)}),WD=ze({Decided:{},Expired:{},Waiting:{request:UD}}),GD=ze({Browser:{next:vn(W)},Client:{request:PD}});ze({Redirect:{url:Yi},Session:{next:vn(W),seconds:vi,token:Yi},Waiting:{}}),ta({delivery:GD,origin:LD}),ta({next:vn(Yi.check(Bt(2048)))});var KD=ta({request:Yi.check(Bt(20))}),qD=ta({code:Yi.check(Bt(20))}),JD=ta({...KD.fields,accept:Ui}),YD=class extends sr(Dr(`auth.lookup`,{error:V,payload:qD,stream:!0,success:tr(UD)}),Dr(`auth.answer`,{error:V,payload:JD}),Dr(`auth.people`,{error:V,stream:!0,success:$r(OD)}),Dr(`auth.admit`,{error:V,payload:jD,success:OD}),Dr(`auth.remove`,{error:V,payload:MD,success:OD}),Dr(`auth.apps`,{error:V,stream:!0,success:$r(BD)}),Dr(`auth.catalog`,{error:V,stream:!0,success:TD}),Dr(`auth.disconnect`,{error:V,payload:VD})).middleware(CD).merge(sr(Dr(`auth.account`,{error:V,stream:!0,success:DD}),Dr(`auth.wait`,{error:V,payload:KD,stream:!0,success:WD}))){};function XD(e){return Dn(Ze(/[^a-z]/giu,``)(e))}t(((e,t,n)=>{(function(e){let n=`(0?\\d+|0x[a-f0-9]+)`,r={fourOctet:RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,`i`),threeOctet:RegExp(`^${n}\\.${n}\\.${n}$`,`i`),twoOctet:RegExp(`^${n}\\.${n}$`,`i`),longValue:RegExp(`^${n}$`,`i`)},i=RegExp(`^0[0-7]+$`,`i`),a=RegExp(`^0x[a-f0-9]+$`,`i`),o=`%[0-9a-z]{1,}`,s=`(?:[0-9a-f]+::?)+`,c={zoneIndex:RegExp(o,`i`),native:RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,`i`),deprecatedTransitional:RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,`i`),transitional:RegExp(`^((?:${s})|(?:::)(?:${s})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,`i`)};function l(e,t){if(e.indexOf(`::`)!==e.lastIndexOf(`::`))return null;let n=0,r=-1,i=(e.match(c.zoneIndex)||[])[0],a,o;for(i&&(i=i.substring(1),e=e.replace(/%.+$/,``));(r=e.indexOf(`:`,r+1))>=0;)n++;if(e.substr(0,2)===`::`&&n--,e.substr(-2,2)===`::`&&n--,n>=t)return null;for(o=t-n,a=`:`;o--;)a+=`0:`;return e=e.replace(`::`,a),e[0]===`:`&&(e=e.slice(1)),e[e.length-1]===`:`&&(e=e.slice(0,-1)),t=(function(){let t=e.split(`:`),n=[];for(let e=0;e<t.length;e++)n.push(t[e].length>4?NaN:parseInt(t[e],16));return n})(),{parts:t,zoneId:i}}function u(e,t,n,r){if(e.length!==t.length)throw Error(`ipaddr: cannot match CIDR for objects with different lengths`);let i=0,a;for(;r>0;){if(a=n-r,a<0&&(a=0),e[i]>>a!==t[i]>>a)return!1;r-=n,i+=1}return!0}function d(e){if(a.test(e))return parseInt(e,16);if(e[0]===`0`&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function f(e,t){for(;e.length<t;)e=`0${e}`;return e}let p={};p.IPv4=(function(){function e(e){if(e.length!==4)throw Error(`ipaddr: ipv4 octet count should be 4`);let t,n;for(t=0;t<e.length;t++)if(n=e[t],!(0<=n&&n<=255))throw Error(`ipaddr: ipv4 octet should fit in 8 bits`);this.octets=e}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]],as112:[[new e([192,175,48,0]),24],[new e([192,31,196,0]),24]],amt:[[new e([192,52,193,0]),24]]},e.prototype.kind=function(){return`ipv4`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv4`)throw Error(`ipaddr: cannot match ipv4 address with non-ipv4 one`);return u(this.octets,e.octets,8,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},r,i,a;for(r=3;r>=0;--r)if(i=this.octets[r],i in n){if(a=n[i],t&&a!==0)return null;a!==8&&(t=!0),e+=a}else return null;return 32-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(`.`)},e})(),p.IPv4.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<4;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.isIPv4=function(e){return this.parser(e)!==null},p.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch{return!1}},p.IPv4.isValidCIDR=function(e){try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(e){return!!(p.IPv4.isValid(e)&&e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.isValidCIDRFourPartDecimal=function(e){let t=e.match(/^(.+)\/(\d+)$/);return!p.IPv4.isValidCIDR(e)||!t?!1:p.IPv4.isValidFourPartDecimal(t[1])},p.IPv4.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv4 Address`);return new this(t)},p.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){let e=parseInt(t[2]);if(e>=0&&e<=32){let n=[this.parse(t[1]),e];return Object.defineProperty(n,"toString",{value:function(){return this.join(`/`)}}),n}}throw Error(`ipaddr: string is not formatted like an IPv4 CIDR range`)},p.IPv4.parser=function(e){let t,n,i;if(t=e.match(r.fourOctet))return(function(){let e=t.slice(1,6),r=[];for(let t=0;t<e.length;t++)n=e[t],r.push(d(n));return r})();if(t=e.match(r.longValue)){if(i=d(t[1]),i>4294967295||i<0)throw Error(`ipaddr: address outside defined range`);return(function(){let e=[],t=0;for(;t<=24;t+=8)e.push(i>>t&255);return e})().reverse()}return(t=e.match(r.twoOctet))?(function(){let e=t.slice(1,4),n=[];if(i=d(e[1]),i>16777215||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(i>>16&255),n.push(i>>8&255),n.push(i&255),n})():(t=e.match(r.threeOctet))?(function(){let e=t.slice(1,5),n=[];if(i=d(e[2]),i>65535||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(d(e[1])),n.push(i>>8&255),n.push(i&255),n})():null},p.IPv4.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>32)throw Error(`ipaddr: invalid IPv4 prefix length`);let t=[0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<4&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.IPv6=(function(){function e(e,t){let n,r;if(e.length===16)for(this.parts=[],n=0;n<=14;n+=2)this.parts.push(e[n]<<8|e[n+1]);else if(e.length===8)this.parts=e;else throw Error(`ipaddr: ipv6 part count should be 8 or 16`);for(n=0;n<this.parts.length;n++)if(r=this.parts[n],!(0<=r&&r<=65535))throw Error(`ipaddr: ipv6 part should fit in 16 bits`);t&&(this.zoneId=t)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],deprecatedSiteLocal:[new e([65216,0,0,0,0,0,0,0]),10],discard:[new e([256,0,0,0,0,0,0,0]),64],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[[new e([100,65435,0,0,0,0,0,0]),96],[new e([100,65435,1,0,0,0,0,0]),48]],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[[new e([8193,4,274,0,0,0,0,0]),48],[new e([9760,79,32768,0,0,0,0,0]),48]],deprecatedOrchid:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new e([8193,48,0,0,0,0,0,0]),28],segmentRouting:[new e([24320,0,0,0,0,0,0,0]),16],reserved:[[new e([8193,0,0,0,0,0,0,0]),23],[new e([8193,3512,0,0,0,0,0,0]),32],[new e([16383,0,0,0,0,0,0,0]),20]]},e.prototype.isIPv4MappedAddress=function(){return this.range()===`ipv4Mapped`},e.prototype.kind=function(){return`ipv6`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv6`)throw Error(`ipaddr: cannot match ipv6 address with non-ipv6 one`);return u(this.parts,e.parts,16,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},r,i;for(let a=7;a>=0;--a)if(r=this.parts[a],r in n){if(i=n[r],t&&i!==0)return null;i!==16&&(t=!0),e+=i}else return null;return 128-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e,t=[],n=this.parts;for(let r=0;r<n.length;r++)e=n[r],t.push(e>>8),t.push(e&255);return t},e.prototype.toFixedLengthString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(f(this.parts[t].toString(16),4));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw Error(`ipaddr: trying to convert a generic ipv6 address to ipv4`);let e=this.parts.slice(-2),t=e[0],n=e[1];return new p.IPv4([t>>8,t&255,n>>8,n&255])},e.prototype.toNormalizedString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(this.parts[t].toString(16));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toRFC5952String=function(){let e=/((^|:)(0(:|$)){2,})/g,t=``;this.zoneId&&(t=`%${this.zoneId}`);let n=this.toNormalizedString(),r=n.slice(0,n.length-t.length),i=0,a=-1,o=-1,s;for(;s=e.exec(r);){let e=(s[0].match(/0/g)||[]).length;e>o&&(o=e,i=s.index,a=s[0].length)}return a<0?r+t:`${r.substring(0,i)}::${r.substring(i+a)}${t}`},e.prototype.toString=function(){return this.toRFC5952String()},e})(),p.IPv6.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<16;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.isIPv6=function(e){return this.parser(e)!==null},p.IPv6.isValid=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{let t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch{return!1}},p.IPv6.isValidCIDR=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<16;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv6 Address`);return new this(t.parts,t.zoneId)},p.IPv6.parseCIDR=function(e){let t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=128))return r=[this.parse(n[1]),t],Object.defineProperty(r,"toString",{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv6 CIDR range`)},p.IPv6.parser=function(e){let t,n,r,i,a,o;if(r=e.match(c.deprecatedTransitional))return this.parser(`::ffff:${r[1]}`);if(c.native.test(e))return l(e,8);if((r=e.match(c.transitional))&&(o=r[6]||``,t=r[1],r[1].endsWith(`::`)||(t=t.slice(0,-1)),t=l(t+o,6),t&&t.parts)){for(a=[parseInt(r[2]),parseInt(r[3]),parseInt(r[4]),parseInt(r[5])],n=0;n<a.length;n++)if(i=a[n],!(0<=i&&i<=255))return null;return t.parts.push(a[0]<<8|a[1]),t.parts.push(a[2]<<8|a[3]),{parts:t.parts,zoneId:t.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>128)throw Error(`ipaddr: invalid IPv6 prefix length`);let t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<16&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.fromByteArray=function(e){let t=e.length;if(t===4)return new p.IPv4(e);if(t===16)return new p.IPv6(e);throw Error(`ipaddr: the binary input is neither an IPv6 nor IPv4 address`)},p.isValid=function(e){return p.IPv6.isValid(e)||p.IPv4.isValid(e)},p.isValidCIDR=function(e){return p.IPv6.isValidCIDR(e)||p.IPv4.isValidCIDR(e)},p.parse=function(e){if(p.IPv6.isValid(e))return p.IPv6.parse(e);if(p.IPv4.isValid(e))return p.IPv4.parse(e);throw Error(`ipaddr: the address has neither IPv6 nor IPv4 format`)},p.parseCIDR=function(e){try{return p.IPv6.parseCIDR(e)}catch{try{return p.IPv4.parseCIDR(e)}catch(e){throw Error(`ipaddr: the address has neither IPv6 nor IPv4 CIDR format`,{cause:e})}}},p.process=function(e){let t=this.parse(e);return t.kind()===`ipv6`&&t.isIPv4MappedAddress()?t.toIPv4Address():t},p.subnetMatch=function(e,t,n){let r,i,a,o;for(i in n??=`unicast`,t)if(Object.prototype.hasOwnProperty.call(t,i)){for(a=t[i],a[0]&&!(a[0]instanceof Array)&&(a=[a]),r=0;r<a.length;r++)if(o=a[r],e.kind()===o[0].kind()&&e.match.apply(e,o))return i}return n},t!==void 0&&t.exports?t.exports=p:e.ipaddr=p})(n)}))();function ZD(e){return Or(Gi(e),_n)}Ut(function*(e,t,n){if(ra(ZD(n.response_type)))return yield*V.make({message:`Send response_type=code`});if(n.response_type!==`code`)return yield*V.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*V.make({message:`Send a PKCE code_challenge with code_challenge_method=S256`});if(!bi(lt(Si(n.scope??``,` `),_n),e=>e===`deslop`||e===`offline_access`))return yield*V.make({error:`invalid_scope`,message:`Only the deslop scope is supported`});let r=yield*mn(Ce(Un(F))(n.resource??[]),fi(e=>V.make({cause:e,error:`invalid_target`,message:`Name a Deslop app with the resource parameter`})));return PD.make({challenge:n.code_challenge,clientId:e.client_id,clientName:t.clientName,redirectUri:t.redirectUri,resources:r,...Zi(ZD(e.state),{onNone:()=>({}),onSome:e=>({state:e})})})});function QD(e){return mn(new URL(e).hostname,Si(`.`),mt(1),Ti(`.`))}function $D(e,t){let n=QD(t);return mi(Vt(e),{onFailure:()=>!1,onSuccess:e=>e.protocol===`https:`&&(e.hostname===n||Jt(`.${n}`)(e.hostname))&&Oe(e.username)&&Oe(e.password)})}var eO=Be(pt),tO=class extends gr()(`@deslop/auth/lib/utils/RpcClient`,{group:YD,protocol:se(`@deslop/auth`)}){};function nO(e){return aa(e,e=>mn(e(zt(`1 second`)),Ke(e=>e.input._tag===`RpcClientError`)))}var rO=Xt(tO.runtime.atom(mn(tO,Jn(e=>e(`auth.account`,void 0)),Ve,nO,Vn(Fe),ir(`AuthError`,()=>wr(rn()))))),iO={accept:Ui,request:UD},aO=Vm(tO.runtime).make(bD({branches:{looked:{found:{target:`Code.Found`},missing:{target:`Code.Missing`}}},events:xD({Answered:iO,Typed:{typed:W}}),root:yD({states:{Code:{fields:{code:W},states:{Found:{fields:{request:UD}},Looking:{},Missing:{}}},Typing:{fields:{answered:vn(ta(iO)),typed:W}}}}),streams:{lookup:e=>nO(Ve(Jn(tO,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=>Zi(e.element,{onNone:()=>e.select.missing(),onSome:t=>e.select.found({data:{request:t}})})},onFailure:{target:`Code.Missing`},src:`lookup`},states:{Found:{},Looking:{},Missing:{}}},Typing:{always:{data:e=>({code:e.state.typed}),guard:e=>rt(e.state.typed)>=8,target:`Code`}}}})),oO=ke(e=>{e.set(aO.send,{_tag:`Typed`,typed:XD(new URLSearchParams(location.search).get(`code`)??``)})}),sO=Xt(tO.runtime.atom(mn(tO,Jn(e=>e(`auth.people`,void 0)),Ve,nO))),cO=Xt(tO.runtime.atom(mn(tO,Jn(e=>e(`auth.apps`,void 0)),Ve,nO))),lO=tO.runtime.fn(e=>In(tO,t=>ge(e,e=>t(`auth.disconnect`,{family:e}),{concurrency:`unbounded`,discard:!0}))),uO=tO.runtime.fn(e=>In(tO,t=>t(`auth.admit`,e))),dO=tO.runtime.fn(e=>In(tO,t=>t(`auth.remove`,{id:e}))),fO=zn(new URLSearchParams(location.search).get(`request`)),pO=ca(e=>tO.runtime.atom(mn(tO,Jn(t=>t(`auth.wait`,{request:e})),Ve,nO,$i(t=>mn(Oi(t),hr(`Decided`,()=>oa(()=>location.assign(`/auth/continue?${new URLSearchParams({request:e})}`))),me(()=>G))))));function mO(e){return`${gt(0,4)(e)}-${gt(4)(e)}`}function hO(e){return`${location.origin}/?code=${e}`}var gO=Xt(tO.runtime.atom(mn(tO,Jn(e=>e(`auth.catalog`,void 0)),Ve,nO)));function _O(e){return Fi(e)?[`browser`]:Ye(Pr(e,e=>new URL(e).origin))}function vO(e){return mn(ji(e),di({hour:`2-digit`,minute:`2-digit`}))}var yO=ke(mn(on(`1 minute`),qi(()=>an)));function bO(e,t){return Math.floor(ha(qn(ji(e),ji(t))))}function xO(e){return e<1?`now`:e<60?`${e}m`:e<1440?`${Math.floor(e/60)}h`:`${Math.floor(e/1440)}d`}function SO(e,t){return`${e} · ${t}`}function CO(e){return ki(e,0,(e,t)=>Wt(e,t.lastActive))}function wO(e){return mn(ji(e),di({day:`numeric`,month:`short`}))}function TO(e){return`https://avatars.githubusercontent.com/u/${Sn(`github:`,``)(e)}?s=96`}var EO=tO.runtime.fn((e,t)=>mn(tO,In(t=>t(`auth.answer`,{accept:e.accept,request:e.request.id})),J(oa(()=>t.set(aO.send,{_tag:`Answered`,...e}))))),DO=zn(new URLSearchParams(location.search).get(`next`)),OO=Xn(()=>Ne({catch:e=>V.make({cause:e,message:`Cannot start GitHub sign-in`}),try:()=>location.assign(`/auth/github${location.search}`)})),kO=Xn(()=>Ne({catch:e=>V.make({cause:e,message:`Cannot start the sign-in`}),try:()=>location.assign(Zi(DO,{onNone:()=>`/auth/code`,onSome:e=>`/auth/code?${new URLSearchParams({next:e})}`}))})),AO=new URLSearchParams(location.search).has(`sign-out`),jO=mn(zn(new URLSearchParams(location.search).get(`next`)),Or(e=>$D(e,SD)),la(()=>location.pathname)),MO=eO.fn(()=>mn(yi.use(e=>ct(e).post(`/auth/sign-out`)),J(oa(()=>location.replace(jO))),fi(e=>V.make({cause:e,message:`Cannot sign out`}))));function NO(e){let t=(0,La.c)(17),n,r,i,a,o,s;if(t[0]!==e.className||t[1]!==e.text){let c=Fn(Lh(e.text)),l=Math.sqrt(c.length);r=`-2 -2 ${l+4} ${l+4}`,i=`crispEdges`,a=`currentColor`,o=e.className,s=`true`,n=mn(c,Pr((e,t)=>({dark:e,x:t%l,y:Math.floor(t/l)})),lt(FO),Pr(PO),Ti(``)),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,X.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,X.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 PO(e){return`M${e.x} ${e.y}h1v1h-1z`}function FO(e){return e.dark===1}function IO(e){let t=(0,La.c)(12),n;t[0]===e.id?n=t[1]:(n=TO(e.id),t[0]=e.id,t[1]=n);let r;t[2]!==e.name||t[3]!==n?(r=(0,X.jsx)(uT,{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=Dn(gt(0,1)(e.name)),t[5]=e.name,t[6]=i);let a;t[7]===i?a=t[8]:(a=(0,X.jsx)(dT,{children:i}),t[7]=i,t[8]=a);let o;return t[9]!==r||t[10]!==a?(o=(0,X.jsxs)(lT,{size:`sm`,children:[r,a]}),t[9]=r,t[10]=a,t[11]=o):o=t[11],o}function LO(e){let t=(0,La.c)(11),[n,r]=(0,Y.useState)(`loading`),i;t[0]===e.small?i=t[1]:(i=_(`text-muted-foreground relative flex shrink-0 items-center justify-center`,tt(e.small===!0,{onFalse:zO,onTrue:RO})),t[0]=e.small,t[1]=i);let a;t[2]===n?a=t[3]:(a=n!==`loaded`&&(0,X.jsx)(ya,{className:`size-4`}),t[2]=n,t[3]=a);let o;t[4]!==e.origin||t[5]!==n?(o=n!==`failed`&&(0,X.jsx)(`img`,{src:`${e.origin}/icon`,alt:``,className:_(`pixelated absolute inset-0 size-full`,n===`loading`&&`invisible`),onLoad:()=>r(`loaded`),onError:()=>r(`failed`)}),t[4]=e.origin,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==i||t[8]!==a||t[9]!==o?(s=(0,X.jsxs)(`span`,{className:i,children:[a,o]}),t[7]=i,t[8]=a,t[9]=o,t[10]=s):s=t[10],s}function RO(){return`size-4`}function zO(){return`size-5`}var BO={Chrome:pD,Edge:gD,Firefox:_D,Safari:vD};function VO(e){return e.kind===`Browser`?Ae(zi(BO,e.name),e=>({mono:!1,src:e})):Zt(dn(/claude/iu)(e.name))?Fe({mono:!1,src:mD}):Zt(dn(/codex/iu)(e.name))?Fe({mono:!0,src:hD}):Zt(dn(/gateway/iu)(e.name))?rn():ln([`iPhone`,`iPad`],e.device)?Fe({mono:!0,src:fD}):e.device===`Android`?Fe({mono:!1,src:dD}):rn()}function HO(e){return Zi(VO(e.client),{onNone:()=>mn(Oi(e.client),Lr({kind:`Browser`},()=>(0,X.jsx)(Ta,{})),Lr(e=>Zt(dn(/gateway/iu)(e.name)),()=>(0,X.jsx)(Da,{})),me(()=>(0,X.jsx)(ja,{}))),onSome:e=>(0,X.jsx)(`img`,{src:e.src,alt:``,className:_(`size-3.5`,e.mono&&`dark:invert`)})})}function UO(e){return Zi(e.client.app,{onNone:()=>(0,X.jsx)(HO,{client:e.client}),onSome:e=>(0,X.jsx)(LO,{origin:e,small:!0})})}function WO(e){let t=(0,La.c)(34),[n,r]=to(lO),i;if(t[0]!==e.column.label||t[1]!==e.column.lastActive||t[2]!==e.column.pending||t[3]!==e.now){let n;t[5]!==e.column.label||t[6]!==e.column.lastActive||t[7]!==e.now?(n=()=>{let t=bO(e.column.lastActive,e.now);return`${e.column.label}, active ${tt(t<1,{onFalse:()=>`${xO(t)} ago`,onTrue:KO})}`},t[5]=e.column.label,t[6]=e.column.lastActive,t[7]=e.now,t[8]=n):n=t[8];let r;t[9]===e.column.label?r=t[10]:(r=()=>`${e.column.label}, waiting for an answer`,t[9]=e.column.label,t[10]=r),i=tt(e.column.pending,{onFalse:n,onTrue:r}),t[0]=e.column.label,t[1]=e.column.lastActive,t[2]=e.column.pending,t[3]=e.now,t[4]=i}else i=t[4];let a=i,o;if(t[11]!==r||t[12]!==n||t[13]!==a||t[14]!==e.column.client||t[15]!==e.column.families||t[16]!==e.column.pending){let i;t[18]!==r||t[19]!==n||t[20]!==a||t[21]!==e.column.client||t[22]!==e.column.families?(i=()=>(0,X.jsxs)(PE,{children:[(0,X.jsx)(FE,{render:(0,X.jsx)(R,{variant:`ghost`,size:`icon-sm`,title:a,"aria-label":a}),children:(0,X.jsx)(UO,{client:e.column.client})}),(0,X.jsxs)(IE,{align:`end`,className:`w-auto min-w-48`,children:[(0,X.jsx)(LE,{children:(0,X.jsx)(RE,{children:a})}),(0,X.jsx)(zE,{variant:`destructive`,disabled:$e(n),onClick:()=>r(e.column.families),children:`Sign out`})]})]}),t[18]=r,t[19]=n,t[20]=a,t[21]=e.column.client,t[22]=e.column.families,t[23]=i):i=t[23];let s;t[24]!==a||t[25]!==e.column.client?(s=()=>(0,X.jsx)(`span`,{title:a,"aria-label":a,role:`img`,className:`ring-primary flex size-7 items-center justify-center rounded-sm ring-1`,children:(0,X.jsx)(UO,{client:e.column.client})}),t[24]=a,t[25]=e.column.client,t[26]=s):s=t[26],o=tt(e.column.pending,{onFalse:i,onTrue:s}),t[11]=r,t[12]=n,t[13]=a,t[14]=e.column.client,t[15]=e.column.families,t[16]=e.column.pending,t[17]=o}else o=t[17];let s;t[27]!==e.column.client||t[28]!==e.column.labelled||t[29]!==e.labels?(s=e.labels&&tt(e.column.labelled,{onFalse:GO,onTrue:()=>(0,X.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground text-xs leading-none font-normal`,children:e.column.client.device})}),t[27]=e.column.client,t[28]=e.column.labelled,t[29]=e.labels,t[30]=s):s=t[30];let c;return t[31]!==o||t[32]!==s?(c=(0,X.jsx)(lD,{className:`px-0.5`,children:(0,X.jsxs)(`span`,{className:`flex flex-col items-center gap-0.5`,children:[o,s]})}),t[31]=o,t[32]=s,t[33]=c):c=t[33],c}function GO(){return(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-3`})}function KO(){return`now`}function qO(e,t,n){let r=_O(e);return ln(r,t)||ln(r,`browser`)&&n}function JO(e,t){return nr(e.resources,e=>qO(e,t.origin,t.web))}function YO(e){let t=(0,La.c)(21),n,r,i,a,o,s;if(t[0]!==e.column||t[1]!==e.row){let c=JO(e.column,e.row);n=uD,s=`w-7 px-0`,a=`flex justify-center`;let l;t[8]===e.column.pending?l=t[9]:(l=()=>(0,X.jsx)(iD,{waiting:e.column.pending}),t[8]=e.column.pending,t[9]=l),o=tt(c,{onFalse:$O,onTrue:l}),r=`sr-only`,i=mn(Oi({held:c,pending:e.column.pending}),Lr({held:!1},QO),Lr({pending:!0},ZO),me(XO)),t[0]=e.column,t[1]=e.row,t[2]=n,t[3]=r,t[4]=i,t[5]=a,t[6]=o,t[7]=s}else n=t[2],r=t[3],i=t[4],a=t[5],o=t[6],s=t[7];let c;t[10]!==r||t[11]!==i?(c=(0,X.jsx)(`span`,{className:r,children:i}),t[10]=r,t[11]=i,t[12]=c):c=t[12];let l;t[13]!==a||t[14]!==o||t[15]!==c?(l=(0,X.jsxs)(`span`,{className:a,children:[o,c]}),t[13]=a,t[14]=o,t[15]=c,t[16]=l):l=t[16];let u;return t[17]!==n||t[18]!==s||t[19]!==l?(u=(0,X.jsx)(n,{className:s,children:l}),t[17]=n,t[18]=s,t[19]=l,t[20]=u):u=t[20],u}function XO(){return`signed in`}function ZO(){return`asked for`}function QO(){return`not signed in`}function $O(){return(0,X.jsx)(iD,{status:`off`})}function ek(e){let t=(0,La.c)(42),[n,r]=to(EO),i;if(t[0]!==e.request.clientName||t[1]!==e.request.device||t[2]!==e.request.kind){let n,r;t[4]!==e.request.clientName||t[5]!==e.request.device?(n=()=>`${SO(e.request.clientName,e.request.device)} asks for the apps its column marks`,r=()=>`Signs in ${SO(e.request.clientName,e.request.device)} as you to every mp281x.xyz app for 30 days, including approving sign-ins`,t[4]=e.request.clientName,t[5]=e.request.device,t[6]=n,t[7]=r):(n=t[6],r=t[7]),i=tt(e.request.kind===`Browser`,{onFalse:n,onTrue:r}),t[0]=e.request.clientName,t[1]=e.request.device,t[2]=e.request.kind,t[3]=i}else i=t[3];let a;t[8]===e.request.address?a=t[9]:(a=Zi(Gi(e.request.address),{onNone:nk,onSome:tk}),t[8]=e.request.address,t[9]=a);let o;t[10]!==i||t[11]!==a?(o=(0,X.jsxs)(Jm,{children:[i,a,`. Approve only a code you started yourself.`]}),t[10]=i,t[11]=a,t[12]=o):o=t[12];let s;t[13]===n?s=t[14]:(s=(0,X.jsx)(tD,{result:n}),t[13]=n,t[14]=s);let c;t[15]!==e.request.clientName||t[16]!==e.request.device?(c=SO(e.request.clientName,e.request.device),t[15]=e.request.clientName,t[16]=e.request.device,t[17]=c):c=t[17];let l=`Approve ${c}`,u;t[18]===n?u=t[19]:(u=$e(n),t[18]=n,t[19]=u);let d;t[20]!==e.request||t[21]!==r?(d=()=>r({accept:!0,request:e.request}),t[20]=e.request,t[21]=r,t[22]=d):d=t[22];let f;t[23]!==l||t[24]!==u||t[25]!==d?(f=(0,X.jsx)(R,{size:`lg`,"aria-label":l,disabled:u,onClick:d,children:`Approve`}),t[23]=l,t[24]=u,t[25]=d,t[26]=f):f=t[26];let p;t[27]===n?p=t[28]:(p=$e(n),t[27]=n,t[28]=p);let m;t[29]!==e.request||t[30]!==r?(m=()=>r({accept:!1,request:e.request}),t[29]=e.request,t[30]=r,t[31]=m):m=t[31];let h;t[32]!==m||t[33]!==p?(h=(0,X.jsx)(R,{size:`lg`,variant:`outline`,disabled:p,onClick:m,children:`Deny`}),t[32]=m,t[33]=p,t[34]=h):h=t[34];let g;t[35]!==h||t[36]!==f?(g=(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[f,h]}),t[35]=h,t[36]=f,t[37]=g):g=t[37];let _;return t[38]!==g||t[39]!==o||t[40]!==s?(_=(0,X.jsxs)(X.Fragment,{children:[o,s,g]}),t[38]=g,t[39]=o,t[40]=s,t[41]=_):_=t[41],_}function tk(e){return` · from ${e}`}function nk(){return``}function rk(e){return la(e.app,()=>Zi(VO(e),{onNone:()=>`${e.kind}:${Zt(dn(/gateway/iu)(e.name))}`,onSome:e=>e.src}))}function ik(e,t,n){function r(e,t,r){return{app:Ae(An(n,t=>r===`App`&&Mn(t.name)===Mn(e)),e=>e.origin),device:t,kind:r,name:e}}let i=[...Zi(e,{onNone:()=>[],onSome:e=>[{client:r(e.clientName,e.device,e.kind),families:[],key:`pending`,label:SO(e.clientName,e.device),labelled:!1,lastActive:0,pending:!0,resources:[e.resources]}]}),...mn(Ht(t,e=>SO(e.client,e.device)),cr,lt(oi),Yr(ye(zr(Wr,CO))),Pr(e=>({client:r(e[0].client,e[0].device,e[0].kind),families:Pr(e,e=>e.family),key:SO(e[0].client,e[0].device),label:SO(e[0].client,e[0].device),labelled:!1,lastActive:CO(e),pending:!1,resources:Pr(e,e=>e.resources)})))];return Pr(i,e=>({...e,labelled:bn(i,t=>rk(t.client)===rk(e.client))>1}))}function ak(e){let t=(0,La.c)(26),n=ao(gO).value,r=ao(cO).value,i=ao(yO).value,[a]=to(lO),o=GE(),s;t[0]===o?s=t[1]:(s=function(e){return _a(o)(Mn(e))},t[0]=o,t[1]=s);let c=s,l,u,d,f;if(t[2]!==n||t[3]!==i||t[4]!==e.pending||t[5]!==c||t[6]!==r){let a;t[11]===c?a=t[12]:(a=e=>c(e.name),t[11]=c,t[12]=a);let o;t[13]!==n||t[14]!==c?(o=e=>e!==`browser`&&!nr(n,t=>t.origin===e)&&c(e),t[13]=n,t[14]=c,t[15]=o):o=t[15];let s=[...Pr(lt(n,a),mk),...mn([...Tn(r,pk),...Zi(e.pending,{onNone:fk,onSome:dk})],Ye,lt(o),Yr(st),Pr(uk))],p=lt(ik(e.pending,r,n),e=>e.pending||nr(s,t=>JO(e,t)));l=`flex flex-col gap-3`,u=`Apps`,t[16]===e.pending?d=t[17]:(d=Zi(e.pending,{onNone:lk,onSome:ck}),t[16]=e.pending,t[17]=d),f=Gn(s,{onEmpty:sk,onNonEmpty:()=>(0,X.jsxs)(aD,{"aria-label":`Apps and the clients signed in to them`,children:[(0,X.jsx)(oD,{children:(0,X.jsxs)(cD,{children:[(0,X.jsx)(lD,{children:(0,X.jsx)(`span`,{className:`sr-only`,children:`App`})}),Pr(p,e=>(0,X.jsx)(WO,{column:e,labels:nr(p,ok),now:i},e.key))]})}),(0,X.jsx)(sD,{children:Pr(s,e=>(0,X.jsxs)(cD,{children:[(0,X.jsx)(lD,{scope:`row`,children:Zi(e.open,{onNone:()=>(0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,X.jsx)(LO,{origin:e.origin}),e.name]}),onSome:t=>(0,X.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,title:`Open ${e.name}`,className:`flex items-center gap-2 text-sm font-medium`,children:[(0,X.jsx)(LO,{origin:e.origin}),e.name]})})}),Pr(p,t=>(0,X.jsx)(YO,{column:t,row:e},t.key))]},e.origin))})]})}),t[2]=n,t[3]=i,t[4]=e.pending,t[5]=c,t[6]=r,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else l=t[7],u=t[8],d=t[9],f=t[10];let p;t[18]===a?p=t[19]:(p=(0,X.jsx)(tD,{result:a}),t[18]=a,t[19]=p);let m;return t[20]!==l||t[21]!==u||t[22]!==d||t[23]!==f||t[24]!==p?(m=(0,X.jsxs)(`section`,{className:l,"aria-label":u,children:[d,f,p]}),t[20]=l,t[21]=u,t[22]=d,t[23]=f,t[24]=p,t[25]=m):m=t[25],m}function ok(e){return e.labelled}function sk(){return(0,X.jsx)(oe,{children:(0,X.jsx)(L,{children:(0,X.jsx)(ce,{children:`No app matches`})})})}function ck(e){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ek,{request:e}),(0,X.jsxs)(`p`,{className:`text-muted-foreground font-mono text-xs`,children:[`open until `,vO(e.expiresAt)]})]})}function lk(){return null}function uk(e){return{name:la(he(Si(new URL(e).hostname,`.`)),()=>e),open:rn(),origin:e,web:!1}}function dk(e){return _O(e.resources)}function fk(){return[]}function pk(e){return _O(e.resources)}function mk(e){return{name:e.name,open:Fe(e.open),origin:e.origin,web:dt(`https://`)(e.open)}}export{Tg as $,zE as A,vT as B,iD as C,PE as D,GE as E,lE as F,Dy as G,mT as H,QT as I,$ as J,oy as K,XT as L,BE as M,FE as N,IE as O,fE as P,Jg as Q,qT as R,XD as S,YE as T,hT as U,yT as V,eT as W,__ as X,k_ as Y,Q as Z,OO as _,uO as a,zm as at,AO as b,kO as c,$a as ct,oO as d,Va as dt,bg as et,sO as f,Ra as ft,fO as g,mO as h,rO as i,Rm as it,RE as j,LE as k,EO as l,eo as lt,pO as m,xa as mt,ak as n,qm as nt,hO as o,Bm as ot,dO as p,Na as pt,Gv as q,NO as r,Um as rt,aO as s,to as st,IO as t,Ym as tt,wO as u,ao as ut,SO as v,eD as w,vO as x,MO as y,FT as z};
|