autoglm-gui 1.0.0__py3-none-any.whl → 1.0.1__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.
Files changed (41) hide show
  1. AutoGLM_GUI/api/devices.py +49 -0
  2. AutoGLM_GUI/schemas.py +16 -0
  3. AutoGLM_GUI/static/assets/{about-29B5FDM8.js → about-BOnRPlKQ.js} +1 -1
  4. AutoGLM_GUI/static/assets/chat-CGW6uMKB.js +149 -0
  5. AutoGLM_GUI/static/assets/{index-mVNV0VwM.js → index-CRFVU0eu.js} +1 -1
  6. AutoGLM_GUI/static/assets/{index-wu8Wjf12.js → index-DH-Dl4tK.js} +5 -5
  7. AutoGLM_GUI/static/assets/index-DzUQ89YC.css +1 -0
  8. AutoGLM_GUI/static/index.html +2 -2
  9. {autoglm_gui-1.0.0.dist-info → autoglm_gui-1.0.1.dist-info}/METADATA +3 -3
  10. autoglm_gui-1.0.1.dist-info/RECORD +73 -0
  11. phone_agent/__init__.py +3 -2
  12. phone_agent/actions/handler.py +124 -31
  13. phone_agent/actions/handler_ios.py +278 -0
  14. phone_agent/adb/connection.py +14 -5
  15. phone_agent/adb/device.py +47 -16
  16. phone_agent/agent.py +8 -8
  17. phone_agent/agent_ios.py +277 -0
  18. phone_agent/config/__init__.py +18 -0
  19. phone_agent/config/apps.py +1 -1
  20. phone_agent/config/apps_harmonyos.py +256 -0
  21. phone_agent/config/apps_ios.py +339 -0
  22. phone_agent/config/i18n.py +8 -0
  23. phone_agent/config/timing.py +167 -0
  24. phone_agent/device_factory.py +166 -0
  25. phone_agent/hdc/__init__.py +53 -0
  26. phone_agent/hdc/connection.py +384 -0
  27. phone_agent/hdc/device.py +269 -0
  28. phone_agent/hdc/input.py +145 -0
  29. phone_agent/hdc/screenshot.py +127 -0
  30. phone_agent/model/client.py +104 -4
  31. phone_agent/xctest/__init__.py +47 -0
  32. phone_agent/xctest/connection.py +379 -0
  33. phone_agent/xctest/device.py +472 -0
  34. phone_agent/xctest/input.py +311 -0
  35. phone_agent/xctest/screenshot.py +226 -0
  36. AutoGLM_GUI/static/assets/chat-DTN2oKtA.js +0 -149
  37. AutoGLM_GUI/static/assets/index-Dy550Qqg.css +0 -1
  38. autoglm_gui-1.0.0.dist-info/RECORD +0 -57
  39. {autoglm_gui-1.0.0.dist-info → autoglm_gui-1.0.1.dist-info}/WHEEL +0 -0
  40. {autoglm_gui-1.0.0.dist-info → autoglm_gui-1.0.1.dist-info}/entry_points.txt +0 -0
  41. {autoglm_gui-1.0.0.dist-info → autoglm_gui-1.0.1.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,149 @@
1
+ import{c as Q,j as c,u as Ut,r as u,B as oe,a as Tt,R as ts,b as zo,d as ns,e as ye,f as Vo,g as ce,P as Xo,S as ar,h as Yo,i as rs,s as Ko,k as cr,l as lr,m as Jo,n as Qo,o as Zo,p as ei,q as ti,t as ni,v as ri,w as si,x as oi}from"./index-DH-Dl4tK.js";const ii=[["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"}]],ai=Q("arrow-up-down",ii);const ci=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ss=Q("chevron-left",ci);const li=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],os=Q("chevron-right",li);const ui=[["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"}]],at=Q("circle-alert",ui);const fi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],lt=Q("circle-check",fi);const di=[["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"}]],hi=Q("external-link",di);const pi=[["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"}]],mi=Q("eye-off",pi);const gi=[["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"}]],_i=Q("eye",gi);const xi=[["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"}]],vi=Q("fingerprint-pattern",xi);const yi=[["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"}]],ur=Q("image",yi);const bi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],wi=Q("info",bi);const Ei=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ut=Q("loader-circle",Ei);const Ci=[["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"}]],Ti=Q("monitor-play",Ci);const Si=[["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"}]],Ri=Q("plug",Si);const ki=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ni=Q("plus",ki);const Pi=[["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"}]],Ai=Q("rotate-ccw",Pi);const Di=[["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"}]],Oi=Q("send",Di);const Li=[["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"}]],ji=Q("server",Li);const Mi=[["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"}]],is=Q("settings",Mi);const Bi=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],as=Q("smartphone",Bi);const Ii=[["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"}]],Qt=Q("sparkles",Ii);const Fi=[["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"}]],Ui=Q("video",Fi);const Wi=[["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"}]],Hi=Q("wifi-off",Wi);const $i=[["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"}]],Gi=Q("wifi",$i);const qi=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],zi=Q("x",qi);function fr({isOpen:t,title:e,content:n,onConfirm:r,onCancel:o,confirmText:s="确认",cancelText:i="取消"}){return t?c.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:c.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:a=>a.stopPropagation(),children:[c.jsxs("div",{className:"p-6",children:[c.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:e}),c.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm leading-relaxed whitespace-pre-wrap",children:n})]}),c.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 px-6 py-4 flex justify-end gap-3",children:[c.jsx("button",{onClick:a=>{a.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:i}),c.jsx("button",{onClick:a=>{a.stopPropagation(),r()},className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors",children:s})]})]})}):null}function Vi({id:t,model:e,status:n,connectionType:r,isInitialized:o,isActive:s,onClick:i,onConnectWifi:a,onDisconnectWifi:l}){const f=Ut(),d=n==="device",h=r==="usb",g=r==="remote",[p,_]=u.useState(!1),[m,v]=u.useState(!1),[y,E]=u.useState(!1),x=T=>{T.stopPropagation(),!(p||!a)&&v(!0)},b=T=>{T.stopPropagation(),!(p||!l)&&E(!0)},C=async()=>{v(!1),_(!0);try{a&&await a()}finally{_(!1)}},S=async()=>{E(!1),_(!0);try{l&&await l()}finally{_(!1)}};return c.jsxs(c.Fragment,{children:[c.jsxs("div",{onClick:i,role:"button",tabIndex:0,onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&i()},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&&c.jsx("div",{className:"absolute left-0 top-2 bottom-2 w-1 bg-[#1d9bf0] rounded-r"}),c.jsxs("div",{className:"flex items-center gap-3 pl-2",children:[c.jsx("div",{className:`relative flex-shrink-0 ${d?"status-online":"status-offline"} w-3 h-3 rounded-full transition-all ${s?"scale-110":""}`}),c.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-0.5",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(as,{className:`w-4 h-4 ${s?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),c.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||f.deviceCard.unknownDevice})]}),c.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})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[h&&a&&c.jsx(oe,{variant:"ghost",size:"icon",onClick:x,disabled:p,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:f.deviceCard.connectViaWifi,children:p?c.jsx(ut,{className:"w-4 h-4 animate-spin"}):c.jsx(Gi,{className:"w-4 h-4"})}),g&&l&&c.jsx(oe,{variant:"ghost",size:"icon",onClick:b,disabled:p,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:f.deviceCard.disconnectWifi,children:p?c.jsx(ut,{className:"w-4 h-4 animate-spin"}):c.jsx(Hi,{className:"w-4 h-4"})}),o&&c.jsxs(Tt,{variant:"success",className:`text-xs ${s?"bg-green-500/10 text-green-600 dark:text-green-400":""}`,children:[c.jsx(lt,{className:"w-3 h-3 mr-1"}),f.deviceCard.ready]})]})]})]}),c.jsx(fr,{isOpen:m,title:f.deviceCard.connectWifiTitle,content:f.deviceCard.connectWifiContent,onConfirm:C,onCancel:()=>v(!1)}),c.jsx(fr,{isOpen:y,title:f.deviceCard.disconnectWifiTitle,content:f.deviceCard.disconnectWifiContent,onConfirm:S,onCancel:()=>E(!1)})]})}function le(t,e,{checkForDefaultPrevented:n=!0}={}){return function(o){if(t?.(o),n===!1||!o.defaultPrevented)return e?.(o)}}function Xi(t,e){const n=u.createContext(e),r=s=>{const{children:i,...a}=s,l=u.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=t+"Provider";function o(s){const i=u.useContext(n);if(i)return i;if(e!==void 0)return e;throw new Error(`\`${s}\` must be used within \`${t}\``)}return[r,o]}function Ln(t,e=[]){let n=[];function r(s,i){const a=u.createContext(i),l=n.length;n=[...n,i];const f=h=>{const{scope:g,children:p,..._}=h,m=g?.[t]?.[l]||a,v=u.useMemo(()=>_,Object.values(_));return c.jsx(m.Provider,{value:v,children:p})};f.displayName=s+"Provider";function d(h,g){const p=g?.[t]?.[l]||a,_=u.useContext(p);if(_)return _;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[f,d]}const o=()=>{const s=n.map(i=>u.createContext(i));return function(a){const l=a?.[t]||s;return u.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return o.scopeName=t,[r,Yi(o,...e)]}function Yi(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:f})=>{const h=l(s)[`__scope${f}`];return{...a,...h}},{});return u.useMemo(()=>({[`__scope${e.scopeName}`]:i}),[i])}};return n.scopeName=e.scopeName,n}var Ie=globalThis?.document?u.useLayoutEffect:()=>{},Ki=ts[" useId ".trim().toString()]||(()=>{}),Ji=0;function St(t){const[e,n]=u.useState(Ki());return Ie(()=>{n(r=>r??String(Ji++))},[t]),t||(e?`radix-${e}`:"")}var Qi=ts[" useInsertionEffect ".trim().toString()]||Ie;function cs({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[o,s,i]=Zi({defaultProp:e,onChange:n}),a=t!==void 0,l=a?t:o;{const d=u.useRef(t!==void 0);u.useEffect(()=>{const h=d.current;h!==a&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const f=u.useCallback(d=>{if(a){const h=ea(d)?d(t):d;h!==t&&i.current?.(h)}else s(d)},[a,t,s,i]);return[l,f]}function Zi({defaultProp:t,onChange:e}){const[n,r]=u.useState(t),o=u.useRef(n),s=u.useRef(e);return Qi(()=>{s.current=e},[e]),u.useEffect(()=>{o.current!==n&&(s.current?.(n),o.current=n)},[n,o]),[n,r,s]}function ea(t){return typeof t=="function"}function ls(t){const e=ta(t),n=u.forwardRef((r,o)=>{const{children:s,...i}=r,a=u.Children.toArray(s),l=a.find(ra);if(l){const f=l.props.children,d=a.map(h=>h===l?u.Children.count(f)>1?u.Children.only(null):u.isValidElement(f)?f.props.children:null:h);return c.jsx(e,{...i,ref:o,children:u.isValidElement(f)?u.cloneElement(f,void 0,d):null})}return c.jsx(e,{...i,ref:o,children:s})});return n.displayName=`${t}.Slot`,n}function ta(t){const e=u.forwardRef((n,r)=>{const{children:o,...s}=n;if(u.isValidElement(o)){const i=oa(o),a=sa(s,o.props);return o.type!==u.Fragment&&(a.ref=r?zo(r,i):i),u.cloneElement(o,a)}return u.Children.count(o)>1?u.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var us=Symbol("radix.slottable");function na(t){const e=({children:n})=>c.jsx(c.Fragment,{children:n});return e.displayName=`${t}.Slottable`,e.__radixId=us,e}function ra(t){return u.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===us}function sa(t,e){const n={...e};for(const r in e){const o=t[r],s=e[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{const l=s(...a);return o(...a),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...t,...n}}function oa(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var ia=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ue=ia.reduce((t,e)=>{const n=ls(`Primitive.${e}`),r=u.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function aa(t,e){t&&ns.flushSync(()=>t.dispatchEvent(e))}function Qe(t){const e=u.useRef(t);return u.useEffect(()=>{e.current=t}),u.useMemo(()=>(...n)=>e.current?.(...n),[])}function ca(t,e=globalThis?.document){const n=Qe(t);u.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var la="DismissableLayer",yn="dismissableLayer.update",ua="dismissableLayer.pointerDownOutside",fa="dismissableLayer.focusOutside",dr,fs=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),jn=u.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=t,f=u.useContext(fs),[d,h]=u.useState(null),g=d?.ownerDocument??globalThis?.document,[,p]=u.useState({}),_=ye(e,T=>h(T)),m=Array.from(f.layers),[v]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),y=m.indexOf(v),E=d?m.indexOf(d):-1,x=f.layersWithOutsidePointerEventsDisabled.size>0,b=E>=y,C=pa(T=>{const P=T.target,w=[...f.branches].some(N=>N.contains(P));!b||w||(o?.(T),i?.(T),T.defaultPrevented||a?.())},g),S=ma(T=>{const P=T.target;[...f.branches].some(N=>N.contains(P))||(s?.(T),i?.(T),T.defaultPrevented||a?.())},g);return ca(T=>{E===f.layers.size-1&&(r?.(T),!T.defaultPrevented&&a&&(T.preventDefault(),a()))},g),u.useEffect(()=>{if(d)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(dr=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(d)),f.layers.add(d),hr(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=dr)}},[d,g,n,f]),u.useEffect(()=>()=>{d&&(f.layers.delete(d),f.layersWithOutsidePointerEventsDisabled.delete(d),hr())},[d,f]),u.useEffect(()=>{const T=()=>p({});return document.addEventListener(yn,T),()=>document.removeEventListener(yn,T)},[]),c.jsx(ue.div,{...l,ref:_,style:{pointerEvents:x?b?"auto":"none":void 0,...t.style},onFocusCapture:le(t.onFocusCapture,S.onFocusCapture),onBlurCapture:le(t.onBlurCapture,S.onBlurCapture),onPointerDownCapture:le(t.onPointerDownCapture,C.onPointerDownCapture)})});jn.displayName=la;var da="DismissableLayerBranch",ha=u.forwardRef((t,e)=>{const n=u.useContext(fs),r=u.useRef(null),o=ye(e,r);return u.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(ue.div,{...t,ref:o})});ha.displayName=da;function pa(t,e=globalThis?.document){const n=Qe(t),r=u.useRef(!1),o=u.useRef(()=>{});return u.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){ds(ua,n,f,{discrete:!0})};const f={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",o.current),o.current=l,e.addEventListener("click",o.current,{once:!0})):l()}else e.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{e.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),e.removeEventListener("pointerdown",s),e.removeEventListener("click",o.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function ma(t,e=globalThis?.document){const n=Qe(t),r=u.useRef(!1);return u.useEffect(()=>{const o=s=>{s.target&&!r.current&&ds(fa,n,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",o),()=>e.removeEventListener("focusin",o)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function hr(){const t=new CustomEvent(yn);document.dispatchEvent(t)}function ds(t,e,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&o.addEventListener(t,e,{once:!0}),r?aa(o,s):o.dispatchEvent(s)}var Zt="focusScope.autoFocusOnMount",en="focusScope.autoFocusOnUnmount",pr={bubbles:!1,cancelable:!0},ga="FocusScope",hs=u.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=t,[a,l]=u.useState(null),f=Qe(o),d=Qe(s),h=u.useRef(null),g=ye(e,m=>l(m)),p=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(r){let m=function(x){if(p.paused||!a)return;const b=x.target;a.contains(b)?h.current=b:Me(h.current,{select:!0})},v=function(x){if(p.paused||!a)return;const b=x.relatedTarget;b!==null&&(a.contains(b)||Me(h.current,{select:!0}))},y=function(x){if(document.activeElement===document.body)for(const C of x)C.removedNodes.length>0&&Me(a)};document.addEventListener("focusin",m),document.addEventListener("focusout",v);const E=new MutationObserver(y);return a&&E.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",v),E.disconnect()}}},[r,a,p.paused]),u.useEffect(()=>{if(a){gr.add(p);const m=document.activeElement;if(!a.contains(m)){const y=new CustomEvent(Zt,pr);a.addEventListener(Zt,f),a.dispatchEvent(y),y.defaultPrevented||(_a(wa(ps(a)),{select:!0}),document.activeElement===m&&Me(a))}return()=>{a.removeEventListener(Zt,f),setTimeout(()=>{const y=new CustomEvent(en,pr);a.addEventListener(en,d),a.dispatchEvent(y),y.defaultPrevented||Me(m??document.body,{select:!0}),a.removeEventListener(en,d),gr.remove(p)},0)}}},[a,f,d,p]);const _=u.useCallback(m=>{if(!n&&!r||p.paused)return;const v=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,y=document.activeElement;if(v&&y){const E=m.currentTarget,[x,b]=xa(E);x&&b?!m.shiftKey&&y===b?(m.preventDefault(),n&&Me(x,{select:!0})):m.shiftKey&&y===x&&(m.preventDefault(),n&&Me(b,{select:!0})):y===E&&m.preventDefault()}},[n,r,p.paused]);return c.jsx(ue.div,{tabIndex:-1,...i,ref:g,onKeyDown:_})});hs.displayName=ga;function _a(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Me(r,{select:e}),document.activeElement!==n)return}function xa(t){const e=ps(t),n=mr(e,t),r=mr(e.reverse(),t);return[n,r]}function ps(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function mr(t,e){for(const n of t)if(!va(n,{upTo:e}))return n}function va(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 ya(t){return t instanceof HTMLInputElement&&"select"in t}function Me(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&ya(t)&&e&&t.select()}}var gr=ba();function ba(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=_r(t,e),t.unshift(e)},remove(e){t=_r(t,e),t[0]?.resume()}}}function _r(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function wa(t){return t.filter(e=>e.tagName!=="A")}var Ea="Portal",Mn=u.forwardRef((t,e)=>{const{container:n,...r}=t,[o,s]=u.useState(!1);Ie(()=>s(!0),[]);const i=n||o&&globalThis?.document?.body;return i?Vo.createPortal(c.jsx(ue.div,{...r,ref:e}),i):null});Mn.displayName=Ea;function Ca(t,e){return u.useReducer((n,r)=>e[n][r]??n,t)}var tt=t=>{const{present:e,children:n}=t,r=Ta(e),o=typeof n=="function"?n({present:r.isPresent}):u.Children.only(n),s=ye(r.ref,Sa(o));return typeof n=="function"||r.isPresent?u.cloneElement(o,{ref:s}):null};tt.displayName="Presence";function Ta(t){const[e,n]=u.useState(),r=u.useRef(null),o=u.useRef(t),s=u.useRef("none"),i=t?"mounted":"unmounted",[a,l]=Ca(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const f=_t(r.current);s.current=a==="mounted"?f:"none"},[a]),Ie(()=>{const f=r.current,d=o.current;if(d!==t){const g=s.current,p=_t(f);t?l("MOUNT"):p==="none"||f?.display==="none"?l("UNMOUNT"):l(d&&g!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,l]),Ie(()=>{if(e){let f;const d=e.ownerDocument.defaultView??window,h=p=>{const m=_t(r.current).includes(CSS.escape(p.animationName));if(p.target===e&&m&&(l("ANIMATION_END"),!o.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",f=d.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},g=p=>{p.target===e&&(s.current=_t(r.current))};return e.addEventListener("animationstart",g),e.addEventListener("animationcancel",h),e.addEventListener("animationend",h),()=>{d.clearTimeout(f),e.removeEventListener("animationstart",g),e.removeEventListener("animationcancel",h),e.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:u.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function _t(t){return t?.animationName||"none"}function Sa(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var tn=0;function Ra(){u.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??xr()),document.body.insertAdjacentElement("beforeend",t[1]??xr()),tn++,()=>{tn===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),tn--}},[])}function xr(){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 Ee=function(){return Ee=Object.assign||function(e){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Ee.apply(this,arguments)};function ms(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]]);return n}function ka(t,e,n){if(n||arguments.length===2)for(var r=0,o=e.length,s;r<o;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}var Rt="right-scroll-bar-position",kt="width-before-scroll-bar",Na="with-scroll-bars-hidden",Pa="--removed-body-scroll-bar-size";function nn(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function Aa(t,e){var n=u.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=e,n.facade}var Da=typeof window<"u"?u.useLayoutEffect:u.useEffect,vr=new WeakMap;function Oa(t,e){var n=Aa(null,function(r){return t.forEach(function(o){return nn(o,r)})});return Da(function(){var r=vr.get(n);if(r){var o=new Set(r),s=new Set(t),i=n.current;o.forEach(function(a){s.has(a)||nn(a,null)}),s.forEach(function(a){o.has(a)||nn(a,i)})}vr.set(n,t)},[t]),n}function La(t){return t}function ja(t,e){e===void 0&&(e=La);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(s){var i=e(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},f=function(){return Promise.resolve().then(l)};f(),n={push:function(d){i.push(d),f()},filter:function(d){return i=i.filter(d),n}}}};return o}function Ma(t){t===void 0&&(t={});var e=ja(null);return e.options=Ee({async:!0,ssr:!1},t),e}var gs=function(t){var e=t.sideCar,n=ms(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return u.createElement(r,Ee({},n))};gs.isSideCarExport=!0;function Ba(t,e){return t.useMedium(e),gs}var _s=Ma(),rn=function(){},Wt=u.forwardRef(function(t,e){var n=u.useRef(null),r=u.useState({onScrollCapture:rn,onWheelCapture:rn,onTouchMoveCapture:rn}),o=r[0],s=r[1],i=t.forwardProps,a=t.children,l=t.className,f=t.removeScrollBar,d=t.enabled,h=t.shards,g=t.sideCar,p=t.noRelative,_=t.noIsolation,m=t.inert,v=t.allowPinchZoom,y=t.as,E=y===void 0?"div":y,x=t.gapMode,b=ms(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=g,S=Oa([n,e]),T=Ee(Ee({},b),o);return u.createElement(u.Fragment,null,d&&u.createElement(C,{sideCar:_s,removeScrollBar:f,shards:h,noRelative:p,noIsolation:_,inert:m,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:x}),i?u.cloneElement(u.Children.only(a),Ee(Ee({},T),{ref:S})):u.createElement(E,Ee({},T,{className:l,ref:S}),a))});Wt.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Wt.classNames={fullWidth:kt,zeroRight:Rt};var Ia=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Fa(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=Ia();return e&&t.setAttribute("nonce",e),t}function Ua(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function Wa(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var Ha=function(){var t=0,e=null;return{add:function(n){t==0&&(e=Fa())&&(Ua(e,n),Wa(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},$a=function(){var t=Ha();return function(e,n){u.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},xs=function(){var t=$a(),e=function(n){var r=n.styles,o=n.dynamic;return t(r,o),null};return e},Ga={left:0,top:0,right:0,gap:0},sn=function(t){return parseInt(t||"",10)||0},qa=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],o=e[t==="padding"?"paddingRight":"marginRight"];return[sn(n),sn(r),sn(o)]},za=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Ga;var e=qa(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},Va=xs(),Ye="data-scroll-locked",Xa=function(t,e,n,r){var o=t.left,s=t.top,i=t.right,a=t.gap;return n===void 0&&(n="margin"),`
6
+ .`.concat(Na,` {
7
+ overflow: hidden `).concat(r,`;
8
+ padding-right: `).concat(a,"px ").concat(r,`;
9
+ }
10
+ body[`).concat(Ye,`] {
11
+ overflow: hidden `).concat(r,`;
12
+ overscroll-behavior: contain;
13
+ `).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
14
+ padding-left: `.concat(o,`px;
15
+ padding-top: `).concat(s,`px;
16
+ padding-right: `).concat(i,`px;
17
+ margin-left:0;
18
+ margin-top:0;
19
+ margin-right: `).concat(a,"px ").concat(r,`;
20
+ `),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
21
+ }
22
+
23
+ .`).concat(Rt,` {
24
+ right: `).concat(a,"px ").concat(r,`;
25
+ }
26
+
27
+ .`).concat(kt,` {
28
+ margin-right: `).concat(a,"px ").concat(r,`;
29
+ }
30
+
31
+ .`).concat(Rt," .").concat(Rt,` {
32
+ right: 0 `).concat(r,`;
33
+ }
34
+
35
+ .`).concat(kt," .").concat(kt,` {
36
+ margin-right: 0 `).concat(r,`;
37
+ }
38
+
39
+ body[`).concat(Ye,`] {
40
+ `).concat(Pa,": ").concat(a,`px;
41
+ }
42
+ `)},yr=function(){var t=parseInt(document.body.getAttribute(Ye)||"0",10);return isFinite(t)?t:0},Ya=function(){u.useEffect(function(){return document.body.setAttribute(Ye,(yr()+1).toString()),function(){var t=yr()-1;t<=0?document.body.removeAttribute(Ye):document.body.setAttribute(Ye,t.toString())}},[])},Ka=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,o=r===void 0?"margin":r;Ya();var s=u.useMemo(function(){return za(o)},[o]);return u.createElement(Va,{styles:Xa(s,!e,o,n?"":"!important")})},bn=!1;if(typeof window<"u")try{var xt=Object.defineProperty({},"passive",{get:function(){return bn=!0,!0}});window.addEventListener("test",xt,xt),window.removeEventListener("test",xt,xt)}catch{bn=!1}var ze=bn?{passive:!1}:!1,Ja=function(t){return t.tagName==="TEXTAREA"},vs=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!Ja(t)&&n[e]==="visible")},Qa=function(t){return vs(t,"overflowY")},Za=function(t){return vs(t,"overflowX")},br=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=ys(t,r);if(o){var s=bs(t,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},ec=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},tc=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},ys=function(t,e){return t==="v"?Qa(e):Za(e)},bs=function(t,e){return t==="v"?ec(e):tc(e)},nc=function(t,e){return t==="h"&&e==="rtl"?-1:1},rc=function(t,e,n,r,o){var s=nc(t,window.getComputedStyle(e).direction),i=s*r,a=n.target,l=e.contains(a),f=!1,d=i>0,h=0,g=0;do{if(!a)break;var p=bs(t,a),_=p[0],m=p[1],v=p[2],y=m-v-s*_;(_||y)&&ys(t,a)&&(h+=y,g+=_);var E=a.parentNode;a=E&&E.nodeType===Node.DOCUMENT_FRAGMENT_NODE?E.host:E}while(!l&&a!==document.body||l&&(e.contains(a)||e===a));return(d&&Math.abs(h)<1||!d&&Math.abs(g)<1)&&(f=!0),f},vt=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},wr=function(t){return[t.deltaX,t.deltaY]},Er=function(t){return t&&"current"in t?t.current:t},sc=function(t,e){return t[0]===e[0]&&t[1]===e[1]},oc=function(t){return`
43
+ .block-interactivity-`.concat(t,` {pointer-events: none;}
44
+ .allow-interactivity-`).concat(t,` {pointer-events: all;}
45
+ `)},ic=0,Ve=[];function ac(t){var e=u.useRef([]),n=u.useRef([0,0]),r=u.useRef(),o=u.useState(ic++)[0],s=u.useState(xs)[0],i=u.useRef(t);u.useEffect(function(){i.current=t},[t]),u.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var m=ka([t.lockRef.current],(t.shards||[]).map(Er),!0).filter(Boolean);return m.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),m.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var a=u.useCallback(function(m,v){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!i.current.allowPinchZoom;var y=vt(m),E=n.current,x="deltaX"in m?m.deltaX:E[0]-y[0],b="deltaY"in m?m.deltaY:E[1]-y[1],C,S=m.target,T=Math.abs(x)>Math.abs(b)?"h":"v";if("touches"in m&&T==="h"&&S.type==="range")return!1;var P=window.getSelection(),w=P&&P.anchorNode,N=w?w===S||w.contains(S):!1;if(N)return!1;var R=br(T,S);if(!R)return!0;if(R?C=T:(C=T==="v"?"h":"v",R=br(T,S)),!R)return!1;if(!r.current&&"changedTouches"in m&&(x||b)&&(r.current=C),!C)return!0;var I=r.current||C;return rc(I,v,m,I==="h"?x:b)},[]),l=u.useCallback(function(m){var v=m;if(!(!Ve.length||Ve[Ve.length-1]!==s)){var y="deltaY"in v?wr(v):vt(v),E=e.current.filter(function(C){return C.name===v.type&&(C.target===v.target||v.target===C.shadowParent)&&sc(C.delta,y)})[0];if(E&&E.should){v.cancelable&&v.preventDefault();return}if(!E){var x=(i.current.shards||[]).map(Er).filter(Boolean).filter(function(C){return C.contains(v.target)}),b=x.length>0?a(v,x[0]):!i.current.noIsolation;b&&v.cancelable&&v.preventDefault()}}},[]),f=u.useCallback(function(m,v,y,E){var x={name:m,delta:v,target:y,should:E,shadowParent:cc(y)};e.current.push(x),setTimeout(function(){e.current=e.current.filter(function(b){return b!==x})},1)},[]),d=u.useCallback(function(m){n.current=vt(m),r.current=void 0},[]),h=u.useCallback(function(m){f(m.type,wr(m),m.target,a(m,t.lockRef.current))},[]),g=u.useCallback(function(m){f(m.type,vt(m),m.target,a(m,t.lockRef.current))},[]);u.useEffect(function(){return Ve.push(s),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",l,ze),document.addEventListener("touchmove",l,ze),document.addEventListener("touchstart",d,ze),function(){Ve=Ve.filter(function(m){return m!==s}),document.removeEventListener("wheel",l,ze),document.removeEventListener("touchmove",l,ze),document.removeEventListener("touchstart",d,ze)}},[]);var p=t.removeScrollBar,_=t.inert;return u.createElement(u.Fragment,null,_?u.createElement(s,{styles:oc(o)}):null,p?u.createElement(Ka,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function cc(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const lc=Ba(_s,ac);var ws=u.forwardRef(function(t,e){return u.createElement(Wt,Ee({},t,{ref:e,sideCar:lc}))});ws.classNames=Wt.classNames;var uc=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Xe=new WeakMap,yt=new WeakMap,bt={},on=0,Es=function(t){return t&&(t.host||Es(t.parentNode))},fc=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=Es(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},dc=function(t,e,n,r){var o=fc(e,Array.isArray(t)?t:[t]);bt[n]||(bt[n]=new WeakMap);var s=bt[n],i=[],a=new Set,l=new Set(o),f=function(h){!h||a.has(h)||(a.add(h),f(h.parentNode))};o.forEach(f);var d=function(h){!h||l.has(h)||Array.prototype.forEach.call(h.children,function(g){if(a.has(g))d(g);else try{var p=g.getAttribute(r),_=p!==null&&p!=="false",m=(Xe.get(g)||0)+1,v=(s.get(g)||0)+1;Xe.set(g,m),s.set(g,v),i.push(g),m===1&&_&&yt.set(g,!0),v===1&&g.setAttribute(n,"true"),_||g.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",g,y)}})};return d(e),a.clear(),on++,function(){i.forEach(function(h){var g=Xe.get(h)-1,p=s.get(h)-1;Xe.set(h,g),s.set(h,p),g||(yt.has(h)||h.removeAttribute(r),yt.delete(h)),p||h.removeAttribute(n)}),on--,on||(Xe=new WeakMap,Xe=new WeakMap,yt=new WeakMap,bt={})}},hc=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),o=uc(t);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),dc(r,o,n,"aria-hidden")):function(){return null}},Ht="Dialog",[Cs]=Ln(Ht),[pc,be]=Cs(Ht),Ts=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=t,a=u.useRef(null),l=u.useRef(null),[f,d]=cs({prop:r,defaultProp:o??!1,onChange:s,caller:Ht});return c.jsx(pc,{scope:e,triggerRef:a,contentRef:l,contentId:St(),titleId:St(),descriptionId:St(),open:f,onOpenChange:d,onOpenToggle:u.useCallback(()=>d(h=>!h),[d]),modal:i,children:n})};Ts.displayName=Ht;var Ss="DialogTrigger",mc=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=be(Ss,n),s=ye(e,o.triggerRef);return c.jsx(ue.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Fn(o.open),...r,ref:s,onClick:le(t.onClick,o.onOpenToggle)})});mc.displayName=Ss;var Bn="DialogPortal",[gc,Rs]=Cs(Bn,{forceMount:void 0}),ks=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:o}=t,s=be(Bn,e);return c.jsx(gc,{scope:e,forceMount:n,children:u.Children.map(r,i=>c.jsx(tt,{present:n||s.open,children:c.jsx(Mn,{asChild:!0,container:o,children:i})}))})};ks.displayName=Bn;var jt="DialogOverlay",Ns=u.forwardRef((t,e)=>{const n=Rs(jt,t.__scopeDialog),{forceMount:r=n.forceMount,...o}=t,s=be(jt,t.__scopeDialog);return s.modal?c.jsx(tt,{present:r||s.open,children:c.jsx(xc,{...o,ref:e})}):null});Ns.displayName=jt;var _c=ls("DialogOverlay.RemoveScroll"),xc=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=be(jt,n);return c.jsx(ws,{as:_c,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(ue.div,{"data-state":Fn(o.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),$e="DialogContent",Ps=u.forwardRef((t,e)=>{const n=Rs($e,t.__scopeDialog),{forceMount:r=n.forceMount,...o}=t,s=be($e,t.__scopeDialog);return c.jsx(tt,{present:r||s.open,children:s.modal?c.jsx(vc,{...o,ref:e}):c.jsx(yc,{...o,ref:e})})});Ps.displayName=$e;var vc=u.forwardRef((t,e)=>{const n=be($e,t.__scopeDialog),r=u.useRef(null),o=ye(e,n.contentRef,r);return u.useEffect(()=>{const s=r.current;if(s)return hc(s)},[]),c.jsx(As,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:le(t.onCloseAutoFocus,s=>{s.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:le(t.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:le(t.onFocusOutside,s=>s.preventDefault())})}),yc=u.forwardRef((t,e)=>{const n=be($e,t.__scopeDialog),r=u.useRef(!1),o=u.useRef(!1);return c.jsx(As,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{t.onCloseAutoFocus?.(s),s.defaultPrevented||(r.current||n.triggerRef.current?.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{t.onInteractOutside?.(s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;n.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),As=u.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=t,a=be($e,n),l=u.useRef(null),f=ye(e,l);return Ra(),c.jsxs(c.Fragment,{children:[c.jsx(hs,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(jn,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Fn(a.open),...i,ref:f,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(bc,{titleId:a.titleId}),c.jsx(Ec,{contentRef:l,descriptionId:a.descriptionId})]})]})}),In="DialogTitle",Ds=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=be(In,n);return c.jsx(ue.h2,{id:o.titleId,...r,ref:e})});Ds.displayName=In;var Os="DialogDescription",Ls=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=be(Os,n);return c.jsx(ue.p,{id:o.descriptionId,...r,ref:e})});Ls.displayName=Os;var js="DialogClose",Ms=u.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=be(js,n);return c.jsx(ue.button,{type:"button",...r,ref:e,onClick:le(t.onClick,()=>o.onOpenChange(!1))})});Ms.displayName=js;function Fn(t){return t?"open":"closed"}var Bs="DialogTitleWarning",[md,Is]=Xi(Bs,{contentName:$e,titleName:In,docsSlug:"dialog"}),bc=({titleId:t})=>{const e=Is(Bs),n=`\`${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 u.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},wc="DialogDescriptionWarning",Ec=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Is(wc).contentName}}.`;return u.useEffect(()=>{const o=t.current?.getAttribute("aria-describedby");e&&o&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},Cc=Ts,Tc=ks,Fs=Ns,Us=Ps,Ws=Ds,Hs=Ls,Sc=Ms;const $s=Cc,Rc=Tc,Gs=u.forwardRef(({className:t,...e},n)=>c.jsx(Fs,{ref:n,className:ce("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}));Gs.displayName=Fs.displayName;const Un=u.forwardRef(({className:t,children:e,...n},r)=>c.jsxs(Rc,{children:[c.jsx(Gs,{}),c.jsxs(Us,{ref:r,className:ce("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-slate-200 bg-white p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-2xl dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50",t),...n,children:[e,c.jsxs(Sc,{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:[c.jsx(zi,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Un.displayName=Us.displayName;const Wn=({className:t,...e})=>c.jsx("div",{className:ce("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});Wn.displayName="DialogHeader";const Hn=({className:t,...e})=>c.jsx("div",{className:ce("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});Hn.displayName="DialogFooter";const $n=u.forwardRef(({className:t,...e},n)=>c.jsx(Ws,{ref:n,className:ce("text-lg font-semibold leading-none tracking-tight",t),...e}));$n.displayName=Ws.displayName;const Gn=u.forwardRef(({className:t,...e},n)=>c.jsx(Hs,{ref:n,className:ce("text-sm text-slate-500 dark:text-slate-400",t),...e}));Gn.displayName=Hs.displayName;const kc=["top","right","bottom","left"],Fe=Math.min,fe=Math.max,Mt=Math.round,wt=Math.floor,Te=t=>({x:t,y:t}),Nc={left:"right",right:"left",bottom:"top",top:"bottom"},Pc={start:"end",end:"start"};function wn(t,e,n){return fe(t,Fe(e,n))}function Pe(t,e){return typeof t=="function"?t(e):t}function Ae(t){return t.split("-")[0]}function nt(t){return t.split("-")[1]}function qn(t){return t==="x"?"y":"x"}function zn(t){return t==="y"?"height":"width"}const Ac=new Set(["top","bottom"]);function Ce(t){return Ac.has(Ae(t))?"y":"x"}function Vn(t){return qn(Ce(t))}function Dc(t,e,n){n===void 0&&(n=!1);const r=nt(t),o=Vn(t),s=zn(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(i=Bt(i)),[i,Bt(i)]}function Oc(t){const e=Bt(t);return[En(t),e,En(e)]}function En(t){return t.replace(/start|end/g,e=>Pc[e])}const Cr=["left","right"],Tr=["right","left"],Lc=["top","bottom"],jc=["bottom","top"];function Mc(t,e,n){switch(t){case"top":case"bottom":return n?e?Tr:Cr:e?Cr:Tr;case"left":case"right":return e?Lc:jc;default:return[]}}function Bc(t,e,n,r){const o=nt(t);let s=Mc(Ae(t),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),e&&(s=s.concat(s.map(En)))),s}function Bt(t){return t.replace(/left|right|bottom|top/g,e=>Nc[e])}function Ic(t){return{top:0,right:0,bottom:0,left:0,...t}}function qs(t){return typeof t!="number"?Ic(t):{top:t,right:t,bottom:t,left:t}}function It(t){const{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}function Sr(t,e,n){let{reference:r,floating:o}=t;const s=Ce(e),i=Vn(e),a=zn(i),l=Ae(e),f=s==="y",d=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,g=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:h};break;case"left":p={x:r.x-o.width,y:h};break;default:p={x:r.x,y:r.y}}switch(nt(e)){case"start":p[i]-=g*(n&&f?-1:1);break;case"end":p[i]+=g*(n&&f?-1:1);break}return p}const Fc=async(t,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(e));let f=await i.getElementRects({reference:t,floating:e,strategy:o}),{x:d,y:h}=Sr(f,r,l),g=r,p={},_=0;for(let m=0;m<a.length;m++){const{name:v,fn:y}=a[m],{x:E,y:x,data:b,reset:C}=await y({x:d,y:h,initialPlacement:r,placement:g,strategy:o,middlewareData:p,rects:f,platform:i,elements:{reference:t,floating:e}});d=E??d,h=x??h,p={...p,[v]:{...p[v],...b}},C&&_<=50&&(_++,typeof C=="object"&&(C.placement&&(g=C.placement),C.rects&&(f=C.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:o}):C.rects),{x:d,y:h}=Sr(f,g,l)),m=-1)}return{x:d,y:h,placement:g,strategy:o,middlewareData:p}};async function ft(t,e){var n;e===void 0&&(e={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=t,{boundary:f="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:g=!1,padding:p=0}=Pe(e,t),_=qs(p),v=a[g?h==="floating"?"reference":"floating":h],y=It(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:f,rootBoundary:d,strategy:l})),E=h==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),b=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},C=It(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:E,offsetParent:x,strategy:l}):E);return{top:(y.top-C.top+_.top)/b.y,bottom:(C.bottom-y.bottom+_.bottom)/b.y,left:(y.left-C.left+_.left)/b.x,right:(C.right-y.right+_.right)/b.x}}const Uc=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=e,{element:f,padding:d=0}=Pe(t,e)||{};if(f==null)return{};const h=qs(d),g={x:n,y:r},p=Vn(o),_=zn(p),m=await i.getDimensions(f),v=p==="y",y=v?"top":"left",E=v?"bottom":"right",x=v?"clientHeight":"clientWidth",b=s.reference[_]+s.reference[p]-g[p]-s.floating[_],C=g[p]-s.reference[p],S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(f));let T=S?S[x]:0;(!T||!await(i.isElement==null?void 0:i.isElement(S)))&&(T=a.floating[x]||s.floating[_]);const P=b/2-C/2,w=T/2-m[_]/2-1,N=Fe(h[y],w),R=Fe(h[E],w),I=N,F=T-m[_]-R,k=T/2-m[_]/2+P,A=wn(I,k,F),D=!l.arrow&&nt(o)!=null&&k!==A&&s.reference[_]/2-(k<I?N:R)-m[_]/2<0,M=D?k<I?k-I:k-F:0;return{[p]:g[p]+M,data:{[p]:A,centerOffset:k-A-M,...D&&{alignmentOffset:M}},reset:D}}}),Wc=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:f}=e,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:g,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:_="none",flipAlignment:m=!0,...v}=Pe(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Ae(o),E=Ce(a),x=Ae(a)===a,b=await(l.isRTL==null?void 0:l.isRTL(f.floating)),C=g||(x||!m?[Bt(a)]:Oc(a)),S=_!=="none";!g&&S&&C.push(...Bc(a,m,_,b));const T=[a,...C],P=await ft(e,v),w=[];let N=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&w.push(P[y]),h){const k=Dc(o,i,b);w.push(P[k[0]],P[k[1]])}if(N=[...N,{placement:o,overflows:w}],!w.every(k=>k<=0)){var R,I;const k=(((R=s.flip)==null?void 0:R.index)||0)+1,A=T[k];if(A&&(!(h==="alignment"?E!==Ce(A):!1)||N.every(L=>Ce(L.placement)===E?L.overflows[0]>0:!0)))return{data:{index:k,overflows:N},reset:{placement:A}};let D=(I=N.filter(M=>M.overflows[0]<=0).sort((M,L)=>M.overflows[1]-L.overflows[1])[0])==null?void 0:I.placement;if(!D)switch(p){case"bestFit":{var F;const M=(F=N.filter(L=>{if(S){const U=Ce(L.placement);return U===E||U==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(U=>U>0).reduce((U,G)=>U+G,0)]).sort((L,U)=>L[1]-U[1])[0])==null?void 0:F[0];M&&(D=M);break}case"initialPlacement":D=a;break}if(o!==D)return{reset:{placement:D}}}return{}}}};function Rr(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function kr(t){return kc.some(e=>t[e]>=0)}const Hc=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...o}=Pe(t,e);switch(r){case"referenceHidden":{const s=await ft(e,{...o,elementContext:"reference"}),i=Rr(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:kr(i)}}}case"escaped":{const s=await ft(e,{...o,altBoundary:!0}),i=Rr(s,n.floating);return{data:{escapedOffsets:i,escaped:kr(i)}}}default:return{}}}}},zs=new Set(["left","top"]);async function $c(t,e){const{placement:n,platform:r,elements:o}=t,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Ae(n),a=nt(n),l=Ce(n)==="y",f=zs.has(i)?-1:1,d=s&&l?-1:1,h=Pe(e,t);let{mainAxis:g,crossAxis:p,alignmentAxis:_}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof _=="number"&&(p=a==="end"?_*-1:_),l?{x:p*d,y:g*f}:{x:g*f,y:p*d}}const Gc=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=e,l=await $c(e,t);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},qc=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:o}=e,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:v=>{let{x:y,y:E}=v;return{x:y,y:E}}},...l}=Pe(t,e),f={x:n,y:r},d=await ft(e,l),h=Ce(Ae(o)),g=qn(h);let p=f[g],_=f[h];if(s){const v=g==="y"?"top":"left",y=g==="y"?"bottom":"right",E=p+d[v],x=p-d[y];p=wn(E,p,x)}if(i){const v=h==="y"?"top":"left",y=h==="y"?"bottom":"right",E=_+d[v],x=_-d[y];_=wn(E,_,x)}const m=a.fn({...e,[g]:p,[h]:_});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[g]:s,[h]:i}}}}}},zc=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=e,{offset:a=0,mainAxis:l=!0,crossAxis:f=!0}=Pe(t,e),d={x:n,y:r},h=Ce(o),g=qn(h);let p=d[g],_=d[h];const m=Pe(a,e),v=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const x=g==="y"?"height":"width",b=s.reference[g]-s.floating[x]+v.mainAxis,C=s.reference[g]+s.reference[x]-v.mainAxis;p<b?p=b:p>C&&(p=C)}if(f){var y,E;const x=g==="y"?"width":"height",b=zs.has(Ae(o)),C=s.reference[h]-s.floating[x]+(b&&((y=i.offset)==null?void 0:y[h])||0)+(b?0:v.crossAxis),S=s.reference[h]+s.reference[x]+(b?0:((E=i.offset)==null?void 0:E[h])||0)-(b?v.crossAxis:0);_<C?_=C:_>S&&(_=S)}return{[g]:p,[h]:_}}}},Vc=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:o,rects:s,platform:i,elements:a}=e,{apply:l=()=>{},...f}=Pe(t,e),d=await ft(e,f),h=Ae(o),g=nt(o),p=Ce(o)==="y",{width:_,height:m}=s.floating;let v,y;h==="top"||h==="bottom"?(v=h,y=g===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=h,v=g==="end"?"top":"bottom");const E=m-d.top-d.bottom,x=_-d.left-d.right,b=Fe(m-d[v],E),C=Fe(_-d[y],x),S=!e.middlewareData.shift;let T=b,P=C;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(P=x),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(T=E),S&&!g){const N=fe(d.left,0),R=fe(d.right,0),I=fe(d.top,0),F=fe(d.bottom,0);p?P=_-2*(N!==0||R!==0?N+R:fe(d.left,d.right)):T=m-2*(I!==0||F!==0?I+F:fe(d.top,d.bottom))}await l({...e,availableWidth:P,availableHeight:T});const w=await i.getDimensions(a.floating);return _!==w.width||m!==w.height?{reset:{rects:!0}}:{}}}};function $t(){return typeof window<"u"}function rt(t){return Vs(t)?(t.nodeName||"").toLowerCase():"#document"}function de(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Ne(t){var e;return(e=(Vs(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Vs(t){return $t()?t instanceof Node||t instanceof de(t).Node:!1}function xe(t){return $t()?t instanceof Element||t instanceof de(t).Element:!1}function Re(t){return $t()?t instanceof HTMLElement||t instanceof de(t).HTMLElement:!1}function Nr(t){return!$t()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof de(t).ShadowRoot}const Xc=new Set(["inline","contents"]);function mt(t){const{overflow:e,overflowX:n,overflowY:r,display:o}=ve(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!Xc.has(o)}const Yc=new Set(["table","td","th"]);function Kc(t){return Yc.has(rt(t))}const Jc=[":popover-open",":modal"];function Gt(t){return Jc.some(e=>{try{return t.matches(e)}catch{return!1}})}const Qc=["transform","translate","scale","rotate","perspective"],Zc=["transform","translate","scale","rotate","perspective","filter"],el=["paint","layout","strict","content"];function Xn(t){const e=Yn(),n=xe(t)?ve(t):t;return Qc.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||Zc.some(r=>(n.willChange||"").includes(r))||el.some(r=>(n.contain||"").includes(r))}function tl(t){let e=Ue(t);for(;Re(e)&&!Ze(e);){if(Xn(e))return e;if(Gt(e))return null;e=Ue(e)}return null}function Yn(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const nl=new Set(["html","body","#document"]);function Ze(t){return nl.has(rt(t))}function ve(t){return de(t).getComputedStyle(t)}function qt(t){return xe(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Ue(t){if(rt(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Nr(t)&&t.host||Ne(t);return Nr(e)?e.host:e}function Xs(t){const e=Ue(t);return Ze(e)?t.ownerDocument?t.ownerDocument.body:t.body:Re(e)&&mt(e)?e:Xs(e)}function dt(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const o=Xs(t),s=o===((r=t.ownerDocument)==null?void 0:r.body),i=de(o);if(s){const a=Cn(i);return e.concat(i,i.visualViewport||[],mt(o)?o:[],a&&n?dt(a):[])}return e.concat(o,dt(o,[],n))}function Cn(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Ys(t){const e=ve(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const o=Re(t),s=o?t.offsetWidth:n,i=o?t.offsetHeight:r,a=Mt(n)!==s||Mt(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Kn(t){return xe(t)?t:t.contextElement}function Ke(t){const e=Kn(t);if(!Re(e))return Te(1);const n=e.getBoundingClientRect(),{width:r,height:o,$:s}=Ys(e);let i=(s?Mt(n.width):n.width)/r,a=(s?Mt(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const rl=Te(0);function Ks(t){const e=de(t);return!Yn()||!e.visualViewport?rl:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function sl(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==de(t)?!1:e}function Ge(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),s=Kn(t);let i=Te(1);e&&(r?xe(r)&&(i=Ke(r)):i=Ke(t));const a=sl(s,n,r)?Ks(s):Te(0);let l=(o.left+a.x)/i.x,f=(o.top+a.y)/i.y,d=o.width/i.x,h=o.height/i.y;if(s){const g=de(s),p=r&&xe(r)?de(r):r;let _=g,m=Cn(_);for(;m&&r&&p!==_;){const v=Ke(m),y=m.getBoundingClientRect(),E=ve(m),x=y.left+(m.clientLeft+parseFloat(E.paddingLeft))*v.x,b=y.top+(m.clientTop+parseFloat(E.paddingTop))*v.y;l*=v.x,f*=v.y,d*=v.x,h*=v.y,l+=x,f+=b,_=de(m),m=Cn(_)}}return It({width:d,height:h,x:l,y:f})}function zt(t,e){const n=qt(t).scrollLeft;return e?e.left+n:Ge(Ne(t)).left+n}function Js(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-zt(t,n),o=n.top+e.scrollTop;return{x:r,y:o}}function ol(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t;const s=o==="fixed",i=Ne(r),a=e?Gt(e.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},f=Te(1);const d=Te(0),h=Re(r);if((h||!h&&!s)&&((rt(r)!=="body"||mt(i))&&(l=qt(r)),Re(r))){const p=Ge(r);f=Ke(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const g=i&&!h&&!s?Js(i,l):Te(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-l.scrollLeft*f.x+d.x+g.x,y:n.y*f.y-l.scrollTop*f.y+d.y+g.y}}function il(t){return Array.from(t.getClientRects())}function al(t){const e=Ne(t),n=qt(t),r=t.ownerDocument.body,o=fe(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=fe(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+zt(t);const a=-n.scrollTop;return ve(r).direction==="rtl"&&(i+=fe(e.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Pr=25;function cl(t,e){const n=de(t),r=Ne(t),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Yn();(!d||d&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const f=zt(r);if(f<=0){const d=r.ownerDocument,h=d.body,g=getComputedStyle(h),p=d.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,_=Math.abs(r.clientWidth-h.clientWidth-p);_<=Pr&&(s-=_)}else f<=Pr&&(s+=f);return{width:s,height:i,x:a,y:l}}const ll=new Set(["absolute","fixed"]);function ul(t,e){const n=Ge(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,s=Re(t)?Ke(t):Te(1),i=t.clientWidth*s.x,a=t.clientHeight*s.y,l=o*s.x,f=r*s.y;return{width:i,height:a,x:l,y:f}}function Ar(t,e,n){let r;if(e==="viewport")r=cl(t,n);else if(e==="document")r=al(Ne(t));else if(xe(e))r=ul(e,n);else{const o=Ks(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return It(r)}function Qs(t,e){const n=Ue(t);return n===e||!xe(n)||Ze(n)?!1:ve(n).position==="fixed"||Qs(n,e)}function fl(t,e){const n=e.get(t);if(n)return n;let r=dt(t,[],!1).filter(a=>xe(a)&&rt(a)!=="body"),o=null;const s=ve(t).position==="fixed";let i=s?Ue(t):t;for(;xe(i)&&!Ze(i);){const a=ve(i),l=Xn(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&ll.has(o.position)||mt(i)&&!l&&Qs(t,i))?r=r.filter(d=>d!==i):o=a,i=Ue(i)}return e.set(t,r),r}function dl(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t;const i=[...n==="clippingAncestors"?Gt(e)?[]:fl(e,this._c):[].concat(n),r],a=i[0],l=i.reduce((f,d)=>{const h=Ar(e,d,o);return f.top=fe(h.top,f.top),f.right=Fe(h.right,f.right),f.bottom=Fe(h.bottom,f.bottom),f.left=fe(h.left,f.left),f},Ar(e,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function hl(t){const{width:e,height:n}=Ys(t);return{width:e,height:n}}function pl(t,e,n){const r=Re(e),o=Ne(e),s=n==="fixed",i=Ge(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=Te(0);function f(){l.x=zt(o)}if(r||!r&&!s)if((rt(e)!=="body"||mt(o))&&(a=qt(e)),r){const p=Ge(e,!0,s,e);l.x=p.x+e.clientLeft,l.y=p.y+e.clientTop}else o&&f();s&&!r&&o&&f();const d=o&&!r&&!s?Js(o,a):Te(0),h=i.left+a.scrollLeft-l.x-d.x,g=i.top+a.scrollTop-l.y-d.y;return{x:h,y:g,width:i.width,height:i.height}}function an(t){return ve(t).position==="static"}function Dr(t,e){if(!Re(t)||ve(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Ne(t)===n&&(n=n.ownerDocument.body),n}function Zs(t,e){const n=de(t);if(Gt(t))return n;if(!Re(t)){let o=Ue(t);for(;o&&!Ze(o);){if(xe(o)&&!an(o))return o;o=Ue(o)}return n}let r=Dr(t,e);for(;r&&Kc(r)&&an(r);)r=Dr(r,e);return r&&Ze(r)&&an(r)&&!Xn(r)?n:r||tl(t)||n}const ml=async function(t){const e=this.getOffsetParent||Zs,n=this.getDimensions,r=await n(t.floating);return{reference:pl(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function gl(t){return ve(t).direction==="rtl"}const _l={convertOffsetParentRelativeRectToViewportRelativeRect:ol,getDocumentElement:Ne,getClippingRect:dl,getOffsetParent:Zs,getElementRects:ml,getClientRects:il,getDimensions:hl,getScale:Ke,isElement:xe,isRTL:gl};function eo(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function xl(t,e){let n=null,r;const o=Ne(t);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const f=t.getBoundingClientRect(),{left:d,top:h,width:g,height:p}=f;if(a||e(),!g||!p)return;const _=wt(h),m=wt(o.clientWidth-(d+g)),v=wt(o.clientHeight-(h+p)),y=wt(d),x={rootMargin:-_+"px "+-m+"px "+-v+"px "+-y+"px",threshold:fe(0,Fe(1,l))||1};let b=!0;function C(S){const T=S[0].intersectionRatio;if(T!==l){if(!b)return i();T?i(!1,T):r=setTimeout(()=>{i(!1,1e-7)},1e3)}T===1&&!eo(f,t.getBoundingClientRect())&&i(),b=!1}try{n=new IntersectionObserver(C,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(t)}return i(!0),s}function vl(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,f=Kn(t),d=o||s?[...f?dt(f):[],...dt(e)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const h=f&&a?xl(f,n):null;let g=-1,p=null;i&&(p=new ResizeObserver(y=>{let[E]=y;E&&E.target===f&&p&&(p.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var x;(x=p)==null||x.observe(e)})),n()}),f&&!l&&p.observe(f),p.observe(e));let _,m=l?Ge(t):null;l&&v();function v(){const y=Ge(t);m&&!eo(m,y)&&n(),m=y,_=requestAnimationFrame(v)}return n(),()=>{var y;d.forEach(E=>{o&&E.removeEventListener("scroll",n),s&&E.removeEventListener("resize",n)}),h?.(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(_)}}const yl=Gc,bl=qc,wl=Wc,El=Vc,Cl=Hc,Or=Uc,Tl=zc,Sl=(t,e,n)=>{const r=new Map,o={platform:_l,...n},s={...o.platform,_c:r};return Fc(t,e,{...o,platform:s})};var Rl=typeof document<"u",kl=function(){},Nt=Rl?u.useLayoutEffect:kl;function Ft(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,o;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!Ft(t[r],e[r]))return!1;return!0}if(o=Object.keys(t),n=o.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&t.$$typeof)&&!Ft(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function to(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Lr(t,e){const n=to(t);return Math.round(e*n)/n}function cn(t){const e=u.useRef(t);return Nt(()=>{e.current=t}),e}function Nl(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:f}=t,[d,h]=u.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[g,p]=u.useState(r);Ft(g,r)||p(r);const[_,m]=u.useState(null),[v,y]=u.useState(null),E=u.useCallback(L=>{L!==S.current&&(S.current=L,m(L))},[]),x=u.useCallback(L=>{L!==T.current&&(T.current=L,y(L))},[]),b=s||_,C=i||v,S=u.useRef(null),T=u.useRef(null),P=u.useRef(d),w=l!=null,N=cn(l),R=cn(o),I=cn(f),F=u.useCallback(()=>{if(!S.current||!T.current)return;const L={placement:e,strategy:n,middleware:g};R.current&&(L.platform=R.current),Sl(S.current,T.current,L).then(U=>{const G={...U,isPositioned:I.current!==!1};k.current&&!Ft(P.current,G)&&(P.current=G,ns.flushSync(()=>{h(G)}))})},[g,e,n,R,I]);Nt(()=>{f===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,h(L=>({...L,isPositioned:!1})))},[f]);const k=u.useRef(!1);Nt(()=>(k.current=!0,()=>{k.current=!1}),[]),Nt(()=>{if(b&&(S.current=b),C&&(T.current=C),b&&C){if(N.current)return N.current(b,C,F);F()}},[b,C,F,N,w]);const A=u.useMemo(()=>({reference:S,floating:T,setReference:E,setFloating:x}),[E,x]),D=u.useMemo(()=>({reference:b,floating:C}),[b,C]),M=u.useMemo(()=>{const L={position:n,left:0,top:0};if(!D.floating)return L;const U=Lr(D.floating,d.x),G=Lr(D.floating,d.y);return a?{...L,transform:"translate("+U+"px, "+G+"px)",...to(D.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:U,top:G}},[n,a,D.floating,d.x,d.y]);return u.useMemo(()=>({...d,update:F,refs:A,elements:D,floatingStyles:M}),[d,F,A,D,M])}const Pl=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:o}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?Or({element:r.current,padding:o}).fn(n):{}:r?Or({element:r,padding:o}).fn(n):{}}}},Al=(t,e)=>({...yl(t),options:[t,e]}),Dl=(t,e)=>({...bl(t),options:[t,e]}),Ol=(t,e)=>({...Tl(t),options:[t,e]}),Ll=(t,e)=>({...wl(t),options:[t,e]}),jl=(t,e)=>({...El(t),options:[t,e]}),Ml=(t,e)=>({...Cl(t),options:[t,e]}),Bl=(t,e)=>({...Pl(t),options:[t,e]});var Il="Arrow",no=u.forwardRef((t,e)=>{const{children:n,width:r=10,height:o=5,...s}=t;return c.jsx(ue.svg,{...s,ref:e,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});no.displayName=Il;var Fl=no;function Ul(t){const[e,n]=u.useState(void 0);return Ie(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,f=Array.isArray(l)?l[0]:l;i=f.inlineSize,a=f.blockSize}else i=t.offsetWidth,a=t.offsetHeight;n({width:i,height:a})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var Jn="Popper",[ro,so]=Ln(Jn),[Wl,oo]=ro(Jn),io=t=>{const{__scopePopper:e,children:n}=t,[r,o]=u.useState(null);return c.jsx(Wl,{scope:e,anchor:r,onAnchorChange:o,children:n})};io.displayName=Jn;var ao="PopperAnchor",co=u.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...o}=t,s=oo(ao,n),i=u.useRef(null),a=ye(e,i),l=u.useRef(null);return u.useEffect(()=>{const f=l.current;l.current=r?.current||i.current,f!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(ue.div,{...o,ref:a})});co.displayName=ao;var Qn="PopperContent",[Hl,$l]=ro(Qn),lo=u.forwardRef((t,e)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:f=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:g=!1,updatePositionStrategy:p="optimized",onPlaced:_,...m}=t,v=oo(Qn,n),[y,E]=u.useState(null),x=ye(e,te=>E(te)),[b,C]=u.useState(null),S=Ul(b),T=S?.width??0,P=S?.height??0,w=r+(s!=="center"?"-"+s:""),N=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},R=Array.isArray(f)?f:[f],I=R.length>0,F={padding:N,boundary:R.filter(ql),altBoundary:I},{refs:k,floatingStyles:A,placement:D,isPositioned:M,middlewareData:L}=Nl({strategy:"fixed",placement:w,whileElementsMounted:(...te)=>vl(...te,{animationFrame:p==="always"}),elements:{reference:v.anchor},middleware:[Al({mainAxis:o+P,alignmentAxis:i}),l&&Dl({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Ol():void 0,...F}),l&&Ll({...F}),jl({...F,apply:({elements:te,rects:ie,availableWidth:K,availableHeight:pe})=>{const{width:We,height:De}=ie.reference,ge=te.floating.style;ge.setProperty("--radix-popper-available-width",`${K}px`),ge.setProperty("--radix-popper-available-height",`${pe}px`),ge.setProperty("--radix-popper-anchor-width",`${We}px`),ge.setProperty("--radix-popper-anchor-height",`${De}px`)}}),b&&Bl({element:b,padding:a}),zl({arrowWidth:T,arrowHeight:P}),g&&Ml({strategy:"referenceHidden",...F})]}),[U,G]=ho(D),q=Qe(_);Ie(()=>{M&&q?.()},[M,q]);const Y=L.arrow?.x,Z=L.arrow?.y,ee=L.arrow?.centerOffset!==0,[se,he]=u.useState();return Ie(()=>{y&&he(window.getComputedStyle(y).zIndex)},[y]),c.jsx("div",{ref:k.setFloating,"data-radix-popper-content-wrapper":"",style:{...A,transform:M?A.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:se,"--radix-popper-transform-origin":[L.transformOrigin?.x,L.transformOrigin?.y].join(" "),...L.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:c.jsx(Hl,{scope:n,placedSide:U,onArrowChange:C,arrowX:Y,arrowY:Z,shouldHideArrow:ee,children:c.jsx(ue.div,{"data-side":U,"data-align":G,...m,ref:x,style:{...m.style,animation:M?void 0:"none"}})})})});lo.displayName=Qn;var uo="PopperArrow",Gl={top:"bottom",right:"left",bottom:"top",left:"right"},fo=u.forwardRef(function(e,n){const{__scopePopper:r,...o}=e,s=$l(uo,r),i=Gl[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(Fl,{...o,ref:n,style:{...o.style,display:"block"}})})});fo.displayName=uo;function ql(t){return t!==null}var zl=t=>({name:"transformOrigin",options:t,fn(e){const{placement:n,rects:r,middlewareData:o}=e,i=o.arrow?.centerOffset!==0,a=i?0:t.arrowWidth,l=i?0:t.arrowHeight,[f,d]=ho(n),h={start:"0%",center:"50%",end:"100%"}[d],g=(o.arrow?.x??0)+a/2,p=(o.arrow?.y??0)+l/2;let _="",m="";return f==="bottom"?(_=i?h:`${g}px`,m=`${-l}px`):f==="top"?(_=i?h:`${g}px`,m=`${r.floating.height+l}px`):f==="right"?(_=`${-l}px`,m=i?h:`${p}px`):f==="left"&&(_=`${r.floating.width+l}px`,m=i?h:`${p}px`),{data:{x:_,y:m}}}});function ho(t){const[e,n="center"]=t.split("-");return[e,n]}var Vl=io,Xl=co,Yl=lo,Kl=fo,Jl=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Ql="VisuallyHidden",po=u.forwardRef((t,e)=>c.jsx(ue.span,{...t,ref:e,style:{...Jl,...t.style}}));po.displayName=Ql;var Zl=po,[Vt]=Ln("Tooltip",[so]),Xt=so(),mo="TooltipProvider",eu=700,Tn="tooltip.open",[tu,Zn]=Vt(mo),go=t=>{const{__scopeTooltip:e,delayDuration:n=eu,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=t,i=u.useRef(!0),a=u.useRef(!1),l=u.useRef(0);return u.useEffect(()=>{const f=l.current;return()=>window.clearTimeout(f)},[]),c.jsx(tu,{scope:e,isOpenDelayedRef:i,delayDuration:n,onOpen:u.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:u.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:u.useCallback(f=>{a.current=f},[]),disableHoverableContent:o,children:s})};go.displayName=mo;var ht="Tooltip",[nu,gt]=Vt(ht),_o=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=t,l=Zn(ht,t.__scopeTooltip),f=Xt(e),[d,h]=u.useState(null),g=St(),p=u.useRef(0),_=i??l.disableHoverableContent,m=a??l.delayDuration,v=u.useRef(!1),[y,E]=cs({prop:r,defaultProp:o??!1,onChange:T=>{T?(l.onOpen(),document.dispatchEvent(new CustomEvent(Tn))):l.onClose(),s?.(T)},caller:ht}),x=u.useMemo(()=>y?v.current?"delayed-open":"instant-open":"closed",[y]),b=u.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v.current=!1,E(!0)},[E]),C=u.useCallback(()=>{window.clearTimeout(p.current),p.current=0,E(!1)},[E]),S=u.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{v.current=!0,E(!0),p.current=0},m)},[m,E]);return u.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),c.jsx(Vl,{...f,children:c.jsx(nu,{scope:e,contentId:g,open:y,stateAttribute:x,trigger:d,onTriggerChange:h,onTriggerEnter:u.useCallback(()=>{l.isOpenDelayedRef.current?S():b()},[l.isOpenDelayedRef,S,b]),onTriggerLeave:u.useCallback(()=>{_?C():(window.clearTimeout(p.current),p.current=0)},[C,_]),onOpen:b,onClose:C,disableHoverableContent:_,children:n})})};_o.displayName=ht;var Sn="TooltipTrigger",xo=u.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,o=gt(Sn,n),s=Zn(Sn,n),i=Xt(n),a=u.useRef(null),l=ye(e,a,o.onTriggerChange),f=u.useRef(!1),d=u.useRef(!1),h=u.useCallback(()=>f.current=!1,[]);return u.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),c.jsx(Xl,{asChild:!0,...i,children:c.jsx(ue.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:le(t.onPointerMove,g=>{g.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:le(t.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:le(t.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:le(t.onFocus,()=>{f.current||o.onOpen()}),onBlur:le(t.onBlur,o.onClose),onClick:le(t.onClick,o.onClose)})})});xo.displayName=Sn;var er="TooltipPortal",[ru,su]=Vt(er,{forceMount:void 0}),vo=t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:o}=t,s=gt(er,e);return c.jsx(ru,{scope:e,forceMount:n,children:c.jsx(tt,{present:n||s.open,children:c.jsx(Mn,{asChild:!0,container:o,children:r})})})};vo.displayName=er;var et="TooltipContent",yo=u.forwardRef((t,e)=>{const n=su(et,t.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=t,i=gt(et,t.__scopeTooltip);return c.jsx(tt,{present:r||i.open,children:i.disableHoverableContent?c.jsx(bo,{side:o,...s,ref:e}):c.jsx(ou,{side:o,...s,ref:e})})}),ou=u.forwardRef((t,e)=>{const n=gt(et,t.__scopeTooltip),r=Zn(et,t.__scopeTooltip),o=u.useRef(null),s=ye(e,o),[i,a]=u.useState(null),{trigger:l,onClose:f}=n,d=o.current,{onPointerInTransitChange:h}=r,g=u.useCallback(()=>{a(null),h(!1)},[h]),p=u.useCallback((_,m)=>{const v=_.currentTarget,y={x:_.clientX,y:_.clientY},E=lu(y,v.getBoundingClientRect()),x=uu(y,E),b=fu(m.getBoundingClientRect()),C=hu([...x,...b]);a(C),h(!0)},[h]);return u.useEffect(()=>()=>g(),[g]),u.useEffect(()=>{if(l&&d){const _=v=>p(v,d),m=v=>p(v,l);return l.addEventListener("pointerleave",_),d.addEventListener("pointerleave",m),()=>{l.removeEventListener("pointerleave",_),d.removeEventListener("pointerleave",m)}}},[l,d,p,g]),u.useEffect(()=>{if(i){const _=m=>{const v=m.target,y={x:m.clientX,y:m.clientY},E=l?.contains(v)||d?.contains(v),x=!du(y,i);E?g():x&&(g(),f())};return document.addEventListener("pointermove",_),()=>document.removeEventListener("pointermove",_)}},[l,d,i,f,g]),c.jsx(bo,{...t,ref:s})}),[iu,au]=Vt(ht,{isInside:!1}),cu=na("TooltipContent"),bo=u.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=t,l=gt(et,n),f=Xt(n),{onClose:d}=l;return u.useEffect(()=>(document.addEventListener(Tn,d),()=>document.removeEventListener(Tn,d)),[d]),u.useEffect(()=>{if(l.trigger){const h=g=>{g.target?.contains(l.trigger)&&d()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[l.trigger,d]),c.jsx(jn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:c.jsxs(Yl,{"data-state":l.stateAttribute,...f,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[c.jsx(cu,{children:r}),c.jsx(iu,{scope:n,isInside:!0,children:c.jsx(Zl,{id:l.contentId,role:"tooltip",children:o||r})})]})})});yo.displayName=et;var wo="TooltipArrow",Eo=u.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,o=Xt(n);return au(wo,n).isInside?null:c.jsx(Kl,{...o,...r,ref:e})});Eo.displayName=wo;function lu(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),o=Math.abs(e.right-t.x),s=Math.abs(e.left-t.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function uu(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function fu(t){const{top:e,right:n,bottom:r,left:o}=t;return[{x:o,y:e},{x:n,y:e},{x:n,y:r},{x:o,y:r}]}function du(t,e){const{x:n,y:r}=t;let o=!1;for(let s=0,i=e.length-1;s<e.length;i=s++){const a=e[s],l=e[i],f=a.x,d=a.y,h=l.x,g=l.y;d>r!=g>r&&n<(h-f)*(r-d)/(g-d)+f&&(o=!o)}return o}function hu(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),pu(e)}function pu(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const o=t[r];for(;e.length>=2;){const s=e[e.length-1],i=e[e.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))e.pop();else break}e.push(o)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const o=t[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var mu=go,gu=_o,_u=xo,xu=vo,vu=yo,yu=Eo;function bu({delayDuration:t=0,...e}){return c.jsx(mu,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function wu({...t}){return c.jsx(bu,{children:c.jsx(gu,{"data-slot":"tooltip",...t})})}function Eu({...t}){return c.jsx(_u,{"data-slot":"tooltip-trigger",...t})}function Cu({className:t,sideOffset:e=0,children:n,...r}){return c.jsx(xu,{children:c.jsxs(vu,{"data-slot":"tooltip-content",sideOffset:e,className:ce("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...r,children:[n,c.jsx(yu,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const Je=u.forwardRef(({className:t,type:e,...n},r)=>c.jsx("input",{type:e,className:ce("flex h-10 w-full rounded-full border border-slate-200 bg-white px-3 py-2 text-sm ring-offset-white file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#1d9bf0] focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-800 dark:bg-slate-950 dark:text-slate-100 dark:ring-offset-slate-950 dark:placeholder:text-slate-400 dark:focus-visible:ring-[#1d9bf0]",t),ref:r,...n}));Je.displayName="Input";var Tu="Label",Co=u.forwardRef((t,e)=>c.jsx(Xo.label,{...t,ref:e,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(t.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Co.displayName=Tu;var To=Co;const He=u.forwardRef(({className:t,...e},n)=>c.jsx(To,{ref:n,className:ce("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 text-slate-900 dark:text-slate-100",t),...e}));He.displayName=To.displayName;const Su=()=>{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 Ru({devices:t,currentDeviceId:e,onSelectDevice:n,onOpenConfig:r,onConnectWifi:o,onDisconnectWifi:s}){const i=Ut(),[a,l]=u.useState(Su),[f,d]=u.useState(!1),[h,g]=u.useState(""),[p,_]=u.useState("5555"),[m,v]=u.useState(""),[y,E]=u.useState(""),[x,b]=u.useState(!1);u.useEffect(()=>{localStorage.setItem("sidebar-collapsed",JSON.stringify(a))},[a]),u.useEffect(()=>{const w=N=>{(N.metaKey||N.ctrlKey)&&N.key==="b"&&(N.preventDefault(),l(!a))};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[a]);const C=()=>{l(!a)},S=w=>/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/.test(w)?w.split(".").every(I=>{const F=parseInt(I,10);return F>=0&&F<=255}):!1,T=w=>{const N=parseInt(w,10);return!isNaN(N)&&N>=1&&N<=65535},P=async()=>{v(""),E("");let w=!1;if(S(h)||(v(i.deviceSidebar.invalidIpError),w=!0),T(p)||(E(i.deviceSidebar.invalidPortError),w=!0),!w){b(!0);try{const N=await Yo({ip:h,port:parseInt(p,10)});N.success?(d(!1),g(""),_("5555")):v(N.message||i.toasts.wifiManualConnectError)}catch{v(i.toasts.wifiManualConnectError)}finally{b(!1)}}};return c.jsxs(c.Fragment,{children:[a&&c.jsx(oe,{variant:"outline",size:"icon",onClick:C,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:c.jsx(os,{className:"h-4 w-4"})}),c.jsxs("div",{className:`
50
+ ${a?"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:[c.jsxs("div",{className:"flex items-center justify-between p-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:c.jsx(as,{className:"h-5 w-5 text-[#1d9bf0]"})}),c.jsxs("div",{children:[c.jsx("h2",{className:"text-base font-bold text-slate-900 dark:text-slate-100",children:"AutoGLM"}),c.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[t.length," ",(t.length===1,i.deviceSidebar.devices)]})]})]}),c.jsx(oe,{variant:"ghost",size:"icon",onClick:C,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:c.jsx(ss,{className:"h-4 w-4"})})]}),c.jsx(ar,{className:"mx-4"}),c.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-2 min-h-0",children:t.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800",children:c.jsx(Ri,{className:"h-8 w-8 text-slate-400"})}),c.jsx("p",{className:"mt-4 font-medium text-slate-900 dark:text-slate-100",children:i.deviceSidebar.noDevicesConnected}),c.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:i.deviceSidebar.clickToRefresh})]}):t.map(w=>c.jsx(Vi,{id:w.id,model:w.model,status:w.status,connectionType:w.connection_type,isInitialized:w.is_initialized,isActive:e===w.id,onClick:()=>n(w.id),onConnectWifi:async()=>{await o(w.id)},onDisconnectWifi:async()=>{await s(w.id)}},w.id))}),c.jsx(ar,{className:"mx-4"}),c.jsxs("div",{className:"p-3 space-y-2",children:[c.jsxs(oe,{variant:"outline",onClick:()=>d(!0),className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[c.jsx(Ni,{className:"h-4 w-4"}),c.jsx("span",{className:"flex-1 text-left",children:i.deviceSidebar.addDevice}),c.jsxs(wu,{children:[c.jsx(Eu,{asChild:!0,children:c.jsx("div",{children:c.jsx(wi,{className:"h-3.5 w-3.5 text-slate-400 flex-shrink-0"})})}),c.jsx(Cu,{side:"right",align:"center",sideOffset:5,className:"max-w-xs",children:c.jsx("p",{children:i.deviceSidebar.addDeviceTooltip})})]})]}),c.jsxs(oe,{variant:"outline",onClick:r,className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[c.jsx(is,{className:"h-4 w-4"}),i.deviceSidebar.settings]})]}),c.jsx($s,{open:f,onOpenChange:d,children:c.jsxs(Un,{className:"sm:max-w-md",children:[c.jsxs(Wn,{children:[c.jsx($n,{children:i.deviceSidebar.manualConnectTitle}),c.jsx(Gn,{children:i.deviceSidebar.manualConnectDescription})]}),c.jsxs("div",{className:"space-y-4 py-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(He,{htmlFor:"ip",children:i.deviceSidebar.ipAddress}),c.jsx(Je,{id:"ip",placeholder:"192.168.1.100",value:h,onChange:w=>g(w.target.value),onKeyDown:w=>w.key==="Enter"&&P(),className:m?"border-red-500":""}),m&&c.jsx("p",{className:"text-sm text-red-500",children:m})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(He,{htmlFor:"port",children:i.deviceSidebar.port}),c.jsx(Je,{id:"port",type:"number",value:p,onChange:w=>_(w.target.value),onKeyDown:w=>w.key==="Enter"&&P(),className:y?"border-red-500":""}),y&&c.jsx("p",{className:"text-sm text-red-500",children:y})]})]}),c.jsxs(Hn,{children:[c.jsx(oe,{variant:"outline",onClick:()=>{d(!1),v(""),E("")},children:i.common.cancel}),c.jsx(oe,{onClick:P,disabled:x,children:x?i.common.loading:i.common.confirm})]})]})})]})]})}const ke=Object.create(null);ke.open="0";ke.close="1";ke.ping="2";ke.pong="3";ke.message="4";ke.upgrade="5";ke.noop="6";const Pt=Object.create(null);Object.keys(ke).forEach(t=>{Pt[ke[t]]=t});const Rn={type:"error",data:"parser error"},So=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Ro=typeof ArrayBuffer=="function",ko=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,tr=({type:t,data:e},n,r)=>So&&e instanceof Blob?n?r(e):jr(e,r):Ro&&(e instanceof ArrayBuffer||ko(e))?n?r(e):jr(new Blob([e]),r):r(ke[t]+(e||"")),jr=(t,e)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];e("b"+(r||""))},n.readAsDataURL(t)};function Mr(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let ln;function ku(t,e){if(So&&t.data instanceof Blob)return t.data.arrayBuffer().then(Mr).then(e);if(Ro&&(t.data instanceof ArrayBuffer||ko(t.data)))return e(Mr(t.data));tr(t,!1,n=>{ln||(ln=new TextEncoder),e(ln.encode(n))})}const Br="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ct=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<Br.length;t++)ct[Br.charCodeAt(t)]=t;const Nu=t=>{let e=t.length*.75,n=t.length,r,o=0,s,i,a,l;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const f=new ArrayBuffer(e),d=new Uint8Array(f);for(r=0;r<n;r+=4)s=ct[t.charCodeAt(r)],i=ct[t.charCodeAt(r+1)],a=ct[t.charCodeAt(r+2)],l=ct[t.charCodeAt(r+3)],d[o++]=s<<2|i>>4,d[o++]=(i&15)<<4|a>>2,d[o++]=(a&3)<<6|l&63;return f},Pu=typeof ArrayBuffer=="function",nr=(t,e)=>{if(typeof t!="string")return{type:"message",data:No(t,e)};const n=t.charAt(0);return n==="b"?{type:"message",data:Au(t.substring(1),e)}:Pt[n]?t.length>1?{type:Pt[n],data:t.substring(1)}:{type:Pt[n]}:Rn},Au=(t,e)=>{if(Pu){const n=Nu(t);return No(n,e)}else return{base64:!0,data:t}},No=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},Po="",Du=(t,e)=>{const n=t.length,r=new Array(n);let o=0;t.forEach((s,i)=>{tr(s,!1,a=>{r[i]=a,++o===n&&e(r.join(Po))})})},Ou=(t,e)=>{const n=t.split(Po),r=[];for(let o=0;o<n.length;o++){const s=nr(n[o],e);if(r.push(s),s.type==="error")break}return r};function Lu(){return new TransformStream({transform(t,e){ku(t,n=>{const r=n.length;let o;if(r<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,r);else if(r<65536){o=new Uint8Array(3);const s=new DataView(o.buffer);s.setUint8(0,126),s.setUint16(1,r)}else{o=new Uint8Array(9);const s=new DataView(o.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(o[0]|=128),e.enqueue(o),e.enqueue(n)})}})}let un;function Et(t){return t.reduce((e,n)=>e+n.length,0)}function Ct(t,e){if(t[0].length===e)return t.shift();const n=new Uint8Array(e);let r=0;for(let o=0;o<e;o++)n[o]=t[0][r++],r===t[0].length&&(t.shift(),r=0);return t.length&&r<t[0].length&&(t[0]=t[0].slice(r)),n}function ju(t,e){un||(un=new TextDecoder);const n=[];let r=0,o=-1,s=!1;return new TransformStream({transform(i,a){for(n.push(i);;){if(r===0){if(Et(n)<1)break;const l=Ct(n,1);s=(l[0]&128)===128,o=l[0]&127,o<126?r=3:o===126?r=1:r=2}else if(r===1){if(Et(n)<2)break;const l=Ct(n,2);o=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(Et(n)<8)break;const l=Ct(n,8),f=new DataView(l.buffer,l.byteOffset,l.length),d=f.getUint32(0);if(d>Math.pow(2,21)-1){a.enqueue(Rn);break}o=d*Math.pow(2,32)+f.getUint32(4),r=3}else{if(Et(n)<o)break;const l=Ct(n,o);a.enqueue(nr(s?l:un.decode(l),e)),r=0}if(o===0||o>t){a.enqueue(Rn);break}}}})}const Ao=4;function re(t){if(t)return Mu(t)}function Mu(t){for(var e in re.prototype)t[e]=re.prototype[e];return t}re.prototype.on=re.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};re.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this};re.prototype.off=re.prototype.removeListener=re.prototype.removeAllListeners=re.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var r,o=0;o<n.length;o++)if(r=n[o],r===e||r.fn===e){n.splice(o,1);break}return n.length===0&&delete this._callbacks["$"+t],this};re.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,o=n.length;r<o;++r)n[r].apply(this,e)}return this};re.prototype.emitReserved=re.prototype.emit;re.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};re.prototype.hasListeners=function(t){return!!this.listeners(t).length};const Yt=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,n)=>n(e,0),me=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Bu="arraybuffer";function Do(t,...e){return e.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const Iu=me.setTimeout,Fu=me.clearTimeout;function Kt(t,e){e.useNativeTimers?(t.setTimeoutFn=Iu.bind(me),t.clearTimeoutFn=Fu.bind(me)):(t.setTimeoutFn=me.setTimeout.bind(me),t.clearTimeoutFn=me.clearTimeout.bind(me))}const Uu=1.33;function Wu(t){return typeof t=="string"?Hu(t):Math.ceil((t.byteLength||t.size)*Uu)}function Hu(t){let e=0,n=0;for(let r=0,o=t.length;r<o;r++)e=t.charCodeAt(r),e<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(r++,n+=4);return n}function Oo(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function $u(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function Gu(t){let e={},n=t.split("&");for(let r=0,o=n.length;r<o;r++){let s=n[r].split("=");e[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return e}class qu extends Error{constructor(e,n,r){super(e),this.description=n,this.context=r,this.type="TransportError"}}class rr extends re{constructor(e){super(),this.writable=!1,Kt(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,n,r){return super.emitReserved("error",new qu(e,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const n=nr(e,this.socket.binaryType);this.onPacket(n)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,n={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const n=$u(e);return n.length?"?"+n:""}}class zu extends rr{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const n=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};Ou(e,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,Du(e,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=Oo()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(e,n)}}let Lo=!1;try{Lo=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Vu=Lo;function Xu(){}class Yu extends zu{constructor(e){if(super(e),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||r!==e.port}}doWrite(e,n){const r=this.request({method:"POST",data:e});r.on("success",n),r.on("error",(o,s)=>{this.onError("xhr post error",o,s)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=e}}class Se extends re{constructor(e,n,r){super(),this.createRequest=e,Kt(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var e;const n=Do(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&r.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var o;r.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=Se.requestsCount++,Se.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=Xu,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Se.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()}}Se.requestsCount=0;Se.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Ir);else if(typeof addEventListener=="function"){const t="onpagehide"in me?"pagehide":"unload";addEventListener(t,Ir,!1)}}function Ir(){for(let t in Se.requests)Se.requests.hasOwnProperty(t)&&Se.requests[t].abort()}const Ku=(function(){const t=jo({xdomain:!1});return t&&t.responseType!==null})();class Ju extends Yu{constructor(e){super(e);const n=e&&e.forceBase64;this.supportsBinary=Ku&&!n}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Se(jo,this.uri(),e)}}function jo(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||Vu))return new XMLHttpRequest}catch{}if(!e)try{return new me[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Mo=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Qu extends rr{get name(){return"websocket"}doOpen(){const e=this.uri(),n=this.opts.protocols,r=Mo?{}:Do(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,n,r)}catch(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 n=0;n<e.length;n++){const r=e[n],o=n===e.length-1;tr(r,this.supportsBinary,s=>{try{this.doWrite(r,s)}catch{}o&&Yt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=Oo()),this.supportsBinary||(n.b64=1),this.createUri(e,n)}}const fn=me.WebSocket||me.MozWebSocket;class Zu extends Qu{createSocket(e,n,r){return Mo?new fn(e,n,r):n?new fn(e,n):new fn(e)}doWrite(e,n){this.ws.send(n)}}class ef extends rr{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const n=ju(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(n).getReader(),o=Lu();o.readable.pipeTo(e.writable),this._writer=o.writable.getWriter();const s=()=>{r.read().then(({done:a,value:l})=>{a||(this.onPacket(l),s())}).catch(a=>{})};s();const i={type:"open"};this.query.sid&&(i.data=`{"sid":"${this.query.sid}"}`),this._writer.write(i).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],o=n===e.length-1;this._writer.write(r).then(()=>{o&&Yt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const tf={websocket:Zu,webtransport:ef,polling:Ju},nf=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,rf=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function kn(t){if(t.length>8e3)throw"URI too long";const e=t,n=t.indexOf("["),r=t.indexOf("]");n!=-1&&r!=-1&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));let o=nf.exec(t||""),s={},i=14;for(;i--;)s[rf[i]]=o[i]||"";return n!=-1&&r!=-1&&(s.source=e,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=sf(s,s.path),s.queryKey=of(s,s.query),s}function sf(t,e){const n=/\/{2,9}/g,r=e.replace(n,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function of(t,e){const n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,o,s){o&&(n[o]=s)}),n}const Nn=typeof addEventListener=="function"&&typeof removeEventListener=="function",At=[];Nn&&addEventListener("offline",()=>{At.forEach(t=>t())},!1);class Be extends re{constructor(e,n){if(super(),this.binaryType=Bu,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(n=e,e=null),e){const r=kn(e);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=kn(n.host).host);Kt(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const o=r.prototype.name;this.transports.push(o),this._transportsByName[o]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Gu(this.opts.query)),Nn&&(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"})},At.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const n=Object.assign({},this.opts.query);n.EIO=Ao,n.transport=e,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&Be.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(e);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",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 n=new Error("server error");n.code=e.data,this._onError(n);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const o=this.writeBuffer[r].data;if(o&&(n+=Wu(o)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,Yt(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,n,r){return this._sendPacket("message",e,n,r),this}send(e,n,r){return this._sendPacket("message",e,n,r),this}_sendPacket(e,n,r,o){if(typeof n=="function"&&(o=n,n=void 0),typeof r=="function"&&(o=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const s={type:e,data:n,options:r};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),o&&this.once("flush",o),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),e()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}_onError(e){if(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,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Nn&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=At.indexOf(this._offlineEventListener);r!==-1&&At.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,n),this.writeBuffer=[],this._prevBufferLen=0}}}Be.protocol=Ao;class af 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 n=this.createTransport(e),r=!1;Be.priorWebsocketSuccess=!1;const o=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",h=>{if(!r)if(h.type==="pong"&&h.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Be.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(d(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const g=new Error("probe error");g.transport=n.name,this.emitReserved("upgradeError",g)}}))};function s(){r||(r=!0,d(),n.close(),n=null)}const i=h=>{const g=new Error("probe error: "+h);g.transport=n.name,s(),this.emitReserved("upgradeError",g)};function a(){i("transport closed")}function l(){i("socket closed")}function f(h){n&&h.name!==n.name&&s()}const d=()=>{n.removeListener("open",o),n.removeListener("error",i),n.removeListener("close",a),this.off("close",l),this.off("upgrading",f)};n.once("open",o),n.once("error",i),n.once("close",a),this.once("close",l),this.once("upgrading",f),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const n=[];for(let r=0;r<e.length;r++)~this.transports.indexOf(e[r])&&n.push(e[r]);return n}}let cf=class extends af{constructor(e,n={}){const r=typeof e=="object"?e:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(o=>tf[o]).filter(o=>!!o)),super(e,r)}};function lf(t,e="",n){let r=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),r=kn(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const s=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+s+":"+r.port+e,r.href=r.protocol+"://"+s+(n&&n.port===r.port?"":":"+r.port),r}const uf=typeof ArrayBuffer=="function",ff=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,Bo=Object.prototype.toString,df=typeof Blob=="function"||typeof Blob<"u"&&Bo.call(Blob)==="[object BlobConstructor]",hf=typeof File=="function"||typeof File<"u"&&Bo.call(File)==="[object FileConstructor]";function sr(t){return uf&&(t instanceof ArrayBuffer||ff(t))||df&&t instanceof Blob||hf&&t instanceof File}function Dt(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(Dt(t[n]))return!0;return!1}if(sr(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return Dt(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&Dt(t[n]))return!0;return!1}function pf(t){const e=[],n=t.data,r=t;return r.data=Pn(n,e),r.attachments=e.length,{packet:r,buffers:e}}function Pn(t,e){if(!t)return t;if(sr(t)){const n={_placeholder:!0,num:e.length};return e.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let r=0;r<t.length;r++)n[r]=Pn(t[r],e);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=Pn(t[r],e));return n}return t}function mf(t,e){return t.data=An(t.data,e),delete t.attachments,t}function An(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=An(t[n],e);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=An(t[n],e));return t}const gf=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],_f=5;var z;(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"})(z||(z={}));class xf{constructor(e){this.replacer=e}encode(e){return(e.type===z.EVENT||e.type===z.ACK)&&Dt(e)?this.encodeAsBinary({type:e.type===z.EVENT?z.BINARY_EVENT:z.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let n=""+e.type;return(e.type===z.BINARY_EVENT||e.type===z.BINARY_ACK)&&(n+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(n+=e.nsp+","),e.id!=null&&(n+=e.id),e.data!=null&&(n+=JSON.stringify(e.data,this.replacer)),n}encodeAsBinary(e){const n=pf(e),r=this.encodeAsString(n.packet),o=n.buffers;return o.unshift(r),o}}function Fr(t){return Object.prototype.toString.call(t)==="[object Object]"}class or extends re{constructor(e){super(),this.reviver=e}add(e){let n;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(e);const r=n.type===z.BINARY_EVENT;r||n.type===z.BINARY_ACK?(n.type=r?z.EVENT:z.ACK,this.reconstructor=new vf(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(sr(e)||e.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(e),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let n=0;const r={type:Number(e.charAt(0))};if(z[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===z.BINARY_EVENT||r.type===z.BINARY_ACK){const s=n+1;for(;e.charAt(++n)!=="-"&&n!=e.length;);const i=e.substring(s,n);if(i!=Number(i)||e.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(i)}if(e.charAt(n+1)==="/"){const s=n+1;for(;++n&&!(e.charAt(n)===","||n===e.length););r.nsp=e.substring(s,n)}else r.nsp="/";const o=e.charAt(n+1);if(o!==""&&Number(o)==o){const s=n+1;for(;++n;){const i=e.charAt(n);if(i==null||Number(i)!=i){--n;break}if(n===e.length)break}r.id=Number(e.substring(s,n+1))}if(e.charAt(++n)){const s=this.tryParse(e.substr(n));if(or.isPayloadValid(r.type,s))r.data=s;else throw new Error("invalid payload")}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,n){switch(e){case z.CONNECT:return Fr(n);case z.DISCONNECT:return n===void 0;case z.CONNECT_ERROR:return typeof n=="string"||Fr(n);case z.EVENT:case z.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&gf.indexOf(n[0])===-1);case z.ACK:case z.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class vf{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const n=mf(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const yf=Object.freeze(Object.defineProperty({__proto__:null,Decoder:or,Encoder:xf,get PacketType(){return z},protocol:_f},Symbol.toStringTag,{value:"Module"}));function _e(t,e,n){return t.on(e,n),function(){t.off(e,n)}}const bf=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Io extends re{constructor(e,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[_e(e,"open",this.onopen.bind(this)),_e(e,"packet",this.onpacket.bind(this)),_e(e,"error",this.onerror.bind(this)),_e(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...n){var r,o,s;if(bf.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const i={type:z.EVENT,data:n};if(i.options={},i.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const d=this.ids++,h=n.pop();this._registerAckCallback(d,h),i.id=d}const a=(o=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||o===void 0?void 0:o.writable,l=this.connected&&!(!((s=this.io.engine)===null||s===void 0)&&s._hasPingExpired());return this.flags.volatile&&!a||(l?(this.notifyOutgoingListeners(i),this.packet(i)):this.sendBuffer.push(i)),this.flags={},this}_registerAckCallback(e,n){var r;const o=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(o===void 0){this.acks[e]=n;return}const s=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===e&&this.sendBuffer.splice(a,1);n.call(this,new Error("operation has timed out"))},o),i=(...a)=>{this.io.clearTimeoutFn(s),n.apply(this,a)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...n){return new Promise((r,o)=>{const s=(i,a)=>i?o(i):r(a);s.withError=!0,n.push(s),this.emit(e,...n)})}_addToQueue(e){let n;typeof e[e.length-1]=="function"&&(n=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((o,...s)=>r!==this._queue[0]?void 0:(o!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(o)):(this._queue.shift(),n&&n(null,...s)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!e||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:z.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(r=>String(r.id)===e)){const r=this.acks[e];delete this.acks[e],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case z.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 z.EVENT:case z.BINARY_EVENT:this.onevent(e);break;case z.ACK:case z.BINARY_ACK:this.onack(e);break;case z.DISCONNECT:this.ondisconnect();break;case z.CONNECT_ERROR:this.destroy();const r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){const n=e.data||[];e.id!=null&&n.push(this.ack(e.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const n=this;let r=!1;return function(...o){r||(r=!0,n.packet({type:z.ACK,id:e,data:o}))}}onack(e){const n=this.acks[e.id];typeof n=="function"&&(delete this.acks[e.id],n.withError&&e.data.unshift(null),n.apply(this,e.data))}onconnect(e,n){this.id=e,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:z.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,e.data)}}}function st(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}st.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-n:t+n}return Math.min(t,this.max)|0};st.prototype.reset=function(){this.attempts=0};st.prototype.setMin=function(t){this.ms=t};st.prototype.setMax=function(t){this.max=t};st.prototype.setJitter=function(t){this.jitter=t};class Dn extends re{constructor(e,n){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(n=e,e=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Kt(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new st({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=e;const o=n.parser||yf;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var n;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(n=this.backoff)===null||n===void 0||n.setMin(e),this)}randomizationFactor(e){var n;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(n=this.backoff)===null||n===void 0||n.setJitter(e),this)}reconnectionDelayMax(e){var n;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(n=this.backoff)===null||n===void 0||n.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new cf(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const o=_e(n,"open",function(){r.onopen(),e&&e()}),s=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},i=_e(n,"error",s);if(this._timeout!==!1){const a=this._timeout,l=this.setTimeoutFn(()=>{o(),s(new Error("timeout")),n.close()},a);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(o),this.subs.push(i),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(_e(e,"ping",this.onping.bind(this)),_e(e,"data",this.ondata.bind(this)),_e(e,"error",this.onerror.bind(this)),_e(e,"close",this.onclose.bind(this)),_e(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(n){this.onclose("parse error",n)}}ondecoded(e){Yt(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,n){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new Io(this,e,n),this.nsps[e]=r),r}_destroy(e){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(e){const n=this.encoder.encode(e);for(let r=0;r<n.length;r++)this.engine.write(n[r],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(o=>{o?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",o)):e.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const ot={};function Ot(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const n=lf(t,e.path||"/socket.io"),r=n.source,o=n.id,s=n.path,i=ot[o]&&s in ot[o].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||i;let l;return a?l=new Dn(r,e):(ot[o]||(ot[o]=new Dn(r,e)),l=ot[o]),n.query&&!e.query&&(e.query=n.queryKey),l.socket(n.path,e)}Object.assign(Ot,{Manager:Dn,Socket:Io,io:Ot,connect:Ot});function wf(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}const Lt={H264:1748121140,H265:1748121141,AV1:6387249},{WritableStream:Ef}=globalThis;class Cf{#e;#t;#n=0;#r=7;get byteAligned(){return this.#r===7}get ended(){return this.#n>=this.#e.length}constructor(e){this.#e=e,this.#t=e[0]}f1(){const e=this.#t>>this.#r;return this.#r-=1,this.#r<0&&(this.#n+=1,this.#r=7,this.#t=this.#e[this.#n]),e&1}f(e){let n=0;for(;e>0;e-=1)n<<=1,n|=this.f1();return n}skip(e){if(e<=this.#r+1){this.#n+=1,this.#r=7,this.#t=this.#e[this.#n];return}e-=this.#r+1,this.#n+=1;const n=e/8|0;n>0&&(this.#n+=n,e-=n*8),this.#r=7-e,this.#t=this.#e[this.#n]}readBytes(e){if(!this.byteAligned)throw new Error("Bytes must be byte-aligned");const n=this.#e.subarray(this.#n,this.#n+e);return this.#n+=e,this.#t=this.#e[this.#n],n}getPosition(){return[this.#n,this.#r]}setPosition([e,n]){this.#n=e,this.#r=n,this.#t=this.#e[e]}}const Tf={SequenceHeader:1,TemporalDelimiter:2,FrameHeader:3,TileGroup:4,Metadata:5,Frame:6,RedundantFrameHeader:7,TileList:8,Padding:15},Sf={Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,GenericFilm:8,Bt2020:9,Xyz:10,Smpte431:11,Smpte432:12,Ebu3213:22},Rf={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},kf={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 ae extends Cf{static ObuType=Tf;static ColorPrimaries=Sf;static TransferCharacteristics=Rf;static MatrixCoefficients=kf;#e=0;uvlc(){let e=0;for(;!this.f1();)e+=1;return e>=32?2**32-1:this.f(e)+(1<<e>>>0)-1}leb128(){if(!this.byteAligned)throw new Error("LEB128 must be byte-aligned");let e=0n;this.#e=0;for(let n=0n;n<8n;n+=1n){const r=this.f(8);if(e|=BigInt(r&127)<<7n*n,this.#e+=1,(r&128)==0)break}return e}*annexBBitstream(){for(;!this.ended;){const e=this.leb128();yield*this.temporalUnit(e)}}*temporalUnit(e){for(;e>0;){const n=this.leb128();e-=BigInt(this.#e),yield*this.frameUnit(n),e-=n}}*frameUnit(e){for(;e>0;){const n=this.leb128();e-=BigInt(this.#e);const r=this.openBitstreamUnit(n);r&&(yield r),e-=n}}#t=0;openBitstreamUnit(e){const n=this.obuHeader();let r;if(n.obu_has_size_field)r=this.leb128();else if(e!==void 0)r=e-1n-(n.obu_extension_flag?1n:0n);else throw new Error("obu_has_size_field must be true");const o=this.getPosition();if(n.obu_type!==ae.ObuType.SequenceHeader&&n.obu_type!==ae.ObuType.TemporalDelimiter&&this.#t!==0&&n.obu_extension_header){const l=!!(this.#t&1<<n.obu_extension_header.temporal_id),f=!!(this.#t&1<<n.obu_extension_header.spatial_id+8);if(!l||!f){this.skip(Number(r));return}}let s;switch(n.obu_type){case ae.ObuType.SequenceHeader:s=this.sequenceHeaderObu();break}const i=this.getPosition(),a=(i[0]-o[0])*8+(o[1]-i[1]);return r>0&&this.skip(Number(r)*8-a),{obu_header:n,obu_size:r,sequence_header_obu:s}}obuHeader(){if(!!this.f1())throw new Error("Invalid data");const n=this.f(4),r=!!this.f1(),o=!!this.f1();this.f1();let s;return r&&(s=this.obuExtensionHeader()),{obu_type:n,obu_extension_flag:r,obu_has_size_field:o,obu_extension_header:s}}obuExtensionHeader(){const e=this.f(3),n=this.f(2);return this.skip(3),{temporal_id:e,spatial_id:n}}static SelectScreenContentTools=2;static SelectIntegerMv=2;sequenceHeaderObu(){const e=this.f(3),n=!!this.f1(),r=!!this.f1();let o=!1,s,i=!1,a,l=!1,f=0;const d=[],h=[],g=[],p=[],_=[];let m,v;if(r)d[0]=0,h[0]=this.f(5),g[0]=0,p[0]=!1,_[0]=!1;else{o=!!this.f1(),o&&(s=this.timingInfo(),i=!!this.f1(),i&&(a=this.decoderModelInfo(),m=[])),l=!!this.f1(),l&&(v=[]),f=this.f(5);for(let K=0;K<=f;K+=1)d[K]=this.f(12),h[K]=this.f(5),h[K]>7?g[K]=this.f1():g[K]=0,i?(p[K]=!!this.f1(),p[K]&&(m[K]=this.operatingParametersInfo(a))):p[K]=!1,l&&(_[K]=!!this.f1(),_[K]&&(v[K]=this.f(4)))}const y=this.chooseOperatingPoint();this.#t=d[y];const E=this.f(4),x=this.f(4),b=this.f(E+1),C=this.f(x+1);let S=!1,T,P;r||(S=!!this.f1(),S&&(T=this.f(4),P=this.f(3)));const w=!!this.f1(),N=!!this.f1(),R=!!this.f1();let I=!1,F=!1,k=!1,A=!1,D=!1,M=!1,L=!1,U=!1,G=ae.SelectScreenContentTools,q=!1,Y=ae.SelectIntegerMv,Z;r||(I=!!this.f1(),F=!!this.f1(),k=!!this.f1(),A=!!this.f1(),D=!!this.f1(),D&&(M=!!this.f1(),L=!!this.f1()),U=!!this.f1(),U||(G=this.f1()),G>0&&(q=!!this.f1(),q||(Y=this.f1())),D&&(Z=this.f(3)));const ee=!!this.f1(),se=!!this.f1(),he=!!this.f1(),te=this.colorConfig(e),ie=!!this.f1();return{seq_profile:e,still_picture:n,reduced_still_picture_header:r,timing_info_present_flag:o,timing_info:s,decoder_model_info_present_flag:i,decoder_model_info:a,initial_display_delay_present_flag:l,initial_display_delay_minus_1:v,operating_points_cnt_minus_1:f,operating_point_idc:d,seq_level_idx:h,seq_tier:g,decoder_model_present_for_this_op:p,operating_parameters_info:m,initial_display_delay_present_for_this_op:_,frame_width_bits_minus_1:E,frame_height_bits_minus_1:x,max_frame_width_minus_1:b,max_frame_height_minus_1:C,frame_id_numbers_present_flag:S,delta_frame_id_length_minus_2:T,additional_frame_id_length_minus_1:P,use_128x128_superblock:w,enable_filter_intra:N,enable_intra_edge_filter:R,enable_interintra_compound:I,enable_masked_compound:F,enable_warped_motion:k,enable_dual_filter:A,enable_order_hint:D,enable_jnt_comp:M,enable_ref_frame_mvs:L,seq_choose_screen_content_tools:U,seq_force_screen_content_tools:G,seq_choose_integer_mv:q,seq_force_integer_mv:Y,order_hint_bits_minus_1:Z,enable_superres:ee,enable_cdef:se,enable_restoration:he,color_config:te,film_grain_params_present:ie}}searchSequenceHeaderObu(){for(;!this.ended;){const e=this.openBitstreamUnit();if(e&&e.sequence_header_obu)return e.sequence_header_obu}}timingInfo(){const e=this.f(32),n=this.f(32),r=!!this.f1();let o;return r&&(o=this.uvlc()),{num_units_in_display_tick:e,time_scale:n,equal_picture_interval:r,num_ticks_per_picture_minus_1:o}}decoderModelInfo(){const e=this.f(5),n=this.f(32),r=this.f(5),o=this.f(5);return{buffer_delay_length_minus_1:e,num_units_in_decoding_tick:n,buffer_removal_time_length_minus_1:r,frame_presentation_time_length_minus_1:o}}operatingParametersInfo(e){const n=e.buffer_delay_length_minus_1+1,r=this.f(n),o=this.f(n),s=!!this.f1();return{decoder_buffer_delay:r,encoder_buffer_delay:o,low_delay_mode_flag:s}}chooseOperatingPoint(){return 0}colorConfig(e){const n=!!this.f1();let r=!1,o=8;e===2&&n?(r=!!this.f1(),o=r?12:10):e<=2&&(o=n?10:8);let s=!1;e===1&&(s=!!this.f1());const i=!!this.f1();let a=ae.ColorPrimaries.Unspecified,l=ae.TransferCharacteristics.Unspecified,f=ae.MatrixCoefficients.Unspecified;i&&(a=this.f(8),l=this.f(8),f=this.f(8));let d=!1,h,g,p=0,_=!1;if(s)d=!!this.f1(),h=!0,g=!0;else{if(a===ae.ColorPrimaries.Bt709&&l===ae.TransferCharacteristics.Srgb&&f===ae.MatrixCoefficients.Identity)d=!0,h=!1,g=!1;else{switch(d=!!this.f1(),e){case 0:h=!0,g=!0;break;case 1:h=!1,g=!1;break;default:o==12?(h=!!this.f1(),h?g=!!this.f1():g=!1):(h=!0,g=!1);break}h&&g&&(p=this.f(2))}_=!!this.f1()}return{high_bitdepth:n,twelve_bit:r,BitDepth:o,mono_chrome:s,color_description_present_flag:i,color_primaries:a,transfer_characteristics:l,matrix_coefficients:f,color_range:d,subsampling_x:h,subsampling_y:g,chroma_sample_position:p,separate_uv_delta_q:_}}}function*Fo(t){let e=-1,n=0,r=!1;for(let o=0;o<t.length;o+=1){const s=t[o];if(r){if(s>3)throw new Error("Invalid data");r=!1;continue}if(s===0){n+=1;continue}const i=n;if(n=0,e===-1){if(i>=2&&s===1){e=o+1;continue}throw new Error("Invalid data")}if(!(i<2)){if(s===1){yield t.subarray(e,o-i),e=o+1;continue}if(i>2)throw new Error("Invalid data");switch(s){case 2:throw new Error("Invalid data");case 3:r=!0;break}}}if(r)throw new Error("Invalid data");yield t.subarray(e,t.length)}class Jt{#e;#t;#n;#r=0;#o=0;#s=7;#i=0;get byteLength(){return this.#t}get stopBitIndex(){return this.#n}get bytePosition(){return this.#o}get bitPosition(){return this.#s}get ended(){return this.#o>=this.#t&&this.#s<=this.#n}constructor(e){this.#e=e;for(let n=e.length-1;n>=0;n-=1){if(this.#e[n]===0)continue;const r=e[n];for(let o=0;o<8;o+=1)if((r>>o&1)===1){this.#t=n,this.#n=o,this.#c();return}}throw new Error("Stop bit not found")}#c(){if(this.#i=this.#e[this.#o],this.#r===2&&this.#i===3){this.#r=0,this.#o+=1,this.#c();return}this.#i===0?this.#r+=1:this.#r=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 n=0;for(let r=0;r<e;r+=1)n=n<<1|this.next();return n}#l(){if(this.#o>=this.#t&&this.#s<this.#n)throw new Error("Bit index out of bounds")}skip(e){if(e<=this.#s+1){this.#s-=e,this.#l();return}for(e-=this.#s+1,this.#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}#f(){return{zeroCount:this.#r,bytePosition:this.#o,bitPosition:this.#s,byte:this.#i}}#a(e){this.#r=e.zeroCount,this.#o=e.bytePosition,this.#s=e.bitPosition,this.#i=e.byte}peek(e){const n=this.#f(),r=this.read(e);return this.#a(n),r}readBytes(e){const n=new Uint8Array(e);for(let r=0;r<e;r+=1)n[r]=this.read(8);return n}peekBytes(e){const n=this.#f(),r=this.readBytes(e);return this.#a(n),r}}function Nf(t){const e=new Jt(t);if(e.next()!==0)throw new Error("Invalid data");const n=e.read(2);if(e.read(5)!==7)throw new Error("Invalid data");if(n===0)throw new Error("Invalid data");const o=e.read(8),s=e.peek(8),i=!!e.next(),a=!!e.next(),l=!!e.next(),f=!!e.next(),d=!!e.next(),h=!!e.next();if(e.read(2)!==0)throw new Error("Invalid data");const g=e.read(8),p=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 w=0;w<(T!==3?8:12);w+=1)e.next()}e.decodeExponentialGolombNumber();const _=e.decodeExponentialGolombNumber();if(_===0)e.decodeExponentialGolombNumber();else if(_===1){e.next(),e.decodeExponentialGolombNumber(),e.decodeExponentialGolombNumber();const T=e.decodeExponentialGolombNumber();for(let P=0;P<T;P+=1)e.decodeExponentialGolombNumber()}e.decodeExponentialGolombNumber(),e.next();const m=e.decodeExponentialGolombNumber(),v=e.decodeExponentialGolombNumber(),y=e.next();y||e.next(),e.next();const E=!!e.next();let x,b,C,S;return E?(x=e.decodeExponentialGolombNumber(),b=e.decodeExponentialGolombNumber(),C=e.decodeExponentialGolombNumber(),S=e.decodeExponentialGolombNumber()):(x=0,b=0,C=0,S=0),e.next(),{profile_idc:o,constraint_set:s,constraint_set0_flag:i,constraint_set1_flag:a,constraint_set2_flag:l,constraint_set3_flag:f,constraint_set4_flag:d,constraint_set5_flag:h,level_idc:g,seq_parameter_set_id:p,pic_width_in_mbs_minus1:m,pic_height_in_map_units_minus1:v,frame_mbs_only_flag:y,frame_cropping_flag:E,frame_crop_left_offset:x,frame_crop_right_offset:b,frame_crop_top_offset:C,frame_crop_bottom_offset:S}}function Pf(t){let e,n;for(const r of Fo(t))switch(r[0]&31){case 7:if(e=r,n)return{sequenceParameterSet:e,pictureParameterSet:n};break;case 8:if(n=r,e)return{sequenceParameterSet:e,pictureParameterSet:n};break}throw new Error("Invalid data")}function Af(t){const{sequenceParameterSet:e,pictureParameterSet:n}=Pf(t),{profile_idc:r,constraint_set:o,level_idc:s,pic_width_in_mbs_minus1:i,pic_height_in_map_units_minus1:a,frame_mbs_only_flag:l,frame_crop_left_offset:f,frame_crop_right_offset:d,frame_crop_top_offset:h,frame_crop_bottom_offset:g}=Nf(e),p=(i+1)*16,_=(a+1)*(2-l)*16,m=f*2,v=d*2,y=h*2,E=g*2,x=p-m-v,b=_-y-E;return{pictureParameterSet:n,sequenceParameterSet:e,profileIndex:r,constraintSet:o,levelIndex:s,encodedWidth:p,encodedHeight:_,cropLeft:m,cropRight:v,cropTop:y,cropBottom:E,croppedWidth:x,croppedHeight:b}}function Df(t){switch(t){case 0:case 3:return 1;case 1:case 2:return 2;default:throw new Error("Invalid chroma_format_idc")}}function Of(t){switch(t){case 0:case 2:case 3:return 1;case 1:return 2;default:throw new Error("Invalid chroma_format_idc")}}function Lf(t){const e=new Jt(t);if(e.next()!==0)throw new Error("Invalid NALU header");const n=e.read(6),r=e.read(6),o=e.read(3);return{nal_unit_type:n,nuh_layer_id:r,nuh_temporal_id_plus1:o}}function jf(t){const e=new Jt(t),n=e.read(4),r=!!e.next(),o=!!e.next(),s=e.read(6),i=e.read(3),a=!!e.next();e.skip(16);const l=Uo(e,!0,i),f=!!e.next(),d=[],h=[],g=[];for(let N=f?0:i;N<=i;N+=1)d[N]=e.decodeExponentialGolombNumber(),h[N]=e.decodeExponentialGolombNumber(),g[N]=e.decodeExponentialGolombNumber();const p=e.read(6),_=e.decodeExponentialGolombNumber(),m=[];for(let N=1;N<=_;N+=1){m[N]=[];for(let R=0;R<=p;R+=1)m[N][R]=!!e.next()}const v=!!e.next();let y,E,x,b,C,S,T,P;if(v){y=e.read(32),E=e.read(32),x=!!e.next(),x&&(b=e.decodeExponentialGolombNumber()),C=e.decodeExponentialGolombNumber(),S=[],T=[!0],P=[];for(let N=0;N<C;N+=1)S[N]=e.decodeExponentialGolombNumber(),N>0&&(T[N]=!!e.next()),P[N]=Wo(e,T[N],i)}const w=!!e.next();return{vps_video_parameter_set_id:n,vps_base_layer_internal_flag:r,vps_base_layer_available_flag:o,vps_max_layers_minus1:s,vps_max_sub_layers_minus1:i,vps_temporal_id_nesting_flag:a,profileTierLevel:l,vps_sub_layer_ordering_info_present_flag:f,vps_max_dec_pic_buffering_minus1:d,vps_max_num_reorder_pics:h,vps_max_latency_increase_plus1:g,vps_max_layer_id:p,vps_num_layer_sets_minus1:_,layer_id_included_flag:m,vps_timing_info_present_flag:v,vps_num_units_in_tick:y,vps_time_scale:E,vps_poc_proportional_to_timing_flag:x,vps_num_ticks_poc_diff_one_minus1:b,vps_num_hrd_parameters:C,hrd_layer_set_idx:S,cprms_present_flag:T,hrdParameters:P,vps_extension_flag:w}}function Mf(t){const e=new Jt(t),n=e.read(4),r=e.read(3),o=!!e.next(),s=Uo(e,!0,r),i=e.decodeExponentialGolombNumber(),a=e.decodeExponentialGolombNumber();let l;a===3&&(l=!!e.next());const f=e.decodeExponentialGolombNumber(),d=e.decodeExponentialGolombNumber(),h=!!e.next();let g,p,_,m;h&&(g=e.decodeExponentialGolombNumber(),p=e.decodeExponentialGolombNumber(),_=e.decodeExponentialGolombNumber(),m=e.decodeExponentialGolombNumber());const v=e.decodeExponentialGolombNumber(),y=e.decodeExponentialGolombNumber(),E=e.decodeExponentialGolombNumber(),x=[],b=[],C=[],S=!!e.next();for(let $=S?0:r;$<=r;$+=1)x[$]=e.decodeExponentialGolombNumber(),b[$]=e.decodeExponentialGolombNumber(),C[$]=e.decodeExponentialGolombNumber();const T=e.decodeExponentialGolombNumber(),P=e.decodeExponentialGolombNumber(),w=e.decodeExponentialGolombNumber(),N=e.decodeExponentialGolombNumber(),R=e.decodeExponentialGolombNumber(),I=e.decodeExponentialGolombNumber(),F=!!e.next();let k,A;F&&(k=!!e.next(),k&&(A=Bf(e)));const D=!!e.next(),M=!!e.next(),L=!!e.next();let U,G,q,Y,Z;L&&(U=e.read(4),G=e.read(4),q=e.read(4),Y=e.read(4),Z=!!e.next());const ee=e.decodeExponentialGolombNumber(),se=[];for(let $=0;$<ee;$+=1)se[$]=If(e,$,ee,se);const he=!!e.next();let te,ie,K;if(he){te=e.decodeExponentialGolombNumber(),ie=[],K=[];for(let $=0;$<te;$+=1)ie[$]=e.read(E+4),K[$]=!!e.next()}const pe=!!e.next(),We=!!e.next(),De=!!e.next();let ge;De&&(ge=Ff(e,r));const Oe=!!e.next();let B,O,j,W,V;if(Oe&&(B=!!e.next(),O=!!e.next(),j=!!e.next(),W=!!e.next(),V=e.read(4)),B)throw new Error("Not implemented");let J;O&&(J=Wf(e));let X;if(j&&(X=Hf(e)),W)throw new Error("Not implemented");let H;if(V){H=[];let $=0;for(;!e.ended;)H[$]=!!e.next(),$+=1}return{sps_video_parameter_set_id:n,sps_max_sub_layers_minus1:r,sps_temporal_id_nesting_flag:o,profileTierLevel:s,sps_seq_parameter_set_id:i,chroma_format_idc:a,separate_colour_plane_flag:l,pic_width_in_luma_samples:f,pic_height_in_luma_samples:d,conformance_window_flag:h,conf_win_left_offset:g,conf_win_right_offset:p,conf_win_top_offset:_,conf_win_bottom_offset:m,bit_depth_luma_minus8:v,bit_depth_chroma_minus8:y,log2_max_pic_order_cnt_lsb_minus4:E,sps_sub_layer_ordering_info_present_flag:S,sps_max_dec_pic_buffering_minus1:x,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:P,log2_min_luma_transform_block_size_minus2:w,log2_diff_max_min_luma_transform_block_size:N,max_transform_hierarchy_depth_inter:R,max_transform_hierarchy_depth_intra:I,scaling_list_enabled_flag:F,sps_scaling_list_data_present_flag:k,scalingListData:A,amp_enabled_flag:D,sample_adaptive_offset_enabled_flag:M,pcm_enabled_flag:L,pcm_sample_bit_depth_luma_minus1:U,pcm_sample_bit_depth_chroma_minus1:G,log2_min_pcm_luma_coding_block_size_minus3:q,log2_diff_max_min_pcm_luma_coding_block_size:Y,pcm_loop_filter_disabled_flag:Z,num_short_term_ref_pic_sets:ee,shortTermRefPicSets:se,long_term_ref_pics_present_flag:he,num_long_term_ref_pics_sps:te,lt_ref_pic_poc_lsb_sps:ie,used_by_curr_pic_lt_sps_flag:K,sps_temporal_mvp_enabled_flag:pe,strong_intra_smoothing_enabled_flag:We,vui_parameters_present_flag:De,vuiParameters:ge,sps_extension_present_flag:Oe,sps_range_extension_flag:B,sps_multilayer_extension_flag:O,sps_3d_extension_flag:j,sps_scc_extension_flag:W,sps_extension_4bits:V,spsMultilayerExtension:J,sps3dExtension:X,sps_extension_data_flag:H}}function Ur(t){const e=t.read(2),n=!!t.next(),r=t.read(5),o=t.peekBytes(4),s=[];for(let S=0;S<32;S+=1)s[S]=!!t.next();const i=t.peekBytes(6),a=!!t.next(),l=!!t.next(),f=!!t.next(),d=!!t.next();let h,g,p,_,m,v,y,E,x,b;r===4||s[4]||r===5||s[5]||r===6||s[6]||r===7||s[7]||r===8||s[8]||r===9||s[9]||r===10||s[10]||r===11||s[11]?(h=!!t.next(),g=!!t.next(),p=!!t.next(),_=!!t.next(),m=!!t.next(),v=!!t.next(),y=!!t.next(),E=!!t.next(),x=!!t.next(),r===5||s[5]||r===9||s[9]||r===10||s[10]||r===11||s[11]?(b=!!t.next(),t.skip(33)):t.skip(34)):r===2||s[2]?(t.skip(7),E=!!t.next(),t.skip(35)):t.skip(43);let C;return r===1||s[1]||r===2||s[2]||r===3||s[3]||r===4||s[4]||r===5||s[5]||r===9||s[9]||r===11||s[11]?C=!!t.next():t.skip(1),{profile_space:e,tier_flag:n,profile_idc:r,profileCompatibilitySet:o,profile_compatibility_flag:s,constraintSet:i,progressive_source_flag:a,interlaced_source_flag:l,non_packed_constraint_flag:f,frame_only_constraint_flag:d,max_12bit_constraint_flag:h,max_10bit_constraint_flag:g,max_8bit_constraint_flag:p,max_422chroma_constraint_flag:_,max_420chroma_constraint_flag:m,max_monochrome_constraint_flag:v,intra_constraint_flag:y,one_picture_only_constraint_flag:E,lower_bit_rate_constraint_flag:x,max_14bit_constraint_flag:b,inbld_flag:C}}function Uo(t,e,n){let r;r=Ur(t);const o=t.read(8),s=[],i=[];for(let f=0;f<n;f+=1)s[f]=!!t.next(),i[f]=!!t.next();if(n>0)for(let f=n;f<8;f+=1)t.read(2);const a=[],l=[];for(let f=0;f<n;f+=1)s[f]&&(a[f]=Ur(t)),i[f]&&(l[f]=t.read(8));return{generalProfileTier:r,general_level_idc:o,sub_layer_profile_present_flag:s,sub_layer_level_present_flag:i,subLayerProfileTier:a,sub_layer_level_idc:l}}function Bf(t){const e=[];for(let n=0;n<4;n+=1){e[n]=[];for(let r=0;r<6;r+=n===3?3:1)if(!!!t.next())t.decodeExponentialGolombNumber();else{let s=8;const i=Math.min(64,1<<4+(n<<1));n>1&&(s=t.decodeExponentialGolombNumber()+8),e[n][r]=[];for(let a=0;a<i;a+=1){const l=t.decodeExponentialGolombNumber();s=(s+l+256)%256,e[n][r][a]=s}}}return e}function If(t,e,n,r){let o=!1;e!==0&&(o=!!t.next());let s=0,i=!1,a=0;const l=[],f=[];let d=0,h=0;const g=[],p=[],_=[],m=[];if(o){e===n&&(s=t.decodeExponentialGolombNumber()),i=!!t.next(),a=t.decodeExponentialGolombNumber();const v=e-(s+1),y=r[v],E=y.num_negative_pics+y.num_positive_pics;for(let R=0;R<=E;R+=1)l[R]=!!t.next(),l[R]?f[R]=!0:f[R]=!!t.next();const x=(1-2*Number(i))*(a+1),b=[],C=[],S=[],T=[];let P=0;for(let R=0;R<y.num_negative_pics;R+=1)P-=y.delta_poc_s0_minus1[R]+1,b[R]=P;P=0;for(let R=0;R<y.num_positive_pics;R+=1)P+=y.delta_poc_s1_minus1[R]+1,C[R]=P;let w=0;if(y.num_positive_pics>0)for(let R=y.num_positive_pics-1;R>=0;R-=1)P=C[R]+x,P<0&&f[y.num_negative_pics+R]&&(S[w]=P,p[w]=l[y.num_negative_pics+R],w+=1);x<0&&f[E]&&(S[w]=x,p[w]=l[E],w+=1);for(let R=0;R<y.num_negative_pics;R+=1)P=b[R]+x,P<0&&f[R]&&(S[w]=P,p[w]=l[R],w+=1);d=w;let N=0;for(w=0;w<d;w+=1){const R=S[w];g[w]=-(R-N-1),N=R}if(w=0,y.num_negative_pics>0)for(let R=y.num_negative_pics-1;R>=0;R-=1)P=b[R]+x,P>0&&f[R]&&(T[w]=P,m[w]=l[R],w+=1);x>0&&f[E]&&(T[w]=x,m[w]=l[E],w+=1);for(let R=0;R<y.num_positive_pics;R+=1)P=C[R]+x,P>0&&f[y.num_negative_pics+R]&&(T[w]=P,m[w]=l[y.num_negative_pics+R],w+=1);for(h=w,N=0,w=0;w<h;w+=1){const R=T[w];_[w]=R-N-1,N=R}}else{d=t.decodeExponentialGolombNumber(),h=t.decodeExponentialGolombNumber();for(let v=0;v<d;v+=1)g[v]=t.decodeExponentialGolombNumber(),p[v]=!!t.next();for(let v=0;v<h;v+=1)_[v]=t.decodeExponentialGolombNumber(),m[v]=!!t.next()}return{stRpsIdx:e,num_short_term_ref_pic_sets:n,inter_ref_pic_set_prediction_flag:o,delta_idx_minus1:s,delta_rps_sign:i,abs_delta_rps_minus1:a,used_by_curr_pic_flag:l,use_delta_flag:f,num_negative_pics:d,num_positive_pics:h,delta_poc_s0_minus1:g,used_by_curr_pic_s0_flag:p,delta_poc_s1_minus1:_,used_by_curr_pic_s1_flag:m}}function Ff(t,e){const n=!!t.next();let r,o,s;n&&(r=t.read(8),r===255&&(o=t.read(16),s=t.read(16)));const i=!!t.next();let a;i&&(a=!!t.next());const l=!!t.next();let f,d,h,g,p,_;l&&(f=t.read(3),d=!!t.next(),h=!!t.next(),h&&(g=t.read(8),p=t.read(8),_=t.read(8)));const m=!!t.next();let v,y;m&&(v=t.decodeExponentialGolombNumber(),y=t.decodeExponentialGolombNumber());const E=!!t.next(),x=!!t.next(),b=!!t.next(),C=!!t.next();let S,T,P,w;C&&(S=t.decodeExponentialGolombNumber(),T=t.decodeExponentialGolombNumber(),P=t.decodeExponentialGolombNumber(),w=t.decodeExponentialGolombNumber());const N=!!t.next();let R,I,F,k,A,D;N&&(R=t.read(32),I=t.read(32),F=!!t.next(),F&&(k=t.decodeExponentialGolombNumber()),A=!!t.next(),A&&(D=Wo(t,!0,e)));const M=!!t.next();let L,U,G,q,Y,Z,ee,se;return M&&(L=!!t.next(),U=!!t.next(),G=!!t.next(),q=t.decodeExponentialGolombNumber(),Y=t.decodeExponentialGolombNumber(),Z=t.decodeExponentialGolombNumber(),ee=t.decodeExponentialGolombNumber(),se=t.decodeExponentialGolombNumber()),{aspect_ratio_info_present_flag:n,aspect_ratio_idc:r,sar_width:o,sar_height:s,overscan_info_present_flag:i,overscan_appropriate_flag:a,video_signal_type_present_flag:l,video_format:f,video_full_range_flag:d,colour_description_present_flag:h,colour_primaries:g,transfer_characteristics:p,matrix_coeffs:_,chroma_loc_info_present_flag:m,chroma_sample_loc_type_top_field:v,chroma_sample_loc_type_bottom_field:y,neutral_chroma_indication_flag:E,field_seq_flag:x,frame_field_info_present_flag:b,default_display_window_flag:C,def_disp_win_left_offset:S,def_disp_win_right_offset:T,def_disp_win_top_offset:P,def_disp_win_bottom_offset:w,vui_timing_info_present_flag:N,vui_num_units_in_tick:R,vui_time_scale:I,vui_poc_proportional_to_timing_flag:F,vui_num_ticks_poc_diff_one_minus1:k,vui_hrd_parameters_present_flag:A,vui_hrd_parameters:D,bitstream_restriction_flag:M,tiles_fixed_structure_flag:L,motion_vectors_over_pic_boundaries_flag:U,restricted_ref_pic_lists_flag:G,min_spatial_segmentation_idc:q,max_bytes_per_pic_denom:Y,max_bits_per_min_cu_denom:Z,log2_max_mv_length_horizontal:ee,log2_max_mv_length_vertical:se}}function Wo(t,e,n){let r,o,s,i,a,l,f,d,h,g,p,_,m;e&&(r=!!t.next(),o=!!t.next(),(r||o)&&(s=!!t.next(),s&&(i=t.read(8),a=t.read(5),l=!!t.next(),f=t.read(5)),d=t.read(4),h=t.read(4),s&&(g=t.read(4)),p=t.read(5),_=t.read(5),m=t.read(5)));const v=[],y=[],E=[],x=[],b=[],C=[],S=[];for(let T=0;T<=n;T+=1)v[T]=!!t.next(),v[T]||(y[T]=!!t.next()),y[T]?E[T]=t.decodeExponentialGolombNumber():x[T]=!!t.next(),x[T]||(b[T]=t.decodeExponentialGolombNumber()),r&&(C[T]=Wr(t,T,Hr(b[T]))),o&&(S[T]=Wr(t,T,Hr(b[T])));return{nal_hrd_parameters_present_flag:r,vcl_hrd_parameters_present_flag:o,sub_pic_hrd_params_present_flag:s,tick_divisor_minus2:i,du_cpb_removal_delay_increment_length_minus1:a,sub_pic_cpb_params_in_pic_timing_sei_flag:l,dpb_output_delay_du_length_minus1:f,bit_rate_scale:d,cpb_size_scale:h,cpb_size_du_scale:g,initial_cpb_removal_delay_length_minus1:p,au_cpb_removal_delay_length_minus1:_,dpb_output_delay_length_minus1:m,fixed_pic_rate_general_flag:v,fixed_pic_rate_within_cvs_flag:y,elemental_duration_in_tc_minus1:E,low_delay_hrd_flag:x,cpb_cnt_minus1:b,nalHrdParameters:C,vclHrdParameters:S}}function Wr(t,e,n){const r=[],o=[],s=[],i=[],a=[];for(let l=0;l<n;l+=1)r[l]=t.decodeExponentialGolombNumber(),o[l]=t.decodeExponentialGolombNumber(),e>0&&(a[l]=!!t.next());return{bit_rate_value_minus1:r,cpb_size_value_minus1:o,cpb_size_du_value_minus1:s,bit_rate_du_value_minus1:i,cbr_flag:a}}function Hr(t){return t+1}function Uf(t){let e,n,r,o=0;for(const s of Fo(t)){const i=Lf(s),a={...i,data:s,rbsp:s.subarray(2)};switch(i.nal_unit_type){case 32:e=a;break;case 33:n=a;break;case 34:r=a;break;default:continue}if(o+=1,o===3)return{videoParameterSet:e,sequenceParameterSet:n,pictureParameterSet:r}}throw new Error("Invalid data")}function Wf(t){return{inter_view_mv_vert_constraint_flag:!!t.next()}}function Hf(t){const e=[],n=[];e[0]=!!t.next(),n[0]=!!t.next();const r=t.decodeExponentialGolombNumber(),o=!!t.next(),s=!!t.next(),i=!!t.next(),a=!!t.next();e[1]=!!t.next(),n[1]=!!t.next();const l=!!t.next(),f=t.decodeExponentialGolombNumber(),d=!!t.next(),h=!!t.next(),g=!!t.next(),p=!!t.next(),_=!!t.next();return{iv_di_mc_enabled_flag:e,iv_mv_scal_enabled_flag:n,log2_ivmc_sub_pb_size_minus3:r,iv_res_pred_enabled_flag:o,depth_ref_enabled_flag:s,vsp_mc_enabled_flag:i,dbbp_enabled_flag:a,tex_mc_enabled_flag:l,log2_texmc_sub_pb_size_minus3:f,intra_contour_enabled_flag:d,intra_dc_only_wedge_enabled_flag:h,cqt_cu_part_pred_enabled_flag:g,inter_dc_only_enabled_flag:p,skip_intra_enabled_flag:_}}function $f(t){const{videoParameterSet:e,sequenceParameterSet:n,pictureParameterSet:r}=Uf(t),{profileTierLevel:{generalProfileTier:{profile_space:o,tier_flag:s,profile_idc:i,profileCompatibilitySet:a,constraintSet:l},general_level_idc:f}}=jf(e.rbsp),{chroma_format_idc:d,pic_width_in_luma_samples:h,pic_height_in_luma_samples:g,conf_win_left_offset:p=0,conf_win_right_offset:_=0,conf_win_top_offset:m=0,conf_win_bottom_offset:v=0}=Mf(n.rbsp),y=Df(d),E=Of(d),x=h-y*(p+_),b=g-E*(m+v);return{videoParameterSet:e,sequenceParameterSet:n,pictureParameterSet:r,generalProfileSpace:o,generalProfileIndex:i,generalProfileCompatibilitySet:a,generalTierFlag:s,generalLevelIndex:f,generalConstraintSet:l,encodedWidth:h,encodedHeight:g,cropLeft:p,cropRight:_,cropTop:m,cropBottom:v,croppedWidth:x,croppedHeight:b}}function $r(t){return t.toString(16).toUpperCase()}function dn(t){return t.toString(16).toUpperCase().padStart(2,"0")}function it(t){return t.toString(10).padStart(2,"0")}class Gf{#e;#t;constructor(e,n){this.#e=e,this.#t=n}#n(e){const r=new ae(e).searchSequenceHeaderObu();if(!r)return;const{seq_profile:o,seq_level_idx:[s=0],max_frame_width_minus_1:i,max_frame_height_minus_1:a,color_config:{BitDepth:l,mono_chrome:f,subsampling_x:d,subsampling_y:h,chroma_sample_position:g,color_description_present_flag:p}}=r;let _,m,v,y;p?{color_primaries:_,transfer_characteristics:m,matrix_coefficients:v,color_range:y}=r.color_config:(_=ae.ColorPrimaries.Bt709,m=ae.TransferCharacteristics.Bt709,v=ae.MatrixCoefficients.Bt709,y=!1);const E=i+1,x=a+1;this.#t(E,x);const b=["av01",o.toString(16),it(s)+(r.seq_tier[0]?"H":"M"),it(l),f?"1":"0",(d?"1":"0")+(h?"1":"0")+g.toString(),it(_),it(m),it(v),y?"1":"0"].join(".");this.#e.configure({codec:b,optimizeForLatency:!0})}decode(e){e.type!=="configuration"&&(this.#n(e.data),this.#e.decode(new EncodedVideoChunk({type:e.keyframe===!1?"delta":"key",timestamp:0,data:e.data})))}}class Ho{#e;#t;constructor(e){this.#t=e}decode(e){if(e.type==="configuration"){this.#e=e.data,this.configure(e.data);return}let n;this.#e!==void 0?(n=new Uint8Array(this.#e.length+e.data.length),n.set(this.#e,0),n.set(e.data,this.#e.length),this.#e=void 0):n=e.data,this.#t.decode(new EncodedVideoChunk({type:e.keyframe===!1?"delta":"key",timestamp:0,data:n}))}}class qf extends Ho{#e;#t;constructor(e,n){super(e),this.#e=e,this.#t=n}configure(e){const{profileIndex:n,constraintSet:r,levelIndex:o,croppedWidth:s,croppedHeight:i}=Af(e);this.#t(s,i);const a="avc1."+dn(n)+dn(r)+dn(o);this.#e.configure({codec:a,optimizeForLatency:!0})}}class zf extends Ho{#e;#t;constructor(e,n){super(e),this.#e=e,this.#t=n}configure(e){const{generalProfileSpace:n,generalProfileIndex:r,generalProfileCompatibilitySet:o,generalTierFlag:s,generalLevelIndex:i,generalConstraintSet:a,croppedWidth:l,croppedHeight:f}=$f(e);this.#t(l,f);const d=["hev1",["","A","B","C"][n]+r.toString(),$r(wf(o,0)),(s?"H":"L")+i.toString(),...Array.from(a,$r)].join(".");this.#e.configure({codec:d,codedWidth:l,codedHeight:f,optimizeForLatency:!0})}}class Vf{listeners=[];constructor(){this.event=this.event.bind(this)}addEventListener(e){this.listeners.push(e);const n=()=>{const r=this.listeners.indexOf(e);r!==-1&&this.listeners.splice(r,1)};return n.dispose=n,n}event=(e,n,...r)=>{const o={listener:e,thisArg:n,args:r};return this.addEventListener(o)};fire(e){for(const n of this.listeners.slice())n.listener.apply(n.thisArg,[e,...n.args])}dispose(){this.listeners.length=0}}class Xf{#e;#t=new ReadableStream({start:e=>{this.#e=e},pull:e=>{e.enqueue(this.#r())}},{highWaterMark:0});#n=this.#t.getReader();#r;#o=0;#s;constructor(e,n){this.#r=e,this.#s=n}async borrow(){return(await this.#n.read()).value}return(e){this.#o<this.#s&&(this.#e.enqueue(e),this.#o+=1)}}class Yf{#e;#t;constructor(){typeof OffscreenCanvas<"u"?this.#e=new OffscreenCanvas(1,1):(this.#e=document.createElement("canvas"),this.#e.width=1,this.#e.height=1),this.#t=this.#e.getContext("bitmaprenderer",{alpha:!1})}async capture(e){this.#e.width=e.displayWidth,this.#e.height=e.displayHeight;const n=await createImageBitmap(e);return this.#t.transferFromImageBitmap(n),this.#e instanceof OffscreenCanvas?await this.#e.convertToBlob({type:"image/png"}):new Promise((r,o)=>{this.#e.toBlob(s=>{s?r(s):o(new Error("Failed to convert canvas to blob"))},"image/png")})}}const Gr=new Xf(()=>new Yf,4);class qr{static get isSupported(){return typeof globalThis.VideoDecoder<"u"}static capabilities={h264:{},h265:{},av1:{}};#e;get codec(){return this.#e}#t;#n;get writable(){return this.#n}#r;#o;#s;get renderer(){return this.#s}#i=0;#c=0;get framesRendered(){return this.#c}#l=0;get framesSkipped(){return this.#l}#f=new Vf;get sizeChanged(){return this.#f.event}#a;#p=!1;#u;#d;#m=0;constructor({codec:e,renderer:n}){switch(this.#e=e,this.#s=n,this.#a=new VideoDecoder({output:r=>{if(this.#d?.close(),this.#d=r.clone(),this.#p){this.#u&&(this.#u.close(),this.#l+=1),this.#u=r;return}this.#_(r)},error:r=>{this.#g(r)}}),this.#e){case Lt.H264:this.#t=new qf(this.#a,this.#h);break;case Lt.H265:this.#t=new zf(this.#a,this.#h);break;case Lt.AV1:this.#t=new Gf(this.#a,this.#h);break;default:throw new Error(`Unsupported codec: ${this.#e}`)}this.#n=new Ef({start:r=>{this.#r?r.error(this.#r):this.#o=r},write:r=>{this.#t.decode(r)}}),this.#x()}#g(e){if(this.#o)try{this.#o.error(e)}catch{}else this.#r=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 n=this.#u;this.#u=void 0,await this.#_(n)}this.#p=!1}catch(n){this.#g(n)}}#h=(e,n)=>{this.#s.setSize(e,n),this.#f.fire({width:e,height:n})};#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.#d;if(!e)return;const n=await Gr.borrow(),r=await n.capture(e);return Gr.return(n),r}dispose(){cancelAnimationFrame(this.#m),this.#a.state!=="closed"&&this.#a.close(),this.#u?.close(),this.#d?.close()}}var hn={exports:{}},pn={exports:{}},zr;function ir(){return zr||(zr=1,(function(){function t(e,n){throw new Error("abstract")}t.prototype.drawFrame=function(e){throw new Error("abstract")},t.prototype.clear=function(){throw new Error("abstract")},pn.exports=t})()),pn.exports}var mn={exports:{}},gn={exports:{}},_n={exports:{}},Vr;function Kf(){return Vr||(Vr=1,(function(){function t(e){for(var n=0,r=e>>1;r!=0;)r=r>>1,n++;if(e!==1<<n)throw"chroma plane dimensions must be power of 2 ratio to luma plane dimensions; got "+e;return n}_n.exports=t})()),_n.exports}var Xr;function Jf(){return Xr||(Xr=1,(function(){var t=Kf();function e(n,r){var o=n.format.width|0,s=n.format.height|0,i=t(n.format.width/n.format.chromaWidth)|0,a=t(n.format.height/n.format.chromaHeight)|0,l=n.y.bytes,f=n.u.bytes,d=n.v.bytes,h=n.y.stride|0,g=n.u.stride|0,p=n.v.stride|0,_=o<<2,m=0,v=0,y=0,E=0,x=0,b=0,C=0,S=0,T=0,P=0,w=0,N=0,R=0,I=0,F=0,k=0,A=0,D=0;if(i==1&&a==1)for(C=0,S=_,D=0,k=0;k<s;k+=2){for(v=k*h|0,y=v+h|0,E=D*g|0,x=D*p|0,F=0;F<o;F+=2)T=f[E++]|0,P=d[x++]|0,N=(409*P|0)-57088|0,R=(100*T|0)+(208*P|0)-34816|0,I=(516*T|0)-70912|0,w=298*l[v++]|0,r[C]=w+N>>8,r[C+1]=w-R>>8,r[C+2]=w+I>>8,C+=4,w=298*l[v++]|0,r[C]=w+N>>8,r[C+1]=w-R>>8,r[C+2]=w+I>>8,C+=4,w=298*l[y++]|0,r[S]=w+N>>8,r[S+1]=w-R>>8,r[S+2]=w+I>>8,S+=4,w=298*l[y++]|0,r[S]=w+N>>8,r[S+1]=w-R>>8,r[S+2]=w+I>>8,S+=4;C+=_,S+=_,D++}else for(b=0,k=0;k<s;k++)for(A=0,D=k>>a,m=k*h|0,E=D*g|0,x=D*p|0,F=0;F<o;F++)A=F>>i,T=f[E+A]|0,P=d[x+A]|0,N=(409*P|0)-57088|0,R=(100*T|0)+(208*P|0)-34816|0,I=(516*T|0)-70912|0,w=298*l[m++]|0,r[b]=w+N>>8,r[b+1]=w-R>>8,r[b+2]=w+I>>8,b+=4}gn.exports={convertYCbCr:e}})()),gn.exports}var Yr;function Qf(){return Yr||(Yr=1,(function(){var t=ir(),e=Jf();function n(r){var o=this,s=r.getContext("2d"),i=null,a=null,l=null;function f(h,g){i=s.createImageData(h,g);for(var p=i.data,_=h*g*4,m=0;m<_;m+=4)p[m+3]=255}function d(h,g){a=document.createElement("canvas"),a.width=h,a.height=g,l=a.getContext("2d")}return o.drawFrame=function(g){var p=g.format;(r.width!==p.displayWidth||r.height!==p.displayHeight)&&(r.width=p.displayWidth,r.height=p.displayHeight),(i===null||i.width!=p.width||i.height!=p.height)&&f(p.width,p.height),e.convertYCbCr(g,i.data);var _=p.cropWidth!=p.displayWidth||p.cropHeight!=p.displayHeight,m;_?(a||d(p.cropWidth,p.cropHeight),m=l):m=s,m.putImageData(i,-p.cropLeft,-p.cropTop,p.cropLeft,p.cropTop,p.cropWidth,p.cropHeight),_&&s.drawImage(a,0,0,p.displayWidth,p.displayHeight)},o.clear=function(){s.clearRect(0,0,r.width,r.height)},o}n.prototype=Object.create(t.prototype),mn.exports=n})()),mn.exports}var xn={exports:{}},vn,Kr;function Zf(){return Kr||(Kr=1,vn={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
+ `}),vn}var Jr;function ed(){return Jr||(Jr=1,(function(){var t=ir(),e=Zf();function n(r){var o=this,s=n.contextForCanvas(r);if(s===null)throw new Error("WebGL unavailable");function i(k,A){var D=s.createShader(k);if(s.shaderSource(D,A),s.compileShader(D),!s.getShaderParameter(D,s.COMPILE_STATUS)){var M=s.getShaderInfoLog(D);throw s.deleteShader(D),new Error("GL shader compilation for "+k+" failed: "+M)}return D}var a,l,f=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),d={},h={},g={},p,_,m,v,y,E,x,b,C,S;function T(k,A){return(!d[k]||A)&&(d[k]=s.createTexture()),d[k]}function P(k,A,D,M,L){var U=!d[k]||A,G=T(k,A);if(s.activeTexture(s.TEXTURE0),n.stripe){var q=!d[k+"_temp"]||A,Y=T(k+"_temp",A);s.bindTexture(s.TEXTURE_2D,Y),q?(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.NEAREST),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,D/4,M,0,s.RGBA,s.UNSIGNED_BYTE,L)):s.texSubImage2D(s.TEXTURE_2D,0,0,0,D/4,M,s.RGBA,s.UNSIGNED_BYTE,L);var Z=d[k+"_stripe"],ee=!Z||A;ee&&(Z=T(k+"_stripe",A)),s.bindTexture(s.TEXTURE_2D,Z),ee&&(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,D,1,0,s.RGBA,s.UNSIGNED_BYTE,R(D)))}else s.bindTexture(s.TEXTURE_2D,G),U?(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,D,M,0,s.ALPHA,s.UNSIGNED_BYTE,L)):s.texSubImage2D(s.TEXTURE_2D,0,0,0,D,M,s.ALPHA,s.UNSIGNED_BYTE,L)}function w(k,A,D,M){var L=d[k];s.useProgram(l);var U=h[k];(!U||A)&&(s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,L),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,D,M,0,s.RGBA,s.UNSIGNED_BYTE,null),U=h[k]=s.createFramebuffer()),s.bindFramebuffer(s.FRAMEBUFFER,U),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,L,0);var G=d[k+"_temp"];s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,G),s.uniform1i(E,1);var q=d[k+"_stripe"];s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,q),s.uniform1i(y,2),s.bindBuffer(s.ARRAY_BUFFER,p),s.enableVertexAttribArray(_),s.vertexAttribPointer(_,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,m),s.enableVertexAttribArray(v),s.vertexAttribPointer(v,2,s.FLOAT,!1,0,0),s.viewport(0,0,D,M),s.drawArrays(s.TRIANGLES,0,f.length/2),s.bindFramebuffer(s.FRAMEBUFFER,null)}function N(k,A,D){s.activeTexture(A),s.bindTexture(s.TEXTURE_2D,d[k]),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.uniform1i(s.getUniformLocation(a,k),D)}function R(k){if(g[k])return g[k];for(var A=k,D=new Uint32Array(A),M=0;M<A;M+=4)D[M]=255,D[M+1]=65280,D[M+2]=16711680,D[M+3]=4278190080;return g[k]=new Uint8Array(D.buffer)}function I(k,A){var D=i(s.VERTEX_SHADER,k),M=i(s.FRAGMENT_SHADER,A),L=s.createProgram();if(s.attachShader(L,D),s.attachShader(L,M),s.linkProgram(L),!s.getProgramParameter(L,s.LINK_STATUS)){var U=s.getProgramInfoLog(L);throw s.deleteProgram(L),new Error("GL program linking failed: "+U)}return L}function F(){if(n.stripe){l=I(e.vertexStripe,e.fragmentStripe),s.getAttribLocation(l,"aPosition"),m=s.createBuffer();var k=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);s.bindBuffer(s.ARRAY_BUFFER,m),s.bufferData(s.ARRAY_BUFFER,k,s.STATIC_DRAW),v=s.getAttribLocation(l,"aTexturePosition"),y=s.getUniformLocation(l,"uStripe"),E=s.getUniformLocation(l,"uTexture")}a=I(e.vertex,e.fragment),p=s.createBuffer(),s.bindBuffer(s.ARRAY_BUFFER,p),s.bufferData(s.ARRAY_BUFFER,f,s.STATIC_DRAW),_=s.getAttribLocation(a,"aPosition"),x=s.createBuffer(),b=s.getAttribLocation(a,"aLumaPosition"),C=s.createBuffer(),S=s.getAttribLocation(a,"aChromaPosition")}return o.drawFrame=function(k){var A=k.format,D=!a||r.width!==A.displayWidth||r.height!==A.displayHeight;if(D&&(r.width=A.displayWidth,r.height=A.displayHeight,o.clear()),a||F(),D){var M=function(L,U,G){var q=A.cropLeft/G,Y=(A.cropLeft+A.cropWidth)/G,Z=(A.cropTop+A.cropHeight)/A.height,ee=A.cropTop/A.height,se=new Float32Array([q,Z,Y,Z,q,ee,q,ee,Y,Z,Y,ee]);s.bindBuffer(s.ARRAY_BUFFER,L),s.bufferData(s.ARRAY_BUFFER,se,s.STATIC_DRAW)};M(x,b,k.y.stride),M(C,S,k.u.stride*A.width/A.chromaWidth)}P("uTextureY",D,k.y.stride,A.height,k.y.bytes),P("uTextureCb",D,k.u.stride,A.chromaHeight,k.u.bytes),P("uTextureCr",D,k.v.stride,A.chromaHeight,k.v.bytes),n.stripe&&(w("uTextureY",D,k.y.stride,A.height),w("uTextureCb",D,k.u.stride,A.chromaHeight),w("uTextureCr",D,k.v.stride,A.chromaHeight)),s.useProgram(a),s.viewport(0,0,r.width,r.height),N("uTextureY",s.TEXTURE0,0),N("uTextureCb",s.TEXTURE1,1),N("uTextureCr",s.TEXTURE2,2),s.bindBuffer(s.ARRAY_BUFFER,p),s.enableVertexAttribArray(_),s.vertexAttribPointer(_,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,x),s.enableVertexAttribArray(b),s.vertexAttribPointer(b,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,C),s.enableVertexAttribArray(S),s.vertexAttribPointer(S,2,s.FLOAT,!1,0,0),s.drawArrays(s.TRIANGLES,0,f.length/2)},o.clear=function(){s.viewport(0,0,r.width,r.height),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT)},o.clear(),o}n.stripe=!1,n.contextForCanvas=function(r){var o={preferLowPowerToHighPerformance:!0,powerPreference:"low-power",failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!0};return r.getContext("webgl",o)||r.getContext("experimental-webgl",o)},n.isAvailable=function(){var r=document.createElement("canvas"),o;r.width=1,r.height=1;try{o=n.contextForCanvas(r)}catch{return!1}if(o){var s=o.TEXTURE0,i=4,a=4,l=o.createTexture(),f=new Uint8Array(i*a),d=n.stripe?i/4:i,h=n.stripe?o.RGBA:o.ALPHA,g=n.stripe?o.NEAREST:o.LINEAR;o.activeTexture(s),o.bindTexture(o.TEXTURE_2D,l),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,g),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,g),o.texImage2D(o.TEXTURE_2D,0,h,d,a,0,h,o.UNSIGNED_BYTE,f);var p=o.getError();return!p}else return!1},n.prototype=Object.create(t.prototype),xn.exports=n})()),xn.exports}var Qr;function td(){return Qr||(Qr=1,(function(){var t=ir(),e=Qf(),n=ed(),r={FrameSink:t,SoftwareFrameSink:e,WebGLFrameSink:n,attach:function(o,s){s=s||{};var i="webGL"in s?s.webGL:n.isAvailable();return i?new n(o,s):new e(o,s)}};hn.exports=r})()),hn.exports}td();function $o(){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 Go{#e;get canvas(){return this.#e}constructor(e){e?this.#e=e:this.#e=$o()}setSize(e,n){(this.#e.width!==e||this.#e.height!==n)&&(this.#e.width=e,this.#e.height=n)}}class nd extends Go{#e;constructor(e){super(e),this.#e=this.canvas.getContext("bitmaprenderer",{alpha:!1})}async draw(e){const n=await createImageBitmap(e);this.#e.transferFromImageBitmap(n)}}const rd=Promise.resolve();function Zr(t,e){const n={powerPreference:"low-power",alpha:!1,failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!!e};return t.getContext("webgl2",n)||t.getContext("webgl",n)}class pt extends Go{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=$o();return!!Zr(e)}#e;constructor(e,n){super(e);const r=Zr(this.canvas,n);if(!r)throw new Error("WebGL not supported");this.#e=r;const o=r.createShader(r.VERTEX_SHADER);if(r.shaderSource(o,pt.vertexShaderSource),r.compileShader(o),!r.getShaderParameter(o,r.COMPILE_STATUS))throw new Error(r.getShaderInfoLog(o));const s=r.createShader(r.FRAGMENT_SHADER);if(r.shaderSource(s,pt.fragmentShaderSource),r.compileShader(s),!r.getShaderParameter(s,r.COMPILE_STATUS))throw new Error(r.getShaderInfoLog(s));const i=r.createProgram();if(r.attachShader(i,o),r.attachShader(i,s),r.linkProgram(i),!r.getProgramParameter(i,r.LINK_STATUS))throw new Error(r.getProgramInfoLog(i));r.useProgram(i);const a=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,a),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW);const l=r.getAttribLocation(i,"xy");r.vertexAttribPointer(l,2,r.FLOAT,!1,0,0),r.enableVertexAttribArray(l);const f=r.createTexture();r.bindTexture(r.TEXTURE_2D,f),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE)}draw(e){const n=this.#e;return n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e),n.viewport(0,0,n.drawingBufferWidth,n.drawingBufferHeight),n.drawArrays(n.TRIANGLE_FAN,0,4),rd}}const es=50,sd=300;function od({deviceId:t,className:e,onFallback:n,fallbackTimeout:r=5e3,enableControl:o=!1,onTapSuccess:s,onTapError:i,onSwipeSuccess:a,onSwipeError:l,onStreamReady:f}){const d=u.useRef(null),h=u.useRef(null),g=u.useRef(null),p=u.useRef(null),_=u.useRef(null),m=u.useRef(null),v=u.useRef(null),y=u.useRef(!1),E=u.useRef(!1),x=u.useRef(n),b=u.useRef(r),C=u.useRef(f),[S,T]=u.useState("connecting"),[P,w]=u.useState(null),[N,R]=u.useState(null),[I,F]=u.useState(null),k=u.useRef(!1),A=u.useRef(null),D=u.useRef(!1),M=u.useRef(0),L=u.useRef(null),U=u.useRef(null),G=u.useRef(null),q=u.useRef(null);u.useEffect(()=>{x.current=n,b.current=r,C.current=f},[n,r,f]),u.useEffect(()=>{(async()=>{try{const j=await rs(t);j.success&&F({width:j.width,height:j.height})}catch(j){console.error("[ScrcpyPlayer] Failed to fetch device resolution:",j)}})()},[t]);const Y=u.useCallback(()=>{const O=p.current,j=g.current;if(!O||!j||!N)return;const W=j.clientWidth,V=j.clientHeight,{width:J,height:X}=N,H=J/X;let $=W,ne=W/H;ne>V&&(ne=V,$=V*H),O.width=J,O.height=X,O.style.width=`${$}px`,O.style.height=`${ne}px`},[N]);u.useEffect(()=>{const O=()=>Y();return window.addEventListener("resize",O),()=>window.removeEventListener("resize",O)},[Y]),u.useEffect(()=>{Y()},[N,Y]);const Z=u.useCallback(async()=>{if(pt.isSupported){const j=new pt;return{renderer:j,element:j.canvas}}const O=new nd;return{renderer:O,element:O.canvas}},[]),ee=u.useCallback(async O=>{if(!qr.isSupported)throw new Error("Current browser does not support WebCodecs API. Please use the latest Chrome/Edge.");const{renderer:j,element:W}=await Z();return p.current=W,g.current&&!W.parentElement&&g.current.appendChild(W),new qr({codec:O,renderer:j})},[Z]),se=u.useCallback(()=>{y.current||(y.current=!0,_.current&&(clearTimeout(_.current),_.current=null))},[]),he=u.useCallback(O=>{let j=!1,W=[];const V=new TransformStream({transform(X,H){if(X.type==="configuration"){H.enqueue(X),j=!0,W.length>0&&(W.forEach($=>H.enqueue($)),W=[]);return}if(X.type==="data"&&!j){W.push(X);return}H.enqueue(X)}});return new ReadableStream({start(X){let H=!1;const $=we=>{if(!H)try{se();const je={...we,data:we.data instanceof Uint8Array?we.data:new Uint8Array(we.data)};X.enqueue(je)}catch(je){console.error("[ScrcpyPlayer] Video enqueue error:",je),H=!0,Le()}},ne=we=>{H||(X.error(new Error(we?.message||"Socket error")),H=!0,Le())},qe=()=>{H||(X.close(),H=!0,Le())},Le=()=>{d.current?.off("video-data",$),d.current?.off("error",ne),d.current?.off("disconnect",qe)};return d.current?.on("video-data",$),d.current?.on("error",ne),d.current?.on("disconnect",qe),()=>{H=!0,Le()}}}).pipeThrough(V)},[se]),te=u.useCallback((O=!1)=>{if(O&&(E.current=!0),h.current){try{h.current.dispose()}catch(j){console.error("[ScrcpyPlayer] Failed to dispose decoder:",j)}h.current=null}p.current=null,d.current&&(d.current.disconnect(),d.current=null),C.current?.(null),m.current&&(clearTimeout(m.current),m.current=null),_.current&&(clearTimeout(_.current),_.current=null),T("disconnected"),R(null),w(null)},[]),ie=u.useCallback(()=>{te(!0),y.current=!1,T("connecting"),w(null);const O=Ot({path:"/socket.io",transports:["websocket"],timeout:1e4});d.current=O,O.on("connect",()=>{O.emit("connect-device",{device_id:t,maxSize:1280,bitRate:4e6}),_.current=setTimeout(()=>{y.current||(T("error"),w("Video stream timeout"),E.current=!0,O.close(),x.current?.())},b.current)}),O.on("video-metadata",async j=>{try{h.current&&(h.current.dispose(),h.current=null);const W=j?.codec?j.codec:Lt.H264;h.current=await ee(W),h.current.sizeChanged(({width:J,height:X})=>{R({width:J,height:X})}),he(j).pipeTo(h.current.writable).catch(J=>{console.error("[ScrcpyPlayer] Video stream error:",J)}),T("connected"),C.current?.({close:()=>O.close()})}catch(W){console.error("[ScrcpyPlayer] Decoder initialization failed:",W),T("error"),w("Decoder initialization failed"),E.current=!0,O.close(),x.current?.()}}),O.on("error",j=>{console.error("[ScrcpyPlayer] Socket error:",j),T("error"),w(j?.message||"Socket error")}),O.on("disconnect",()=>{if(E.current){E.current=!1;return}T("disconnected"),C.current?.(null),m.current||(m.current=setTimeout(()=>{m.current=null,v.current?.()},3e3))})},[t,te,ee,he]);u.useEffect(()=>{v.current=ie},[ie]),u.useEffect(()=>(queueMicrotask(()=>{ie()}),()=>{U.current&&(clearTimeout(U.current),U.current=null),G.current&&(clearTimeout(G.current),G.current=null),te(!0)}),[ie,te]);const K=()=>{if(N)return{width:N.width,height:N.height};const O=p.current;return O?{width:O.width,height:O.height}:null},pe=(O,j)=>{const W=p.current,V=K();if(!W||!V)return null;const J=W.getBoundingClientRect();if(O<J.left||O>J.right||j<J.top||j>J.bottom)return null;const X=O-J.left,H=j-J.top,$=Math.round(X/J.width*V.width),ne=Math.round(H/J.height*V.height),qe=I?I.width/V.width:1,Le=I?I.height/V.height:1;return{x:Math.round($*qe),y:Math.round(ne*Le)}},We=async O=>{if(!o||S!=="connected")return;const j=pe(O.clientX,O.clientY);if(j){k.current=!0,D.current=!1,A.current={x:O.clientX,y:O.clientY};try{await Jo(j.x,j.y,t)}catch(W){console.error("[ScrcpyPlayer] Touch down failed:",W)}}},De=O=>{if(!k.current||S!=="connected")return;const j=Date.now(),W=pe(O.clientX,O.clientY);if(W){if(A.current){const V=O.clientX-A.current.x,J=O.clientY-A.current.y;Math.hypot(V,J)>4&&(D.current=!0)}if(L.current=W,j-M.current<es){U.current||(U.current=setTimeout(()=>{U.current=null,L.current&&(lr(L.current.x,L.current.y,t).catch(V=>{console.error("[ScrcpyPlayer] Touch move failed:",V)}),L.current=null,M.current=Date.now())},es));return}M.current=j,lr(W.x,W.y,t).catch(V=>{console.error("[ScrcpyPlayer] Touch move failed:",V)})}},ge=async O=>{if(!k.current||S!=="connected")return;const j=pe(O.clientX,O.clientY);if(k.current=!1,A.current=null,!!j)try{await cr(j.x,j.y,t),D.current?a?.():s?.()}catch(W){const V=String(W);D.current?l?.(V):i?.(V)}},Oe=async O=>{if(!k.current||S!=="connected")return;const j=pe(O.clientX,O.clientY);if(k.current=!1,A.current=null,!!j)try{await cr(j.x,j.y,t)}catch(W){console.error("[ScrcpyPlayer] Touch cancel failed:",W)}},B=O=>{if(!o||S!=="connected")return;O.preventDefault();const j=O.deltaY;q.current||(q.current={deltaY:0}),q.current.deltaY+=j,G.current&&clearTimeout(G.current),G.current=setTimeout(async()=>{const W=q.current;if(q.current=null,!W)return;const V=p.current,J=K();if(!V||!J)return;const X=V.getBoundingClientRect(),H=X.left+X.width/2,$=X.top+X.height/2,ne=pe(H,$);if(!ne)return;const qe=Math.max(Math.min(W.deltaY,600),-600),Le=$+qe,we=pe(H,Le);if(we)try{const je=await Ko(ne.x,ne.y,we.x,we.y,300,t);je.success?a?.():l?.(je.error||"Scroll failed")}catch(je){l?.(String(je))}},sd)};return c.jsx("div",{className:`relative w-full h-full flex items-center justify-center ${e||""}`,children:c.jsx("div",{ref:g,className:"relative w-full h-full flex items-center justify-center bg-slate-50 dark:bg-slate-900",onMouseDown:We,onMouseMove:De,onMouseUp:ge,onMouseLeave:Oe,onWheel:B,children:S!=="connected"&&c.jsxs("div",{className:"absolute inset-0 flex items-center justify-center text-slate-400",children:[S==="connecting"&&"Connecting...",S==="error"&&(P||"Connection error"),S==="disconnected"&&"Disconnected"]})})})}const qo=u.forwardRef(({className:t,...e},n)=>c.jsx("textarea",{className:ce("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:n,...e}));qo.displayName="Textarea";const On=u.forwardRef(({className:t,...e},n)=>c.jsx("div",{ref:n,className:ce("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}));On.displayName="Card";const id=u.forwardRef(({className:t,...e},n)=>c.jsx("div",{ref:n,className:ce("flex flex-col space-y-1.5 p-6",t),...e}));id.displayName="CardHeader";const ad=u.forwardRef(({className:t,...e},n)=>c.jsx("h3",{ref:n,className:ce("text-xl font-semibold leading-none tracking-tight",t),...e}));ad.displayName="CardTitle";const cd=u.forwardRef(({className:t,...e},n)=>c.jsx("p",{ref:n,className:ce("text-sm text-slate-500 dark:text-slate-400",t),...e}));cd.displayName="CardDescription";const ld=u.forwardRef(({className:t,...e},n)=>c.jsx("div",{ref:n,className:ce("p-6 pt-0",t),...e}));ld.displayName="CardContent";const ud=u.forwardRef(({className:t,...e},n)=>c.jsx("div",{ref:n,className:ce("flex items-center p-6 pt-0",t),...e}));ud.displayName="CardFooter";function fd({deviceId:t,deviceName:e,config:n,isConfigured:r}){const o=Ut(),[s,i]=u.useState([]),[a,l]=u.useState(""),[f,d]=u.useState(!1),[h,g]=u.useState(null),[p,_]=u.useState(!1),[m,v]=u.useState(null),[y,E]=u.useState(!0),[x,b]=u.useState(!1),[C,S]=u.useState("auto"),[T,P]=u.useState(null),[w,N]=u.useState("success"),R=u.useRef(null),I=(B,O=2e3,j="success")=>{R.current&&clearTimeout(R.current),N(j),P(B),R.current=setTimeout(()=>{P(null)},O)};u.useEffect(()=>()=>{R.current&&clearTimeout(R.current)},[]);const[F,k]=u.useState(!1),[A,D]=u.useState(!1),M=u.useRef(null),L=()=>{M.current&&clearTimeout(M.current),k(!0)},U=()=>{M.current=setTimeout(()=>{k(!1)},500)};u.useEffect(()=>()=>{M.current&&clearTimeout(M.current)},[]);const G=()=>{D(B=>!B)},q=u.useRef(null),Y=u.useRef(null),Z=u.useRef(null),ee=u.useRef(!1),se=u.useRef(!1),he=u.useRef(null),te=u.useCallback(async()=>{if(n)try{await Qo({model_config:{base_url:n.base_url||void 0,api_key:n.api_key||void 0,model_name:n.model_name||void 0},agent_config:{device_id:t}}),_(!0),g(null)}catch(B){const O=B instanceof Error?B.message:"Initialization failed";g(O)}},[t,n]);u.useEffect(()=>{r&&n&&!p&&!se.current&&(se.current=!0,te())},[r,n,p,te]),u.useEffect(()=>{if(!p||!n)return;const B=he.current;B&&(B.base_url!==n.base_url||B.model_name!==n.model_name||B.api_key!==n.api_key)&&(console.log(`[DevicePanel] Config changed for device ${t}, re-initializing...`),te()),he.current=n},[n,p,t,te]);const ie=u.useCallback(async()=>{const B=a.trim();if(!B||f)return;p||await te();const O={id:Date.now().toString(),role:"user",content:B,timestamp:new Date};i(H=>[...H,O]),l(""),d(!0),g(null);const j=[],W=[],V=(Date.now()+1).toString(),J={id:V,role:"agent",content:"",timestamp:new Date,thinking:[],actions:[],isStreaming:!0};i(H=>[...H,J]);const X=Zo(O.content,t,H=>{j.push(H.thinking),W.push(H.action),i($=>$.map(ne=>ne.id===V?{...ne,thinking:[...j],actions:[...W],steps:H.step}:ne))},H=>{i($=>$.map(ne=>ne.id===V?{...ne,content:H.message,success:H.success,isStreaming:!1}:ne)),d(!1),q.current=null},H=>{i($=>$.map(ne=>ne.id===V?{...ne,content:`Error: ${H.message}`,success:!1,isStreaming:!1}:ne)),d(!1),g(H.message),q.current=null});q.current=X},[a,f,p,t,te]),K=u.useCallback(async()=>{q.current&&q.current.close(),i([]),d(!1),g(null),q.current=null,await ei(t)},[t]),pe=()=>{Z.current?.scrollIntoView({behavior:"smooth"})};u.useEffect(()=>{pe()},[s]),u.useEffect(()=>()=>{q.current&&q.current.close(),Y.current&&Y.current.close()},[t]),u.useEffect(()=>{if(!t||!(C==="screenshot"||C==="auto"&&x))return;const O=async()=>{if(!ee.current){ee.current=!0;try{const W=await rs(t);W.success&&v(W)}catch(W){console.error("Failed to fetch screenshot:",W)}finally{ee.current=!1}}};O();const j=setInterval(O,500);return()=>clearInterval(j)},[t,x,C]);const We=B=>{(B.metaKey||B.ctrlKey)&&B.key==="Enter"&&(B.preventDefault(),ie())},De=u.useCallback(B=>{Y.current=B},[]),ge=u.useCallback(()=>{b(!0),E(!1)},[]),Oe=B=>{S(B)};return c.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[c.jsxs(On,{className:"flex-1 flex flex-col min-h-0 max-w-2xl",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:c.jsx(Qt,{className:"h-5 w-5 text-[#1d9bf0]"})}),c.jsxs("div",{children:[c.jsx("h2",{className:"font-bold text-slate-900 dark:text-slate-100",children:e}),c.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 font-mono",children:t})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[r?p?c.jsxs(Tt,{variant:"success",children:[c.jsx(lt,{className:"w-3 h-3 mr-1"}),o.devicePanel.ready]}):c.jsx(oe,{onClick:te,disabled:!r||!n,size:"sm",variant:"twitter",children:o.devicePanel.initializing}):c.jsxs(Tt,{variant:"warning",children:[c.jsx(at,{className:"w-3 h-3 mr-1"}),o.devicePanel.noConfig]}),c.jsx(oe,{variant:"ghost",size:"icon",onClick:K,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:c.jsx(Ai,{className:"h-4 w-4"})})]})]}),h&&c.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:[c.jsx(at,{className:"w-4 h-4 flex-shrink-0"}),h]}),c.jsxs("div",{className:"flex-1 overflow-y-auto p-4 min-h-0",children:[s.length===0?c.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center min-h-[calc(100%-1rem)]",children:[c.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800 mb-4",children:c.jsx(Qt,{className:"h-8 w-8 text-slate-400"})}),c.jsx("p",{className:"font-medium text-slate-900 dark:text-slate-100",children:o.devicePanel.readyToHelp}),c.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:o.devicePanel.describeTask})]}):s.map(B=>c.jsx("div",{className:`flex ${B.role==="user"?"justify-end":"justify-start"}`,children:B.role==="agent"?c.jsxs("div",{className:"max-w-[85%] space-y-3",children:[B.thinking?.map((O,j)=>c.jsxs("div",{className:"bg-slate-100 dark:bg-slate-800 rounded-2xl rounded-tl-sm px-4 py-3",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:c.jsx(Qt,{className:"h-3 w-3 text-[#1d9bf0]"})}),c.jsxs("span",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:["Step ",j+1]})]}),c.jsx("p",{className:"text-sm whitespace-pre-wrap text-slate-700 dark:text-slate-300",children:O}),B.actions?.[j]&&c.jsxs("details",{className:"mt-2 text-xs",children:[c.jsx("summary",{className:"cursor-pointer text-[#1d9bf0] hover:text-[#1a8cd8]",children:"View action"}),c.jsx("pre",{className:"mt-2 p-2 bg-slate-900 text-slate-200 rounded-lg overflow-x-auto text-xs",children:JSON.stringify(B.actions[j],null,2)})]})]},j)),B.content&&c.jsxs("div",{className:`
147
+ rounded-2xl px-4 py-3 flex items-start gap-2
148
+ ${B.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:[c.jsx(lt,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${B.success===!1?"text-red-500":"text-green-500"}`}),c.jsxs("div",{children:[c.jsx("p",{className:"whitespace-pre-wrap",children:B.content}),B.steps!==void 0&&c.jsxs("p",{className:"text-xs mt-2 opacity-60 text-slate-500 dark:text-slate-400",children:[B.steps," steps completed"]})]})]}),B.isStreaming&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 dark:text-slate-400",children:[c.jsx(ut,{className:"w-4 h-4 animate-spin"}),"Processing..."]})]}):c.jsxs("div",{className:"max-w-[75%]",children:[c.jsx("div",{className:"chat-bubble-user px-4 py-3",children:c.jsx("p",{className:"whitespace-pre-wrap text-white dark:text-white",children:B.content})}),c.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-1 text-right",children:B.timestamp.toLocaleTimeString()})]})},B.id)),c.jsx("div",{ref:Z})]}),c.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800",children:c.jsxs("div",{className:"flex items-end gap-3",children:[c.jsx(qo,{value:a,onChange:B=>l(B.target.value),onKeyDown:We,placeholder:r?p?o.devicePanel.whatToDo:o.devicePanel.initDeviceFirst:o.devicePanel.configureFirst,disabled:f,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),c.jsx(oe,{onClick:ie,disabled:f||!a.trim(),size:"icon",variant:"twitter",className:"h-10 w-10 rounded-full flex-shrink-0",children:f?c.jsx(ut,{className:"h-4 w-4 animate-spin"}):c.jsx(Oi,{className:"h-4 w-4"})})]})})]}),c.jsxs(On,{className:"w-[320px] flex-shrink-0 relative min-h-0 overflow-hidden bg-background",onMouseEnter:L,onMouseLeave:U,children:[c.jsx("div",{className:`absolute top-4 right-4 z-10 transition-opacity duration-200 ${F?"opacity-100":"opacity-0 pointer-events-none"}`,children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.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 ${A?"opacity-100 translate-x-0":"opacity-0 translate-x-4 pointer-events-none"}`,children:[c.jsx(oe,{variant:"ghost",size:"sm",onClick:()=>Oe("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}),c.jsxs(oe,{variant:"ghost",size:"sm",onClick:()=>Oe("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:[c.jsx(Ui,{className:"w-3 h-3 mr-1"}),o.devicePanel.video]}),c.jsxs(oe,{variant:"ghost",size:"sm",onClick:()=>Oe("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:[c.jsx(ur,{className:"w-3 h-3 mr-1"}),o.devicePanel.image]})]}),c.jsx(oe,{variant:"ghost",size:"icon",onClick:G,className:"h-8 w-8 rounded-full bg-popover/90 backdrop-blur border border-border shadow-lg hover:bg-accent",title:A?"Hide controls":"Show controls",children:A?c.jsx(os,{className:"w-4 h-4"}):c.jsx(ss,{className:"w-4 h-4"})})]})}),c.jsx("div",{className:"absolute bottom-4 left-4 z-10",children:c.jsxs(Tt,{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"&&c.jsxs(c.Fragment,{children:[c.jsx(Ti,{className:"w-3 h-3 mr-1"}),o.devicePanel.video]}),C==="screenshot"&&c.jsxs(c.Fragment,{children:[c.jsx(ur,{className:"w-3 h-3 mr-1"}),o.devicePanel.imageRefresh]})]})}),T&&c.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:[w==="error"&&c.jsx(at,{className:"w-4 h-4"}),w==="tap"&&c.jsx(vi,{className:"w-4 h-4"}),w==="swipe"&&c.jsx(ai,{className:"w-4 h-4"}),w==="success"&&c.jsx(lt,{className:"w-4 h-4"}),c.jsx("span",{children:T})]}),C==="video"||C==="auto"&&y&&!x?c.jsx(od,{deviceId:t,className:"w-full h-full",enableControl:!0,onFallback:ge,onTapSuccess:()=>I(o.devicePanel.tapped,2e3,"tap"),onTapError:B=>I(o.devicePanel.tapError.replace("{error}",B),3e3,"error"),onSwipeSuccess:()=>I(o.devicePanel.swiped,2e3,"swipe"),onSwipeError:B=>I(o.devicePanel.swipeError.replace("{error}",B),3e3,"error"),onStreamReady:De,fallbackTimeout:1e5}):c.jsx("div",{className:"w-full h-full flex items-center justify-center bg-muted/30 min-h-0",children:m&&m.success?c.jsxs("div",{className:"relative w-full h-full flex items-center justify-center min-h-0",children:[c.jsx("img",{src:`data:image/png;base64,${m.image}`,alt:"Device Screenshot",className:"max-w-full max-h-full object-contain",style:{width:m.width>m.height?"100%":"auto",height:m.width>m.height?"auto":"100%"}}),m.is_sensitive&&c.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})]}):m?.error?c.jsxs("div",{className:"text-center text-destructive",children:[c.jsx(at,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"font-medium",children:o.devicePanel.screenshotFailed}),c.jsx("p",{className:"text-xs mt-1 opacity-60",children:m.error})]}):c.jsxs("div",{className:"text-center text-muted-foreground",children:[c.jsx(ut,{className:"w-8 h-8 mx-auto mb-2 animate-spin"}),c.jsx("p",{className:"text-sm",children:o.devicePanel.loading})]})})]})]})}function dd({message:t,type:e="info",onClose:n,duration:r=3e3}){u.useEffect(()=>{const i=setTimeout(()=>{n()},r);return()=>clearTimeout(i)},[r,n]);const o={success:"bg-green-500",error:"bg-red-500",info:"bg-blue-500"},s={success:c.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})}),error:c.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})}),info:c.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 c.jsx("div",{className:"fixed top-4 left-1/2 transform -translate-x-1/2 z-50 animate-fade-in-down",children:c.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],c.jsx("span",{className:"font-medium",children:t}),c.jsx("button",{onClick:n,className:"ml-auto hover:bg-white/20 rounded-full p-1 transition-colors",children:c.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]})})}const hd=[{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 _d(){const t=Ut(),[e,n]=u.useState([]),[r,o]=u.useState(""),[s,i]=u.useState({message:"",type:"info",visible:!1}),a=(x,b="info")=>{i({message:x,type:b,visible:!0})},[l,f]=u.useState(null),[d,h]=u.useState(!1),[g,p]=u.useState(!1),[_,m]=u.useState({base_url:"",model_name:"",api_key:""});u.useEffect(()=>{(async()=>{try{const b=await ti();f({base_url:b.base_url,model_name:b.model_name,api_key:b.api_key||void 0}),m({base_url:b.base_url,model_name:b.model_name,api_key:b.api_key||""}),b.base_url||h(!0)}catch(b){console.error("Failed to load config:",b),h(!0)}})()},[]),u.useEffect(()=>{const x=async()=>{try{const C=await ni(),S=new Map,T=new Map;for(const w of C.devices)if(w.serial){const N=T.get(w.serial)||[];N.push(w),T.set(w.serial,N)}else S.set(w.id,w);Array.from(T.values()).forEach(w=>{const R=w.find(I=>I.connection_type==="remote")||w[0];S.set(R.id,R)});const P=Array.from(S.values());n(P),P.length>0&&!r&&o(P[0].id),r&&!P.find(w=>w.id===r)&&o(P[0]?.id||"")}catch(C){console.error("Failed to load devices:",C)}};x();const b=setInterval(x,3e3);return()=>clearInterval(b)},[r]);const v=async()=>{if(!_.base_url){a(t.chat.baseUrlRequired,"error");return}try{await ri({base_url:_.base_url,model_name:_.model_name||"autoglm-phone-9b",api_key:_.api_key||void 0}),f({base_url:_.base_url,model_name:_.model_name,api_key:_.api_key||void 0}),h(!1),a(t.toasts.configSaved,"success")}catch(x){console.error("Failed to save config:",x),a(`Failed to save: ${x instanceof Error?x.message:"Unknown error"}`,"error")}},y=async x=>{try{const b=await oi({device_id:x});b.success&&b.device_id?(o(b.device_id),a(t.toasts.wifiConnected,"success")):b.success||a(b.message||b.error||t.toasts.connectionFailed,"error")}catch(b){a(t.toasts.wifiConnectionError,"error"),console.error("Connect WiFi error:",b)}},E=async x=>{try{const b=await si(x);b.success?a(t.toasts.wifiDisconnected,"success"):a(b.message||b.error||t.toasts.disconnectFailed,"error")}catch(b){a(t.toasts.wifiDisconnectError,"error"),console.error("Disconnect WiFi error:",b)}};return c.jsxs("div",{className:"h-full flex relative min-h-0",children:[s.visible&&c.jsx(dd,{message:s.message,type:s.type,onClose:()=>i(x=>({...x,visible:!1}))}),c.jsx($s,{open:d,onOpenChange:h,children:c.jsxs(Un,{className:"sm:max-w-md",children:[c.jsxs(Wn,{children:[c.jsxs($n,{className:"flex items-center gap-2",children:[c.jsx(is,{className:"w-5 h-5 text-[#1d9bf0]"}),t.chat.configuration]}),c.jsx(Gn,{children:t.chat.configureApi})]}),c.jsxs("div",{className:"space-y-4 py-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(He,{className:"text-sm font-medium",children:t.chat.selectPreset}),c.jsx("div",{className:"grid grid-cols-1 gap-2",children:hd.map(x=>c.jsxs("div",{className:"relative",children:[c.jsxs("button",{type:"button",onClick:()=>m({base_url:x.config.base_url,model_name:x.config.model_name,api_key:x.config.api_key}),className:`w-full text-left p-3 rounded-lg border transition-all ${_.base_url===x.config.base_url&&(x.name!=="custom"||x.name==="custom"&&_.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:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ji,{className:`w-4 h-4 ${_.base_url===x.config.base_url&&(x.name!=="custom"||x.name==="custom"&&_.base_url==="")?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),c.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:t.presetConfigs[x.name].name})]}),c.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 ml-6",children:t.presetConfigs[x.name].description})]}),"apiKeyUrl"in x&&c.jsx("a",{href:x.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:c.jsx(hi,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-[#1d9bf0] transition-colors"})})]},x.name))})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs(He,{htmlFor:"base_url",children:[t.chat.baseUrl," *"]}),c.jsx(Je,{id:"base_url",value:_.base_url,onChange:x=>m({..._,base_url:x.target.value}),placeholder:"http://localhost:8080/v1"}),!_.base_url&&c.jsxs("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[c.jsx(at,{className:"w-3 h-3"}),t.chat.baseUrlRequired]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(He,{htmlFor:"api_key",children:t.chat.apiKey}),c.jsxs("div",{className:"relative",children:[c.jsx(Je,{id:"api_key",type:g?"text":"password",value:_.api_key,onChange:x=>m({..._,api_key:x.target.value}),placeholder:"Leave empty if not required",className:"pr-10"}),c.jsx(oe,{type:"button",variant:"ghost",size:"icon",onClick:()=>p(!g),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:g?c.jsx(mi,{className:"w-4 h-4 text-slate-400"}):c.jsx(_i,{className:"w-4 h-4 text-slate-400"})})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(He,{htmlFor:"model_name",children:t.chat.modelName}),c.jsx(Je,{id:"model_name",value:_.model_name,onChange:x=>m({..._,model_name:x.target.value}),placeholder:"autoglm-phone-9b"})]})]}),c.jsxs(Hn,{className:"sm:justify-between gap-2",children:[c.jsx(oe,{variant:"outline",onClick:()=>{h(!1),l&&m({base_url:l.base_url,model_name:l.model_name,api_key:l.api_key||""})},children:t.chat.cancel}),c.jsxs(oe,{onClick:v,variant:"twitter",children:[c.jsx(lt,{className:"w-4 h-4 mr-2"}),t.chat.saveConfig]})]})]})}),c.jsx(Ru,{devices:e,currentDeviceId:r,onSelectDevice:o,onOpenConfig:()=>h(!0),onConnectWifi:y,onDisconnectWifi:E}),c.jsx("div",{className:"flex-1 flex items-stretch justify-center min-h-0 px-4 py-4",children:e.length===0?c.jsx("div",{className:"flex-1 flex items-center justify-center bg-slate-50 dark:bg-slate-950",children:c.jsxs("div",{className:"text-center",children:[c.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:c.jsx("svg",{className:"w-10 h-10 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.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"})})}),c.jsx("h3",{className:"text-lg font-semibold text-slate-900 dark:text-slate-100 mb-2",children:t.chat.welcomeTitle}),c.jsx("p",{className:"text-slate-500 dark:text-slate-400",children:t.chat.connectDevice})]})}):e.map(x=>c.jsx("div",{className:`w-full max-w-7xl flex items-stretch justify-center min-h-0 ${x.id===r?"":"hidden"}`,children:c.jsx(fd,{deviceId:x.id,deviceName:x.model,config:l,isVisible:x.id===r,isConfigured:!!l?.base_url})},x.id))})]})}export{_d as component};