autoglm-gui 1.0.1__py3-none-any.whl → 1.1.0__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/adb_plus/__init__.py +7 -0
- AutoGLM_GUI/adb_plus/mdns.py +192 -0
- AutoGLM_GUI/adb_plus/pair.py +60 -0
- AutoGLM_GUI/adb_plus/qr_pair.py +372 -0
- AutoGLM_GUI/api/__init__.py +8 -0
- AutoGLM_GUI/api/devices.py +224 -1
- AutoGLM_GUI/schemas.py +70 -0
- AutoGLM_GUI/static/assets/{about-BOnRPlKQ.js → about-Crpy4Xue.js} +1 -1
- AutoGLM_GUI/static/assets/chat-DGFuSj6_.js +149 -0
- AutoGLM_GUI/static/assets/index-C1k5Ch1V.js +10 -0
- AutoGLM_GUI/static/assets/{index-CRFVU0eu.js → index-COYnSjzf.js} +1 -1
- AutoGLM_GUI/static/assets/index-QX6oy21q.css +1 -0
- AutoGLM_GUI/static/index.html +2 -2
- {autoglm_gui-1.0.1.dist-info → autoglm_gui-1.1.0.dist-info}/METADATA +45 -40
- {autoglm_gui-1.0.1.dist-info → autoglm_gui-1.1.0.dist-info}/RECORD +18 -15
- AutoGLM_GUI/static/assets/chat-CGW6uMKB.js +0 -149
- AutoGLM_GUI/static/assets/index-DH-Dl4tK.js +0 -10
- AutoGLM_GUI/static/assets/index-DzUQ89YC.css +0 -1
- {autoglm_gui-1.0.1.dist-info → autoglm_gui-1.1.0.dist-info}/WHEEL +0 -0
- {autoglm_gui-1.0.1.dist-info → autoglm_gui-1.1.0.dist-info}/entry_points.txt +0 -0
- {autoglm_gui-1.0.1.dist-info → autoglm_gui-1.1.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import{c as J,j as i,u as dt,r as h,B as te,a as lt,b as Pe,d as _e,P as le,e as Mt,f as rt,g as Qe,h as Me,i as Mn,k as se,l as Rt,D as In,m as Uo,n as ae,R as ne,o as Go,p as Ho,q as zo,s as Wo,t as $o,S as ot,v as Wr,w as qo,x as Ln,y as Xo,z as $r,A as qr,C as Vo,E as On,F as Yo,G as Fn,H as Ko,I as Qo,J as Jo,K as Zo,L as ei,M as ti,N as ri,O as ni,Q as si,T as oi,U as ii}from"./index-C1k5Ch1V.js";const ai=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],ci=J("arrow-up-down",ai);const li=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Bn=J("chevron-left",li);const ui=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Un=J("chevron-right",ui);const di=[["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"}]],ze=J("circle-alert",di);const fi=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],hi=J("circle-check-big",fi);const pi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Je=J("circle-check",pi);const mi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Xr=J("circle-x",mi);const gi=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],_i=J("external-link",gi);const xi=[["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"}]],vi=J("eye-off",xi);const bi=[["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"}]],yi=J("eye",bi);const wi=[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]],Ei=J("fingerprint-pattern",wi);const Si=[["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"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Vr=J("history",Si);const Ci=[["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"}]],Yr=J("image",Ci);const Ni=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],We=J("loader-circle",Ni);const Ti=[["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"}]],Ri=J("monitor-play",Ti);const ki=[["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"}]],Pi=J("plug",ki);const Ai=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ji=J("plus",Ai);const Di=[["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"}]],Mi=J("rotate-ccw",Di);const Ii=[["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"}]],Li=J("send",Ii);const Oi=[["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"}]],Fi=J("server",Oi);const Bi=[["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"}]],Gn=J("settings",Bi);const Ui=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],bt=J("smartphone",Ui);const Gi=[["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=J("sparkles",Gi);const Hi=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],zi=J("trash-2",Hi);const Wi=[["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"}]],$i=J("video",Wi);const qi=[["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"}]],Xi=J("wifi-off",qi);const Vi=[["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"}]],dr=J("wifi",Vi);const Yi=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ki=J("x",Yi);function Kr({isOpen:t,title:e,content:r,onConfirm:n,onCancel:o,confirmText:s="确认",cancelText:a="取消"}){return t?i.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:i.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:d=>d.stopPropagation(),children:[i.jsxs("div",{className:"p-6",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:e}),i.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm leading-relaxed whitespace-pre-wrap",children:r})]}),i.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 px-6 py-4 flex justify-end gap-3",children:[i.jsx("button",{onClick:d=>{d.stopPropagation(),o()},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:a}),i.jsx("button",{onClick:d=>{d.stopPropagation(),n()},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 Qi({id:t,model:e,status:r,connectionType:n,isInitialized:o,isActive:s,onClick:a,onConnectWifi:d,onDisconnectWifi:c}){const u=dt(),l=r==="device",f=n==="usb",p=n==="remote",[m,x]=h.useState(!1),[g,v]=h.useState(!1),[y,S]=h.useState(!1),_=T=>{T.stopPropagation(),!(m||!d)&&v(!0)},b=T=>{T.stopPropagation(),!(m||!c)&&S(!0)},C=async()=>{v(!1),x(!0);try{d&&await d()}finally{x(!1)}},R=async()=>{S(!1),x(!0);try{c&&await c()}finally{x(!1)}};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{onClick:a,role:"button",tabIndex:0,onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&a()},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&&i.jsx("div",{className:"absolute left-0 top-2 bottom-2 w-1 bg-[#1d9bf0] rounded-r"}),i.jsxs("div",{className:"flex items-center gap-3 pl-2",children:[i.jsx("div",{className:`relative flex-shrink-0 ${l?"status-online":"status-offline"} w-3 h-3 rounded-full transition-all ${s?"scale-110":""}`}),i.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-0.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(bt,{className:`w-4 h-4 ${s?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),i.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||u.deviceCard.unknownDevice})]}),i.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})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[f&&d&&i.jsx(te,{variant:"ghost",size:"icon",onClick:_,disabled:m,className:`h-8 w-8 rounded-full ${s?"bg-[#1d9bf0]/10 text-[#1d9bf0] hover:bg-[#1d9bf0]/20":"text-slate-400 dark:text-slate-500 hover:text-[#1d9bf0] dark:hover:text-[#1d9bf0] hover:bg-slate-100 dark:hover:bg-slate-800"}`,title:u.deviceCard.connectViaWifi,children:m?i.jsx(We,{className:"w-4 h-4 animate-spin"}):i.jsx(dr,{className:"w-4 h-4"})}),p&&c&&i.jsx(te,{variant:"ghost",size:"icon",onClick:b,disabled:m,className:`h-8 w-8 rounded-full ${s?"bg-red-500/10 text-red-500 hover:bg-red-500/20":"text-slate-400 dark:text-slate-500 hover:text-red-500 dark:hover:text-red-500 hover:bg-slate-100 dark:hover:bg-slate-800"}`,title:u.deviceCard.disconnectWifi,children:m?i.jsx(We,{className:"w-4 h-4 animate-spin"}):i.jsx(Xi,{className:"w-4 h-4"})}),o&&i.jsxs(lt,{variant:"success",className:`text-xs ${s?"bg-green-500/10 text-green-600 dark:text-green-400":""}`,children:[i.jsx(Je,{className:"w-3 h-3 mr-1"}),u.deviceCard.ready]})]})]})]}),i.jsx(Kr,{isOpen:g,title:u.deviceCard.connectWifiTitle,content:u.deviceCard.connectWifiContent,onConfirm:C,onCancel:()=>v(!1)}),i.jsx(Kr,{isOpen:y,title:u.deviceCard.disconnectWifiTitle,content:u.deviceCard.disconnectWifiContent,onConfirm:R,onCancel:()=>S(!1)})]})}var qt="focusScope.autoFocusOnMount",Xt="focusScope.autoFocusOnUnmount",Qr={bubbles:!1,cancelable:!0},Ji="FocusScope",wr=h.forwardRef((t,e)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=t,[d,c]=h.useState(null),u=Pe(o),l=Pe(s),f=h.useRef(null),p=_e(e,g=>c(g)),m=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(n){let g=function(_){if(m.paused||!d)return;const b=_.target;d.contains(b)?f.current=b:Fe(f.current,{select:!0})},v=function(_){if(m.paused||!d)return;const b=_.relatedTarget;b!==null&&(d.contains(b)||Fe(f.current,{select:!0}))},y=function(_){if(document.activeElement===document.body)for(const C of _)C.removedNodes.length>0&&Fe(d)};document.addEventListener("focusin",g),document.addEventListener("focusout",v);const S=new MutationObserver(y);return d&&S.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",v),S.disconnect()}}},[n,d,m.paused]),h.useEffect(()=>{if(d){Zr.add(m);const g=document.activeElement;if(!d.contains(g)){const y=new CustomEvent(qt,Qr);d.addEventListener(qt,u),d.dispatchEvent(y),y.defaultPrevented||(Zi(sa(Hn(d)),{select:!0}),document.activeElement===g&&Fe(d))}return()=>{d.removeEventListener(qt,u),setTimeout(()=>{const y=new CustomEvent(Xt,Qr);d.addEventListener(Xt,l),d.dispatchEvent(y),y.defaultPrevented||Fe(g??document.body,{select:!0}),d.removeEventListener(Xt,l),Zr.remove(m)},0)}}},[d,u,l,m]);const x=h.useCallback(g=>{if(!r&&!n||m.paused)return;const v=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(v&&y){const S=g.currentTarget,[_,b]=ea(S);_&&b?!g.shiftKey&&y===b?(g.preventDefault(),r&&Fe(_,{select:!0})):g.shiftKey&&y===_&&(g.preventDefault(),r&&Fe(b,{select:!0})):y===S&&g.preventDefault()}},[r,n,m.paused]);return i.jsx(le.div,{tabIndex:-1,...a,ref:p,onKeyDown:x})});wr.displayName=Ji;function Zi(t,{select:e=!1}={}){const r=document.activeElement;for(const n of t)if(Fe(n,{select:e}),document.activeElement!==r)return}function ea(t){const e=Hn(t),r=Jr(e,t),n=Jr(e.reverse(),t);return[r,n]}function Hn(t){const e=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const o=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||o?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)e.push(r.currentNode);return e}function Jr(t,e){for(const r of t)if(!ta(r,{upTo:e}))return r}function ta(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 ra(t){return t instanceof HTMLInputElement&&"select"in t}function Fe(t,{select:e=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&ra(t)&&e&&t.select()}}var Zr=na();function na(){let t=[];return{add(e){const r=t[0];e!==r&&r?.pause(),t=en(t,e),t.unshift(e)},remove(e){t=en(t,e),t[0]?.resume()}}}function en(t,e){const r=[...t],n=r.indexOf(e);return n!==-1&&r.splice(n,1),r}function sa(t){return t.filter(e=>e.tagName!=="A")}var Vt=0;function zn(){h.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??tn()),document.body.insertAdjacentElement("beforeend",t[1]??tn()),Vt++,()=>{Vt===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Vt--}},[])}function tn(){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 Ae=function(){return Ae=Object.assign||function(e){for(var r,n=1,o=arguments.length;n<o;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Ae.apply(this,arguments)};function Wn(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r}function oa(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,s;n<o;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))}var yt="right-scroll-bar-position",wt="width-before-scroll-bar",ia="with-scroll-bars-hidden",aa="--removed-body-scroll-bar-size";function Yt(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function ca(t,e){var r=h.useState(function(){return{value:t,callback:e,facade:{get current(){return r.value},set current(n){var o=r.value;o!==n&&(r.value=n,r.callback(n,o))}}}})[0];return r.callback=e,r.facade}var la=typeof window<"u"?h.useLayoutEffect:h.useEffect,rn=new WeakMap;function ua(t,e){var r=ca(null,function(n){return t.forEach(function(o){return Yt(o,n)})});return la(function(){var n=rn.get(r);if(n){var o=new Set(n),s=new Set(t),a=r.current;o.forEach(function(d){s.has(d)||Yt(d,null)}),s.forEach(function(d){o.has(d)||Yt(d,a)})}rn.set(r,t)},[t]),r}function da(t){return t}function fa(t,e){e===void 0&&(e=da);var r=[],n=!1,o={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:t},useMedium:function(s){var a=e(s,n);return r.push(a),function(){r=r.filter(function(d){return d!==a})}},assignSyncMedium:function(s){for(n=!0;r.length;){var a=r;r=[],a.forEach(s)}r={push:function(d){return s(d)},filter:function(){return r}}},assignMedium:function(s){n=!0;var a=[];if(r.length){var d=r;r=[],d.forEach(s),a=r}var c=function(){var l=a;a=[],l.forEach(s)},u=function(){return Promise.resolve().then(c)};u(),r={push:function(l){a.push(l),u()},filter:function(l){return a=a.filter(l),r}}}};return o}function ha(t){t===void 0&&(t={});var e=fa(null);return e.options=Ae({async:!0,ssr:!1},t),e}var $n=function(t){var e=t.sideCar,r=Wn(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=e.read();if(!n)throw new Error("Sidecar medium not found");return h.createElement(n,Ae({},r))};$n.isSideCarExport=!0;function pa(t,e){return t.useMedium(e),$n}var qn=ha(),Kt=function(){},It=h.forwardRef(function(t,e){var r=h.useRef(null),n=h.useState({onScrollCapture:Kt,onWheelCapture:Kt,onTouchMoveCapture:Kt}),o=n[0],s=n[1],a=t.forwardProps,d=t.children,c=t.className,u=t.removeScrollBar,l=t.enabled,f=t.shards,p=t.sideCar,m=t.noRelative,x=t.noIsolation,g=t.inert,v=t.allowPinchZoom,y=t.as,S=y===void 0?"div":y,_=t.gapMode,b=Wn(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=p,R=ua([r,e]),T=Ae(Ae({},b),o);return h.createElement(h.Fragment,null,l&&h.createElement(C,{sideCar:qn,removeScrollBar:u,shards:f,noRelative:m,noIsolation:x,inert:g,setCallbacks:s,allowPinchZoom:!!v,lockRef:r,gapMode:_}),a?h.cloneElement(h.Children.only(d),Ae(Ae({},T),{ref:R})):h.createElement(S,Ae({},T,{className:c,ref:R}),d))});It.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};It.classNames={fullWidth:wt,zeroRight:yt};var ma=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ga(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=ma();return e&&t.setAttribute("nonce",e),t}function _a(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function xa(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var va=function(){var t=0,e=null;return{add:function(r){t==0&&(e=ga())&&(_a(e,r),xa(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},ba=function(){var t=va();return function(e,r){h.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&r])}},Xn=function(){var t=ba(),e=function(r){var n=r.styles,o=r.dynamic;return t(n,o),null};return e},ya={left:0,top:0,right:0,gap:0},Qt=function(t){return parseInt(t||"",10)||0},wa=function(t){var e=window.getComputedStyle(document.body),r=e[t==="padding"?"paddingLeft":"marginLeft"],n=e[t==="padding"?"paddingTop":"marginTop"],o=e[t==="padding"?"paddingRight":"marginRight"];return[Qt(r),Qt(n),Qt(o)]},Ea=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return ya;var e=wa(t),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,n-r+e[2]-e[0])}},Sa=Xn(),Ze="data-scroll-locked",Ca=function(t,e,r,n){var o=t.left,s=t.top,a=t.right,d=t.gap;return r===void 0&&(r="margin"),`
|
|
6
|
+
.`.concat(ia,` {
|
|
7
|
+
overflow: hidden `).concat(n,`;
|
|
8
|
+
padding-right: `).concat(d,"px ").concat(n,`;
|
|
9
|
+
}
|
|
10
|
+
body[`).concat(Ze,`] {
|
|
11
|
+
overflow: hidden `).concat(n,`;
|
|
12
|
+
overscroll-behavior: contain;
|
|
13
|
+
`).concat([e&&"position: relative ".concat(n,";"),r==="margin"&&`
|
|
14
|
+
padding-left: `.concat(o,`px;
|
|
15
|
+
padding-top: `).concat(s,`px;
|
|
16
|
+
padding-right: `).concat(a,`px;
|
|
17
|
+
margin-left:0;
|
|
18
|
+
margin-top:0;
|
|
19
|
+
margin-right: `).concat(d,"px ").concat(n,`;
|
|
20
|
+
`),r==="padding"&&"padding-right: ".concat(d,"px ").concat(n,";")].filter(Boolean).join(""),`
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.`).concat(yt,` {
|
|
24
|
+
right: `).concat(d,"px ").concat(n,`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.`).concat(wt,` {
|
|
28
|
+
margin-right: `).concat(d,"px ").concat(n,`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.`).concat(yt," .").concat(yt,` {
|
|
32
|
+
right: 0 `).concat(n,`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.`).concat(wt," .").concat(wt,` {
|
|
36
|
+
margin-right: 0 `).concat(n,`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
body[`).concat(Ze,`] {
|
|
40
|
+
`).concat(aa,": ").concat(d,`px;
|
|
41
|
+
}
|
|
42
|
+
`)},nn=function(){var t=parseInt(document.body.getAttribute(Ze)||"0",10);return isFinite(t)?t:0},Na=function(){h.useEffect(function(){return document.body.setAttribute(Ze,(nn()+1).toString()),function(){var t=nn()-1;t<=0?document.body.removeAttribute(Ze):document.body.setAttribute(Ze,t.toString())}},[])},Ta=function(t){var e=t.noRelative,r=t.noImportant,n=t.gapMode,o=n===void 0?"margin":n;Na();var s=h.useMemo(function(){return Ea(o)},[o]);return h.createElement(Sa,{styles:Ca(s,!e,o,r?"":"!important")})},fr=!1;if(typeof window<"u")try{var pt=Object.defineProperty({},"passive",{get:function(){return fr=!0,!0}});window.addEventListener("test",pt,pt),window.removeEventListener("test",pt,pt)}catch{fr=!1}var Xe=fr?{passive:!1}:!1,Ra=function(t){return t.tagName==="TEXTAREA"},Vn=function(t,e){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[e]!=="hidden"&&!(r.overflowY===r.overflowX&&!Ra(t)&&r[e]==="visible")},ka=function(t){return Vn(t,"overflowY")},Pa=function(t){return Vn(t,"overflowX")},sn=function(t,e){var r=e.ownerDocument,n=e;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var o=Yn(t,n);if(o){var s=Kn(t,n),a=s[1],d=s[2];if(a>d)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},Aa=function(t){var e=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[e,r,n]},ja=function(t){var e=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[e,r,n]},Yn=function(t,e){return t==="v"?ka(e):Pa(e)},Kn=function(t,e){return t==="v"?Aa(e):ja(e)},Da=function(t,e){return t==="h"&&e==="rtl"?-1:1},Ma=function(t,e,r,n,o){var s=Da(t,window.getComputedStyle(e).direction),a=s*n,d=r.target,c=e.contains(d),u=!1,l=a>0,f=0,p=0;do{if(!d)break;var m=Kn(t,d),x=m[0],g=m[1],v=m[2],y=g-v-s*x;(x||y)&&Yn(t,d)&&(f+=y,p+=x);var S=d.parentNode;d=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!c&&d!==document.body||c&&(e.contains(d)||e===d));return(l&&Math.abs(f)<1||!l&&Math.abs(p)<1)&&(u=!0),u},mt=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},on=function(t){return[t.deltaX,t.deltaY]},an=function(t){return t&&"current"in t?t.current:t},Ia=function(t,e){return t[0]===e[0]&&t[1]===e[1]},La=function(t){return`
|
|
43
|
+
.block-interactivity-`.concat(t,` {pointer-events: none;}
|
|
44
|
+
.allow-interactivity-`).concat(t,` {pointer-events: all;}
|
|
45
|
+
`)},Oa=0,Ve=[];function Fa(t){var e=h.useRef([]),r=h.useRef([0,0]),n=h.useRef(),o=h.useState(Oa++)[0],s=h.useState(Xn)[0],a=h.useRef(t);h.useEffect(function(){a.current=t},[t]),h.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var g=oa([t.lockRef.current],(t.shards||[]).map(an),!0).filter(Boolean);return g.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var d=h.useCallback(function(g,v){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!a.current.allowPinchZoom;var y=mt(g),S=r.current,_="deltaX"in g?g.deltaX:S[0]-y[0],b="deltaY"in g?g.deltaY:S[1]-y[1],C,R=g.target,T=Math.abs(_)>Math.abs(b)?"h":"v";if("touches"in g&&T==="h"&&R.type==="range")return!1;var A=window.getSelection(),E=A&&A.anchorNode,j=E?E===R||E.contains(R):!1;if(j)return!1;var N=sn(T,R);if(!N)return!0;if(N?C=T:(C=T==="v"?"h":"v",N=sn(T,R)),!N)return!1;if(!n.current&&"changedTouches"in g&&(_||b)&&(n.current=C),!C)return!0;var G=n.current||C;return Ma(G,v,g,G==="h"?_:b)},[]),c=h.useCallback(function(g){var v=g;if(!(!Ve.length||Ve[Ve.length-1]!==s)){var y="deltaY"in v?on(v):mt(v),S=e.current.filter(function(C){return C.name===v.type&&(C.target===v.target||v.target===C.shadowParent)&&Ia(C.delta,y)})[0];if(S&&S.should){v.cancelable&&v.preventDefault();return}if(!S){var _=(a.current.shards||[]).map(an).filter(Boolean).filter(function(C){return C.contains(v.target)}),b=_.length>0?d(v,_[0]):!a.current.noIsolation;b&&v.cancelable&&v.preventDefault()}}},[]),u=h.useCallback(function(g,v,y,S){var _={name:g,delta:v,target:y,should:S,shadowParent:Ba(y)};e.current.push(_),setTimeout(function(){e.current=e.current.filter(function(b){return b!==_})},1)},[]),l=h.useCallback(function(g){r.current=mt(g),n.current=void 0},[]),f=h.useCallback(function(g){u(g.type,on(g),g.target,d(g,t.lockRef.current))},[]),p=h.useCallback(function(g){u(g.type,mt(g),g.target,d(g,t.lockRef.current))},[]);h.useEffect(function(){return Ve.push(s),t.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",c,Xe),document.addEventListener("touchmove",c,Xe),document.addEventListener("touchstart",l,Xe),function(){Ve=Ve.filter(function(g){return g!==s}),document.removeEventListener("wheel",c,Xe),document.removeEventListener("touchmove",c,Xe),document.removeEventListener("touchstart",l,Xe)}},[]);var m=t.removeScrollBar,x=t.inert;return h.createElement(h.Fragment,null,x?h.createElement(s,{styles:La(o)}):null,m?h.createElement(Ta,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function Ba(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const Ua=pa(qn,Fa);var Er=h.forwardRef(function(t,e){return h.createElement(It,Ae({},t,{ref:e,sideCar:Ua}))});Er.classNames=It.classNames;var Ga=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Ye=new WeakMap,gt=new WeakMap,_t={},Jt=0,Qn=function(t){return t&&(t.host||Qn(t.parentNode))},Ha=function(t,e){return e.map(function(r){if(t.contains(r))return r;var n=Qn(r);return n&&t.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",t,". Doing nothing"),null)}).filter(function(r){return!!r})},za=function(t,e,r,n){var o=Ha(e,Array.isArray(t)?t:[t]);_t[r]||(_t[r]=new WeakMap);var s=_t[r],a=[],d=new Set,c=new Set(o),u=function(f){!f||d.has(f)||(d.add(f),u(f.parentNode))};o.forEach(u);var l=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(p){if(d.has(p))l(p);else try{var m=p.getAttribute(n),x=m!==null&&m!=="false",g=(Ye.get(p)||0)+1,v=(s.get(p)||0)+1;Ye.set(p,g),s.set(p,v),a.push(p),g===1&&x&>.set(p,!0),v===1&&p.setAttribute(r,"true"),x||p.setAttribute(n,"true")}catch(y){console.error("aria-hidden: cannot operate on ",p,y)}})};return l(e),d.clear(),Jt++,function(){a.forEach(function(f){var p=Ye.get(f)-1,m=s.get(f)-1;Ye.set(f,p),s.set(f,m),p||(gt.has(f)||f.removeAttribute(n),gt.delete(f)),m||f.removeAttribute(r)}),Jt--,Jt||(Ye=new WeakMap,Ye=new WeakMap,gt=new WeakMap,_t={})}},Jn=function(t,e,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),o=Ga(t);return o?(n.push.apply(n,Array.from(o.querySelectorAll("[aria-live], script"))),za(n,o,r,"aria-hidden")):function(){return null}},Lt="Dialog",[Zn]=rt(Lt),[Wa,Te]=Zn(Lt),es=t=>{const{__scopeDialog:e,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:a=!0}=t,d=h.useRef(null),c=h.useRef(null),[u,l]=Mt({prop:n,defaultProp:o??!1,onChange:s,caller:Lt});return i.jsx(Wa,{scope:e,triggerRef:d,contentRef:c,contentId:Qe(),titleId:Qe(),descriptionId:Qe(),open:u,onOpenChange:l,onOpenToggle:h.useCallback(()=>l(f=>!f),[l]),modal:a,children:r})};es.displayName=Lt;var ts="DialogTrigger",$a=h.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,o=Te(ts,r),s=_e(e,o.triggerRef);return i.jsx(le.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Nr(o.open),...n,ref:s,onClick:se(t.onClick,o.onOpenToggle)})});$a.displayName=ts;var Sr="DialogPortal",[qa,rs]=Zn(Sr,{forceMount:void 0}),ns=t=>{const{__scopeDialog:e,forceMount:r,children:n,container:o}=t,s=Te(Sr,e);return i.jsx(qa,{scope:e,forceMount:r,children:h.Children.map(n,a=>i.jsx(Me,{present:r||s.open,children:i.jsx(Mn,{asChild:!0,container:o,children:a})}))})};ns.displayName=Sr;var kt="DialogOverlay",ss=h.forwardRef((t,e)=>{const r=rs(kt,t.__scopeDialog),{forceMount:n=r.forceMount,...o}=t,s=Te(kt,t.__scopeDialog);return s.modal?i.jsx(Me,{present:n||s.open,children:i.jsx(Va,{...o,ref:e})}):null});ss.displayName=kt;var Xa=Rt("DialogOverlay.RemoveScroll"),Va=h.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,o=Te(kt,r);return i.jsx(Er,{as:Xa,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(le.div,{"data-state":Nr(o.open),...n,ref:e,style:{pointerEvents:"auto",...n.style}})})}),$e="DialogContent",os=h.forwardRef((t,e)=>{const r=rs($e,t.__scopeDialog),{forceMount:n=r.forceMount,...o}=t,s=Te($e,t.__scopeDialog);return i.jsx(Me,{present:n||s.open,children:s.modal?i.jsx(Ya,{...o,ref:e}):i.jsx(Ka,{...o,ref:e})})});os.displayName=$e;var Ya=h.forwardRef((t,e)=>{const r=Te($e,t.__scopeDialog),n=h.useRef(null),o=_e(e,r.contentRef,n);return h.useEffect(()=>{const s=n.current;if(s)return Jn(s)},[]),i.jsx(is,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:se(t.onCloseAutoFocus,s=>{s.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:se(t.onPointerDownOutside,s=>{const a=s.detail.originalEvent,d=a.button===0&&a.ctrlKey===!0;(a.button===2||d)&&s.preventDefault()}),onFocusOutside:se(t.onFocusOutside,s=>s.preventDefault())})}),Ka=h.forwardRef((t,e)=>{const r=Te($e,t.__scopeDialog),n=h.useRef(!1),o=h.useRef(!1);return i.jsx(is,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{t.onCloseAutoFocus?.(s),s.defaultPrevented||(n.current||r.triggerRef.current?.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{t.onInteractOutside?.(s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=s.target;r.triggerRef.current?.contains(a)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),is=h.forwardRef((t,e)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,...a}=t,d=Te($e,r),c=h.useRef(null),u=_e(e,c);return zn(),i.jsxs(i.Fragment,{children:[i.jsx(wr,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:i.jsx(In,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":Nr(d.open),...a,ref:u,onDismiss:()=>d.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(Qa,{titleId:d.titleId}),i.jsx(Za,{contentRef:c,descriptionId:d.descriptionId})]})]})}),Cr="DialogTitle",as=h.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,o=Te(Cr,r);return i.jsx(le.h2,{id:o.titleId,...n,ref:e})});as.displayName=Cr;var cs="DialogDescription",ls=h.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,o=Te(cs,r);return i.jsx(le.p,{id:o.descriptionId,...n,ref:e})});ls.displayName=cs;var us="DialogClose",ds=h.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,o=Te(us,r);return i.jsx(le.button,{type:"button",...n,ref:e,onClick:se(t.onClick,()=>o.onOpenChange(!1))})});ds.displayName=us;function Nr(t){return t?"open":"closed"}var fs="DialogTitleWarning",[fd,hs]=Uo(fs,{contentName:$e,titleName:Cr,docsSlug:"dialog"}),Qa=({titleId:t})=>{const e=hs(fs),r=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
46
|
+
|
|
47
|
+
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
48
|
+
|
|
49
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return h.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},Ja="DialogDescriptionWarning",Za=({contentRef:t,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${hs(Ja).contentName}}.`;return h.useEffect(()=>{const o=t.current?.getAttribute("aria-describedby");e&&o&&(document.getElementById(e)||console.warn(n))},[n,t,e]),null},ec=es,tc=ns,ps=ss,ms=os,gs=as,_s=ls,rc=ds;const xs=ec,nc=tc,vs=h.forwardRef(({className:t,...e},r)=>i.jsx(ps,{ref:r,className:ae("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}));vs.displayName=ps.displayName;const Tr=h.forwardRef(({className:t,children:e,...r},n)=>i.jsxs(nc,{children:[i.jsx(vs,{}),i.jsxs(ms,{ref:n,className:ae("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),...r,children:[e,i.jsxs(rc,{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:[i.jsx(Ki,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Tr.displayName=ms.displayName;const Rr=({className:t,...e})=>i.jsx("div",{className:ae("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});Rr.displayName="DialogHeader";const kr=({className:t,...e})=>i.jsx("div",{className:ae("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});kr.displayName="DialogFooter";const Pr=h.forwardRef(({className:t,...e},r)=>i.jsx(gs,{ref:r,className:ae("text-lg font-semibold leading-none tracking-tight",t),...e}));Pr.displayName=gs.displayName;const Ar=h.forwardRef(({className:t,...e},r)=>i.jsx(_s,{ref:r,className:ae("text-sm text-slate-500 dark:text-slate-400",t),...e}));Ar.displayName=_s.displayName;function sc(t){const e=t+"CollectionProvider",[r,n]=rt(e),[o,s]=r(e,{collectionRef:{current:null},itemMap:new Map}),a=g=>{const{scope:v,children:y}=g,S=ne.useRef(null),_=ne.useRef(new Map).current;return i.jsx(o,{scope:v,itemMap:_,collectionRef:S,children:y})};a.displayName=e;const d=t+"CollectionSlot",c=Rt(d),u=ne.forwardRef((g,v)=>{const{scope:y,children:S}=g,_=s(d,y),b=_e(v,_.collectionRef);return i.jsx(c,{ref:b,children:S})});u.displayName=d;const l=t+"CollectionItemSlot",f="data-radix-collection-item",p=Rt(l),m=ne.forwardRef((g,v)=>{const{scope:y,children:S,..._}=g,b=ne.useRef(null),C=_e(v,b),R=s(l,y);return ne.useEffect(()=>(R.itemMap.set(b,{ref:b,..._}),()=>void R.itemMap.delete(b))),i.jsx(p,{[f]:"",ref:C,children:S})});m.displayName=l;function x(g){const v=s(t+"CollectionConsumer",g);return ne.useCallback(()=>{const S=v.collectionRef.current;if(!S)return[];const _=Array.from(S.querySelectorAll(`[${f}]`));return Array.from(v.itemMap.values()).sort((R,T)=>_.indexOf(R.ref.current)-_.indexOf(T.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:a,Slot:u,ItemSlot:m},x,n]}var oc=h.createContext(void 0);function jr(t){const e=h.useContext(oc);return t||e||"ltr"}var Zt="rovingFocusGroup.onEntryFocus",ic={bubbles:!1,cancelable:!0},ft="RovingFocusGroup",[hr,bs,ac]=sc(ft),[cc,ys]=rt(ft,[ac]),[lc,uc]=cc(ft),ws=h.forwardRef((t,e)=>i.jsx(hr.Provider,{scope:t.__scopeRovingFocusGroup,children:i.jsx(hr.Slot,{scope:t.__scopeRovingFocusGroup,children:i.jsx(dc,{...t,ref:e})})}));ws.displayName=ft;var dc=h.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:d,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:l=!1,...f}=t,p=h.useRef(null),m=_e(e,p),x=jr(s),[g,v]=Mt({prop:a,defaultProp:d??null,onChange:c,caller:ft}),[y,S]=h.useState(!1),_=Pe(u),b=bs(r),C=h.useRef(!1),[R,T]=h.useState(0);return h.useEffect(()=>{const A=p.current;if(A)return A.addEventListener(Zt,_),()=>A.removeEventListener(Zt,_)},[_]),i.jsx(lc,{scope:r,orientation:n,dir:x,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(A=>v(A),[v]),onItemShiftTab:h.useCallback(()=>S(!0),[]),onFocusableItemAdd:h.useCallback(()=>T(A=>A+1),[]),onFocusableItemRemove:h.useCallback(()=>T(A=>A-1),[]),children:i.jsx(le.div,{tabIndex:y||R===0?-1:0,"data-orientation":n,...f,ref:m,style:{outline:"none",...t.style},onMouseDown:se(t.onMouseDown,()=>{C.current=!0}),onFocus:se(t.onFocus,A=>{const E=!C.current;if(A.target===A.currentTarget&&E&&!y){const j=new CustomEvent(Zt,ic);if(A.currentTarget.dispatchEvent(j),!j.defaultPrevented){const N=b().filter(M=>M.focusable),G=N.find(M=>M.active),z=N.find(M=>M.id===g),D=[G,z,...N].filter(Boolean).map(M=>M.ref.current);Cs(D,l)}}C.current=!1}),onBlur:se(t.onBlur,()=>S(!1))})})}),Es="RovingFocusGroupItem",Ss=h.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:s,children:a,...d}=t,c=Qe(),u=s||c,l=uc(Es,r),f=l.currentTabStopId===u,p=bs(r),{onFocusableItemAdd:m,onFocusableItemRemove:x,currentTabStopId:g}=l;return h.useEffect(()=>{if(n)return m(),()=>x()},[n,m,x]),i.jsx(hr.ItemSlot,{scope:r,id:u,focusable:n,active:o,children:i.jsx(le.span,{tabIndex:f?0:-1,"data-orientation":l.orientation,...d,ref:e,onMouseDown:se(t.onMouseDown,v=>{n?l.onItemFocus(u):v.preventDefault()}),onFocus:se(t.onFocus,()=>l.onItemFocus(u)),onKeyDown:se(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){l.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const y=pc(v,l.orientation,l.dir);if(y!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let _=p().filter(b=>b.focusable).map(b=>b.ref.current);if(y==="last")_.reverse();else if(y==="prev"||y==="next"){y==="prev"&&_.reverse();const b=_.indexOf(v.currentTarget);_=l.loop?mc(_,b+1):_.slice(b+1)}setTimeout(()=>Cs(_))}}),children:typeof a=="function"?a({isCurrentTabStop:f,hasTabStop:g!=null}):a})})});Ss.displayName=Es;var fc={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function hc(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function pc(t,e,r){const n=hc(t.key,r);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return fc[n]}function Cs(t,e=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:e}),document.activeElement!==r))return}function mc(t,e){return t.map((r,n)=>t[(e+n)%t.length])}var gc=ws,_c=Ss,Ot="Tabs",[xc]=rt(Ot,[ys]),Ns=ys(),[vc,Dr]=xc(Ot),Ts=h.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,onValueChange:o,defaultValue:s,orientation:a="horizontal",dir:d,activationMode:c="automatic",...u}=t,l=jr(d),[f,p]=Mt({prop:n,onChange:o,defaultProp:s??"",caller:Ot});return i.jsx(vc,{scope:r,baseId:Qe(),value:f,onValueChange:p,orientation:a,dir:l,activationMode:c,children:i.jsx(le.div,{dir:l,"data-orientation":a,...u,ref:e})})});Ts.displayName=Ot;var Rs="TabsList",ks=h.forwardRef((t,e)=>{const{__scopeTabs:r,loop:n=!0,...o}=t,s=Dr(Rs,r),a=Ns(r);return i.jsx(gc,{asChild:!0,...a,orientation:s.orientation,dir:s.dir,loop:n,children:i.jsx(le.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:e})})});ks.displayName=Rs;var Ps="TabsTrigger",As=h.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,disabled:o=!1,...s}=t,a=Dr(Ps,r),d=Ns(r),c=Ms(a.baseId,n),u=Is(a.baseId,n),l=n===a.value;return i.jsx(_c,{asChild:!0,...d,focusable:!o,active:l,children:i.jsx(le.button,{type:"button",role:"tab","aria-selected":l,"aria-controls":u,"data-state":l?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...s,ref:e,onMouseDown:se(t.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?a.onValueChange(n):f.preventDefault()}),onKeyDown:se(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&a.onValueChange(n)}),onFocus:se(t.onFocus,()=>{const f=a.activationMode!=="manual";!l&&!o&&f&&a.onValueChange(n)})})})});As.displayName=Ps;var js="TabsContent",Ds=h.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,forceMount:o,children:s,...a}=t,d=Dr(js,r),c=Ms(d.baseId,n),u=Is(d.baseId,n),l=n===d.value,f=h.useRef(l);return h.useEffect(()=>{const p=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(p)},[]),i.jsx(Me,{present:o||l,children:({present:p})=>i.jsx(le.div,{"data-state":l?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":c,hidden:!p,id:u,tabIndex:0,...a,ref:e,style:{...t.style,animationDuration:f.current?"0s":void 0},children:p&&s})})});Ds.displayName=js;function Ms(t,e){return`${t}-trigger-${e}`}function Is(t,e){return`${t}-content-${e}`}var bc=Ts,yc=ks,wc=As,Ec=Ds;function Sc({className:t,...e}){return i.jsx(bc,{"data-slot":"tabs",className:ae("flex flex-col gap-2",t),...e})}function Cc({className:t,...e}){return i.jsx(yc,{"data-slot":"tabs-list",className:ae("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",t),...e})}function cn({className:t,...e}){return i.jsx(wc,{"data-slot":"tabs-trigger",className:ae("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...e})}function ln({className:t,...e}){return i.jsx(Ec,{"data-slot":"tabs-content",className:ae("flex-1 outline-none",t),...e})}function Oe({className:t,type:e,...r}){return i.jsx("input",{type:e,"data-slot":"input",className:ae("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...r})}var Nc="Label",Ls=h.forwardRef((t,e)=>i.jsx(Go.label,{...t,ref:e,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(t.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));Ls.displayName=Nc;var Os=Ls;const Ne=h.forwardRef(({className:t,...e},r)=>i.jsx(Os,{ref:r,className:ae("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 text-slate-900 dark:text-slate-100",t),...e}));Ne.displayName=Os.displayName;var Tc=Object.defineProperty,Pt=Object.getOwnPropertySymbols,Fs=Object.prototype.hasOwnProperty,Bs=Object.prototype.propertyIsEnumerable,un=(t,e,r)=>e in t?Tc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,pr=(t,e)=>{for(var r in e||(e={}))Fs.call(e,r)&&un(t,r,e[r]);if(Pt)for(var r of Pt(e))Bs.call(e,r)&&un(t,r,e[r]);return t},mr=(t,e)=>{var r={};for(var n in t)Fs.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Pt)for(var n of Pt(t))e.indexOf(n)<0&&Bs.call(t,n)&&(r[n]=t[n]);return r};var qe;(t=>{const e=class ${constructor(c,u,l,f){if(this.version=c,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],c<$.MIN_VERSION||c>$.MAX_VERSION)throw new RangeError("Version value out of range");if(f<-1||f>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let p=[];for(let x=0;x<this.size;x++)p.push(!1);for(let x=0;x<this.size;x++)this.modules.push(p.slice()),this.isFunction.push(p.slice());this.drawFunctionPatterns();const m=this.addEccAndInterleave(l);if(this.drawCodewords(m),f==-1){let x=1e9;for(let g=0;g<8;g++){this.applyMask(g),this.drawFormatBits(g);const v=this.getPenaltyScore();v<x&&(f=g,x=v),this.applyMask(g)}}o(0<=f&&f<=7),this.mask=f,this.applyMask(f),this.drawFormatBits(f),this.isFunction=[]}static encodeText(c,u){const l=t.QrSegment.makeSegments(c);return $.encodeSegments(l,u)}static encodeBinary(c,u){const l=t.QrSegment.makeBytes(c);return $.encodeSegments([l],u)}static encodeSegments(c,u,l=1,f=40,p=-1,m=!0){if(!($.MIN_VERSION<=l&&l<=f&&f<=$.MAX_VERSION)||p<-1||p>7)throw new RangeError("Invalid value");let x,g;for(x=l;;x++){const _=$.getNumDataCodewords(x,u)*8,b=a.getTotalBits(c,x);if(b<=_){g=b;break}if(x>=f)throw new RangeError("Data too long")}for(const _ of[$.Ecc.MEDIUM,$.Ecc.QUARTILE,$.Ecc.HIGH])m&&g<=$.getNumDataCodewords(x,_)*8&&(u=_);let v=[];for(const _ of c){r(_.mode.modeBits,4,v),r(_.numChars,_.mode.numCharCountBits(x),v);for(const b of _.getData())v.push(b)}o(v.length==g);const y=$.getNumDataCodewords(x,u)*8;o(v.length<=y),r(0,Math.min(4,y-v.length),v),r(0,(8-v.length%8)%8,v),o(v.length%8==0);for(let _=236;v.length<y;_^=253)r(_,8,v);let S=[];for(;S.length*8<v.length;)S.push(0);return v.forEach((_,b)=>S[b>>>3]|=_<<7-(b&7)),new $(x,u,S,p)}getModule(c,u){return 0<=c&&c<this.size&&0<=u&&u<this.size&&this.modules[u][c]}getModules(){return this.modules}drawFunctionPatterns(){for(let l=0;l<this.size;l++)this.setFunctionModule(6,l,l%2==0),this.setFunctionModule(l,6,l%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const c=this.getAlignmentPatternPositions(),u=c.length;for(let l=0;l<u;l++)for(let f=0;f<u;f++)l==0&&f==0||l==0&&f==u-1||l==u-1&&f==0||this.drawAlignmentPattern(c[l],c[f]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const u=this.errorCorrectionLevel.formatBits<<3|c;let l=u;for(let p=0;p<10;p++)l=l<<1^(l>>>9)*1335;const f=(u<<10|l)^21522;o(f>>>15==0);for(let p=0;p<=5;p++)this.setFunctionModule(8,p,n(f,p));this.setFunctionModule(8,7,n(f,6)),this.setFunctionModule(8,8,n(f,7)),this.setFunctionModule(7,8,n(f,8));for(let p=9;p<15;p++)this.setFunctionModule(14-p,8,n(f,p));for(let p=0;p<8;p++)this.setFunctionModule(this.size-1-p,8,n(f,p));for(let p=8;p<15;p++)this.setFunctionModule(8,this.size-15+p,n(f,p));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let l=0;l<12;l++)c=c<<1^(c>>>11)*7973;const u=this.version<<12|c;o(u>>>18==0);for(let l=0;l<18;l++){const f=n(u,l),p=this.size-11+l%3,m=Math.floor(l/3);this.setFunctionModule(p,m,f),this.setFunctionModule(m,p,f)}}drawFinderPattern(c,u){for(let l=-4;l<=4;l++)for(let f=-4;f<=4;f++){const p=Math.max(Math.abs(f),Math.abs(l)),m=c+f,x=u+l;0<=m&&m<this.size&&0<=x&&x<this.size&&this.setFunctionModule(m,x,p!=2&&p!=4)}}drawAlignmentPattern(c,u){for(let l=-2;l<=2;l++)for(let f=-2;f<=2;f++)this.setFunctionModule(c+f,u+l,Math.max(Math.abs(f),Math.abs(l))!=1)}setFunctionModule(c,u,l){this.modules[u][c]=l,this.isFunction[u][c]=!0}addEccAndInterleave(c){const u=this.version,l=this.errorCorrectionLevel;if(c.length!=$.getNumDataCodewords(u,l))throw new RangeError("Invalid argument");const f=$.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][u],p=$.ECC_CODEWORDS_PER_BLOCK[l.ordinal][u],m=Math.floor($.getNumRawDataModules(u)/8),x=f-m%f,g=Math.floor(m/f);let v=[];const y=$.reedSolomonComputeDivisor(p);for(let _=0,b=0;_<f;_++){let C=c.slice(b,b+g-p+(_<x?0:1));b+=C.length;const R=$.reedSolomonComputeRemainder(C,y);_<x&&C.push(0),v.push(C.concat(R))}let S=[];for(let _=0;_<v[0].length;_++)v.forEach((b,C)=>{(_!=g-p||C>=x)&&S.push(b[_])});return o(S.length==m),S}drawCodewords(c){if(c.length!=Math.floor($.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let l=this.size-1;l>=1;l-=2){l==6&&(l=5);for(let f=0;f<this.size;f++)for(let p=0;p<2;p++){const m=l-p,g=(l+1&2)==0?this.size-1-f:f;!this.isFunction[g][m]&&u<c.length*8&&(this.modules[g][m]=n(c[u>>>3],7-(u&7)),u++)}}o(u==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let u=0;u<this.size;u++)for(let l=0;l<this.size;l++){let f;switch(c){case 0:f=(l+u)%2==0;break;case 1:f=u%2==0;break;case 2:f=l%3==0;break;case 3:f=(l+u)%3==0;break;case 4:f=(Math.floor(l/3)+Math.floor(u/2))%2==0;break;case 5:f=l*u%2+l*u%3==0;break;case 6:f=(l*u%2+l*u%3)%2==0;break;case 7:f=((l+u)%2+l*u%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[u][l]&&f&&(this.modules[u][l]=!this.modules[u][l])}}getPenaltyScore(){let c=0;for(let p=0;p<this.size;p++){let m=!1,x=0,g=[0,0,0,0,0,0,0];for(let v=0;v<this.size;v++)this.modules[p][v]==m?(x++,x==5?c+=$.PENALTY_N1:x>5&&c++):(this.finderPenaltyAddHistory(x,g),m||(c+=this.finderPenaltyCountPatterns(g)*$.PENALTY_N3),m=this.modules[p][v],x=1);c+=this.finderPenaltyTerminateAndCount(m,x,g)*$.PENALTY_N3}for(let p=0;p<this.size;p++){let m=!1,x=0,g=[0,0,0,0,0,0,0];for(let v=0;v<this.size;v++)this.modules[v][p]==m?(x++,x==5?c+=$.PENALTY_N1:x>5&&c++):(this.finderPenaltyAddHistory(x,g),m||(c+=this.finderPenaltyCountPatterns(g)*$.PENALTY_N3),m=this.modules[v][p],x=1);c+=this.finderPenaltyTerminateAndCount(m,x,g)*$.PENALTY_N3}for(let p=0;p<this.size-1;p++)for(let m=0;m<this.size-1;m++){const x=this.modules[p][m];x==this.modules[p][m+1]&&x==this.modules[p+1][m]&&x==this.modules[p+1][m+1]&&(c+=$.PENALTY_N2)}let u=0;for(const p of this.modules)u=p.reduce((m,x)=>m+(x?1:0),u);const l=this.size*this.size,f=Math.ceil(Math.abs(u*20-l*10)/l)-1;return o(0<=f&&f<=9),c+=f*$.PENALTY_N4,o(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let l=[6];for(let f=this.size-7;l.length<c;f-=u)l.splice(1,0,f);return l}}static getNumRawDataModules(c){if(c<$.MIN_VERSION||c>$.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*c+128)*c+64;if(c>=2){const l=Math.floor(c/7)+2;u-=(25*l-10)*l-55,c>=7&&(u-=36)}return o(208<=u&&u<=29648),u}static getNumDataCodewords(c,u){return Math.floor($.getNumRawDataModules(c)/8)-$.ECC_CODEWORDS_PER_BLOCK[u.ordinal][c]*$.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let u=[];for(let f=0;f<c-1;f++)u.push(0);u.push(1);let l=1;for(let f=0;f<c;f++){for(let p=0;p<u.length;p++)u[p]=$.reedSolomonMultiply(u[p],l),p+1<u.length&&(u[p]^=u[p+1]);l=$.reedSolomonMultiply(l,2)}return u}static reedSolomonComputeRemainder(c,u){let l=u.map(f=>0);for(const f of c){const p=f^l.shift();l.push(0),u.forEach((m,x)=>l[x]^=$.reedSolomonMultiply(m,p))}return l}static reedSolomonMultiply(c,u){if(c>>>8||u>>>8)throw new RangeError("Byte out of range");let l=0;for(let f=7;f>=0;f--)l=l<<1^(l>>>7)*285,l^=(u>>>f&1)*c;return o(l>>>8==0),l}finderPenaltyCountPatterns(c){const u=c[1];o(u<=this.size*3);const l=u>0&&c[2]==u&&c[3]==u*3&&c[4]==u&&c[5]==u;return(l&&c[0]>=u*4&&c[6]>=u?1:0)+(l&&c[6]>=u*4&&c[0]>=u?1:0)}finderPenaltyTerminateAndCount(c,u,l){return c&&(this.finderPenaltyAddHistory(u,l),u=0),u+=this.size,this.finderPenaltyAddHistory(u,l),this.finderPenaltyCountPatterns(l)}finderPenaltyAddHistory(c,u){u[0]==0&&(c+=this.size),u.pop(),u.unshift(c)}};e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=e;function r(d,c,u){if(c<0||c>31||d>>>c)throw new RangeError("Value out of range");for(let l=c-1;l>=0;l--)u.push(d>>>l&1)}function n(d,c){return(d>>>c&1)!=0}function o(d){if(!d)throw new Error("Assertion error")}const s=class ie{constructor(c,u,l){if(this.mode=c,this.numChars=u,this.bitData=l,u<0)throw new RangeError("Invalid argument");this.bitData=l.slice()}static makeBytes(c){let u=[];for(const l of c)r(l,8,u);return new ie(ie.Mode.BYTE,c.length,u)}static makeNumeric(c){if(!ie.isNumeric(c))throw new RangeError("String contains non-numeric characters");let u=[];for(let l=0;l<c.length;){const f=Math.min(c.length-l,3);r(parseInt(c.substring(l,l+f),10),f*3+1,u),l+=f}return new ie(ie.Mode.NUMERIC,c.length,u)}static makeAlphanumeric(c){if(!ie.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let u=[],l;for(l=0;l+2<=c.length;l+=2){let f=ie.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l))*45;f+=ie.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l+1)),r(f,11,u)}return l<c.length&&r(ie.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l)),6,u),new ie(ie.Mode.ALPHANUMERIC,c.length,u)}static makeSegments(c){return c==""?[]:ie.isNumeric(c)?[ie.makeNumeric(c)]:ie.isAlphanumeric(c)?[ie.makeAlphanumeric(c)]:[ie.makeBytes(ie.toUtf8ByteArray(c))]}static makeEci(c){let u=[];if(c<0)throw new RangeError("ECI assignment value out of range");if(c<128)r(c,8,u);else if(c<16384)r(2,2,u),r(c,14,u);else if(c<1e6)r(6,3,u),r(c,21,u);else throw new RangeError("ECI assignment value out of range");return new ie(ie.Mode.ECI,0,u)}static isNumeric(c){return ie.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return ie.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,u){let l=0;for(const f of c){const p=f.mode.numCharCountBits(u);if(f.numChars>=1<<p)return 1/0;l+=4+p+f.bitData.length}return l}static toUtf8ByteArray(c){c=encodeURI(c);let u=[];for(let l=0;l<c.length;l++)c.charAt(l)!="%"?u.push(c.charCodeAt(l)):(u.push(parseInt(c.substring(l+1,l+3),16)),l+=2);return u}};s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let a=s;t.QrSegment=s})(qe||(qe={}));(t=>{(e=>{const r=class{constructor(o,s){this.ordinal=o,this.formatBits=s}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),e.Ecc=r})(t.QrCode||(t.QrCode={}))})(qe||(qe={}));(t=>{(e=>{const r=class{constructor(o,s){this.modeBits=o,this.numBitsCharCount=s}numCharCountBits(o){return this.numBitsCharCount[Math.floor((o+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),e.Mode=r})(t.QrSegment||(t.QrSegment={}))})(qe||(qe={}));var Ke=qe;var Rc={L:Ke.QrCode.Ecc.LOW,M:Ke.QrCode.Ecc.MEDIUM,Q:Ke.QrCode.Ecc.QUARTILE,H:Ke.QrCode.Ecc.HIGH},Us=128,Gs="L",Hs="#FFFFFF",zs="#000000",Ws=!1,$s=1,kc=4,Pc=0,Ac=.1;function qs(t,e=0){const r=[];return t.forEach(function(n,o){let s=null;n.forEach(function(a,d){if(!a&&s!==null){r.push(`M${s+e} ${o+e}h${d-s}v1H${s+e}z`),s=null;return}if(d===n.length-1){if(!a)return;s===null?r.push(`M${d+e},${o+e} h1v1H${d+e}z`):r.push(`M${s+e},${o+e} h${d+1-s}v1H${s+e}z`);return}a&&s===null&&(s=d)})}),r.join("")}function Xs(t,e){return t.slice().map((r,n)=>n<e.y||n>=e.y+e.h?r:r.map((o,s)=>s<e.x||s>=e.x+e.w?o:!1))}function jc(t,e,r,n){if(n==null)return null;const o=t.length+r*2,s=Math.floor(e*Ac),a=o/e,d=(n.width||s)*a,c=(n.height||s)*a,u=n.x==null?t.length/2-d/2:n.x*a,l=n.y==null?t.length/2-c/2:n.y*a,f=n.opacity==null?1:n.opacity;let p=null;if(n.excavate){let x=Math.floor(u),g=Math.floor(l),v=Math.ceil(d+u-x),y=Math.ceil(c+l-g);p={x,y:g,w:v,h:y}}const m=n.crossOrigin;return{x:u,y:l,h:c,w:d,excavation:p,opacity:f,crossOrigin:m}}function Dc(t,e){return e!=null?Math.max(Math.floor(e),0):t?kc:Pc}function Vs({value:t,level:e,minVersion:r,includeMargin:n,marginSize:o,imageSettings:s,size:a,boostLevel:d}){let c=ne.useMemo(()=>{const x=(Array.isArray(t)?t:[t]).reduce((g,v)=>(g.push(...Ke.QrSegment.makeSegments(v)),g),[]);return Ke.QrCode.encodeSegments(x,Rc[e],r,void 0,void 0,d)},[t,e,r,d]);const{cells:u,margin:l,numCells:f,calculatedImageSettings:p}=ne.useMemo(()=>{let m=c.getModules();const x=Dc(n,o),g=m.length+x*2,v=jc(m,a,x,s);return{cells:m,margin:x,numCells:g,calculatedImageSettings:v}},[c,a,s,n,o]);return{qrcode:c,margin:l,cells:u,numCells:f,calculatedImageSettings:p}}var Mc=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Ic=ne.forwardRef(function(e,r){const n=e,{value:o,size:s=Us,level:a=Gs,bgColor:d=Hs,fgColor:c=zs,includeMargin:u=Ws,minVersion:l=$s,boostLevel:f,marginSize:p,imageSettings:m}=n,g=mr(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:v}=g,y=mr(g,["style"]),S=m?.src,_=ne.useRef(null),b=ne.useRef(null),C=ne.useCallback(P=>{_.current=P,typeof r=="function"?r(P):r&&(r.current=P)},[r]),[R,T]=ne.useState(!1),{margin:A,cells:E,numCells:j,calculatedImageSettings:N}=Vs({value:o,level:a,minVersion:l,boostLevel:f,includeMargin:u,marginSize:p,imageSettings:m,size:s});ne.useEffect(()=>{if(_.current!=null){const P=_.current,D=P.getContext("2d");if(!D)return;let M=E;const U=b.current,H=N!=null&&U!==null&&U.complete&&U.naturalHeight!==0&&U.naturalWidth!==0;H&&N.excavation!=null&&(M=Xs(E,N.excavation));const W=window.devicePixelRatio||1;P.height=P.width=s*W;const V=s/j*W;D.scale(V,V),D.fillStyle=d,D.fillRect(0,0,j,j),D.fillStyle=c,Mc?D.fill(new Path2D(qs(M,A))):E.forEach(function(F,Q){F.forEach(function(Z,oe){Z&&D.fillRect(oe+A,Q+A,1,1)})}),N&&(D.globalAlpha=N.opacity),H&&D.drawImage(U,N.x+A,N.y+A,N.w,N.h)}}),ne.useEffect(()=>{T(!1)},[S]);const G=pr({height:s,width:s},v);let z=null;return S!=null&&(z=ne.createElement("img",{src:S,key:S,style:{display:"none"},onLoad:()=>{T(!0)},ref:b,crossOrigin:N?.crossOrigin})),ne.createElement(ne.Fragment,null,ne.createElement("canvas",pr({style:G,height:s,width:s,ref:C,role:"img"},y)),z)});Ic.displayName="QRCodeCanvas";var Ys=ne.forwardRef(function(e,r){const n=e,{value:o,size:s=Us,level:a=Gs,bgColor:d=Hs,fgColor:c=zs,includeMargin:u=Ws,minVersion:l=$s,boostLevel:f,title:p,marginSize:m,imageSettings:x}=n,g=mr(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:v,cells:y,numCells:S,calculatedImageSettings:_}=Vs({value:o,level:a,minVersion:l,boostLevel:f,includeMargin:u,marginSize:m,imageSettings:x,size:s});let b=y,C=null;x!=null&&_!=null&&(_.excavation!=null&&(b=Xs(y,_.excavation)),C=ne.createElement("image",{href:x.src,height:_.h,width:_.w,x:_.x+v,y:_.y+v,preserveAspectRatio:"none",opacity:_.opacity,crossOrigin:_.crossOrigin}));const R=qs(b,v);return ne.createElement("svg",pr({height:s,width:s,viewBox:`0 0 ${S} ${S}`,ref:r,role:"img"},g),!!p&&ne.createElement("title",null,p),ne.createElement("path",{fill:d,d:`M0,0 h${S}v${S}H0z`,shapeRendering:"crispEdges"}),ne.createElement("path",{fill:c,d:R,shapeRendering:"crispEdges"}),C)});Ys.displayName="QRCodeSVG";const Lc=()=>{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 Oc({devices:t,currentDeviceId:e,onSelectDevice:r,onOpenConfig:n,onConnectWifi:o,onDisconnectWifi:s}){const a=dt(),[d,c]=h.useState(Lc),[u,l]=h.useState(!1),[f,p]=h.useState(""),[m,x]=h.useState("5555"),[g,v]=h.useState(""),[y,S]=h.useState(""),[_,b]=h.useState("direct"),[C,R]=h.useState(""),[T,A]=h.useState(""),[E,j]=h.useState("5555"),[N,G]=h.useState(""),[z,P]=h.useState(!1),[D,M]=h.useState([]),[U,H]=h.useState(!1),[W,V]=h.useState(""),[F,Q]=h.useState(null),[Z,oe]=h.useState(!1),ee=h.useRef(null);h.useEffect(()=>{localStorage.setItem("sidebar-collapsed",JSON.stringify(d))},[d]),h.useEffect(()=>{const w=I=>{(I.metaKey||I.ctrlKey)&&I.key==="b"&&(I.preventDefault(),c(!d))};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[d]);const xe=()=>{c(!d)},de=w=>/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/.test(w)?w.split(".").every(Y=>{const k=parseInt(Y,10);return k>=0&&k<=255}):!1,ue=w=>{const I=parseInt(w,10);return!isNaN(I)&&I>=1&&I<=65535},re=w=>/^\d{6}$/.test(w),me=async()=>{v(""),S("");let w=!1;if(de(f)||(v(a.deviceSidebar.invalidIpError),w=!0),ue(m)||(S(a.deviceSidebar.invalidPortError),w=!0),!w){P(!0);try{const I=await Wr({ip:f,port:parseInt(m,10)});I.success?(l(!1),p(""),x("5555")):v(I.message||a.toasts.wifiManualConnectError)}catch{v(a.toasts.wifiManualConnectError)}finally{P(!1)}}},ge=async()=>{G(""),v(""),S("");let w=!1;if(de(f)||(v(a.deviceSidebar.invalidIpError),w=!0),ue(T)||(S(a.deviceSidebar.invalidPortError),w=!0),ue(E)||(S(a.deviceSidebar.invalidPortError),w=!0),re(C)||(G(a.deviceSidebar.invalidPairingCodeError),w=!0),!w){P(!0);try{const I=await qo({ip:f,pairing_port:parseInt(T,10),pairing_code:C,connection_port:parseInt(E,10)});I.success?(l(!1),p(""),x("5555"),R(""),A(""),j("5555"),b("direct")):I.error==="invalid_pairing_code"?G(I.message):I.error==="invalid_ip"?v(I.message):v(I.message||a.toasts.wifiPairError)}catch{v(a.toasts.wifiPairError)}finally{P(!1)}}},fe=h.useCallback(()=>{ee.current!==null&&(clearInterval(ee.current),ee.current=null)},[]),Le=h.useCallback(w=>{fe(),ee.current=window.setInterval(async()=>{try{const I=await Ho(w);Q(X=>X?{...X,status:I.status}:null),["connected","timeout","error"].includes(I.status)&&(fe(),I.status==="connected"&&setTimeout(()=>{l(!1),Q(null)},2e3))}catch(I){console.error("[QR Pairing] Status poll failed:",I)}},1e3)},[fe]),Re=h.useCallback(async()=>{oe(!0);try{const w=await zo();w.success&&w.qr_payload&&w.session_id&&(Q({sessionId:w.session_id,payload:w.qr_payload,status:"listening",expiresAt:w.expires_at??Date.now()+12e4}),Le(w.session_id))}catch(w){console.error("[QR Pairing] Generation failed:",w)}finally{oe(!1)}},[Le]),we=h.useCallback(async()=>{if(F)try{await Wo(F.sessionId),Q(null),fe()}catch(w){console.error("[QR Pairing] Cancel failed:",w)}},[F,fe]);h.useEffect(()=>{(!u||_!=="pair")&&(F&&F.status==="listening"&&we(),fe())},[u,_,F,fe,we]),h.useEffect(()=>()=>{fe()},[fe]),h.useEffect(()=>{u&&_==="pair"&&!F&&!Z&&Re()},[u,_,F,Z,Re]);const L=h.useCallback(async()=>{H(!0),V("");try{const w=await $o();w.success?M(w.devices):(V(w.error||a.deviceSidebar.scanError.replace("{error}","Unknown error")),M([]))}catch(w){V(a.deviceSidebar.scanError.replace("{error}",String(w))),M([])}finally{H(!1)}},[a.deviceSidebar.scanError]),O=async(w,I)=>{if(!I&&!w.has_pairing){P(!0),v("");try{const X=await Wr({ip:w.ip,port:w.port});X.success?l(!1):v(X.message||a.toasts.wifiManualConnectError)}catch(X){v(a.toasts.wifiManualConnectError),console.error("[DeviceSidebar] Error connecting:",X)}finally{P(!1)}}else I&&w.has_pairing&&(p(w.ip),A(w.pairing_port?String(w.pairing_port):""),j(String(w.port)),setTimeout(()=>{document.getElementById("pairing-code")?.focus()},100))};return h.useEffect(()=>{if(u){L();const w=setInterval(()=>{L()},5e3);return()=>{clearInterval(w)}}},[u,L]),i.jsxs(i.Fragment,{children:[d&&i.jsx(te,{variant:"outline",size:"icon",onClick:xe,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:i.jsx(Un,{className:"h-4 w-4"})}),i.jsxs("div",{className:`
|
|
50
|
+
${d?"w-0 -ml-4 opacity-0":"w-80 opacity-100"}
|
|
51
|
+
transition-all duration-300 ease-in-out
|
|
52
|
+
h-full min-h-0
|
|
53
|
+
bg-white dark:bg-slate-950
|
|
54
|
+
border-r border-slate-200 dark:border-slate-800
|
|
55
|
+
flex flex-col
|
|
56
|
+
overflow-hidden
|
|
57
|
+
`,children:[i.jsxs("div",{className:"flex items-center justify-between p-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:i.jsx(bt,{className:"h-5 w-5 text-[#1d9bf0]"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"text-base font-bold text-slate-900 dark:text-slate-100",children:"AutoGLM"}),i.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[t.length," ",(t.length===1,a.deviceSidebar.devices)]})]})]}),i.jsx(te,{variant:"ghost",size:"icon",onClick:xe,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:i.jsx(Bn,{className:"h-4 w-4"})})]}),i.jsx(ot,{className:"mx-4"}),i.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-2 min-h-0",children:t.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[i.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800",children:i.jsx(Pi,{className:"h-8 w-8 text-slate-400"})}),i.jsx("p",{className:"mt-4 font-medium text-slate-900 dark:text-slate-100",children:a.deviceSidebar.noDevicesConnected}),i.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:a.deviceSidebar.clickToRefresh})]}):t.map(w=>i.jsx(Qi,{id:w.id,model:w.model,status:w.status,connectionType:w.connection_type,isInitialized:w.is_initialized,isActive:e===w.id,onClick:()=>r(w.id),onConnectWifi:async()=>{await o(w.id)},onDisconnectWifi:async()=>{await s(w.id)}},w.id))}),i.jsx(ot,{className:"mx-4"}),i.jsxs("div",{className:"p-3 space-y-2",children:[i.jsxs(te,{variant:"outline",onClick:()=>l(!0),className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[i.jsx(ji,{className:"h-4 w-4"}),a.deviceSidebar.addDevice]}),i.jsxs(te,{variant:"outline",onClick:n,className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[i.jsx(Gn,{className:"h-4 w-4"}),a.deviceSidebar.settings]})]}),i.jsx(xs,{open:u,onOpenChange:l,children:i.jsxs(Tr,{className:"sm:max-w-md max-h-[80vh] overflow-y-auto",children:[i.jsxs(Rr,{children:[i.jsx(Pr,{children:a.deviceSidebar.manualConnectTitle}),i.jsx(Ar,{children:a.deviceSidebar.manualConnectDescription})]}),i.jsxs(Sc,{value:_,onValueChange:b,className:"w-full",children:[i.jsxs(Cc,{className:"grid w-full grid-cols-2",children:[i.jsx(cn,{value:"direct",children:a.deviceSidebar.directConnectTab}),i.jsx(cn,{value:"pair",children:a.deviceSidebar.pairTab})]}),i.jsxs(ln,{value:"direct",className:"space-y-4 mt-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h3",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:a.deviceSidebar.discoveredDevices}),i.jsx(te,{variant:"outline",size:"sm",onClick:L,disabled:U,className:"h-8",children:U?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"mr-2 h-3 w-3 animate-spin rounded-full border-2 border-slate-400 border-t-transparent"}),a.deviceSidebar.scanning]}):a.deviceSidebar.scanAgain})]}),W&&i.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:i.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:W})}),(()=>{const w=D.filter(I=>!I.has_pairing);return!U&&w.length===0?i.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[i.jsx(dr,{className:"mx-auto h-8 w-8 text-slate-400"}),i.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:a.deviceSidebar.noDirectDevices})]}):w.length>0?i.jsx("div",{className:"space-y-2",children:w.map(I=>i.jsx("button",{onClick:()=>O(I,!1),disabled:z,className:"w-full rounded-lg border border-slate-200 dark:border-slate-700 p-3 text-left transition-colors hover:bg-slate-50 dark:hover:bg-slate-800 disabled:opacity-50 disabled:cursor-not-allowed",children:i.jsx("div",{className:"flex items-start justify-between",children:i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(bt,{className:"h-4 w-4 text-[#1d9bf0]"}),i.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:I.name})]}),i.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[I.ip,":",I.port]})]})})},`${I.ip}:${I.port}`))}):null})(),g&&_==="direct"&&i.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:i.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:g})}),i.jsxs("div",{className:"relative my-4",children:[i.jsx(ot,{}),i.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-slate-950 px-2 text-sm text-slate-500",children:a.deviceSidebar.orManualConnect})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("div",{className:"rounded-lg bg-amber-50 dark:bg-amber-950/20 p-3 text-sm",children:i.jsx("p",{className:"text-amber-800 dark:text-amber-200",children:a.deviceSidebar.directConnectNote})}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ne,{htmlFor:"ip",children:a.deviceSidebar.ipAddress}),i.jsx(Oe,{id:"ip",placeholder:"192.168.1.100",value:f,onChange:w=>p(w.target.value),onKeyDown:w=>w.key==="Enter"&&me(),className:g?"border-red-500":""})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ne,{htmlFor:"port",children:a.deviceSidebar.port}),i.jsx(Oe,{id:"port",type:"number",value:m,onChange:w=>x(w.target.value),onKeyDown:w=>w.key==="Enter"&&me(),className:y?"border-red-500":""}),y&&i.jsx("p",{className:"text-sm text-red-500",children:y})]}),i.jsx(te,{onClick:me,disabled:z,className:"w-full",children:z?a.common.loading:a.deviceSidebar.connect})]})]}),i.jsxs(ln,{value:"pair",className:"space-y-4 mt-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h3",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:a.deviceSidebar.discoveredDevices}),i.jsx(te,{variant:"outline",size:"sm",onClick:L,disabled:U,className:"h-8",children:U?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"mr-2 h-3 w-3 animate-spin rounded-full border-2 border-slate-400 border-t-transparent"}),a.deviceSidebar.scanning]}):a.deviceSidebar.scanAgain})]}),W&&i.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:i.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:W})}),(()=>{const w=D.filter(I=>I.has_pairing);return!U&&w.length===0?i.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[i.jsx(dr,{className:"mx-auto h-8 w-8 text-slate-400"}),i.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:a.deviceSidebar.noPairingDevices})]}):w.length>0?i.jsx("div",{className:"space-y-2",children:w.map(I=>i.jsx("button",{onClick:()=>O(I,!0),disabled:z,className:"w-full rounded-lg border border-slate-200 dark:border-slate-700 p-3 text-left transition-colors hover:bg-slate-50 dark:hover:bg-slate-800 disabled:opacity-50 disabled:cursor-not-allowed",children:i.jsx("div",{className:"flex items-start justify-between",children:i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(bt,{className:"h-4 w-4 text-[#1d9bf0]"}),i.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:I.name})]}),i.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[I.ip,":",I.port]}),i.jsxs("div",{className:"mt-2 flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400",children:[i.jsx(ze,{className:"h-3 w-3"}),i.jsx("span",{children:a.deviceSidebar.pairingRequired})]})]})})},`${I.ip}:${I.port}`))}):null})(),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"relative my-4",children:[i.jsx(ot,{}),i.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-slate-950 px-2 text-sm text-slate-500",children:a.deviceSidebar.orQrPair})]}),i.jsxs("div",{className:"rounded-lg bg-purple-50 dark:bg-purple-950/20 p-3 text-sm",children:[i.jsx("p",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:a.deviceSidebar.qrPairingTitle}),i.jsxs("ol",{className:"space-y-1 text-purple-700 dark:text-purple-300 text-xs",children:[i.jsx("li",{children:a.deviceSidebar.qrStep1}),i.jsx("li",{children:a.deviceSidebar.qrStep2}),i.jsx("li",{children:a.deviceSidebar.qrStep3})]})]}),F&&i.jsx("div",{className:"rounded-lg border border-slate-200 dark:border-slate-700 p-4 bg-white dark:bg-slate-900",children:i.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[i.jsx("div",{className:"bg-white p-4 rounded-lg",children:i.jsx(Ys,{value:F.payload,size:200,level:"M"})}),i.jsxs("div",{className:"flex items-center gap-2",children:[F.status==="listening"&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"h-2 w-2 rounded-full bg-blue-500 animate-pulse"}),i.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:a.deviceSidebar.qrWaitingForScan})]}),F.status==="pairing"&&i.jsxs(i.Fragment,{children:[i.jsx(We,{className:"h-4 w-4 animate-spin text-blue-500"}),i.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:a.deviceSidebar.qrPairing})]}),F.status==="connected"&&i.jsxs(i.Fragment,{children:[i.jsx(hi,{className:"h-4 w-4 text-green-500"}),i.jsx("span",{className:"text-sm text-green-600 dark:text-green-400",children:a.deviceSidebar.qrConnected})]}),F.status==="timeout"&&i.jsxs(i.Fragment,{children:[i.jsx(Xr,{className:"h-4 w-4 text-amber-500"}),i.jsx("span",{className:"text-sm text-amber-600 dark:text-amber-400",children:a.deviceSidebar.qrTimeout})]}),F.status==="error"&&i.jsxs(i.Fragment,{children:[i.jsx(Xr,{className:"h-4 w-4 text-red-500"}),i.jsx("span",{className:"text-sm text-red-600 dark:text-red-400",children:a.deviceSidebar.qrError})]})]}),i.jsxs("div",{className:"flex gap-2 w-full",children:[(F.status==="timeout"||F.status==="error")&&i.jsx(te,{variant:"outline",onClick:Re,className:"flex-1",children:a.deviceSidebar.qrRegenerate}),F.status==="listening"&&i.jsx(te,{variant:"outline",onClick:we,className:"flex-1",children:a.common.cancel}),F.status==="connected"&&i.jsx(te,{onClick:()=>l(!1),className:"flex-1",children:a.common.confirm})]})]})}),!F&&Z&&i.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-slate-600 dark:text-slate-400",children:[i.jsx(We,{className:"h-4 w-4 animate-spin"}),i.jsx("span",{className:"text-sm",children:a.common.loading})]})]}),i.jsxs("div",{className:"relative my-4",children:[i.jsx(ot,{}),i.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-slate-950 px-2 text-sm text-slate-500",children:a.deviceSidebar.orManualPair})]}),i.jsxs("div",{className:"rounded-lg bg-blue-50 dark:bg-blue-950/20 p-3 text-sm",children:[i.jsx("p",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:a.deviceSidebar.pairingInstructions}),i.jsxs("ol",{className:"space-y-1 text-blue-700 dark:text-blue-300 text-xs",children:[i.jsx("li",{children:a.deviceSidebar.pairingStep1}),i.jsx("li",{children:a.deviceSidebar.pairingStep2}),i.jsx("li",{children:a.deviceSidebar.pairingStep3}),i.jsx("li",{children:a.deviceSidebar.pairingStep4})]}),i.jsx("p",{className:"mt-2 text-xs text-blue-600 dark:text-blue-400",children:a.deviceSidebar.pairingNote})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ne,{htmlFor:"pair-ip",children:a.deviceSidebar.ipAddress}),i.jsx(Oe,{id:"pair-ip",placeholder:"192.168.1.100",value:f,onChange:w=>p(w.target.value),className:g?"border-red-500":""}),g&&_==="pair"&&i.jsx("p",{className:"text-sm text-red-500",children:g})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ne,{htmlFor:"pairing-port",children:a.deviceSidebar.pairingPort}),i.jsx(Oe,{id:"pairing-port",type:"number",placeholder:"37831",value:T,onChange:w=>A(w.target.value),className:y?"border-red-500":""}),y&&i.jsx("p",{className:"text-sm text-red-500",children:y})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ne,{htmlFor:"pairing-code",children:a.deviceSidebar.pairingCode}),i.jsx(Oe,{id:"pairing-code",type:"text",placeholder:"123456",maxLength:6,value:C,onChange:w=>R(w.target.value.replace(/\D/g,"")),onKeyDown:w=>w.key==="Enter"&&ge(),className:N?"border-red-500":""}),N&&i.jsx("p",{className:"text-sm text-red-500",children:N})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ne,{htmlFor:"connection-port",children:a.deviceSidebar.connectionPort}),i.jsx(Oe,{id:"connection-port",type:"number",value:E,onChange:w=>j(w.target.value),onKeyDown:w=>w.key==="Enter"&&ge()})]}),i.jsx(te,{onClick:ge,disabled:z,className:"w-full",children:z?a.common.loading:a.deviceSidebar.pairAndConnect})]})]})]}),i.jsx(kr,{children:i.jsx(te,{variant:"outline",onClick:()=>{l(!1),v(""),S(""),G(""),V(""),p(""),x("5555"),R(""),A(""),j("5555"),b("direct"),M([])},children:a.common.cancel})})]})})]})]})}const De=Object.create(null);De.open="0";De.close="1";De.ping="2";De.pong="3";De.message="4";De.upgrade="5";De.noop="6";const Et=Object.create(null);Object.keys(De).forEach(t=>{Et[De[t]]=t});const gr={type:"error",data:"parser error"},Ks=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Qs=typeof ArrayBuffer=="function",Js=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,Mr=({type:t,data:e},r,n)=>Ks&&e instanceof Blob?r?n(e):dn(e,n):Qs&&(e instanceof ArrayBuffer||Js(e))?r?n(e):dn(new Blob([e]),n):n(De[t]+(e||"")),dn=(t,e)=>{const r=new FileReader;return r.onload=function(){const n=r.result.split(",")[1];e("b"+(n||""))},r.readAsDataURL(t)};function fn(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let er;function Fc(t,e){if(Ks&&t.data instanceof Blob)return t.data.arrayBuffer().then(fn).then(e);if(Qs&&(t.data instanceof ArrayBuffer||Js(t.data)))return e(fn(t.data));Mr(t,!1,r=>{er||(er=new TextEncoder),e(er.encode(r))})}const hn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ct=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<hn.length;t++)ct[hn.charCodeAt(t)]=t;const Bc=t=>{let e=t.length*.75,r=t.length,n,o=0,s,a,d,c;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const u=new ArrayBuffer(e),l=new Uint8Array(u);for(n=0;n<r;n+=4)s=ct[t.charCodeAt(n)],a=ct[t.charCodeAt(n+1)],d=ct[t.charCodeAt(n+2)],c=ct[t.charCodeAt(n+3)],l[o++]=s<<2|a>>4,l[o++]=(a&15)<<4|d>>2,l[o++]=(d&3)<<6|c&63;return u},Uc=typeof ArrayBuffer=="function",Ir=(t,e)=>{if(typeof t!="string")return{type:"message",data:Zs(t,e)};const r=t.charAt(0);return r==="b"?{type:"message",data:Gc(t.substring(1),e)}:Et[r]?t.length>1?{type:Et[r],data:t.substring(1)}:{type:Et[r]}:gr},Gc=(t,e)=>{if(Uc){const r=Bc(t);return Zs(r,e)}else return{base64:!0,data:t}},Zs=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},eo="",Hc=(t,e)=>{const r=t.length,n=new Array(r);let o=0;t.forEach((s,a)=>{Mr(s,!1,d=>{n[a]=d,++o===r&&e(n.join(eo))})})},zc=(t,e)=>{const r=t.split(eo),n=[];for(let o=0;o<r.length;o++){const s=Ir(r[o],e);if(n.push(s),s.type==="error")break}return n};function Wc(){return new TransformStream({transform(t,e){Fc(t,r=>{const n=r.length;let o;if(n<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,n);else if(n<65536){o=new Uint8Array(3);const s=new DataView(o.buffer);s.setUint8(0,126),s.setUint16(1,n)}else{o=new Uint8Array(9);const s=new DataView(o.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(n))}t.data&&typeof t.data!="string"&&(o[0]|=128),e.enqueue(o),e.enqueue(r)})}})}let tr;function xt(t){return t.reduce((e,r)=>e+r.length,0)}function vt(t,e){if(t[0].length===e)return t.shift();const r=new Uint8Array(e);let n=0;for(let o=0;o<e;o++)r[o]=t[0][n++],n===t[0].length&&(t.shift(),n=0);return t.length&&n<t[0].length&&(t[0]=t[0].slice(n)),r}function $c(t,e){tr||(tr=new TextDecoder);const r=[];let n=0,o=-1,s=!1;return new TransformStream({transform(a,d){for(r.push(a);;){if(n===0){if(xt(r)<1)break;const c=vt(r,1);s=(c[0]&128)===128,o=c[0]&127,o<126?n=3:o===126?n=1:n=2}else if(n===1){if(xt(r)<2)break;const c=vt(r,2);o=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),n=3}else if(n===2){if(xt(r)<8)break;const c=vt(r,8),u=new DataView(c.buffer,c.byteOffset,c.length),l=u.getUint32(0);if(l>Math.pow(2,21)-1){d.enqueue(gr);break}o=l*Math.pow(2,32)+u.getUint32(4),n=3}else{if(xt(r)<o)break;const c=vt(r,o);d.enqueue(Ir(s?c:tr.decode(c),e)),n=0}if(o===0||o>t){d.enqueue(gr);break}}}})}const to=4;function ce(t){if(t)return qc(t)}function qc(t){for(var e in ce.prototype)t[e]=ce.prototype[e];return t}ce.prototype.on=ce.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};ce.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this};ce.prototype.off=ce.prototype.removeListener=ce.prototype.removeAllListeners=ce.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+t];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var n,o=0;o<r.length;o++)if(n=r[o],n===e||n.fn===e){r.splice(o,1);break}return r.length===0&&delete this._callbacks["$"+t],this};ce.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(r){r=r.slice(0);for(var n=0,o=r.length;n<o;++n)r[n].apply(this,e)}return this};ce.prototype.emitReserved=ce.prototype.emit;ce.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};ce.prototype.hasListeners=function(t){return!!this.listeners(t).length};const Ft=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,r)=>r(e,0),Ee=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Xc="arraybuffer";function ro(t,...e){return e.reduce((r,n)=>(t.hasOwnProperty(n)&&(r[n]=t[n]),r),{})}const Vc=Ee.setTimeout,Yc=Ee.clearTimeout;function Bt(t,e){e.useNativeTimers?(t.setTimeoutFn=Vc.bind(Ee),t.clearTimeoutFn=Yc.bind(Ee)):(t.setTimeoutFn=Ee.setTimeout.bind(Ee),t.clearTimeoutFn=Ee.clearTimeout.bind(Ee))}const Kc=1.33;function Qc(t){return typeof t=="string"?Jc(t):Math.ceil((t.byteLength||t.size)*Kc)}function Jc(t){let e=0,r=0;for(let n=0,o=t.length;n<o;n++)e=t.charCodeAt(n),e<128?r+=1:e<2048?r+=2:e<55296||e>=57344?r+=3:(n++,r+=4);return r}function no(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Zc(t){let e="";for(let r in t)t.hasOwnProperty(r)&&(e.length&&(e+="&"),e+=encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e}function el(t){let e={},r=t.split("&");for(let n=0,o=r.length;n<o;n++){let s=r[n].split("=");e[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return e}class tl extends Error{constructor(e,r,n){super(e),this.description=r,this.context=n,this.type="TransportError"}}class Lr extends ce{constructor(e){super(),this.writable=!1,Bt(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,r,n){return super.emitReserved("error",new tl(e,r,n)),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 r=Ir(e,this.socket.binaryType);this.onPacket(r)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,r={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_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 r=Zc(e);return r.length?"?"+r:""}}class rl extends Lr{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const r=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let n=0;this._polling&&(n++,this.once("pollComplete",function(){--n||r()})),this.writable||(n++,this.once("drain",function(){--n||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const r=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};zc(e,this.socket.binaryType).forEach(r),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,Hc(e,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=no()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(e,r)}}let so=!1;try{so=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const nl=so;function sl(){}class ol extends rl{constructor(e){if(super(e),typeof location<"u"){const r=location.protocol==="https:";let n=location.port;n||(n=r?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,r){const n=this.request({method:"POST",data:e});n.on("success",r),n.on("error",(o,s)=>{this.onError("xhr post error",o,s)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(r,n)=>{this.onError("xhr poll error",r,n)}),this.pollXhr=e}}class je extends ce{constructor(e,r,n){super(),this.createRequest=e,Bt(this,n),this._opts=n,this._method=n.method||"GET",this._uri=r,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var e;const r=ro(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(r);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&n.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var o;n.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},n.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=je.requestsCount++,je.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=sl,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete je.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()}}je.requestsCount=0;je.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",pn);else if(typeof addEventListener=="function"){const t="onpagehide"in Ee?"pagehide":"unload";addEventListener(t,pn,!1)}}function pn(){for(let t in je.requests)je.requests.hasOwnProperty(t)&&je.requests[t].abort()}const il=(function(){const t=oo({xdomain:!1});return t&&t.responseType!==null})();class al extends ol{constructor(e){super(e);const r=e&&e.forceBase64;this.supportsBinary=il&&!r}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new je(oo,this.uri(),e)}}function oo(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||nl))return new XMLHttpRequest}catch{}if(!e)try{return new Ee[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const io=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class cl extends Lr{get name(){return"websocket"}doOpen(){const e=this.uri(),r=this.opts.protocols,n=io?{}:ro(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,r,n)}catch(o){return this.emitReserved("error",o)}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 r=0;r<e.length;r++){const n=e[r],o=r===e.length-1;Mr(n,this.supportsBinary,s=>{try{this.doWrite(n,s)}catch{}o&&Ft(()=>{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",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=no()),this.supportsBinary||(r.b64=1),this.createUri(e,r)}}const rr=Ee.WebSocket||Ee.MozWebSocket;class ll extends cl{createSocket(e,r,n){return io?new rr(e,r,n):r?new rr(e,r):new rr(e)}doWrite(e,r){this.ws.send(r)}}class ul extends Lr{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 r=$c(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(r).getReader(),o=Wc();o.readable.pipeTo(e.writable),this._writer=o.writable.getWriter();const s=()=>{n.read().then(({done:d,value:c})=>{d||(this.onPacket(c),s())}).catch(d=>{})};s();const a={type:"open"};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let r=0;r<e.length;r++){const n=e[r],o=r===e.length-1;this._writer.write(n).then(()=>{o&&Ft(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const dl={websocket:ll,webtransport:ul,polling:al},fl=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,hl=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function _r(t){if(t.length>8e3)throw"URI too long";const e=t,r=t.indexOf("["),n=t.indexOf("]");r!=-1&&n!=-1&&(t=t.substring(0,r)+t.substring(r,n).replace(/:/g,";")+t.substring(n,t.length));let o=fl.exec(t||""),s={},a=14;for(;a--;)s[hl[a]]=o[a]||"";return r!=-1&&n!=-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=pl(s,s.path),s.queryKey=ml(s,s.query),s}function pl(t,e){const r=/\/{2,9}/g,n=e.replace(r,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&n.splice(0,1),e.slice(-1)=="/"&&n.splice(n.length-1,1),n}function ml(t,e){const r={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,o,s){o&&(r[o]=s)}),r}const xr=typeof addEventListener=="function"&&typeof removeEventListener=="function",St=[];xr&&addEventListener("offline",()=>{St.forEach(t=>t())},!1);class Be extends ce{constructor(e,r){if(super(),this.binaryType=Xc,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(r=e,e=null),e){const n=_r(e);r.hostname=n.host,r.secure=n.protocol==="https"||n.protocol==="wss",r.port=n.port,n.query&&(r.query=n.query)}else r.host&&(r.hostname=_r(r.host).host);Bt(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(n=>{const o=n.prototype.name;this.transports.push(o),this._transportsByName[o]=n}),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},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=el(this.opts.query)),xr&&(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"})},St.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const r=Object.assign({},this.opts.query);r.EIO=to,r.transport=e,this.id&&(r.sid=this.id);const n=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&Be.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(e);r.open(),this.setTransport(r)}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",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",Be.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 r=new Error("server error");r.code=e.data,this._onError(r);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 r=1;for(let n=0;n<this.writeBuffer.length;n++){const o=this.writeBuffer[n].data;if(o&&(r+=Qc(o)),n>0&&r>this._maxPayload)return this.writeBuffer.slice(0,n);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,Ft(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,r,n){return this._sendPacket("message",e,r,n),this}send(e,r,n){return this._sendPacket("message",e,r,n),this}_sendPacket(e,r,n,o){if(typeof r=="function"&&(o=r,r=void 0),typeof n=="function"&&(o=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const s={type:e,data:r,options:n};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),o&&this.once("flush",o),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),e()},n=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(e){if(Be.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,r){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(),xr&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const n=St.indexOf(this._offlineEventListener);n!==-1&&St.splice(n,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,r),this.writeBuffer=[],this._prevBufferLen=0}}}Be.protocol=to;class gl extends Be{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 r=this.createTransport(e),n=!1;Be.priorWebsocketSuccess=!1;const o=()=>{n||(r.send([{type:"ping",data:"probe"}]),r.once("packet",f=>{if(!n)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;Be.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(l(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const p=new Error("probe error");p.transport=r.name,this.emitReserved("upgradeError",p)}}))};function s(){n||(n=!0,l(),r.close(),r=null)}const a=f=>{const p=new Error("probe error: "+f);p.transport=r.name,s(),this.emitReserved("upgradeError",p)};function d(){a("transport closed")}function c(){a("socket closed")}function u(f){r&&f.name!==r.name&&s()}const l=()=>{r.removeListener("open",o),r.removeListener("error",a),r.removeListener("close",d),this.off("close",c),this.off("upgrading",u)};r.once("open",o),r.once("error",a),r.once("close",d),this.once("close",c),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{n||r.open()},200):r.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const r=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&r.push(e[n]);return r}}let _l=class extends gl{constructor(e,r={}){const n=typeof e=="object"?e:r;(!n.transports||n.transports&&typeof n.transports[0]=="string")&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(o=>dl[o]).filter(o=>!!o)),super(e,n)}};function xl(t,e="",r){let n=t;r=r||typeof location<"u"&&location,t==null&&(t=r.protocol+"//"+r.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=r.protocol+t:t=r.host+t),/^(https?|wss?):\/\//.test(t)||(typeof r<"u"?t=r.protocol+"//"+t:t="https://"+t),n=_r(t)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const s=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+s+":"+n.port+e,n.href=n.protocol+"://"+s+(r&&r.port===n.port?"":":"+n.port),n}const vl=typeof ArrayBuffer=="function",bl=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,ao=Object.prototype.toString,yl=typeof Blob=="function"||typeof Blob<"u"&&ao.call(Blob)==="[object BlobConstructor]",wl=typeof File=="function"||typeof File<"u"&&ao.call(File)==="[object FileConstructor]";function Or(t){return vl&&(t instanceof ArrayBuffer||bl(t))||yl&&t instanceof Blob||wl&&t instanceof File}function Ct(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let r=0,n=t.length;r<n;r++)if(Ct(t[r]))return!0;return!1}if(Or(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return Ct(t.toJSON(),!0);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&Ct(t[r]))return!0;return!1}function El(t){const e=[],r=t.data,n=t;return n.data=vr(r,e),n.attachments=e.length,{packet:n,buffers:e}}function vr(t,e){if(!t)return t;if(Or(t)){const r={_placeholder:!0,num:e.length};return e.push(t),r}else if(Array.isArray(t)){const r=new Array(t.length);for(let n=0;n<t.length;n++)r[n]=vr(t[n],e);return r}else if(typeof t=="object"&&!(t instanceof Date)){const r={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=vr(t[n],e));return r}return t}function Sl(t,e){return t.data=br(t.data,e),delete t.attachments,t}function br(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 r=0;r<t.length;r++)t[r]=br(t[r],e);else if(typeof t=="object")for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(t[r]=br(t[r],e));return t}const Cl=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Nl=5;var q;(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"})(q||(q={}));class Tl{constructor(e){this.replacer=e}encode(e){return(e.type===q.EVENT||e.type===q.ACK)&&Ct(e)?this.encodeAsBinary({type:e.type===q.EVENT?q.BINARY_EVENT:q.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let r=""+e.type;return(e.type===q.BINARY_EVENT||e.type===q.BINARY_ACK)&&(r+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(r+=e.nsp+","),e.id!=null&&(r+=e.id),e.data!=null&&(r+=JSON.stringify(e.data,this.replacer)),r}encodeAsBinary(e){const r=El(e),n=this.encodeAsString(r.packet),o=r.buffers;return o.unshift(n),o}}function mn(t){return Object.prototype.toString.call(t)==="[object Object]"}class Fr extends ce{constructor(e){super(),this.reviver=e}add(e){let r;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(e);const n=r.type===q.BINARY_EVENT;n||r.type===q.BINARY_ACK?(r.type=n?q.EVENT:q.ACK,this.reconstructor=new Rl(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Or(e)||e.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(e),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let r=0;const n={type:Number(e.charAt(0))};if(q[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===q.BINARY_EVENT||n.type===q.BINARY_ACK){const s=r+1;for(;e.charAt(++r)!=="-"&&r!=e.length;);const a=e.substring(s,r);if(a!=Number(a)||e.charAt(r)!=="-")throw new Error("Illegal attachments");n.attachments=Number(a)}if(e.charAt(r+1)==="/"){const s=r+1;for(;++r&&!(e.charAt(r)===","||r===e.length););n.nsp=e.substring(s,r)}else n.nsp="/";const o=e.charAt(r+1);if(o!==""&&Number(o)==o){const s=r+1;for(;++r;){const a=e.charAt(r);if(a==null||Number(a)!=a){--r;break}if(r===e.length)break}n.id=Number(e.substring(s,r+1))}if(e.charAt(++r)){const s=this.tryParse(e.substr(r));if(Fr.isPayloadValid(n.type,s))n.data=s;else throw new Error("invalid payload")}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,r){switch(e){case q.CONNECT:return mn(r);case q.DISCONNECT:return r===void 0;case q.CONNECT_ERROR:return typeof r=="string"||mn(r);case q.EVENT:case q.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&Cl.indexOf(r[0])===-1);case q.ACK:case q.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Rl{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const r=Sl(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const kl=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Fr,Encoder:Tl,get PacketType(){return q},protocol:Nl},Symbol.toStringTag,{value:"Module"}));function Ce(t,e,r){return t.on(e,r),function(){t.off(e,r)}}const Pl=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class co extends ce{constructor(e,r,n){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=r,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Ce(e,"open",this.onopen.bind(this)),Ce(e,"packet",this.onpacket.bind(this)),Ce(e,"error",this.onerror.bind(this)),Ce(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,...r){var n,o,s;if(Pl.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(r.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const a={type:q.EVENT,data:r};if(a.options={},a.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const l=this.ids++,f=r.pop();this._registerAckCallback(l,f),a.id=l}const d=(o=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||o===void 0?void 0:o.writable,c=this.connected&&!(!((s=this.io.engine)===null||s===void 0)&&s._hasPingExpired());return this.flags.volatile&&!d||(c?(this.notifyOutgoingListeners(a),this.packet(a)):this.sendBuffer.push(a)),this.flags={},this}_registerAckCallback(e,r){var n;const o=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(o===void 0){this.acks[e]=r;return}const s=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let d=0;d<this.sendBuffer.length;d++)this.sendBuffer[d].id===e&&this.sendBuffer.splice(d,1);r.call(this,new Error("operation has timed out"))},o),a=(...d)=>{this.io.clearTimeoutFn(s),r.apply(this,d)};a.withError=!0,this.acks[e]=a}emitWithAck(e,...r){return new Promise((n,o)=>{const s=(a,d)=>a?o(a):n(d);s.withError=!0,r.push(s),this.emit(e,...r)})}_addToQueue(e){let r;typeof e[e.length-1]=="function"&&(r=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((o,...s)=>n!==this._queue[0]?void 0:(o!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(o)):(this._queue.shift(),r&&r(null,...s)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!e||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.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:q.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,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(n=>String(n.id)===e)){const n=this.acks[e];delete this.acks[e],n.withError&&n.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case q.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 q.EVENT:case q.BINARY_EVENT:this.onevent(e);break;case q.ACK:case q.BINARY_ACK:this.onack(e);break;case q.DISCONNECT:this.ondisconnect();break;case q.CONNECT_ERROR:this.destroy();const n=new Error(e.data.message);n.data=e.data.data,this.emitReserved("connect_error",n);break}}onevent(e){const r=e.data||[];e.id!=null&&r.push(this.ack(e.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const n of r)n.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 r=this;let n=!1;return function(...o){n||(n=!0,r.packet({type:q.ACK,id:e,data:o}))}}onack(e){const r=this.acks[e.id];typeof r=="function"&&(delete this.acks[e.id],r.withError&&e.data.unshift(null),r.apply(this,e.data))}onconnect(e,r){this.id=e,this.recovered=r&&this._pid===r,this._pid=r,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:q.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 r=this._anyListeners;for(let n=0;n<r.length;n++)if(e===r[n])return r.splice(n,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 r=this._anyOutgoingListeners;for(let n=0;n<r.length;n++)if(e===r[n])return r.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const n of r)n.apply(this,e.data)}}}function nt(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}nt.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),r=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-r:t+r}return Math.min(t,this.max)|0};nt.prototype.reset=function(){this.attempts=0};nt.prototype.setMin=function(t){this.ms=t};nt.prototype.setMax=function(t){this.max=t};nt.prototype.setJitter=function(t){this.jitter=t};class yr extends ce{constructor(e,r){var n;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(r=e,e=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,Bt(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((n=r.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new nt({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=e;const o=r.parser||kl;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=r.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 r;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(r=this.backoff)===null||r===void 0||r.setMin(e),this)}randomizationFactor(e){var r;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(r=this.backoff)===null||r===void 0||r.setJitter(e),this)}reconnectionDelayMax(e){var r;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(r=this.backoff)===null||r===void 0||r.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 _l(this.uri,this.opts);const r=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const o=Ce(r,"open",function(){n.onopen(),e&&e()}),s=d=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",d),e?e(d):this.maybeReconnectOnOpen()},a=Ce(r,"error",s);if(this._timeout!==!1){const d=this._timeout,c=this.setTimeoutFn(()=>{o(),s(new Error("timeout")),r.close()},d);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(o),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Ce(e,"ping",this.onping.bind(this)),Ce(e,"data",this.ondata.bind(this)),Ce(e,"error",this.onerror.bind(this)),Ce(e,"close",this.onclose.bind(this)),Ce(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(r){this.onclose("parse error",r)}}ondecoded(e){Ft(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,r){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new co(this,e,r),this.nsps[e]=n),n}_destroy(e){const r=Object.keys(this.nsps);for(const n of r)if(this.nsps[n].active)return;this._close()}_packet(e){const r=this.encoder.encode(e);for(let n=0;n<r.length;n++)this.engine.write(r[n],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,r){var n;this.cleanup(),(n=this.engine)===null||n===void 0||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,r),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 r=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(o=>{o?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",o)):e.onreconnect()}))},r);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const it={};function Nt(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const r=xl(t,e.path||"/socket.io"),n=r.source,o=r.id,s=r.path,a=it[o]&&s in it[o].nsps,d=e.forceNew||e["force new connection"]||e.multiplex===!1||a;let c;return d?c=new yr(n,e):(it[o]||(it[o]=new yr(n,e)),c=it[o]),r.query&&!e.query&&(e.query=r.queryKey),c.socket(r.path,e)}Object.assign(Nt,{Manager:yr,Socket:co,io:Nt,connect:Nt});function Al(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}const Tt={H264:1748121140,H265:1748121141,AV1:6387249},{WritableStream:jl}=globalThis;class Dl{#e;#t;#r=0;#n=7;get byteAligned(){return this.#n===7}get ended(){return this.#r>=this.#e.length}constructor(e){this.#e=e,this.#t=e[0]}f1(){const e=this.#t>>this.#n;return this.#n-=1,this.#n<0&&(this.#r+=1,this.#n=7,this.#t=this.#e[this.#r]),e&1}f(e){let r=0;for(;e>0;e-=1)r<<=1,r|=this.f1();return r}skip(e){if(e<=this.#n+1){this.#r+=1,this.#n=7,this.#t=this.#e[this.#r];return}e-=this.#n+1,this.#r+=1;const r=e/8|0;r>0&&(this.#r+=r,e-=r*8),this.#n=7-e,this.#t=this.#e[this.#r]}readBytes(e){if(!this.byteAligned)throw new Error("Bytes must be byte-aligned");const r=this.#e.subarray(this.#r,this.#r+e);return this.#r+=e,this.#t=this.#e[this.#r],r}getPosition(){return[this.#r,this.#n]}setPosition([e,r]){this.#r=e,this.#n=r,this.#t=this.#e[e]}}const Ml={SequenceHeader:1,TemporalDelimiter:2,FrameHeader:3,TileGroup:4,Metadata:5,Frame:6,RedundantFrameHeader:7,TileList:8,Padding:15},Il={Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,GenericFilm:8,Bt2020:9,Xyz:10,Smpte431:11,Smpte432:12,Ebu3213:22},Ll={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},Ol={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 pe extends Dl{static ObuType=Ml;static ColorPrimaries=Il;static TransferCharacteristics=Ll;static MatrixCoefficients=Ol;#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 r=0n;r<8n;r+=1n){const n=this.f(8);if(e|=BigInt(n&127)<<7n*r,this.#e+=1,(n&128)==0)break}return e}*annexBBitstream(){for(;!this.ended;){const e=this.leb128();yield*this.temporalUnit(e)}}*temporalUnit(e){for(;e>0;){const r=this.leb128();e-=BigInt(this.#e),yield*this.frameUnit(r),e-=r}}*frameUnit(e){for(;e>0;){const r=this.leb128();e-=BigInt(this.#e);const n=this.openBitstreamUnit(r);n&&(yield n),e-=r}}#t=0;openBitstreamUnit(e){const r=this.obuHeader();let n;if(r.obu_has_size_field)n=this.leb128();else if(e!==void 0)n=e-1n-(r.obu_extension_flag?1n:0n);else throw new Error("obu_has_size_field must be true");const o=this.getPosition();if(r.obu_type!==pe.ObuType.SequenceHeader&&r.obu_type!==pe.ObuType.TemporalDelimiter&&this.#t!==0&&r.obu_extension_header){const c=!!(this.#t&1<<r.obu_extension_header.temporal_id),u=!!(this.#t&1<<r.obu_extension_header.spatial_id+8);if(!c||!u){this.skip(Number(n));return}}let s;switch(r.obu_type){case pe.ObuType.SequenceHeader:s=this.sequenceHeaderObu();break}const a=this.getPosition(),d=(a[0]-o[0])*8+(o[1]-a[1]);return n>0&&this.skip(Number(n)*8-d),{obu_header:r,obu_size:n,sequence_header_obu:s}}obuHeader(){if(!!this.f1())throw new Error("Invalid data");const r=this.f(4),n=!!this.f1(),o=!!this.f1();this.f1();let s;return n&&(s=this.obuExtensionHeader()),{obu_type:r,obu_extension_flag:n,obu_has_size_field:o,obu_extension_header:s}}obuExtensionHeader(){const e=this.f(3),r=this.f(2);return this.skip(3),{temporal_id:e,spatial_id:r}}static SelectScreenContentTools=2;static SelectIntegerMv=2;sequenceHeaderObu(){const e=this.f(3),r=!!this.f1(),n=!!this.f1();let o=!1,s,a=!1,d,c=!1,u=0;const l=[],f=[],p=[],m=[],x=[];let g,v;if(n)l[0]=0,f[0]=this.f(5),p[0]=0,m[0]=!1,x[0]=!1;else{o=!!this.f1(),o&&(s=this.timingInfo(),a=!!this.f1(),a&&(d=this.decoderModelInfo(),g=[])),c=!!this.f1(),c&&(v=[]),u=this.f(5);for(let re=0;re<=u;re+=1)l[re]=this.f(12),f[re]=this.f(5),f[re]>7?p[re]=this.f1():p[re]=0,a?(m[re]=!!this.f1(),m[re]&&(g[re]=this.operatingParametersInfo(d))):m[re]=!1,c&&(x[re]=!!this.f1(),x[re]&&(v[re]=this.f(4)))}const y=this.chooseOperatingPoint();this.#t=l[y];const S=this.f(4),_=this.f(4),b=this.f(S+1),C=this.f(_+1);let R=!1,T,A;n||(R=!!this.f1(),R&&(T=this.f(4),A=this.f(3)));const E=!!this.f1(),j=!!this.f1(),N=!!this.f1();let G=!1,z=!1,P=!1,D=!1,M=!1,U=!1,H=!1,W=!1,V=pe.SelectScreenContentTools,F=!1,Q=pe.SelectIntegerMv,Z;n||(G=!!this.f1(),z=!!this.f1(),P=!!this.f1(),D=!!this.f1(),M=!!this.f1(),M&&(U=!!this.f1(),H=!!this.f1()),W=!!this.f1(),W||(V=this.f1()),V>0&&(F=!!this.f1(),F||(Q=this.f1())),M&&(Z=this.f(3)));const oe=!!this.f1(),ee=!!this.f1(),xe=!!this.f1(),de=this.colorConfig(e),ue=!!this.f1();return{seq_profile:e,still_picture:r,reduced_still_picture_header:n,timing_info_present_flag:o,timing_info:s,decoder_model_info_present_flag:a,decoder_model_info:d,initial_display_delay_present_flag:c,initial_display_delay_minus_1:v,operating_points_cnt_minus_1:u,operating_point_idc:l,seq_level_idx:f,seq_tier:p,decoder_model_present_for_this_op:m,operating_parameters_info:g,initial_display_delay_present_for_this_op:x,frame_width_bits_minus_1:S,frame_height_bits_minus_1:_,max_frame_width_minus_1:b,max_frame_height_minus_1:C,frame_id_numbers_present_flag:R,delta_frame_id_length_minus_2:T,additional_frame_id_length_minus_1:A,use_128x128_superblock:E,enable_filter_intra:j,enable_intra_edge_filter:N,enable_interintra_compound:G,enable_masked_compound:z,enable_warped_motion:P,enable_dual_filter:D,enable_order_hint:M,enable_jnt_comp:U,enable_ref_frame_mvs:H,seq_choose_screen_content_tools:W,seq_force_screen_content_tools:V,seq_choose_integer_mv:F,seq_force_integer_mv:Q,order_hint_bits_minus_1:Z,enable_superres:oe,enable_cdef:ee,enable_restoration:xe,color_config:de,film_grain_params_present:ue}}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),r=this.f(32),n=!!this.f1();let o;return n&&(o=this.uvlc()),{num_units_in_display_tick:e,time_scale:r,equal_picture_interval:n,num_ticks_per_picture_minus_1:o}}decoderModelInfo(){const e=this.f(5),r=this.f(32),n=this.f(5),o=this.f(5);return{buffer_delay_length_minus_1:e,num_units_in_decoding_tick:r,buffer_removal_time_length_minus_1:n,frame_presentation_time_length_minus_1:o}}operatingParametersInfo(e){const r=e.buffer_delay_length_minus_1+1,n=this.f(r),o=this.f(r),s=!!this.f1();return{decoder_buffer_delay:n,encoder_buffer_delay:o,low_delay_mode_flag:s}}chooseOperatingPoint(){return 0}colorConfig(e){const r=!!this.f1();let n=!1,o=8;e===2&&r?(n=!!this.f1(),o=n?12:10):e<=2&&(o=r?10:8);let s=!1;e===1&&(s=!!this.f1());const a=!!this.f1();let d=pe.ColorPrimaries.Unspecified,c=pe.TransferCharacteristics.Unspecified,u=pe.MatrixCoefficients.Unspecified;a&&(d=this.f(8),c=this.f(8),u=this.f(8));let l=!1,f,p,m=0,x=!1;if(s)l=!!this.f1(),f=!0,p=!0;else{if(d===pe.ColorPrimaries.Bt709&&c===pe.TransferCharacteristics.Srgb&&u===pe.MatrixCoefficients.Identity)l=!0,f=!1,p=!1;else{switch(l=!!this.f1(),e){case 0:f=!0,p=!0;break;case 1:f=!1,p=!1;break;default:o==12?(f=!!this.f1(),f?p=!!this.f1():p=!1):(f=!0,p=!1);break}f&&p&&(m=this.f(2))}x=!!this.f1()}return{high_bitdepth:r,twelve_bit:n,BitDepth:o,mono_chrome:s,color_description_present_flag:a,color_primaries:d,transfer_characteristics:c,matrix_coefficients:u,color_range:l,subsampling_x:f,subsampling_y:p,chroma_sample_position:m,separate_uv_delta_q:x}}}function*lo(t){let e=-1,r=0,n=!1;for(let o=0;o<t.length;o+=1){const s=t[o];if(n){if(s>3)throw new Error("Invalid data");n=!1;continue}if(s===0){r+=1;continue}const a=r;if(r=0,e===-1){if(a>=2&&s===1){e=o+1;continue}throw new Error("Invalid data")}if(!(a<2)){if(s===1){yield t.subarray(e,o-a),e=o+1;continue}if(a>2)throw new Error("Invalid data");switch(s){case 2:throw new Error("Invalid data");case 3:n=!0;break}}}if(n)throw new Error("Invalid data");yield t.subarray(e,t.length)}class Ut{#e;#t;#r;#n=0;#o=0;#s=7;#i=0;get byteLength(){return this.#t}get stopBitIndex(){return this.#r}get bytePosition(){return this.#o}get bitPosition(){return this.#s}get ended(){return this.#o>=this.#t&&this.#s<=this.#r}constructor(e){this.#e=e;for(let r=e.length-1;r>=0;r-=1){if(this.#e[r]===0)continue;const n=e[r];for(let o=0;o<8;o+=1)if((n>>o&1)===1){this.#t=r,this.#r=o,this.#c();return}}throw new Error("Stop bit not found")}#c(){if(this.#i=this.#e[this.#o],this.#n===2&&this.#i===3){this.#n=0,this.#o+=1,this.#c();return}this.#i===0?this.#n+=1:this.#n=0}next(){if(this.ended)throw new Error("Bit index out of bounds");const e=this.#i>>this.#s&1;return this.#s-=1,this.#s<0&&(this.#o+=1,this.#s=7,this.#c()),e}read(e){if(e>32)throw new Error("Read length too large");let r=0;for(let n=0;n<e;n+=1)r=r<<1|this.next();return r}#l(){if(this.#o>=this.#t&&this.#s<this.#r)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.#o+=1,this.#s=7,this.#c(),this.#l();e>=8;e-=8)this.#o+=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.#n,bytePosition:this.#o,bitPosition:this.#s,byte:this.#i}}#a(e){this.#n=e.zeroCount,this.#o=e.bytePosition,this.#s=e.bitPosition,this.#i=e.byte}peek(e){const r=this.#d(),n=this.read(e);return this.#a(r),n}readBytes(e){const r=new Uint8Array(e);for(let n=0;n<e;n+=1)r[n]=this.read(8);return r}peekBytes(e){const r=this.#d(),n=this.readBytes(e);return this.#a(r),n}}function Fl(t){const e=new Ut(t);if(e.next()!==0)throw new Error("Invalid data");const r=e.read(2);if(e.read(5)!==7)throw new Error("Invalid data");if(r===0)throw new Error("Invalid data");const o=e.read(8),s=e.peek(8),a=!!e.next(),d=!!e.next(),c=!!e.next(),u=!!e.next(),l=!!e.next(),f=!!e.next();if(e.read(2)!==0)throw new Error("Invalid data");const p=e.read(8),m=e.decodeExponentialGolombNumber();if(o===100||o===110||o===122||o===244||o===44||o===83||o===86||o===118||o===128||o===138||o===139||o===134){const T=e.decodeExponentialGolombNumber();if(T===3&&e.next(),e.decodeExponentialGolombNumber(),e.decodeExponentialGolombNumber(),e.next(),!!e.next())for(let E=0;E<(T!==3?8:12);E+=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 T=e.decodeExponentialGolombNumber();for(let A=0;A<T;A+=1)e.decodeExponentialGolombNumber()}e.decodeExponentialGolombNumber(),e.next();const g=e.decodeExponentialGolombNumber(),v=e.decodeExponentialGolombNumber(),y=e.next();y||e.next(),e.next();const S=!!e.next();let _,b,C,R;return S?(_=e.decodeExponentialGolombNumber(),b=e.decodeExponentialGolombNumber(),C=e.decodeExponentialGolombNumber(),R=e.decodeExponentialGolombNumber()):(_=0,b=0,C=0,R=0),e.next(),{profile_idc:o,constraint_set:s,constraint_set0_flag:a,constraint_set1_flag:d,constraint_set2_flag:c,constraint_set3_flag:u,constraint_set4_flag:l,constraint_set5_flag:f,level_idc:p,seq_parameter_set_id:m,pic_width_in_mbs_minus1:g,pic_height_in_map_units_minus1:v,frame_mbs_only_flag:y,frame_cropping_flag:S,frame_crop_left_offset:_,frame_crop_right_offset:b,frame_crop_top_offset:C,frame_crop_bottom_offset:R}}function Bl(t){let e,r;for(const n of lo(t))switch(n[0]&31){case 7:if(e=n,r)return{sequenceParameterSet:e,pictureParameterSet:r};break;case 8:if(r=n,e)return{sequenceParameterSet:e,pictureParameterSet:r};break}throw new Error("Invalid data")}function Ul(t){const{sequenceParameterSet:e,pictureParameterSet:r}=Bl(t),{profile_idc:n,constraint_set:o,level_idc:s,pic_width_in_mbs_minus1:a,pic_height_in_map_units_minus1:d,frame_mbs_only_flag:c,frame_crop_left_offset:u,frame_crop_right_offset:l,frame_crop_top_offset:f,frame_crop_bottom_offset:p}=Fl(e),m=(a+1)*16,x=(d+1)*(2-c)*16,g=u*2,v=l*2,y=f*2,S=p*2,_=m-g-v,b=x-y-S;return{pictureParameterSet:r,sequenceParameterSet:e,profileIndex:n,constraintSet:o,levelIndex:s,encodedWidth:m,encodedHeight:x,cropLeft:g,cropRight:v,cropTop:y,cropBottom:S,croppedWidth:_,croppedHeight:b}}function Gl(t){switch(t){case 0:case 3:return 1;case 1:case 2:return 2;default:throw new Error("Invalid chroma_format_idc")}}function Hl(t){switch(t){case 0:case 2:case 3:return 1;case 1:return 2;default:throw new Error("Invalid chroma_format_idc")}}function zl(t){const e=new Ut(t);if(e.next()!==0)throw new Error("Invalid NALU header");const r=e.read(6),n=e.read(6),o=e.read(3);return{nal_unit_type:r,nuh_layer_id:n,nuh_temporal_id_plus1:o}}function Wl(t){const e=new Ut(t),r=e.read(4),n=!!e.next(),o=!!e.next(),s=e.read(6),a=e.read(3),d=!!e.next();e.skip(16);const c=uo(e,!0,a),u=!!e.next(),l=[],f=[],p=[];for(let j=u?0:a;j<=a;j+=1)l[j]=e.decodeExponentialGolombNumber(),f[j]=e.decodeExponentialGolombNumber(),p[j]=e.decodeExponentialGolombNumber();const m=e.read(6),x=e.decodeExponentialGolombNumber(),g=[];for(let j=1;j<=x;j+=1){g[j]=[];for(let N=0;N<=m;N+=1)g[j][N]=!!e.next()}const v=!!e.next();let y,S,_,b,C,R,T,A;if(v){y=e.read(32),S=e.read(32),_=!!e.next(),_&&(b=e.decodeExponentialGolombNumber()),C=e.decodeExponentialGolombNumber(),R=[],T=[!0],A=[];for(let j=0;j<C;j+=1)R[j]=e.decodeExponentialGolombNumber(),j>0&&(T[j]=!!e.next()),A[j]=fo(e,T[j],a)}const E=!!e.next();return{vps_video_parameter_set_id:r,vps_base_layer_internal_flag:n,vps_base_layer_available_flag:o,vps_max_layers_minus1:s,vps_max_sub_layers_minus1:a,vps_temporal_id_nesting_flag:d,profileTierLevel:c,vps_sub_layer_ordering_info_present_flag:u,vps_max_dec_pic_buffering_minus1:l,vps_max_num_reorder_pics:f,vps_max_latency_increase_plus1:p,vps_max_layer_id:m,vps_num_layer_sets_minus1:x,layer_id_included_flag:g,vps_timing_info_present_flag:v,vps_num_units_in_tick:y,vps_time_scale:S,vps_poc_proportional_to_timing_flag:_,vps_num_ticks_poc_diff_one_minus1:b,vps_num_hrd_parameters:C,hrd_layer_set_idx:R,cprms_present_flag:T,hrdParameters:A,vps_extension_flag:E}}function $l(t){const e=new Ut(t),r=e.read(4),n=e.read(3),o=!!e.next(),s=uo(e,!0,n),a=e.decodeExponentialGolombNumber(),d=e.decodeExponentialGolombNumber();let c;d===3&&(c=!!e.next());const u=e.decodeExponentialGolombNumber(),l=e.decodeExponentialGolombNumber(),f=!!e.next();let p,m,x,g;f&&(p=e.decodeExponentialGolombNumber(),m=e.decodeExponentialGolombNumber(),x=e.decodeExponentialGolombNumber(),g=e.decodeExponentialGolombNumber());const v=e.decodeExponentialGolombNumber(),y=e.decodeExponentialGolombNumber(),S=e.decodeExponentialGolombNumber(),_=[],b=[],C=[],R=!!e.next();for(let B=R?0:n;B<=n;B+=1)_[B]=e.decodeExponentialGolombNumber(),b[B]=e.decodeExponentialGolombNumber(),C[B]=e.decodeExponentialGolombNumber();const T=e.decodeExponentialGolombNumber(),A=e.decodeExponentialGolombNumber(),E=e.decodeExponentialGolombNumber(),j=e.decodeExponentialGolombNumber(),N=e.decodeExponentialGolombNumber(),G=e.decodeExponentialGolombNumber(),z=!!e.next();let P,D;z&&(P=!!e.next(),P&&(D=ql(e)));const M=!!e.next(),U=!!e.next(),H=!!e.next();let W,V,F,Q,Z;H&&(W=e.read(4),V=e.read(4),F=e.read(4),Q=e.read(4),Z=!!e.next());const oe=e.decodeExponentialGolombNumber(),ee=[];for(let B=0;B<oe;B+=1)ee[B]=Xl(e,B,oe,ee);const xe=!!e.next();let de,ue,re;if(xe){de=e.decodeExponentialGolombNumber(),ue=[],re=[];for(let B=0;B<de;B+=1)ue[B]=e.read(S+4),re[B]=!!e.next()}const me=!!e.next(),ge=!!e.next(),fe=!!e.next();let Le;fe&&(Le=Vl(e,n));const Re=!!e.next();let we,L,O,w,I;if(Re&&(we=!!e.next(),L=!!e.next(),O=!!e.next(),w=!!e.next(),I=e.read(4)),we)throw new Error("Not implemented");let X;L&&(X=Kl(e));let Y;if(O&&(Y=Ql(e)),w)throw new Error("Not implemented");let k;if(I){k=[];let B=0;for(;!e.ended;)k[B]=!!e.next(),B+=1}return{sps_video_parameter_set_id:r,sps_max_sub_layers_minus1:n,sps_temporal_id_nesting_flag:o,profileTierLevel:s,sps_seq_parameter_set_id:a,chroma_format_idc:d,separate_colour_plane_flag:c,pic_width_in_luma_samples:u,pic_height_in_luma_samples:l,conformance_window_flag:f,conf_win_left_offset:p,conf_win_right_offset:m,conf_win_top_offset:x,conf_win_bottom_offset:g,bit_depth_luma_minus8:v,bit_depth_chroma_minus8:y,log2_max_pic_order_cnt_lsb_minus4:S,sps_sub_layer_ordering_info_present_flag:R,sps_max_dec_pic_buffering_minus1:_,sps_max_num_reorder_pics:b,sps_max_latency_increase_plus1:C,log2_min_luma_coding_block_size_minus3:T,log2_diff_max_min_luma_coding_block_size:A,log2_min_luma_transform_block_size_minus2:E,log2_diff_max_min_luma_transform_block_size:j,max_transform_hierarchy_depth_inter:N,max_transform_hierarchy_depth_intra:G,scaling_list_enabled_flag:z,sps_scaling_list_data_present_flag:P,scalingListData:D,amp_enabled_flag:M,sample_adaptive_offset_enabled_flag:U,pcm_enabled_flag:H,pcm_sample_bit_depth_luma_minus1:W,pcm_sample_bit_depth_chroma_minus1:V,log2_min_pcm_luma_coding_block_size_minus3:F,log2_diff_max_min_pcm_luma_coding_block_size:Q,pcm_loop_filter_disabled_flag:Z,num_short_term_ref_pic_sets:oe,shortTermRefPicSets:ee,long_term_ref_pics_present_flag:xe,num_long_term_ref_pics_sps:de,lt_ref_pic_poc_lsb_sps:ue,used_by_curr_pic_lt_sps_flag:re,sps_temporal_mvp_enabled_flag:me,strong_intra_smoothing_enabled_flag:ge,vui_parameters_present_flag:fe,vuiParameters:Le,sps_extension_present_flag:Re,sps_range_extension_flag:we,sps_multilayer_extension_flag:L,sps_3d_extension_flag:O,sps_scc_extension_flag:w,sps_extension_4bits:I,spsMultilayerExtension:X,sps3dExtension:Y,sps_extension_data_flag:k}}function gn(t){const e=t.read(2),r=!!t.next(),n=t.read(5),o=t.peekBytes(4),s=[];for(let R=0;R<32;R+=1)s[R]=!!t.next();const a=t.peekBytes(6),d=!!t.next(),c=!!t.next(),u=!!t.next(),l=!!t.next();let f,p,m,x,g,v,y,S,_,b;n===4||s[4]||n===5||s[5]||n===6||s[6]||n===7||s[7]||n===8||s[8]||n===9||s[9]||n===10||s[10]||n===11||s[11]?(f=!!t.next(),p=!!t.next(),m=!!t.next(),x=!!t.next(),g=!!t.next(),v=!!t.next(),y=!!t.next(),S=!!t.next(),_=!!t.next(),n===5||s[5]||n===9||s[9]||n===10||s[10]||n===11||s[11]?(b=!!t.next(),t.skip(33)):t.skip(34)):n===2||s[2]?(t.skip(7),S=!!t.next(),t.skip(35)):t.skip(43);let C;return n===1||s[1]||n===2||s[2]||n===3||s[3]||n===4||s[4]||n===5||s[5]||n===9||s[9]||n===11||s[11]?C=!!t.next():t.skip(1),{profile_space:e,tier_flag:r,profile_idc:n,profileCompatibilitySet:o,profile_compatibility_flag:s,constraintSet:a,progressive_source_flag:d,interlaced_source_flag:c,non_packed_constraint_flag:u,frame_only_constraint_flag:l,max_12bit_constraint_flag:f,max_10bit_constraint_flag:p,max_8bit_constraint_flag:m,max_422chroma_constraint_flag:x,max_420chroma_constraint_flag:g,max_monochrome_constraint_flag:v,intra_constraint_flag:y,one_picture_only_constraint_flag:S,lower_bit_rate_constraint_flag:_,max_14bit_constraint_flag:b,inbld_flag:C}}function uo(t,e,r){let n;n=gn(t);const o=t.read(8),s=[],a=[];for(let u=0;u<r;u+=1)s[u]=!!t.next(),a[u]=!!t.next();if(r>0)for(let u=r;u<8;u+=1)t.read(2);const d=[],c=[];for(let u=0;u<r;u+=1)s[u]&&(d[u]=gn(t)),a[u]&&(c[u]=t.read(8));return{generalProfileTier:n,general_level_idc:o,sub_layer_profile_present_flag:s,sub_layer_level_present_flag:a,subLayerProfileTier:d,sub_layer_level_idc:c}}function ql(t){const e=[];for(let r=0;r<4;r+=1){e[r]=[];for(let n=0;n<6;n+=r===3?3:1)if(!!!t.next())t.decodeExponentialGolombNumber();else{let s=8;const a=Math.min(64,1<<4+(r<<1));r>1&&(s=t.decodeExponentialGolombNumber()+8),e[r][n]=[];for(let d=0;d<a;d+=1){const c=t.decodeExponentialGolombNumber();s=(s+c+256)%256,e[r][n][d]=s}}}return e}function Xl(t,e,r,n){let o=!1;e!==0&&(o=!!t.next());let s=0,a=!1,d=0;const c=[],u=[];let l=0,f=0;const p=[],m=[],x=[],g=[];if(o){e===r&&(s=t.decodeExponentialGolombNumber()),a=!!t.next(),d=t.decodeExponentialGolombNumber();const v=e-(s+1),y=n[v],S=y.num_negative_pics+y.num_positive_pics;for(let N=0;N<=S;N+=1)c[N]=!!t.next(),c[N]?u[N]=!0:u[N]=!!t.next();const _=(1-2*Number(a))*(d+1),b=[],C=[],R=[],T=[];let A=0;for(let N=0;N<y.num_negative_pics;N+=1)A-=y.delta_poc_s0_minus1[N]+1,b[N]=A;A=0;for(let N=0;N<y.num_positive_pics;N+=1)A+=y.delta_poc_s1_minus1[N]+1,C[N]=A;let E=0;if(y.num_positive_pics>0)for(let N=y.num_positive_pics-1;N>=0;N-=1)A=C[N]+_,A<0&&u[y.num_negative_pics+N]&&(R[E]=A,m[E]=c[y.num_negative_pics+N],E+=1);_<0&&u[S]&&(R[E]=_,m[E]=c[S],E+=1);for(let N=0;N<y.num_negative_pics;N+=1)A=b[N]+_,A<0&&u[N]&&(R[E]=A,m[E]=c[N],E+=1);l=E;let j=0;for(E=0;E<l;E+=1){const N=R[E];p[E]=-(N-j-1),j=N}if(E=0,y.num_negative_pics>0)for(let N=y.num_negative_pics-1;N>=0;N-=1)A=b[N]+_,A>0&&u[N]&&(T[E]=A,g[E]=c[N],E+=1);_>0&&u[S]&&(T[E]=_,g[E]=c[S],E+=1);for(let N=0;N<y.num_positive_pics;N+=1)A=C[N]+_,A>0&&u[y.num_negative_pics+N]&&(T[E]=A,g[E]=c[y.num_negative_pics+N],E+=1);for(f=E,j=0,E=0;E<f;E+=1){const N=T[E];x[E]=N-j-1,j=N}}else{l=t.decodeExponentialGolombNumber(),f=t.decodeExponentialGolombNumber();for(let v=0;v<l;v+=1)p[v]=t.decodeExponentialGolombNumber(),m[v]=!!t.next();for(let v=0;v<f;v+=1)x[v]=t.decodeExponentialGolombNumber(),g[v]=!!t.next()}return{stRpsIdx:e,num_short_term_ref_pic_sets:r,inter_ref_pic_set_prediction_flag:o,delta_idx_minus1:s,delta_rps_sign:a,abs_delta_rps_minus1:d,used_by_curr_pic_flag:c,use_delta_flag:u,num_negative_pics:l,num_positive_pics:f,delta_poc_s0_minus1:p,used_by_curr_pic_s0_flag:m,delta_poc_s1_minus1:x,used_by_curr_pic_s1_flag:g}}function Vl(t,e){const r=!!t.next();let n,o,s;r&&(n=t.read(8),n===255&&(o=t.read(16),s=t.read(16)));const a=!!t.next();let d;a&&(d=!!t.next());const c=!!t.next();let u,l,f,p,m,x;c&&(u=t.read(3),l=!!t.next(),f=!!t.next(),f&&(p=t.read(8),m=t.read(8),x=t.read(8)));const g=!!t.next();let v,y;g&&(v=t.decodeExponentialGolombNumber(),y=t.decodeExponentialGolombNumber());const S=!!t.next(),_=!!t.next(),b=!!t.next(),C=!!t.next();let R,T,A,E;C&&(R=t.decodeExponentialGolombNumber(),T=t.decodeExponentialGolombNumber(),A=t.decodeExponentialGolombNumber(),E=t.decodeExponentialGolombNumber());const j=!!t.next();let N,G,z,P,D,M;j&&(N=t.read(32),G=t.read(32),z=!!t.next(),z&&(P=t.decodeExponentialGolombNumber()),D=!!t.next(),D&&(M=fo(t,!0,e)));const U=!!t.next();let H,W,V,F,Q,Z,oe,ee;return U&&(H=!!t.next(),W=!!t.next(),V=!!t.next(),F=t.decodeExponentialGolombNumber(),Q=t.decodeExponentialGolombNumber(),Z=t.decodeExponentialGolombNumber(),oe=t.decodeExponentialGolombNumber(),ee=t.decodeExponentialGolombNumber()),{aspect_ratio_info_present_flag:r,aspect_ratio_idc:n,sar_width:o,sar_height:s,overscan_info_present_flag:a,overscan_appropriate_flag:d,video_signal_type_present_flag:c,video_format:u,video_full_range_flag:l,colour_description_present_flag:f,colour_primaries:p,transfer_characteristics:m,matrix_coeffs:x,chroma_loc_info_present_flag:g,chroma_sample_loc_type_top_field:v,chroma_sample_loc_type_bottom_field:y,neutral_chroma_indication_flag:S,field_seq_flag:_,frame_field_info_present_flag:b,default_display_window_flag:C,def_disp_win_left_offset:R,def_disp_win_right_offset:T,def_disp_win_top_offset:A,def_disp_win_bottom_offset:E,vui_timing_info_present_flag:j,vui_num_units_in_tick:N,vui_time_scale:G,vui_poc_proportional_to_timing_flag:z,vui_num_ticks_poc_diff_one_minus1:P,vui_hrd_parameters_present_flag:D,vui_hrd_parameters:M,bitstream_restriction_flag:U,tiles_fixed_structure_flag:H,motion_vectors_over_pic_boundaries_flag:W,restricted_ref_pic_lists_flag:V,min_spatial_segmentation_idc:F,max_bytes_per_pic_denom:Q,max_bits_per_min_cu_denom:Z,log2_max_mv_length_horizontal:oe,log2_max_mv_length_vertical:ee}}function fo(t,e,r){let n,o,s,a,d,c,u,l,f,p,m,x,g;e&&(n=!!t.next(),o=!!t.next(),(n||o)&&(s=!!t.next(),s&&(a=t.read(8),d=t.read(5),c=!!t.next(),u=t.read(5)),l=t.read(4),f=t.read(4),s&&(p=t.read(4)),m=t.read(5),x=t.read(5),g=t.read(5)));const v=[],y=[],S=[],_=[],b=[],C=[],R=[];for(let T=0;T<=r;T+=1)v[T]=!!t.next(),v[T]||(y[T]=!!t.next()),y[T]?S[T]=t.decodeExponentialGolombNumber():_[T]=!!t.next(),_[T]||(b[T]=t.decodeExponentialGolombNumber()),n&&(C[T]=_n(t,T,xn(b[T]))),o&&(R[T]=_n(t,T,xn(b[T])));return{nal_hrd_parameters_present_flag:n,vcl_hrd_parameters_present_flag:o,sub_pic_hrd_params_present_flag:s,tick_divisor_minus2:a,du_cpb_removal_delay_increment_length_minus1:d,sub_pic_cpb_params_in_pic_timing_sei_flag:c,dpb_output_delay_du_length_minus1:u,bit_rate_scale:l,cpb_size_scale:f,cpb_size_du_scale:p,initial_cpb_removal_delay_length_minus1:m,au_cpb_removal_delay_length_minus1:x,dpb_output_delay_length_minus1:g,fixed_pic_rate_general_flag:v,fixed_pic_rate_within_cvs_flag:y,elemental_duration_in_tc_minus1:S,low_delay_hrd_flag:_,cpb_cnt_minus1:b,nalHrdParameters:C,vclHrdParameters:R}}function _n(t,e,r){const n=[],o=[],s=[],a=[],d=[];for(let c=0;c<r;c+=1)n[c]=t.decodeExponentialGolombNumber(),o[c]=t.decodeExponentialGolombNumber(),e>0&&(d[c]=!!t.next());return{bit_rate_value_minus1:n,cpb_size_value_minus1:o,cpb_size_du_value_minus1:s,bit_rate_du_value_minus1:a,cbr_flag:d}}function xn(t){return t+1}function Yl(t){let e,r,n,o=0;for(const s of lo(t)){const a=zl(s),d={...a,data:s,rbsp:s.subarray(2)};switch(a.nal_unit_type){case 32:e=d;break;case 33:r=d;break;case 34:n=d;break;default:continue}if(o+=1,o===3)return{videoParameterSet:e,sequenceParameterSet:r,pictureParameterSet:n}}throw new Error("Invalid data")}function Kl(t){return{inter_view_mv_vert_constraint_flag:!!t.next()}}function Ql(t){const e=[],r=[];e[0]=!!t.next(),r[0]=!!t.next();const n=t.decodeExponentialGolombNumber(),o=!!t.next(),s=!!t.next(),a=!!t.next(),d=!!t.next();e[1]=!!t.next(),r[1]=!!t.next();const c=!!t.next(),u=t.decodeExponentialGolombNumber(),l=!!t.next(),f=!!t.next(),p=!!t.next(),m=!!t.next(),x=!!t.next();return{iv_di_mc_enabled_flag:e,iv_mv_scal_enabled_flag:r,log2_ivmc_sub_pb_size_minus3:n,iv_res_pred_enabled_flag:o,depth_ref_enabled_flag:s,vsp_mc_enabled_flag:a,dbbp_enabled_flag:d,tex_mc_enabled_flag:c,log2_texmc_sub_pb_size_minus3:u,intra_contour_enabled_flag:l,intra_dc_only_wedge_enabled_flag:f,cqt_cu_part_pred_enabled_flag:p,inter_dc_only_enabled_flag:m,skip_intra_enabled_flag:x}}function Jl(t){const{videoParameterSet:e,sequenceParameterSet:r,pictureParameterSet:n}=Yl(t),{profileTierLevel:{generalProfileTier:{profile_space:o,tier_flag:s,profile_idc:a,profileCompatibilitySet:d,constraintSet:c},general_level_idc:u}}=Wl(e.rbsp),{chroma_format_idc:l,pic_width_in_luma_samples:f,pic_height_in_luma_samples:p,conf_win_left_offset:m=0,conf_win_right_offset:x=0,conf_win_top_offset:g=0,conf_win_bottom_offset:v=0}=$l(r.rbsp),y=Gl(l),S=Hl(l),_=f-y*(m+x),b=p-S*(g+v);return{videoParameterSet:e,sequenceParameterSet:r,pictureParameterSet:n,generalProfileSpace:o,generalProfileIndex:a,generalProfileCompatibilitySet:d,generalTierFlag:s,generalLevelIndex:u,generalConstraintSet:c,encodedWidth:f,encodedHeight:p,cropLeft:m,cropRight:x,cropTop:g,cropBottom:v,croppedWidth:_,croppedHeight:b}}function vn(t){return t.toString(16).toUpperCase()}function nr(t){return t.toString(16).toUpperCase().padStart(2,"0")}function at(t){return t.toString(10).padStart(2,"0")}class Zl{#e;#t;constructor(e,r){this.#e=e,this.#t=r}#r(e){const n=new pe(e).searchSequenceHeaderObu();if(!n)return;const{seq_profile:o,seq_level_idx:[s=0],max_frame_width_minus_1:a,max_frame_height_minus_1:d,color_config:{BitDepth:c,mono_chrome:u,subsampling_x:l,subsampling_y:f,chroma_sample_position:p,color_description_present_flag:m}}=n;let x,g,v,y;m?{color_primaries:x,transfer_characteristics:g,matrix_coefficients:v,color_range:y}=n.color_config:(x=pe.ColorPrimaries.Bt709,g=pe.TransferCharacteristics.Bt709,v=pe.MatrixCoefficients.Bt709,y=!1);const S=a+1,_=d+1;this.#t(S,_);const b=["av01",o.toString(16),at(s)+(n.seq_tier[0]?"H":"M"),at(c),u?"1":"0",(l?"1":"0")+(f?"1":"0")+p.toString(),at(x),at(g),at(v),y?"1":"0"].join(".");this.#e.configure({codec:b,optimizeForLatency:!0})}decode(e){e.type!=="configuration"&&(this.#r(e.data),this.#e.decode(new EncodedVideoChunk({type:e.keyframe===!1?"delta":"key",timestamp:0,data:e.data})))}}class ho{#e;#t;constructor(e){this.#t=e}decode(e){if(e.type==="configuration"){this.#e=e.data,this.configure(e.data);return}let r;this.#e!==void 0?(r=new Uint8Array(this.#e.length+e.data.length),r.set(this.#e,0),r.set(e.data,this.#e.length),this.#e=void 0):r=e.data,this.#t.decode(new EncodedVideoChunk({type:e.keyframe===!1?"delta":"key",timestamp:0,data:r}))}}class eu extends ho{#e;#t;constructor(e,r){super(e),this.#e=e,this.#t=r}configure(e){const{profileIndex:r,constraintSet:n,levelIndex:o,croppedWidth:s,croppedHeight:a}=Ul(e);this.#t(s,a);const d="avc1."+nr(r)+nr(n)+nr(o);this.#e.configure({codec:d,optimizeForLatency:!0})}}class tu extends ho{#e;#t;constructor(e,r){super(e),this.#e=e,this.#t=r}configure(e){const{generalProfileSpace:r,generalProfileIndex:n,generalProfileCompatibilitySet:o,generalTierFlag:s,generalLevelIndex:a,generalConstraintSet:d,croppedWidth:c,croppedHeight:u}=Jl(e);this.#t(c,u);const l=["hev1",["","A","B","C"][r]+n.toString(),vn(Al(o,0)),(s?"H":"L")+a.toString(),...Array.from(d,vn)].join(".");this.#e.configure({codec:l,codedWidth:c,codedHeight:u,optimizeForLatency:!0})}}class ru{listeners=[];constructor(){this.event=this.event.bind(this)}addEventListener(e){this.listeners.push(e);const r=()=>{const n=this.listeners.indexOf(e);n!==-1&&this.listeners.splice(n,1)};return r.dispose=r,r}event=(e,r,...n)=>{const o={listener:e,thisArg:r,args:n};return this.addEventListener(o)};fire(e){for(const r of this.listeners.slice())r.listener.apply(r.thisArg,[e,...r.args])}dispose(){this.listeners.length=0}}class nu{#e;#t=new ReadableStream({start:e=>{this.#e=e},pull:e=>{e.enqueue(this.#n())}},{highWaterMark:0});#r=this.#t.getReader();#n;#o=0;#s;constructor(e,r){this.#n=e,this.#s=r}async borrow(){return(await this.#r.read()).value}return(e){this.#o<this.#s&&(this.#e.enqueue(e),this.#o+=1)}}class su{#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 r=await createImageBitmap(e);return this.#t.transferFromImageBitmap(r),this.#e instanceof OffscreenCanvas?await this.#e.convertToBlob({type:"image/png"}):new Promise((n,o)=>{this.#e.toBlob(s=>{s?n(s):o(new Error("Failed to convert canvas to blob"))},"image/png")})}}const bn=new nu(()=>new su,4);class yn{static get isSupported(){return typeof globalThis.VideoDecoder<"u"}static capabilities={h264:{},h265:{},av1:{}};#e;get codec(){return this.#e}#t;#r;get writable(){return this.#r}#n;#o;#s;get renderer(){return this.#s}#i=0;#c=0;get framesRendered(){return this.#c}#l=0;get framesSkipped(){return this.#l}#d=new ru;get sizeChanged(){return this.#d.event}#a;#p=!1;#u;#f;#m=0;constructor({codec:e,renderer:r}){switch(this.#e=e,this.#s=r,this.#a=new VideoDecoder({output:n=>{if(this.#f?.close(),this.#f=n.clone(),this.#p){this.#u&&(this.#u.close(),this.#l+=1),this.#u=n;return}this.#_(n)},error:n=>{this.#g(n)}}),this.#e){case Tt.H264:this.#t=new eu(this.#a,this.#h);break;case Tt.H265:this.#t=new tu(this.#a,this.#h);break;case Tt.AV1:this.#t=new Zl(this.#a,this.#h);break;default:throw new Error(`Unsupported codec: ${this.#e}`)}this.#r=new jl({start:n=>{this.#n?n.error(this.#n):this.#o=n},write:n=>{this.#t.decode(n)}}),this.#x()}#g(e){if(this.#o)try{this.#o.error(e)}catch{}else this.#n=e}async#_(e){try{if(this.#p=!0,this.#h(e.displayWidth,e.displayHeight),await this.#s.draw(e),this.#i+=1,e.close(),this.#u){const r=this.#u;this.#u=void 0,await this.#_(r)}this.#p=!1}catch(r){this.#g(r)}}#h=(e,r)=>{this.#s.setSize(e,r),this.#d.fire({width:e,height:r})};#x=()=>{this.#i>0&&(this.#c+=1,this.#l+=this.#i-1,this.#i=0),this.#m=requestAnimationFrame(this.#x)};async snapshot(){const e=this.#f;if(!e)return;const r=await bn.borrow(),n=await r.capture(e);return bn.return(r),n}dispose(){cancelAnimationFrame(this.#m),this.#a.state!=="closed"&&this.#a.close(),this.#u?.close(),this.#f?.close()}}var sr={exports:{}},or={exports:{}},wn;function Br(){return wn||(wn=1,(function(){function t(e,r){throw new Error("abstract")}t.prototype.drawFrame=function(e){throw new Error("abstract")},t.prototype.clear=function(){throw new Error("abstract")},or.exports=t})()),or.exports}var ir={exports:{}},ar={exports:{}},cr={exports:{}},En;function ou(){return En||(En=1,(function(){function t(e){for(var r=0,n=e>>1;n!=0;)n=n>>1,r++;if(e!==1<<r)throw"chroma plane dimensions must be power of 2 ratio to luma plane dimensions; got "+e;return r}cr.exports=t})()),cr.exports}var Sn;function iu(){return Sn||(Sn=1,(function(){var t=ou();function e(r,n){var o=r.format.width|0,s=r.format.height|0,a=t(r.format.width/r.format.chromaWidth)|0,d=t(r.format.height/r.format.chromaHeight)|0,c=r.y.bytes,u=r.u.bytes,l=r.v.bytes,f=r.y.stride|0,p=r.u.stride|0,m=r.v.stride|0,x=o<<2,g=0,v=0,y=0,S=0,_=0,b=0,C=0,R=0,T=0,A=0,E=0,j=0,N=0,G=0,z=0,P=0,D=0,M=0;if(a==1&&d==1)for(C=0,R=x,M=0,P=0;P<s;P+=2){for(v=P*f|0,y=v+f|0,S=M*p|0,_=M*m|0,z=0;z<o;z+=2)T=u[S++]|0,A=l[_++]|0,j=(409*A|0)-57088|0,N=(100*T|0)+(208*A|0)-34816|0,G=(516*T|0)-70912|0,E=298*c[v++]|0,n[C]=E+j>>8,n[C+1]=E-N>>8,n[C+2]=E+G>>8,C+=4,E=298*c[v++]|0,n[C]=E+j>>8,n[C+1]=E-N>>8,n[C+2]=E+G>>8,C+=4,E=298*c[y++]|0,n[R]=E+j>>8,n[R+1]=E-N>>8,n[R+2]=E+G>>8,R+=4,E=298*c[y++]|0,n[R]=E+j>>8,n[R+1]=E-N>>8,n[R+2]=E+G>>8,R+=4;C+=x,R+=x,M++}else for(b=0,P=0;P<s;P++)for(D=0,M=P>>d,g=P*f|0,S=M*p|0,_=M*m|0,z=0;z<o;z++)D=z>>a,T=u[S+D]|0,A=l[_+D]|0,j=(409*A|0)-57088|0,N=(100*T|0)+(208*A|0)-34816|0,G=(516*T|0)-70912|0,E=298*c[g++]|0,n[b]=E+j>>8,n[b+1]=E-N>>8,n[b+2]=E+G>>8,b+=4}ar.exports={convertYCbCr:e}})()),ar.exports}var Cn;function au(){return Cn||(Cn=1,(function(){var t=Br(),e=iu();function r(n){var o=this,s=n.getContext("2d"),a=null,d=null,c=null;function u(f,p){a=s.createImageData(f,p);for(var m=a.data,x=f*p*4,g=0;g<x;g+=4)m[g+3]=255}function l(f,p){d=document.createElement("canvas"),d.width=f,d.height=p,c=d.getContext("2d")}return o.drawFrame=function(p){var m=p.format;(n.width!==m.displayWidth||n.height!==m.displayHeight)&&(n.width=m.displayWidth,n.height=m.displayHeight),(a===null||a.width!=m.width||a.height!=m.height)&&u(m.width,m.height),e.convertYCbCr(p,a.data);var x=m.cropWidth!=m.displayWidth||m.cropHeight!=m.displayHeight,g;x?(d||l(m.cropWidth,m.cropHeight),g=c):g=s,g.putImageData(a,-m.cropLeft,-m.cropTop,m.cropLeft,m.cropTop,m.cropWidth,m.cropHeight),x&&s.drawImage(d,0,0,m.displayWidth,m.displayHeight)},o.clear=function(){s.clearRect(0,0,n.width,n.height)},o}r.prototype=Object.create(t.prototype),ir.exports=r})()),ir.exports}var lr={exports:{}},ur,Nn;function cu(){return Nn||(Nn=1,ur={vertex:`precision mediump float;
|
|
58
|
+
|
|
59
|
+
attribute vec2 aPosition;
|
|
60
|
+
attribute vec2 aLumaPosition;
|
|
61
|
+
attribute vec2 aChromaPosition;
|
|
62
|
+
varying vec2 vLumaPosition;
|
|
63
|
+
varying vec2 vChromaPosition;
|
|
64
|
+
void main() {
|
|
65
|
+
gl_Position = vec4(aPosition, 0, 1);
|
|
66
|
+
vLumaPosition = aLumaPosition;
|
|
67
|
+
vChromaPosition = aChromaPosition;
|
|
68
|
+
}
|
|
69
|
+
`,fragment:`// inspired by https://github.com/mbebenita/Broadway/blob/master/Player/canvas.js
|
|
70
|
+
|
|
71
|
+
precision mediump float;
|
|
72
|
+
|
|
73
|
+
uniform sampler2D uTextureY;
|
|
74
|
+
uniform sampler2D uTextureCb;
|
|
75
|
+
uniform sampler2D uTextureCr;
|
|
76
|
+
varying vec2 vLumaPosition;
|
|
77
|
+
varying vec2 vChromaPosition;
|
|
78
|
+
void main() {
|
|
79
|
+
// Y, Cb, and Cr planes are uploaded as ALPHA textures.
|
|
80
|
+
float fY = texture2D(uTextureY, vLumaPosition).w;
|
|
81
|
+
float fCb = texture2D(uTextureCb, vChromaPosition).w;
|
|
82
|
+
float fCr = texture2D(uTextureCr, vChromaPosition).w;
|
|
83
|
+
|
|
84
|
+
// Premultipy the Y...
|
|
85
|
+
float fYmul = fY * 1.1643828125;
|
|
86
|
+
|
|
87
|
+
// And convert that to RGB!
|
|
88
|
+
gl_FragColor = vec4(
|
|
89
|
+
fYmul + 1.59602734375 * fCr - 0.87078515625,
|
|
90
|
+
fYmul - 0.39176171875 * fCb - 0.81296875 * fCr + 0.52959375,
|
|
91
|
+
fYmul + 2.017234375 * fCb - 1.081390625,
|
|
92
|
+
1
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
`,vertexStripe:`precision mediump float;
|
|
96
|
+
|
|
97
|
+
attribute vec2 aPosition;
|
|
98
|
+
attribute vec2 aTexturePosition;
|
|
99
|
+
varying vec2 vTexturePosition;
|
|
100
|
+
|
|
101
|
+
void main() {
|
|
102
|
+
gl_Position = vec4(aPosition, 0, 1);
|
|
103
|
+
vTexturePosition = aTexturePosition;
|
|
104
|
+
}
|
|
105
|
+
`,fragmentStripe:`// extra 'stripe' texture fiddling to work around IE 11's poor performance on gl.LUMINANCE and gl.ALPHA textures
|
|
106
|
+
|
|
107
|
+
precision mediump float;
|
|
108
|
+
|
|
109
|
+
uniform sampler2D uStripe;
|
|
110
|
+
uniform sampler2D uTexture;
|
|
111
|
+
varying vec2 vTexturePosition;
|
|
112
|
+
void main() {
|
|
113
|
+
// Y, Cb, and Cr planes are mapped into a pseudo-RGBA texture
|
|
114
|
+
// so we can upload them without expanding the bytes on IE 11
|
|
115
|
+
// which doesn't allow LUMINANCE or ALPHA textures
|
|
116
|
+
// The stripe textures mark which channel to keep for each pixel.
|
|
117
|
+
// Each texture extraction will contain the relevant value in one
|
|
118
|
+
// channel only.
|
|
119
|
+
|
|
120
|
+
float fLuminance = dot(
|
|
121
|
+
texture2D(uStripe, vTexturePosition),
|
|
122
|
+
texture2D(uTexture, vTexturePosition)
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
gl_FragColor = vec4(0, 0, 0, fLuminance);
|
|
126
|
+
}
|
|
127
|
+
`}),ur}var Tn;function lu(){return Tn||(Tn=1,(function(){var t=Br(),e=cu();function r(n){var o=this,s=r.contextForCanvas(n);if(s===null)throw new Error("WebGL unavailable");function a(P,D){var M=s.createShader(P);if(s.shaderSource(M,D),s.compileShader(M),!s.getShaderParameter(M,s.COMPILE_STATUS)){var U=s.getShaderInfoLog(M);throw s.deleteShader(M),new Error("GL shader compilation for "+P+" failed: "+U)}return M}var d,c,u=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),l={},f={},p={},m,x,g,v,y,S,_,b,C,R;function T(P,D){return(!l[P]||D)&&(l[P]=s.createTexture()),l[P]}function A(P,D,M,U,H){var W=!l[P]||D,V=T(P,D);if(s.activeTexture(s.TEXTURE0),r.stripe){var F=!l[P+"_temp"]||D,Q=T(P+"_temp",D);s.bindTexture(s.TEXTURE_2D,Q),F?(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,M/4,U,0,s.RGBA,s.UNSIGNED_BYTE,H)):s.texSubImage2D(s.TEXTURE_2D,0,0,0,M/4,U,s.RGBA,s.UNSIGNED_BYTE,H);var Z=l[P+"_stripe"],oe=!Z||D;oe&&(Z=T(P+"_stripe",D)),s.bindTexture(s.TEXTURE_2D,Z),oe&&(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,M,1,0,s.RGBA,s.UNSIGNED_BYTE,N(M)))}else s.bindTexture(s.TEXTURE_2D,V),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,M,U,0,s.ALPHA,s.UNSIGNED_BYTE,H)):s.texSubImage2D(s.TEXTURE_2D,0,0,0,M,U,s.ALPHA,s.UNSIGNED_BYTE,H)}function E(P,D,M,U){var H=l[P];s.useProgram(c);var W=f[P];(!W||D)&&(s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,H),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,M,U,0,s.RGBA,s.UNSIGNED_BYTE,null),W=f[P]=s.createFramebuffer()),s.bindFramebuffer(s.FRAMEBUFFER,W),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,H,0);var V=l[P+"_temp"];s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,V),s.uniform1i(S,1);var F=l[P+"_stripe"];s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,F),s.uniform1i(y,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(v),s.vertexAttribPointer(v,2,s.FLOAT,!1,0,0),s.viewport(0,0,M,U),s.drawArrays(s.TRIANGLES,0,u.length/2),s.bindFramebuffer(s.FRAMEBUFFER,null)}function j(P,D,M){s.activeTexture(D),s.bindTexture(s.TEXTURE_2D,l[P]),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(d,P),M)}function N(P){if(p[P])return p[P];for(var D=P,M=new Uint32Array(D),U=0;U<D;U+=4)M[U]=255,M[U+1]=65280,M[U+2]=16711680,M[U+3]=4278190080;return p[P]=new Uint8Array(M.buffer)}function G(P,D){var M=a(s.VERTEX_SHADER,P),U=a(s.FRAGMENT_SHADER,D),H=s.createProgram();if(s.attachShader(H,M),s.attachShader(H,U),s.linkProgram(H),!s.getProgramParameter(H,s.LINK_STATUS)){var W=s.getProgramInfoLog(H);throw s.deleteProgram(H),new Error("GL program linking failed: "+W)}return H}function z(){if(r.stripe){c=G(e.vertexStripe,e.fragmentStripe),s.getAttribLocation(c,"aPosition"),g=s.createBuffer();var P=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);s.bindBuffer(s.ARRAY_BUFFER,g),s.bufferData(s.ARRAY_BUFFER,P,s.STATIC_DRAW),v=s.getAttribLocation(c,"aTexturePosition"),y=s.getUniformLocation(c,"uStripe"),S=s.getUniformLocation(c,"uTexture")}d=G(e.vertex,e.fragment),m=s.createBuffer(),s.bindBuffer(s.ARRAY_BUFFER,m),s.bufferData(s.ARRAY_BUFFER,u,s.STATIC_DRAW),x=s.getAttribLocation(d,"aPosition"),_=s.createBuffer(),b=s.getAttribLocation(d,"aLumaPosition"),C=s.createBuffer(),R=s.getAttribLocation(d,"aChromaPosition")}return o.drawFrame=function(P){var D=P.format,M=!d||n.width!==D.displayWidth||n.height!==D.displayHeight;if(M&&(n.width=D.displayWidth,n.height=D.displayHeight,o.clear()),d||z(),M){var U=function(H,W,V){var F=D.cropLeft/V,Q=(D.cropLeft+D.cropWidth)/V,Z=(D.cropTop+D.cropHeight)/D.height,oe=D.cropTop/D.height,ee=new Float32Array([F,Z,Q,Z,F,oe,F,oe,Q,Z,Q,oe]);s.bindBuffer(s.ARRAY_BUFFER,H),s.bufferData(s.ARRAY_BUFFER,ee,s.STATIC_DRAW)};U(_,b,P.y.stride),U(C,R,P.u.stride*D.width/D.chromaWidth)}A("uTextureY",M,P.y.stride,D.height,P.y.bytes),A("uTextureCb",M,P.u.stride,D.chromaHeight,P.u.bytes),A("uTextureCr",M,P.v.stride,D.chromaHeight,P.v.bytes),r.stripe&&(E("uTextureY",M,P.y.stride,D.height),E("uTextureCb",M,P.u.stride,D.chromaHeight),E("uTextureCr",M,P.v.stride,D.chromaHeight)),s.useProgram(d),s.viewport(0,0,n.width,n.height),j("uTextureY",s.TEXTURE0,0),j("uTextureCb",s.TEXTURE1,1),j("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,_),s.enableVertexAttribArray(b),s.vertexAttribPointer(b,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,C),s.enableVertexAttribArray(R),s.vertexAttribPointer(R,2,s.FLOAT,!1,0,0),s.drawArrays(s.TRIANGLES,0,u.length/2)},o.clear=function(){s.viewport(0,0,n.width,n.height),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT)},o.clear(),o}r.stripe=!1,r.contextForCanvas=function(n){var o={preferLowPowerToHighPerformance:!0,powerPreference:"low-power",failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!0};return n.getContext("webgl",o)||n.getContext("experimental-webgl",o)},r.isAvailable=function(){var n=document.createElement("canvas"),o;n.width=1,n.height=1;try{o=r.contextForCanvas(n)}catch{return!1}if(o){var s=o.TEXTURE0,a=4,d=4,c=o.createTexture(),u=new Uint8Array(a*d),l=r.stripe?a/4:a,f=r.stripe?o.RGBA:o.ALPHA,p=r.stripe?o.NEAREST:o.LINEAR;o.activeTexture(s),o.bindTexture(o.TEXTURE_2D,c),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,p),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,p),o.texImage2D(o.TEXTURE_2D,0,f,l,d,0,f,o.UNSIGNED_BYTE,u);var m=o.getError();return!m}else return!1},r.prototype=Object.create(t.prototype),lr.exports=r})()),lr.exports}var Rn;function uu(){return Rn||(Rn=1,(function(){var t=Br(),e=au(),r=lu(),n={FrameSink:t,SoftwareFrameSink:e,WebGLFrameSink:r,attach:function(o,s){s=s||{};var a="webGL"in s?s.webGL:r.isAvailable();return a?new r(o,s):new e(o,s)}};sr.exports=n})()),sr.exports}uu();function po(){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 mo{#e;get canvas(){return this.#e}constructor(e){e?this.#e=e:this.#e=po()}setSize(e,r){(this.#e.width!==e||this.#e.height!==r)&&(this.#e.width=e,this.#e.height=r)}}class du extends mo{#e;constructor(e){super(e),this.#e=this.canvas.getContext("bitmaprenderer",{alpha:!1})}async draw(e){const r=await createImageBitmap(e);this.#e.transferFromImageBitmap(r)}}const fu=Promise.resolve();function kn(t,e){const r={powerPreference:"low-power",alpha:!1,failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!!e};return t.getContext("webgl2",r)||t.getContext("webgl",r)}class ut extends mo{static vertexShaderSource=`
|
|
128
|
+
attribute vec2 xy;
|
|
129
|
+
|
|
130
|
+
varying highp vec2 uv;
|
|
131
|
+
|
|
132
|
+
void main(void) {
|
|
133
|
+
gl_Position = vec4(xy, 0.0, 1.0);
|
|
134
|
+
// Map vertex coordinates (-1 to +1) to UV coordinates (0 to 1).
|
|
135
|
+
// UV coordinates are Y-flipped relative to vertex coordinates.
|
|
136
|
+
uv = vec2((1.0 + xy.x) / 2.0, (1.0 - xy.y) / 2.0);
|
|
137
|
+
}
|
|
138
|
+
`;static fragmentShaderSource=`
|
|
139
|
+
varying highp vec2 uv;
|
|
140
|
+
|
|
141
|
+
uniform sampler2D texture;
|
|
142
|
+
|
|
143
|
+
void main(void) {
|
|
144
|
+
gl_FragColor = texture2D(texture, uv);
|
|
145
|
+
}
|
|
146
|
+
`;static get isSupported(){const e=po();return!!kn(e)}#e;constructor(e,r){super(e);const n=kn(this.canvas,r);if(!n)throw new Error("WebGL not supported");this.#e=n;const o=n.createShader(n.VERTEX_SHADER);if(n.shaderSource(o,ut.vertexShaderSource),n.compileShader(o),!n.getShaderParameter(o,n.COMPILE_STATUS))throw new Error(n.getShaderInfoLog(o));const s=n.createShader(n.FRAGMENT_SHADER);if(n.shaderSource(s,ut.fragmentShaderSource),n.compileShader(s),!n.getShaderParameter(s,n.COMPILE_STATUS))throw new Error(n.getShaderInfoLog(s));const a=n.createProgram();if(n.attachShader(a,o),n.attachShader(a,s),n.linkProgram(a),!n.getProgramParameter(a,n.LINK_STATUS))throw new Error(n.getProgramInfoLog(a));n.useProgram(a);const d=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,d),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),n.STATIC_DRAW);const c=n.getAttribLocation(a,"xy");n.vertexAttribPointer(c,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(c);const u=n.createTexture();n.bindTexture(n.TEXTURE_2D,u),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}draw(e){const r=this.#e;return r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,e),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight),r.drawArrays(r.TRIANGLE_FAN,0,4),fu}}const Pn=50,hu=300;function pu({deviceId:t,className:e,onFallback:r,fallbackTimeout:n=5e3,enableControl:o=!1,onTapSuccess:s,onTapError:a,onSwipeSuccess:d,onSwipeError:c,onStreamReady:u}){const l=h.useRef(null),f=h.useRef(null),p=h.useRef(null),m=h.useRef(null),x=h.useRef(null),g=h.useRef(null),v=h.useRef(null),y=h.useRef(!1),S=h.useRef(!1),_=h.useRef(r),b=h.useRef(n),C=h.useRef(u),[R,T]=h.useState("connecting"),[A,E]=h.useState(null),[j,N]=h.useState(null),[G,z]=h.useState(null),P=h.useRef(!1),D=h.useRef(null),M=h.useRef(!1),U=h.useRef(0),H=h.useRef(null),W=h.useRef(null),V=h.useRef(null),F=h.useRef(null);h.useEffect(()=>{_.current=r,b.current=n,C.current=u},[r,n,u]),h.useEffect(()=>{(async()=>{try{const O=await Ln(t);O.success&&z({width:O.width,height:O.height})}catch(O){console.error("[ScrcpyPlayer] Failed to fetch device resolution:",O)}})()},[t]);const Q=h.useCallback(()=>{const L=m.current,O=p.current;if(!L||!O||!j)return;const w=O.clientWidth,I=O.clientHeight,{width:X,height:Y}=j,k=X/Y;let B=w,K=w/k;K>I&&(K=I,B=I*k),L.width=X,L.height=Y,L.style.width=`${B}px`,L.style.height=`${K}px`},[j]);h.useEffect(()=>{const L=()=>Q();return window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[Q]),h.useEffect(()=>{Q()},[j,Q]);const Z=h.useCallback(async()=>{if(ut.isSupported){const O=new ut;return{renderer:O,element:O.canvas}}const L=new du;return{renderer:L,element:L.canvas}},[]),oe=h.useCallback(async L=>{if(!yn.isSupported)throw new Error("Current browser does not support WebCodecs API. Please use the latest Chrome/Edge.");const{renderer:O,element:w}=await Z();return m.current=w,p.current&&!w.parentElement&&p.current.appendChild(w),new yn({codec:L,renderer:O})},[Z]),ee=h.useCallback(()=>{y.current||(y.current=!0,x.current&&(clearTimeout(x.current),x.current=null))},[]),xe=h.useCallback(L=>{let O=!1,w=[];const I=new TransformStream({transform(Y,k){if(Y.type==="configuration"){k.enqueue(Y),O=!0,w.length>0&&(w.forEach(B=>k.enqueue(B)),w=[]);return}if(Y.type==="data"&&!O){w.push(Y);return}k.enqueue(Y)}});return new ReadableStream({start(Y){let k=!1;const B=ve=>{if(!k)try{ee();const ke={...ve,data:ve.data instanceof Uint8Array?ve.data:new Uint8Array(ve.data)};Y.enqueue(ke)}catch(ke){console.error("[ScrcpyPlayer] Video enqueue error:",ke),k=!0,ye()}},K=ve=>{k||(Y.error(new Error(ve?.message||"Socket error")),k=!0,ye())},he=()=>{k||(Y.close(),k=!0,ye())},ye=()=>{l.current?.off("video-data",B),l.current?.off("error",K),l.current?.off("disconnect",he)};return l.current?.on("video-data",B),l.current?.on("error",K),l.current?.on("disconnect",he),()=>{k=!0,ye()}}}).pipeThrough(I)},[ee]),de=h.useCallback((L=!1)=>{if(L&&(S.current=!0),f.current){try{f.current.dispose()}catch(O){console.error("[ScrcpyPlayer] Failed to dispose decoder:",O)}f.current=null}m.current=null,l.current&&(l.current.disconnect(),l.current=null),C.current?.(null),g.current&&(clearTimeout(g.current),g.current=null),x.current&&(clearTimeout(x.current),x.current=null),T("disconnected"),N(null),E(null)},[]),ue=h.useCallback(()=>{de(!0),y.current=!1,T("connecting"),E(null);const L=Nt({path:"/socket.io",transports:["websocket"],timeout:1e4});l.current=L,L.on("connect",()=>{L.emit("connect-device",{device_id:t,maxSize:1280,bitRate:4e6}),x.current=setTimeout(()=>{y.current||(T("error"),E("Video stream timeout"),S.current=!0,L.close(),_.current?.())},b.current)}),L.on("video-metadata",async O=>{try{f.current&&(f.current.dispose(),f.current=null);const w=O?.codec?O.codec:Tt.H264;f.current=await oe(w),f.current.sizeChanged(({width:X,height:Y})=>{N({width:X,height:Y})}),xe(O).pipeTo(f.current.writable).catch(X=>{console.error("[ScrcpyPlayer] Video stream error:",X)}),T("connected"),C.current?.({close:()=>L.close()})}catch(w){console.error("[ScrcpyPlayer] Decoder initialization failed:",w),T("error"),E("Decoder initialization failed"),S.current=!0,L.close(),_.current?.()}}),L.on("error",O=>{console.error("[ScrcpyPlayer] Socket error:",O),T("error"),E(O?.message||"Socket error")}),L.on("disconnect",()=>{if(S.current){S.current=!1;return}T("disconnected"),C.current?.(null),g.current||(g.current=setTimeout(()=>{g.current=null,v.current?.()},3e3))})},[t,de,oe,xe]);h.useEffect(()=>{v.current=ue},[ue]),h.useEffect(()=>(queueMicrotask(()=>{ue()}),()=>{W.current&&(clearTimeout(W.current),W.current=null),V.current&&(clearTimeout(V.current),V.current=null),de(!0)}),[ue,de]);const re=()=>{if(j)return{width:j.width,height:j.height};const L=m.current;return L?{width:L.width,height:L.height}:null},me=(L,O)=>{const w=m.current,I=re();if(!w||!I)return null;const X=w.getBoundingClientRect();if(L<X.left||L>X.right||O<X.top||O>X.bottom)return null;const Y=L-X.left,k=O-X.top,B=Math.round(Y/X.width*I.width),K=Math.round(k/X.height*I.height),he=G?G.width/I.width:1,ye=G?G.height/I.height:1;return{x:Math.round(B*he),y:Math.round(K*ye)}},ge=async L=>{if(!o||R!=="connected")return;const O=me(L.clientX,L.clientY);if(O){P.current=!0,M.current=!1,D.current={x:L.clientX,y:L.clientY};try{await Vo(O.x,O.y,t)}catch(w){console.error("[ScrcpyPlayer] Touch down failed:",w)}}},fe=L=>{if(!P.current||R!=="connected")return;const O=Date.now(),w=me(L.clientX,L.clientY);if(w){if(D.current){const I=L.clientX-D.current.x,X=L.clientY-D.current.y;Math.hypot(I,X)>4&&(M.current=!0)}if(H.current=w,O-U.current<Pn){W.current||(W.current=setTimeout(()=>{W.current=null,H.current&&(qr(H.current.x,H.current.y,t).catch(I=>{console.error("[ScrcpyPlayer] Touch move failed:",I)}),H.current=null,U.current=Date.now())},Pn));return}U.current=O,qr(w.x,w.y,t).catch(I=>{console.error("[ScrcpyPlayer] Touch move failed:",I)})}},Le=async L=>{if(!P.current||R!=="connected")return;const O=me(L.clientX,L.clientY);if(P.current=!1,D.current=null,!!O)try{await $r(O.x,O.y,t),M.current?d?.():s?.()}catch(w){const I=String(w);M.current?c?.(I):a?.(I)}},Re=async L=>{if(!P.current||R!=="connected")return;const O=me(L.clientX,L.clientY);if(P.current=!1,D.current=null,!!O)try{await $r(O.x,O.y,t)}catch(w){console.error("[ScrcpyPlayer] Touch cancel failed:",w)}},we=L=>{if(!o||R!=="connected")return;L.preventDefault();const O=L.deltaY;F.current||(F.current={deltaY:0}),F.current.deltaY+=O,V.current&&clearTimeout(V.current),V.current=setTimeout(async()=>{const w=F.current;if(F.current=null,!w)return;const I=m.current,X=re();if(!I||!X)return;const Y=I.getBoundingClientRect(),k=Y.left+Y.width/2,B=Y.top+Y.height/2,K=me(k,B);if(!K)return;const he=Math.max(Math.min(w.deltaY,600),-600),ye=B+he,ve=me(k,ye);if(ve)try{const ke=await Xo(K.x,K.y,ve.x,ve.y,300,t);ke.success?d?.():c?.(ke.error||"Scroll failed")}catch(ke){c?.(String(ke))}},hu)};return i.jsx("div",{className:`relative w-full h-full flex items-center justify-center ${e||""}`,children:i.jsx("div",{ref:p,className:"relative w-full h-full flex items-center justify-center bg-slate-50 dark:bg-slate-900",onMouseDown:ge,onMouseMove:fe,onMouseUp:Le,onMouseLeave:Re,onWheel:we,children:R!=="connected"&&i.jsxs("div",{className:"absolute inset-0 flex items-center justify-center text-slate-400",children:[R==="connecting"&&"Connecting...",R==="error"&&(A||"Connection error"),R==="disconnected"&&"Disconnected"]})})})}const go=h.forwardRef(({className:t,...e},r)=>i.jsx("textarea",{className:ae("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:text-slate-100 dark:ring-offset-slate-950 dark:placeholder:text-slate-400 dark:focus-visible:ring-[#1d9bf0] resize-none",t),ref:r,...e}));go.displayName="Textarea";const At=h.forwardRef(({className:t,...e},r)=>i.jsx("div",{ref:r,className:ae("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}));At.displayName="Card";const mu=h.forwardRef(({className:t,...e},r)=>i.jsx("div",{ref:r,className:ae("flex flex-col space-y-1.5 p-6",t),...e}));mu.displayName="CardHeader";const gu=h.forwardRef(({className:t,...e},r)=>i.jsx("h3",{ref:r,className:ae("text-xl font-semibold leading-none tracking-tight",t),...e}));gu.displayName="CardTitle";const _u=h.forwardRef(({className:t,...e},r)=>i.jsx("p",{ref:r,className:ae("text-sm text-slate-500 dark:text-slate-400",t),...e}));_u.displayName="CardDescription";const xu=h.forwardRef(({className:t,...e},r)=>i.jsx("div",{ref:r,className:ae("p-6 pt-0",t),...e}));xu.displayName="CardContent";const vu=h.forwardRef(({className:t,...e},r)=>i.jsx("div",{ref:r,className:ae("flex items-center p-6 pt-0",t),...e}));vu.displayName="CardFooter";var Gt="Popover",[_o]=rt(Gt,[On]),ht=On(),[bu,Ue]=_o(Gt),xo=t=>{const{__scopePopover:e,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:a=!1}=t,d=ht(e),c=h.useRef(null),[u,l]=h.useState(!1),[f,p]=Mt({prop:n,defaultProp:o??!1,onChange:s,caller:Gt});return i.jsx(Yo,{...d,children:i.jsx(bu,{scope:e,contentId:Qe(),triggerRef:c,open:f,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),hasCustomAnchor:u,onCustomAnchorAdd:h.useCallback(()=>l(!0),[]),onCustomAnchorRemove:h.useCallback(()=>l(!1),[]),modal:a,children:r})})};xo.displayName=Gt;var vo="PopoverAnchor",yu=h.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,o=Ue(vo,r),s=ht(r),{onCustomAnchorAdd:a,onCustomAnchorRemove:d}=o;return h.useEffect(()=>(a(),()=>d()),[a,d]),i.jsx(Fn,{...s,...n,ref:e})});yu.displayName=vo;var bo="PopoverTrigger",yo=h.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,o=Ue(bo,r),s=ht(r),a=_e(e,o.triggerRef),d=i.jsx(le.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":No(o.open),...n,ref:a,onClick:se(t.onClick,o.onOpenToggle)});return o.hasCustomAnchor?d:i.jsx(Fn,{asChild:!0,...s,children:d})});yo.displayName=bo;var Ur="PopoverPortal",[wu,Eu]=_o(Ur,{forceMount:void 0}),wo=t=>{const{__scopePopover:e,forceMount:r,children:n,container:o}=t,s=Ue(Ur,e);return i.jsx(wu,{scope:e,forceMount:r,children:i.jsx(Me,{present:r||s.open,children:i.jsx(Mn,{asChild:!0,container:o,children:n})})})};wo.displayName=Ur;var et="PopoverContent",Eo=h.forwardRef((t,e)=>{const r=Eu(et,t.__scopePopover),{forceMount:n=r.forceMount,...o}=t,s=Ue(et,t.__scopePopover);return i.jsx(Me,{present:n||s.open,children:s.modal?i.jsx(Cu,{...o,ref:e}):i.jsx(Nu,{...o,ref:e})})});Eo.displayName=et;var Su=Rt("PopoverContent.RemoveScroll"),Cu=h.forwardRef((t,e)=>{const r=Ue(et,t.__scopePopover),n=h.useRef(null),o=_e(e,n),s=h.useRef(!1);return h.useEffect(()=>{const a=n.current;if(a)return Jn(a)},[]),i.jsx(Er,{as:Su,allowPinchZoom:!0,children:i.jsx(So,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:se(t.onCloseAutoFocus,a=>{a.preventDefault(),s.current||r.triggerRef.current?.focus()}),onPointerDownOutside:se(t.onPointerDownOutside,a=>{const d=a.detail.originalEvent,c=d.button===0&&d.ctrlKey===!0,u=d.button===2||c;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:se(t.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),Nu=h.forwardRef((t,e)=>{const r=Ue(et,t.__scopePopover),n=h.useRef(!1),o=h.useRef(!1);return i.jsx(So,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{t.onCloseAutoFocus?.(s),s.defaultPrevented||(n.current||r.triggerRef.current?.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{t.onInteractOutside?.(s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=s.target;r.triggerRef.current?.contains(a)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),So=h.forwardRef((t,e)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEscapeKeyDown:d,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:l,...f}=t,p=Ue(et,r),m=ht(r);return zn(),i.jsx(wr,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:i.jsx(In,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:l,onEscapeKeyDown:d,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:i.jsx(Ko,{"data-state":No(p.open),role:"dialog",id:p.contentId,...m,...f,ref:e,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Co="PopoverClose",Tu=h.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,o=Ue(Co,r);return i.jsx(le.button,{type:"button",...n,ref:e,onClick:se(t.onClick,()=>o.onOpenChange(!1))})});Tu.displayName=Co;var Ru="PopoverArrow",ku=h.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,o=ht(r);return i.jsx(Qo,{...o,...n,ref:e})});ku.displayName=Ru;function No(t){return t?"open":"closed"}var Pu=xo,Au=yo,ju=wo,Du=Eo;function Mu({...t}){return i.jsx(Pu,{"data-slot":"popover",...t})}function Iu({...t}){return i.jsx(Au,{"data-slot":"popover-trigger",...t})}function Lu({className:t,align:e="center",sideOffset:r=4,...n}){return i.jsx(ju,{children:i.jsx(Du,{"data-slot":"popover-content",align:e,sideOffset:r,className:ae("bg-popover text-popover-foreground 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...n})})}function Ou(t,[e,r]){return Math.min(r,Math.max(e,t))}function Fu(t,e){return h.useReducer((r,n)=>e[r][n]??r,t)}var Gr="ScrollArea",[To]=rt(Gr),[Bu,Se]=To(Gr),Ro=h.forwardRef((t,e)=>{const{__scopeScrollArea:r,type:n="hover",dir:o,scrollHideDelay:s=600,...a}=t,[d,c]=h.useState(null),[u,l]=h.useState(null),[f,p]=h.useState(null),[m,x]=h.useState(null),[g,v]=h.useState(null),[y,S]=h.useState(0),[_,b]=h.useState(0),[C,R]=h.useState(!1),[T,A]=h.useState(!1),E=_e(e,N=>c(N)),j=jr(o);return i.jsx(Bu,{scope:r,type:n,dir:j,scrollHideDelay:s,scrollArea:d,viewport:u,onViewportChange:l,content:f,onContentChange:p,scrollbarX:m,onScrollbarXChange:x,scrollbarXEnabled:C,onScrollbarXEnabledChange:R,scrollbarY:g,onScrollbarYChange:v,scrollbarYEnabled:T,onScrollbarYEnabledChange:A,onCornerWidthChange:S,onCornerHeightChange:b,children:i.jsx(le.div,{dir:j,...a,ref:E,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":_+"px",...t.style}})})});Ro.displayName=Gr;var ko="ScrollAreaViewport",Po=h.forwardRef((t,e)=>{const{__scopeScrollArea:r,children:n,nonce:o,...s}=t,a=Se(ko,r),d=h.useRef(null),c=_e(e,d,a.onViewportChange);return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),i.jsx(le.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...t.style},children:i.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});Po.displayName=ko;var Ie="ScrollAreaScrollbar",Ao=h.forwardRef((t,e)=>{const{forceMount:r,...n}=t,o=Se(Ie,t.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:a}=o,d=t.orientation==="horizontal";return h.useEffect(()=>(d?s(!0):a(!0),()=>{d?s(!1):a(!1)}),[d,s,a]),o.type==="hover"?i.jsx(Uu,{...n,ref:e,forceMount:r}):o.type==="scroll"?i.jsx(Gu,{...n,ref:e,forceMount:r}):o.type==="auto"?i.jsx(jo,{...n,ref:e,forceMount:r}):o.type==="always"?i.jsx(Hr,{...n,ref:e}):null});Ao.displayName=Ie;var Uu=h.forwardRef((t,e)=>{const{forceMount:r,...n}=t,o=Se(Ie,t.__scopeScrollArea),[s,a]=h.useState(!1);return h.useEffect(()=>{const d=o.scrollArea;let c=0;if(d){const u=()=>{window.clearTimeout(c),a(!0)},l=()=>{c=window.setTimeout(()=>a(!1),o.scrollHideDelay)};return d.addEventListener("pointerenter",u),d.addEventListener("pointerleave",l),()=>{window.clearTimeout(c),d.removeEventListener("pointerenter",u),d.removeEventListener("pointerleave",l)}}},[o.scrollArea,o.scrollHideDelay]),i.jsx(Me,{present:r||s,children:i.jsx(jo,{"data-state":s?"visible":"hidden",...n,ref:e})})}),Gu=h.forwardRef((t,e)=>{const{forceMount:r,...n}=t,o=Se(Ie,t.__scopeScrollArea),s=t.orientation==="horizontal",a=zt(()=>c("SCROLL_END"),100),[d,c]=Fu("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return h.useEffect(()=>{if(d==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[d,o.scrollHideDelay,c]),h.useEffect(()=>{const u=o.viewport,l=s?"scrollLeft":"scrollTop";if(u){let f=u[l];const p=()=>{const m=u[l];f!==m&&(c("SCROLL"),a()),f=m};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,s,c,a]),i.jsx(Me,{present:r||d!=="hidden",children:i.jsx(Hr,{"data-state":d==="hidden"?"hidden":"visible",...n,ref:e,onPointerEnter:se(t.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:se(t.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),jo=h.forwardRef((t,e)=>{const r=Se(Ie,t.__scopeScrollArea),{forceMount:n,...o}=t,[s,a]=h.useState(!1),d=t.orientation==="horizontal",c=zt(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,l=r.viewport.offsetHeight<r.viewport.scrollHeight;a(d?u:l)}},10);return tt(r.viewport,c),tt(r.content,c),i.jsx(Me,{present:n||s,children:i.jsx(Hr,{"data-state":s?"visible":"hidden",...o,ref:e})})}),Hr=h.forwardRef((t,e)=>{const{orientation:r="vertical",...n}=t,o=Se(Ie,t.__scopeScrollArea),s=h.useRef(null),a=h.useRef(0),[d,c]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Oo(d.viewport,d.content),l={...n,sizes:d,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:p=>a.current=p};function f(p,m){return Xu(p,a.current,d,m)}return r==="horizontal"?i.jsx(Hu,{...l,ref:e,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,m=An(p,d,o.dir);s.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=f(p,o.dir))}}):r==="vertical"?i.jsx(zu,{...l,ref:e,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,m=An(p,d);s.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=f(p))}}):null}),Hu=h.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...o}=t,s=Se(Ie,t.__scopeScrollArea),[a,d]=h.useState(),c=h.useRef(null),u=_e(e,c,s.onScrollbarXChange);return h.useEffect(()=>{c.current&&d(getComputedStyle(c.current))},[c]),i.jsx(Mo,{"data-orientation":"horizontal",...o,ref:u,sizes:r,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Ht(r)+"px",...t.style},onThumbPointerDown:l=>t.onThumbPointerDown(l.x),onDragScroll:l=>t.onDragScroll(l.x),onWheelScroll:(l,f)=>{if(s.viewport){const p=s.viewport.scrollLeft+l.deltaX;t.onWheelScroll(p),Bo(p,f)&&l.preventDefault()}},onResize:()=>{c.current&&s.viewport&&a&&n({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Dt(a.paddingLeft),paddingEnd:Dt(a.paddingRight)}})}})}),zu=h.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...o}=t,s=Se(Ie,t.__scopeScrollArea),[a,d]=h.useState(),c=h.useRef(null),u=_e(e,c,s.onScrollbarYChange);return h.useEffect(()=>{c.current&&d(getComputedStyle(c.current))},[c]),i.jsx(Mo,{"data-orientation":"vertical",...o,ref:u,sizes:r,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Ht(r)+"px",...t.style},onThumbPointerDown:l=>t.onThumbPointerDown(l.y),onDragScroll:l=>t.onDragScroll(l.y),onWheelScroll:(l,f)=>{if(s.viewport){const p=s.viewport.scrollTop+l.deltaY;t.onWheelScroll(p),Bo(p,f)&&l.preventDefault()}},onResize:()=>{c.current&&s.viewport&&a&&n({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Dt(a.paddingTop),paddingEnd:Dt(a.paddingBottom)}})}})}),[Wu,Do]=To(Ie),Mo=h.forwardRef((t,e)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:o,onThumbChange:s,onThumbPointerUp:a,onThumbPointerDown:d,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:l,onResize:f,...p}=t,m=Se(Ie,r),[x,g]=h.useState(null),v=_e(e,E=>g(E)),y=h.useRef(null),S=h.useRef(""),_=m.viewport,b=n.content-n.viewport,C=Pe(l),R=Pe(c),T=zt(f,10);function A(E){if(y.current){const j=E.clientX-y.current.left,N=E.clientY-y.current.top;u({x:j,y:N})}}return h.useEffect(()=>{const E=j=>{const N=j.target;x?.contains(N)&&C(j,b)};return document.addEventListener("wheel",E,{passive:!1}),()=>document.removeEventListener("wheel",E,{passive:!1})},[_,x,b,C]),h.useEffect(R,[n,R]),tt(x,T),tt(m.content,T),i.jsx(Wu,{scope:r,scrollbar:x,hasThumb:o,onThumbChange:Pe(s),onThumbPointerUp:Pe(a),onThumbPositionChange:R,onThumbPointerDown:Pe(d),children:i.jsx(le.div,{...p,ref:v,style:{position:"absolute",...p.style},onPointerDown:se(t.onPointerDown,E=>{E.button===0&&(E.target.setPointerCapture(E.pointerId),y.current=x.getBoundingClientRect(),S.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),A(E))}),onPointerMove:se(t.onPointerMove,A),onPointerUp:se(t.onPointerUp,E=>{const j=E.target;j.hasPointerCapture(E.pointerId)&&j.releasePointerCapture(E.pointerId),document.body.style.webkitUserSelect=S.current,m.viewport&&(m.viewport.style.scrollBehavior=""),y.current=null})})})}),jt="ScrollAreaThumb",Io=h.forwardRef((t,e)=>{const{forceMount:r,...n}=t,o=Do(jt,t.__scopeScrollArea);return i.jsx(Me,{present:r||o.hasThumb,children:i.jsx($u,{ref:e,...n})})}),$u=h.forwardRef((t,e)=>{const{__scopeScrollArea:r,style:n,...o}=t,s=Se(jt,r),a=Do(jt,r),{onThumbPositionChange:d}=a,c=_e(e,f=>a.onThumbChange(f)),u=h.useRef(void 0),l=zt(()=>{u.current&&(u.current(),u.current=void 0)},100);return h.useEffect(()=>{const f=s.viewport;if(f){const p=()=>{if(l(),!u.current){const m=Vu(f,d);u.current=m,d()}};return d(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[s.viewport,l,d]),i.jsx(le.div,{"data-state":a.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:se(t.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),x=f.clientX-m.left,g=f.clientY-m.top;a.onThumbPointerDown({x,y:g})}),onPointerUp:se(t.onPointerUp,a.onThumbPointerUp)})});Io.displayName=jt;var zr="ScrollAreaCorner",Lo=h.forwardRef((t,e)=>{const r=Se(zr,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?i.jsx(qu,{...t,ref:e}):null});Lo.displayName=zr;var qu=h.forwardRef((t,e)=>{const{__scopeScrollArea:r,...n}=t,o=Se(zr,r),[s,a]=h.useState(0),[d,c]=h.useState(0),u=!!(s&&d);return tt(o.scrollbarX,()=>{const l=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(l),c(l)}),tt(o.scrollbarY,()=>{const l=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(l),a(l)}),u?i.jsx(le.div,{...n,ref:e,style:{width:s,height:d,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function Dt(t){return t?parseInt(t,10):0}function Oo(t,e){const r=t/e;return isNaN(r)?0:r}function Ht(t){const e=Oo(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*e;return Math.max(n,18)}function Xu(t,e,r,n="ltr"){const o=Ht(r),s=o/2,a=e||s,d=o-a,c=r.scrollbar.paddingStart+a,u=r.scrollbar.size-r.scrollbar.paddingEnd-d,l=r.content-r.viewport,f=n==="ltr"?[0,l]:[l*-1,0];return Fo([c,u],f)(t)}function An(t,e,r="ltr"){const n=Ht(e),o=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=e.scrollbar.size-o,a=e.content-e.viewport,d=s-n,c=r==="ltr"?[0,a]:[a*-1,0],u=Ou(t,c);return Fo([0,a],[0,d])(u)}function Fo(t,e){return r=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const n=(e[1]-e[0])/(t[1]-t[0]);return e[0]+n*(r-t[0])}}function Bo(t,e){return t>0&&t<e}var Vu=(t,e=()=>{})=>{let r={left:t.scrollLeft,top:t.scrollTop},n=0;return(function o(){const s={left:t.scrollLeft,top:t.scrollTop},a=r.left!==s.left,d=r.top!==s.top;(a||d)&&e(),r=s,n=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(n)};function zt(t,e){const r=Pe(t),n=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(n.current),[]),h.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,e)},[r,e])}function tt(t,e){const r=Pe(e);Jo(()=>{let n=0;if(t){const o=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return o.observe(t),()=>{window.cancelAnimationFrame(n),o.unobserve(t)}}},[t,r])}var Yu=Ro,Ku=Po,Qu=Lo;function Ju({className:t,children:e,...r}){return i.jsxs(Yu,{"data-slot":"scroll-area",className:ae("relative",t),...r,children:[i.jsx(Ku,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:e}),i.jsx(Zu,{}),i.jsx(Qu,{})]})}function Zu({className:t,orientation:e="vertical",...r}){return i.jsx(Ao,{"data-slot":"scroll-area-scrollbar",orientation:e,className:ae("flex touch-none p-px transition-colors select-none",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",t),...r,children:i.jsx(Io,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const ed=100,td=20;function jn(t,e,r,n){return{id:Date.now().toString(),deviceId:t||"unknown",deviceName:e||"Unknown Device",taskText:r?.content||"No task description",success:n?.success??!1,steps:n?.steps??0,startTime:r?.timestamp||new Date,endTime:n?.timestamp||new Date,duration:(n?.timestamp?.getTime()||Date.now())-(r?.timestamp?.getTime()||Date.now()),thinking:n?.thinking??[],actions:n?.actions??[],finalMessage:n?.content||"No result message",errorMessage:n?.success===!1?n?.content||"Unknown error":void 0}}function Dn(t,e){try{const r=`history-${t}`,n=localStorage.getItem(r),o=n?JSON.parse(n):[];o.unshift(e);const s=o.slice(0,ed);localStorage.setItem(r,JSON.stringify(s))}catch(r){if(r instanceof Error&&r.name==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old history");try{const n=`history-${t}`,o=localStorage.getItem(n),a=(o?JSON.parse(o):[]).slice(0,td);a.unshift(e),localStorage.setItem(n,JSON.stringify(a))}catch(n){console.error("Failed to save history even after reduction:",n)}}else console.warn("Failed to save history:",r)}}function rd(t){try{const e=`history-${t}`,r=localStorage.getItem(e);return r?JSON.parse(r).map(o=>({...o,startTime:new Date(o.startTime),endTime:new Date(o.endTime)})):[]}catch(e){return console.warn("Failed to load history:",e),[]}}function nd(t,e){try{const r=`history-${t}`,n=localStorage.getItem(r);if(!n)return;const s=JSON.parse(n).filter(a=>a.id!==e);localStorage.setItem(r,JSON.stringify(s))}catch(r){console.warn("Failed to delete history item:",r)}}function sd(t){try{const e=`history-${t}`;localStorage.removeItem(e)}catch(e){console.warn("Failed to clear history:",e)}}function od(t){const r=new Date().getTime()-t.getTime(),n=Math.floor(r/6e4),o=Math.floor(r/36e5),s=Math.floor(r/864e5);return n<1?"Just now":n<60?`${n}m ago`:o<24?`${o}h ago`:s<7?`${s}d ago`:t.toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function id(t){const e=Math.floor(t/1e3),r=Math.floor(e/60),n=e%60;return r===0?`${n}s`:`${r}m ${n}s`}function ad({item:t,onSelect:e,onDelete:r}){const n=dt(),o=s=>{s.stopPropagation(),confirm(n.history.deleteConfirm)&&r(t.id)};return i.jsx(At,{className:"hover:bg-slate-50 dark:hover:bg-slate-800/50 transition-colors cursor-pointer group",onClick:()=>e(t),children:i.jsxs("div",{className:"p-3 space-y-2",children:[i.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 line-clamp-2",children:t.taskText}),i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500 dark:text-slate-400",children:[i.jsx("span",{children:od(t.startTime)}),i.jsx("span",{children:"•"}),i.jsxs("span",{children:[t.steps," ",t.steps===1?"step":"steps"]}),i.jsx("span",{children:"•"}),i.jsx("span",{children:id(t.duration)})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(lt,{variant:t.success?"success":"destructive",className:"shrink-0",children:t.success?i.jsxs(i.Fragment,{children:[i.jsx(Je,{className:"w-3 h-3 mr-1"}),n.history.success]}):i.jsxs(i.Fragment,{children:[i.jsx(ze,{className:"w-3 h-3 mr-1"}),n.history.failed]})}),i.jsx(te,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity text-slate-400 hover:text-red-500 dark:text-slate-500 dark:hover:text-red-400",onClick:o,title:n.history.deleteItem,children:i.jsx(zi,{className:"w-3 h-3"})})]})]})]})})}function cd({deviceId:t,deviceName:e,config:r,isConfigured:n}){const o=dt(),[s,a]=h.useState([]),[d,c]=h.useState(""),[u,l]=h.useState(!1),[f,p]=h.useState(null),[m,x]=h.useState(!1),[g,v]=h.useState(null),[y,S]=h.useState(!0),[_,b]=h.useState(!1),[C,R]=h.useState("auto"),[T,A]=h.useState(null),[E,j]=h.useState("success"),[N,G]=h.useState(!1),[z,P]=h.useState([]),D=h.useRef(null),M=(k,B=2e3,K="success")=>{D.current&&clearTimeout(D.current),j(K),A(k),D.current=setTimeout(()=>{A(null)},B)};h.useEffect(()=>()=>{D.current&&clearTimeout(D.current)},[]);const[U,H]=h.useState(!1),[W,V]=h.useState(!1),F=h.useRef(null),Q=()=>{F.current&&clearTimeout(F.current),H(!0)},Z=()=>{F.current=setTimeout(()=>{H(!1)},500)};h.useEffect(()=>()=>{F.current&&clearTimeout(F.current)},[]);const oe=()=>{V(k=>!k)},ee=h.useRef(null),xe=h.useRef(null),de=h.useRef(null),ue=h.useRef(!1),re=h.useRef(!1),me=h.useRef(null),ge=h.useCallback(async()=>{if(r)try{await Zo({model_config:{base_url:r.base_url||void 0,api_key:r.api_key||void 0,model_name:r.model_name||void 0},agent_config:{device_id:t}}),x(!0),p(null)}catch(k){const B=k instanceof Error?k.message:"Initialization failed";p(B)}},[t,r]);h.useEffect(()=>{n&&r&&!m&&!re.current&&(re.current=!0,ge())},[n,r,m,ge]),h.useEffect(()=>{if(N){const k=rd(t);P(k)}},[N,t]);const fe=k=>{const B={id:`${k.id}-user`,role:"user",content:k.taskText,timestamp:k.startTime},K={id:`${k.id}-agent`,role:"agent",content:k.finalMessage,timestamp:k.endTime,steps:k.steps,success:k.success,thinking:k.thinking,actions:k.actions,isStreaming:!1};a([B,K]),G(!1)},Le=()=>{confirm(o.history.clearAllConfirm)&&(sd(t),P([]))},Re=k=>{nd(t,k),P(B=>B.filter(K=>K.id!==k))};h.useEffect(()=>{if(!m||!r)return;const k=me.current;k&&(k.base_url!==r.base_url||k.model_name!==r.model_name||k.api_key!==r.api_key)&&(console.log(`[DevicePanel] Config changed for device ${t}, re-initializing...`),ge()),me.current=r},[r,m,t,ge]);const we=h.useCallback(async()=>{const k=d.trim();if(!k||u)return;m||await ge();const B={id:Date.now().toString(),role:"user",content:k,timestamp:new Date};a(be=>[...be,B]),c(""),l(!0),p(null);const K=[],he=[],ye=(Date.now()+1).toString(),ve={id:ye,role:"agent",content:"",timestamp:new Date,thinking:[],actions:[],isStreaming:!0};a(be=>[...be,ve]);const ke=ei(B.content,t,be=>{K.push(be.thinking),he.push(be.action),a(Ge=>Ge.map(He=>He.id===ye?{...He,thinking:[...K],actions:[...he],steps:be.step}:He))},be=>{const Ge={...ve,content:be.message,success:be.success,isStreaming:!1,steps:be.steps,thinking:[...K],actions:[...he],timestamp:new Date};a(Wt=>Wt.map(st=>st.id===ye?Ge:st)),l(!1),ee.current=null;const He=jn(t,e,B,Ge);Dn(t,He)},be=>{const Ge={...ve,content:`Error: ${be.message}`,success:!1,isStreaming:!1,thinking:[...K],actions:[...he],timestamp:new Date};a(Wt=>Wt.map(st=>st.id===ye?Ge:st)),l(!1),p(be.message),ee.current=null;const He=jn(t,e,B,Ge);Dn(t,He)});ee.current=ke},[d,u,m,t,e,ge]),L=h.useCallback(async()=>{ee.current&&ee.current.close(),a([]),l(!1),p(null),ee.current=null,await ti(t)},[t]),O=()=>{de.current?.scrollIntoView({behavior:"smooth"})};h.useEffect(()=>{O()},[s]),h.useEffect(()=>()=>{ee.current&&ee.current.close(),xe.current&&xe.current.close()},[t]),h.useEffect(()=>{if(!t||!(C==="screenshot"||C==="auto"&&_))return;const B=async()=>{if(!ue.current){ue.current=!0;try{const he=await Ln(t);he.success&&v(he)}catch(he){console.error("Failed to fetch screenshot:",he)}finally{ue.current=!1}}};B();const K=setInterval(B,500);return()=>clearInterval(K)},[t,_,C]);const w=k=>{(k.metaKey||k.ctrlKey)&&k.key==="Enter"&&(k.preventDefault(),we())},I=h.useCallback(k=>{xe.current=k},[]),X=h.useCallback(()=>{b(!0),S(!1)},[]),Y=k=>{R(k)};return i.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[i.jsxs(At,{className:"flex-1 flex flex-col min-h-0 max-w-2xl",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:i.jsx($t,{className:"h-5 w-5 text-[#1d9bf0]"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-bold text-slate-900 dark:text-slate-100",children:e}),i.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 font-mono",children:t})]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs(Mu,{open:N,onOpenChange:G,children:[i.jsx(Iu,{asChild:!0,children:i.jsx(te,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300",title:o.history.title,children:i.jsx(Vr,{className:"h-4 w-4"})})}),i.jsxs(Lu,{className:"w-96 p-0",align:"end",sideOffset:8,children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[i.jsx("h3",{className:"font-semibold text-sm text-slate-900 dark:text-slate-100",children:o.history.title}),z.length>0&&i.jsx(te,{variant:"ghost",size:"sm",onClick:Le,className:"h-7 text-xs",children:o.history.clearAll})]}),i.jsx(Ju,{className:"h-[400px]",children:i.jsx("div",{className:"p-4 space-y-2",children:z.length>0?z.map(k=>i.jsx(ad,{item:k,onSelect:fe,onDelete:Re},k.id)):i.jsxs("div",{className:"text-center py-8",children:[i.jsx(Vr,{className:"h-12 w-12 text-slate-300 dark:text-slate-700 mx-auto mb-3"}),i.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:o.history.noHistory}),i.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:o.history.noHistoryDescription})]})})})]})]}),n?m?i.jsxs(lt,{variant:"success",children:[i.jsx(Je,{className:"w-3 h-3 mr-1"}),o.devicePanel.ready]}):i.jsx(te,{onClick:ge,disabled:!n||!r,size:"sm",variant:"twitter",children:o.devicePanel.initializing}):i.jsxs(lt,{variant:"warning",children:[i.jsx(ze,{className:"w-3 h-3 mr-1"}),o.devicePanel.noConfig]}),i.jsx(te,{variant:"ghost",size:"icon",onClick:L,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:i.jsx(Mi,{className:"h-4 w-4"})})]})]}),f&&i.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:[i.jsx(ze,{className:"w-4 h-4 flex-shrink-0"}),f]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-4 min-h-0",children:[s.length===0?i.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center min-h-[calc(100%-1rem)]",children:[i.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800 mb-4",children:i.jsx($t,{className:"h-8 w-8 text-slate-400"})}),i.jsx("p",{className:"font-medium text-slate-900 dark:text-slate-100",children:o.devicePanel.readyToHelp}),i.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:o.devicePanel.describeTask})]}):s.map(k=>i.jsx("div",{className:`flex ${k.role==="user"?"justify-end":"justify-start"}`,children:k.role==="agent"?i.jsxs("div",{className:"max-w-[85%] space-y-3",children:[k.thinking?.map((B,K)=>i.jsxs("div",{className:"bg-slate-100 dark:bg-slate-800 rounded-2xl rounded-tl-sm px-4 py-3",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:i.jsx($t,{className:"h-3 w-3 text-[#1d9bf0]"})}),i.jsxs("span",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:["Step ",K+1]})]}),i.jsx("p",{className:"text-sm whitespace-pre-wrap text-slate-700 dark:text-slate-300",children:B}),k.actions?.[K]&&i.jsxs("details",{className:"mt-2 text-xs",children:[i.jsx("summary",{className:"cursor-pointer text-[#1d9bf0] hover:text-[#1a8cd8]",children:"View action"}),i.jsx("pre",{className:"mt-2 p-2 bg-slate-900 text-slate-200 rounded-lg overflow-x-auto text-xs",children:JSON.stringify(k.actions[K],null,2)})]})]},K)),k.content&&i.jsxs("div",{className:`
|
|
147
|
+
rounded-2xl px-4 py-3 flex items-start gap-2
|
|
148
|
+
${k.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"}
|
|
149
|
+
`,children:[i.jsx(Je,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${k.success===!1?"text-red-500":"text-green-500"}`}),i.jsxs("div",{children:[i.jsx("p",{className:"whitespace-pre-wrap",children:k.content}),k.steps!==void 0&&i.jsxs("p",{className:"text-xs mt-2 opacity-60 text-slate-500 dark:text-slate-400",children:[k.steps," steps completed"]})]})]}),k.isStreaming&&i.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 dark:text-slate-400",children:[i.jsx(We,{className:"w-4 h-4 animate-spin"}),"Processing..."]})]}):i.jsxs("div",{className:"max-w-[75%]",children:[i.jsx("div",{className:"chat-bubble-user px-4 py-3",children:i.jsx("p",{className:"whitespace-pre-wrap",children:k.content})}),i.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-1 text-right",children:k.timestamp.toLocaleTimeString()})]})},k.id)),i.jsx("div",{ref:de})]}),i.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800",children:i.jsxs("div",{className:"flex items-end gap-3",children:[i.jsx(go,{value:d,onChange:k=>c(k.target.value),onKeyDown:w,placeholder:n?m?o.devicePanel.whatToDo:o.devicePanel.initDeviceFirst:o.devicePanel.configureFirst,disabled:u,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),i.jsx(te,{onClick:we,disabled:u||!d.trim(),size:"icon",variant:"twitter",className:"h-10 w-10 rounded-full flex-shrink-0",children:u?i.jsx(We,{className:"h-4 w-4 animate-spin"}):i.jsx(Li,{className:"h-4 w-4"})})]})})]}),i.jsxs(At,{className:"w-[320px] flex-shrink-0 relative min-h-0 overflow-hidden bg-background",onMouseEnter:Q,onMouseLeave:Z,children:[i.jsx("div",{className:`absolute top-4 right-4 z-10 transition-opacity duration-200 ${U?"opacity-100":"opacity-0 pointer-events-none"}`,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:`flex items-center gap-1 bg-popover/90 backdrop-blur rounded-xl p-1 shadow-lg border border-border transition-all duration-300 ${W?"opacity-100 translate-x-0":"opacity-0 translate-x-4 pointer-events-none"}`,children:[i.jsx(te,{variant:"ghost",size:"sm",onClick:()=>Y("auto"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${C==="auto"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:o.devicePanel.auto}),i.jsxs(te,{variant:"ghost",size:"sm",onClick:()=>Y("video"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${C==="video"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[i.jsx($i,{className:"w-3 h-3 mr-1"}),o.devicePanel.video]}),i.jsxs(te,{variant:"ghost",size:"sm",onClick:()=>Y("screenshot"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${C==="screenshot"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[i.jsx(Yr,{className:"w-3 h-3 mr-1"}),o.devicePanel.image]})]}),i.jsx(te,{variant:"ghost",size:"icon",onClick:oe,className:"h-8 w-8 rounded-full bg-popover/90 backdrop-blur border border-border shadow-lg hover:bg-accent",title:W?"Hide controls":"Show controls",children:W?i.jsx(Un,{className:"w-4 h-4"}):i.jsx(Bn,{className:"w-4 h-4"})})]})}),i.jsx("div",{className:"absolute bottom-4 left-4 z-10",children:i.jsxs(lt,{variant:"secondary",className:"bg-white/90 text-slate-700 border border-slate-200 dark:bg-slate-900/90 dark:text-slate-300 dark:border-slate-700",children:[C==="auto"&&o.devicePanel.auto,C==="video"&&i.jsxs(i.Fragment,{children:[i.jsx(Ri,{className:"w-3 h-3 mr-1"}),o.devicePanel.video]}),C==="screenshot"&&i.jsxs(i.Fragment,{children:[i.jsx(Yr,{className:"w-3 h-3 mr-1"}),o.devicePanel.imageRefresh]})]})}),T&&i.jsxs("div",{className:"absolute bottom-4 right-4 z-20 flex items-center gap-2 px-3 py-2 bg-[#1d9bf0] text-white text-sm rounded-xl shadow-lg",children:[E==="error"&&i.jsx(ze,{className:"w-4 h-4"}),E==="tap"&&i.jsx(Ei,{className:"w-4 h-4"}),E==="swipe"&&i.jsx(ci,{className:"w-4 h-4"}),E==="success"&&i.jsx(Je,{className:"w-4 h-4"}),i.jsx("span",{children:T})]}),C==="video"||C==="auto"&&y&&!_?i.jsx(pu,{deviceId:t,className:"w-full h-full",enableControl:!0,onFallback:X,onTapSuccess:()=>M(o.devicePanel.tapped,2e3,"tap"),onTapError:k=>M(o.devicePanel.tapError.replace("{error}",k),3e3,"error"),onSwipeSuccess:()=>M(o.devicePanel.swiped,2e3,"swipe"),onSwipeError:k=>M(o.devicePanel.swipeError.replace("{error}",k),3e3,"error"),onStreamReady:I,fallbackTimeout:1e5}):i.jsx("div",{className:"w-full h-full flex items-center justify-center bg-muted/30 min-h-0",children:g&&g.success?i.jsxs("div",{className:"relative w-full h-full flex items-center justify-center min-h-0",children:[i.jsx("img",{src:`data:image/png;base64,${g.image}`,alt:"Device Screenshot",className:"max-w-full max-h-full object-contain",style:{width:g.width>g.height?"100%":"auto",height:g.width>g.height?"auto":"100%"}}),g.is_sensitive&&i.jsx("div",{className:"absolute top-12 right-2 px-2 py-1 bg-yellow-500 text-white text-xs rounded-lg",children:o.devicePanel.sensitiveContent})]}):g?.error?i.jsxs("div",{className:"text-center text-destructive",children:[i.jsx(ze,{className:"w-8 h-8 mx-auto mb-2"}),i.jsx("p",{className:"font-medium",children:o.devicePanel.screenshotFailed}),i.jsx("p",{className:"text-xs mt-1 opacity-60",children:g.error})]}):i.jsxs("div",{className:"text-center text-muted-foreground",children:[i.jsx(We,{className:"w-8 h-8 mx-auto mb-2 animate-spin"}),i.jsx("p",{className:"text-sm",children:o.devicePanel.loading})]})})]})]})}function ld({message:t,type:e="info",onClose:r,duration:n=3e3}){h.useEffect(()=>{const a=setTimeout(()=>{r()},n);return()=>clearTimeout(a)},[n,r]);const o={success:"bg-green-500",error:"bg-red-500",info:"bg-blue-500"},s={success:i.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})}),error:i.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})}),info:i.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 i.jsx("div",{className:"fixed top-4 left-1/2 transform -translate-x-1/2 z-50 animate-fade-in-down",children:i.jsxs("div",{className:`${o[e]} text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3 min-w-[300px]`,children:[s[e],i.jsx("span",{className:"font-medium",children:t}),i.jsx("button",{onClick:r,className:"ml-auto hover:bg-white/20 rounded-full p-1 transition-colors",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]})})}const ud=[{name:"bigmodel",config:{base_url:"https://open.bigmodel.cn/api/paas/v4",model_name:"autoglm-phone",api_key:""},apiKeyUrl:"https://bigmodel.cn/usercenter/proj-mgmt/apikeys"},{name:"modelscope",config:{base_url:"https://api-inference.modelscope.cn/v1",model_name:"ZhipuAI/AutoGLM-Phone-9B",api_key:""},apiKeyUrl:"https://www.modelscope.cn/my/myaccesstoken"},{name:"custom",config:{base_url:"",model_name:"autoglm-phone-9b",api_key:""}}];function gd(){const t=dt(),[e,r]=h.useState([]),[n,o]=h.useState(""),[s,a]=h.useState({message:"",type:"info",visible:!1}),d=(_,b="info")=>{a({message:_,type:b,visible:!0})},[c,u]=h.useState(null),[l,f]=h.useState(!1),[p,m]=h.useState(!1),[x,g]=h.useState({base_url:"",model_name:"",api_key:""});h.useEffect(()=>{(async()=>{try{const b=await ri();u({base_url:b.base_url,model_name:b.model_name,api_key:b.api_key||void 0}),g({base_url:b.base_url,model_name:b.model_name,api_key:b.api_key||""}),b.base_url||f(!0)}catch(b){console.error("Failed to load config:",b),f(!0)}})()},[]),h.useEffect(()=>{const _=async()=>{try{const C=await ni(),R=new Map,T=new Map;for(const E of C.devices)if(E.serial){const j=T.get(E.serial)||[];j.push(E),T.set(E.serial,j)}else R.set(E.id,E);Array.from(T.values()).forEach(E=>{const N=E.find(G=>G.connection_type==="remote")||E[0];R.set(N.id,N)});const A=Array.from(R.values());r(A),A.length>0&&!n&&o(A[0].id),n&&!A.find(E=>E.id===n)&&o(A[0]?.id||"")}catch(C){console.error("Failed to load devices:",C)}};_();const b=setInterval(_,3e3);return()=>clearInterval(b)},[n]);const v=async()=>{if(!x.base_url){d(t.chat.baseUrlRequired,"error");return}try{await si({base_url:x.base_url,model_name:x.model_name||"autoglm-phone-9b",api_key:x.api_key||void 0}),u({base_url:x.base_url,model_name:x.model_name,api_key:x.api_key||void 0}),f(!1),d(t.toasts.configSaved,"success")}catch(_){console.error("Failed to save config:",_),d(`Failed to save: ${_ instanceof Error?_.message:"Unknown error"}`,"error")}},y=async _=>{try{const b=await ii({device_id:_});b.success&&b.device_id?(o(b.device_id),d(t.toasts.wifiConnected,"success")):b.success||d(b.message||b.error||t.toasts.connectionFailed,"error")}catch(b){d(t.toasts.wifiConnectionError,"error"),console.error("Connect WiFi error:",b)}},S=async _=>{try{const b=await oi(_);b.success?d(t.toasts.wifiDisconnected,"success"):d(b.message||b.error||t.toasts.disconnectFailed,"error")}catch(b){d(t.toasts.wifiDisconnectError,"error"),console.error("Disconnect WiFi error:",b)}};return i.jsxs("div",{className:"h-full flex relative min-h-0",children:[s.visible&&i.jsx(ld,{message:s.message,type:s.type,onClose:()=>a(_=>({..._,visible:!1}))}),i.jsx(xs,{open:l,onOpenChange:f,children:i.jsxs(Tr,{className:"sm:max-w-md",children:[i.jsxs(Rr,{children:[i.jsxs(Pr,{className:"flex items-center gap-2",children:[i.jsx(Gn,{className:"w-5 h-5 text-[#1d9bf0]"}),t.chat.configuration]}),i.jsx(Ar,{children:t.chat.configureApi})]}),i.jsxs("div",{className:"space-y-4 py-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ne,{className:"text-sm font-medium",children:t.chat.selectPreset}),i.jsx("div",{className:"grid grid-cols-1 gap-2",children:ud.map(_=>i.jsxs("div",{className:"relative",children:[i.jsxs("button",{type:"button",onClick:()=>g({base_url:_.config.base_url,model_name:_.config.model_name,api_key:_.config.api_key}),className:`w-full text-left p-3 rounded-lg border transition-all ${x.base_url===_.config.base_url&&(_.name!=="custom"||_.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:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Fi,{className:`w-4 h-4 ${x.base_url===_.config.base_url&&(_.name!=="custom"||_.name==="custom"&&x.base_url==="")?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),i.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:t.presetConfigs[_.name].name})]}),i.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 ml-6",children:t.presetConfigs[_.name].description})]}),"apiKeyUrl"in _&&i.jsx("a",{href:_.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",onClick:b=>b.stopPropagation(),className:"absolute top-3 right-3 p-1.5 rounded-md hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors group",title:t.chat.getApiKey||"获取 API Key",children:i.jsx(_i,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-[#1d9bf0] transition-colors"})})]},_.name))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs(Ne,{htmlFor:"base_url",children:[t.chat.baseUrl," *"]}),i.jsx(Oe,{id:"base_url",value:x.base_url,onChange:_=>g({...x,base_url:_.target.value}),placeholder:"http://localhost:8080/v1"}),!x.base_url&&i.jsxs("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[i.jsx(ze,{className:"w-3 h-3"}),t.chat.baseUrlRequired]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ne,{htmlFor:"api_key",children:t.chat.apiKey}),i.jsxs("div",{className:"relative",children:[i.jsx(Oe,{id:"api_key",type:p?"text":"password",value:x.api_key,onChange:_=>g({...x,api_key:_.target.value}),placeholder:"Leave empty if not required",className:"pr-10"}),i.jsx(te,{type:"button",variant:"ghost",size:"icon",onClick:()=>m(!p),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:p?i.jsx(vi,{className:"w-4 h-4 text-slate-400"}):i.jsx(yi,{className:"w-4 h-4 text-slate-400"})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ne,{htmlFor:"model_name",children:t.chat.modelName}),i.jsx(Oe,{id:"model_name",value:x.model_name,onChange:_=>g({...x,model_name:_.target.value}),placeholder:"autoglm-phone-9b"})]})]}),i.jsxs(kr,{className:"sm:justify-between gap-2",children:[i.jsx(te,{variant:"outline",onClick:()=>{f(!1),c&&g({base_url:c.base_url,model_name:c.model_name,api_key:c.api_key||""})},children:t.chat.cancel}),i.jsxs(te,{onClick:v,variant:"twitter",children:[i.jsx(Je,{className:"w-4 h-4 mr-2"}),t.chat.saveConfig]})]})]})}),i.jsx(Oc,{devices:e,currentDeviceId:n,onSelectDevice:o,onOpenConfig:()=>f(!0),onConnectWifi:y,onDisconnectWifi:S}),i.jsx("div",{className:"flex-1 flex items-stretch justify-center min-h-0 px-4 py-4",children:e.length===0?i.jsx("div",{className:"flex-1 flex items-center justify-center bg-slate-50 dark:bg-slate-950",children:i.jsxs("div",{className:"text-center",children:[i.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:i.jsx("svg",{className:"w-10 h-10 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.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"})})}),i.jsx("h3",{className:"text-lg font-semibold text-slate-900 dark:text-slate-100 mb-2",children:t.chat.welcomeTitle}),i.jsx("p",{className:"text-slate-500 dark:text-slate-400",children:t.chat.connectDevice})]})}):e.map(_=>i.jsx("div",{className:`w-full max-w-7xl flex items-stretch justify-center min-h-0 ${_.id===n?"":"hidden"}`,children:i.jsx(cd,{deviceId:_.id,deviceName:_.model,config:c,isVisible:_.id===n,isConfigured:!!c?.base_url})},_.id))})]})}export{gd as component};
|