autoglm-gui 0.4.12__py3-none-any.whl → 0.4.14__py3-none-any.whl
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.
- AutoGLM_GUI/api/__init__.py +2 -1
- AutoGLM_GUI/api/version.py +192 -0
- AutoGLM_GUI/schemas.py +11 -0
- AutoGLM_GUI/static/assets/{about-kgOkkOWe.js → about-29B5FDM8.js} +1 -1
- AutoGLM_GUI/static/assets/chat-DTN2oKtA.js +149 -0
- AutoGLM_GUI/static/assets/index-Dy550Qqg.css +1 -0
- AutoGLM_GUI/static/assets/{index-BPYHsweG.js → index-mVNV0VwM.js} +1 -1
- AutoGLM_GUI/static/assets/index-wu8Wjf12.js +10 -0
- AutoGLM_GUI/static/index.html +2 -2
- {autoglm_gui-0.4.12.dist-info → autoglm_gui-0.4.14.dist-info}/METADATA +55 -2
- {autoglm_gui-0.4.12.dist-info → autoglm_gui-0.4.14.dist-info}/RECORD +14 -13
- AutoGLM_GUI/static/assets/chat-CZV3RByK.js +0 -149
- AutoGLM_GUI/static/assets/index-Beu9cbSy.css +0 -1
- AutoGLM_GUI/static/assets/index-DfI_Z1Cx.js +0 -10
- {autoglm_gui-0.4.12.dist-info → autoglm_gui-0.4.14.dist-info}/WHEEL +0 -0
- {autoglm_gui-0.4.12.dist-info → autoglm_gui-0.4.14.dist-info}/entry_points.txt +0 -0
- {autoglm_gui-0.4.12.dist-info → autoglm_gui-0.4.14.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import{c as te,a as es,r as l,j as a,S as ts,b as ne,u as lt,d as en,g as Un,s as ns,e as tn,f as nn,h as rs,i as ss,k as is,l as os,R as Gn,m as as,n as cs,o as ke,p as ls,P as us,q as ds,t as fs,v as hs,w as ps,x as ms}from"./index-DfI_Z1Cx.js";const _s=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],gs=te("chevron-left",_s);const xs=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],vs=te("chevron-right",xs);const bs=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Je=te("circle-alert",bs);const ys=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],at=te("circle-check",ys);const ws=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Es=te("eye-off",ws);const Ts=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Cs=te("eye",Ts);const Ss=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],rn=te("image",Ss);const Ns=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ue=te("loader-circle",Ns);const ks=[["path",{d:"M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z",key:"vbtd3f"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]],Rs=te("monitor-play",ks);const Ps=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],As=te("plug",Ps);const Ds=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Ls=te("rotate-ccw",Ds);const js=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Os=te("send",js);const Bs=[["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"}]],Is=te("server",Bs);const Ms=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Wn=te("settings",Ms);const Fs=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],qn=te("smartphone",Fs);const Us=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],_t=te("sparkles",Us);const Gs=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Ws=te("video",Gs);const qs=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Hs=te("wifi-off",qs);const Xs=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Vs=te("wifi",Xs);const zs=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],$s=te("x",zs),sn=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,on=es,Hn=(t,e)=>n=>{var r;if(e?.variants==null)return on(t,n?.class,n?.className);const{variants:i,defaultVariants:s}=e,c=Object.keys(i).map(d=>{const f=n?.[d],h=s?.[d];if(f===null)return null;const _=sn(f)||sn(h);return i[d][_]}),o=n&&Object.entries(n).reduce((d,f)=>{let[h,_]=f;return _===void 0||(d[h]=_),d},{}),u=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((d,f)=>{let{class:h,className:_,...m}=f;return Object.entries(m).every(x=>{let[p,v]=x;return Array.isArray(v)?v.includes({...s,...o}[p]):{...s,...o}[p]===v})?[...d,h,_]:d},[]);return on(t,c,u,n?.class,n?.className)},Ys=Hn("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-slate-900 text-white hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-900 dark:hover:bg-slate-200",destructive:"bg-red-500 text-white hover:bg-red-600 dark:bg-red-900 dark:hover:bg-red-800",outline:"border border-slate-200 bg-white hover:bg-slate-100 hover:text-slate-900 dark:border-slate-800 dark:bg-slate-950 dark:hover:bg-slate-800 dark:hover:text-slate-50",secondary:"bg-slate-100 text-slate-900 hover:bg-slate-200 dark:bg-slate-800 dark:text-slate-50 dark:hover:bg-slate-700",ghost:"hover:bg-slate-100 hover:text-slate-900 dark:hover:bg-slate-800 dark:hover:text-slate-50",link:"text-slate-900 underline-offset-4 hover:underline dark:text-slate-50",twitter:"bg-[#1d9bf0] text-white hover:bg-[#1a8cd8] dark:bg-[#1d9bf0] dark:hover:bg-[#1a8cd8]"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-full px-3",lg:"h-11 rounded-full px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),ie=l.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...i},s)=>{const c=r?ts:"button";return a.jsx(c,{className:ne(Ys({variant:e,size:n,className:t})),ref:s,...i})});ie.displayName="Button";const Ks=Hn("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-slate-400 focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-[#1d9bf0] text-white dark:bg-[#1d9bf0] dark:text-white",secondary:"border-transparent bg-slate-100 text-slate-900 dark:bg-slate-800 dark:text-slate-50",destructive:"border-transparent bg-red-500 text-white dark:bg-red-900 dark:text-slate-50",outline:"text-slate-950 dark:text-slate-50",success:"border-transparent bg-green-500 text-white dark:bg-green-900 dark:text-slate-50",warning:"border-transparent bg-yellow-500 text-white dark:bg-yellow-900 dark:text-slate-50"}},defaultVariants:{variant:"default"}});function Qe({className:t,variant:e,...n}){return a.jsx("div",{className:ne(Ks({variant:e}),t),...n})}function an({isOpen:t,title:e,content:n,onConfirm:r,onCancel:i,confirmText:s="确认",cancelText:c="取消"}){return t?a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm animate-in fade-in duration-200",children:a.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-xl max-w-md w-full overflow-hidden transform transition-all animate-in zoom-in-95 duration-200",onClick:o=>o.stopPropagation(),children:[a.jsxs("div",{className:"p-6",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:e}),a.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm leading-relaxed whitespace-pre-wrap",children:n})]}),a.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 px-6 py-4 flex justify-end gap-3",children:[a.jsx("button",{onClick:o=>{o.stopPropagation(),i()},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 transition-colors",children:c}),a.jsx("button",{onClick:o=>{o.stopPropagation(),r()},className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors",children:s})]})]})}):null}function Js({id:t,model:e,status:n,connectionType:r,isInitialized:i,isActive:s,onClick:c,onConnectWifi:o,onDisconnectWifi:u}){const d=lt(),f=n==="device",h=r==="usb",_=r==="remote",[m,x]=l.useState(!1),[p,v]=l.useState(!1),[E,S]=l.useState(!1),g=y=>{y.stopPropagation(),!(m||!o)&&v(!0)},b=y=>{y.stopPropagation(),!(m||!u)&&S(!0)},C=async()=>{v(!1),x(!0);try{o&&await o()}finally{x(!1)}},N=async()=>{S(!1),x(!0);try{u&&await u()}finally{x(!1)}};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:c,role:"button",tabIndex:0,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&c()},className:`
|
|
2
|
-
group relative w-full text-left p-4 rounded-xl transition-all duration-200 cursor-pointer
|
|
3
|
-
border-2
|
|
4
|
-
${s?"bg-slate-50 border-[#1d9bf0] dark:bg-slate-800/50 dark:border-[#1d9bf0]":"bg-white border-transparent hover:border-slate-200 dark:bg-slate-900 dark:hover:border-slate-700"}
|
|
5
|
-
`,children:[s&&a.jsx("div",{className:"absolute left-0 top-2 bottom-2 w-1 bg-[#1d9bf0] rounded-r"}),a.jsxs("div",{className:"flex items-center gap-3 pl-2",children:[a.jsx("div",{className:`relative flex-shrink-0 ${f?"status-online":"status-offline"} w-3 h-3 rounded-full transition-all ${s?"scale-110":""}`}),a.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-0.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qn,{className:`w-4 h-4 ${s?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:`font-semibold text-sm truncate ${s?"text-slate-900 dark:text-slate-100":"text-slate-700 dark:text-slate-300"}`,children:e||d.deviceCard.unknownDevice})]}),a.jsx("span",{className:`text-xs font-mono truncate ${s?"text-slate-500 dark:text-slate-400":"text-slate-400 dark:text-slate-500"}`,children:t})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[h&&o&&a.jsx(ie,{variant:"ghost",size:"icon",onClick:g,disabled:m,className:`h-8 w-8 rounded-full ${s?"text-white hover:bg-white/20":"text-slate-400 hover:text-[#1d9bf0] hover:bg-slate-100 dark:hover:bg-slate-800"}`,title:d.deviceCard.connectViaWifi,children:m?a.jsx(Ue,{className:"w-4 h-4 animate-spin"}):a.jsx(Vs,{className:"w-4 h-4"})}),_&&u&&a.jsx(ie,{variant:"ghost",size:"icon",onClick:b,disabled:m,className:`h-8 w-8 rounded-full ${s?"text-white hover:bg-white/20":"text-slate-400 hover:text-red-500 hover:bg-slate-100 dark:hover:bg-slate-800"}`,title:d.deviceCard.disconnectWifi,children:m?a.jsx(Ue,{className:"w-4 h-4 animate-spin"}):a.jsx(Hs,{className:"w-4 h-4"})}),i&&a.jsxs(Qe,{variant:"success",className:`text-xs ${s?"bg-white/20 text-white":""}`,children:[a.jsx(at,{className:"w-3 h-3 mr-1"}),d.deviceCard.ready]})]})]})]}),a.jsx(an,{isOpen:p,title:d.deviceCard.connectWifiTitle,content:d.deviceCard.connectWifiContent,onConfirm:C,onCancel:()=>v(!1)}),a.jsx(an,{isOpen:E,title:d.deviceCard.disconnectWifiTitle,content:d.deviceCard.disconnectWifiContent,onConfirm:N,onCancel:()=>S(!1)})]})}const Qs=()=>{try{const t=localStorage.getItem("sidebar-collapsed");return t!==null?JSON.parse(t):!1}catch(t){return console.warn("Failed to load sidebar collapsed state:",t),!1}};function Zs({devices:t,currentDeviceId:e,onSelectDevice:n,onOpenConfig:r,onConnectWifi:i,onDisconnectWifi:s}){const c=lt(),[o,u]=l.useState(Qs);l.useEffect(()=>{localStorage.setItem("sidebar-collapsed",JSON.stringify(o))},[o]),l.useEffect(()=>{const f=h=>{(h.metaKey||h.ctrlKey)&&h.key==="b"&&(h.preventDefault(),u(!o))};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[o]);const d=()=>{u(!o)};return a.jsxs(a.Fragment,{children:[o&&a.jsx(ie,{variant:"outline",size:"icon",onClick:d,className:"fixed left-0 top-20 z-50 h-16 w-8 rounded-r-lg rounded-l-none border-l-0 bg-slate-100 hover:bg-slate-200 dark:bg-slate-800 dark:hover:bg-slate-700",title:"Expand sidebar",style:{left:0},children:a.jsx(vs,{className:"h-4 w-4"})}),a.jsxs("div",{className:`
|
|
6
|
-
${o?"w-0 -ml-4 opacity-0":"w-80 opacity-100"}
|
|
7
|
-
transition-all duration-300 ease-in-out
|
|
8
|
-
h-full min-h-0
|
|
9
|
-
bg-white dark:bg-slate-950
|
|
10
|
-
border-r border-slate-200 dark:border-slate-800
|
|
11
|
-
flex flex-col
|
|
12
|
-
overflow-hidden
|
|
13
|
-
`,children:[a.jsxs("div",{className:"flex items-center justify-between p-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:a.jsx(qn,{className:"h-5 w-5 text-[#1d9bf0]"})}),a.jsxs("div",{children:[a.jsx("h2",{className:"text-base font-bold text-slate-900 dark:text-slate-100",children:"AutoGLM"}),a.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[t.length," ",(t.length===1,c.deviceSidebar.devices)]})]})]}),a.jsx(ie,{variant:"ghost",size:"icon",onClick:d,className:"h-8 w-8 rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300",title:"Collapse sidebar",children:a.jsx(gs,{className:"h-4 w-4"})})]}),a.jsx(en,{className:"mx-4"}),a.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-2 min-h-0",children:t.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800",children:a.jsx(As,{className:"h-8 w-8 text-slate-400"})}),a.jsx("p",{className:"mt-4 font-medium text-slate-900 dark:text-slate-100",children:c.deviceSidebar.noDevicesConnected}),a.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:c.deviceSidebar.clickToRefresh})]}):t.map(f=>a.jsx(Js,{id:f.id,model:f.model,status:f.status,connectionType:f.connection_type,isInitialized:f.is_initialized,isActive:e===f.id,onClick:()=>n(f.id),onConnectWifi:async()=>{await i(f.id)},onDisconnectWifi:async()=>{await s(f.id)}},f.id))}),a.jsx(en,{className:"mx-4"}),a.jsx("div",{className:"p-3",children:a.jsxs(ie,{variant:"outline",onClick:r,className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[a.jsx(Wn,{className:"h-4 w-4"}),c.deviceSidebar.settings]})})]})]})}const ge=Object.create(null);ge.open="0";ge.close="1";ge.ping="2";ge.pong="3";ge.message="4";ge.upgrade="5";ge.noop="6";const Ze=Object.create(null);Object.keys(ge).forEach(t=>{Ze[ge[t]]=t});const Bt={type:"error",data:"parser error"},Xn=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Vn=typeof ArrayBuffer=="function",zn=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,Xt=({type:t,data:e},n,r)=>Xn&&e instanceof Blob?n?r(e):cn(e,r):Vn&&(e instanceof ArrayBuffer||zn(e))?n?r(e):cn(new Blob([e]),r):r(ge[t]+(e||"")),cn=(t,e)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];e("b"+(r||""))},n.readAsDataURL(t)};function ln(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let gt;function ei(t,e){if(Xn&&t.data instanceof Blob)return t.data.arrayBuffer().then(ln).then(e);if(Vn&&(t.data instanceof ArrayBuffer||zn(t.data)))return e(ln(t.data));Xt(t,!1,n=>{gt||(gt=new TextEncoder),e(gt.encode(n))})}const un="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Me=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<un.length;t++)Me[un.charCodeAt(t)]=t;const ti=t=>{let e=t.length*.75,n=t.length,r,i=0,s,c,o,u;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const d=new ArrayBuffer(e),f=new Uint8Array(d);for(r=0;r<n;r+=4)s=Me[t.charCodeAt(r)],c=Me[t.charCodeAt(r+1)],o=Me[t.charCodeAt(r+2)],u=Me[t.charCodeAt(r+3)],f[i++]=s<<2|c>>4,f[i++]=(c&15)<<4|o>>2,f[i++]=(o&3)<<6|u&63;return d},ni=typeof ArrayBuffer=="function",Vt=(t,e)=>{if(typeof t!="string")return{type:"message",data:$n(t,e)};const n=t.charAt(0);return n==="b"?{type:"message",data:ri(t.substring(1),e)}:Ze[n]?t.length>1?{type:Ze[n],data:t.substring(1)}:{type:Ze[n]}:Bt},ri=(t,e)=>{if(ni){const n=ti(t);return $n(n,e)}else return{base64:!0,data:t}},$n=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},Yn="",si=(t,e)=>{const n=t.length,r=new Array(n);let i=0;t.forEach((s,c)=>{Xt(s,!1,o=>{r[c]=o,++i===n&&e(r.join(Yn))})})},ii=(t,e)=>{const n=t.split(Yn),r=[];for(let i=0;i<n.length;i++){const s=Vt(n[i],e);if(r.push(s),s.type==="error")break}return r};function oi(){return new TransformStream({transform(t,e){ei(t,n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const s=new DataView(i.buffer);s.setUint8(0,126),s.setUint16(1,r)}else{i=new Uint8Array(9);const s=new DataView(i.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(n)})}})}let xt;function He(t){return t.reduce((e,n)=>e+n.length,0)}function Xe(t,e){if(t[0].length===e)return t.shift();const n=new Uint8Array(e);let r=0;for(let i=0;i<e;i++)n[i]=t[0][r++],r===t[0].length&&(t.shift(),r=0);return t.length&&r<t[0].length&&(t[0]=t[0].slice(r)),n}function ai(t,e){xt||(xt=new TextDecoder);const n=[];let r=0,i=-1,s=!1;return new TransformStream({transform(c,o){for(n.push(c);;){if(r===0){if(He(n)<1)break;const u=Xe(n,1);s=(u[0]&128)===128,i=u[0]&127,i<126?r=3:i===126?r=1:r=2}else if(r===1){if(He(n)<2)break;const u=Xe(n,2);i=new DataView(u.buffer,u.byteOffset,u.length).getUint16(0),r=3}else if(r===2){if(He(n)<8)break;const u=Xe(n,8),d=new DataView(u.buffer,u.byteOffset,u.length),f=d.getUint32(0);if(f>Math.pow(2,21)-1){o.enqueue(Bt);break}i=f*Math.pow(2,32)+d.getUint32(4),r=3}else{if(He(n)<i)break;const u=Xe(n,i);o.enqueue(Vt(s?u:xt.decode(u),e)),r=0}if(i===0||i>t){o.enqueue(Bt);break}}}})}const Kn=4;function ee(t){if(t)return ci(t)}function ci(t){for(var e in ee.prototype)t[e]=ee.prototype[e];return t}ee.prototype.on=ee.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};ee.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this};ee.prototype.off=ee.prototype.removeListener=ee.prototype.removeAllListeners=ee.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===e||r.fn===e){n.splice(i,1);break}return n.length===0&&delete this._callbacks["$"+t],this};ee.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,e)}return this};ee.prototype.emitReserved=ee.prototype.emit;ee.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};ee.prototype.hasListeners=function(t){return!!this.listeners(t).length};const ut=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,n)=>n(e,0),de=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),li="arraybuffer";function Jn(t,...e){return e.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const ui=de.setTimeout,di=de.clearTimeout;function dt(t,e){e.useNativeTimers?(t.setTimeoutFn=ui.bind(de),t.clearTimeoutFn=di.bind(de)):(t.setTimeoutFn=de.setTimeout.bind(de),t.clearTimeoutFn=de.clearTimeout.bind(de))}const fi=1.33;function hi(t){return typeof t=="string"?pi(t):Math.ceil((t.byteLength||t.size)*fi)}function pi(t){let e=0,n=0;for(let r=0,i=t.length;r<i;r++)e=t.charCodeAt(r),e<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(r++,n+=4);return n}function Qn(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function mi(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function _i(t){let e={},n=t.split("&");for(let r=0,i=n.length;r<i;r++){let s=n[r].split("=");e[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return e}class gi extends Error{constructor(e,n,r){super(e),this.description=n,this.context=r,this.type="TransportError"}}class zt extends ee{constructor(e){super(),this.writable=!1,dt(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,n,r){return super.emitReserved("error",new gi(e,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const n=Vt(e,this.socket.binaryType);this.onPacket(n)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,n={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const n=mi(e);return n.length?"?"+n:""}}class xi extends zt{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const n=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};ii(e,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,si(e,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=Qn()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(e,n)}}let Zn=!1;try{Zn=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const vi=Zn;function bi(){}class yi extends xi{constructor(e){if(super(e),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||r!==e.port}}doWrite(e,n){const r=this.request({method:"POST",data:e});r.on("success",n),r.on("error",(i,s)=>{this.onError("xhr post error",i,s)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=e}}class _e extends ee{constructor(e,n,r){super(),this.createRequest=e,dt(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var e;const n=Jn(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&r.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var i;r.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=_e.requestsCount++,_e.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=bi,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete _e.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}_e.requestsCount=0;_e.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",dn);else if(typeof addEventListener=="function"){const t="onpagehide"in de?"pagehide":"unload";addEventListener(t,dn,!1)}}function dn(){for(let t in _e.requests)_e.requests.hasOwnProperty(t)&&_e.requests[t].abort()}const wi=(function(){const t=er({xdomain:!1});return t&&t.responseType!==null})();class Ei extends yi{constructor(e){super(e);const n=e&&e.forceBase64;this.supportsBinary=wi&&!n}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new _e(er,this.uri(),e)}}function er(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||vi))return new XMLHttpRequest}catch{}if(!e)try{return new de[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const tr=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Ti extends zt{get name(){return"websocket"}doOpen(){const e=this.uri(),n=this.opts.protocols,r=tr?{}:Jn(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,n,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],i=n===e.length-1;Xt(r,this.supportsBinary,s=>{try{this.doWrite(r,s)}catch{}i&&ut(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=Qn()),this.supportsBinary||(n.b64=1),this.createUri(e,n)}}const vt=de.WebSocket||de.MozWebSocket;class Ci extends Ti{createSocket(e,n,r){return tr?new vt(e,n,r):n?new vt(e,n):new vt(e)}doWrite(e,n){this.ws.send(n)}}class Si extends zt{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const n=ai(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(n).getReader(),i=oi();i.readable.pipeTo(e.writable),this._writer=i.writable.getWriter();const s=()=>{r.read().then(({done:o,value:u})=>{o||(this.onPacket(u),s())}).catch(o=>{})};s();const c={type:"open"};this.query.sid&&(c.data=`{"sid":"${this.query.sid}"}`),this._writer.write(c).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],i=n===e.length-1;this._writer.write(r).then(()=>{i&&ut(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const Ni={websocket:Ci,webtransport:Si,polling:Ei},ki=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Ri=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function It(t){if(t.length>8e3)throw"URI too long";const e=t,n=t.indexOf("["),r=t.indexOf("]");n!=-1&&r!=-1&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));let i=ki.exec(t||""),s={},c=14;for(;c--;)s[Ri[c]]=i[c]||"";return n!=-1&&r!=-1&&(s.source=e,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=Pi(s,s.path),s.queryKey=Ai(s,s.query),s}function Pi(t,e){const n=/\/{2,9}/g,r=e.replace(n,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Ai(t,e){const n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,s){i&&(n[i]=s)}),n}const Mt=typeof addEventListener=="function"&&typeof removeEventListener=="function",et=[];Mt&&addEventListener("offline",()=>{et.forEach(t=>t())},!1);class Te extends ee{constructor(e,n){if(super(),this.binaryType=li,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(n=e,e=null),e){const r=It(e);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=It(n.host).host);dt(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const i=r.prototype.name;this.transports.push(i),this._transportsByName[i]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=_i(this.opts.query)),Mt&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},et.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const n=Object.assign({},this.opts.query);n.EIO=Kn,n.transport=e,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&Te.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(e);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",Te.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=e.data,this._onError(n);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const i=this.writeBuffer[r].data;if(i&&(n+=hi(i)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,ut(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,n,r){return this._sendPacket("message",e,n,r),this}send(e,n,r){return this._sendPacket("message",e,n,r),this}_sendPacket(e,n,r,i){if(typeof n=="function"&&(i=n,n=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const s={type:e,data:n,options:r};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),e()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}_onError(e){if(Te.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Mt&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=et.indexOf(this._offlineEventListener);r!==-1&&et.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,n),this.writeBuffer=[],this._prevBufferLen=0}}}Te.protocol=Kn;class Di extends Te{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let n=this.createTransport(e),r=!1;Te.priorWebsocketSuccess=!1;const i=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",h=>{if(!r)if(h.type==="pong"&&h.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Te.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(f(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const _=new Error("probe error");_.transport=n.name,this.emitReserved("upgradeError",_)}}))};function s(){r||(r=!0,f(),n.close(),n=null)}const c=h=>{const _=new Error("probe error: "+h);_.transport=n.name,s(),this.emitReserved("upgradeError",_)};function o(){c("transport closed")}function u(){c("socket closed")}function d(h){n&&h.name!==n.name&&s()}const f=()=>{n.removeListener("open",i),n.removeListener("error",c),n.removeListener("close",o),this.off("close",u),this.off("upgrading",d)};n.once("open",i),n.once("error",c),n.once("close",o),this.once("close",u),this.once("upgrading",d),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const n=[];for(let r=0;r<e.length;r++)~this.transports.indexOf(e[r])&&n.push(e[r]);return n}}let Li=class extends Di{constructor(e,n={}){const r=typeof e=="object"?e:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(i=>Ni[i]).filter(i=>!!i)),super(e,r)}};function ji(t,e="",n){let r=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),r=It(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const s=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+s+":"+r.port+e,r.href=r.protocol+"://"+s+(n&&n.port===r.port?"":":"+r.port),r}const Oi=typeof ArrayBuffer=="function",Bi=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,nr=Object.prototype.toString,Ii=typeof Blob=="function"||typeof Blob<"u"&&nr.call(Blob)==="[object BlobConstructor]",Mi=typeof File=="function"||typeof File<"u"&&nr.call(File)==="[object FileConstructor]";function $t(t){return Oi&&(t instanceof ArrayBuffer||Bi(t))||Ii&&t instanceof Blob||Mi&&t instanceof File}function tt(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(tt(t[n]))return!0;return!1}if($t(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return tt(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&tt(t[n]))return!0;return!1}function Fi(t){const e=[],n=t.data,r=t;return r.data=Ft(n,e),r.attachments=e.length,{packet:r,buffers:e}}function Ft(t,e){if(!t)return t;if($t(t)){const n={_placeholder:!0,num:e.length};return e.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let r=0;r<t.length;r++)n[r]=Ft(t[r],e);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=Ft(t[r],e));return n}return t}function Ui(t,e){return t.data=Ut(t.data,e),delete t.attachments,t}function Ut(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=Ut(t[n],e);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=Ut(t[n],e));return t}const Gi=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Wi=5;var F;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(F||(F={}));class qi{constructor(e){this.replacer=e}encode(e){return(e.type===F.EVENT||e.type===F.ACK)&&tt(e)?this.encodeAsBinary({type:e.type===F.EVENT?F.BINARY_EVENT:F.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let n=""+e.type;return(e.type===F.BINARY_EVENT||e.type===F.BINARY_ACK)&&(n+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(n+=e.nsp+","),e.id!=null&&(n+=e.id),e.data!=null&&(n+=JSON.stringify(e.data,this.replacer)),n}encodeAsBinary(e){const n=Fi(e),r=this.encodeAsString(n.packet),i=n.buffers;return i.unshift(r),i}}function fn(t){return Object.prototype.toString.call(t)==="[object Object]"}class Yt extends ee{constructor(e){super(),this.reviver=e}add(e){let n;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(e);const r=n.type===F.BINARY_EVENT;r||n.type===F.BINARY_ACK?(n.type=r?F.EVENT:F.ACK,this.reconstructor=new Hi(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if($t(e)||e.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(e),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let n=0;const r={type:Number(e.charAt(0))};if(F[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===F.BINARY_EVENT||r.type===F.BINARY_ACK){const s=n+1;for(;e.charAt(++n)!=="-"&&n!=e.length;);const c=e.substring(s,n);if(c!=Number(c)||e.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(c)}if(e.charAt(n+1)==="/"){const s=n+1;for(;++n&&!(e.charAt(n)===","||n===e.length););r.nsp=e.substring(s,n)}else r.nsp="/";const i=e.charAt(n+1);if(i!==""&&Number(i)==i){const s=n+1;for(;++n;){const c=e.charAt(n);if(c==null||Number(c)!=c){--n;break}if(n===e.length)break}r.id=Number(e.substring(s,n+1))}if(e.charAt(++n)){const s=this.tryParse(e.substr(n));if(Yt.isPayloadValid(r.type,s))r.data=s;else throw new Error("invalid payload")}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,n){switch(e){case F.CONNECT:return fn(n);case F.DISCONNECT:return n===void 0;case F.CONNECT_ERROR:return typeof n=="string"||fn(n);case F.EVENT:case F.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&Gi.indexOf(n[0])===-1);case F.ACK:case F.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Hi{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const n=Ui(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Xi=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Yt,Encoder:qi,get PacketType(){return F},protocol:Wi},Symbol.toStringTag,{value:"Module"}));function fe(t,e,n){return t.on(e,n),function(){t.off(e,n)}}const Vi=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class rr extends ee{constructor(e,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[fe(e,"open",this.onopen.bind(this)),fe(e,"packet",this.onpacket.bind(this)),fe(e,"error",this.onerror.bind(this)),fe(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...n){var r,i,s;if(Vi.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const c={type:F.EVENT,data:n};if(c.options={},c.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const f=this.ids++,h=n.pop();this._registerAckCallback(f,h),c.id=f}const o=(i=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||i===void 0?void 0:i.writable,u=this.connected&&!(!((s=this.io.engine)===null||s===void 0)&&s._hasPingExpired());return this.flags.volatile&&!o||(u?(this.notifyOutgoingListeners(c),this.packet(c)):this.sendBuffer.push(c)),this.flags={},this}_registerAckCallback(e,n){var r;const i=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(i===void 0){this.acks[e]=n;return}const s=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&this.sendBuffer.splice(o,1);n.call(this,new Error("operation has timed out"))},i),c=(...o)=>{this.io.clearTimeoutFn(s),n.apply(this,o)};c.withError=!0,this.acks[e]=c}emitWithAck(e,...n){return new Promise((r,i)=>{const s=(c,o)=>c?i(c):r(o);s.withError=!0,n.push(s),this.emit(e,...n)})}_addToQueue(e){let n;typeof e[e.length-1]=="function"&&(n=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...s)=>r!==this._queue[0]?void 0:(i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...s)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!e||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:F.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(r=>String(r.id)===e)){const r=this.acks[e];delete this.acks[e],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case F.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case F.EVENT:case F.BINARY_EVENT:this.onevent(e);break;case F.ACK:case F.BINARY_ACK:this.onack(e);break;case F.DISCONNECT:this.ondisconnect();break;case F.CONNECT_ERROR:this.destroy();const r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){const n=e.data||[];e.id!=null&&n.push(this.ack(e.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const n=this;let r=!1;return function(...i){r||(r=!0,n.packet({type:F.ACK,id:e,data:i}))}}onack(e){const n=this.acks[e.id];typeof n=="function"&&(delete this.acks[e.id],n.withError&&e.data.unshift(null),n.apply(this,e.data))}onconnect(e,n){this.id=e,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:F.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,e.data)}}}function Oe(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Oe.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-n:t+n}return Math.min(t,this.max)|0};Oe.prototype.reset=function(){this.attempts=0};Oe.prototype.setMin=function(t){this.ms=t};Oe.prototype.setMax=function(t){this.max=t};Oe.prototype.setJitter=function(t){this.jitter=t};class Gt extends ee{constructor(e,n){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(n=e,e=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,dt(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Oe({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=e;const i=n.parser||Xi;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var n;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(n=this.backoff)===null||n===void 0||n.setMin(e),this)}randomizationFactor(e){var n;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(n=this.backoff)===null||n===void 0||n.setJitter(e),this)}reconnectionDelayMax(e){var n;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(n=this.backoff)===null||n===void 0||n.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Li(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=fe(n,"open",function(){r.onopen(),e&&e()}),s=o=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",o),e?e(o):this.maybeReconnectOnOpen()},c=fe(n,"error",s);if(this._timeout!==!1){const o=this._timeout,u=this.setTimeoutFn(()=>{i(),s(new Error("timeout")),n.close()},o);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(i),this.subs.push(c),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(fe(e,"ping",this.onping.bind(this)),fe(e,"data",this.ondata.bind(this)),fe(e,"error",this.onerror.bind(this)),fe(e,"close",this.onclose.bind(this)),fe(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(n){this.onclose("parse error",n)}}ondecoded(e){ut(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,n){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new rr(this,e,n),this.nsps[e]=r),r}_destroy(e){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(e){const n=this.encoder.encode(e);for(let r=0;r<n.length;r++)this.engine.write(n[r],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Be={};function nt(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const n=ji(t,e.path||"/socket.io"),r=n.source,i=n.id,s=n.path,c=Be[i]&&s in Be[i].nsps,o=e.forceNew||e["force new connection"]||e.multiplex===!1||c;let u;return o?u=new Gt(r,e):(Be[i]||(Be[i]=new Gt(r,e)),u=Be[i]),n.query&&!e.query&&(e.query=n.queryKey),u.socket(n.path,e)}Object.assign(nt,{Manager:Gt,Socket:rr,io:nt,connect:nt});function zi(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}const rt={H264:1748121140,H265:1748121141,AV1:6387249},{WritableStream:$i}=globalThis;class Yi{#e;#t;#n=0;#r=7;get byteAligned(){return this.#r===7}get ended(){return this.#n>=this.#e.length}constructor(e){this.#e=e,this.#t=e[0]}f1(){const e=this.#t>>this.#r;return this.#r-=1,this.#r<0&&(this.#n+=1,this.#r=7,this.#t=this.#e[this.#n]),e&1}f(e){let n=0;for(;e>0;e-=1)n<<=1,n|=this.f1();return n}skip(e){if(e<=this.#r+1){this.#n+=1,this.#r=7,this.#t=this.#e[this.#n];return}e-=this.#r+1,this.#n+=1;const n=e/8|0;n>0&&(this.#n+=n,e-=n*8),this.#r=7-e,this.#t=this.#e[this.#n]}readBytes(e){if(!this.byteAligned)throw new Error("Bytes must be byte-aligned");const n=this.#e.subarray(this.#n,this.#n+e);return this.#n+=e,this.#t=this.#e[this.#n],n}getPosition(){return[this.#n,this.#r]}setPosition([e,n]){this.#n=e,this.#r=n,this.#t=this.#e[e]}}const Ki={SequenceHeader:1,TemporalDelimiter:2,FrameHeader:3,TileGroup:4,Metadata:5,Frame:6,RedundantFrameHeader:7,TileList:8,Padding:15},Ji={Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,GenericFilm:8,Bt2020:9,Xyz:10,Smpte431:11,Smpte432:12,Ebu3213:22},Qi={Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,Linear:8,Log100:9,Log100Sqrt10:10,Iec61966:11,Bt1361:12,Srgb:13,Bt2020Ten:14,Bt2020Twelve:15,Smpte2084:16,Smpte428:17,Hlg:18},Zi={Identity:0,Bt709:1,Unspecified:2,Fcc:4,Bt470BG:5,Bt601:6,Smpte240:7,YCgCo:8,Bt2020Ncl:9,Bt2020Cl:10,Smpte2085:11,ChromatNcl:12,ChromatCl:13,ICtCp:14};class re extends Yi{static ObuType=Ki;static ColorPrimaries=Ji;static TransferCharacteristics=Qi;static MatrixCoefficients=Zi;#e=0;uvlc(){let e=0;for(;!this.f1();)e+=1;return e>=32?2**32-1:this.f(e)+(1<<e>>>0)-1}leb128(){if(!this.byteAligned)throw new Error("LEB128 must be byte-aligned");let e=0n;this.#e=0;for(let n=0n;n<8n;n+=1n){const r=this.f(8);if(e|=BigInt(r&127)<<7n*n,this.#e+=1,(r&128)==0)break}return e}*annexBBitstream(){for(;!this.ended;){const e=this.leb128();yield*this.temporalUnit(e)}}*temporalUnit(e){for(;e>0;){const n=this.leb128();e-=BigInt(this.#e),yield*this.frameUnit(n),e-=n}}*frameUnit(e){for(;e>0;){const n=this.leb128();e-=BigInt(this.#e);const r=this.openBitstreamUnit(n);r&&(yield r),e-=n}}#t=0;openBitstreamUnit(e){const n=this.obuHeader();let r;if(n.obu_has_size_field)r=this.leb128();else if(e!==void 0)r=e-1n-(n.obu_extension_flag?1n:0n);else throw new Error("obu_has_size_field must be true");const i=this.getPosition();if(n.obu_type!==re.ObuType.SequenceHeader&&n.obu_type!==re.ObuType.TemporalDelimiter&&this.#t!==0&&n.obu_extension_header){const u=!!(this.#t&1<<n.obu_extension_header.temporal_id),d=!!(this.#t&1<<n.obu_extension_header.spatial_id+8);if(!u||!d){this.skip(Number(r));return}}let s;switch(n.obu_type){case re.ObuType.SequenceHeader:s=this.sequenceHeaderObu();break}const c=this.getPosition(),o=(c[0]-i[0])*8+(i[1]-c[1]);return r>0&&this.skip(Number(r)*8-o),{obu_header:n,obu_size:r,sequence_header_obu:s}}obuHeader(){if(!!this.f1())throw new Error("Invalid data");const n=this.f(4),r=!!this.f1(),i=!!this.f1();this.f1();let s;return r&&(s=this.obuExtensionHeader()),{obu_type:n,obu_extension_flag:r,obu_has_size_field:i,obu_extension_header:s}}obuExtensionHeader(){const e=this.f(3),n=this.f(2);return this.skip(3),{temporal_id:e,spatial_id:n}}static SelectScreenContentTools=2;static SelectIntegerMv=2;sequenceHeaderObu(){const e=this.f(3),n=!!this.f1(),r=!!this.f1();let i=!1,s,c=!1,o,u=!1,d=0;const f=[],h=[],_=[],m=[],x=[];let p,v;if(r)f[0]=0,h[0]=this.f(5),_[0]=0,m[0]=!1,x[0]=!1;else{i=!!this.f1(),i&&(s=this.timingInfo(),c=!!this.f1(),c&&(o=this.decoderModelInfo(),p=[])),u=!!this.f1(),u&&(v=[]),d=this.f(5);for(let j=0;j<=d;j+=1)f[j]=this.f(12),h[j]=this.f(5),h[j]>7?_[j]=this.f1():_[j]=0,c?(m[j]=!!this.f1(),m[j]&&(p[j]=this.operatingParametersInfo(o))):m[j]=!1,u&&(x[j]=!!this.f1(),x[j]&&(v[j]=this.f(4)))}const E=this.chooseOperatingPoint();this.#t=f[E];const S=this.f(4),g=this.f(4),b=this.f(S+1),C=this.f(g+1);let N=!1,y,L;r||(N=!!this.f1(),N&&(y=this.f(4),L=this.f(3)));const w=!!this.f1(),A=!!this.f1(),T=!!this.f1();let G=!1,z=!1,k=!1,D=!1,P=!1,I=!1,M=!1,W=!1,X=re.SelectScreenContentTools,q=!1,K=re.SelectIntegerMv,J;r||(G=!!this.f1(),z=!!this.f1(),k=!!this.f1(),D=!!this.f1(),P=!!this.f1(),P&&(I=!!this.f1(),M=!!this.f1()),W=!!this.f1(),W||(X=this.f1()),X>0&&(q=!!this.f1(),q||(K=this.f1())),P&&(J=this.f(3)));const Q=!!this.f1(),se=!!this.f1(),xe=!!this.f1(),ce=this.colorConfig(e),oe=!!this.f1();return{seq_profile:e,still_picture:n,reduced_still_picture_header:r,timing_info_present_flag:i,timing_info:s,decoder_model_info_present_flag:c,decoder_model_info:o,initial_display_delay_present_flag:u,initial_display_delay_minus_1:v,operating_points_cnt_minus_1:d,operating_point_idc:f,seq_level_idx:h,seq_tier:_,decoder_model_present_for_this_op:m,operating_parameters_info:p,initial_display_delay_present_for_this_op:x,frame_width_bits_minus_1:S,frame_height_bits_minus_1:g,max_frame_width_minus_1:b,max_frame_height_minus_1:C,frame_id_numbers_present_flag:N,delta_frame_id_length_minus_2:y,additional_frame_id_length_minus_1:L,use_128x128_superblock:w,enable_filter_intra:A,enable_intra_edge_filter:T,enable_interintra_compound:G,enable_masked_compound:z,enable_warped_motion:k,enable_dual_filter:D,enable_order_hint:P,enable_jnt_comp:I,enable_ref_frame_mvs:M,seq_choose_screen_content_tools:W,seq_force_screen_content_tools:X,seq_choose_integer_mv:q,seq_force_integer_mv:K,order_hint_bits_minus_1:J,enable_superres:Q,enable_cdef:se,enable_restoration:xe,color_config:ce,film_grain_params_present:oe}}searchSequenceHeaderObu(){for(;!this.ended;){const e=this.openBitstreamUnit();if(e&&e.sequence_header_obu)return e.sequence_header_obu}}timingInfo(){const e=this.f(32),n=this.f(32),r=!!this.f1();let i;return r&&(i=this.uvlc()),{num_units_in_display_tick:e,time_scale:n,equal_picture_interval:r,num_ticks_per_picture_minus_1:i}}decoderModelInfo(){const e=this.f(5),n=this.f(32),r=this.f(5),i=this.f(5);return{buffer_delay_length_minus_1:e,num_units_in_decoding_tick:n,buffer_removal_time_length_minus_1:r,frame_presentation_time_length_minus_1:i}}operatingParametersInfo(e){const n=e.buffer_delay_length_minus_1+1,r=this.f(n),i=this.f(n),s=!!this.f1();return{decoder_buffer_delay:r,encoder_buffer_delay:i,low_delay_mode_flag:s}}chooseOperatingPoint(){return 0}colorConfig(e){const n=!!this.f1();let r=!1,i=8;e===2&&n?(r=!!this.f1(),i=r?12:10):e<=2&&(i=n?10:8);let s=!1;e===1&&(s=!!this.f1());const c=!!this.f1();let o=re.ColorPrimaries.Unspecified,u=re.TransferCharacteristics.Unspecified,d=re.MatrixCoefficients.Unspecified;c&&(o=this.f(8),u=this.f(8),d=this.f(8));let f=!1,h,_,m=0,x=!1;if(s)f=!!this.f1(),h=!0,_=!0;else{if(o===re.ColorPrimaries.Bt709&&u===re.TransferCharacteristics.Srgb&&d===re.MatrixCoefficients.Identity)f=!0,h=!1,_=!1;else{switch(f=!!this.f1(),e){case 0:h=!0,_=!0;break;case 1:h=!1,_=!1;break;default:i==12?(h=!!this.f1(),h?_=!!this.f1():_=!1):(h=!0,_=!1);break}h&&_&&(m=this.f(2))}x=!!this.f1()}return{high_bitdepth:n,twelve_bit:r,BitDepth:i,mono_chrome:s,color_description_present_flag:c,color_primaries:o,transfer_characteristics:u,matrix_coefficients:d,color_range:f,subsampling_x:h,subsampling_y:_,chroma_sample_position:m,separate_uv_delta_q:x}}}function*sr(t){let e=-1,n=0,r=!1;for(let i=0;i<t.length;i+=1){const s=t[i];if(r){if(s>3)throw new Error("Invalid data");r=!1;continue}if(s===0){n+=1;continue}const c=n;if(n=0,e===-1){if(c>=2&&s===1){e=i+1;continue}throw new Error("Invalid data")}if(!(c<2)){if(s===1){yield t.subarray(e,i-c),e=i+1;continue}if(c>2)throw new Error("Invalid data");switch(s){case 2:throw new Error("Invalid data");case 3:r=!0;break}}}if(r)throw new Error("Invalid data");yield t.subarray(e,t.length)}class ft{#e;#t;#n;#r=0;#i=0;#s=7;#o=0;get byteLength(){return this.#t}get stopBitIndex(){return this.#n}get bytePosition(){return this.#i}get bitPosition(){return this.#s}get ended(){return this.#i>=this.#t&&this.#s<=this.#n}constructor(e){this.#e=e;for(let n=e.length-1;n>=0;n-=1){if(this.#e[n]===0)continue;const r=e[n];for(let i=0;i<8;i+=1)if((r>>i&1)===1){this.#t=n,this.#n=i,this.#c();return}}throw new Error("Stop bit not found")}#c(){if(this.#o=this.#e[this.#i],this.#r===2&&this.#o===3){this.#r=0,this.#i+=1,this.#c();return}this.#o===0?this.#r+=1:this.#r=0}next(){if(this.ended)throw new Error("Bit index out of bounds");const e=this.#o>>this.#s&1;return this.#s-=1,this.#s<0&&(this.#i+=1,this.#s=7,this.#c()),e}read(e){if(e>32)throw new Error("Read length too large");let n=0;for(let r=0;r<e;r+=1)n=n<<1|this.next();return n}#l(){if(this.#i>=this.#t&&this.#s<this.#n)throw new Error("Bit index out of bounds")}skip(e){if(e<=this.#s+1){this.#s-=e,this.#l();return}for(e-=this.#s+1,this.#i+=1,this.#s=7,this.#c(),this.#l();e>=8;e-=8)this.#i+=1,this.#c(),this.#l();this.#s=7-e,this.#l()}decodeExponentialGolombNumber(){let e=0;for(;this.next()===0;)e+=1;return e===0?0:(1<<e|this.read(e))-1}#d(){return{zeroCount:this.#r,bytePosition:this.#i,bitPosition:this.#s,byte:this.#o}}#a(e){this.#r=e.zeroCount,this.#i=e.bytePosition,this.#s=e.bitPosition,this.#o=e.byte}peek(e){const n=this.#d(),r=this.read(e);return this.#a(n),r}readBytes(e){const n=new Uint8Array(e);for(let r=0;r<e;r+=1)n[r]=this.read(8);return n}peekBytes(e){const n=this.#d(),r=this.readBytes(e);return this.#a(n),r}}function eo(t){const e=new ft(t);if(e.next()!==0)throw new Error("Invalid data");const n=e.read(2);if(e.read(5)!==7)throw new Error("Invalid data");if(n===0)throw new Error("Invalid data");const i=e.read(8),s=e.peek(8),c=!!e.next(),o=!!e.next(),u=!!e.next(),d=!!e.next(),f=!!e.next(),h=!!e.next();if(e.read(2)!==0)throw new Error("Invalid data");const _=e.read(8),m=e.decodeExponentialGolombNumber();if(i===100||i===110||i===122||i===244||i===44||i===83||i===86||i===118||i===128||i===138||i===139||i===134){const y=e.decodeExponentialGolombNumber();if(y===3&&e.next(),e.decodeExponentialGolombNumber(),e.decodeExponentialGolombNumber(),e.next(),!!e.next())for(let w=0;w<(y!==3?8:12);w+=1)e.next()}e.decodeExponentialGolombNumber();const x=e.decodeExponentialGolombNumber();if(x===0)e.decodeExponentialGolombNumber();else if(x===1){e.next(),e.decodeExponentialGolombNumber(),e.decodeExponentialGolombNumber();const y=e.decodeExponentialGolombNumber();for(let L=0;L<y;L+=1)e.decodeExponentialGolombNumber()}e.decodeExponentialGolombNumber(),e.next();const p=e.decodeExponentialGolombNumber(),v=e.decodeExponentialGolombNumber(),E=e.next();E||e.next(),e.next();const S=!!e.next();let g,b,C,N;return S?(g=e.decodeExponentialGolombNumber(),b=e.decodeExponentialGolombNumber(),C=e.decodeExponentialGolombNumber(),N=e.decodeExponentialGolombNumber()):(g=0,b=0,C=0,N=0),e.next(),{profile_idc:i,constraint_set:s,constraint_set0_flag:c,constraint_set1_flag:o,constraint_set2_flag:u,constraint_set3_flag:d,constraint_set4_flag:f,constraint_set5_flag:h,level_idc:_,seq_parameter_set_id:m,pic_width_in_mbs_minus1:p,pic_height_in_map_units_minus1:v,frame_mbs_only_flag:E,frame_cropping_flag:S,frame_crop_left_offset:g,frame_crop_right_offset:b,frame_crop_top_offset:C,frame_crop_bottom_offset:N}}function to(t){let e,n;for(const r of sr(t))switch(r[0]&31){case 7:if(e=r,n)return{sequenceParameterSet:e,pictureParameterSet:n};break;case 8:if(n=r,e)return{sequenceParameterSet:e,pictureParameterSet:n};break}throw new Error("Invalid data")}function no(t){const{sequenceParameterSet:e,pictureParameterSet:n}=to(t),{profile_idc:r,constraint_set:i,level_idc:s,pic_width_in_mbs_minus1:c,pic_height_in_map_units_minus1:o,frame_mbs_only_flag:u,frame_crop_left_offset:d,frame_crop_right_offset:f,frame_crop_top_offset:h,frame_crop_bottom_offset:_}=eo(e),m=(c+1)*16,x=(o+1)*(2-u)*16,p=d*2,v=f*2,E=h*2,S=_*2,g=m-p-v,b=x-E-S;return{pictureParameterSet:n,sequenceParameterSet:e,profileIndex:r,constraintSet:i,levelIndex:s,encodedWidth:m,encodedHeight:x,cropLeft:p,cropRight:v,cropTop:E,cropBottom:S,croppedWidth:g,croppedHeight:b}}function ro(t){switch(t){case 0:case 3:return 1;case 1:case 2:return 2;default:throw new Error("Invalid chroma_format_idc")}}function so(t){switch(t){case 0:case 2:case 3:return 1;case 1:return 2;default:throw new Error("Invalid chroma_format_idc")}}function io(t){const e=new ft(t);if(e.next()!==0)throw new Error("Invalid NALU header");const n=e.read(6),r=e.read(6),i=e.read(3);return{nal_unit_type:n,nuh_layer_id:r,nuh_temporal_id_plus1:i}}function oo(t){const e=new ft(t),n=e.read(4),r=!!e.next(),i=!!e.next(),s=e.read(6),c=e.read(3),o=!!e.next();e.skip(16);const u=ir(e,!0,c),d=!!e.next(),f=[],h=[],_=[];for(let A=d?0:c;A<=c;A+=1)f[A]=e.decodeExponentialGolombNumber(),h[A]=e.decodeExponentialGolombNumber(),_[A]=e.decodeExponentialGolombNumber();const m=e.read(6),x=e.decodeExponentialGolombNumber(),p=[];for(let A=1;A<=x;A+=1){p[A]=[];for(let T=0;T<=m;T+=1)p[A][T]=!!e.next()}const v=!!e.next();let E,S,g,b,C,N,y,L;if(v){E=e.read(32),S=e.read(32),g=!!e.next(),g&&(b=e.decodeExponentialGolombNumber()),C=e.decodeExponentialGolombNumber(),N=[],y=[!0],L=[];for(let A=0;A<C;A+=1)N[A]=e.decodeExponentialGolombNumber(),A>0&&(y[A]=!!e.next()),L[A]=or(e,y[A],c)}const w=!!e.next();return{vps_video_parameter_set_id:n,vps_base_layer_internal_flag:r,vps_base_layer_available_flag:i,vps_max_layers_minus1:s,vps_max_sub_layers_minus1:c,vps_temporal_id_nesting_flag:o,profileTierLevel:u,vps_sub_layer_ordering_info_present_flag:d,vps_max_dec_pic_buffering_minus1:f,vps_max_num_reorder_pics:h,vps_max_latency_increase_plus1:_,vps_max_layer_id:m,vps_num_layer_sets_minus1:x,layer_id_included_flag:p,vps_timing_info_present_flag:v,vps_num_units_in_tick:E,vps_time_scale:S,vps_poc_proportional_to_timing_flag:g,vps_num_ticks_poc_diff_one_minus1:b,vps_num_hrd_parameters:C,hrd_layer_set_idx:N,cprms_present_flag:y,hrdParameters:L,vps_extension_flag:w}}function ao(t){const e=new ft(t),n=e.read(4),r=e.read(3),i=!!e.next(),s=ir(e,!0,r),c=e.decodeExponentialGolombNumber(),o=e.decodeExponentialGolombNumber();let u;o===3&&(u=!!e.next());const d=e.decodeExponentialGolombNumber(),f=e.decodeExponentialGolombNumber(),h=!!e.next();let _,m,x,p;h&&(_=e.decodeExponentialGolombNumber(),m=e.decodeExponentialGolombNumber(),x=e.decodeExponentialGolombNumber(),p=e.decodeExponentialGolombNumber());const v=e.decodeExponentialGolombNumber(),E=e.decodeExponentialGolombNumber(),S=e.decodeExponentialGolombNumber(),g=[],b=[],C=[],N=!!e.next();for(let U=N?0:r;U<=r;U+=1)g[U]=e.decodeExponentialGolombNumber(),b[U]=e.decodeExponentialGolombNumber(),C[U]=e.decodeExponentialGolombNumber();const y=e.decodeExponentialGolombNumber(),L=e.decodeExponentialGolombNumber(),w=e.decodeExponentialGolombNumber(),A=e.decodeExponentialGolombNumber(),T=e.decodeExponentialGolombNumber(),G=e.decodeExponentialGolombNumber(),z=!!e.next();let k,D;z&&(k=!!e.next(),k&&(D=co(e)));const P=!!e.next(),I=!!e.next(),M=!!e.next();let W,X,q,K,J;M&&(W=e.read(4),X=e.read(4),q=e.read(4),K=e.read(4),J=!!e.next());const Q=e.decodeExponentialGolombNumber(),se=[];for(let U=0;U<Q;U+=1)se[U]=lo(e,U,Q,se);const xe=!!e.next();let ce,oe,j;if(xe){ce=e.decodeExponentialGolombNumber(),oe=[],j=[];for(let U=0;U<ce;U+=1)oe[U]=e.read(S+4),j[U]=!!e.next()}const Z=!!e.next(),ae=!!e.next(),le=!!e.next();let ve;le&&(ve=uo(e,r));const Re=!!e.next();let Se,R,O,B,H;if(Re&&(Se=!!e.next(),R=!!e.next(),O=!!e.next(),B=!!e.next(),H=e.read(4)),Se)throw new Error("Not implemented");let $;R&&($=ho(e));let V;if(O&&(V=po(e)),B)throw new Error("Not implemented");let Y;if(H){Y=[];let U=0;for(;!e.ended;)Y[U]=!!e.next(),U+=1}return{sps_video_parameter_set_id:n,sps_max_sub_layers_minus1:r,sps_temporal_id_nesting_flag:i,profileTierLevel:s,sps_seq_parameter_set_id:c,chroma_format_idc:o,separate_colour_plane_flag:u,pic_width_in_luma_samples:d,pic_height_in_luma_samples:f,conformance_window_flag:h,conf_win_left_offset:_,conf_win_right_offset:m,conf_win_top_offset:x,conf_win_bottom_offset:p,bit_depth_luma_minus8:v,bit_depth_chroma_minus8:E,log2_max_pic_order_cnt_lsb_minus4:S,sps_sub_layer_ordering_info_present_flag:N,sps_max_dec_pic_buffering_minus1:g,sps_max_num_reorder_pics:b,sps_max_latency_increase_plus1:C,log2_min_luma_coding_block_size_minus3:y,log2_diff_max_min_luma_coding_block_size:L,log2_min_luma_transform_block_size_minus2:w,log2_diff_max_min_luma_transform_block_size:A,max_transform_hierarchy_depth_inter:T,max_transform_hierarchy_depth_intra:G,scaling_list_enabled_flag:z,sps_scaling_list_data_present_flag:k,scalingListData:D,amp_enabled_flag:P,sample_adaptive_offset_enabled_flag:I,pcm_enabled_flag:M,pcm_sample_bit_depth_luma_minus1:W,pcm_sample_bit_depth_chroma_minus1:X,log2_min_pcm_luma_coding_block_size_minus3:q,log2_diff_max_min_pcm_luma_coding_block_size:K,pcm_loop_filter_disabled_flag:J,num_short_term_ref_pic_sets:Q,shortTermRefPicSets:se,long_term_ref_pics_present_flag:xe,num_long_term_ref_pics_sps:ce,lt_ref_pic_poc_lsb_sps:oe,used_by_curr_pic_lt_sps_flag:j,sps_temporal_mvp_enabled_flag:Z,strong_intra_smoothing_enabled_flag:ae,vui_parameters_present_flag:le,vuiParameters:ve,sps_extension_present_flag:Re,sps_range_extension_flag:Se,sps_multilayer_extension_flag:R,sps_3d_extension_flag:O,sps_scc_extension_flag:B,sps_extension_4bits:H,spsMultilayerExtension:$,sps3dExtension:V,sps_extension_data_flag:Y}}function hn(t){const e=t.read(2),n=!!t.next(),r=t.read(5),i=t.peekBytes(4),s=[];for(let N=0;N<32;N+=1)s[N]=!!t.next();const c=t.peekBytes(6),o=!!t.next(),u=!!t.next(),d=!!t.next(),f=!!t.next();let h,_,m,x,p,v,E,S,g,b;r===4||s[4]||r===5||s[5]||r===6||s[6]||r===7||s[7]||r===8||s[8]||r===9||s[9]||r===10||s[10]||r===11||s[11]?(h=!!t.next(),_=!!t.next(),m=!!t.next(),x=!!t.next(),p=!!t.next(),v=!!t.next(),E=!!t.next(),S=!!t.next(),g=!!t.next(),r===5||s[5]||r===9||s[9]||r===10||s[10]||r===11||s[11]?(b=!!t.next(),t.skip(33)):t.skip(34)):r===2||s[2]?(t.skip(7),S=!!t.next(),t.skip(35)):t.skip(43);let C;return r===1||s[1]||r===2||s[2]||r===3||s[3]||r===4||s[4]||r===5||s[5]||r===9||s[9]||r===11||s[11]?C=!!t.next():t.skip(1),{profile_space:e,tier_flag:n,profile_idc:r,profileCompatibilitySet:i,profile_compatibility_flag:s,constraintSet:c,progressive_source_flag:o,interlaced_source_flag:u,non_packed_constraint_flag:d,frame_only_constraint_flag:f,max_12bit_constraint_flag:h,max_10bit_constraint_flag:_,max_8bit_constraint_flag:m,max_422chroma_constraint_flag:x,max_420chroma_constraint_flag:p,max_monochrome_constraint_flag:v,intra_constraint_flag:E,one_picture_only_constraint_flag:S,lower_bit_rate_constraint_flag:g,max_14bit_constraint_flag:b,inbld_flag:C}}function ir(t,e,n){let r;r=hn(t);const i=t.read(8),s=[],c=[];for(let d=0;d<n;d+=1)s[d]=!!t.next(),c[d]=!!t.next();if(n>0)for(let d=n;d<8;d+=1)t.read(2);const o=[],u=[];for(let d=0;d<n;d+=1)s[d]&&(o[d]=hn(t)),c[d]&&(u[d]=t.read(8));return{generalProfileTier:r,general_level_idc:i,sub_layer_profile_present_flag:s,sub_layer_level_present_flag:c,subLayerProfileTier:o,sub_layer_level_idc:u}}function co(t){const e=[];for(let n=0;n<4;n+=1){e[n]=[];for(let r=0;r<6;r+=n===3?3:1)if(!!!t.next())t.decodeExponentialGolombNumber();else{let s=8;const c=Math.min(64,1<<4+(n<<1));n>1&&(s=t.decodeExponentialGolombNumber()+8),e[n][r]=[];for(let o=0;o<c;o+=1){const u=t.decodeExponentialGolombNumber();s=(s+u+256)%256,e[n][r][o]=s}}}return e}function lo(t,e,n,r){let i=!1;e!==0&&(i=!!t.next());let s=0,c=!1,o=0;const u=[],d=[];let f=0,h=0;const _=[],m=[],x=[],p=[];if(i){e===n&&(s=t.decodeExponentialGolombNumber()),c=!!t.next(),o=t.decodeExponentialGolombNumber();const v=e-(s+1),E=r[v],S=E.num_negative_pics+E.num_positive_pics;for(let T=0;T<=S;T+=1)u[T]=!!t.next(),u[T]?d[T]=!0:d[T]=!!t.next();const g=(1-2*Number(c))*(o+1),b=[],C=[],N=[],y=[];let L=0;for(let T=0;T<E.num_negative_pics;T+=1)L-=E.delta_poc_s0_minus1[T]+1,b[T]=L;L=0;for(let T=0;T<E.num_positive_pics;T+=1)L+=E.delta_poc_s1_minus1[T]+1,C[T]=L;let w=0;if(E.num_positive_pics>0)for(let T=E.num_positive_pics-1;T>=0;T-=1)L=C[T]+g,L<0&&d[E.num_negative_pics+T]&&(N[w]=L,m[w]=u[E.num_negative_pics+T],w+=1);g<0&&d[S]&&(N[w]=g,m[w]=u[S],w+=1);for(let T=0;T<E.num_negative_pics;T+=1)L=b[T]+g,L<0&&d[T]&&(N[w]=L,m[w]=u[T],w+=1);f=w;let A=0;for(w=0;w<f;w+=1){const T=N[w];_[w]=-(T-A-1),A=T}if(w=0,E.num_negative_pics>0)for(let T=E.num_negative_pics-1;T>=0;T-=1)L=b[T]+g,L>0&&d[T]&&(y[w]=L,p[w]=u[T],w+=1);g>0&&d[S]&&(y[w]=g,p[w]=u[S],w+=1);for(let T=0;T<E.num_positive_pics;T+=1)L=C[T]+g,L>0&&d[E.num_negative_pics+T]&&(y[w]=L,p[w]=u[E.num_negative_pics+T],w+=1);for(h=w,A=0,w=0;w<h;w+=1){const T=y[w];x[w]=T-A-1,A=T}}else{f=t.decodeExponentialGolombNumber(),h=t.decodeExponentialGolombNumber();for(let v=0;v<f;v+=1)_[v]=t.decodeExponentialGolombNumber(),m[v]=!!t.next();for(let v=0;v<h;v+=1)x[v]=t.decodeExponentialGolombNumber(),p[v]=!!t.next()}return{stRpsIdx:e,num_short_term_ref_pic_sets:n,inter_ref_pic_set_prediction_flag:i,delta_idx_minus1:s,delta_rps_sign:c,abs_delta_rps_minus1:o,used_by_curr_pic_flag:u,use_delta_flag:d,num_negative_pics:f,num_positive_pics:h,delta_poc_s0_minus1:_,used_by_curr_pic_s0_flag:m,delta_poc_s1_minus1:x,used_by_curr_pic_s1_flag:p}}function uo(t,e){const n=!!t.next();let r,i,s;n&&(r=t.read(8),r===255&&(i=t.read(16),s=t.read(16)));const c=!!t.next();let o;c&&(o=!!t.next());const u=!!t.next();let d,f,h,_,m,x;u&&(d=t.read(3),f=!!t.next(),h=!!t.next(),h&&(_=t.read(8),m=t.read(8),x=t.read(8)));const p=!!t.next();let v,E;p&&(v=t.decodeExponentialGolombNumber(),E=t.decodeExponentialGolombNumber());const S=!!t.next(),g=!!t.next(),b=!!t.next(),C=!!t.next();let N,y,L,w;C&&(N=t.decodeExponentialGolombNumber(),y=t.decodeExponentialGolombNumber(),L=t.decodeExponentialGolombNumber(),w=t.decodeExponentialGolombNumber());const A=!!t.next();let T,G,z,k,D,P;A&&(T=t.read(32),G=t.read(32),z=!!t.next(),z&&(k=t.decodeExponentialGolombNumber()),D=!!t.next(),D&&(P=or(t,!0,e)));const I=!!t.next();let M,W,X,q,K,J,Q,se;return I&&(M=!!t.next(),W=!!t.next(),X=!!t.next(),q=t.decodeExponentialGolombNumber(),K=t.decodeExponentialGolombNumber(),J=t.decodeExponentialGolombNumber(),Q=t.decodeExponentialGolombNumber(),se=t.decodeExponentialGolombNumber()),{aspect_ratio_info_present_flag:n,aspect_ratio_idc:r,sar_width:i,sar_height:s,overscan_info_present_flag:c,overscan_appropriate_flag:o,video_signal_type_present_flag:u,video_format:d,video_full_range_flag:f,colour_description_present_flag:h,colour_primaries:_,transfer_characteristics:m,matrix_coeffs:x,chroma_loc_info_present_flag:p,chroma_sample_loc_type_top_field:v,chroma_sample_loc_type_bottom_field:E,neutral_chroma_indication_flag:S,field_seq_flag:g,frame_field_info_present_flag:b,default_display_window_flag:C,def_disp_win_left_offset:N,def_disp_win_right_offset:y,def_disp_win_top_offset:L,def_disp_win_bottom_offset:w,vui_timing_info_present_flag:A,vui_num_units_in_tick:T,vui_time_scale:G,vui_poc_proportional_to_timing_flag:z,vui_num_ticks_poc_diff_one_minus1:k,vui_hrd_parameters_present_flag:D,vui_hrd_parameters:P,bitstream_restriction_flag:I,tiles_fixed_structure_flag:M,motion_vectors_over_pic_boundaries_flag:W,restricted_ref_pic_lists_flag:X,min_spatial_segmentation_idc:q,max_bytes_per_pic_denom:K,max_bits_per_min_cu_denom:J,log2_max_mv_length_horizontal:Q,log2_max_mv_length_vertical:se}}function or(t,e,n){let r,i,s,c,o,u,d,f,h,_,m,x,p;e&&(r=!!t.next(),i=!!t.next(),(r||i)&&(s=!!t.next(),s&&(c=t.read(8),o=t.read(5),u=!!t.next(),d=t.read(5)),f=t.read(4),h=t.read(4),s&&(_=t.read(4)),m=t.read(5),x=t.read(5),p=t.read(5)));const v=[],E=[],S=[],g=[],b=[],C=[],N=[];for(let y=0;y<=n;y+=1)v[y]=!!t.next(),v[y]||(E[y]=!!t.next()),E[y]?S[y]=t.decodeExponentialGolombNumber():g[y]=!!t.next(),g[y]||(b[y]=t.decodeExponentialGolombNumber()),r&&(C[y]=pn(t,y,mn(b[y]))),i&&(N[y]=pn(t,y,mn(b[y])));return{nal_hrd_parameters_present_flag:r,vcl_hrd_parameters_present_flag:i,sub_pic_hrd_params_present_flag:s,tick_divisor_minus2:c,du_cpb_removal_delay_increment_length_minus1:o,sub_pic_cpb_params_in_pic_timing_sei_flag:u,dpb_output_delay_du_length_minus1:d,bit_rate_scale:f,cpb_size_scale:h,cpb_size_du_scale:_,initial_cpb_removal_delay_length_minus1:m,au_cpb_removal_delay_length_minus1:x,dpb_output_delay_length_minus1:p,fixed_pic_rate_general_flag:v,fixed_pic_rate_within_cvs_flag:E,elemental_duration_in_tc_minus1:S,low_delay_hrd_flag:g,cpb_cnt_minus1:b,nalHrdParameters:C,vclHrdParameters:N}}function pn(t,e,n){const r=[],i=[],s=[],c=[],o=[];for(let u=0;u<n;u+=1)r[u]=t.decodeExponentialGolombNumber(),i[u]=t.decodeExponentialGolombNumber(),e>0&&(o[u]=!!t.next());return{bit_rate_value_minus1:r,cpb_size_value_minus1:i,cpb_size_du_value_minus1:s,bit_rate_du_value_minus1:c,cbr_flag:o}}function mn(t){return t+1}function fo(t){let e,n,r,i=0;for(const s of sr(t)){const c=io(s),o={...c,data:s,rbsp:s.subarray(2)};switch(c.nal_unit_type){case 32:e=o;break;case 33:n=o;break;case 34:r=o;break;default:continue}if(i+=1,i===3)return{videoParameterSet:e,sequenceParameterSet:n,pictureParameterSet:r}}throw new Error("Invalid data")}function ho(t){return{inter_view_mv_vert_constraint_flag:!!t.next()}}function po(t){const e=[],n=[];e[0]=!!t.next(),n[0]=!!t.next();const r=t.decodeExponentialGolombNumber(),i=!!t.next(),s=!!t.next(),c=!!t.next(),o=!!t.next();e[1]=!!t.next(),n[1]=!!t.next();const u=!!t.next(),d=t.decodeExponentialGolombNumber(),f=!!t.next(),h=!!t.next(),_=!!t.next(),m=!!t.next(),x=!!t.next();return{iv_di_mc_enabled_flag:e,iv_mv_scal_enabled_flag:n,log2_ivmc_sub_pb_size_minus3:r,iv_res_pred_enabled_flag:i,depth_ref_enabled_flag:s,vsp_mc_enabled_flag:c,dbbp_enabled_flag:o,tex_mc_enabled_flag:u,log2_texmc_sub_pb_size_minus3:d,intra_contour_enabled_flag:f,intra_dc_only_wedge_enabled_flag:h,cqt_cu_part_pred_enabled_flag:_,inter_dc_only_enabled_flag:m,skip_intra_enabled_flag:x}}function mo(t){const{videoParameterSet:e,sequenceParameterSet:n,pictureParameterSet:r}=fo(t),{profileTierLevel:{generalProfileTier:{profile_space:i,tier_flag:s,profile_idc:c,profileCompatibilitySet:o,constraintSet:u},general_level_idc:d}}=oo(e.rbsp),{chroma_format_idc:f,pic_width_in_luma_samples:h,pic_height_in_luma_samples:_,conf_win_left_offset:m=0,conf_win_right_offset:x=0,conf_win_top_offset:p=0,conf_win_bottom_offset:v=0}=ao(n.rbsp),E=ro(f),S=so(f),g=h-E*(m+x),b=_-S*(p+v);return{videoParameterSet:e,sequenceParameterSet:n,pictureParameterSet:r,generalProfileSpace:i,generalProfileIndex:c,generalProfileCompatibilitySet:o,generalTierFlag:s,generalLevelIndex:d,generalConstraintSet:u,encodedWidth:h,encodedHeight:_,cropLeft:m,cropRight:x,cropTop:p,cropBottom:v,croppedWidth:g,croppedHeight:b}}function _n(t){return t.toString(16).toUpperCase()}function bt(t){return t.toString(16).toUpperCase().padStart(2,"0")}function Ie(t){return t.toString(10).padStart(2,"0")}class _o{#e;#t;constructor(e,n){this.#e=e,this.#t=n}#n(e){const r=new re(e).searchSequenceHeaderObu();if(!r)return;const{seq_profile:i,seq_level_idx:[s=0],max_frame_width_minus_1:c,max_frame_height_minus_1:o,color_config:{BitDepth:u,mono_chrome:d,subsampling_x:f,subsampling_y:h,chroma_sample_position:_,color_description_present_flag:m}}=r;let x,p,v,E;m?{color_primaries:x,transfer_characteristics:p,matrix_coefficients:v,color_range:E}=r.color_config:(x=re.ColorPrimaries.Bt709,p=re.TransferCharacteristics.Bt709,v=re.MatrixCoefficients.Bt709,E=!1);const S=c+1,g=o+1;this.#t(S,g);const b=["av01",i.toString(16),Ie(s)+(r.seq_tier[0]?"H":"M"),Ie(u),d?"1":"0",(f?"1":"0")+(h?"1":"0")+_.toString(),Ie(x),Ie(p),Ie(v),E?"1":"0"].join(".");this.#e.configure({codec:b,optimizeForLatency:!0})}decode(e){e.type!=="configuration"&&(this.#n(e.data),this.#e.decode(new EncodedVideoChunk({type:e.keyframe===!1?"delta":"key",timestamp:0,data:e.data})))}}class ar{#e;#t;constructor(e){this.#t=e}decode(e){if(e.type==="configuration"){this.#e=e.data,this.configure(e.data);return}let n;this.#e!==void 0?(n=new Uint8Array(this.#e.length+e.data.length),n.set(this.#e,0),n.set(e.data,this.#e.length),this.#e=void 0):n=e.data,this.#t.decode(new EncodedVideoChunk({type:e.keyframe===!1?"delta":"key",timestamp:0,data:n}))}}class go extends ar{#e;#t;constructor(e,n){super(e),this.#e=e,this.#t=n}configure(e){const{profileIndex:n,constraintSet:r,levelIndex:i,croppedWidth:s,croppedHeight:c}=no(e);this.#t(s,c);const o="avc1."+bt(n)+bt(r)+bt(i);this.#e.configure({codec:o,optimizeForLatency:!0})}}class xo extends ar{#e;#t;constructor(e,n){super(e),this.#e=e,this.#t=n}configure(e){const{generalProfileSpace:n,generalProfileIndex:r,generalProfileCompatibilitySet:i,generalTierFlag:s,generalLevelIndex:c,generalConstraintSet:o,croppedWidth:u,croppedHeight:d}=mo(e);this.#t(u,d);const f=["hev1",["","A","B","C"][n]+r.toString(),_n(zi(i,0)),(s?"H":"L")+c.toString(),...Array.from(o,_n)].join(".");this.#e.configure({codec:f,codedWidth:u,codedHeight:d,optimizeForLatency:!0})}}class vo{listeners=[];constructor(){this.event=this.event.bind(this)}addEventListener(e){this.listeners.push(e);const n=()=>{const r=this.listeners.indexOf(e);r!==-1&&this.listeners.splice(r,1)};return n.dispose=n,n}event=(e,n,...r)=>{const i={listener:e,thisArg:n,args:r};return this.addEventListener(i)};fire(e){for(const n of this.listeners.slice())n.listener.apply(n.thisArg,[e,...n.args])}dispose(){this.listeners.length=0}}class bo{#e;#t=new ReadableStream({start:e=>{this.#e=e},pull:e=>{e.enqueue(this.#r())}},{highWaterMark:0});#n=this.#t.getReader();#r;#i=0;#s;constructor(e,n){this.#r=e,this.#s=n}async borrow(){return(await this.#n.read()).value}return(e){this.#i<this.#s&&(this.#e.enqueue(e),this.#i+=1)}}class yo{#e;#t;constructor(){typeof OffscreenCanvas<"u"?this.#e=new OffscreenCanvas(1,1):(this.#e=document.createElement("canvas"),this.#e.width=1,this.#e.height=1),this.#t=this.#e.getContext("bitmaprenderer",{alpha:!1})}async capture(e){this.#e.width=e.displayWidth,this.#e.height=e.displayHeight;const n=await createImageBitmap(e);return this.#t.transferFromImageBitmap(n),this.#e instanceof OffscreenCanvas?await this.#e.convertToBlob({type:"image/png"}):new Promise((r,i)=>{this.#e.toBlob(s=>{s?r(s):i(new Error("Failed to convert canvas to blob"))},"image/png")})}}const gn=new bo(()=>new yo,4);class xn{static get isSupported(){return typeof globalThis.VideoDecoder<"u"}static capabilities={h264:{},h265:{},av1:{}};#e;get codec(){return this.#e}#t;#n;get writable(){return this.#n}#r;#i;#s;get renderer(){return this.#s}#o=0;#c=0;get framesRendered(){return this.#c}#l=0;get framesSkipped(){return this.#l}#d=new vo;get sizeChanged(){return this.#d.event}#a;#p=!1;#u;#f;#m=0;constructor({codec:e,renderer:n}){switch(this.#e=e,this.#s=n,this.#a=new VideoDecoder({output:r=>{if(this.#f?.close(),this.#f=r.clone(),this.#p){this.#u&&(this.#u.close(),this.#l+=1),this.#u=r;return}this.#g(r)},error:r=>{this.#_(r)}}),this.#e){case rt.H264:this.#t=new go(this.#a,this.#h);break;case rt.H265:this.#t=new xo(this.#a,this.#h);break;case rt.AV1:this.#t=new _o(this.#a,this.#h);break;default:throw new Error(`Unsupported codec: ${this.#e}`)}this.#n=new $i({start:r=>{this.#r?r.error(this.#r):this.#i=r},write:r=>{this.#t.decode(r)}}),this.#x()}#_(e){if(this.#i)try{this.#i.error(e)}catch{}else this.#r=e}async#g(e){try{if(this.#p=!0,this.#h(e.displayWidth,e.displayHeight),await this.#s.draw(e),this.#o+=1,e.close(),this.#u){const n=this.#u;this.#u=void 0,await this.#g(n)}this.#p=!1}catch(n){this.#_(n)}}#h=(e,n)=>{this.#s.setSize(e,n),this.#d.fire({width:e,height:n})};#x=()=>{this.#o>0&&(this.#c+=1,this.#l+=this.#o-1,this.#o=0),this.#m=requestAnimationFrame(this.#x)};async snapshot(){const e=this.#f;if(!e)return;const n=await gn.borrow(),r=await n.capture(e);return gn.return(n),r}dispose(){cancelAnimationFrame(this.#m),this.#a.state!=="closed"&&this.#a.close(),this.#u?.close(),this.#f?.close()}}var yt={exports:{}},wt={exports:{}},vn;function Kt(){return vn||(vn=1,(function(){function t(e,n){throw new Error("abstract")}t.prototype.drawFrame=function(e){throw new Error("abstract")},t.prototype.clear=function(){throw new Error("abstract")},wt.exports=t})()),wt.exports}var Et={exports:{}},Tt={exports:{}},Ct={exports:{}},bn;function wo(){return bn||(bn=1,(function(){function t(e){for(var n=0,r=e>>1;r!=0;)r=r>>1,n++;if(e!==1<<n)throw"chroma plane dimensions must be power of 2 ratio to luma plane dimensions; got "+e;return n}Ct.exports=t})()),Ct.exports}var yn;function Eo(){return yn||(yn=1,(function(){var t=wo();function e(n,r){var i=n.format.width|0,s=n.format.height|0,c=t(n.format.width/n.format.chromaWidth)|0,o=t(n.format.height/n.format.chromaHeight)|0,u=n.y.bytes,d=n.u.bytes,f=n.v.bytes,h=n.y.stride|0,_=n.u.stride|0,m=n.v.stride|0,x=i<<2,p=0,v=0,E=0,S=0,g=0,b=0,C=0,N=0,y=0,L=0,w=0,A=0,T=0,G=0,z=0,k=0,D=0,P=0;if(c==1&&o==1)for(C=0,N=x,P=0,k=0;k<s;k+=2){for(v=k*h|0,E=v+h|0,S=P*_|0,g=P*m|0,z=0;z<i;z+=2)y=d[S++]|0,L=f[g++]|0,A=(409*L|0)-57088|0,T=(100*y|0)+(208*L|0)-34816|0,G=(516*y|0)-70912|0,w=298*u[v++]|0,r[C]=w+A>>8,r[C+1]=w-T>>8,r[C+2]=w+G>>8,C+=4,w=298*u[v++]|0,r[C]=w+A>>8,r[C+1]=w-T>>8,r[C+2]=w+G>>8,C+=4,w=298*u[E++]|0,r[N]=w+A>>8,r[N+1]=w-T>>8,r[N+2]=w+G>>8,N+=4,w=298*u[E++]|0,r[N]=w+A>>8,r[N+1]=w-T>>8,r[N+2]=w+G>>8,N+=4;C+=x,N+=x,P++}else for(b=0,k=0;k<s;k++)for(D=0,P=k>>o,p=k*h|0,S=P*_|0,g=P*m|0,z=0;z<i;z++)D=z>>c,y=d[S+D]|0,L=f[g+D]|0,A=(409*L|0)-57088|0,T=(100*y|0)+(208*L|0)-34816|0,G=(516*y|0)-70912|0,w=298*u[p++]|0,r[b]=w+A>>8,r[b+1]=w-T>>8,r[b+2]=w+G>>8,b+=4}Tt.exports={convertYCbCr:e}})()),Tt.exports}var wn;function To(){return wn||(wn=1,(function(){var t=Kt(),e=Eo();function n(r){var i=this,s=r.getContext("2d"),c=null,o=null,u=null;function d(h,_){c=s.createImageData(h,_);for(var m=c.data,x=h*_*4,p=0;p<x;p+=4)m[p+3]=255}function f(h,_){o=document.createElement("canvas"),o.width=h,o.height=_,u=o.getContext("2d")}return i.drawFrame=function(_){var m=_.format;(r.width!==m.displayWidth||r.height!==m.displayHeight)&&(r.width=m.displayWidth,r.height=m.displayHeight),(c===null||c.width!=m.width||c.height!=m.height)&&d(m.width,m.height),e.convertYCbCr(_,c.data);var x=m.cropWidth!=m.displayWidth||m.cropHeight!=m.displayHeight,p;x?(o||f(m.cropWidth,m.cropHeight),p=u):p=s,p.putImageData(c,-m.cropLeft,-m.cropTop,m.cropLeft,m.cropTop,m.cropWidth,m.cropHeight),x&&s.drawImage(o,0,0,m.displayWidth,m.displayHeight)},i.clear=function(){s.clearRect(0,0,r.width,r.height)},i}n.prototype=Object.create(t.prototype),Et.exports=n})()),Et.exports}var St={exports:{}},Nt,En;function Co(){return En||(En=1,Nt={vertex:`precision mediump float;
|
|
14
|
-
|
|
15
|
-
attribute vec2 aPosition;
|
|
16
|
-
attribute vec2 aLumaPosition;
|
|
17
|
-
attribute vec2 aChromaPosition;
|
|
18
|
-
varying vec2 vLumaPosition;
|
|
19
|
-
varying vec2 vChromaPosition;
|
|
20
|
-
void main() {
|
|
21
|
-
gl_Position = vec4(aPosition, 0, 1);
|
|
22
|
-
vLumaPosition = aLumaPosition;
|
|
23
|
-
vChromaPosition = aChromaPosition;
|
|
24
|
-
}
|
|
25
|
-
`,fragment:`// inspired by https://github.com/mbebenita/Broadway/blob/master/Player/canvas.js
|
|
26
|
-
|
|
27
|
-
precision mediump float;
|
|
28
|
-
|
|
29
|
-
uniform sampler2D uTextureY;
|
|
30
|
-
uniform sampler2D uTextureCb;
|
|
31
|
-
uniform sampler2D uTextureCr;
|
|
32
|
-
varying vec2 vLumaPosition;
|
|
33
|
-
varying vec2 vChromaPosition;
|
|
34
|
-
void main() {
|
|
35
|
-
// Y, Cb, and Cr planes are uploaded as ALPHA textures.
|
|
36
|
-
float fY = texture2D(uTextureY, vLumaPosition).w;
|
|
37
|
-
float fCb = texture2D(uTextureCb, vChromaPosition).w;
|
|
38
|
-
float fCr = texture2D(uTextureCr, vChromaPosition).w;
|
|
39
|
-
|
|
40
|
-
// Premultipy the Y...
|
|
41
|
-
float fYmul = fY * 1.1643828125;
|
|
42
|
-
|
|
43
|
-
// And convert that to RGB!
|
|
44
|
-
gl_FragColor = vec4(
|
|
45
|
-
fYmul + 1.59602734375 * fCr - 0.87078515625,
|
|
46
|
-
fYmul - 0.39176171875 * fCb - 0.81296875 * fCr + 0.52959375,
|
|
47
|
-
fYmul + 2.017234375 * fCb - 1.081390625,
|
|
48
|
-
1
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
`,vertexStripe:`precision mediump float;
|
|
52
|
-
|
|
53
|
-
attribute vec2 aPosition;
|
|
54
|
-
attribute vec2 aTexturePosition;
|
|
55
|
-
varying vec2 vTexturePosition;
|
|
56
|
-
|
|
57
|
-
void main() {
|
|
58
|
-
gl_Position = vec4(aPosition, 0, 1);
|
|
59
|
-
vTexturePosition = aTexturePosition;
|
|
60
|
-
}
|
|
61
|
-
`,fragmentStripe:`// extra 'stripe' texture fiddling to work around IE 11's poor performance on gl.LUMINANCE and gl.ALPHA textures
|
|
62
|
-
|
|
63
|
-
precision mediump float;
|
|
64
|
-
|
|
65
|
-
uniform sampler2D uStripe;
|
|
66
|
-
uniform sampler2D uTexture;
|
|
67
|
-
varying vec2 vTexturePosition;
|
|
68
|
-
void main() {
|
|
69
|
-
// Y, Cb, and Cr planes are mapped into a pseudo-RGBA texture
|
|
70
|
-
// so we can upload them without expanding the bytes on IE 11
|
|
71
|
-
// which doesn't allow LUMINANCE or ALPHA textures
|
|
72
|
-
// The stripe textures mark which channel to keep for each pixel.
|
|
73
|
-
// Each texture extraction will contain the relevant value in one
|
|
74
|
-
// channel only.
|
|
75
|
-
|
|
76
|
-
float fLuminance = dot(
|
|
77
|
-
texture2D(uStripe, vTexturePosition),
|
|
78
|
-
texture2D(uTexture, vTexturePosition)
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
gl_FragColor = vec4(0, 0, 0, fLuminance);
|
|
82
|
-
}
|
|
83
|
-
`}),Nt}var Tn;function So(){return Tn||(Tn=1,(function(){var t=Kt(),e=Co();function n(r){var i=this,s=n.contextForCanvas(r);if(s===null)throw new Error("WebGL unavailable");function c(k,D){var P=s.createShader(k);if(s.shaderSource(P,D),s.compileShader(P),!s.getShaderParameter(P,s.COMPILE_STATUS)){var I=s.getShaderInfoLog(P);throw s.deleteShader(P),new Error("GL shader compilation for "+k+" failed: "+I)}return P}var o,u,d=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),f={},h={},_={},m,x,p,v,E,S,g,b,C,N;function y(k,D){return(!f[k]||D)&&(f[k]=s.createTexture()),f[k]}function L(k,D,P,I,M){var W=!f[k]||D,X=y(k,D);if(s.activeTexture(s.TEXTURE0),n.stripe){var q=!f[k+"_temp"]||D,K=y(k+"_temp",D);s.bindTexture(s.TEXTURE_2D,K),q?(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.NEAREST),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,P/4,I,0,s.RGBA,s.UNSIGNED_BYTE,M)):s.texSubImage2D(s.TEXTURE_2D,0,0,0,P/4,I,s.RGBA,s.UNSIGNED_BYTE,M);var J=f[k+"_stripe"],Q=!J||D;Q&&(J=y(k+"_stripe",D)),s.bindTexture(s.TEXTURE_2D,J),Q&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.NEAREST),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,P,1,0,s.RGBA,s.UNSIGNED_BYTE,T(P)))}else s.bindTexture(s.TEXTURE_2D,X),W?(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texImage2D(s.TEXTURE_2D,0,s.ALPHA,P,I,0,s.ALPHA,s.UNSIGNED_BYTE,M)):s.texSubImage2D(s.TEXTURE_2D,0,0,0,P,I,s.ALPHA,s.UNSIGNED_BYTE,M)}function w(k,D,P,I){var M=f[k];s.useProgram(u);var W=h[k];(!W||D)&&(s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,M),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,P,I,0,s.RGBA,s.UNSIGNED_BYTE,null),W=h[k]=s.createFramebuffer()),s.bindFramebuffer(s.FRAMEBUFFER,W),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,M,0);var X=f[k+"_temp"];s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,X),s.uniform1i(S,1);var q=f[k+"_stripe"];s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,q),s.uniform1i(E,2),s.bindBuffer(s.ARRAY_BUFFER,m),s.enableVertexAttribArray(x),s.vertexAttribPointer(x,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,p),s.enableVertexAttribArray(v),s.vertexAttribPointer(v,2,s.FLOAT,!1,0,0),s.viewport(0,0,P,I),s.drawArrays(s.TRIANGLES,0,d.length/2),s.bindFramebuffer(s.FRAMEBUFFER,null)}function A(k,D,P){s.activeTexture(D),s.bindTexture(s.TEXTURE_2D,f[k]),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.uniform1i(s.getUniformLocation(o,k),P)}function T(k){if(_[k])return _[k];for(var D=k,P=new Uint32Array(D),I=0;I<D;I+=4)P[I]=255,P[I+1]=65280,P[I+2]=16711680,P[I+3]=4278190080;return _[k]=new Uint8Array(P.buffer)}function G(k,D){var P=c(s.VERTEX_SHADER,k),I=c(s.FRAGMENT_SHADER,D),M=s.createProgram();if(s.attachShader(M,P),s.attachShader(M,I),s.linkProgram(M),!s.getProgramParameter(M,s.LINK_STATUS)){var W=s.getProgramInfoLog(M);throw s.deleteProgram(M),new Error("GL program linking failed: "+W)}return M}function z(){if(n.stripe){u=G(e.vertexStripe,e.fragmentStripe),s.getAttribLocation(u,"aPosition"),p=s.createBuffer();var k=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);s.bindBuffer(s.ARRAY_BUFFER,p),s.bufferData(s.ARRAY_BUFFER,k,s.STATIC_DRAW),v=s.getAttribLocation(u,"aTexturePosition"),E=s.getUniformLocation(u,"uStripe"),S=s.getUniformLocation(u,"uTexture")}o=G(e.vertex,e.fragment),m=s.createBuffer(),s.bindBuffer(s.ARRAY_BUFFER,m),s.bufferData(s.ARRAY_BUFFER,d,s.STATIC_DRAW),x=s.getAttribLocation(o,"aPosition"),g=s.createBuffer(),b=s.getAttribLocation(o,"aLumaPosition"),C=s.createBuffer(),N=s.getAttribLocation(o,"aChromaPosition")}return i.drawFrame=function(k){var D=k.format,P=!o||r.width!==D.displayWidth||r.height!==D.displayHeight;if(P&&(r.width=D.displayWidth,r.height=D.displayHeight,i.clear()),o||z(),P){var I=function(M,W,X){var q=D.cropLeft/X,K=(D.cropLeft+D.cropWidth)/X,J=(D.cropTop+D.cropHeight)/D.height,Q=D.cropTop/D.height,se=new Float32Array([q,J,K,J,q,Q,q,Q,K,J,K,Q]);s.bindBuffer(s.ARRAY_BUFFER,M),s.bufferData(s.ARRAY_BUFFER,se,s.STATIC_DRAW)};I(g,b,k.y.stride),I(C,N,k.u.stride*D.width/D.chromaWidth)}L("uTextureY",P,k.y.stride,D.height,k.y.bytes),L("uTextureCb",P,k.u.stride,D.chromaHeight,k.u.bytes),L("uTextureCr",P,k.v.stride,D.chromaHeight,k.v.bytes),n.stripe&&(w("uTextureY",P,k.y.stride,D.height),w("uTextureCb",P,k.u.stride,D.chromaHeight),w("uTextureCr",P,k.v.stride,D.chromaHeight)),s.useProgram(o),s.viewport(0,0,r.width,r.height),A("uTextureY",s.TEXTURE0,0),A("uTextureCb",s.TEXTURE1,1),A("uTextureCr",s.TEXTURE2,2),s.bindBuffer(s.ARRAY_BUFFER,m),s.enableVertexAttribArray(x),s.vertexAttribPointer(x,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,g),s.enableVertexAttribArray(b),s.vertexAttribPointer(b,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,C),s.enableVertexAttribArray(N),s.vertexAttribPointer(N,2,s.FLOAT,!1,0,0),s.drawArrays(s.TRIANGLES,0,d.length/2)},i.clear=function(){s.viewport(0,0,r.width,r.height),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT)},i.clear(),i}n.stripe=!1,n.contextForCanvas=function(r){var i={preferLowPowerToHighPerformance:!0,powerPreference:"low-power",failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!0};return r.getContext("webgl",i)||r.getContext("experimental-webgl",i)},n.isAvailable=function(){var r=document.createElement("canvas"),i;r.width=1,r.height=1;try{i=n.contextForCanvas(r)}catch{return!1}if(i){var s=i.TEXTURE0,c=4,o=4,u=i.createTexture(),d=new Uint8Array(c*o),f=n.stripe?c/4:c,h=n.stripe?i.RGBA:i.ALPHA,_=n.stripe?i.NEAREST:i.LINEAR;i.activeTexture(s),i.bindTexture(i.TEXTURE_2D,u),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,_),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,_),i.texImage2D(i.TEXTURE_2D,0,h,f,o,0,h,i.UNSIGNED_BYTE,d);var m=i.getError();return!m}else return!1},n.prototype=Object.create(t.prototype),St.exports=n})()),St.exports}var Cn;function No(){return Cn||(Cn=1,(function(){var t=Kt(),e=To(),n=So(),r={FrameSink:t,SoftwareFrameSink:e,WebGLFrameSink:n,attach:function(i,s){s=s||{};var c="webGL"in s?s.webGL:n.isAvailable();return c?new n(i,s):new e(i,s)}};yt.exports=r})()),yt.exports}No();function cr(){if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("no canvas input found nor any canvas can be created")}class lr{#e;get canvas(){return this.#e}constructor(e){e?this.#e=e:this.#e=cr()}setSize(e,n){(this.#e.width!==e||this.#e.height!==n)&&(this.#e.width=e,this.#e.height=n)}}class ko extends lr{#e;constructor(e){super(e),this.#e=this.canvas.getContext("bitmaprenderer",{alpha:!1})}async draw(e){const n=await createImageBitmap(e);this.#e.transferFromImageBitmap(n)}}const Ro=Promise.resolve();function Sn(t,e){const n={powerPreference:"low-power",alpha:!1,failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!!e};return t.getContext("webgl2",n)||t.getContext("webgl",n)}class Ge extends lr{static vertexShaderSource=`
|
|
84
|
-
attribute vec2 xy;
|
|
85
|
-
|
|
86
|
-
varying highp vec2 uv;
|
|
87
|
-
|
|
88
|
-
void main(void) {
|
|
89
|
-
gl_Position = vec4(xy, 0.0, 1.0);
|
|
90
|
-
// Map vertex coordinates (-1 to +1) to UV coordinates (0 to 1).
|
|
91
|
-
// UV coordinates are Y-flipped relative to vertex coordinates.
|
|
92
|
-
uv = vec2((1.0 + xy.x) / 2.0, (1.0 - xy.y) / 2.0);
|
|
93
|
-
}
|
|
94
|
-
`;static fragmentShaderSource=`
|
|
95
|
-
varying highp vec2 uv;
|
|
96
|
-
|
|
97
|
-
uniform sampler2D texture;
|
|
98
|
-
|
|
99
|
-
void main(void) {
|
|
100
|
-
gl_FragColor = texture2D(texture, uv);
|
|
101
|
-
}
|
|
102
|
-
`;static get isSupported(){const e=cr();return!!Sn(e)}#e;constructor(e,n){super(e);const r=Sn(this.canvas,n);if(!r)throw new Error("WebGL not supported");this.#e=r;const i=r.createShader(r.VERTEX_SHADER);if(r.shaderSource(i,Ge.vertexShaderSource),r.compileShader(i),!r.getShaderParameter(i,r.COMPILE_STATUS))throw new Error(r.getShaderInfoLog(i));const s=r.createShader(r.FRAGMENT_SHADER);if(r.shaderSource(s,Ge.fragmentShaderSource),r.compileShader(s),!r.getShaderParameter(s,r.COMPILE_STATUS))throw new Error(r.getShaderInfoLog(s));const c=r.createProgram();if(r.attachShader(c,i),r.attachShader(c,s),r.linkProgram(c),!r.getProgramParameter(c,r.LINK_STATUS))throw new Error(r.getProgramInfoLog(c));r.useProgram(c);const o=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,o),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW);const u=r.getAttribLocation(c,"xy");r.vertexAttribPointer(u,2,r.FLOAT,!1,0,0),r.enableVertexAttribArray(u);const d=r.createTexture();r.bindTexture(r.TEXTURE_2D,d),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE)}draw(e){const n=this.#e;return n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e),n.viewport(0,0,n.drawingBufferWidth,n.drawingBufferHeight),n.drawArrays(n.TRIANGLE_FAN,0,4),Ro}}const Nn=50,Po=300;function Ao({deviceId:t,className:e,onFallback:n,fallbackTimeout:r=5e3,enableControl:i=!1,onTapSuccess:s,onTapError:c,onSwipeSuccess:o,onSwipeError:u,onStreamReady:d}){const f=l.useRef(null),h=l.useRef(null),_=l.useRef(null),m=l.useRef(null),x=l.useRef(null),p=l.useRef(null),v=l.useRef(null),E=l.useRef(!1),S=l.useRef(!1),g=l.useRef(n),b=l.useRef(r),C=l.useRef(d),[N,y]=l.useState("connecting"),[L,w]=l.useState(null),[A,T]=l.useState(null),[G,z]=l.useState(null),k=l.useRef(!1),D=l.useRef(null),P=l.useRef(!1),I=l.useRef(0),M=l.useRef(null),W=l.useRef(null),X=l.useRef(null),q=l.useRef(null);l.useEffect(()=>{g.current=n,b.current=r,C.current=d},[n,r,d]),l.useEffect(()=>{(async()=>{try{const O=await Un(t);O.success&&z({width:O.width,height:O.height})}catch(O){console.error("[ScrcpyPlayer] Failed to fetch device resolution:",O)}})()},[t]);const K=l.useCallback(()=>{const R=m.current,O=_.current;if(!R||!O||!A)return;const B=O.clientWidth,H=O.clientHeight,{width:$,height:V}=A,Y=$/V;let U=B,ue=B/Y;ue>H&&(ue=H,U=H*Y),R.width=$,R.height=V,R.style.width=`${U}px`,R.style.height=`${ue}px`},[A]);l.useEffect(()=>{const R=()=>K();return window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)},[K]),l.useEffect(()=>{K()},[A,K]);const J=l.useCallback(async()=>{if(Ge.isSupported){const O=new Ge;return{renderer:O,element:O.canvas}}const R=new ko;return{renderer:R,element:R.canvas}},[]),Q=l.useCallback(async R=>{if(!xn.isSupported)throw new Error("Current browser does not support WebCodecs API. Please use the latest Chrome/Edge.");const{renderer:O,element:B}=await J();return m.current=B,_.current&&!B.parentElement&&_.current.appendChild(B),new xn({codec:R,renderer:O})},[J]),se=l.useCallback(()=>{E.current||(E.current=!0,x.current&&(clearTimeout(x.current),x.current=null))},[]),xe=l.useCallback(R=>{let O=!1,B=[];const H=new TransformStream({transform(V,Y){if(V.type==="configuration"){Y.enqueue(V),O=!0,B.length>0&&(B.forEach(U=>Y.enqueue(U)),B=[]);return}if(V.type==="data"&&!O){B.push(V);return}Y.enqueue(V)}});return new ReadableStream({start(V){let Y=!1;const U=pe=>{if(!Y)try{se();const we={...pe,data:pe.data instanceof Uint8Array?pe.data:new Uint8Array(pe.data)};V.enqueue(we)}catch(we){console.error("[ScrcpyPlayer] Video enqueue error:",we),Y=!0,ye()}},ue=pe=>{Y||(V.error(new Error(pe?.message||"Socket error")),Y=!0,ye())},Pe=()=>{Y||(V.close(),Y=!0,ye())},ye=()=>{f.current?.off("video-data",U),f.current?.off("error",ue),f.current?.off("disconnect",Pe)};return f.current?.on("video-data",U),f.current?.on("error",ue),f.current?.on("disconnect",Pe),()=>{Y=!0,ye()}}}).pipeThrough(H)},[se]),ce=l.useCallback((R=!1)=>{if(R&&(S.current=!0),h.current){try{h.current.dispose()}catch(O){console.error("[ScrcpyPlayer] Failed to dispose decoder:",O)}h.current=null}m.current=null,f.current&&(f.current.disconnect(),f.current=null),C.current?.(null),p.current&&(clearTimeout(p.current),p.current=null),x.current&&(clearTimeout(x.current),x.current=null),y("disconnected"),T(null),w(null)},[]),oe=l.useCallback(()=>{ce(!0),E.current=!1,y("connecting"),w(null);const R=nt({path:"/socket.io",transports:["websocket"],timeout:1e4});f.current=R,R.on("connect",()=>{R.emit("connect-device",{device_id:t,maxSize:1280,bitRate:4e6}),x.current=setTimeout(()=>{E.current||(y("error"),w("Video stream timeout"),S.current=!0,R.close(),g.current?.())},b.current)}),R.on("video-metadata",async O=>{try{h.current&&(h.current.dispose(),h.current=null);const B=O?.codec?O.codec:rt.H264;h.current=await Q(B),h.current.sizeChanged(({width:$,height:V})=>{T({width:$,height:V})}),xe(O).pipeTo(h.current.writable).catch($=>{console.error("[ScrcpyPlayer] Video stream error:",$)}),y("connected"),C.current?.({close:()=>R.close()})}catch(B){console.error("[ScrcpyPlayer] Decoder initialization failed:",B),y("error"),w("Decoder initialization failed"),S.current=!0,R.close(),g.current?.()}}),R.on("error",O=>{console.error("[ScrcpyPlayer] Socket error:",O),y("error"),w(O?.message||"Socket error")}),R.on("disconnect",()=>{if(S.current){S.current=!1;return}y("disconnected"),C.current?.(null),p.current||(p.current=setTimeout(()=>{p.current=null,v.current?.()},3e3))})},[t,ce,Q,xe]);l.useEffect(()=>{v.current=oe},[oe]),l.useEffect(()=>(queueMicrotask(()=>{oe()}),()=>{W.current&&(clearTimeout(W.current),W.current=null),X.current&&(clearTimeout(X.current),X.current=null),ce(!0)}),[oe,ce]);const j=()=>{if(A)return{width:A.width,height:A.height};const R=m.current;return R?{width:R.width,height:R.height}:null},Z=(R,O)=>{const B=m.current,H=j();if(!B||!H)return null;const $=B.getBoundingClientRect();if(R<$.left||R>$.right||O<$.top||O>$.bottom)return null;const V=R-$.left,Y=O-$.top,U=Math.round(V/$.width*H.width),ue=Math.round(Y/$.height*H.height),Pe=G?G.width/H.width:1,ye=G?G.height/H.height:1;return{x:Math.round(U*Pe),y:Math.round(ue*ye)}},ae=async R=>{if(!i||N!=="connected")return;const O=Z(R.clientX,R.clientY);if(O){k.current=!0,P.current=!1,D.current={x:R.clientX,y:R.clientY};try{await rs(O.x,O.y,t)}catch(B){console.error("[ScrcpyPlayer] Touch down failed:",B)}}},le=R=>{if(!k.current||N!=="connected")return;const O=Date.now(),B=Z(R.clientX,R.clientY);if(B){if(D.current){const H=R.clientX-D.current.x,$=R.clientY-D.current.y;Math.hypot(H,$)>4&&(P.current=!0)}if(M.current=B,O-I.current<Nn){W.current||(W.current=setTimeout(()=>{W.current=null,M.current&&(nn(M.current.x,M.current.y,t).catch(H=>{console.error("[ScrcpyPlayer] Touch move failed:",H)}),M.current=null,I.current=Date.now())},Nn));return}I.current=O,nn(B.x,B.y,t).catch(H=>{console.error("[ScrcpyPlayer] Touch move failed:",H)})}},ve=async R=>{if(!k.current||N!=="connected")return;const O=Z(R.clientX,R.clientY);if(k.current=!1,D.current=null,!!O)try{await tn(O.x,O.y,t),P.current?o?.():s?.()}catch(B){const H=String(B);P.current?u?.(H):c?.(H)}},Re=async R=>{if(!k.current||N!=="connected")return;const O=Z(R.clientX,R.clientY);if(k.current=!1,D.current=null,!!O)try{await tn(O.x,O.y,t)}catch(B){console.error("[ScrcpyPlayer] Touch cancel failed:",B)}},Se=R=>{if(!i||N!=="connected")return;R.preventDefault();const O=R.deltaY;q.current||(q.current={deltaY:0}),q.current.deltaY+=O,X.current&&clearTimeout(X.current),X.current=setTimeout(async()=>{const B=q.current;if(q.current=null,!B)return;const H=m.current,$=j();if(!H||!$)return;const V=H.getBoundingClientRect(),Y=V.left+V.width/2,U=V.top+V.height/2,ue=Z(Y,U);if(!ue)return;const Pe=Math.max(Math.min(B.deltaY,600),-600),ye=U+Pe,pe=Z(Y,ye);if(pe)try{const we=await ns(ue.x,ue.y,pe.x,pe.y,300,t);we.success?o?.():u?.(we.error||"Scroll failed")}catch(we){u?.(String(we))}},Po)};return a.jsx("div",{className:`relative w-full h-full flex items-center justify-center ${e||""}`,children:a.jsx("div",{ref:_,className:"relative w-full h-full flex items-center justify-center bg-slate-900",onMouseDown:ae,onMouseMove:le,onMouseUp:ve,onMouseLeave:Re,onWheel:Se,children:N!=="connected"&&a.jsxs("div",{className:"absolute inset-0 flex items-center justify-center text-slate-400",children:[N==="connecting"&&"Connecting...",N==="error"&&(L||"Connection error"),N==="disconnected"&&"Disconnected"]})})})}const ur=l.forwardRef(({className:t,...e},n)=>a.jsx("textarea",{className:ne("flex min-h-[40px] w-full rounded-full border border-slate-200 bg-white px-3 py-2 text-sm ring-offset-white file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#1d9bf0] focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-800 dark:bg-slate-950 dark:ring-offset-slate-950 dark:placeholder:text-slate-400 dark:focus-visible:ring-[#1d9bf0] resize-none",t),ref:n,...e}));ur.displayName="Textarea";const Wt=l.forwardRef(({className:t,...e},n)=>a.jsx("div",{ref:n,className:ne("rounded-2xl border border-slate-200 bg-white text-slate-950 shadow-sm dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50",t),...e}));Wt.displayName="Card";const Do=l.forwardRef(({className:t,...e},n)=>a.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",t),...e}));Do.displayName="CardHeader";const Lo=l.forwardRef(({className:t,...e},n)=>a.jsx("h3",{ref:n,className:ne("text-xl font-semibold leading-none tracking-tight",t),...e}));Lo.displayName="CardTitle";const jo=l.forwardRef(({className:t,...e},n)=>a.jsx("p",{ref:n,className:ne("text-sm text-slate-500 dark:text-slate-400",t),...e}));jo.displayName="CardDescription";const Oo=l.forwardRef(({className:t,...e},n)=>a.jsx("div",{ref:n,className:ne("p-6 pt-0",t),...e}));Oo.displayName="CardContent";const Bo=l.forwardRef(({className:t,...e},n)=>a.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",t),...e}));Bo.displayName="CardFooter";function Io({deviceId:t,deviceName:e,config:n,isConfigured:r}){const i=lt(),[s,c]=l.useState([]),[o,u]=l.useState(""),[d,f]=l.useState(!1),[h,_]=l.useState(null),[m,x]=l.useState(!1),[p,v]=l.useState(null),[E,S]=l.useState(!0),[g,b]=l.useState(!1),[C,N]=l.useState("auto"),[y,L]=l.useState(null),w=l.useRef(null),A=(j,Z=2e3)=>{w.current&&clearTimeout(w.current),L(j),w.current=setTimeout(()=>{L(null)},Z)};l.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]);const T=l.useRef(null),G=()=>{T.current&&clearTimeout(T.current),D(!0)},z=()=>{T.current=setTimeout(()=>{D(!1)},500)};l.useEffect(()=>()=>{T.current&&clearTimeout(T.current)},[]);const[k,D]=l.useState(!1),P=l.useRef(null),I=l.useRef(null),M=l.useRef(null),W=l.useRef(!1),X=l.useRef(!1),q=l.useCallback(async()=>{if(n)try{await ss({model_config:{base_url:n.base_url||void 0,api_key:n.api_key||void 0,model_name:n.model_name||void 0},agent_config:{device_id:t}}),x(!0),_(null)}catch(j){const Z=j instanceof Error?j.message:"Initialization failed";_(Z)}},[t,n]);l.useEffect(()=>{r&&n&&!m&&!X.current&&(X.current=!0,q())},[r,n,m,q]);const K=l.useCallback(async()=>{const j=o.trim();if(!j||d)return;m||await q();const Z={id:Date.now().toString(),role:"user",content:j,timestamp:new Date};c(R=>[...R,Z]),u(""),f(!0),_(null);const ae=[],le=[],ve=(Date.now()+1).toString(),Re={id:ve,role:"agent",content:"",timestamp:new Date,thinking:[],actions:[],isStreaming:!0};c(R=>[...R,Re]);const Se=is(Z.content,t,R=>{ae.push(R.thinking),le.push(R.action),c(O=>O.map(B=>B.id===ve?{...B,thinking:[...ae],actions:[...le],steps:R.step}:B))},R=>{c(O=>O.map(B=>B.id===ve?{...B,content:R.message,success:R.success,isStreaming:!1}:B)),f(!1),P.current=null},R=>{c(O=>O.map(B=>B.id===ve?{...B,content:`Error: ${R.message}`,success:!1,isStreaming:!1}:B)),f(!1),_(R.message),P.current=null});P.current=Se},[o,d,m,t,q]),J=l.useCallback(async()=>{P.current&&P.current.close(),c([]),f(!1),_(null),P.current=null,await os(t)},[t]),Q=()=>{M.current?.scrollIntoView({behavior:"smooth"})};l.useEffect(()=>{Q()},[s]),l.useEffect(()=>()=>{P.current&&P.current.close(),I.current&&I.current.close()},[t]),l.useEffect(()=>{if(!t||!(C==="screenshot"||C==="auto"&&g))return;const Z=async()=>{if(!W.current){W.current=!0;try{const le=await Un(t);le.success&&v(le)}catch(le){console.error("Failed to fetch screenshot:",le)}finally{W.current=!1}}};Z();const ae=setInterval(Z,500);return()=>clearInterval(ae)},[t,g,C]);const se=j=>{(j.metaKey||j.ctrlKey)&&j.key==="Enter"&&(j.preventDefault(),K())},xe=l.useCallback(j=>{I.current=j},[]),ce=l.useCallback(()=>{b(!0),S(!1)},[]),oe=j=>{N(j)};return a.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[a.jsxs(Wt,{className:"flex-1 flex flex-col min-h-0 max-w-2xl",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:a.jsx(_t,{className:"h-5 w-5 text-[#1d9bf0]"})}),a.jsxs("div",{children:[a.jsx("h2",{className:"font-bold text-slate-900 dark:text-slate-100",children:e}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 font-mono",children:t})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[!r&&a.jsxs(Qe,{variant:"warning",children:[a.jsx(Je,{className:"w-3 h-3 mr-1"}),i.devicePanel.noConfig]}),m?a.jsxs(Qe,{variant:"success",children:[a.jsx(at,{className:"w-3 h-3 mr-1"}),i.devicePanel.ready]}):a.jsx(ie,{onClick:q,disabled:!r||!n,size:"sm",variant:"twitter",children:i.devicePanel.initializing}),a.jsx(ie,{variant:"ghost",size:"icon",onClick:J,className:"h-8 w-8 rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300",title:"Reset chat",children:a.jsx(Ls,{className:"h-4 w-4"})})]})]}),h&&a.jsxs("div",{className:"mx-4 mt-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl text-sm text-red-600 dark:text-red-400 flex items-center gap-2",children:[a.jsx(Je,{className:"w-4 h-4 flex-shrink-0"}),h]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 min-h-0",children:a.jsxs("div",{className:"w-full",children:[s.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[a.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800 mb-4",children:a.jsx(_t,{className:"h-8 w-8 text-slate-400"})}),a.jsx("p",{className:"font-medium text-slate-900 dark:text-slate-100",children:i.devicePanel.readyToHelp}),a.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:i.devicePanel.describeTask})]}):null,s.map(j=>a.jsx("div",{className:`flex ${j.role==="user"?"justify-end":"justify-start"}`,children:j.role==="agent"?a.jsxs("div",{className:"max-w-[85%] space-y-3",children:[j.thinking?.map((Z,ae)=>a.jsxs("div",{className:"bg-slate-100 dark:bg-slate-800 rounded-2xl rounded-tl-sm px-4 py-3",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:a.jsx(_t,{className:"h-3 w-3 text-[#1d9bf0]"})}),a.jsxs("span",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:["Step ",ae+1]})]}),a.jsx("p",{className:"text-sm whitespace-pre-wrap",children:Z}),j.actions?.[ae]&&a.jsxs("details",{className:"mt-2 text-xs",children:[a.jsx("summary",{className:"cursor-pointer text-[#1d9bf0] hover:text-[#1a8cd8]",children:"View action"}),a.jsx("pre",{className:"mt-2 p-2 bg-slate-900 text-slate-200 rounded-lg overflow-x-auto text-xs",children:JSON.stringify(j.actions[ae],null,2)})]})]},ae)),j.content&&a.jsxs("div",{className:`
|
|
103
|
-
rounded-2xl px-4 py-3 flex items-start gap-2
|
|
104
|
-
${j.success===!1?"bg-red-100 dark:bg-red-900/20 text-red-600 dark:text-red-400":"bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300"}
|
|
105
|
-
`,children:[a.jsx(at,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${j.success===!1?"text-red-500":"text-green-500"}`}),a.jsxs("div",{children:[a.jsx("p",{className:"whitespace-pre-wrap",children:j.content}),j.steps!==void 0&&a.jsxs("p",{className:"text-xs mt-2 opacity-60",children:[j.steps," steps completed"]})]})]}),j.isStreaming&&a.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-400",children:[a.jsx(Ue,{className:"w-4 h-4 animate-spin"}),"Processing..."]})]}):a.jsxs("div",{className:"max-w-[75%]",children:[a.jsx("div",{className:"chat-bubble-user px-4 py-3",children:a.jsx("p",{className:"whitespace-pre-wrap",children:j.content})}),a.jsx("p",{className:"text-xs text-slate-400 mt-1 text-right",children:j.timestamp.toLocaleTimeString()})]})},j.id)),a.jsx("div",{ref:M})]})}),a.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800",children:a.jsxs("div",{className:"flex items-end gap-3",children:[a.jsx(ur,{value:o,onChange:j=>u(j.target.value),onKeyDown:se,placeholder:r?m?i.devicePanel.whatToDo:i.devicePanel.initDeviceFirst:i.devicePanel.configureFirst,disabled:d,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),a.jsx(ie,{onClick:K,disabled:d||!o.trim(),size:"icon",variant:"twitter",className:"h-10 w-10 rounded-full flex-shrink-0",children:d?a.jsx(Ue,{className:"h-4 w-4 animate-spin"}):a.jsx(Os,{className:"h-4 w-4"})})]})})]}),a.jsxs(Wt,{className:"w-[320px] flex-shrink-0 relative min-h-0 overflow-hidden bg-slate-950",onMouseEnter:G,onMouseLeave:z,children:[a.jsx("div",{className:`absolute top-4 right-4 z-10 transition-opacity duration-200 ${k?"opacity-100":"opacity-0 pointer-events-none"}`,children:a.jsxs("div",{className:"flex items-center gap-1 bg-slate-900/90 backdrop-blur rounded-xl p-1 shadow-lg",children:[a.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>oe("auto"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${C==="auto"?"bg-[#1d9bf0] text-white":"text-slate-300 hover:text-white hover:bg-slate-800"}`,children:i.devicePanel.auto}),a.jsxs(ie,{variant:"ghost",size:"sm",onClick:()=>oe("video"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${C==="video"?"bg-[#1d9bf0] text-white":"text-slate-300 hover:text-white hover:bg-slate-800"}`,children:[a.jsx(Ws,{className:"w-3 h-3 mr-1"}),i.devicePanel.video]}),a.jsxs(ie,{variant:"ghost",size:"sm",onClick:()=>oe("screenshot"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${C==="screenshot"?"bg-[#1d9bf0] text-white":"text-slate-300 hover:text-white hover:bg-slate-800"}`,children:[a.jsx(rn,{className:"w-3 h-3 mr-1"}),i.devicePanel.image]})]})}),a.jsx("div",{className:"absolute bottom-4 left-4 z-10",children:a.jsxs(Qe,{variant:"secondary",className:"bg-slate-900/90 text-slate-300 border border-slate-700",children:[C==="auto"&&i.devicePanel.auto,C==="video"&&a.jsxs(a.Fragment,{children:[a.jsx(Rs,{className:"w-3 h-3 mr-1"}),i.devicePanel.video]}),C==="screenshot"&&a.jsxs(a.Fragment,{children:[a.jsx(rn,{className:"w-3 h-3 mr-1"}),i.devicePanel.imageRefresh]})]})}),y&&a.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-20 px-3 py-2 bg-[#1d9bf0] text-white text-sm rounded-xl shadow-lg",children:y}),C==="video"||C==="auto"&&E&&!g?a.jsx(Ao,{deviceId:t,className:"w-full h-full",enableControl:!0,onFallback:ce,onTapSuccess:()=>A(i.devicePanel.tapped,2e3),onTapError:j=>A(i.devicePanel.tapError.replace("{error}",j),3e3),onSwipeSuccess:()=>A(i.devicePanel.swiped,2e3),onSwipeError:j=>A(i.devicePanel.swipeError.replace("{error}",j),3e3),onStreamReady:xe,fallbackTimeout:1e5}):a.jsx("div",{className:"w-full h-full flex items-center justify-center bg-slate-900 min-h-0",children:p&&p.success?a.jsxs("div",{className:"relative w-full h-full flex items-center justify-center min-h-0",children:[a.jsx("img",{src:`data:image/png;base64,${p.image}`,alt:"Device Screenshot",className:"max-w-full max-h-full object-contain",style:{width:p.width>p.height?"100%":"auto",height:p.width>p.height?"auto":"100%"}}),p.is_sensitive&&a.jsx("div",{className:"absolute top-12 right-2 px-2 py-1 bg-yellow-500 text-white text-xs rounded-lg",children:i.devicePanel.sensitiveContent})]}):p?.error?a.jsxs("div",{className:"text-center text-red-400",children:[a.jsx(Je,{className:"w-8 h-8 mx-auto mb-2"}),a.jsx("p",{className:"font-medium",children:i.devicePanel.screenshotFailed}),a.jsx("p",{className:"text-xs mt-1 opacity-60",children:p.error})]}):a.jsxs("div",{className:"text-center text-slate-400",children:[a.jsx(Ue,{className:"w-8 h-8 mx-auto mb-2 animate-spin"}),a.jsx("p",{className:"text-sm",children:i.devicePanel.loading})]})})]})]})}function Mo({message:t,type:e="info",onClose:n,duration:r=3e3}){l.useEffect(()=>{const c=setTimeout(()=>{n()},r);return()=>clearTimeout(c)},[r,n]);const i={success:"bg-green-500",error:"bg-red-500",info:"bg-blue-500"},s={success:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})}),error:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})}),info:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})};return a.jsx("div",{className:"fixed top-4 left-1/2 transform -translate-x-1/2 z-50 animate-fade-in-down",children:a.jsxs("div",{className:`${i[e]} text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3 min-w-[300px]`,children:[s[e],a.jsx("span",{className:"font-medium",children:t}),a.jsx("button",{onClick:n,className:"ml-auto hover:bg-white/20 rounded-full p-1 transition-colors",children:a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]})})}const st=l.forwardRef(({className:t,type:e,...n},r)=>a.jsx("input",{type:e,className:ne("flex h-10 w-full rounded-full border border-slate-200 bg-white px-3 py-2 text-sm ring-offset-white file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#1d9bf0] focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-800 dark:bg-slate-950 dark:ring-offset-slate-950 dark:placeholder:text-slate-400 dark:focus-visible:ring-[#1d9bf0]",t),ref:r,...n}));st.displayName="Input";function Ce(t,e,{checkForDefaultPrevented:n=!0}={}){return function(i){if(t?.(i),n===!1||!i.defaultPrevented)return e?.(i)}}function Fo(t,e){const n=l.createContext(e),r=s=>{const{children:c,...o}=s,u=l.useMemo(()=>o,Object.values(o));return a.jsx(n.Provider,{value:u,children:c})};r.displayName=t+"Provider";function i(s){const c=l.useContext(n);if(c)return c;if(e!==void 0)return e;throw new Error(`\`${s}\` must be used within \`${t}\``)}return[r,i]}function Uo(t,e=[]){let n=[];function r(s,c){const o=l.createContext(c),u=n.length;n=[...n,c];const d=h=>{const{scope:_,children:m,...x}=h,p=_?.[t]?.[u]||o,v=l.useMemo(()=>x,Object.values(x));return a.jsx(p.Provider,{value:v,children:m})};d.displayName=s+"Provider";function f(h,_){const m=_?.[t]?.[u]||o,x=l.useContext(m);if(x)return x;if(c!==void 0)return c;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[d,f]}const i=()=>{const s=n.map(c=>l.createContext(c));return function(o){const u=o?.[t]||s;return l.useMemo(()=>({[`__scope${t}`]:{...o,[t]:u}}),[o,u])}};return i.scopeName=t,[r,Go(i,...e)]}function Go(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const c=r.reduce((o,{useScope:u,scopeName:d})=>{const h=u(s)[`__scope${d}`];return{...o,...h}},{});return l.useMemo(()=>({[`__scope${e.scopeName}`]:c}),[c])}};return n.scopeName=e.scopeName,n}var We=globalThis?.document?l.useLayoutEffect:()=>{},Wo=Gn[" useId ".trim().toString()]||(()=>{}),qo=0;function kt(t){const[e,n]=l.useState(Wo());return We(()=>{n(r=>r??String(qo++))},[t]),t||(e?`radix-${e}`:"")}var Ho=Gn[" useInsertionEffect ".trim().toString()]||We;function Xo({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[i,s,c]=Vo({defaultProp:e,onChange:n}),o=t!==void 0,u=o?t:i;{const f=l.useRef(t!==void 0);l.useEffect(()=>{const h=f.current;h!==o&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${o?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=o},[o,r])}const d=l.useCallback(f=>{if(o){const h=zo(f)?f(t):f;h!==t&&c.current?.(h)}else s(f)},[o,t,s,c]);return[u,d]}function Vo({defaultProp:t,onChange:e}){const[n,r]=l.useState(t),i=l.useRef(n),s=l.useRef(e);return Ho(()=>{s.current=e},[e]),l.useEffect(()=>{i.current!==n&&(s.current?.(n),i.current=n)},[n,i]),[n,r,s]}function zo(t){return typeof t=="function"}function dr(t){const e=$o(t),n=l.forwardRef((r,i)=>{const{children:s,...c}=r,o=l.Children.toArray(s),u=o.find(Ko);if(u){const d=u.props.children,f=o.map(h=>h===u?l.Children.count(d)>1?l.Children.only(null):l.isValidElement(d)?d.props.children:null:h);return a.jsx(e,{...c,ref:i,children:l.isValidElement(d)?l.cloneElement(d,void 0,f):null})}return a.jsx(e,{...c,ref:i,children:s})});return n.displayName=`${t}.Slot`,n}function $o(t){const e=l.forwardRef((n,r)=>{const{children:i,...s}=n;if(l.isValidElement(i)){const c=Qo(i),o=Jo(s,i.props);return i.type!==l.Fragment&&(o.ref=r?as(r,c):c),l.cloneElement(i,o)}return l.Children.count(i)>1?l.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var Yo=Symbol("radix.slottable");function Ko(t){return l.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Yo}function Jo(t,e){const n={...e};for(const r in e){const i=t[r],s=e[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...o)=>{const u=s(...o);return i(...o),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...t,...n}}function Qo(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Zo=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],be=Zo.reduce((t,e)=>{const n=dr(`Primitive.${e}`),r=l.forwardRef((i,s)=>{const{asChild:c,...o}=i,u=c?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(u,{...o,ref:s})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function ea(t,e){t&&cs.flushSync(()=>t.dispatchEvent(e))}function qe(t){const e=l.useRef(t);return l.useEffect(()=>{e.current=t}),l.useMemo(()=>(...n)=>e.current?.(...n),[])}function ta(t,e=globalThis?.document){const n=qe(t);l.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var na="DismissableLayer",qt="dismissableLayer.update",ra="dismissableLayer.pointerDownOutside",sa="dismissableLayer.focusOutside",kn,fr=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),hr=l.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:c,onDismiss:o,...u}=t,d=l.useContext(fr),[f,h]=l.useState(null),_=f?.ownerDocument??globalThis?.document,[,m]=l.useState({}),x=ke(e,y=>h(y)),p=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),E=p.indexOf(v),S=f?p.indexOf(f):-1,g=d.layersWithOutsidePointerEventsDisabled.size>0,b=S>=E,C=aa(y=>{const L=y.target,w=[...d.branches].some(A=>A.contains(L));!b||w||(i?.(y),c?.(y),y.defaultPrevented||o?.())},_),N=ca(y=>{const L=y.target;[...d.branches].some(A=>A.contains(L))||(s?.(y),c?.(y),y.defaultPrevented||o?.())},_);return ta(y=>{S===d.layers.size-1&&(r?.(y),!y.defaultPrevented&&o&&(y.preventDefault(),o()))},_),l.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(kn=_.body.style.pointerEvents,_.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),Rn(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(_.body.style.pointerEvents=kn)}},[f,_,n,d]),l.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),Rn())},[f,d]),l.useEffect(()=>{const y=()=>m({});return document.addEventListener(qt,y),()=>document.removeEventListener(qt,y)},[]),a.jsx(be.div,{...u,ref:x,style:{pointerEvents:g?b?"auto":"none":void 0,...t.style},onFocusCapture:Ce(t.onFocusCapture,N.onFocusCapture),onBlurCapture:Ce(t.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Ce(t.onPointerDownCapture,C.onPointerDownCapture)})});hr.displayName=na;var ia="DismissableLayerBranch",oa=l.forwardRef((t,e)=>{const n=l.useContext(fr),r=l.useRef(null),i=ke(e,r);return l.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),a.jsx(be.div,{...t,ref:i})});oa.displayName=ia;function aa(t,e=globalThis?.document){const n=qe(t),r=l.useRef(!1),i=l.useRef(()=>{});return l.useEffect(()=>{const s=o=>{if(o.target&&!r.current){let u=function(){pr(ra,n,d,{discrete:!0})};const d={originalEvent:o};o.pointerType==="touch"?(e.removeEventListener("click",i.current),i.current=u,e.addEventListener("click",i.current,{once:!0})):u()}else e.removeEventListener("click",i.current);r.current=!1},c=window.setTimeout(()=>{e.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(c),e.removeEventListener("pointerdown",s),e.removeEventListener("click",i.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function ca(t,e=globalThis?.document){const n=qe(t),r=l.useRef(!1);return l.useEffect(()=>{const i=s=>{s.target&&!r.current&&pr(sa,n,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Rn(){const t=new CustomEvent(qt);document.dispatchEvent(t)}function pr(t,e,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),r?ea(i,s):i.dispatchEvent(s)}var Rt="focusScope.autoFocusOnMount",Pt="focusScope.autoFocusOnUnmount",Pn={bubbles:!1,cancelable:!0},la="FocusScope",mr=l.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...c}=t,[o,u]=l.useState(null),d=qe(i),f=qe(s),h=l.useRef(null),_=ke(e,p=>u(p)),m=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(r){let p=function(g){if(m.paused||!o)return;const b=g.target;o.contains(b)?h.current=b:Ee(h.current,{select:!0})},v=function(g){if(m.paused||!o)return;const b=g.relatedTarget;b!==null&&(o.contains(b)||Ee(h.current,{select:!0}))},E=function(g){if(document.activeElement===document.body)for(const C of g)C.removedNodes.length>0&&Ee(o)};document.addEventListener("focusin",p),document.addEventListener("focusout",v);const S=new MutationObserver(E);return o&&S.observe(o,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",v),S.disconnect()}}},[r,o,m.paused]),l.useEffect(()=>{if(o){Dn.add(m);const p=document.activeElement;if(!o.contains(p)){const E=new CustomEvent(Rt,Pn);o.addEventListener(Rt,d),o.dispatchEvent(E),E.defaultPrevented||(ua(ma(_r(o)),{select:!0}),document.activeElement===p&&Ee(o))}return()=>{o.removeEventListener(Rt,d),setTimeout(()=>{const E=new CustomEvent(Pt,Pn);o.addEventListener(Pt,f),o.dispatchEvent(E),E.defaultPrevented||Ee(p??document.body,{select:!0}),o.removeEventListener(Pt,f),Dn.remove(m)},0)}}},[o,d,f,m]);const x=l.useCallback(p=>{if(!n&&!r||m.paused)return;const v=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,E=document.activeElement;if(v&&E){const S=p.currentTarget,[g,b]=da(S);g&&b?!p.shiftKey&&E===b?(p.preventDefault(),n&&Ee(g,{select:!0})):p.shiftKey&&E===g&&(p.preventDefault(),n&&Ee(b,{select:!0})):E===S&&p.preventDefault()}},[n,r,m.paused]);return a.jsx(be.div,{tabIndex:-1,...c,ref:_,onKeyDown:x})});mr.displayName=la;function ua(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Ee(r,{select:e}),document.activeElement!==n)return}function da(t){const e=_r(t),n=An(e,t),r=An(e.reverse(),t);return[n,r]}function _r(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function An(t,e){for(const n of t)if(!fa(n,{upTo:e}))return n}function fa(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function ha(t){return t instanceof HTMLInputElement&&"select"in t}function Ee(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&ha(t)&&e&&t.select()}}var Dn=pa();function pa(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=Ln(t,e),t.unshift(e)},remove(e){t=Ln(t,e),t[0]?.resume()}}}function Ln(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function ma(t){return t.filter(e=>e.tagName!=="A")}var _a="Portal",gr=l.forwardRef((t,e)=>{const{container:n,...r}=t,[i,s]=l.useState(!1);We(()=>s(!0),[]);const c=n||i&&globalThis?.document?.body;return c?ls.createPortal(a.jsx(be.div,{...r,ref:e}),c):null});gr.displayName=_a;function ga(t,e){return l.useReducer((n,r)=>e[n][r]??n,t)}var ht=t=>{const{present:e,children:n}=t,r=xa(e),i=typeof n=="function"?n({present:r.isPresent}):l.Children.only(n),s=ke(r.ref,va(i));return typeof n=="function"||r.isPresent?l.cloneElement(i,{ref:s}):null};ht.displayName="Presence";function xa(t){const[e,n]=l.useState(),r=l.useRef(null),i=l.useRef(t),s=l.useRef("none"),c=t?"mounted":"unmounted",[o,u]=ga(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const d=Ve(r.current);s.current=o==="mounted"?d:"none"},[o]),We(()=>{const d=r.current,f=i.current;if(f!==t){const _=s.current,m=Ve(d);t?u("MOUNT"):m==="none"||d?.display==="none"?u("UNMOUNT"):u(f&&_!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,u]),We(()=>{if(e){let d;const f=e.ownerDocument.defaultView??window,h=m=>{const p=Ve(r.current).includes(CSS.escape(m.animationName));if(m.target===e&&p&&(u("ANIMATION_END"),!i.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",d=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},_=m=>{m.target===e&&(s.current=Ve(r.current))};return e.addEventListener("animationstart",_),e.addEventListener("animationcancel",h),e.addEventListener("animationend",h),()=>{f.clearTimeout(d),e.removeEventListener("animationstart",_),e.removeEventListener("animationcancel",h),e.removeEventListener("animationend",h)}}else u("ANIMATION_END")},[e,u]),{isPresent:["mounted","unmountSuspended"].includes(o),ref:l.useCallback(d=>{r.current=d?getComputedStyle(d):null,n(d)},[])}}function Ve(t){return t?.animationName||"none"}function va(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var At=0;function ba(){l.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??jn()),document.body.insertAdjacentElement("beforeend",t[1]??jn()),At++,()=>{At===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),At--}},[])}function jn(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var me=function(){return me=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},me.apply(this,arguments)};function xr(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n}function ya(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}var it="right-scroll-bar-position",ot="width-before-scroll-bar",wa="with-scroll-bars-hidden",Ea="--removed-body-scroll-bar-size";function Dt(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function Ta(t,e){var n=l.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=e,n.facade}var Ca=typeof window<"u"?l.useLayoutEffect:l.useEffect,On=new WeakMap;function Sa(t,e){var n=Ta(null,function(r){return t.forEach(function(i){return Dt(i,r)})});return Ca(function(){var r=On.get(n);if(r){var i=new Set(r),s=new Set(t),c=n.current;i.forEach(function(o){s.has(o)||Dt(o,null)}),s.forEach(function(o){i.has(o)||Dt(o,c)})}On.set(n,t)},[t]),n}function Na(t){return t}function ka(t,e){e===void 0&&(e=Na);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(s){var c=e(s,r);return n.push(c),function(){n=n.filter(function(o){return o!==c})}},assignSyncMedium:function(s){for(r=!0;n.length;){var c=n;n=[],c.forEach(s)}n={push:function(o){return s(o)},filter:function(){return n}}},assignMedium:function(s){r=!0;var c=[];if(n.length){var o=n;n=[],o.forEach(s),c=n}var u=function(){var f=c;c=[],f.forEach(s)},d=function(){return Promise.resolve().then(u)};d(),n={push:function(f){c.push(f),d()},filter:function(f){return c=c.filter(f),n}}}};return i}function Ra(t){t===void 0&&(t={});var e=ka(null);return e.options=me({async:!0,ssr:!1},t),e}var vr=function(t){var e=t.sideCar,n=xr(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return l.createElement(r,me({},n))};vr.isSideCarExport=!0;function Pa(t,e){return t.useMedium(e),vr}var br=Ra(),Lt=function(){},pt=l.forwardRef(function(t,e){var n=l.useRef(null),r=l.useState({onScrollCapture:Lt,onWheelCapture:Lt,onTouchMoveCapture:Lt}),i=r[0],s=r[1],c=t.forwardProps,o=t.children,u=t.className,d=t.removeScrollBar,f=t.enabled,h=t.shards,_=t.sideCar,m=t.noRelative,x=t.noIsolation,p=t.inert,v=t.allowPinchZoom,E=t.as,S=E===void 0?"div":E,g=t.gapMode,b=xr(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=_,N=Sa([n,e]),y=me(me({},b),i);return l.createElement(l.Fragment,null,f&&l.createElement(C,{sideCar:br,removeScrollBar:d,shards:h,noRelative:m,noIsolation:x,inert:p,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:g}),c?l.cloneElement(l.Children.only(o),me(me({},y),{ref:N})):l.createElement(S,me({},y,{className:u,ref:N}),o))});pt.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};pt.classNames={fullWidth:ot,zeroRight:it};var Aa=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Da(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=Aa();return e&&t.setAttribute("nonce",e),t}function La(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function ja(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var Oa=function(){var t=0,e=null;return{add:function(n){t==0&&(e=Da())&&(La(e,n),ja(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},Ba=function(){var t=Oa();return function(e,n){l.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},yr=function(){var t=Ba(),e=function(n){var r=n.styles,i=n.dynamic;return t(r,i),null};return e},Ia={left:0,top:0,right:0,gap:0},jt=function(t){return parseInt(t||"",10)||0},Ma=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],i=e[t==="padding"?"paddingRight":"marginRight"];return[jt(n),jt(r),jt(i)]},Fa=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Ia;var e=Ma(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},Ua=yr(),je="data-scroll-locked",Ga=function(t,e,n,r){var i=t.left,s=t.top,c=t.right,o=t.gap;return n===void 0&&(n="margin"),`
|
|
106
|
-
.`.concat(wa,` {
|
|
107
|
-
overflow: hidden `).concat(r,`;
|
|
108
|
-
padding-right: `).concat(o,"px ").concat(r,`;
|
|
109
|
-
}
|
|
110
|
-
body[`).concat(je,`] {
|
|
111
|
-
overflow: hidden `).concat(r,`;
|
|
112
|
-
overscroll-behavior: contain;
|
|
113
|
-
`).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
114
|
-
padding-left: `.concat(i,`px;
|
|
115
|
-
padding-top: `).concat(s,`px;
|
|
116
|
-
padding-right: `).concat(c,`px;
|
|
117
|
-
margin-left:0;
|
|
118
|
-
margin-top:0;
|
|
119
|
-
margin-right: `).concat(o,"px ").concat(r,`;
|
|
120
|
-
`),n==="padding"&&"padding-right: ".concat(o,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.`).concat(it,` {
|
|
124
|
-
right: `).concat(o,"px ").concat(r,`;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.`).concat(ot,` {
|
|
128
|
-
margin-right: `).concat(o,"px ").concat(r,`;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.`).concat(it," .").concat(it,` {
|
|
132
|
-
right: 0 `).concat(r,`;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.`).concat(ot," .").concat(ot,` {
|
|
136
|
-
margin-right: 0 `).concat(r,`;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
body[`).concat(je,`] {
|
|
140
|
-
`).concat(Ea,": ").concat(o,`px;
|
|
141
|
-
}
|
|
142
|
-
`)},Bn=function(){var t=parseInt(document.body.getAttribute(je)||"0",10);return isFinite(t)?t:0},Wa=function(){l.useEffect(function(){return document.body.setAttribute(je,(Bn()+1).toString()),function(){var t=Bn()-1;t<=0?document.body.removeAttribute(je):document.body.setAttribute(je,t.toString())}},[])},qa=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,i=r===void 0?"margin":r;Wa();var s=l.useMemo(function(){return Fa(i)},[i]);return l.createElement(Ua,{styles:Ga(s,!e,i,n?"":"!important")})},Ht=!1;if(typeof window<"u")try{var ze=Object.defineProperty({},"passive",{get:function(){return Ht=!0,!0}});window.addEventListener("test",ze,ze),window.removeEventListener("test",ze,ze)}catch{Ht=!1}var Ae=Ht?{passive:!1}:!1,Ha=function(t){return t.tagName==="TEXTAREA"},wr=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!Ha(t)&&n[e]==="visible")},Xa=function(t){return wr(t,"overflowY")},Va=function(t){return wr(t,"overflowX")},In=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=Er(t,r);if(i){var s=Tr(t,r),c=s[1],o=s[2];if(c>o)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},za=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},$a=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},Er=function(t,e){return t==="v"?Xa(e):Va(e)},Tr=function(t,e){return t==="v"?za(e):$a(e)},Ya=function(t,e){return t==="h"&&e==="rtl"?-1:1},Ka=function(t,e,n,r,i){var s=Ya(t,window.getComputedStyle(e).direction),c=s*r,o=n.target,u=e.contains(o),d=!1,f=c>0,h=0,_=0;do{if(!o)break;var m=Tr(t,o),x=m[0],p=m[1],v=m[2],E=p-v-s*x;(x||E)&&Er(t,o)&&(h+=E,_+=x);var S=o.parentNode;o=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!u&&o!==document.body||u&&(e.contains(o)||e===o));return(f&&Math.abs(h)<1||!f&&Math.abs(_)<1)&&(d=!0),d},$e=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},Mn=function(t){return[t.deltaX,t.deltaY]},Fn=function(t){return t&&"current"in t?t.current:t},Ja=function(t,e){return t[0]===e[0]&&t[1]===e[1]},Qa=function(t){return`
|
|
143
|
-
.block-interactivity-`.concat(t,` {pointer-events: none;}
|
|
144
|
-
.allow-interactivity-`).concat(t,` {pointer-events: all;}
|
|
145
|
-
`)},Za=0,De=[];function ec(t){var e=l.useRef([]),n=l.useRef([0,0]),r=l.useRef(),i=l.useState(Za++)[0],s=l.useState(yr)[0],c=l.useRef(t);l.useEffect(function(){c.current=t},[t]),l.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(i));var p=ya([t.lockRef.current],(t.shards||[]).map(Fn),!0).filter(Boolean);return p.forEach(function(v){return v.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),p.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(i))})}}},[t.inert,t.lockRef.current,t.shards]);var o=l.useCallback(function(p,v){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!c.current.allowPinchZoom;var E=$e(p),S=n.current,g="deltaX"in p?p.deltaX:S[0]-E[0],b="deltaY"in p?p.deltaY:S[1]-E[1],C,N=p.target,y=Math.abs(g)>Math.abs(b)?"h":"v";if("touches"in p&&y==="h"&&N.type==="range")return!1;var L=window.getSelection(),w=L&&L.anchorNode,A=w?w===N||w.contains(N):!1;if(A)return!1;var T=In(y,N);if(!T)return!0;if(T?C=y:(C=y==="v"?"h":"v",T=In(y,N)),!T)return!1;if(!r.current&&"changedTouches"in p&&(g||b)&&(r.current=C),!C)return!0;var G=r.current||C;return Ka(G,v,p,G==="h"?g:b)},[]),u=l.useCallback(function(p){var v=p;if(!(!De.length||De[De.length-1]!==s)){var E="deltaY"in v?Mn(v):$e(v),S=e.current.filter(function(C){return C.name===v.type&&(C.target===v.target||v.target===C.shadowParent)&&Ja(C.delta,E)})[0];if(S&&S.should){v.cancelable&&v.preventDefault();return}if(!S){var g=(c.current.shards||[]).map(Fn).filter(Boolean).filter(function(C){return C.contains(v.target)}),b=g.length>0?o(v,g[0]):!c.current.noIsolation;b&&v.cancelable&&v.preventDefault()}}},[]),d=l.useCallback(function(p,v,E,S){var g={name:p,delta:v,target:E,should:S,shadowParent:tc(E)};e.current.push(g),setTimeout(function(){e.current=e.current.filter(function(b){return b!==g})},1)},[]),f=l.useCallback(function(p){n.current=$e(p),r.current=void 0},[]),h=l.useCallback(function(p){d(p.type,Mn(p),p.target,o(p,t.lockRef.current))},[]),_=l.useCallback(function(p){d(p.type,$e(p),p.target,o(p,t.lockRef.current))},[]);l.useEffect(function(){return De.push(s),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:_}),document.addEventListener("wheel",u,Ae),document.addEventListener("touchmove",u,Ae),document.addEventListener("touchstart",f,Ae),function(){De=De.filter(function(p){return p!==s}),document.removeEventListener("wheel",u,Ae),document.removeEventListener("touchmove",u,Ae),document.removeEventListener("touchstart",f,Ae)}},[]);var m=t.removeScrollBar,x=t.inert;return l.createElement(l.Fragment,null,x?l.createElement(s,{styles:Qa(i)}):null,m?l.createElement(qa,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function tc(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const nc=Pa(br,ec);var Cr=l.forwardRef(function(t,e){return l.createElement(pt,me({},t,{ref:e,sideCar:nc}))});Cr.classNames=pt.classNames;var rc=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Le=new WeakMap,Ye=new WeakMap,Ke={},Ot=0,Sr=function(t){return t&&(t.host||Sr(t.parentNode))},sc=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=Sr(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},ic=function(t,e,n,r){var i=sc(e,Array.isArray(t)?t:[t]);Ke[n]||(Ke[n]=new WeakMap);var s=Ke[n],c=[],o=new Set,u=new Set(i),d=function(h){!h||o.has(h)||(o.add(h),d(h.parentNode))};i.forEach(d);var f=function(h){!h||u.has(h)||Array.prototype.forEach.call(h.children,function(_){if(o.has(_))f(_);else try{var m=_.getAttribute(r),x=m!==null&&m!=="false",p=(Le.get(_)||0)+1,v=(s.get(_)||0)+1;Le.set(_,p),s.set(_,v),c.push(_),p===1&&x&&Ye.set(_,!0),v===1&&_.setAttribute(n,"true"),x||_.setAttribute(r,"true")}catch(E){console.error("aria-hidden: cannot operate on ",_,E)}})};return f(e),o.clear(),Ot++,function(){c.forEach(function(h){var _=Le.get(h)-1,m=s.get(h)-1;Le.set(h,_),s.set(h,m),_||(Ye.has(h)||h.removeAttribute(r),Ye.delete(h)),m||h.removeAttribute(n)}),Ot--,Ot||(Le=new WeakMap,Le=new WeakMap,Ye=new WeakMap,Ke={})}},oc=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),i=rc(t);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),ic(r,i,n,"aria-hidden")):function(){return null}},mt="Dialog",[Nr]=Uo(mt),[ac,he]=Nr(mt),kr=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:c=!0}=t,o=l.useRef(null),u=l.useRef(null),[d,f]=Xo({prop:r,defaultProp:i??!1,onChange:s,caller:mt});return a.jsx(ac,{scope:e,triggerRef:o,contentRef:u,contentId:kt(),titleId:kt(),descriptionId:kt(),open:d,onOpenChange:f,onOpenToggle:l.useCallback(()=>f(h=>!h),[f]),modal:c,children:n})};kr.displayName=mt;var Rr="DialogTrigger",cc=l.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=he(Rr,n),s=ke(e,i.triggerRef);return a.jsx(be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Zt(i.open),...r,ref:s,onClick:Ce(t.onClick,i.onOpenToggle)})});cc.displayName=Rr;var Jt="DialogPortal",[lc,Pr]=Nr(Jt,{forceMount:void 0}),Ar=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:i}=t,s=he(Jt,e);return a.jsx(lc,{scope:e,forceMount:n,children:l.Children.map(r,c=>a.jsx(ht,{present:n||s.open,children:a.jsx(gr,{asChild:!0,container:i,children:c})}))})};Ar.displayName=Jt;var ct="DialogOverlay",Dr=l.forwardRef((t,e)=>{const n=Pr(ct,t.__scopeDialog),{forceMount:r=n.forceMount,...i}=t,s=he(ct,t.__scopeDialog);return s.modal?a.jsx(ht,{present:r||s.open,children:a.jsx(dc,{...i,ref:e})}):null});Dr.displayName=ct;var uc=dr("DialogOverlay.RemoveScroll"),dc=l.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=he(ct,n);return a.jsx(Cr,{as:uc,allowPinchZoom:!0,shards:[i.contentRef],children:a.jsx(be.div,{"data-state":Zt(i.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Ne="DialogContent",Lr=l.forwardRef((t,e)=>{const n=Pr(Ne,t.__scopeDialog),{forceMount:r=n.forceMount,...i}=t,s=he(Ne,t.__scopeDialog);return a.jsx(ht,{present:r||s.open,children:s.modal?a.jsx(fc,{...i,ref:e}):a.jsx(hc,{...i,ref:e})})});Lr.displayName=Ne;var fc=l.forwardRef((t,e)=>{const n=he(Ne,t.__scopeDialog),r=l.useRef(null),i=ke(e,n.contentRef,r);return l.useEffect(()=>{const s=r.current;if(s)return oc(s)},[]),a.jsx(jr,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ce(t.onCloseAutoFocus,s=>{s.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ce(t.onPointerDownOutside,s=>{const c=s.detail.originalEvent,o=c.button===0&&c.ctrlKey===!0;(c.button===2||o)&&s.preventDefault()}),onFocusOutside:Ce(t.onFocusOutside,s=>s.preventDefault())})}),hc=l.forwardRef((t,e)=>{const n=he(Ne,t.__scopeDialog),r=l.useRef(!1),i=l.useRef(!1);return a.jsx(jr,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{t.onCloseAutoFocus?.(s),s.defaultPrevented||(r.current||n.triggerRef.current?.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{t.onInteractOutside?.(s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const c=s.target;n.triggerRef.current?.contains(c)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),jr=l.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...c}=t,o=he(Ne,n),u=l.useRef(null),d=ke(e,u);return ba(),a.jsxs(a.Fragment,{children:[a.jsx(mr,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:a.jsx(hr,{role:"dialog",id:o.contentId,"aria-describedby":o.descriptionId,"aria-labelledby":o.titleId,"data-state":Zt(o.open),...c,ref:d,onDismiss:()=>o.onOpenChange(!1)})}),a.jsxs(a.Fragment,{children:[a.jsx(pc,{titleId:o.titleId}),a.jsx(_c,{contentRef:u,descriptionId:o.descriptionId})]})]})}),Qt="DialogTitle",Or=l.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=he(Qt,n);return a.jsx(be.h2,{id:i.titleId,...r,ref:e})});Or.displayName=Qt;var Br="DialogDescription",Ir=l.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=he(Br,n);return a.jsx(be.p,{id:i.descriptionId,...r,ref:e})});Ir.displayName=Br;var Mr="DialogClose",Fr=l.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=he(Mr,n);return a.jsx(be.button,{type:"button",...r,ref:e,onClick:Ce(t.onClick,()=>i.onOpenChange(!1))})});Fr.displayName=Mr;function Zt(t){return t?"open":"closed"}var Ur="DialogTitleWarning",[Sc,Gr]=Fo(Ur,{contentName:Ne,titleName:Qt,docsSlug:"dialog"}),pc=({titleId:t})=>{const e=Gr(Ur),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
146
|
-
|
|
147
|
-
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
148
|
-
|
|
149
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return l.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},mc="DialogDescriptionWarning",_c=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Gr(mc).contentName}}.`;return l.useEffect(()=>{const i=t.current?.getAttribute("aria-describedby");e&&i&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},gc=kr,xc=Ar,Wr=Dr,qr=Lr,Hr=Or,Xr=Ir,vc=Fr;const bc=gc,yc=xc,Vr=l.forwardRef(({className:t,...e},n)=>a.jsx(Wr,{ref:n,className:ne("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));Vr.displayName=Wr.displayName;const zr=l.forwardRef(({className:t,children:e,...n},r)=>a.jsxs(yc,{children:[a.jsx(Vr,{}),a.jsxs(qr,{ref:r,className:ne("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-slate-200 bg-white p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-2xl dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50",t),...n,children:[e,a.jsxs(vc,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-[#1d9bf0] focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-slate-100 data-[state=open]:text-slate-500 dark:ring-offset-slate-950 dark:focus:ring-[#1d9bf0] dark:data-[state=open]:bg-slate-800 dark:data-[state=open]:text-slate-400",children:[a.jsx($s,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));zr.displayName=qr.displayName;const $r=({className:t,...e})=>a.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});$r.displayName="DialogHeader";const Yr=({className:t,...e})=>a.jsx("div",{className:ne("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});Yr.displayName="DialogFooter";const Kr=l.forwardRef(({className:t,...e},n)=>a.jsx(Hr,{ref:n,className:ne("text-lg font-semibold leading-none tracking-tight",t),...e}));Kr.displayName=Hr.displayName;const Jr=l.forwardRef(({className:t,...e},n)=>a.jsx(Xr,{ref:n,className:ne("text-sm text-slate-500 dark:text-slate-400",t),...e}));Jr.displayName=Xr.displayName;var wc="Label",Qr=l.forwardRef((t,e)=>a.jsx(us.label,{...t,ref:e,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(t.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Qr.displayName=wc;var Zr=Qr;const Fe=l.forwardRef(({className:t,...e},n)=>a.jsx(Zr,{ref:n,className:ne("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));Fe.displayName=Zr.displayName;const Ec=[{name:"bigmodel",config:{base_url:"https://open.bigmodel.cn/api/paas/v4",model_name:"autoglm-phone",api_key:""}},{name:"modelscope",config:{base_url:"https://api-inference.modelscope.cn/v1",model_name:"ZhipuAI/AutoGLM-Phone-9B",api_key:""}},{name:"custom",config:{base_url:"",model_name:"autoglm-phone-9b",api_key:""}}];function Nc(){const t=lt(),[e,n]=l.useState([]),[r,i]=l.useState(""),[s,c]=l.useState({message:"",type:"info",visible:!1}),o=(g,b="info")=>{c({message:g,type:b,visible:!0})},[u,d]=l.useState(null),[f,h]=l.useState(!1),[_,m]=l.useState(!1),[x,p]=l.useState({base_url:"",model_name:"",api_key:""});l.useEffect(()=>{(async()=>{try{const b=await ds();d({base_url:b.base_url,model_name:b.model_name,api_key:b.api_key||void 0}),p({base_url:b.base_url,model_name:b.model_name,api_key:b.api_key||""}),b.base_url||h(!0)}catch(b){console.error("Failed to load config:",b),h(!0)}})()},[]),l.useEffect(()=>{const g=async()=>{try{const C=await fs(),N=new Map,y=new Map;for(const w of C.devices)if(w.serial){const A=y.get(w.serial)||[];A.push(w),y.set(w.serial,A)}else N.set(w.id,w);Array.from(y.values()).forEach(w=>{const T=w.find(G=>G.connection_type==="remote")||w[0];N.set(T.id,T)});const L=Array.from(N.values());n(L),L.length>0&&!r&&i(L[0].id),r&&!L.find(w=>w.id===r)&&i(L[0]?.id||"")}catch(C){console.error("Failed to load devices:",C)}};g();const b=setInterval(g,3e3);return()=>clearInterval(b)},[r]);const v=async()=>{if(!x.base_url){o(t.chat.baseUrlRequired,"error");return}try{await hs({base_url:x.base_url,model_name:x.model_name||"autoglm-phone-9b",api_key:x.api_key||void 0}),d({base_url:x.base_url,model_name:x.model_name,api_key:x.api_key||void 0}),h(!1),o(t.toasts.configSaved,"success")}catch(g){console.error("Failed to save config:",g),o(`Failed to save: ${g instanceof Error?g.message:"Unknown error"}`,"error")}},E=async g=>{try{const b=await ms({device_id:g});b.success&&b.device_id?(i(b.device_id),o(t.toasts.wifiConnected,"success")):b.success||o(b.message||b.error||t.toasts.connectionFailed,"error")}catch(b){o(t.toasts.wifiConnectionError,"error"),console.error("Connect WiFi error:",b)}},S=async g=>{try{const b=await ps(g);b.success?o(t.toasts.wifiDisconnected,"success"):o(b.message||b.error||t.toasts.disconnectFailed,"error")}catch(b){o(t.toasts.wifiDisconnectError,"error"),console.error("Disconnect WiFi error:",b)}};return a.jsxs("div",{className:"h-full flex relative min-h-0",children:[s.visible&&a.jsx(Mo,{message:s.message,type:s.type,onClose:()=>c(g=>({...g,visible:!1}))}),a.jsx(bc,{open:f,onOpenChange:h,children:a.jsxs(zr,{className:"sm:max-w-md",children:[a.jsxs($r,{children:[a.jsxs(Kr,{className:"flex items-center gap-2",children:[a.jsx(Wn,{className:"w-5 h-5 text-[#1d9bf0]"}),t.chat.configuration]}),a.jsx(Jr,{children:t.chat.configureApi})]}),a.jsxs("div",{className:"space-y-4 py-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(Fe,{className:"text-sm font-medium",children:t.chat.selectPreset}),a.jsx("div",{className:"grid grid-cols-1 gap-2",children:Ec.map(g=>a.jsxs("button",{type:"button",onClick:()=>p({base_url:g.config.base_url,model_name:g.config.model_name,api_key:g.config.api_key}),className:`text-left p-3 rounded-lg border transition-all ${x.base_url===g.config.base_url&&(g.name!=="custom"||g.name==="custom"&&x.base_url==="")?"border-[#1d9bf0] bg-[#1d9bf0]/5":"border-slate-200 dark:border-slate-700 hover:border-[#1d9bf0]/50 hover:bg-slate-50 dark:hover:bg-slate-800/50"}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Is,{className:`w-4 h-4 ${x.base_url===g.config.base_url&&(g.name!=="custom"||g.name==="custom"&&x.base_url==="")?"text-[#1d9bf0]":"text-slate-400"}`}),a.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:t.presetConfigs[g.name].name})]}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 ml-6",children:t.presetConfigs[g.name].description})]},g.name))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(Fe,{htmlFor:"base_url",children:[t.chat.baseUrl," *"]}),a.jsx(st,{id:"base_url",value:x.base_url,onChange:g=>p({...x,base_url:g.target.value}),placeholder:"http://localhost:8080/v1"}),!x.base_url&&a.jsxs("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[a.jsx(Je,{className:"w-3 h-3"}),t.chat.baseUrlRequired]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Fe,{htmlFor:"api_key",children:t.chat.apiKey}),a.jsxs("div",{className:"relative",children:[a.jsx(st,{id:"api_key",type:_?"text":"password",value:x.api_key,onChange:g=>p({...x,api_key:g.target.value}),placeholder:"Leave empty if not required",className:"pr-10"}),a.jsx(ie,{type:"button",variant:"ghost",size:"icon",onClick:()=>m(!_),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:_?a.jsx(Es,{className:"w-4 h-4 text-slate-400"}):a.jsx(Cs,{className:"w-4 h-4 text-slate-400"})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Fe,{htmlFor:"model_name",children:t.chat.modelName}),a.jsx(st,{id:"model_name",value:x.model_name,onChange:g=>p({...x,model_name:g.target.value}),placeholder:"autoglm-phone-9b"})]})]}),a.jsxs(Yr,{className:"sm:justify-between gap-2",children:[a.jsx(ie,{variant:"outline",onClick:()=>{h(!1),u&&p({base_url:u.base_url,model_name:u.model_name,api_key:u.api_key||""})},children:t.chat.cancel}),a.jsxs(ie,{onClick:v,variant:"twitter",children:[a.jsx(at,{className:"w-4 h-4 mr-2"}),t.chat.saveConfig]})]})]})}),a.jsx(Zs,{devices:e,currentDeviceId:r,onSelectDevice:i,onOpenConfig:()=>h(!0),onConnectWifi:E,onDisconnectWifi:S}),a.jsx("div",{className:"flex-1 relative flex items-stretch justify-center min-h-0 px-4 py-4",children:e.length===0?a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-slate-50 dark:bg-slate-950",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800 mx-auto mb-4",children:a.jsx("svg",{className:"w-10 h-10 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),a.jsx("h3",{className:"text-lg font-semibold text-slate-900 dark:text-slate-100 mb-2",children:t.chat.welcomeTitle}),a.jsx("p",{className:"text-slate-500 dark:text-slate-400",children:t.chat.connectDevice})]})}):e.map(g=>a.jsx("div",{className:`w-full h-full flex items-stretch justify-center min-h-0 ${g.id===r?"":"hidden"}`,children:a.jsx(Io,{deviceId:g.id,deviceName:g.model,config:u,isVisible:g.id===r,isConfigured:!!u?.base_url})},g.id))})]})}export{Nc as component};
|