@fabiofiorita/porcelain 0.67.0 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/web/dist/assets/_-CUiVgd1P.js +1 -0
- package/web/dist/assets/_paired-BQ4zvgTl.js +1 -0
- package/web/dist/assets/_paired-D53rFQOm.js +1 -0
- package/web/dist/assets/_paired-DulRqWh5.js +1 -0
- package/web/dist/assets/_paired-b-omTaSX.js +1 -0
- package/web/dist/assets/_section-cagtcy7G.js +1 -0
- package/web/dist/assets/_worktreeId-CThUIoTM.js +1 -0
- package/web/dist/assets/_worktreeId-D53rFQOm.js +1 -0
- package/web/dist/assets/{_worktreeId-D0bWoqgW.js → _worktreeId-DpH-vYss.js} +1 -1
- package/web/dist/assets/_worktreeId-b-omTaSX.js +1 -0
- package/web/dist/assets/access-DZtk9_ZO.js +1 -0
- package/web/dist/assets/connected-workspace-CJrJi9V0.js +1 -0
- package/web/dist/assets/desktop-actions-5oLi8NTj.js +11 -0
- package/web/dist/assets/edit-file-C2ZWXEDJ.js +1568 -0
- package/web/dist/assets/{file-editor-CSiOZ6Sd.js → file-editor-Tv5rckrw.js} +6 -6
- package/web/dist/assets/{files-De0CgA0d.js → files-BbuoUlj4.js} +3 -3
- package/web/dist/assets/index-C-v0DMR2.css +2 -0
- package/web/dist/assets/index-l0ZrxQZJ.js +10 -0
- package/web/dist/assets/lazyRouteComponent-DzjAS4Ua.js +1 -0
- package/web/dist/assets/link-82OWhnou.js +1 -0
- package/web/dist/assets/{pair-Datv-jBb.js → pair-VKM46ps6.js} +1 -1
- package/web/dist/assets/pair-b-omTaSX.js +1 -0
- package/web/dist/assets/settings-page-CH2ar5aA.js +1345 -0
- package/web/dist/assets/useMatch-BfG81Osp.js +1 -0
- package/web/dist/assets/useRouterState-B-M09Je-.js +1 -0
- package/web/dist/assets/{workspace-error-DZaV6KWv.js → workspace-error-WgJhsFQh.js} +1 -1
- package/web/dist/assets/{workspace-pending-BUZzjlSx.js → workspace-pending-CuIxZqCb.js} +1 -1
- package/web/dist/index.html +10 -10
- package/web/dist/assets/_paired-Cf9W7w-r.js +0 -1
- package/web/dist/assets/_paired-DV6Uu96D.js +0 -1
- package/web/dist/assets/_paired-DdiJtBi7.js +0 -1
- package/web/dist/assets/_paired-DtZr8WeA.js +0 -1
- package/web/dist/assets/_section-BhA0KAGA.js +0 -1
- package/web/dist/assets/_worktreeId-Bn1qBq2T.js +0 -1
- package/web/dist/assets/_worktreeId-Cf9W7w-r.js +0 -1
- package/web/dist/assets/_worktreeId-DtZr8WeA.js +0 -1
- package/web/dist/assets/access-DKodjctH.js +0 -1
- package/web/dist/assets/connected-workspace-B0v2QBMa.js +0 -1
- package/web/dist/assets/desktop-actions-xMY_-vix.js +0 -11
- package/web/dist/assets/edit-file-DpmO9xHx.js +0 -1568
- package/web/dist/assets/index-CTp3Y5lC.css +0 -2
- package/web/dist/assets/index-DL7Akkem.js +0 -10
- package/web/dist/assets/lazyRouteComponent-D-Ru9boN.js +0 -1
- package/web/dist/assets/link-BtPdbBer.js +0 -1
- package/web/dist/assets/pair-DtZr8WeA.js +0 -1
- package/web/dist/assets/search-BYxM2Eui.js +0 -1
- package/web/dist/assets/settings-page-BdwyGbHc.js +0 -1345
- package/web/dist/assets/useRouterState-B1-fsbiG.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$a as t,$c as n,$i as r,$l as i,$n as a,$o as o,$s as s,$t as c,Aa as l,Ac as u,Ai as d,Al as f,An as p,Ar as m,As as h,Au as g,Ba as _,Bc as v,Bi as y,Bl as b,Bn as x,Br as S,Bs as C,Bt as w,Ca as T,Cc as E,Ci as D,Cl as O,Cn as k,Co as A,Cr as j,Cs as M,Ct as N,Cu as P,D as F,Da as I,Dc as L,Di as R,Dl as z,Dn as B,Do as ee,Dr as V,Ds as te,Dt as ne,Du as re,E as ie,Ec as ae,Ei as oe,El as H,En as se,Er as ce,Es as le,Et as ue,Eu as de,Fa as fe,Fc as pe,Fi as U,Fl as me,Fn as he,Fr as ge,Fs as _e,Ft as ve,G as ye,Ga as be,Gc as xe,Gi as Se,Gl as Ce,Gn as we,Go as Te,Gr as Ee,Gs as De,Ha as Oe,Hc as ke,Hi as Ae,Hl as je,Hn as Me,Ho as Ne,Hr as Pe,Hs as Fe,Ht as Ie,I as Le,Ia as Re,Ic as ze,Ii as Be,Il as Ve,In as He,Io as Ue,Ir as We,Is as Ge,J as Ke,Ja as qe,Jc as Je,Jl as Ye,Jn as Xe,Js as Ze,Jt as Qe,K as $e,Ka as et,Kc as tt,Ki as nt,Kn as rt,Ko as it,Kr as at,Ks as ot,Kt as st,L as ct,La as lt,Lc as ut,Ll as dt,Lo as ft,Lr as pt,Ls as mt,Lt as ht,M as gt,Ma as _t,Mc as vt,Mi as yt,Ml as bt,Mn as xt,Mr as St,Ms as W,Mt as Ct,Na as wt,Nc as Tt,Ni as Et,Nl as Dt,Nn as Ot,No as kt,Nr as At,Ns as jt,Nt as Mt,O as Nt,Oa as Pt,Oc as Ft,Oi as It,Ol as Lt,On as Rt,Oo as zt,Or as Bt,Os as Vt,Ou as Ht,Pa as Ut,Pc as Wt,Pi as Gt,Pl as Kt,Pn as qt,Pr as Jt,Ps as G,Pt as Yt,Q as Xt,Qa as Zt,Qc as Qt,Ql as $t,Qo as en,Qr as tn,Qs as nn,Qt as rn,Ra as an,Rc as on,Ri as sn,Rl as cn,Ro as ln,Rr as un,Rs as dn,Rt as fn,Sa as pn,Sc as mn,Si as hn,Sl as gn,So as _n,Sr as vn,Ss as yn,St as bn,Ta as xn,Tc as Sn,Ti as Cn,Tl as wn,Tn,Tr as En,Ts as Dn,Tt as On,Tu as kn,Ua as An,Uc as jn,Ui as Mn,Ul as Nn,Un as Pn,Uo as Fn,Ur as In,Us as Ln,Ut as K,V as Rn,Va as zn,Vc as Bn,Vi as Vn,Vl as Hn,Vn as Un,Vo as Wn,Vr as Gn,Vs as Kn,Wa as qn,Wc as Jn,Wl as Yn,Wn as Xn,Wo as Zn,Wr as Qn,Ws as $n,Wt as er,X as tr,Xa as nr,Xc as rr,Xi as ir,Xl as ar,Xr as or,Xs as sr,Ya as cr,Yc as lr,Yi as ur,Yl as dr,Yn as fr,Ys as pr,Yt as mr,Z as hr,Za as gr,Zc as _r,Zi as vr,Zl as yr,Zn as br,Zo as xr,Zr as q,Zs as Sr,_a as Cr,_c as wr,_i as Tr,_l as Er,_o as Dr,_r as Or,_s as kr,_t as Ar,_u as jr,aa as Mr,ac as Nr,ai as Pr,al as Fr,an as Ir,ar as Lr,at as Rr,au as zr,ba as Br,bc as Vr,bi as Hr,bl as Ur,bn as Wr,bo as Gr,bs as Kr,bt as qr,bu as Jr,ca as Yr,cc as Xr,cl as Zr,co as Qr,cr as $r,ct as ei,cu as ti,da as ni,dc as ri,di as ii,dl as ai,dn as oi,dr as si,ds as ci,dt as li,ea as ui,ec as di,ei as fi,el as pi,eo as mi,er as hi,es as gi,et as _i,eu as vi,fa as yi,fc as bi,fi as xi,fl as Si,fn as Ci,fo as wi,fr as Ti,fs as Ei,ft as Di,fu as Oi,ga as ki,gc as Ai,gi as ji,gl as Mi,gn as Ni,go as Pi,gr as Fi,gs as Ii,gt as Li,gu as Ri,ha as zi,hc as Bi,hl as Vi,hr as Hi,hs as Ui,hu as Wi,ic as Gi,io as Ki,ir as qi,is as Ji,iu as Yi,j as Xi,ja as Zi,jc as Qi,ji as $i,jl as ea,jn as ta,jo as na,jr as ra,js as ia,jt as aa,ka as oa,kc as sa,ki as ca,kl as la,ko as ua,kr as da,ks as fa,ku as pa,la as ma,lc as ha,li as ga,ll as _a,ln as va,lo as ya,lr as ba,ls as xa,lt as Sa,lu as Ca,ma as wa,mc as Ta,ml as Ea,mo as Da,mr as J,ms as Oa,mt as ka,nc as Aa,ni as ja,nl as Ma,nn as Na,no as Pa,ns as Fa,nt as Ia,nu as La,oa as Ra,oc as za,oi as Ba,ol as Va,on as Ha,or as Ua,os as Wa,ou as Ga,pa as Ka,pc as qa,pl as Ja,pn as Ya,po as Xa,pr as Za,ps as Qa,pt as $a,pu as eo,qa as to,qc as no,qi as ro,ql as io,qn as ao,qo as oo,qr as Y,qs as so,qt as co,ra as lo,rc as uo,ri as fo,rl as po,rn as mo,ro as ho,rr as go,rs as _o,rt as vo,ru as yo,sa as bo,sc as xo,si as So,sl as Co,so as wo,sr as To,ss as Eo,st as Do,su as Oo,ta as ko,tc as Ao,ti as jo,tl as Mo,to as No,ts as Po,tt as Fo,tu as Io,ua as Lo,ul as Ro,un as zo,uo as Bo,ur as Vo,us as Ho,ut as Uo,uu as Wo,vc as X,vi as Go,vl as Ko,vr as qo,vs as Jo,vt as Yo,vu as Xo,wa as Zo,wc as Qo,wi as $o,wl as es,wo as ts,wr as ns,ws as rs,wt as is,wu as as,xa as os,xc as ss,xi as cs,xl as ls,xo as us,xr as ds,xs as fs,xt as ps,xu as ms,ya as hs,yc as gs,yi as _s,yl as vs,yn as ys,yr as bs,ys as xs,yt as Ss,yu as Cs,za as ws,zc as Ts,zl as Es,zn as Ds,zr as Os,zs as ks,zt as As}from"./files-BbuoUlj4.js";var js=e=>t=>!vi(e(t)),Ms=e=>t=>t.has(e)?La(t):i(t),Ns=pa(2,(e,t)=>n=>{let r=e(n);return vi(r)?r:t(r.success)}),Ps=(e,t,n)=>{let r=n*(t-e)+e;if(r!==t||e>=t||!Number.isFinite(t))return r;if(t===0)return-Number.MIN_VALUE;let i=new DataView(new ArrayBuffer(8));i.setFloat64(0,t);let a=i.getBigUint64(0);return i.setBigUint64(0,t>0?a-BigInt(1):a+BigInt(1)),i.getFloat64(0)},Fs=`~effect/PlatformError`,Is=class extends Es(`BadArgument`){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:``}`}},Ls=class extends cn{get message(){return`${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor===void 0?``:` (${this.pathOrDescriptor})`}${this.description?`: ${this.description}`:``}`}},Rs=class extends Es(`PlatformError`){constructor(e){`cause`in e?super({reason:e,cause:e.cause}):super({reason:e})}[Fs]=Fs;get message(){return this.reason.message}},zs=e=>new Rs(new Ls(e)),Bs=e=>new Rs(new Is(e)),Vs=`~effect/socket/Socket`,Hs=Yi(`effect/socket/Socket`),Us=e=>Hs.of({[Vs]:Vs,reader:e.reader,writer:e.writer}),Ws=new TextEncoder,Gs=`~effect/socket/Socket/CloseEvent`,Ks=e=>re(e,Gs),qs=`~effect/socket/Socket/SocketError`,Js=e=>re(e,qs),Ys=class extends Xa(`effect/socket/Socket/SocketReadError`)({_tag:it(`SocketReadError`),cause:wi()}){message=`An error occurred during Read`},Xs=class extends Xa(`effect/socket/Socket/SocketWriteError`)({_tag:it(`SocketWriteError`),cause:wi()}){message=`An error occurred during Write`},Zs=class extends Xa(`effect/socket/Socket/SocketOpenError`)({_tag:it(`SocketOpenError`),kind:Pi([`Unknown`,`Timeout`]),cause:wi()}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},Qs=class e extends Xa(`effect/socket/Socket/SocketUpgradeError`)({_tag:it(`SocketUpgradeError`),cause:Te(wi())}){static unsupported=()=>W(new tc({reason:new e({})}));get message(){return this.cause===void 0?`Socket does not support TLS upgrade`:`An error occurred during TLS upgrade`}},$s=class extends Xa(`effect/socket/Socket/SocketCloseError`)({_tag:it(`SocketCloseError`),code:Da,closeReason:Te(_n)}){get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},ec=zt([Ys,Xs,Zs,Qs,$s]),tc=class extends ts(qs)(`SocketError`,{_tag:it(`SocketError`),reason:ec}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[qs]=qs;static is(e){return Js(e)}message=this.reason.message},nc=(e,t)=>new tc({reason:new $s({code:e,closeReason:t})}),rc=class extends Yi()(`@effect/platform/Socket/WebSocketConstructor`){},ic=(e,t)=>rc.use(n=>oc(Qa((typeof e==`string`?Ai(e):e).pipe(so(e=>n(e,t?.protocols))),e=>X(()=>e.close(1e3))),t)),ac=e=>`pause`in e&&typeof e.pause==`function`,oc=(e,t)=>Tt(n=>{let r,i=et(!1),a=n.context,o=C(function*(){let n=yield*bi,a=yield*Fr(e,n);`binaryType`in a&&(a.binaryType=`arraybuffer`);let o=ac(a),s=t?.highWaterMark??(o?sc:void 0),c=a.readyState===1,l=o&&`isPaused`in a&&a.isPaused===!0,u=[],d=0,f,p,m;function h(){o&&!l&&(a.pause(),l=!0)}function g(){o&&l&&(a.resume(),l=!1)}function _(){let e=u;return u=[],d=0,f===void 0&&g(),e}function v(){if(p===void 0||u.length===0)return;let e=p;p=void 0,e(Ai(_()))}function y(e){u.push(e),s!==void 0&&(d+=typeof e==`string`?Ws.encode(e).byteLength:e.byteLength),p!==void 0&&v(),o&&d>=s?h():!o&&!p&&s!==void 0&&d>s&&b(new tc({reason:new Ys({cause:Error(`Socket highWaterMark of ${s} bytes exceeded`)})}))}function b(e){if(f===void 0&&(f=e),m!==void 0){let{cleanup:e,resume:t}=m;m=void 0,e(),t(W(f))}if(p!==void 0){let e=p;p=void 0,e(u.length>0?Ai(_()):W(f))}}function x(e){let t=e.data;if(typeof Blob<`u`&&t instanceof Blob){t.arrayBuffer().then(e=>y(new Uint8Array(e)),e=>{b(new tc({reason:new Ys({cause:e})}))});return}y(t instanceof ArrayBuffer?new Uint8Array(t):t)}function S(e){b(new tc({reason:c?new Ys({cause:e}):new Zs({kind:`Unknown`,cause:e})}))}function C(e){b(nc(typeof e.code==`number`?e.code:1006,e.reason))}return a.addEventListener(`message`,x),a.addEventListener(`error`,S,{once:!0}),a.addEventListener(`close`,C,{once:!0}),yield*pi(n,X(()=>{if(b(nc(1006)),a.removeEventListener(`message`,x),a.removeEventListener(`error`,S),a.removeEventListener(`close`,C),o)try{g()}catch{}i.closeUnsafe(),r=void 0})),a.readyState>=2?yield*W(f??nc(1006)):(c||=(yield*Kr(e=>{let t=()=>{m?.resume===e&&(m=void 0,a.removeEventListener(`open`,t),e(Qi))},n=()=>a.removeEventListener(`open`,t);return m={resume:e,cleanup:n},a.addEventListener(`open`,t,{once:!0}),X(()=>{m?.resume===e&&(m=void 0),n()})}).pipe(Qo({duration:t?.openTimeout??1e4,orElse:()=>W(new tc({reason:new Zs({kind:`Timeout`,cause:Error(`timeout waiting for "open"`)})}))})),!0),f===void 0&&d<s&&g(),r=a,i.openUnsafe(),{pull:Kr(e=>u.length>0?e(Ai(_())):f===void 0?(p=e,X(()=>{p===e&&(p=void 0)})):e(W(f))),upgrade:Qs.unsupported})}).pipe(sa(e=>Wo(a,e))),s=e=>wr(()=>{let t=r;if(t===void 0)return i.whenOpen(s(e));try{return Ks(e)?t.close(e.code,e.reason):t.send(e),Qi}catch(e){return W(new tc({reason:new Xs({cause:e})}))}}),c=e=>wr(()=>{let t=r;if(t===void 0)return i.whenOpen(c(e));try{for(let n=0;n<e.length;n++)t.send(e[n]);return Qi}catch(e){return W(new tc({reason:new Xs({cause:e})}))}}),l=Ai({write:s,writeAll:c});return Ai(Us({reader:o,writer:l}))}),sc=65536,cc=class extends Yi()(`effect/workers/Transferable/Collector`){},lc=()=>{let e=[],t=t=>{e.push(...t)},n=()=>e,r=()=>{let t=e;return e=[],t};return cc.of({addAllUnsafe:t,addAll:e=>X(()=>t(e)),readUnsafe:n,read:X(n),clearUnsafe:r,clear:X(r)})},uc=zt([class extends Xa(`effect/workers/WorkerError/WorkerSpawnError`)({_tag:it(`WorkerSpawnError`),message:_n,cause:Te(wi())}){},class extends Xa(`effect/workers/WorkerError/WorkerSendError`)({_tag:it(`WorkerSendError`),message:_n,cause:Te(wi())}){},class extends Xa(`effect/workers/WorkerError/WorkerReceiveError`)({_tag:it(`WorkerReceiveError`),message:_n,cause:Te(wi())}){},class extends Xa(`effect/workers/WorkerError/WorkerUnknownError`)({_tag:it(`WorkerUnknownError`),message:_n,cause:Te(wi())}){}]),dc=`~effect/rpc/RpcClientError`,fc=class extends Xa(`effect/rpc/RpcClientError/RpcClientDefect`)({_tag:it(`RpcClientDefect`),message:_n,cause:wi()}){},pc=class extends Xa(dc)({_tag:it(`RpcClientError`),reason:zt([uc,ec,It,fc])}){[dc]=dc;get message(){return`${this.reason._tag}: ${this.reason.message}`}},mc=e=>e,hc={_tag:`Ping`},gc=oo,_c,vc=e=>(_c??=new TextDecoder).decode(e),yc=class extends Yi()(`effect/rpc/RpcSerialization`){},bc=yc.of({contentType:`application/json`,includesFraming:!1,codecFor:gc,makeUnsafe:()=>({decode:e=>{let t=JSON.parse(typeof e==`string`?e:vc(e));return Array.isArray(t)?t:[t]},encode:e=>JSON.stringify(e)})}),xc=e=>wr(()=>{let t=new Set,n=new Map,r=new Map,i=(e,t)=>te(r=>{let i=n.get(e);return i||(i=[],n.set(e,i)),i.push([t,r]),Qi});return so(e((e,t)=>{let n=r.get(e);return n?n(t):i(e,t)},t),e=>({...e,run(e,i){return C(function*(){t.add(e),r.set(e,i);let a=n.get(e);if(a){n.delete(e);for(let[e,t]of a)yield*uo(wr(()=>i(e)),t)}return yield*nn(sr,()=>(t.delete(e),r.delete(e),Qi))})}}))}),Sc=0,Cc=_e(function*(e,t){let r=t?.spanPrefix??`RpcClient`,i=t?.supportsAck??!0,a=t?.disableTracing??!1,c=t?.generateRequestId??(()=>Sc++),l=yield*le(),d=Oo(l,n),f=new Map,p=!1;yield*pi(d,Tt(e=>(p=!0,m(Vi(e.id)))));let m=_e(function*(e){for(let[t,n]of f)f.delete(t),n._tag===`Queue`?yield*e._tag===`Success`?an(n.queue):ws(n.queue,e.cause):n.resume(e)}),h=e=>{let n=Hr(e.successSchema),i=b(e);return(o,s)=>{let c=s?.headers?en(s.headers):xr,l=s?.context??Ga();if(!n){let n=t=>v(e,i,t,e.payloadSchema.make(o),c,l,s?.discard??!1);return a?n(void 0):u(`${r}.${e._tag}`,{attributes:t.spanAttributes},n)}let d=y(e,i,e.payloadSchema.make(o),c,s?.streamBufferSize??16,l);return s?.asQueue?d:xn(so(d,yi))}},v=(e,n,r,i,a,l,u)=>Tt(d=>{if(p)return Ln;let m=c(),h=n(e=>t.onFromClient({message:e,context:l,discard:u}),{_tag:`Request`,id:m,tag:e._tag,payload:i,...r?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{},headers:o(d.getRef(Dc),a)});if(u)return h;let _;return s(Kr(t=>{let n={_tag:`Effect`,rpc:e,context:l,resume(e){t(e),_&&!_.pollUnsafe()&&d.currentDispatcher.scheduleTask(()=>{_.interruptUnsafe(d.id)},0)}};f.set(m,n),_=h.pipe(r?Wt(r,{captureStackTrace:!1}):g,ha(d.context)),_.addObserver(e=>{if(e._tag===`Failure`)return t(e)})}),e=>(f.delete(m),kr(cr(_),x(m,Array.from(e),l))))}),y=_e(function*(e,i,s,l,u,d){if(p)return yield*Ln;let m=a?void 0:yield*ot(`${r}.${e._tag}`,{attributes:t.spanAttributes}),h=qe(),_=c(),v=Ca(h.context,n),y=yield*lt(u);return yield*Mo(v,e=>(An(y),f.has(_)?(f.delete(_),x(_,Mi(e)?Array.from(es(e.cause)):[],d)):Qi)),f.set(_,{_tag:`Queue`,rpc:e,queue:y,scope:v,context:d}),yield*i(e=>t.onFromClient({message:e,context:d,discard:!1}),{_tag:`Request`,id:_,tag:e._tag,payload:s,...m?{traceId:m.traceId,spanId:m.spanId,sampled:m.sampled}:{},headers:o(h.getRef(Dc),l)}).pipe(m?Wt(m,{captureStackTrace:!1}):g,Sr(e=>ws(y,e)),$n,dn(v,{startImmediately:!0})),y}),b=e=>{let t=[];for(let n of e.middlewares.values()){let e=ti(l,`${n.key}/Client`);e&&t.push(e)}return t.length===0?(e,t)=>e(t):function n(r,i,a=t.length-1){return a===-1?r(i):t[a]({rpc:e,request:i,next(e){return n(r,e,a-1)}})}},x=(e,n,r)=>Kr(i=>{let a=qe();t.onFromClient({message:{_tag:`Interrupt`,requestId:e,interruptors:n},context:r,discard:!1}).pipe(mn(1e3),ha(a.context)).addObserver(()=>{i(Qi)})}),S=e=>{switch(e._tag){case`Chunk`:{let n=e.requestId,r=f.get(n);return!r||r._tag!==`Queue`?Qi:_(r.queue,e.values).pipe(i?jt(()=>t.onFromClient({message:{_tag:`Ack`,requestId:e.requestId},context:r.context,discard:!1})):g,fs(e=>ws(r.queue,e)))}case`Exit`:{let t=e.requestId,n=f.get(t);return n?(f.delete(t),n._tag===`Effect`?(n.resume(e.exit),Qi):e.exit._tag===`Success`?an(n.queue):ws(n.queue,e.exit.cause)):Qi}case`Defect`:return m(Si(e.defect));case`ClientEnd`:return Qi}},C;if(t.flatten){let t=new Map;C=function(n,r,i){let a=t.get(n);return a||(a=h(e.requests.get(n)),t.set(n,a)),a(r,i)}}else C={},e.requests.forEach(e=>{kn(C,e._tag,h(e))});return{client:C,write:S}}),wc=0,Tc=_e(function*(e,t){let n=wc++,{codecFor:r,run:i,send:a,supportsAck:o,supportsTransferables:s}=yield*Oc,c=Ec(r),l=na(r(wi())),u=new Map,d=e=>u.has(e)?(u.delete(e),a(n,{_tag:`Interrupt`,requestId:e})):Qi,{client:f,write:p}=yield*Cc(e,{...t,supportsAck:o,onFromClient({message:t}){switch(t._tag){case`Request`:{let r=e.requests.get(t.tag),i=s?lc():void 0,o=qe(),l={rpc:r,context:i?zr(o.context,cc,i):o.context,schemas:c(r)};return u.set(t.id,l),l.schemas.encodePayload(t.payload).pipe(uo(l.context),di,jt(e=>a(n,{...t,id:t.id,payload:e,headers:Object.entries(t.headers)},i&&i.readUnsafe())))}case`Ack`:return u.get(t.requestId)?a(n,{_tag:`Ack`,requestId:t.requestId}):Qi;case`Interrupt`:return d(t.requestId);case`Eof`:return Qi}}});return yield*i(n,e=>{switch(e._tag){case`Chunk`:{let t=mc(e.requestId),n=u.get(t);if(!n||Ri(n.schemas.decodeChunk))return Qi;let r=n.schemas.decodeChunk.value;return Ft(i=>i(r(e.values).pipe(uo(n.context),di,jt(e=>p({_tag:`Chunk`,clientId:0,requestId:t,values:e})))).pipe(Sr(e=>p({_tag:`Exit`,clientId:0,requestId:t,exit:Ea(e)}).pipe(kr(gn(e)?Qi:Kn(d(t))))),yn(e=>!gn(e),()=>Qi)))}case`Exit`:{let t=mc(e.requestId),n=u.get(t);return n?(u.delete(t),n.schemas.decodeExit(e.exit).pipe(uo(n.context),di,pr({onSuccess:e=>p({_tag:`Exit`,clientId:0,requestId:t,exit:e}),onFailure:e=>p({_tag:`Exit`,clientId:0,requestId:t,exit:Ea(e)})}))):Qi}case`Defect`:return p({_tag:`Defect`,clientId:0,defect:l(e.defect)});case`ClientProtocolError`:{let t=Ja(e.error);return Ge(Array.from(u.keys()),e=>p({_tag:`Exit`,clientId:0,requestId:e,exit:t}))}default:return Qi}}).pipe(fs(De),$n,ks),f}),Ec=e=>{let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=_s(n.successSchema);return r={decodeChunk:Xo(i,t=>kt(e(Dr(t.success)))),encodePayload:Ue(e(n.payloadSchema)),decodeExit:kt(e(Go(n)))},t.set(n,r),r}},Dc=yo(`effect/rpc/RpcClient/CurrentHeaders`,{defaultValue:()=>xr}),Oc=class extends Yi()(`effect/rpc/RpcClient/Protocol`){static make=xc},kc=e=>Oc.make(_e(function*(t,n){let r=yield*Hs,i=yield*yc,a=yield*Ta(Mc),o=new Map,s=yield*r.writer,c=i.makeUnsafe(),l=yield*jc(wr(()=>s.write(c.encode(hc)))),u,d=e=>Ge(n,n=>t(n,e)),f=e=>(u=e,d({_tag:`ClientProtocolError`,error:e})),p=e=>{try{let n=c.decode(e);if(n.length===0)return Qi;let r=0;return vt({while:()=>r<n.length,body:()=>{let e=n[r++];if(e._tag===`Pong`)return l.onPong(),Qi;if(Object.hasOwn(e,`requestId`)){let n=e.requestId,r=o.get(n);if(r!==void 0)return e._tag===`Exit`&&o.delete(n),t(r,e)}return d(e)},step:Ht})}catch(e){return d({_tag:`ClientProtocolError`,error:new pc({reason:new fc({message:`Error decoding message`,cause:e})})})}};return yield*wr(()=>(c=i.makeUnsafe(),l.reset(),C(function*(){let{pull:e}=yield*r.reader;for(u=void 0,jr(a)&&(yield*a.value.onConnect);;){let t=yield*e;for(let e=0;e<t.length;e++)yield*p(t[e])}}).pipe(qa,Nr(jt(l.timeout,()=>W(new tc({reason:new Ys({cause:Error(`ping timeout`)})}))))))).pipe(jr(a)?h(a.value.onDisconnect):g,Vr(t=>{let n=ls(t),r=Io(n),i=new pc({reason:r?n.success.reason:new fc({message:`Unknown socket error`,cause:wn(t)})});return e?.retryTransientErrors&&r&&n.success.reason._tag===`SocketOpenError`?(e.onTransientError?.(i)??Qi).pipe(Fe({log:!0,message:`RpcClient onTransientError hook failed`})):f(i)}),xo(e?.retryPolicy??Ac,e=>f(new pc({reason:e.reason}))),Jo({module:`RpcClient`,method:`makeProtocolSocket`}),ks),{send(e,t){if(u)return W(u);t._tag===`Request`&&o.set(t.id,e);let n=c.encode(t);return n===void 0?Qi:di(s.write(n))},supportsAck:!0,supportsTransferables:!1,codecFor:i.codecFor}})),Ac=on([ze(500,1.5),v(5e3)]),jc=_e(function*(e){let t=!0,n=et();return yield*wr(()=>t?(t=!1,e):n.open).pipe(Vt(`5 seconds`),Kn,mt,$n,ks),{timeout:n.await,reset:()=>{t=!0,n.closeUnsafe()},onPong:()=>{t=!0}}}),Mc=class extends Yi()(`effect/rpc/RpcClient/ConnectionHooks`){},Z=e(Tr(),1),Nc=Z.createContext(null);function Pc(e){return Z.useContext(Nc)}var Q=ji(),Fc=e(xi(),1),Ic=`data-open`,Lc=`data-closed`,Rc=To,zc=Ua,Bc=`data-anchor-hidden`,Vc={[go]:``},Hc={[go]:``,[qi]:``},Uc={[Ic]:``},Wc={[Lc]:``},Gc={[Bc]:``},Kc={open(e){return e?Vc:null}},qc={open(e){return e?Hc:null}},Jc={open(e){return e?Uc:Wc},anchorHidden(e){return e?Gc:null}},Yc={...Jc,...Lr};function Xc(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...Xc(e,t.id,n)])}function Zc(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 Qc(e){e.preventDefault(),e.stopPropagation()}function $c(e){return`nativeEvent`in e}function el(e){return e.pointerType===``&&e.isTrusted?!0:qo&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function tl(e){return Fi?!1:!qo&&e.width===0&&e.height===0||qo&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function nl(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function rl(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}var il=Math.min,al=Math.max,ol=Math.round,sl=Math.floor,cl=e=>({x:e,y:e}),ll={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function ul(e,t,n){return al(e,il(t,n))}function dl(e,t){return typeof e==`function`?e(t):e}function fl(e){return e.split(`-`)[0]}function pl(e){return e.split(`-`)[1]}function ml(e){return e===`x`?`y`:`x`}function hl(e){return e===`y`?`height`:`width`}function gl(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function _l(e){return ml(gl(e))}function vl(e,t,n){n===void 0&&(n=!1);let r=pl(e),i=_l(e),a=hl(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Dl(o)),[o,Dl(o)]}function yl(e){let t=Dl(e);return[bl(e),t,bl(t)]}function bl(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var xl=[`left`,`right`],Sl=[`right`,`left`],Cl=[`top`,`bottom`],wl=[`bottom`,`top`];function Tl(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Sl:xl:t?xl:Sl;case`left`:case`right`:return t?Cl:wl;default:return[]}}function El(e,t,n,r){let i=pl(e),a=Tl(fl(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(bl)))),a}function Dl(e){let t=fl(e);return ll[t]+e.slice(t.length)}function Ol(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function kl(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Ol(e)}function Al(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 jl(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function Ml(e){let t=tn(Nl,e).current;return t.next=e,q(t.effect),t}function Nl(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Pl=0;function Fl(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(Pl);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),ja;let o=requestAnimationFrame(a);return Pl=o,()=>{Pl===o&&(cancelAnimationFrame(o),Pl=0)}}var Il={inert:new WeakMap,"aria-hidden":new WeakMap},Ll=`data-base-ui-inert`,Rl={inert:new WeakSet,"aria-hidden":new WeakSet},zl=new WeakMap,Bl=0;function Vl(e){return Rl[e]}function Hl(e){return e?Pe(e)?e.host:Hl(e.parentNode):null}var Ul=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=Hl(t);return e.contains(n)?n:null}).filter(e=>e!=null),Wl=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},Gl=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{St(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function Kl(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=Ul(t,e),l=i?Gl(t,Wl(c),new Set(c)):[],u=[],d=[];if(a){let e=Il[a],n=Vl(a);s=n,o=e;let r=Ul(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);Gl(t,Wl(i),new Set(i)).forEach(t=>{let r=t.getAttribute(a),i=r!==null&&r!==`false`,o=(e.get(t)||0)+1;e.set(t,o),u.push(t),o===1&&i&&n.add(t),i||t.setAttribute(a,a===`inert`?``:`true`)})}return i&&l.forEach(e=>{let t=(zl.get(e)||0)+1;zl.set(e,t),d.push(e),t===1&&e.setAttribute(Ll,``)}),Bl+=1,()=>{o&&u.forEach(e=>{let t=(o.get(e)||0)-1;o.set(e,t),t||(!s?.has(e)&&a&&e.removeAttribute(a),s?.delete(e))}),i&&d.forEach(e=>{let t=(zl.get(e)||0)-1;zl.set(e,t),t||e.removeAttribute(Ll)}),--Bl,Bl||(Il.inert=new WeakMap,Il[`aria-hidden`]=new WeakMap,Rl.inert=new WeakSet,Rl[`aria-hidden`]=new WeakSet,zl=new WeakMap)}}function ql(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=ce(e[0]).body;return Kl(e,a,n,r,{mark:i})}function Jl(){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 Yl=class{nodesRef={current:[]};events=Jl();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)}},Xl=Z.createContext(null),Zl=Z.createContext(null),Ql=()=>Z.useContext(Xl)?.id||null,$l=e=>{let t=Z.useContext(Zl);return e??t};function eu(e){let t=Ni(),n=$l(e),r=Ql();return q(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function tu(e){let{children:t,id:n}=e,r=Ql();return(0,Q.jsx)(Xl.Provider,{value:Z.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function nu(e){let{children:t,externalTree:n}=e,r=tn(()=>n??new Yl).current;return(0,Q.jsx)(Zl.Provider,{value:r,children:t})}function ru(e,t){let n=We(Hi(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var iu=20,au=[];function ou(){au=au.filter(e=>e.deref()?.isConnected)}function su(e){ou(),e&&St(e)!==`body`&&(au.push(new WeakRef(e)),au.length>iu&&(au=au.slice(-20)))}function cu(){return ou(),au[au.length-1]?.deref()}function lu(e){return e?x(e)?e:Un(e)[0]||e:null}function uu(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=qt(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return x(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 du(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:o=!0,restoreFocus:s=!1,modal:l=!0,closeOnFocusOut:u=!0,openInteractionType:d=``,nextFocusableElement:f,previousFocusableElement:m,beforeContentFocusGuardRef:h,externalTree:g,getInsideElements:_}=e,v=`rootStore`in t?t.rootStore:t,y=v.useState(`open`),b=v.useState(`domReferenceElement`),S=v.useState(`floatingElement`),{events:C,dataRef:w}=v.context,T=Y(()=>w.current.floatingContext?.nodeId),E=i===!1,D=a(b)&&E,O=Ml(i),k=Ml(o),A=Ml(d),j=Ml(y),M=$l(g),N=st(),P=Z.useRef(!1),F=Z.useRef(!1),I=Z.useRef(!1),L=Z.useRef(null),R=Z.useRef(``),z=Z.useRef(``),B=Z.useRef(null),ee=Z.useRef(null),te=p(B,h,N?.beforeInsideRef),ne=p(ee,N?.afterInsideRef),re=vn(),ie=vn(),ae=ns(),oe=N!=null,H=Xe(S),se=Y((e=H)=>e?Un(e):[]),le=Y(()=>_?.().filter(e=>e!=null)??[]);Z.useEffect(()=>{if(r||!l)return;function e(e){e.key===`Tab`&&J(H,Za(ce(H)))&&se().length===0&&!D&&Qc(e)}let t=ce(H);return En(t,`keydown`,e)},[r,H,l,D,se]),Z.useEffect(()=>{if(r||!y)return;let e=ce(H);function t(){I.current=!1}function n(e){let t=Hi(e),n=le(),r=J(S,t)||J(b,t)||J(N?.portalNode,t)||n.some(e=>e===t||J(e,t));I.current=!r,z.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(F.current=!0,ie.start(0,()=>{F.current=!1}))}function i(){z.current=`keyboard`}return V(En(e,`pointerdown`,n,!0),En(e,`pointerup`,t,!0),En(e,`pointercancel`,t,!0),En(e,`keydown`,i,!0),t)},[r,S,b,H,y,N,ie,le]),Z.useEffect(()=>{if(r||!u)return;let e=ce(H);function t(){F.current=!0,ie.start(0,()=>{F.current=!1})}function n(e){let t=Hi(e);x(t)&&(L.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=Hi(t);l&&n==null&&i!=null&&J(S,i)&&su(i),queueMicrotask(()=>{let a=T(),o=v.context.triggerElements,u=le(),d=n?.hasAttribute(co(`focus-guard`))&&[B.current,ee.current,N?.beforeInsideRef.current,N?.afterInsideRef.current,N?.beforeOutsideRef.current,N?.afterOutsideRef.current,Tn(m),Tn(f)].includes(n),p=!(J(b,n)||J(S,n)||J(n,S)||J(N?.portalNode,n)||u.some(e=>e===n||J(e,n))||o.hasMatchingElement(e=>J(e,n))||d||M&&(Xc(M.nodesRef.current,a).find(e=>J(e.context?.elements.floating,n)||J(e.context?.elements.domReference,n))||Zc(M.nodesRef.current,a).find(e=>[e.context?.elements.floating,Xe(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===b&&H&&uu(H),s&&r!==b&&!we(i)&&Za(e)===e.body){if(Os(H)&&(H.focus(),s===`popup`)){ae.request(()=>{H.focus()});return}let e=se(),t=L.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||H;Os(n)&&n.focus()}if(w.current.insideReactTree){w.current.insideReactTree=!1;return}(D||!l)&&n&&p&&!F.current&&(D||n!==cu())&&(P.current=!0,v.setOpen(!1,Qe(c,t)))})}function a(){I.current||(w.current.insideReactTree=!0,re.start(0,()=>{w.current.insideReactTree=!1}))}let o=Os(b)?b:null;if(S||o)return V(o&&En(o,`focusout`,i),o&&En(o,`pointerdown`,t),S&&En(S,`focusin`,n),S&&En(S,`focusout`,i),S&&N&&En(S,`focusout`,a,!0))},[r,b,S,H,l,M,N,v,u,s,se,D,T,w,re,ie,ae,f,m,le]),Z.useEffect(()=>{if(r||!S||!y)return;let e=Array.from(N?.portalNode?.querySelectorAll(`[${co(`portal`)}]`)||[]),t=(M?Zc(M.nodesRef.current,T()):[]).find(e=>a(e.context?.elements.domReference||null))?.context?.elements.domReference,n=ql([S,...e,B.current,ee.current,N?.beforeOutsideRef.current,N?.afterOutsideRef.current,...le(),t,Tn(m),Tn(f),D?b:null].filter(e=>e!=null),{ariaHidden:l||D,mark:!1}),i=ql([S,...e].filter(e=>e!=null));return()=>{i(),n()}},[y,r,b,S,l,N,D,M,T,f,m,le]),q(()=>{if(!y||r||!Os(H))return;R.current=``,z.current=``;let e=ce(H),t=Za(e);queueMicrotask(()=>{let n=O.current,r=typeof n==`function`?n(A.current||``):n;if(r===void 0||r===!1||J(H,t))return;let i=null,a=()=>(i??=se(H),i[0]||H),o;o=r===!0||r===null?a():Tn(r),o||=a();let s=J(H,Za(e));Fl(o,{preventScroll:o===H,shouldFocus(){if(!j.current)return!1;if(s)return!0;let t=Za(e);return!(t!==o&&J(H,t))}})})},[r,y,H,se,O,A,j]),q(()=>{if(r||!H)return;let e=ce(H),t=Za(e),n=A.current==null;su(t);function i(e){if(e.open||(R.current=ru(e.nativeEvent,z.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(P.current=!0),e.reason===`outside-press`){if(e.nested)P.current=!1;else if(el(e.nativeEvent)||tl(e.nativeEvent))P.current=!1;else{let e=!1;ce(H).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?P.current=!1:P.current=!0}}}C.on(`openchange`,i);function a(e){let r=k.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=b?.isConnected?b:null,o=t?.isConnected&&St(t)!==`body`?t:null,s=n?o||a:a||o;return s||=cu()||null,typeof i==`boolean`?s:Tn(i)||s||null}return()=>{C.off(`openchange`,i);let t=Za(e),n=le(),r=J(S,t)||n.some(e=>e===t||J(e,t))||M&&Xc(M.nodesRef.current,T(),!1).some(e=>J(e.context?.elements.floating,t)),o=k.current,s=R.current,c=a(s);queueMicrotask(()=>{let n=lu(c),i=typeof o!=`boolean`;if(o&&!P.current&&Os(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}P.current=!1})}},[r,S,H,k,A,C,M,b,T,le]),q(()=>{if(!Or||y||!S)return;let e=Za(ce(S));Os(e)&&hi(e)&&J(S,e)&&e.blur()},[y,S]),q(()=>{if(!r&&N)return N.setFocusManagerState({modal:l,closeOnFocusOut:u,open:y,onOpenChange:v.setOpen,domReference:b}),()=>{N.setFocusManagerState(null)}},[r,N,l,y,v,u,b]),q(()=>{if(!r&&H)return uu(H),()=>{queueMicrotask(ou)}},[r,H]);let ue=!r&&(!l||!D)&&(oe||l);return(0,Q.jsxs)(Z.Fragment,{children:[ue&&(0,Q.jsx)(ta,{"data-type":`inside`,ref:te,onFocus:e=>{if(l){let e=se();Fl(e[e.length-1])}else N?.portalNode&&(P.current=!1,Ds(e,N.portalNode)?he(b)?.focus():Tn(m??N.beforeOutsideRef)?.focus())}}),n,ue&&(0,Q.jsx)(ta,{"data-type":`inside`,ref:ne,onFocus:e=>{l?Fl(se()[0]):N?.portalNode&&(u&&(P.current=!0),Ds(e,N.portalNode)?He(b)?.focus():Tn(f??N.afterOutsideRef)?.focus())}})]})}function fu(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=zo}=t,l=`rootStore`in e?e.rootStore:e,u=l.context.dataRef,d=Z.useRef(void 0),f=ns(),p=vn(),m=Z.useMemo(()=>{function e(e,t,n,r){let i=Qe(c,t,n);e&&r===`touch`&&s>0?p.start(s,()=>{l.setOpen(!0,i)}):l.setOpen(e,i)}function t(e,t,n){let r=u.current.openEvent,a=l.select(`domReferenceElement`)!==t;return e&&a||!e||!i?!0:r&&o?!n(r.type):!1}return{onPointerDown(e){d.current=nl(e.pointerType,!0)&&tl(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(n){let i=d.current,o=n.nativeEvent,s=l.select(`open`);if(n.button!==0||r===`click`||nl(i,!0)&&a)return;let c=t(s,n.currentTarget,e=>e===`click`||e===`mousedown`),u=Hi(o);if(hi(u)){e(c,o,u,i);return}let p=n.currentTarget;f.request(()=>{e(c,o,p,i)})},onClick(n){if(r===`mousedown-only`)return;let i=d.current;if(r===`mousedown`&&i){d.current=void 0;return}nl(i,!0)&&a||e(t(l.select(`open`),n.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),n.nativeEvent,n.currentTarget,i)},onKeyDown(){d.current=void 0}}},[u,r,a,c,l,o,i,f,p,s]);return Z.useMemo(()=>n?{reference:m}:jo,[n,m])}function pu(){return!1}function mu(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function hu(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=pu,bubbles:s,externalTree:c}=t,l=`rootStore`in e?e.rootStore:e,u=l.useState(`open`),d=l.useState(`floatingElement`),{dataRef:f,events:p}=l.context,m=$l(c),h=Y(typeof i==`function`?i:()=>!1),g=typeof i==`function`?h:i,_=g!==!1,v=Y(()=>a),{escapeKey:y,outsidePress:b}=mu(s),x=Z.useRef(!1),C=Z.useRef(!1),w=Z.useRef(!1),T=Z.useRef(!1),E=Z.useRef(!1),D=Z.useRef(``),O=Z.useRef(null),k=vn(),A=vn(),j=Y(()=>{A.clear(),f.current.insideReactTree=!1}),M=Y(e=>{let t=f.current.floatingContext?.nodeId;return(m?Xc(m.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),N=Y(e=>fr(e,l.select(`floatingElement`))||fr(e,l.select(`domReferenceElement`))),P=Y(e=>{o()&&l.setOpen(!1,Qe(zo,e.nativeEvent))}),F=Y(e=>{if(!u||!n||!r||e.key!==`Escape`||E.current||!y&&M(`__escapeKeyBubbles`))return;let t=$c(e)?e.nativeEvent:e,i=Qe(rn,t);l.setOpen(!1,i),i.isCanceled||e.preventDefault(),!y&&!i.isPropagationAllowed&&e.stopPropagation()}),I=Y(()=>{f.current.insideReactTree=!0,A.start(0,j)}),L=Y(e=>{if(!u||!n||e.button!==0)return;let t=Hi(e.nativeEvent);J(l.select(`floatingElement`),t)&&(x.current||(x.current=!0,C.current=!1))}),R=Y(e=>{u&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&x.current&&(C.current=!0)});Z.useEffect(()=>{function e(e){e.open||(T.current=!1)}return p.on(`openchange`,e),()=>{p.off(`openchange`,e)}},[p]),Z.useEffect(()=>{if(!u||!n)return u||(T.current=!1),j;f.current.__escapeKeyBubbles=y,f.current.__outsidePressBubbles=b;let e=new ds,t=new ds,i=ce(d);function a(){e.clear(),E.current=!0}function o(){e.start(Or?5:0,()=>{E.current=!1})}function s(){w.current=!0,t.start(0,()=>{w.current=!1})}function c(){x.current=!1,C.current=!1}function p(){let e=D.current,t=e===`pen`||!e?`mouse`:e,n=v(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function h(e){let t=p();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function A(e){let t=f.current.floatingContext?.nodeId,n=m&&Xc(m.nodesRef.current,t).some(t=>fr(e,t.context?.elements.floating));return N(e)||n}function P(e){if(h(e)){e.type!==`click`&&!N(e)&&(t.clear(),w.current=!1),j();return}if(f.current.insideReactTree){j();return}let n=Hi(e),r=`[${co(`inert`)}]`,i=un(n)?n.getRootNode():null,a=Array.from((Pe(i)?i:ce(l.select(`floatingElement`))).querySelectorAll(r)),o=l.context.triggerElements;if(n&&(o.hasElement(n)||o.hasMatchingElement(e=>J(e,n))))return;let s=un(n)?n:null;for(;s&&!S(s);){let e=ge(s);if(S(e)||!un(e))break;s=e}if(!(a.length&&un(n)&&!br(n)&&!J(n,l.select(`floatingElement`))&&a.every(e=>!J(s,e)))){if(Os(n)&&!(`touches`in e)){let t=S(n),r=Bt(n),i=/auto|scroll/,a=t||i.test(r.overflowX),o=t||i.test(r.overflowY),s=a&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=o&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l=r.direction===`rtl`,u=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),d=s&&e.offsetY>n.clientHeight;if(u||d)return}if(!A(e)){if(p()===`intentional`){if(e.detail!==0&&!el(e)&&!T.current)return;if(w.current){t.clear(),w.current=!1;return}}(typeof g!=`function`||g(e))&&(M(`__outsidePressBubbles`)||(l.setOpen(!1,Qe(Ha,e)),j()))}}}function I(e){p()===`sloppy`&&e.pointerType!==`touch`&&l.select(`open`)&&n&&!N(e)&&P(e)}function L(e){if(p()!==`sloppy`||!l.select(`open`)||!n||N(e))return;let t=e.touches[0];t&&(O.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},k.start(1e3,()=>{O.current&&(O.current.dismissOnTouchEnd=!1,O.current.dismissOnMouseDown=!1)}))}function R(e,t){let n=Hi(e);if(!n)return;let r=En(n,e.type,()=>{t(e),r()})}function z(e){D.current=`touch`,R(e,L)}function B(e){k.clear(),e.type===`pointerdown`&&(e.button===0&&(T.current=!0),D.current=e.pointerType),(e.type!==`mousedown`||!O.current||O.current.dismissOnMouseDown)&&R(e,e=>{e.type===`pointerdown`?I(e):P(e)})}function ee(e){if(e.type===`pointercancel`&&(T.current=!1),!x.current)return;let n=C.current;if(c(),p()===`intentional`){if(e.type===`pointercancel`){n&&s();return}if(!A(e)){if(n){s();return}(typeof g!=`function`||g(e))&&(t.clear(),w.current=!0,j())}}}function te(e){if(p()!==`sloppy`||!O.current||N(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-O.current.startX),r=Math.abs(t.clientY-O.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(O.current.dismissOnTouchEnd=!0),i>10&&(P(e),k.clear(),O.current=null)}function ne(e){R(e,te)}function re(e){p()===`sloppy`&&O.current&&!N(e)&&(O.current.dismissOnTouchEnd&&P(e),k.clear(),O.current=null)}function ie(e){R(e,re)}let ae=V(r&&V(En(i,`keydown`,F),En(i,`compositionstart`,a),En(i,`compositionend`,o)),_&&V(En(i,`click`,B,!0),En(i,`pointerdown`,B,!0),En(i,`pointerup`,ee,!0),En(i,`pointercancel`,ee,!0),En(i,`mousedown`,B,!0),En(i,`mouseup`,ee,!0),En(i,`touchstart`,z,{capture:!0,passive:!0}),En(i,`touchmove`,ne,{capture:!0,passive:!0}),En(i,`touchend`,ie,{capture:!0,passive:!0})));return()=>{ae(),e.clear(),t.clear(),c(),w.current=!1,j()}},[f,d,r,_,g,u,n,y,b,F,j,v,M,N,m,l,k]);let z=Z.useMemo(()=>({onKeyDown:F,onPointerDown:P,onClick:P}),[F,P]),B=Z.useMemo(()=>({onKeyDown:F,onPointerDown:R,onMouseDown:R,onClickCapture:I,onMouseDownCapture(e){I(),L(e)},onPointerDownCapture(e){I(),L(e)},onMouseUpCapture:I,onTouchEndCapture:I,onTouchMoveCapture:I}),[F,I,L,R]);return Z.useMemo(()=>n?{reference:z,floating:B,trigger:z}:{},[n,z,B])}function gu(e,t,n){let{reference:r,floating:i}=e,a=gl(t),o=_l(t),s=hl(o),c=fl(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=pl(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function _u(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}=dl(t,e),p=kl(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Al(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=Al(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 vu=50,yu=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:_u},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=gu(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<vu&&(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}=gu(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},bu=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}=dl(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=fl(r),_=gl(o),v=fl(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Dl(o)]:yl(o)),x=p!==`none`;!d&&x&&b.push(...El(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=vl(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`||_===gl(t)||T.every(e=>gl(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=gl(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{}}}},xu=new Set([`left`,`top`]);async function Su(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=fl(n),s=pl(n),c=gl(n)===`y`,l=xu.has(o)?-1:1,u=a&&c?-1:1,d=dl(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 Cu=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 Su(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}}}}},wu=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}=dl(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=gl(i),p=ml(f),m=u[p],h=u[f],g=(e,t)=>ul(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}}}}}},Tu=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}=dl(e,t),u={x:n,y:r},d=gl(i),f=ml(d),p=u[f],m=u[d],h=dl(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=xu.has(fl(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}}}},Eu=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}=dl(e,t),c=await i.detectOverflow(t,s),l=fl(n),u=pl(n),d=gl(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=il(p-c[m],g),y=il(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*al(c.left,c.right):S=p-2*al(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 Du(e){let t=Bt(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Os(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=ol(n)!==a||ol(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Ou(e){return un(e)?e:e.contextElement}function ku(e){let t=Ou(e);if(!Os(t))return cl(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Du(t),o=(a?ol(n.width):n.width)/r,s=(a?ol(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Au=cl(0);function ju(e){let t=We(e);return!Ee()||!t.visualViewport?Au:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Mu(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===We(e)}function Nu(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Ou(e),o=cl(1);t&&(r?un(r)&&(o=ku(r)):o=ku(e));let s=Mu(a,n,r)?ju(a):cl(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=We(a),t=un(r)?We(r):r,n=e,i=ra(n);for(;i&&t!==n;){let e=ku(i),t=i.getBoundingClientRect(),r=Bt(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=We(i),i=ra(n)}}return Al({width:u,height:d,x:c,y:l})}function Pu(e,t){let n=At(e).scrollLeft;return t?t.left+n:Nu(m(e)).left+n}function Fu(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Pu(e,n),y:n.top+t.scrollTop}}function Iu(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=m(r),s=t?Qn(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=cl(1),u=cl(0),d=Os(r);if((d||!a)&&((St(r)!==`body`||Gn(o))&&(c=At(r)),d)){let e=Nu(r);l=ku(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Fu(o,c):cl(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 Lu(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ru(e){let t=At(e),n=e.ownerDocument.body,r=al(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=al(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Pu(e),o=-t.scrollTop;return Bt(n).direction===`rtl`&&(a+=al(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var zu=25;function Bu(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=We(e),a=m(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Ee()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Pu(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<=zu&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Vu(e,t){let n=Nu(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=ku(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Hu(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Bu(e,n,t);else if(t===`document`)r=Ru(m(e));else if(un(t))r=Vu(t,n);else{let n=ju(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Al(r)}function Uu(e,t){let n=t.get(e);if(n)return n;let r=Jt(e,[],!1).filter(e=>un(e)&&St(e)!==`body`),i=null,a=Bt(e).position===`fixed`,o=a?ge(e):e;for(;un(o)&&!S(o);){let e=Bt(o),t=pt(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=ge(o)}return t.set(e,r),r}function Wu(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Qn(t)?[]:Uu(t,this._c):[].concat(n),r],o=Hu(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=Hu(t,a[e],i);s=al(n.top,s),c=il(n.right,c),l=il(n.bottom,l),u=al(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Gu(e){let{width:t,height:n}=Du(e);return{width:t,height:n}}function Ku(e,t,n){let r=Os(t),i=m(t),a=n===`fixed`,o=Nu(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=cl(0);if((r||!a)&&((St(t)!==`body`||Gn(i))&&(s=At(t)),r)){let e=Nu(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Pu(i));let l=i&&!r&&!a?Fu(i,s):cl(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 qu(e){return Bt(e).position===`static`}function Ju(e,t){if(!Os(e)||Bt(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return m(e)===n&&(n=n.ownerDocument.body),n}function Yu(e,t){let n=We(e);if(Qn(e))return n;if(!Os(e)){let t=ge(e);for(;t&&!S(t);){if(un(t)&&!qu(t))return t;t=ge(t)}return n}let r=Ju(e,t);for(;r&&In(r)&&qu(r);)r=Ju(r,t);return r&&S(r)&&qu(r)&&!pt(r)?n:r||da(e)||n}var Xu=async function(e){let t=this.getOffsetParent||Yu,n=this.getDimensions,r=await n(e.floating);return{reference:Ku(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Zu(e){return Bt(e).direction===`rtl`}var Qu={convertOffsetParentRelativeRectToViewportRelativeRect:Iu,getDocumentElement:m,getClippingRect:Wu,getOffsetParent:Yu,getElementRects:Xu,getClientRects:Lu,getDimensions:Gu,getScale:ku,isElement:un,isRTL:Zu};function $u(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ed(e,t,n){let r=null,i,a=m(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=sl(d),h=sl(a.clientWidth-(u+f)),g=sl(a.clientHeight-(d+p)),_=sl(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:al(0,il(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!$u(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=We(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function td(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Ou(e),u=i||a?[...l?Jt(l):[],...t?Jt(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?ed(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?Nu(e):null;c&&g();function g(){let t=Nu(e);h&&!$u(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 nd=Cu,rd=wu,id=bu,ad=Eu,od=Tu,sd=(e,t,n)=>{let r=new Map,i=n??{},a={...Qu,...i.platform,_c:r};return yu(e,t,{...i,platform:a})},cd=typeof document<`u`?Z.useLayoutEffect:function(){};function ld(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(!ld(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)&&!ld(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function ud(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function dd(e,t){let n=ud(e);return Math.round(t*n)/n}function fd(e){let t=Z.useRef(e);return cd(()=>{t.current=e}),t}function pd(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=Z.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=Z.useState(r);ld(f,r)||p(r);let[m,h]=Z.useState(null),[g,_]=Z.useState(null),v=Z.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=Z.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=Z.useRef(null),C=Z.useRef(null),w=Z.useRef(u),T=c!=null,E=fd(c),D=fd(i),O=fd(l),k=Z.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),sd(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!ld(w.current,t)&&(w.current=t,Fc.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);cd(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=Z.useRef(!1);cd(()=>(A.current=!0,()=>{A.current=!1}),[]),cd(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=Z.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=Z.useMemo(()=>({reference:b,floating:x}),[b,x]),N=Z.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=dd(M.floating,u.x),r=dd(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...ud(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return Z.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var md=(e,t)=>{let n=nd(e);return{name:n.name,fn:n.fn,options:[e,t]}},hd=(e,t)=>{let n=rd(e);return{name:n.name,fn:n.fn,options:[e,t]}},gd=(e,t)=>({fn:od(e).fn,options:[e,t]}),_d=(e,t)=>{let n=id(e);return{name:n.name,fn:n.fn,options:[e,t]}},vd=(e,t)=>{let n=ad(e);return{name:n.name,fn:n.fn,options:[e,t]}},yd={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},bd=class extends at{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:Jl(),nested:n,triggerElements:i},yd),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&rl(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)=>{if(this.syncOnly){this.context.onOpenChange?.(e,t);return}this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function xd(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=t.context.triggerElements,d=o,f=Z.useRef(null);r===void 0&&f.current===null&&(f.current=new bd({open:s,transitionStatus:void 0,referenceElement:c,floatingElement:l,triggerElements:u,onOpenChange:d,floatingId:i,syncOnly:!0,nested:a}));let p=r??f.current;return t.useSyncedValue(`floatingId`,i),q(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};un(c)&&(e.domReferenceElement=c),p.state.positionReference===p.state.referenceElement&&(e.positionReference=c),p.update(e)},[s,i,c,l,p]),p.context.onOpenChange=d,p.context.nested=a,p}function Sd(e,t=!1,n=!1,r=!1){let[i,a]=Z.useState(e&&t?`idle`:void 0),[o,s]=Z.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),q(()=>{if(!e&&o&&i!==`ending`&&n){let e=j.request(()=>{a(`ending`)});return()=>{j.cancel(e)}}},[e,o,i,n]),q(()=>{if(!e||t)return;let n=j.request(()=>{a(void 0)});return()=>{j.cancel(n)}},[t,e]),q(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=j.request(()=>{a(`idle`)});return()=>{j.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}var Cd={tabIndex:-1,[Ti]:``};function wd(e){return t=>t!==`touch`||e.current}function Td(e,t=!1){let n=Ni(),r=Ql()!=null,i=tn(()=>e(n,r)).current;return xd({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function Ed({handle:e,store:t}){return q(()=>e.attachStore(t),[e,t]),null}function Dd(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function Od(e,t){let n=Z.useRef(null);return Y(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),Dd(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),Dd(t))})}function kd(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}}function Ad(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function jd(e,t,n,r={}){let i=n.reason,a=i===va,o=t&&i===`trigger-focus`,s=!t&&(i===`trigger-press`||i===`escape-key`),c=Ad(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let l=()=>{let i=kd(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?Fc.flushSync(l):l()}function Md(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=Od(e,n),o=Y(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e);return}if(a==null&&i){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=Y(e=>{a(e),e&&o(e)});return q(()=>(s(t.current),()=>s(null)),[s,t,n,e]),q(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function Nd(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=Z.useRef(null),i=e.useState(`open`),a=e.useState(`triggerCount`),o=e.useState(`activeTriggerId`),s=e.useState(`activeTriggerElement`);q(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0);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&&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=Qe(Ir);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,a,o,s,n])}function Pd(e,t,n,r){let{mounted:i,setMounted:a,transitionStatus:o}=Sd(e,!1,!1,r),s=t.useState(`preventUnmountingOnClose`),c=!e&&s;t.useSyncedValues({mounted:i,transitionStatus:o,preventUnmountingOnClose:c});let l=Y(()=>{a(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return k({enabled:i&&!e&&!c,open:e,ref:t.context.popupRef,onComplete(){e||l()}}),{forceUnmount:l,transitionStatus:o}}function Fd(e,t){e.useSyncedValues(t),q(()=>()=>{e.update({activeTriggerProps:jo,inactiveTriggerProps:jo,popupProps:jo})},[e])}function Id(e,t){q(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),q(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var Ld=class{constructor(){this.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}};function Rd(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=Ni(),a=Ql()!=null,o=tn(()=>new bd({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Ld,floatingId:i,syncOnly:!1,nested:a})).current;return q(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=un(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}function zd(e){return Bd(e,e.rootContext)}function Bd(e,t){let{nodeId:n,externalTree:r}=e,i=t.useState(`referenceElement`),a=t.useState(`floatingElement`),o=t.useState(`domReferenceElement`),s=t.useState(`open`),c=t.useState(`floatingId`),[l,u]=Z.useState(null),[d,f]=Z.useState(void 0),[p,m]=Z.useState(void 0),h=Z.useRef(null),g=$l(r),_=Z.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),v=pd({...e,elements:{..._,...l&&{reference:l}}}),y=un(d)?d:null,b=p===void 0?t.state.floatingElement:p;t.useSyncedValue(`referenceElement`,d??null),t.useSyncedValue(`domReferenceElement`,d===void 0?o:y),t.useSyncedValue(`floatingElement`,b);let x=Z.useCallback(e=>{let t=un(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),v.refs.setReference(t)},[v.refs]),S=Z.useCallback(e=>{(un(e)||e===null)&&(h.current=e,f(e)),(un(v.refs.reference.current)||v.refs.reference.current===null||e!==null&&!un(e))&&v.refs.setReference(e)},[v.refs,f]),C=Z.useCallback(e=>{m(e),v.refs.setFloating(e)},[v.refs]),w=Z.useMemo(()=>({...v.refs,setReference:S,setFloating:C,setPositionReference:x,domReference:h}),[v.refs,S,C,x]),T=Z.useMemo(()=>({...v.elements,domReference:o}),[v.elements,o]),E=Z.useMemo(()=>({...v,dataRef:t.context.dataRef,open:s,onOpenChange:t.setOpen,events:t.context.events,floatingId:c,refs:w,elements:T,nodeId:n,rootStore:t}),[v,w,T,n,t,s,c]);return q(()=>{o&&(h.current=o)},[o]),q(()=>{t.context.dataRef.current.floatingContext=E;let e=g?.nodesRef.current.find(e=>e.id===n);e&&(e.context=E)}),Z.useMemo(()=>({...v,context:E,refs:w,elements:T,rootStore:t}),[v,w,T,E,t])}var Vd=`Escape`;function Hd(e){return Or&&e.movementX===0&&e.movementY===0}function Ud(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function Wd(e,t){return Ud(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Gd(e,t,n){return Ud(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Kd(e,t,n){return Ud(t,n?e===ba:e===Vo,e===$r)}function qd(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===Vd:Ud(t,n?e===Vo:e===ba,e===si)}function Jd(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:o=!0,selectedIndex:s=null,allowEscape:l=!1,loopFocus:u=!1,nested:d=!1,rtl:f=!1,virtual:p=!1,focusItemOnOpen:m=`auto`,focusItemOnHover:h=!0,openOnArrowKeyDown:g=!0,disabledIndices:_=void 0,orientation:v=`vertical`,parentOrientation:y,id:b,resetOnPointerLeave:x=!0,externalTree:S,grid:C}=t,w=C!=null,T=`rootStore`in e?e.rootStore:e,E=T.useState(`open`),D=T.useState(`floatingElement`),O=T.useState(`domReferenceElement`),k=T.context.dataRef,A=Xe(D),j=a(O),M=Ml(A),N=Ql(),P=$l(S),F=Z.useRef(m),I=Z.useRef(s??-1),L=Z.useRef(null),R=Z.useRef(!0),z=Y(e=>{i(I.current===-1?null:I.current,e)}),B=Z.useRef(!!D),ee=Z.useRef(E),V=Z.useRef(!1),te=Z.useRef(!1),ne=Z.useRef(null),re=Ml(_),ie=Ml(E),ae=Ml(s),oe=Ml(x),H=ns(),se=ns(),le=Y(()=>{function e(e){p?P?.events.emit(`virtualfocus`,e):ne.current=Fl(e,{sync:V.current,preventScroll:!0})}let t=n.current[I.current],r=te.current;t&&e(t),(V.current?e=>e():e=>H.request(e))(()=>{let i=n.current[I.current]||t;i&&(t||e(i),me&&(r||!R.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});q(()=>{k.current.orientation=v},[k,v]),q(()=>{o&&(E&&D?(I.current=s??-1,F.current&&s!=null&&(te.current=!0,z())):B.current&&(I.current=-1,z()))},[o,E,D,s,z]),q(()=>{if(o){if(!E){V.current=!1;return}if(D){if(r==null){if(V.current=!1,ae.current!=null)return;if(B.current&&(I.current=-1,le()),(!ee.current||!B.current)&&F.current&&(L.current!=null||F.current===!0&&L.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>se.request(e):queueMicrotask)(t),e+=1):(I.current=L.current==null||Gd(L.current,v,f)||d?Xn(n):Pn(n),L.current=null,z())};t()}}else rt(n.current,r)||(I.current=r,le(),te.current=!1)}}},[o,E,D,r,ae,d,n,v,f,z,le,se]),q(()=>{if(!o||D||!P||p||!B.current)return;let e=P.nodesRef.current,t=e.find(e=>e.id===N)?.context?.elements.floating,n=Za(ce(O??t??null)),r=e.some(e=>e.context&&J(e.context.elements.floating,n));t&&!r&&R.current&&t.focus({preventScroll:!0})},[o,D,O,P,N,p]),q(()=>{ee.current=E,B.current=!!D}),q(()=>{E||(L.current=null,F.current=m)},[E,m]);let ue=r!=null,de=Y(e=>{if(!ie.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(I.current!==t||r!==t)&&(I.current=t,z(e))}),fe=Y(()=>y??P?.nodesRef.current.find(e=>e.id===N)?.context?.dataRef?.current.orientation),pe=Y(()=>Xn(n,re.current)),U=Y(e=>{if(R.current=!1,V.current=!0,e.which===229||!ie.current&&e.currentTarget===M.current)return;if(d&&qd(e.key,v,f,w)){Wd(e.key,fe())||Qc(e),T.setOpen(!1,Qe(mo,e.nativeEvent)),Os(O)&&(p?P?.events.emit(`virtualfocus`,O):O.focus());return}let t=I.current,r=Xn(n,_),i=Pn(n,_);if(j||(e.key===`Home`&&(Qc(e),I.current=r,z(e)),e.key===`End`&&(Qc(e),I.current=i,z(e))),C!=null){let t=C(e,I.current,n,v,u,f,_,r,i);if(t!=null&&(I.current=t,z(e)),v===`both`)return}if(Wd(e.key,v)){if(Qc(e),E&&!p&&Za(e.currentTarget.ownerDocument)===e.currentTarget){I.current=Gd(e.key,v,f)?r:i,z(e);return}Gd(e.key,v,f)?u?t>=i?l&&t!==n.current.length?I.current=-1:(V.current=!1,I.current=r):I.current=Me(n.current,{startingIndex:t,disabledIndices:_}):I.current=Math.min(i,Me(n.current,{startingIndex:t,disabledIndices:_})):u?t<=r?l&&t!==-1?I.current=n.current.length:(V.current=!1,I.current=i):I.current=Me(n.current,{startingIndex:t,decrement:!0,disabledIndices:_}):I.current=Math.max(r,Me(n.current,{startingIndex:t,decrement:!0,disabledIndices:_})),rt(n.current,I.current)&&(I.current=-1),z(e)}}),me=Z.useMemo(()=>({onFocus(e){V.current=!0,de(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){Hd(e)||(V.current=!0,te.current=!1,h&&de(e))},onPointerLeave(e){if(!ie.current||!R.current||e.pointerType===`touch`)return;V.current=!0;let t=e.relatedTarget;if(h&&!n.current.includes(t)&&oe.current&&(ne.current?.(),ne.current=null,I.current=-1,z(e),!p)){let e=M.current,t=Za(ce(e));e&&J(e,t)&&e.focus({preventScroll:!0})}}}),[de,ie,M,h,n,z,oe,p]),he=Z.useMemo(()=>p&&E&&ue&&{"aria-activedescendant":`${b}-${r}`},[p,E,ue,b,r]),ge=Z.useMemo(()=>({...j?{}:he,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&E&&!p){let t=Hi(e.nativeEvent);if(t&&!J(M.current,t))return;Qc(e),T.setOpen(!1,Qe(c,e.nativeEvent)),Os(O)&&O.focus();return}U(e)},onPointerMove(e){Hd(e)||(R.current=!0)}}),[he,U,M,j,T,E,p,O]),_e=Z.useMemo(()=>{function e(e){T.setOpen(!0,Qe(mo,e.nativeEvent,e.currentTarget))}function t(e){m===`auto`&&el(e.nativeEvent)&&(F.current=!p)}function n(e){F.current=m,m===`auto`&&tl(e.nativeEvent)&&(F.current=!0)}return{onKeyDown(t){let n=T.select(`open`);R.current=!1;let r=t.key.startsWith(`Arrow`),i=Kd(t.key,fe(),f),a=Wd(t.key,v),o=(d?i:a)||t.key===`Enter`||t.key.trim()===``;if(p&&n)return U(t);if(n||g||!r){if(o){let e=Wd(t.key,fe());L.current=d&&e?null:t.key}if(d){i&&(Qc(t),n?(I.current=pe(),z(t)):e(t));return}a&&(ae.current!=null&&(I.current=ae.current),Qc(t),!n&&g?e(t):U(t),n&&z(t))}},onFocus(e){T.select(`open`)&&!p&&(I.current=-1,z(e))},onPointerDown:n,onPointerEnter:n,onMouseDown:t,onClick:t}},[U,m,pe,d,z,T,g,v,fe,f,ae,p]),ve=Z.useMemo(()=>({...he,..._e}),[he,_e]);return Z.useMemo(()=>o?{reference:ve,floating:ge,item:me,trigger:_e}:{},[o,ve,ge,_e,me])}function Yd(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=`rootStore`in e?e.rootStore:e,f=d.useState(`open`),p=vn(),m=Z.useRef(``),h=Z.useRef(u??i??-1),g=Z.useRef(null),_=Y(e=>{function t(e){return r?.current[e]}function c(e){let n=t(e);return n&&!we(n)||n?.matches(`:disabled`)?!1:o==null||!ao(fi,e,o)}function d(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)&&c(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(Qc(e),s?.(!0)),m.current.length>0&&m.current[0]!==` `&&d(_,m.current)===-1&&e.key!==` `&&s?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(Qc(e),s?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&c(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,s?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=d(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,s?.(!1)):(a?.(b),g.current=b)}),v=Y(e=>{let t=e.relatedTarget,n=d.select(`domReferenceElement`),r=d.select(`floatingElement`);J(n,t)||J(r,t)||(p.clear(),m.current=``,h.current=g.current,s?.(!1))});q(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``))},[f,u,p]);let y=Z.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return Z.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var Xd=Z.createContext(void 0);function Zd(){return Z.useContext(Xd)?.direction??`ltr`}var Qd=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,offsetParent:d=`real`}=dl(e,t)||{};if(l==null)return{};let f=kl(u),p={x:n,y:r},m=_l(i),h=hl(m),g=await o.getDimensions(l),_=m===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,x=a.reference[h]+a.reference[m]-p[m]-a.floating[h],S=p[m]-a.reference[m],C=d===`real`?await o.getOffsetParent?.(l):s.floating,w=s.floating[b]||a.floating[h];(!w||!await o.isElement?.(C))&&(w=s.floating[b]||a.floating[h]);let T=x/2-S/2,E=w/2-g[h]/2-1,D=Math.min(f[v],E),O=Math.min(f[y],E),k=D,A=w-g[h]-O,j=w/2-g[h]/2+T,M=ul(k,j,A),N=!c.arrow&&pl(i)!=null&&j!==M&&a.reference[h]/2-(j<k?D:O)-g[h]/2<0,P=N?j<k?j-k:j-A:0;return{[m]:p[m]+P,data:{[m]:M,centerOffset:j-M-P,...N&&{alignmentOffset:P}},reset:N}}}),$d=(e,t)=>{let{name:n,fn:r}=Qd(e);return{name:n,fn:r,options:[e,t]}},ef={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}}}},tf={sideX:`left`,sideY:`top`},nf=`--available-width`,rf=`--available-height`,af=`--anchor-width`,of=`--anchor-height`,sf=`--transform-origin`,cf=nf,lf=rf;function uf(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 df(e,t,n){let{rects:r,placement:i}=e;return{side:uf(t,fl(i),n),align:pl(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function ff(e){return pf(e,zd)}function pf(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,w]=Z.useState(null);!g&&C!==null&&w(null);let T=_.side||`flip`,E=_.align||`flip`,D=_.fallbackAxisSide||`end`,O=v?.crossAxis??!1,k=v?.rootBoundary,A=typeof n==`function`?n:void 0,j=Y(A),M=A?j:n,N=Ml(n),P=Ml(g),F=Zd()===`rtl`,I=C||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":F?`left`:`right`,"inline-start":F?`right`:`left`}[i],L=o===`center`?I:`${I}-${o}`,R=l;typeof R==`number`?R={top:R,right:R,bottom:R,left:R}:R&&={top:R.top||0,right:R.right||0,bottom:R.bottom||0,left:R.left||0};let z=+(i===`bottom`),B=+(i===`top`),ee=+(i===`right`),V=+(i===`left`),te={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:R},ne=Z.useRef(null),re=Ml(a),ie=Ml(s),ae=typeof a==`function`?0:a,oe=typeof s==`function`?0:s,H=[];p&&H.push(p),H.push(md(e=>{let t=df(e,i,F),n=typeof re.current==`function`?re.current(t):re.current,r=typeof ie.current==`function`?ie.current(t):ie.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[ae,oe,F,i]));let se=E===`none`&&T!==`shift`,le=!se&&(u||O||T===`shift`),ue=T===`none`?null:_d({...te,padding:{top:R.top+1+z,right:R.right+1+V,bottom:R.bottom+1+B,left:R.left+1+ee},mainAxis:!O&&T===`flip`,crossAxis:E===`flip`&&`alignment`,fallbackAxisSideDirection:D}),de=se?null:hd({...te,rootBoundary:k,mainAxis:E!==`none`,crossAxis:le,limiter:u||O?void 0:gd(e=>{if(!ne.current)return{};let{width:t,height:n}=ne.current.getBoundingClientRect(),r=gl(fl(e.placement)),i=r===`y`?t:n,a=r===`y`?R.left+R.right:R.top+R.bottom;return{offset:i/2+a/2}})},[te,u,O,k,R,E]);T===`shift`||E===`shift`||o===`center`?H.push(de,ue):H.push(ue,de),H.push(vd({...te,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!P.current)return;let i=e.style;i.setProperty(cf,`${t}px`),i.setProperty(lf,`${n}px`);let a=We(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(af,`${u}px`),i.setProperty(of,`${d}px`)}}),$d(e=>({element:ne.current||ce(e.elements.floating).createElement(`div`),padding:ne.current?d:0,offsetParent:`floating`}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=fl(r),u=pl(r),d=gl(l)===`y`,f=ne.current,p=typeof a==`function`?a(df(e,i,F)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return le&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(sf,d?`${m} ${h}`:`${h} ${m}`),{}}},ef,b),q(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let fe=Z.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:pe,elements:U,x:me,y:he,middlewareData:ge,update:_e,placement:ve,context:ye,isPositioned:be,floatingStyles:xe}=t({rootContext:h,open:m?g:void 0,placement:L,middleware:H,strategy:r,whileElementsMounted:m?void 0:(...e)=>td(...e,fe),nodeId:y,externalTree:S}),{sideX:Se,sideY:Ce}=ge.adaptiveOrigin||tf,we=be?r:`fixed`,Te=Z.useMemo(()=>{let e;return e=be?b?{position:we,[Se]:me,[Ce]:he}:{...xe,position:we}:{position:we,top:0,left:0},e[cf]=`100vw`,e[lf]=`100vh`,be||(e.opacity=0),e},[b,we,Se,me,Ce,he,xe,be]),Ee=Z.useRef(null);q(()=>{if(!g)return;let e=N.current,t=typeof e==`function`?e():e,n=(mf(t)?t.current:t)||null;n!==Ee.current&&(pe.setPositionReference(n),Ee.current=n)},[g,pe,M,N]),Z.useEffect(()=>{if(!g)return;let e=N.current;typeof e!=`function`&&mf(e)&&e.current!==Ee.current&&(pe.setPositionReference(e.current),Ee.current=e.current)},[g,pe,M,N]),Z.useEffect(()=>{if(m&&g&&U.reference&&U.floating)return td(U.reference,U.floating,_e,fe)},[m,g,U,_e,fe]);let De=fl(ve),Oe=uf(i,De,F),ke=pl(ve)||`center`,Ae=!!ge.hide?.referenceHidden;q(()=>{x&&g&&be&&De!==I&&w(De)},[x,g,be,De,I]);let je=Z.useMemo(()=>({position:`absolute`,top:ge.arrow?.y,left:ge.arrow?.x}),[ge.arrow]),Me=ge.arrow?.centerOffset!==0;return Z.useMemo(()=>({positionerStyles:Te,arrowStyles:je,arrowRef:ne,arrowUncentered:Me,side:Oe,align:ke,physicalSide:De,anchorHidden:Ae,refs:pe,context:ye,isPositioned:be,update:_e}),[Te,je,ne,Me,Oe,ke,De,Ae,pe,ye,be,_e])}function mf(e){return e!=null&&`current`in e}function hf(e){return e===`starting`?ys:jo}function gf(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),B(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},hf(r),i],stateAttributesMapping:Jc})}var _f={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};_f.node;var vf=As(_f),yf={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};yf.node;var bf=As(yf),xf={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};xf.node;var Sf=As(xf),Cf={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};Cf.node;var wf=As(Cf),Tf={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};Tf.node;var Ef=As(Tf),Df={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};Df.node;var Of=As(Df),kf={name:`server-off`,size:24,node:[[`path`,{d:`M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5`,key:`bt2siv`}],[`path`,{d:`M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z`,key:`1hjrv1`}],[`path`,{d:`M22 17v-1a2 2 0 0 0-2-2h-1`,key:`1iynyr`}],[`path`,{d:`M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z`,key:`161ggg`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};kf.node;var Af=As(kf),jf={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};jf.node;var Mf=As(jf),Nf={name:`shield-alert`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]};Nf.node;var Pf=As(Nf),Ff={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Ff.node;var If=As(Ff),Lf={name:`unplug`,size:24,node:[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]};Lf.node;var Rf=As(Lf);function zf(e){return Ni(e,`base-ui`)}function Bf(e){let[t,n]=Z.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}var $=ii();function Vf(e){let t=(0,$.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(window.addEventListener(`focus`,e),window.addEventListener(`online`,e),window.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),window.removeEventListener(`online`,e),window.removeEventListener(`visibilitychange`,e)}),r=[e],t[0]=e,t[1]=n,t[2]=r),(0,Z.useEffect)(n,r)}var Hf=`~effect/Cache`,Uf=(e,t)=>z(n=>{let r=Object.create(Gf);return r.lookup=t=>me(e(t),e=>Wo(n,e)),r.map=l(),r.capacity=t.capacity,r.timeToLive=t.timeToLive?(e,n)=>Hn(t.timeToLive(e,n)):Kf,Dt(r)}),Wf=e=>Uf(e.lookup,{...e,timeToLive:e.timeToLive===void 0?Kf:()=>e.timeToLive}),Gf={...P,[Hf]:Hf,toJSON(){return{_id:`Cache`,capacity:this.capacity,map:this.map}}},Kf=(e,t)=>Nn,qf=pa(2,(e,t)=>as(n=>{let r=Pt(e.map,t);if(jr(r)&&(Zi(e.map,t),!Xf(r.value,n)))return _t(e.map,t,r.value),r.value.await();let i=new Jf(n,e.lookup(t));i.onInterrupt=()=>Yf(e,t,i);let a=!1;i.fiber.addObserver(r=>{if(i.onInterrupt=void 0,Lt(r)){Yf(e,t,i);return}let o=e.timeToLive(r,t);Ce(o)?(a=!0,Yf(e,t,i)):Yn(o)&&(i.expiresAt=n.getRef(H).currentTimeMillisUnsafe()+dr(o))});let o=i.fiber.pollUnsafe();return!a&&(o===void 0||!Lt(o))&&_t(e.map,t,i),Number.isFinite(e.capacity)&&Zf(e),i.await()})),Jf=class{expiresAt;awaiters;fiber;onInterrupt;constructor(e,t){this.fiber=ea(e,t,!0,!0),this.awaiters=0,this.expiresAt=void 0}await(){return this.fiber.pollUnsafe()||(this.awaiters++,bt(f(this.fiber),()=>(this.awaiters--,this.awaiters>0||this.fiber.pollUnsafe()?Ve:(this.onInterrupt?.(),la(this.fiber)))))}},Yf=(e,t,n)=>{let r=Pt(e.map,t);jr(r)&&r.value===n&&Zi(e.map,t)},Xf=(e,t)=>e.expiresAt!==void 0&&t.getRef(H).currentTimeMillisUnsafe()>=e.expiresAt,Zf=e=>{let t=wt(e.map)-e.capacity;if(!(t<=0)){for(let[n]of e.map)if(Zi(e.map,n),t--,t===0)return}},Qf=pa(2,(e,t)=>Kt(()=>{Zi(e.map,t)})),$f=2**48-1,ep=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,tp=(e,t)=>{if(t.length!==10)throw Error(`ULID randomness must be exactly 10 bytes, received ${t.length}`);let n=Math.min(Math.max(0,Math.trunc(e)),$f),r=``;for(let e=45;e>=0;e-=5)r+=ep[Math.floor(n/2**e)&31];let i=0,a=0;for(let e of t){for(i=i<<8|e,a+=8;a>=5;)a-=5,r+=ep[i>>>a&31];i&=(1<<a)-1}return r},np=e=>e.toString(16).padStart(2,`0`),rp=e=>[e.subarray(0,4),e.subarray(4,6),e.subarray(6,8),e.subarray(8,10),e.subarray(10,16)].map(e=>Array.from(e,np).join(``)).join(`-`),ip=()=>globalThis.crypto.getRandomValues(new Uint8Array(16));function ap(e=ip()){return e[6]=e[6]&15|64,e[8]=e[8]&63|128,e}var op=e=>rp(e===void 0?ap():ap(e)),sp=2**48-1;function cp(e,t=ip()){let n=Math.min(Math.max(0,Math.trunc(e)),sp);return t[0]=Math.floor(n/2**40),t[1]=Math.floor(n/2**32)&255,t[2]=Math.floor(n/2**24)&255,t[3]=Math.floor(n/2**16)&255,t[4]=Math.floor(n/256)&255,t[5]=n&255,t[6]=t[6]&15|112,t[8]=t[8]&63|128,t}var lp=(e,t)=>rp(t===void 0?cp(e):cp(e,t)),up=`~effect/Crypto`,dp=Yi(`effect/Crypto`),fp=e=>{let t=e.randomBytes,n=e=>so(pp(`randomBytes`,e),t),r=e=>(e[0]&31)*2**48+e[1]*2**40+e[2]*2**32+e[3]*2**24+e[4]*2**16+e[5]*256+e[6],i=()=>r(t(7))/2**53,a=()=>{for(;;){let e=t(7),n=r(e);if(!(e[0]&32))return n+-(2**53-1);if(n<2**53-1)return n+1}};return dp.of({[up]:up,randomBytes:n,nextDoubleUnsafe:i,nextIntUnsafe:a,digest:e.digest,random:X(()=>i()),randomBoolean:X(()=>i()>.5),randomInt:X(()=>a()),randomBetween:(e,t)=>X(()=>Ps(e,t,i())),randomIntBetween(e,t,n){let r=n?.halfOpen===!0?0:1;return X(()=>{let n=Math.ceil(e),a=Math.floor(t);return Math.floor(i()*(a-n+r))+n})},randomShuffle:e=>X(()=>{let t=Array.from(e);for(let e=t.length-1;e>=1;--e){let n=Math.min(e,Math.floor(i()*(e+1))),r=t[e];t[e]=t[n],t[n]=r}return t}),randomUUIDv4:X(()=>op(t(16))),randomUUIDv7:Dn(e=>Ai(lp(e.currentTimeMillisUnsafe(),t(16)))),randomULID:Dn(e=>Ai(tp(e.currentTimeMillisUnsafe(),t(10))))})},pp=(e,t)=>Number.isSafeInteger(t)&&t>=0?Ai(t):W(Bs({module:`Crypto`,method:e,description:`size must be a non-negative safe integer`})),mp=`~effect/FiberMap`,hp=e=>re(e,mp),gp={[mp]:mp,[Symbol.iterator](){return this.state._tag===`Closed`?$t():this.state.backing[Symbol.iterator]()},...P,toJSON(){return{_id:`FiberMap`,state:this.state}}},_p=(e,t)=>{let n=Object.create(gp);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},vp=()=>Qa(X(()=>_p(I(),ai())),e=>wr(()=>{let t=e.state;return t._tag===`Closed`?Qi:(e.state={_tag:`Closed`},nr(Ut(t.backing)).pipe(_a(e.deferred)))})),yp=-1,bp=js(Ns(Ur,Ms(yp))),xp=pa(e=>hp(e[0]),(e,t,n,r)=>{if(e.state._tag===`Closed`){n.interruptUnsafe(yp);return}let i=Pt(e.state.backing,t);if(i._tag===`Some`){if(i.value===n)return;if(r?.onlyIfMissing===!0){n.interruptUnsafe(yp);return}}_t(e.state.backing,t,n),i._tag===`Some`&&i.value.interruptUnsafe(yp),n.addObserver(i=>{if(e.state._tag===`Closed`)return;let a=Pt(e.state.backing,t);jr(a)&&n===a.value&&Zi(e.state.backing,t),Mi(i)&&(r?.propagateInterruption===!0?!bp(i.cause):!O(i.cause))&&Co(e.deferred,i)})}),Sp=pa(2,(e,t)=>e.state._tag!==`Closed`&&oa(e.state.backing,t)),Cp=function(){let e;return()=>(e===void 0&&(e=Xr(Ln)),e)}(),wp=e=>()=>so(le(),t=>{let n=ha(t);return(t,r,i)=>{if(e.state._tag===`Closed`||i?.onlyIfMissing===!0&&Sp(e,t))return Cp();let a=n(r,i);return xp(e,t,a,i),a}}),Tp=class extends Yi()(`@porcelain/client/EnvironmentStorage`){},Ep=class extends Yi()(`@porcelain/client/AccessPlatform`){},Dp=A({environmentId:_n,name:_n,address:_n,credential:us(_n),deviceId:Te(_n)});function Op(e){return JSON.stringify(ft(Bo(Dp))(e))}function kp(e,t){if(t===void 0)return{kind:`checking`};if(t.kind===`reconnecting`)return{kind:`reconnecting`};if(t.kind===`unauthorized`)return{kind:`needs-pairing`};if(t.kind===`unreachable`)return{kind:`offline`};let{environment:n}=t;return n.environmentId===e.environmentId?n.protocol===2?{kind:`online`,name:n.name,version:n.version}:{kind:`incompatible`}:{kind:`other-server`}}function Ap(e,t){let n=Reflect.get(e,t);return typeof n==`string`?n:void 0}function jp(e){if(!e||typeof e!=`object`)return[];let t=Ap(e,`environmentId`),n=Ap(e,`name`),r=Ap(e,`address`),i=Ap(e,`credential`),a=Ap(e,`deviceId`);return t&&n!==void 0&&r&&i?[{environmentId:t,name:n,address:r,credential:gi(i),...a?{deviceId:a}:{}}]:[]}function Mp(e){return Array.isArray(e)?e.flatMap(jp):[]}function Np(e,t){return[...e.filter(e=>e.environmentId!==t.environmentId),t]}var Pp=Po((e,t)=>e===t);function Fp(e,t){return e.environmentId===t.environmentId&&e.address===t.address&&Pp(e.credential,t.credential)&&e.deviceId===t.deviceId}function Ip(e){switch(e.kind){case`checking`:return`Checking`;case`reconnecting`:return`Reconnecting`;case`online`:return`Online`;case`offline`:return`Offline`;case`needs-pairing`:return`Needs pairing`;case`other-server`:return`Another server`;case`incompatible`:return`Update needed`}}function Lp(e){switch(e.kind){case`offline`:return`It did not answer. Check that it runs and that this device reaches its address.`;case`needs-pairing`:return`It no longer accepts this app. Run porcelain pair on it and add the new link.`;case`other-server`:return`Another Porcelain answers at this address now, so this app stays away from it.`;case`incompatible`:return`It runs a Porcelain this app cannot talk to. Update both to the same version.`;default:return}}var Rp=class e extends Yi()(`@porcelain/client/AccessStore`){static layer=jn(e,C(function*(){let e=yield*Tp,t=yield*aa({initial:{remotes:[]},read:()=>so(e.read(),e=>({remotes:e})),write:({remotes:t})=>e.write(t),messages:{beforeRead:`Saved environments must be read before changing them.`,readFailed:`Saved environments could not be read. Try reading them again.`,writeFailed:`The saved environments could not be updated. Read them again before making changes.`}}),n=e=>t.write(({remotes:t})=>Ai({remotes:e(t)}));return{state:t.state,load:t.load,save:G(`AccessStore.save`)(e=>n(t=>Np(t,e))),forget:G(`AccessStore.forget`)(e=>n(t=>t.filter(t=>t.environmentId!==e)))}}))},zp=class extends Yi()(`@porcelain/client/ConnectionFactory`){},Bp=class extends Yi()(`@porcelain/client/RemoteConnectionFactory`){},Vp=class e extends Yi()(`@porcelain/client/AccessSession`){static layer=jn(e,C(function*(){let e=yield*zp,t=yield*n,r,i=cs({connection:null,generation:0,writerIdentity:void 0});return{state:i,beginConnection:G(`AccessSession.beginConnection`)((a=!1)=>X(()=>{if(a&&i.value.generation!==0)return null;let o=i.value.generation;return G(`AccessSession.completeConnection`)(function*(a){if(o!==i.value.generation)return!1;let s=JSON.stringify(a.principal),c=i.value.connection?.environmentId===a.inventory.environmentId&&i.value.writerIdentity===s,l=r,u=i.value.connection;if(c||(l=yield*po(t,`sequential`),u=yield*e.local(a).pipe(Gi(n,l))),o!==i.value.generation)return!c&&l&&(yield*Ma(l,Ko)),!1;let d=r;return r=l,i.update(e=>({...e,connection:u,writerIdentity:s,generation:o+1})),d&&d!==r&&(yield*Ma(d,Ko)),!0},L)})),clear:G(`AccessSession.clear`)(function*(){let e=r;r=void 0,i.update(e=>({...e,connection:null,writerIdentity:void 0,generation:e.generation+1})),e&&(yield*Ma(e,Ko))},L)}}))},Hp=class e extends Yi()(`@porcelain/client/RemoteConnections`){static layer=jn(e,C(function*(){let e=yield*Bp,t=yield*n,r=yield*fe(1),i=[],a=cs([]);return{state:a,synchronize:G(`RemoteConnections.synchronize`)(o=>C(function*(){let r=yield*Ge(o,r=>C(function*(){let a=i.find(e=>Fp(e.remote,r));if(a)return{...a,remote:r};let o=yield*po(t,`sequential`);return{remote:r,connection:yield*e.open(r).pipe(Gi(n,o)),scope:o}})),s=i.filter(e=>!r.some(t=>t.scope===e.scope));i=r,a.set(r.map(({remote:e,connection:t})=>({remote:e,connection:t}))),yield*Ge(s,e=>Ma(e.scope,Ko),{discard:!0})}).pipe(Re(r),L))}}))},Up=xe(C(function*(){let e=yield*Rp,t=yield*Hp;yield*t.synchronize(e.state.value.remotes),yield*bo(G(`RemoteConnections.subscribe`)(function*(t){yield*Qa(X(()=>e.state.subscribe(({remotes:e})=>{zn(t,e)})),e=>X(e))})).pipe(Br(t.synchronize),ks({startImmediately:!0}))}));function Wp(e,t,n){return(r,i)=>{let a=new Headers(i?.headers);return t&&a.set(`authorization`,`Bearer ${Fa(t)}`),n(new URL(r,e),{...i,headers:a,mode:`cors`,credentials:`omit`,redirect:`error`,cache:`no-store`})}}var Gp=class extends Yi()(`@porcelain/client/PairingPlatform`){};function Kp(e){let t;try{t=new URL(e.trim())}catch{return}if(t.protocol!==`http:`&&t.protocol!==`https:`||t.pathname!==`/pair`)return;let n=qp(t.hash);return n?{address:t.origin,...n}:void 0}function qp(e){let t=new URLSearchParams(e.replace(/^#/,``)),n=t.get(`c`),r=t.get(`e`);return n&&r?{code:n,environmentId:r}:null}var Jp=U(e=>cs(void 0)),Yp=U(e=>Gt()),Xp=hn(ka),Zp=class e extends Yi()(`@porcelain/client/BootstrapClient`){static layer=U(t=>rr(jn(e,Xp),Di(t)))},Qp=U(e=>Se(Zp.layer(e)));function $p(e,t){return Pa(t)?{kind:`offline`}:kp(e,Wi(Qr(t)))}function em(e,t){return C(function*(){let e=yield*Zp,n=yield*li(e.publicAccess.readEnvironment());return n.environmentId===t&&n.protocol===2&&(yield*li(e.session.readSession())),{kind:`described`,environment:n}}).pipe(Aa(Zp.layer(e)),rs(e=>Ai(e instanceof $a&&e.status===401?{kind:`unauthorized`}:{kind:`unreachable`})),E(Sa),so(e=>eo(e,()=>({kind:`unreachable`}))))}function tm(e,t){Jp(e.send).set({remote:t,revision:Symbol()})}var nm=U(({platform:e,remote:t})=>{let{send:n,statusActivity:r}=e;return Yp(e)(tt).atom(()=>{let e=!1,i=!1,a,o=bo(a=>C(function*(){let o=()=>{let t=r?.isActive()??!0,n=t&&!i;i=t,(!t||n||!e)&&zn(a,t)};yield*Qa(X(()=>{let e=r?.subscribe(o),i=Jp(n).subscribe(()=>{let e=Jp(n).value;e&&Fp(e.remote,t)&&o()});return()=>{e?.(),i?.()}}),e=>X(e)),o()}),{bufferSize:1,strategy:`sliding`}),s=C(function*(){e=!0;let r=yield*em(Wp(t.address,t.credential,n),t.environmentId);return a=r,r}).pipe(h(X(()=>{e=!1})));return o.pipe(T(e=>e?pn(()=>a?.kind===`unreachable`?Yr(Ka({kind:`reconnecting`}),ni(s)):ni(s)).pipe(hs(v(ei))):Cr))}).pipe(nt(0))});function rm(e,t){return nm({platform:e,remote:t})}function im(e){return e instanceof $a?!0:e instanceof Ct?!1:e._tag===`InvalidPairingError`||e._tag===`InvalidDeviceDetailsError`}function am(e,t){return C(function*(){let n=Kp(t);if(!n)return yield*W(new Ct({message:`Paste the whole link porcelain pair printed, starting with http.`}));let r=Wp(n.address,void 0,e.send),i=yield*li(C(function*(){return yield*(yield*Zp).pairing.redeemPairing({payload:{code:n.code,platform:e.name()}})}).pipe(Aa(Zp.layer(r)))).pipe(Ze(e=>im(e)?new Ct({message:`That link was not accepted. It works once, for a few minutes; run porcelain pair again.`}):e instanceof Ct?new Ct({message:`Could not reach ${n.address}. Check that Porcelain runs there and that this device reaches it.`,cause:e.cause}):e));if(!i.credential)return yield*W(new Ct({message:`The remote paired but sent no credential.`}));let a=gi(i.credential),o=kp(n,yield*em(Wp(n.address,a,e.send),n.environmentId));return o.kind===`online`?{environmentId:n.environmentId,address:n.address,name:o.name,credential:a,deviceId:i.device.id}:yield*W(new Ct({message:o.kind===`other-server`?`Another Porcelain answered at that address than the one that made the link.`:o.kind===`incompatible`?`That Porcelain runs a version this app cannot talk to. Update both to the same version.`:`The remote paired but did not answer afterwards. Try again.`}))})}var om=G(`Environments.pairAndSave`)(function*(e){let t=yield*Rp,n=yield*Ep;if(t.state.value.status!==`ready`)return yield*W(new Ct({message:`Read saved environments before pairing.`}));let r=yield*am(n,e);return yield*t.save(r),r}),sm=G(`BrowserSession.pair`)(function*(e){let t=yield*Gp,n=yield*Zp;if((yield*li(n.publicAccess.readHealth()).pipe(Ze(e=>!(e instanceof Ct)&&!(e instanceof $a)&&e._tag!==`MissingEnvironmentIdentityError`?new Ct({message:`That address answered, but it is not a Porcelain server.`}):new Ct({message:`Could not reach Porcelain. Check that the server is running, then open the link again.`,cause:e})))).environmentId!==e.environmentId)return yield*W(new Ct({message:`This link was made for a different Porcelain installation.`}));let r=yield*li(n.pairing.redeemPairing({payload:{code:e.code,platform:t.name()}})).pipe(Ze(e=>im(e)?new Ct({message:`This pairing link is not usable. Ask for a new one.`}):e));return{inventory:yield*li(n.projects.readInventory()).pipe(Ze(e=>e instanceof $a?new Ct({message:`Pairing succeeded but the workspace could not be loaded. Reload the page.`}):e)),principal:{kind:`device`,deviceId:r.device.id}}}),cm=U(({transport:e,platform:t})=>Se(Je(Zp.layer(e),Qt(Gp,t))).fn(e=>sm(e))),lm=class e extends Yi()(`@porcelain/client/AccessSnapshots`){static layer=jn(e,C(function*(){return{remote:yield*d(Jr()),update:yield*d(Jr())}}))},um=U(e=>e.atoms(t=>_r(lm.layer,t(_i(e).layer)))),dm=ua,fm=ee,pm=class extends ps.add(is(`live`).add($o(`liveUpdates`,`/api/live`,{disableCodecs:!0,query:Ss.fields,success:qr.pipe(oe({decode:()=>void 0}),R(`SwitchingProtocols`))})).middleware(bn)){};ps.add(is(`reviewMcp`).add(Cn(`reviewMcp`,`/mcp`,{disableCodecs:!0,payload:dm,success:[dm,fm.pipe(oe({decode:()=>void 0}),R(`Accepted`))]})).middleware(bn));var mm=[`lan`,`tailnet`,`cloudflare`],hm={lan:`Local network`,tailnet:`Tailscale`,cloudflare:`Cloudflare tunnel`},gm={loopback:`This computer`,lan:`Local network`,tailnet:`Tailscale`,tunnel:`Cloudflare tunnel`};function _m(e){return`${e.subnet} on ${e.interfaceName}`}function vm(e){let{lan:t}=e.routes,n=e.localNetwork,r=e.lanNetwork,i=`Porcelain cannot tell this network from another one yet, because the hardware address of its router is not known.`;return t.enabled?t.status.kind===`paused`?n?n.gatewayHardware?r?_m(r)===_m(n)?`Paused on this network. It looks like ${_m(r)}, but its router is another one, so this is another network; turn it on for this network to listen here.`:`Paused on this network. It was turned on for ${_m(r)}, and listens again there, or here once you turn it on for this network.`:`Paused on this network. It was turned on before Porcelain kept the network it was turned on for; turn it on for this network to listen here.`:`Paused. ${i}`:r?`Paused: this computer is not on a local network. Porcelain listens again when it is back on ${_m(r)}.`:`Paused: this computer is not on a local network.`:r?`Listening on ${_m(r)} only.`:`Listening on this network only.`:n?n.gatewayHardware?`Turning it on listens on ${_m(n)} only, and pauses on any other network.`:`${i} Try again in a moment.`:`This computer is not on a local network right now.`}function ym(e){return e?mm.some(t=>{let n=e.routes[t];return n.enabled?n.status.kind===`starting`||n.status.kind===`off`:n.status.kind!==`off`}):!1}function bm(e){return e===void 0?[]:mm.flatMap(t=>{let{status:n}=e.routes[t];return n.kind===`on`?n.urls.map(e=>({route:t,url:e})):[]})}function xm(e){let[t]=e.grants;return t?{label:t.grant.label,link:N(t.link),expiresAt:t.grant.expiresAt}:null}function Sm(e){return`tailscale serve --bg --https=443 ${e}`}function Cm(e,t){let n=`Your devices may reach that program instead of Porcelain: run tailscale serve --https=443 off now, then turn Tailscale off and on here to pick a free port and run the new command Porcelain names.`;switch(t){case`address-in-use`:return e===`tailnet`?`Another program already listens on the port Tailscale forwards to. ${n}`:`Another program already listens on this port.`;case`address-unavailable`:return e===`tailnet`?`Porcelain could not open the local listener Tailscale forwards to. ${n}`:`This computer could not listen at its address.`;case`unreachable`:return e===`tailnet`?`Nothing answered at this Tailscale name yet. Check that you ran the command below, that Tailscale is connected on this computer and uses MagicDNS, and that MagicDNS and HTTPS Certificates are on in the Tailscale admin console. Porcelain keeps checking.`:`Nothing answered at this hostname. Check that cloudflared is running and routes it here.`;case`other-server`:return e===`tailnet`?`Another server answered at this Tailscale name. Run the command below so Tailscale forwards to this Porcelain; Porcelain keeps checking.`:`Another server answered at this hostname.`}}function wm(e,t,n){return C(function*(){let r=yield*ia(n.pipe(gs(()=>hr(e))));return Mi(r)&&gn(r.cause)?yield*Ln:(Er(r)&&(yield*$i(t,ms(r.value))),mi(r,Xo(yield*ca(t),wo)))})}function Tm(e,n,r,i){return Ae(e.atom(xn(so(i,e=>ni(n).pipe(hs(v(r)),Zo(t=>!e(Wi(Qr(t)))))))).pipe(Vn(e=>t(e,e=>e)))).pipe(nt(0))}function Em(e,t,n){return jt(lm,r=>wm(e,t(r),n))}var Dm=U(e=>_i(e).atom(Ia(e,e=>e.administration.listAccess())).pipe(nt(0))),Om=U(e=>Tm(um(e),Em(e,e=>e.remote,Ia(e,e=>e.administration.readRemoteAccess()).pipe(rs(e=>e instanceof $a&&e.status===403?Ai(null):W(e)))),Do,Ai(ym))),km=U(e=>Tm(um(e),Em(e,e=>e.update,Ia(e,e=>e.serviceUpdates.readServiceUpdate())),Uo,C(function*(){let e=yield*lm,t=Wi(yield*ca(e.update)),n=t?.running?t.last?.target:void 0;return e=>e?.managed===!0?e.running?(n=e.last?.target,!0):n!==void 0&&e.last?.stage===`updated`&&e.last.target===n&&e.version===e.last.from&&e.version!==n:!1})));function Am(e){return C(function*(){let t=yield*Fo(e),n=yield*Mt,r=yield*lm,i=yield*ir;function a(t,r){return n.run([t],C(function*(){yield*hr(e);let t=yield*r;return yield*hr(e),t}))}function o(t){return X(()=>{e.isClosed()||i.refresh(t)})}function s(e,t,n){return Oa(X(()=>{let t=i.mount(e),n=y(wo(i.get(e),{waiting:!0}));return i.set(e,n),{transition:n,unmount:t}}),({transition:e})=>n.pipe(gs(n=>C(function*(){yield*$i(t,ms(n)),i.set(e,wo(wo(n),{waiting:!0}))}))),({transition:e,unmount:t},n)=>X(()=>{i.set(e,Er(n)?wo(wo(n.value)):Zt(n.cause)),t()}))}return{issue:n=>a(`paired-access`,t.request(e=>e.administration.issuePairing({payload:{labels:[n.label],addresses:n.addresses,...n.trusted?{trusted:!0}:{}}})).pipe(gs(()=>o(Dm(e))))),revoke:n=>a(`paired-access`,t.request(e=>e.administration.revokeAccess({payload:{id:n}})).pipe(h(o(Dm(e))))),trust:n=>a(`paired-access`,t.request(e=>e.administration.setDeviceTrust({payload:n})).pipe(h(o(Dm(e))))),setRemote:n=>a(`remote-access`,s(Om(e),r.remote,t.request(e=>e.administration.setRemoteAccess({payload:n})).pipe(gs(()=>hr(e))))),startUpdate:n=>a(`service-update`,s(km(e),r.update,t.request(e=>e.serviceUpdates.startServiceUpdate({payload:{version:n}})).pipe(gs(()=>hr(e)),ss(()=>o(km(e))))))}})}var jm=class e extends Yi()(`@porcelain/client/AccessCommands`){static layer(t){return jn(e,Am(t))}},Mm=U(e=>e.atoms(t=>_r(jm.layer(e),t(um(e).layer)))),Nm=U(e=>Mm(e).fn(e=>jm.use(t=>t.issue(e)).pipe(so(xm)),{concurrent:!0})),Pm=U(({connection:e,id:t})=>Mm(e).fn(()=>jm.use(e=>e.revoke(t)),{concurrent:!0})),Fm=U(({connection:e,id:t})=>Mm(e).fn(e=>jm.use(n=>n.trust({id:t,trusted:e})),{concurrent:!0})),Im=U(e=>Mm(e).fn(e=>jm.use(t=>t.setRemote(e)),{concurrent:!0})),Lm=U(e=>Mm(e).fn(e=>jm.use(t=>t.startUpdate(e)),{concurrent:!0}));function Rm(e,t,n,i=Jr(),a=[t,tr.environment(e.environmentId)]){return C(function*(){let o=yield*Mt,s=yield*Mr,c=yield*ko({epoch:0,result:Cs(i,{onNone:()=>No(),onSome:e=>wo(e)})}),l=(t=n,r=!1)=>C(function*(){let n=(yield*ui(c)).epoch;yield*lo(c,e=>({...e,result:ya(e.result)}));let i=yield*ia(t.pipe(gs(()=>hr(e))));yield*lo(c,e=>e.epoch===n?{...e,epoch:e.epoch+ +!!r,result:mi(i,ms(e.result))}:e)});function u(n,r){return o.run(tr.withIdentity(t,e),C(function*(){yield*hr(e),yield*lo(c,e=>({...e,epoch:e.epoch+1}));let t=yield*n;return yield*hr(e),yield*lo(c,e=>({epoch:e.epoch+1,result:Cs(r(Qr(e.result),t),{onNone:()=>e.result,onSome:e=>wo(e)})})),t}).pipe(h(s.invalidate([t]))))}return{confirm:u,refresh:e=>C(function*(){yield*lo(c,e=>({...e,epoch:e.epoch+1})),yield*l(e,!0)}),stream:ki(r(c).pipe(wa(e=>e.result)),s.stream(a,l()).pipe(ma))}})}var zm=yo(`@porcelain/client/InventorySeed`,{defaultValue:()=>Jr()}),Bm=class e extends Yi()(`@porcelain/client/InventoryState`){static layer(t){return jn(e,C(function*(){let e=yield*zm,n=yield*Fo(t),r=e=>hr(t,e.environmentId===t.environmentId),i=n.request(e=>e.projects.readInventory()),a=yield*Rm(t,tr.inventory(t.environmentId),i.pipe(gs(r)),e);function o(e,t){return a.confirm(e,(e,n)=>Xo(e,e=>t(e,n)))}return{stream:a.stream,confirm:o,refresh:()=>a.refresh(n.request(e=>e.projects.refreshInventory()).pipe(M(`RequestError`,e=>e.status===404?i:W(e)),gs(r)))}}))}},Vm=U(e=>e.atoms(t=>_r(Bm.layer(e),t(_i(e).layer)))),Hm=U(e=>Vm(e).fn(t=>C(function*(){let n=yield*Fo(e);return yield*(yield*Bm).confirm(n.request(e=>e.environmentName.renameEnvironment({payload:{name:t}})),(e,t)=>({...e,environment:t}))}),{concurrent:!0})),Um=G(`BrowserSession.restore`)(function*(){let e=yield*Zp;return{principal:yield*li(e.session.readSession()),inventory:yield*li(e.projects.readInventory())}},rs(e=>e instanceof $a&&e.status===401?Ai(null):W(e instanceof $a||Fn(e)?new Ct({message:`Could not reach Porcelain to restore this browser session.`,cause:e}):e))),Wm=U(e=>Qp(e).atom(Um())),Gm=`Save or discard unsaved file drafts before disconnecting.`;function Km(e){return e instanceof Error&&(e.name===`ConnectionError`||e.name===`RequestError`)?e.message:`Could not connect to the environment. Try again.`}var qm=U(e=>e.atoms(t=>Je(t(Fo(e).runtime.layer),Ke.layer)).fn(G(`BrowserSession.disconnect`)(function*(){let t=yield*Ke,n=yield*Fo(e);if(!(yield*t.save(e.environmentId)))return yield*W(new Ct({message:Gm}));yield*n.request(e=>e.browserAccess.clearBrowserSession())},Ze(e=>e instanceof Ct?e:new Ct({message:`Could not disconnect. Check the connection and try again.`,cause:e}))))),Jm=G(`BrowserSession.connect`)(function*(e,t,n,r){let i=yield*Vp,a=yield*i.beginConnection(),o=yield*Oa(X(()=>e.set(t,n)),()=>vr(e,t,{suspendOnWaiting:!0}),()=>X(()=>e.set(t,yt))).pipe(Qo({duration:r,orElse:()=>Ln}),fs(e=>W(new Ct({message:Km(wn(e)),cause:wn(e)}))));if(a&&(yield*a(o)),i.state.value.connection?.environmentId!==o.inventory.environmentId)return yield*W(new Ct({message:`Could not connect to the environment. Try again.`}))}),Ym=G(`BrowserSession.restoreConnection`)(function*(e,t){let n=yield*Vp;if(n.state.value.connection)return!0;let r=yield*n.beginConnection(!0);if(!r)return!1;let i=e.get(t);Pa(i)&&!i.waiting&&e.refresh(t);let a=yield*vr(e,t,{suspendOnWaiting:!0});return a!==null&&(yield*r(a),n.state.value.connection!==null)}),Xm=class e extends Yi()(`@porcelain/client/EnvironmentMutations`){static layer=jn(e,C(function*(){let e=yield*fe(1),t=cs(0);return{pendingSelections:t,run:(n,r)=>Oa(X(()=>{n===`selection`&&t.update(e=>e+1)}),()=>e.withPermit(r),()=>X(()=>{n===`selection`&&t.update(e=>e-1)}))}}))},Zm=class extends Yi()(`@porcelain/client/WorkspaceSelectionCleanup`){},Qm=C(function*(){let e=yield*Rp,t=yield*Ep,n=yield*Xm,r=yield*Ke,i=yield*Zm;return{read:G(`Environments.read`)(()=>n.run(`access`,e.load())),pair:G(`Environments.pair`)(r=>n.run(`access`,C(function*(){return r.localEnvironmentId&&Kp(r.value)?.environmentId===r.localEnvironmentId?yield*W(new Ct({message:`That link is for this computer.`})):yield*om(r.value).pipe(Gi(Rp,e),Gi(Ep,t))}))),forget:G(`Environments.forget`)(t=>n.run(`selection`,C(function*(){if(!(yield*r.save(t)))return yield*W(new Ct({message:Gm}));yield*C(function*(){yield*e.forget(t),yield*i.forgetEnvironment(t),yield*r.drop(t)}).pipe(L)})))}}),$m=class e extends Yi()(`@porcelain/client/EnvironmentCommands`){static layer=jn(e,Qm)},eh=D(pm).live.liveUpdates,th=D(Ar).pairing.redeemPairing,nh=new Set;function rh(e){return nh.add(e),()=>nh.delete(e)}function ih(){for(let e of[...nh])e()}function ah(e,t={}){return async(n,r)=>{let i=new Headers(r?.headers);i.delete(`authorization`),i.set(`x-porcelain-browser`,`1`);let a=await e(n,{...r,headers:i,credentials:`same-origin`});return a.status===401&&n!==th()&&t.reportUnauthorized!==!1&&ih(),a}}var oh=U(e=>Vm(e).atom(xn(so(Bm,e=>e.stream))).pipe(Vn(e=>t(e,e=>e)),nt(0)));U(e=>Mn(t=>e.map(e=>({connection:e,result:t(oh(e))}))));var sh=class extends Yi()(`@porcelain/client/ProjectSelectionStorage`){},ch=class e extends Yi()(`@porcelain/client/ProjectSelectionStore`){static layer=jn(e,C(function*(){let e=yield*sh,t=yield*aa({initial:{currentEnvironmentId:void 0,selections:{}},read:e.read,write:e.write,messages:{beforeRead:`Saved workspace selections must be read before changing them.`,readFailed:`Saved workspace selections could not be read. Try reading them again.`,writeFailed:`Saved workspace selections could not be updated. Read them again before making changes.`}}),n=t.write;return{state:t.state,load:t.load,selectWorkspace:G(`ProjectSelectionStore.selectWorkspace`)((e,t,r)=>n(({selections:n})=>Ai({currentEnvironmentId:e,selections:{...n,[e]:{projectId:t,worktreeId:r}}}))),forgetEnvironment:G(`ProjectSelectionStore.forgetEnvironment`)(e=>n(({currentEnvironmentId:t,selections:n})=>Ai({currentEnvironmentId:t===e?void 0:t,selections:Object.fromEntries(Object.entries(n).filter(([t])=>t!==e))})))}}))};function lh(e){return C(function*(){let t=yield*Fo(e),n=yield*Bm,r=yield*Ke;return{register:e=>n.confirm(t.request(t=>t.projects.registerProject({payload:{path:e}})),(e,t)=>({...e,projects:e.projects.some(e=>e.id===t.id)?e.projects.map(e=>e.id===t.id?t:e):[...e.projects,t]})),rename:e=>n.confirm(t.request(t=>t.projects.renameProject({params:{projectId:e.projectId},payload:{name:e.name}})),(e,t)=>({...e,projects:e.projects.map(e=>e.id===t.id?{...e,name:t.name}:e)})),remove:i=>n.confirm(C(function*(){let n=`[${JSON.stringify(i)},`;for(let[t,i]of r.entries(e))if(t.startsWith(n)&&!(yield*i.save()))return yield*W(new Ct({message:`Save or discard unsaved file drafts before removing this project.`}));return yield*t.request(e=>e.projects.removeProject({params:{projectId:i}}))}),e=>({...e,projects:e.projects.filter(e=>e.id!==i)}))}})}var uh=class extends Yi()(`@porcelain/client/ProjectCommands`){},dh=U(e=>e.atoms(t=>_r(jn(uh,lh(e)),Je(t(Vm(e).layer),Ke.layer)))),fh=U(e=>dh(e).fn(e=>uh.use(t=>t.register(e)),{concurrent:!0})),ph=U(e=>dh(e).fn(e=>uh.use(t=>t.rename(e)),{concurrent:!0})),mh=U(e=>dh(e).fn(e=>uh.use(t=>t.remove(e)),{concurrent:!0})),hh=U(e=>Vm(e).fn(e=>Bm.use(e=>e.refresh()),{concurrent:!0}));U(e=>ur(t=>e.map(e=>t(hh(e))),(t,n)=>{for(let n of e)t.set(hh(n),void 0)}));var gh=class e extends Yi()(`@porcelain/client/FilePreferencesState`){static layer(t,n){return jn(e,C(function*(){let e=yield*Fo(t);return yield*Rm(t,tr.filePreferences(t.environmentId,n),e.request(e=>e.projects.listFilePreferences({params:{projectId:n}})))}))}},_h=U(({connection:e,projectId:t})=>e.atoms(n=>_r(gh.layer(e,t),n(_i(e).layer)))),vh=U(({connection:e,projectId:t})=>_h({connection:e,projectId:t}).fn(n=>C(function*(){let r=yield*Fo(e);return yield*(yield*gh).confirm(r.request(e=>e.projects.setFilePreference({params:{projectId:t},payload:n})),(e,t)=>ms(t))}),{concurrent:!0})),yh=U(e=>_h(e).atom(xn(so(gh,e=>e.stream))).pipe(Vn(e=>t(e,e=>e)),nt(0))),bh=U(({connection:e,path:t})=>_i(e).atom(C(function*(){return yield*(yield*Fo(e)).request(e=>e.projects.browseProjectFolders({query:t===void 0?{}:{path:t}}))})));function xh(e,t){return bh({connection:e,path:t})}A({currentEnvironmentId:Te(ue),selections:Gr(_n,A({projectId:ue,worktreeId:ne})).check(Ne(ue))});var Sh=C(function*(){let e=yield*Rp,t=yield*ch,n=yield*Xm;return{pending:n.pendingSelections,execute:G(`WorkspaceSelection.execute`)(r=>n.run(`selection`,C(function*(){if(r.kind===`read`){if(yield*t.load(),e.state.value.status!==`ready`||t.state.value.status!==`ready`)return;let n=new Set(e.state.value.remotes.map(e=>e.environmentId)),r=new Set(Object.keys(t.state.value.selections));t.state.value.currentEnvironmentId&&r.add(t.state.value.currentEnvironmentId);for(let e of r)n.has(e)||(yield*t.forgetEnvironment(e));return}if(e.state.value.status!==`ready`||!e.state.value.remotes.some(e=>e.environmentId===r.environmentId))return yield*W(new Ct({message:`That environment is no longer paired. Open the workspace picker again.`}));yield*t.selectWorkspace(r.environmentId,r.projectId,r.worktreeId)})))}});(class e extends Yi()(`@porcelain/client/ProjectSelectionCommands`){static layer=jn(e,Sh)});var Ch=U(e=>Be((t,n)=>C(function*(){let r=yield*n.setResult(fh(e),t.path.trim()),i=r.worktrees.find(e=>e.available);t.complete(),i&&(yield*t.select({remote:t.remote,projectId:r.id,worktreeId:i.id}))})));jn(Zm,so(ch,e=>({forgetEnvironment:e.forgetEnvironment})));var wh={isActive:()=>document.visibilityState!==`hidden`&&!0,subscribe:e=>(window.addEventListener(`focus`,e),window.addEventListener(`online`,e),window.addEventListener(`offline`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e),document.removeEventListener(`visibilitychange`,e)})};function Th(e,t){if(!e.running)return null;let n=e.last?.target??e.latest??`the new version`;return t||e.last?.stage===`restarting`?`Restarting Porcelain on ${n}. This page reconnects when it is back.`:e.last?.stage===`installing`?`Installing ${n}…`:`Downloading ${n}…`}function Eh(e){let{last:t}=e;return e.running||t==null?null:t.stage===`updated`&&t.target===e.version?{kind:`updated`,from:t.from,target:t.target}:t.stage===`failed`?{kind:`failed`,target:t.target,reason:t.reason??`The updater gave no reason.`}:null}function Dh(e){return e.kind===`online`?`secondary`:e.kind===`checking`?`outline`:`destructive`}function Oh(e,t){return t&&e.kind===`online`}function kh(e){if(e.status===`unreadable`)return{kind:`unreadable`,message:e.message};if(e.status===`empty`)return{kind:`readable`,remotes:void 0};try{return{kind:`readable`,remotes:Mp(JSON.parse(e.value))}}catch{return{kind:`unreadable`,message:`The saved remote computers are not in a form this app reads.`}}}var Ah=Tp.of({read:()=>Sn({try:async()=>{let e=Xi();if(!e){let e=localStorage.getItem(`porcelain.remotes`);return e===null?[]:Mp(JSON.parse(e))}let t=kh(await e.read());if(t.kind===`unreadable`)throw Error(t.message);return t.remotes??[]},catch:e=>new vs(e)}),write:e=>Sn({try:async()=>{let t=Xi(),n=Op(e);t?await t.write(n):localStorage.setItem(`porcelain.remotes`,n)},catch:e=>new vs(e)})}),jh=class extends Yi()(`@porcelain/client/OperationStore`){},Mh=class extends Yi()(`@porcelain/client/OperationStorage`){},Nh=ln(Bo(A({requestId:Li.fields.requestId,projectId:_n.check(Wn(1)),worktreeId:On.fields.worktreeId,request:Li}).check(Zn(e=>e.requestId===e.request.requestId))));function Ph(e){return e.state!==`running`}var Fh=(e,t)=>JSON.stringify([e.projectId,e.worktreeId,t]),Ih=jn(jh,C(function*(){let e=yield*Mh,t=yield*fe(1),n=yield*ko(0),i=yield*e.read().pipe(jt(e=>kt(Nh)(e??`[]`)),za),a=cs({operations:Io(i)?new Map(i.success.map(e=>[Fh(e,e.request.input.action),e])):new Map,closed:!1,restorationError:vi(i)?new Ct({message:`Could not restore pending Git operations. Check the previous operation before starting another.`,cause:i.failure}):void 0}),o=G(`OperationStore.publish`)(function*(e){a.set(e),yield*lo(n,e=>e+1)});yield*Ui(()=>t.withPermit(o({...a.value,operations:new Map,closed:!0})));let s=G(`OperationStore.persist`)(function*(t){if(a.value.restorationError)return yield*W(a.value.restorationError);let n=[...t.values()].filter(e=>!e.receipt||!Ph(e.receipt)).map(({receipt:e,...t})=>t),r=yield*Ue(Nh)(n).pipe(Ze(e=>new Ct({message:`Could not save the Git operation. Check device storage before trying again.`,cause:e})));yield*(n.length?e.write(r):e.clear()).pipe(Ze(({cause:e})=>new Ct({message:`Could not save the Git operation. Check device storage before trying again.`,cause:e}))),yield*o({...a.value,operations:t})}),c=e=>t.withPermit(C(function*(){return a.value.closed?yield*Ln:yield*e().pipe(L)}));return{state:a,set:G(`OperationStore.set`)((e,t)=>c(()=>C(function*(){let n=new Map(a.value.operations);t?n.set(e,t):n.delete(e),yield*s(n)}))),accept:G(`OperationStore.accept`)(e=>c(()=>C(function*(){let t=Fh(e,e.action),n=a.value.operations.get(t);if(!n||n.requestId!==e.requestId||n.receipt&&Ph(n.receipt))return!1;let r=new Map(a.value.operations);return r.set(t,{...n,receipt:e}),yield*s(r),!0}))),wait:G(`OperationStore.wait`)(function*(e,t){let i=yield*r(n).pipe(zi(()=>C(function*(){let n=a.value.operations.get(e);return yield*Xt(!a.value.closed&&n?.requestId===t),n?.receipt&&Ph(n.receipt)?ms(n.receipt):Jr()})),Lo(jr),wa(e=>e.value),os);return yield*Cs(i,{onSome:Ai,onNone:()=>Xt(!1).pipe(kr(sr))})})}}));function Lh(e,t){return C(function*(){let n=yield*(yield*Fo(e)).request(e=>e.gitActions.readGitActionReceipt({params:{worktreeId:t.worktreeId,requestId:t.requestId}}));return yield*hr(e,n.projectId===t.projectId&&n.worktreeId===t.worktreeId&&n.requestId===t.requestId),n})}var Rh=class extends dt{},zh=class e extends Yi()(`@porcelain/client/GitReceiptRefresh`){static layer(t){return jn(e,C(function*(){let e=yield*bi,n=yield*Mr,r=yield*ct,i=yield*Wf({capacity:1/0,timeToLive:Nn,lookup:a=>C(function*(){let o=new Set(F(t.environmentId,a).map(e=>String(e[4]))),s=[..._o(yield*r.snapshot)].filter(e=>e.projectId===a.projectId&&e.worktreeId===a.worktreeId&&o.has(e.surface)),c=yield*dn(C(function*(){n.invalidateUnsafe([tr.inventory(t.environmentId),...F(t.environmentId,a)]),yield*Ge(s,e=>e.settled,{concurrency:`unbounded`,discard:!0})}),e);return yield*dn(to(c).pipe(kr(Qf(i,a))),e),c})});return{refresh:G(`GitReceiptRefresh.refresh`)(function*(e){if(e.state===`running`||e.state===`rejected`||e.state===`no-change`)return;let t=new Rh({projectId:e.projectId,worktreeId:e.worktreeId,requestId:e.requestId,action:e.action,state:e.state}),n=yield*qf(i,t);n.pollUnsafe()&&(yield*Qf(i,t)),yield*gr(n)})}}))}},Bh=U(e=>e.atoms(t=>_r(zh.layer(e),t(_i(e).layer))));function Vh(e,t,n){let r=new Map;for(let t of[...e.state.value.operations.values()])t.receipt&&Ph(t.receipt)||r.set(JSON.stringify([t.projectId,t.worktreeId]),{projectId:t.projectId,worktreeId:t.worktreeId,paths:new Set});for(let e of n){let t=JSON.stringify([e.projectId,e.worktreeId]),n=r.get(t)??{projectId:e.projectId,worktreeId:e.worktreeId,paths:new Set};for(let t of e.paths)t!==``&&n.paths.add(t);r.set(t,n)}return{projects:t?.projects.map(e=>e.id).slice(0,128)??[],worktrees:[...r.values()].slice(0,32).map(e=>({projectId:e.projectId,worktreeId:e.worktreeId,paths:[...e.paths].slice(0,64)}))}}var Hh=G(`Live.connect`)(function*(e,t){let r=yield*ir,i=yield*ct,a=yield*jh,o=yield*zh,s=yield*Mr,c=yield*Qa(po(e.scope,`sequential`),e=>Ma(e,Ko)),l=yield*wp(yield*vp().pipe(Gi(n,c)))(),u=yield*le(),d=G(`Live.applyNotice`)(function*(t){if(t.type===`git-action`)return yield*o.refresh(t.receipt);(t.type===`inventory`||t.type===`worktree`)&&(yield*s.invalidate([tr.inventory(e.environmentId)])),t.type===`project`&&t.change===`preferences`&&(yield*s.invalidate([tr.filePreferences(e.environmentId,t.projectId)])),yield*s.invalidate(ie(e.environmentId,t))}),f=()=>{for(let t of a.state.value.operations.values())t.receipt&&Ph(t.receipt)||l(Symbol(),C(function*(){let n=yield*Lh(e,{...t}).pipe(uo(u));yield*hr(e),yield*o.refresh(n),yield*a.accept(n)}).pipe(Kn,xs))},p=yield*e.liveUpdates.connect({onNotice:t=>{e.isClosed()||c.state._tag===`Closed`||(t.type===`inventory`&&e.onStatusChange?.(),t.type===`ready`&&f(),l(Symbol(),C(function*(){yield*d(t),t.type===`git-action`&&!e.isClosed()&&c.state._tag!==`Closed`&&(yield*a.accept(t.receipt))}).pipe(fs(()=>X(()=>{!e.isClosed()&&c.state._tag!==`Closed`&&f()})),xs)))},onReconnect:()=>{!e.isClosed()&&c.state._tag!==`Closed`&&(e.onStatusChange?.(),l(Symbol(),s.invalidate([tr.environment(e.environmentId)])))},onUnauthorized:()=>{e.isClosed()||c.state._tag===`Closed`||(e.onStatusChange?.(),t?t():l(Symbol(),s.invalidate([tr.inventory(e.environmentId)])))}}).pipe(Gi(n,c)),m=``,h=C(function*(){if(e.isClosed()||c.state._tag===`Closed`)return;let t=Vh(a,Wi(Qr(r.get(oh(e)))),_o(yield*i.snapshot)),n=JSON.stringify(t);n!==m&&(m=n,p.subscribe(t))}),g=()=>{!e.isClosed()&&c.state._tag!==`Closed`&&l(`subscription`,kr(pe,h),{onlyIfMissing:!0})};yield*Qa(X(()=>r.subscribe(oh(e),g)),e=>X(e)).pipe(Gi(n,c)),yield*Qa(X(()=>a.state.subscribe(g)),e=>X(()=>e?.())).pipe(Gi(n,c)),l(Symbol(),Br(i.changes,()=>X(g))),g()}),Uh=U(e=>e.atoms(t=>lr(t(Vm(e).layer),t(Bh(e).layer),Jn(e.runtime.contextEffect)))),Wh=U(({connection:e,onUnauthorized:t})=>Uh(e).atom(Hh(e,t)).pipe(nt(0))),Gh=y(wo(void 0));function Kh(e){return e instanceof $a?e.status===401:e instanceof pc||Js(e)?e.reason._tag===`SocketCloseError`&&e.reason.code===4001:!1}function qh(e,t=Ga()){return{connect:G(`LiveUpdates.connect`)(function*({onNotice:n,onReconnect:r,onUnauthorized:i}){let a=yield*d({projects:[],worktrees:[]}),o=yield*qn(1),s=0,c=500,l=qa(C(function*(){let t=yield*e,i=yield*Ro(),l=yield*kc({retryPolicy:ut.pipe(Ts(),Bn(({input:e})=>Zr(i,e)),ke({times:0}))}).pipe(Gi(Hs,t),Gi(yc,bc)),u=yield*Tc(Yo,{disableTracing:!0}).pipe(Gi(Oc,l)),d=u.notices(void 0).pipe(Br(e=>C(function*(){e.type===`ready`&&(s>0&&r(),s+=1,c=500,yield*u.follow(yield*ca(a))),n(e)}))),f=mt(jt(be(o),e=>u.follow(e)));yield*Ii([d,f],{concurrency:`unbounded`}).pipe(Nr(Va(i)))}));return yield*qa(C(function*(){for(yield*Ui(()=>Oe(o));;){let e=yield*ia(l);if(Mi(e)&&Kh(wn(e.cause))){i();return}yield*Bi(c),c=Math.min(c*2,Rr)}})).pipe(uo(t),fs(e=>gn(e)?Qi:De(`Live updates stopped unexpectedly`)),ks),{subscribe(e){o.state._tag!==`Done`&&(ri($i(a,e)),zn(o,e))}}})}}function Jh(e,t,n){return qh(C(function*(){let t=yield*Zp,{ticket:r}=yield*li(t.session.issueLiveTicket()),i=new URL(e);return yield*n(`${i.protocol===`https:`?`wss:`:`ws:`}//${i.host}${eh({query:{ticket:r}})}`)}).pipe(Aa(Zp.layer(t))))}function Yh(e,t,n){let r=Je(no(Ih),Ke.layer).pipe(_r(t)),{connection:i}=Le(e,n,r),a=de({...i,address:e.address,liveUpdates:e.liveUpdates,...e.onStatusChange?{onStatusChange:e.onStatusChange}:{},operations:i.runtime.runSync(jh)});return i.runtime.runSync(Ke).adopt(a),a}function Xh(e,t,n){let r=Wp(e.address,e.credential,e.send);return Yh({environmentId:e.environmentId,address:e.address,transport:r,cacheIdentity:[e.address,e.deviceId??``],liveUpdates:Jh(e.address,r,e.socket),...e.onStatusChange?{onStatusChange:e.onStatusChange}:{},timeoutMs:e.timeoutMs},t,n)}function Zh(e){return ic(e).pipe(Gi(rc,e=>new WebSocket(e)))}function Qh(){let e=location.protocol===`https:`?`wss:`:`ws:`;return qh(Zh(gt()??`${e}//${location.host}${eh({query:{}})}`))}var $h=U(e=>_i(e).atom(Ia(e,e=>e.gitActions.listCommitModels())).pipe(nt(vo),ro({staleTime:vo,revalidateOnFocus:!1})));function eg(e){return $h(e)}var tg=U(({connection:e,scope:t})=>_i(e).fn(G(`GitActions.generateCommitDraft`)(function*({lifetime:n,...r}){let i=yield*(yield*Fo(e)).request(e=>e.gitActions.generateCommitDraft({params:{worktreeId:t.worktreeId},payload:r}),n);return yield*hr(e),i}),{concurrent:!0})),ng=U(({connection:e,scope:t})=>_i(e).fn(G(`GitActions.dismissInterrupted`)(function*(n){yield*(yield*Fo(e)).request(e=>e.gitActions.dismissInterruptedGitAction({params:{worktreeId:t.worktreeId,requestId:n}})),yield*hr(e),yield*Ra([tr.reviewSurface(e.environmentId,t,[`changes`])])}))),rg=U(e=>y(C(function*(){let t=yield*ir,n=tg(e);return G(`CommitDraft.submit`)(function*(e,r){return t.set(n,{...e,lifetime:r}),yield*vr(t,n,{suspendOnWaiting:!0})})}))),ig=class extends ts()(`GitOperationStateError`,{reason:Pi([`pending`,`missing`,`mismatch`])}){get message(){switch(this.reason){case`pending`:return`Check the existing receipt before starting another operation.`;case`missing`:return`No operation to recover`;case`mismatch`:return`Action mismatch`}}},ag=G(`GitActionController.make`)(function*({connection:e,scope:t,action:n}){let r=yield*Fo(e),i=yield*jh,a=yield*dp,o=yield*zh,s=yield*fe(1),c=Fh(t,n),l=G(`GitActionController.accept`)(function*(t){yield*hr(e,t.requestId===i.state.value.operations.get(c)?.requestId),yield*o.refresh(t),yield*hr(e,t.requestId===i.state.value.operations.get(c)?.requestId),yield*i.accept(t)}),u=G(`GitActionController.send`)(function*(a){let o=yield*r.request(e=>e.gitActions.runGitAction({params:{worktreeId:t.worktreeId},payload:a}));return`requestId`in o?(yield*hr(e,o.projectId===t.projectId&&o.worktreeId===t.worktreeId&&o.requestId===a.requestId&&o.action===n),yield*l(o),yield*i.wait(c,a.requestId)):yield*W(new $a({status:o.statusCode,message:o.message}))});return{execute:G(`GitActionController.execute`)(function*(r){return yield*e.request(C(function*(){let o=yield*s.withPermit(C(function*(){yield*hr(e);let o=i.state.value.operations.get(c);if(o&&(!o.receipt||!Ph(o.receipt)))return yield*W(new ig({reason:`pending`}));if(r.input.action!==n)return yield*W(new ig({reason:`mismatch`}));let s={...r,requestId:yield*a.randomUUIDv4.pipe(Ze(e=>new Ct({message:`Could not create a Git recovery identity.`,cause:e})))};return yield*i.set(c,{...t,requestId:s.requestId,request:s}),s}));return yield*u(o)}))}),recover:G(`GitActionController.recover`)(function*(){return yield*e.request(C(function*(){yield*hr(e);let t=i.state.value.operations.get(c);return t?yield*u(t.request):yield*W(new ig({reason:`missing`}))}))}),startNew:G(`GitActionController.startNew`)(function*(){return yield*s.withPermit(C(function*(){let e=i.state.value.operations.get(c)?.receipt;return!e||!Ph(e)?!1:(yield*i.set(c,null),!0)}))})}}),og=class e extends Yi()(`@porcelain/client/GitActionController`){static layer(t){return jn(e,ag(t))}},sg=U(e=>e.connection.atoms(t=>_r(og.layer(e),lr(t(Bh(e.connection).layer),Jn(e.connection.runtime.contextEffect))))),cg=U(e=>sg(e).fn(e=>og.use(t=>t.execute(e)),{concurrent:!0})),lg=U(e=>sg(e).fn(e=>og.use(e=>e.recover()),{concurrent:!0})),ug=U(e=>sg(e).fn(e=>og.use(e=>e.startNew())));function dg(e,t){let n=cg(e),r=lg(e),i=ug(e),a=()=>{t.set(n,Et),t.set(r,Et)};return{run:G(`GitActions.run`)(function*(e,r){return t.set(n,{input:e,expected:r}),yield*vr(t,n,{suspendOnWaiting:!0})}),recover:G(`GitActions.recover`)(function*(){return t.set(r,void 0),yield*vr(t,r,{suspendOnWaiting:!0})}),startNew:G(`GitActions.startNew`)(function*(){t.set(i,void 0),(yield*vr(t,i,{suspendOnWaiting:!0}))&&a()}),reset:a}}var fg=U(e=>y(C(function*(){return dg(e,yield*ir)})));function pg(e,t,n){return{mode:e===`amend`?`amend`:`single`,message:e===`commit`?t:``,amendMessage:e===`amend`?t:n,excluded:new Set,added:new Set,groups:null}}function mg(e,t,n=new Set){return t.some(t=>!n.has(t.path)&&e.files?.find(e=>e.path===t.path)?.fingerprint!==t.fingerprint)}function hg(e,t=[],n,r=t.length>0){let i=new Set(t);return{headOid:e.headOid??void 0,inProgress:e.inProgress??void 0,mergeHeadOid:e.mergeHeadOid??void 0,branch:e.branch?.name?.replace(/^refs\/heads\//,``)??void 0,...n===void 0?{}:{upstreamOid:n},...r?{files:(e.files??[]).flatMap(e=>i.has(e.path)&&e.fingerprint!==null&&e.fingerprint!==void 0?[{path:e.path,fingerprint:e.fingerprint}]:[])}:{}}}var gg=e=>![`succeeded`,`no-change`].includes(e.state),_g=e=>e.message??(e.reason?e.reason.replaceAll(`_`,` `).toLowerCase():`Git ${e.state}`),vg=e=>e.state===`rejected`&&e.reason===`CHANGED_SINCE_LOOKED`;function yg(e){return e instanceof Error?e.message:`Git could not complete this action. Check the current state and try again.`}var bg=e=>t=>X(()=>{gn(t)||e.setError(wn(t))}),xg=G(`CommitForm.generate`)(function*(e,t,n=e.paths){let{model:r,working:i,setBusy:a,setError:o,generator:s,status:c,setDrafted:l,setDone:u,setActiveGroup:d,setMessage:f,setGroups:p}=e;if(!r||!n.length||i)return;a(!0),o(null),yield*Ui(()=>X(()=>a(!1)));let m=yield*s.submit({mode:t,model:r,paths:n,expectedStatusToken:c.statusToken});l(t,m.expectedFiles),u(new Set),d(null),t===`message`?(f(m.groups[0]?.message??``),p(null)):p(m.groups.map(t=>({...t,id:e.createId()})))},qa,(e,t)=>e.pipe(fs(bg(t)))),Sg=G(`CommitForm.commit`)(function*(e){let{working:t,uncertain:n,setBusy:r,setError:i,currentMessage:a,mode:o,commitAction:s,model:c,paths:l,generator:u,status:d,setMessage:f,setDrafted:p,groups:m,done:h,ownHead:g,onBusy:_,setActiveGroup:v,git:y,setOwnHead:b,setDone:x}=e;if(t||n)return;r(!0),i(null),yield*Ui(()=>X(()=>r(!1)));let S=a;if(o!==`groups`&&!S.trim()){if(s===`amend`)return yield*W(new vs(void 0,`Give the amended commit a message.`));if(!c||!l.length)return yield*W(new vs(void 0,`Give every commit a message and at least one file.`));let e=yield*u.submit({mode:`message`,model:c,paths:l,expectedStatusToken:d.statusToken});if(S=e.groups[0]?.message??``,f(S),p(`message`,e.expectedFiles),mg(d,e.expectedFiles))return}let C=s===`amend`?[{id:`single`,message:S,paths:l}]:o===`groups`&&m?m.filter(e=>!h.has(e.id)):[{id:`single`,message:S,paths:l}],w=g??d.headOid??null;_(!0),yield*Ui(()=>X(()=>_(!1)));for(let e of C){if(!e.message.trim()||s!==`amend`&&d.inProgress!==`merge`&&!e.paths.length)return yield*W(new vs(void 0,`Give every commit a message and at least one file.`));v(e.id);let t=yield*y.run({action:s,message:e.message,paths:e.paths},hg({...d,headOid:w},d.inProgress===`merge`?d.files?.map(e=>e.path)??[]:e.paths,void 0,!0));if(gg(t))return yield*W(new vs(void 0,_g(t)));t.result?.headOid&&(w=t.result.headOid,b(w)),x(t=>new Set([...t,e.id])),v(null)}},qa,(e,t)=>e.pipe(fs(bg(t)))),Cg=G(`CommitForm.lookAgain`)(function*(e){let{onLookAgain:t,working:n,setBusy:r,setError:i,git:a,setOwnHead:o}=e;t&&!n&&(r(!0),i(null),yield*Ui(()=>X(()=>r(!1))),yield*t,yield*a.startNew(),o(null))},qa,(e,t)=>e.pipe(fs(bg(t)))),wg=G(`CommitForm.recover`)(function*(e){let{setError:t,git:n,activeGroup:r,setDone:i,setActiveGroup:a}=e;t(null);let o=yield*n.recover();r&&[`succeeded`,`no-change`].includes(o.state)&&(i(e=>new Set([...e,r])),a(null))},(e,t)=>e.pipe(fs(bg(t))));function Tg(e){return{statusToken:e.statusToken,inProgress:e.inProgress,mergeHeadOid:e.mergeHeadOid,headOid:e.headOid,branch:e.branch,changes:e.changes.flatMap(e=>e.comparisons),files:e.changes.map(({path:e,fingerprint:t})=>({path:e,fingerprint:t}))}}function Eg(e,t){return e==null?t:t==null||t.name!==e.name||t.upstream!==e.upstream?e:{...t,name:e.name,upstream:e.upstream,ahead:e.ahead,behind:e.behind}}function Dg(e){return e.branch??null}function Og(e){return e.changes.some(e=>e.scope===`unmerged`)}function kg(e,t){let n=Dg(t);if(t.inProgress===`rebase`)return`Continue or abort the rebase in a terminal.`;if(t.inProgress===`merge`&&e!==`commit`)return`Finish or abort the merge first.`;if(t.inProgress===`merge`&&!t.mergeHeadOid)return`Finish this merge in a terminal.`;switch(e){case`commit`:return Og(t)&&t.inProgress!==`merge`?`Resolve the conflicts before committing.`:null;case`amend`:return Og(t)?`Resolve the conflicts before amending.`:t.headOid===null||t.headOid===void 0?`There is no commit to amend.`:null;case`push`:return n?n.name===null||n.name===void 0?`Detached HEAD: check out a branch before pushing.`:n.behind>0?`Pull the upstream changes before pushing.`:n.ahead>0||n.upstream===null||n.upstream===void 0?null:`No local commits to push.`:null;case`pull`:return n?.upstream===null||n?.upstream===void 0?`No upstream branch to pull from.`:t.changes.length?`Commit or stash local changes before pulling.`:n?.name===null?`Detached HEAD: check out a branch before pulling.`:null;case`fetch`:return n?.upstream===null||n?.upstream===void 0?`No upstream branch to fetch.`:null;case`stash-create`:return null;case`stash-apply`:case`stash-pop`:return n?.stashes&&n.stashes.length===0?`No stash is available.`:null;case`discard`:return null}}function Ag(e,t){let n=Dg(t);if(t.inProgress===`rebase`)return`Continue or abort the rebase in a terminal.`;if(t.inProgress===`merge`&&e!==`commit`)return`Finish or abort the merge first.`;switch(e){case`commit`:return t.changes.length?null:`Nothing to commit.`;case`amend`:return t.changes.length?`Choose which changed files to add to the last commit.`:`Change the last commit message.`;case`push`:return n==null?`Enter the configured remote and full branch ref.`:null;case`pull`:case`fetch`:return n==null?`Enter the configured remote and full branch ref.`:null;case`stash-create`:return t.changes.length===0?`Nothing changed; the server will report no change.`:null;case`stash-apply`:case`stash-pop`:return n?.stashes===null||n?.stashes===void 0?`Enter a full stash object ID.`:null;case`discard`:return null}}function jg(e,t){let n=Dg(t);return e.kind!==`run`||n==null?null:e.action===`pull`?n.behind:n.ahead}function Mg(e){if(e.inProgress===`rebase`||e.inProgress===`merge`&&!e.mergeHeadOid)return{kind:`hint`,label:`Git recovery`,hint:`Finish or abort this operation in a terminal.`};if(e.inProgress===`merge`||e.changes.length>0)return{kind:`commit`,label:`Commit`};let t=Dg(e);return t==null?{kind:`hint`,label:`Commit`,hint:`Nothing to commit. Choose a Git action to continue.`}:t.name===null||t.name===void 0?{kind:`hint`,label:`Commit`,hint:`Detached HEAD: check out a branch before pushing.`}:t.behind>0?{kind:`run`,action:`pull`,label:`Pull`}:t.ahead>0?{kind:`run`,action:`push`,label:`Push`}:(t.stashes?.length??0)>0?{kind:`stash`,label:`Apply stash`}:{kind:`hint`,label:`Commit`,hint:`Nothing to commit, pull or push.`}}var Ng=G(`GitActions.restoreStash`)(function*(e,t,n,r,i){let a=yield*e.run({action:`stash-apply`,...t},n).pipe(so(e=>gg(e)?_g(e):null),rs(e=>Ai(yg(e))));r(a===null?{title:i.restored,type:`success`}:{title:i.failed,description:a,type:`error`})}),Pg=G(`Discard.restore`)(function*({what:e,readChanges:t,notify:n,dismissNotice:r,restore:i},a,o,s){let c=yield*t().pipe(so(Tg),rs(t=>X(()=>(n({title:`Could not restore ${e}`,description:yg(t),type:`error`}),null))));if(!c)return;let l=c.files?.filter(e=>e.fingerprint!==null&&e.fingerprint!==void 0).map(e=>e.path)??[];r(s),yield*Ng(i,{stashOid:a,restoreIndex:o},hg(c,l,void 0,!0),n,{restored:`Restored ${e}`,failed:`Could not restore ${e}`})});function Fg(e,t){let{what:n,notify:r,close:i}=e;if(gg(t))return{text:_g(t),moved:vg(t)};i();let a=t.result?.restoreStashOid;if(t.state===`no-change`)return r({title:`Nothing to discard`,description:`${n} already matches the last commit.`,type:`info`}),null;let o=t.result?.restoreIndex??!1,s=r({title:`Discarded ${n}`,type:`success`,timeout:e.restoreTimeoutMs,...a?{actionProps:{children:`Restore`,onClick:()=>e.run(Pg(e,a,o,s))}}:{}});return null}var Ig=G(`Discard.finish`)(function*(e,t){return Fg(t,yield*e)});function Lg(e){return e===`fetch`||e===`pull`||e===`push`}function Rg(e,t,n){return e?n&&(e.branch?.name!==t?.name||e.branch?.upstream!==t?.upstream)?{ready:!1,reason:`The branch target changed. Review it and try again.`}:{ready:!0,looked:e}:{ready:!1,reason:`The branch target is still loading. Try again.`}}function zg(e,t,n){if(!t?.name)throw Error(`Check out a branch before using the remote.`);let r=t.name.replace(/^refs\/heads\//,``);if(e===`fetch`||e===`pull`){if(!t?.upstream||!t.remoteName||!t.sourceRef)throw Error(`Configure an upstream branch first.`);if(`${t.remoteName}/${t.sourceRef.replace(/^refs\/heads\//,``)}`!==t.upstream)throw Error(`The configured upstream changed. Review it and try again.`);return e===`fetch`?{action:e,remoteName:t.remoteName,sourceRef:t.sourceRef}:{action:e,remoteName:t.remoteName,sourceRef:t.sourceRef,strategy:n}}let i=t.sourceRef??`refs/heads/${r}`;return{action:e,remoteName:t.remoteName??`origin`,destinationRef:i,allowCreate:t?.upstream===null||t?.upstream===void 0}}var Bg=e=>e===`fetch`?`Fetch`:e===`pull`?`Pull`:`Push`,Vg=e=>e===`fetch`?`Fetching`:e===`pull`?`Pulling`:`Pushing`,Hg=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function Ug(e,t){if(e.kind===`hint`)return e.hint;if(e.kind===`commit`)return`Commit ${Hg(t.changes.length,`changed file`)}`;let n=Dg(t);if(e.kind===`stash`){let e=n?.stashes?.[0]?.message;return e?`Apply the stash “${e}”`:`Apply the latest stash`}let r=n?.upstream??`the configured remote`;return e.action===`pull`?`Pull from ${r}`:`Push ${Hg(n?.ahead??0,`commit`)} to ${r}`}var Wg=G(`GitMenu.runNetwork`)(function*(e,t,n,r){let{details:i}=e,a=e.onResult,o=Bg(n),s=Ki(i.result)?i.result.value:void 0,c=!s;c&&e.enableDetails();let l=Rg(s??(yield*i.read()),r,c);if(!l.ready){a({title:`${o} did not run`,description:l.reason,type:`error`});return}let{looked:u}=l,d=zg(n,u.branch,e.pullStrategy),f=yield*Oa(X(()=>e.onProgress(!0)),()=>t.run(d,hg(u,[],u.branch?.upstreamOid??null)),()=>X(()=>e.onProgress(!1)));a({title:gg(f)?`${o} did not run`:o,description:_g(f),type:gg(f)?`error`:`success`})},(e,t,n,r)=>e.pipe(rs(e=>X(()=>t.onResult({title:`${Bg(r)} did not run`,description:yg(e),type:`error`}))))),Gg=G(`GitMenu.restoreDiscarded`)(function*(e,t,n){let{details:r,notify:i}=e,a=n.kind===`rename`?`rename of ${n.path}`:`hunk of ${n.path}`,o=Wi(Qr(r.result));(!o||Pa(r.result))&&(e.enableDetails(),o=yield*r.read()),yield*Ng(t,{stashOid:n.oid,restoreIndex:n.kind===`rename`},hg(o,[n.path],void 0,!0),i,{restored:`Restored the discarded ${a}`,failed:`Could not restore the discarded ${a}`})},(e,t,n,r)=>e.pipe(rs(e=>X(()=>t.notify({title:`Could not restore the discarded ${r.kind===`rename`?`rename of ${r.path}`:`hunk of ${r.path}`}`,description:yg(e),type:`error`}))))),Kg=G(`GitActions.lookAgain`)(function*(e,t){yield*e,yield*t}),qg=G(`GitActions.refreshLook`)(function*(e,t){t(Tg(yield*e))});function Jg(e){return Mh.of({read:()=>ae(()=>{if(!e)throw Error(`Pair this environment again to identify its pending Git operations.`);return window.sessionStorage.getItem(e)}),write:t=>ae(()=>{if(!e)throw Error(`Pending Git operations require an identified connection.`);window.sessionStorage.setItem(e,t)}),clear:()=>ae(()=>{if(!e)throw Error(`Pending Git operations require an identified connection.`);window.sessionStorage.removeItem(e)})})}var Yg=yo(`@effect/platform-browser/Crypto/WebCrypto`,{defaultValue:()=>globalThis.crypto}),Xg=jn(dp,C(function*(){let e=yield*Yg;return e?fp({randomBytes:t=>{let n=new Uint8Array(t);for(let t=0;t<n.length;t+=65536)e.getRandomValues(n.subarray(t,t+65536));return n},digest:(t,n)=>typeof e.subtle?.digest==`function`?so(Sn({try:()=>e.subtle.digest(t,new Uint8Array(n)),catch:e=>zs({module:`Crypto`,method:`digest`,_tag:`Unknown`,description:`Could not compute digest`,cause:e})}),e=>new Uint8Array(e)):W(zs({module:`Crypto`,method:`digest`,_tag:`Unknown`,description:`crypto.subtle.digest is not available`}))}):yield*fa(Error(`Web Crypto API is not available`))}));function Zg(e){if(!e)throw Error(`A connected environment is required`);return e}var Qg={name:()=>typeof navigator>`u`?`Browser`:navigator.userAgent.slice(0,120)||`Browser`,send:fetch,statusActivity:wh};function $g(e,t){return Yh({environmentId:e,address:t.address,transport:t.transport,liveUpdates:t.liveUpdates,timeoutMs:$e},Je(Xg,Qt(Mh,Jg(t.operationsKey))),a_.memoMap)}function e_({inventory:e,principal:t}){let n=t.kind===`owner`?`owner`:t.deviceId,r=$g(e.environmentId,{address:window.location.href,transport:ah(fetch),liveUpdates:Qh(),operationsKey:`porcelain-git-requests:${JSON.stringify([e.environmentId,t.kind,n])}`});return r.atoms.addGlobalLayer(Qt(zm,ms(e))),r}function t_(e){return Xh({...e,send:fetch,socket:Zh,onStatusChange:()=>tm(Qg,e),timeoutMs:$e},Je(Xg,Qt(Mh,Jg(e.deviceId?`porcelain-git-requests:${JSON.stringify([e.environmentId,e.address,e.deviceId])}`:void 0))),a_.memoMap)}var n_=Je(Rp.layer,Xm.layer).pipe(rr(Qt(Tp,Ah))),r_=lr(n_,Qt(Ep,Qg),Ke.layer,Qt(zp,{local:e=>Qa(X(()=>e_(e)),e=>Ao(()=>e.close()))}),Qt(Bp,{open:e=>Qa(X(()=>t_(e)),e=>Ao(()=>e.close()))}),Qt(Zm,{forgetEnvironment:()=>Qi})),i_=Up.pipe(_r(lr($m.layer,Vp.layer,Hp.layer).pipe(_r(r_)))),a_=Yt(i_),o_=Gt({memoMap:a_.memoMap})(i_),s_=a_.runSync(Rp),c_=a_.runSync(Vp),l_=a_.runSync(Hp),u_=o_.atom(C(function*(){yield*(yield*$m).read()}));function d_(){ga(u_)}function f_(){return Pr(s_.state)}function p_(){return Pr(c_.state).connection}function m_(){return Pr(l_.state)}function h_(e){let t=(0,$.c)(5),n=Pr(l_.state),r;if(t[0]!==e||t[1]!==n){let i;t[3]===e?i=t[4]:(i=t=>t.remote.environmentId===e,t[3]=e,t[4]=i),r=n.find(i),t[0]=e,t[1]=n,t[2]=r}else r=t[2];return r}function g_(e){let t=(0,$.c)(6),n=p_();if(e){let n;return t[0]===e?n=t[1]:(n={connection:e},t[0]=e,t[1]=n),n}let r;t[2]===n?r=t[3]:(r=Zg(n),t[2]=n,t[3]=r);let i;return t[4]===r?i=t[5]:(i={connection:r},t[4]=r,t[5]=i),i}var __=cm({transport:ah(fetch),platform:Qg});function v_(e,t,n){return a_.runPromise(Jm(e,__,t,$e),{signal:n})}var y_=Wm(ah(fetch,{reportUnauthorized:!1}));function b_(e){return a_.runPromise(Ym(e,y_))}var x_=U(e=>o_.fn(e=>C(function*(){let t=yield*(yield*$m).pair({value:e,localEnvironmentId:c_.state.value.connection?.environmentId}).pipe(mn($e));return tm(Qg,t),t}))),S_=U(e=>o_.fn(t=>C(function*(){yield*(yield*$m).forget(e.environmentId)}))),C_=o_.fn(e=>C(function*(){yield*(yield*$m).read()})),w_=Be(e=>X(()=>{tm(Qg,e)}));function T_(e){let t=(0,$.c)(12),[n]=(0,Z.useState)(Symbol),r;t[0]===n?r=t[1]:(r=x_(n),t[0]=n,t[1]=r);let i=r,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a={mode:`promiseExit`},t[2]=a):a=t[2];let[o,s]=fo(i,a),c=So(i),l;t[3]!==e||t[4]!==s?(l=async t=>{let n=await s(t);Er(n)&&e()},t[3]=e,t[4]=s,t[5]=l):l=t[5];let u;t[6]===c?u=t[7]:(u=()=>c(Et),t[6]=c,t[7]=u);let d;return t[8]!==o||t[9]!==l||t[10]!==u?(d={result:o,submit:l,reset:u},t[8]=o,t[9]=l,t[10]=u,t[11]=d):d=t[11],d}function E_(e){let t=(0,$.c)(7),n;t[0]===e?n=t[1]:(n=S_(e),t[0]=e,t[1]=n);let[r,i]=fo(n),a;t[2]===i?a=t[3]:(a=()=>i(void 0),t[2]=i,t[3]=a);let o;return t[4]!==r||t[5]!==a?(o={result:r,submit:a},t[4]=r,t[5]=a,t[6]=o):o=t[6],o}function D_(){return So(w_)}function O_(){let e=(0,$.c)(5),[t,n]=fo(C_),r;e[0]===n?r=e[1]:(r=()=>n(void 0),e[0]=n,e[1]=r);let i;return e[2]!==t||e[3]!==r?(i={result:t,read:r},e[2]=t,e[3]=r,e[4]=i):i=e[4],i}function k_(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Z.useEffect)(A_,t),ih}function A_(){return rh(j_)}function j_(){a_.runFork(c_.clear())}function M_(e){let t=(0,$.c)(5),n;t[0]===e?n=t[1]:(n=rm(Qg,e),t[0]=e,t[1]=n);let r=ga(n),i;return t[2]!==e||t[3]!==r?(i=$p(e,r),t[2]=e,t[3]=r,t[4]=i):i=t[4],i}var N_=Ie(`group/alert relative grid w-full gap-0.5 rounded-2xl border px-4 py-3 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current`}},defaultVariants:{variant:`default`}});function P_({className:e,variant:t,...n}){return(0,Q.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:K(N_({variant:t}),e),...n})}function F_({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`alert-title`,className:K(`font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground`,e),...t})}function I_({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`alert-description`,className:K(`text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4`,e),...t})}function L_({className:e,...t}){return(0,Q.jsx)(ht,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:K(`size-4 animate-spin`,e),...t})}var R_=U(e=>o_.fn((t,n)=>C(function*(){yield*n.setResult(qm(e),void 0),yield*(yield*Vp).clear()})));function z_(e){let t=(0,$.c)(8),n;t[0]===e?n=t[1]:(n=R_(e),t[0]=e,t[1]=n);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r={mode:`promiseExit`},t[2]=r):r=t[2];let[i,a]=fo(n,r),o;t[3]===a?o=t[4]:(o=()=>{a()},t[3]=a,t[4]=o);let s;return t[5]!==i||t[6]!==o?(s={result:i,submit:o},t[5]=i,t[6]=o,t[7]=s):s=t[7],s}function B_(){let e=(0,$.c)(12),{connection:t}=g_(),{result:n,submit:r}=z_(t),i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:`This browser`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Ends its session here. Pair it again with a new link.`})]}),e[0]=i):i=e[0];let a;e[1]===n.waiting?a=e[2]:(a=n.waiting?(0,Q.jsx)(L_,{}):(0,Q.jsx)(Rf,{}),e[1]=n.waiting,e[2]=a);let o;e[3]!==n.waiting||e[4]!==r||e[5]!==a?(o=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-6`,children:[i,(0,Q.jsxs)(w,{variant:`outline`,className:`shrink-0`,disabled:n.waiting,onClick:r,children:[a,`Disconnect this browser`]})]}),e[3]=n.waiting,e[4]=r,e[5]=a,e[6]=o):o=e[6];let s;e[7]===n?s=e[8]:(s=Pa(n)&&(0,Q.jsx)(P_,{variant:`destructive`,children:(0,Q.jsx)(I_,{children:Km(wn(n.cause))})}),e[7]=n,e[8]=s);let c;return e[9]!==o||e[10]!==s?(c=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[o,s]}),e[9]=o,e[10]=s,e[11]=c):c=e[11],c}function V_(e){let t=(0,$.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsx)(`div`,{className:`absolute right-4 top-3`,children:(0,Q.jsx)(`h1`,{className:`font-medium`,children:`Porcelain`})}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,Q.jsxs)(Q.Fragment,{children:[r,(0,Q.jsx)(`main`,{className:`mx-auto flex min-h-svh max-w-6xl flex-col items-start gap-6 px-6 py-24`,children:n})]}),t[1]=n,t[2]=i),i}function H_(){return typeof window>`u`?`http://127.0.0.1:3000`:window.location.origin}function U_(e){let t=(0,$.c)(9),{reason:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-medium`,children:`This browser is not paired`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Run this on the machine hosting Porcelain, then open the link it prints on this device.`})]}),t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(`pre`,{className:`overflow-x-auto rounded-md border bg-muted p-3 text-sm`,children:(0,Q.jsx)(`code`,{children:`porcelain pair "This browser" --address ${H_()}`})}),t[1]=i):i=t[1];let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(`code`,{children:`porcelain devices`}),t[2]=a):a=t[2];let o,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`The link works once and expires. Revoke this device at any time with`,` `,a,` and `,(0,Q.jsx)(`code`,{children:`porcelain revoke`}),`.`]}),s=!1,t[3]=o,t[4]=s):(o=t[3],s=t[4]);let c;t[5]===n?c=t[6]:(c=n&&(0,Q.jsx)(P_,{variant:`destructive`,children:(0,Q.jsx)(I_,{children:n})}),t[5]=n,t[6]=c);let l;return t[7]===c?l=t[8]:(l=(0,Q.jsxs)(`section`,{className:`mx-auto flex w-full max-w-md flex-col gap-6`,children:[r,i,o,s,c]}),t[7]=c,t[8]=l),l}function W_(e){let t=(0,$.c)(2),{reason:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Q.jsx)(V_,{children:n?(0,Q.jsx)(U_,{reason:n}):(0,Q.jsxs)(`section`,{className:`mx-auto flex w-full max-w-md flex-col gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-medium`,children:`Pairing this browser…`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Checking that the link belongs to this Porcelain installation.`})]})}),t[0]=n,t[1]=r),r}function G_(e){let t=(0,$.c)(3),n;t[0]===e?n=t[1]:(n=Nm(e),t[0]=e,t[1]=n);let r;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r={mode:`promise`},t[2]=r):r=t[2],fo(n,r)}function K_(e,t){let n=(0,$.c)(3),r;return n[0]!==e||n[1]!==t?(r=Pm({connection:e,id:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2],fo(r)}function q_(e,t){let n=(0,$.c)(3),r;return n[0]!==e||n[1]!==t?(r=Fm({connection:e,id:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2],fo(r)}function J_(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=Im(e),t[0]=e,t[1]=n),fo(n)}function Y_(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=Lm(e),t[0]=e,t[1]=n),fo(n)}function X_(e){let t=(0,$.c)(3),n;t[0]===e?n=t[1]:(n=Hm(e),t[0]=e,t[1]=n);let r;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r={mode:`promise`},t[2]=r):r=t[2],fo(n,r)}function Z_(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=Dm(e),t[0]=e,t[1]=n),ga(n)}function Q_(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=Om(e),t[0]=e,t[1]=n),ga(n)}function $_(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=km(e),t[0]=e,t[1]=n),ga(n)}function ev(e){return e.kind===`local`?`Only a browser on the computer that runs Porcelain, or a device its owner trusts, can update it.`:e.deviceId?`Trust this app on ${e.name} to update it from here: run porcelain trust ${e.deviceId} there.`:`Trust this app on ${e.name} to update it from here: run porcelain devices there, then porcelain trust with this app's id.`}function tv(e){let t=(0,$.c)(17),{state:n,started:r}=e,i;t[0]===n?i=t[1]:(i=Eh(n),t[0]=n,t[1]=i);let a=i;if(a?.kind===`updated`){let e=`Updated from ${a.from} to ${a.target}.${r?` Reload to use the new version here.`:``}`,n;t[2]===e?n=t[3]:(n=(0,Q.jsx)(P_,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(I_,{children:e})}),t[2]=e,t[3]=n);let i;t[4]===r?i=t[5]:(i=r&&(0,Q.jsx)(w,{size:`sm`,variant:`outline`,onClick:nv,children:`Reload`}),t[4]=r,t[5]=i);let o;return t[6]!==n||t[7]!==i?(o=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[n,i]}),t[6]=n,t[7]=i,t[8]=o):o=t[8],o}if(a?.kind===`failed`){let e=n.version??`the version it had`,r;t[9]!==a.target||t[10]!==e?(r=(0,Q.jsxs)(`p`,{children:[`The update to `,a.target,` failed, so Porcelain still runs`,` `,e,`.`]}),t[9]=a.target,t[10]=e,t[11]=r):r=t[11];let i;t[12]===a.reason?i=t[13]:(i=(0,Q.jsx)(`p`,{children:a.reason}),t[12]=a.reason,t[13]=i);let o;return t[14]!==r||t[15]!==i?(o=(0,Q.jsx)(P_,{variant:`destructive`,children:(0,Q.jsxs)(I_,{children:[r,i]})}),t[14]=r,t[15]=i,t[16]=o):o=t[16],o}return null}function nv(){return window.location.reload()}function rv(e){let t=(0,$.c)(22),{connection:n,target:r,state:i,onStart:a}=e,[o,s]=Y_(n),{latest:c}=i;if(!i.available||c==null){let e=c==null?`Could not check for a newer version.`:`This is the newest version.`,n;return t[0]===e?n=t[1]:(n=(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e}),t[0]=e,t[1]=n),n}let l;t[2]===c?l=t[3]:(l=(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Porcelain `,c,` is available.`]}),t[2]=c,t[3]=l);let u;t[4]!==c||t[5]!==a||t[6]!==o||t[7]!==s||t[8]!==i.canUpdate?(u=i.canUpdate&&(0,Q.jsxs)(w,{size:`sm`,disabled:o.waiting,onClick:()=>{a(),s(c)},children:[o.waiting&&(0,Q.jsx)(L_,{}),`Update to `,c]}),t[4]=c,t[5]=a,t[6]=o,t[7]=s,t[8]=i.canUpdate,t[9]=u):u=t[9];let d;t[10]!==l||t[11]!==u?(d=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[l,u]}),t[10]=l,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==i.canUpdate||t[14]!==r?(f=!i.canUpdate&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:ev(r)}),t[13]=i.canUpdate,t[14]=r,t[15]=f):f=t[15];let p;t[16]===o?p=t[17]:(p=Pa(o)&&(0,Q.jsx)(P_,{variant:`destructive`,children:(0,Q.jsx)(I_,{children:Km(wn(o.cause))})}),t[16]=o,t[17]=p);let m;return t[18]!==d||t[19]!==f||t[20]!==p?(m=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[d,f,p]}),t[18]=d,t[19]=f,t[20]=p,t[21]=m):m=t[21],m}function iv(e){let t=(0,$.c)(15),{connection:n,target:r,state:i,progress:a,started:o,onStart:s}=e;if(!i.managed){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This server runs outside the installed service. Update it with npm, then run porcelain service update.`}),t[0]=e):e=t[0],e}if(a){let e;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(L_,{}),t[1]=e):e=t[1];let n;return t[2]===a?n=t[3]:(n=(0,Q.jsxs)(`div`,{"aria-live":`polite`,className:`flex items-center gap-2 text-sm`,children:[e,(0,Q.jsx)(`p`,{children:a})]}),t[2]=a,t[3]=n),n}let c;t[4]!==o||t[5]!==i?(c=(0,Q.jsx)(tv,{state:i,started:o}),t[4]=o,t[5]=i,t[6]=c):c=t[6];let l;t[7]!==n||t[8]!==s||t[9]!==i||t[10]!==r?(l=(0,Q.jsx)(rv,{connection:n,target:r,state:i,onStart:s}),t[7]=n,t[8]=s,t[9]=i,t[10]=r,t[11]=l):l=t[11];let u;return t[12]!==c||t[13]!==l?(u=(0,Q.jsxs)(Q.Fragment,{children:[c,l]}),t[12]=c,t[13]=l,t[14]=u):u=t[14],u}function av(e){let t=(0,$.c)(16),{connection:n,target:r}=e,i=$_(n),[a,o]=(0,Z.useState)(!1),s,c,l;if(t[0]!==i){l=Symbol.for(`react.early_return_sentinel`);bb0:{if(s=Wi(Qr(i)),!s){l=Pa(i)?(0,Q.jsx)(P_,{variant:`destructive`,children:(0,Q.jsx)(I_,{children:Km(wn(i.cause))})}):(0,Q.jsx)(L_,{});break bb0}c=Th(s,Pa(i))}t[0]=i,t[1]=s,t[2]=c,t[3]=l}else s=t[1],c=t[2],l=t[3];if(l!==Symbol.for(`react.early_return_sentinel`))return l;let u=c,d=s.version??`development build`,f;t[4]===d?f=t[5]:(f=(0,Q.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Porcelain `,d]}),t[4]=d,t[5]=f);let p=a&&r.kind===`local`,m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>o(!0),t[6]=m):m=t[6];let h;t[7]!==n||t[8]!==u||t[9]!==s||t[10]!==p||t[11]!==r?(h=(0,Q.jsx)(iv,{connection:n,target:r,state:s,progress:u,started:p,onStart:m}),t[7]=n,t[8]=u,t[9]=s,t[10]=p,t[11]=r,t[12]=h):h=t[12];let g;return t[13]!==f||t[14]!==h?(g=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f,h]}),t[13]=f,t[14]=h,t[15]=g):g=t[15],g}function ov(){let e=(0,$.c)(2),t=p_(),n;return e[0]===t?n=e[1]:(n=t&&(0,Q.jsx)(av,{connection:t,target:{kind:`local`}}),e[0]=t,e[1]=n),n}function sv(e){let t=(0,$.c)(6),{connection:n,name:r,deviceId:i}=e,a;t[0]!==i||t[1]!==r?(a={kind:`remote`,name:r,deviceId:i},t[0]=i,t[1]=r,t[2]=a):a=t[2];let o;return t[3]!==n||t[4]!==a?(o=(0,Q.jsx)(av,{connection:n,target:a}),t[3]=n,t[4]=a,t[5]=o):o=t[5],o}function cv({className:e,...t}){return(0,Q.jsx)(`label`,{"data-slot":`label`,className:K(`flex items-center gap-2 text-sm 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`,e),...t})}function lv({className:e,...t}){return(0,Q.jsx)(`fieldset`,{"data-slot":`field-set`,className:K(`flex flex-col gap-6 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3`,e),...t})}function uv({className:e,variant:t=`legend`,...n}){return(0,Q.jsx)(`legend`,{"data-slot":`field-legend`,"data-variant":t,className:K(`mb-3 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base`,e),...n})}function dv({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`field-group`,className:K(`group/field-group @container/field-group flex w-full flex-col gap-6 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4`,e),...t})}var fv=Ie(`group/field flex w-full gap-3 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 pv({className:e,orientation:t=`vertical`,...n}){return(0,Q.jsx)(`div`,{role:`group`,"data-slot":`field`,"data-orientation":t,className:K(fv({orientation:t}),e),...n})}function mv({className:e,...t}){return(0,Q.jsx)(cv,{"data-slot":`field-label`,className:K(`group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:bg-input/30 has-[>[data-slot=field]]:rounded-2xl 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-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-4`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col`,e),...t})}function hv({className:e,...t}){return(0,Q.jsx)(`p`,{"data-slot":`field-description`,className:K(`text-left text-sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5`,`last:mt-0 nth-last-2:-mt-1`,`[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function gv({className:e,children:t,errors:n,...r}){let i=(0,Z.useMemo)(()=>{if(t)return t;if(!n?.length)return null;let e=[...new Map(n.map(e=>[e?.message,e])).values()];return e?.length==1?e[0]?.message:(0,Q.jsx)(`ul`,{className:`ml-4 flex list-disc flex-col gap-1`,children:e.map((e,t)=>e?.message&&(0,Q.jsx)(`li`,{children:e.message},t))})},[t,n]);return i?(0,Q.jsx)(`div`,{role:`alert`,"data-slot":`field-error`,className:K(`text-sm font-normal text-destructive`,e),...r,children:i}):null}function _v(e){return B(e.defaultTagName??`div`,e,e)}function vv({className:e,...t}){return(0,Q.jsx)(`div`,{role:`list`,"data-slot":`item-group`,className:K(`group/item-group flex w-full flex-col gap-4 has-data-[size=sm]:gap-2.5 has-data-[size=xs]:gap-2`,e),...t})}var yv=Ie(`group/item flex w-full flex-wrap items-center rounded-2xl border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted`,{variants:{variant:{default:`border-transparent`,outline:`border-border`,muted:`border-transparent bg-muted/50`},size:{default:`gap-3.5 px-4 py-3.5`,sm:`gap-3.5 px-3.5 py-3`,xs:`gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0`}},defaultVariants:{variant:`default`,size:`default`}});function bv({className:e,variant:t=`default`,size:n=`default`,render:r,...i}){return _v({defaultTagName:`div`,props:Rt({className:K(yv({variant:t,size:n,className:e}))},i),render:r,state:{slot:`item`,variant:t,size:n}})}var xv=Ie(`flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none`,{variants:{variant:{default:`bg-transparent`,icon:`[&_svg:not([class*='size-'])]:size-4`,image:`size-10 overflow-hidden rounded-xl group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 group-data-[size=xs]/item:rounded-lg [&_img]:size-full [&_img]:object-cover`}},defaultVariants:{variant:`default`}});function Sv({className:e,variant:t=`default`,...n}){return(0,Q.jsx)(`div`,{"data-slot":`item-media`,"data-variant":t,className:K(xv({variant:t,className:e})),...n})}function Cv({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`item-content`,className:K(`flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0.5 [&+[data-slot=item-content]]:flex-none`,e),...t})}function wv({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`item-title`,className:K(`line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4`,e),...t})}function Tv({className:e,...t}){return(0,Q.jsx)(`p`,{"data-slot":`item-description`,className:K(`line-clamp-2 text-left text-sm font-normal text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function Ev({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`item-actions`,className:K(`flex items-center gap-2`,e),...t})}function Dv({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`item-footer`,className:K(`flex basis-full items-center justify-between gap-2`,e),...t})}var Ov=Se(Nt.layer),kv=Ov.atom(C(function*(){let e=yield*Nt;return{isDesktopShell:e.isDesktopShell,hasAppUpdateFeed:e.hasAppUpdateFeed}})),Av=Ov.atom(C(function*(){return yield*(yield*Nt).checkUpdate})).pipe(sn),jv=Ov.atom(xn(C(function*(){return(yield*Nt).updateStates}))).pipe(nt(0));function Mv(){let e=(0,$.c)(3),t=ga(Av),n=Ba(Av),r;return e[0]!==t||e[1]!==n?(r={result:t,check:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],r}function Nv(){let e=(0,$.c)(2),t=ga(jv),n;return e[0]===t?n=e[1]:(n=eo(Qr(t),Pv),e[0]=t,e[1]=n),n}function Pv(){return{status:`idle`}}function Fv(){return ga(kv)}var Iv=`data-valid`,Lv=`data-invalid`,Rv={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},zv={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Bv={valid(e){return e===null?null:e?{[Iv]:``}:{[Lv]:``}}},Vv={invalid:void 0,name:void 0,validityData:{state:Rv,errors:[],error:``,value:``,initialValue:null},setValidityData:ja,disabled:void 0,setTouched:ja,setDirty:ja,setFilled:ja,setFocused:ja,validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:zv,registerFieldControl:ja,validation:{getValidationProps:(e,t=jo)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:ja,getInputControl:()=>null,commit:async()=>{},change:ja}},Hv=Z.createContext(Vv);function Uv(e=!0){let t=Z.useContext(Hv);if(t.setValidityData===ja&&!e)throw Error(or(28));return t}var Wv=Z.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:ja,validationMode:`onSubmit`,submitCountRef:{current:0}});function Gv(){return Z.useContext(Wv)}var Kv=Z.createContext({controlId:void 0,registerControlId:ja,resetControlId:ja,labelId:void 0,setLabelId:ja,messageIds:[],setMessageIds:ja,getDescriptionProps:e=>e});function qv(){return Z.useContext(Kv)}function Jv(e,t,n,r=!0,i){let[a,o]=Z.useState(),s=zf(i?`${i}-label`:void 0),c=e??t??a;return q(()=>{let i=e||t||!r?void 0:Yv(n.current,s);a!==i&&o(i)}),c}function Yv(e,t){let n=Xv(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function Xv(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}function Zv(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=qv(),o=zf(),s=tn(()=>Symbol()),c=Z.useRef(!1),l=Z.useRef(!1),u=Y(()=>{c.current&&i!==ja&&(c.current=!1,i(s.current,void 0))});return q(()=>{if(!n||i===ja){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}if(e===void 0){u();return}c.current=!0,i(s.current,e)},[t,n,i,a,o,s,u]),q(()=>u,[u]),(n?r:void 0)??t??o}function Qv({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=Z.useRef(e!==void 0),[a,o]=Z.useState(t);return[i&&e!==void 0?e:a,Z.useCallback(e=>{i||o(e)},[])]}function $v(e,t,n,r,i=!0,a){let{registerFieldControl:o}=Uv(),s=tn(()=>Symbol());q(()=>{let c=s.current;if(!i){o(c,void 0);return}o(c,{controlRef:e,getValue:r,id:t,name:a,value:n})},[e,i,r,t,a,o,s,n]),q(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}function ey(e,t){let n=Z.useRef(e),r=Y(t);q(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}var ty=Z.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFocused:y,setFilled:b,validationMode:x,validation:S}=Uv(),{clearErrors:C,elementRef:w,submitCountRef:T}=Gv(),E=h||s,D=m??a,O={...p,disabled:E},{labelId:k}=qv(),A=Zv({id:i}),[j]=Qv({controlled:o,default:l,name:`FieldControl`,state:`value`}),M=o!==void 0,N=M?j:void 0,P=N==null?void 0:String(N),F=Y(()=>S.inputRef.current?.value);$v(S.inputRef,A,P,F,!E,a),q(()=>{let e=P??S.inputRef.current?.value;e!==void 0&&b(e!==``)},[P,S.inputRef,b]),ey(P,()=>{P!==void 0&&(C(D),_(P!==(v.initialValue??``)),S.change(P))});let I=Z.useRef(null),L=vn();return q(()=>{u&&I.current===Za(ce(I.current))&&y(!0)},[u,y]),B(`input`,e,{ref:[t,I],state:O,props:[{id:A,disabled:E,name:D,ref:S.inputRef,"aria-labelledby":k,autoFocus:u,...M?{value:N}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=Qe(Ir,e.nativeEvent);c?.(t,n),!M&&(_(t!==(v.initialValue??``)),b(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(C(D),S.change(t)))},onFocus(){y(!0)},onBlur(e){if(g(!0),y(!1),x===`onBlur`){let t=e.currentTarget.value;S.commit(t),M&&queueMicrotask(()=>{let e=S.inputRef.current?.value;e!==void 0&&e!==t&&e!==(v.initialValue??``)&&S.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){g(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===w.current&&!e.defaultPrevented){let t=e.currentTarget,n=T.current;L.start(0,()=>{T.current===n&&S.commit(t.value)})}else S.commit(t)}}},f,e=>S.getValidationProps(E,e)],stateAttributesMapping:Bv})}),ny=Z.forwardRef(function(e,t){return(0,Q.jsx)(ty,{ref:t,...e})});function ry({className:e,type:t,...n}){return(0,Q.jsx)(ny,{type:t,"data-slot":`input`,className:K(`h-8 w-full min-w-0 rounded-2xl border border-transparent bg-input/50 px-2.5 py-1 text-base transition-[color,box-shadow] duration-200 outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}function iy(e){e.catch(()=>void 0)}function ay(e,t){e.preventDefault(),iy(t())}function oy(e){let t=(0,$.c)(25),{connection:n,environment:r}=e,[i,a]=(0,Z.useState)(null),[o,s]=X_(n),c=i??(r.custom?r.name:``),l;t[0]===c?l=t[1]:(l=c.trim(),t[0]=c,t[1]=l);let u=l,d=r.custom?u===r.name:u===``,f;t[2]!==u||t[3]!==s?(f=e=>ay(e,async()=>s(u===``?null:u)),t[2]=u,t[3]=s,t[4]=f):f=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(cv,{htmlFor:`environment-name`,children:`Name of this computer`}),t[5]=p):p=t[5];let m=r.custom?`Host name`:r.name,h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>a(e.target.value),t[6]=h):h=t[6];let g;t[7]!==m||t[8]!==c?(g=(0,Q.jsx)(ry,{id:`environment-name`,className:`min-w-0 flex-1`,placeholder:m,maxLength:Rn,value:c,onChange:h}),t[7]=m,t[8]=c,t[9]=g):g=t[9];let _=d||o.waiting,v=o.waiting?`Saving…`:`Save`,y;t[10]!==_||t[11]!==v?(y=(0,Q.jsx)(w,{type:`submit`,variant:`outline`,disabled:_,children:v}),t[10]=_,t[11]=v,t[12]=y):y=t[12];let b;t[13]!==g||t[14]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[g,y]}),t[13]=g,t[14]=y,t[15]=b):b=t[15];let x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(hv,{children:`Paired devices show it so you know where they are connected. Leave it empty to use the host name.`}),t[16]=x):x=t[16];let S;t[17]===b?S=t[18]:(S=(0,Q.jsxs)(pv,{children:[p,b,x]}),t[17]=b,t[18]=S);let C;t[19]===o?C=t[20]:(C=Pa(o)&&(0,Q.jsx)(P_,{variant:`destructive`,children:(0,Q.jsx)(I_,{children:Km(wn(o.cause))})}),t[19]=o,t[20]=C);let T;return t[21]!==S||t[22]!==C||t[23]!==f?(T=(0,Q.jsxs)(`form`,{className:`flex flex-col gap-2`,onSubmit:f,children:[S,C]}),t[21]=S,t[22]=C,t[23]=f,t[24]=T):T=t[24],T}var sy=Se(Nt.layer).fn(e=>C(function*(){yield*(yield*Nt).installUpdate}));function cy(){let e=(0,$.c)(5),[t,n]=fo(sy),r;e[0]===n?r=e[1]:(r=()=>n(void 0),e[0]=n,e[1]=r);let i;return e[2]!==t||e[3]!==r?(i={result:t,install:r},e[2]=t,e[3]=r,e[4]=i):i=e[4],i}function ly(e){switch(e.status){case`checking`:return`Checking for a new version…`;case`downloading`:return`Downloading ${e.version}…`;case`ready`:return`${e.version} is ready; the app restarts to finish.`;case`installing`:return`Installing ${e.version}; the app restarts in a moment.`;default:return}}function uy(e){return e.status===`unavailable`?`This build updates by reinstalling; there is no update feed yet.`:`This is the newest version of the app.`}function dy(e){return e.isDesktopShell&&e.hasAppUpdateFeed}function fy(){let e=(0,$.c)(24),{result:t,check:n}=Mv(),r=cy(),i=Nv(),a=Wi(Qr(Fv())),o;e[0]===t?o=e[1]:(o=Wi(Oi(Qr(t))),e[0]=t,e[1]=o);let s=o;if(!s){let n;return e[2]===t?n=e[3]:(n=ho(t)?(0,Q.jsx)(L_,{}):null,e[2]=t,e[3]=n),n}let c;e[4]===i?c=e[5]:(c=ly(i),e[4]=i,e[5]=c);let l=c,u;e[6]!==r.result||e[7]!==i||e[8]!==t?(u=my(i,t,r.result),e[6]=r.result,e[7]=i,e[8]=t,e[9]=u):u=e[9];let d=u,f;e[10]===s.current?f=e[11]:(f=(0,Q.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Porcelain app `,s.current]}),e[10]=s.current,e[11]=f);let p;e[12]!==r||e[13]!==l||e[14]!==i||e[15]!==t?(p=(0,Q.jsx)(py,{progress:l,state:i,update:t,install:r}),e[12]=r,e[13]=l,e[14]=i,e[15]=t,e[16]=p):p=e[16];let m=a&&dy(a)&&(0,Q.jsx)(w,{size:`sm`,variant:`outline`,className:`self-start`,disabled:t.waiting||l!==void 0,onClick:n,children:`Check for updates`}),h;e[17]===d?h=e[18]:(h=d!==void 0&&(0,Q.jsx)(P_,{variant:`destructive`,children:(0,Q.jsx)(I_,{children:d})}),e[17]=d,e[18]=h);let g;return e[19]!==f||e[20]!==p||e[21]!==m||e[22]!==h?(g=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f,p,m,h]}),e[19]=f,e[20]=p,e[21]=m,e[22]=h,e[23]=g):g=e[23],g}function py(e){let t=(0,$.c)(18),{progress:n,state:r,update:i,install:a}=e;if(n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(L_,{}),t[0]=e):e=t[0];let r;return t[1]===n?r=t[2]:(r=(0,Q.jsxs)(`div`,{"aria-live":`polite`,className:`flex items-center gap-2 text-sm`,children:[e,(0,Q.jsx)(`p`,{children:n})]}),t[1]=n,t[2]=r),r}if(r.status===`available`){let e;t[3]===r.version?e=t[4]:(e=(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Porcelain app `,r.version,` is available.`]}),t[3]=r.version,t[4]=e);let n=i.waiting||a.result.waiting,o;t[5]===a?o=t[6]:(o=()=>a.install(),t[5]=a,t[6]=o);let s;t[7]!==r.version||t[8]!==n||t[9]!==o?(s=(0,Q.jsxs)(w,{size:`sm`,disabled:n,onClick:o,children:[`Update to `,r.version]}),t[7]=r.version,t[8]=n,t[9]=o,t[10]=s):s=t[10];let c;return t[11]!==e||t[12]!==s?(c=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[e,s]}),t[11]=e,t[12]=s,t[13]=c):c=t[13],c}if(r.status===`error`||Pa(i))return null;let o;t[14]===r?o=t[15]:(o=uy(r),t[14]=r,t[15]=o);let s;return t[16]===o?s=t[17]:(s=(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o}),t[16]=o,t[17]=s),s}function my(e,t,n){if(e.status===`error`)return e.message;if(Pa(t)&&!t.waiting)return Km(wn(t.cause));if(Pa(n))return Km(wn(n.cause))}var hy=Z.createContext(void 0);function gy(){let e=Z.useContext(hy);if(e===void 0)throw Error(or(63));return e}var _y=`data-checked`,vy=`data-unchecked`,yy={...Bv,checked(e){return e?{[_y]:``}:{[vy]:``}}},by=Z.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,"aria-labelledby":a,form:o,id:s,inputRef:c,name:l,nativeButton:u=!1,onCheckedChange:d,readOnly:f=!1,required:m=!1,disabled:h=!1,render:g,uncheckedValue:_,value:v,style:y,...b}=e,{clearErrors:x}=Gv(),{state:S,setTouched:C,setDirty:w,validityData:T,setFilled:E,setFocused:D,validationMode:O,disabled:k,name:A,validation:j}=Uv(),{labelId:M}=qv(),N=k||h,P=A??l,F=Z.useRef(null),I=p(F,c,j.inputRef),L=Z.useRef(null),R=zf(),z=Zv({id:s}),ee=u?void 0:z,[V,te]=Qv({controlled:n,default:!!i,name:`Switch`,state:`checked`});$v(L,R,V,void 0,!N,l),q(()=>{E(V)},[V,E]),ey(V,()=>{x(P),w(V!==T.initialValue),j.change(V)});let{getButtonProps:ne,buttonRef:re}=Ci({disabled:N,native:u}),ie=Jv(a,M,F,!u,ee),ae={id:u?z:R,role:`switch`,"aria-checked":V,"aria-readonly":f||void 0,"aria-required":m||void 0,"aria-labelledby":ie,onFocus(){N||D(!0)},onBlur(){let e=F.current;e&&!N&&(C(!0),D(!1),O===`onBlur`&&j.commit(e.checked))},onClick(e){if(f||N)return;e.preventDefault();let t=F.current;t&&Ya(t,e)}},oe={...j.getValidationProps(N),checked:V,disabled:N,form:o,id:ee,name:P,required:m,style:P?Ot:xt,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:I,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(f){e.preventDefault();return}let t=e.currentTarget.checked,n=Qe(Ir,e.nativeEvent);d?.(t,n),!n.isCanceled&&te(t)},onClick(e){e.stopPropagation()},onFocus(){L.current?.focus()},...v===void 0?jo:{value:v}},H=Z.useMemo(()=>({...S,checked:V,disabled:N,readOnly:f,required:m}),[S,V,N,f,m]),se=B(`span`,e,{state:H,ref:[t,L,re],props:[ae,b,ne,e=>j.getValidationProps(N,e)],stateAttributesMapping:yy});return(0,Q.jsxs)(hy.Provider,{value:H,children:[se,!V&&P&&_!==void 0&&(0,Q.jsx)(`input`,{type:`hidden`,form:o,name:P,value:_,disabled:N}),(0,Q.jsx)(`input`,{...oe,suppressHydrationWarning:!0})]})}),xy=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=gy();return B(`span`,e,{state:o,ref:t,stateAttributesMapping:yy,props:a})});function Sy({className:e,size:t=`default`,...n}){return(0,Q.jsx)(by,{"data-slot":`switch`,"data-size":t,className:K(`peer group/switch relative inline-flex shrink-0 items-center rounded-2xl border-2 transition-all outline-none group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-5 data-[size=default]:w-8 data-[size=sm]:h-4 data-[size=sm]:w-6 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary group-has-[:focus-visible]/field-label:data-checked:border-primary data-unchecked:border-transparent data-unchecked:bg-input/90 group-has-[:focus-visible]/field-label:data-unchecked:border-transparent data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,Q.jsx)(xy,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-2xl bg-background shadow-sm ring-0 transition-transform not-dark:bg-clip-padding group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-checked:translate-x-[calc(100%-4px)] dark:data-checked:bg-primary-foreground data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}function Cy(e){let t=Z.useRef(!0);t.current&&(t.current=!1,e())}function wy(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var Ty=Z.createContext(void 0),Ey=Z.createContext(void 0),Dy=Z.createContext(void 0);function Oy(){let e=Z.useContext(Ty);if(e===void 0)throw Error(or(60));return e}function ky(){let e=Z.useContext(Ey);if(e===void 0)throw Error(or(101));return e}function Ay(){let e=Z.useContext(Dy);if(e===void 0)throw Error(or(61));return e}function jy(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var My=(e,t)=>Object.is(e,t);function Ny(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Py(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!jy(e,t,(e,t)=>Ny(e,t,n)):e!==t}function Fy(e,t,n){return e?e.some(e=>e!==void 0&&Ny(t,e,n)):!1}function Iy(e,t,n){return e?e.findIndex(e=>e!==void 0&&Ny(e,t,n)):-1}function Ly(e,t){if(t!==My)return n=>Fy(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function Ry(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(Ly(t,n)):Iy(e,t,n);return i===-1?null:i}function zy(e,t,n,r,i,a){return Fy(r,t,i)?a!=null&&e>a&&Fy(r,n[a],i)?a:e:e===a?Ry(n,r,i,!0):a}function By(e,t,n){return e.filter(e=>!Ny(t,e,n))}function Vy(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function Hy(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function Uy(e){return Hy(e?.[0])}function Wy(e){return Uy(e)?e.flatMap(e=>e.items):e}function Gy(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(Uy(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function Ky(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return Vy(e)}function qy(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?Vy(e.value):Vy(e)}function Jy(e,t,n){function r(){return Ky(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){let n=Wy(t);if(typeof e!=`object`||!e){let t=n.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=n.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function Yy(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,Q.jsx)(Z.Fragment,{children:Jy(r,t,n)},i)),e),[])}var Xy={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:qy(t,r)!==``},hasNullItemLabel:(e,t)=>t?Gy(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>Ny(t,e,n)):Ny(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function Zy(e){let t=Z.useRef(``),n=Z.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:Z.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function Qy(e,t){let{onClick:n,onPointerDown:r}=Zy(Y((n,r)=>{(typeof e==`function`?e():e)||t(r||(bs?`touch`:``))}));return Z.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function $y(e){let[t,n]=Z.useState(null),r=Qy(e,n);return ey(e,t=>{t&&!e&&n(null)}),Z.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function eb(e,t){return Math.max(0,e-t)}function tb(e,t){if(t<=0)return 0;let n=jl(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}function nb(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:m=!1,modal:h=!0,actionsRef:g,inputRef:_,onOpenChangeComplete:v,items:y,multiple:b=!1,itemToStringLabel:x,itemToStringValue:S,isItemEqualToValue:C=My,highlightItemOnHover:w=!0,children:T}=e,{clearErrors:E}=Gv(),{setDirty:D,setTouched:O,setFocused:A,validityData:j,setFilled:M,name:N,disabled:P,validation:F,validationMode:I}=Uv(),L=Zv({id:t}),R=P||d,z=N??c,[B,ee]=Qv({controlled:n,default:b?r??fi:r,name:`Select`,state:`value`}),[V,te]=Qv({controlled:a,default:o,name:`Select`,state:`open`}),ne=Z.useRef([]),re=Z.useRef([]),ie=Z.useRef(null),ae=Z.useRef(null),oe=Z.useRef(0),H=Z.useRef(null),se=Z.useRef([]),ce=Z.useRef(!1),le=Z.useRef(null),ue=Z.useRef(null),de=Z.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),fe=Z.useRef(!1),pe=Z.useRef(B),{mounted:U,setMounted:me,transitionStatus:he}=Sd(V),{openMethod:ge,triggerProps:_e}=$y(V),ve=tn(()=>new at({id:L,labelId:void 0,modal:h,multiple:b,itemToStringLabel:x,itemToStringValue:S,isItemEqualToValue:C,value:B,open:V,mounted:U,transitionStatus:he,items:y,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:jo,triggerProps:jo,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:ja,setOpen:ja,handleScrollArrowVisibility:ja,onOpenChangeComplete:ja,listRef:ne,popupRef:ie,scrollHandlerRef:ae,scrollArrowsMountedCountRef:oe,valueRef:H,valuesRef:se,labelsRef:re,typingRef:ce,selectionRef:de,firstItemTextRef:le,selectedItemTextRef:ue,alignItemWithTriggerActiveRef:fe,initialValueRef:pe},Xy)).current,ye=ve.useState(`activeIndex`),be=ve.useState(`selectedIndex`),xe=ve.useState(`triggerElement`),Se=ve.useState(`positionerElement`),Ce=Bf(ge),we=ge??Ce,Te=Z.useMemo(()=>b?``:qy(B,S),[b,B,S]),Ee=Z.useMemo(()=>b&&Array.isArray(B)?B.map(e=>qy(e,S)):qy(B,S),[b,B,S]);$v(Ml(xe),L,B,Y(()=>Ee),!R,c);let De=b?Array.isArray(B)&&B.length>0:B!=null&&Te!==``;q(()=>{M(De)},[De,M]),q(function(){let e=Ry(se.current,B,C,b);e===null&&(ue.current=null),!V&&ve.set(`selectedIndex`,e)},[b,V,B,C,ve]),ey(B,()=>{E(z),D(Py(B,j.initialValue,C)),F.change(B)});let Oe=Y((e,t)=>{s?.(e,t),!t.isCanceled&&(te(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(O(!0),A(!1),I===`onBlur`&&F.commit(B)))}),ke=Y(()=>{me(!1),ve.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),v?.(!1)});k({enabled:!g,open:V,ref:ie,onComplete(){V||ke()}}),Z.useImperativeHandle(g,()=>({unmount:ke}),[ke]);let Ae=Y((e,t)=>{i?.(e,t),!t.isCanceled&&ee(e)}),je=Y(e=>{let t=eb(e.scrollHeight,e.clientHeight),n=tb(e.scrollTop,t),r=n>0,i=n<t;ve.set(`scrollUpArrowVisible`,r),ve.set(`scrollDownArrowVisible`,i)}),Me=Rd({open:V,onOpenChange:Oe,elements:{reference:xe,floating:Se}}),Ne=fu(Me,{enabled:!R,event:`mousedown`}),Pe=hu(Me),Fe=Jd(Me,{enabled:!R,listRef:ne,activeIndex:ye,selectedIndex:be,disabledIndices:fi,onNavigate(e){(e!==null||V)&&ve.set(`activeIndex`,e)},focusItemOnHover:w}),Ie=Yd(Me,{enabled:!R&&(V||!f&&!b),listRef:re,activeIndex:ye,selectedIndex:be,disabledIndices:e=>wy(ne.current[e]),onMatch(e){V?ve.set(`activeIndex`,e):Ae(se.current[e],Qe(Ir))},onTyping(e){ce.current=e}}),Le=Z.useMemo(()=>Rt(Ie.reference,Fe.reference,Pe.reference,Ne.reference,_e),[Ne.reference,Ie.reference,Fe.reference,Pe.reference,_e]),Re=Z.useMemo(()=>Rt(Cd,Ie.floating,Fe.floating,Pe.floating),[Ie.floating,Fe.floating,Pe.floating]),ze=Fe.item??jo;ve.useContextCallback(`setValue`,Ae),ve.useContextCallback(`setOpen`,Oe),ve.useContextCallback(`handleScrollArrowVisibility`,je),ve.useContextCallback(`onOpenChangeComplete`,v),Cy(()=>{ve.update({popupProps:Re,triggerProps:Le})}),ve.useSyncedValues({id:L,modal:h,multiple:b,value:B,open:V,mounted:U,transitionStatus:he,popupProps:Re,triggerProps:Le,items:y,itemToStringLabel:x,itemToStringValue:S,isItemEqualToValue:C,openMethod:we});let Be=Z.useMemo(()=>({disabled:R,readOnly:f,required:m,multiple:b,highlightItemOnHover:w,itemProps:ze}),[R,f,m,b,w,ze]),Ve=p(_,F.inputRef),He=b?void 0:z,Ue=Z.useMemo(()=>!b||!Array.isArray(B)||!z?null:B.map(e=>{let t=qy(e,S);return(0,Q.jsx)(`input`,{type:`hidden`,form:l,name:z,value:t,disabled:R},t)}),[b,B,l,z,S,R]);return(0,Q.jsxs)(Ty.Provider,{value:ve,children:[(0,Q.jsx)(Ey.Provider,{value:Be,children:(0,Q.jsx)(Dy.Provider,{value:Me,children:T})}),(0,Q.jsx)(`input`,{...F.getValidationProps(R,{onFocus(){ve.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||R||f)return;let t=e.currentTarget.value,n=Qe(Ir,e.nativeEvent);function r(){if(b)return;let e=t.toLowerCase(),r=se.current.findIndex(t=>qy(t,S).toLowerCase()===e||Ky(t,x).toLowerCase()===e);r===-1&&(r=se.current.findIndex((t,n)=>{let r=re.current[n];return r!=null&&r.toLowerCase()===e}));let i=se.current[r];i!=null&&Ae(i,n)}ve.set(`forceMount`,!0),queueMicrotask(r)}}),id:L&&He==null?`${L}-hidden-input`:void 0,form:l,name:He,autoComplete:u,value:Te,disabled:R,required:m&&!(b&&De),readOnly:f,ref:Ve,style:z?Ot:xt,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Ue]})}function rb(e,t){return e??t}var ib=5;function ab(e,t){let n=ob(t);return e.clientX>=n.left-ib&&e.clientX<=n.right+ib&&e.clientY>=n.top-ib&&e.clientY<=n.bottom+ib}function ob(e){let t=e.getBoundingClientRect(),n=We(e);if(Fi)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}}var sb=`data-popup-side`,cb=400,lb={...qc,...Bv,popupSide:e=>e?{[sb]:e}:null,value:()=>null},ub=Z.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,setFocused:u,validationMode:d,validation:f,state:p,disabled:m}=Uv(),{labelId:h}=qv(),g=Oy(),{readOnly:_,required:v,disabled:y}=ky(),b=m||y||a,x=g.useState(`open`),S=g.useState(`mounted`),C=g.useState(`value`),w=g.useState(`triggerProps`),T=g.useState(`positionerElement`),E=g.useState(`listElement`),D=g.useState(`popupSide`),O=g.useState(`id`),k=g.useState(`labelId`),A=g.useState(`hasSelectedValue`),j=S&&T?D:null,M=i??O,N=rb(h,k);Zv({id:i});let P=Ml(T),F=Z.useRef(null),{getButtonProps:I,buttonRef:L}=Ci({disabled:b,native:o}),R=g.useStateSetter(`triggerElement`),z=vn(),ee=vn(),V=vn();Z.useEffect(()=>{if(x)return V.start(cb,()=>{g.context.selectionRef.current.allowUnselectedMouseUp=!0,g.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{V.clear()};g.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},ee.clear()},[x,g,ee,V]);let te=Rt(w,{id:M,role:`combobox`,"aria-expanded":x,"aria-haspopup":`listbox`,"aria-controls":x?E?.id??Xe(T)?.id:void 0,"aria-labelledby":N,"aria-readonly":_||void 0,"aria-required":v||void 0,tabIndex:b?-1:0,onFocus(e){u(!0),x&&g.context.alignItemWithTriggerActiveRef.current&&g.context.setOpen(!1,Qe(Ir,e.nativeEvent)),z.start(0,()=>{g.set(`forceMount`,!0)})},onBlur(e){J(T,e.relatedTarget)||(l(!0),u(!1),d===`onBlur`&&f.commit(C))},onMouseDown(e){if(x)return;let t=ce(e.currentTarget);function n(e){if(!F.current)return;let t=e.target;J(F.current,t)||J(P.current,t)||ab(e,F.current)||g.context.setOpen(!1,Qe(mr,e))}ee.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,I),ne=f.getValidationProps(b,te);ne.role=`combobox`;let re={...p,open:x,disabled:b,value:C,readOnly:_,popupSide:j,placeholder:!A};return B(`button`,e,{ref:[t,F,L,R],state:re,stateAttributesMapping:lb,props:ne})}),db={value:()=>null},fb=Z.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=Oy(),l=c.useState(`value`),u=c.useState(`items`),d=c.useState(`itemToStringLabel`),f=c.useState(`hasSelectedValue`),p=!f&&a!=null&&i==null,m=c.useState(`hasNullItemLabel`,p),h={value:l,placeholder:!f},g=null;return g=typeof i==`function`?i(l):i??(p&&!m?a:Array.isArray(l)?Yy(l,u,d):Jy(l,u,d)),B(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:db})}),pb=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o={open:Oy().useState(`open`)};return B(`span`,e,{state:o,ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:Kc})}),mb=Z.forwardRef(function(e,t){let n=Oy(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,Q.jsx)(er,{ref:t,...e}):null}),hb=Z.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function gb(){return Z.useContext(hb)}function _b(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Y(i),[,o]=Z.useState(!1),s=tn(yb).current,c=tn(vb).current,l=Z.useRef(0),u=Z.useRef(!0),d=Z.useRef(null),f=Z.useRef(null),p=Y(()=>{u.current||(u.current=!0,o(e=>!e))}),m=Y((e,t)=>{c.set(e,t),p()}),h=Y(e=>{c.delete(e),p()}),g=Y(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(!Sb(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&Cb(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=xb(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Y(()=>{let[e,t]=bb(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});q(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),q(()=>{u.current&&v()}),q(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=Y(e=>(s.add(e),()=>{s.delete(e)})),b=Z.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,Q.jsx)(hb.Provider,{value:b,children:t})}function vb(){return new Map}function yb(){return new Set}function bb(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)=>Cb(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 xb(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function Sb(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 Cb(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var wb=Z.createContext(void 0);function Tb(){let e=Z.useContext(wb);if(!e)throw Error(or(59));return e}var Eb=Z.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,Q.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function Db(e,t){e&&Object.assign(e.style,t)}var Ob={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},kb={},Ab={},jb=``;function Mb(e,t){return Gn(e)?e:t}function Nb(e,t,n){return/hidden|clip/.test(e.getComputedStyle(Mb(t,n)).overflowY)}function Pb(e){if(typeof document>`u`)return!1;let t=ce(e);return We(t).innerWidth-t.documentElement.clientWidth>0}function Fb(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=ce(e),n=t.documentElement,r=t.body,i=Mb(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 Ib(e){let t=ce(e),n=t.documentElement,r=t.body,i=Mb(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 Lb(e){let t=ce(e),n=t.documentElement,r=t.body,i=We(n),a=0,o=0,s=!1,c=j.create();if(Or&&(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,kb={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},jb=n.style.scrollBehavior,Ab={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=Mb(n,r);if(s=Fb(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}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,kb),Object.assign(r.style,Ab),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=jb)}function d(){u(),c.request(l)}l();let f=En(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var Rb=new class{lockCount=0;restore=null;timeoutLock=ds.create();timeoutUnlock=ds.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=ce(e),n=t.documentElement,r=t.body,i=We(n);if(Nb(i,n,r)){let t=new i.MutationObserver(()=>{Nb(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=bs||!Pb(e);this.restore=a?Ib(e):Lb(e)}};function zb(e=!0,t=null){q(()=>{if(e)return Rb.acquire(t)},[e,t])}var Bb=20;function Vb(e,t,n,r){let[i,a]=Z.useState(!1);q(()=>{if(!e||!t||n==null){a(!1);return}let r=ce(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-Bb)},[e,t,n]),zb(e&&(!t||i),r)}var Hb={position:`fixed`},Ub=Z.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=Wr,style:_,...v}=e,y=Oy(),b=Ay(),x=y.useState(`open`),S=y.useState(`mounted`),C=y.useState(`modal`),w=y.useState(`value`),T=y.useState(`openMethod`),E=y.useState(`positionerElement`),D=y.useState(`triggerElement`),O=y.useState(`isItemEqualToValue`),k=y.useState(`transitionStatus`),A=Z.useRef(null),j=Z.useRef(null),[M,N]=Z.useState(h),P=S&&M&&T!==`touch`;!S&&M!==h&&N(h),Z.useImperativeHandle(y.context.alignItemWithTriggerActiveRef,()=>P),Vb((P||C)&&x,T===`touch`,E,D);let F=ff({anchor:n,floatingRootContext:b,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??P,collisionAvoidance:g,keepMounted:!0}),I=P?`none`:F.side,L=P?Hb:F.positionerStyles,R={open:x,side:I,align:F.align,anchorHidden:F.anchorHidden};q(()=>{y.set(`popupSide`,F.side)},[y,F.side]);let z=gf(e,R,{styles:L,transitionStatus:k,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!S,inert:!x}),B=Z.useRef(0),ee=Y(e=>{if(y.context.valuesRef.current.length===0)return;let t=B.current;B.current=e.size;let n=Qe(Ir);if(t!==0&&!y.state.multiple&&w!==null&&Iy(y.context.valuesRef.current,w,O)===-1){let e=y.context.initialValueRef.current,t=e!=null&&Iy(y.context.valuesRef.current,e,O)!==-1?e:null;y.context.setValue(t,n),t===null&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null)}if(t!==0&&y.state.multiple&&Array.isArray(w)){let e=w.filter(e=>Iy(y.context.valuesRef.current,e,O)!==-1);e.length!==w.length&&(y.context.setValue(e,n),e.length===0&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null))}if(x&&P){y.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};Db(E,e),Db(y.context.popupRef.current,e)}}),V=Z.useMemo(()=>({...F,side:I,alignItemWithTriggerActive:P,setControlledAlignItemWithTrigger:N,scrollUpArrowRef:A,scrollDownArrowRef:j}),[F,I,P,N]);return(0,Q.jsx)(_b,{elementsRef:y.context.listRef,labelsRef:y.context.labelsRef,onMapChange:ee,children:(0,Q.jsxs)(wb.Provider,{value:V,children:[S&&C&&(0,Q.jsx)(Eb,{inert:se(!x),cutout:D}),z]})})}),Wb=`base-ui-disable-scrollbar`,Gb={className:Wb,getElement(e){return(0,Q.jsx)(`style`,{nonce:e,href:Wb,precedence:`base-ui:low`,children:`.${Wb}{scrollbar-width:none}.${Wb}::-webkit-scrollbar{display:none}`})}},Kb=Z.createContext(void 0);function qb(e){let t=Z.useContext(Kb);if(t===void 0&&!e)throw Error(or(69));return t}var Jb=`ArrowUp`,Yb=`ArrowDown`,Xb=`ArrowLeft`,Zb=`ArrowRight`,Qb=`Home`,$b=new Set([Jb,Yb,Xb,Zb,Qb,`End`]),ex=[`Shift`,`Control`,`Alt`,`Meta`];function tx(e){return Os(e)&&e.tagName===`INPUT`}function nx(e){return!!(tx(e)&&e.selectionStart!=null||Os(e)&&e.tagName===`TEXTAREA`)}function rx(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=ix(e,t,`left`),a=ax(e),o=ax(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=ix(e,t,`top`),r=ax(e),i=ax(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function ix(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function ax(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}var ox=Z.createContext(void 0),sx={disableStyleElements:!1};function cx(){return Z.useContext(ox)??sx}var lx=`--transform-origin`,ux={...Jc,...Lr},dx=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=Oy(),{multiple:c,readOnly:l,highlightItemOnHover:u}=ky(),d=Ay(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:g}=Tb(),_=qb(!0)!=null,v=Zd(),{nonce:y,disableStyleElements:b}=cx(),x=s.useState(`id`),S=s.useState(`open`),C=s.useState(`openMethod`),w=s.useState(`mounted`),T=s.useState(`popupProps`),E=s.useState(`transitionStatus`),D=s.useState(`triggerElement`),O=s.useState(`positionerElement`),A=s.useState(`listElement`),j=Z.useRef(!1),M=Z.useRef(!1),N=Z.useRef({}),P=ns(),F=Y(e=>{if(!O||!s.context.popupRef.current||!M.current)return;let t=O.style.top===`0px`,n=O.style.bottom===`0px`;if(j.current||!m||!t&&!n){s.context.handleScrollArrowVisibility(e);return}let r=mx(O),i=hx(O.getBoundingClientRect().height,`y`,r),a=ce(O),o=We(O),c=o.getComputedStyle(O),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=fx(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=px(e),g=null,_=e=>{O.style.height=`${e}px`},v=t?h-p:p,y=Math.min(i+v,f);if(v<=1){let n=jl(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?h:0,f-(i+n)<=1&&(j.current=!0),s.context.handleScrollArrowVisibility(e);return}f-y>1?g=t?1/0:0:n&&p<h&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=jl(g,0,px(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(j.current=!0),s.context.handleScrollArrowVisibility(e)});Z.useImperativeHandle(s.context.scrollHandlerRef,()=>F,[F]),k({open:S,ref:s.context.popupRef,onComplete(){S&&s.context.onOpenChangeComplete(!0)}});let I={open:S,transitionStatus:E,side:f,align:p};q(()=>{O&&s.context.popupRef.current&&!Object.keys(N.current).length&&(N.current={top:O.style.top||`0`,left:O.style.left||`0`,right:O.style.right,height:O.style.height,bottom:O.style.bottom,minHeight:O.style.minHeight,maxHeight:O.style.maxHeight,marginTop:O.style.marginTop,marginBottom:O.style.marginBottom})},[s,O]),q(()=>{S||m||(M.current=!1,j.current=!1,Db(O,N.current))},[S,m,O]),q(()=>{let e=s.context.popupRef.current;if(!S||!D||!O||!e||m&&!h||s.state.transitionStatus===`ending`)return;if(M.current=!0,e.style.removeProperty(lx),!m){P.request(()=>s.context.handleScrollArrowVisibility(A||e));return}let t=vx(e);try{let t=s.context.selectedItemTextRef.current;t?.isConnected||(t=!s.select(`hasSelectedValue`)&&s.context.firstItemTextRef.current?.isConnected?s.context.firstItemTextRef.current:null);let n=s.context.valueRef.current,r=We(O),i=r.getComputedStyle(O),a=r.getComputedStyle(e),o=ce(D),c=mx(D),l=gx(D.getBoundingClientRect(),c),d=gx(O.getBoundingClientRect(),c),f=l.height,p=A||e,m=p.scrollHeight,h=parseFloat(a.borderBottomWidth),_=parseFloat(i.marginTop)||10,y=parseFloat(i.marginBottom)||10,b=parseFloat(i.minHeight)||100,x=fx(a),S=o.documentElement.clientHeight-_-y,C=o.documentElement.clientWidth,w=S-l.bottom+f,T,E=v===`rtl`?l.right-d.width:l.left,k=0;if(t&&n){let e=gx(n.getBoundingClientRect(),c);T=gx(t.getBoundingClientRect(),c),E=d.left+(v===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-l.top+e.height/2;k=T.top-d.top+T.height/2-r}let M=w+k+y+h,P=Math.min(S,M),F=S-_-y,I=M-P,L=C-5;O.style.left=`${jl(E,5,L-d.width)}px`,O.style.height=`${P}px`,O.style.maxHeight=`none`,O.style.marginTop=`${_}px`,O.style.marginBottom=`${y}px`,e.style.height=`100%`;let R=px(p),z=I>=R-1;z&&(P=Math.min(S,d.height)-(I-R));let B=l.top<20||l.bottom>S-20||Math.ceil(P)+1<Math.min(m,b),ee=(r.visualViewport?.scale??1)!==1&⩔if(B||ee){Db(O,N.current),g(!1);return}let V=Math.max(b,P);if(z){let e=Math.max(0,S-M);O.style.top=d.height>=F?`0`:`${e}px`,O.style.height=`${P}px`,p.scrollTop=px(p)}else O.style.bottom=`0`,p.scrollTop=I;if(T){let t=d.top,n=d.height,r=T.top+T.height/2,i=jl(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(lx,`50% ${i}%`)}(V===S||P>=x)&&(j.current=!0),s.context.handleScrollArrowVisibility(p),u&&s.state.selectedIndex===null&&s.state.activeIndex===null&&s.context.listRef.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,S,O,D,m,g,P,A,u,v,h]),Z.useEffect(()=>{if(!m||!O||!S)return;let e=We(O);function t(e){s.context.setOpen(!1,Qe(oi,e))}return En(e,`resize`,t)},[s,m,O,S]);let L={...A?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":c||void 0,"aria-readonly":l||void 0,id:`${x}-list`},onKeyDown(e){_&&$b.has(e.key)&&e.stopPropagation()},onScroll(e){A||F(e.currentTarget)},...m&&{style:A?{height:`100%`}:Ob},className:!A&&m?Gb.className:void 0},R=B(`div`,e,{ref:[t,s.context.popupRef],state:I,stateAttributesMapping:ux,props:[T,L,hf(E),o]});return(0,Q.jsxs)(Z.Fragment,{children:[!b&&Gb.getElement(y),(0,Q.jsx)(du,{context:d,modal:!1,disabled:!w,openInteractionType:C,returnFocus:a,restoreFocus:!0,children:R})]})});function fx(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function px(e){return eb(e.scrollHeight,e.clientHeight)}function mx(e){return Qu.getScale(e)}function hx(e,t,n){return e/n[t]}function gx(e,t){return Al({x:hx(e.x,`x`,t),y:hx(e.y,`y`,t),width:hx(e.width,`x`,t),height:hx(e.height,`y`,t)})}var _x=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function vx(e){let{style:t}=e,n={};for(let[e,r]of _x)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of _x){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var yx=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Oy(),{multiple:s,readOnly:c}=ky(),{alignItemWithTriggerActive:l}=Tb(),u=o.useState(`hasScrollArrows`),d=o.useState(`openMethod`),f={id:`${o.useState(`id`)}-list`,role:`listbox`,"aria-multiselectable":s||void 0,"aria-readonly":c||void 0,onScroll(e){o.context.scrollHandlerRef.current?.(e.currentTarget)},...l&&{style:Ob},className:u&&d!==`touch`?Gb.className:void 0},p=o.useStateSetter(`listElement`);return B(`div`,e,{ref:[t,p],props:[f,a]})});function bx(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=gb(),u=Z.useRef(-1),[d,f]=Z.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=Z.useRef(null),h=Z.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return q(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}var xx=Z.createContext(void 0);function Sx(){let e=Z.useContext(xx);if(!e)throw Error(or(57));return e}var Cx=Z.memo(Z.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=Z.useRef(null),d=bx({guess:!0,label:o,textRef:u}),f=Oy(),{itemProps:p,multiple:m,disabled:h,readOnly:g}=ky(),_=h||s,v=f.useState(`isActive`,d.index),y=f.useState(`open`),b=f.useState(`isSelected`,a),x=f.useState(`isSelectedByFocus`,d.index),S=f.useState(`isItemEqualToValue`),C=d.index,w=Z.useRef(null);q(()=>{let e=f.context.valuesRef.current;return e[C]=a,()=>{delete e[C]}},[C,a,f]),q(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=zy(C,a,f.context.valuesRef.current,e,S,t),r=n===C,C===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&Ny(a,e,S),r&&(n=C)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[C,m,S,f,a]);let T=Z.useRef(`mouse`),E=Z.useRef(!1),{getButtonProps:D,buttonRef:O}=Ci({disabled:_,focusableWhenDisabled:!0,native:c,composite:!0}),k={disabled:_,selected:b,highlighted:v};function A(e){if(h||g)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=b?By(n,a,S):[...n,a];f.context.setValue(r,Qe(Na,e))}else f.context.setValue(a,Qe(Na,e)),f.context.setOpen(!1,Qe(Na,e))}function j(){f.context.selectionRef.current.dragY=0}let M={role:`option`,"aria-selected":b,tabIndex:y&&v?0:-1,onKeyDown(e){f.set(`activeIndex`,C),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=T.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&el(e.nativeEvent)&&(n!==void 0||v),i=t&&!r&&!E.current;E.current=!1,!(_||i)&&A(e.nativeEvent)},onPointerEnter(e){T.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){T.current=e.pointerType,E.current=!0,j()},onMouseUp(){if(j(),_||T.current===`touch`||E.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&b,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!b;e||t||(E.current=!0,w.current?.click(),E.current=!1)}},N=B(`div`,e,{ref:[O,t,d.ref,w],state:k,props:[p,M,l,D]}),P=Z.useMemo(()=>({selected:b,index:C,textRef:u,selectedByFocus:x}),[b,C,u,x]);return(0,Q.jsx)(xx.Provider,{value:P,children:N})})),wx=Z.forwardRef(function(e,t){let{selected:n}=Sx();return e.keepMounted||n?(0,Q.jsx)(Tx,{...e,ref:t}):null}),Tx=Z.memo(Z.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=Sx(),c=Z.useRef(null),{transitionStatus:l,setMounted:u}=Sd(s),d=B(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:Lr});return k({batch:!0,enabled:!s,open:s,ref:c,onComplete(){s||u(!1)}}),d})),Ex=Z.memo(Z.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=Sx(),a=Oy(),{render:o,className:s,style:c,...l}=e,u=Z.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]);return B(`div`,e,{ref:[u,t,r],props:l})})),Dx=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,direction:a,keepMounted:o,...s}=e,c=a===`up`,l=Oy(),{side:u,scrollDownArrowRef:d,scrollUpArrowRef:f}=Tb(),p=c?`scrollUpArrowVisible`:`scrollDownArrowVisible`,m=l.useState(p),h=l.useState(`openMethod`),g=m&&h!==`touch`,_=vn(),v=c?f:d,{mounted:y,transitionStatus:b,setMounted:x}=Sd(g);q(()=>(l.context.scrollArrowsMountedCountRef.current+=1,l.set(`hasScrollArrows`,!0),()=>{l.context.scrollArrowsMountedCountRef.current=Math.max(0,l.context.scrollArrowsMountedCountRef.current-1),l.context.scrollArrowsMountedCountRef.current===0&&l.set(`hasScrollArrows`,!1)}),[l]),k({open:g,ref:v,onComplete(){g||x(!1)}});let S=B(`div`,e,{ref:[t,v],state:{direction:a,visible:g,side:u,transitionStatus:b},props:[{"aria-hidden":!0,children:c?`▲`:`▼`,style:{position:`absolute`},onMouseMove(e){if(e.movementX===0&&e.movementY===0||_.isStarted())return;l.set(`activeIndex`,null);function t(){let e=l.state.listElement??l.context.popupRef.current;if(!e)return;l.set(`activeIndex`,null),l.context.handleScrollArrowVisibility(e);let n=eb(e.scrollHeight,e.clientHeight),r=tb(e.scrollTop,n),i=r===(c?0:n),a=l.context.listRef.current;if(r!==e.scrollTop&&(e.scrollTop=r),i){_.clear();return}if(a.length>0){let t=v.current?.offsetHeight||0;e.scrollTop=Ox(a,c,r,e.clientHeight,t,n)}_.start(40,t)}_.start(40,t)},onMouseLeave(){_.clear()}},s],stateAttributesMapping:Lr});return y||o?S:null});function Ox(e,t,n,r,i,a){if(t){let t=0,r=n+i-1;for(let n=0;n<e.length;n+=1){let i=e[n];if(i&&i.offsetTop>=r){t=n;break}}let o=Math.max(0,t-1),s=e[o];return o<t&&s?tb(s.offsetTop-i,a):0}let o=e.length-1,s=n+r-i+1;for(let t=0;t<e.length;t+=1){let n=e[t];if(n&&n.offsetTop+n.offsetHeight>s){o=Math.max(0,t-1);break}}let c=Math.min(e.length-1,o+1),l=e[c];return c>o&&l?tb(l.offsetTop+l.offsetHeight-r+i,a):a}var kx=Z.forwardRef(function(e,t){return(0,Q.jsx)(Dx,{...e,ref:t,direction:`down`})}),Ax=Z.forwardRef(function(e,t){return(0,Q.jsx)(Dx,{...e,ref:t,direction:`up`})}),jx=Z.createContext(void 0);function Mx(){let e=Z.useContext(jx);if(e===void 0)throw Error(or(56));return e}var Nx=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Z.useState(),c=Z.useMemo(()=>({labelId:o,setLabelId:s}),[o,s]),l=B(`div`,e,{ref:t,props:[{role:`group`,"aria-labelledby":o},a]});return(0,Q.jsx)(jx.Provider,{value:c,children:l})}),Px=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{setLabelId:s}=Mx(),c=zf(a);return q(()=>(s(c),()=>{s(e=>e===c?void 0:e)}),[c,s]),B(`div`,e,{ref:t,props:[{id:c,"aria-hidden":!0},o]})}),Fx=nb;function Ix({className:e,...t}){return(0,Q.jsx)(Nx,{"data-slot":`select-group`,className:K(`scroll-my-1.5 p-1`,e),...t})}function Lx({className:e,...t}){return(0,Q.jsx)(fb,{"data-slot":`select-value`,className:K(`flex flex-1 text-left`,e),...t})}function Rx({className:e,size:t=`default`,children:n,...r}){return(0,Q.jsxs)(ub,{"data-slot":`select-trigger`,"data-size":t,className:K(`flex w-fit items-center justify-between gap-1.5 rounded-2xl border border-transparent bg-input/50 px-3 py-2 text-sm whitespace-nowrap transition-[color,box-shadow] duration-200 outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,Q.jsx)(pb,{render:(0,Q.jsx)(vf,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function zx({className:e,children:t,side:n=`bottom`,sideOffset:r=4,align:i=`center`,alignOffset:a=0,alignItemWithTrigger:o=!0,...s}){return(0,Q.jsx)(mb,{children:(0,Q.jsx)(Ub,{side:n,sideOffset:r,align:i,alignOffset:a,alignItemWithTrigger:o,className:`isolate z-50`,children:(0,Q.jsxs)(dx,{"data-slot":`select-content`,"data-align-trigger":o,className:K(`isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-2xl text-popover-foreground shadow-lg ring-1 ring-foreground/5 duration-100 data-[align-trigger=true]:animate-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 dark:ring-foreground/10 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 animate-none! relative bg-popover/70 before:pointer-events-none before:absolute before:inset-0 before:-z-1 before:rounded-[inherit] before:backdrop-blur-2xl before:backdrop-saturate-150 **:data-[slot$=-item]:focus:bg-foreground/10 **:data-[slot$=-item]:data-highlighted:bg-foreground/10 **:data-[slot$=-separator]:bg-foreground/5 **:data-[slot$=-trigger]:focus:bg-foreground/10 **:data-[slot$=-trigger]:aria-expanded:bg-foreground/10! **:data-[variant=destructive]:focus:bg-foreground/10! **:data-[variant=destructive]:text-accent-foreground! **:data-[variant=destructive]:**:text-accent-foreground!`,e),...s,children:[(0,Q.jsx)(Hx,{}),(0,Q.jsx)(yx,{children:t}),(0,Q.jsx)(Ux,{})]})})})}function Bx({className:e,...t}){return(0,Q.jsx)(Px,{"data-slot":`select-label`,className:K(`px-2 py-1 text-xs text-muted-foreground`,e),...t})}function Vx({className:e,children:t,...n}){return(0,Q.jsxs)(Cx,{"data-slot":`select-item`,className:K(`relative flex min-h-7 w-full cursor-default items-center gap-2 rounded-xl py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,Q.jsx)(Ex,{className:`flex flex-1 shrink-0 gap-2 whitespace-nowrap`,children:t}),(0,Q.jsx)(wx,{render:(0,Q.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`}),children:(0,Q.jsx)(fn,{className:`pointer-events-none`})})]})}function Hx({className:e,...t}){return(0,Q.jsx)(Ax,{"data-slot":`select-scroll-up-button`,className:K(`top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,Q.jsx)(bf,{})})}function Ux({className:e,...t}){return(0,Q.jsx)(kx,{"data-slot":`select-scroll-down-button`,className:K(`bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,Q.jsx)(vf,{})})}var Wx=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(Wx||{}),Gx=[0,1],Kx=[1,0],qx=[2,3],Jx=[3,2],Yx={L:Gx,M:Kx,Q:qx,H:Jx},Xx=/^\d*$/,Zx=/^[A-Z0-9 $%*+./:-]*$/,Qx=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,$x=1,eS=40,tS=3,nS=3,rS=40,iS=10,aS=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],oS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],sS=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<$x||e>eS)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size}).fill(!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,Wx.Timing),this.setFunctionModule(e,6,e%2==0,Wx.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,lS(r,e));this.setFunctionModule(8,7,lS(r,6)),this.setFunctionModule(8,8,lS(r,7)),this.setFunctionModule(7,8,lS(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,lS(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,lS(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,lS(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=lS(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,Wx.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,Wx.Alignment)}setFunctionModule(e,t,n,r=Wx.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==wS(t,n))throw RangeError(`Invalid argument`);let r=oS[n[0]][t],i=aS[n[0]][t],a=Math.floor(CS(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=TS(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=ES(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(CS(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=lS(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=tS:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*rS),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*rS}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=tS:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*rS),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*rS}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=nS)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*iS,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function cS(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function lS(e,t){return!!(e>>>t&1)}var uS=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},dS=[1,10,12,14],fS=[2,9,11,13],pS=[4,8,16,16];function mS(e,t){return e[Math.floor((t+7)/17)+1]}function hS(e){let t=[];for(let n of e)cS(n,8,t);return new uS(pS,e.length,t)}function gS(e){if(!yS(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);cS(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new uS(dS,e.length,t)}function _S(e){if(!bS(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=Qx.indexOf(e.charAt(n))*45;r+=Qx.indexOf(e.charAt(n+1)),cS(r,11,t)}return n<e.length&&cS(Qx.indexOf(e.charAt(n)),6,t),new uS(fS,e.length,t)}function vS(e){return e===``?[]:yS(e)?[gS(e)]:bS(e)?[_S(e)]:[hS(SS(e))]}function yS(e){return Xx.test(e)}function bS(e){return Zx.test(e)}function xS(e,t){let n=0;for(let r of e){let e=mS(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function SS(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function CS(e){if(e<$x||e>eS)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function wS(e,t){return Math.floor(CS(e)/8)-aS[t[0]][e]*oS[t[0]][e]}function TS(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=DS(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=DS(n,2)}return t}function ES(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=DS(t,e))}return n}function DS(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function OS(e,t,n=1,r=40,i=-1,a=!0){if(!($x<=n&&n<=r&&r<=eS)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=wS(o,t)*8,i=xS(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[Kx,qx,Jx])a&&s<=wS(o,e)*8&&(t=e);let c=[];for(let t of e){cS(t.mode[0],4,c),cS(t.numChars,mS(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=wS(o,t)*8;cS(0,Math.min(4,l-c.length),c),cS(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)cS(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new sS(o,t,u,i)}function kS(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?vS(e):Array.isArray(e)?[hS(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=OS(c,Yx[n],i,a,o,r),u=AS({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function AS(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=Wx.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}function jS(e){let t=(0,$.c)(8),{link:n}=e,r,i;if(t[0]!==n){let{size:e,data:a}=kS(n,{ecc:`M`,border:2});r=e,i=a.flatMap(MS).join(``),t[0]=n,t[1]=r,t[2]=i}else r=t[1],i=t[2];let a=i,o=`0 0 ${r} ${r}`,s;t[3]===a?s=t[4]:(s=(0,Q.jsx)(`path`,{d:a,fill:`currentColor`}),t[3]=a,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,Q.jsx)(`svg`,{role:`img`,"aria-label":`Pairing QR code`,viewBox:o,shapeRendering:`crispEdges`,className:`size-40 shrink-0 rounded-md bg-white text-black`,children:s}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function MS(e,t){return e.flatMap((e,n)=>e?[`M${n} ${t}h1v1h-1z`]:[])}function NS(e){let t=(0,$.c)(38),{connection:n,remote:r}=e,i=bm(r),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=G_(n),p;t[0]===d?p=t[1]:(p=Ki(d)?d.value:null,t[0]=d,t[1]=p);let m=p,h=i.find(e=>{let{url:t}=e;return t===s})??i[0];if(h===void 0){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Turn on a way in under Ways in to pair a phone or another computer.`}),t[2]=e):e=t[2],e}let g=e=>ay(e,async()=>f({label:a.trim(),addresses:[h.url],trusted:l})),_;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(cv,{htmlFor:`pairing-label`,children:`Device name`}),t[3]=_):_=t[3];let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>o(e.target.value),t[4]=v):v=t[4];let y;t[5]===a?y=t[6]:(y=(0,Q.jsxs)(pv,{className:`min-w-0 flex-1`,children:[_,(0,Q.jsx)(ry,{id:`pairing-label`,placeholder:`My phone`,maxLength:ye,value:a,onChange:v})]}),t[5]=a,t[6]=y);let b=i.length>1&&(0,Q.jsxs)(pv,{className:`min-w-0 sm:w-56`,children:[(0,Q.jsx)(cv,{htmlFor:`pairing-address`,children:`Opens through`}),(0,Q.jsxs)(Fx,{items:i.map(FS),value:h.url,onValueChange:e=>{e&&c(e)},children:[(0,Q.jsx)(Rx,{id:`pairing-address`,className:`w-full`,children:(0,Q.jsx)(Lx,{})}),(0,Q.jsx)(zx,{children:i.map(PS)})]})]}),x;t[7]!==d.waiting||t[8]!==a?(x=d.waiting||a.trim()===``,t[7]=d.waiting,t[8]=a,t[9]=x):x=t[9];let S;t[10]===d.waiting?S=t[11]:(S=d.waiting?(0,Q.jsx)(L_,{}):(0,Q.jsx)(Ef,{}),t[10]=d.waiting,t[11]=S);let C;t[12]!==x||t[13]!==S?(C=(0,Q.jsxs)(w,{type:`submit`,className:`shrink-0`,disabled:x,children:[S,`Create pairing link`]}),t[12]=x,t[13]=S,t[14]=C):C=t[14];let T;t[15]!==C||t[16]!==g||t[17]!==y||t[18]!==b?(T=(0,Q.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:g,children:[y,b,C]}),t[15]=C,t[16]=g,t[17]=y,t[18]=b,t[19]=T):T=t[19];let E;t[20]!==u||t[21]!==l?(E=(0,Q.jsx)(Sy,{id:`pairing-trusted`,checked:l,onCheckedChange:u}),t[20]=u,t[21]=l,t[22]=E):E=t[22];let D;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Q.jsx)(cv,{htmlFor:`pairing-trusted`,children:`The paired device can update Porcelain`}),t[23]=D):D=t[23];let O;t[24]===E?O=t[25]:(O=(0,Q.jsxs)(pv,{orientation:`horizontal`,children:[E,D]}),t[24]=E,t[25]=O);let k=hm[h.route],A;t[26]===k?A=t[27]:(A=(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`The link opens through `,k,`. The device will work only through the way in it pairs over. To use it through another way in too, pair it again through that one.`]}),t[26]=k,t[27]=A);let j;t[28]===d?j=t[29]:(j=Pa(d)&&(0,Q.jsx)(P_,{variant:`destructive`,children:(0,Q.jsx)(I_,{children:Km(wn(d.cause))})}),t[28]=d,t[29]=j);let M;t[30]===m?M=t[31]:(M=m&&(0,Q.jsxs)(bv,{variant:`muted`,children:[(0,Q.jsx)(Sv,{children:(0,Q.jsx)(jS,{link:m.link})}),(0,Q.jsxs)(Cv,{children:[(0,Q.jsxs)(wv,{children:[`Scan on `,m.label]}),(0,Q.jsx)(`p`,{"aria-label":`Pairing link`,className:`font-mono text-xs break-all text-muted-foreground`,children:m.link}),(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Works once, until`,` `,new Date(m.expiresAt).toLocaleTimeString(),`.`]}),(0,Q.jsxs)(w,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>ve(m?.link??``,`pairing link`),children:[(0,Q.jsx)(Sf,{}),`Copy link`]})]})]}),t[30]=m,t[31]=M);let N;return t[32]!==T||t[33]!==O||t[34]!==A||t[35]!==j||t[36]!==M?(N=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[T,O,A,j,M]}),t[32]=T,t[33]=O,t[34]=A,t[35]=j,t[36]=M,t[37]=N):N=t[37],N}function PS(e){let{route:t,url:n}=e;return(0,Q.jsx)(Vx,{value:n,children:`${hm[t]} · ${n}`},n)}function FS(e){let{route:t,url:n}=e;return{value:n,label:`${hm[t]} · ${n}`}}var IS=new Intl.RelativeTimeFormat(`en`,{numeric:`always`});function LS(e,t=xa()){let n=Eo(e),r=Wa(n,t),[i,a]=r?[t,n]:[n,t],o=Ji(i,a),s=dr(o),c=ci(),l=(s+Ei(Ho(a,c))-Ei(Ho(i,c)))/dr(b(1)),u,d;return s<dr(io(1))?(u=`second`,d=Math.round(yr(o))):s<dr(je(1))?(u=`minute`,d=Math.round(ar(o))):s<dr(b(1))?(u=`hour`,d=Math.round(Ye(o))):l<30?(u=`day`,d=Math.round(l)):l<365?(d=Math.round(l/30),u=d===12?`year`:`month`,u===`year`&&(d=1)):(u=`year`,d=Math.round(l/365)),IS.format(r?d:-d,u)}var RS=Ie(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-2xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function zS({className:e,variant:t=`default`,render:n,...r}){return _v({defaultTagName:`span`,props:Rt({className:K(RS({variant:t}),e)},r),render:n,state:{slot:`badge`,variant:t}})}function BS(e){let t=(0,$.c)(28),{connection:n}=e,r=Z_(n),i,a,o,s,c,l,u;if(t[0]!==r||t[1]!==n){u=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Wi(Qr(r));if(Pa(r)){let e;t[9]===r.cause?e=t[10]:(e=Km(wn(r.cause)),t[9]=r.cause,t[10]=e);let n;t[11]===e?n=t[12]:(n=(0,Q.jsx)(P_,{variant:`destructive`,children:(0,Q.jsx)(I_,{children:e})}),t[11]=e,t[12]=n),u=n;break bb0}if(!e){let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(L_,{}),t[13]=e):e=t[13],u=e;break bb0}l=`flex flex-col gap-2`,i=vv,a=`list`,o=`Paired devices and links`;let d;t[14]===n?d=t[15]:(d=e=>(0,Q.jsxs)(bv,{variant:`outline`,size:`sm`,role:`listitem`,"aria-label":e.label,children:[(0,Q.jsxs)(Cv,{className:`min-w-0`,children:[(0,Q.jsxs)(wv,{children:[e.label,e.current&&(0,Q.jsx)(zS,{variant:`secondary`,children:`This browser`}),(0,Q.jsx)(zS,{variant:`outline`,children:gm[e.route]})]}),(0,Q.jsxs)(Tv,{children:[`Last seen `,LS(e.lastSeenAt),` · `,e.platform]}),e.routeInferred&&(0,Q.jsxs)(Tv,{children:[`Paired before each device was tied to one way in, so it now works only through `,gm[e.route],`, where it was last seen. Pair it again to use another way in.`]})]}),(0,Q.jsxs)(Ev,{children:[(0,Q.jsx)(VS,{connection:n,id:e.id,label:e.label,trusted:e.trusted}),!e.current&&(0,Q.jsx)(HS,{connection:n,id:e.id,label:e.label,cancelLink:!1})]})]},e.id),t[14]=n,t[15]=d),s=e.devices.map(d);let f;t[16]===n?f=t[17]:(f=e=>(0,Q.jsxs)(bv,{variant:`outline`,size:`sm`,role:`listitem`,"aria-label":e.label,children:[(0,Q.jsxs)(Cv,{className:`min-w-0`,children:[(0,Q.jsxs)(wv,{children:[e.label,(0,Q.jsx)(zS,{variant:`outline`,children:`Pending link`})]}),(0,Q.jsxs)(Tv,{children:[`Works once, until`,` `,new Date(e.expiresAt).toLocaleTimeString()]})]}),(0,Q.jsx)(Ev,{children:(0,Q.jsx)(HS,{connection:n,id:e.id,label:e.label,cancelLink:!0})})]},e.id),t[16]=n,t[17]=f),c=e.grants.map(f)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8];if(u!==Symbol.for(`react.early_return_sentinel`))return u;let d;t[18]!==i||t[19]!==a||t[20]!==o||t[21]!==s||t[22]!==c?(d=(0,Q.jsxs)(i,{role:a,"aria-label":o,children:[s,c]}),t[18]=i,t[19]=a,t[20]=o,t[21]=s,t[22]=c,t[23]=d):d=t[23];let f;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Each device has its own credential, which works only through the way in it was paired over, so a credential seen on one network cannot be used through another. A phone that uses two ways in is paired once through each. Revoking a device signs it out at once and leaves the others alone.`}),t[24]=f):f=t[24];let p;return t[25]!==l||t[26]!==d?(p=(0,Q.jsxs)(`div`,{className:l,children:[d,f]}),t[25]=l,t[26]=d,t[27]=p):p=t[27],p}function VS(e){let t=(0,$.c)(11),{connection:n,id:r,label:i,trusted:a}=e,[o,s]=q_(n,r),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(cv,{"aria-hidden":!0,children:`Can update`}),t[0]=c):c=t[0];let l=`${i} can update Porcelain`,u;t[1]!==s||t[2]!==l||t[3]!==o.waiting||t[4]!==a?(u=(0,Q.jsx)(Sy,{"aria-label":l,checked:a,disabled:o.waiting,onCheckedChange:s}),t[1]=s,t[2]=l,t[3]=o.waiting,t[4]=a,t[5]=u):u=t[5];let d;t[6]===o?d=t[7]:(d=Pa(o)&&(0,Q.jsx)(P_,{variant:`destructive`,children:(0,Q.jsx)(I_,{children:Km(wn(o.cause))})}),t[6]=o,t[7]=d);let f;return t[8]!==u||t[9]!==d?(f=(0,Q.jsxs)(Q.Fragment,{children:[c,u,d]}),t[8]=u,t[9]=d,t[10]=f):f=t[10],f}function HS(e){let t=(0,$.c)(12),{connection:n,id:r,label:i,cancelLink:a}=e,[o,s]=K_(n,r),c=a?`Cancel the link for ${i}`:`Revoke ${i}`,l;t[0]===s?l=t[1]:(l=()=>s(),t[0]=s,t[1]=l);let u=a?`Cancel`:`Revoke`,d;t[2]!==o.waiting||t[3]!==c||t[4]!==l||t[5]!==u?(d=(0,Q.jsx)(w,{size:`sm`,variant:`outline`,"aria-label":c,disabled:o.waiting,onClick:l,children:u}),t[2]=o.waiting,t[3]=c,t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;t[7]===o?f=t[8]:(f=Pa(o)&&(0,Q.jsx)(P_,{variant:`destructive`,children:(0,Q.jsx)(I_,{children:Km(wn(o.cause))})}),t[7]=o,t[8]=f);let p;return t[9]!==d||t[10]!==f?(p=(0,Q.jsxs)(Q.Fragment,{children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11],p}var US={lan:`Phones and computers on the same Wi-Fi or wired network as this computer, on that one network only.`,tailnet:`Your devices signed in to Tailscale, from anywhere, encrypted and over HTTPS at this computer’s Tailscale name. You set up tailscale serve once; Porcelain checks that it reaches here.`,cloudflare:`Your own Cloudflare tunnel and hostname, over HTTPS from anywhere.`},WS={lan:`Starting`,tailnet:`Checking the Tailscale name`,cloudflare:`Checking the tunnel`};function GS(e){let t=(0,$.c)(19),{name:n,route:r}=e,{status:i}=r;if(i.kind===`off`){let e;return t[0]===r.enabled?e=t[1]:(e=r.enabled?(0,Q.jsxs)(zS,{variant:`outline`,children:[(0,Q.jsx)(L_,{}),`Starting`]}):null,t[0]=r.enabled,t[1]=e),e}if(i.kind===`starting`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(L_,{}),t[2]=e):e=t[2];let r=WS[n],i;return t[3]===r?i=t[4]:(i=(0,Q.jsxs)(zS,{variant:`outline`,children:[e,r]}),t[3]=r,t[4]=i),i}if(i.kind===`paused`){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(zS,{variant:`outline`,children:`Paused on this network`}),t[5]=e):e=t[5],e}if(i.kind===`failed`){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(zS,{variant:`destructive`,children:`Failed`}),t[6]=e):e=t[6];let r;t[7]!==n||t[8]!==i.reason?(r=Cm(n,i.reason),t[7]=n,t[8]=i.reason,t[9]=r):r=t[9];let a;return t[10]===r?a=t[11]:(a=(0,Q.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[e,(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r})]}),t[10]=r,t[11]=a),a}let a=r.enabled?`On`:`Stopping`,o;t[12]===a?o=t[13]:(o=(0,Q.jsx)(zS,{variant:`secondary`,children:a}),t[12]=a,t[13]=o);let s;t[14]===i.urls?s=t[15]:(s=i.urls.map(KS),t[14]=i.urls,t[15]=s);let c;return t[16]!==o||t[17]!==s?(c=(0,Q.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[o,s]}),t[16]=o,t[17]=s,t[18]=c):c=t[18],c}function KS(e){return(0,Q.jsxs)(`div`,{className:`flex max-w-full items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`truncate font-mono text-xs text-muted-foreground`,children:e}),(0,Q.jsx)(w,{size:`icon-xs`,variant:`ghost`,"aria-label":`Copy ${e}`,onClick:()=>ve(e,`address`),children:(0,Q.jsx)(Sf,{})})]},e)}function qS(e){let t=(0,$.c)(24),{name:n,route:r,disabled:i,onChange:a,children:o}=e,s=hm[n],c;t[0]===s?c=t[1]:(c=(0,Q.jsx)(wv,{children:s}),t[0]=s,t[1]=c);let l=US[n],u;t[2]===l?u=t[3]:(u=(0,Q.jsx)(Tv,{children:l}),t[2]=l,t[3]=u);let d;t[4]!==c||t[5]!==u?(d=(0,Q.jsxs)(Cv,{children:[c,u]}),t[4]=c,t[5]=u,t[6]=d):d=t[6];let f;t[7]===a?f=t[8]:(f=e=>a(e),t[7]=a,t[8]=f);let p;t[9]!==i||t[10]!==r.enabled||t[11]!==f||t[12]!==s?(p=(0,Q.jsx)(Ev,{children:(0,Q.jsx)(Sy,{"aria-label":s,checked:r.enabled,disabled:i,onCheckedChange:f})}),t[9]=i,t[10]=r.enabled,t[11]=f,t[12]=s,t[13]=p):p=t[13];let m;t[14]!==n||t[15]!==r?(m=(0,Q.jsx)(GS,{name:n,route:r}),t[14]=n,t[15]=r,t[16]=m):m=t[16];let h;t[17]!==o||t[18]!==m?(h=(0,Q.jsx)(Dv,{children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[m,o]})}),t[17]=o,t[18]=m,t[19]=h):h=t[19];let g;return t[20]!==d||t[21]!==p||t[22]!==h?(g=(0,Q.jsxs)(bv,{variant:`outline`,children:[d,p,h]}),t[20]=d,t[21]=p,t[22]=h,t[23]=g):g=t[23],g}function JS(e){let t=(0,$.c)(13),{remote:n,disabled:r,onTurnOn:i}=e,{lan:a}=n.routes,o=n.localNetwork,s=a.enabled&&a.status.kind===`paused`,c;t[0]!==r||t[1]!==o||t[2]!==i||t[3]!==s?(c=s&&o&&(0,Q.jsxs)(w,{variant:`outline`,size:`sm`,className:`self-start`,disabled:r,onClick:i,children:[`Turn on for `,_m(o)]}),t[0]=r,t[1]=o,t[2]=i,t[3]=s,t[4]=c):c=t[4];let l;t[5]===n?l=t[6]:(l=vm(n),t[5]=n,t[6]=l);let u;t[7]===l?u=t[8]:(u=(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l}),t[7]=l,t[8]=u);let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsxs)(P_,{role:`note`,"aria-label":`Local network warning`,children:[(0,Q.jsx)(Pf,{}),(0,Q.jsx)(F_,{children:`Not encrypted`}),(0,Q.jsx)(I_,{children:`Anyone on the same network can read what Porcelain shows and the device credentials it sends. For an encrypted connection, use Tailscale.`})]}),t[9]=d):d=t[9];let f;return t[10]!==c||t[11]!==u?(f=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[c,u,d]}),t[10]=c,t[11]=u,t[12]=f):f=t[12],f}function YS(e){let t=(0,$.c)(25),{label:n,saveLabel:r,placeholder:i,saved:a,failed:o,disabled:s,onSave:c,onCheck:l}=e,[u,d]=(0,Z.useState)(null),f=u??a,p;t[0]!==f||t[1]!==c?(p=e=>ay(e,async()=>{c(f.trim()),d(null)}),t[0]=f,t[1]=c,t[2]=p):p=t[2];let m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=e=>d(e.target.value),t[3]=m):m=t[3];let h;t[4]!==s||t[5]!==f||t[6]!==n||t[7]!==i?(h=(0,Q.jsx)(ry,{"aria-label":n,placeholder:i,value:f,disabled:s,onChange:m}),t[4]=s,t[5]=f,t[6]=n,t[7]=i,t[8]=h):h=t[8];let g;t[9]!==s||t[10]!==f||t[11]!==a?(g=s||f.trim()===``||f.trim()===a,t[9]=s,t[10]=f,t[11]=a,t[12]=g):g=t[12];let _;t[13]!==r||t[14]!==g?(_=(0,Q.jsx)(w,{type:`submit`,variant:`outline`,className:`shrink-0`,disabled:g,children:r}),t[13]=r,t[14]=g,t[15]=_):_=t[15];let v;t[16]!==s||t[17]!==o||t[18]!==l?(v=o&&(0,Q.jsx)(w,{type:`button`,variant:`outline`,className:`shrink-0`,disabled:s,onClick:l,children:`Check again`}),t[16]=s,t[17]=o,t[18]=l,t[19]=v):v=t[19];let y;return t[20]!==p||t[21]!==h||t[22]!==_||t[23]!==v?(y=(0,Q.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:p,children:[h,_,v]}),t[20]=p,t[21]=h,t[22]=_,t[23]=v,t[24]=y):y=t[24],y}function XS(e){let t=(0,$.c)(20),{remote:n,disabled:r,onSave:i,onCheck:a}=e,o=n.routes.tailnet,s;t[0]===n.tailnetTarget?s=t[1]:(s=n.tailnetTarget===void 0?void 0:Sm(n.tailnetTarget),t[0]=n.tailnetTarget,t[1]=s);let c=s,l=n.tailnetHostname??``,u=o.enabled&&o.status.kind===`failed`,d;t[2]!==r||t[3]!==a||t[4]!==i||t[5]!==l||t[6]!==u?(d=(0,Q.jsx)(YS,{label:`Tailscale name`,saveLabel:`Save name`,placeholder:`laptop.tail1234.ts.net`,saved:l,failed:u,disabled:r,onSave:i,onCheck:a}),t[2]=r,t[3]=a,t[4]=i,t[5]=l,t[6]=u,t[7]=d):d=t[7];let f;t[8]===n.tailnetHostname?f=t[9]:(f=n.tailnetHostname===void 0&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Save this computer’s name on your tailnet, as tailscale status or the Tailscale admin console shows it, to turn this on. Porcelain then names the one command to run.`}),t[8]=n.tailnetHostname,t[9]=f);let p;t[10]!==n.tailnetHostname||t[11]!==o.enabled?(p=n.tailnetHostname!==void 0&&!o.enabled&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`If you set up tailscale serve for Porcelain, remove it with tailscale serve --https=443 off, or Tailscale keeps forwarding to a port Porcelain no longer holds.`}),t[10]=n.tailnetHostname,t[11]=o.enabled,t[12]=p):p=t[12];let m;t[13]===c?m=t[14]:(m=c!==void 0&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Run this once on this computer. Tailscale keeps it across restarts; remove it with tailscale serve --https=443 off.`}),(0,Q.jsxs)(`div`,{className:`flex max-w-full items-center gap-1`,children:[(0,Q.jsx)(`code`,{className:`truncate rounded bg-muted px-1.5 py-0.5 font-mono text-xs`,children:c}),(0,Q.jsx)(w,{size:`icon-xs`,variant:`ghost`,"aria-label":`Copy the tailscale serve command`,onClick:()=>ve(c,`command`),children:(0,Q.jsx)(Sf,{})})]})]}),t[13]=c,t[14]=m);let h;return t[15]!==d||t[16]!==f||t[17]!==p||t[18]!==m?(h=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[d,f,p,m]}),t[15]=d,t[16]=f,t[17]=p,t[18]=m,t[19]=h):h=t[19],h}function ZS(e){let t=(0,$.c)(11),{remote:n,disabled:r,onSave:i,onCheck:a}=e,o=n.routes.cloudflare,s=n.cloudflareHostname??``,c=o.enabled&&o.status.kind===`failed`,l;t[0]!==r||t[1]!==a||t[2]!==i||t[3]!==s||t[4]!==c?(l=(0,Q.jsx)(YS,{label:`Public hostname`,saveLabel:`Save hostname`,placeholder:`porcelain.example.com`,saved:s,failed:c,disabled:r,onSave:i,onCheck:a}),t[0]=r,t[1]=a,t[2]=i,t[3]=s,t[4]=c,t[5]=l):l=t[5];let u;t[6]===n.serviceUrl?u=t[7]:(u=(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`In Cloudflare, publish this hostname from your tunnel to`,` `,(0,Q.jsx)(`span`,{className:`font-mono`,children:n.serviceUrl}),`, and run cloudflared on this computer as a service. Porcelain answers to the hostname only while this is on.`]}),t[6]=n.serviceUrl,t[7]=u);let d;return t[8]!==l||t[9]!==u?(d=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10],d}function QS(e){let t=(0,$.c)(54),{connection:n,remote:r}=e,[i,a]=J_(n),o=i.waiting,s=o||!r.routes.lan.enabled&&r.localNetwork===void 0,c;t[0]===a?c=t[1]:(c=e=>a({lan:e}),t[0]=a,t[1]=c);let l;t[2]===a?l=t[3]:(l=()=>a({lan:!0}),t[2]=a,t[3]=l);let u;t[4]!==o||t[5]!==r||t[6]!==l?(u=(0,Q.jsx)(JS,{remote:r,disabled:o,onTurnOn:l}),t[4]=o,t[5]=r,t[6]=l,t[7]=u):u=t[7];let d;t[8]!==r.routes.lan||t[9]!==s||t[10]!==c||t[11]!==u?(d=(0,Q.jsx)(vv,{children:(0,Q.jsx)(qS,{name:`lan`,route:r.routes.lan,disabled:s,onChange:c,children:u})}),t[8]=r.routes.lan,t[9]=s,t[10]=c,t[11]=u,t[12]=d):d=t[12];let f=o||r.tailnetHostname===void 0,p;t[13]===a?p=t[14]:(p=e=>a({tailnet:e}),t[13]=a,t[14]=p);let m;t[15]!==r.tailnetHostname||t[16]!==a?(m=e=>a({tailnetHostname:e,...r.tailnetHostname===void 0?{tailnet:!0}:{}}),t[15]=r.tailnetHostname,t[16]=a,t[17]=m):m=t[17];let h;t[18]===a?h=t[19]:(h=()=>a({tailnet:!0}),t[18]=a,t[19]=h);let g;t[20]!==o||t[21]!==r||t[22]!==m||t[23]!==h?(g=(0,Q.jsx)(XS,{remote:r,disabled:o,onSave:m,onCheck:h}),t[20]=o,t[21]=r,t[22]=m,t[23]=h,t[24]=g):g=t[24];let _;t[25]!==r.routes.tailnet||t[26]!==g||t[27]!==f||t[28]!==p?(_=(0,Q.jsx)(vv,{children:(0,Q.jsx)(qS,{name:`tailnet`,route:r.routes.tailnet,disabled:f,onChange:p,children:g})}),t[25]=r.routes.tailnet,t[26]=g,t[27]=f,t[28]=p,t[29]=_):_=t[29];let v=o||r.cloudflareHostname===void 0,y;t[30]===a?y=t[31]:(y=e=>a({cloudflare:e}),t[30]=a,t[31]=y);let b;t[32]!==r.cloudflareHostname||t[33]!==a?(b=e=>a({cloudflareHostname:e,...r.cloudflareHostname===void 0?{cloudflare:!0}:{}}),t[32]=r.cloudflareHostname,t[33]=a,t[34]=b):b=t[34];let x;t[35]===a?x=t[36]:(x=()=>a({cloudflare:!0}),t[35]=a,t[36]=x);let S;t[37]!==o||t[38]!==r||t[39]!==b||t[40]!==x?(S=(0,Q.jsx)(ZS,{remote:r,disabled:o,onSave:b,onCheck:x}),t[37]=o,t[38]=r,t[39]=b,t[40]=x,t[41]=S):S=t[41];let C;t[42]!==r.routes.cloudflare||t[43]!==v||t[44]!==y||t[45]!==S?(C=(0,Q.jsx)(vv,{children:(0,Q.jsx)(qS,{name:`cloudflare`,route:r.routes.cloudflare,disabled:v,onChange:y,children:S})}),t[42]=r.routes.cloudflare,t[43]=v,t[44]=y,t[45]=S,t[46]=C):C=t[46];let w;t[47]===i?w=t[48]:(w=Pa(i)&&(0,Q.jsx)(P_,{variant:`destructive`,children:(0,Q.jsx)(I_,{children:Km(wn(i.cause))})}),t[47]=i,t[48]=w);let T;return t[49]!==_||t[50]!==C||t[51]!==w||t[52]!==d?(T=(0,Q.jsxs)(Q.Fragment,{children:[d,_,C,w]}),t[49]=_,t[50]=C,t[51]=w,t[52]=d,t[53]=T):T=t[53],T}function $S(e){let t=(0,$.c)(10),{connection:n,children:r}=e,i=Q_(n),a,o;if(t[0]!==r||t[1]!==i){o=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Wi(Qr(i));if(e===null){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Sharing is managed from a browser on the computer that runs Porcelain.`}),t[4]=e):e=t[4],o=e;break bb0}if(Pa(i)){let e;t[5]===i.cause?e=t[6]:(e=Km(wn(i.cause)),t[5]=i.cause,t[6]=e);let n;t[7]===e?n=t[8]:(n=(0,Q.jsx)(P_,{variant:`destructive`,children:(0,Q.jsx)(I_,{children:e})}),t[7]=e,t[8]=n),o=n;break bb0}if(!e){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(L_,{}),t[9]=e):e=t[9],o=e;break bb0}a=r(e)}t[0]=r,t[1]=i,t[2]=a,t[3]=o}else a=t[2],o=t[3];return o===Symbol.for(`react.early_return_sentinel`)?a:o}function eC(){return p_(),null}function tC(e){let t=(0,$.c)(3),{desktop:n}=e;if(n===!0){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(fy,{}),t[0]=e):e=t[0],e}if(n===!1){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(ov,{}),t[1]=e):e=t[1],e}let r;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsx)(L_,{}),t[2]=r):r=t[2],r}function nC(e){let t=(0,$.c)(4),{environment:n}=e,r=eC(),i=Wi(Qr(Fv())),a;return t[0]!==r||t[1]!==i?.isDesktopShell||t[2]!==n?(a=r&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(vv,{children:(0,Q.jsx)(bv,{variant:`outline`,children:(0,Q.jsx)(Cv,{children:(0,Q.jsx)(oy,{connection:r,environment:n})})})}),(0,Q.jsxs)(lv,{children:[(0,Q.jsx)(uv,{variant:`label`,children:`Updates`}),(0,Q.jsx)(vv,{children:(0,Q.jsx)(bv,{variant:`outline`,children:(0,Q.jsx)(Cv,{children:(0,Q.jsx)(tC,{desktop:i?.isDesktopShell})})})})]})]}),t[0]=r,t[1]=i?.isDesktopShell,t[2]=n,t[3]=a):a=t[3],a}function rC(){let e=(0,$.c)(2),t=eC(),n;return e[0]===t?n=e[1]:(n=t&&(0,Q.jsx)($S,{connection:t,children:e=>(0,Q.jsx)(QS,{connection:t,remote:e})}),e[0]=t,e[1]=n),n}function iC(e){let t=(0,$.c)(3),{environment:n}=e,r=eC(),i;return t[0]!==r||t[1]!==n?(i=r&&(0,Q.jsx)($S,{connection:r,children:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(lv,{children:[(0,Q.jsx)(uv,{variant:`label`,children:`Pair a device`}),(0,Q.jsx)(vv,{children:(0,Q.jsx)(bv,{variant:`outline`,children:(0,Q.jsxs)(Cv,{children:[(0,Q.jsxs)(Tv,{children:[`Open the link or scan the code on the other device to connect it to `,n.name,`. Each link works once, for a few minutes.`]}),(0,Q.jsx)(NS,{connection:r,remote:e})]})})})]}),(0,Q.jsxs)(lv,{children:[(0,Q.jsx)(uv,{variant:`label`,children:`Paired devices`}),(0,Q.jsx)(BS,{connection:r})]})]})}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function aC({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`empty`,className:K(`flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-3xl border-dashed p-12 text-center text-balance`,e),...t})}function oC({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`empty-header`,className:K(`flex max-w-sm flex-col items-center gap-2`,e),...t})}var sC=Ie(`mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-transparent`,icon:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-muted text-foreground [&_svg:not([class*='size-'])]:size-5`}},defaultVariants:{variant:`default`}});function cC({className:e,variant:t=`default`,...n}){return(0,Q.jsx)(`div`,{"data-slot":`empty-icon`,"data-variant":t,className:K(sC({variant:t,className:e})),...n})}function lC({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`empty-title`,className:K(`font-heading text-lg font-medium tracking-tight`,e),...t})}function uC({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`empty-description`,className:K(`text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function dC({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`empty-content`,className:K(`flex w-full max-w-sm min-w-0 flex-col items-center gap-4 text-sm text-balance`,e),...t})}function fC(e){let t=(0,$.c)(41),{remote:n}=e,r=M_(n),i=E_(n),a=h_(n.environmentId),o;t[0]===r?o=t[1]:(o=Lp(r),t[0]=r,t[1]=o);let s=o,c=r.kind===`online`?r.name:n.name,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(Sv,{variant:`icon`,children:(0,Q.jsx)(Mf,{})}),t[2]=l):l=t[2];let u;t[3]===c?u=t[4]:(u=(0,Q.jsx)(wv,{children:c}),t[3]=c,t[4]=u);let d=r.kind===`online`&&r.version?` · Porcelain ${r.version}`:``,f;t[5]!==n.address||t[6]!==d?(f=(0,Q.jsxs)(Tv,{children:[n.address,d]}),t[5]=n.address,t[6]=d,t[7]=f):f=t[7];let p;t[8]!==u||t[9]!==f?(p=(0,Q.jsxs)(Cv,{children:[u,f]}),t[8]=u,t[9]=f,t[10]=p):p=t[10];let m;t[11]===r?m=t[12]:(m=Dh(r),t[11]=r,t[12]=m);let h;t[13]===r?h=t[14]:(h=Ip(r),t[13]=r,t[14]=h);let g;t[15]!==m||t[16]!==h?(g=(0,Q.jsx)(zS,{variant:m,children:h}),t[15]=m,t[16]=h,t[17]=g):g=t[17];let _=`Remove ${c}`,v;t[18]===i?v=t[19]:(v=()=>i.submit(),t[18]=i,t[19]=v);let y;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(If,{}),t[20]=y):y=t[20];let b;t[21]!==i.result.waiting||t[22]!==_||t[23]!==v?(b=(0,Q.jsx)(w,{variant:`ghost`,size:`icon-sm`,"aria-label":_,disabled:i.result.waiting,onClick:v,children:y}),t[21]=i.result.waiting,t[22]=_,t[23]=v,t[24]=b):b=t[24];let x;t[25]!==b||t[26]!==g?(x=(0,Q.jsxs)(Ev,{children:[g,b]}),t[25]=b,t[26]=g,t[27]=x):x=t[27];let S;t[28]!==a||t[29]!==c||t[30]!==r.kind?(S=r.kind===`online`&&a&&(0,Q.jsx)(Dv,{children:(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(sv,{connection:a.connection,name:c,deviceId:a.remote.deviceId})})}),t[28]=a,t[29]=c,t[30]=r.kind,t[31]=S):S=t[31];let C;t[32]!==i.result||t[33]!==s?(C=(s||Pa(i.result))&&(0,Q.jsx)(Dv,{children:(0,Q.jsx)(Tv,{children:Pa(i.result)?Km(wn(i.result.cause)):s})}),t[32]=i.result,t[33]=s,t[34]=C):C=t[34];let T;return t[35]!==c||t[36]!==x||t[37]!==S||t[38]!==C||t[39]!==p?(T=(0,Q.jsxs)(bv,{variant:`outline`,role:`listitem`,"aria-label":c,children:[l,p,x,S,C]}),t[35]=c,t[36]=x,t[37]=S,t[38]=C,t[39]=p,t[40]=T):T=t[40],T}function pC(){let e=(0,$.c)(27),[t,n]=(0,Z.useState)(``),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>n(``),e[0]=r):r=e[0];let i=T_(r),{status:a}=f_(),o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(Tv,{children:`On the other computer, run porcelain pair and paste the link it prints. This app keeps its own credential for that computer.`}),e[1]=o):o=e[1];let s;e[2]!==i||e[3]!==t?(s=e=>ay(e,()=>i.submit(t)),e[2]=i,e[3]=t,e[4]=s):s=e[4];let c=i.result.waiting||a!==`ready`,l;e[5]===i?l=e[6]:(l=e=>{i.reset(),n(e.target.value)},e[5]=i,e[6]=l);let u;e[7]!==t||e[8]!==c||e[9]!==l?(u=(0,Q.jsx)(ry,{"aria-label":`Pairing link`,placeholder:`http://192.168.1.20:4738/pair#c=…`,value:t,disabled:c,onChange:l}),e[7]=t,e[8]=c,e[9]=l,e[10]=u):u=e[10];let d;e[11]!==i.result.waiting||e[12]!==t||e[13]!==a?(d=i.result.waiting||a!==`ready`||t.trim()===``,e[11]=i.result.waiting,e[12]=t,e[13]=a,e[14]=d):d=e[14];let f=i.result.waiting?`Pairing…`:`Add`,p;e[15]!==d||e[16]!==f?(p=(0,Q.jsx)(w,{type:`submit`,className:`shrink-0`,disabled:d,children:f}),e[15]=d,e[16]=f,e[17]=p):p=e[17];let m;e[18]!==s||e[19]!==u||e[20]!==p?(m=(0,Q.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:s,children:[u,p]}),e[18]=s,e[19]=u,e[20]=p,e[21]=m):m=e[21];let h;e[22]===i.result?h=e[23]:(h=Pa(i.result)&&(0,Q.jsx)(P_,{variant:`destructive`,children:(0,Q.jsx)(I_,{children:Km(wn(i.result.cause))})}),e[22]=i.result,e[23]=h);let g;return e[24]!==h||e[25]!==m?(g=(0,Q.jsx)(bv,{variant:`outline`,children:(0,Q.jsxs)(Cv,{children:[o,m,h]})}),e[24]=h,e[25]=m,e[26]=g):g=e[26],g}function mC(){let e=(0,$.c)(11),{remotes:t,error:n}=f_(),r=O_(),i;e[0]!==r||e[1]!==n?(i=n!==void 0&&(0,Q.jsxs)(P_,{variant:`destructive`,children:[(0,Q.jsx)(wf,{}),(0,Q.jsx)(F_,{children:`Saved remote computers could not be read`}),(0,Q.jsxs)(I_,{children:[`Porcelain keeps them as they are and saves no change over them. Allow Porcelain to read its saved credentials, then try again.`,` `,n,(0,Q.jsx)(w,{variant:`outline`,disabled:r.result.waiting,onClick:()=>r.read(),children:`Read saved environments`})]})]}),e[0]=r,e[1]=n,e[2]=i):i=e[2];let a;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(uv,{variant:`label`,children:`Add a remote computer`}),e[3]=a):a=e[3];let o;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsxs)(lv,{children:[a,(0,Q.jsx)(vv,{children:(0,Q.jsx)(pC,{})})]}),e[4]=o):o=e[4];let s;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(uv,{variant:`label`,children:`Remote computers`}),e[5]=s):s=e[5];let c;e[6]===t?c=e[7]:(c=(0,Q.jsxs)(lv,{children:[s,t.length===0?(0,Q.jsx)(aC,{children:(0,Q.jsxs)(oC,{children:[(0,Q.jsx)(cC,{variant:`icon`,children:(0,Q.jsx)(Of,{})}),(0,Q.jsx)(lC,{children:`No remote computers yet`}),(0,Q.jsx)(uC,{children:`Add one to review its projects from this app, next to the projects on this computer.`})]})}):(0,Q.jsx)(vv,{"aria-label":`Remote computers`,children:t.map(hC)})]}),e[6]=t,e[7]=c);let l;return e[8]!==i||e[9]!==c?(l=(0,Q.jsxs)(Q.Fragment,{children:[i,o,c]}),e[8]=i,e[9]=c,e[10]=l):l=e[10],l}function hC(e){return(0,Q.jsx)(fC,{remote:e},e.environmentId)}function gC(e){let t=(0,$.c)(18),{name:n,status:r,onOpenRemotes:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(cC,{variant:`icon`,children:(0,Q.jsx)(Af,{})}),t[0]=a):a=t[0];let o;t[1]===r?o=t[2]:(o=Ip(r),t[1]=r,t[2]=o);let s;t[3]!==n||t[4]!==o?(s=(0,Q.jsxs)(lC,{children:[n,`: `,o]}),t[3]=n,t[4]=o,t[5]=s):s=t[5];let c;t[6]===r?c=t[7]:(c=Lp(r),t[6]=r,t[7]=c);let l;t[8]===c?l=t[9]:(l=(0,Q.jsx)(uC,{children:c}),t[8]=c,t[9]=l);let u;t[10]!==s||t[11]!==l?(u=(0,Q.jsxs)(oC,{children:[a,s,l]}),t[10]=s,t[11]=l,t[12]=u):u=t[12];let d;t[13]===i?d=t[14]:(d=(0,Q.jsx)(dC,{children:(0,Q.jsx)(w,{variant:`outline`,onClick:i,children:`Open Remote computers`})}),t[13]=i,t[14]=d);let f;return t[15]!==u||t[16]!==d?(f=(0,Q.jsxs)(aC,{children:[u,d]}),t[15]=u,t[16]=d,t[17]=f):f=t[17],f}var _C=Se(Nt.layer).atom(C(function*(){return Jr()}));function vC(){let e=(0,$.c)(8),t=ga(_C),n;e[0]===t?n=e[1]:(n=Wi(Oi(Qr(t))),e[0]=t,e[1]=n);let r;e[2]===t?r=e[3]:(r=Pa(t),e[2]=t,e[3]=r);let i=Ba(_C),a;return e[4]!==n||e[5]!==r||e[6]!==i?(a={configuration:n,failed:r,retry:i},e[4]=n,e[5]=r,e[6]=i,e[7]=a):a=e[7],a}export{wv as $,xd as $n,lg as $t,nx as A,Sf as An,Wg as At,$y as B,Cd as Bn,Tg as Bt,Yb as C,Ip as Cn,Pc as Cr,p_ as Ct,$b as D,If as Dn,Kg as Dt,Jb as E,Rf as En,d_ as Et,zb as F,ff as Fn,Dg as Ft,ay as G,kd as Gn,wg as Gt,wy as H,jd as Hn,Sg as Ht,Eb as I,Zd as In,kg as It,bv as J,Fd as Jn,yg as Jt,ry as K,Nd as Kn,vg as Kt,_b as L,Yd as Ln,Ag as Lt,qb as M,vf as Mn,Vg as Mt,Gb as N,gf as Nn,Ug as Nt,Qb as O,Mf as On,qg as Ot,Vb as P,hf as Pn,Ig as Pt,vv as Q,Sd as Qn,fg as Qt,ab as R,Jd as Rn,Mg as Rt,cx as S,Lp as Sn,Rc as Sr,g_ as St,Zb as T,zf as Tn,m_ as Tt,Sy as U,Ad as Un,xg as Ut,Qy as V,Ed as Vn,jg as Vt,iy as W,wd as Wn,Cg as Wt,Cv as X,Id as Xn,pg as Xt,Ev as Y,Td as Yn,gg as Yt,Tv as Z,Md as Zn,mg as Zt,Vx as _,ph as _n,qc as _r,M_ as _t,uC as a,Gh as an,nu as ar,uv as at,Lx as b,Rm as bn,zc as br,b_ as bt,lC as c,Fh as cn,$l as cr,ov as ct,rC as d,Ch as dn,jl as dr,V_ as dt,cg as en,bd as er,_v as et,zS as f,xh as fn,nl as fr,B_ as ft,Ix as g,mh as gn,Yc as gr,F_ as gt,zx as h,hh as hn,Jc as hr,I_ as ht,aC as i,eg as in,tu as ir,mv as it,rx as j,bf as jn,Lg as jt,ex as k,Of as kn,Gg as kt,nC as l,Oh as ln,Yl as lr,W_ as lt,Fx as m,vh as mn,Xc as mr,P_ as mt,gC as n,tg as nn,fu as nr,gv as nt,oC as o,Wh as on,eu as or,lv as ot,LS as p,yh as pn,Qc as pr,L_ as pt,Qv as q,Pd as qn,hg as qt,mC as r,rg as rn,du as rr,dv as rt,cC as s,Ph as sn,Ql as sr,cv as st,vC as t,ng as tn,hu as tr,pv as tt,iC as u,Dh as un,Ml as ur,U_ as ut,Bx as v,oh as vn,Kc as vr,k_ as vt,Xb as w,Vf as wn,Nc as wr,h_ as wt,bx as x,qp as xn,Ic as xr,v_ as xt,Rx as y,Km as yn,Lc as yr,D_ as yt,tb as z,Ld as zn,Eg as zt};
|