@deslop/gateway 0.1.1247 → 0.1.1249
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)-CcYgj9q6.js +41 -0
- package/dist/client/assets/effect-vqsGZRUz.js +17 -0
- package/dist/client/assets/icon-CboSz0gI.svg +1 -0
- package/dist/client/assets/index-CHbcU5tn.css +2 -0
- package/dist/client/assets/index-NqpG0kja.js +3 -0
- package/dist/client/assets/{react-BUjtWCUj.js → react-COyt-gOi.js} +1 -1
- package/dist/client/index.html +5 -5
- package/dist/server.js +550 -241
- package/package.json +2 -2
- package/dist/client/assets/(home)-BI8XKvh4.js +0 -41
- package/dist/client/assets/effect-C_dSYsHy.js +0 -17
- package/dist/client/assets/icon-61pmFc-p.svg +0 -1
- package/dist/client/assets/index-BraGnsIF.css +0 -2
- package/dist/client/assets/index-JOdkABge.js +0 -4
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{a as t,i as n,n as r,o as i,t as a}from"./react-COyt-gOi.js";import{$ as o,$i as s,$n as c,$t as l,A as u,Aa as d,Ai as f,An as p,At as m,B as h,Bi as g,Bn as _,Br as v,Bt as y,C as b,Ca as x,Ci as S,Cn as C,Cr as w,Ct as T,D as E,Da as D,Di as O,Dn as k,Dr as A,Dt as j,E as M,Ea as N,Ei as P,En as F,Er as I,Et as L,F as R,Fa as ee,Fi as te,Fn as ne,Fr as z,Ft as re,G as ie,Gi as B,Gn as V,Gt as ae,H as oe,Hn as se,Hr as ce,Ht as le,I as ue,Ia as de,Ii as fe,In as pe,Ir as me,It as he,Jn as ge,Jr as _e,Jt as ve,Ki as ye,Kn as be,Kr as xe,Kt as Se,L as Ce,La as we,Li as Te,Ln as Ee,Lr as De,M as Oe,Mi as ke,Mn as Ae,Mr as je,Mt as Me,N as Ne,Na as Pe,Ni as Fe,Nn as Ie,Nr as Le,Nt as Re,O as ze,Oa as Be,On as Ve,Or as He,Ot as Ue,P as We,Pi as Ge,Pn as Ke,Pr as qe,Pt as Je,Q as Ye,Qi as Xe,Qn as Ze,Qt as Qe,R as $e,Ra as et,Ri as tt,Rn as nt,Rr as rt,Rt as it,S as at,Sa as ot,Si as st,Sn as ct,Sr as lt,St as ut,T as dt,Ti as ft,Tn as pt,Tr as mt,Tt as ht,U as gt,Ui as _t,Un as vt,Ut as yt,V as bt,Vi as xt,Vn as H,Vr as St,Vt as Ct,W as wt,Wn as Tt,Wt as Et,X as Dt,Xi as Ot,Xn as kt,Xr as At,Xt as jt,Yi as Mt,Yn as Nt,Yr as Pt,Yt as Ft,Zi as It,Zn as Lt,Zt as Rt,_ as zt,_a as Bt,_i as Vt,_r as Ht,_t as Ut,a as Wt,aa as Gt,an as Kt,ar as qt,at as Jt,b as Yt,ba as Xt,bi as Zt,bn as Qt,br as $t,bt as en,c as tn,ca as nn,ci as rn,cn as an,ct as on,d as sn,da as cn,di as ln,dn as un,dr as dn,dt as fn,en as pn,er as U,et as mn,fa as hn,fi as gn,fn as _n,fr as vn,ft as yn,g as bn,ga as xn,gi as Sn,gn as Cn,gr as wn,gt as Tn,h as En,ha as Dn,hi as On,hn as kn,hr as An,ht as jn,i as Mn,ia as Nn,in as Pn,ir as Fn,it as In,j as Ln,ja as W,ji as Rn,jn as zn,jr as Bn,jt as Vn,k as Hn,ka as Un,ki as Wn,kn as Gn,kr as Kn,kt as qn,la as Jn,li as Yn,ln as Xn,lt as Zn,m as Qn,ma as $n,mi as er,mn as tr,n as nr,na as rr,nn as ir,nr as ar,nt as or,o as sr,oa as cr,on as lr,or as ur,ot as dr,pi as fr,pn as pr,pr as mr,pt as hr,qi as gr,qn as _r,qr as vr,qt as yr,r as br,ra as xr,rn as Sr,rr as Cr,rt as wr,s as Tr,sa as Er,si as Dr,sn as Or,sr as kr,st as Ar,t as jr,ta as Mr,tr as Nr,tt as Pr,ua as Fr,ui as Ir,un as Lr,ur as Rr,ut as zr,v as Br,va as Vr,vi as Hr,vn as Ur,vr as Wr,vt as Gr,w as Kr,wa as qr,wi as Jr,wn as Yr,wr as Xr,wt as Zr,x as Qr,xa as $r,xi as ei,xn as ti,xr as ni,xt as ri,y as ii,yi as ai,yn as oi,yr as si,yt as ci,z as li,zi as ui,zn as di,zr as fi,zt as pi}from"./effect-vqsGZRUz.js";import{$ as mi,$t as G,A as hi,At as gi,B as _i,Bt as vi,C as yi,Cn as bi,Ct as xi,D as Si,Dt as Ci,E as wi,Et as Ti,F as Ei,Ft as Di,G as Oi,Gt as ki,H as Ai,Ht as ji,I as Mi,It as Ni,J as Pi,Jt as Fi,K as Ii,Kt as Li,L as Ri,Lt as zi,M as Bi,Mt as Vi,N as Hi,Nt as Ui,O as Wi,Ot as Gi,P as Ki,Pt as qi,Q as Ji,Qt as Yi,R as K,Rt as Xi,S as q,Sn as Zi,St as Qi,T as $i,Tt as ea,U as ta,Ut as na,V as ra,Vt as ia,W as aa,Wt as oa,X as sa,Xt as ca,Y as la,Yt as ua,Z as da,Zt as fa,_ as pa,_n as ma,_t as ha,a as ga,an as _a,at as va,b as ya,bn as ba,bt as xa,c as Sa,cn as Ca,ct as wa,d as Ta,dn as Ea,en as J,et as Da,f as Oa,fn as ka,ft as Aa,g as ja,gn as Ma,gt as Na,h as Pa,hn as Fa,ht as Ia,i as La,in as Ra,it as za,j as Ba,jt as Va,k as Ha,kt as Ua,l as Wa,ln as Ga,lt as Ka,m as qa,mn as Ja,mt as Ya,n as Xa,nn as Za,nt as Qa,o as $a,on as eo,ot as to,p as no,pn as ro,pt as io,q as ao,qt as oo,r as so,rn as co,rt as lo,s as uo,sn as fo,st as po,t as mo,tn as ho,tt as go,u as _o,un as vo,v as yo,vn as bo,vt as xo,w as So,wt as Co,x as wo,xn as To,xt as Eo,y as Do,yn as Oo,yt as Y,z as ko,zt as Ao}from"./index-NqpG0kja.js";var X=e(i(),1),jo=new Map([[`bold`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,36H40A20,20,0,0,0,20,56V200a20,20,0,0,0,20,20H216a20,20,0,0,0,20-20V56A20,20,0,0,0,216,36Zm-4,160H44V60H212ZM60,92a16,16,0,1,1,16,16A16,16,0,0,1,60,92Zm48,0a16,16,0,1,1,16,16A16,16,0,0,1,108,92Z`}))],[`duotone`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M224,56V200a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H216A8,8,0,0,1,224,56Z`,opacity:`0.2`}),X.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,160H40V56H216V200ZM80,84A12,12,0,1,1,68,72,12,12,0,0,1,80,84Zm40,0a12,12,0,1,1-12-12A12,12,0,0,1,120,84Z`}))],[`fill`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM68,96A12,12,0,1,1,80,84,12,12,0,0,1,68,96Zm40,0a12,12,0,1,1,12-12A12,12,0,0,1,108,96Z`}))],[`light`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,42H40A14,14,0,0,0,26,56V200a14,14,0,0,0,14,14H216a14,14,0,0,0,14-14V56A14,14,0,0,0,216,42Zm2,158a2,2,0,0,1-2,2H40a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2H216a2,2,0,0,1,2,2ZM78,84A10,10,0,1,1,68,74,10,10,0,0,1,78,84Zm40,0a10,10,0,1,1-10-10A10,10,0,0,1,118,84Z`}))],[`regular`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,160H40V56H216V200ZM80,84A12,12,0,1,1,68,72,12,12,0,0,1,80,84Zm40,0a12,12,0,1,1-12-12A12,12,0,0,1,120,84Z`}))],[`thin`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,44H40A12,12,0,0,0,28,56V200a12,12,0,0,0,12,12H216a12,12,0,0,0,12-12V56A12,12,0,0,0,216,44Zm4,156a4,4,0,0,1-4,4H40a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4H216a4,4,0,0,1,4,4ZM76,84a8,8,0,1,1-8-8A8,8,0,0,1,76,84Zm40,0a8,8,0,1,1-8-8A8,8,0,0,1,116,84Z`}))]]),Mo=X.forwardRef((e,t)=>X.createElement(To,{ref:t,...e,weights:jo}));Mo.displayName=`AppWindowIcon`;var No=new Map([[`bold`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M244,56v48a12,12,0,0,1-12,12H184a12,12,0,1,1,0-24H201.1l-19-17.38c-.13-.12-.26-.24-.38-.37A76,76,0,1,0,127,204h1a75.53,75.53,0,0,0,52.15-20.72,12,12,0,0,1,16.49,17.45A99.45,99.45,0,0,1,128,228h-1.37A100,100,0,1,1,198.51,57.06L220,76.72V56a12,12,0,0,1,24,0Z`}))],[`duotone`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,128a88,88,0,1,1-88-88A88,88,0,0,1,216,128Z`,opacity:`0.2`}),X.createElement(`path`,{d:`M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1,0-16H211.4L184.81,71.64l-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,0,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60L224,85.8V56a8,8,0,1,1,16,0Z`}))],[`fill`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1-5.66-13.66l17-17-10.55-9.65-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,1,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60l10.93,10L226.34,50.3A8,8,0,0,1,240,56Z`}))],[`light`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M238,56v48a6,6,0,0,1-6,6H184a6,6,0,0,1,0-12h32.55l-30.38-27.8c-.06-.06-.12-.13-.19-.19a82,82,0,1,0-1.7,117.65,6,6,0,0,1,8.24,8.73A93.46,93.46,0,0,1,128,222h-1.28A94,94,0,1,1,194.37,61.4L226,90.35V56a6,6,0,1,1,12,0Z`}))],[`regular`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1,0-16H211.4L184.81,71.64l-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,0,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60L224,85.8V56a8,8,0,1,1,16,0Z`}))],[`thin`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M236,56v48a4,4,0,0,1-4,4H184a4,4,0,0,1,0-8h37.7L187.53,68.69l-.13-.12a84,84,0,1,0-1.75,120.51,4,4,0,0,1,5.5,5.82A91.43,91.43,0,0,1,128,220h-1.26A92,92,0,1,1,193,62.84l35,32.05V56a4,4,0,1,1,8,0Z`}))]]),Po=X.forwardRef((e,t)=>X.createElement(To,{ref:t,...e,weights:No}));Po.displayName=`ArrowClockwiseIcon`;var Fo=new Map([[`bold`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M224.49,136.49l-72,72a12,12,0,0,1-17-17L187,140H40a12,12,0,0,1,0-24H187L135.51,64.48a12,12,0,0,1,17-17l72,72A12,12,0,0,1,224.49,136.49Z`}))],[`duotone`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,128l-72,72V56Z`,opacity:`0.2`}),X.createElement(`path`,{d:`M221.66,122.34l-72-72A8,8,0,0,0,136,56v64H40a8,8,0,0,0,0,16h96v64a8,8,0,0,0,13.66,5.66l72-72A8,8,0,0,0,221.66,122.34ZM152,180.69V75.31L204.69,128Z`}))],[`fill`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M221.66,133.66l-72,72A8,8,0,0,1,136,200V136H40a8,8,0,0,1,0-16h96V56a8,8,0,0,1,13.66-5.66l72,72A8,8,0,0,1,221.66,133.66Z`}))],[`light`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M220.24,132.24l-72,72a6,6,0,0,1-8.48-8.48L201.51,134H40a6,6,0,0,1,0-12H201.51L139.76,60.24a6,6,0,0,1,8.48-8.48l72,72A6,6,0,0,1,220.24,132.24Z`}))],[`regular`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z`}))],[`thin`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M218.83,130.83l-72,72a4,4,0,0,1-5.66-5.66L206.34,132H40a4,4,0,0,1,0-8H206.34L141.17,58.83a4,4,0,0,1,5.66-5.66l72,72A4,4,0,0,1,218.83,130.83Z`}))]]),Io=X.forwardRef((e,t)=>X.createElement(To,{ref:t,...e,weights:Fo}));Io.displayName=`ArrowRightIcon`;var Lo=new Map([[`bold`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M168.49,199.51a12,12,0,0,1-17,17l-80-80a12,12,0,0,1,0-17l80-80a12,12,0,0,1,17,17L97,128Z`}))],[`duotone`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M160,48V208L80,128Z`,opacity:`0.2`}),X.createElement(`path`,{d:`M163.06,40.61a8,8,0,0,0-8.72,1.73l-80,80a8,8,0,0,0,0,11.32l80,80A8,8,0,0,0,168,208V48A8,8,0,0,0,163.06,40.61ZM152,188.69,91.31,128,152,67.31Z`}))],[`fill`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M168,48V208a8,8,0,0,1-13.66,5.66l-80-80a8,8,0,0,1,0-11.32l80-80A8,8,0,0,1,168,48Z`}))],[`light`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M164.24,203.76a6,6,0,1,1-8.48,8.48l-80-80a6,6,0,0,1,0-8.48l80-80a6,6,0,0,1,8.48,8.48L88.49,128Z`}))],[`regular`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M165.66,202.34a8,8,0,0,1-11.32,11.32l-80-80a8,8,0,0,1,0-11.32l80-80a8,8,0,0,1,11.32,11.32L91.31,128Z`}))],[`thin`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M162.83,205.17a4,4,0,0,1-5.66,5.66l-80-80a4,4,0,0,1,0-5.66l80-80a4,4,0,1,1,5.66,5.66L85.66,128Z`}))]]),Ro=X.forwardRef((e,t)=>X.createElement(To,{ref:t,...e,weights:Lo}));Ro.displayName=`CaretLeftIcon`;var zo=new Map([[`bold`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M232.49,80.49l-128,128a12,12,0,0,1-17,0l-56-56a12,12,0,1,1,17-17L96,183,215.51,63.51a12,12,0,0,1,17,17Z`}))],[`duotone`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M232,56V200a16,16,0,0,1-16,16H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40H216A16,16,0,0,1,232,56Z`,opacity:`0.2`}),X.createElement(`path`,{d:`M205.66,85.66l-96,96a8,8,0,0,1-11.32,0l-40-40a8,8,0,0,1,11.32-11.32L104,164.69l90.34-90.35a8,8,0,0,1,11.32,11.32Z`}))],[`fill`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM205.66,85.66l-96,96a8,8,0,0,1-11.32,0l-40-40a8,8,0,0,1,11.32-11.32L104,164.69l90.34-90.35a8,8,0,0,1,11.32,11.32Z`}))],[`light`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M228.24,76.24l-128,128a6,6,0,0,1-8.48,0l-56-56a6,6,0,0,1,8.48-8.48L96,191.51,219.76,67.76a6,6,0,0,1,8.48,8.48Z`}))],[`regular`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z`}))],[`thin`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M226.83,74.83l-128,128a4,4,0,0,1-5.66,0l-56-56a4,4,0,0,1,5.66-5.66L96,194.34,221.17,69.17a4,4,0,1,1,5.66,5.66Z`}))]]),Bo=X.forwardRef((e,t)=>X.createElement(To,{ref:t,...e,weights:zo}));Bo.displayName=`CheckIcon`;var Vo=new Map([[`bold`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,28H88A12,12,0,0,0,76,40V76H40A12,12,0,0,0,28,88V216a12,12,0,0,0,12,12H168a12,12,0,0,0,12-12V180h36a12,12,0,0,0,12-12V40A12,12,0,0,0,216,28ZM156,204H52V100H156Zm48-48H180V88a12,12,0,0,0-12-12H100V52H204Z`}))],[`duotone`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,40V168H168V88H88V40Z`,opacity:`0.2`}),X.createElement(`path`,{d:`M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z`}))],[`fill`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32Zm-8,128H176V88a8,8,0,0,0-8-8H96V48H208Z`}))],[`light`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,34H88a6,6,0,0,0-6,6V82H40a6,6,0,0,0-6,6V216a6,6,0,0,0,6,6H168a6,6,0,0,0,6-6V174h42a6,6,0,0,0,6-6V40A6,6,0,0,0,216,34ZM162,210H46V94H162Zm48-48H174V88a6,6,0,0,0-6-6H94V46H210Z`}))],[`regular`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z`}))],[`thin`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,36H88a4,4,0,0,0-4,4V84H40a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H168a4,4,0,0,0,4-4V172h44a4,4,0,0,0,4-4V40A4,4,0,0,0,216,36ZM164,212H44V92H164Zm48-48H172V88a4,4,0,0,0-4-4H92V44H212Z`}))]]),Ho=X.forwardRef((e,t)=>X.createElement(To,{ref:t,...e,weights:Vo}));Ho.displayName=`CopyIcon`;var Uo=new Map([[`bold`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M208,36H48A20,20,0,0,0,28,56V200a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V56A20,20,0,0,0,208,36Zm-4,24v56H52V60ZM52,196V140H204v56ZM160,88a16,16,0,1,1,16,16A16,16,0,0,1,160,88Zm32,80a16,16,0,1,1-16-16A16,16,0,0,1,192,168Z`}))],[`duotone`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,152v48a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V152a8,8,0,0,1,8-8H208A8,8,0,0,1,216,152ZM208,48H48a8,8,0,0,0-8,8v48a8,8,0,0,0,8,8H208a8,8,0,0,0,8-8V56A8,8,0,0,0,208,48Z`,opacity:`0.2`}),X.createElement(`path`,{d:`M208,136H48a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V152A16,16,0,0,0,208,136Zm0,64H48V152H208v48Zm0-160H48A16,16,0,0,0,32,56v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V56A16,16,0,0,0,208,40Zm0,64H48V56H208v48ZM192,80a12,12,0,1,1-12-12A12,12,0,0,1,192,80Zm0,96a12,12,0,1,1-12-12A12,12,0,0,1,192,176Z`}))],[`fill`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M208,40H48A16,16,0,0,0,32,56v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V56A16,16,0,0,0,208,40ZM180,92a12,12,0,1,1,12-12A12,12,0,0,1,180,92Z`}),X.createElement(`path`,{d:`M208,136H48a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V152A16,16,0,0,0,208,136Zm-28,52a12,12,0,1,1,12-12A12,12,0,0,1,180,188Z`}))],[`light`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M208,138H48a14,14,0,0,0-14,14v48a14,14,0,0,0,14,14H208a14,14,0,0,0,14-14V152A14,14,0,0,0,208,138Zm2,62a2,2,0,0,1-2,2H48a2,2,0,0,1-2-2V152a2,2,0,0,1,2-2H208a2,2,0,0,1,2,2ZM208,42H48A14,14,0,0,0,34,56v48a14,14,0,0,0,14,14H208a14,14,0,0,0,14-14V56A14,14,0,0,0,208,42Zm2,62a2,2,0,0,1-2,2H48a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2H208a2,2,0,0,1,2,2ZM190,80a10,10,0,1,1-10-10A10,10,0,0,1,190,80Zm0,96a10,10,0,1,1-10-10A10,10,0,0,1,190,176Z`}))],[`regular`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M208,136H48a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V152A16,16,0,0,0,208,136Zm0,64H48V152H208v48Zm0-160H48A16,16,0,0,0,32,56v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V56A16,16,0,0,0,208,40Zm0,64H48V56H208v48ZM192,80a12,12,0,1,1-12-12A12,12,0,0,1,192,80Zm0,96a12,12,0,1,1-12-12A12,12,0,0,1,192,176Z`}))],[`thin`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M208,140H48a12,12,0,0,0-12,12v48a12,12,0,0,0,12,12H208a12,12,0,0,0,12-12V152A12,12,0,0,0,208,140Zm4,60a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V152a4,4,0,0,1,4-4H208a4,4,0,0,1,4,4ZM208,44H48A12,12,0,0,0,36,56v48a12,12,0,0,0,12,12H208a12,12,0,0,0,12-12V56A12,12,0,0,0,208,44Zm4,60a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4H208a4,4,0,0,1,4,4Zm-24,72a8,8,0,1,1-8-8A8,8,0,0,1,188,176Zm0-96a8,8,0,1,1-8-8A8,8,0,0,1,188,80Z`}))]]),Wo=X.forwardRef((e,t)=>X.createElement(To,{ref:t,...e,weights:Uo}));Wo.displayName=`HardDrivesIcon`;var Go=new Map([[`bold`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M232.49,215.51,185,168a92.12,92.12,0,1,0-17,17l47.53,47.54a12,12,0,0,0,17-17ZM44,112a68,68,0,1,1,68,68A68.07,68.07,0,0,1,44,112Z`}))],[`duotone`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M192,112a80,80,0,1,1-80-80A80,80,0,0,1,192,112Z`,opacity:`0.2`}),X.createElement(`path`,{d:`M229.66,218.34,179.6,168.28a88.21,88.21,0,1,0-11.32,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`fill`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M168,112a56,56,0,1,1-56-56A56,56,0,0,1,168,112Zm61.66,117.66a8,8,0,0,1-11.32,0l-50.06-50.07a88,88,0,1,1,11.32-11.31l50.06,50.06A8,8,0,0,1,229.66,229.66ZM112,184a72,72,0,1,0-72-72A72.08,72.08,0,0,0,112,184Z`}))],[`light`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M228.24,219.76l-51.38-51.38a86.15,86.15,0,1,0-8.48,8.48l51.38,51.38a6,6,0,0,0,8.48-8.48ZM38,112a74,74,0,1,1,74,74A74.09,74.09,0,0,1,38,112Z`}))],[`regular`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`thin`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M226.83,221.17l-52.7-52.7a84.1,84.1,0,1,0-5.66,5.66l52.7,52.7a4,4,0,0,0,5.66-5.66ZM36,112a76,76,0,1,1,76,76A76.08,76.08,0,0,1,36,112Z`}))]]),Ko=X.forwardRef((e,t)=>X.createElement(To,{ref:t,...e,weights:Go}));Ko.displayName=`MagnifyingGlassIcon`;var qo=new Map([[`bold`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z`}))],[`duotone`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`,opacity:`0.2`}),X.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`fill`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z`}))],[`light`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z`}))],[`regular`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`thin`,X.createElement(X.Fragment,null,X.createElement(`path`,{d:`M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z`}))]]),Jo=X.forwardRef((e,t)=>X.createElement(To,{ref:t,...e,weights:qo}));Jo.displayName=`PlusIcon`;var Yo=`data-open`,Xo=`data-closed`,Zo=`data-anchor-hidden`,Qo={[po]:``},$o={[po]:``,[wa]:``},es={[Yo]:``},ts={[Xo]:``},ns={[Zo]:``},rs={open(e){return e?Qo:null}},is={open(e){return e?$o:null}},as={open(e){return e?es:ts},anchorHidden(e){return e?ns:null}},os={...as,...Ka};function ss(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...ss(e,t.id,n)])}function cs(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 ls(e){e.preventDefault(),e.stopPropagation()}function us(e){return`nativeEvent`in e}function ds(e){return e.pointerType===``&&e.isTrusted?!0:xi&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function fs(e){return Eo?!1:!xi&&e.width===0&&e.height===0||e.type===`pointerdown`&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`&&(xi||e.buttons===0)||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function ps(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function ms(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}var hs=Math.min,gs=Math.max,_s=Math.round,vs=Math.floor,ys=e=>({x:e,y:e}),bs={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function xs(e,t,n){return gs(e,hs(t,n))}function Ss(e,t){return typeof e==`function`?e(t):e}function Cs(e){return e.split(`-`)[0]}function ws(e){return e.split(`-`)[1]}function Ts(e){return e===`x`?`y`:`x`}function Es(e){return e===`y`?`height`:`width`}function Ds(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Os(e){return Ts(Ds(e))}function ks(e,t,n){n===void 0&&(n=!1);let r=ws(e),i=Os(e),a=Es(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Rs(o)),[o,Rs(o)]}function As(e){let t=Rs(e);return[js(e),t,js(t)]}function js(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Ms=[`left`,`right`],Ns=[`right`,`left`],Ps=[`top`,`bottom`],Fs=[`bottom`,`top`];function Is(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Ns:Ms:t?Ms:Ns;case`left`:case`right`:return t?Ps:Fs;default:return[]}}function Ls(e,t,n,r){let i=ws(e),a=Is(Cs(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(js)))),a}function Rs(e){let t=Cs(e);return bs[t]+e.slice(t.length)}function zs(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Bs(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:zs(e)}function Vs(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 Hs(e){let t=ho(Us,e).current;return t.next=e,G(t.effect),t}function Us(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function Ws(e,t){return t!=null&&!ps(t)?0:typeof e==`function`?e():e}function Gs(e,t,n){let r=Ws(e,n);return typeof r==`number`?r:r?.[t]}function Ks(e){return typeof e==`function`?e():e}function qs(e,t){return t||e===`click`||e===`mousedown`}function Js(e){return e?.includes(`mouse`)&&e!==`mousedown`}var Z=t(),Ys=X.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new Ti,currentIdRef:{current:null},currentContextRef:{current:null}});function Xs(e,t){e.current=t.current}function Zs(e,t={open:!1}){let{open:n}=t,r=e.useState(`floatingId`),{currentIdRef:i,delayRef:a,timeoutMs:o,initialDelayRef:s,currentContextRef:c,hasProvider:l,timeout:u}=X.useContext(Ys),[d,f]=X.useState(!1),p=X.useRef(n);return G(()=>{p.current=n},[n]),G(()=>{function t(){c.current?.setIsInstantPhase(!1),i.current=null,c.current=null,a.current=s.current,u.clear()}if(i.current&&!n&&i.current===r){if(f(!1),o){let n=r;return u.start(o,()=>{e.select(`open`)||i.current&&i.current!==n||t()}),()=>{(p.current||i.current!==n)&&u.clear()}}t()}},[n,r,i,a,o,s,c,u,e]),G(()=>{if(!n)return;let t=c.current,o=i.current;u.clear(),c.current={onOpenChange:e.setOpen,setIsInstantPhase:f},i.current=r,a.current={open:0,close:Gs(s.current,`close`)},o!==null&&o!==r?(f(!0),t?.setIsInstantPhase(!0),t?.onOpenChange(!1,q(Pa))):(f(!1),t?.setIsInstantPhase(!1))},[n,r,e,i,a,s,c,u]),G(()=>()=>{if(i.current===r){if(c.current=null,!p.current)return;i.current=null,Xs(a,s),u.clear()}},[c,i,a,r,s,u]),X.useMemo(()=>({activeIdRef:i,hasProvider:l,delayRef:a,isInstantPhase:d}),[i,l,a,d])}var Qs=0;function $s(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(Qs);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),ki;let o=requestAnimationFrame(a);return Qs=o,()=>{Qs===o&&(cancelAnimationFrame(o),Qs=0)}}var ec=`data-base-ui-inert`,tc=new WeakMap,nc=new WeakSet,rc=new WeakMap,ic=0;function ac(e){return e?Ma(e)?e.host:ac(e.parentNode):null}var oc=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=ac(t);return e.contains(n)?n:null}).filter(e=>e!=null),sc=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},cc=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{eo(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function lc(e,t,n,{mark:r=!0}){let i=oc(t,e),a=r?cc(t,sc(i),new Set(i)):[],o=[],s=[];if(n){let e=oc(t,Array.from(t.querySelectorAll(`[aria-live]`))),n=i.concat(e);cc(t,sc(n),new Set(n)).forEach(e=>{let t=e.getAttribute(`aria-hidden`),n=t!==null&&t!==`false`,r=(tc.get(e)||0)+1;tc.set(e,r),o.push(e),r===1&&n&&nc.add(e),n||e.setAttribute(`aria-hidden`,`true`)})}return r&&a.forEach(e=>{let t=(rc.get(e)||0)+1;rc.set(e,t),s.push(e),t===1&&e.setAttribute(ec,``)}),ic+=1,()=>{o.forEach(e=>{let t=(tc.get(e)||0)-1;tc.set(e,t),t||(nc.has(e)||e.removeAttribute(`aria-hidden`),nc.delete(e))}),r&&s.forEach(e=>{let t=(rc.get(e)||0)-1;rc.set(e,t),t||e.removeAttribute(ec)}),--ic,ic||(tc=new WeakMap,nc=new WeakSet,rc=new WeakMap)}}function uc(e,t={}){let{ariaHidden:n=!1,mark:r=!0}=t,i=ua(e[0]).body;return lc(e,i,n,{mark:r})}function dc(){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 fc=class{nodesRef={current:[]};events=dc();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)}},pc=X.createContext(null),mc=X.createContext(null),hc=()=>X.useContext(pc)?.id||null,gc=e=>{let t=X.useContext(mc);return e??t};function _c(e){let t=So(),n=gc(e),r=hc();return G(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function vc(e){let{children:t,id:n}=e,r=hc();return(0,Z.jsx)(pc.Provider,{value:X.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function yc(e){let{children:t,externalTree:n}=e,r=ho(()=>n??new fc).current;return(0,Z.jsx)(mc.Provider,{value:r,children:t})}function bc(e,t){let n=vo(xa(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||(ds(e)?`keyboard`:t||`mouse`):`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var xc=20,Sc=[];function Cc(){Sc=Sc.filter(e=>e.deref()?.isConnected)}function wc(e){Cc(),e&&eo(e)!==`body`&&(Sc.push(new WeakRef(e)),Sc.length>xc&&(Sc=Sc.slice(-20)))}function Tc(){return Cc(),Sc[Sc.length-1]?.deref()}function Ec(e){return e?aa(e)?e:Oi(e)[0]||e:null}function Dc(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=ko(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return aa(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 Oc(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,explicitReturnFocus:o,restoreFocus:s=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:u=``,nextFocusableElement:d,previousFocusableElement:f,beforeContentFocusGuardRef:p,externalTree:m,getInsideElements:h}=e,g=t.useState(`open`),_=t.useState(`domReferenceElement`),v=t.useState(`floatingElement`),{events:y,dataRef:b}=t.context,x=J(()=>b.current.floatingContext?.nodeId),S=i===!1,C=lo(_)&&S,w=Hs(i),T=Hs(a),E=Hs(o),D=Hs(u),O=Hs(g),k=gc(m),A=La(),j=X.useRef(!1),M=X.useRef(!1),N=X.useRef(!1),P=X.useRef(null),F=X.useRef(``),I=X.useRef(``),L=X.useRef(null),R=X.useRef(null),ee=Li(L,p,A?.beforeInsideRef),te=Li(R,A?.afterInsideRef),ne=Ci(),z=Ci(),re=Ki(),ie=A!=null,B=Ji(v),V=J((e=B)=>e?Oi(e):[]),ae=J(()=>h?.().filter(e=>e!=null)??[]);X.useEffect(()=>{if(r||!c)return;function e(e){e.key===`Tab`&&Y(B,ha(ua(B)))&&V().length===0&&!C&&ls(e)}let t=ua(B);return K(t,`keydown`,e)},[r,B,c,C,V]),X.useEffect(()=>{if(r||!g)return;let e=ua(B);function t(){N.current=!1}function n(e){let t=xa(e),n=ae(),r=Y(v,t)||Y(_,t)||Y(A?.portalNode,t)||n.some(e=>e===t||Y(e,t));N.current=!r,I.current=e.pointerType||`keyboard`,xo(t,`[data-base-ui-click-trigger]`)&&(M.current=!0,z.start(0,()=>{M.current=!1}))}function i(){I.current=`keyboard`}return Ri(K(e,`pointerdown`,n,!0),K(e,`pointerup`,t,!0),K(e,`pointercancel`,t,!0),K(e,`keydown`,i,!0),t)},[r,v,_,B,g,A,z,ae]),X.useEffect(()=>{if(r||!l)return;let e=ua(B);function n(){M.current=!0,z.start(0,()=>{M.current=!1})}function i(e){let t=xa(e);aa(t)&&(P.current=t)}function a(n){let r=n.relatedTarget,i=n.currentTarget,a=xa(n);c&&r==null&&a!=null&&Y(v,a)&&wc(a),queueMicrotask(()=>{let o=x(),l=t.context.triggerElements,u=ae(),p=r?.hasAttribute(ga(`focus-guard`))&&[L.current,R.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,Bi(f),Bi(d)].includes(r),m=!(Y(_,r)||Y(v,r)||Y(r,v)||Y(A?.portalNode,r)||u.some(e=>e===r||Y(e,r))||l.hasMatchingElement(e=>Y(e,r))||p||k&&(ss(k.nodesRef.current,o).find(e=>Y(e.context?.elements.floating,r)||Y(e.context?.elements.domReference,r))||cs(k.nodesRef.current,o).find(e=>[e.context?.elements.floating,Ji(e.context?.elements.floating)].includes(r)||e.context?.elements.domReference===r)));if(i===_&&B&&Dc(B),s&&i!==_&&!la(a)&&ha(e)===e.body){if(ro(B)&&(B.focus(),s===`popup`)){re.request(()=>{B.focus()});return}let e=V(),t=P.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||B;ro(n)&&n.focus()}b.current.insideReactTree?b.current.insideReactTree=!1:(C||!c)&&r&&m&&!M.current&&(C||r!==Tc())&&(j.current=!0,t.setOpen(!1,q(_o,n)))})}function o(){N.current||(b.current.insideReactTree=!0,ne.start(0,()=>{b.current.insideReactTree=!1}))}let u=ro(_)?_:null;if(v||u)return Ri(u&&K(u,`focusout`,a),u&&K(u,`pointerdown`,n),v&&K(v,`focusin`,i),v&&K(v,`focusout`,a),v&&A&&K(v,`focusout`,o,!0))},[r,_,v,B,c,k,A,t,l,s,V,C,x,b,ne,z,re,d,f,ae]),X.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${ga(`portal`)}]`)||[]),t=(k?cs(k.nodesRef.current,x()):[]).find(e=>lo(e.context?.elements.domReference||null))?.context?.elements.domReference,n=uc([v,...e,L.current,R.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...ae(),t,Bi(f),Bi(d),C?_:null].filter(e=>e!=null),{ariaHidden:c||C,mark:!1}),i=uc([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,c,A,C,k,x,d,f,ae]),G(()=>{if(!g||r||!ro(B))return;F.current=``,I.current=``;let e=ua(B),t=ha(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(D.current||``):n;if(r===void 0||r===!1||Y(B,t))return;let i=null,a=()=>(i??=V(B),i[0]||B),o;o=r===!0||r===null?a():Bi(r),o||=a();let s=Y(B,ha(e)),c=b.current.openEvent,l=c?.type===`mousedown`&&ds(c);$s(o,{sync:l,preventScroll:o===B,shouldFocus(){if(!O.current)return!1;if(s)return!0;let t=ha(e);return!(t!==o&&Y(B,t))}})})},[r,g,B,V,w,D,O,b]);let oe=X.useRef(null);G(()=>{if(r||!B){oe.current=null;return}oe.current&&=(oe.current.cancelled=!0,null);let e=ua(B),t=ha(e),n=D.current==null;wc(t);function i(e){if(e.open||(F.current=bc(e.nativeEvent,I.current)),(e.reason===`focus-out`&&e.triggerElement?.hasAttribute(ga(`focus-guard`))||e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`)&&(j.current=!0),e.reason===`outside-press`){if(e.nested)j.current=!1;else if(ds(e.nativeEvent)||fs(e.nativeEvent))j.current=!1;else{let e=!1;ua(B).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?j.current=!1:j.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&eo(t)!==`body`?t:null,s=n?o||a:a||o;return s||=Tc()||null,typeof i==`boolean`?s:Bi(i)||s||null}return()=>{y.off(`openchange`,i);let t=ha(e),n=ae(),r=Y(v,t)||n.some(e=>e===t||Y(e,t))||k&&ss(k.nodesRef.current,x(),!1).some(e=>Y(e.context?.elements.floating,t)),o=T.current,s=F.current,c=a(s),l={cancelled:!1};oe.current=l,queueMicrotask(()=>{oe.current===l&&(oe.current=null);let n=Ec(c),i=E.current??typeof o!=`boolean`;if(!l.cancelled&&o&&!j.current&&ro(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}j.current=!1})}},[r,v,B,T,E,D,y,k,_,x,ae]),G(()=>{if(!Qi||g||!v)return;let e=ha(ua(v));ro(e)&&za(e)&&Y(v,e)&&e.blur()},[g,v]),G(()=>{if(!r&&A)return A.setFocusManagerState({modal:c,closeOnFocusOut:l,open:g,onOpenChange:t.setOpen,domReference:_}),()=>{A.setFocusManagerState(null)}},[r,A,c,g,t,l,_]),G(()=>{if(!r&&B)return Dc(B),()=>{queueMicrotask(Cc)}},[r,B]);let se=!r&&(!c||!C)&&(ie||c);return(0,Z.jsxs)(X.Fragment,{children:[se&&(0,Z.jsx)(Mi,{"data-type":`inside`,ref:ee,onFocus:e=>{if(c){let e=V();$s(e[e.length-1])}else A?.portalNode&&(j.current=!1,ta(e,A.portalNode)?_i(_)?.focus():Bi(f??A.beforeOutsideRef)?.focus())}}),n,se&&(0,Z.jsx)(Mi,{"data-type":`inside`,ref:te,onFocus:e=>{c?$s(V()[0]):A?.portalNode&&(l&&(j.current=!0),ta(e,A.portalNode)?ra(_)?.focus():Bi(d??A.afterOutsideRef)?.focus())}})]})}function kc(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=wo}=t,l=e.context.dataRef,u=X.useRef(void 0),d=Ki(),f=Ci(),p=X.useMemo(()=>{function t(t,n,r,i){let a=q(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=ps(e.pointerType,!0)&&fs(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(i){let o=u.current,s=i.nativeEvent,c=e.select(`open`);if(i.button!==0||r===`click`||ps(o,!0)&&a)return;let l=n(c,i.currentTarget,e=>e===`click`||e===`mousedown`),f=xa(s),p=za(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:ps(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 X.useMemo(()=>n?{reference:p}:oa,[n,p])}function Ac(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){let a=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},o=t.axis===`x`||t.axis===`both`,s=t.axis===`y`||t.axis===`both`,c=[`mouseenter`,`mousemove`].includes(t.dataRef.current.openEvent?.type||``)&&t.pointerType!==`touch`,l=t.axis===`y`?a.width:0,u=t.axis===`x`?a.height:0,d=a.x,f=a.y;return n==null&&t.x&&o&&(n=a.x-t.x),r==null&&t.y&&s&&(r=a.y-t.y),d-=n||0,f-=r||0,(!i||c)&&(d=o&&t.x!=null?t.x:d,f=s&&t.y!=null?t.y:f),i=!0,{width:l,height:u,x:d,y:f,top:f,right:d+l,bottom:f+u,left:d}}}}function jc(e){return e!=null&&e.clientX!=null}function Mc(e,t={}){let{enabled:n=!0,axis:r=`both`}=t,i=e.useState(`open`),a=e.useState(`floatingElement`),o=e.useState(`domReferenceElement`),s=e.context.dataRef,c=X.useRef(!1),l=X.useRef(null),[u,d]=X.useState(),[f,p]=X.useState([]),m=J(t=>{e.set(`positionReference`,t)}),h=J((t,n,i)=>{c.current||(!s.current.openEvent||jc(s.current.openEvent))&&e.set(`positionReference`,Ac(i??o,{x:t,y:n,axis:r,dataRef:s,pointerType:u}))}),g=J(e=>{i?l.current||(h(e.clientX,e.clientY,e.currentTarget),p([])):h(e.clientX,e.clientY,e.currentTarget)}),_=ps(u)?a:i;X.useEffect(()=>{if(!n){m(o);return}if(!_)return;function e(){l.current?.(),l.current=null}let t=vo(a);function r(t){let n=xa(t);Y(a,n)?e():h(t.clientX,t.clientY)}return!s.current.openEvent||jc(s.current.openEvent)?l.current=K(t,`mousemove`,r):m(o),e},[_,n,a,s,o,e,h,m,f]),X.useEffect(()=>()=>{e.set(`positionReference`,null)},[e]),X.useEffect(()=>{n&&!a&&(c.current=!1)},[n,a]),X.useEffect(()=>{!n&&i&&(c.current=!0)},[n,i]);let v=X.useMemo(()=>{function e(e){d(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:g,onMouseEnter:g}},[g]);return X.useMemo(()=>n?{reference:v,trigger:v}:{},[n,v])}function Nc(){return!1}function Pc(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function Fc(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=Nc,bubbles:s,externalTree:c}=t,l=e.useState(`open`),u=e.useState(`floatingElement`),{dataRef:d,events:f}=e.context,p=gc(c),m=J(typeof i==`function`?i:()=>!1),h=typeof i==`function`?m:i,g=h!==!1,_=J(()=>a),{escapeKey:v,outsidePress:y}=Pc(s),b=X.useRef(!1),x=X.useRef(!1),S=X.useRef(!1),C=X.useRef(!1),w=X.useRef(!1),T=X.useRef(``),E=X.useRef(null),D=Ci(),O=Ci(),k=Ci(),A=J(()=>{O.clear(),d.current.insideReactTree=!1}),j=J(e=>{let t=d.current.floatingContext?.nodeId;return(p?ss(p.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),M=J(t=>mi(t,e.select(`floatingElement`))||mi(t,e.select(`domReferenceElement`))),N=J(t=>{o()&&e.setOpen(!1,q(wo,t.nativeEvent))}),P=J(t=>{if(!l||!n||!r||t.key!==`Escape`)return;let i=us(t)?t.nativeEvent:t;if(w.current||i.isComposing||!v&&j(`__escapeKeyBubbles`))return;let a=q(Wa,i);e.setOpen(!1,a),a.isCanceled||t.preventDefault(),!v&&!a.isPropagationAllowed&&t.stopPropagation()}),F=J(()=>{d.current.insideReactTree=!0,O.start(0,A)}),I=J(t=>{if(!l||!n||t.button!==0)return;let r=xa(t.nativeEvent);Y(e.select(`floatingElement`),r)&&(b.current||(b.current=!0,x.current=!1))}),L=J(e=>{l&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&b.current&&(x.current=!0)});X.useEffect(()=>{function e(e){e.open||(C.current=!1)}return f.on(`openchange`,e),()=>{f.off(`openchange`,e)}},[f]),X.useEffect(()=>A,[A]),X.useEffect(()=>{if(!l||!n)return l||(C.current=!1,w.current=!1,T.current=``,E.current=null),A;d.current.__escapeKeyBubbles=v,d.current.__outsidePressBubbles=y;let t=new Ti,i=ua(u);function a(){k.clear(),w.current=!0}function o(){w.current=!0,k.start(Qi?5:0,()=>{w.current=!1})}function s(){S.current=!0,t.start(0,()=>{S.current=!1})}function c(){b.current=!1,x.current=!1}function f(){let e=T.current,t=e===`pen`||!e?`mouse`:e,n=_(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function m(e){let t=f();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function O(e){let t=d.current.floatingContext?.nodeId,n=p&&ss(p.nodesRef.current,t).some(t=>mi(e,t.context?.elements.floating));return M(e)||n}function N(n){if(m(n)){n.type!==`click`&&!M(n)&&(t.clear(),S.current=!1),A();return}if(d.current.insideReactTree){A();return}let r=xa(n),i=`[${ga(`inert`)}]`,a=ka(r)?r.getRootNode():null,o=Array.from((Ma(a)?a:ua(e.select(`floatingElement`))).querySelectorAll(i)),s=e.context.triggerElements;if(r&&(s.hasElement(r)||s.hasMatchingElement(e=>Y(e,r))))return;let c=ka(r)?r:null;for(;c&&!Ja(c);){let e=Ga(c);if(Ja(e)||!ka(e))break;c=e}if(!(o.length&&ka(r)&&!go(r)&&!Y(r,e.select(`floatingElement`))&&o.every(e=>!Y(c,e)))){if(ro(r)&&!(`touches`in n)){let e=Ja(r),t=Za(r),i=/auto|scroll/,a=e||i.test(t.overflowX),o=e||i.test(t.overflowY),s=a&&r.clientWidth>0&&r.scrollWidth>r.clientWidth,c=o&&r.clientHeight>0&&r.scrollHeight>r.clientHeight,l=t.direction===`rtl`,u=c&&(l?n.offsetX<=r.offsetWidth-r.clientWidth:n.offsetX>r.clientWidth),d=s&&n.offsetY>r.clientHeight;if(u||d)return}if(!O(n)){if(f()===`intentional`){if(n.detail!==0&&!ds(n)&&!C.current)return;if(S.current){t.clear(),S.current=!1;return}}typeof h==`function`&&!h(n)||j(`__outsidePressBubbles`)||(e.setOpen(!1,q(ja,n)),A())}}}function F(t){f()===`sloppy`&&t.pointerType!==`touch`&&e.select(`open`)&&n&&!M(t)&&N(t)}function I(t){if(f()!==`sloppy`||!e.select(`open`)||!n||M(t))return;let r=t.touches[0];r&&(E.current={startTime:Date.now(),startX:r.clientX,startY:r.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},D.start(1e3,()=>{E.current&&(E.current.dismissOnTouchEnd=!1,E.current.dismissOnMouseDown=!1)}))}function L(e,t){let n=xa(e);if(!n)return;let r=K(n,e.type,()=>{t(e),r()})}function R(e){T.current=`touch`,L(e,I)}function ee(e){D.clear(),e.type===`pointerdown`&&(e.button===0&&(C.current=!0),T.current=e.pointerType),(e.type!==`mousedown`||!E.current||E.current.dismissOnMouseDown)&&L(e,e=>{e.type===`pointerdown`?F(e):N(e)})}function te(e){if(e.type===`pointercancel`&&(C.current=!1),!b.current)return;let n=x.current;c(),f()===`intentional`&&(e.type===`pointercancel`?n&&s():O(e)||(n?s():(typeof h!=`function`||h(e))&&(t.clear(),S.current=!0,A())))}function ne(e){if(f()!==`sloppy`||!E.current||M(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-E.current.startX),r=Math.abs(t.clientY-E.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(E.current.dismissOnTouchEnd=!0),i>10&&(N(e),D.clear(),E.current=null)}function z(e){L(e,ne)}function re(e){f()===`sloppy`&&E.current&&!M(e)&&(E.current.dismissOnTouchEnd&&N(e),D.clear(),E.current=null)}function ie(e){L(e,re)}let B=Ri(r&&Ri(K(i,`keydown`,P),K(i,`compositionstart`,a),K(i,`compositionend`,o)),g&&Ri(K(i,`click`,ee,!0),K(i,`pointerdown`,ee,!0),K(i,`pointerup`,te,!0),K(i,`pointercancel`,te,!0),K(i,`mousedown`,ee,!0),K(i,`mouseup`,te,!0),K(i,`touchstart`,R,{capture:!0,passive:!0}),K(i,`touchmove`,z,{capture:!0,passive:!0}),K(i,`touchend`,ie,{capture:!0,passive:!0})));return()=>{B(),t.clear(),c(),S.current=!1}},[d,u,r,g,h,l,n,v,y,P,A,_,j,M,p,e,D,k]);let R=X.useMemo(()=>({onKeyDown:P,onPointerDown:N,onClick:N}),[P,N]),ee=X.useMemo(()=>({onKeyDown:P,onPointerDown:L,onMouseDown:L,onClickCapture:F,onMouseDownCapture(e){F(),I(e)},onPointerDownCapture(e){F(),I(e)},onMouseUpCapture:F,onTouchEndCapture:F,onTouchMoveCapture:F}),[P,F,I,L]);return X.useMemo(()=>n?{reference:R,floating:ee,trigger:R}:{},[n,R,ee])}function Ic(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),G(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};ka(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 Lc(e,t=!1,n=!1,r=!1){let[i,a]=X.useState(e&&t?`idle`:void 0),[o,s]=X.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),G(()=>{if(!e&&o&&i!==`ending`&&n){let e=Hi.request(()=>{a(`ending`)});return()=>{Hi.cancel(e)}}},[e,o,i,n]),G(()=>{if(!e||t||i===void 0)return;let n=Hi.request(()=>{a(void 0)});return()=>{Hi.cancel(n)}},[t,e,i]),G(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=Hi.request(()=>{a(`idle`)});return()=>{Hi.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}function Rc(e){let{open:t,ref:n,preventUnmountOnClose:r,setPreventUnmountOnClose:i,onUnmount:a,animateInitialOpen:o}=e,s=J(i),{mounted:c,setMounted:l,transitionStatus:u}=Lc(t,!1,!1,o),d=!t&&r;G(()=>{t&&s(!1)},[t,s]);let f=X.useRef(c),p=X.useRef(!1),m=$i(),h=()=>{f.current=!1,l(!1),a()};G(()=>{f.current=c,p.current&&(p.current=!1,!t&&c&&h())});let g=J(()=>{f.current&&(t?(p.current=!0,m()):h())});return hi({enabled:c&&!t&&!d,open:t,ref:n,onComplete(){t||g()}}),{mounted:c,transitionStatus:u,preventUnmountingOnClose:d,forceUnmount:g}}var zc=e(n(),1),Bc={tabIndex:-1,[Na]:``};function Vc(e){return t=>t!==`touch`||e.current}function Hc(e,t=!1){let n=So(),r=hc()!=null,i=ho(()=>e(n,r)).current;return Ic({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function Uc({handle:e,store:t}){return G(()=>e.attachStore(t),[e,t]),null}function Wc(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function Gc(e,t){let n=X.useRef(null);return J(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),Wc(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),Wc(t))})}function Kc(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 qc(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function Jc(e,t,n,r={}){let i=n.reason,a=i===ya,o=t&&i===`trigger-focus`,s=!t&&(i===`trigger-press`||i===`escape-key`),c=qc(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let l=()=>{let i=Kc(e.state,t,n.trigger,c()),l={...r.extraState,...i};o?l.instantType=`focus`:s?l.instantType=`dismiss`:a&&(l.instantType=void 0),e.update(l)};a?zc.flushSync(l):l()}function Yc(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=Gc(e,n),o=J(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e)}else if(a==null&&i&&!n.state.openedWithoutTrigger){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=J(e=>{a(e),e&&o(e)});return G(()=>(s(t.current),()=>s(null)),[s,t,n,e]),G(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function Xc(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=X.useRef(null),i=e.useState(`open`),a=e.useState(`triggerCount`),o=e.useState(`activeTriggerId`),s=e.useState(`activeTriggerElement`);G(()=>{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=q(Pa);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,a,o,s,n])}function Zc(e,t,n,r){let{mounted:i,transitionStatus:a,forceUnmount:o}=Rc({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 ho(()=>(t.set(`mounted`,i),null)),t.useSyncedValues({mounted:i,transitionStatus:a}),{forceUnmount:o,transitionStatus:a}}function Qc(e,t){e.useSyncedValues(t),G(()=>()=>{e.update({activeTriggerProps:oa,inactiveTriggerProps:oa,popupProps:oa})},[e])}function $c(e,t){G(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),G(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var el=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}},tl={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},nl=class extends Gi{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:dc(),nested:n,triggerElements:i},tl),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&ms(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 rl(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new nl({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:oa,inactiveTriggerProps:oa,popupProps:oa}}var il=e=>e.triggerIdProp??e.activeTriggerId,al=e=>e.openProp??e.open,ol=e=>(e.popupElement?.id??e.floatingId)||void 0;function sl(e,t){return t!==void 0&&al(e)&&il(e)===t}function cl(e,t){return sl(e,t)?!0:t!==void 0&&al(e)&&il(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}var ll={open:al,mounted:e=>e.mounted,transitionStatus:e=>al(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:il,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:ol,isTriggerActive:(e,t)=>t!==void 0&&il(e)===t,isOpenedByTrigger:(e,t)=>sl(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&il(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>cl(e,t)?ol(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement},ul=Zi();function dl(e){let t=X.useCallback(t=>e===void 0?ki:e.subscribeStore(t),[e]),n=X.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,ul.useSyncExternalStore)(t,n,()=>e?.serverStore)}var fl=ea&&Qi;function pl(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=X.useRef(!1),s=X.useRef(null),c=X.useRef(!0),l=Ci();X.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=vo(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&ro(t)&&t===ha(ua(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return Ri(K(r,`blur`,i),fl&&K(r,`keydown`,a,!0),fl&&K(r,`pointerdown`,l,!0))},[e,n]),X.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);ka(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=X.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=xa(n.nativeEvent);if(ka(a)){if(fl&&!n.relatedTarget){if(!c.current&&!za(a))return}else if(!va(a))return}let u=Qa(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;e.select(`open`)&&u||!r?e.setOpen(!0,q(Do,d,f)):l.start(r,()=>{o.current||e.setOpen(!0,q(Do,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=ka(r)&&r.hasAttribute(ga(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=ha(ua(t));!r&&n===t||Y(a.current.floatingContext?.refs.floating.current,n)||Y(t,n)||o||Qa(r??n,e.context.triggerElements)||e.setOpen(!1,q(Do,i))})}}},[a,r,e,l]);return X.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}var ml=class e{pointerType=void 0;interactedInside=!1;handler=void 0;blockMouseMove=!0;performedPointerEventsMutation=!1;pointerEventsScopeElement=null;pointerEventsReferenceElement=null;pointerEventsFloatingElement=null;restTimeoutPending=!1;openChangeTimeout=new Ti;restTimeout=new Ti;handleCloseOptions=void 0;static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},hl=new WeakMap;function gl(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&hl.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),hl.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function _l(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=hl.get(n);a&&a!==e&&gl(a),gl(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,hl.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function vl(e){let t=e.context.dataRef.current,n=ho(()=>t.hoverInteractionState??ml.create()).current;return t.hoverInteractionState||=n,Va(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function yl(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=gc(),u=hc(),d=vl(e),f=Ci(),p=J(()=>qs(c.current.openEvent?.type,d.interactedInside)),m=J(()=>Js(c.current.openEvent?.type)),h=J(()=>{gl(d)});G(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,h())},[a,d,h]),X.useEffect(()=>h,[h]),G(()=>{if(n&&a&&d.handleCloseOptions?.blockPointerEvents&&m()&&ka(s)&&o){let e=s,t=o,n=ua(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??xo(e,`[data-rootownerid]`)??n.body;return _l(d,{scopeElement:c,referenceElement:e,floatingElement:t}),()=>{h()}}},[n,a,s,o,d,m,l,u,h]),X.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&ss(l.nodesRef.current,u).length>0)}function a(t){let n=Gs(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,q(ya,t)),l?.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=xa(e);Da(t)?d.interactedInside=xo(t,`[aria-haspopup]`)!=null:d.interactedInside=!1}function g(){d.openChangeTimeout.clear(),f.clear(),l?.events.off(`floating.closed`,v),h()}function _(n){if(t()&&l){l.events.on(`floating.closed`,v);return}if(Qa(n.relatedTarget,e.context.triggerElements))return;let r=c.current.floatingContext?.nodeId??i,o=n.relatedTarget;l&&r&&ka(o)&&ss(l.nodesRef.current,r,!1).some(e=>Y(e.context?.elements.floating,o))||(d.handler?d.handler(n):(h(),m()&&!p()&&a(n)))}function v(n){l&&u&&!t()&&f.start(0,()=>{l.events.off(`floating.closed`,v),e.setOpen(!1,q(ya,n)),l.events.emit(`floating.closed`,n)})}let y=o;return Ri(y&&K(y,`mouseenter`,g),y&&K(y,`mouseleave`,_),y&&K(y,`pointerdown`,s,!0),()=>{l?.events.off(`floating.closed`,v)})},[n,o,e,c,r,i,m,p,h,d,l,u,f])}var bl={current:null};function xl(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=bl,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,{dataRef:h,events:g}=e.context,_=gc(l),v=vl(e),y=X.useRef(!1),b=Hs(i),x=Hs(r),S=Hs(o),C=Hs(n),w=Hs(p),T=Hs(f),E=J(()=>qs(h.current.openEvent?.type,v.interactedInside)),D=J(()=>w.current?.()!==!1),O=J((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!Y(t,n);if(!ka(r))return!1;let a=r;return i.hasMatchingElement(e=>Y(e,a))&&(!t||!Y(t,a))}),k=J(()=>{v.handler&&=(ua(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,v.handler),void 0)}),A=J(()=>{gl(v)});return u&&(v.handleCloseOptions=i?.__options),X.useEffect(()=>k,[k]),X.useEffect(()=>{if(!n)return;function e(e){e.open?y.current=!1:(y.current=e.reason===ya,k(),v.openChangeTimeout.clear(),v.restTimeout.clear(),v.blockMouseMove=!0,v.restTimeoutPending=!1)}return g.on(`openchange`,e),()=>{g.off(`openchange`,e)}},[n,g,v,k]),X.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=Gs(x.current,`close`,v.pointerType);r?v.openChangeTimeout.start(r,()=>{e.setOpen(!1,q(ya,t)),_?.events.emit(`floating.closed`,t)}):n&&(v.openChangeTimeout.clear(),e.setOpen(!1,q(ya,t)),_?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!ka(r))return;function i(t){if(v.openChangeTimeout.clear(),v.blockMouseMove=!1,a&&!ps(v.pointerType))return;let n=Ks(S.current),r=Gs(x.current,`open`,v.pointerType),i=xa(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(ka(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(Y(t,i)){c=t;break}}ka(o)&&ka(s)&&!e.context.triggerElements.hasElement(o)&&Y(o,s)&&(c=s);let l=c!=null&&O(s,c,i),u=e.select(`open`),d=T.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&y.current,p=!l&&ka(c)&&ka(s)&&Y(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;h?D()&&e.setOpen(!0,q(ya,t,c)):m||(r?v.openChangeTimeout.start(r,()=>{g&&D()&&e.setOpen(!0,q(ya,t,c))}):g&&D()&&e.setOpen(!0,q(ya,t,c)))}function o(n){if(E()){A();return}k();let r=e.select(`domReferenceElement`),i=ua(r);v.restTimeout.clear(),v.restTimeoutPending=!1;let a=h.current.floatingContext??d?.();if(!Qa(n.relatedTarget,e.context.triggerElements)){if(b.current&&a){e.select(`open`)||v.openChangeTimeout.clear();let r=c.current;v.handler=b.current({...a,tree:_,x:n.clientX,y:n.clientY,onClose(){A(),k(),C.current&&!E()&&r===e.select(`domReferenceElement`)&&t(n,!0)}}),i.addEventListener(`mousemove`,v.handler),v.handler(n)}else v.pointerType===`touch`&&Y(e.select(`floatingElement`),n.relatedTarget)||t(n)}}function l(e){Y(r,e.relatedTarget)||(v.openChangeTimeout.clear(),v.restTimeout.clear(),v.restTimeoutPending=!1)}let f=m?K(r,`mouseout`,l):void 0;return s?Ri(K(r,`mousemove`,i,{once:!0}),K(r,`mouseenter`,i),K(r,`mouseleave`,o),f):Ri(K(r,`mouseenter`,i),K(r,`mouseleave`,o),f)},[k,A,h,x,e,n,b,v,u,O,E,a,s,S,c,_,C,d,T,D,m]),X.useMemo(()=>{if(!n)return;function t(e){v.pointerType=e.pointerType}return{onPointerDown:t,onPointerEnter:t,onMouseMove(t){let{nativeEvent:n}=t,r=t.currentTarget,i=e.select(`domReferenceElement`),o=e.select(`open`),s=O(i,r,t.target);if(a&&!ps(v.pointerType))return;if(o&&s&&v.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=v.handleCloseOptions?.getScope?.()??r.ownerDocument.body;_l(v,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=Ks(S.current);if(o&&!s||c===0||!s&&v.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;v.restTimeout.clear();function l(){if(v.restTimeoutPending=!1,E())return;let t=e.select(`open`);!v.blockMouseMove&&(!t||s)&&D()&&e.setOpen(!0,q(ya,n,r))}v.pointerType===`touch`?zc.flushSync(()=>{l()}):s&&o?l():(v.restTimeoutPending=!0,v.restTimeout.start(c,l))}}},[n,v,E,O,a,e,S,D])}function Sl(e){return Qi&&e.movementX===0&&e.movementY===0}function Cl(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function wl(e,t){return Cl(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Tl(e,t,n){return Cl(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function El(e,t,n){return Cl(t,n?e===io:e===Ya,e===Aa)}function Dl(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:Cl(t,n?e===Ya:e===io,e===Ia)}function Ol(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,triggerOrientation:_=g,parentOrientation:v,id:y,resetOnPointerLeave:b=!0,externalTree:x,nestedReturnFocusRef:S,grid:C}=t,w=C!=null,T=e.useState(`open`),E=e.useState(`floatingElement`),D=e.useState(`domReferenceElement`),O=e.context.dataRef,k=Ji(E),A=lo(D),j=Hs(k),M=hc(),N=gc(x),P=X.useRef(f),F=X.useRef(o??-1),I=X.useRef(null),L=X.useRef(!0),R=J(e=>{i(F.current===-1?null:F.current,e)}),ee=X.useRef(!!E),te=X.useRef(T),ne=X.useRef(!1),z=X.useRef(!1),re=X.useRef(null),ie=Hs(h),B=Hs(T),V=Hs(o),ae=Hs(b),oe=Ki(),se=Ki(),ce=J(()=>{oe.cancel();function e(e){d||(re.current=$s(e,{sync:ne.current,preventScroll:!0}))}let t=n.current[F.current],r=z.current;t&&e(t),(ne.current?e=>e():e=>oe.request(e))(()=>{let i=n.current[F.current]||t;i&&(t||e(i),me&&(r||!L.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});G(()=>{O.current.orientation=g},[O,g]),G(()=>{T||(I.current=null),T&&f===`auto`||(P.current=f)},[T,f]),G(()=>{a&&(T&&E?(F.current=o??-1,P.current&&o!=null&&(z.current=!0,R())):ee.current&&(F.current=-1,R()))},[a,T,E,o,R]),G(()=>{if(a){if(!T)ne.current=!1;else if(E){if(r==null){if(ne.current=!1,V.current!=null)return;if(ee.current&&(F.current=-1,ce()),(!te.current||!ee.current)&&P.current&&(I.current!=null||P.current===!0&&I.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>se.request(e):queueMicrotask)(t),e+=1):(F.current=I.current==null||Tl(I.current,_,u)||l?ao(n):Ii(n),I.current=null,R())};t()}}else sa(n.current,r)||(F.current=r,ce(),z.current=!1)}}},[a,T,E,r,V,l,n,_,u,R,ce,se]),G(()=>{if(!a||E||!N||d||!ee.current)return;let e=N.nodesRef.current,t=e.find(e=>e.id===M)?.context?.elements.floating,n=ha(ua(D??t??null)),r=e.some(e=>e.context&&Y(e.context.elements.floating,n));t&&!r&&L.current&&t.focus({preventScroll:!0})},[a,E,D,N,M,d]),G(()=>{te.current=T,ee.current=!!E});let le=r!=null,ue=J(e=>{if(!B.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(F.current!==t||r!==t)&&(F.current=t,R(e))}),de=J(()=>v??N?.nodesRef.current.find(e=>e.id===M)?.context?.dataRef?.current.orientation),fe=J(()=>ao(n,ie.current)),pe=J(t=>{if(L.current=!1,ne.current=!0,t.which===229||!B.current&&t.currentTarget===j.current)return;if(l&&Dl(t.key,g,u,w)){wl(t.key,de())||ls(t),e.setOpen(!1,q(qa,t.nativeEvent));let n=S?.current??D;ro(n)&&n.focus();return}r!=null&&r!==F.current&&!sa(n.current,r)&&(F.current=r);let i=F.current,a=ao(n,h),o=Ii(n,h);if(A||(t.key===`Home`&&(ls(t),F.current=a,R(t)),t.key===`End`&&(ls(t),F.current=o,R(t))),C!=null){let e=C(t,F.current,n,g,c,u,h,a,o);if(e!=null&&e!==F.current&&(F.current=e,R(t)),g===`both`)return}if(wl(t.key,g)){ls(t);let e=ha(t.currentTarget.ownerDocument);if(T&&!d&&Y(t.currentTarget,e)&&!n.current.some(t=>t!=null&&Y(t,e))){F.current=Tl(t.key,g,u)?a:o,R(t),r===F.current&&ce();return}let{index:l,wrapped:f}=Pi(n.current,i,{decrement:!Tl(t.key,g,u),loopFocus:c,allowEscape:s,disabledIndices:h,minIndex:a,maxIndex:o});f&&(ne.current=!1),F.current=l,R(t)}}),me=X.useMemo(()=>({onFocus(e){ne.current=!0,ue(e)},onClick({currentTarget:e}){d||e.focus({preventScroll:!0})},onMouseMove(e){Sl(e)||(ne.current=!0,z.current=!1,p&&ue(e))},onPointerLeave(e){if(!B.current||!L.current||e.pointerType===`touch`)return;ne.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&ae.current&&(re.current?.(),re.current=null,F.current=-1,R(e),!d)){let e=j.current,t=ha(ua(e));e&&Y(e,t)&&e.focus({preventScroll:!0})}}}),[ue,B,j,p,n,R,ae,d]),he=X.useMemo(()=>d&&T&&le&&{"aria-activedescendant":`${y}-${r}`},[d,T,le,y,r]),ge=X.useMemo(()=>({...A?{}:he,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&T&&!d){let n=xa(t.nativeEvent);if(n&&!Y(j.current,n))return;ls(t);let r=q(_o,t.nativeEvent);e.setOpen(!1,r);let i=S?.current??D;!r.isCanceled&&ro(i)&&i.focus()}else pe(t)},onPointerMove(e){Sl(e)||(L.current=!0)}}),[he,pe,j,A,e,T,d,D,S]),_e=X.useMemo(()=>{function t(t){e.setOpen(!0,q(qa,t.nativeEvent,t.currentTarget))}function n(e){f===`auto`&&ds(e.nativeEvent)&&(P.current=!d)}function r(e){P.current=f,f===`auto`&&fs(e.nativeEvent)&&(P.current=!0)}return{onKeyDown(n){let r=e.select(`open`);L.current=!1;let i=n.key.startsWith(`Arrow`),a=El(n.key,de(),u),o=wl(n.key,r?g:_),s=(l?a:o)||n.key===`Enter`||n.key.trim()===``;if(d&&r&&(!l||za(n.currentTarget)))return pe(n);if(r||m||!i){if(s){let e=wl(n.key,de());I.current=l&&e?null:n.key}l?a&&(ls(n),r?(F.current=fe(),R(n),d&&j.current?.focus()):t(n)):o&&(V.current!=null&&(F.current=V.current),ls(n),!r&&m?t(n):pe(n),r&&R(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!d&&(F.current=-1,R(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[pe,f,fe,l,R,e,m,g,_,de,u,V,d,j]),ve=X.useMemo(()=>({...he,..._e}),[he,_e]);return X.useMemo(()=>a?{reference:ve,floating:ge,item:me,trigger:_e}:{},[a,ve,ge,_e,me])}function kl(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=J(s),f=e.useState(`open`),p=Ci(),m=X.useRef(``),h=X.useRef(u??i??-1),g=X.useRef(null),_=J(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!la(n)||n?.matches(`:disabled`)?!1:o==null||!da(na,e,o)}function c(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&s(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(ls(e),d?.(!0)),m.current.length>0&&m.current[0]!==` `&&c(_,m.current)===-1&&e.key!==` `&&d?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(ls(e),d?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&s(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,d?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=c(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,d?.(!1)):(a?.(b,e),g.current=b)}),v=J(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);Y(r,n)||Y(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});G(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``,d?.(!1)))},[f,u,p,d]);let y=X.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return X.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var Al=.1,jl=Al*Al,Ml=.5;function Nl(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function Pl(e,t,n,r,i,a,o,s,c,l){let u=!1;return Nl(e,t,n,r,i,a)&&(u=!u),Nl(e,t,i,a,o,s)&&(u=!u),Nl(e,t,o,s,c,l)&&(u=!u),Nl(e,t,c,l,n,r)&&(u=!u),u}function Fl(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function Il(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 Ll(e={}){let{blockPointerEvents:t=!1}=e,n=new Ti,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*jl;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=xa(r),g=r.type===`mouseleave`,_=Y(u,h),v=Y(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&ka(r.relatedTarget)&&Y(u,r.relatedTarget))return;function y(){return!!(s&&ss(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=Il(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=Il(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=Il(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=Il(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Fl(d,f,x)||!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?Ml/2:Ml*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+Ml+1,o=C||T?S.bottom-Ml:S.top,s=C?T?S.bottom-Ml:S.top:S.bottom-Ml;M=Pl(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?Ml/2:Ml*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-Ml,o=C||T?S.top+Ml:S.bottom,s=C?T?S.top+Ml:S.bottom:S.top+Ml;M=Pl(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?Ml/2:Ml*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+Ml+1,o=w||E?S.right-Ml:S.left,s=w?E?S.right-Ml:S.left:S.right-Ml;M=Pl(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?Ml/2:Ml*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-Ml,o=w||E?S.left+Ml:S.right,s=w?E?S.left+Ml:S.right:S.left+Ml;M=Pl(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 Rl(e,t,n){let{reference:r,floating:i}=e,a=Ds(t),o=Os(t),s=Es(o),c=Cs(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=ws(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function zl(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}=Ss(t,e),p=Bs(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Vs(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=Vs(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 Bl=50,Vl=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:zl},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Rl(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<Bl&&(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}=Rl(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Hl=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}=Ss(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Cs(r),_=Ds(o),v=Cs(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Rs(o)]:As(o)),x=p!==`none`;!d&&x&&b.push(...Ls(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=ks(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`||_===Ds(t)||T.every(e=>Ds(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=Ds(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{}}}},Ul=new Set([`left`,`top`]);async function Wl(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Cs(n),s=ws(n),c=Ds(n)===`y`,l=Ul.has(o)?-1:1,u=a&&c?-1:1,d=Ss(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 Gl=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 Wl(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}}}}},Kl=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}=Ss(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Ds(i),p=Ts(f),m=u[p],h=u[f],g=(e,t)=>xs(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}}}}}},ql=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}=Ss(e,t),u={x:n,y:r},d=Ds(i),f=Ts(d),p=u[f],m=u[d],h=Ss(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=Ul.has(Cs(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}}}},Jl=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}=Ss(e,t),c=await i.detectOverflow(t,s),l=Cs(n),u=ws(n),d=Ds(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=hs(p-c[m],g),y=hs(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*gs(c.left,c.right):S=p-2*gs(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 Yl(e){let t=Za(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ro(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=_s(n)!==a||_s(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Xl(e){return ka(e)?e:e.contextElement}function Zl(e){let t=Xl(e);if(!ro(t))return ys(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Yl(t),o=(a?_s(n.width):n.width)/r,s=(a?_s(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var Ql=ys(0);function $l(e){let t=vo(e);return!Oo()||!t.visualViewport?Ql:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function eu(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===vo(e)}function tu(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Xl(e),o=ys(1);t&&(r?ka(r)&&(o=Zl(r)):o=Zl(e));let s=eu(a,n,r)?$l(a):ys(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=vo(a),t=ka(r)?vo(r):r,n=e,i=_a(n);for(;i&&t!==n;){let e=Zl(i),t=i.getBoundingClientRect(),r=Za(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=vo(i),i=_a(n)}}return Vs({width:u,height:d,x:c,y:l})}function nu(e,t){let n=fo(e).scrollLeft;return t?t.left+n:tu(Ra(e)).left+n}function ru(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-nu(e,n),y:n.top+t.scrollTop}}function iu(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Ra(r),s=t?bo(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=ys(1),u=ys(0),d=ro(r);if((d||!a)&&((eo(r)!==`body`||Fa(o))&&(c=fo(r)),d)){let e=tu(r);l=Zl(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?ru(o,c):ys(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function au(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function ou(e){let t=fo(e),n=e.ownerDocument.body,r=gs(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=gs(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+nu(e),o=-t.scrollTop;return Za(n).direction===`rtl`&&(a+=gs(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var su=25;function cu(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=vo(e),a=Ra(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Oo()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(nu(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<=su&&(s-=o)}return{width:s,height:c,x:l,y:u}}function lu(e,t){let n=tu(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Zl(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function uu(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=cu(e,n,t);else if(t===`document`)r=ou(Ra(e));else if(ka(t))r=lu(t,n);else{let n=$l(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Vs(r)}function du(e,t){let n=t.get(e);if(n)return n;let r=Ca(e,[],!1).filter(e=>ka(e)&&eo(e)!==`body`),i=null,a=Za(e).position===`fixed`,o=a?Ga(e):e;for(;ka(o)&&!Ja(o);){let e=Za(o),t=Ea(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Ga(o)}return t.set(e,r),r}function fu(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?bo(t)?[]:du(t,this._c):[].concat(n),r],o=uu(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=uu(t,a[e],i);s=gs(n.top,s),c=hs(n.right,c),l=hs(n.bottom,l),u=gs(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function pu(e){let{width:t,height:n}=Yl(e);return{width:t,height:n}}function mu(e,t,n){let r=ro(t),i=Ra(t),a=n===`fixed`,o=tu(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=ys(0);if((r||!a)&&((eo(t)!==`body`||Fa(i))&&(s=fo(t)),r)){let e=tu(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=nu(i));let l=i&&!r&&!a?ru(i,s):ys(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function hu(e){return Za(e).position===`static`}function gu(e,t){if(!ro(e)||Za(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Ra(e)===n&&(n=n.ownerDocument.body),n}function _u(e,t){let n=vo(e);if(bo(e))return n;if(!ro(e)){let t=Ga(e);for(;t&&!Ja(t);){if(ka(t)&&!hu(t))return t;t=Ga(t)}return n}let r=gu(e,t);for(;r&&ma(r)&&hu(r);)r=gu(r,t);return r&&Ja(r)&&hu(r)&&!Ea(r)?n:r||co(e)||n}var vu=async function(e){let t=this.getOffsetParent||_u,n=this.getDimensions,r=await n(e.floating);return{reference:mu(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function yu(e){return Za(e).direction===`rtl`}var bu={convertOffsetParentRelativeRectToViewportRelativeRect:iu,getDocumentElement:Ra,getClippingRect:fu,getOffsetParent:_u,getElementRects:vu,getClientRects:au,getDimensions:pu,getScale:Zl,isElement:ka,isRTL:yu};function xu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Su(e,t,n){let r=null,i,a=Ra(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=vs(d),h=vs(a.clientWidth-(u+f)),g=vs(a.clientHeight-(d+p)),_=vs(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:gs(0,hs(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!xu(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=vo(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Cu(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=Xl(e),u=i||a?[...l?Ca(l):[],...t?Ca(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Su(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?tu(e):null;c&&g();function g(){let t=tu(e);h&&!xu(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var wu=Gl,Tu=Kl,Eu=Hl,Du=Jl,Ou=ql,ku=(e,t,n)=>{let r=new Map,i=n??{},a={...bu,...i.platform,_c:r};return Vl(e,t,{...i,platform:a})},Au=typeof document<`u`?X.useLayoutEffect:function(){};function ju(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(!ju(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)&&!ju(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Mu(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Nu(e,t){let n=Mu(e);return Math.round(t*n)/n}function Pu(e){let t=X.useRef(e);return Au(()=>{t.current=e}),t}function Fu(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]=X.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=X.useState(r);ju(f,r)||p(r);let[m,h]=X.useState(null),[g,_]=X.useState(null),v=X.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=X.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=X.useRef(null),C=X.useRef(null),w=X.useRef(u),T=c!=null,E=Pu(c),D=Pu(i),O=Pu(l),k=X.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),ku(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!ju(w.current,t)&&(w.current=t,zc.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);Au(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=X.useRef(!1);Au(()=>(A.current=!0,()=>{A.current=!1}),[]),Au(()=>{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=X.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=X.useMemo(()=>({reference:b,floating:x}),[b,x]),N=X.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=Nu(M.floating,u.x),r=Nu(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Mu(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return X.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var Iu=(e,t)=>{let n=wu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Lu=(e,t)=>{let n=Tu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ru=(e,t)=>({fn:Ou(e).fn,options:[e,t]}),zu=(e,t)=>{let n=Eu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Bu=(e,t)=>{let n=Du(e);return{name:n.name,fn:n.fn,options:[e,t]}};function Vu(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]=X.useState(null),d=X.useRef(null),f=gc(n),p=X.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=Fu({...e,elements:{...p,...l&&{reference:l}}}),h=X.useCallback(e=>{let t=ka(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=X.useMemo(()=>({...m.refs,setPositionReference:h,domReference:d}),[m.refs,h]),_=X.useMemo(()=>({...m.elements,domReference:o}),[m.elements,o]),v=X.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 G(()=>{o&&(d.current=o)},[o]),G(()=>{r.context.dataRef.current.floatingContext=v;let e=f?.nodesRef.current.find(e=>e.id===t);e&&(e.context=v)}),X.useMemo(()=>({...m,context:v,refs:g,elements:_,rootStore:r}),[m,g,_,v,r])}var Hu=X.createContext(void 0);function Uu(){return X.useContext(Hu)?.direction??`ltr`}var Wu=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}=Ss(e,t)||{};if(l==null)return{};let d=Bs(u),f={x:n,y:r},p=Os(i),m=Es(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=xs(D,k,O),j=!c.arrow&&ws(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}}}),Gu=(e,t)=>{let{name:n,fn:r}=Wu(e);return{name:n,fn:r,options:[e,t]}},Ku={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}}}},qu={sideX:`left`,sideY:`top`},Ju=`--available-width`,Yu=`--available-height`,Xu=`--anchor-width`,Zu=`--anchor-height`,Qu=`--transform-origin`,$u=Ju,ed=Yu;function td(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 nd(e,t,n){let{rects:r,placement:i}=e;return{side:td(t,Cs(i),n),align:ws(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function rd(e){return id(e,Vu)}function id(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,C=_.side||`flip`,w=_.align||`flip`,T=_.fallbackAxisSide||`end`,E=v?.crossAxis??!1,D=v?.rootBoundary,O=typeof n==`function`?n:void 0,k=J(O),A=O?k:n,j=Hs(n),M=Hs(g),N=Uu()===`rtl`,[P,F]=X.useState(null);!g&&P!==null&&F(null);let I=x===`placement`,L=P?Cs(P):null,R=P&&I?ws(P)||`center`:null,ee=L||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":N?`left`:`right`,"inline-start":N?`right`:`left`}[i],te=R||o,ne=te===`center`?ee:`${ee}-${te}`,z=l;typeof z==`number`?z={top:z,right:z,bottom:z,left:z}:z&&={top:z.top||0,right:z.right||0,bottom:z.bottom||0,left:z.left||0};let re=+(i===`bottom`),ie=+(i===`top`),B=+(i===`right`),V=+(i===`left`),ae={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:z},oe=X.useRef(null),se=Hs(a),ce=Hs(s),le=typeof a==`function`?0:a,ue=typeof s==`function`?0:s,de=[];p&&de.push(p),de.push(Iu(e=>{let t=nd(e,i,N),n=typeof se.current==`function`?se.current(t):se.current,r=typeof ce.current==`function`?ce.current(t):ce.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[le,ue,N,i]));let fe=w===`none`&&C!==`shift`,pe=!fe&&(u||E||C===`shift`),me=C===`none`?null:zu({...ae,padding:{top:z.top+1+re,right:z.right+1+V,bottom:z.bottom+1+ie,left:z.left+1+B},mainAxis:!E&&C===`flip`,crossAxis:w===`flip`&&`alignment`,fallbackAxisSideDirection:T}),he=fe?null:Lu({...ae,rootBoundary:D,mainAxis:w!==`none`,crossAxis:pe,limiter:u||E?void 0:Ru(e=>{if(!oe.current)return{};let{width:t,height:n}=oe.current.getBoundingClientRect(),r=Ds(Cs(e.placement)),i=r===`y`?t:n,a=r===`y`?z.left+z.right:z.top+z.bottom;return{offset:i/2+a/2}})},[ae,u,E,D,z,w]);C===`shift`||w===`shift`||te===`center`?de.push(he,me):de.push(me,he),de.push(Bu({...ae,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!M.current)return;let i=e.style;i.setProperty($u,`${t}px`),i.setProperty(ed,`${n}px`);let a=vo(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(Xu,`${u}px`),i.setProperty(Zu,`${d}px`)}}),Gu(e=>({element:oe.current||ua(e.elements.floating).createElement(`div`),padding:oe.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=Cs(r),u=ws(r),d=Ds(l)===`y`,f=oe.current,p=typeof a==`function`?a(nd(e,i,N)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return pe&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(Qu,d?`${m} ${h}`:`${h} ${m}`),{}}},Ku,b),G(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let ge=X.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:_e,elements:ve,x:ye,y:be,middlewareData:xe,update:Se,placement:Ce,context:we,isPositioned:Te,floatingStyles:Ee}=t({rootContext:h,open:m?g:void 0,placement:ne,middleware:de,strategy:r,whileElementsMounted:m?void 0:(...e)=>Cu(...e,ge),nodeId:y,externalTree:S}),{sideX:De,sideY:Oe}=xe.adaptiveOrigin||qu,ke=Te?r:`fixed`,Ae=X.useMemo(()=>{let e;return e=Te?b?{position:ke,[De]:ye,[Oe]:be}:{...Ee,position:ke}:{position:ke,top:0,left:0},e[$u]=`100vw`,e[ed]=`100vh`,Te||(e.opacity=0),e},[b,ke,De,ye,Oe,be,Ee,Te]),je=X.useRef(null);G(()=>{if(!g)return;let e=j.current,t=typeof e==`function`?e():e,n=(ad(t)?t.current:t)||null;n!==je.current&&(_e.setPositionReference(n),je.current=n)},[g,_e,A,j]),X.useEffect(()=>{if(!g)return;let e=j.current;typeof e!=`function`&&ad(e)&&e.current!==je.current&&(_e.setPositionReference(e.current),je.current=e.current)},[g,_e,A,j]),X.useEffect(()=>{if(m&&g&&ve.reference&&ve.floating)return Cu(ve.reference,ve.floating,Se,ge)},[m,g,ve,Se,ge]);let Me=Cs(Ce),Ne=td(i,Me,N),Pe=ws(Ce)||`center`,Fe=!!xe.hide?.referenceHidden;G(()=>{x&&g&&Te&&(Me!==ee||I&&Pe!==te)&&F(Ce)},[x,I,g,Te,Ce,Me,Pe,ee,te]);let Ie=X.useMemo(()=>({position:`absolute`,top:xe.arrow?.y,left:xe.arrow?.x}),[xe.arrow]),Le=xe.arrow?.centerOffset!==0;return X.useMemo(()=>({positionerStyles:Ae,arrowStyles:Ie,arrowRef:oe,arrowUncentered:Le,side:Ne,align:Pe,physicalSide:Me,anchorHidden:Fe,refs:_e,context:we,isPositioned:Te,update:Se}),[Ae,Ie,oe,Le,Ne,Pe,Me,Fe,_e,we,Te,Se])}function ad(e){return e!=null&&`current`in e}function od(e){return e===`starting`?Si:oa}function sd(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),ji(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},od(r),i],stateAttributesMapping:as})}var cd=e(a(),1);function ld(e){let t=cd.unstable_scheduleCallback(4,e);return()=>cd.unstable_cancelCallback(t)}var ud=X.createContext(u({scheduleTask:ld,defaultIdleTTL:400})),dd=new WeakMap,fd=0,pd=new Set;function md(e){fd++;try{return e()}finally{fd--}}function hd(e){if(fd===0)return e();pd.size===0&&queueMicrotask(gd),pd.add(e)}function gd(){for(let e of pd)pd.delete(e),e()}function _d(e,t){let n=dd.get(e);n===void 0&&(n=new WeakMap,dd.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,()=>hd(n));return()=>{i--,pd.delete(n),r()}},snapshot(){return md(()=>e.get(t))},getServerSnapshot(){return(i===0||a===void 0)&&(a={value:md(()=>zt(t,e))}),a.value}};return n.set(t,o),o}function vd(e,t){let n=_d(e,t);return X.useEffect(gd),X.useSyncExternalStore(n.subscribe,n.snapshot,n.getServerSnapshot)}function yd(e,t,n){let r=_d(e,t),i=X.useMemo(()=>{let e;return t=>(e!==void 0&&Object.is(e.source,t)||(e={source:t,value:n(t)}),e.value)},[n]);return X.useEffect(gd),X.useSyncExternalStore(r.subscribe,()=>i(r.snapshot()),()=>i(r.getServerSnapshot()))}var bd=(e,t)=>{let n=X.useContext(ud);return t?yd(n,e,t):vd(n,e)};function xd(e,t){X.useEffect(()=>e.mount(t),[t,e])}function Sd(e,t,n){return n?.mode===`promise`||n?.mode===`promiseExit`?X.useCallback(r=>{e.set(t,r);let i=si(Hn(e,t,{suspendOnWaiting:!0}));return n.mode===`promise`?i.then(Cd):i},[e,t,n.mode]):X.useCallback(n=>{e.set(t,typeof n==`function`?n(e.get(t)):n)},[e,t])}var Cd=e=>{if(Jr(e))return e.value;throw tt(e.cause)},wd=(e,t)=>{let n=X.useContext(ud);return xd(n,e),Sd(n,e,t)},Td=e=>{let t=X.useContext(ud);return xd(t,e),X.useCallback(()=>{t.refresh(e)},[t,e])},Ed=(e,t)=>{let n=X.useContext(ud);return[vd(n,e),Sd(n,e,t)]},Dd={suspendOnWaiting:new WeakMap,default:new WeakMap};function Od(e,t,n){let r=n?Dd.suspendOnWaiting:Dd.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 kd(e,t,n){let r=vd(e,t);if(r._tag===`Initial`||n&&r.waiting)throw Od(e,t,n);return r}var Ad=(e,t)=>{let n=kd(X.useContext(ud),e,t?.suspendOnWaiting??!1);if(n._tag===`Failure`&&!t?.includeFailure)throw tt(n.cause);return n};ui(`MachineSchemaEncodeError`);var jd=class extends ui(`MachineSchemaDecodeError`){},Md=class extends ui(`InfiniteTransitionError`){},Nd=class extends ui(`StartupError`){},Pd=class extends ui(`ChildAlreadyExistsError`){};ui(`ProcessLocalError`);var Fd=class extends ui(`StoppedError`){},Id=e=>e instanceof Md||e instanceof jd,Ld=e=>Id(e)?Ze(e):Nt(e),Rd=e=>Id(e)||e instanceof Nd?e:new Nd({cause:Wn(e)}),zd=e=>e,Bd=`~effect/Machine/Target`,Vd=Symbol(`effect/Machine/TargetSnapshot`),Hd=Symbol(`effect/Machine/StateInput`),Ud=Symbol(`effect/Machine/HistoryTarget`),Wd=Symbol(`effect/Machine/InitialTarget`),Gd=Symbol(`effect/Machine/ChoiceTarget`),Kd=Symbol(`effect/Machine/NoTarget`),qd=Symbol(`effect/Machine/Declined`),Jd=Symbol(`effect/Machine/TargetSelection`),Yd=Symbol(`effect/Machine/StateUpdate`),Xd=Symbol(`effect/Machine/CombinedTarget`),Zd=Symbol(`effect/Machine/SelectedBranch`),Qd=(e,t,n,r)=>Object.freeze({[Jd]:Jd,kind:e,scope:n,path:t,...r===void 0?{}:{updatePath:r}}),$d=Qd(`none`,void 0,`local`),ef=e=>W(e,Jd),tf=(e,t)=>Object.freeze({[Yd]:Yd,path:e,value:t}),nf=e=>W(e,Yd),rf=(e,t)=>Object.freeze({[Xd]:Xd,target:e,update:t}),af=e=>W(e,Xd),of=(e,t,n,r)=>Object.freeze({[Zd]:Zd,owner:e,branchIndex:t,branchKey:n,result:r}),sf=e=>W(e,Zd),cf=Object.freeze({[Kd]:Kd}),lf=()=>cf,uf=e=>W(e,Kd),df=Object.freeze({[qd]:qd}),ff=()=>df,pf=e=>W(e,qd),mf=(e,t)=>({[Ud]:Ud,path:e,parent:t}),hf=e=>W(e,Ud),gf=(e,t,n)=>({[Wd]:Wd,_tag:`InitialTarget`,path:e,value:t,...n===void 0?{}:{values:n}}),_f=e=>W(e,Wd),vf=(e,t,n)=>({[Gd]:Gd,path:e,parent:t,...n===void 0?{}:{values:n}}),yf=e=>W(e,Gd),bf=(e,t)=>{if(!Je(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(!Je(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(Je(t))return{schema:t,output:void 0,annotations:pi(t),type:`atomic`,history:void 0,initial:void 0,states:void 0};let n=W(t,`schema`)&&Je(t.schema)?t.schema:void 0,r=n===void 0?t.annotations:pi(n);if(t.type===`parallel`&&!W(t,`states`))throw Error(`Machine.make expected parallel state "${e}" to declare child regions`);if(W(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:Je(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=Je(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}},xf=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=bf(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)}},Sf=e=>typeof e==`object`&&e&&`branches`in e&&Array.isArray(e.branches)?Array.from(e.branches):[],Cf=e=>typeof e==`object`&&e&&`declinable`in e&&e.declinable===!0?`declinable`:`required`,wf=e=>{let t=[];for(let n of e.stateNodes.byPath.values()){let r=zd(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:Sf(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:W(i,`reenter`)&&i.reenter===!0,acceptance:Cf(i),branches:Sf(i)})}r.always!==void 0&&t.push({source:n.path,trigger:{type:`always`},reenter:!1,acceptance:Cf(r.always),branches:Sf(r.always)}),r.onDone!==void 0&&t.push({source:n.path,trigger:{type:`done`},reenter:!1,acceptance:Cf(r.onDone),branches:Sf(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:Cf(a),branches:Sf(a)})}}}return t},Tf=(e,t,n)=>({[Bd]:Bd,[Vd]:n?.snapshot,path:e,value:t,values:n?.values}),Ef=e=>W(e,Bd),Df=e=>({[Hd]:Hd,input:e}),Of=e=>W(e,Hd),kf=e=>W(e,`path`)&&W(e,`value`),Af=(e,t,n)=>{if(e.path===t)return qr(e);if(e.path!==``&&!t.startsWith(`${e.path}.`))return ot();if(n!==void 0&&e.value!==void 0&&(n[e.path]=e.value),W(e,`state`)&&kf(e.state))return Af(e.state,t,n);if(W(e,`states`)&&typeof e.states==`object`&&e.states!==null){for(let r of Object.values(e.states))if(kf(r)){let e=Af(r,t,n);if(Vr(e))return e}}return ot()},Q=(e,t)=>{let n=e.stateNodes.byPath.get(t);if(n===void 0)throw Error(`Machine expected state path "${t}" to exist`);return n},jf=e=>{if(e.schema===void 0)throw Error(`Machine state "${e.path}" has no value schema`);return e.schema},Mf=new WeakMap,Nf=Symbol(`effect/Machine/EventConstruction`),Pf=new WeakMap,Ff=new WeakMap,If=new WeakMap,Lf=e=>{let t=e,n=Ff.get(t);if(n!==void 0)return n;let r=Ue(Ct(e));return Ff.set(t,r),r},Rf=e=>{let t=e,n=If.get(t);if(n!==void 0)return n;let r=qn(Ct(e));return If.set(t,r),r},zf=Symbol.for(`effect/Machine/protocol`),Bf=e=>{let t=e[zf];if(t===void 0)throw Error(`Machine protocol is unavailable`);return t},Vf=(e,t)=>{Object.defineProperty(e,zf,{value:t,enumerable:!1})},Hf=e=>{let t=new Set,n=e=>{let r=e;if(!t.has(r)&&(t.add(r),W(e,`cases`)&&typeof e.cases==`object`&&e.cases!==null))for(let t of Object.values(e.cases))(typeof t==`object`&&t||typeof t==`function`)&&W(t,`make`)&&n(t)};for(let t of e)n(t);return t},Uf=(e,t)=>{let n=Mf.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},Wf=e=>Uf(e.events,`public`).schemas,Gf=e=>Uf(e.internalEvents,`internal`).schemas,Kf=e=>Uf(e.emittedEvents,`emitted`).schemas,qf=e=>{let t=Wf(e),n=Gf(e),r=Kf(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];Vf(e,{event:L(a),emit:L(r),eventConstructors:Hf(a),emissionConstructors:Hf(r)})},Jf=(e,t)=>Vf(t,Bf(e)),Yf=e=>W(e,`_tag`)?String(e._tag):void 0,Xf=(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={[Nf]:Nf,_tag:n};return Pf.set(o,{kind:e,schema:t,input:i,...a===void 0?{}:{inputError:a}}),Object.freeze(o)},Zf=e=>typeof e==`object`&&!!e&&Pf.has(e),Qf=(e,t)=>{let n=[],r=e=>{if(W(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(W(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=>Et(e)?typeof e.literal==`string`||typeof e.literal==`number`?[e.literal]:[]:l(e)?[e.symbol]:yt(e)?e.enums.map(([,e])=>e):Qe(e)?e.types.flatMap(a):Ft(e)?a(e.thunk()):[],o=e=>{let t=pn(e.ast);if(Se(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 L([e]).pipe(y(`_tag`)).discriminants}catch{return[]}};for(let t of n){let n=o(t);if(n.length!==0)for(let r of n){if(W(i,r))throw Error(`Duplicate machine event constructor tag: ${String(r)}`);Object.defineProperty(i,r,{value:(...n)=>Xf(e,t,r,n.length===0?{}:n[0]),enumerable:!0})}}return i},$f=(e,t)=>{let n=Object.freeze(Array.from(t)),r=Qf(e,n);return Mf.set(r,{kind:e,schemas:n}),Object.freeze(r)},ep=(e,t,n,r)=>Lf(t)(n).pipe(dn(t=>new jd({machineId:e.id,boundary:r.boundary,cause:t,...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}}))),tp=(e,t,n,r)=>{let i=Rf(t)(n);if(nn(i))throw new jd({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},np=(e,t,n,r)=>{try{return t.make(n)}catch(t){let n=t instanceof Error?t.cause:void 0;throw new jd({machineId:e.id,boundary:r.boundary,cause:re(t)?t:W(n,`~effect/SchemaIssue/Issue`)?new en(n):Wn(t),...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}})}},rp=(e,t,n)=>new jd({machineId:e.id,boundary:n,event:String(t._tag),cause:Wn(Error(`Constructed ${n} schema does not belong to the machine ${n} protocol`))}),ip=(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}},ap=(e,t,n,r)=>new jd({machineId:e.id,boundary:n,event:String(t._tag),cause:Wn(r)}),op=(e,t,n,r)=>{let i=Pf.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)?Ze(rp(e,n,r)):je({try:()=>ip(n,i),catch:t=>ap(e,n,r,t)}).pipe(U(t=>i.schema.makeEffect(t).pipe(dn(t=>new jd({machineId:e.id,boundary:r,event:String(n._tag),cause:new en(t)})))))},sp=(e,t,n,r)=>{let i=Pf.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 rp(e,n,r);let o;try{o=ip(n,i)}catch(t){throw ap(e,n,r,t)}return np(e,i.schema,o,{boundary:r,event:String(n._tag)})},cp=(e,t)=>{let n=Bf(e);if(Zf(t))return op(e,n,t,`event`);let r=Yf(t);return ep(e,n.event,t,r===void 0?{boundary:`event`}:{boundary:`event`,event:r})},lp=(e,t)=>{let n=Bf(e);if(Zf(t))return sp(e,n,t,`event`);let r=Yf(t);return tp(e,n.event,t,r===void 0?{boundary:`event`}:{boundary:`event`,event:r})},up=(e,t)=>{let n=Bf(e);if(Zf(t))return op(e,n,t,`emission`);let r=Yf(t);return ep(e,n.emit,t,r===void 0?{boundary:`emission`}:{boundary:`emission`,event:r})},dp=(e,t)=>{let n=Bf(e);if(Zf(t))return sp(e,n,t,`emission`);let r=Yf(t);return tp(e,n.emit,t,r===void 0?{boundary:`emission`}:{boundary:`emission`,event:r})},fp=(e,t,n)=>tp(e,t,n,{boundary:`input`}),pp=(e,t,n)=>Of(n)?jf(t).makeEffect(n.input).pipe(dn(n=>new jd({machineId:e.id,boundary:`state`,state:t.path,cause:new en(n)}))):ep(e,jf(t),n,{boundary:`state`,state:t.path}),mp=(e,t,n)=>Of(n)?np(e,jf(t),n.input,{boundary:`state`,state:t.path}):tp(e,jf(t),n,{boundary:`state`,state:t.path}),hp=(e,t,n)=>t.output===void 0?mt(n):ep(e,t.output,n,{boundary:`output`,state:t.path}),gp=(e,t,n)=>t.output===void 0?n:tp(e,t.output,n,{boundary:`output`,state:t.path}),_p=(e,t)=>{let n=new Set(Dp(e,t.parent)),r=n=>{let i=Q(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)&&!Ep(r,t.parent))throw Error(`Machine history contains state "${r}" outside parent "${t.parent}"`);if(t.mode===`shallow`&&Tp(r,t.parent)&&Q(e,r).parent!==t.parent)throw Error(`Machine shallow history contains deep descendant "${r}"`)}},vp=(e,t)=>{let n=new Map;for(let[r,i]of Object.entries(t.history??{})){let t=Q(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=Q(e,n);if(r.type===`history`||r.type===`choice`||!(Ep(n,t.parent)||Dp(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,mp(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}),_p(e,n.get(r))}return n},yp=Nr(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*Ze(new jd({machineId:e.id,boundary:`history`,state:r,cause:Wn(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`||!(Ep(n,t.parent)||Dp(e,t.parent).includes(n)))return yield*Ze(new jd({machineId:e.id,boundary:`history`,state:n,cause:Wn(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*Ze(new jd({machineId:e.id,boundary:`history`,state:n,cause:Wn(Error(`Machine snapshot contains a value for structural state "${n}"`))}))}else{if(!s)return yield*Ze(new jd({machineId:e.id,boundary:`history`,state:n,cause:Wn(Error(`Machine snapshot omits remembered value for "${n}"`))}));o.set(n,yield*ep(e,jf(r),i.values[n],{boundary:`history`,state:n}))}}if(!a.has(t.parent)||Object.keys(i.values).length!==o.size)return yield*Ze(new jd({machineId:e.id,boundary:`history`,state:r,cause:Wn(Error(`Machine snapshot contains incomplete history record "${r}"`))}));n.set(r,{mode:i.mode,parent:t.parent,active:a,values:o});try{_p(e,n.get(r))}catch(t){return yield*Ze(new jd({machineId:e.id,boundary:`history`,state:r,cause:Wn(t)}))}}return n}),bp=(e,t)=>{let n={};for(let[r,i]of t){let t=Array.from(i.active).sort((t,n)=>kp(e,t,n));n[r]={mode:i.mode,active:t,values:Object.fromEntries(i.values)}}return n},xp=(e,t)=>({...e,machineReferences:{self:t.self,parent:t.parent}}),Sp=e=>e.machineReferences,Cp=new WeakMap,wp=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Tp=(e,t)=>e!==t&&(t===``||e.startsWith(`${t}.`)),Ep=(e,t)=>e===t||Tp(e,t),Dp=(e,t)=>{let n=Cp.get(e.stateNodes);n===void 0&&(n=new Map,Cp.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=Q(e,a).parent;return n.set(t,i),i},Op=(e,t)=>Dp(e,t).length,kp=(e,t,n)=>Q(e,t).order-Q(e,n).order,Ap=(e,t,n)=>Q(e,n).children.some(e=>t.active.has(e)),jp=(e,t)=>{let n=Array.from(t.active).filter(n=>!Ap(e,t,n)).sort((t,n)=>kp(e,t,n));if(n.length===0)throw Error(`Machine expected an active leaf state`);return n},Mp=(e,t)=>jp(e,t)[0],Np=(e,t,n)=>{let r=jp(e,t).filter(e=>Ep(e,n));if(r.length===0)throw Error(`Machine expected state "${n}" to have an active leaf state`);return r[0]},Pp=(e,t)=>{for(let n of t.active)if(Q(e,n).parent===void 0)return n;throw Error(`Machine expected an active root state`)},Fp=(e,t,n)=>{let r={},i=Dp(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},Ip=(e,t,n)=>{let r=Q(e,n).parent;return r===void 0?void 0:t.values.get(r)},Lp=(e,t)=>{let n=r=>t.active.has(r)?[r,...Q(e,r).children.flatMap(n)]:[];return e.stateNodes.roots.flatMap(n)},Rp=(e,t,n)=>{let r=Q(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=Rp(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=Q(e,i);a[r.key]=Rp(e,t,i)}i.states=a}return i},zp=(e,t)=>{let n=Rp(e,t,Pp(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:bp(e,t.history)}),n},Bp=(e,t,n)=>{let r=Rp(e,t,n);return t.history.size>0&&Object.assign(r,{history:bp(e,t.history)}),r},Vp=(e,t,n)=>{if(!W(n,`state`)||!kf(n.state))throw Error(`Machine expected compound snapshot "${t.path}" to include an active child state`);let r=Q(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},Hp=(e,t)=>{if(!W(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},Up=(e,t,n,r)=>{let i=Q(e,n),a=r[i.key];if(!wp(r,i.key)||!kf(a))throw Error(`Machine expected parallel snapshot "${t.path}" to include region "${i.key}"`);let o=Q(e,String(a.path));if(o.path!==i.path)throw Error(`Machine expected snapshot "${o.path}" to be region "${i.path}"`);return a},Wp=(e,t)=>{let n=new Set,r=new Map,i=t.completed,a=t=>{let i=Q(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,mp(e,i,t.value));if(i.type===`compound`&&a(Vp(e,i,t)),i.type===`parallel`){let n=Hp(i,t);for(let t of i.children)a(Up(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:vp(e,t)}},Gp=(e,t)=>Wp(e,t),Kp=(e,t)=>{try{return Wp(e,t)}catch(t){throw t instanceof jd?t:new jd({machineId:e.id,boundary:`configuration`,cause:Wn(t)})}},qp=Nr(function*(e,t){let n=new Set,r=new Map,i=t.completed,a=Nr(function*(t){let i=Q(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*pp(e,i,t.value));if(i.type===`compound`&&(yield*a(Vp(e,i,t))),i.type===`parallel`){let n=Hp(i,t);for(let t of i.children)yield*a(Up(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*yp(e,t)}}),Jp=(e,t)=>qp(e,t).pipe(be(t=>{if(Fe(t))return c(Te(t,t=>t instanceof jd?t:new jd({machineId:e.id,boundary:`configuration`,cause:f(t)})));let n=Rn(t);return Vr(n)&&n.value instanceof jd?Ze(n.value):Ze(new jd({machineId:e.id,boundary:`configuration`,cause:t}))})),Yp=(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 Dp(e,n.parent))t.active.has(r)&&o.add(r);for(let i of t.active)(i===n.parent||r===`deep`&&Tp(i,n.parent)||r===`shallow`&&Q(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}},Xp=(e,t)=>e.history.get(t),Zp=(e,t,n)=>{let r=new Set(n.active),i=new Map(n.values),a=new Map,o=Dp(e,n.parent),s=new Set(o);for(let c of o){let o=Q(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)Ep(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}};Nr(function*(e,t,n,r,i){let a=Q(e,n),o=new Set,s=new Map,c=new Map,l=Dp(e,a.path),u=new Set(l);for(let n of l){let c=Q(e,n);if(o.add(n),c.schema===void 0){if((n===a.path?r:i!==void 0&&wp(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*pp(e,c,r));else if(i!==void 0&&wp(i,n))s.set(n,yield*pp(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=Q(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)Ep(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}}),Nr(function*(e,t,n,r){let i=yield*qp(e,n),a=new Set(i.active),o=new Map(i.values),s=new Map(i.outputs),c=Dp(e,String(n.path)),l=new Set(c);for(let i of c.slice(0,-1)){let s=Q(e,i);if(a.add(i),s.schema===void 0){if(r!==void 0&&wp(r,i))throw Error(`Machine structural target "${i}" cannot contain a value`)}else if(r!==void 0&&wp(r,i))o.set(i,yield*pp(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=Q(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)Ep(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&&wp(r,n))for(let[t,i]of Object.entries(r)){if(!Ep(t,n))continue;let r=Q(e,t);if(a.add(t),r.schema===void 0)throw Error(`Machine structural target "${t}" cannot contain a value`);o.set(t,yield*pp(e,r,i))}}}}return{active:a,values:o,outputs:s,history:new Map([...t.history,...i.history])}});var Qp=(e,t,n,r,i,a=!1)=>{let o=Q(e,n),s=new Set,c=new Map,l=new Map,u=Dp(e,o.path),d=new Set(u);for(let n of u){let a=Q(e,n);if(s.add(n),a.schema===void 0){if((n===o.path?r:i!==void 0&&wp(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,mp(e,a,r));else if(i!==void 0&&wp(i,n))c.set(n,mp(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=Q(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)Ep(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}},$p=(e,t,n)=>{let r=Qp(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=Q(e,t);i.add(t),n.schema!==void 0&&a.set(t,mp(e,n,r))}return{...r,active:i,values:a}},em=(e,t,n,r)=>{let i=Wp(e,n),a=new Set(i.active),o=new Map(i.values),s=new Map(i.outputs),c=Dp(e,String(n.path)),l=new Set(c);for(let i of c.slice(0,-1)){let s=Q(e,i);if(a.add(i),s.schema===void 0){if(r!==void 0&&wp(r,i))throw Error(`Machine structural target "${i}" cannot contain a value`)}else if(r!==void 0&&wp(r,i))o.set(i,mp(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=Q(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)Ep(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&&wp(r,n))for(let[t,i]of Object.entries(r)){if(!Ep(t,n))continue;let r=Q(e,t);if(a.add(t),r.schema===void 0)throw Error(`Machine structural target "${t}" cannot contain a value`);o.set(t,mp(e,r,i))}}}}return{active:a,values:o,outputs:s,history:new Map([...t.history,...i.history])}},tm=(e,t,n)=>{if(Ef(n)){let r=n[Vd];if(r!==void 0){if(String(r.path)!==String(n.path))throw Error(`Machine expected target snapshot path to be "${n.path}"`);return em(e,t,r,n.values)}return Qp(e,t,n.path,n.value,n.values)}if(kf(n)){let r=Kp(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`)},nm=(e,t)=>zd(e).handlers[t],rm=(e,t,n)=>Q(e,n).children.find(e=>t.active.has(e)),im=(e,t)=>Q(e,t).type===`final`,am=(e,t)=>nm(e,t)?.onDone!==void 0,om=(e,t,n)=>{if(!t.active.has(n))return!1;let r=Q(e,n);if(r.type===`compound`){let r=rm(e,t,n);return r!==void 0&&(n===``?!am(e,r)&&om(e,t,r):im(e,r))}if(r.type===`parallel`){for(let n of r.children)if(!om(e,t,n))return!1;return!0}return im(e,n)},sm=(e,t)=>{let n=Pp(e,t);return om(e,t,n)&&!am(e,n)},cm=(e,t,n)=>e.has(t)?{path:t,output:e.get(t),isNew:!1}:(e.set(t,n),{path:t,output:n,isNew:!0}),lm=Nr(function*(e,t,n,r,i){let a=Q(e,n),o=nm(e,n)?.output?.({state:t.values.get(n),containingState:Ip(e,t,n),ancestors:Fp(e,t,n),event:r,outputs:i});return yield*hp(e,a,o)}),um=Nr(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=Q(e,n);if(o.type===`compound`){let o=rm(e,t,n);if(o===void 0||(n===``?am(e,o):!im(e,o)))return;let s=yield*um(e,t,o,r,i,a);if(s===void 0)return;let c=cm(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*um(e,t,n,r,i,a);o===void 0?c=!1:s[Q(e,n).key]=o.output}if(!c)return;let l=cm(i,n,yield*lm(e,t,n,r,s));return l.isNew&&a.push(l),l}if(!im(e,n))return;let s=cm(i,n,yield*lm(e,t,n,r));return s.isNew&&a.push(s),s}),dm=Nr(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=Op(e,n)-Op(e,t);return r===0?kp(e,t,n):r}))yield*um(e,a,t,n,r,i);return{configuration:a,completions:i}}),fm=(e,t,n,r,i)=>{let a=Q(e,n),o=nm(e,n)?.output?.({state:t.values.get(n),containingState:Ip(e,t,n),ancestors:Fp(e,t,n),event:r,outputs:i});return gp(e,a,o)},pm=(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=Q(e,n);if(o.type===`compound`){let o=rm(e,t,n);if(o===void 0||(n===``?am(e,o):!im(e,o)))return;let s=pm(e,t,o,r,i,a);if(s===void 0)return;let c=cm(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=pm(e,t,n,r,i,a);o===void 0?c=!1:s[Q(e,n).key]=o.output}if(!c)return;let l=cm(i,n,fm(e,t,n,r,s));return l.isNew&&a.push(l),l}if(!im(e,n))return;let s=cm(i,n,fm(e,t,n,r));return s.isNew&&a.push(s),s},mm=(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=Op(e,n)-Op(e,t);return r===0?kp(e,t,n):r}))pm(e,a,t,n,r,i);return{configuration:a,completions:i}},hm=e=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine construction must be an object`);return e},gm=(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 Df(Object.hasOwn(t,`data`)?t.data:{})}},_m=(e,t,n={},r)=>{let i=e.byPath.get(t);if(i?.type===`atomic`||i?.type===`final`){let e=hm(n);if(Reflect.ownKeys(e).some(e=>e!==`data`&&e!==`decoded`))throw Error(`Machine leaf construction accepts only data and decoded`);return Tf(t,gm(i,e))}let a=new Map,o=(t,n)=>{let i=hm(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=gm(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=hm(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=hm(n);for(;u.states!==void 0;){let t=e.byPath.get(l),n=hm(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=hm(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 vf(l,d.parent??``,p);if(d.type===`atomic`||d.type===`final`)return Tf(l,f,{values:p});let m=new Map([...a].filter(([e])=>e.startsWith(`${l}.`)));return{...gf(l,f,p),...m.size===0?{}:{children:m}}},vm=(e,t,n)=>{let r=hm(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 tf(t,gm(i,r))},ym=(e,t,n=``)=>{let r=hm(t),i=e.byPath.get(n);_m(e,n,r);let a=gm(i,r);if(i.type===`choice`)return vf(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=hm(r.states),s=Object.fromEntries(Object.entries(o).map(([t,r])=>[t,ym(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]}},bm=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(t);return e},xm=`root`,Sm=e=>{let t=new Map,n=(e,r)=>{let i=!Je(e)&&`type`in e?e.type:void 0;if(t.set(r,i===`history`||i===`choice`?i:`state`),!Je(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 "${xm}" is reserved for the root`);return t},Cm=(e,t)=>{let n=Sm(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(bm(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(bm(t.branches,`Machine branches must be a map`))){let t=bm(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={...bm(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 Tm({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}},wm=(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}},Tm=(e,t)=>{let n=[`target`,`history`,`none`,`initialize`].filter(e=>t[e]!==void 0);if(n.length===0&&t.update!==void 0){let n=wm(t.update,e);if(n.kind!==`state`)throw Error(`Machine update requires an active state reference`);return Qd(`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 $d}if(r===`initialize`){if(t.update!==void 0)throw Error(`Machine initialize cannot update a retained owner`);return Qd(`state`,``,`branch`)}let i=wm(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:wm(t.update,e).path;if(a!==void 0&&r!==`target`)throw Error(`Machine owner updates require an ordinary destination`);return Qd(i.kind,i.path,r===`history`?`full`:`branch`,a)},Em=(e,t,n,r)=>{let i=bm(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`&&kr(a.value))&&!(a.kind===`streams`&&_n(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}},Dm=Symbol(`effect/Machine/InitialEvent`),Om=Symbol(`effect/Machine/SnapshotBuilderState`),km=Symbol(`effect/Machine/ChildMachineLogic`),Am=new WeakSet,jm=e=>Am.has(e),Mm=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine ${t} must be an object`);return e},Nm=e=>typeof e==`function`?e:()=>e,Pm=e=>{if(typeof e==`object`&&e&&W(e,`decoded`)&&e.decoded===!0&&W(e,`data`)){let t=Mm(e,`decoded construction`);if(Reflect.ownKeys(t).some(e=>e!==`decoded`&&e!==`data`))throw Error(`Machine decoded construction accepts only decoded and data`);return Nm(t.data)}let t=Nm(e);return n=>Df(e===void 0?{}:t(n))},Fm=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(!W(e,`data`))throw Error(`Machine decoded construction requires data`);return Nm(e.data)}let t=Nm(e.data);return n=>Df(W(e,`data`)?t(n):{})},Im=(e,t)=>{let n=(e,t,r)=>{if(W(t,`initialize`))throw Error(`Machine child construction belongs in initial declarations`);if(r!==``&&W(t,`root`))throw Error(`Machine root construction belongs at the root handler`);let{initial:i,root:a,states:o,...s}=t;if(Je(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?{}:Mm(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?{}:Mm(i,`parallel initial regions`);for(let[n,r]of Object.entries(t)){let t=e.states[n];if(t===void 0||!Je(t)&&(t.type===`history`||t.type===`choice`))throw Error(`Machine invalid initial region "${n}"`);if(!Je(t)&&(!(`schema`in t)||t.schema===void 0))throw Error(`Machine schema-less region "${n}" cannot construct data`);d[n]=Pm(r)}}else{let t=Mm(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||Je(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`&&(W(t,`data`)||W(t,`decoded`)))throw Error(`Machine choice initial edges cannot construct data`);let c=Fm(t),l=e.states[a];if(W(t,`data`)&&!Je(l)&&(!(`schema`in l)||l.schema===void 0))throw Error(`Machine schema-less initial child "${a}" cannot construct data`);W(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?{}:Mm(c[t],`state handler`),e);l[t]=a.node,(Je(i)||i.type!==`history`)&&(c[t]!==void 0||!Je(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{[Om]:i}};return Am.add(g),{node:m,handlers:{...s,...h.length===0?{}:{initialize:g},states:u}}};return n(e.node,t,``)},Lm=(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)},Rm=e=>`child`in e?e.child.id:e.id,zm=(e,t)=>{let n=new Set;for(let r of e){let e=Rm(r);if(n.has(e))throw Error(`Machine invocations for state "${t}" must have distinct ids; "${e}" is declared twice`);n.add(e)}},Bm=e=>e===void 0?[]:Array.isArray(e)?e:[e],Vm=e=>{let t=[],n=[],r=[];return{commands:t,raisedEvents:n,emittedEvents:r,enqueue:{raise:t=>{n.push(lp(e,t))},emit:t=>{r.push(dp(e,t))},sendTo:(e,n)=>{t.push({_tag:`SendTo`,target:e,event:n})},stop:e=>{t.push({_tag:`Stop`,child:e})}}}},Hm=(e,t)=>{let n=e.stateNodes.byPath.get(t);if(n===void 0)throw Error(`Machine expected state path "${t}" to exist`);return n},Um=e=>{let t={};return Object.defineProperty(t,"decoded",{value:e,enumerable:!1}),Object.defineProperty(t,"from",{value:(...t)=>e(Df(t.length===0?{}:t[0])),enumerable:!1}),t},Wm=e=>{let t={};return Object.defineProperty(t,Om,{value:e,enumerable:!1}),t},Gm=(e,t,n)=>{let r=Wm(n);for(let i of t.children){let a=Hm(e,i);a.schema===void 0||W(n,a.key)||(r[a.key]=Um(r=>{let i=Object.assign({},n);return i[a.key]=r,Gm(e,t,i)}))}return r},Km=(e,t)=>{let n=Hm(e,t);if(n.type===`parallel`)return Gm(e,n,{});if(n.type!==`compound`)throw Error(`Machine state "${t}" cannot initialize child states`);let r=Hm(e,n.initial);if(r.schema===void 0)throw Error(`Machine state "${t}" has no schema-valued initial child`);return Um(e=>Wm({[r.key]:e}))},qm=(e,t)=>{if(typeof t!=`object`||!t||!W(t,Om))throw Error(`Machine initialize handler for "${e}" must return its builder result`);return t[Om]},Jm=Symbol(`effect/Machine/InvocationEvent`),Ym=(e,t,n)=>({[Jm]:!0,path:e,id:t,type:`done`,output:n}),Xm=(e,t,n)=>({[Jm]:!0,path:e,id:t,type:`element`,element:n}),Zm=(e,t,n)=>({[Jm]:!0,path:e,id:t,type:`failure`,error:n}),Qm=(e,t,n)=>({[Jm]:!0,path:e,id:t,type:`snapshot`,snapshot:n}),$m=e=>typeof e==`object`&&!!e&&Jm in e,eh=new WeakMap,th=new WeakMap,nh=(e,t)=>e.parent===void 0?{self:t.self}:{self:t.self,parent:t.parent},rh=(e,t)=>{let n=Object.create(e);return th.set(n,nh(e,t)),n},ih=(e,t)=>{let n=t.machineReferences;if(n!==void 0)return nh(e,n);let r=th.get(e);if(r!==void 0)return r;let i=eh.get(e);if(i!==void 0)return i;let a=nh(e,{self:{id:e.id??`Machine`,sessionId:`Machine.plan`,send:()=>Ze(new Fd)},parent:void 0});return eh.set(e,a),a},ah=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}},oh=(e,t,n)=>{let r=Vm(e);return t===void 0||t(n,r.enqueue),{commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents}},sh=(e,t,n,r)=>{let i=Vm(e),a=r===void 0?{result:t(n,i.enqueue),branchIndex:0,branchKey:void 0}:r(n,i.enqueue);return pf(a.result)?{declined:!0}:{declined:!1,state:uf(a.result)?void 0:a.result,branchIndex:a.branchIndex,branchKey:a.branchKey,commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents}},ch=(e,t,n)=>{let r=Vm(e);return{value:t(n,r.enqueue),commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents}},lh=(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)=>kp(e,t,n))){let f=Q(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=Q(e,f.initial),m={active:i,values:a,outputs:t.outputs,history:t.history,machineReferences:t.machineReferences};if(p.type===`choice`){let t=zh(e,m,vf(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=_f(i)?dh(e,r,i,n):hf(i)?fh(e,r,i,n):void 0;r=tm(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=zd(e).handlers[d]?.initialize;if(t===void 0){a.set(p.path,mp(e,p,Df({}))),u=!0;continue}let i=ch(e,t,{...ih(e,m),state:m.values.get(d),containingState:Ip(e,m,d),ancestors:Fp(e,m,d),event:n,...d===``&&r!==void 0?{input:r.value}:{},...jm(t)?{}:{builder:Km(e,d)}}),l=qm(d,i.value);a.set(p.path,mp(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=>Q(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:zd(e).handlers[d]?.initialize,h=m===void 0?void 0:ch(e,m,{...ih(e,p),state:p.values.get(d),containingState:Ip(e,p,d),ancestors:Fp(e,p,d),event:n,...d===``&&r!==void 0?{input:r.value}:{},...jm(m)?{}:{builder:Km(e,d)}}),g=h===void 0?void 0:qm(d,h.value);for(let t of l){let n=Q(e,t);if(i.add(n.path),n.schema!==void 0){if(h===void 0){a.set(n.path,mp(e,n,Df({})));continue}if(g===void 0||!Object.prototype.hasOwnProperty.call(g,n.key)){if(m!==void 0&&jm(m)){a.set(n.path,mp(e,n,Df({})));continue}throw Error(`Machine parallel state initializer for "${d}" must return region "${n.key}"`)}a.set(n.path,mp(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 uh(e,t,n,r){let i=$p(e,t,n);if(n.children===void 0||![...n.children.keys()].some(t=>Q(e,t).type===`choice`))return lh(e,i,r,n.input);let a=[],o=[],s=[],c=[];for(let t of n.children?.keys()??[]){let n=Q(e,t);if(n.type!==`choice`)continue;let l=zh(e,i,vf(t,n.parent),r);for(let t of[l.target,...l.additionalTargets]){let n=_f(t)?dh(e,i,t,r):hf(t)?fh(e,i,t,r):void 0;i=tm(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=lh(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 dh(e,t,n,r){let i=uh(e,t,n,r),a=Bp(e,i.configuration,n.path);return{target:Tf(n.path,a.value,{snapshot:a,values:n.values}),commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents,transitions:i.transitions}}function fh(e,t,n,r){let i=Q(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=Xp(t,n.path);if(a!==void 0){let i=lh(e,Zp(e,t,a),r),o=Bp(e,i.configuration,n.parent),s=Object.fromEntries(i.configuration.values);return n.parent!==``&&t.active.has(``)&&delete s[``],{target:Tf(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=zd(e).handlers[n.parent]?.history?.[o]?.default;if(s===void 0)throw Error(`Machine history state "${n.path}" requires a default implementation`);let c=sh(e,s,{event:r,target:t=>ym(e.stateNodes,t),owner:n.parent});if(c.state===void 0||hf(c.state)||!kf(c.state))throw Error(`Machine history default for "${n.path}" must return a complete snapshot containing its owner`);let l=Lh(c.state)===void 0?void 0:zh(e,{active:new Set,values:new Map,outputs:new Map,history:t.history},c.state,r),u=l===void 0?Kp(e,c.state):tm(e,{active:new Set,values:new Map,outputs:new Map,history:t.history},l.target);for(let t of l?.additionalTargets??[])u=tm(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=Bp(e,u,n.parent),f=Object.fromEntries(u.values);return n.parent!==``&&t.active.has(``)&&delete f[``],{target:Tf(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 ph=(e,t)=>{if(!t.transition.declinable)return t;let n=sh(e,t.transition.transition,t.context,t.transition.evaluate);return n.declined?void 0:{...t,collected:n}},mh=(e,t)=>[...Dp(e,t)].reverse(),hh=(e,t,n)=>{let r=Dp(e,t),i=Dp(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},gh=(e,t)=>{if(e!==void 0&&t!==void 0)return e===t||Tp(e,t)?t:e},_h=(e,t,n)=>bh(e,Array.from(t.active).filter(e=>n===void 0||Tp(e,n))),vh=(e,t,n)=>xh(e,Array.from(t.active).filter(e=>n===void 0||Tp(e,n))),yh=(e,t)=>e.active.size===t.active.size&&Array.from(e.active).every(e=>t.active.has(e)),bh=(e,t)=>Array.from(new Set(t)).sort((t,n)=>{let r=Dp(e,n).length-Dp(e,t).length;return r===0?Q(e,n).order-Q(e,t).order:r}),xh=(e,t)=>Array.from(new Set(t)).sort((t,n)=>{let r=Dp(e,t).length-Dp(e,n).length;return r===0?kp(e,t,n):r}),Sh=(e,t,n,r)=>({...ih(e,t),state:t.values.get(n),containingState:Ip(e,t,n),ancestors:Fp(e,t,n),event:r}),Ch=(e,t,n,r,i)=>({...ih(e,t),state:t.values.get(n),containingState:Ip(e,t,n),ancestors:Fp(e,t,n),event:r,snapshot:i}),wh=(e,t,n,r,i,a)=>({...ih(e,t),state:t.values.get(n),containingState:Ip(e,t,n),ancestors:Fp(e,t,n),event:r,output:i,snapshot:a}),Th=(e,t,n,r,i)=>{let a=[],o=[],s=[];for(let c of n){let n=oh(e,zd(e).handlers[c]?.[i],Sh(e,t,c,r));a.push(...n.commands),o.push(...n.raisedEvents),s.push(...n.emittedEvents)}return{commands:a,emittedEvents:s,raisedEvents:o}},Eh=(e,t,n)=>{let r=[],i=new Set,a=new Map,o,s=()=>o??=zp(e,t);for(let o of jp(e,t))for(let c of mh(e,o)){let l=ah(zd(e).handlers[c]?.always);if(l!==void 0){let u=a.get(c);if(a.has(c)||(u=ph(e,{sourcePath:c,leafPath:o,trigger:{type:`always`},transition:l,context:{...ih(e,t),state:t.values.get(c),containingState:Ip(e,t,c),ancestors:Fp(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},Dh=(e,t,n,r)=>{let i=[],a=new Set,o,s=()=>o??=zp(e,t);for(let o of r){let r=ah(zd(e).handlers[o.path]?.onDone);if(r!==void 0&&!a.has(o.path)){a.add(o.path);let c=ph(e,{sourcePath:o.path,leafPath:Np(e,t,o.path),trigger:{type:`done`},transition:r,context:wh(e,t,o.path,n,o.output,s())});c!==void 0&&i.push(c)}}return i},Oh=(e,t,n)=>{let r=[],i=new Set,a=new Map,o,s=()=>o??=zp(e,t);for(let o of jp(e,t))for(let c of mh(e,o)){let l=ah(zd(e).handlers[c]?.on?.[n._tag]);if(l!==void 0){let u=a.get(c);if(a.has(c)||(u=ph(e,{sourcePath:c,leafPath:o,trigger:{type:`event`,event:n._tag},transition:l,context:Ch(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},kh=(e,t,n)=>{if(!t.active.has(n.path))return[];let r=zd(e).handlers[n.path],i=Bm(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=ah(n.type===`element`?i.onElement:n.type===`done`?i.onDone:n.type===`failure`?i.onFailure:i.onSnapshot);if(a===void 0)return[];let o=zp(e,t),s={...ih(e,t),state:t.values.get(n.path),containingState:Ip(e,t,n.path),ancestors:Fp(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=ph(e,{sourcePath:n.path,leafPath:Np(e,t,n.path),trigger:{type:`invoke`,id:n.id,outcome:n.type},transition:a,context:s});return c===void 0?[]:[c]},Ah=e=>{if(hf(e)||yf(e)||Ef(e)||kf(e))return String(e.path);throw Error(`Machine expected transition target to be a snapshot or target builder result`)},jh=(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(`, `)}`)}},Mh=(e,t)=>{for(let n of e)if(t.includes(n))return!0;return!1},Nh=(e,t)=>Array.from(t).sort((t,n)=>kp(e,t.selection.sourcePath,n.selection.sourcePath)),Ph=e=>e.filter(t=>!e.some(e=>e.sourcePath!==t.sourcePath&&Tp(e.sourcePath,t.sourcePath))),Fh=(e,t)=>{let n=[];for(let r of Nh(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(Mh(r.exitPaths,i.exitPaths)||n){if(Tp(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},Ih=(e,t={})=>{let n={...t},r=[],i=e=>{if(yf(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:vf(e.path,e.parent,n),values:n}))},Lh=(e,t={})=>Ih(e,t)[0],Rh=(e,t)=>{if(yf(e))return vf(e.path,e.parent,{...t,...e.values??{}});if(_f(e))return{...e,values:{...t,...e.values}};if(!Ef(e)||Object.keys(t).length===0)return e;let n=e[Vd];return Tf(e.path,e.value,{...n===void 0?{}:{snapshot:n},values:{...t,...e.values??{}}})};function zh(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=Ih(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 Md({machineId:e.id,state:d.target.path,maxIterations:Vh});let f=Q(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=zd(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=Q(e,t);r.schema!==void 0&&m.set(t,mp(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=sh(e,p.transition,{...ih(e,h),containingState:Ip(e,h,f.path),ancestors:Fp(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`);jh(f.path,{type:`choice`},p.targets,g.state);let _=Ah(g.state);n=Rh(g.state,d.values);let v=Lh(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(!Ef(n)&&!kf(n)&&!hf(n)&&!_f(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 Bh=(e,t,n)=>{let r=n.leafPath,i=n.collected??sh(e,n.transition.transition,n.context,n.transition.evaluate);if(i.declined)throw Error(`Machine transition returned decline without declaring declinable: true`);let a=af(i.state)?i.state:void 0,o=a?.target??i.state,s=o===void 0||nf(o)?void 0:o;jh(n.sourcePath,n.trigger,n.transition.targets,s);let c=a?.update??(nf(o)?o:void 0),l=c===void 0?void 0:(()=>{let n=Q(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:mp(e,n,c.value)}})(),u=l!==void 0&&(_f(s)||yf(s))?{...t,values:new Map(t.values).set(l.path,l.value)}:t,d=s===void 0?void 0:zh(e,u,s,n.context.event),f=d?.target??s,p=f!==void 0&&_f(f)?dh(e,u,f,n.context.event):void 0,m=p?.target??f,h,g=hf(m)&&n.transition.reenter&&t.active.has(m.parent)?m:void 0;if(m!==void 0&&hf(m)){let i=n.transition.reenter?Q(e,n.sourcePath).parent:hh(e,r,m.parent),a=g===void 0?_h(e,t,i):bh(e,Array.from(t.active).filter(e=>Ep(e,m.parent)));h=fh(e,a.includes(m.parent)?Yp(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(_f(r)){let i=dh(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(!hf(r)){S.push(r);continue}let i=fh(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?Ah(_):Ah(s),w=_===void 0?l===void 0?t:{...t,values:new Map(t.values).set(l.path,l.value)}:tm(e,t,_);for(let t of S)w=tm(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||!yh(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?Q(e,n.sourcePath).parent:hh(e,r,C),O=Q(e,n.sourcePath).parent,k=n.transition.reenter?gh(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?_h(e,t,k):bh(e,Array.from(t.active).filter(e=>Ep(e,g.parent))),entryPaths:g===void 0?vh(e,w,k):xh(e,Array.from(w.active).filter(e=>Ep(e,g.parent))),choiceTransitions:[...d?.transitions??[],...p?.transitions??[],...h?.transitions??[],...x]}},Vh=1e3,Hh={_tag:Dm},Uh=(e,t)=>sm(e,Gp(e,t)),Wh=(e,t,n)=>Jp(e,t).pipe(U(t=>dm(e,t,n)),U(t=>{let n=Pp(e,t.configuration);return!sm(e,t.configuration)||!t.configuration.outputs.has(n)?Nt(Error(`Machine attempted to read terminal output from a non-terminal configuration`)):mt(t.configuration.outputs.get(n))})),Gh=(e,...t)=>{let n=e.input===void 0?t:t.length===0?(fp(e,e.input,void 0),t):[fp(e,e.input,t[0])],r=e.initial(...n),i={active:new Set,values:new Map,outputs:new Map,history:new Map},a=dh(e,i,r,Hh),o=tm(e,i,a.target),s=zp(e,o),c=Lp(e,o),l=a.commands,u=a.raisedEvents,d=a.emittedEvents,f=Th(e,o,c,Hh,`entry`),p=qh(e,o,Hh,[...f.commands],[...u,...f.raisedEvents],[...d,...f.emittedEvents],a.transitions.length===0?[]:[{next:o,event:Hh,transitions:a.transitions,commands:l,raisedEvents:[...u],emittedEvents:d,exitPaths:[],entryPaths:[],changed:!1,stabilize:!1}]),m={startingState:s,initialEntryPaths:c,state:zp(e,p.next),commands:[...l,...p.commands],emittedEvents:p.emittedEvents,microsteps:p.microsteps.map(t=>({next:zp(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}},Kh=(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=Ph(r),a=[];for(let n of i)a.push(Bh(e,t,n));let o=Fh(e,a),s=Nh(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:Ah(e.unresolvedTarget),resolvedTarget:e.target===void 0?void 0:Ah(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=tm(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=bh(e,s.flatMap(e=>e.exitPaths)),_=xh(e,s.flatMap(e=>e.entryPaths));l=Yp(e,t,l,g);let v=Th(e,t,g,n,`exit`),y=Th(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}},qh=(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 Md({machineId:e.id,state:String(Mp(e,s)),maxIterations:Vh});let t=mm(e,s,c);for(s=t.configuration,m.push(...t.completions.filter(t=>zd(e).handlers[t.path]?.onDone!==void 0));m.length>0&&!s.active.has(m[0].path);)m.shift();let n=Dh(e,s,c,m.length===0?[]:[m.shift()]);if(n.length>0){let t=Kh(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(sm(e,s)){let t=Pp(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?Eh(e,s,c):[];if(h.length>0){let t=Kh(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=Oh(e,s,_);if(v.length===0){l=!0;continue}let y=Kh(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}},Jh=(e,t,n)=>{let r=$m(n)?n:lp(e,n);if(sm(e,t)){let n=mm(e,t,r),i=Pp(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=$m(r)?kh(e,t,r):Oh(e,t,r);if(i.length===0)return{event:r,next:t,commands:[],emittedEvents:[],microsteps:[],done:!1,output:void 0};let a=Kh(e,t,r,i),o=[...a.commands],s=[...a.raisedEvents],c=[...a.emittedEvents],l=[a];return{...qh(e,a.next,r,o,s,c,l),event:r}},Yh=(e,...t)=>je({try:()=>Gh(e,...t),catch:Rd}),Xh=(e,t)=>({raise:n=>cp(e,n).pipe(U(e=>t.sendTo(t.self,e))),emit:n=>up(e,n).pipe(U(e=>t.emit(e)))}),Zh=(e,t)=>ar(e,e=>e._tag===`SendTo`?t.sendTo(e.target,e.event):t.stopChild(e.child),{discard:!0}),Qh=(e,t)=>_(Array.from(e,e=>t.emit(e)),{discard:!0}),$h=new WeakMap,eg=e=>{let t=$h.get(e);if(t!==void 0)return t;let n={self:{id:e.id??`Machine`,sessionId:`Machine.plan`,send:()=>Ze(new Fd)},parent:void 0};return $h.set(e,n),n},tg=(e,t)=>{let n=t===void 0?eg(e):t;return e.parent===void 0?{self:n.self}:{self:n.self,parent:n.parent}},ng=new Set([`initialize`,`invoke`,`on`,`output`]),rg=e=>{if(e===void 0)return!0;for(let t of Reflect.ownKeys(e))if(!ng.has(t))return!1;return!0},ig=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=zd(e).handlers[a.path];if(!rg(o))return;if(o?.on===void 0)continue;let s=new Map;for(let e of Reflect.ownKeys(o.on)){let t=ah(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)=>kp(e,t,n)),r.sort((t,n)=>kp(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=>Dp(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&&(zd(e).handlers[``]===void 0||Reflect.ownKeys(zd(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}},ag=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()}),og=(e,t)=>t?{...e,next:ag(e.next)}:e,sg=(e,t,n)=>{e.values[t]=n},cg=(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}},lg=(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}},ug=(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=ug(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]=ug(e,t,i)}i.states=a}return i},dg=(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=ug(e,t,n);return t.completedOrder.length>0&&(r.completed=t.completedOrder.map(n=>({path:e.nodes[n].path,output:t.outputs[n]}))),r},fg=(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{...tg(e,a),state:n.values[r],containingState:o<0?void 0:n.values[o],ancestors:s,event:i,snapshot:dg(t,n)}},pg=Object.freeze([]),mg=(e,t,n,r)=>{let i,a,o,s={raise:t=>{(a??=[]).push(lp(e,t))},emit:t=>{(o??=[]).push(dp(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:uf(c.result)?void 0:c.result,branchIndex:c.branchIndex,branchKey:c.branchKey,commands:i??pg,raisedEvents:a??pg,emittedEvents:o??pg}},hg=(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:fg(e,t,n,c,r,i)})}}}return a},gg=(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},_g=(e,t,n,r,i)=>{if((Ef(r)?t.indexByPath.get(String(r.path)):void 0)===i&&n.active[i]===1&&Ef(r)&&r[Vd]===void 0&&r.values===void 0&&n.completedOrder.length===0&&t.valued[i]){let a=n.values.slice();return a[i]=mp(e,t.nodes[i],r.value),{...n,values:a}}return cg(t,tm(e,lg(t,n),r))},vg=(e,t,n,r)=>{let i=mg(e,r.transition.transition,r.context,r.transition.evaluate),a=af(i.state)?i.state:void 0,o=a?.target??i.state,s=a?.update??(nf(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:mp(e,i,s.value)}})(),l=o===void 0||nf(o)?void 0:o;jh(r.sourcePath,r.trigger,r.transition.targets,l);let u=l!==void 0&&_f(l)?dh(e,(()=>{let e=lg(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&&!Ef(d)&&!kf(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=ag(n);return e.values[t.indexByPath.get(c.path)]=c.value,e})():_g(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||!gg(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:Ah(d),g=h===void 0?t.nodes[r.sourceIndex].parent:hh(e,r.leafPath,h),_=t.nodes[r.sourceIndex].parent,v=r.transition.reenter?gh(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:_h(e,lg(t,n),v),entryPaths:vh(e,lg(t,f),v),choiceTransitions:u?.transitions??[]}},yg=(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:Ah(e.unresolvedTarget),resolvedTarget:e.target===void 0?void 0:Ah(e.target),updates:e.update===void 0?[]:[e.update.path]});if(i.length===1){let s=vg(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=Nh(e,Fh(e,i.filter(e=>!i.some(t=>t.sourceIndex!==e.sourceIndex&&Tp(t.sourcePath,e.sourcePath))).map(r=>vg(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=_g(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?bh(e,s.flatMap(e=>e.exitPaths)):[],entryPaths:f?xh(e,s.flatMap(e=>e.entryPaths)):[],changed:f}},bg=(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 Md({machineId:e.id,state:t.nodes[o.activeLeaves[0]].path,maxIterations:Vh});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=mm(e,lg(t,o),s).configuration,i=Pp(e,n);if(!n.outputs.has(i))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:r,next:cg(t,n),commands:c??pg,emittedEvents:u??pg,microsteps:d??pg,done:!0,output:n.outputs.get(i)}}let m=t.nodes[n].path,h=ah(zd(e).handlers[m]?.on?.[s._tag]);if(h!==void 0){let r=mg(e,h.transition,{...tg(e,a),state:o.values[n],containingState:void 0,ancestors:{},event:s,snapshot:dg(t,o)},h.evaluate),f=nf(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`);sg(o,n,mp(e,r,f.value))}if(jh(m,{type:`event`,event:s._tag},h.targets,p),p!==void 0&&!Ef(p)&&!kf(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=Ef(p)?p[Vd]===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]?sg(o,n,mp(e,t.nodes[n],p.value)):g=_g(e,t,o,p,n)}let _=h.reenter||!gg(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:Ah(p),resolvedTarget:p===void 0?void 0:Ah(p),updates:f===void 0?[]:[f.path]}]}:void 0,commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents,exitPaths:_?[m]:pg,entryPaths:_?[t.nodes[v].path]:pg,changed:_};o=g,(d??=[]).push(og(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??pg,emittedEvents:u??pg,microsteps:d??pg,done:!1,output:void 0};f+=1,s=g}},xg=(e,t,n,r,i,a)=>{if($m(r)){let i=Jh(e,a===void 0?lg(t,n):xp(lg(t,n),a),r);return{event:i.event,next:cg(t,i.next),commands:i.commands,emittedEvents:i.emittedEvents,microsteps:i.microsteps.map(e=>({next:cg(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=lp(e,r);if(t.flat)return bg(e,t,n,o,i,a);if(t.finalIndices.some(e=>n.active[e]===1)){let r=lg(t,n);if(sm(e,r)){let n=mm(e,r,o).configuration,i=Pp(e,n);if(!n.outputs.has(i))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:o,next:cg(t,n),commands:[],emittedEvents:[],microsteps:[],done:!0,output:n.outputs.get(i)}}}let s=hg(e,t,n,o,a);if(s.length===0)return{event:o,next:n,commands:[],emittedEvents:[],microsteps:[],done:!1,output:void 0};let c=yg(e,t,n,o,s,i),l=c.next,u=o,d=[...c.commands],f=[...c.raisedEvents],p=[...c.emittedEvents],m=[og(c,i)],h=0,g=0;for(;;){if(g+=1,g>1e3)throw new Md({machineId:e.id,state:t.nodes[t.leafIndices.find(e=>l.active[e]===1)].path,maxIterations:Vh});if(t.finalIndices.some(e=>l.active[e]===1)){let n=mm(e,lg(t,l),u).configuration;if(l=cg(t,n),sm(e,n)){let t=Pp(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=hg(e,t,l,n,a);if(r.length===0)continue;let s=yg(e,t,l,n,r,i);l=s.next,d.push(...s.commands),f.push(...s.raisedEvents),p.push(...s.emittedEvents),m.push(og(s,i))}},Sg=new WeakMap,Cg=e=>({fromConfiguration:e=>e,toConfiguration:e=>e,snapshot:t=>zp(e,t),plan:(t,n,r,i)=>Jh(e,i===void 0?t:xp(t,i),n)}),wg=(e,t)=>({fromConfiguration:e=>cg(t,e),toConfiguration:e=>lg(t,e),snapshot:e=>dg(t,e),plan:(n,r,i=!1,a)=>xg(e,t,n,r,i,a),...Object.values(zd(e).handlers).some(e=>e.initialize!==void 0&&!jm(e.initialize))?{}:{initial:(n,r)=>{let i=e.input===void 0?n:n.length===0?(fp(e,e.input,void 0),n):[fp(e,e.input,n[0])],a=e.initial(...i),o=_f(a)?uh(e,{active:new Set,values:new Map,outputs:new Map,history:new Map,...r===void 0?{}:{machineReferences:r}},a,Hh).configuration:Kp(e,a),s=mm(e,r===void 0?o:xp(o,r),Hh).configuration,c=cg(t,s),l=dg(t,c);if(!sm(e,s))return{state:l,configuration:c,activeConfiguration:s,initialEntryPaths:Lp(e,s),done:!1,output:void 0};let u=Pp(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:Lp(e,s),done:!0,output:s.outputs.get(u)}}}}),Tg=e=>{let t=Sg.get(e);if(t!==void 0)return t;let n=ig(e),r=n===void 0?Cg(e):wg(e,n);return Sg.set(e,r),r},Eg=`Machine.invocation:`,Dg=e=>e.startsWith(Eg),Og=(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,er(t,z)}},kg=e=>I(()=>{if(e.values!==void 0){let t=e.values;return e.values=void 0,mt(t)}let t=Hr();return e.waiter=t,gn(t).pipe(H(kg(e)))}),Ag=(e,t)=>e._tag===`Started`&&(typeof t==`string`||e.descriptor!==void 0&&e.descriptor.id===t.id&&e.descriptor.machine===t.machine),jg=(e,t,n)=>{if(e.closed)return ot();let r=e.children.get(t);return r!==void 0&&Ag(r,n)?qr(r.ref):ot()},Mg=e=>{if(e.observers!==void 0)for(let t of e.observers)Og(t,jg(e,t.id,t.child))},Ng=(e,t,n)=>{let r=e.children.get(t);r!==void 0&&r.token===n&&(e.children.delete(t),typeof t==`string`&&Mg(e))},Pg=(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`&&Mg(e),!0},Fg=e=>qt(function*(){let t=yield*Ie(),n=0,r=0,i=0,a=0;return{rootSessionId:e,stream:un(t).pipe(Cn(A(()=>{n+=1})),Or(A(()=>{--n}))),isActive:()=>n>0,nextDeliveryId:()=>i++,nextMacrostepId:()=>a++,publishUnsafe:i=>{n!==0&&Gn(t,{...i,sequence:r++,rootSessionId:e})},close:p(t)}}),Ig=e=>({id:e.id,sessionId:e.sessionId}),Lg=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?Ig(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?Ig(t):{id:String(t.id)}}]:[]}return[]}),Rg=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:Lg(Array.isArray(e.commands)?e.commands:[]),exitPaths:Array.isArray(e.exitPaths)?e.exitPaths:[],entryPaths:Array.isArray(e.entryPaths)?e.entryPaths:[],changed:e.changed===!0})),zg=Symbol.for(`effect/Machine/activeSnapshotObserver`),Bg=Symbol.for(`effect/Machine/snapshotObserver`),Vg=e=>typeof e==`object`&&!!e&&Bg in e,Hg=Symbol.for(`effect/Machine/sendParentOverride`),Ug=Symbol.for(`effect/Machine/acknowledgedSend`),Wg=Symbol(`effect/Machine/AcknowledgedMessage`),Gg=e=>typeof e==`object`&&!!e&&Wg in e,Kg=e=>Gg(e)?e.event:e,qg=(e,t)=>{e!==void 0&&Gg(e)&&(e.deferred!==void 0&&er(e.deferred,mt(t)),e.inspection?.complete(t))},Jg=(e,t)=>{e!==void 0&&Gg(e)&&e.deferred!==void 0&&er(e.deferred,c(t))},Yg=e=>{e!==void 0&&Gg(e)&&e.deferred!==void 0&&er(e.deferred,Ze(new Fd))},Xg=e=>typeof e==`object`&&!!e&&`send`in e&&typeof e.send==`function`,Zg=(e,t,n,r)=>`inspectionSubject`in e&&`sendInspected`in e&&typeof e.sendInspected==`function`?e.sendInspected(t,n,r):e.send(t),Qg=e=>e?._tag===`Childless`||e?.childless===!0,$g=(e,t)=>{let n=e.items??[];e.items=n,n.push(t)},e_=e=>{if(e.items===void 0)return ot();let t=e.items[e.index];return e.index+=1,e.index===e.items.length&&(e.items=void 0,e.index=0),qr(t)},t_=e=>{if(e.items!==void 0)for(let t=e.index;t<e.items.length;t+=1)Yg(e.items[t]);e.closed=!0,e.items=void 0,e.index=0},n_=()=>({items:void 0,index:0,closed:!1,receivers:new Set}),r_=(e,t,n)=>{if(e.closed)return!1;for($g(e,t),n?.();e.items!==void 0&&e.receivers.size>0;){let t=e.receivers.values().next().value;e.receivers.delete(t),t(z)}return!0},i_=e=>I(()=>{let t=e_(e);return Vr(t)?mt(t.value):e.closed?ur:V(t=>(e.receivers.add(t),A(()=>{e.receivers.delete(t)}))).pipe(H(i_(e)))}),a_=e=>{t_(e);let t=Array.from(e.receivers);e.receivers.clear();for(let e of t)e(ur)},o_=class extends g()(`effect/Machine/MachineRuntime`){},s_=(e,t)=>wn(e,o_,t),c_=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(te);if(t!==void 0)return{_tag:`Failure`,error:t.error,cause:e.cause,snapshot:e};let n=e.cause.reasons.find(Ge);return n===void 0?e.cause.reasons.find(fe)===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}}},l_=(e,t)=>I(()=>e(t)).pipe(Lt,vt),u_=(e,t)=>{class n{nextSessionId;constructor(){let e=0;this.nextSessionId=A(()=>`machine:${e++}`)}get start(){return e}get startCompiledSync(){return t}}return A(()=>new n)},d_=(e,t,n)=>({id:t,sessionId:n,kind:e.inspection?.kind??`Logic`}),f_=(e,t)=>t?{_tag:`Initialization`}:e!==void 0&&Gg(e)&&e.inspection!==void 0?{_tag:`Macrostep`,macrostepId:e.inspection.macrostepId}:void 0,p_=(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=Rg(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{[Wg]:!0,event:n,...a===void 0?void 0:{deferred:a},inspection:c}},m_=(e,t,n)=>{if(!Gg(n)||n.inspection===void 0)return;let r=n.inspection;e.publishUnsafe({_tag:`EventSent`,subject:t,deliveryId:r.deliveryId,source:r.source,target:Ig(t),event:r.event,causedBy:r.causedBy})},h_=class{registry;self;runtime;services;sendAcknowledged;scopedServices;constructor(e,t,n,r,i){this.registry=e,this.self=t,this.runtime=n,this.services=r,this.sendAcknowledged=i}has(e){for(let t of this.registry.children.values())if(t.ownerActive&&t.ownerKey===e)return!0;return!1}stopEntry(e){return e.ownerActive=!1,e._tag===`Started`?e.ref.stop:z}spawn(e,t){let n=Symbol(),r,i=()=>{let e=this.registry.children.get(t.id);return e?.token===n&&e.ownerKey===t.key&&e.ownerActive===!0};return I(()=>{if(this.registry.closed)return ur;if(this.has(t.key)||this.registry.children.has(t.id))return Ze(new Pd({id:t.duplicateId}));let a=e(),o=this.registry.scope??=Ir(`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()?Zg(this.self,e,t,n):z,...this.sendAcknowledged===void 0?void 0:{[Ug]:e=>i()?this.sendAcknowledged(e):ur}},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,Pg(this.registry,t.id,n,e,t.descriptor)),onStopSync:()=>Ng(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?U(this.runtime.nextSessionId,e=>this.runtime.startCompiledSync(a,c,this.scopedServices??=xt(this.services,Dr,o),e)):this.runtime.start(a,c)).pipe(mr(e=>Jr(e)?z:(Ng(this.registry,t.id,n),r===void 0?z:r.stop)));return(u?d:ln(d,o)).pipe(vt)})}stopAll(){return I(()=>{let e=[];for(let t of this.registry.children.values())t.ownerActive&&e.push(this.stopEntry(t));return e.length===0?z:e.length===1?e[0]:_(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]:_(n,{concurrency:`unbounded`,discard:!0})}},g_=oi(ot()).pipe(Kt(kn)),__=e=>z,v_=(e,t)=>{},y_=()=>void 0,b_=Symbol(`effect/Machine/EmissionsClosed`),x_=()=>{let e,t=I(()=>{let t=e;return t===b_?mt(void 0):t===void 0?Ie().pipe(U(t=>A(()=>{let n=e;return n===b_?[void 0,!0]:n===void 0?(e=t,[t,!1]):[n,!0]}).pipe(U(([e,n])=>n?p(t).pipe(se(e)):mt(e))))):mt(t)});return{emit:t=>I(()=>e===void 0||e===b_?z:Ve(e,t).pipe(vt)),close:()=>{let t=e;return e=b_,t===void 0||t===b_?z:p(t)},stream:Yr(t.pipe(Rr(e=>e===void 0?lr:un(e))))}},S_={close:()=>z,spawn:(()=>Nt(Error(`Childless machine logic cannot spawn a process`))),get:()=>mt(ot()),changes:()=>g_,sendTo:()=>z,stop:()=>z,owned:{spawn:()=>Nt(Error(`Childless machine logic cannot spawn an owned process`)),stopAll:()=>z,stopPaths:()=>void 0}},C_=(e,t,n,r)=>{let i={closed:!1,children:new Map,observers:void 0,scope:void 0},a=e=>I(()=>{if(i.closed||(i.closed=!0,i.scope===void 0))return z;let t=Yn(i.scope,e),n,r;for(let e of i.children.values())e._tag===`Started`&&(n===void 0?n=e.ref.stop:(r??=[n],r.push(e.ref.stop)));t!==void 0&&(n===void 0?n=t:(r??=[n],r.push(t)));let a=r??n;return a===void 0?z:Array.isArray(a)?_(a,{concurrency:`unbounded`,discard:!0}):a}),o=(e,t)=>A(()=>Ng(i,e,t)),s=(e,t,n,r)=>A(()=>Pg(i,e,t,n,r)),c=e=>{let t=typeof e==`string`?e:e.id;return A(()=>{if(i.closed)return ot();let n=i.children.get(t);return n!==void 0&&Ag(n,e)?qr(n.ref):ot()})},l=e=>{let t=typeof e==`string`?e:e.id;return Lr(k((n,r)=>A(()=>({child:e,id:t,values:void 0,waiter:void 0})).pipe(U(n=>{let a=A(()=>{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 rn(r,a).pipe(H(A(()=>{!i.closed&&r.state._tag!==`Closed`&&(i.observers??=new Set,i.observers.add(n)),Og(n,jg(i,t,e))})),se(kg(n)))}))))},u=(e,t,n,r)=>{let a=typeof e==`string`?e:e.id;return I(()=>{if(i.closed)return z;let o=i.children.get(a);return o!==void 0&&Ag(o,e)?Zg(o.ref,t,n,r):z})},d=e=>{let t=typeof e==`string`?e:e.id;return I(()=>{if(i.closed)return z;let n=i.children.get(t);return n!==void 0&&Ag(n,e)?n.ref.stop:z})};function f(n,r){let a=typeof n==`object`&&n&&km in n?n:void 0,c=a===void 0?n:a[km](r?.input),l=a===void 0?r:{id:a.id,descriptor:a},u=Symbol(),d=l?.id??u,f;return I(()=>i.closed?ur:typeof d==`string`&&(i.children.has(d)||Dg(d))?Ze(new Pd({id:d})):(i.scope??=Ir(`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?.[zg]===void 0?void 0:{onSnapshot:l[zg]},...l?.[Hg]===void 0?void 0:{sendParent:l[Hg]},onReady:(e,t)=>A(()=>{f=e}).pipe(H(s(d,u,e,l?.descriptor)),U(e=>e?z:t)),onStop:o(d,u),parent:e,runtime:t,origin:{_tag:`Spawn`,address:l?.id}}).pipe(mr(e=>S(e)?o(d,u).pipe(H(f===void 0?z:f.stop)):z),ln(i.scope))))}return{close:a,spawn:f,get:c,changes:l,sendTo:u,stop:d,owned:new h_(i,e,t,n,r)}},w_=(e,t,n,r)=>A(()=>C_(e,t,n,r)),T_=(e,t)=>`${e.length}:${e}${t}`,E_=(e,t)=>`${Eg}${T_(e,t)}`,D_=e=>({initial:()=>z,run:()=>e}),O_=(e,t,n)=>({initial:()=>z,run:({parent:r})=>{let i=r?.[Ug];return i===void 0?Nt(Error(`Stream invocation requires an acknowledged parent machine`)):Ur(e,e=>i(Xm(t,n,e)).pipe(vt,be(()=>ur)))}}),k_=(e,t)=>typeof e==`function`?e(t):e,A_=e=>({spawn:((t,n)=>e.spawn(t,n)),sendTo:((t,n)=>e.sendTo(t,n)),stop:(t=>e.stopChild(t))}),j_=(e,t,n)=>{if(`effect`in e)return{id:String(e.id),sourceName:e.sourceName,src:()=>D_(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:()=>D_(Xr(k_(e.after,t))),onDone:e.onDone,activityKind:`Timer`};if(`stream`in e){let r=String(e.id);return{id:r,sourceName:e.sourceName,src:()=>O_(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:()=>k_(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[km](`input`in e?k_(e.input,t):void 0),onDone:e.onDone,onFailure:e.onFailure,onSnapshot:e.onSnapshot}}throw Error(`Unsupported captured machine invocation: ${String(e)}`)},M_=e=>e.length===0?z:e.length===1?e[0]:_(e,{discard:!0}),N_=(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(_r(`StoppedError`,()=>z)),P_=e=>e instanceof Md||e instanceof jd||e instanceof Fd,F_=(e,t,n,r,i,a,o,s,c,l,u,d)=>I(()=>{let f=T_(n,r),p=u===void 0?o:()=>{let t=o();return{...t,run:i=>De(I(()=>t.run(i)),`Machine.invoke`,{attributes:{"machine.id":e.self.id,"machine.sessionId":e.self.sessionId,"machine.state.path":n,"machine.invoke.id":r,"machine.invoke.source":d??r,"machine.invoke.kind":u,"machine.invoke.sessionId":i.self.sessionId},captureStackTrace:!1})}};return t.spawn(p,{key:f,path:n,id:i,duplicateId:r,...a===void 0?void 0:{descriptor:a},...u===void 0?void 0:{activityKind:u},sendParent:(t,n)=>t()?e.self.send(n):z,onOutcome:(t,i,o)=>H(rt,I(()=>i._tag===`Stopped`||!t()?z:i._tag===`Done`?s===void 0?e.failCause(Wn(Error(`Invocation "${r}" completed without the required onDone handler`))):N_(e,Ym(n,r,i.output),u===void 0?void 0:o):i._tag===`Failure`&&c!==void 0&&(a===void 0||!P_(i.error))?N_(e,Zm(n,r,i.error),u===void 0?void 0:o):e.failCause(i.cause))),...l===void 0?void 0:{onSnapshot:(t,i)=>t()?N_(e,Qm(n,r,i)):z}})}),I_=(e,t)=>Dg(e)?Ze(new Pd({id:t})):void 0,L_=(e,t,n,r)=>{let i=String(r.id),a=r.address===void 0?void 0:I_(String(r.address),i);return a===void 0?F_(e,t,n,i,r.address===void 0?E_(n,i):String(r.address),r.descriptor,r.src,r.onDone,r.onFailure,r.onSnapshot,r.activityKind,r.sourceName):a},R_=(e,t,n,r)=>{let i=r.child,a=I_(i.id,i.id);return a===void 0?F_(e,t,n,i.id,i.id,i,i[km],r.onDone,r.onFailure,r.onSnapshot,void 0):a},z_=(e,t,n,r,i,a)=>{let o=A_(t),s=xh(e,i).filter(e=>r.active.has(e)).flatMap(i=>{let s={...Sp(r)??{self:t.self,parent:t.parent},children:o,state:r.values.get(i),containingState:Ip(e,r,i),ancestors:Fp(e,r,i),event:a};return Bm(nm(e,i)?.invoke).map(e=>`child`in e&&!(`input`in e)?R_(t,n,i,e):L_(t,n,i,j_(e,s,i)))});return s.length===0?void 0:M_(s)},B_=Symbol(`effect/Machine/CompiledStoppedCompletion`),V_=class{logic;options;services;id;sessionId;inspectionSubject;send;sendInspected(e,t,n){return this.offerEvent(e,t,n)}[Ug](e){return this.sendAcknowledgedEffect(e)}[Bg](e){let t=this.snapshotObservers??=new Set;return t.add(e),()=>{t.delete(e)}}mailbox={items:void 0,index:0,closed:!1};address;childRuntime=S_;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=d_(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:I(()=>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 f_(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:Rg({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:ei(e)})}get execution(){return this.logic.execution}initializeCompiledSync(){this.publishCreated(),this.execution.childless||(this.childRuntime=C_(this.address,this.options.runtime,this.services,e=>this.sendAcknowledgedEffect(e)));let e=this.options.parent,t=this.options.sendParent??(e===void 0?__:this.inspector===void 0?e.send:t=>Zg(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)=>Xg(e)?this.inspector===void 0?e.send(t):Zg(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?v_:(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(f(e)),Ze(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 H_(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?mt(this):(this.runState=`Draining`,An(this.drainRuntime(),this.services).pipe(se(this)))}initialize(){let e=this;return qt(function*(){e.publishCreated(),e.execution.childless||(e.childRuntime=yield*w_(e.address,e.options.runtime,e.services,t=>e.sendAcknowledgedEffect(t)));let t=e.options.parent,n=e.options.sendParent??(t===void 0?__:e.inspector===void 0?t.send:n=>Zg(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)=>Xg(t)?e.inspector===void 0?t.send(n):Zg(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?v_:(t,n=[])=>{e.initialEntryPaths=t,e.initialMicrosteps=n}};let r=t=>S(t)?e.childRuntime.close(t):z,i=e.execution.initial,a=yield*(i===void 0?e.logic.initial(e.processScope).pipe(Rr(e=>({state:e,done:void 0,output:void 0}))):i(e.processScope)).pipe(mr(t=>(S(t)&&e.publishStartFailed(t.cause),r(t))),kt(A(()=>{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:vn,poll:A(()=>Xt(e_(e.mailbox),Kg)),receiveMessage:vn,pollMessage:A(()=>e.pollCompiledMessage()),completeMessage:t=>e.completeCompiledMessage(t),state:A(()=>e.current.snapshot.state),setState:t=>e.setActiveState(t),updateState:t=>e.updateState(t)}:(e.compiledContext=new H_(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(vt))),e.options.onSnapshot!==void 0&&(yield*l_(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 A(()=>this.current.snapshot.state)}get snapshot(){return A(()=>this.current.snapshot)}get changes(){return this.changesStream()}get emissions(){return this.externalEmissions?.stream??this.emissionsStream()}get join(){return I(()=>this.lifecycle===`Completed`?this.resolveCompletion(this.completion):(this.waiter??=Hr(),gn(this.waiter)))}get stop(){return Le(this.stopEffect())}child(e){return this.childRuntime.get(e)}childChanges(e){return this.childRuntime.changes(e)}requestTermination(e){return A(()=>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(vt);return this.runState===`Initializing`?e:e.pipe(H(ur))}failCause(e){let t={_tag:`Failure`,cause:e};return this.requestTermination(t).pipe(U(e=>e?Fn(this.settleRequestedTermination()).pipe(vt):z))}sendAcknowledgedEffect(e){return qe(t=>Vt().pipe(U(n=>this.offerEvent(e,void 0,void 0,n).pipe(H(t(gn(n)))))))}offerEvent(e,t,n,r){return I(()=>{let i=this.inspector,a=this.inspectionSubject,o=i?.isActive()===!0&&a!==void 0?p_(i,a,e,t,n,r):r===void 0?e:{[Wg]:!0,event:e,deferred:r};return this.offerMessage(o)})}offerMessage(e){return Le(me(t=>{if(this.mailbox.closed||this.lifecycle!==`Active`)return Ze(new Fd);let n=this.inspector,r=this.inspectionSubject;n!==void 0&&r!==void 0&&m_(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&&$g(this.mailbox,e),this.runState!==`Idle`)return z;if(this.runState=`Draining`,o!==void 0){let n;try{n=o(a,e)}catch(e){n=Nt(e)}return n!==void 0||this.hasTerminationRequest()?this.startWorker(n):(this.runState=`Idle`,this.scheduleChangesFlush(t.currentDispatcher),z)}return this.startWorker(void 0)}))}startWorker(e){let t=An(this.drainRuntime(e),this.services);return(this.options.detached===!0?Fn(t,{startImmediately:!0}):Cr(t,{startImmediately:!0})).pipe(U(e=>A(()=>(e.pollUnsafe()===void 0&&(this.worker=e),this.interruptRequested?(this.interruptRequested=!1,!0):!1)).pipe(U(t=>t?Fn(this.interruptAndFinish(e)):z))),vt)}stopEffect(){return I(()=>this.lifecycle===`Completed`||this.finishIdleChildlessStop()?z:this.requestTermination({_tag:`Stopped`}).pipe(U(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!==b_||this.current.terminalizing||this.current.snapshot.status!==`active`)return!1;this.emissionsPubSub=b_;let e={status:`stopped`,state:this.current.snapshot.state};return this.lifecycle=`TerminationRequested`,this.termination={_tag:`Stopped`},this.terminationSnapshot=e,t_(this.mailbox),this.current={revision:this.current.revision+1,terminalizing:!0,changes:void 0,snapshot:e},this.notifySnapshotObservers(),Yg(this.inFlightMessage),this.inFlightMessage=void 0,this.interruptRequested=!1,this.compiledContext!==void 0&&(this.compiledContext.executionState=void 0),this.options.onStopSync?.(this),this.completion=B_,this.lifecycle=`Completed`,this.waiter!==void 0&&(er(this.waiter,this.resolveCompletion(B_)),this.waiter=void 0),!0}settleRequestedTermination(){return I(()=>this.runState===`Draining`?this.worker===void 0?(this.interruptRequested=!0,this.awaitCompletion()):this.interruptAndFinish(this.worker).pipe(H(this.awaitCompletion())):this.finishRequestedTermination())}interruptAndFinish(e){return nt(e).pipe(H(I(()=>this.lifecycle===`Completed`?z:this.finishRequestedTermination())))}awaitCompletion(){return this.lifecycle===`Completed`?z:this.join.pipe(Lt,vt)}resolveCompletion(e){if(e!==B_)return e;let t=Ze(new Fd);return this.completion=t,t}drainRuntime(e){let t=this;return qe(n=>qt(function*(){let r=t.offerRevision,i=e;for(;;){if(t.hasTerminationRequest())return yield*t.finishRequestedTermination();let e=yield*n(I(()=>{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(Lt);if(t.flushPendingChanges(),S(e))return t.lifecycle===`Active`&&(yield*t.requestTermination({_tag:`Failure`,cause:e.cause})),yield*t.finishRequestedTermination();if(Vr(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 I(()=>{if(this.lifecycle!==`TerminationRequested`)return z;let e=this.termination;if(e===void 0)return z;let t=this.terminationSnapshot??this.reserveTermination(e);if(t===void 0)return this.awaitCompletion();let n=e._tag===`Stopped`?P:e._tag===`Done`?ft(e.output):ei(e.cause),r=e._tag===`Stopped`?B_:e._tag===`Done`?mt(e.output):c(e.cause),i=this.options.onOutcome===void 0||e._tag===`Stopped`&&this.options.skipStoppedOutcome===!0?z:I(()=>this.options.onOutcome(c_(t))).pipe(Lt,vt),a=this.inspector,o=this.inspectionSubject,s=a===void 0||o===void 0?this.closeEmissions():this.closeEmissions().pipe(H(A(()=>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`?st():n}))));return Le(A(()=>{t_(this.mailbox)}).pipe(H(this.childRuntime.close(n)),H(this.setAndPublishSnapshot(t)),H(s),H(A(()=>{e._tag===`Failure`?Jg(this.inFlightMessage,e.cause):Yg(this.inFlightMessage),this.inFlightMessage=void 0})),H(i),H(this.options.onStop??z),H(this.options.inspectionRoot===!0&&this.inspector!==void 0?this.inspector.close:z),H(A(()=>{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&&(er(this.waiter,this.resolveCompletion(r)),this.waiter=void 0)}))))})}publishSnapshot(e){let t=e.changes===void 0?mt(e):Ve(e.changes,[e]).pipe(se(e)),n=e.snapshot;return this.options.onSnapshot===void 0||n.status!==`active`?t:t.pipe(He(()=>l_(this.options.onSnapshot,n)))}completeChanges(e){return e.changes===void 0?z:Ve(e.changes,ft(void 0)).pipe(vt)}emitEvent(e){let t=this.externalEmissions===void 0?I(()=>this.emissionsPubSub===void 0||this.emissionsPubSub===b_?z:Ve(this.emissionsPubSub,e).pipe(vt)):this.externalEmissions.emit(e),n=this.inspector,r=this.inspectionSubject;return n===void 0||r===void 0?t:t.pipe(He(()=>A(()=>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=b_,e===void 0||e===b_?z:p(e)}getOrCreateEmissions(){return I(()=>{let e=this.emissionsPubSub;return e===b_?mt(void 0):e===void 0?Ie().pipe(U(e=>A(()=>{let t=this.emissionsPubSub;return t===b_?[void 0,!0]:t===void 0?(this.emissionsPubSub=e,[e,!1]):[t,!0]}).pipe(U(([t,n])=>n?p(e).pipe(se(t)):mt(t))))):mt(e)})}emissionsStream(){return Yr(this.getOrCreateEmissions().pipe(Rr(e=>e===void 0?lr:un(e))))}setAndPublishSnapshot(e){return I(()=>{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(U(e=>this.completeChanges(e)),vt)})}setActiveState(e){return I(()=>this.commitActiveState(e)??z)}pollCompiledMessage(){let e=e_(this.mailbox);return Vr(e)&&(this.inFlightMessage=Gg(e.value)?e.value:void 0),e}beginCompiledMessage(e){this.inFlightMessage=Gg(e)?e:void 0}completeCompiledMessage(e){qg(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]:Gn(a.changes,[a]):(r.push(a),t?a.pendingChanges=r:Gn(a.changes,r))),this.notifySnapshotObservers(),this.options.onSnapshot===void 0?void 0:l_(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,Gn(e.changes,t))}updateState(e){return I(()=>{let t=this.current;return t.terminalizing||t.snapshot.status!==`active`?z:e(t.snapshot.state).pipe(U(e=>{let n=this.current;return n.terminalizing||n.revision!==t.revision?z:this.setActiveState(e)}))})}getOrCreateChanges(){return I(()=>{let e=this.current;return e.snapshot.status===`active`?e.changes===void 0?Ie({replay:1}).pipe(U(e=>A(()=>{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(U(([t,n])=>n?p(e).pipe(se(t)):mt(t))))):mt(e.changes):mt(void 0)})}changesStream(){let e=this;return Yr(qt(function*(){let t=yield*e.getOrCreateChanges();if(t===void 0)return oi(e.current.snapshot);let n=yield*zn(t),r=e.current;return r.snapshot.status===`active`?oi(r.snapshot).pipe(Kt(Lr(F(Ae(n))).pipe(Xn(e=>e.revision>r.revision),pr(e=>e.snapshot)))):oi(r.snapshot)}))}},H_=class{scope;ownedChildren;process;executionState;constructor(e,t,n){this.scope=e,this.ownedChildren=t,this.process=n}poll(){return Xt(this.process.pollCompiledMessage(),Kg)}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}},U_=Nr(function*(e,t){let n=t.sessionId??(yield*t.runtime.nextSessionId),r=yield*ge(),i=e.execution,a=new V_(e,t,r,n);return yield*(i.initialSync!==void 0&&t.onReady===void 0&&t.onSnapshot===void 0?a.initializeCompiledSync():a.initialize()).pipe(mr(e=>S(e)?a.shutdownEmissions().pipe(H(t.inspectionRoot===!0&&t.runtime.inspection!==void 0?t.runtime.inspection.close:z)):z))}),W_=(e,t,n,r)=>new V_(e,t,n,r).initializeCompiledSync(),G_=Nr(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:d_(e,m,p),_=h===void 0||t.activity===void 0?void 0:{...t.activity,sessionId:p},v,y,b=n_(),x=t.emissions??x_(),C=yield*Vt(),w=yield*Vt(),T=gn(w).pipe(Lt,vt),E=!0,D,O=Zt(C,{_tag:`Stopped`}).pipe(vt),k=(e,t)=>I(()=>r_(b,e,t)?z:Ze(new Fd)),j=h===void 0?void 0:(e,t,n,r)=>I(()=>{let i=h.isActive()?p_(h,g,e,t,n,r):r===void 0?e:{[Wg]:!0,event:e,deferred:r};return k(i,()=>m_(h,g,i))}),M=e.execution?._tag===`Compiled`?e=>qe(t=>Vt().pipe(U(n=>(h===void 0?k({[Wg]:!0,event:e,deferred:n}):j(e,void 0,void 0,n)).pipe(H(t(gn(n))))),Rr(e=>e))):void 0,N={id:m,sessionId:p,stop:I(()=>E?O:O.pipe(H(vn))),send:h===void 0?e=>k(e):e=>j(e,void 0,void 0),...h===void 0?void 0:{inspectionSubject:g,sendInspected:j}},{changes:L,close:R,get:ee,owned:te,sendTo:ne,spawn:re,stop:ie}=S_;Qg(e.execution)||({changes:L,close:R,get:ee,owned:te,sendTo:ne,spawn:re,stop:ie}=yield*w_(N,d,void 0,M===void 0?void 0:e=>M(e)));let B=e=>Jr(e)?z:(h!==void 0&&h.publishUnsafe(_===void 0?{_tag:`StartFailed`,subject:g,cause:e.cause}:{_tag:`ActivityStopped`,subject:_.owner,activity:_,exit:e}),R(e).pipe(H(x.close()),H(t.inspectionRoot===!0&&h!==void 0?h.close:z))),V=l===void 0?c??z:A(()=>l(Re)),ae=h===void 0?y_:()=>f_(D,E),oe=f??(u===void 0?__:h===void 0?u.send:e=>Zg(u,e,g,ae())),ce=h===void 0?x.emit:e=>x.emit(e).pipe(He(()=>A(()=>h.publishUnsafe({_tag:`Emitted`,subject:g,emission:e,causedBy:ae()})))),le={self:N,parent:u,spawn:re,sendParent:oe,emit:ce,sendTo:h===void 0?((e,t)=>Xg(e)?e.send(t):ne(e,t)):((e,t)=>Xg(e)?Zg(e,t,g,ae()):ne(e,t,g,ae())),stopChild:ie,failCause:e=>Zt(C,{_tag:`Failure`,cause:e}).pipe(vt),inspectInitial:h===void 0?v_:(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 ue=yield*e.initial(le).pipe(mr(B),kt(A(()=>{E=!1}))),de=yield*nr({revision:0,terminalizing:!1,changes:void 0,snapshot:{status:`active`,state:ue}});_===void 0&&h?.publishUnsafe({_tag:`Initialized`,subject:g,snapshot:{status:`active`,state:ue},initialEntryPaths:v??[],microsteps:Rg({microsteps:y??[]})});let fe=s===void 0?e=>e.changes===void 0?mt(e):Ve(e.changes,[e]).pipe(se(e)):e=>{let t=e.changes===void 0?mt(e):Ve(e.changes,[e]).pipe(se(e)),n=e.snapshot;return n.status===`active`?t.pipe(He(()=>l_(s,n))):t},pe=e=>e.changes===void 0?z:Ve(e.changes,ft(void 0)).pipe(vt),me=e=>e.snapshot.status===`active`?mt(e):pe(e).pipe(se(e)),he=e=>jr(de).pipe(U(t=>t.revision===e.revision?fe(e).pipe(U(me)):mt(void 0))),ge=e=>Mn(de,t=>t.terminalizing?mt([void 0,t]):Rr(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(U(e=>e===void 0?mt(void 0):he(e)),Rr(e=>e?.snapshot)),_e=e=>br(de,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(Rr(e=>e?.snapshot)),ve=e=>Wt(de,t=>({revision:t.revision+1,snapshot:e,terminalizing:!0,changes:t.changes})).pipe(U(fe),U(me),vt),ye=h===void 0?e=>ge(t=>mt(t.status===`active`?{status:`active`,state:e}:void 0)).pipe(vt):t=>jr(de).pipe(U(n=>ge(e=>mt(e.status===`active`?{status:`active`,state:t}:void 0)).pipe(He(r=>A(()=>{e.inspection?.kind!==`Machine`&&r!==void 0&&h.publishUnsafe({_tag:`StateChanged`,subject:g,before:n.snapshot.state,after:t,causedByDeliveryId:D!==void 0&&Gg(D)?D.inspection?.deliveryId:void 0})})))),vt),be=(e,n,r)=>{let a=i===void 0||e.status===`stopped`&&t.skipStoppedOutcome===!0?z:I(()=>i(c_(e))).pipe(Lt,vt),o=h===void 0?x.close():x.close().pipe(H(A(()=>h.publishUnsafe(_===void 0?{_tag:`Terminated`,subject:g,snapshot:e}:{_tag:`ActivityStopped`,subject:_.owner,activity:_,exit:e.status===`stopped`?st():n}))));return Le(A(()=>a_(b)).pipe(H(R(n)),H(ve(e)),H(o),H(A(()=>{S(n)?Jg(D,n.cause):Yg(D),D=void 0})),H(a),H(V),H(t.inspectionRoot===!0&&h!==void 0?h.close:z),H(r)))},xe=_e(e=>({status:`stopped`,state:e.state})),Se=e=>_e(t=>({status:`error`,state:t.state,cause:e})),Ce=e=>_e(t=>({status:`done`,state:t.state,output:e})),we=e=>be(e,P,On(w,new Fd)),Te=(e,t)=>{let n=ei(t);return be(e,n,Sn(w,t))},Ee=(e,t)=>{let n=ft(t);return be(e,n,Zt(w,t))},De=Le(O.pipe(H(T))),Oe=e.execution?._tag===`Compiled`?{receiveMessage:i_(b).pipe(He(e=>A(()=>{D=Gg(e)?e:void 0}))),pollMessage:A(()=>e_(b)).pipe(He(e=>A(()=>{Vr(e)&&(D=Gg(e.value)?e.value:void 0)}))),completeMessage:e=>{qg(D,e),D=void 0}}:void 0,ke=h===void 0||e.execution?._tag===`Compiled`?i_(b).pipe(Rr(Kg)):i_(b).pipe(He(e=>A(()=>{D=e})),Rr(Kg)),je=h===void 0||e.execution?._tag===`Compiled`?A(()=>e_(b)).pipe(Rr(Xt(Kg))):A(()=>e_(b)).pipe(He(e=>A(()=>{Vr(e)&&(D=e.value)})),Rr(Xt(Kg))),Me=h===void 0?e=>ge(t=>t.status===`active`?e(t.state).pipe(Rr(e=>({status:`active`,state:e}))):mt(void 0)).pipe(vt):t=>jr(de).pipe(U(n=>ge(e=>e.status===`active`?t(e.state).pipe(Rr(e=>({status:`active`,state:e}))):mt(void 0)).pipe(He(t=>A(()=>{e.inspection?.kind!==`Machine`&&t?.status===`active`&&h.publishUnsafe({_tag:`StateChanged`,subject:g,before:n.snapshot.state,after:t.state,causedByDeliveryId:D!==void 0&&Gg(D)?D.inspection?.deliveryId:void 0})})))),vt),Ne={...le,...e.execution?._tag===`Compiled`&&!e.execution.childless?{ownedChildren:te}:void 0,...Oe,receive:ke,poll:je,state:jr(de).pipe(Rr(e=>e.snapshot.state)),setState:ye,updateState:Me},Pe=Mn(de,e=>e.snapshot.status===`active`?e.changes===void 0?Ie({replay:1}).pipe(Rr(t=>[t,{...e,changes:t}])):mt([e.changes,e]):mt([void 0,e])),Fe=Yr(qt(function*(){let e=yield*Pe;if(e===void 0)return oi((yield*jr(de)).snapshot);let t=yield*zn(e),n=yield*jr(de);return n.snapshot.status===`active`?oi(n.snapshot).pipe(Kt(Lr(F(Ae(t))).pipe(Xn(e=>e.revision>n.revision),pr(e=>e.snapshot)))):oi(n.snapshot)})),Re={id:m,sessionId:p,...h===void 0?void 0:{inspectionSubject:g,sendInspected:j},state:jr(de).pipe(Rr(e=>e.snapshot.state)),snapshot:jr(de).pipe(Rr(e=>e.snapshot)),changes:Fe,emissions:x.stream,join:gn(w),stop:De,send:N.send,...M===void 0?void 0:{[Ug]:M},child:ee,childChanges:L};o!==void 0&&!o(Re)?yield*O:a!==void 0&&(yield*a(Re,O)),s!==void 0&&(yield*l_(s,{status:`active`,state:ue}));let ze=e=>{switch(e._tag){case`Stopped`:return xe;case`Done`:return Ce(e.output);case`Failure`:return Se(e.cause)}},Be=(e,t)=>{switch(e._tag){case`Stopped`:return we(t);case`Done`:return Ee(t,e.output);case`Failure`:return Te(t,e.cause)}},Ue=e=>n===!0?Fn(e,{startImmediately:!0}):Cr(e,{startImmediately:!0}),We=yield*ai(C),Ge=Bt(We)?yield*qe(t=>t(I(()=>e.run(Ne))).pipe(Lt,U(e=>Zt(C,S(e)?{_tag:`Failure`,cause:e.cause}:{_tag:`Done`,output:e.value})))).pipe(Ue):void 0;return yield*Ue(qe(e=>qt(function*(){let t=Vr(We)?yield*We.value:yield*e(gn(C)),n=yield*ze(t);return Ge!==void 0&&(yield*nt(Ge)),n===void 0?yield*T:yield*Be(t,n)}))),Re}),K_=((e,t)=>e.execution?._tag===`Compiled`?U_(e,t):G_(e,t)),q_=u_(K_,W_),J_=new WeakMap,Y_=e=>I(()=>{e.closed=!0;let t=Array.from(e.live).reverse();return e.live.clear(),ar(t,e=>e.stop,{discard:!0})}),X_=()=>{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},Z_=e=>U(lt,t=>{let n=J_.get(t);if(n!==void 0)return e(n.hooks);let r=X_();return J_.set(t,r),H(rn(t,Y_(r)),e(r.hooks))});Nr(function*(e,t,n){let r=yield*q_,i=n===void 0?{detached:!0,runtime:r}:{...n,detached:!0,runtime:r};return t===`generic`?yield*Z_(t=>G_(e,{...i,...t})):t===`compiled`?e.execution?._tag===`Compiled`?yield*Z_(t=>U_(e,{...i,...t})):yield*Nt(Error(`Machine cannot force the compiled runtime for generic process logic`)):yield*Z_(t=>K_(e,{...i,...t}))});var Q_=Nr(function*(e,t){let n=yield*q_;return yield*Z_(r=>K_(e,t===void 0?{detached:!0,runtime:n,...r}:{...t,detached:!0,runtime:n,...r}))}),$_=Nr(function*(e,t,n){let r=yield*q_,i=yield*r.nextSessionId,a=yield*Fg(i);r.inspection=a;let o=x_(),s=yield*Vt(),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*Tt(Z_(n=>{let r={...c,...n};return t===`generic`?G_(e,r):t===`compiled`?e.execution?._tag===`Compiled`?U_(e,r):Nt(Error(`Machine cannot force the compiled runtime for generic process logic`)):K_(e,r)}).pipe(mr(e=>fr(s,e))));return{id:n?.id??i,sessionId:i,changes:Yr(gn(s).pipe(Rr(e=>e.changes))),emissions:o.stream,inspection:a.stream,start:l}}),ev=((e,t)=>$_(e,`auto`,t));ut({_tag:Tn(`MachineSnapshot`),version:Tn(2),active:zr(ut({path:ri,value:it(jn)})),completed:it(zr(ut({path:ri,output:it(jn)}))),history:it(ci(ri,ut({mode:Ut([`shallow`,`deep`]),active:zr(ri),values:ci(ri,jn)})))});var tv=(e,t,n)=>{let r=Q(e,n);if(r.type===`compound`){let r=rm(e,t,n);if(r===void 0)throw Error(`Machine expected completed state "${n}" to have an active child`);return tv(e,t,r)}return r.output},nv=(e,t)=>qt(function*(){let n=yield*Jp(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)||!om(e,n,a))throw Error(`Machine snapshot contains invalid completion "${a}"`);i.add(a);let o=tv(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*ep(e,o,t.output,{boundary:`output`,state:a}))}return zp(e,{...n,outputs:r})}).pipe(be(t=>rv(e,t))),rv=(e,t)=>{if(Fe(t))return c(Te(t,t=>t instanceof jd?t:new jd({machineId:e.id,boundary:`configuration`,cause:f(t)})));let n=Rn(t);return Vr(n)&&n.value instanceof jd?Ze(n.value):Ze(new jd({machineId:e.id,boundary:`configuration`,cause:t}))},iv=e=>e.length===0?z:e.length===1?e[0]:_(e,{discard:!0}),av=(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}),ov=new WeakMap,sv=e=>{let t=ov.get(e);if(t!==void 0)return t;let n=Object.values(zd(e).handlers).some(e=>e.invoke!==void 0);return ov.set(e,n),n},cv=mt(ot()),lv=(e,t)=>{let n=Tg(e),r=new WeakMap,i=t=>{let n=r.get(t.scope);return n===void 0&&(n=Xh(e,t.scope),r.set(t.scope,n)),n},a=n=>{if(!t)return;let r=n.state();return Uh(e,r)?Wh(e,r,Hh).pipe(Rr(qr)):void 0},o=e=>I(()=>c(e)??cv),s=(e,t,r,a,s)=>{let c=a.commands.length===0?void 0:Zh(a.commands,e.scope),l=a.emittedEvents.length===0?void 0:Qh(a.emittedEvents,i(e)),u=()=>{let i=I(()=>(t&&e.completeMessage({before:r,plan:av(a,n.snapshot),after:s}),a.done?mt(qr(a.output)):o(e)));return l===void 0?i:l.pipe(H(i))},d=()=>{let t=e.commit(s),n=u(),r=t===void 0?n:t.pipe(H(n));return t===void 0&&l===void 0?r:e.runAfterChanges(r)};return c===void 0?d():e.runAfterChanges(c.pipe(H(I(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(Bt(e))return;r=e.value}let a=Gg(r),c=a?r.event:r,l=t.state(),u;try{u=n.plan(t.executionState??n.fromConfiguration(Kp(e,l)),c,a,t.scope)}catch(e){return Ld(e)}if(t.executionState=u.next,u.microsteps.length===0){a&&t.completeMessage({before:l,plan:av(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(H(I(()=>(a&&t.completeMessage({before:l,plan:av(u,n.snapshot),after:d}),o(t))))));a&&t.completeMessage({before:l,plan:av(u,n.snapshot),after:d})}};return{run:e=>s_(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:s_(r,e.scope)}}},uv=class{initialized=!1;initial;constructor(e){this.initial=e}},dv=(e,t)=>{let n=Tg(e);return r=>{let i=r.state();if(t&&Uh(e,i))return Wh(e,i,Hh).pipe(Rr(qr));let a=r.scope,o=r.executionState,s=o instanceof uv?o:new uv;r.executionState=s;let c,l,u;return u=I(()=>{let t=r.pollMessage();if(Bt(t))return l=void 0,mt(ot());let o=t.value,s=Gg(o),d=s?o.event:o,f=i,p;try{p=n.plan(l??n.fromConfiguration(Kp(e,i)),d,s,a)}catch(e){return Ld(e)}if(l=p.next,p.microsteps.length===0)return s&&r.completeMessage({before:f,plan:av(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(Zh(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(Qh(p.emittedEvents,c??=Xh(e,a))),p.done)b.push(r.ownedChildren.stopAll());else if(m)for(let[t,n]of g){let i=z_(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=I(()=>(s&&r.completeMessage({before:f,plan:av(p,n.snapshot),after:v}),p.done?mt(qr(p.output)):u));return b.length===0?e:iv(b).pipe(H(e))},C=()=>{let e=x(),t=S(),n=e===void 0?t:e.pipe(H(t));return e===void 0&&b.length===0?n:r.runAfterChanges(n)};return y.length===0?C():r.runAfterChanges(iv(y).pipe(H(I(C))))}),s_(I(()=>{if(s.initialized)return u;let t=s.initial,o=t?.activeConfiguration??Kp(e,i);l=t?.configuration??n.fromConfiguration(o);let c=z_(e,a,r.ownedChildren,o,t?.entryPaths??Lp(e,o),Hh);return s.initial=void 0,s.initialized=!0,c===void 0?u:c.pipe(H(u))}),a)}},fv=e=>e.done?{state:e.state,done:!0,output:e.output}:{state:e.state,done:!1,output:void 0},pv=(e,t)=>{let n=sv(e),r=Tg(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=fv(t);return n?{...r,executionState:new uv({configuration:t.configuration,activeConfiguration:t.activeConfiguration,entryPaths:t.initialEntryPaths})}:r}catch(e){throw Rd(e)}},s=t=>a===void 0?s_(Yh(rh(e,t),...i).pipe(U(n=>{t.inspectInitial(n.initialEntryPaths,n.microsteps);let r=n.commands.length===0?void 0:Zh(n.commands,t),i=n.emittedEvents.length===0?void 0:Qh(n.emittedEvents,Xh(e,t)),a=mt(fv(n));return r===void 0?i===void 0?a:i.pipe(H(a)):i===void 0?r.pipe(H(a)):r.pipe(H(i),H(a))})),t):je({try:()=>o(t),catch:Rd});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:dv(e,t._tag===`Resume`)}:{_tag:`Owned`,...lv(e,t._tag===`Resume`)}},initial:n=>t._tag===`Resume`?s_(nv(e,t.snapshot),n):s(n).pipe(Rr(e=>e.state)),run:t=>s_(qt(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*Nt(Error(`Machine statechart started without acknowledged mailbox access`));let c,l=yield*o;if(Uh(e,l))return yield*Wh(e,l,Hh);if(!n){let n,o=ot(),u;for(;c===void 0;){let d=Vr(o)?o.value:yield*a;o=ot();let f=Gg(d),p=f?d.event:d,m=l,h;try{h=Jh(e,xp(n??Kp(e,l),t),p)}catch(e){return yield*Ld(e)}if(n=h.next,h.microsteps.length>0){let n=zp(e,h.next);yield*Zh(h.commands,t),yield*s(n),l=n,h.emittedEvents.length>0&&(yield*Qh(h.emittedEvents,u??=Xh(e,t))),h.done&&(c={output:h.output})}f&&r({before:m,plan:av(h,t=>zp(e,t)),after:l}),c===void 0&&(o=yield*i,Bt(o)&&(n=void 0))}return c===void 0?yield*Nt(Error(`Machine process stopped receiving events before reaching a terminal configuration`)):c.output}let u=t.ownedChildren;if(u===void 0)return yield*Nt(Error(`Invoking statechart started without an owned child runtime`));let d=(n,r,i)=>z_(e,t,u,n,r,i)??z,f=e=>u.stopPaths(e)??z;return yield*qt(function*(){let n=yield*Jp(e,l);yield*d(n,Lp(e,n),Hh),n=void 0;let o=ot(),p;for(;c===void 0;){let m=Vr(o)?o.value:yield*a;o=ot();let h=Gg(m),g=h?m.event:m,_=l,v;try{v=Jh(e,xp(n??Kp(e,l),t),g)}catch(e){return yield*Ld(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=zp(e,v.next);if(yield*Zh(v.commands,t),n&&(yield*f(r)),yield*s(a),l=a,v.emittedEvents.length>0&&(yield*Qh(v.emittedEvents,p??=Xh(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:av(v,t=>zp(e,t)),after:l}),c===void 0&&(o=yield*i,Bt(o)&&(n=void 0))}return c===void 0?yield*Nt(Error(`Machine process stopped receiving events before reaching a terminal configuration`)):c.output}).pipe(mr(()=>u.stopAll()))}),t)}},mv=new WeakMap,hv=(e,...t)=>{if(t.length>0)return pv(e,{_tag:`Initial`,args:t});let n=mv.get(e);if(n!==void 0)return n;let r=pv(e,{_tag:`Initial`,args:t});return mv.set(e,r),r},gv=(e,t)=>pv(e,{_tag:`Resume`,snapshot:t}),_v=(e,...t)=>ev(hv(e,...t),e.id===void 0?void 0:{id:e.id}),vv=(e,t)=>Q_(gv(e,t),e.id===void 0?void 0:{id:e.id}),yv={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`]},bv=[`title`,`description`,`documentation`],xv=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Sv=(e,t)=>{let n=typeof t==`symbol`?`[${String(t)}]`:t===``?`<empty>`:String(t);return e===``?n:`${e}.${n}`},Cv=(e,t,n)=>{throw Error(`${e} invalid state definition at "${t}": ${n}`)},wv=e=>Number.isFinite(Number(e)),Tv=e=>e.length===0||e.some(e=>e===`untagged`)?`untagged`:e.every(e=>e===`tagged`)?`tagged`:`opaque`,Ev=(e,t)=>{if(t.has(e))return`opaque`;if(ve(e)||ae(e)||jt(e)||Rt(e)||l(e)||yt(e))return`tagged`;if(Et(e))return typeof e.literal==`string`||typeof e.literal==`number`?`tagged`:`untagged`;let n=new Set(t).add(e);return Qe(e)?Tv(e.types.map(e=>Ev(e,n))):Ft(e)?Ev(e.thunk(),n):le(e)?`opaque`:`untagged`},Dv=(e,t=new Set)=>{if(t.has(e))return`opaque`;if(Se(e)){let n=e.propertySignatures.find(({name:e})=>e===`_tag`)?.type;return n===void 0||yr(n)?`untagged`:Ev(n,new Set(t).add(e))}let n=new Set(t).add(e);return Qe(e)?Tv(e.types.map(e=>Dv(e,n))):Ft(e)?Dv(e.thunk(),n):le(e)?`opaque`:`untagged`},Ov=e=>Je(e)&&Dv(pn(e.ast))!==`untagged`,kv=(e,t,n)=>{let r=Sv(t,n);return typeof n==`symbol`?Cv(e,r,`state keys must be strings, not symbols`):typeof n==`number`?Cv(e,r,`state keys cannot use numeric forms`):n===``?Cv(e,r,`state keys cannot be empty`):n===`__proto__`?Cv(e,r,`the state key "__proto__" is not allowed`):n.includes(`.`)?Cv(e,r,`state keys cannot contain "."`):wv(n)?Cv(e,r,`state keys cannot use numeric forms`):r},Av=(e,t,n,r)=>{(typeof n!=`object`||!n||Array.isArray(n))&&Cv(e,t,`${r} must be a plain record`);let i=Object.getPrototypeOf(n);i!==Object.prototype&&i!==null&&Cv(e,Sv(t===`<root>`?``:t,`__proto__`),`${r} must not declare an implicit "__proto__" state key`)},jv=(e,t,n,r,i)=>{if(typeof n!=`object`||!n||Array.isArray(n)||!xv(n,r))return;let a=n[r];(typeof a!=`object`||!a||Je(a)||a.type!==`history`)&&Cv(e,`${t}.${r}`,i)},Mv=(e,t,n,r)=>{let i=yv[r];for(let a of Reflect.ownKeys(n))i.includes(a)||Cv(e,t,`${r} states cannot declare property "${String(a)}"`)},Nv=(e,t,n)=>{Av(e,`${t}.annotations`,n,`schema-less state annotations`);for(let r of Reflect.ownKeys(n))bv.includes(r)||Cv(e,`${t}.annotations`,`schema-less state annotations cannot declare property "${String(r)}"`),typeof n[r]!=`string`&&Cv(e,`${t}.annotations.${String(r)}`,`schema-less state annotation values must be strings`)},Pv=(e,t,n,r,i=!1)=>{Av(e,n===``?`<root>`:n,t,`state trees`);for(let a of Reflect.ownKeys(t)){let o=i&&a===``?``:kv(e,n,a),s=t[a];if(Je(s)){Ov(s)||Cv(e,o,`state schemas must decode to an object with a required PropertyKey _tag`);continue}Av(e,o,s,`state nodes`);let c=s.type,l=c===`history`?`history`:c===`choice`?`choice`:c===`parallel`?`parallel`:c===`final`?`final`:xv(s,`states`)?`compound`:`atomic`;if(Mv(e,o,s,l),l===`history`||l===`choice`){r||Cv(e,o,`${l} states must be declared below an active parent state`),xv(s,`annotations`)&&Nv(e,o,s.annotations),l===`history`&&xv(s,`history`)&&s.history!==`shallow`&&s.history!==`deep`&&Cv(e,`${o}.history`,`history must be "shallow" or "deep"`);continue}let u=xv(s,`schema`);u&&!Ov(s.schema)&&Cv(e,`${o}.schema`,`state schemas must decode to an object with a required PropertyKey _tag`),u&&xv(s,`annotations`)&&Cv(e,`${o}.annotations`,`schema-backed states must declare annotations on their schema`),!u&&xv(s,`annotations`)&&Nv(e,o,s.annotations),l===`atomic`&&xv(s,`type`)&&s.type!==`active`&&Cv(e,`${o}.type`,`atomic state type must be "active"`),l===`final`&&s.type!==`final`&&Cv(e,`${o}.type`,`final state type must be "final"`),l===`compound`&&xv(s,`type`)&&s.type!==`active`&&Cv(e,`${o}.type`,`compound state type must be "active"`),l===`parallel`&&s.type!==`parallel`&&Cv(e,`${o}.type`,`parallel state type must be "parallel"`),(l===`final`||l===`parallel`)&&xv(s,`output`)&&!Je(s.output)&&Cv(e,`${o}.output`,`state output must be an Effect Schema`),l===`compound`?(jv(e,o,s.states,`initial`,`active and choice child states cannot use the reserved target selector key "initial"`),u&&jv(e,o,s.states,`with`,`schema-backed compound child states cannot use the reserved local target selector key "with"`),Pv(e,s.states,o,!0)):l===`parallel`&&(xv(s,`states`)||Cv(e,`${o}.states`,`parallel states must declare child regions`),jv(e,o,s.states,`initial`,`active and choice child states cannot use the reserved target selector key "initial"`),Pv(e,s.states,o,!0))}},Fv=e=>typeof e==`object`&&e?Object.freeze({...e}):e,Iv=e=>{let t={};for(let n of Object.keys(e)){let r=e[n];if(Je(r)){Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!1,writable:!1});continue}let i=r,a={...i};`states`in i&&(a.states=Iv(i.states)),`annotations`in i&&(a.annotations=Fv(i.annotations)),Object.defineProperty(t,n,{value:Object.freeze(a),enumerable:!0,configurable:!1,writable:!1})}return Object.freeze(t)},Lv=e=>Iv(e),Rv=(e,t=``)=>{if(Je(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(xv(n,`fields`)&&(xv(n,`schema`)&&Cv(`Machine.state`,t,`declare fields or schema, not both`),Av(`Machine.state`,t,n.fields,`state fields`),xv(n.fields,`_tag`)&&Cv(`Machine.state`,t,`state fields cannot declare _tag`),r.schema=Zr(t,n.fields),delete r.fields),xv(n,`states`)){Av(`Machine.state`,t,n.states,`child states`);let e=Object.create(null);for(let r of Reflect.ownKeys(n.states))kv(`Machine.state`,t,r),e[r]=Rv(n.states[r],r);r.states=e}return t===``?(Pv(`Machine.state`,{"":r},``,!1,!0),Lv({"":r})[``]):r},zv=`~effect/Machine`,Bv=`~effect/Machine/ChildMachine`,Vv={...Un,...et,[zv]:zv,toJSON(){return{_id:`Machine`}}},Hv=(e,t)=>{let n=Object.create(Vv);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,Jf(e,n),n},Uv=e=>e.kind===`none`?$d:Qd(e.kind,e.path,e.scope,e.updatePath),Wv=e=>Object.freeze({path:e.path,kind:e.kind,scope:e.scope}),Gv=e=>e.updatePath===void 0?e.kind===`update`&&e.path!==void 0?[e.path]:[]:[e.updatePath],Kv=(e,t,n,r,i)=>{if(typeof e!=`object`||!e||!W(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(!ef(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`||!Tp(r,e.path)||!Tp(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}},qv=(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(!nf(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(!af(e)||e.update.path!==t.updatePath)throw Error(`Machine target updating "${t.updatePath}" must return target construction .update(...)`)}else if(af(e))throw Error(`Machine combined target requires an updating owner declaration`);if(e===void 0)return;let r=af(e)?e.target:e,i=typeof r==`object`&&r&&W(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&&Tp(i,t.path)))throw Error(`Machine transition resolver selected "${t.path}" but constructed "${i??`<invalid>`}"`)},Jv=(e,t,n,r,i)=>{let a={...t,root:i===``?t.state:t.ancestors[``],decline:ff};delete a.target;let o=e.resolve(a,n);if(pf(o)){if(e.declinable!==!0)throw Error(`Machine transition for state "${i}" returned decline without declaring declinable: true`);return o}return qv(o,e.selection,r),o},Yv=e=>e.kind===`update`?void 0:e.path,Xv=e=>{let t=Number(e);return Number.isInteger(t)&&t>=0&&t<4294967295&&String(t)===e},Zv=(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||Xv(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||!W(i,`target`))throw Error(`Machine transition branch "${r}" requires a target selection`);let{target:a,title:o}=i;if(!ef(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:Uv(a)})}))},Qv=(e,t,n,r={},i)=>{let a=hm(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 rf(vf(i.path,i.parent),vm(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`?mf(n.path,n.parent):vf(n.path,n.parent)}if(e.kind===`update`)return vm(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 rf(_m(t,e.path,r,i),vm(t,e.updatePath,n))}return _m(t,e.path,a,i)},$v=(e,t,n,r,i)=>Object.freeze(Object.fromEntries(e.map((e,a)=>[e.key,o=>of(t,a,e.key,e.selection.kind===`none`?lf():Qv(e.selection,n,r,o,i))]))),ey=(e,t,n)=>{if(t.kind===`none`){if(!uf(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`);qv(e,t,n)}},ty=(e,t)=>({...e,root:t===``?e.state:e.ancestors[``]}),ny=(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:Kv({target:()=>Tm(t,i)},void 0,r,n,e).selection}]));return{branches:()=>a,reenter:i.reenter,declinable:f,resolve:(e,t)=>d&&!o(e)?ff():s(e,t)}}let p=Tm(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 ff();if(s!==void 0)return s(e,a);if(h)return Qv(p,r,t,{input:g(e)});let l=u(e);return Qv(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)}}},ry=(e,t,n,r,i)=>{let a=ny(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(W(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=Zv(e.branches(),n,i),u=Object.freeze({}),d=(e,o)=>{let s={...e,root:n===``?e.state:e.ancestors[``],decline:ff};delete s.target,s.select=$v(l,u,t,r,n);let d=a(s,o);if(pf(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(!sf(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 ey(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=>Yv(e.selection)===void 0?[]:[e.selection.path]))],branches:l.map(e=>Object.freeze({type:`branch`,key:e.key,title:e.title,target:Yv(e.selection),selection:Wv(e.selection),updates:Gv(e.selection)})),evaluate:d,transition:(e,t)=>d(e,t).result}}let l=Kv(a,void 0,t,n,i),u=(e,r)=>({result:Jv(l,e,r,t,n),branchIndex:0,branchKey:void 0});return{reenter:s,declinable:c,targets:Yv(l.selection)===void 0?[]:[l.selection.path],branches:[{type:`direct`,target:Yv(l.selection),selection:Wv(l.selection),updates:Gv(l.selection)}],evaluate:u,transition:(e,t)=>u(e,t).result}},iy=(e,t,n,r)=>{let i=Object.create(null);for(let a of Reflect.ownKeys(e))i[a]=ry(e[a],t,n,r,a);return i},ay=(e,t,n,r)=>{let i=(Array.isArray(e)?e:[e]).map(e=>{let i=Em(r,e,n,e=>ty(e,n));for(let e of[`onElement`,`onDone`,`onFailure`,`onSnapshot`])i[e]!==void 0&&(i[e]=ry(i[e],t,n,r,e));return Lm(i,n)});return zm(i,n),Array.isArray(e)?Object.freeze(i):i[0]},oy=(e,t,n,r,i,a)=>{for(let o of Object.keys(a)){let s=r===``?o:`${r}.${o}`;if(!W(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=iy(d,t,s,i)),u.always!==void 0&&(u.always=ry(u.always,t,s,i,`always`)),u.onDone!==void 0&&(u.onDone=ry(u.onDone,t,s,i,`done`)),u.choice!==void 0&&(u.choice=ry(u.choice,t,s,i,`choice`)),u.invoke!==void 0&&(u.invoke=ay(u.invoke,t,s,i)),t.byPath.get(s)?.type===`choice`&&(typeof u.choice!=`object`||u.choice===null||!W(u.choice,`transition`)||typeof u.choice.transition!=`function`||!W(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=bf(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`);oy(e,t,r.states,s,i,l)}}},sy=e=>e===``?xm:e,cy=e=>{let t=!1;for(let n of e.stateNodes.byPath.values())if(n.type===`choice`){t=!0;break}if(!t)return;let n=wf(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(!Tp(o,n)){let r=i.type===`branch`?`branch "${i.key}"`:`transition`;throw Error(`Machine transition from "${sy(e.source)}" updates "${sy(n)}" before choice "${t}", whose ${r} targets "${sy(o)}" outside that owner`)}}}}}}},ly=(e,t)=>(n=>{let r=Im(t.root,n),i=Object.assign(Object.create(Vv),e);if(Jf(e,i),i.states=Object.freeze({"":r.node}),i.stateNodes=xf(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:Pm(n.root);i.initial=e=>({...gf(``,a({input:e})),input:{value:e}}),i.initialDefinition=Object.freeze({target:``,selection:Object.freeze({path:``,kind:`initial`,scope:`initial`})});let o=Object.create(null);oy(o,i.stateNodes,i.states,``,{...t,initialize:e=>i.initial(i.input===void 0?void 0:fp(i,i.input,e))},{"":r.handlers});let s=Hv(i,o);return cy(s),s}),uy=e=>{let t=Rv(e),n=dy();return Object.freeze({...n,"~effect/Machine/State":`~effect/Machine/State`,node:t})},dy=()=>({path:(e=>e),get:((e,t)=>Af(e,t).pipe(Xt(e=>e.value))),getWithParents:((e,t)=>{let n={};return Af(e,t,n).pipe(Xt(e=>({value:e.value,parents:n})))}),getSnapshot:Af,matches:((e,t)=>Vr(Af(e,t)))}),fy=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??$f(`internal`,[]),n.emittedEvents=e.emittedEvents??$f(`emitted`,[]),n.parent=e.parent,n.input=e.input,n.id=e.id,n.handlers=Object.create(null),n.handle=ly(n,Cm(e.root,e)),qf(n),n},py=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?[]:[ht(e)]},my=e=>$f(`public`,py(e)),hy=(e,t)=>gy(e,t,e=>t.input===void 0?hv(t):hv(t,e)),gy=(e,t,n)=>({[Bv]:Bv,id:e,machine:t,[km]:n}),_y=_v,vy=vv,yy=(e,t)=>{try{let n=Gh(e,...t);return{machine:e,snapshot:n.done?{status:`done`,state:n.state,output:n.output}:{status:`active`,state:n.state}}}catch{return}},by=(e,t)=>{try{let n=ni(nv(e,t));if(n._tag===`Failure`)return;let r=n.value;if(!Uh(e,r))return{machine:e,snapshot:{status:`active`,state:r}};let i=ni(Wh(e,r,Hh));return i._tag===`Success`?{machine:e,snapshot:{status:`done`,state:r,output:i.value}}:void 0}catch{return}},xy={spawn:()=>Nt(Error(`Child operations are unavailable in a planned snapshot`)),sendTo:()=>Ze(new Fd),stop:()=>z},Sy=(e,t)=>{if(e.snapshot.status!==`active`)return ot();try{let n=e.machine,r=Kp(n,e.snapshot.state);for(let e of Lp(n,r)){let i=nm(n,e);for(let a of Bm(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({...Sp(r)??ih(n,r),children:xy,state:r.values.get(e),containingState:Ip(n,r,e),ancestors:Fp(n,r,e),event:Hh}):a.input);let s=yy(i,i.input===void 0?[]:[o]);return s===void 0?void 0:qr(s)}}return ot()}catch{return}},Cy=class extends ui(`ChildNotActiveError`){},wy=new WeakMap,Ty=new WeakMap,Ey=e=>{if(typeof WeakRef>`u`||typeof FinalizationRegistry>`u`)return En(e);let t=fi(),n=new FinalizationRegistry(({entry:e,key:n})=>{let r=v(t,n);Vr(r)&&r.value===e&&St(t,n)});return r=>{let i=v(t,r);if(Vr(i)){let e=i.value.ref.deref();if(e!==void 0)return e}let a=e(r),o={ref:new WeakRef(a)};return ce(t,r,o),n.register(a,{key:r,entry:o}),a}},Dy=(e,t)=>w(di(t,e=>e.stop).pipe(He(t=>A(()=>e.setSelf(gt(t)))),U(()=>vn))),Oy=(e,t)=>Dy(e,e.result(t).pipe(U(e=>e.start))),ky=(e,t,n)=>Dy(e,vy(t,n)),Ay=(e,t)=>`~effect-atom/atom/Atom/ServerValue`in e?e[Qn](t):t(e),jy=(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}},My=e=>{let t;return()=>(t===void 0&&(t={value:e()}),t.value)},Ny=e=>e.snapshot,Py=Qr(e=>e.registry).pipe(Br),Fy=e=>I(()=>{let t=e.pending.shift();return t===void 0?(e.draining=!1,z):H(t,Fy(e))}),Iy=(e,t)=>{let n=e.get(t);return n===void 0&&(n={pending:[],draining:!1},e.set(t,n)),n},Ly=(e,t,n)=>ze(n=>{let r=bt(n(e),()=>void 0),i=t.get(n.registry);return i===void 0||!i.draining?r:Dn(Xt(n.self(),ie),()=>ue(!0))},(r,i)=>{let a=r.get(e),o=r.get(Py),s=Iy(t,o);$e(a)||s.draining?(r.setSelf(ue(!0)),s.pending.push(Hn(o,e).pipe(U(e=>n(e,i)),Lt,Rr(e=>{let t=We(e);r.setSelf(s.pending.length===0?t:ie(t))}))),s.draining||(s.draining=!0,Wr(Fy(s)))):Ce(a)?r.setSelf(bt(a,()=>void 0)):Ht(n(a.value,i),{onExit:e=>r.setSelf(We(e))})}).pipe(E),Ry=e=>Qr(t=>{let n=t(e);return $e(n)?ue(n.waiting):Ce(n)?Ne(n.cause,{previous:t.self(),waiting:n.waiting}):n.value.status===`error`?Ne(n.value.cause,{previous:t.self(),waiting:n.waiting}):gt(n.value.state,{waiting:n.waiting})}).pipe(Kr(d),M(jy(t=>[Ay(e,t)],e=>bt(e,e=>e.state)))),zy=e=>Qr(t=>{let n=t(e);if($e(n))return ue(n.waiting);if(Ce(n))return Ne(n.cause,{previous:t.self(),waiting:n.waiting});if(Bt(n.value)){let e=t.self();return Vr(e)&&Ce(e.value)?e.value:gt(ot(),{waiting:n.waiting})}return n.value.value.status===`error`?Ne(n.value.value.cause,{previous:t.self(),waiting:n.waiting}):gt(qr(n.value.value.state),{waiting:n.waiting})}).pipe(Kr(d),M(jy(t=>[Ay(e,t)],e=>bt(e,Xt(e=>e.state))))),By=(e,t)=>Qr(n=>{let r=n(e);if($e(r))return ue(r.waiting);if(Ce(r))return Ne(r.cause,{previous:n.self(),waiting:r.waiting});if(Bt(r.value))return gt(ot());let i=r.value.value,a=$t(i.child(t)),o=Ht(rt.pipe(H(i.childChanges(t).pipe(Ur(e=>A(()=>n.setSelf(gt(e))))))));return n.addFinalizer(o),gt(a)}).pipe(E),Vy=(e,t)=>Vg(e)?e[Bg](()=>t($t(e.snapshot))):Ht(e.changes.pipe(Ur(e=>A(()=>t(e))))),Hy=(e,t,n)=>{let r=Qr(t=>{let n=t(e);if($e(n))return ue(n.waiting);if(Ce(n))return Ne(n.cause,{previous:t.self(),waiting:n.waiting});if(Bt(n.value))return gt(ot());let r=n.value.value;return t.addFinalizer(Vy(r,e=>t.setSelf(gt(qr(e))))),gt(qr($t(r.snapshot)))}).pipe(M(jy(()=>[],()=>{let e=n();return e===void 0?ue(!0):gt(Xt(e,Ny),{waiting:!0})}))),i=new WeakMap,a=e=>Vr(e)?mt(e.value):Ze(new Cy({id:t.id})),o=Ly(e,i,(e,t)=>U(a(e),e=>e.send(t))),s=Ly(e,i,(e,t)=>U(a(e),e=>e.stop)),c=Uy(e,n);return{ref:e,snapshot:r,result:zy(r),send:o,stop:s,child:c}},Uy=(e,t)=>{let n=new WeakMap;return r=>{let i=n.get(r.machine);if(i===void 0){let a=r.machine,o=En(n=>{let r=hy(n,a);return Hy(By(e,r),r,My(()=>{let e=t();return e===void 0||Bt(e)?e:Sy(e.value,r)}))});i=e=>o(e),n.set(a,i)}return i(r.id)}},Wy=(e,t,n)=>{let r=E(e),i=Qr(e=>{let t=e(r);if($e(t))return ue(t.waiting);if(Ce(t))return Ne(t.cause,{previous:e.self(),waiting:t.waiting});let n=t.value;e.addFinalizer(Vy(n,t=>e.setSelf(gt(t,{waiting:t.status===`active`}))));let i=$t(n.snapshot);return gt(i,{waiting:i.status===`active`})}).pipe(M(jy(()=>[],()=>{let e=n();return e===void 0?ue(!0):gt(Ny(e),{waiting:!0})}))),a=new WeakMap,o=Ly(r,a,(e,t)=>e.send(t)),s=Ly(r,a,(e,t)=>e.stop),c=Uy(Yt(r,qr),()=>{let e=n();return e===void 0?void 0:qr(e)}),l={ref:r,snapshot:i,result:Ry(i),send:o,stop:s,child:c};return Ty.set(l,t),l},Gy=(e,t)=>Af(e,t).pipe(Xt(e=>e.value)),Ky=(e,t)=>Af(e,t),qy=(e,t)=>Yt(e,t).pipe(Kr(d),M(jy(t=>[Ay(e,t)],e=>bt(e,t)))),Jy=new WeakMap,Yy=(e,t,n,r)=>{let i=Jy.get(e);i===void 0&&(i=new Map,Jy.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},Xy=(e,t)=>Yy(e,`select`,t,()=>qy(e.result,e=>Gy(e,t))),Zy=(e,t)=>Yy(e,`selectSnapshot`,t,()=>qy(e.result,e=>Ky(e,t))),Qy=(e,t)=>Yy(e,`selectChild`,t,()=>qy(e.result,cn(e=>Gy(e,t)))),$y=(e,t)=>Yy(e,`selectSnapshotChild`,t,()=>qy(e.result,cn(e=>Ky(e,t)))),eb=(e,t)=>Yy(e,`matches`,t,()=>qy(e.result,e=>Vr(Af(e,t)))),tb=(e,t)=>Yy(e,`matchesChild`,t,()=>qy(e.result,Jn(e=>Vr(Af(e,t))))),nb=(e,t,n)=>{let r=e.atom(()=>_y(t,...n)),i=Wy(e.atom(e=>Oy(e,r)),t,My(()=>yy(t,n)));return wy.set(i,r),i},rb=(e,t,n)=>Wy(e.atom(e=>ky(e,t,n)),t,My(()=>by(t,n))),ib=(e,t,n)=>{let r={owner:e,source:t},i=b(t,e=>e(r.source),{initialValueTarget:t}).pipe(Kr((e,t)=>r.source.equals(e,t)),M(e=>Ay(r.source,e)));return n!==void 0&&(i=i.pipe(dt(n))),i},ab=(e,t)=>{let n=Ey(t=>({bridge:e(t)})),r={};for(let e of Object.keys(t.atoms)){let i=t.atoms[e];r[e]=Ey(r=>{let a=n(r);return ib(a,i(a.bridge),t.label?.(r,e))})}return r},ob=e=>{let t=((t,...n)=>nb(e,t,n));return{make:t,factory:(e=>(...n)=>t(e,...n)),resume:((t,n)=>rb(e,t,n)),family:((t,n)=>ab(n=>nb(e,t,[n]),n))}},sb=ee(2,Xy);ee(2,Zy),ee(2,Qy),ee(2,$y),ee(2,eb),ee(2,tb);var cb=ob,lb=e=>ub(X.useContext(ud),e),ub=(e,t)=>{let n=X.useMemo(()=>{let n,r,i=e=>li(e)?(n=e,e):$e(e)&&n!==void 0?n:e;return{subscribe:n=>e.subscribe(t,n),snapshot:()=>i(e.get(t)),serverSnapshot:()=>r??=i(zt(t,e))}},[e,t]);return X.useSyncExternalStore(n.subscribe,n.snapshot,n.serverSnapshot)},db=lb,$=r(),fb=1,pb=.9,mb=.8,hb=.17,gb=.1,_b=.999,vb=.9999,yb=.99,bb=/[\\\/_+.#"@\[\(\{&]/,xb=/[\\\/_+.#"@\[\(\{&]/g,Sb=/[\s-]/,Cb=/[\s-]/g;function wb(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?fb:yb;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=wb(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=fb:bb.test(e.charAt(l-1))?(d*=mb,p=e.slice(i,l-1).match(xb),p&&i>0&&(d*=_b**+p.length)):Sb.test(e.charAt(l-1))?(d*=pb,m=e.slice(i,l-1).match(Cb),m&&i>0&&(d*=_b**+m.length)):(d*=hb,i>0&&(d*=_b**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=vb)),(d<gb&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=wb(e,t,n,r,l+1,a+2,o),f*gb>d&&(d=f*gb)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Tb(e){return e.toLowerCase().replace(Cb,` `)}function Eb(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,wb(e,t,Tb(e),Tb(t),0,0,{})}var Db=Object.defineProperty,Ob=(e,t)=>Db(e,`name`,{value:t,configurable:!0}),kb=!!(typeof window<`u`&&window.document&&window.document.createElement);function Ab(e,t,{checkForDefaultPrevented:n=!0}={}){return Ob(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}Ob(Ab,`composeEventHandlers`);function jb(e){if(!kb)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}Ob(jb,`getOwnerWindow`);function Mb(e){if(!kb)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}Ob(Mb,`getOwnerDocument`);function Nb(e,t=!1){let{activeElement:n}=Mb(e);if(!n?.nodeName)return null;if(Pb(n)&&n.contentDocument)return Nb(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=Mb(n).getElementById(e);if(t)return t}}return n}Ob(Nb,`getActiveElement`);function Pb(e){return e.tagName===`IFRAME`}Ob(Pb,`isFrame`);var Fb=Object.defineProperty,Ib=(e,t)=>Fb(e,`name`,{value:t,configurable:!0});function Lb(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}Ib(Lb,`setRef`);function Rb(...e){return t=>{let n=!1,r=e.map(e=>{let r=Lb(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Lb(e[t],null)}}}}Ib(Rb,`composeRefs`);function zb(...e){return X.useCallback(Rb(...e),e)}Ib(zb,`useComposedRefs`);var Bb=Object.defineProperty,Vb=(e,t)=>Bb(e,`name`,{value:t,configurable:!0});function Hb(e,t){let n=X.createContext(t);n.displayName=e+`Context`;let r=Vb(e=>{let{children:t,...r}=e,i=X.useMemo(()=>r,Object.values(r));return(0,Z.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=X.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return Vb(i,`useContext`),[r,i]}Vb(Hb,`createContext`);function Ub(e,t=[]){let n=[];function r(t,r){let i=X.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=Vb(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=X.useMemo(()=>o,Object.values(o));return(0,Z.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=X.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return Vb(s,`useContext`),[o,s]}Vb(r,`createContext`);let i=Vb(()=>{let t=n.map(e=>X.createContext(e));return Vb(function(n){let r=n?.[e]||t;return X.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,Wb(i,...t)]}Vb(Ub,`createContextScope`);function Wb(...e){let t=e[0];if(e.length===1)return t;let n=Vb(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return Vb(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return X.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}Vb(Wb,`composeContextScopes`);var Gb=globalThis?.document?X.useLayoutEffect:()=>{},Kb=Object.defineProperty,qb=(e,t)=>Kb(e,`name`,{value:t,configurable:!0}),Jb=X.useId||(()=>void 0),Yb=0;function Xb(e){let[t,n]=X.useState(Jb());return Gb(()=>{e||n(e=>e??String(Yb++))},[e]),e||(t?`radix-${t}`:``)}qb(Xb,`useId`);var Zb=Object.defineProperty,Qb=(e,t)=>Zb(e,`name`,{value:t,configurable:!0}),$b=X.useEffectEvent,ex=X.useInsertionEffect;function tx(e){if(typeof $b==`function`)return $b(e);let t=X.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof ex==`function`?ex(()=>{t.current=e}):Gb(()=>{t.current=e}),X.useMemo(()=>((...e)=>t.current?.(...e)),[])}Qb(tx,`useEffectEvent`);var nx=Object.defineProperty,rx=(e,t)=>nx(e,`name`,{value:t,configurable:!0}),ix=X.useInsertionEffect||Gb;function ax({prop:e,defaultProp:t,onChange:n=rx(()=>{},`onChange`),caller:r}){let[i,a,o]=ox({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,X.useCallback(t=>{if(s){let n=sx(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}rx(ax,`useControllableState`);function ox({defaultProp:e,onChange:t}){let[n,r]=X.useState(e),i=X.useRef(n),a=X.useRef(t);return ix(()=>{a.current=t},[t]),X.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}rx(ox,`useUncontrolledState`);function sx(e){return typeof e==`function`}rx(sx,`isFunction`);var cx=Symbol(`RADIX:SYNC_STATE`);function lx(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=tx(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=X.useReducer((t,n)=>{if(n.type===cx)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=X.useRef(p);X.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=X.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return X.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:cx,state:i})},[i,d.state,c]),[h,f]}rx(lx,`useControllableStateReducer`);var ux=Object.defineProperty,dx=(e,t)=>ux(e,`name`,{value:t,configurable:!0});function fx(e){let t=X.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];r=Sx(r),X.Children.forEach(r,e=>{if(vx(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;for(;bx(n)&&typeof Ex==`function`;)n=Ex(n._payload);a=hx(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=X.cloneElement(a,void 0,s):!o&&X.Children.count(r)===1&&X.isValidElement(r)&&(a=r);let c=a?_x(a):void 0,l=zb(n,c);if(!a){if(r||r===0)throw Error(o?Tx(e):wx(e));return r}let u=gx(i,a.props??{});return a.type!==X.Fragment&&(u.ref=n?l:c),X.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}dx(fx,`createSlot`);var px=Symbol.for(`radix.slottable`);function mx(e){let t=dx(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=px,t}dx(mx,`createSlottable`);var hx=dx((e,t)=>`child`in e.props?X.isValidElement(t)?X.cloneElement(t,void 0,e.props.children(t.props.children)):null:X.isValidElement(t)?t:null,`getSlottableElementFromSlottable`);function gx(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`?n[r]=[i,a].filter(Boolean).join(` `):r===`aria-describedby`&&(n[r]=Cx(a,i))}return{...e,...n}}dx(gx,`mergeProps`);function _x(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}dx(_x,`getElementRef`);function vx(e){return X.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===px}dx(vx,`isSlottable`);var yx=Symbol.for(`react.lazy`);function bx(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===yx&&`_payload`in e&&xx(e._payload)}dx(bx,`isLazyComponent`);function xx(e){return typeof e==`object`&&!!e&&`then`in e}dx(xx,`isPromiseLike`);function Sx(e){let t=e;for(;bx(t)&&typeof Ex==`function`;)t=Ex(t._payload);return t}dx(Sx,`useUnwrappedLazy`);function Cx(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}dx(Cx,`concatAriaDescribedby`);var wx=dx(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),Tx=dx(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),Ex=X.use,Dx=Object.defineProperty,Ox=(e,t)=>Dx(e,`name`,{value:t,configurable:!0}),kx=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=fx(`Primitive.${t}`),r=X.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,Z.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ax(e,t){e&&zc.flushSync(()=>e.dispatchEvent(t))}Ox(Ax,`dispatchDiscreteCustomEvent`);var jx=Object.defineProperty,Mx=(e,t)=>jx(e,`name`,{value:t,configurable:!0}),Nx=X.useInsertionEffect;function Px(e){let t=X.useRef(e);return typeof Nx==`function`?Nx(()=>{t.current=e}):Gb(()=>{t.current=e}),X.useMemo(()=>((...e)=>t.current?.(...e)),[])}Mx(Px,`useCallbackRef`);var Fx=Object.defineProperty,Ix=(e,t)=>Fx(e,`name`,{value:t,configurable:!0}),Lx=`dismissableLayer.update`,Rx=`dismissableLayer.pointerDownOutside`,zx=`dismissableLayer.focusOutside`,Bx,Vx=X.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Hx=X.forwardRef(Ix(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=X.useContext(Vx),[d,f]=X.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=X.useState({}),h=zb(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=_?g.indexOf(_):-1,y=d?g.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,S=X.useRef(!1),C=Gx(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:X.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return x&&!t},[u.branches,x])}),w=Kx(e=>{if(r&&S.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),T=d?y===g.length-1:!1,E=Px(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return X.useEffect(()=>{if(T)return p.addEventListener(`keydown`,E,{capture:!0}),()=>p.removeEventListener(`keydown`,E,{capture:!0})},[p,T,E]),X.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Bx=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),qx(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=Bx))}},[d,p,n,u]),X.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),qx())},[d,u]),X.useEffect(()=>{let e=Ix(()=>m({}),`handleUpdate`);return document.addEventListener(Lx,e),()=>document.removeEventListener(Lx,e)},[]),(0,Z.jsx)(kx.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:Ab(e.onFocusCapture,w.onFocusCapture),onBlurCapture:Ab(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:Ab(e.onPointerDownCapture,C.onPointerDownCapture)})},`DismissableLayer`));function Ux(){let e=X.useContext(Vx),[t,n]=X.useState(null);return X.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}Ix(Ux,`useDismissableLayerSurface`);var Wx=Ix(()=>!0,`IS_TRUE`);function Gx(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Wx}=t,s=Px(e),c=X.useRef(!1),l=X.useRef(!1),u=X.useRef(new Map),d=X.useRef(()=>{});return X.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}Ix(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}Ix(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}Ix(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}Ix(p,`handleInteractionBubble`);let m=Ix(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||Jx(Rx,s,p,{discrete:!0})};if(Ix(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:Ix(()=>c.current=!0,`onPointerDownCapture`)}}Ix(Gx,`usePointerDownOutside`);function Kx(e,t=globalThis?.document){let n=Px(e),r=X.useRef(!1);return X.useEffect(()=>{let e=Ix(e=>{e.target&&!r.current&&Jx(zx,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:Ix(()=>r.current=!0,`onFocusCapture`),onBlurCapture:Ix(()=>r.current=!1,`onBlurCapture`)}}Ix(Kx,`useFocusOutside`);function qx(){let e=new CustomEvent(Lx);document.dispatchEvent(e)}Ix(qx,`dispatchUpdate`);function Jx(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Ax(i,a):i.dispatchEvent(a)}Ix(Jx,`handleAndDispatchCustomEvent`);var Yx=Object.defineProperty,Xx=(e,t)=>Yx(e,`name`,{value:t,configurable:!0}),Zx=`focusScope.autoFocusOnMount`,Qx=`focusScope.autoFocusOnUnmount`,$x={bubbles:!1,cancelable:!0},eS=X.forwardRef(Xx(function(e,t){let{loop:n=!1,trapped:r=!1,branches:i,onMountAutoFocus:a,onUnmountAutoFocus:o,...s}=e,[c,l]=X.useState(null),u=Px(a),d=Px(o),f=X.useRef(null),p=zb(t,l),m=X.useRef(i);X.useEffect(()=>{m.current=i});let h=X.useCallback(e=>e?c?.contains(e)?!0:!!m.current?.some(t=>t.contains(e)):!1,[c]),g=X.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;X.useEffect(()=>{if(r){let e=function(e){if(g.paused||!c)return;let t=e.target;h(t)?f.current=t:dS(f.current,{select:!0})},t=function(e){if(g.paused||!c)return;let t=e.relatedTarget;t!==null&&(h(t)||dS(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&dS(c)};Xx(e,`handleFocusIn`),Xx(t,`handleFocusOut`),Xx(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,c,g.paused,h]),X.useEffect(()=>{if(c){fS.add(g);let e=document.activeElement;if(!c.contains(e)){let t=new CustomEvent(Zx,$x);c.addEventListener(Zx,u),c.dispatchEvent(t),t.defaultPrevented||(aS(hS(sS(c)),{select:!0}),document.activeElement===e&&dS(c))}return()=>{c.removeEventListener(Zx,u);let t=c.ownerDocument,n=CustomEvent;setTimeout(()=>{let r=new n(Qx,$x);c.addEventListener(Qx,d),c.dispatchEvent(r),r.defaultPrevented||dS(e??t.body,{select:!0}),c.removeEventListener(Qx,d),fS.remove(g)},0)}}},[c,u,d,g]);let _=X.useCallback(e=>{if(!n&&!r||g.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=oS(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&dS(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&dS(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,g.paused]);return(0,Z.jsx)(kx.div,{tabIndex:-1,...s,ref:p,onKeyDown:_})},`FocusScope`)),tS=X.createContext(null);function nS({registry:e,children:t}){return e?(0,Z.jsx)(tS.Provider,{value:e,children:t}):t}Xx(nS,`FocusScopeBranchProvider`);function rS(){let[e,t]=X.useState([]);return{nodes:e,registry:X.useMemo(()=>({add:Xx(e=>t(t=>t.includes(e)?t:[...t,e]),`add`),remove:Xx(e=>t(t=>t.filter(t=>t!==e)),`remove`)}),[])}}Xx(rS,`useFocusScopeBranchRegistry`);function iS(e){let t=X.useContext(tS);X.useEffect(()=>{if(e&&t)return t.add(e),()=>t.remove(e)},[e,t])}Xx(iS,`useFocusScopeBranch`);function aS(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(dS(r,{select:t}),document.activeElement!==n)return}Xx(aS,`focusFirst`);function oS(e){let t=sS(e);return[cS(t,e),cS(t.reverse(),e)]}Xx(oS,`getTabbableEdges`);function sS(e){let t=[],n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Xx(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}Xx(sS,`getTabbableCandidates`);function cS(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):lS(r,{upTo:t})))return r}Xx(cS,`findVisible`);function lS(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}Xx(lS,`isHidden`);function uS(e){return e.tagName===`INPUT`&&typeof e.select==`function`}Xx(uS,`isSelectableInput`);function dS(e,{select:t=!1}={}){if(e&&e.focus){let n=(e.ownerDocument??document).activeElement;e.focus({preventScroll:!0}),e!==n&&uS(e)&&t&&e.select()}}Xx(dS,`focus`);var fS=pS();function pS(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=mS(e,t),e.unshift(t)},remove(t){e=mS(e,t),e[0]?.resume()}}}Xx(pS,`createFocusScopesStack`);function mS(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Xx(mS,`arrayRemove`);function hS(e){return e.filter(e=>e.tagName!==`A`)}Xx(hS,`removeLinks`);var gS=Object.defineProperty,_S=X.forwardRef(((e,t)=>gS(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=X.useState(!1);Gb(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?zc.createPortal((0,Z.jsx)(kx.div,{...r,ref:t}),o):null},`Portal`)),vS=Object.defineProperty,yS=(e,t)=>vS(e,`name`,{value:t,configurable:!0});function bS(e,t){return X.useReducer((e,n)=>t[e][n]??e,e)}yS(bS,`useStateMachine`);var xS=yS(e=>{let{present:t,children:n}=e,r=SS(t),i=typeof n==`function`?n({present:r.isPresent}):X.Children.only(n),a=wS(r.ref,ES(i));return typeof n==`function`||r.isPresent?X.cloneElement(i,{ref:a}):null},`Presence`);function SS(e){let[t,n]=X.useState(),r=X.useRef(null),i=X.useRef(e),a=X.useRef(`none`),o=X.useRef(void 0),[s,c]=bS(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return X.useEffect(()=>{s===`mounted`?(a.current=o.current??TS(r.current),o.current=void 0):a.current=`none`},[s]),Gb(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=TS(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),Gb(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=yS(a=>{let o=TS(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=yS(e=>{e.target===t&&(a.current=TS(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:X.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=TS(t)}else r.current=null;n(e)},[])}}yS(SS,`usePresence`);function CS(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}yS(CS,`setRef`);function wS(...e){let t=X.useRef(e);return t.current=e,X.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=CS(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():CS(n[e],null)}}},[])}yS(wS,`useStableComposedRefs`);function TS(e){return e?.animationName||`none`}yS(TS,`getAnimationName`);function ES(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}yS(ES,`getElementRef`);var DS=Object.defineProperty,OS=(e,t)=>DS(e,`name`,{value:t,configurable:!0}),kS=0,AS=null;function jS(e){return MS(),e.children}OS(jS,`FocusGuards`);function MS(){X.useEffect(()=>{AS||={start:NS(),end:NS()};let{start:e,end:t}=AS;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),kS++,()=>{kS===1&&(AS?.start.remove(),AS?.end.remove(),AS=null),kS=Math.max(0,kS-1)}},[])}OS(MS,`useFocusGuards`);function NS(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}OS(NS,`createFocusGuard`);var PS=function(){return PS=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},PS.apply(this,arguments)};function FS(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function IS(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var LS=`right-scroll-bar-position`,RS=`width-before-scroll-bar`,zS=`with-scroll-bars-hidden`,BS=`--removed-body-scroll-bar-size`;function VS(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function HS(e,t){var n=(0,X.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var US=typeof window<`u`?X.useLayoutEffect:X.useEffect,WS=new WeakMap;function GS(e,t){var n=HS(t||null,function(t){return e.forEach(function(e){return VS(e,t)})});return US(function(){var t=WS.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||VS(e,null)}),i.forEach(function(e){r.has(e)||VS(e,a)})}WS.set(n,e)},[e]),n}function KS(e){return e}function qS(e,t){t===void 0&&(t=KS);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function JS(e){e===void 0&&(e={});var t=qS(null);return t.options=PS({async:!0,ssr:!1},e),t}var YS=function(e){var t=e.sideCar,n=FS(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return X.createElement(r,PS({},n))};YS.isSideCarExport=!0;function XS(e,t){return e.useMedium(t),YS}var ZS=JS(),QS=function(){},$S=X.forwardRef(function(e,t){var n=X.useRef(null),r=X.useState({onScrollCapture:QS,onWheelCapture:QS,onTouchMoveCapture:QS}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=FS(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=GS([n,t]),C=PS(PS({},b),i);return X.createElement(X.Fragment,null,u&&X.createElement(x,{sideCar:ZS,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?X.cloneElement(X.Children.only(s),PS(PS({},C),{ref:S})):X.createElement(v,PS({},C,{className:c,ref:S}),s))});$S.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},$S.classNames={fullWidth:RS,zeroRight:LS};var eC=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function tC(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=eC();return t&&e.setAttribute(`nonce`,t),e}function nC(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function rC(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var iC=function(){var e=0,t=null;return{add:function(n){e==0&&(t=tC())&&(nC(t,n),rC(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},aC=function(){var e=iC();return function(t,n){X.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},oC=function(){var e=aC();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},sC={left:0,top:0,right:0,gap:0},cC=function(e){return parseInt(e||``,10)||0},lC=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[cC(n),cC(r),cC(i)]},uC=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return sC;var t=lC(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},dC=oC(),fC=`data-scroll-locked`,pC=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
2
|
+
.${zS} {
|
|
3
|
+
overflow: hidden ${r};
|
|
4
|
+
padding-right: ${s}px ${r};
|
|
5
|
+
}
|
|
6
|
+
body[${fC}] {
|
|
7
|
+
overflow: hidden ${r};
|
|
8
|
+
overscroll-behavior: contain;
|
|
9
|
+
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
10
|
+
padding-left: ${i}px;
|
|
11
|
+
padding-top: ${a}px;
|
|
12
|
+
padding-right: ${o}px;
|
|
13
|
+
margin-left:0;
|
|
14
|
+
margin-top:0;
|
|
15
|
+
margin-right: ${s}px ${r};
|
|
16
|
+
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.${LS} {
|
|
20
|
+
right: ${s}px ${r};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.${RS} {
|
|
24
|
+
margin-right: ${s}px ${r};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.${LS} .${LS} {
|
|
28
|
+
right: 0 ${r};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.${RS} .${RS} {
|
|
32
|
+
margin-right: 0 ${r};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
body[${fC}] {
|
|
36
|
+
${BS}: ${s}px;
|
|
37
|
+
}
|
|
38
|
+
`},mC=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},hC=function(){X.useEffect(function(){return document.body.setAttribute(fC,(mC()+1).toString()),function(){var e=mC()-1;e<=0?document.body.removeAttribute(fC):document.body.setAttribute(fC,e.toString())}},[])},gC=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;hC();var a=X.useMemo(function(){return uC(i)},[i]);return X.createElement(dC,{styles:pC(a,!t,i,n?``:`!important`)})},_C=!1;if(typeof window<`u`)try{var vC=Object.defineProperty({},"passive",{get:function(){return _C=!0,!0}});window.addEventListener(`test`,vC,vC),window.removeEventListener(`test`,vC,vC)}catch{_C=!1}var yC=_C?{passive:!1}:!1,bC=function(e){return e.tagName===`TEXTAREA`},xC=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!bC(e)&&n[t]===`visible`)},SC=function(e){return xC(e,`overflowY`)},CC=function(e){return xC(e,`overflowX`)},wC=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),DC(e,r)){var i=OC(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},TC=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},EC=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},DC=function(e,t){return e===`v`?SC(t):CC(t)},OC=function(e,t){return e===`v`?TC(t):EC(t)},kC=function(e,t){return e===`h`&&t===`rtl`?-1:1},AC=function(e,t,n,r,i){var a=kC(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=OC(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&DC(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},jC=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},MC=function(e){return[e.deltaX,e.deltaY]},NC=function(e){return e&&`current`in e?e.current:e},PC=function(e,t){return e[0]===t[0]&&e[1]===t[1]},FC=function(e){return`
|
|
39
|
+
.block-interactivity-${e} {pointer-events: none;}
|
|
40
|
+
.allow-interactivity-${e} {pointer-events: all;}
|
|
41
|
+
`},IC=0,LC=[];function RC(e){var t=X.useRef([]),n=X.useRef([0,0]),r=X.useRef(),i=X.useState(IC++)[0],a=X.useState(oC)[0],o=X.useRef(e);X.useEffect(function(){o.current=e},[e]),X.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=IS([e.lockRef.current],(e.shards||[]).map(NC),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=X.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=jC(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=wC(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=wC(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return AC(h,t,e,h===`h`?s:c,!0)},[]),c=X.useCallback(function(e){var n=e;if(LC.length&&LC[LC.length-1]===a){var r=`deltaY`in n?MC(n):jC(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&PC(e.delta,r)})[0];if(i&&i.should)n.cancelable&&n.preventDefault();else if(!i){var c=(o.current.shards||[]).map(NC).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=X.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:zC(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=X.useCallback(function(e){n.current=jC(e),r.current=void 0},[]),d=X.useCallback(function(t){l(t.type,MC(t),t.target,s(t,e.lockRef.current))},[]),f=X.useCallback(function(t){l(t.type,jC(t),t.target,s(t,e.lockRef.current))},[]);X.useEffect(function(){return LC.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,yC),document.addEventListener(`touchmove`,c,yC),document.addEventListener(`touchstart`,u,yC),function(){LC=LC.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,yC),document.removeEventListener(`touchmove`,c,yC),document.removeEventListener(`touchstart`,u,yC)}},[]);var p=e.removeScrollBar,m=e.inert;return X.createElement(X.Fragment,null,m?X.createElement(a,{styles:FC(i)}):null,p?X.createElement(gC,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function zC(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var BC=XS(ZS,RC),VC=X.forwardRef(function(e,t){return X.createElement($S,PS({},e,{ref:t,sideCar:BC}))});VC.classNames=$S.classNames;var HC=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},UC=new WeakMap,WC=new WeakMap,GC={},KC=0,qC=function(e){return e&&(e.host||qC(e.parentNode))},JC=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=qC(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},YC=function(e,t,n,r){var i=JC(t,Array.isArray(e)?e:[e]);GC[n]||(GC[n]=new WeakMap);var a=GC[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(UC.get(e)||0)+1,l=(a.get(e)||0)+1;UC.set(e,c),a.set(e,l),o.push(e),c===1&&i&&WC.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),KC++,function(){o.forEach(function(e){var t=UC.get(e)-1,i=a.get(e)-1;UC.set(e,t),a.set(e,i),t||(WC.has(e)||e.removeAttribute(r),WC.delete(e)),i||e.removeAttribute(n)}),KC--,KC||(UC=new WeakMap,UC=new WeakMap,WC=new WeakMap,GC={})}},XC=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||HC(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),YC(r,i,n,`aria-hidden`)):function(){return null}},ZC=Object.defineProperty,QC=(e,t)=>ZC(e,`name`,{value:t,configurable:!0}),$C=`Dialog`,[ew,tw]=Ub($C),[nw,rw]=ew($C),iw=QC(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=X.useRef(null),c=X.useRef(null),{nodes:l,registry:u}=rS(),[d,f]=ax({prop:r,defaultProp:i??!1,onChange:a,caller:$C}),[p,m]=X.useState(0),[h,g]=X.useState(0);return(0,Z.jsx)(nw,{scope:t,triggerRef:s,contentRef:c,contentId:Xb(),titleId:Xb(),descriptionId:Xb(),titlePresent:p>0,descriptionPresent:h>0,setTitleCount:m,setDescriptionCount:g,open:d,onOpenChange:f,onOpenToggle:X.useCallback(()=>f(e=>!e),[f]),modal:o,branchNodes:l,branchRegistry:u,children:n})},`Dialog`),aw=`DialogPortal`,[ow,sw]=ew(aw,{forceMount:void 0}),cw=QC(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=rw(aw,t);return(0,Z.jsx)(ow,{scope:t,forceMount:n,children:X.Children.map(r,e=>(0,Z.jsx)(xS,{present:n||a.open,children:(0,Z.jsx)(_S,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),lw=`DialogOverlay`,uw=X.forwardRef(QC(function(e,t){let n=sw(lw,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=rw(lw,e.__scopeDialog);return a.modal?(0,Z.jsx)(xS,{present:r||a.open,children:(0,Z.jsx)(fw,{...i,ref:t})}):null},`DialogOverlay`)),dw=fx(`DialogOverlay.RemoveScroll`),fw=X.forwardRef(QC(function(e,t){let{__scopeDialog:n,...r}=e,i=rw(lw,n),a=zb(t,Ux());return(0,Z.jsx)(VC,{as:dw,allowPinchZoom:!0,shards:X.useMemo(()=>[i.contentRef,...i.branchNodes.map(e=>({current:e}))],[i.contentRef,i.branchNodes]),children:(0,Z.jsx)(kx.div,{"data-state":yw(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),pw=`DialogContent`,mw=X.forwardRef(QC(function(e,t){let n=sw(pw,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=rw(pw,e.__scopeDialog);return(0,Z.jsx)(xS,{present:r||a.open,children:a.modal?(0,Z.jsx)(hw,{...i,ref:t}):(0,Z.jsx)(gw,{...i,ref:t})})},`DialogContent`)),hw=X.forwardRef(QC(function(e,t){let n=rw(pw,e.__scopeDialog),r=X.useRef(null),i=zb(t,n.contentRef,r);return X.useEffect(()=>{let e=r.current;if(e)return XC(e)},[]),(0,Z.jsx)(_w,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Ab(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ab(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Ab(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),gw=X.forwardRef(QC(function(e,t){let n=rw(pw,e.__scopeDialog),r=X.useRef(!1),i=X.useRef(!1);return(0,Z.jsx)(_w,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),_w=X.forwardRef(QC(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,"aria-describedby":o,children:s,...c}=e,l=rw(pw,n);return MS(),(0,Z.jsx)(nS,{registry:l.branchRegistry,children:(0,Z.jsx)(eS,{asChild:!0,loop:!0,trapped:r,branches:l.branchNodes,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,Z.jsx)(Hx,{role:`dialog`,id:l.contentId,"aria-labelledby":l.titlePresent?l.titleId:void 0,"aria-describedby":l.descriptionPresent?vw(o,l.descriptionId):o,"data-state":yw(l.open),...c,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1),children:s})})})},`DialogContentImpl`));function vw(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}QC(vw,`concatAriaDescribedby`);function yw(e){return e?`open`:`closed`}QC(yw,`getState`);var bw=`[cmdk-group=""]`,xw=`[cmdk-group-items=""]`,Sw=`[cmdk-group-heading=""]`,Cw=`[cmdk-item=""]`,ww=`${Cw}:not([aria-disabled="true"])`,Tw=`cmdk-item-select`,Ew=`data-value`,Dw=(e,t,n)=>Eb(e,t,n),Ow=X.createContext(void 0),kw=()=>X.useContext(Ow),Aw=X.createContext(void 0),jw=()=>X.useContext(Aw),Mw=X.createContext(void 0),Nw=X.forwardRef((e,t)=>{let n=qw(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=qw(()=>new Set),i=qw(()=>new Map),a=qw(()=>new Map),o=qw(()=>new Set),s=Gw(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Xb(),y=Xb(),b=Xb(),x=X.useRef(null),S=Xw();Kw(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Kw(()=>{S(6,k)},[]);let C=X.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=X.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??Dw;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(xw);t?t.appendChild(e.parentElement===t?e:e.closest(`${xw} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${xw} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${bw}[${Ew}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(Ew);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(bw)?.querySelector(Sw))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${Cw}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(ww)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(Ew))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(Ew))}function P(e){let t=A()?.closest(bw),n;for(;t&&!n;)t=e>0?Uw(t,bw):Ww(t,bw),n=t?.querySelector(ww);n?C.setState(`value`,n.getAttribute(Ew)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},L=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return X.createElement(kx.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&L(e);break;case`ArrowUp`:L(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(Tw);t.dispatchEvent(e)}}}}},X.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:$w},c),Qw(e,e=>X.createElement(Aw.Provider,{value:C},X.createElement(Ow.Provider,{value:w},e))))}),Pw=X.forwardRef((e,t)=>{let n=Xb(),r=X.useRef(null),i=X.useContext(Mw),a=kw(),o=Gw(e),s=o.current?.forceMount??i?.forceMount;Kw(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Yw(n,r,[e.value,e.children,r],e.keywords),l=jw(),u=Jw(e=>e.value&&e.value===c.current),d=Jw(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);X.useEffect(()=>{let t=r.current;if(t&&!e.disabled)return t.addEventListener(Tw,f),()=>t.removeEventListener(Tw,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return X.createElement(kx.div,{ref:Rb(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),Fw=X.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Xb(),s=X.useRef(null),c=X.useRef(null),l=Xb(),u=kw(),d=Jw(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Kw(()=>u.group(o),[]),Yw(o,s,[e.value,e.heading,c]);let f=X.useMemo(()=>({id:o,forceMount:i}),[i]);return X.createElement(kx.div,{ref:Rb(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&X.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Qw(e,e=>X.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},X.createElement(Mw.Provider,{value:f},e))))}),Iw=X.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=X.useRef(null),a=Jw(e=>!e.search);return!n&&!a?null:X.createElement(kx.div,{ref:Rb(i,t),...r,"cmdk-separator":``,role:`separator`})}),Lw=X.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=jw(),o=Jw(e=>e.search),s=Jw(e=>e.selectedItemId),c=kw();return X.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),X.createElement(kx.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Rw=X.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=X.useRef(null),o=X.useRef(null),s=Jw(e=>e.selectedItemId),c=kw();return X.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),X.createElement(kx.div,{ref:Rb(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Qw(e,e=>X.createElement(`div`,{ref:Rb(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),zw=X.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return X.createElement(iw,{open:n,onOpenChange:r},X.createElement(cw,{container:o},X.createElement(uw,{"cmdk-overlay":``,className:i}),X.createElement(mw,{"aria-label":e.label,"cmdk-dialog":``,className:a},X.createElement(Nw,{ref:t,...s}))))}),Bw=X.forwardRef((e,t)=>Jw(e=>e.filtered.count===0)?X.createElement(kx.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Vw=X.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return X.createElement(kx.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Qw(e,e=>X.createElement(`div`,{"aria-hidden":!0},e)))}),Hw=Object.assign(Nw,{List:Rw,Item:Pw,Input:Lw,Group:Fw,Separator:Iw,Dialog:zw,Empty:Bw,Loading:Vw});function Uw(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Ww(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Gw(e){let t=X.useRef(e);return Kw(()=>{t.current=e}),t}var Kw=typeof window>`u`?X.useEffect:X.useLayoutEffect;function qw(e){let t=X.useRef();return t.current===void 0&&(t.current=e()),t}function Jw(e){let t=jw(),n=()=>e(t.snapshot());return X.useSyncExternalStore(t.subscribe,n,n)}function Yw(e,t,n,r=[]){let i=X.useRef(),a=kw();return Kw(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(Ew,s),i.current=s}),i}var Xw=()=>{let[e,t]=X.useState(),n=qw(()=>new Map);return Kw(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Zw(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Qw({asChild:e,children:t},n){return e&&X.isValidElement(t)?X.cloneElement(Zw(t),{ref:t.ref},n(t.props.children)):n(t)}var $w={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},eT=X.createContext(void 0);function tT(e){let t=X.useContext(eT);if(!e&&t===void 0)throw Error(fa(27));return t}var nT=X.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=tT(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`),d={open:c,transitionStatus:s.useState(`transitionStatus`)};return ji(`div`,e,{state:d,ref:[s.context.backdropRef,t],stateAttributesMapping:os,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),rT=X.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=tT(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=oo({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,q(uo,e.nativeEvent))}return ji(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})});function iT(e){return So(e,`base-ui`)}var aT=X.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=tT(),c=iT(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),ji(`p`,e,{ref:t,props:[{id:c},o]})}),oT=X.createContext(void 0);function sT(){let e=X.useContext(oT);if(e===void 0)throw Error(fa(26));return e}var cT=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),lT=`--nested-dialogs`,uT=`data-nested-dialog-open`,dT={...as,...Ka,nestedDialogOpen(e){return e?{[uT]:``}:null}},fT=X.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=tT(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);sT(),hi({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?Vc(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=ji(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...Bc,hidden:!m,onKeyDown(e){cT.has(e.key)&&e.stopPropagation()},style:{[lT]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:dT});return(0,Z.jsx)(Oc,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),pT=X.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,Z.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),mT=X.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=tT(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,Z.jsx)(oT.Provider,{value:n,children:(0,Z.jsxs)(so,{ref:t,...r,children:[a&&o===!0&&(0,Z.jsx)(pT,{ref:i.context.internalBackdropRef,inert:Ei(!s)}),e.children]})}):null}),hT={},gT={},_T=``;function vT(e,t){return Fa(e)?e:t}function yT(e,t,n){return/hidden|clip/.test(e.getComputedStyle(vT(t,n)).overflowY)}function bT(e){if(typeof document>`u`)return!1;let t=ua(e);return vo(t).innerWidth-t.documentElement.clientWidth>0}function xT(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=ua(e),n=t.documentElement,r=t.body,i=vT(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 ST(e){let t=ua(e),n=t.documentElement,r=t.body,i=vT(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 CT(e){let t=ua(e),n=t.documentElement,r=t.body,i=vo(n),a=0,o=0,s=!1,c=Hi.create();if(Qi&&(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,hT={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},_T=n.style.scrollBehavior,gT={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=vT(n,r);s=xT(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,hT),Object.assign(r.style,gT),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=_T)}function d(){u(),c.request(l)}l();let f=K(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var wT=new class{lockCount=0;restore=null;timeoutLock=Ti.create();timeoutUnlock=Ti.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=ua(e),n=t.documentElement,r=t.body,i=vo(n);if(yT(i,n,r)){let t=new i.MutationObserver(()=>{yT(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=Co||!bT(e);this.restore=a?ST(e):CT(e)}};function TT(e=!0,t=null){G(()=>{if(e)return wT.acquire(t)},[e,t])}function ET({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`mounted`),a=e.useState(`disablePointerDismissal`),o=e.useState(`modal`),s=e.useState(`popupElement`),c=e.useState(`floatingRootContext`),[l,u]=X.useState(0),[d,f]=X.useState(0),p=l===0,m=Fc(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=xa(t);if(p&&!a){if(o){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Y(n,s)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return TT(r&&o===!0,s),e.useContextCallback(`onNestedDialogOpen`,(t,n)=>{(e.select(`open`)||e.select(`mounted`))&&(u(t),f(n))}),G(()=>{!r&&!i&&(u(0),f(0))},[r,i]),G(()=>(t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(l+1,d+ +!!n),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,l,d,t]),Qc(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}var DT={...ll,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},OT=class extends Gi{constructor(e,t,n){let r=new el,i=kT(e,r,t,n);super(i,AT(r),DT)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled||(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(Kc(this.state,e,t.trigger)))}};function kT(e,t,n,r=!1){return{...rl(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function AT(e){return{popupRef:X.createRef(),backdropRef:X.createRef(),internalBackdropRef:X.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function jT(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=tT(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=Hc((e,t)=>new OT({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...y},e,t),!0);b.useControlledProp(`openProp`,r),b.useControlledProp(`triggerIdProp`,d),b.useSyncedValues(y),b.useContextCallback(`onOpenChange`,a),b.useContextCallback(`onOpenChangeComplete`,o);let x=b.useState(`open`),S=b.useState(`mounted`),C=b.useState(`payload`);$c(b,x),Xc(b);let{forceUnmount:w}=Zc(x,b);X.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,q(Ta))}),[w,b]);let T=x||S||u!=null;return(0,Z.jsxs)(eT.Provider,{value:b,children:[u&&(0,Z.jsx)(Uc,{handle:u,store:b}),T&&(0,Z.jsx)(ET,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}var MT=Ua(function(e){return jT(`dialog`,e)}),NT=X.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=tT(),c=iT(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),ji(`h2`,e,{ref:t,props:[{id:c},o]})});function PT(e){let t=X.useRef(``),n=X.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:X.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 FT(e,t){let n=X.useRef(e),r=J(t);G(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function IT(e,t){let{onClick:n,onPointerDown:r}=PT(J((n,r)=>{(typeof e==`function`?e():e)||t(r||(Co?`touch`:``))}));return X.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function LT(e){let[t,n]=X.useState(null),r=IT(e,n);return FT(e,t=>{t&&!e&&n(null)}),X.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function RT(e){let t=(0,$.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,Z.jsx)(MT,{"data-slot":`dialog`,...n}),t[2]=n,t[3]=r),r}function zT(e){let t=(0,$.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,Z.jsx)(mT,{"data-slot":`dialog-portal`,...n}),t[2]=n,t[3]=r),r}function BT(e){let t=(0,$.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,Z.jsx)(rT,{"data-slot":`dialog-close`,...n}),t[2]=n,t[3]=r),r}function VT(e){let t=(0,$.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=Ao(`fixed inset-0 isolate z-50 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(nT,{"data-slot":`dialog-overlay`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function HT(e){let t=(0,$.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,showCloseButton:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0||a,s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(VT,{}),t[5]=s):s=t[5];let c;t[6]===r?c=t[7]:(c=Ao(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-xs/relaxed text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm 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[6]=r,t[7]=c);let l;t[8]===o?l=t[9]:(l=o&&(0,Z.jsxs)(rT,{"data-slot":`dialog-close`,render:(0,Z.jsx)(Xi,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,Z.jsx)(ba,{}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Close`})]}),t[8]=o,t[9]=l);let u;return t[10]!==n||t[11]!==i||t[12]!==c||t[13]!==l?(u=(0,Z.jsxs)(zT,{children:[s,(0,Z.jsxs)(fT,{"data-slot":`dialog-content`,className:c,...i,children:[n,l]})]}),t[10]=n,t[11]=i,t[12]=c,t[13]=l,t[14]=u):u=t[14],u}function UT(e){let t=(0,$.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=Ao(`flex flex-col gap-1`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`dialog-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function WT(e){let t=(0,$.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,showCloseButton:a,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a!==void 0&&a,s;t[5]===r?s=t[6]:(s=Ao(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,r),t[5]=r,t[6]=s);let c;t[7]===o?c=t[8]:(c=o&&(0,Z.jsx)(rT,{render:(0,Z.jsx)(Xi,{variant:`outline`}),children:`Close`}),t[7]=o,t[8]=c);let l;return t[9]!==n||t[10]!==i||t[11]!==s||t[12]!==c?(l=(0,Z.jsxs)(`div`,{"data-slot":`dialog-footer`,className:s,...i,children:[n,c]}),t[9]=n,t[10]=i,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function GT(e){let t=(0,$.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=Ao(`text-sm font-medium`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(NT,{"data-slot":`dialog-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function KT(e){let t=(0,$.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=Ao(`text-xs/relaxed text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(aT,{"data-slot":`dialog-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var qT=`data-valid`,JT=`data-invalid`,YT={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},XT={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},ZT={valid(e){return e===null?null:e?{[qT]:``}:{[JT]:``}}},QT={invalid:void 0,name:void 0,validityData:{state:YT,errors:[],error:``,value:``,initialValue:null},setValidityData:ki,disabled:void 0,setTouched:ki,setDirty:ki,setFilled:ki,setFocused:ki,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:XT,registerFieldControl:ki,validation:{getValidationProps:(e,t=oa)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:ki,getInputControl:()=>null,commit:async()=>{},change:ki}},$T=X.createContext(QT);function eE(e=!0){let t=X.useContext($T);if(t.setValidityData===ki&&!e)throw Error(fa(28));return t}var tE=X.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:ki,validationMode:`onSubmit`,submitCountRef:{current:0}});function nE(){return X.useContext(tE)}var rE=X.createContext({controlId:void 0,registerControlId:ki,resetControlId:ki,labelId:void 0,setLabelId:ki,messageIds:[],setMessageIds:ki,getDescriptionProps:e=>e});function iE(){return X.useContext(rE)}function aE(e,t,n){let{setFocused:r,focusOwnerRef:i}=eE(),a=J(t=>{(t?!e:i.current===a)&&(i.current=t&&a,n?.(t),r(t))});return G(()=>{let e=t.current;return e?.getRootNode()?.activeElement===e&&a(!0),()=>a(!1)},[e,t,a]),a}function oE(e,t,n,r,i=!0,a){let{registerFieldControl:o}=eE(),s=ho(()=>Symbol());G(()=>{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]),G(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}function sE(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=iE(),o=iT(),s=ho(()=>Symbol()),c=X.useRef(!1),l=X.useRef(!1),u=J(()=>{c.current&&i!==ki&&(c.current=!1,i(s.current,void 0))});return G(()=>{if(!n||i===ki){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]),G(()=>u,[u]),(n?r:void 0)??t??o}var cE=X.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFilled:y,validationMode:b,validation:x}=eE(),{clearErrors:S,elementRef:C,submitCountRef:w}=nE(),T=h||s,E=m??a,D={...p,disabled:T},{labelId:O}=iE(),k=sE({id:i}),A=o!==void 0,j=o==null?void 0:String(o),M=J(()=>x.inputRef.current?.value);oE(x.inputRef,k,j,M,!T,a),G(()=>{let e=j??x.inputRef.current?.value;e!==void 0&&y(e!==``)},[j,l,x.inputRef,y]),FT(j,()=>{j!==void 0&&(S(E),_(j!==(v.initialValue??``)),x.change(j))});let N=X.useRef(null),P=aE(T,N),F=Ci();return ji(`input`,e,{ref:[t,N],state:D,props:[{id:k,disabled:T,name:E,ref:x.inputRef,"aria-labelledby":O,autoFocus:u,...A?{value:o}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=q(Pa,e.nativeEvent);c?.(t,n),A||(_(t!==(v.initialValue??``)),y(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(S(E),x.change(t)))},onFocus(){P(!0)},onBlur(e){if(g(!0),P(!1),b===`onBlur`){let t=e.currentTarget.value;x.commit(t),A&&queueMicrotask(()=>{let e=x.inputRef.current?.value;e!==void 0&&e!==t&&e!==(v.initialValue??``)&&x.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){g(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===C.current&&!e.defaultPrevented){let t=e.currentTarget,n=w.current;F.start(0,()=>{w.current===n&&x.commit(t.value)})}else x.commit(t)}}},f,e=>x.getValidationProps(T,e)],stateAttributesMapping:ZT})}),lE=X.forwardRef(function(e,t){return(0,Z.jsx)(cE,{ref:t,...e})});function uE(e){let t=(0,$.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=Ao(`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,Z.jsx)(lE,{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 dE(e){let t=(0,$.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=Ao(`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,Z.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 fE=vi(`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 pE(e){let t=(0,$.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=Ao(fE({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,Z.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":a,className:o,onClick:mE,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function mE(e){e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()}vi(`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 hE(e){let t=(0,$.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=Ao(`flex size-full flex-col overflow-hidden rounded-xl bg-popover p-1 text-popover-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Hw,{"data-slot":`command`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function gE(e){let t=(0,$.c)(11),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=Ao(`w-full text-xs/relaxed outline-hidden disabled:cursor-not-allowed disabled:opacity-50`,n),t[3]=n,t[4]=i);let a;t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Hw.Input,{"data-slot":`command-input`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7];let o;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(pE,{children:(0,Z.jsx)(Ko,{className:`size-3.5 shrink-0 opacity-50`})}),t[8]=o):o=t[8];let s;return t[9]===a?s=t[10]:(s=(0,Z.jsx)(`div`,{"data-slot":`command-input-wrapper`,className:`p-1 pb-0`,children:(0,Z.jsxs)(dE,{className:`h-8! bg-input/20 dark:bg-input/30`,children:[a,o]})}),t[9]=a,t[10]=s),s}function _E(e){let t=(0,$.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=Ao(`no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Hw.List,{"data-slot":`command-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function vE(e){let t=(0,$.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=Ao(`py-6 text-center text-xs/relaxed`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Hw.Empty,{"data-slot":`command-empty`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function yE(e){let t=(0,$.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=Ao(`overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2.5 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Hw.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function bE(e){let t=(0,$.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=Ao(`group/command-item relative flex min-h-7 cursor-default items-center gap-2 rounded-md px-2.5 py-1.5 text-xs/relaxed outline-hidden select-none in-data-[slot=dialog-content]:rounded-md data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5 data-selected:*:[svg]:text-foreground`,r),t[4]=r,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(Bo,{className:`ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100`}),t[6]=o):o=t[6];let s;return t[7]!==n||t[8]!==i||t[9]!==a?(s=(0,Z.jsxs)(Hw.Item,{"data-slot":`command-item`,className:a,...i,children:[n,o]}),t[7]=n,t[8]=i,t[9]=a,t[10]=s):s=t[10],s}function xE(e){let t=(0,$.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=Ao(`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,Z.jsx)(`kbd`,{"data-slot":`kbd`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var SE=X.createContext(void 0);function CE(e){let t=X.useContext(SE);if(t===void 0&&!e)throw Error(fa(72));return t}var wE={...ll,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,appliedTriggerProps:(e,t)=>t?e.activeTriggerProps:void 0,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},TE=class extends Gi{constructor(e,t,n){let r=new el;super(EE(e,r,t,n),DE(r),wE)}setOpen=(e,t)=>{Jc(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,q(wo,e))}};function EE(e,t,n,r=!1){return{...rl(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function DE(e){return{popupRef:X.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var OE=Ua(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:d=null,children:f}=e,p=Hc((e,t)=>new TE({open:n,openProp:r,activeTriggerId:d,triggerIdProp:u},e,t));p.useControlledProp(`openProp`,r),p.useControlledProp(`triggerIdProp`,u),p.useContextCallback(`onOpenChange`,s),p.useContextCallback(`onOpenChangeComplete`,c);let m=p.useState(`open`),h=!t&&m,g=p.useState(`activeTriggerId`),_=p.useState(`mounted`),v=p.useState(`payload`);p.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),Xc(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:y,transitionStatus:b}=Zc(h,p),x=p.useState(`isInstantPhase`),S=p.useState(`instantType`),C=p.useState(`lastOpenChangeReason`),w=X.useRef(null);G(()=>{m&&t&&p.setOpen(!1,q(Sa))},[m,t,p]),G(()=>{b===`ending`&&C===`none`||b!==`ending`&&x?(S!==`delay`&&(w.current=S),p.set(`instantType`,`delay`)):w.current!==null&&(p.set(`instantType`,w.current),w.current=null)},[b,x,C,S,p]),G(()=>{h&&(g??p.set(`payload`,void 0))},[p,g,h]),X.useImperativeHandle(o,()=>({unmount:y,close:()=>p.setOpen(!1,q(Ta))}),[y,p]);let T=h||_||!t&&a!==`none`;return(0,Z.jsxs)(SE.Provider,{value:p,children:[l&&(0,Z.jsx)(Uc,{handle:l,store:p}),T&&(0,Z.jsx)(kE,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function kE({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=Fc(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=Mc(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=X.useMemo(()=>Yi(a.reference,i.reference),[a.reference,i.reference]);return Qc(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??oa}),null}var AE=X.createContext(void 0);function jE(){return X.useContext(AE)}var ME=`data-base-ui-tooltip-trigger`;function NE(e){let t=xa(e);return ka(t)?t:null}var PE=gi(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:d,...f}=e,p=CE(!0),m=dl(a)??p;if(!m)throw Error(fa(82));let h=iT(d),g=m.useState(`isTriggerActive`,h),_=m.useState(`isOpenedByTrigger`,h),v=m.useState(`floatingRootContext`),y=X.useRef(null),b=u??0,{registerTrigger:x,isMountedByThisTrigger:S}=Yc(h,y,m,{payload:o,closeOnClick:l,closeDelay:b}),C=jE(),{activeIdRef:w,delayRef:T,isInstantPhase:E,hasProvider:D}=Zs(v,{open:_}),O=vl(v);m.useSyncedValue(`isInstantPhase`,E);let k=m.useState(`disabled`),A=s??k,j=Hs(A),M=m.useState(`trackCursorAxis`),N=m.useState(`disableHoverablePopup`),P=X.useRef(!1),F=Ci(),I=X.useRef(void 0);function L(){return D&&w.current!=null?0:c??C??600}function R(e){let t=y.current;if(!t||!e)return!1;let n=xo(e,`[${ME}]`);return n!==null&&n!==t&&Y(t,n)}function ee(e){let t=R(e);return P.current=t,t&&(O.openChangeTimeout.clear(),O.restTimeout.clear(),O.restTimeoutPending=!1,F.clear()),t}let te=xl(v,{enabled:!A,mouseOnly:!0,move:!1,handleClose:!N&&M!==`both`?Ll():null,restMs:L,delay(){return u==null&&D?{close:Gs(T.current,`close`)}:{close:b}},triggerElementRef:y,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!P.current}}),ne=pl(v,{enabled:!A}).reference,z=e=>{let t=P.current,n=NE(e),r=ee(n),i=y.current,a=i&&n&&Y(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`)m.setOpen(!1,q(ya,e));else if(t&&!r&&a&&!j.current&&!m.select(`open`)&&i&&ps(I.current)){let t=()=>{P.current||j.current||m.select(`open`)||m.setOpen(!0,q(ya,e,i))},n=L();n===0?(F.clear(),t()):F.start(n,t)}},re=m.useState(`appliedTriggerProps`,S||M!==`none`);return ji(`button`,e,{state:{open:_},ref:[t,x,y],props:[te,ne,re,{onMouseOver(e){z(e.nativeEvent)},onFocus(e){R(NE(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){P.current=!1,F.clear(),I.current=void 0},onPointerEnter(e){I.current=e.pointerType},onPointerDown(e){I.current=e.pointerType,m.set(`closeOnClick`,l),l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},id:h,[to]:A?``:void 0,[ME]:A?void 0:``},f],stateAttributesMapping:rs})}),FE=X.createContext(void 0);function IE(){let e=X.useContext(FE);if(e===void 0)throw Error(fa(70));return e}var LE=X.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return CE().useState(`mounted`)||n?(0,Z.jsx)(FE.Provider,{value:n,children:(0,Z.jsx)(Xa,{ref:t,...r})}):null}),RE=X.createContext(void 0);function zE(){let e=X.useContext(RE);if(e===void 0)throw Error(fa(71));return e}var BE=X.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=Ha,style:g,..._}=e,v=CE(),y=IE(),b=v.useState(`open`),x=v.useState(`mounted`),S=v.useState(`trackCursorAxis`),C=v.useState(`disableHoverablePopup`),w=v.useState(`floatingRootContext`),T=v.useState(`instantType`),E=v.useState(`transitionStatus`),D=rd({anchor:i,positionMethod:a,floatingRootContext:w,mounted:x,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:y,collisionAvoidance:h,adaptiveOrigin:v.useState(`adaptiveOrigin`)}),O=sd(e,X.useMemo(()=>({open:b,side:D.side,align:D.align,anchorHidden:D.anchorHidden,instant:S===`none`?T:`tracking-cursor`}),[b,D.side,D.align,D.anchorHidden,S,T]),{styles:D.positionerStyles,transitionStatus:E,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!x,inert:!b||S===`both`||C});return(0,Z.jsx)(RE.Provider,{value:D,children:O})}),VE=X.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=CE(),{side:s,align:c}=zE(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);hi({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),yl(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return ji(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[Bc,f,od(d),a],stateAttributesMapping:os})}),HE=X.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=CE(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=zE(),f={open:o.useState(`open`),side:c,align:l,uncentered:u,instant:o.useState(`instantType`)};return ji(`div`,e,{state:f,ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:as})});function UE(e){let t=(0,$.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,Z.jsx)(OE,{"data-slot":`tooltip`,...n}),t[2]=n,t[3]=r),r}function WE(e){let t=(0,$.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,Z.jsx)(PE,{"data-slot":`tooltip-trigger`,...n}),t[2]=n,t[3]=r),r}function GE(e){let t=(0,$.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,children: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?`top`:a,u=o===void 0?4:o,d=s===void 0?`center`:s,f=c===void 0?0:c,p;t[8]===r?p=t[9]:(p=Ao(`z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 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=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 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]=p);let m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(HE,{className:`z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5`}),t[10]=m):m=t[10];let h;t[11]!==n||t[12]!==i||t[13]!==p?(h=(0,Z.jsxs)(VE,{"data-slot":`tooltip-content`,className:p,...i,children:[n,m]}),t[11]=n,t[12]=i,t[13]=p,t[14]=h):h=t[14];let g;return t[15]!==d||t[16]!==f||t[17]!==l||t[18]!==u||t[19]!==h?(g=(0,Z.jsx)(LE,{children:(0,Z.jsx)(BE,{align:d,alignOffset:f,side:l,sideOffset:u,className:`isolate z-50`,children:h})}),t[15]=d,t[16]=f,t[17]=l,t[18]=u,t[19]=h,t[20]=g):g=t[20],g}var KE=[{name:`deploy`,url:`https://deploy.mp281x.xyz`},{name:`scope`,url:`https://scope.mp281x.xyz`},{name:`gateway`,url:`https://gateway.mp281x.xyz`},{name:`auth`,url:`https://auth.mp281x.xyz`},{name:`signal`,url:`https://signal.mp281x.xyz`},{name:`portfolio`,url:`https://mp281x.xyz`}];function qE(e){let t=(0,$.c)(5),[n,r]=(0,X.useState)(!1);if(n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Mo,{className:`text-muted-foreground size-4`}),t[0]=e):e=t[0],e}let i=`${e.url}/icon`,a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>r(!0),t[1]=a):a=t[1];let o;return t[2]!==e.name||t[3]!==i?(o=(0,Z.jsx)(`img`,{src:i,alt:``,className:`pixelated size-4`,onError:a,title:e.name}),t[2]=e.name,t[3]=i,t[4]=o):o=t[4],o}function JE(e){return{items:Mr(gr(KE,t=>t.name!==e),e=>({detail:new URL(e.url).hostname,icon:(0,Z.jsx)(qE,{name:e.name,url:e.url}),label:e.name,run:()=>location.assign(e.url)})),label:`Other apps`}}function YE(e){let t=(0,$.c)(15),n=`${e.group}:${e.item.id??e.item.label}`,r;t[0]===e.item.icon?r=t[1]:(r=e.item.icon??(0,Z.jsx)(Io,{className:`text-muted-foreground size-4`}),t[0]=e.item.icon,t[1]=r);let i;t[2]===e.item.label?i=t[3]:(i=(0,Z.jsx)(`span`,{className:`min-w-0 shrink truncate`,children:e.item.label}),t[2]=e.item.label,t[3]=i);let a;t[4]===e.item.detail?a=t[5]:(a=e.item.detail!==void 0&&(0,Z.jsx)(`span`,{className:`text-muted-foreground ml-auto max-w-1/2 truncate text-xs`,children:e.item.detail}),t[4]=e.item.detail,t[5]=a);let o;t[6]===e.item.shortcut?o=t[7]:(o=e.item.shortcut!==void 0&&(0,Z.jsx)(xE,{className:`ml-auto`,children:e.item.shortcut}),t[6]=e.item.shortcut,t[7]=o);let s;return t[8]!==e.onSelect||t[9]!==n||t[10]!==r||t[11]!==i||t[12]!==a||t[13]!==o?(s=(0,Z.jsxs)(bE,{value:n,onSelect:e.onSelect,children:[r,i,a,o]}),t[8]=e.onSelect,t[9]=n,t[10]=r,t[11]=i,t[12]=a,t[13]=o,t[14]=s):s=t[14],s}function XE(e){let t=(0,$.c)(27),n;t[0]===e?n=t[1]:(n=function(t){e.onOpenChange(!1),t.run()},t[0]=e,t[1]=n);let r=n,i;t[2]===e.groups?i=t[3]:(i=Gt(Mt(e.groups,QE)),t[2]=e.groups,t[3]=i);let a=i,o=e.open,s=e.onOpenChange,c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsxs)(UT,{className:`sr-only`,children:[(0,Z.jsx)(GT,{children:`Search or run a command`}),(0,Z.jsx)(KT,{children:`Search available records and actions.`})]}),t[4]=c):c=t[4];let l;t[5]===a?l=t[6]:(l=(e,t)=>Dw(Dn(cr(a,e),()=>e),t),t[5]=a,t[6]=l);let u=`Search ${e.current??`Deslop`}…`,d;t[7]===u?d=t[8]:(d=(0,Z.jsx)(gE,{placeholder:u}),t[7]=u,t[8]=d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(vE,{"aria-label":`No matches`,children:(0,Z.jsx)(Ko,{weight:`light`,className:`text-muted-foreground mx-auto size-6`})}),t[9]=f):f=t[9];let p;if(t[10]!==e.groups||t[11]!==r){let n;t[13]===r?n=t[14]:(n=e=>(0,Z.jsx)(yE,{heading:e.label,children:Mr(e.items,t=>(0,Z.jsx)(YE,{group:e.label,item:t,onSelect:()=>r(t)},`${e.label}:${t.id??t.label}`))},e.label),t[13]=r,t[14]=n),p=Mr(gr(e.groups,ZE),n),t[10]=e.groups,t[11]=r,t[12]=p}else p=t[12];let m;t[15]===p?m=t[16]:(m=(0,Z.jsxs)(_E,{className:`min-h-0`,children:[f,p]}),t[15]=p,t[16]=m);let h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(xE,{children:`↑`}),(0,Z.jsx)(xE,{children:`↓`}),(0,Z.jsx)(`span`,{children:`navigate`})]}),t[17]=h):h=t[17];let g;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsxs)(`div`,{className:`text-muted-foreground hidden items-center justify-between border-t px-3 py-2 text-xs sm:flex`,children:[h,(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(xE,{children:`↵`}),(0,Z.jsx)(`span`,{children:`open`}),(0,Z.jsx)(xE,{children:`esc`}),(0,Z.jsx)(`span`,{children:`close`})]})]}),t[18]=g):g=t[18];let _;t[19]!==m||t[20]!==l||t[21]!==d?(_=(0,Z.jsxs)(HT,{showCloseButton:!1,className:`max-h-palette flex flex-col sm:max-w-lg`,children:[c,(0,Z.jsxs)(hE,{className:`min-h-0`,filter:l,children:[d,m,g]})]}),t[19]=m,t[20]=l,t[21]=d,t[22]=_):_=t[22];let v;return t[23]!==e.onOpenChange||t[24]!==e.open||t[25]!==_?(v=(0,Z.jsx)(RT,{open:o,onOpenChange:s,children:_}),t[23]=e.onOpenChange,t[24]=e.open,t[25]=_,t[26]=v):v=t[26],v}function ZE(e){return Xe(e.items)}function QE(e){return Mr(e.items,t=>[`${e.label}:${t.id??t.label}`,`${t.label} ${t.detail??``} ${t.keywords??``}`])}function $E(e){let t=(0,$.c)(18),n=(0,X.useSyncExternalStore)(oD,aD,iD),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(Xi,{variant:`ghost`,size:`icon`}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=_t(n,{onFalse:rD,onTrue:nD}),t[1]=n,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Ko,{className:`size-4`}),t[3]=a):a=t[3];let o;t[4]!==e.label||t[5]!==e.onClick||t[6]!==i?(o=(0,Z.jsx)(WE,{render:r,"aria-keyshortcuts":i,"aria-label":e.label,onClick:e.onClick,className:`max-sm:size-11`,children:a}),t[4]=e.label,t[5]=e.onClick,t[6]=i,t[7]=o):o=t[7];let s=e.label,c;t[8]===n?c=t[9]:(c=_t(n,{onFalse:tD,onTrue:eD}),t[8]=n,t[9]=c);let l;t[10]===c?l=t[11]:(l=(0,Z.jsx)(xE,{children:c}),t[10]=c,t[11]=l);let u;t[12]!==e.label||t[13]!==l?(u=(0,Z.jsxs)(GE,{children:[s,l]}),t[12]=e.label,t[13]=l,t[14]=u):u=t[14];let d;return t[15]!==o||t[16]!==u?(d=(0,Z.jsxs)(UE,{children:[o,u]}),t[15]=o,t[16]=u,t[17]=d):d=t[17],d}function eD(){return`⌘K`}function tD(){return`Ctrl K`}function nD(){return`Meta+K`}function rD(){return`Control+K`}function iD(){return!0}function aD(){return Vr(xe(/Mac|iPhone|iPad/u)(navigator.userAgent))}function oD(){return sD}function sD(){}var cD=X.createContext(void 0);function lD(){let e=X.useContext(cD);if(e===void 0)throw Error(fa(13));return e}var uD={imageLoadingStatus:()=>null},dD=X.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,[o,s]=X.useState(`idle`),c={imageLoadingStatus:o},l=X.useMemo(()=>({imageLoadingStatus:o,setImageLoadingStatus:s}),[o,s]),u=ji(`span`,e,{state:c,ref:t,props:a,stateAttributesMapping:uD});return(0,Z.jsx)(cD.Provider,{value:l,children:u})});function fD(e,{referrerPolicy:t,crossOrigin:n,sizes:r,srcSet:i},a){let o=X.useState(`idle`),s=o[1];return G(()=>{if(!a)return ki;if(!e&&!i)return s(`error`),ki;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 pD={...uD,...Ka},mD=X.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}=lD(),[f,p]=fD(l,e,!a),m=f===`loaded`,{mounted:h,transitionStatus:g,setMounted:_}=Lc(m),v=X.useRef(null),y=X.useRef(!0);G(()=>{if(!a)return;let e=y.current;y.current=!1;let t=v.current;if(!t)return;if(!t.complete){p(`loading`);return}let n=t.naturalWidth>0?`loaded`:`error`;p(n),n===`loaded`&&e&&_(!0)},[a,l,c,s,u.crossOrigin,u.referrerPolicy,r,p,_]);let b=a?{"data-loading":f===`loading`?``:void 0,"data-error":f===`error`?``:void 0,"aria-hidden":f!==`loaded`||void 0,onLoad(){p(`loaded`)},onError(){p(`error`)}}:void 0,x=J(e=>{i?.(e),d(e)});G(()=>{f!==`idle`&&x(f)},[f,x]),G(()=>()=>d(`idle`),[d]),hi({enabled:!m,open:m,ref:v,onComplete(){m||_(!1)}});let S={imageLoadingStatus:f,transitionStatus:a&&g===`ending`?void 0:g},C=a||h,w={};s!==void 0&&(w.sizes=s),c!==void 0&&(w.srcSet=c),l!==void 0&&(w.src=l);let T=ji(`img`,e,{state:S,ref:[t,v],props:[b,u,w],stateAttributesMapping:pD,enabled:C});return C?T:null}),hD=X.forwardRef(function(e,t){let{className:n,render:r,delay:i=0,style:a,...o}=e,{imageLoadingStatus:s}=lD(),[c,l]=X.useState(i===0),u=Ci();return X.useEffect(()=>(i>0?u.start(i,()=>l(!0)):l(!0),u.clear),[u,i]),ji(`span`,e,{state:{imageLoadingStatus:s},ref:t,props:o,stateAttributesMapping:uD,enabled:s!==`loaded`&&(i===0||c)})});function gD(e){let t=(0,$.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=Ao(`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,Z.jsx)(dD,{"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 _D(e){let t=(0,$.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=Ao(`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,Z.jsx)(mD,{"data-slot":`avatar-image`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function vD(e){let t=(0,$.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=Ao(`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,Z.jsx)(hD,{"data-slot":`avatar-fallback`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var yD=X.createContext(void 0);function bD(e){let t=X.useContext(yD);if(t===void 0&&!e)throw Error(fa(33));return t}var xD=X.createContext(void 0);function SD(e){let t=X.useContext(xD);if(t===void 0&&!e)throw Error(fa(36));return t}var CD=X.createContext(void 0);function wD(e=!0){let t=X.useContext(CD);if(t===void 0&&!e)throw Error(fa(25));return t}var TD=X.createContext(null);function ED(e=`root`){let t=X.useContext(TD),n=X.useContext(xD);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var DD={visible:!0,ref:null};function OD(){return DD}function kD(e,t,n=`root`){let r=ED(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??OD)({label:e.label,children:e.children,render:e.render}),a=Li(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}function AD(e){e.preventDefault()}function jD(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=SD(),u=wD(!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 X.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?AD: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:Oa})},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&&!ea&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&Fi(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var MD={type:`regular-item`};function ND(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=X.useRef(null),{getButtonProps:d,buttonRef:f}=oo({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=jD({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=X.useCallback(e=>Yi(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=Li(u,f);return X.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var PD=X.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function FD(){return X.useContext(PD)}function ID(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=FD(),u=X.useRef(-1),[d,f]=X.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=X.useRef(null),h=X.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 G(()=>{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 LD=X.createContext(void 0);function RD(){let e=X.useContext(LD);if(e===void 0)throw Error(fa(31));return e}var zD=X.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=X.useState(void 0),c=ji(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,Z.jsx)(LD.Provider,{value:s,children:c})}),BD=X.forwardRef(function(e,t){let n=ED()?.Group??zD;return(0,Z.jsx)(n,{...e,ref:t})}),VD=X.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=iT(a),c=RD();return G(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),ji(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),HD=X.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}=SD(),f=ID({guess:!0,label:a}),p=iT(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}=ND({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:MD});return ji(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),UD=X.forwardRef(function(e,t){let n=kD(e,t);return n.visible?(0,Z.jsx)(HD,{...e,ref:n.ref}):null}),WD=X.createContext(void 0);function GD(e){let t=X.useContext(WD);if(t===void 0&&!e)throw Error(fa(69));return t}var KD=X.createContext(void 0);function qD(){return X.useContext(KD)}function JD(e,t){let n=ia(e.render);if(X.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function YD(e,t,n){let r=JD(e,t),i=r===t?void 0:r;return[r,X.useCallback(e=>n?.(e?i:void 0),[i,n])]}function XD(e,t,n){let r=ia(e.render),i=X.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 ZD=X.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}=SD(),m=qD(),{side:h,align:g}=bD(),_=GD(!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]=YD(e,u,d),L=XD(e,C,N),R=w.type===`menu`?m:void 0,ee=w.type===`context-menu`,te=s??w.type!==`menu`;s===void 0&&P&&w.type!==`menu`&&(te=()=>l.state.activeIndex===null&&P),hi({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),X.useEffect(()=>{function e(e){l.setOpen(!1,q(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),yl(D,{enabled:A&&!j&&!ee&&w.type!==`menubar`,closeDelay:k});let ne=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:z,handleFocus:re}=(X.useContext(TD)?.useParentHandoff??$D)(l,w,v,f),ie={transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},B=ji(`div`,e,{state:ie,ref:[t,l.context.popupRef,ne,I],stateAttributesMapping:os,props:[b,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":L},onKeyDown(e){R?.onPopupKeyDown?.(e),_&&cT.has(e.key)&&e.stopPropagation()},onFocus:re},od(y),c,{"data-rootownerid":E}]}),V=w.type===void 0||ee;(C||w.type===`menubar`&&T!==`outside-press`)&&(V=!0);let ae=R?.getReturnElement??z;return(0,Z.jsx)(Oc,{context:D,openInteractionType:M,modal:ee,disabled:!x,returnFocus:a??ae??V,explicitReturnFocus:a===void 0&&ae?!1:void 0,initialFocus:te,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:B})}),QD={parentVirtualFocusRef:void 0,handleFocus:void 0};function $D(){return QD}var eO=X.forwardRef(function(e,t){let n=ED()?.Popup??ZD;return(0,Z.jsx)(n,{...e,ref:t})}),tO=X.createContext(void 0);function nO(){let e=X.useContext(tO);if(e===void 0)throw Error(fa(32));return e}var rO=X.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=SD();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Z.jsx)(tO.Provider,{value:n,children:(0,Z.jsx)(so,{ref:t,...r,portalOwnerRole:o})})});function iO(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=J(i),[,o]=X.useState(0),s=ho(oO).current,c=ho(aO).current,l=X.useRef(0),u=X.useRef(!0),d=X.useRef(null),f=X.useRef(null),p=J(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=J((e,t)=>{c.set(e,t),p()}),h=J(e=>{c.delete(e),p()}),g=J(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!lO(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&uO(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=cO(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=J(()=>{let[e,t]=sO(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});G(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),G(()=>{u.current&&v()}),G(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=J(e=>(s.add(e),()=>{s.delete(e)})),b=X.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,Z.jsx)(PD.Provider,{value:b,children:t})}function aO(){return new Map}function oO(){return new Set}function sO(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)=>uO(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 cO(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function lO(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 uO(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function dO(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=X.useRef(null),o=X.useRef(null),s=Ba(r);G(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),G(()=>{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 fO=20;function pO(e,t,n,r){let[i,a]=X.useState(!1);G(()=>{if(!e||!t||n==null){a(!1);return}let r=ua(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-fO)},[e,t,n]),TT(e&&(!t||i),r)}var mO=X.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=Wi,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=SD(),x=nO(),S=wD(!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,te=c,ne=l,z=s,re=h;C.type===`context-menu`&&(ee=n??C.context?.anchor,z??=`start`,!o&&z!==`center`&&(ne=e.alignOffset??2,te=e.sideOffset??-5));let ie=o,B=z;C.type===`menu`?(ie??=`inline-end`,B??=`start`,re=e.collisionAvoidance??Ha):C.type===`menubar`&&(ie??=C.context.orientation===`vertical`?`inline-end`:`bottom`,B??=`start`);let V=C.type===`context-menu`,ae=rd({anchor:ee,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:ie,sideOffset:te,align:B,alignOffset:ne,arrowPadding:V?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:I,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:re,shift:V?{crossAxis:!(`side`in re&&re.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P,lazyFlip:y?`placement`:!1});X.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&v.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,q(yo)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,I]),X.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,q(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let oe=Ci();X.useEffect(()=>{D||oe.clear()},[D,oe]),X.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?oe.isStarted()||oe.start(e,()=>{v.setOpen(!1,q(yo))}):v.setOpen(!1,q(yo))}else oe.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,oe]),X.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,I,L]),dO({store:v,domReference:R,positionerElement:M,open:D});let se={open:D,side:ae.side,align:ae.align,anchorHidden:ae.anchorHidden,nested:C.type===`menu`,instant:N},ce=C.type===`menubar`&&C.context.modal;pO(D&&(ce||O&&F!==`trigger-hover`),k===`touch`,M,A);let le=sd(e,se,{styles:ae.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),ue=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),de=null;return C.type===`menubar`?de=C.context.contentElement:C.type===void 0&&(de=A),(0,Z.jsxs)(yD.Provider,{value:ae,children:[ue&&(0,Z.jsx)(pT,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:Ei(!D),cutout:de}),(0,Z.jsx)(vc,{id:I,children:(0,Z.jsx)(iO,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:le})})]})}),hO=X.createContext(null);function gO(e){let t=X.useContext(hO);if(t===null&&!e)throw Error(fa(5));return t}function _O(e){return e==null?Pa:e.type.startsWith(`key`)?no:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?pa:Pa}var vO={...ll,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=ll.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>Qi&&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`&&!ll.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`)}},yO=class extends Gi{constructor(e,t,n=!1){let r=new el,i=xO(r,t,n,e);super(i,bO(r),vO),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 bO(e){return{positionerRef:X.createRef(),popupRef:X.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:X.createRef(),beforeTriggerFocusGuardRef:X.createRef(),beforeContentFocusGuardRef:X.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function xO(e,t,n=!1,r){return{...rl(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:oa,inputProps:oa,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new fc,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:oa,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var SO=X.createContext(null);function CO(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function wO(e,t){return e===`list-navigation`||CO(e,t)}var TO=Ua(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:y,allowEscape:b=!0,resetOnPointerLeave:x=!0}=e,S=wD(!0),C=SD(!0),w=gO(!0),T=C?.store,E=C?.virtualFocus??!1,D=X.useMemo(()=>_&&T?{type:`menu`,store:T}:w?{type:`menubar`,context:w}:S&&!T?{type:`context-menu`,context:S}:{type:void 0},[S,T,w,_]),O=iT(),k=iT(),[A,j]=X.useState(void 0),M=(A??k)||void 0,N=hc(),P=D.type===`menu`?D.store:void 0,F=(n??o)&&P?.state.transitionStatus===`starting`,I=ho(()=>F?P?.state.instantType:void 0).current,L=ho(()=>{let e=new yO({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:D,disabled:s,highlightItemOnHover:g,modal:D.type===void 0?c:void 0,rootId:O,instantType:I},M,N!=null);return e.context.virtualFocusRef=y,e}).current;L.useControlledProp(`openProp`,n),L.useControlledProp(`triggerIdProp`,m),L.useContextCallback(`onOpenChangeComplete`,i);let R=L.useState(`floatingTreeRoot`),ee=_c(R),te=L.useState(`open`),ne=L.useState(`activeTriggerElement`),z=L.useState(`positionerElement`),re=L.useState(`hoverEnabled`),ie=L.useState(`disabled`),B=L.useState(`lastOpenChangeReason`),V=L.useState(`parent`),ae=L.useState(`activeIndex`),oe=L.useState(`keyboardOpen`),se=L.useState(`payload`),ce=L.useState(`floatingParentNodeId`),le=X.useRef(null),ue=X.useRef(V.type!==`context-menu`),de=Ci(),fe=X.useRef(!0),pe=Ci(),me=ce!=null,{openMethod:he,triggerProps:ge}=LT(te);L.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:V.type===void 0?c:void 0,openMethod:he,rootId:O}),Xc(L);let{forceUnmount:_e,transitionStatus:ve}=Zc(te,L,()=>{L.set(`allowMouseEnter`,!1)},F),ye=Ba(L.context.popupRef);X.useEffect(()=>{if(I===void 0)return;let e=()=>{L.state.instantType===I&&L.set(`instantType`,void 0)};if(!te){e();return}if(ve!==void 0)return;if(L.context.popupRef.current==null){e();return}let t=new AbortController;return ye(e,t.signal),()=>{t.abort()}},[I,te,ve,ye,L]),G(()=>{S&&!C?L.update({parent:{type:`context-menu`,context:S},floatingNodeId:ee,floatingParentNodeId:N}):(C||!L.select(`activeTriggerElement`))&&L.update({floatingNodeId:ee,floatingParentNodeId:N})},[S,C,ee,N,ne,L]),X.useEffect(()=>{te||(le.current=null),V.type===`context-menu`&&(te?de.start(500,()=>{ue.current=!0}):(de.clear(),ue.current=!1))},[de,te,V.type]),G(()=>{!te&&!re&&L.set(`hoverEnabled`,!0)},[te,re,L]);let be=J((e,t)=>{let n=t.reason;if(!e&&!L.select(`open`)||te===e&&t.trigger===ne&&B===n)return;let i=qc(t);if(!e&&t.trigger==null&&(t.trigger=ne??void 0),r?.(e,t),t.isCanceled)return;L.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!fe.current)return;e&&n===`trigger-focus`?(fe.current=!1,pe.start(300,()=>{fe.current=!0})):(fe.current=!0,pe.clear());let o=!e&&(n===`escape-key`||n==null);le.current=t.event;let s=Kc(L.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&wO(n,a),s.instantType=V.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:CO(n,a)?`click`:o?`dismiss`:void 0,L.update(s)}),xe=Ic({popupStore:L,floatingRootContext:L.state.floatingRootContext,floatingId:M,nested:N!=null,onOpenChange:be}),Se=xe.context.events;G(()=>{let e=({open:e,eventDetails:t})=>be(e,t);return Se.on(`setOpen`,e),()=>{Se?.off(`setOpen`,e)}},[Se,be]),G(()=>L.subscribeToParentMenu(),[L]);let Ce=X.useCallback(()=>{L.setOpen(!1,q(Ta))},[L]);X.useImperativeHandle(d,()=>({unmount:_e,close:Ce}),[_e,Ce]);let we;V.type===`context-menu`&&(we=V.context),X.useImperativeHandle(we?.positionerRef,()=>z,[z]),X.useImperativeHandle(we?.actionsRef,()=>({setOpen:be}),[be]);let Te=Fc(xe,{enabled:!ie,bubbles:{escapeKey:f&&V.type===`menu`},outsidePress(){return V.type!==`context-menu`||le.current?.type===`contextmenu`||ue.current},externalTree:me?R:void 0}),Ee=Uu(),De=Ol(xe,{enabled:!ie,listRef:L.context.itemDomElements,activeIndex:ae,virtual:v,nested:V.type===`menubar`||!v&&V.type!==void 0,parentOrientation:V.type===`menubar`?V.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?oe:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:Ee===`rtl`,disabledIndices:na,onNavigate(e,t){L.setActiveIndex(e,_O(t),t?.nativeEvent)},openOnArrowKeyDown:V.type!==`context-menu`&&!(v&&_),externalTree:!v&&me?R:void 0,nestedReturnFocusRef:P?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),Oe=X.useCallback(e=>{L.context.typingRef.current=e},[L]),ke=kl(xe,{enabled:!ie&&!v,listRef:L.context.itemLabels,elementsRef:L.context.itemDomElements,activeIndex:ae,resetMs:500,onMatch:(e,t)=>{te&&e!==ae&&L.setActiveIndex(e,no,t.nativeEvent)},onTyping:Oe}),Ae=J(a),je=X.useRef(-1),Me=J(()=>{let e=L.state.activeIndex,t=e===null?void 0:L.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(je.current===n&&L.context.reportedItem===t)return;je.current=n,L.context.reportedItem=t,v&&L.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=L.context;L.context.highlightReason=Pa,L.context.highlightEvent=void 0,a&&Ae(t,yi(r,i,{label:t===void 0?void 0:L.context.itemLabels.current[n]??void 0}))});G(()=>{Me()},[ae,Me]);let Ne=X.useMemo(()=>{if(!v)return De.reference;if(!De.trigger)return oa;let{onFocus:e,...t}=De.trigger;return t},[v,De.reference,De.trigger]);L.useSyncedValue(`inputProps`,v?De.reference??oa:oa);let Pe=X.useMemo(()=>{let e=Yi(ke.reference,Ne,Te.reference,{onMouseMove(){L.set(`allowMouseEnter`,!0)}},ge);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=te,e},[L,ke.reference,Ne,Te.reference,ge,te]),Fe=X.useMemo(()=>{let e=Yi(De.trigger,Te.trigger,ge);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[De.trigger,Te.trigger,ge]);ho(()=>(L.update({inactiveTriggerProps:Fe}),null)),Qc(L,{floatingRootContext:xe,activeTriggerProps:Pe,inactiveTriggerProps:Fe,popupProps:X.useMemo(()=>Yi(Bc,{onMouseMove(){L.set(`allowMouseEnter`,!0),V.type===`menu`&&L.set(`hoverEnabled`,!1)},onClick(){L.select(`hoverEnabled`)&&L.set(`hoverEnabled`,!1)},onKeyDown(e){let t=L.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},ke.floating,De.floating,Te.floating),[V.type,L,ke.floating,De.floating,Te.floating]),itemProps:De.item??oa});let Ie=X.useMemo(()=>({store:L,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:Me}),[L,D,u,l,b,k,v,E,Me]),Le=typeof t==`function`?t({payload:se}):t,Re=(0,Z.jsxs)(xD.Provider,{value:Ie,children:[p&&(0,Z.jsx)(Uc,{handle:p,store:L}),Le]});return(V.type===void 0||V.type===`context-menu`)&&(Re=(0,Z.jsx)(yc,{externalTree:R,children:Re})),Re});function EO(e){let t=X.useContext(SO);if(t===null)return(0,Z.jsx)(TO,{...e});let n=t.Root;return(0,Z.jsx)(SO.Provider,{value:null,children:(0,Z.jsx)(n,{...t.options,...e})})}var DO=5;function OO(e,t){let n=kO(t);return e.clientX>=n.left-DO&&e.clientX<=n.right+DO&&e.clientY>=n.top-DO&&e.clientY<=n.bottom+DO}function kO(e){let t=e.getBoundingClientRect(),n=vo(e);if(Eo)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 AO(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=ca(),{ref:i,index:a}=ID(e),o=n===a,s=X.useRef(null),c=Li(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 jO(e){let{render:t,className:n,style:r,state:i=oa,props:a=na,refs:o=na,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=AO({metadata:s});return ji(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function MO(e){if(ro(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Ja(e))return MO(Ga(e))}function NO(e,t){function n(n,r,i){let a=n.currentTarget;zc.flushSync(()=>{e.setOpen(!1,q(_o,n.nativeEvent,a))}),Ai(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&&ta(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function PO(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=X.useRef(!1);return X.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,ua(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:oa,[t,n,r])}var FO=gi(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=SD(!0),h=dl(d)??m?.store;if(!h)throw Error(fa(85));let g=iT(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=X.useRef(null),S=LO(),C=ca(!0),w=gc(),T=X.useMemo(()=>w??new fc,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=Yc(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:_c(T),floatingParentNodeId:hc(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=oo({disabled:A,native:o});X.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=X.useRef(null),P=Ci(),F=J(e=>{if(!N.current)return;P.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Y(N.current,t)||Y(h.select(`positionerElement`),t)||t===N.current||t!=null&&MO(t)===h.select(`rootId`)||OO(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:$a})});X.useEffect(()=>{let e=ua(N.current);if(y&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,F,{once:!0}),()=>{e.removeEventListener(`mouseup`,F)}},[y,F,h]);let I=O&&S.context.hasSubmenuOpen,L=xl(v,{enabled:(c??I)&&!A&&(!O||I&&!D),handleClose:Ll({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),R=IO(y,h.select(`lastOpenChangeReason`)),ee=kc(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&R}),te=pl(v,{enabled:!A&&I}),ne=PO({open:y,enabled:O,mouseDownAction:`open`}),z=X.useMemo(()=>Yi(te.reference,ee.reference),[te.reference,ee.reference]),re=h.useState(`triggerProps`,D),ie=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:B,handleFocusTargetFocus:V}=NO(h,x),ae={disabled:A,open:y},oe=[N,t,M,E,x],se=[z,L??oa,re,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(P.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),ua(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},ie,O?{role:`menuitem`}:{},ne,p,j],ce=ji(`button`,e,{enabled:!O,stateAttributesMapping:is,state:ae,ref:oe,props:se});return O?(0,Z.jsx)(jO,{tag:`button`,render:n,className:r,style:i,state:ae,refs:oe,props:se,stateAttributesMapping:is}):y?(0,Z.jsxs)(X.Fragment,{children:[(0,Z.jsx)(Mi,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:B},`${g}-pre-focus-guard`),(0,Z.jsx)(X.Fragment,{children:ce},g),(0,Z.jsx)(Mi,{ref:h.context.triggerFocusTargetRef,onFocus:V},`${g}-post-focus-guard`)]}):(0,Z.jsx)(X.Fragment,{children:ce},g)});function IO(e,t){let n=Ci(),[r,i]=X.useState(!1);return G(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function LO(){let e=gO(!0);return X.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var RO=X.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return ji(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function zO(e){let t=(0,$.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,Z.jsx)(EO,{"data-slot":`dropdown-menu`,...n}),t[2]=n,t[3]=r),r}function BO(e){let t=(0,$.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,Z.jsx)(FO,{"data-slot":`dropdown-menu-trigger`,...n}),t[2]=n,t[3]=r),r}function VO(e){let t=(0,$.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=Ao(`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,Z.jsx)(eO,{"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,Z.jsx)(rO,{children:(0,Z.jsx)(mO,{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 HO(e){let t=(0,$.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,Z.jsx)(BD,{"data-slot":`dropdown-menu-group`,...n}),t[2]=n,t[3]=r),r}function UO(e){let t=(0,$.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=Ao(`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,Z.jsx)(VD,{"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 WO(e){let t=(0,$.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=Ao(`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,Z.jsx)(UD,{"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 GO(e){let t=(0,$.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=Ao(`-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,Z.jsx)(RO,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var KO=ut({id:ri,name:ri,signOut:fn}),qO=at(Dt).atom(we(Ye(`/auth/user`),U(o),U(mn(KO))));function JO(){let e=(0,$.c)(27),t=bd(qO);if(!li(t))return null;let n;e[0]===t.value.id?n=e[1]:(n=vr(`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,Z.jsx)(_D,{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=Pt(_e(0,1)(t.value.name)),e[5]=t.value.name,e[6]=a);let o;e[7]===a?o=e[8]:(o=(0,Z.jsx)(vD,{children:a}),e[7]=a,e[8]=o);let s;e[9]!==i||e[10]!==o?(s=(0,Z.jsx)(BO,{"aria-label":`Account`,className:`flex items-center justify-center max-sm:size-11`,children:(0,Z.jsxs)(gD,{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,Z.jsx)(HO,{children:(0,Z.jsxs)(UO,{children:[`@`,t.value.name]})}),e[12]=t.value.name,e[13]=c);let l;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(GO,{}),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,Z.jsx)(`a`,{"aria-label":`Sign out`,href:f}),e[16]=f,e[17]=p);let m;e[18]!==p||e[19]!==u?(m=(0,Z.jsx)(WO,{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,Z.jsxs)(VO,{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,Z.jsxs)(zO,{children:[s,h]}),e[24]=h,e[25]=s,e[26]=g):g=e[26],g}function YO(e){let t=(0,$.c)(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(Xi,{variant:`ghost`,size:`icon`}),t[0]=n):n=t[0];let r;t[1]!==e.disabled||t[2]!==e.icon||t[3]!==e.label||t[4]!==e.onClick?(r=(0,Z.jsx)(WE,{render:n,"aria-label":e.label,className:`max-sm:size-11`,disabled:e.disabled,onClick:e.onClick,children:e.icon}),t[1]=e.disabled,t[2]=e.icon,t[3]=e.label,t[4]=e.onClick,t[5]=r):r=t[5];let i;t[6]===e.label?i=t[7]:(i=(0,Z.jsx)(GE,{children:e.label}),t[6]=e.label,t[7]=i);let a;return t[8]!==r||t[9]!==i?(a=(0,Z.jsxs)(UE,{children:[r,i]}),t[8]=r,t[9]=i,t[10]=a):a=t[10],a}function XO(e){let t=(0,$.c)(44),[n,r]=(0,X.useState)(!1),i,a;t[0]===e.palette?(i=t[1],a=t[2]):(i=()=>{if(e.palette===void 0)return;let t=function(e){e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),r(!0))};return addEventListener(`keydown`,t),()=>removeEventListener(`keydown`,t)},a=[e.palette],t[0]=e.palette,t[1]=i,t[2]=a),(0,X.useEffect)(i,a);let o;if(t[3]!==e.back||t[4]!==e.icon||t[5]!==e.name||t[6]!==e.title){let n;t[8]!==e.icon||t[9]!==e.name?(n=()=>(0,Z.jsxs)(`a`,{href:`/`,className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsx)(`img`,{src:e.icon,alt:``,className:`pixelated size-8 opacity-60`}),(0,Z.jsx)(`span`,{className:`text-sm font-semibold`,children:e.name})]}),t[8]=e.icon,t[9]=e.name,t[10]=n):n=t[10];let r;t[11]!==e.back||t[12]!==e.icon||t[13]!==e.name?(r=t=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink items-center gap-1.5`,children:[$r($n(e.back),{onNone:()=>(0,Z.jsx)(`a`,{href:`/`,"aria-label":e.name,className:`flex size-8 shrink-0 items-center justify-center max-sm:size-11`,children:(0,Z.jsx)(`img`,{src:e.icon,alt:``,className:`pixelated size-8 opacity-60`})}),onSome:$O}),(0,Z.jsx)(`span`,{className:`max-w-40 min-w-0 truncate text-sm font-medium`,children:t})]}),t[11]=e.back,t[12]=e.icon,t[13]=e.name,t[14]=r):r=t[14],o=$r($n(e.title),{onNone:n,onSome:r}),t[3]=e.back,t[4]=e.icon,t[5]=e.name,t[6]=e.title,t[7]=o}else o=t[7];let s;t[15]===e.tabs?s=t[16]:(s=e.tabs!==void 0&&(0,Z.jsx)(`nav`,{"aria-label":`Sections`,className:`flex items-center gap-1`,children:e.tabs}),t[15]=e.tabs,t[16]=s);let c;if(t[17]!==e.name||t[18]!==e.palette){let n;t[20]===e.name?n=t[21]:(n=()=>(0,Z.jsx)($E,{label:`Search ${e.name}`,onClick:()=>r(!0)}),t[20]=e.name,t[21]=n),c=$r($n(e.palette),{onNone:QO,onSome:n}),t[17]=e.name,t[18]=e.palette,t[19]=c}else c=t[19];let l;t[22]===c?l=t[23]:(l=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center justify-end`,children:c}),t[22]=c,t[23]=l);let u;t[24]===e.account?u=t[25]:(u=e.account??(0,Z.jsx)(JO,{}),t[24]=e.account,t[25]=u);let d;t[26]!==e.action||t[27]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[e.action,u]}),t[26]=e.action,t[27]=u,t[28]=d):d=t[28];let f;t[29]!==o||t[30]!==s||t[31]!==l||t[32]!==d?(f=(0,Z.jsxs)(`header`,{className:`bg-background text-muted-foreground border-border sticky top-0 z-30 flex h-12 shrink-0 items-center gap-2 border-b px-3`,children:[o,s,l,d]}),t[29]=o,t[30]=s,t[31]=l,t[32]=d,t[33]=f):f=t[33];let p;if(t[34]!==n||t[35]!==e.name||t[36]!==e.palette){let i;t[38]!==n||t[39]!==e.name?(i=t=>(0,Z.jsx)(XE,{current:e.name,groups:t,open:n,onOpenChange:r}),t[38]=n,t[39]=e.name,t[40]=i):i=t[40],p=$r($n(e.palette),{onNone:ZO,onSome:i}),t[34]=n,t[35]=e.name,t[36]=e.palette,t[37]=p}else p=t[37];let m;return t[41]!==f||t[42]!==p?(m=(0,Z.jsxs)(Z.Fragment,{children:[f,p]}),t[41]=f,t[42]=p,t[43]=m):m=t[43],m}function ZO(){return null}function QO(){return null}function $O(e){return(0,Z.jsx)(Xi,{variant:`ghost`,size:`icon`,className:`max-sm:size-11`,"aria-label":e.label,onClick:e.onClick,children:(0,Z.jsx)(Ro,{className:`size-4`})})}function ek(e){let t=(0,$.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=Ao(`animate-pulse rounded-md bg-muted`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`skeleton`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function tk(e){let t=(0,$.c)(12),n=e.label,r;if(t[0]!==e.media||t[1]!==e.mediaClassName||t[2]!==e.rowClassName||t[3]!==e.rows){let n;t[5]!==e.media||t[6]!==e.mediaClassName||t[7]!==e.rowClassName?(n=t=>(0,Z.jsxs)(`div`,{"aria-hidden":!0,className:Ao(`list-row flex h-8 items-center gap-3 px-1 max-sm:h-11`,e.rowClassName),children:[e.media===!0&&(0,Z.jsx)(ek,{className:Ao(`size-5 shrink-0`,e.mediaClassName)}),(0,Z.jsx)(ek,{className:`h-4 w-1/3`})]},t),t[5]=e.media,t[6]=e.mediaClassName,t[7]=e.rowClassName,t[8]=n):n=t[8],r=Mr(xr(1,e.rows),n),t[0]=e.media,t[1]=e.mediaClassName,t[2]=e.rowClassName,t[3]=e.rows,t[4]=r}else r=t[4];let i;return t[9]!==e.label||t[10]!==r?(i=(0,Z.jsx)(`div`,{"aria-busy":`true`,"aria-label":n,role:`status`,children:r}),t[9]=e.label,t[10]=r,t[11]=i):i=t[11],i}var nk=vi(`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 rk(e){let t=(0,$.c)(6),n;t[0]!==e.className||t[1]!==e.status||t[2]!==e.waiting?(n=Ao(nk({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,Z.jsx)(`span`,{"data-slot":`status-dot`,"aria-hidden":`true`,className:n}),t[4]=n,t[5]=r),r}var ik=X.createContext(void 0);function ak(e){let t=X.useContext(ik);if(t===void 0&&!e)throw Error(fa(47));return t}var ok={...ll,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!ll.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&ll.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>ll.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},sk=class extends Gi{constructor(e,t,n){let r=new el;super(ck(e,r,t,n),lk(r),ok)}setOpen=(e,t)=>{let n=t.reason===ya,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=qc(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=Kc(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),zc.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function ck(e,t,n,r=!1){let i={...rl(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function lk(e){return{popupRef:X.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:X.createRef(),beforeTriggerFocusGuardRef:X.createRef(),beforeContentFocusGuardRef:X.createRef(),stickIfOpenTimeout:new Ti,stickIfOpen:!0,triggerElements:e}}var uk=Ua(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=fk(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),$c(u,d),Xc(u);let{forceUnmount:m}=Zc(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),X.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),X.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,q(Ta))}),[m,u]);let h=d||f||s!=null;return(0,Z.jsxs)(ik.Provider,{value:u,children:[s&&(0,Z.jsx)(Uc,{handle:s,store:u}),h&&(0,Z.jsx)(pk,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function dk(e){return ak(!0)?(0,Z.jsx)(uk,{props:e}):(0,Z.jsx)(yc,{children:(0,Z.jsx)(uk,{props:e})})}function fk(e,t){let n=Hc((e,n)=>new sk(t,e,n));return X.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function pk({store:e,modal:t}){let n=Fc(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return Qc(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var mk=gi(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=ak(!0),h=dl(s)??m;if(!h)throw Error(fa(74));let g=iT(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=X.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=Yc(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`isPressOpenedByTrigger`,g),T=h.useState(`isTouchPressOpen`,l),E=h.useState(`hasTriggerFocusGuards`,g),D=xl(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:Ll(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=kc(v,{stickIfOpen:J(()=>h.context.stickIfOpen)}),k=IT(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),A=h.useState(`triggerProps`,C),{getButtonProps:j,buttonRef:M}=oo({disabled:a,native:o}),N={open(e){return w?is.open(e):rs.open(e)}},{handlePreFocusGuardFocus:P,handleFocusTargetFocus:F}=NO(h,x),I=ji(`button`,e,{state:{disabled:a,open:y},ref:[M,t,S,x],props:[O.reference,D,A,k,{[wi]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,j],stateAttributesMapping:N}),L=(0,Z.jsx)(X.Fragment,{children:I},g);return E?(0,Z.jsxs)(X.Fragment,{children:[(0,Z.jsx)(Mi,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:P}),L,(0,Z.jsx)(Mi,{ref:h.context.triggerFocusTargetRef,onFocus:F})]}):L}),hk=X.createContext(void 0);function gk(){let e=X.useContext(hk);if(e===void 0)throw Error(fa(45));return e}var _k=X.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return ak().useState(`mounted`)||n?(0,Z.jsx)(hk.Provider,{value:n,children:(0,Z.jsx)(so,{ref:t,...r})}):null}),vk=X.createContext(void 0);function yk(){let e=X.useContext(vk);if(!e)throw Error(fa(46));return e}var bk=X.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=Ha,..._}=e,v=ak(),y=gk(),b=_c(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=rd({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});dO({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let M=E===!0&&w!==`trigger-hover`;pO(C&&M,D===`touch`,O,T);let N=v.useStateSetter(`positionerElement`),P=sd(e,{open:C,side:j.side,align:j.align,anchorHidden:j.anchorHidden,instant:k},{styles:j.positionerStyles,transitionStatus:A,props:_,refs:[t,N],hidden:!S,inert:!C});return(0,Z.jsxs)(vk.Provider,{value:j,children:[S&&M&&(0,Z.jsx)(pT,{inert:Ei(!C),cutout:T}),(0,Z.jsx)(vc,{id:b,children:P})]})}),xk=X.createContext(void 0);function Sk(){let[e,t]=X.useState(0),n=J(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:X.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var Ck=X.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=ak(),l=yk(),u=GD(!0)!=null,{context:d,hasClosePart:f}=Sk(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);hi({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),yl(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?Vc(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M={open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},N=ji(`div`,e,{state:M,ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...Bc,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&cT.has(e.key)&&e.stopPropagation()}},od(g),s],stateAttributesMapping:os});return(0,Z.jsx)(Oc,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:ro(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,Z.jsx)(xk.Provider,{value:d,children:N})})}),wk=X.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=ak(),s=iT(a.id);return o.useSyncedValueWithCleanup(`titleElementId`,s),ji(`h2`,e,{ref:t,props:[{id:s},a]})});function Tk(e){let t=(0,$.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,Z.jsx)(dk,{"data-slot":`popover`,...n}),t[2]=n,t[3]=r),r}function Ek(e){let t=(0,$.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,Z.jsx)(mk,{"data-slot":`popover-trigger`,...n}),t[2]=n,t[3]=r),r}function Dk(e){let t=(0,$.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]):({className:n,align:i,alignOffset:a,side:o,sideOffset:s,...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?`center`: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=Ao(`z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-lg bg-popover p-2.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 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: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,Z.jsx)(Ck,{"data-slot":`popover-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,Z.jsx)(_k,{children:(0,Z.jsx)(bk,{align:c,alignOffset:l,side:u,sideOffset:d,className:`isolate z-50`,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 Ok(e){let t=(0,$.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=Ao(`text-sm font-medium`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(wk,{"data-slot":`popover-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var kk=En(e=>ii(t=>Ce(t(e))?x(hn(t.self()),()=>qr(Sr(ir()))):ot())),Ak=En(e=>ii(Yr(Rr(O,t=>tr(C(`1 second`),()=>Rr(O,n=>{let r=At(0,Math.floor((n-Dn(Fr(qr(e),Pe),()=>t))/1e3));return r<60?`${r}s`:r<3600?`${Math.floor(r/60)}m`:r<86400?`${Math.floor(r/3600)}h`:`${Math.floor(r/86400)}d`}))))));function jk(e){let t=(0,$.c)(34),n=(0,X.useId)(),r=e.since??n,i;t[0]===r?i=t[1]:(i=Ak(r),t[0]=r,t[1]=i);let a=bd(i),[o,s]=(0,X.useState)(!1),c=(0,X.useRef)(null),l=(0,X.useRef)(null),u=(0,X.useRef)(!1),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(e,t)=>{!e&&t.reason===`escape-key`&&(u.current=!0),!e&&t.reason===`trigger-press`?l.current?.focus():s(e)},t[2]=d):d=t[2];let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(Xi,{variant:`ghost`,size:`sm`}),t[3]=f):f=t[3];let p=e.label,m;t[4]===e.className?m=t[5]:(m=Ao(`h-8 w-16 max-sm:h-11`,e.className),t[4]=e.className,t[5]=m);let h,g;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>{u.current?u.current=!1:e.currentTarget.matches(`:focus-visible`)&&c.current?.contains(e.relatedTarget)!==!0&&s(!0)},g=()=>{u.current=!1},t[6]=h,t[7]=g):(h=t[6],g=t[7]);let _;t[8]===e.warning?_=t[9]:(_=_t(e.warning===!0,{onFalse:Pk,onTrue:Nk}),t[8]=e.warning,t[9]=_);let v;t[10]===_?v=t[11]:(v=(0,Z.jsx)(rk,{status:_}),t[10]=_,t[11]=v);let y;t[12]===a?y=t[13]:(y=Dn(wt(a),Mk),t[12]=a,t[13]=y);let b;t[14]===y?b=t[15]:(b=(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground font-mono tabular-nums`,children:y}),t[14]=y,t[15]=b);let x;t[16]!==n||t[17]!==e.label||t[18]!==b||t[19]!==m||t[20]!==v?(x=(0,Z.jsxs)(Ek,{id:n,render:f,openOnHover:!0,delay:150,"aria-label":p,className:m,onFocus:h,onBlur:g,children:[v,b]}),t[16]=n,t[17]=e.label,t[18]=b,t[19]=m,t[20]=v,t[21]=x):x=t[21];let S;t[22]===e.label?S=t[23]:(S=(0,Z.jsx)(Ok,{children:e.label}),t[22]=e.label,t[23]=S);let C;t[24]===e.reset?C=t[25]:(C=e.reset!==void 0&&(0,Z.jsx)(Xi,{ref:l,variant:`ghost`,size:`icon`,className:`max-sm:size-11`,"aria-label":`Try again`,title:`Try again`,onClick:e.reset,children:(0,Z.jsx)(Po,{className:`size-4`})}),t[24]=e.reset,t[25]=C);let w;t[26]!==S||t[27]!==C?(w=(0,Z.jsx)(Dk,{ref:c,initialFocus:!1,className:`w-auto max-w-xs`,align:`end`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[S,C]})}),t[26]=S,t[27]=C,t[28]=w):w=t[28];let T;return t[29]!==n||t[30]!==o||t[31]!==x||t[32]!==w?(T=(0,Z.jsxs)(Tk,{open:o,triggerId:n,onOpenChange:d,children:[x,w]}),t[29]=n,t[30]=o,t[31]=x,t[32]=w,t[33]=T):T=t[33],T}function Mk(){return`0s`}function Nk(){return`warning`}function Pk(){return`error`}function Fk(e){let t=(0,$.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=Ao(`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,Z.jsx)(`label`,{"data-slot":`label`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Ik=vi(`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 Lk(e){let t=(0,$.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`vertical`:i,o;t[4]!==n||t[5]!==a?(o=Ao(Ik({orientation:a}),n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,Z.jsx)(`div`,{role:`group`,"data-slot":`field`,"data-orientation":a,className:o,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function Rk(e){let t=(0,$.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=Ao(`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,Z.jsx)(Fk,{"data-slot":`field-label`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function zk(e){let t=(0,$.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(Vk)).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,Z.jsx)(`ul`,{className:`ml-4 flex list-disc flex-col gap-1`,children:r.map(Bk)}),t[7]=r,t[8]=a),o=a}let s=o;if(!s)return null;let c;t[9]===r?c=t[10]:(c=Ao(`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,Z.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 Bk(e,t){return e?.message&&(0,Z.jsx)(`li`,{children:e.message},t)}function Vk(e){return[e?.message,e]}function Hk(e){let t=(0,$.c)(5),n=e.className,r;t[0]===e.result?r=t[1]:(r=xn(Xt(Ln(e.result),Uk)),t[0]=e.result,t[1]=r);let i;return t[2]!==e.className||t[3]!==r?(i=(0,Z.jsx)(zk,{className:n,children:r}),t[2]=e.className,t[3]=r,t[4]=i):i=t[4],i}function Uk(e){return e.message}function Wk(e){let[t,n]=X.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=X.useRef(null),i=X.useRef(null),a=X.useRef(null),o=X.useRef(null),s=X.useRef(!0),c=X.useRef(null),l=So(),u=X.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:a,backdropRef:r,internalBackdropRef:i,positionerRef:o,allowMouseUpTriggerRef:s,initialCursorPointRef:c,rootId:l}),[t,l]);return(0,Z.jsx)(CD.Provider,{value:u,children:(0,Z.jsx)(xD.Provider,{value:void 0,children:(0,Z.jsx)(EO,{...e})})})}var Gk=500,Kk=X.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{setAnchor:o,actionsRef:s,internalBackdropRef:c,backdropRef:l,positionerRef:u,allowMouseUpTriggerRef:d,initialCursorPointRef:f,rootId:p}=wD(!1),{store:m}=SD(!1),h=m.useState(`open`),g=m.useState(`disabled`),_=X.useRef(null),v=X.useRef(null),y=Ci(),b=Ci(),x=X.useRef(!1),S=X.useRef(null);function C(e,t,n){let r=n.type.startsWith(`touch`);f.current={x:e,y:t},o({getBoundingClientRect(){return DOMRect.fromRect({width:r?10:0,height:r?10:0,x:e,y:t})}}),x.current=!1,s.current?.setOpen(!0,q(wo,n)),b.start(Gk,()=>{x.current=!0})}function w(e){if(g)return;d.current=!0,ls(e),C(e.clientX,e.clientY,e.nativeEvent);let t=ua(_.current);S.current?.abort();let n=new AbortController;S.current=n,t.addEventListener(`mouseup`,e=>{if(d.current=!1,!x.current)return;b.clear(),x.current=!1;let t=xa(e);Y(u.current,t)||p&&t&&MO(t)===p||s.current?.setOpen(!1,q($a,e))},{once:!0,signal:n.signal})}function T(){y.clear(),v.current=null}function E(e){if(g||(d.current=!1,e.touches.length!==1)){T();return}e.stopPropagation();let t=e.touches[0],n={x:t.clientX,y:t.clientY};v.current=n,y.start(Gk,()=>{C(n.x,n.y,e.nativeEvent)})}function D(e){if(e.touches.length!==1)T();else if(y.isStarted()&&v.current){let t=e.touches[0],n=Math.abs(t.clientX-v.current.x),r=Math.abs(t.clientY-v.current.y);(n>10||r>10)&&T()}}return X.useEffect(()=>()=>{S.current?.abort()},[]),X.useEffect(()=>{function e(e){if(g)return;let t=xa(e);(Y(_.current,t)||Y(c.current,t)||Y(l.current,t))&&e.preventDefault()}let t=ua(_.current);return K(t,`contextmenu`,e)},[l,g,c]),ji(`div`,e,{state:{open:h},ref:[_,t],props:[{onContextMenu:w,onTouchStart:E,onTouchMove:D,onTouchEnd:T,onTouchCancel:T,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:is})}),qk=mO;function Jk(e){let t=(0,$.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,Z.jsx)(Wk,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function Yk(e){let t=(0,$.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=Ao(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Kk,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Xk(e){let t=(0,$.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]):({className:n,align:i,alignOffset:a,side:o,sideOffset:s,...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?4:a,u=o===void 0?`right`:o,d=s===void 0?0:s,f;t[7]===n?f=t[8]:(f=Ao(`z-50 max-h-(--available-height) 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: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,Z.jsx)(eO,{"data-slot":`context-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,Z.jsx)(rO,{children:(0,Z.jsx)(qk,{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 Zk(e){let t=(0,$.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=Ao(`group/context-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,Z.jsx)(UD,{"data-slot":`context-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}var Qk=Ar(on(dr(`AUTH_URL`)),Bt);qt(function*(){let e=Jt(ri,`GITHUB_ADMINS`);return(yield*Qk)?yield*Zn(e,[`0`]):yield*e});function $k(e){return`${new URL(e).origin}/auth/sign-in?${new URLSearchParams({next:e})}`}function eA(e){return m(qi)(e)&&e.error!==`temporarily_unavailable`&&e.error!==`access_denied`}function tA(e){return m(qi)(e)&&e.error!==`temporarily_unavailable`}g()(`@deslop/runtime/auth/lib/utils/CurrentUser`);var nA=class extends sr()(`@deslop/runtime/auth/lib/utils/RpcAuth`,{error:qi}){};function rA(e,t,n=de){function r(e){let t=gr(e.reasons,e=>te(e)&&tA(e.error));return It(t)?ot():qr(ke(t))}let i=ne(we(e.self(),Fr(Ce),cn(e=>r(e.cause))));function a(e){return $r(Ke(i),{onNone:()=>e,onSome:t=>ke([...t.reasons,...gr(e.reasons,e=>!te(e)||!tA(e.error))])})}let o=we(t,ct(t=>A(()=>{Ee(i,e=>x(r(t),()=>e));let n=a(t);Vr(Ke(i))?e.setSelf(Oe(n)):e.setSelf(Ne(n,{previous:e.self()}))})));return we(n(o),ti(()=>A(()=>pe(i,ot()))),Pn(e=>an(a(e))),Kt(Qt(()=>$r(Ke(i),{onNone:()=>lr,onSome:an}))))}var iA=uy,aA=fy,oA=my,sA=class extends T()(`UpstreamError`,{cause:yn()}){},cA=ri.check(Re(/^[a-z0-9][a-z0-9_-]{0,23}$/u)),lA=Gr.check(Me(2048),he(e=>Jn(Er(Pr(e)),e=>e.protocol===`https:`&&e.username===``&&e.password===``&&e.hash===``),{expected:`a public HTTPS URL without credentials or a fragment`})),uA=ut({url:lA}),dA=ut({id:cA}),fA=ut({authorization_endpoint:lA,authorization_response_iss_parameter_supported:it(fn),client_id_metadata_document_supported:it(fn),code_challenge_methods_supported:it(zr(ri)),issuer:lA,registration_endpoint:it(lA),response_types_supported:it(zr(ri)),token_endpoint:lA});ut({client_id:Gr});var pA=ut({access_token:Gr,expires_in:it(hr.check(Vn(0))),refresh_token:it(Gr),token_type:ri.check(Re(/^Bearer$/iu))}),mA=ut({client:ht({Document:{},Registered:{clientId:Gr}}),metadata:fA,scope:ri}),hA=ht({Authorized:{expiresAt:hr,token:pA},Connected:{},Disconnected:{}}),gA=ut({src:ri,theme:it(Ut([`light`,`dark`]))}),_A=ut({error:it(ri),generation:Gr,icons:it(zr(gA)),id:cA,instructions:it(ri),link:hA,mode:Ut([`oauth`,`public`]),name:Gr,oauth:it(mA),toolDescriptions:it(ci(ri,ri)),tools:zr(ri),url:lA});ci(ri,_A);var vA=ut({description:it(ri),name:Gr}),yA=ut({error:it(ri),icons:zr(gA),id:cA,name:Gr,status:Ut([`Connected`,`Not connected`,`Expired`]),tools:zr(vA),url:lA});ht({Discovered:{icons:zr(gA),instructions:it(ri),toolDescriptions:it(ci(ri,ri)),tools:zr(ri)},Failed:{error:ri}}),ut({code:it(Gr),error:it(ri),iss:it(Gr),state:Gr});var bA=class extends Tr(sn(`gateway.servers`,{error:qi,stream:!0,success:zr(yA)}),sn(`gateway.calls`,{error:qi,stream:!0,success:cA}),sn(`gateway.add`,{error:qi,payload:uA,success:yA}),sn(`gateway.remove`,{error:qi,payload:dA})).middleware(nA){},xA=`${window.location.origin}/mcp`,SA=class extends tn()(`@deslop/gateway/lib/utils/RpcClient`,{group:bA,protocol:Vi(`@deslop/gateway`)}){};function CA(e){return`/oauth/connect?${new URLSearchParams({id:e})}`}var wA=Br(SA.runtime.atom(e=>rA(e,Yr(Rr(SA,e=>e(`gateway.servers`,void 0))),Ui))),TA=Br(SA.runtime.atom(pt(Ui(Yr(Rr(SA,e=>e(`gateway.calls`,void 0))))))),EA=En(e=>ii(t=>{let n=Dn(t.self(),()=>-1);return oe(t(TA),{onFailure:()=>n,onInitial:()=>n,onSuccess:t=>_t(t.value[0]===e,{onFalse:()=>n,onTrue:()=>t.value[1]})})})),DA=En(e=>SA.runtime.fn(()=>U(SA,t=>t(`gateway.remove`,{id:e})))),OA=cb(SA.runtime).make(aA({effects:{add:Nr(function*(e){yield*we(j(lA)(e),dn(e=>qi.make({cause:e,message:`Enter a public HTTPS MCP URL without credentials or a fragment, outside the gateway itself.`})));let t=yield*(yield*SA)(`gateway.add`,{url:e});t.status!==`Connected`&&location.assign(CA(t.id))})},events:oA({Cancel:{},Open:{},Submit:{},Typed:{url:ri}}),root:iA({states:{Adding:{fields:{url:ri}},Closed:{},Editing:{fields:{error:ri,url:ri}}}})}).handle({initial:{target:`Closed`},states:{Adding:{invoke:{input:e=>e.state.url,onDone:{target:`Closed`},onFailure:{data:e=>({error:e.error.message,url:e.state.url}),target:`Editing`},src:`add`}},Closed:{on:{Open:{data:{error:``,url:``},target:`Editing`}}},Editing:{on:{Cancel:{target:`Closed`},Submit:{data:e=>({url:e.state.url}),target:`Adding`},Typed:{data:e=>({error:``,url:e.event.url}),update:`Editing`}}}}})),kA=En(e=>bn(()=>we(Bn({catch:e=>sA.make({cause:e}),try:()=>navigator.clipboard.writeText(e)}),Kn(()=>A(()=>mo.add({description:e,title:`Cannot copy`,type:`error`}))),H(Xr(`1500 millis`))))),AA=`/assets/icon-CboSz0gI.svg`,jA=Be(D,e=>we(wr(e.status),In(`Expired`,()=>0),In(()=>e.error!==void 0,()=>0),In(`Not connected`,()=>1),or(()=>2)));function MA(e){let t=(0,$.c)(10);if(!m(qi)(e.error)){let n;return t[0]!==e.error||t[1]!==e.reset?(n=(0,Z.jsx)(Ni,{error:e.error,reset:e.reset}),t[0]=e.error,t[1]=e.reset,t[2]=n):n=t[2],n}if(e.error.error===`access_denied`){let n;return t[3]!==e.error||t[4]!==e.reset?(n=(0,Z.jsx)(Ni,{error:e.error,label:`Access denied`,reset:e.reset}),t[3]=e.error,t[4]=e.reset,t[5]=n):n=t[5],n}if(!eA(e.error)){let n;return t[6]!==e.error||t[7]!==e.reset?(n=(0,Z.jsx)(Ni,{error:e.error,reset:e.reset}),t[6]=e.error,t[7]=e.reset,t[8]=n):n=t[8],n}let n;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(zi,{href:$k(location.href)}),t[9]=n):n=t[9],n}function NA(e){let t=(0,$.c)(10),n;t[0]===e.server.id?n=t[1]:(n=EA(e.server.id),t[0]=e.server.id,t[1]=n);let r=bd(n),i;t[2]===r?i=t[3]:(i=_t(r>=0,{onFalse:RA,onTrue:LA}),t[2]=r,t[3]=i);let a;t[4]===e.server.status?a=t[5]:(a=we(wr(e.server.status),In(`Connected`,IA),In(`Expired`,FA),or(PA)),t[4]=e.server.status,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,Z.jsx)(rk,{className:i,status:a},r),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function PA(){return`off`}function FA(){return`error`}function IA(){return`live`}function LA(){return`animate-port-blink`}function RA(){}function zA(e){return we(wr(e.status),In(`Expired`,()=>`Sign-in expired`),In(`Not connected`,()=>`Not connected`),or(()=>new URL(e.url).hostname))}function BA(e){let t=(0,$.c)(29),n;t[0]===e.server.id?n=t[1]:(n=DA(e.server.id),t[0]=e.server.id,t[1]=n);let[r,i]=Ed(n),a=e.open,o=e.onOpenChange,s;t[2]===e.server.name?s=t[3]:(s=(0,Z.jsxs)(GT,{children:[`Remove `,e.server.name,`?`]}),t[2]=e.server.name,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(KT,{children:`Its tools will no longer be available through the gateway. This does not revoke the provider’s grant.`}),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,Z.jsx)(Hk,{result:r}),t[5]=r,t[6]=l);let u;t[7]===r?u=t[8]:(u=h(r),t[7]=r,t[8]=u);let d;t[9]===u?d=t[10]:(d=(0,Z.jsx)(BT,{render:(0,Z.jsx)(Xi,{variant:`ghost`,disabled:u}),children:`Cancel`}),t[9]=u,t[10]=d);let f;t[11]===r?f=t[12]:(f=h(r),t[11]=r,t[12]=f);let p;t[13]===i?p=t[14]:(p=()=>i(),t[13]=i,t[14]=p);let m;t[15]!==f||t[16]!==p?(m=(0,Z.jsx)(Xi,{variant:`destructive`,disabled:f,onClick:p,children:`Remove server`}),t[15]=f,t[16]=p,t[17]=m):m=t[17];let g;t[18]!==m||t[19]!==d?(g=(0,Z.jsxs)(WT,{children:[d,m]}),t[18]=m,t[19]=d,t[20]=g):g=t[20];let _;t[21]!==g||t[22]!==s||t[23]!==l?(_=(0,Z.jsxs)(HT,{children:[s,c,l,g]}),t[21]=g,t[22]=s,t[23]=l,t[24]=_):_=t[24];let v;return t[25]!==e.onOpenChange||t[26]!==e.open||t[27]!==_?(v=(0,Z.jsx)(RT,{open:a,onOpenChange:o,children:_}),t[25]=e.onOpenChange,t[26]=e.open,t[27]=_,t[28]=v):v=t[28],v}function VA(e){let t=(0,$.c)(7),[n,r]=(0,X.useState)(0),i;if(t[0]!==n||t[1]!==e.sources){let a;t[3]===n?a=t[4]:(a=e=>(0,Z.jsx)(`img`,{src:e,alt:``,className:`size-full object-contain`,onError:()=>r(n+1)}),t[3]=n,t[4]=a),i=$r(Ot(e.sources,n),{onNone:HA,onSome:a}),t[0]=n,t[1]=e.sources,t[2]=i}else i=t[2];let a;return t[5]===i?a=t[6]:(a=(0,Z.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:i}),t[5]=i,t[6]=a),a}function HA(){return(0,Z.jsx)(Wo,{className:`text-muted-foreground size-4`})}function UA(e){let t=(0,$.c)(9),n,r,i;if(t[0]!==e.server.icons||t[1]!==e.server.url){let a=new URL(e.server.url).hostname;r=B([...Mr(Nn(e.server.icons,Be(N,GA)),WA),`https://${a}/favicon.ico`,`https://${vr(/^(?:api|app|mcp)\./u,``)(a)}/favicon.ico`]),n=VA,i=s(r,` `),t[0]=e.server.icons,t[1]=e.server.url,t[2]=n,t[3]=r,t[4]=i}else n=t[2],r=t[3],i=t[4];let a;return t[5]!==n||t[6]!==r||t[7]!==i?(a=(0,Z.jsx)(n,{sources:r},i),t[5]=n,t[6]=r,t[7]=i,t[8]=a):a=t[8],a}function WA(e){return e.src}function GA(e){return e.theme!==`dark`}function KA(e){let t=document.getElementById(`server-${e.id}`);t?.focus(),t?.scrollIntoView({block:`center`})}function qA(e){let t=(0,$.c)(42),[n,r]=(0,X.useState)(!1),i=e.server.status===`Connected`,a;t[0]!==n||t[1]!==e.server?(a=(0,Z.jsx)(BA,{open:n,onOpenChange:r,server:e.server}),t[0]=n,t[1]=e.server,t[2]=a):a=t[2];let o=`server-${e.server.id}`,s=e.server.name,c;t[3]===e.server?c=t[4]:(c=zA(e.server),t[3]=e.server,t[4]=c);let l=`${s}, ${c}`,u;t[5]!==o||t[6]!==l?(u=(0,Z.jsx)(Yk,{render:(0,Z.jsx)(Xi,{variant:`ghost`,"data-row":!0,id:o,type:`button`,"aria-label":l,className:`absolute inset-0 h-full w-full`})}),t[5]=o,t[6]=l,t[7]=u):u=t[7];let d;t[8]===e.server?d=t[9]:(d=(0,Z.jsx)(UA,{server:e.server}),t[8]=e.server,t[9]=d);let f;t[10]===e.server.name?f=t[11]:(f=(0,Z.jsx)(`span`,{className:`max-w-56 min-w-0 shrink truncate text-sm font-medium`,children:e.server.name}),t[10]=e.server.name,t[11]=f);let p;t[12]===e.server.url?p=t[13]:(p=new URL(e.server.url),t[12]=e.server.url,t[13]=p);let m;t[14]===p.hostname?m=t[15]:(m=(0,Z.jsx)(`span`,{className:`text-muted-foreground min-w-0 flex-1 truncate font-mono text-xs`,children:p.hostname}),t[14]=p.hostname,t[15]=m);let h;t[16]===e.server.tools?h=t[17]:(h=Xe(e.server.tools)&&(0,Z.jsx)(`span`,{className:`text-muted-foreground w-12 shrink-0 text-right font-mono text-xs tabular-nums`,title:`Tools`,children:e.server.tools.length}),t[16]=e.server.tools,t[17]=h);let g;t[18]!==h||t[19]!==d||t[20]!==f||t[21]!==m?(g=(0,Z.jsxs)(`div`,{className:`pointer-events-none relative flex min-w-0 flex-1 items-center gap-3`,children:[d,f,m,h]}),t[18]=h,t[19]=d,t[20]=f,t[21]=m,t[22]=g):g=t[22];let _;t[23]!==i||t[24]!==e.server?(_=i&&e.server.error===void 0&&(0,Z.jsx)(`span`,{role:`img`,title:e.server.status,"aria-label":e.server.status,className:`flex size-3 shrink-0 items-center justify-center`,children:(0,Z.jsx)(NA,{server:e.server})}),t[23]=i,t[24]=e.server,t[25]=_):_=t[25];let v;t[26]!==i||t[27]!==e.server?(v=(!i||e.server.error!==void 0)&&(0,Z.jsx)(jk,{label:_t(i,{onFalse:()=>zA(e.server),onTrue:JA}),reset:()=>location.assign(CA(e.server.id))}),t[26]=i,t[27]=e.server,t[28]=v):v=t[28];let y;t[29]!==_||t[30]!==v?(y=(0,Z.jsxs)(`div`,{className:`relative flex w-16 shrink-0 justify-end`,children:[_,v]}),t[29]=_,t[30]=v,t[31]=y):y=t[31];let b;t[32]!==g||t[33]!==y||t[34]!==u?(b=(0,Z.jsxs)(`div`,{className:`relative flex h-8 items-center gap-3 px-3 max-sm:h-11`,children:[u,g,y]}),t[32]=g,t[33]=y,t[34]=u,t[35]=b):b=t[35];let x;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(Xk,{className:`w-auto min-w-36`,children:(0,Z.jsx)(Zk,{variant:`destructive`,onClick:()=>r(!0),children:`Remove`})}),t[36]=x):x=t[36];let S;t[37]===b?S=t[38]:(S=(0,Z.jsxs)(Jk,{children:[b,x]}),t[37]=b,t[38]=S);let C;return t[39]!==a||t[40]!==S?(C=(0,Z.jsxs)(`div`,{role:`listitem`,className:`list-row`,children:[a,S]}),t[39]=a,t[40]=S,t[41]=C):C=t[41],C}function JA(){return`Connection failed`}function YA(){let e=(0,$.c)(18),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={includeFailure:!0},e[0]=t):t=e[0];let n=Ad(wA,t),r=Td(wA),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=kk(wA),e[1]=i):i=e[1];let a=xn(bd(i)),o,s;if(e[2]!==r||e[3]!==n){s=Symbol.for(`react.early_return_sentinel`);bb0:{let t=wt(n);if(Ce(n)&&(Bt(t)||Jn(Ln(n),tA))){let t;e[6]===n.cause?t=e[7]:(t=tt(n.cause),e[6]=n.cause,e[7]=t);let i;e[8]!==r||e[9]!==t?(i=(0,Z.jsx)(MA,{error:t,reset:r}),e[8]=r,e[9]=t,e[10]=i):i=e[10],s=i;break bb0}o=xn(Xt(t,XA))}e[2]=r,e[3]=n,e[4]=o,e[5]=s}else o=e[4],s=e[5];if(s!==Symbol.for(`react.early_return_sentinel`))return s;let c;e[11]!==r||e[12]!==n||e[13]!==a?(c=Ce(n)&&(0,Z.jsx)(`div`,{className:`bg-background sticky bottom-0 z-20 mt-auto flex shrink-0 justify-end px-3`,children:(0,Z.jsx)(jk,{label:`Servers out of date`,warning:!0,reset:r,since:a})}),e[11]=r,e[12]=n,e[13]=a,e[14]=c):c=e[14];let l;return e[15]!==o||e[16]!==c?(l=(0,Z.jsxs)(Z.Fragment,{children:[o,c]}),e[15]=o,e[16]=c,e[17]=l):l=e[17],l}function XA(e){return rr(Nn(e,jA),{onEmpty:$A,onNonEmpty:ZA})}function ZA(e){return(0,Z.jsx)(`div`,{role:`list`,"aria-label":`MCP servers`,children:Mr(e,QA)})}function QA(e){return(0,Z.jsx)(qA,{server:e},e.id)}function $A(){return(0,Z.jsx)(Di,{label:`No servers`,icon:(0,Z.jsx)(`img`,{src:AA,alt:``,className:`pixelated size-8 opacity-50`})})}function ej(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`section`,{"aria-label":`MCP servers`,className:`pb-safe-bottom flex min-h-0 flex-1 flex-col overflow-y-auto`,children:(0,Z.jsx)(bi,{getResetKey:tj,errorComponent:MA,children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(tk,{label:`MCP servers`,media:!0,rows:5,rowClassName:`gap-3 px-3`}),children:(0,Z.jsx)(YA,{})})})}),e[0]=t):t=e[0],t}function tj(){return`servers`}function nj(e){let t=(0,$.c)(31),n=wd(OA.send),r;t[0]===n?r=t[1]:(r=e=>{e.preventDefault(),n({_tag:`Submit`})},t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(GT,{children:`Add a server`}),t[2]=i):i=t[2];let a=e.error!==``,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(Rk,{htmlFor:`mcp-url`,children:`MCP URL`}),t[3]=o):o=t[3];let s;t[4]===n?s=t[5]:(s=e=>n({_tag:`Typed`,url:e.target.value}),t[4]=n,t[5]=s);let c=e.error!==``,l;t[6]!==e.adding||t[7]!==e.url||t[8]!==s||t[9]!==c?(l=(0,Z.jsx)(uE,{id:`mcp-url`,type:`url`,autoComplete:`url`,placeholder:`https://example.com/mcp`,required:!0,autoFocus:!0,value:e.url,disabled:e.adding,onChange:s,"aria-invalid":c,"aria-describedby":`mcp-add-error`}),t[6]=e.adding,t[7]=e.url,t[8]=s,t[9]=c,t[10]=l):l=t[10];let u;t[11]===e.error?u=t[12]:(u=(0,Z.jsx)(zk,{id:`mcp-add-error`,children:e.error}),t[11]=e.error,t[12]=u);let d;t[13]!==a||t[14]!==l||t[15]!==u?(d=(0,Z.jsxs)(Lk,{"data-invalid":a,children:[o,l,u]}),t[13]=a,t[14]=l,t[15]=u,t[16]=d):d=t[16];let f;t[17]===e.adding?f=t[18]:(f=(0,Z.jsx)(BT,{render:(0,Z.jsx)(Xi,{variant:`ghost`,type:`button`,disabled:e.adding}),children:`Cancel`}),t[17]=e.adding,t[18]=f);let p=e.adding,m;t[19]===e.adding?m=t[20]:(m=_t(e.adding,{onFalse:ij,onTrue:rj}),t[19]=e.adding,t[20]=m);let h;t[21]!==e.adding||t[22]!==m?(h=(0,Z.jsx)(Xi,{type:`submit`,disabled:p,children:m}),t[21]=e.adding,t[22]=m,t[23]=h):h=t[23];let g;t[24]!==h||t[25]!==f?(g=(0,Z.jsxs)(WT,{children:[f,h]}),t[24]=h,t[25]=f,t[26]=g):g=t[26];let _;return t[27]!==r||t[28]!==g||t[29]!==d?(_=(0,Z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:r,children:[i,d,g]}),t[27]=r,t[28]=g,t[29]=d,t[30]=_):_=t[30],_}function rj(){return`Adding…`}function ij(){return`Add server`}function aj(){let e=(0,$.c)(11),t=wd(OA.send),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=sb(OA,`Editing`),e[0]=n):n=e[0];let r=R(db(n),ot),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=sb(OA,`Adding`),e[1]=i):i=e[1];let a=R(db(i),ot),o=x(Xt(r,lj),()=>Xt(a,cj)),s=RT,c=Vr(o),l=e=>{!e&&Vr(r)&&t({_tag:`Cancel`})},u=HT,d=Bt(a),f=$r(o,{onNone:sj,onSome:oj}),p;e[2]!==u||e[3]!==d||e[4]!==f?(p=(0,Z.jsx)(u,{showCloseButton:d,children:f}),e[2]=u,e[3]=d,e[4]=f,e[5]=p):p=e[5];let m;return e[6]!==s||e[7]!==c||e[8]!==l||e[9]!==p?(m=(0,Z.jsx)(s,{open:c,onOpenChange:l,children:p}),e[6]=s,e[7]=c,e[8]=l,e[9]=p,e[10]=m):m=e[10],m}function oj(e){return(0,Z.jsx)(nj,{...e})}function sj(){return null}function cj(e){return{adding:!0,error:``,url:e.url}}function lj(e){return{adding:!1,error:e.error,url:e.url}}function uj(){let e=(0,$.c)(30),t=wd(OA.send),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=kA(xA),e[0]=n):n=e[0];let[r,i]=Ed(n),a=h(r),o=bd(wA),s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=kk(wA),e[1]=s):s=e[1],bd(s);let c=wt(o),l=Fr(Ln(o),tA),u=Nn(Dn(c,xj),jA),d=Bt(l)&&Vr(c),f={items:Mr(gr(u,bj),yj),label:`Needs you`},p={items:Mr(u,_j),label:`Servers`},m;e[2]===t?m=e[3]:(m=()=>[{icon:(0,Z.jsx)(Jo,{}),label:`Add server`,run:()=>t({_tag:`Open`})}],e[2]=t,e[3]=m);let g;e[4]===i?g=e[5]:(g=()=>i(),e[4]=i,e[5]=g);let _={items:[..._t(d,{onFalse:gj,onTrue:m}),{icon:_t(a,{onFalse:hj,onTrue:mj}),label:`Copy MCP URL`,run:g}],label:`Actions`},v=XO,y=AA,b=_t(Vr(l),{onFalse:()=>[_,f,p,JE(`gateway`)],onTrue:pj}),x=YO,S=_t(a,{onFalse:fj,onTrue:dj}),C;e[6]===i?C=e[7]:(C=()=>i(),e[6]=i,e[7]=C);let w;e[8]!==x||e[9]!==S||e[10]!==C?(w=(0,Z.jsx)(x,{icon:S,label:`Copy MCP URL`,onClick:C}),e[8]=x,e[9]=S,e[10]=C,e[11]=w):w=e[11];let T=!d,E;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(Jo,{}),e[12]=E):E=e[12];let D;e[13]===t?D=e[14]:(D=()=>t({_tag:`Open`}),e[13]=t,e[14]=D);let O;e[15]!==T||e[16]!==D?(O=(0,Z.jsx)(YO,{disabled:T,icon:E,label:`Add server`,onClick:D}),e[15]=T,e[16]=D,e[17]=O):O=e[17];let k;e[18]!==w||e[19]!==O?(k=(0,Z.jsxs)(Z.Fragment,{children:[w,O]}),e[18]=w,e[19]=O,e[20]=k):k=e[20];let A;e[21]!==v||e[22]!==k||e[23]!==y||e[24]!==b?(A=(0,Z.jsx)(v,{icon:y,name:`gateway`,palette:b,action:k}),e[21]=v,e[22]=k,e[23]=y,e[24]=b,e[25]=A):A=e[25];let j,M;e[26]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(ej,{}),M=(0,Z.jsx)(aj,{}),e[26]=j,e[27]=M):(j=e[26],M=e[27]);let N;return e[28]===A?N=e[29]:(N=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[A,j,M]}),e[28]=A,e[29]=N),N}function dj(){return(0,Z.jsx)(Bo,{className:`text-primary`})}function fj(){return(0,Z.jsx)(Ho,{})}function pj(){return[JE(`gateway`)]}function mj(){return(0,Z.jsx)(Bo,{className:`text-primary`})}function hj(){return(0,Z.jsx)(Ho,{})}function gj(){return[]}function _j(e){return{detail:new URL(e.url).hostname,icon:(0,Z.jsx)(UA,{server:e}),id:e.id,keywords:`${e.name} ${e.url} ${s(Mr(e.tools,vj),` `)}`,label:e.name,run:()=>KA(e)}}function vj(e){return e.name}function yj(e){return{detail:zA(e),icon:(0,Z.jsx)(UA,{server:e}),id:e.id,keywords:`${e.name} ${e.url}`,label:e.name,run:()=>KA(e)}}function bj(e){return e.status!==`Connected`||e.error!==void 0}function xj(){return ye()}export{uj as component};
|