autoglm-gui 1.5.5__py3-none-any.whl → 1.5.6__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 (39) hide show
  1. AutoGLM_GUI/api/agents.py +118 -93
  2. AutoGLM_GUI/api/devices.py +177 -0
  3. AutoGLM_GUI/api/scheduled_tasks.py +7 -2
  4. AutoGLM_GUI/device_group_manager.py +354 -0
  5. AutoGLM_GUI/models/__init__.py +8 -0
  6. AutoGLM_GUI/models/device_group.py +63 -0
  7. AutoGLM_GUI/models/scheduled_task.py +47 -4
  8. AutoGLM_GUI/scheduler_manager.py +255 -80
  9. AutoGLM_GUI/schemas.py +148 -3
  10. AutoGLM_GUI/static/assets/{about-BwLRPh96.js → about-DVviVdH2.js} +1 -1
  11. AutoGLM_GUI/static/assets/{alert-dialog-BvDNaR9v.js → alert-dialog-IHmO2JCQ.js} +1 -1
  12. AutoGLM_GUI/static/assets/chat-C_3D0Ao7.js +134 -0
  13. AutoGLM_GUI/static/assets/{dialog-IM0Ds7Lf.js → dialog-DOpd71Lu.js} +3 -3
  14. AutoGLM_GUI/static/assets/{eye-BWBwz8sy.js → eye-CZP5ZJ_Y.js} +1 -1
  15. AutoGLM_GUI/static/assets/folder-open-_KlT8ZW7.js +1 -0
  16. AutoGLM_GUI/static/assets/{history-BkQlPjpV.js → history-BXMlCwUV.js} +1 -1
  17. AutoGLM_GUI/static/assets/index-84TrNz7w.css +1 -0
  18. AutoGLM_GUI/static/assets/index-Bh2f556h.js +1 -0
  19. AutoGLM_GUI/static/assets/index-DUNWZsFq.js +11 -0
  20. AutoGLM_GUI/static/assets/{label-CmQFo_IT.js → label-CRZhpiYG.js} +1 -1
  21. AutoGLM_GUI/static/assets/logs-DEN9nDRS.js +1 -0
  22. AutoGLM_GUI/static/assets/popover-DitUZhUk.js +1 -0
  23. AutoGLM_GUI/static/assets/scheduled-tasks-boxDKe87.js +1 -0
  24. AutoGLM_GUI/static/assets/{textarea-BlKvI11g.js → textarea-CvRHzjfV.js} +1 -1
  25. AutoGLM_GUI/static/assets/{workflows-CRq1fJf5.js → workflows-Bg3qN-6j.js} +1 -1
  26. AutoGLM_GUI/static/index.html +2 -2
  27. {autoglm_gui-1.5.5.dist-info → autoglm_gui-1.5.6.dist-info}/METADATA +355 -6
  28. {autoglm_gui-1.5.5.dist-info → autoglm_gui-1.5.6.dist-info}/RECORD +31 -29
  29. AutoGLM_GUI/static/assets/chat-DAmrsouh.js +0 -129
  30. AutoGLM_GUI/static/assets/circle-alert-C8768IhH.js +0 -1
  31. AutoGLM_GUI/static/assets/index-B0fISVXF.js +0 -1
  32. AutoGLM_GUI/static/assets/index-CH4jPveL.js +0 -11
  33. AutoGLM_GUI/static/assets/index-DSIMVL8V.css +0 -1
  34. AutoGLM_GUI/static/assets/logs-ChcSA2r_.js +0 -1
  35. AutoGLM_GUI/static/assets/popover-BnpBfSOh.js +0 -1
  36. AutoGLM_GUI/static/assets/scheduled-tasks-BwgoPEdP.js +0 -1
  37. {autoglm_gui-1.5.5.dist-info → autoglm_gui-1.5.6.dist-info}/WHEEL +0 -0
  38. {autoglm_gui-1.5.5.dist-info → autoglm_gui-1.5.6.dist-info}/entry_points.txt +0 -0
  39. {autoglm_gui-1.5.5.dist-info → autoglm_gui-1.5.6.dist-info}/licenses/LICENSE +0 -0
@@ -1,129 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CH4jPveL.js","assets/index-DSIMVL8V.css"])))=>i.map(i=>d[i]);
2
- import{o as $e,j as o,u as An,r as E,T as en,t as tn,v as nn,B as we,f as Hn,w as vx,x as bx,y as Xs,R as Ye,z as xn,A as jc,D as du,P as Vt,E as _t,G as fu,H as Rn,I as Br,b as cr,J as As,K as yx,L as wx,M as Ex,N as Sx,O as Nx,S as Tr,Q as Pc,U as Cx,V as Tx,W as Rx,X as hu,Y as kx,Z as Mc,_ as Ic,$ as Ax,a0 as jx,a1 as Px,a2 as Mx,a3 as Ix,a4 as Fs,a5 as pu,p as mu,l as gu,q as _u,s as xu,a6 as vu,a7 as Lx,a8 as Dx,a9 as Ox,aa as Bx,ab as Fx,ac as Ux,ad as Wx,ae as Hx,af as Gx,ag as zx}from"./index-CH4jPveL.js";import{L as Yt,T as bu,D as Fo,d as Uo,e as Wo,f as Ho,h as Go,g as zo,C as Ys,X as qx}from"./dialog-IM0Ds7Lf.js";import{S as $x,L as nt,I as ht,P as yu}from"./label-CmQFo_IT.js";import{C as wu,E as mo}from"./eye-BWBwz8sy.js";import{C as _n}from"./circle-alert-C8768IhH.js";import{C as Lc,a as Dc,P as Us,c as Ws,d as Hs,b as Xx}from"./popover-BnpBfSOh.js";import{T as Eu}from"./textarea-BlKvI11g.js";const Yx=[["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"}]],Vx=$e("arrow-up-down",Yx);const Kx=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Su=$e("brain",Kx);const Qx=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Nu=$e("chevron-left",Qx);const Jx=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Zx=$e("chevron-up",Jx);const ev=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Fr=$e("circle-check",ev);const tv=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],nv=$e("cpu",tv);const rv=[["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"}]],Oc=$e("external-link",rv);const sv=[["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"}]],Bc=$e("eye-off",sv);const iv=[["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"}]],ov=$e("fingerprint-pattern",iv);const av=[["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"}]],Fc=$e("image",av);const lv=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],cv=$e("info",lv);const uv=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Ro=$e("layers",uv);const dv=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],fv=$e("maximize",dv);const hv=[["path",{d:"M5 12h14",key:"1ays0h"}]],pv=$e("minus",hv);const mv=[["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"}]],gv=$e("monitor-play",mv);const _v=[["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"}]],xv=$e("plug",_v);const vv=[["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"}]],Cu=$e("rotate-ccw",vv);const bv=[["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"}]],Tu=$e("send",bv);const yv=[["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"}]],ko=$e("server",yv);const wv=[["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"}]],Ru=$e("settings",wv);const Ev=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Ms=$e("smartphone",Ev);const Sv=[["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"}]],jr=$e("sparkles",Sv);const Nv=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ku=$e("square",Nv);const Cv=[["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"}]],Tv=$e("video",Cv);const Rv=[["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"}]],kv=$e("wifi-off",Rv);const Av=[["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"}]],Gs=$e("wifi",Av);const jv=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Pv=$e("wrench",jv);function Uc({isOpen:i,title:n,content:r,onConfirm:a,onCancel:d,confirmText:l="确认",cancelText:_="取消"}){return i?o.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:o.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:v=>v.stopPropagation(),children:[o.jsxs("div",{className:"p-6",children:[o.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:n}),o.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm leading-relaxed whitespace-pre-wrap",children:r})]}),o.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 px-6 py-4 flex justify-end gap-3",children:[o.jsx("button",{onClick:v=>{v.stopPropagation(),d()},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:_}),o.jsx("button",{onClick:v=>{v.stopPropagation(),a()},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:l})]})]})}):null}function Mv({id:i,serial:n,model:r,status:a,connectionType:d,displayName:l,agent:_,isActive:v,onClick:u,onConnectWifi:m,onDisconnectWifi:p,onNameUpdated:x,showToast:y}){const b=An(),N=a==="device",M=d==="usb",A=d==="wifi",O=d==="remote",[L,P]=E.useState(!1),[j,z]=E.useState(!1),[Q,q]=E.useState(!1),[Y,B]=E.useState(!1),[C,R]=E.useState(""),[se,_e]=E.useState(!1),$=l||r||b.deviceCard.unknownDevice,X=()=>{if(!N||!_)return"status-agent-none";switch(_.state){case"idle":return"status-agent-idle";case"busy":return"status-agent-busy";case"error":return"status-agent-error";case"initializing":return"status-agent-initializing";default:return"status-agent-none"}},K=()=>{if(!N||!_)return b.deviceCard.statusTooltip.none;switch(_.state){case"idle":return b.deviceCard.statusTooltip.idle;case"busy":return b.deviceCard.statusTooltip.busy;case"error":return b.deviceCard.statusTooltip.error;case"initializing":return b.deviceCard.statusTooltip.initializing;default:return b.deviceCard.statusTooltip.none}},ne=ie=>{ie.stopPropagation(),!(L||!m)&&z(!0)},oe=ie=>{ie.stopPropagation(),!(L||!p)&&q(!0)},ke=async()=>{z(!1),P(!0);try{m&&await m()}finally{P(!1)}},G=async()=>{q(!1),P(!0);try{p&&await p()}finally{P(!1)}},J=ie=>{ie.stopPropagation(),R(l||r||""),B(!0)},ue=async()=>{try{_e(!0);const ie=C.trim(),Se=await bx(n,ie||null);if(!Se.success){y&&y(Se.error||b.deviceCard.saveNameError,"error");return}B(!1),x&&x(),y&&y(b.deviceCard.saveNameSuccess,"success")}catch(ie){console.error("Failed to update device name:",ie),y&&y(b.deviceCard.saveNameError,"error")}finally{_e(!1)}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{onClick:u,role:"button",tabIndex:0,onKeyDown:ie=>{(ie.key==="Enter"||ie.key===" ")&&u()},className:`
3
- group relative w-full text-left p-4 rounded-xl transition-all duration-200 cursor-pointer
4
- border-2
5
- ${v?"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"}
6
- `,children:[v&&o.jsx("div",{className:"absolute left-0 top-2 bottom-2 w-1 bg-[#1d9bf0] rounded-r"}),o.jsxs("div",{className:"flex items-center gap-3 pl-2",children:[o.jsxs(en,{children:[o.jsx(tn,{asChild:!0,children:o.jsx("div",{className:`relative flex-shrink-0 ${X()} w-3 h-3 rounded-full transition-all cursor-help ${v?"scale-110":""}`})}),o.jsx(nn,{side:"right",sideOffset:8,className:"max-w-xs",children:o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("p",{className:"font-medium",children:[b.deviceCard.statusTooltip.title,K()]}),o.jsxs("div",{className:"text-xs opacity-80 space-y-0.5",children:[o.jsx("p",{children:b.deviceCard.statusTooltip.legend.green}),o.jsx("p",{children:b.deviceCard.statusTooltip.legend.yellow}),o.jsx("p",{children:b.deviceCard.statusTooltip.legend.red}),o.jsx("p",{children:b.deviceCard.statusTooltip.legend.gray})]})]})})]}),o.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-0.5",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ms,{className:`w-4 h-4 flex-shrink-0 ${v?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),o.jsx("span",{className:`font-semibold text-sm truncate ${v?"text-slate-900 dark:text-slate-100":"text-slate-700 dark:text-slate-300"}`,children:$}),o.jsxs(en,{children:[o.jsx(tn,{asChild:!0,children:o.jsx(we,{variant:"ghost",size:"icon",onClick:J,className:"h-5 w-5 text-slate-400 hover:text-[#1d9bf0] opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx($x,{className:"w-3 h-3"})})}),o.jsx(nn,{children:o.jsx("p",{children:b.deviceCard.editName})})]})]}),o.jsx("span",{className:`text-xs font-mono truncate ${v?"text-slate-500 dark:text-slate-400":"text-slate-400 dark:text-slate-500"}`,children:n})]}),o.jsx("div",{className:"flex-shrink-0 flex flex-col items-end gap-1",children:O?o.jsxs(Hn,{variant:"outline",className:"text-xs border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",children:[o.jsx(ko,{className:"w-2.5 h-2.5 mr-1"}),b.deviceCard.remote||"Remote"]}):A?o.jsxs(Hn,{variant:"outline",className:"text-xs border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",children:[o.jsx(Gs,{className:"w-2.5 h-2.5 mr-1"}),b.deviceCard.wifi||"WiFi"]}):M?o.jsx(Hn,{variant:"outline",className:"text-xs border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",children:"USB"}):null}),o.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[m&&M&&o.jsxs(en,{children:[o.jsx(tn,{asChild:!0,children:o.jsx(we,{variant:"ghost",size:"icon",onClick:ne,disabled:L,className:"h-7 w-7 text-slate-400 hover:text-[#1d9bf0]",children:L?o.jsx(Yt,{className:"w-3.5 h-3.5 animate-spin"}):o.jsx(Gs,{className:"w-3.5 h-3.5"})})}),o.jsx(nn,{children:o.jsx("p",{children:b.deviceCard.connectViaWifi})})]}),p&&A&&o.jsxs(en,{children:[o.jsx(tn,{asChild:!0,children:o.jsx(we,{variant:"ghost",size:"icon",onClick:oe,disabled:L,className:"h-7 w-7 text-slate-400 hover:text-orange-500",children:L?o.jsx(Yt,{className:"w-3.5 h-3.5 animate-spin"}):o.jsx(kv,{className:"w-3.5 h-3.5"})})}),o.jsx(nn,{children:o.jsx("p",{children:b.deviceCard.disconnectWifi})})]}),O&&o.jsx(we,{variant:"ghost",size:"icon",onClick:async ie=>{ie.stopPropagation(),P(!0);try{await vx(n)}catch(Se){console.error("Failed to remove remote device:",Se)}finally{P(!1)}},disabled:L,className:"h-7 w-7 text-slate-400 hover:text-red-500",title:b.deviceCard.removeRemote||"移除远程设备",children:L?o.jsx(Yt,{className:"w-3.5 h-3.5 animate-spin"}):o.jsx(bu,{className:"w-3.5 h-3.5"})})]})]})]}),o.jsx(Uc,{isOpen:j,title:b.deviceCard.connectWifiTitle,content:b.deviceCard.connectWifiContent,onConfirm:ke,onCancel:()=>z(!1)}),o.jsx(Uc,{isOpen:Q,title:b.deviceCard.disconnectWifiTitle,content:b.deviceCard.disconnectWifiContent,onConfirm:G,onCancel:()=>q(!1)}),o.jsx(Fo,{open:Y,onOpenChange:B,children:o.jsxs(Uo,{className:"sm:max-w-md",children:[o.jsxs(Wo,{children:[o.jsx(Ho,{children:b.deviceCard.editNameDialogTitle}),o.jsx(Go,{children:b.deviceCard.editNameDialogDescription})]}),o.jsx("div",{className:"space-y-4 py-4",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{htmlFor:"device-name",children:b.deviceCard.deviceNameLabel}),o.jsx(ht,{id:"device-name",value:C,onChange:ie=>R(ie.target.value),placeholder:b.deviceCard.deviceNamePlaceholder,maxLength:100,onKeyDown:ie=>{ie.key==="Enter"&&!se&&ue()}}),o.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[b.deviceCard.deviceSerialLabel,": ",n]})]})}),o.jsxs(zo,{children:[o.jsx(we,{variant:"outline",onClick:()=>B(!1),disabled:se,children:b.common.cancel}),o.jsx(we,{onClick:ue,disabled:se,children:se?o.jsxs(o.Fragment,{children:[o.jsx(Yt,{className:"w-4 h-4 mr-2 animate-spin"}),b.common.loading]}):b.common.save})]})]})})]})}function Iv(i){const n=i+"CollectionProvider",[r,a]=Xs(n),[d,l]=r(n,{collectionRef:{current:null},itemMap:new Map}),_=M=>{const{scope:A,children:O}=M,L=Ye.useRef(null),P=Ye.useRef(new Map).current;return o.jsx(d,{scope:A,itemMap:P,collectionRef:L,children:O})};_.displayName=n;const v=i+"CollectionSlot",u=jc(v),m=Ye.forwardRef((M,A)=>{const{scope:O,children:L}=M,P=l(v,O),j=xn(A,P.collectionRef);return o.jsx(u,{ref:j,children:L})});m.displayName=v;const p=i+"CollectionItemSlot",x="data-radix-collection-item",y=jc(p),b=Ye.forwardRef((M,A)=>{const{scope:O,children:L,...P}=M,j=Ye.useRef(null),z=xn(A,j),Q=l(p,O);return Ye.useEffect(()=>(Q.itemMap.set(j,{ref:j,...P}),()=>void Q.itemMap.delete(j))),o.jsx(y,{[x]:"",ref:z,children:L})});b.displayName=p;function N(M){const A=l(i+"CollectionConsumer",M);return Ye.useCallback(()=>{const L=A.collectionRef.current;if(!L)return[];const P=Array.from(L.querySelectorAll(`[${x}]`));return Array.from(A.itemMap.values()).sort((Q,q)=>P.indexOf(Q.ref.current)-P.indexOf(q.ref.current))},[A.collectionRef,A.itemMap])}return[{Provider:_,Slot:m,ItemSlot:b},N,a]}var Lv=E.createContext(void 0);function qo(i){const n=E.useContext(Lv);return i||n||"ltr"}var go="rovingFocusGroup.onEntryFocus",Dv={bubbles:!1,cancelable:!0},Ur="RovingFocusGroup",[Ao,Au,Ov]=Iv(Ur),[Bv,ju]=Xs(Ur,[Ov]),[Fv,Uv]=Bv(Ur),Pu=E.forwardRef((i,n)=>o.jsx(Ao.Provider,{scope:i.__scopeRovingFocusGroup,children:o.jsx(Ao.Slot,{scope:i.__scopeRovingFocusGroup,children:o.jsx(Wv,{...i,ref:n})})}));Pu.displayName=Ur;var Wv=E.forwardRef((i,n)=>{const{__scopeRovingFocusGroup:r,orientation:a,loop:d=!1,dir:l,currentTabStopId:_,defaultCurrentTabStopId:v,onCurrentTabStopIdChange:u,onEntryFocus:m,preventScrollOnEntryFocus:p=!1,...x}=i,y=E.useRef(null),b=xn(n,y),N=qo(l),[M,A]=fu({prop:_,defaultProp:v??null,onChange:u,caller:Ur}),[O,L]=E.useState(!1),P=Rn(m),j=Au(r),z=E.useRef(!1),[Q,q]=E.useState(0);return E.useEffect(()=>{const Y=y.current;if(Y)return Y.addEventListener(go,P),()=>Y.removeEventListener(go,P)},[P]),o.jsx(Fv,{scope:r,orientation:a,dir:N,loop:d,currentTabStopId:M,onItemFocus:E.useCallback(Y=>A(Y),[A]),onItemShiftTab:E.useCallback(()=>L(!0),[]),onFocusableItemAdd:E.useCallback(()=>q(Y=>Y+1),[]),onFocusableItemRemove:E.useCallback(()=>q(Y=>Y-1),[]),children:o.jsx(Vt.div,{tabIndex:O||Q===0?-1:0,"data-orientation":a,...x,ref:b,style:{outline:"none",...i.style},onMouseDown:_t(i.onMouseDown,()=>{z.current=!0}),onFocus:_t(i.onFocus,Y=>{const B=!z.current;if(Y.target===Y.currentTarget&&B&&!O){const C=new CustomEvent(go,Dv);if(Y.currentTarget.dispatchEvent(C),!C.defaultPrevented){const R=j().filter(K=>K.focusable),se=R.find(K=>K.active),_e=R.find(K=>K.id===M),X=[se,_e,...R].filter(Boolean).map(K=>K.ref.current);Lu(X,p)}}z.current=!1}),onBlur:_t(i.onBlur,()=>L(!1))})})}),Mu="RovingFocusGroupItem",Iu=E.forwardRef((i,n)=>{const{__scopeRovingFocusGroup:r,focusable:a=!0,active:d=!1,tabStopId:l,children:_,...v}=i,u=du(),m=l||u,p=Uv(Mu,r),x=p.currentTabStopId===m,y=Au(r),{onFocusableItemAdd:b,onFocusableItemRemove:N,currentTabStopId:M}=p;return E.useEffect(()=>{if(a)return b(),()=>N()},[a,b,N]),o.jsx(Ao.ItemSlot,{scope:r,id:m,focusable:a,active:d,children:o.jsx(Vt.span,{tabIndex:x?0:-1,"data-orientation":p.orientation,...v,ref:n,onMouseDown:_t(i.onMouseDown,A=>{a?p.onItemFocus(m):A.preventDefault()}),onFocus:_t(i.onFocus,()=>p.onItemFocus(m)),onKeyDown:_t(i.onKeyDown,A=>{if(A.key==="Tab"&&A.shiftKey){p.onItemShiftTab();return}if(A.target!==A.currentTarget)return;const O=zv(A,p.orientation,p.dir);if(O!==void 0){if(A.metaKey||A.ctrlKey||A.altKey||A.shiftKey)return;A.preventDefault();let P=y().filter(j=>j.focusable).map(j=>j.ref.current);if(O==="last")P.reverse();else if(O==="prev"||O==="next"){O==="prev"&&P.reverse();const j=P.indexOf(A.currentTarget);P=p.loop?qv(P,j+1):P.slice(j+1)}setTimeout(()=>Lu(P))}}),children:typeof _=="function"?_({isCurrentTabStop:x,hasTabStop:M!=null}):_})})});Iu.displayName=Mu;var Hv={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Gv(i,n){return n!=="rtl"?i:i==="ArrowLeft"?"ArrowRight":i==="ArrowRight"?"ArrowLeft":i}function zv(i,n,r){const a=Gv(i.key,r);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(a))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(a)))return Hv[a]}function Lu(i,n=!1){const r=document.activeElement;for(const a of i)if(a===r||(a.focus({preventScroll:n}),document.activeElement!==r))return}function qv(i,n){return i.map((r,a)=>i[(n+a)%i.length])}var $v=Pu,Xv=Iu,Vs="Tabs",[Yv]=Xs(Vs,[ju]),Du=ju(),[Vv,$o]=Yv(Vs),Ou=E.forwardRef((i,n)=>{const{__scopeTabs:r,value:a,onValueChange:d,defaultValue:l,orientation:_="horizontal",dir:v,activationMode:u="automatic",...m}=i,p=qo(v),[x,y]=fu({prop:a,onChange:d,defaultProp:l??"",caller:Vs});return o.jsx(Vv,{scope:r,baseId:du(),value:x,onValueChange:y,orientation:_,dir:p,activationMode:u,children:o.jsx(Vt.div,{dir:p,"data-orientation":_,...m,ref:n})})});Ou.displayName=Vs;var Bu="TabsList",Fu=E.forwardRef((i,n)=>{const{__scopeTabs:r,loop:a=!0,...d}=i,l=$o(Bu,r),_=Du(r);return o.jsx($v,{asChild:!0,..._,orientation:l.orientation,dir:l.dir,loop:a,children:o.jsx(Vt.div,{role:"tablist","aria-orientation":l.orientation,...d,ref:n})})});Fu.displayName=Bu;var Uu="TabsTrigger",Wu=E.forwardRef((i,n)=>{const{__scopeTabs:r,value:a,disabled:d=!1,...l}=i,_=$o(Uu,r),v=Du(r),u=zu(_.baseId,a),m=qu(_.baseId,a),p=a===_.value;return o.jsx(Xv,{asChild:!0,...v,focusable:!d,active:p,children:o.jsx(Vt.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":m,"data-state":p?"active":"inactive","data-disabled":d?"":void 0,disabled:d,id:u,...l,ref:n,onMouseDown:_t(i.onMouseDown,x=>{!d&&x.button===0&&x.ctrlKey===!1?_.onValueChange(a):x.preventDefault()}),onKeyDown:_t(i.onKeyDown,x=>{[" ","Enter"].includes(x.key)&&_.onValueChange(a)}),onFocus:_t(i.onFocus,()=>{const x=_.activationMode!=="manual";!p&&!d&&x&&_.onValueChange(a)})})})});Wu.displayName=Uu;var Hu="TabsContent",Gu=E.forwardRef((i,n)=>{const{__scopeTabs:r,value:a,forceMount:d,children:l,..._}=i,v=$o(Hu,r),u=zu(v.baseId,a),m=qu(v.baseId,a),p=a===v.value,x=E.useRef(p);return E.useEffect(()=>{const y=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(y)},[]),o.jsx(Br,{present:d||p,children:({present:y})=>o.jsx(Vt.div,{"data-state":p?"active":"inactive","data-orientation":v.orientation,role:"tabpanel","aria-labelledby":u,hidden:!y,id:m,tabIndex:0,..._,ref:n,style:{...i.style,animationDuration:x.current?"0s":void 0},children:y&&l})})});Gu.displayName=Hu;function zu(i,n){return`${i}-trigger-${n}`}function qu(i,n){return`${i}-content-${n}`}var Kv=Ou,Qv=Fu,Jv=Wu,Zv=Gu;function $u({className:i,...n}){return o.jsx(Kv,{"data-slot":"tabs",className:cr("flex flex-col gap-2",i),...n})}function Xu({className:i,...n}){return o.jsx(Qv,{"data-slot":"tabs-list",className:cr("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",i),...n})}function Ir({className:i,...n}){return o.jsx(Jv,{"data-slot":"tabs-trigger",className:cr("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",i),...n})}function Lr({className:i,...n}){return o.jsx(Zv,{"data-slot":"tabs-content",className:cr("flex-1 outline-none",i),...n})}var e1=Object.defineProperty,zs=Object.getOwnPropertySymbols,Yu=Object.prototype.hasOwnProperty,Vu=Object.prototype.propertyIsEnumerable,Wc=(i,n,r)=>n in i?e1(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,jo=(i,n)=>{for(var r in n||(n={}))Yu.call(n,r)&&Wc(i,r,n[r]);if(zs)for(var r of zs(n))Vu.call(n,r)&&Wc(i,r,n[r]);return i},Po=(i,n)=>{var r={};for(var a in i)Yu.call(i,a)&&n.indexOf(a)<0&&(r[a]=i[a]);if(i!=null&&zs)for(var a of zs(i))n.indexOf(a)<0&&Vu.call(i,a)&&(r[a]=i[a]);return r};var Gn;(i=>{const n=class Le{constructor(u,m,p,x){if(this.version=u,this.errorCorrectionLevel=m,this.modules=[],this.isFunction=[],u<Le.MIN_VERSION||u>Le.MAX_VERSION)throw new RangeError("Version value out of range");if(x<-1||x>7)throw new RangeError("Mask value out of range");this.size=u*4+17;let y=[];for(let N=0;N<this.size;N++)y.push(!1);for(let N=0;N<this.size;N++)this.modules.push(y.slice()),this.isFunction.push(y.slice());this.drawFunctionPatterns();const b=this.addEccAndInterleave(p);if(this.drawCodewords(b),x==-1){let N=1e9;for(let M=0;M<8;M++){this.applyMask(M),this.drawFormatBits(M);const A=this.getPenaltyScore();A<N&&(x=M,N=A),this.applyMask(M)}}d(0<=x&&x<=7),this.mask=x,this.applyMask(x),this.drawFormatBits(x),this.isFunction=[]}static encodeText(u,m){const p=i.QrSegment.makeSegments(u);return Le.encodeSegments(p,m)}static encodeBinary(u,m){const p=i.QrSegment.makeBytes(u);return Le.encodeSegments([p],m)}static encodeSegments(u,m,p=1,x=40,y=-1,b=!0){if(!(Le.MIN_VERSION<=p&&p<=x&&x<=Le.MAX_VERSION)||y<-1||y>7)throw new RangeError("Invalid value");let N,M;for(N=p;;N++){const P=Le.getNumDataCodewords(N,m)*8,j=_.getTotalBits(u,N);if(j<=P){M=j;break}if(N>=x)throw new RangeError("Data too long")}for(const P of[Le.Ecc.MEDIUM,Le.Ecc.QUARTILE,Le.Ecc.HIGH])b&&M<=Le.getNumDataCodewords(N,P)*8&&(m=P);let A=[];for(const P of u){r(P.mode.modeBits,4,A),r(P.numChars,P.mode.numCharCountBits(N),A);for(const j of P.getData())A.push(j)}d(A.length==M);const O=Le.getNumDataCodewords(N,m)*8;d(A.length<=O),r(0,Math.min(4,O-A.length),A),r(0,(8-A.length%8)%8,A),d(A.length%8==0);for(let P=236;A.length<O;P^=253)r(P,8,A);let L=[];for(;L.length*8<A.length;)L.push(0);return A.forEach((P,j)=>L[j>>>3]|=P<<7-(j&7)),new Le(N,m,L,y)}getModule(u,m){return 0<=u&&u<this.size&&0<=m&&m<this.size&&this.modules[m][u]}getModules(){return this.modules}drawFunctionPatterns(){for(let p=0;p<this.size;p++)this.setFunctionModule(6,p,p%2==0),this.setFunctionModule(p,6,p%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const u=this.getAlignmentPatternPositions(),m=u.length;for(let p=0;p<m;p++)for(let x=0;x<m;x++)p==0&&x==0||p==0&&x==m-1||p==m-1&&x==0||this.drawAlignmentPattern(u[p],u[x]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(u){const m=this.errorCorrectionLevel.formatBits<<3|u;let p=m;for(let y=0;y<10;y++)p=p<<1^(p>>>9)*1335;const x=(m<<10|p)^21522;d(x>>>15==0);for(let y=0;y<=5;y++)this.setFunctionModule(8,y,a(x,y));this.setFunctionModule(8,7,a(x,6)),this.setFunctionModule(8,8,a(x,7)),this.setFunctionModule(7,8,a(x,8));for(let y=9;y<15;y++)this.setFunctionModule(14-y,8,a(x,y));for(let y=0;y<8;y++)this.setFunctionModule(this.size-1-y,8,a(x,y));for(let y=8;y<15;y++)this.setFunctionModule(8,this.size-15+y,a(x,y));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let u=this.version;for(let p=0;p<12;p++)u=u<<1^(u>>>11)*7973;const m=this.version<<12|u;d(m>>>18==0);for(let p=0;p<18;p++){const x=a(m,p),y=this.size-11+p%3,b=Math.floor(p/3);this.setFunctionModule(y,b,x),this.setFunctionModule(b,y,x)}}drawFinderPattern(u,m){for(let p=-4;p<=4;p++)for(let x=-4;x<=4;x++){const y=Math.max(Math.abs(x),Math.abs(p)),b=u+x,N=m+p;0<=b&&b<this.size&&0<=N&&N<this.size&&this.setFunctionModule(b,N,y!=2&&y!=4)}}drawAlignmentPattern(u,m){for(let p=-2;p<=2;p++)for(let x=-2;x<=2;x++)this.setFunctionModule(u+x,m+p,Math.max(Math.abs(x),Math.abs(p))!=1)}setFunctionModule(u,m,p){this.modules[m][u]=p,this.isFunction[m][u]=!0}addEccAndInterleave(u){const m=this.version,p=this.errorCorrectionLevel;if(u.length!=Le.getNumDataCodewords(m,p))throw new RangeError("Invalid argument");const x=Le.NUM_ERROR_CORRECTION_BLOCKS[p.ordinal][m],y=Le.ECC_CODEWORDS_PER_BLOCK[p.ordinal][m],b=Math.floor(Le.getNumRawDataModules(m)/8),N=x-b%x,M=Math.floor(b/x);let A=[];const O=Le.reedSolomonComputeDivisor(y);for(let P=0,j=0;P<x;P++){let z=u.slice(j,j+M-y+(P<N?0:1));j+=z.length;const Q=Le.reedSolomonComputeRemainder(z,O);P<N&&z.push(0),A.push(z.concat(Q))}let L=[];for(let P=0;P<A[0].length;P++)A.forEach((j,z)=>{(P!=M-y||z>=N)&&L.push(j[P])});return d(L.length==b),L}drawCodewords(u){if(u.length!=Math.floor(Le.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let m=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let x=0;x<this.size;x++)for(let y=0;y<2;y++){const b=p-y,M=(p+1&2)==0?this.size-1-x:x;!this.isFunction[M][b]&&m<u.length*8&&(this.modules[M][b]=a(u[m>>>3],7-(m&7)),m++)}}d(m==u.length*8)}applyMask(u){if(u<0||u>7)throw new RangeError("Mask value out of range");for(let m=0;m<this.size;m++)for(let p=0;p<this.size;p++){let x;switch(u){case 0:x=(p+m)%2==0;break;case 1:x=m%2==0;break;case 2:x=p%3==0;break;case 3:x=(p+m)%3==0;break;case 4:x=(Math.floor(p/3)+Math.floor(m/2))%2==0;break;case 5:x=p*m%2+p*m%3==0;break;case 6:x=(p*m%2+p*m%3)%2==0;break;case 7:x=((p+m)%2+p*m%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[m][p]&&x&&(this.modules[m][p]=!this.modules[m][p])}}getPenaltyScore(){let u=0;for(let y=0;y<this.size;y++){let b=!1,N=0,M=[0,0,0,0,0,0,0];for(let A=0;A<this.size;A++)this.modules[y][A]==b?(N++,N==5?u+=Le.PENALTY_N1:N>5&&u++):(this.finderPenaltyAddHistory(N,M),b||(u+=this.finderPenaltyCountPatterns(M)*Le.PENALTY_N3),b=this.modules[y][A],N=1);u+=this.finderPenaltyTerminateAndCount(b,N,M)*Le.PENALTY_N3}for(let y=0;y<this.size;y++){let b=!1,N=0,M=[0,0,0,0,0,0,0];for(let A=0;A<this.size;A++)this.modules[A][y]==b?(N++,N==5?u+=Le.PENALTY_N1:N>5&&u++):(this.finderPenaltyAddHistory(N,M),b||(u+=this.finderPenaltyCountPatterns(M)*Le.PENALTY_N3),b=this.modules[A][y],N=1);u+=this.finderPenaltyTerminateAndCount(b,N,M)*Le.PENALTY_N3}for(let y=0;y<this.size-1;y++)for(let b=0;b<this.size-1;b++){const N=this.modules[y][b];N==this.modules[y][b+1]&&N==this.modules[y+1][b]&&N==this.modules[y+1][b+1]&&(u+=Le.PENALTY_N2)}let m=0;for(const y of this.modules)m=y.reduce((b,N)=>b+(N?1:0),m);const p=this.size*this.size,x=Math.ceil(Math.abs(m*20-p*10)/p)-1;return d(0<=x&&x<=9),u+=x*Le.PENALTY_N4,d(0<=u&&u<=2568888),u}getAlignmentPatternPositions(){if(this.version==1)return[];{const u=Math.floor(this.version/7)+2,m=this.version==32?26:Math.ceil((this.version*4+4)/(u*2-2))*2;let p=[6];for(let x=this.size-7;p.length<u;x-=m)p.splice(1,0,x);return p}}static getNumRawDataModules(u){if(u<Le.MIN_VERSION||u>Le.MAX_VERSION)throw new RangeError("Version number out of range");let m=(16*u+128)*u+64;if(u>=2){const p=Math.floor(u/7)+2;m-=(25*p-10)*p-55,u>=7&&(m-=36)}return d(208<=m&&m<=29648),m}static getNumDataCodewords(u,m){return Math.floor(Le.getNumRawDataModules(u)/8)-Le.ECC_CODEWORDS_PER_BLOCK[m.ordinal][u]*Le.NUM_ERROR_CORRECTION_BLOCKS[m.ordinal][u]}static reedSolomonComputeDivisor(u){if(u<1||u>255)throw new RangeError("Degree out of range");let m=[];for(let x=0;x<u-1;x++)m.push(0);m.push(1);let p=1;for(let x=0;x<u;x++){for(let y=0;y<m.length;y++)m[y]=Le.reedSolomonMultiply(m[y],p),y+1<m.length&&(m[y]^=m[y+1]);p=Le.reedSolomonMultiply(p,2)}return m}static reedSolomonComputeRemainder(u,m){let p=m.map(x=>0);for(const x of u){const y=x^p.shift();p.push(0),m.forEach((b,N)=>p[N]^=Le.reedSolomonMultiply(b,y))}return p}static reedSolomonMultiply(u,m){if(u>>>8||m>>>8)throw new RangeError("Byte out of range");let p=0;for(let x=7;x>=0;x--)p=p<<1^(p>>>7)*285,p^=(m>>>x&1)*u;return d(p>>>8==0),p}finderPenaltyCountPatterns(u){const m=u[1];d(m<=this.size*3);const p=m>0&&u[2]==m&&u[3]==m*3&&u[4]==m&&u[5]==m;return(p&&u[0]>=m*4&&u[6]>=m?1:0)+(p&&u[6]>=m*4&&u[0]>=m?1:0)}finderPenaltyTerminateAndCount(u,m,p){return u&&(this.finderPenaltyAddHistory(m,p),m=0),m+=this.size,this.finderPenaltyAddHistory(m,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(u,m){m[0]==0&&(u+=this.size),m.pop(),m.unshift(u)}};n.MIN_VERSION=1,n.MAX_VERSION=40,n.PENALTY_N1=3,n.PENALTY_N2=3,n.PENALTY_N3=40,n.PENALTY_N4=10,n.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],n.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],i.QrCode=n;function r(v,u,m){if(u<0||u>31||v>>>u)throw new RangeError("Value out of range");for(let p=u-1;p>=0;p--)m.push(v>>>p&1)}function a(v,u){return(v>>>u&1)!=0}function d(v){if(!v)throw new Error("Assertion error")}const l=class tt{constructor(u,m,p){if(this.mode=u,this.numChars=m,this.bitData=p,m<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(u){let m=[];for(const p of u)r(p,8,m);return new tt(tt.Mode.BYTE,u.length,m)}static makeNumeric(u){if(!tt.isNumeric(u))throw new RangeError("String contains non-numeric characters");let m=[];for(let p=0;p<u.length;){const x=Math.min(u.length-p,3);r(parseInt(u.substring(p,p+x),10),x*3+1,m),p+=x}return new tt(tt.Mode.NUMERIC,u.length,m)}static makeAlphanumeric(u){if(!tt.isAlphanumeric(u))throw new RangeError("String contains unencodable characters in alphanumeric mode");let m=[],p;for(p=0;p+2<=u.length;p+=2){let x=tt.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p))*45;x+=tt.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p+1)),r(x,11,m)}return p<u.length&&r(tt.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p)),6,m),new tt(tt.Mode.ALPHANUMERIC,u.length,m)}static makeSegments(u){return u==""?[]:tt.isNumeric(u)?[tt.makeNumeric(u)]:tt.isAlphanumeric(u)?[tt.makeAlphanumeric(u)]:[tt.makeBytes(tt.toUtf8ByteArray(u))]}static makeEci(u){let m=[];if(u<0)throw new RangeError("ECI assignment value out of range");if(u<128)r(u,8,m);else if(u<16384)r(2,2,m),r(u,14,m);else if(u<1e6)r(6,3,m),r(u,21,m);else throw new RangeError("ECI assignment value out of range");return new tt(tt.Mode.ECI,0,m)}static isNumeric(u){return tt.NUMERIC_REGEX.test(u)}static isAlphanumeric(u){return tt.ALPHANUMERIC_REGEX.test(u)}getData(){return this.bitData.slice()}static getTotalBits(u,m){let p=0;for(const x of u){const y=x.mode.numCharCountBits(m);if(x.numChars>=1<<y)return 1/0;p+=4+y+x.bitData.length}return p}static toUtf8ByteArray(u){u=encodeURI(u);let m=[];for(let p=0;p<u.length;p++)u.charAt(p)!="%"?m.push(u.charCodeAt(p)):(m.push(parseInt(u.substring(p+1,p+3),16)),p+=2);return m}};l.NUMERIC_REGEX=/^[0-9]*$/,l.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,l.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let _=l;i.QrSegment=l})(Gn||(Gn={}));(i=>{(n=>{const r=class{constructor(d,l){this.ordinal=d,this.formatBits=l}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),n.Ecc=r})(i.QrCode||(i.QrCode={}))})(Gn||(Gn={}));(i=>{(n=>{const r=class{constructor(d,l){this.modeBits=d,this.numBitsCharCount=l}numCharCountBits(d){return this.numBitsCharCount[Math.floor((d+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),n.Mode=r})(i.QrSegment||(i.QrSegment={}))})(Gn||(Gn={}));var ar=Gn;var t1={L:ar.QrCode.Ecc.LOW,M:ar.QrCode.Ecc.MEDIUM,Q:ar.QrCode.Ecc.QUARTILE,H:ar.QrCode.Ecc.HIGH},Ku=128,Qu="L",Ju="#FFFFFF",Zu="#000000",ed=!1,td=1,n1=4,r1=0,s1=.1;function nd(i,n=0){const r=[];return i.forEach(function(a,d){let l=null;a.forEach(function(_,v){if(!_&&l!==null){r.push(`M${l+n} ${d+n}h${v-l}v1H${l+n}z`),l=null;return}if(v===a.length-1){if(!_)return;l===null?r.push(`M${v+n},${d+n} h1v1H${v+n}z`):r.push(`M${l+n},${d+n} h${v+1-l}v1H${l+n}z`);return}_&&l===null&&(l=v)})}),r.join("")}function rd(i,n){return i.slice().map((r,a)=>a<n.y||a>=n.y+n.h?r:r.map((d,l)=>l<n.x||l>=n.x+n.w?d:!1))}function i1(i,n,r,a){if(a==null)return null;const d=i.length+r*2,l=Math.floor(n*s1),_=d/n,v=(a.width||l)*_,u=(a.height||l)*_,m=a.x==null?i.length/2-v/2:a.x*_,p=a.y==null?i.length/2-u/2:a.y*_,x=a.opacity==null?1:a.opacity;let y=null;if(a.excavate){let N=Math.floor(m),M=Math.floor(p),A=Math.ceil(v+m-N),O=Math.ceil(u+p-M);y={x:N,y:M,w:A,h:O}}const b=a.crossOrigin;return{x:m,y:p,h:u,w:v,excavation:y,opacity:x,crossOrigin:b}}function o1(i,n){return n!=null?Math.max(Math.floor(n),0):i?n1:r1}function sd({value:i,level:n,minVersion:r,includeMargin:a,marginSize:d,imageSettings:l,size:_,boostLevel:v}){let u=Ye.useMemo(()=>{const N=(Array.isArray(i)?i:[i]).reduce((M,A)=>(M.push(...ar.QrSegment.makeSegments(A)),M),[]);return ar.QrCode.encodeSegments(N,t1[n],r,void 0,void 0,v)},[i,n,r,v]);const{cells:m,margin:p,numCells:x,calculatedImageSettings:y}=Ye.useMemo(()=>{let b=u.getModules();const N=o1(a,d),M=b.length+N*2,A=i1(b,_,N,l);return{cells:b,margin:N,numCells:M,calculatedImageSettings:A}},[u,_,l,a,d]);return{qrcode:u,margin:p,cells:m,numCells:x,calculatedImageSettings:y}}var a1=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),l1=Ye.forwardRef(function(n,r){const a=n,{value:d,size:l=Ku,level:_=Qu,bgColor:v=Ju,fgColor:u=Zu,includeMargin:m=ed,minVersion:p=td,boostLevel:x,marginSize:y,imageSettings:b}=a,M=Po(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:A}=M,O=Po(M,["style"]),L=b?.src,P=Ye.useRef(null),j=Ye.useRef(null),z=Ye.useCallback($=>{P.current=$,typeof r=="function"?r($):r&&(r.current=$)},[r]),[Q,q]=Ye.useState(!1),{margin:Y,cells:B,numCells:C,calculatedImageSettings:R}=sd({value:d,level:_,minVersion:p,boostLevel:x,includeMargin:m,marginSize:y,imageSettings:b,size:l});Ye.useEffect(()=>{if(P.current!=null){const $=P.current,X=$.getContext("2d");if(!X)return;let K=B;const ne=j.current,oe=R!=null&&ne!==null&&ne.complete&&ne.naturalHeight!==0&&ne.naturalWidth!==0;oe&&R.excavation!=null&&(K=rd(B,R.excavation));const ke=window.devicePixelRatio||1;$.height=$.width=l*ke;const G=l/C*ke;X.scale(G,G),X.fillStyle=v,X.fillRect(0,0,C,C),X.fillStyle=u,a1?X.fill(new Path2D(nd(K,Y))):B.forEach(function(J,ue){J.forEach(function(ie,Se){ie&&X.fillRect(Se+Y,ue+Y,1,1)})}),R&&(X.globalAlpha=R.opacity),oe&&X.drawImage(ne,R.x+Y,R.y+Y,R.w,R.h)}}),Ye.useEffect(()=>{q(!1)},[L]);const se=jo({height:l,width:l},A);let _e=null;return L!=null&&(_e=Ye.createElement("img",{src:L,key:L,style:{display:"none"},onLoad:()=>{q(!0)},ref:j,crossOrigin:R?.crossOrigin})),Ye.createElement(Ye.Fragment,null,Ye.createElement("canvas",jo({style:se,height:l,width:l,ref:z,role:"img"},O)),_e)});l1.displayName="QRCodeCanvas";var id=Ye.forwardRef(function(n,r){const a=n,{value:d,size:l=Ku,level:_=Qu,bgColor:v=Ju,fgColor:u=Zu,includeMargin:m=ed,minVersion:p=td,boostLevel:x,title:y,marginSize:b,imageSettings:N}=a,M=Po(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:A,cells:O,numCells:L,calculatedImageSettings:P}=sd({value:d,level:_,minVersion:p,boostLevel:x,includeMargin:m,marginSize:b,imageSettings:N,size:l});let j=O,z=null;N!=null&&P!=null&&(P.excavation!=null&&(j=rd(O,P.excavation)),z=Ye.createElement("image",{href:N.src,height:P.h,width:P.w,x:P.x+A,y:P.y+A,preserveAspectRatio:"none",opacity:P.opacity,crossOrigin:P.crossOrigin}));const Q=nd(j,A);return Ye.createElement("svg",jo({height:l,width:l,viewBox:`0 0 ${L} ${L}`,ref:r,role:"img"},M),!!y&&Ye.createElement("title",null,y),Ye.createElement("path",{fill:v,d:`M0,0 h${L}v${L}H0z`,shapeRendering:"crispEdges"}),Ye.createElement("path",{fill:u,d:Q,shapeRendering:"crispEdges"}),z)});id.displayName="QRCodeSVG";var Pr={exports:{}};var c1=Pr.exports,Hc;function u1(){return Hc||(Hc=1,(function(i,n){(function(){var r,a="4.17.21",d=200,l="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",_="Expected a function",v="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",m=500,p="__lodash_placeholder__",x=1,y=2,b=4,N=1,M=2,A=1,O=2,L=4,P=8,j=16,z=32,Q=64,q=128,Y=256,B=512,C=30,R="...",se=800,_e=16,$=1,X=2,K=3,ne=1/0,oe=9007199254740991,ke=17976931348623157e292,G=NaN,J=4294967295,ue=J-1,ie=J>>>1,Se=[["ary",q],["bind",A],["bindKey",O],["curry",P],["curryRight",j],["flip",B],["partial",z],["partialRight",Q],["rearg",Y]],ae="[object Arguments]",ze="[object Array]",Qe="[object AsyncFunction]",me="[object Boolean]",D="[object Date]",le="[object DOMException]",he="[object Error]",Fe="[object Function]",We="[object GeneratorFunction]",de="[object Map]",Ne="[object Number]",ee="[object Null]",Z="[object Object]",Ee="[object Promise]",je="[object Proxy]",fe="[object RegExp]",xe="[object Set]",Ce="[object String]",pe="[object Symbol]",ct="[object Undefined]",yt="[object WeakMap]",wt="[object WeakSet]",it="[object ArrayBuffer]",Ve="[object DataView]",zn="[object Float32Array]",jn="[object Float64Array]",Pn="[object Int8Array]",qn="[object Int16Array]",dr="[object Int32Array]",an="[object Uint8Array]",$n="[object Uint8ClampedArray]",U="[object Uint16Array]",ve="[object Uint32Array]",Kt=/\b__p \+= '';/g,ti=/\b(__p \+=) '' \+/g,Wr=/(__e\(.*?\)|\b__t\)) \+\n'';/g,na=/&(?:amp|lt|gt|quot|#39);/g,ra=/[&<>"']/g,Hd=RegExp(na.source),Gd=RegExp(ra.source),zd=/<%-([\s\S]+?)%>/g,qd=/<%([\s\S]+?)%>/g,sa=/<%=([\s\S]+?)%>/g,$d=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Xd=/^\w*$/,Yd=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ni=/[\\^$.*+?()[\]{}|]/g,Vd=RegExp(ni.source),ri=/^\s+/,Kd=/\s/,Qd=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Jd=/\{\n\/\* \[wrapped with (.+)\] \*/,Zd=/,? & /,ef=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,tf=/[()=,{}\[\]\/\s]/,nf=/\\(\\)?/g,rf=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ia=/\w*$/,sf=/^[-+]0x[0-9a-f]+$/i,of=/^0b[01]+$/i,af=/^\[object .+?Constructor\]$/,lf=/^0o[0-7]+$/i,cf=/^(?:0|[1-9]\d*)$/,uf=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Hr=/($^)/,df=/['\n\r\u2028\u2029\\]/g,Gr="\\ud800-\\udfff",ff="\\u0300-\\u036f",hf="\\ufe20-\\ufe2f",pf="\\u20d0-\\u20ff",oa=ff+hf+pf,aa="\\u2700-\\u27bf",la="a-z\\xdf-\\xf6\\xf8-\\xff",mf="\\xac\\xb1\\xd7\\xf7",gf="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",_f="\\u2000-\\u206f",xf=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",ca="A-Z\\xc0-\\xd6\\xd8-\\xde",ua="\\ufe0e\\ufe0f",da=mf+gf+_f+xf,si="['’]",vf="["+Gr+"]",fa="["+da+"]",zr="["+oa+"]",ha="\\d+",bf="["+aa+"]",pa="["+la+"]",ma="[^"+Gr+da+ha+aa+la+ca+"]",ii="\\ud83c[\\udffb-\\udfff]",yf="(?:"+zr+"|"+ii+")",ga="[^"+Gr+"]",oi="(?:\\ud83c[\\udde6-\\uddff]){2}",ai="[\\ud800-\\udbff][\\udc00-\\udfff]",Xn="["+ca+"]",_a="\\u200d",xa="(?:"+pa+"|"+ma+")",wf="(?:"+Xn+"|"+ma+")",va="(?:"+si+"(?:d|ll|m|re|s|t|ve))?",ba="(?:"+si+"(?:D|LL|M|RE|S|T|VE))?",ya=yf+"?",wa="["+ua+"]?",Ef="(?:"+_a+"(?:"+[ga,oi,ai].join("|")+")"+wa+ya+")*",Sf="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Nf="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Ea=wa+ya+Ef,Cf="(?:"+[bf,oi,ai].join("|")+")"+Ea,Tf="(?:"+[ga+zr+"?",zr,oi,ai,vf].join("|")+")",Rf=RegExp(si,"g"),kf=RegExp(zr,"g"),li=RegExp(ii+"(?="+ii+")|"+Tf+Ea,"g"),Af=RegExp([Xn+"?"+pa+"+"+va+"(?="+[fa,Xn,"$"].join("|")+")",wf+"+"+ba+"(?="+[fa,Xn+xa,"$"].join("|")+")",Xn+"?"+xa+"+"+va,Xn+"+"+ba,Nf,Sf,ha,Cf].join("|"),"g"),jf=RegExp("["+_a+Gr+oa+ua+"]"),Pf=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Mf=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],If=-1,Ke={};Ke[zn]=Ke[jn]=Ke[Pn]=Ke[qn]=Ke[dr]=Ke[an]=Ke[$n]=Ke[U]=Ke[ve]=!0,Ke[ae]=Ke[ze]=Ke[it]=Ke[me]=Ke[Ve]=Ke[D]=Ke[he]=Ke[Fe]=Ke[de]=Ke[Ne]=Ke[Z]=Ke[fe]=Ke[xe]=Ke[Ce]=Ke[yt]=!1;var Xe={};Xe[ae]=Xe[ze]=Xe[it]=Xe[Ve]=Xe[me]=Xe[D]=Xe[zn]=Xe[jn]=Xe[Pn]=Xe[qn]=Xe[dr]=Xe[de]=Xe[Ne]=Xe[Z]=Xe[fe]=Xe[xe]=Xe[Ce]=Xe[pe]=Xe[an]=Xe[$n]=Xe[U]=Xe[ve]=!0,Xe[he]=Xe[Fe]=Xe[yt]=!1;var Lf={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Df={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Of={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Bf={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ff=parseFloat,Uf=parseInt,Sa=typeof As=="object"&&As&&As.Object===Object&&As,Wf=typeof self=="object"&&self&&self.Object===Object&&self,dt=Sa||Wf||Function("return this")(),ci=n&&!n.nodeType&&n,Mn=ci&&!0&&i&&!i.nodeType&&i,Na=Mn&&Mn.exports===ci,ui=Na&&Sa.process,Mt=(function(){try{var T=Mn&&Mn.require&&Mn.require("util").types;return T||ui&&ui.binding&&ui.binding("util")}catch{}})(),Ca=Mt&&Mt.isArrayBuffer,Ta=Mt&&Mt.isDate,Ra=Mt&&Mt.isMap,ka=Mt&&Mt.isRegExp,Aa=Mt&&Mt.isSet,ja=Mt&&Mt.isTypedArray;function Tt(T,F,I){switch(I.length){case 0:return T.call(F);case 1:return T.call(F,I[0]);case 2:return T.call(F,I[0],I[1]);case 3:return T.call(F,I[0],I[1],I[2])}return T.apply(F,I)}function Hf(T,F,I,re){for(var Te=-1,Ue=T==null?0:T.length;++Te<Ue;){var at=T[Te];F(re,at,I(at),T)}return re}function It(T,F){for(var I=-1,re=T==null?0:T.length;++I<re&&F(T[I],I,T)!==!1;);return T}function Gf(T,F){for(var I=T==null?0:T.length;I--&&F(T[I],I,T)!==!1;);return T}function Pa(T,F){for(var I=-1,re=T==null?0:T.length;++I<re;)if(!F(T[I],I,T))return!1;return!0}function vn(T,F){for(var I=-1,re=T==null?0:T.length,Te=0,Ue=[];++I<re;){var at=T[I];F(at,I,T)&&(Ue[Te++]=at)}return Ue}function qr(T,F){var I=T==null?0:T.length;return!!I&&Yn(T,F,0)>-1}function di(T,F,I){for(var re=-1,Te=T==null?0:T.length;++re<Te;)if(I(F,T[re]))return!0;return!1}function Je(T,F){for(var I=-1,re=T==null?0:T.length,Te=Array(re);++I<re;)Te[I]=F(T[I],I,T);return Te}function bn(T,F){for(var I=-1,re=F.length,Te=T.length;++I<re;)T[Te+I]=F[I];return T}function fi(T,F,I,re){var Te=-1,Ue=T==null?0:T.length;for(re&&Ue&&(I=T[++Te]);++Te<Ue;)I=F(I,T[Te],Te,T);return I}function zf(T,F,I,re){var Te=T==null?0:T.length;for(re&&Te&&(I=T[--Te]);Te--;)I=F(I,T[Te],Te,T);return I}function hi(T,F){for(var I=-1,re=T==null?0:T.length;++I<re;)if(F(T[I],I,T))return!0;return!1}var qf=pi("length");function $f(T){return T.split("")}function Xf(T){return T.match(ef)||[]}function Ma(T,F,I){var re;return I(T,function(Te,Ue,at){if(F(Te,Ue,at))return re=Ue,!1}),re}function $r(T,F,I,re){for(var Te=T.length,Ue=I+(re?1:-1);re?Ue--:++Ue<Te;)if(F(T[Ue],Ue,T))return Ue;return-1}function Yn(T,F,I){return F===F?ih(T,F,I):$r(T,Ia,I)}function Yf(T,F,I,re){for(var Te=I-1,Ue=T.length;++Te<Ue;)if(re(T[Te],F))return Te;return-1}function Ia(T){return T!==T}function La(T,F){var I=T==null?0:T.length;return I?gi(T,F)/I:G}function pi(T){return function(F){return F==null?r:F[T]}}function mi(T){return function(F){return T==null?r:T[F]}}function Da(T,F,I,re,Te){return Te(T,function(Ue,at,qe){I=re?(re=!1,Ue):F(I,Ue,at,qe)}),I}function Vf(T,F){var I=T.length;for(T.sort(F);I--;)T[I]=T[I].value;return T}function gi(T,F){for(var I,re=-1,Te=T.length;++re<Te;){var Ue=F(T[re]);Ue!==r&&(I=I===r?Ue:I+Ue)}return I}function _i(T,F){for(var I=-1,re=Array(T);++I<T;)re[I]=F(I);return re}function Kf(T,F){return Je(F,function(I){return[I,T[I]]})}function Oa(T){return T&&T.slice(0,Wa(T)+1).replace(ri,"")}function Rt(T){return function(F){return T(F)}}function xi(T,F){return Je(F,function(I){return T[I]})}function fr(T,F){return T.has(F)}function Ba(T,F){for(var I=-1,re=T.length;++I<re&&Yn(F,T[I],0)>-1;);return I}function Fa(T,F){for(var I=T.length;I--&&Yn(F,T[I],0)>-1;);return I}function Qf(T,F){for(var I=T.length,re=0;I--;)T[I]===F&&++re;return re}var Jf=mi(Lf),Zf=mi(Df);function eh(T){return"\\"+Bf[T]}function th(T,F){return T==null?r:T[F]}function Vn(T){return jf.test(T)}function nh(T){return Pf.test(T)}function rh(T){for(var F,I=[];!(F=T.next()).done;)I.push(F.value);return I}function vi(T){var F=-1,I=Array(T.size);return T.forEach(function(re,Te){I[++F]=[Te,re]}),I}function Ua(T,F){return function(I){return T(F(I))}}function yn(T,F){for(var I=-1,re=T.length,Te=0,Ue=[];++I<re;){var at=T[I];(at===F||at===p)&&(T[I]=p,Ue[Te++]=I)}return Ue}function Xr(T){var F=-1,I=Array(T.size);return T.forEach(function(re){I[++F]=re}),I}function sh(T){var F=-1,I=Array(T.size);return T.forEach(function(re){I[++F]=[re,re]}),I}function ih(T,F,I){for(var re=I-1,Te=T.length;++re<Te;)if(T[re]===F)return re;return-1}function oh(T,F,I){for(var re=I+1;re--;)if(T[re]===F)return re;return re}function Kn(T){return Vn(T)?lh(T):qf(T)}function Gt(T){return Vn(T)?ch(T):$f(T)}function Wa(T){for(var F=T.length;F--&&Kd.test(T.charAt(F)););return F}var ah=mi(Of);function lh(T){for(var F=li.lastIndex=0;li.test(T);)++F;return F}function ch(T){return T.match(li)||[]}function uh(T){return T.match(Af)||[]}var dh=(function T(F){F=F==null?dt:Qn.defaults(dt.Object(),F,Qn.pick(dt,Mf));var I=F.Array,re=F.Date,Te=F.Error,Ue=F.Function,at=F.Math,qe=F.Object,bi=F.RegExp,fh=F.String,Lt=F.TypeError,Yr=I.prototype,hh=Ue.prototype,Jn=qe.prototype,Vr=F["__core-js_shared__"],Kr=hh.toString,Ge=Jn.hasOwnProperty,ph=0,Ha=(function(){var e=/[^.]+$/.exec(Vr&&Vr.keys&&Vr.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})(),Qr=Jn.toString,mh=Kr.call(qe),gh=dt._,_h=bi("^"+Kr.call(Ge).replace(ni,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Jr=Na?F.Buffer:r,wn=F.Symbol,Zr=F.Uint8Array,Ga=Jr?Jr.allocUnsafe:r,es=Ua(qe.getPrototypeOf,qe),za=qe.create,qa=Jn.propertyIsEnumerable,ts=Yr.splice,$a=wn?wn.isConcatSpreadable:r,hr=wn?wn.iterator:r,In=wn?wn.toStringTag:r,ns=(function(){try{var e=Fn(qe,"defineProperty");return e({},"",{}),e}catch{}})(),xh=F.clearTimeout!==dt.clearTimeout&&F.clearTimeout,vh=re&&re.now!==dt.Date.now&&re.now,bh=F.setTimeout!==dt.setTimeout&&F.setTimeout,rs=at.ceil,ss=at.floor,yi=qe.getOwnPropertySymbols,yh=Jr?Jr.isBuffer:r,Xa=F.isFinite,wh=Yr.join,Eh=Ua(qe.keys,qe),lt=at.max,pt=at.min,Sh=re.now,Nh=F.parseInt,Ya=at.random,Ch=Yr.reverse,wi=Fn(F,"DataView"),pr=Fn(F,"Map"),Ei=Fn(F,"Promise"),Zn=Fn(F,"Set"),mr=Fn(F,"WeakMap"),gr=Fn(qe,"create"),is=mr&&new mr,er={},Th=Un(wi),Rh=Un(pr),kh=Un(Ei),Ah=Un(Zn),jh=Un(mr),os=wn?wn.prototype:r,_r=os?os.valueOf:r,Va=os?os.toString:r;function h(e){if(et(e)&&!Re(e)&&!(e instanceof De)){if(e instanceof Dt)return e;if(Ge.call(e,"__wrapped__"))return Kl(e)}return new Dt(e)}var tr=(function(){function e(){}return function(t){if(!Ze(t))return{};if(za)return za(t);e.prototype=t;var s=new e;return e.prototype=r,s}})();function as(){}function Dt(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}h.templateSettings={escape:zd,evaluate:qd,interpolate:sa,variable:"",imports:{_:h}},h.prototype=as.prototype,h.prototype.constructor=h,Dt.prototype=tr(as.prototype),Dt.prototype.constructor=Dt;function De(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=J,this.__views__=[]}function Ph(){var e=new De(this.__wrapped__);return e.__actions__=Et(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Et(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Et(this.__views__),e}function Mh(){if(this.__filtered__){var e=new De(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Ih(){var e=this.__wrapped__.value(),t=this.__dir__,s=Re(e),c=t<0,f=s?e.length:0,g=$p(0,f,this.__views__),w=g.start,S=g.end,k=S-w,W=c?S:w-1,H=this.__iteratees__,V=H.length,te=0,ce=pt(k,this.__takeCount__);if(!s||!c&&f==k&&ce==k)return vl(e,this.__actions__);var be=[];e:for(;k--&&te<ce;){W+=t;for(var Pe=-1,ye=e[W];++Pe<V;){var Ie=H[Pe],Oe=Ie.iteratee,jt=Ie.type,bt=Oe(ye);if(jt==X)ye=bt;else if(!bt){if(jt==$)continue e;break e}}be[te++]=ye}return be}De.prototype=tr(as.prototype),De.prototype.constructor=De;function Ln(e){var t=-1,s=e==null?0:e.length;for(this.clear();++t<s;){var c=e[t];this.set(c[0],c[1])}}function Lh(){this.__data__=gr?gr(null):{},this.size=0}function Dh(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function Oh(e){var t=this.__data__;if(gr){var s=t[e];return s===u?r:s}return Ge.call(t,e)?t[e]:r}function Bh(e){var t=this.__data__;return gr?t[e]!==r:Ge.call(t,e)}function Fh(e,t){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=gr&&t===r?u:t,this}Ln.prototype.clear=Lh,Ln.prototype.delete=Dh,Ln.prototype.get=Oh,Ln.prototype.has=Bh,Ln.prototype.set=Fh;function ln(e){var t=-1,s=e==null?0:e.length;for(this.clear();++t<s;){var c=e[t];this.set(c[0],c[1])}}function Uh(){this.__data__=[],this.size=0}function Wh(e){var t=this.__data__,s=ls(t,e);if(s<0)return!1;var c=t.length-1;return s==c?t.pop():ts.call(t,s,1),--this.size,!0}function Hh(e){var t=this.__data__,s=ls(t,e);return s<0?r:t[s][1]}function Gh(e){return ls(this.__data__,e)>-1}function zh(e,t){var s=this.__data__,c=ls(s,e);return c<0?(++this.size,s.push([e,t])):s[c][1]=t,this}ln.prototype.clear=Uh,ln.prototype.delete=Wh,ln.prototype.get=Hh,ln.prototype.has=Gh,ln.prototype.set=zh;function cn(e){var t=-1,s=e==null?0:e.length;for(this.clear();++t<s;){var c=e[t];this.set(c[0],c[1])}}function qh(){this.size=0,this.__data__={hash:new Ln,map:new(pr||ln),string:new Ln}}function $h(e){var t=bs(this,e).delete(e);return this.size-=t?1:0,t}function Xh(e){return bs(this,e).get(e)}function Yh(e){return bs(this,e).has(e)}function Vh(e,t){var s=bs(this,e),c=s.size;return s.set(e,t),this.size+=s.size==c?0:1,this}cn.prototype.clear=qh,cn.prototype.delete=$h,cn.prototype.get=Xh,cn.prototype.has=Yh,cn.prototype.set=Vh;function Dn(e){var t=-1,s=e==null?0:e.length;for(this.__data__=new cn;++t<s;)this.add(e[t])}function Kh(e){return this.__data__.set(e,u),this}function Qh(e){return this.__data__.has(e)}Dn.prototype.add=Dn.prototype.push=Kh,Dn.prototype.has=Qh;function zt(e){var t=this.__data__=new ln(e);this.size=t.size}function Jh(){this.__data__=new ln,this.size=0}function Zh(e){var t=this.__data__,s=t.delete(e);return this.size=t.size,s}function ep(e){return this.__data__.get(e)}function tp(e){return this.__data__.has(e)}function np(e,t){var s=this.__data__;if(s instanceof ln){var c=s.__data__;if(!pr||c.length<d-1)return c.push([e,t]),this.size=++s.size,this;s=this.__data__=new cn(c)}return s.set(e,t),this.size=s.size,this}zt.prototype.clear=Jh,zt.prototype.delete=Zh,zt.prototype.get=ep,zt.prototype.has=tp,zt.prototype.set=np;function Ka(e,t){var s=Re(e),c=!s&&Wn(e),f=!s&&!c&&Tn(e),g=!s&&!c&&!f&&ir(e),w=s||c||f||g,S=w?_i(e.length,fh):[],k=S.length;for(var W in e)(t||Ge.call(e,W))&&!(w&&(W=="length"||f&&(W=="offset"||W=="parent")||g&&(W=="buffer"||W=="byteLength"||W=="byteOffset")||hn(W,k)))&&S.push(W);return S}function Qa(e){var t=e.length;return t?e[Ii(0,t-1)]:r}function rp(e,t){return ys(Et(e),On(t,0,e.length))}function sp(e){return ys(Et(e))}function Si(e,t,s){(s!==r&&!qt(e[t],s)||s===r&&!(t in e))&&un(e,t,s)}function xr(e,t,s){var c=e[t];(!(Ge.call(e,t)&&qt(c,s))||s===r&&!(t in e))&&un(e,t,s)}function ls(e,t){for(var s=e.length;s--;)if(qt(e[s][0],t))return s;return-1}function ip(e,t,s,c){return En(e,function(f,g,w){t(c,f,s(f),w)}),c}function Ja(e,t){return e&&Jt(t,ut(t),e)}function op(e,t){return e&&Jt(t,Nt(t),e)}function un(e,t,s){t=="__proto__"&&ns?ns(e,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):e[t]=s}function Ni(e,t){for(var s=-1,c=t.length,f=I(c),g=e==null;++s<c;)f[s]=g?r:io(e,t[s]);return f}function On(e,t,s){return e===e&&(s!==r&&(e=e<=s?e:s),t!==r&&(e=e>=t?e:t)),e}function Ot(e,t,s,c,f,g){var w,S=t&x,k=t&y,W=t&b;if(s&&(w=f?s(e,c,f,g):s(e)),w!==r)return w;if(!Ze(e))return e;var H=Re(e);if(H){if(w=Yp(e),!S)return Et(e,w)}else{var V=mt(e),te=V==Fe||V==We;if(Tn(e))return wl(e,S);if(V==Z||V==ae||te&&!f){if(w=k||te?{}:Wl(e),!S)return k?Op(e,op(w,e)):Dp(e,Ja(w,e))}else{if(!Xe[V])return f?e:{};w=Vp(e,V,S)}}g||(g=new zt);var ce=g.get(e);if(ce)return ce;g.set(e,w),gc(e)?e.forEach(function(ye){w.add(Ot(ye,t,s,ye,e,g))}):pc(e)&&e.forEach(function(ye,Ie){w.set(Ie,Ot(ye,t,s,Ie,e,g))});var be=W?k?qi:zi:k?Nt:ut,Pe=H?r:be(e);return It(Pe||e,function(ye,Ie){Pe&&(Ie=ye,ye=e[Ie]),xr(w,Ie,Ot(ye,t,s,Ie,e,g))}),w}function ap(e){var t=ut(e);return function(s){return Za(s,e,t)}}function Za(e,t,s){var c=s.length;if(e==null)return!c;for(e=qe(e);c--;){var f=s[c],g=t[f],w=e[f];if(w===r&&!(f in e)||!g(w))return!1}return!0}function el(e,t,s){if(typeof e!="function")throw new Lt(_);return Nr(function(){e.apply(r,s)},t)}function vr(e,t,s,c){var f=-1,g=qr,w=!0,S=e.length,k=[],W=t.length;if(!S)return k;s&&(t=Je(t,Rt(s))),c?(g=di,w=!1):t.length>=d&&(g=fr,w=!1,t=new Dn(t));e:for(;++f<S;){var H=e[f],V=s==null?H:s(H);if(H=c||H!==0?H:0,w&&V===V){for(var te=W;te--;)if(t[te]===V)continue e;k.push(H)}else g(t,V,c)||k.push(H)}return k}var En=Tl(Qt),tl=Tl(Ti,!0);function lp(e,t){var s=!0;return En(e,function(c,f,g){return s=!!t(c,f,g),s}),s}function cs(e,t,s){for(var c=-1,f=e.length;++c<f;){var g=e[c],w=t(g);if(w!=null&&(S===r?w===w&&!At(w):s(w,S)))var S=w,k=g}return k}function cp(e,t,s,c){var f=e.length;for(s=Ae(s),s<0&&(s=-s>f?0:f+s),c=c===r||c>f?f:Ae(c),c<0&&(c+=f),c=s>c?0:xc(c);s<c;)e[s++]=t;return e}function nl(e,t){var s=[];return En(e,function(c,f,g){t(c,f,g)&&s.push(c)}),s}function ft(e,t,s,c,f){var g=-1,w=e.length;for(s||(s=Qp),f||(f=[]);++g<w;){var S=e[g];t>0&&s(S)?t>1?ft(S,t-1,s,c,f):bn(f,S):c||(f[f.length]=S)}return f}var Ci=Rl(),rl=Rl(!0);function Qt(e,t){return e&&Ci(e,t,ut)}function Ti(e,t){return e&&rl(e,t,ut)}function us(e,t){return vn(t,function(s){return pn(e[s])})}function Bn(e,t){t=Nn(t,e);for(var s=0,c=t.length;e!=null&&s<c;)e=e[Zt(t[s++])];return s&&s==c?e:r}function sl(e,t,s){var c=t(e);return Re(e)?c:bn(c,s(e))}function xt(e){return e==null?e===r?ct:ee:In&&In in qe(e)?qp(e):sm(e)}function Ri(e,t){return e>t}function up(e,t){return e!=null&&Ge.call(e,t)}function dp(e,t){return e!=null&&t in qe(e)}function fp(e,t,s){return e>=pt(t,s)&&e<lt(t,s)}function ki(e,t,s){for(var c=s?di:qr,f=e[0].length,g=e.length,w=g,S=I(g),k=1/0,W=[];w--;){var H=e[w];w&&t&&(H=Je(H,Rt(t))),k=pt(H.length,k),S[w]=!s&&(t||f>=120&&H.length>=120)?new Dn(w&&H):r}H=e[0];var V=-1,te=S[0];e:for(;++V<f&&W.length<k;){var ce=H[V],be=t?t(ce):ce;if(ce=s||ce!==0?ce:0,!(te?fr(te,be):c(W,be,s))){for(w=g;--w;){var Pe=S[w];if(!(Pe?fr(Pe,be):c(e[w],be,s)))continue e}te&&te.push(be),W.push(ce)}}return W}function hp(e,t,s,c){return Qt(e,function(f,g,w){t(c,s(f),g,w)}),c}function br(e,t,s){t=Nn(t,e),e=ql(e,t);var c=e==null?e:e[Zt(Ft(t))];return c==null?r:Tt(c,e,s)}function il(e){return et(e)&&xt(e)==ae}function pp(e){return et(e)&&xt(e)==it}function mp(e){return et(e)&&xt(e)==D}function yr(e,t,s,c,f){return e===t?!0:e==null||t==null||!et(e)&&!et(t)?e!==e&&t!==t:gp(e,t,s,c,yr,f)}function gp(e,t,s,c,f,g){var w=Re(e),S=Re(t),k=w?ze:mt(e),W=S?ze:mt(t);k=k==ae?Z:k,W=W==ae?Z:W;var H=k==Z,V=W==Z,te=k==W;if(te&&Tn(e)){if(!Tn(t))return!1;w=!0,H=!1}if(te&&!H)return g||(g=new zt),w||ir(e)?Bl(e,t,s,c,f,g):Gp(e,t,k,s,c,f,g);if(!(s&N)){var ce=H&&Ge.call(e,"__wrapped__"),be=V&&Ge.call(t,"__wrapped__");if(ce||be){var Pe=ce?e.value():e,ye=be?t.value():t;return g||(g=new zt),f(Pe,ye,s,c,g)}}return te?(g||(g=new zt),zp(e,t,s,c,f,g)):!1}function _p(e){return et(e)&&mt(e)==de}function Ai(e,t,s,c){var f=s.length,g=f,w=!c;if(e==null)return!g;for(e=qe(e);f--;){var S=s[f];if(w&&S[2]?S[1]!==e[S[0]]:!(S[0]in e))return!1}for(;++f<g;){S=s[f];var k=S[0],W=e[k],H=S[1];if(w&&S[2]){if(W===r&&!(k in e))return!1}else{var V=new zt;if(c)var te=c(W,H,k,e,t,V);if(!(te===r?yr(H,W,N|M,c,V):te))return!1}}return!0}function ol(e){if(!Ze(e)||Zp(e))return!1;var t=pn(e)?_h:af;return t.test(Un(e))}function xp(e){return et(e)&&xt(e)==fe}function vp(e){return et(e)&&mt(e)==xe}function bp(e){return et(e)&&Ts(e.length)&&!!Ke[xt(e)]}function al(e){return typeof e=="function"?e:e==null?Ct:typeof e=="object"?Re(e)?ul(e[0],e[1]):cl(e):kc(e)}function ji(e){if(!Sr(e))return Eh(e);var t=[];for(var s in qe(e))Ge.call(e,s)&&s!="constructor"&&t.push(s);return t}function yp(e){if(!Ze(e))return rm(e);var t=Sr(e),s=[];for(var c in e)c=="constructor"&&(t||!Ge.call(e,c))||s.push(c);return s}function Pi(e,t){return e<t}function ll(e,t){var s=-1,c=St(e)?I(e.length):[];return En(e,function(f,g,w){c[++s]=t(f,g,w)}),c}function cl(e){var t=Xi(e);return t.length==1&&t[0][2]?Gl(t[0][0],t[0][1]):function(s){return s===e||Ai(s,e,t)}}function ul(e,t){return Vi(e)&&Hl(t)?Gl(Zt(e),t):function(s){var c=io(s,e);return c===r&&c===t?oo(s,e):yr(t,c,N|M)}}function ds(e,t,s,c,f){e!==t&&Ci(t,function(g,w){if(f||(f=new zt),Ze(g))wp(e,t,w,s,ds,c,f);else{var S=c?c(Qi(e,w),g,w+"",e,t,f):r;S===r&&(S=g),Si(e,w,S)}},Nt)}function wp(e,t,s,c,f,g,w){var S=Qi(e,s),k=Qi(t,s),W=w.get(k);if(W){Si(e,s,W);return}var H=g?g(S,k,s+"",e,t,w):r,V=H===r;if(V){var te=Re(k),ce=!te&&Tn(k),be=!te&&!ce&&ir(k);H=k,te||ce||be?Re(S)?H=S:rt(S)?H=Et(S):ce?(V=!1,H=wl(k,!0)):be?(V=!1,H=El(k,!0)):H=[]:Cr(k)||Wn(k)?(H=S,Wn(S)?H=vc(S):(!Ze(S)||pn(S))&&(H=Wl(k))):V=!1}V&&(w.set(k,H),f(H,k,c,g,w),w.delete(k)),Si(e,s,H)}function dl(e,t){var s=e.length;if(s)return t+=t<0?s:0,hn(t,s)?e[t]:r}function fl(e,t,s){t.length?t=Je(t,function(g){return Re(g)?function(w){return Bn(w,g.length===1?g[0]:g)}:g}):t=[Ct];var c=-1;t=Je(t,Rt(ge()));var f=ll(e,function(g,w,S){var k=Je(t,function(W){return W(g)});return{criteria:k,index:++c,value:g}});return Vf(f,function(g,w){return Lp(g,w,s)})}function Ep(e,t){return hl(e,t,function(s,c){return oo(e,c)})}function hl(e,t,s){for(var c=-1,f=t.length,g={};++c<f;){var w=t[c],S=Bn(e,w);s(S,w)&&wr(g,Nn(w,e),S)}return g}function Sp(e){return function(t){return Bn(t,e)}}function Mi(e,t,s,c){var f=c?Yf:Yn,g=-1,w=t.length,S=e;for(e===t&&(t=Et(t)),s&&(S=Je(e,Rt(s)));++g<w;)for(var k=0,W=t[g],H=s?s(W):W;(k=f(S,H,k,c))>-1;)S!==e&&ts.call(S,k,1),ts.call(e,k,1);return e}function pl(e,t){for(var s=e?t.length:0,c=s-1;s--;){var f=t[s];if(s==c||f!==g){var g=f;hn(f)?ts.call(e,f,1):Oi(e,f)}}return e}function Ii(e,t){return e+ss(Ya()*(t-e+1))}function Np(e,t,s,c){for(var f=-1,g=lt(rs((t-e)/(s||1)),0),w=I(g);g--;)w[c?g:++f]=e,e+=s;return w}function Li(e,t){var s="";if(!e||t<1||t>oe)return s;do t%2&&(s+=e),t=ss(t/2),t&&(e+=e);while(t);return s}function Me(e,t){return Ji(zl(e,t,Ct),e+"")}function Cp(e){return Qa(or(e))}function Tp(e,t){var s=or(e);return ys(s,On(t,0,s.length))}function wr(e,t,s,c){if(!Ze(e))return e;t=Nn(t,e);for(var f=-1,g=t.length,w=g-1,S=e;S!=null&&++f<g;){var k=Zt(t[f]),W=s;if(k==="__proto__"||k==="constructor"||k==="prototype")return e;if(f!=w){var H=S[k];W=c?c(H,k,S):r,W===r&&(W=Ze(H)?H:hn(t[f+1])?[]:{})}xr(S,k,W),S=S[k]}return e}var ml=is?function(e,t){return is.set(e,t),e}:Ct,Rp=ns?function(e,t){return ns(e,"toString",{configurable:!0,enumerable:!1,value:lo(t),writable:!0})}:Ct;function kp(e){return ys(or(e))}function Bt(e,t,s){var c=-1,f=e.length;t<0&&(t=-t>f?0:f+t),s=s>f?f:s,s<0&&(s+=f),f=t>s?0:s-t>>>0,t>>>=0;for(var g=I(f);++c<f;)g[c]=e[c+t];return g}function Ap(e,t){var s;return En(e,function(c,f,g){return s=t(c,f,g),!s}),!!s}function fs(e,t,s){var c=0,f=e==null?c:e.length;if(typeof t=="number"&&t===t&&f<=ie){for(;c<f;){var g=c+f>>>1,w=e[g];w!==null&&!At(w)&&(s?w<=t:w<t)?c=g+1:f=g}return f}return Di(e,t,Ct,s)}function Di(e,t,s,c){var f=0,g=e==null?0:e.length;if(g===0)return 0;t=s(t);for(var w=t!==t,S=t===null,k=At(t),W=t===r;f<g;){var H=ss((f+g)/2),V=s(e[H]),te=V!==r,ce=V===null,be=V===V,Pe=At(V);if(w)var ye=c||be;else W?ye=be&&(c||te):S?ye=be&&te&&(c||!ce):k?ye=be&&te&&!ce&&(c||!Pe):ce||Pe?ye=!1:ye=c?V<=t:V<t;ye?f=H+1:g=H}return pt(g,ue)}function gl(e,t){for(var s=-1,c=e.length,f=0,g=[];++s<c;){var w=e[s],S=t?t(w):w;if(!s||!qt(S,k)){var k=S;g[f++]=w===0?0:w}}return g}function _l(e){return typeof e=="number"?e:At(e)?G:+e}function kt(e){if(typeof e=="string")return e;if(Re(e))return Je(e,kt)+"";if(At(e))return Va?Va.call(e):"";var t=e+"";return t=="0"&&1/e==-ne?"-0":t}function Sn(e,t,s){var c=-1,f=qr,g=e.length,w=!0,S=[],k=S;if(s)w=!1,f=di;else if(g>=d){var W=t?null:Wp(e);if(W)return Xr(W);w=!1,f=fr,k=new Dn}else k=t?[]:S;e:for(;++c<g;){var H=e[c],V=t?t(H):H;if(H=s||H!==0?H:0,w&&V===V){for(var te=k.length;te--;)if(k[te]===V)continue e;t&&k.push(V),S.push(H)}else f(k,V,s)||(k!==S&&k.push(V),S.push(H))}return S}function Oi(e,t){return t=Nn(t,e),e=ql(e,t),e==null||delete e[Zt(Ft(t))]}function xl(e,t,s,c){return wr(e,t,s(Bn(e,t)),c)}function hs(e,t,s,c){for(var f=e.length,g=c?f:-1;(c?g--:++g<f)&&t(e[g],g,e););return s?Bt(e,c?0:g,c?g+1:f):Bt(e,c?g+1:0,c?f:g)}function vl(e,t){var s=e;return s instanceof De&&(s=s.value()),fi(t,function(c,f){return f.func.apply(f.thisArg,bn([c],f.args))},s)}function Bi(e,t,s){var c=e.length;if(c<2)return c?Sn(e[0]):[];for(var f=-1,g=I(c);++f<c;)for(var w=e[f],S=-1;++S<c;)S!=f&&(g[f]=vr(g[f]||w,e[S],t,s));return Sn(ft(g,1),t,s)}function bl(e,t,s){for(var c=-1,f=e.length,g=t.length,w={};++c<f;){var S=c<g?t[c]:r;s(w,e[c],S)}return w}function Fi(e){return rt(e)?e:[]}function Ui(e){return typeof e=="function"?e:Ct}function Nn(e,t){return Re(e)?e:Vi(e,t)?[e]:Vl(He(e))}var jp=Me;function Cn(e,t,s){var c=e.length;return s=s===r?c:s,!t&&s>=c?e:Bt(e,t,s)}var yl=xh||function(e){return dt.clearTimeout(e)};function wl(e,t){if(t)return e.slice();var s=e.length,c=Ga?Ga(s):new e.constructor(s);return e.copy(c),c}function Wi(e){var t=new e.constructor(e.byteLength);return new Zr(t).set(new Zr(e)),t}function Pp(e,t){var s=t?Wi(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.byteLength)}function Mp(e){var t=new e.constructor(e.source,ia.exec(e));return t.lastIndex=e.lastIndex,t}function Ip(e){return _r?qe(_r.call(e)):{}}function El(e,t){var s=t?Wi(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.length)}function Sl(e,t){if(e!==t){var s=e!==r,c=e===null,f=e===e,g=At(e),w=t!==r,S=t===null,k=t===t,W=At(t);if(!S&&!W&&!g&&e>t||g&&w&&k&&!S&&!W||c&&w&&k||!s&&k||!f)return 1;if(!c&&!g&&!W&&e<t||W&&s&&f&&!c&&!g||S&&s&&f||!w&&f||!k)return-1}return 0}function Lp(e,t,s){for(var c=-1,f=e.criteria,g=t.criteria,w=f.length,S=s.length;++c<w;){var k=Sl(f[c],g[c]);if(k){if(c>=S)return k;var W=s[c];return k*(W=="desc"?-1:1)}}return e.index-t.index}function Nl(e,t,s,c){for(var f=-1,g=e.length,w=s.length,S=-1,k=t.length,W=lt(g-w,0),H=I(k+W),V=!c;++S<k;)H[S]=t[S];for(;++f<w;)(V||f<g)&&(H[s[f]]=e[f]);for(;W--;)H[S++]=e[f++];return H}function Cl(e,t,s,c){for(var f=-1,g=e.length,w=-1,S=s.length,k=-1,W=t.length,H=lt(g-S,0),V=I(H+W),te=!c;++f<H;)V[f]=e[f];for(var ce=f;++k<W;)V[ce+k]=t[k];for(;++w<S;)(te||f<g)&&(V[ce+s[w]]=e[f++]);return V}function Et(e,t){var s=-1,c=e.length;for(t||(t=I(c));++s<c;)t[s]=e[s];return t}function Jt(e,t,s,c){var f=!s;s||(s={});for(var g=-1,w=t.length;++g<w;){var S=t[g],k=c?c(s[S],e[S],S,s,e):r;k===r&&(k=e[S]),f?un(s,S,k):xr(s,S,k)}return s}function Dp(e,t){return Jt(e,Yi(e),t)}function Op(e,t){return Jt(e,Fl(e),t)}function ps(e,t){return function(s,c){var f=Re(s)?Hf:ip,g=t?t():{};return f(s,e,ge(c,2),g)}}function nr(e){return Me(function(t,s){var c=-1,f=s.length,g=f>1?s[f-1]:r,w=f>2?s[2]:r;for(g=e.length>3&&typeof g=="function"?(f--,g):r,w&&vt(s[0],s[1],w)&&(g=f<3?r:g,f=1),t=qe(t);++c<f;){var S=s[c];S&&e(t,S,c,g)}return t})}function Tl(e,t){return function(s,c){if(s==null)return s;if(!St(s))return e(s,c);for(var f=s.length,g=t?f:-1,w=qe(s);(t?g--:++g<f)&&c(w[g],g,w)!==!1;);return s}}function Rl(e){return function(t,s,c){for(var f=-1,g=qe(t),w=c(t),S=w.length;S--;){var k=w[e?S:++f];if(s(g[k],k,g)===!1)break}return t}}function Bp(e,t,s){var c=t&A,f=Er(e);function g(){var w=this&&this!==dt&&this instanceof g?f:e;return w.apply(c?s:this,arguments)}return g}function kl(e){return function(t){t=He(t);var s=Vn(t)?Gt(t):r,c=s?s[0]:t.charAt(0),f=s?Cn(s,1).join(""):t.slice(1);return c[e]()+f}}function rr(e){return function(t){return fi(Tc(Cc(t).replace(Rf,"")),e,"")}}function Er(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var s=tr(e.prototype),c=e.apply(s,t);return Ze(c)?c:s}}function Fp(e,t,s){var c=Er(e);function f(){for(var g=arguments.length,w=I(g),S=g,k=sr(f);S--;)w[S]=arguments[S];var W=g<3&&w[0]!==k&&w[g-1]!==k?[]:yn(w,k);if(g-=W.length,g<s)return Il(e,t,ms,f.placeholder,r,w,W,r,r,s-g);var H=this&&this!==dt&&this instanceof f?c:e;return Tt(H,this,w)}return f}function Al(e){return function(t,s,c){var f=qe(t);if(!St(t)){var g=ge(s,3);t=ut(t),s=function(S){return g(f[S],S,f)}}var w=e(t,s,c);return w>-1?f[g?t[w]:w]:r}}function jl(e){return fn(function(t){var s=t.length,c=s,f=Dt.prototype.thru;for(e&&t.reverse();c--;){var g=t[c];if(typeof g!="function")throw new Lt(_);if(f&&!w&&vs(g)=="wrapper")var w=new Dt([],!0)}for(c=w?c:s;++c<s;){g=t[c];var S=vs(g),k=S=="wrapper"?$i(g):r;k&&Ki(k[0])&&k[1]==(q|P|z|Y)&&!k[4].length&&k[9]==1?w=w[vs(k[0])].apply(w,k[3]):w=g.length==1&&Ki(g)?w[S]():w.thru(g)}return function(){var W=arguments,H=W[0];if(w&&W.length==1&&Re(H))return w.plant(H).value();for(var V=0,te=s?t[V].apply(this,W):H;++V<s;)te=t[V].call(this,te);return te}})}function ms(e,t,s,c,f,g,w,S,k,W){var H=t&q,V=t&A,te=t&O,ce=t&(P|j),be=t&B,Pe=te?r:Er(e);function ye(){for(var Ie=arguments.length,Oe=I(Ie),jt=Ie;jt--;)Oe[jt]=arguments[jt];if(ce)var bt=sr(ye),Pt=Qf(Oe,bt);if(c&&(Oe=Nl(Oe,c,f,ce)),g&&(Oe=Cl(Oe,g,w,ce)),Ie-=Pt,ce&&Ie<W){var st=yn(Oe,bt);return Il(e,t,ms,ye.placeholder,s,Oe,st,S,k,W-Ie)}var $t=V?s:this,gn=te?$t[e]:e;return Ie=Oe.length,S?Oe=im(Oe,S):be&&Ie>1&&Oe.reverse(),H&&k<Ie&&(Oe.length=k),this&&this!==dt&&this instanceof ye&&(gn=Pe||Er(gn)),gn.apply($t,Oe)}return ye}function Pl(e,t){return function(s,c){return hp(s,e,t(c),{})}}function gs(e,t){return function(s,c){var f;if(s===r&&c===r)return t;if(s!==r&&(f=s),c!==r){if(f===r)return c;typeof s=="string"||typeof c=="string"?(s=kt(s),c=kt(c)):(s=_l(s),c=_l(c)),f=e(s,c)}return f}}function Hi(e){return fn(function(t){return t=Je(t,Rt(ge())),Me(function(s){var c=this;return e(t,function(f){return Tt(f,c,s)})})})}function _s(e,t){t=t===r?" ":kt(t);var s=t.length;if(s<2)return s?Li(t,e):t;var c=Li(t,rs(e/Kn(t)));return Vn(t)?Cn(Gt(c),0,e).join(""):c.slice(0,e)}function Up(e,t,s,c){var f=t&A,g=Er(e);function w(){for(var S=-1,k=arguments.length,W=-1,H=c.length,V=I(H+k),te=this&&this!==dt&&this instanceof w?g:e;++W<H;)V[W]=c[W];for(;k--;)V[W++]=arguments[++S];return Tt(te,f?s:this,V)}return w}function Ml(e){return function(t,s,c){return c&&typeof c!="number"&&vt(t,s,c)&&(s=c=r),t=mn(t),s===r?(s=t,t=0):s=mn(s),c=c===r?t<s?1:-1:mn(c),Np(t,s,c,e)}}function xs(e){return function(t,s){return typeof t=="string"&&typeof s=="string"||(t=Ut(t),s=Ut(s)),e(t,s)}}function Il(e,t,s,c,f,g,w,S,k,W){var H=t&P,V=H?w:r,te=H?r:w,ce=H?g:r,be=H?r:g;t|=H?z:Q,t&=~(H?Q:z),t&L||(t&=-4);var Pe=[e,t,f,ce,V,be,te,S,k,W],ye=s.apply(r,Pe);return Ki(e)&&$l(ye,Pe),ye.placeholder=c,Xl(ye,e,t)}function Gi(e){var t=at[e];return function(s,c){if(s=Ut(s),c=c==null?0:pt(Ae(c),292),c&&Xa(s)){var f=(He(s)+"e").split("e"),g=t(f[0]+"e"+(+f[1]+c));return f=(He(g)+"e").split("e"),+(f[0]+"e"+(+f[1]-c))}return t(s)}}var Wp=Zn&&1/Xr(new Zn([,-0]))[1]==ne?function(e){return new Zn(e)}:fo;function Ll(e){return function(t){var s=mt(t);return s==de?vi(t):s==xe?sh(t):Kf(t,e(t))}}function dn(e,t,s,c,f,g,w,S){var k=t&O;if(!k&&typeof e!="function")throw new Lt(_);var W=c?c.length:0;if(W||(t&=-97,c=f=r),w=w===r?w:lt(Ae(w),0),S=S===r?S:Ae(S),W-=f?f.length:0,t&Q){var H=c,V=f;c=f=r}var te=k?r:$i(e),ce=[e,t,s,c,f,H,V,g,w,S];if(te&&nm(ce,te),e=ce[0],t=ce[1],s=ce[2],c=ce[3],f=ce[4],S=ce[9]=ce[9]===r?k?0:e.length:lt(ce[9]-W,0),!S&&t&(P|j)&&(t&=-25),!t||t==A)var be=Bp(e,t,s);else t==P||t==j?be=Fp(e,t,S):(t==z||t==(A|z))&&!f.length?be=Up(e,t,s,c):be=ms.apply(r,ce);var Pe=te?ml:$l;return Xl(Pe(be,ce),e,t)}function Dl(e,t,s,c){return e===r||qt(e,Jn[s])&&!Ge.call(c,s)?t:e}function Ol(e,t,s,c,f,g){return Ze(e)&&Ze(t)&&(g.set(t,e),ds(e,t,r,Ol,g),g.delete(t)),e}function Hp(e){return Cr(e)?r:e}function Bl(e,t,s,c,f,g){var w=s&N,S=e.length,k=t.length;if(S!=k&&!(w&&k>S))return!1;var W=g.get(e),H=g.get(t);if(W&&H)return W==t&&H==e;var V=-1,te=!0,ce=s&M?new Dn:r;for(g.set(e,t),g.set(t,e);++V<S;){var be=e[V],Pe=t[V];if(c)var ye=w?c(Pe,be,V,t,e,g):c(be,Pe,V,e,t,g);if(ye!==r){if(ye)continue;te=!1;break}if(ce){if(!hi(t,function(Ie,Oe){if(!fr(ce,Oe)&&(be===Ie||f(be,Ie,s,c,g)))return ce.push(Oe)})){te=!1;break}}else if(!(be===Pe||f(be,Pe,s,c,g))){te=!1;break}}return g.delete(e),g.delete(t),te}function Gp(e,t,s,c,f,g,w){switch(s){case Ve:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case it:return!(e.byteLength!=t.byteLength||!g(new Zr(e),new Zr(t)));case me:case D:case Ne:return qt(+e,+t);case he:return e.name==t.name&&e.message==t.message;case fe:case Ce:return e==t+"";case de:var S=vi;case xe:var k=c&N;if(S||(S=Xr),e.size!=t.size&&!k)return!1;var W=w.get(e);if(W)return W==t;c|=M,w.set(e,t);var H=Bl(S(e),S(t),c,f,g,w);return w.delete(e),H;case pe:if(_r)return _r.call(e)==_r.call(t)}return!1}function zp(e,t,s,c,f,g){var w=s&N,S=zi(e),k=S.length,W=zi(t),H=W.length;if(k!=H&&!w)return!1;for(var V=k;V--;){var te=S[V];if(!(w?te in t:Ge.call(t,te)))return!1}var ce=g.get(e),be=g.get(t);if(ce&&be)return ce==t&&be==e;var Pe=!0;g.set(e,t),g.set(t,e);for(var ye=w;++V<k;){te=S[V];var Ie=e[te],Oe=t[te];if(c)var jt=w?c(Oe,Ie,te,t,e,g):c(Ie,Oe,te,e,t,g);if(!(jt===r?Ie===Oe||f(Ie,Oe,s,c,g):jt)){Pe=!1;break}ye||(ye=te=="constructor")}if(Pe&&!ye){var bt=e.constructor,Pt=t.constructor;bt!=Pt&&"constructor"in e&&"constructor"in t&&!(typeof bt=="function"&&bt instanceof bt&&typeof Pt=="function"&&Pt instanceof Pt)&&(Pe=!1)}return g.delete(e),g.delete(t),Pe}function fn(e){return Ji(zl(e,r,Zl),e+"")}function zi(e){return sl(e,ut,Yi)}function qi(e){return sl(e,Nt,Fl)}var $i=is?function(e){return is.get(e)}:fo;function vs(e){for(var t=e.name+"",s=er[t],c=Ge.call(er,t)?s.length:0;c--;){var f=s[c],g=f.func;if(g==null||g==e)return f.name}return t}function sr(e){var t=Ge.call(h,"placeholder")?h:e;return t.placeholder}function ge(){var e=h.iteratee||co;return e=e===co?al:e,arguments.length?e(arguments[0],arguments[1]):e}function bs(e,t){var s=e.__data__;return Jp(t)?s[typeof t=="string"?"string":"hash"]:s.map}function Xi(e){for(var t=ut(e),s=t.length;s--;){var c=t[s],f=e[c];t[s]=[c,f,Hl(f)]}return t}function Fn(e,t){var s=th(e,t);return ol(s)?s:r}function qp(e){var t=Ge.call(e,In),s=e[In];try{e[In]=r;var c=!0}catch{}var f=Qr.call(e);return c&&(t?e[In]=s:delete e[In]),f}var Yi=yi?function(e){return e==null?[]:(e=qe(e),vn(yi(e),function(t){return qa.call(e,t)}))}:ho,Fl=yi?function(e){for(var t=[];e;)bn(t,Yi(e)),e=es(e);return t}:ho,mt=xt;(wi&&mt(new wi(new ArrayBuffer(1)))!=Ve||pr&&mt(new pr)!=de||Ei&&mt(Ei.resolve())!=Ee||Zn&&mt(new Zn)!=xe||mr&&mt(new mr)!=yt)&&(mt=function(e){var t=xt(e),s=t==Z?e.constructor:r,c=s?Un(s):"";if(c)switch(c){case Th:return Ve;case Rh:return de;case kh:return Ee;case Ah:return xe;case jh:return yt}return t});function $p(e,t,s){for(var c=-1,f=s.length;++c<f;){var g=s[c],w=g.size;switch(g.type){case"drop":e+=w;break;case"dropRight":t-=w;break;case"take":t=pt(t,e+w);break;case"takeRight":e=lt(e,t-w);break}}return{start:e,end:t}}function Xp(e){var t=e.match(Jd);return t?t[1].split(Zd):[]}function Ul(e,t,s){t=Nn(t,e);for(var c=-1,f=t.length,g=!1;++c<f;){var w=Zt(t[c]);if(!(g=e!=null&&s(e,w)))break;e=e[w]}return g||++c!=f?g:(f=e==null?0:e.length,!!f&&Ts(f)&&hn(w,f)&&(Re(e)||Wn(e)))}function Yp(e){var t=e.length,s=new e.constructor(t);return t&&typeof e[0]=="string"&&Ge.call(e,"index")&&(s.index=e.index,s.input=e.input),s}function Wl(e){return typeof e.constructor=="function"&&!Sr(e)?tr(es(e)):{}}function Vp(e,t,s){var c=e.constructor;switch(t){case it:return Wi(e);case me:case D:return new c(+e);case Ve:return Pp(e,s);case zn:case jn:case Pn:case qn:case dr:case an:case $n:case U:case ve:return El(e,s);case de:return new c;case Ne:case Ce:return new c(e);case fe:return Mp(e);case xe:return new c;case pe:return Ip(e)}}function Kp(e,t){var s=t.length;if(!s)return e;var c=s-1;return t[c]=(s>1?"& ":"")+t[c],t=t.join(s>2?", ":" "),e.replace(Qd,`{
7
- /* [wrapped with `+t+`] */
8
- `)}function Qp(e){return Re(e)||Wn(e)||!!($a&&e&&e[$a])}function hn(e,t){var s=typeof e;return t=t??oe,!!t&&(s=="number"||s!="symbol"&&cf.test(e))&&e>-1&&e%1==0&&e<t}function vt(e,t,s){if(!Ze(s))return!1;var c=typeof t;return(c=="number"?St(s)&&hn(t,s.length):c=="string"&&t in s)?qt(s[t],e):!1}function Vi(e,t){if(Re(e))return!1;var s=typeof e;return s=="number"||s=="symbol"||s=="boolean"||e==null||At(e)?!0:Xd.test(e)||!$d.test(e)||t!=null&&e in qe(t)}function Jp(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Ki(e){var t=vs(e),s=h[t];if(typeof s!="function"||!(t in De.prototype))return!1;if(e===s)return!0;var c=$i(s);return!!c&&e===c[0]}function Zp(e){return!!Ha&&Ha in e}var em=Vr?pn:po;function Sr(e){var t=e&&e.constructor,s=typeof t=="function"&&t.prototype||Jn;return e===s}function Hl(e){return e===e&&!Ze(e)}function Gl(e,t){return function(s){return s==null?!1:s[e]===t&&(t!==r||e in qe(s))}}function tm(e){var t=Ns(e,function(c){return s.size===m&&s.clear(),c}),s=t.cache;return t}function nm(e,t){var s=e[1],c=t[1],f=s|c,g=f<(A|O|q),w=c==q&&s==P||c==q&&s==Y&&e[7].length<=t[8]||c==(q|Y)&&t[7].length<=t[8]&&s==P;if(!(g||w))return e;c&A&&(e[2]=t[2],f|=s&A?0:L);var S=t[3];if(S){var k=e[3];e[3]=k?Nl(k,S,t[4]):S,e[4]=k?yn(e[3],p):t[4]}return S=t[5],S&&(k=e[5],e[5]=k?Cl(k,S,t[6]):S,e[6]=k?yn(e[5],p):t[6]),S=t[7],S&&(e[7]=S),c&q&&(e[8]=e[8]==null?t[8]:pt(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=f,e}function rm(e){var t=[];if(e!=null)for(var s in qe(e))t.push(s);return t}function sm(e){return Qr.call(e)}function zl(e,t,s){return t=lt(t===r?e.length-1:t,0),function(){for(var c=arguments,f=-1,g=lt(c.length-t,0),w=I(g);++f<g;)w[f]=c[t+f];f=-1;for(var S=I(t+1);++f<t;)S[f]=c[f];return S[t]=s(w),Tt(e,this,S)}}function ql(e,t){return t.length<2?e:Bn(e,Bt(t,0,-1))}function im(e,t){for(var s=e.length,c=pt(t.length,s),f=Et(e);c--;){var g=t[c];e[c]=hn(g,s)?f[g]:r}return e}function Qi(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var $l=Yl(ml),Nr=bh||function(e,t){return dt.setTimeout(e,t)},Ji=Yl(Rp);function Xl(e,t,s){var c=t+"";return Ji(e,Kp(c,om(Xp(c),s)))}function Yl(e){var t=0,s=0;return function(){var c=Sh(),f=_e-(c-s);if(s=c,f>0){if(++t>=se)return arguments[0]}else t=0;return e.apply(r,arguments)}}function ys(e,t){var s=-1,c=e.length,f=c-1;for(t=t===r?c:t;++s<t;){var g=Ii(s,f),w=e[g];e[g]=e[s],e[s]=w}return e.length=t,e}var Vl=tm(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Yd,function(s,c,f,g){t.push(f?g.replace(nf,"$1"):c||s)}),t});function Zt(e){if(typeof e=="string"||At(e))return e;var t=e+"";return t=="0"&&1/e==-ne?"-0":t}function Un(e){if(e!=null){try{return Kr.call(e)}catch{}try{return e+""}catch{}}return""}function om(e,t){return It(Se,function(s){var c="_."+s[0];t&s[1]&&!qr(e,c)&&e.push(c)}),e.sort()}function Kl(e){if(e instanceof De)return e.clone();var t=new Dt(e.__wrapped__,e.__chain__);return t.__actions__=Et(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function am(e,t,s){(s?vt(e,t,s):t===r)?t=1:t=lt(Ae(t),0);var c=e==null?0:e.length;if(!c||t<1)return[];for(var f=0,g=0,w=I(rs(c/t));f<c;)w[g++]=Bt(e,f,f+=t);return w}function lm(e){for(var t=-1,s=e==null?0:e.length,c=0,f=[];++t<s;){var g=e[t];g&&(f[c++]=g)}return f}function cm(){var e=arguments.length;if(!e)return[];for(var t=I(e-1),s=arguments[0],c=e;c--;)t[c-1]=arguments[c];return bn(Re(s)?Et(s):[s],ft(t,1))}var um=Me(function(e,t){return rt(e)?vr(e,ft(t,1,rt,!0)):[]}),dm=Me(function(e,t){var s=Ft(t);return rt(s)&&(s=r),rt(e)?vr(e,ft(t,1,rt,!0),ge(s,2)):[]}),fm=Me(function(e,t){var s=Ft(t);return rt(s)&&(s=r),rt(e)?vr(e,ft(t,1,rt,!0),r,s):[]});function hm(e,t,s){var c=e==null?0:e.length;return c?(t=s||t===r?1:Ae(t),Bt(e,t<0?0:t,c)):[]}function pm(e,t,s){var c=e==null?0:e.length;return c?(t=s||t===r?1:Ae(t),t=c-t,Bt(e,0,t<0?0:t)):[]}function mm(e,t){return e&&e.length?hs(e,ge(t,3),!0,!0):[]}function gm(e,t){return e&&e.length?hs(e,ge(t,3),!0):[]}function _m(e,t,s,c){var f=e==null?0:e.length;return f?(s&&typeof s!="number"&&vt(e,t,s)&&(s=0,c=f),cp(e,t,s,c)):[]}function Ql(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=s==null?0:Ae(s);return f<0&&(f=lt(c+f,0)),$r(e,ge(t,3),f)}function Jl(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=c-1;return s!==r&&(f=Ae(s),f=s<0?lt(c+f,0):pt(f,c-1)),$r(e,ge(t,3),f,!0)}function Zl(e){var t=e==null?0:e.length;return t?ft(e,1):[]}function xm(e){var t=e==null?0:e.length;return t?ft(e,ne):[]}function vm(e,t){var s=e==null?0:e.length;return s?(t=t===r?1:Ae(t),ft(e,t)):[]}function bm(e){for(var t=-1,s=e==null?0:e.length,c={};++t<s;){var f=e[t];c[f[0]]=f[1]}return c}function ec(e){return e&&e.length?e[0]:r}function ym(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=s==null?0:Ae(s);return f<0&&(f=lt(c+f,0)),Yn(e,t,f)}function wm(e){var t=e==null?0:e.length;return t?Bt(e,0,-1):[]}var Em=Me(function(e){var t=Je(e,Fi);return t.length&&t[0]===e[0]?ki(t):[]}),Sm=Me(function(e){var t=Ft(e),s=Je(e,Fi);return t===Ft(s)?t=r:s.pop(),s.length&&s[0]===e[0]?ki(s,ge(t,2)):[]}),Nm=Me(function(e){var t=Ft(e),s=Je(e,Fi);return t=typeof t=="function"?t:r,t&&s.pop(),s.length&&s[0]===e[0]?ki(s,r,t):[]});function Cm(e,t){return e==null?"":wh.call(e,t)}function Ft(e){var t=e==null?0:e.length;return t?e[t-1]:r}function Tm(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=c;return s!==r&&(f=Ae(s),f=f<0?lt(c+f,0):pt(f,c-1)),t===t?oh(e,t,f):$r(e,Ia,f,!0)}function Rm(e,t){return e&&e.length?dl(e,Ae(t)):r}var km=Me(tc);function tc(e,t){return e&&e.length&&t&&t.length?Mi(e,t):e}function Am(e,t,s){return e&&e.length&&t&&t.length?Mi(e,t,ge(s,2)):e}function jm(e,t,s){return e&&e.length&&t&&t.length?Mi(e,t,r,s):e}var Pm=fn(function(e,t){var s=e==null?0:e.length,c=Ni(e,t);return pl(e,Je(t,function(f){return hn(f,s)?+f:f}).sort(Sl)),c});function Mm(e,t){var s=[];if(!(e&&e.length))return s;var c=-1,f=[],g=e.length;for(t=ge(t,3);++c<g;){var w=e[c];t(w,c,e)&&(s.push(w),f.push(c))}return pl(e,f),s}function Zi(e){return e==null?e:Ch.call(e)}function Im(e,t,s){var c=e==null?0:e.length;return c?(s&&typeof s!="number"&&vt(e,t,s)?(t=0,s=c):(t=t==null?0:Ae(t),s=s===r?c:Ae(s)),Bt(e,t,s)):[]}function Lm(e,t){return fs(e,t)}function Dm(e,t,s){return Di(e,t,ge(s,2))}function Om(e,t){var s=e==null?0:e.length;if(s){var c=fs(e,t);if(c<s&&qt(e[c],t))return c}return-1}function Bm(e,t){return fs(e,t,!0)}function Fm(e,t,s){return Di(e,t,ge(s,2),!0)}function Um(e,t){var s=e==null?0:e.length;if(s){var c=fs(e,t,!0)-1;if(qt(e[c],t))return c}return-1}function Wm(e){return e&&e.length?gl(e):[]}function Hm(e,t){return e&&e.length?gl(e,ge(t,2)):[]}function Gm(e){var t=e==null?0:e.length;return t?Bt(e,1,t):[]}function zm(e,t,s){return e&&e.length?(t=s||t===r?1:Ae(t),Bt(e,0,t<0?0:t)):[]}function qm(e,t,s){var c=e==null?0:e.length;return c?(t=s||t===r?1:Ae(t),t=c-t,Bt(e,t<0?0:t,c)):[]}function $m(e,t){return e&&e.length?hs(e,ge(t,3),!1,!0):[]}function Xm(e,t){return e&&e.length?hs(e,ge(t,3)):[]}var Ym=Me(function(e){return Sn(ft(e,1,rt,!0))}),Vm=Me(function(e){var t=Ft(e);return rt(t)&&(t=r),Sn(ft(e,1,rt,!0),ge(t,2))}),Km=Me(function(e){var t=Ft(e);return t=typeof t=="function"?t:r,Sn(ft(e,1,rt,!0),r,t)});function Qm(e){return e&&e.length?Sn(e):[]}function Jm(e,t){return e&&e.length?Sn(e,ge(t,2)):[]}function Zm(e,t){return t=typeof t=="function"?t:r,e&&e.length?Sn(e,r,t):[]}function eo(e){if(!(e&&e.length))return[];var t=0;return e=vn(e,function(s){if(rt(s))return t=lt(s.length,t),!0}),_i(t,function(s){return Je(e,pi(s))})}function nc(e,t){if(!(e&&e.length))return[];var s=eo(e);return t==null?s:Je(s,function(c){return Tt(t,r,c)})}var e0=Me(function(e,t){return rt(e)?vr(e,t):[]}),t0=Me(function(e){return Bi(vn(e,rt))}),n0=Me(function(e){var t=Ft(e);return rt(t)&&(t=r),Bi(vn(e,rt),ge(t,2))}),r0=Me(function(e){var t=Ft(e);return t=typeof t=="function"?t:r,Bi(vn(e,rt),r,t)}),s0=Me(eo);function i0(e,t){return bl(e||[],t||[],xr)}function o0(e,t){return bl(e||[],t||[],wr)}var a0=Me(function(e){var t=e.length,s=t>1?e[t-1]:r;return s=typeof s=="function"?(e.pop(),s):r,nc(e,s)});function rc(e){var t=h(e);return t.__chain__=!0,t}function l0(e,t){return t(e),e}function ws(e,t){return t(e)}var c0=fn(function(e){var t=e.length,s=t?e[0]:0,c=this.__wrapped__,f=function(g){return Ni(g,e)};return t>1||this.__actions__.length||!(c instanceof De)||!hn(s)?this.thru(f):(c=c.slice(s,+s+(t?1:0)),c.__actions__.push({func:ws,args:[f],thisArg:r}),new Dt(c,this.__chain__).thru(function(g){return t&&!g.length&&g.push(r),g}))});function u0(){return rc(this)}function d0(){return new Dt(this.value(),this.__chain__)}function f0(){this.__values__===r&&(this.__values__=_c(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function h0(){return this}function p0(e){for(var t,s=this;s instanceof as;){var c=Kl(s);c.__index__=0,c.__values__=r,t?f.__wrapped__=c:t=c;var f=c;s=s.__wrapped__}return f.__wrapped__=e,t}function m0(){var e=this.__wrapped__;if(e instanceof De){var t=e;return this.__actions__.length&&(t=new De(this)),t=t.reverse(),t.__actions__.push({func:ws,args:[Zi],thisArg:r}),new Dt(t,this.__chain__)}return this.thru(Zi)}function g0(){return vl(this.__wrapped__,this.__actions__)}var _0=ps(function(e,t,s){Ge.call(e,s)?++e[s]:un(e,s,1)});function x0(e,t,s){var c=Re(e)?Pa:lp;return s&&vt(e,t,s)&&(t=r),c(e,ge(t,3))}function v0(e,t){var s=Re(e)?vn:nl;return s(e,ge(t,3))}var b0=Al(Ql),y0=Al(Jl);function w0(e,t){return ft(Es(e,t),1)}function E0(e,t){return ft(Es(e,t),ne)}function S0(e,t,s){return s=s===r?1:Ae(s),ft(Es(e,t),s)}function sc(e,t){var s=Re(e)?It:En;return s(e,ge(t,3))}function ic(e,t){var s=Re(e)?Gf:tl;return s(e,ge(t,3))}var N0=ps(function(e,t,s){Ge.call(e,s)?e[s].push(t):un(e,s,[t])});function C0(e,t,s,c){e=St(e)?e:or(e),s=s&&!c?Ae(s):0;var f=e.length;return s<0&&(s=lt(f+s,0)),Rs(e)?s<=f&&e.indexOf(t,s)>-1:!!f&&Yn(e,t,s)>-1}var T0=Me(function(e,t,s){var c=-1,f=typeof t=="function",g=St(e)?I(e.length):[];return En(e,function(w){g[++c]=f?Tt(t,w,s):br(w,t,s)}),g}),R0=ps(function(e,t,s){un(e,s,t)});function Es(e,t){var s=Re(e)?Je:ll;return s(e,ge(t,3))}function k0(e,t,s,c){return e==null?[]:(Re(t)||(t=t==null?[]:[t]),s=c?r:s,Re(s)||(s=s==null?[]:[s]),fl(e,t,s))}var A0=ps(function(e,t,s){e[s?0:1].push(t)},function(){return[[],[]]});function j0(e,t,s){var c=Re(e)?fi:Da,f=arguments.length<3;return c(e,ge(t,4),s,f,En)}function P0(e,t,s){var c=Re(e)?zf:Da,f=arguments.length<3;return c(e,ge(t,4),s,f,tl)}function M0(e,t){var s=Re(e)?vn:nl;return s(e,Cs(ge(t,3)))}function I0(e){var t=Re(e)?Qa:Cp;return t(e)}function L0(e,t,s){(s?vt(e,t,s):t===r)?t=1:t=Ae(t);var c=Re(e)?rp:Tp;return c(e,t)}function D0(e){var t=Re(e)?sp:kp;return t(e)}function O0(e){if(e==null)return 0;if(St(e))return Rs(e)?Kn(e):e.length;var t=mt(e);return t==de||t==xe?e.size:ji(e).length}function B0(e,t,s){var c=Re(e)?hi:Ap;return s&&vt(e,t,s)&&(t=r),c(e,ge(t,3))}var F0=Me(function(e,t){if(e==null)return[];var s=t.length;return s>1&&vt(e,t[0],t[1])?t=[]:s>2&&vt(t[0],t[1],t[2])&&(t=[t[0]]),fl(e,ft(t,1),[])}),Ss=vh||function(){return dt.Date.now()};function U0(e,t){if(typeof t!="function")throw new Lt(_);return e=Ae(e),function(){if(--e<1)return t.apply(this,arguments)}}function oc(e,t,s){return t=s?r:t,t=e&&t==null?e.length:t,dn(e,q,r,r,r,r,t)}function ac(e,t){var s;if(typeof t!="function")throw new Lt(_);return e=Ae(e),function(){return--e>0&&(s=t.apply(this,arguments)),e<=1&&(t=r),s}}var to=Me(function(e,t,s){var c=A;if(s.length){var f=yn(s,sr(to));c|=z}return dn(e,c,t,s,f)}),lc=Me(function(e,t,s){var c=A|O;if(s.length){var f=yn(s,sr(lc));c|=z}return dn(t,c,e,s,f)});function cc(e,t,s){t=s?r:t;var c=dn(e,P,r,r,r,r,r,t);return c.placeholder=cc.placeholder,c}function uc(e,t,s){t=s?r:t;var c=dn(e,j,r,r,r,r,r,t);return c.placeholder=uc.placeholder,c}function dc(e,t,s){var c,f,g,w,S,k,W=0,H=!1,V=!1,te=!0;if(typeof e!="function")throw new Lt(_);t=Ut(t)||0,Ze(s)&&(H=!!s.leading,V="maxWait"in s,g=V?lt(Ut(s.maxWait)||0,t):g,te="trailing"in s?!!s.trailing:te);function ce(st){var $t=c,gn=f;return c=f=r,W=st,w=e.apply(gn,$t),w}function be(st){return W=st,S=Nr(Ie,t),H?ce(st):w}function Pe(st){var $t=st-k,gn=st-W,Ac=t-$t;return V?pt(Ac,g-gn):Ac}function ye(st){var $t=st-k,gn=st-W;return k===r||$t>=t||$t<0||V&&gn>=g}function Ie(){var st=Ss();if(ye(st))return Oe(st);S=Nr(Ie,Pe(st))}function Oe(st){return S=r,te&&c?ce(st):(c=f=r,w)}function jt(){S!==r&&yl(S),W=0,c=k=f=S=r}function bt(){return S===r?w:Oe(Ss())}function Pt(){var st=Ss(),$t=ye(st);if(c=arguments,f=this,k=st,$t){if(S===r)return be(k);if(V)return yl(S),S=Nr(Ie,t),ce(k)}return S===r&&(S=Nr(Ie,t)),w}return Pt.cancel=jt,Pt.flush=bt,Pt}var W0=Me(function(e,t){return el(e,1,t)}),H0=Me(function(e,t,s){return el(e,Ut(t)||0,s)});function G0(e){return dn(e,B)}function Ns(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new Lt(_);var s=function(){var c=arguments,f=t?t.apply(this,c):c[0],g=s.cache;if(g.has(f))return g.get(f);var w=e.apply(this,c);return s.cache=g.set(f,w)||g,w};return s.cache=new(Ns.Cache||cn),s}Ns.Cache=cn;function Cs(e){if(typeof e!="function")throw new Lt(_);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function z0(e){return ac(2,e)}var q0=jp(function(e,t){t=t.length==1&&Re(t[0])?Je(t[0],Rt(ge())):Je(ft(t,1),Rt(ge()));var s=t.length;return Me(function(c){for(var f=-1,g=pt(c.length,s);++f<g;)c[f]=t[f].call(this,c[f]);return Tt(e,this,c)})}),no=Me(function(e,t){var s=yn(t,sr(no));return dn(e,z,r,t,s)}),fc=Me(function(e,t){var s=yn(t,sr(fc));return dn(e,Q,r,t,s)}),$0=fn(function(e,t){return dn(e,Y,r,r,r,t)});function X0(e,t){if(typeof e!="function")throw new Lt(_);return t=t===r?t:Ae(t),Me(e,t)}function Y0(e,t){if(typeof e!="function")throw new Lt(_);return t=t==null?0:lt(Ae(t),0),Me(function(s){var c=s[t],f=Cn(s,0,t);return c&&bn(f,c),Tt(e,this,f)})}function V0(e,t,s){var c=!0,f=!0;if(typeof e!="function")throw new Lt(_);return Ze(s)&&(c="leading"in s?!!s.leading:c,f="trailing"in s?!!s.trailing:f),dc(e,t,{leading:c,maxWait:t,trailing:f})}function K0(e){return oc(e,1)}function Q0(e,t){return no(Ui(t),e)}function J0(){if(!arguments.length)return[];var e=arguments[0];return Re(e)?e:[e]}function Z0(e){return Ot(e,b)}function eg(e,t){return t=typeof t=="function"?t:r,Ot(e,b,t)}function tg(e){return Ot(e,x|b)}function ng(e,t){return t=typeof t=="function"?t:r,Ot(e,x|b,t)}function rg(e,t){return t==null||Za(e,t,ut(t))}function qt(e,t){return e===t||e!==e&&t!==t}var sg=xs(Ri),ig=xs(function(e,t){return e>=t}),Wn=il((function(){return arguments})())?il:function(e){return et(e)&&Ge.call(e,"callee")&&!qa.call(e,"callee")},Re=I.isArray,og=Ca?Rt(Ca):pp;function St(e){return e!=null&&Ts(e.length)&&!pn(e)}function rt(e){return et(e)&&St(e)}function ag(e){return e===!0||e===!1||et(e)&&xt(e)==me}var Tn=yh||po,lg=Ta?Rt(Ta):mp;function cg(e){return et(e)&&e.nodeType===1&&!Cr(e)}function ug(e){if(e==null)return!0;if(St(e)&&(Re(e)||typeof e=="string"||typeof e.splice=="function"||Tn(e)||ir(e)||Wn(e)))return!e.length;var t=mt(e);if(t==de||t==xe)return!e.size;if(Sr(e))return!ji(e).length;for(var s in e)if(Ge.call(e,s))return!1;return!0}function dg(e,t){return yr(e,t)}function fg(e,t,s){s=typeof s=="function"?s:r;var c=s?s(e,t):r;return c===r?yr(e,t,r,s):!!c}function ro(e){if(!et(e))return!1;var t=xt(e);return t==he||t==le||typeof e.message=="string"&&typeof e.name=="string"&&!Cr(e)}function hg(e){return typeof e=="number"&&Xa(e)}function pn(e){if(!Ze(e))return!1;var t=xt(e);return t==Fe||t==We||t==Qe||t==je}function hc(e){return typeof e=="number"&&e==Ae(e)}function Ts(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=oe}function Ze(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function et(e){return e!=null&&typeof e=="object"}var pc=Ra?Rt(Ra):_p;function pg(e,t){return e===t||Ai(e,t,Xi(t))}function mg(e,t,s){return s=typeof s=="function"?s:r,Ai(e,t,Xi(t),s)}function gg(e){return mc(e)&&e!=+e}function _g(e){if(em(e))throw new Te(l);return ol(e)}function xg(e){return e===null}function vg(e){return e==null}function mc(e){return typeof e=="number"||et(e)&&xt(e)==Ne}function Cr(e){if(!et(e)||xt(e)!=Z)return!1;var t=es(e);if(t===null)return!0;var s=Ge.call(t,"constructor")&&t.constructor;return typeof s=="function"&&s instanceof s&&Kr.call(s)==mh}var so=ka?Rt(ka):xp;function bg(e){return hc(e)&&e>=-oe&&e<=oe}var gc=Aa?Rt(Aa):vp;function Rs(e){return typeof e=="string"||!Re(e)&&et(e)&&xt(e)==Ce}function At(e){return typeof e=="symbol"||et(e)&&xt(e)==pe}var ir=ja?Rt(ja):bp;function yg(e){return e===r}function wg(e){return et(e)&&mt(e)==yt}function Eg(e){return et(e)&&xt(e)==wt}var Sg=xs(Pi),Ng=xs(function(e,t){return e<=t});function _c(e){if(!e)return[];if(St(e))return Rs(e)?Gt(e):Et(e);if(hr&&e[hr])return rh(e[hr]());var t=mt(e),s=t==de?vi:t==xe?Xr:or;return s(e)}function mn(e){if(!e)return e===0?e:0;if(e=Ut(e),e===ne||e===-ne){var t=e<0?-1:1;return t*ke}return e===e?e:0}function Ae(e){var t=mn(e),s=t%1;return t===t?s?t-s:t:0}function xc(e){return e?On(Ae(e),0,J):0}function Ut(e){if(typeof e=="number")return e;if(At(e))return G;if(Ze(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Ze(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Oa(e);var s=of.test(e);return s||lf.test(e)?Uf(e.slice(2),s?2:8):sf.test(e)?G:+e}function vc(e){return Jt(e,Nt(e))}function Cg(e){return e?On(Ae(e),-oe,oe):e===0?e:0}function He(e){return e==null?"":kt(e)}var Tg=nr(function(e,t){if(Sr(t)||St(t)){Jt(t,ut(t),e);return}for(var s in t)Ge.call(t,s)&&xr(e,s,t[s])}),bc=nr(function(e,t){Jt(t,Nt(t),e)}),ks=nr(function(e,t,s,c){Jt(t,Nt(t),e,c)}),Rg=nr(function(e,t,s,c){Jt(t,ut(t),e,c)}),kg=fn(Ni);function Ag(e,t){var s=tr(e);return t==null?s:Ja(s,t)}var jg=Me(function(e,t){e=qe(e);var s=-1,c=t.length,f=c>2?t[2]:r;for(f&&vt(t[0],t[1],f)&&(c=1);++s<c;)for(var g=t[s],w=Nt(g),S=-1,k=w.length;++S<k;){var W=w[S],H=e[W];(H===r||qt(H,Jn[W])&&!Ge.call(e,W))&&(e[W]=g[W])}return e}),Pg=Me(function(e){return e.push(r,Ol),Tt(yc,r,e)});function Mg(e,t){return Ma(e,ge(t,3),Qt)}function Ig(e,t){return Ma(e,ge(t,3),Ti)}function Lg(e,t){return e==null?e:Ci(e,ge(t,3),Nt)}function Dg(e,t){return e==null?e:rl(e,ge(t,3),Nt)}function Og(e,t){return e&&Qt(e,ge(t,3))}function Bg(e,t){return e&&Ti(e,ge(t,3))}function Fg(e){return e==null?[]:us(e,ut(e))}function Ug(e){return e==null?[]:us(e,Nt(e))}function io(e,t,s){var c=e==null?r:Bn(e,t);return c===r?s:c}function Wg(e,t){return e!=null&&Ul(e,t,up)}function oo(e,t){return e!=null&&Ul(e,t,dp)}var Hg=Pl(function(e,t,s){t!=null&&typeof t.toString!="function"&&(t=Qr.call(t)),e[t]=s},lo(Ct)),Gg=Pl(function(e,t,s){t!=null&&typeof t.toString!="function"&&(t=Qr.call(t)),Ge.call(e,t)?e[t].push(s):e[t]=[s]},ge),zg=Me(br);function ut(e){return St(e)?Ka(e):ji(e)}function Nt(e){return St(e)?Ka(e,!0):yp(e)}function qg(e,t){var s={};return t=ge(t,3),Qt(e,function(c,f,g){un(s,t(c,f,g),c)}),s}function $g(e,t){var s={};return t=ge(t,3),Qt(e,function(c,f,g){un(s,f,t(c,f,g))}),s}var Xg=nr(function(e,t,s){ds(e,t,s)}),yc=nr(function(e,t,s,c){ds(e,t,s,c)}),Yg=fn(function(e,t){var s={};if(e==null)return s;var c=!1;t=Je(t,function(g){return g=Nn(g,e),c||(c=g.length>1),g}),Jt(e,qi(e),s),c&&(s=Ot(s,x|y|b,Hp));for(var f=t.length;f--;)Oi(s,t[f]);return s});function Vg(e,t){return wc(e,Cs(ge(t)))}var Kg=fn(function(e,t){return e==null?{}:Ep(e,t)});function wc(e,t){if(e==null)return{};var s=Je(qi(e),function(c){return[c]});return t=ge(t),hl(e,s,function(c,f){return t(c,f[0])})}function Qg(e,t,s){t=Nn(t,e);var c=-1,f=t.length;for(f||(f=1,e=r);++c<f;){var g=e==null?r:e[Zt(t[c])];g===r&&(c=f,g=s),e=pn(g)?g.call(e):g}return e}function Jg(e,t,s){return e==null?e:wr(e,t,s)}function Zg(e,t,s,c){return c=typeof c=="function"?c:r,e==null?e:wr(e,t,s,c)}var Ec=Ll(ut),Sc=Ll(Nt);function e_(e,t,s){var c=Re(e),f=c||Tn(e)||ir(e);if(t=ge(t,4),s==null){var g=e&&e.constructor;f?s=c?new g:[]:Ze(e)?s=pn(g)?tr(es(e)):{}:s={}}return(f?It:Qt)(e,function(w,S,k){return t(s,w,S,k)}),s}function t_(e,t){return e==null?!0:Oi(e,t)}function n_(e,t,s){return e==null?e:xl(e,t,Ui(s))}function r_(e,t,s,c){return c=typeof c=="function"?c:r,e==null?e:xl(e,t,Ui(s),c)}function or(e){return e==null?[]:xi(e,ut(e))}function s_(e){return e==null?[]:xi(e,Nt(e))}function i_(e,t,s){return s===r&&(s=t,t=r),s!==r&&(s=Ut(s),s=s===s?s:0),t!==r&&(t=Ut(t),t=t===t?t:0),On(Ut(e),t,s)}function o_(e,t,s){return t=mn(t),s===r?(s=t,t=0):s=mn(s),e=Ut(e),fp(e,t,s)}function a_(e,t,s){if(s&&typeof s!="boolean"&&vt(e,t,s)&&(t=s=r),s===r&&(typeof t=="boolean"?(s=t,t=r):typeof e=="boolean"&&(s=e,e=r)),e===r&&t===r?(e=0,t=1):(e=mn(e),t===r?(t=e,e=0):t=mn(t)),e>t){var c=e;e=t,t=c}if(s||e%1||t%1){var f=Ya();return pt(e+f*(t-e+Ff("1e-"+((f+"").length-1))),t)}return Ii(e,t)}var l_=rr(function(e,t,s){return t=t.toLowerCase(),e+(s?Nc(t):t)});function Nc(e){return ao(He(e).toLowerCase())}function Cc(e){return e=He(e),e&&e.replace(uf,Jf).replace(kf,"")}function c_(e,t,s){e=He(e),t=kt(t);var c=e.length;s=s===r?c:On(Ae(s),0,c);var f=s;return s-=t.length,s>=0&&e.slice(s,f)==t}function u_(e){return e=He(e),e&&Gd.test(e)?e.replace(ra,Zf):e}function d_(e){return e=He(e),e&&Vd.test(e)?e.replace(ni,"\\$&"):e}var f_=rr(function(e,t,s){return e+(s?"-":"")+t.toLowerCase()}),h_=rr(function(e,t,s){return e+(s?" ":"")+t.toLowerCase()}),p_=kl("toLowerCase");function m_(e,t,s){e=He(e),t=Ae(t);var c=t?Kn(e):0;if(!t||c>=t)return e;var f=(t-c)/2;return _s(ss(f),s)+e+_s(rs(f),s)}function g_(e,t,s){e=He(e),t=Ae(t);var c=t?Kn(e):0;return t&&c<t?e+_s(t-c,s):e}function __(e,t,s){e=He(e),t=Ae(t);var c=t?Kn(e):0;return t&&c<t?_s(t-c,s)+e:e}function x_(e,t,s){return s||t==null?t=0:t&&(t=+t),Nh(He(e).replace(ri,""),t||0)}function v_(e,t,s){return(s?vt(e,t,s):t===r)?t=1:t=Ae(t),Li(He(e),t)}function b_(){var e=arguments,t=He(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var y_=rr(function(e,t,s){return e+(s?"_":"")+t.toLowerCase()});function w_(e,t,s){return s&&typeof s!="number"&&vt(e,t,s)&&(t=s=r),s=s===r?J:s>>>0,s?(e=He(e),e&&(typeof t=="string"||t!=null&&!so(t))&&(t=kt(t),!t&&Vn(e))?Cn(Gt(e),0,s):e.split(t,s)):[]}var E_=rr(function(e,t,s){return e+(s?" ":"")+ao(t)});function S_(e,t,s){return e=He(e),s=s==null?0:On(Ae(s),0,e.length),t=kt(t),e.slice(s,s+t.length)==t}function N_(e,t,s){var c=h.templateSettings;s&&vt(e,t,s)&&(t=r),e=He(e),t=ks({},t,c,Dl);var f=ks({},t.imports,c.imports,Dl),g=ut(f),w=xi(f,g),S,k,W=0,H=t.interpolate||Hr,V="__p += '",te=bi((t.escape||Hr).source+"|"+H.source+"|"+(H===sa?rf:Hr).source+"|"+(t.evaluate||Hr).source+"|$","g"),ce="//# sourceURL="+(Ge.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++If+"]")+`
9
- `;e.replace(te,function(ye,Ie,Oe,jt,bt,Pt){return Oe||(Oe=jt),V+=e.slice(W,Pt).replace(df,eh),Ie&&(S=!0,V+=`' +
10
- __e(`+Ie+`) +
11
- '`),bt&&(k=!0,V+=`';
12
- `+bt+`;
13
- __p += '`),Oe&&(V+=`' +
14
- ((__t = (`+Oe+`)) == null ? '' : __t) +
15
- '`),W=Pt+ye.length,ye}),V+=`';
16
- `;var be=Ge.call(t,"variable")&&t.variable;if(!be)V=`with (obj) {
17
- `+V+`
18
- }
19
- `;else if(tf.test(be))throw new Te(v);V=(k?V.replace(Kt,""):V).replace(ti,"$1").replace(Wr,"$1;"),V="function("+(be||"obj")+`) {
20
- `+(be?"":`obj || (obj = {});
21
- `)+"var __t, __p = ''"+(S?", __e = _.escape":"")+(k?`, __j = Array.prototype.join;
22
- function print() { __p += __j.call(arguments, '') }
23
- `:`;
24
- `)+V+`return __p
25
- }`;var Pe=Rc(function(){return Ue(g,ce+"return "+V).apply(r,w)});if(Pe.source=V,ro(Pe))throw Pe;return Pe}function C_(e){return He(e).toLowerCase()}function T_(e){return He(e).toUpperCase()}function R_(e,t,s){if(e=He(e),e&&(s||t===r))return Oa(e);if(!e||!(t=kt(t)))return e;var c=Gt(e),f=Gt(t),g=Ba(c,f),w=Fa(c,f)+1;return Cn(c,g,w).join("")}function k_(e,t,s){if(e=He(e),e&&(s||t===r))return e.slice(0,Wa(e)+1);if(!e||!(t=kt(t)))return e;var c=Gt(e),f=Fa(c,Gt(t))+1;return Cn(c,0,f).join("")}function A_(e,t,s){if(e=He(e),e&&(s||t===r))return e.replace(ri,"");if(!e||!(t=kt(t)))return e;var c=Gt(e),f=Ba(c,Gt(t));return Cn(c,f).join("")}function j_(e,t){var s=C,c=R;if(Ze(t)){var f="separator"in t?t.separator:f;s="length"in t?Ae(t.length):s,c="omission"in t?kt(t.omission):c}e=He(e);var g=e.length;if(Vn(e)){var w=Gt(e);g=w.length}if(s>=g)return e;var S=s-Kn(c);if(S<1)return c;var k=w?Cn(w,0,S).join(""):e.slice(0,S);if(f===r)return k+c;if(w&&(S+=k.length-S),so(f)){if(e.slice(S).search(f)){var W,H=k;for(f.global||(f=bi(f.source,He(ia.exec(f))+"g")),f.lastIndex=0;W=f.exec(H);)var V=W.index;k=k.slice(0,V===r?S:V)}}else if(e.indexOf(kt(f),S)!=S){var te=k.lastIndexOf(f);te>-1&&(k=k.slice(0,te))}return k+c}function P_(e){return e=He(e),e&&Hd.test(e)?e.replace(na,ah):e}var M_=rr(function(e,t,s){return e+(s?" ":"")+t.toUpperCase()}),ao=kl("toUpperCase");function Tc(e,t,s){return e=He(e),t=s?r:t,t===r?nh(e)?uh(e):Xf(e):e.match(t)||[]}var Rc=Me(function(e,t){try{return Tt(e,r,t)}catch(s){return ro(s)?s:new Te(s)}}),I_=fn(function(e,t){return It(t,function(s){s=Zt(s),un(e,s,to(e[s],e))}),e});function L_(e){var t=e==null?0:e.length,s=ge();return e=t?Je(e,function(c){if(typeof c[1]!="function")throw new Lt(_);return[s(c[0]),c[1]]}):[],Me(function(c){for(var f=-1;++f<t;){var g=e[f];if(Tt(g[0],this,c))return Tt(g[1],this,c)}})}function D_(e){return ap(Ot(e,x))}function lo(e){return function(){return e}}function O_(e,t){return e==null||e!==e?t:e}var B_=jl(),F_=jl(!0);function Ct(e){return e}function co(e){return al(typeof e=="function"?e:Ot(e,x))}function U_(e){return cl(Ot(e,x))}function W_(e,t){return ul(e,Ot(t,x))}var H_=Me(function(e,t){return function(s){return br(s,e,t)}}),G_=Me(function(e,t){return function(s){return br(e,s,t)}});function uo(e,t,s){var c=ut(t),f=us(t,c);s==null&&!(Ze(t)&&(f.length||!c.length))&&(s=t,t=e,e=this,f=us(t,ut(t)));var g=!(Ze(s)&&"chain"in s)||!!s.chain,w=pn(e);return It(f,function(S){var k=t[S];e[S]=k,w&&(e.prototype[S]=function(){var W=this.__chain__;if(g||W){var H=e(this.__wrapped__),V=H.__actions__=Et(this.__actions__);return V.push({func:k,args:arguments,thisArg:e}),H.__chain__=W,H}return k.apply(e,bn([this.value()],arguments))})}),e}function z_(){return dt._===this&&(dt._=gh),this}function fo(){}function q_(e){return e=Ae(e),Me(function(t){return dl(t,e)})}var $_=Hi(Je),X_=Hi(Pa),Y_=Hi(hi);function kc(e){return Vi(e)?pi(Zt(e)):Sp(e)}function V_(e){return function(t){return e==null?r:Bn(e,t)}}var K_=Ml(),Q_=Ml(!0);function ho(){return[]}function po(){return!1}function J_(){return{}}function Z_(){return""}function ex(){return!0}function tx(e,t){if(e=Ae(e),e<1||e>oe)return[];var s=J,c=pt(e,J);t=ge(t),e-=J;for(var f=_i(c,t);++s<e;)t(s);return f}function nx(e){return Re(e)?Je(e,Zt):At(e)?[e]:Et(Vl(He(e)))}function rx(e){var t=++ph;return He(e)+t}var sx=gs(function(e,t){return e+t},0),ix=Gi("ceil"),ox=gs(function(e,t){return e/t},1),ax=Gi("floor");function lx(e){return e&&e.length?cs(e,Ct,Ri):r}function cx(e,t){return e&&e.length?cs(e,ge(t,2),Ri):r}function ux(e){return La(e,Ct)}function dx(e,t){return La(e,ge(t,2))}function fx(e){return e&&e.length?cs(e,Ct,Pi):r}function hx(e,t){return e&&e.length?cs(e,ge(t,2),Pi):r}var px=gs(function(e,t){return e*t},1),mx=Gi("round"),gx=gs(function(e,t){return e-t},0);function _x(e){return e&&e.length?gi(e,Ct):0}function xx(e,t){return e&&e.length?gi(e,ge(t,2)):0}return h.after=U0,h.ary=oc,h.assign=Tg,h.assignIn=bc,h.assignInWith=ks,h.assignWith=Rg,h.at=kg,h.before=ac,h.bind=to,h.bindAll=I_,h.bindKey=lc,h.castArray=J0,h.chain=rc,h.chunk=am,h.compact=lm,h.concat=cm,h.cond=L_,h.conforms=D_,h.constant=lo,h.countBy=_0,h.create=Ag,h.curry=cc,h.curryRight=uc,h.debounce=dc,h.defaults=jg,h.defaultsDeep=Pg,h.defer=W0,h.delay=H0,h.difference=um,h.differenceBy=dm,h.differenceWith=fm,h.drop=hm,h.dropRight=pm,h.dropRightWhile=mm,h.dropWhile=gm,h.fill=_m,h.filter=v0,h.flatMap=w0,h.flatMapDeep=E0,h.flatMapDepth=S0,h.flatten=Zl,h.flattenDeep=xm,h.flattenDepth=vm,h.flip=G0,h.flow=B_,h.flowRight=F_,h.fromPairs=bm,h.functions=Fg,h.functionsIn=Ug,h.groupBy=N0,h.initial=wm,h.intersection=Em,h.intersectionBy=Sm,h.intersectionWith=Nm,h.invert=Hg,h.invertBy=Gg,h.invokeMap=T0,h.iteratee=co,h.keyBy=R0,h.keys=ut,h.keysIn=Nt,h.map=Es,h.mapKeys=qg,h.mapValues=$g,h.matches=U_,h.matchesProperty=W_,h.memoize=Ns,h.merge=Xg,h.mergeWith=yc,h.method=H_,h.methodOf=G_,h.mixin=uo,h.negate=Cs,h.nthArg=q_,h.omit=Yg,h.omitBy=Vg,h.once=z0,h.orderBy=k0,h.over=$_,h.overArgs=q0,h.overEvery=X_,h.overSome=Y_,h.partial=no,h.partialRight=fc,h.partition=A0,h.pick=Kg,h.pickBy=wc,h.property=kc,h.propertyOf=V_,h.pull=km,h.pullAll=tc,h.pullAllBy=Am,h.pullAllWith=jm,h.pullAt=Pm,h.range=K_,h.rangeRight=Q_,h.rearg=$0,h.reject=M0,h.remove=Mm,h.rest=X0,h.reverse=Zi,h.sampleSize=L0,h.set=Jg,h.setWith=Zg,h.shuffle=D0,h.slice=Im,h.sortBy=F0,h.sortedUniq=Wm,h.sortedUniqBy=Hm,h.split=w_,h.spread=Y0,h.tail=Gm,h.take=zm,h.takeRight=qm,h.takeRightWhile=$m,h.takeWhile=Xm,h.tap=l0,h.throttle=V0,h.thru=ws,h.toArray=_c,h.toPairs=Ec,h.toPairsIn=Sc,h.toPath=nx,h.toPlainObject=vc,h.transform=e_,h.unary=K0,h.union=Ym,h.unionBy=Vm,h.unionWith=Km,h.uniq=Qm,h.uniqBy=Jm,h.uniqWith=Zm,h.unset=t_,h.unzip=eo,h.unzipWith=nc,h.update=n_,h.updateWith=r_,h.values=or,h.valuesIn=s_,h.without=e0,h.words=Tc,h.wrap=Q0,h.xor=t0,h.xorBy=n0,h.xorWith=r0,h.zip=s0,h.zipObject=i0,h.zipObjectDeep=o0,h.zipWith=a0,h.entries=Ec,h.entriesIn=Sc,h.extend=bc,h.extendWith=ks,uo(h,h),h.add=sx,h.attempt=Rc,h.camelCase=l_,h.capitalize=Nc,h.ceil=ix,h.clamp=i_,h.clone=Z0,h.cloneDeep=tg,h.cloneDeepWith=ng,h.cloneWith=eg,h.conformsTo=rg,h.deburr=Cc,h.defaultTo=O_,h.divide=ox,h.endsWith=c_,h.eq=qt,h.escape=u_,h.escapeRegExp=d_,h.every=x0,h.find=b0,h.findIndex=Ql,h.findKey=Mg,h.findLast=y0,h.findLastIndex=Jl,h.findLastKey=Ig,h.floor=ax,h.forEach=sc,h.forEachRight=ic,h.forIn=Lg,h.forInRight=Dg,h.forOwn=Og,h.forOwnRight=Bg,h.get=io,h.gt=sg,h.gte=ig,h.has=Wg,h.hasIn=oo,h.head=ec,h.identity=Ct,h.includes=C0,h.indexOf=ym,h.inRange=o_,h.invoke=zg,h.isArguments=Wn,h.isArray=Re,h.isArrayBuffer=og,h.isArrayLike=St,h.isArrayLikeObject=rt,h.isBoolean=ag,h.isBuffer=Tn,h.isDate=lg,h.isElement=cg,h.isEmpty=ug,h.isEqual=dg,h.isEqualWith=fg,h.isError=ro,h.isFinite=hg,h.isFunction=pn,h.isInteger=hc,h.isLength=Ts,h.isMap=pc,h.isMatch=pg,h.isMatchWith=mg,h.isNaN=gg,h.isNative=_g,h.isNil=vg,h.isNull=xg,h.isNumber=mc,h.isObject=Ze,h.isObjectLike=et,h.isPlainObject=Cr,h.isRegExp=so,h.isSafeInteger=bg,h.isSet=gc,h.isString=Rs,h.isSymbol=At,h.isTypedArray=ir,h.isUndefined=yg,h.isWeakMap=wg,h.isWeakSet=Eg,h.join=Cm,h.kebabCase=f_,h.last=Ft,h.lastIndexOf=Tm,h.lowerCase=h_,h.lowerFirst=p_,h.lt=Sg,h.lte=Ng,h.max=lx,h.maxBy=cx,h.mean=ux,h.meanBy=dx,h.min=fx,h.minBy=hx,h.stubArray=ho,h.stubFalse=po,h.stubObject=J_,h.stubString=Z_,h.stubTrue=ex,h.multiply=px,h.nth=Rm,h.noConflict=z_,h.noop=fo,h.now=Ss,h.pad=m_,h.padEnd=g_,h.padStart=__,h.parseInt=x_,h.random=a_,h.reduce=j0,h.reduceRight=P0,h.repeat=v_,h.replace=b_,h.result=Qg,h.round=mx,h.runInContext=T,h.sample=I0,h.size=O0,h.snakeCase=y_,h.some=B0,h.sortedIndex=Lm,h.sortedIndexBy=Dm,h.sortedIndexOf=Om,h.sortedLastIndex=Bm,h.sortedLastIndexBy=Fm,h.sortedLastIndexOf=Um,h.startCase=E_,h.startsWith=S_,h.subtract=gx,h.sum=_x,h.sumBy=xx,h.template=N_,h.times=tx,h.toFinite=mn,h.toInteger=Ae,h.toLength=xc,h.toLower=C_,h.toNumber=Ut,h.toSafeInteger=Cg,h.toString=He,h.toUpper=T_,h.trim=R_,h.trimEnd=k_,h.trimStart=A_,h.truncate=j_,h.unescape=P_,h.uniqueId=rx,h.upperCase=M_,h.upperFirst=ao,h.each=sc,h.eachRight=ic,h.first=ec,uo(h,(function(){var e={};return Qt(h,function(t,s){Ge.call(h.prototype,s)||(e[s]=t)}),e})(),{chain:!1}),h.VERSION=a,It(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){h[e].placeholder=h}),It(["drop","take"],function(e,t){De.prototype[e]=function(s){s=s===r?1:lt(Ae(s),0);var c=this.__filtered__&&!t?new De(this):this.clone();return c.__filtered__?c.__takeCount__=pt(s,c.__takeCount__):c.__views__.push({size:pt(s,J),type:e+(c.__dir__<0?"Right":"")}),c},De.prototype[e+"Right"]=function(s){return this.reverse()[e](s).reverse()}}),It(["filter","map","takeWhile"],function(e,t){var s=t+1,c=s==$||s==K;De.prototype[e]=function(f){var g=this.clone();return g.__iteratees__.push({iteratee:ge(f,3),type:s}),g.__filtered__=g.__filtered__||c,g}}),It(["head","last"],function(e,t){var s="take"+(t?"Right":"");De.prototype[e]=function(){return this[s](1).value()[0]}}),It(["initial","tail"],function(e,t){var s="drop"+(t?"":"Right");De.prototype[e]=function(){return this.__filtered__?new De(this):this[s](1)}}),De.prototype.compact=function(){return this.filter(Ct)},De.prototype.find=function(e){return this.filter(e).head()},De.prototype.findLast=function(e){return this.reverse().find(e)},De.prototype.invokeMap=Me(function(e,t){return typeof e=="function"?new De(this):this.map(function(s){return br(s,e,t)})}),De.prototype.reject=function(e){return this.filter(Cs(ge(e)))},De.prototype.slice=function(e,t){e=Ae(e);var s=this;return s.__filtered__&&(e>0||t<0)?new De(s):(e<0?s=s.takeRight(-e):e&&(s=s.drop(e)),t!==r&&(t=Ae(t),s=t<0?s.dropRight(-t):s.take(t-e)),s)},De.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},De.prototype.toArray=function(){return this.take(J)},Qt(De.prototype,function(e,t){var s=/^(?:filter|find|map|reject)|While$/.test(t),c=/^(?:head|last)$/.test(t),f=h[c?"take"+(t=="last"?"Right":""):t],g=c||/^find/.test(t);f&&(h.prototype[t]=function(){var w=this.__wrapped__,S=c?[1]:arguments,k=w instanceof De,W=S[0],H=k||Re(w),V=function(Ie){var Oe=f.apply(h,bn([Ie],S));return c&&te?Oe[0]:Oe};H&&s&&typeof W=="function"&&W.length!=1&&(k=H=!1);var te=this.__chain__,ce=!!this.__actions__.length,be=g&&!te,Pe=k&&!ce;if(!g&&H){w=Pe?w:new De(this);var ye=e.apply(w,S);return ye.__actions__.push({func:ws,args:[V],thisArg:r}),new Dt(ye,te)}return be&&Pe?e.apply(this,S):(ye=this.thru(V),be?c?ye.value()[0]:ye.value():ye)})}),It(["pop","push","shift","sort","splice","unshift"],function(e){var t=Yr[e],s=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",c=/^(?:pop|shift)$/.test(e);h.prototype[e]=function(){var f=arguments;if(c&&!this.__chain__){var g=this.value();return t.apply(Re(g)?g:[],f)}return this[s](function(w){return t.apply(Re(w)?w:[],f)})}}),Qt(De.prototype,function(e,t){var s=h[t];if(s){var c=s.name+"";Ge.call(er,c)||(er[c]=[]),er[c].push({name:t,func:s})}}),er[ms(r,O).name]=[{name:"wrapper",func:r}],De.prototype.clone=Ph,De.prototype.reverse=Mh,De.prototype.value=Ih,h.prototype.at=c0,h.prototype.chain=u0,h.prototype.commit=d0,h.prototype.next=f0,h.prototype.plant=p0,h.prototype.reverse=m0,h.prototype.toJSON=h.prototype.valueOf=h.prototype.value=g0,h.prototype.first=h.prototype.head,hr&&(h.prototype[hr]=h0),h}),Qn=dh();Mn?((Mn.exports=Qn)._=Qn,ci._=Qn):dt._=Qn}).call(c1)})(Pr,Pr.exports)),Pr.exports}var od=u1();const d1=yx(od);function f1(i,n){const[r,a]=E.useState(i),d=E.useRef(d1.debounce(a,n)),l=E.useCallback(_=>{d.current(_)},[]);return[r,l]}const h1=[{id:"mumu",nameKey:"emulatorMumu",ip:"127.0.0.1",port:7555},{id:"nox",nameKey:"emulatorNox",ip:"127.0.0.1",port:62001},{id:"ldplayer",nameKey:"emulatorLdplayer",ip:"127.0.0.1",port:5555},{id:"bluestacks",nameKey:"emulatorBluestacks",ip:"127.0.0.1",port:5555},{id:"custom",nameKey:"emulatorCustom",ip:"",port:5555}],p1=()=>{try{const i=localStorage.getItem("sidebar-collapsed");return i!==null?JSON.parse(i):!1}catch(i){return console.warn("Failed to load sidebar collapsed state:",i),!1}};function m1({devices:i,currentDeviceId:n,onSelectDevice:r,onOpenConfig:a,onConnectWifi:d,onDisconnectWifi:l,onRefreshDevices:_,showToast:v}){const u=An(),[m,p]=E.useState(p1),[x,y]=E.useState(!1),[b,N]=E.useState(""),[M,A]=E.useState("5555"),[O,L]=E.useState(""),[P,j]=E.useState(""),[z,Q]=E.useState("custom"),[q,Y]=E.useState("direct"),[B,C]=E.useState(""),[R,se]=E.useState(""),[_e,$]=E.useState("5555"),[X,K]=E.useState(""),[ne,oe]=E.useState(!1),[ke,G]=E.useState([]),[J,ue]=f1(!1,300),[ie,Se]=E.useState(""),[ae,ze]=E.useState(null),[Qe,me]=E.useState(!1),D=E.useRef(null),[le,he]=E.useState(""),[Fe,We]=E.useState(""),[de,Ne]=E.useState(!1),[ee,Z]=E.useState([]),[Ee,je]=E.useState(null),[fe,xe]=E.useState(!1);E.useEffect(()=>{localStorage.setItem("sidebar-collapsed",JSON.stringify(m))},[m]),E.useEffect(()=>{const U=ve=>{(ve.metaKey||ve.ctrlKey)&&ve.key==="b"&&(ve.preventDefault(),p(!m))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[m]);const Ce=()=>{p(!m)},pe=U=>/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/.test(U)?U.split(".").every(ti=>{const Wr=parseInt(ti,10);return Wr>=0&&Wr<=255}):!1,ct=U=>{const ve=parseInt(U,10);return!isNaN(ve)&&ve>=1&&ve<=65535},yt=U=>/^\d{6}$/.test(U),wt=async()=>{L(""),j("");let U=!1;if(pe(b)||(L(u.deviceSidebar.invalidIpError),U=!0),ct(M)||(j(u.deviceSidebar.invalidPortError),U=!0),!U){oe(!0);try{const ve=await Pc({ip:b,port:parseInt(M,10)});ve.success?(y(!1),N(""),A("5555")):L(ve.message||u.toasts.wifiManualConnectError)}catch{L(u.toasts.wifiManualConnectError)}finally{oe(!1)}}},it=async()=>{K(""),L(""),j("");let U=!1;if(pe(b)||(L(u.deviceSidebar.invalidIpError),U=!0),ct(R)||(j(u.deviceSidebar.invalidPortError),U=!0),ct(_e)||(j(u.deviceSidebar.invalidPortError),U=!0),yt(B)||(K(u.deviceSidebar.invalidPairingCodeError),U=!0),!U){oe(!0);try{const ve=await Cx({ip:b,pairing_port:parseInt(R,10),pairing_code:B,connection_port:parseInt(_e,10)});ve.success?(y(!1),N(""),A("5555"),C(""),se(""),$("5555"),Y("direct")):ve.error==="invalid_pairing_code"?K(ve.message):ve.error==="invalid_ip"?L(ve.message):L(ve.message||u.toasts.wifiPairError)}catch{L(u.toasts.wifiPairError)}finally{oe(!1)}}},Ve=E.useCallback(()=>{D.current!==null&&(clearInterval(D.current),D.current=null)},[]),zn=E.useCallback(U=>{Ve(),D.current=window.setInterval(async()=>{try{const ve=await wx(U);ze(Kt=>Kt?{...Kt,status:ve.status}:null),["connected","timeout","error"].includes(ve.status)&&(Ve(),ve.status==="connected"&&setTimeout(()=>{y(!1),ze(null)},2e3))}catch(ve){console.error("[QR Pairing] Status poll failed:",ve)}},1e3)},[Ve]),jn=E.useCallback(async()=>{me(!0);try{const U=await Ex();U.success&&U.qr_payload&&U.session_id&&(ze({sessionId:U.session_id,payload:U.qr_payload,status:"listening",expiresAt:U.expires_at??Date.now()+12e4}),zn(U.session_id))}catch(U){console.error("[QR Pairing] Generation failed:",U)}finally{me(!1)}},[zn]),Pn=E.useCallback(async()=>{if(ae)try{await Sx(ae.sessionId),ze(null),Ve()}catch(U){console.error("[QR Pairing] Cancel failed:",U)}},[ae,Ve]),qn=async()=>{if(We(""),!le.trim()){We(u.deviceSidebar.remoteUrlRequired||"请输入远程服务器地址");return}if(!le.startsWith("http://")&&!le.startsWith("https://")){We(u.deviceSidebar.remoteUrlInvalid||"地址必须以 http:// 或 https:// 开头");return}Ne(!0);try{const U=await Tx({base_url:le,timeout:5});U.success?(Z(U.devices),je(null)):(We(U.message||"发现设备失败"),Z([]))}catch{We("连接失败,请检查地址是否正确"),Z([])}finally{Ne(!1)}},dr=async()=>{if(Ee){xe(!0);try{const U=await Rx({base_url:le,device_id:Ee});U.success?(y(!1),he(""),Z([]),je(null)):We(U.message||u.toasts.remoteDeviceAddError)}catch{We(u.toasts.remoteDeviceAddError)}finally{xe(!1)}}};E.useEffect(()=>{(!x||q!=="pair")&&(ae&&ae.status==="listening"&&Pn(),Ve())},[x,q,ae,Ve,Pn]),E.useEffect(()=>()=>{Ve()},[Ve]),E.useEffect(()=>{x&&q==="pair"&&!ae&&!Qe&&jn()},[x,q,ae,Qe,jn]);const an=E.useCallback(async()=>{ue(!0),Se("");try{const U=await Nx();U.success?G(U.devices):(Se(U.error||u.deviceSidebar.scanError.replace("{error}","Unknown error")),G([]))}catch(U){Se(u.deviceSidebar.scanError.replace("{error}",String(U))),G([])}finally{ue(!1)}},[u.deviceSidebar.scanError,ue]),$n=async(U,ve)=>{if(!ve&&!U.has_pairing){oe(!0),L("");try{const Kt=await Pc({ip:U.ip,port:U.port});Kt.success?y(!1):L(Kt.message||u.toasts.wifiManualConnectError)}catch(Kt){L(u.toasts.wifiManualConnectError),console.error("[DeviceSidebar] Error connecting:",Kt)}finally{oe(!1)}}else ve&&U.has_pairing&&(N(U.ip),se(U.pairing_port?String(U.pairing_port):""),$(String(U.port)),setTimeout(()=>{document.getElementById("pairing-code")?.focus()},100))};return E.useEffect(()=>{if(x){an();const U=setInterval(()=>{an()},5e3);return()=>{clearInterval(U)}}},[x,an]),o.jsxs(o.Fragment,{children:[m&&o.jsx(we,{variant:"outline",size:"icon",onClick:Ce,className:"absolute 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",children:o.jsx(wu,{className:"h-4 w-4"})}),o.jsxs("div",{className:`
26
- ${m?"w-0 -ml-4 opacity-0":"w-80 opacity-100"}
27
- transition-all duration-300 ease-in-out
28
- h-full min-h-0
29
- bg-white dark:bg-slate-950
30
- border-r border-slate-200 dark:border-slate-800
31
- flex flex-col
32
- overflow-hidden
33
- `,children:[o.jsxs("div",{className:"flex items-center justify-between p-4",children:[o.jsx("div",{className:"flex items-center gap-2",children:o.jsxs("div",{children:[o.jsx("h2",{className:"text-base font-bold text-slate-900 dark:text-slate-100",children:"AutoGLM"}),o.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[i.length," ",(i.length===1,u.deviceSidebar.devices)]})]})}),o.jsx(we,{variant:"ghost",size:"icon",onClick:Ce,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:o.jsx(Nu,{className:"h-4 w-4"})})]}),o.jsx(Tr,{className:"mx-4"}),o.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-2 min-h-0",children:i.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[o.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800",children:o.jsx(xv,{className:"h-8 w-8 text-slate-400"})}),o.jsx("p",{className:"mt-4 font-medium text-slate-900 dark:text-slate-100",children:u.deviceSidebar.noDevicesConnected}),o.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:u.deviceSidebar.clickToRefresh})]}):i.map(U=>o.jsx(Mv,{id:U.id,serial:U.serial,model:U.model,displayName:U.display_name,status:U.status,connectionType:U.connection_type,agent:U.agent,isActive:n===U.id,onClick:()=>r(U.id),onConnectWifi:async()=>{await d(U.id)},onDisconnectWifi:async()=>{await l(U.id)},onNameUpdated:()=>{_&&_()},showToast:v},U.id))}),o.jsx(Tr,{className:"mx-4"}),o.jsxs("div",{className:"p-3 space-y-2",children:[o.jsxs(we,{variant:"outline",onClick:()=>y(!0),className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[o.jsx(yu,{className:"h-4 w-4"}),u.deviceSidebar.addDevice]}),o.jsxs(we,{variant:"outline",onClick:a,className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[o.jsx(Ru,{className:"h-4 w-4"}),u.deviceSidebar.settings]})]}),o.jsx(Fo,{open:x,onOpenChange:y,children:o.jsxs(Uo,{className:"sm:max-w-md max-h-[80vh] overflow-y-auto",children:[o.jsxs(Wo,{children:[o.jsx(Ho,{children:u.deviceSidebar.manualConnectTitle}),o.jsx(Go,{children:u.deviceSidebar.manualConnectDescription})]}),o.jsxs($u,{value:q,onValueChange:Y,className:"w-full",children:[o.jsxs(Xu,{className:"grid w-full grid-cols-3",children:[o.jsx(Ir,{value:"direct",children:u.deviceSidebar.directConnectTab}),o.jsx(Ir,{value:"pair",children:u.deviceSidebar.pairTab}),o.jsx(Ir,{value:"remote",children:u.deviceSidebar.remoteTab||"远程设备"})]}),o.jsxs(Lr,{value:"direct",className:"space-y-4 mt-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("h3",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:u.deviceSidebar.discoveredDevices}),o.jsx(we,{variant:"outline",size:"sm",onClick:an,disabled:J,className:"h-8",children:J?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"mr-2 h-3 w-3 animate-spin rounded-full border-2 border-slate-400 border-t-transparent"}),u.deviceSidebar.scanning]}):u.deviceSidebar.scanAgain})]}),ie&&o.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:o.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:ie})}),(()=>{const U=ke.filter(ve=>!ve.has_pairing);return!J&&U.length===0?o.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[o.jsx(Gs,{className:"mx-auto h-8 w-8 text-slate-400"}),o.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:u.deviceSidebar.noDirectDevices})]}):U.length>0?o.jsx("div",{className:"space-y-2",children:U.map(ve=>o.jsx("button",{onClick:()=>$n(ve,!1),disabled:ne,className:"w-full rounded-lg border border-slate-200 dark:border-slate-700 p-3 text-left transition-colors hover:bg-slate-50 dark:hover:bg-slate-800 disabled:opacity-50 disabled:cursor-not-allowed",children:o.jsx("div",{className:"flex items-start justify-between",children:o.jsxs("div",{className:"flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ms,{className:"h-4 w-4 text-[#1d9bf0]"}),o.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:ve.name})]}),o.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[ve.ip,":",ve.port]})]})})},`${ve.ip}:${ve.port}`))}):null})(),O&&q==="direct"&&o.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:o.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:O})}),o.jsxs("div",{className:"relative my-4",children:[o.jsx(Tr,{}),o.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-slate-950 px-2 text-sm text-slate-500",children:u.deviceSidebar.orManualConnect})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{children:u.deviceSidebar.emulatorPreset}),o.jsx("div",{className:"grid grid-cols-3 gap-2",children:h1.map(U=>o.jsx("button",{onClick:()=>{Q(U.id),U.id!=="custom"&&(N(U.ip),A(String(U.port))),L(""),j("")},className:`rounded-lg border p-2 text-xs text-center transition-colors ${z===U.id?"border-blue-500 bg-blue-50 dark:bg-blue-950/30 text-blue-700 dark:text-blue-300":"border-slate-200 dark:border-slate-700 hover:bg-slate-50 dark:hover:bg-slate-800"}`,children:u.deviceSidebar[U.nameKey]||U.nameKey},U.id))})]}),o.jsx("div",{className:"rounded-lg bg-blue-50 dark:bg-blue-950/20 p-3 text-sm",children:o.jsx("p",{className:"text-blue-800 dark:text-blue-200",children:u.deviceSidebar.emulatorNote})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{htmlFor:"ip",children:u.deviceSidebar.ipAddress}),o.jsx(ht,{id:"ip",placeholder:"192.168.1.100",value:b,onChange:U=>{N(U.target.value),z!=="custom"&&Q("custom")},onKeyDown:U=>U.key==="Enter"&&wt(),className:O?"border-red-500":""})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{htmlFor:"port",children:u.deviceSidebar.port}),o.jsx(ht,{id:"port",type:"number",value:M,onChange:U=>{A(U.target.value),z!=="custom"&&Q("custom")},onKeyDown:U=>U.key==="Enter"&&wt(),className:P?"border-red-500":""}),P&&o.jsx("p",{className:"text-sm text-red-500",children:P})]}),o.jsx(we,{onClick:wt,disabled:ne,className:"w-full",children:ne?u.common.loading:u.deviceSidebar.connect})]})]}),o.jsxs(Lr,{value:"pair",className:"space-y-4 mt-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("h3",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:u.deviceSidebar.discoveredDevices}),o.jsx(we,{variant:"outline",size:"sm",onClick:an,disabled:J,className:"h-8",children:J?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"mr-2 h-3 w-3 animate-spin rounded-full border-2 border-slate-400 border-t-transparent"}),u.deviceSidebar.scanning]}):u.deviceSidebar.scanAgain})]}),ie&&o.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:o.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:ie})}),(()=>{const U=ke.filter(ve=>ve.has_pairing);return!J&&U.length===0?o.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[o.jsx(Gs,{className:"mx-auto h-8 w-8 text-slate-400"}),o.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:u.deviceSidebar.noPairingDevices})]}):U.length>0?o.jsx("div",{className:"space-y-2",children:U.map(ve=>o.jsx("button",{onClick:()=>$n(ve,!0),disabled:ne,className:"w-full rounded-lg border border-slate-200 dark:border-slate-700 p-3 text-left transition-colors hover:bg-slate-50 dark:hover:bg-slate-800 disabled:opacity-50 disabled:cursor-not-allowed",children:o.jsx("div",{className:"flex items-start justify-between",children:o.jsxs("div",{className:"flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ms,{className:"h-4 w-4 text-[#1d9bf0]"}),o.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:ve.name})]}),o.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[ve.ip,":",ve.port]}),o.jsxs("div",{className:"mt-2 flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400",children:[o.jsx(_n,{className:"h-3 w-3"}),o.jsx("span",{children:u.deviceSidebar.pairingRequired})]})]})})},`${ve.ip}:${ve.port}`))}):null})(),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"relative my-4",children:[o.jsx(Tr,{}),o.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-slate-950 px-2 text-sm text-slate-500",children:u.deviceSidebar.orQrPair})]}),o.jsxs("div",{className:"rounded-lg bg-purple-50 dark:bg-purple-950/20 p-3 text-sm",children:[o.jsx("p",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:u.deviceSidebar.qrPairingTitle}),o.jsxs("ol",{className:"space-y-1 text-purple-700 dark:text-purple-300 text-xs",children:[o.jsx("li",{children:u.deviceSidebar.qrStep1}),o.jsx("li",{children:u.deviceSidebar.qrStep2}),o.jsx("li",{children:u.deviceSidebar.qrStep3})]})]}),ae&&o.jsx("div",{className:"rounded-lg border border-slate-200 dark:border-slate-700 p-4 bg-white dark:bg-slate-900",children:o.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[o.jsx("div",{className:"bg-white p-4 rounded-lg",children:o.jsx(id,{value:ae.payload,size:200,level:"M"})}),o.jsxs("div",{className:"flex items-center gap-2",children:[ae.status==="listening"&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"h-2 w-2 rounded-full bg-blue-500 animate-pulse"}),o.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:u.deviceSidebar.qrWaitingForScan})]}),ae.status==="pairing"&&o.jsxs(o.Fragment,{children:[o.jsx(Yt,{className:"h-4 w-4 animate-spin text-blue-500"}),o.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:u.deviceSidebar.qrPairing})]}),ae.status==="connected"&&o.jsxs(o.Fragment,{children:[o.jsx(Lc,{className:"h-4 w-4 text-green-500"}),o.jsx("span",{className:"text-sm text-green-600 dark:text-green-400",children:u.deviceSidebar.qrConnected})]}),ae.status==="timeout"&&o.jsxs(o.Fragment,{children:[o.jsx(Dc,{className:"h-4 w-4 text-amber-500"}),o.jsx("span",{className:"text-sm text-amber-600 dark:text-amber-400",children:u.deviceSidebar.qrTimeout})]}),ae.status==="error"&&o.jsxs(o.Fragment,{children:[o.jsx(Dc,{className:"h-4 w-4 text-red-500"}),o.jsx("span",{className:"text-sm text-red-600 dark:text-red-400",children:u.deviceSidebar.qrError})]})]}),o.jsxs("div",{className:"flex gap-2 w-full",children:[(ae.status==="timeout"||ae.status==="error")&&o.jsx(we,{variant:"outline",onClick:jn,className:"flex-1",children:u.deviceSidebar.qrRegenerate}),ae.status==="listening"&&o.jsx(we,{variant:"outline",onClick:Pn,className:"flex-1",children:u.common.cancel}),ae.status==="connected"&&o.jsx(we,{onClick:()=>y(!1),className:"flex-1",children:u.common.confirm})]})]})}),!ae&&Qe&&o.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-slate-600 dark:text-slate-400",children:[o.jsx(Yt,{className:"h-4 w-4 animate-spin"}),o.jsx("span",{className:"text-sm",children:u.common.loading})]})]}),o.jsxs("div",{className:"relative my-4",children:[o.jsx(Tr,{}),o.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-slate-950 px-2 text-sm text-slate-500",children:u.deviceSidebar.orManualPair})]}),o.jsxs("div",{className:"rounded-lg bg-blue-50 dark:bg-blue-950/20 p-3 text-sm",children:[o.jsx("p",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:u.deviceSidebar.pairingInstructions}),o.jsxs("ol",{className:"space-y-1 text-blue-700 dark:text-blue-300 text-xs",children:[o.jsx("li",{children:u.deviceSidebar.pairingStep1}),o.jsx("li",{children:u.deviceSidebar.pairingStep2}),o.jsx("li",{children:u.deviceSidebar.pairingStep3}),o.jsx("li",{children:u.deviceSidebar.pairingStep4})]}),o.jsx("p",{className:"mt-2 text-xs text-blue-600 dark:text-blue-400",children:u.deviceSidebar.pairingNote})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{htmlFor:"pair-ip",children:u.deviceSidebar.ipAddress}),o.jsx(ht,{id:"pair-ip",placeholder:"192.168.1.100",value:b,onChange:U=>N(U.target.value),className:O?"border-red-500":""}),O&&q==="pair"&&o.jsx("p",{className:"text-sm text-red-500",children:O})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{htmlFor:"pairing-port",children:u.deviceSidebar.pairingPort}),o.jsx(ht,{id:"pairing-port",type:"number",placeholder:"37831",value:R,onChange:U=>se(U.target.value),className:P?"border-red-500":""}),P&&o.jsx("p",{className:"text-sm text-red-500",children:P})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{htmlFor:"pairing-code",children:u.deviceSidebar.pairingCode}),o.jsx(ht,{id:"pairing-code",type:"text",placeholder:"123456",maxLength:6,value:B,onChange:U=>C(U.target.value.replace(/\D/g,"")),onKeyDown:U=>U.key==="Enter"&&it(),className:X?"border-red-500":""}),X&&o.jsx("p",{className:"text-sm text-red-500",children:X})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{htmlFor:"connection-port",children:u.deviceSidebar.connectionPort}),o.jsx(ht,{id:"connection-port",type:"number",value:_e,onChange:U=>$(U.target.value),onKeyDown:U=>U.key==="Enter"&&it()})]}),o.jsx(we,{onClick:it,disabled:ne,className:"w-full",children:ne?u.common.loading:u.deviceSidebar.pairAndConnect})]})]}),o.jsxs(Lr,{value:"remote",className:"space-y-4 mt-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{htmlFor:"remote-url",children:u.deviceSidebar.remoteUrl||"远程服务器地址"}),o.jsx(ht,{id:"remote-url",placeholder:"http://192.168.1.100:8001",value:le,onChange:U=>{he(U.target.value),We("")},disabled:de,onKeyDown:U=>U.key==="Enter"&&qn(),className:Fe?"border-red-500":""}),Fe&&o.jsx("p",{className:"text-sm text-red-500",children:Fe}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:u.deviceSidebar.remoteUrlHint||"运行 Device Agent Server 的地址"}),o.jsx(we,{onClick:qn,disabled:de||!le,className:"w-full",children:de?"正在发现...":"发现设备"})]}),ee.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{children:"可用设备"}),o.jsx("div",{className:"space-y-2",children:ee.map(U=>o.jsx("button",{onClick:()=>je(U.device_id),className:`
34
- w-full rounded-lg border p-3 text-left transition-colors
35
- ${Ee===U.device_id?"border-[#1d9bf0] bg-blue-50 dark:bg-blue-950/20":"border-slate-200 hover:bg-slate-50 dark:border-slate-700 dark:hover:bg-slate-800"}
36
- `,children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ms,{className:"h-4 w-4 text-[#1d9bf0]"}),o.jsxs("div",{className:"flex-1",children:[o.jsx("p",{className:"font-medium text-sm",children:U.device_id}),o.jsxs("p",{className:"text-xs text-slate-500",children:[U.model," · ",U.platform]})]}),Ee===U.device_id&&o.jsx(Lc,{className:"h-4 w-4 text-[#1d9bf0]"})]})},U.device_id))})]}),Ee&&o.jsx(we,{onClick:dr,disabled:fe,className:"w-full",children:fe?"正在连接...":"连接远程设备"})]})]}),o.jsx(zo,{children:o.jsx(we,{variant:"outline",onClick:()=>{y(!1),L(""),j(""),K(""),Se(""),N(""),A("5555"),C(""),se(""),$("5555"),Y("direct"),G([])},children:u.common.cancel})})]})})]})]})}const sn=Object.create(null);sn.open="0";sn.close="1";sn.ping="2";sn.pong="3";sn.message="4";sn.upgrade="5";sn.noop="6";const Is=Object.create(null);Object.keys(sn).forEach(i=>{Is[sn[i]]=i});const Mo={type:"error",data:"parser error"},ad=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",ld=typeof ArrayBuffer=="function",cd=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i&&i.buffer instanceof ArrayBuffer,Xo=({type:i,data:n},r,a)=>ad&&n instanceof Blob?r?a(n):Gc(n,a):ld&&(n instanceof ArrayBuffer||cd(n))?r?a(n):Gc(new Blob([n]),a):a(sn[i]+(n||"")),Gc=(i,n)=>{const r=new FileReader;return r.onload=function(){const a=r.result.split(",")[1];n("b"+(a||""))},r.readAsDataURL(i)};function zc(i){return i instanceof Uint8Array?i:i instanceof ArrayBuffer?new Uint8Array(i):new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}let _o;function g1(i,n){if(ad&&i.data instanceof Blob)return i.data.arrayBuffer().then(zc).then(n);if(ld&&(i.data instanceof ArrayBuffer||cd(i.data)))return n(zc(i.data));Xo(i,!1,r=>{_o||(_o=new TextEncoder),n(_o.encode(r))})}const qc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Mr=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let i=0;i<qc.length;i++)Mr[qc.charCodeAt(i)]=i;const _1=i=>{let n=i.length*.75,r=i.length,a,d=0,l,_,v,u;i[i.length-1]==="="&&(n--,i[i.length-2]==="="&&n--);const m=new ArrayBuffer(n),p=new Uint8Array(m);for(a=0;a<r;a+=4)l=Mr[i.charCodeAt(a)],_=Mr[i.charCodeAt(a+1)],v=Mr[i.charCodeAt(a+2)],u=Mr[i.charCodeAt(a+3)],p[d++]=l<<2|_>>4,p[d++]=(_&15)<<4|v>>2,p[d++]=(v&3)<<6|u&63;return m},x1=typeof ArrayBuffer=="function",Yo=(i,n)=>{if(typeof i!="string")return{type:"message",data:ud(i,n)};const r=i.charAt(0);return r==="b"?{type:"message",data:v1(i.substring(1),n)}:Is[r]?i.length>1?{type:Is[r],data:i.substring(1)}:{type:Is[r]}:Mo},v1=(i,n)=>{if(x1){const r=_1(i);return ud(r,n)}else return{base64:!0,data:i}},ud=(i,n)=>{switch(n){case"blob":return i instanceof Blob?i:new Blob([i]);case"arraybuffer":default:return i instanceof ArrayBuffer?i:i.buffer}},dd="",b1=(i,n)=>{const r=i.length,a=new Array(r);let d=0;i.forEach((l,_)=>{Xo(l,!1,v=>{a[_]=v,++d===r&&n(a.join(dd))})})},y1=(i,n)=>{const r=i.split(dd),a=[];for(let d=0;d<r.length;d++){const l=Yo(r[d],n);if(a.push(l),l.type==="error")break}return a};function w1(){return new TransformStream({transform(i,n){g1(i,r=>{const a=r.length;let d;if(a<126)d=new Uint8Array(1),new DataView(d.buffer).setUint8(0,a);else if(a<65536){d=new Uint8Array(3);const l=new DataView(d.buffer);l.setUint8(0,126),l.setUint16(1,a)}else{d=new Uint8Array(9);const l=new DataView(d.buffer);l.setUint8(0,127),l.setBigUint64(1,BigInt(a))}i.data&&typeof i.data!="string"&&(d[0]|=128),n.enqueue(d),n.enqueue(r)})}})}let xo;function js(i){return i.reduce((n,r)=>n+r.length,0)}function Ps(i,n){if(i[0].length===n)return i.shift();const r=new Uint8Array(n);let a=0;for(let d=0;d<n;d++)r[d]=i[0][a++],a===i[0].length&&(i.shift(),a=0);return i.length&&a<i[0].length&&(i[0]=i[0].slice(a)),r}function E1(i,n){xo||(xo=new TextDecoder);const r=[];let a=0,d=-1,l=!1;return new TransformStream({transform(_,v){for(r.push(_);;){if(a===0){if(js(r)<1)break;const u=Ps(r,1);l=(u[0]&128)===128,d=u[0]&127,d<126?a=3:d===126?a=1:a=2}else if(a===1){if(js(r)<2)break;const u=Ps(r,2);d=new DataView(u.buffer,u.byteOffset,u.length).getUint16(0),a=3}else if(a===2){if(js(r)<8)break;const u=Ps(r,8),m=new DataView(u.buffer,u.byteOffset,u.length),p=m.getUint32(0);if(p>Math.pow(2,21)-1){v.enqueue(Mo);break}d=p*Math.pow(2,32)+m.getUint32(4),a=3}else{if(js(r)<d)break;const u=Ps(r,d);v.enqueue(Yo(l?u:xo.decode(u),n)),a=0}if(d===0||d>i){v.enqueue(Mo);break}}}})}const fd=4;function ot(i){if(i)return S1(i)}function S1(i){for(var n in ot.prototype)i[n]=ot.prototype[n];return i}ot.prototype.on=ot.prototype.addEventListener=function(i,n){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(n),this};ot.prototype.once=function(i,n){function r(){this.off(i,r),n.apply(this,arguments)}return r.fn=n,this.on(i,r),this};ot.prototype.off=ot.prototype.removeListener=ot.prototype.removeAllListeners=ot.prototype.removeEventListener=function(i,n){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+i];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+i],this;for(var a,d=0;d<r.length;d++)if(a=r[d],a===n||a.fn===n){r.splice(d,1);break}return r.length===0&&delete this._callbacks["$"+i],this};ot.prototype.emit=function(i){this._callbacks=this._callbacks||{};for(var n=new Array(arguments.length-1),r=this._callbacks["$"+i],a=1;a<arguments.length;a++)n[a-1]=arguments[a];if(r){r=r.slice(0);for(var a=0,d=r.length;a<d;++a)r[a].apply(this,n)}return this};ot.prototype.emitReserved=ot.prototype.emit;ot.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};ot.prototype.hasListeners=function(i){return!!this.listeners(i).length};const Ks=typeof Promise=="function"&&typeof Promise.resolve=="function"?n=>Promise.resolve().then(n):(n,r)=>r(n,0),Wt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),N1="arraybuffer";function hd(i,...n){return n.reduce((r,a)=>(i.hasOwnProperty(a)&&(r[a]=i[a]),r),{})}const C1=Wt.setTimeout,T1=Wt.clearTimeout;function Qs(i,n){n.useNativeTimers?(i.setTimeoutFn=C1.bind(Wt),i.clearTimeoutFn=T1.bind(Wt)):(i.setTimeoutFn=Wt.setTimeout.bind(Wt),i.clearTimeoutFn=Wt.clearTimeout.bind(Wt))}const R1=1.33;function k1(i){return typeof i=="string"?A1(i):Math.ceil((i.byteLength||i.size)*R1)}function A1(i){let n=0,r=0;for(let a=0,d=i.length;a<d;a++)n=i.charCodeAt(a),n<128?r+=1:n<2048?r+=2:n<55296||n>=57344?r+=3:(a++,r+=4);return r}function pd(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function j1(i){let n="";for(let r in i)i.hasOwnProperty(r)&&(n.length&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(i[r]));return n}function P1(i){let n={},r=i.split("&");for(let a=0,d=r.length;a<d;a++){let l=r[a].split("=");n[decodeURIComponent(l[0])]=decodeURIComponent(l[1])}return n}class M1 extends Error{constructor(n,r,a){super(n),this.description=r,this.context=a,this.type="TransportError"}}class Vo extends ot{constructor(n){super(),this.writable=!1,Qs(this,n),this.opts=n,this.query=n.query,this.socket=n.socket,this.supportsBinary=!n.forceBase64}onError(n,r,a){return super.emitReserved("error",new M1(n,r,a)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(n){this.readyState==="open"&&this.write(n)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(n){const r=Yo(n,this.socket.binaryType);this.onPacket(r)}onPacket(n){super.emitReserved("packet",n)}onClose(n){this.readyState="closed",super.emitReserved("close",n)}pause(n){}createUri(n,r={}){return n+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const n=this.opts.hostname;return n.indexOf(":")===-1?n:"["+n+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(n){const r=j1(n);return r.length?"?"+r:""}}class I1 extends Vo{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(n){this.readyState="pausing";const r=()=>{this.readyState="paused",n()};if(this._polling||!this.writable){let a=0;this._polling&&(a++,this.once("pollComplete",function(){--a||r()})),this.writable||(a++,this.once("drain",function(){--a||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(n){const r=a=>{if(this.readyState==="opening"&&a.type==="open"&&this.onOpen(),a.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(a)};y1(n,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const n=()=>{this.write([{type:"close"}])};this.readyState==="open"?n():this.once("open",n)}write(n){this.writable=!1,b1(n,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const n=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=pd()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(n,r)}}let md=!1;try{md=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const L1=md;function D1(){}class O1 extends I1{constructor(n){if(super(n),typeof location<"u"){const r=location.protocol==="https:";let a=location.port;a||(a=r?"443":"80"),this.xd=typeof location<"u"&&n.hostname!==location.hostname||a!==n.port}}doWrite(n,r){const a=this.request({method:"POST",data:n});a.on("success",r),a.on("error",(d,l)=>{this.onError("xhr post error",d,l)})}doPoll(){const n=this.request();n.on("data",this.onData.bind(this)),n.on("error",(r,a)=>{this.onError("xhr poll error",r,a)}),this.pollXhr=n}}class rn extends ot{constructor(n,r,a){super(),this.createRequest=n,Qs(this,a),this._opts=a,this._method=a.method||"GET",this._uri=r,this._data=a.data!==void 0?a.data:null,this._create()}_create(){var n;const r=hd(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const a=this._xhr=this.createRequest(r);try{a.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){a.setDisableHeaderCheck&&a.setDisableHeaderCheck(!0);for(let d in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(d)&&a.setRequestHeader(d,this._opts.extraHeaders[d])}}catch{}if(this._method==="POST")try{a.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{a.setRequestHeader("Accept","*/*")}catch{}(n=this._opts.cookieJar)===null||n===void 0||n.addCookies(a),"withCredentials"in a&&(a.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(a.timeout=this._opts.requestTimeout),a.onreadystatechange=()=>{var d;a.readyState===3&&((d=this._opts.cookieJar)===null||d===void 0||d.parseCookies(a.getResponseHeader("set-cookie"))),a.readyState===4&&(a.status===200||a.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof a.status=="number"?a.status:0)},0))},a.send(this._data)}catch(d){this.setTimeoutFn(()=>{this._onError(d)},0);return}typeof document<"u"&&(this._index=rn.requestsCount++,rn.requests[this._index]=this)}_onError(n){this.emitReserved("error",n,this._xhr),this._cleanup(!0)}_cleanup(n){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=D1,n)try{this._xhr.abort()}catch{}typeof document<"u"&&delete rn.requests[this._index],this._xhr=null}}_onLoad(){const n=this._xhr.responseText;n!==null&&(this.emitReserved("data",n),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}rn.requestsCount=0;rn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",$c);else if(typeof addEventListener=="function"){const i="onpagehide"in Wt?"pagehide":"unload";addEventListener(i,$c,!1)}}function $c(){for(let i in rn.requests)rn.requests.hasOwnProperty(i)&&rn.requests[i].abort()}const B1=(function(){const i=gd({xdomain:!1});return i&&i.responseType!==null})();class F1 extends O1{constructor(n){super(n);const r=n&&n.forceBase64;this.supportsBinary=B1&&!r}request(n={}){return Object.assign(n,{xd:this.xd},this.opts),new rn(gd,this.uri(),n)}}function gd(i){const n=i.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!n||L1))return new XMLHttpRequest}catch{}if(!n)try{return new Wt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const _d=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class U1 extends Vo{get name(){return"websocket"}doOpen(){const n=this.uri(),r=this.opts.protocols,a=_d?{}:hd(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(a.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(n,r,a)}catch(d){return this.emitReserved("error",d)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=n=>this.onClose({description:"websocket connection closed",context:n}),this.ws.onmessage=n=>this.onData(n.data),this.ws.onerror=n=>this.onError("websocket error",n)}write(n){this.writable=!1;for(let r=0;r<n.length;r++){const a=n[r],d=r===n.length-1;Xo(a,this.supportsBinary,l=>{try{this.doWrite(a,l)}catch{}d&&Ks(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const n=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=pd()),this.supportsBinary||(r.b64=1),this.createUri(n,r)}}const vo=Wt.WebSocket||Wt.MozWebSocket;class W1 extends U1{createSocket(n,r,a){return _d?new vo(n,r,a):r?new vo(n,r):new vo(n)}doWrite(n,r){this.ws.send(r)}}class H1 extends Vo{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(n){return this.emitReserved("error",n)}this._transport.closed.then(()=>{this.onClose()}).catch(n=>{this.onError("webtransport error",n)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(n=>{const r=E1(Number.MAX_SAFE_INTEGER,this.socket.binaryType),a=n.readable.pipeThrough(r).getReader(),d=w1();d.readable.pipeTo(n.writable),this._writer=d.writable.getWriter();const l=()=>{a.read().then(({done:v,value:u})=>{v||(this.onPacket(u),l())}).catch(v=>{})};l();const _={type:"open"};this.query.sid&&(_.data=`{"sid":"${this.query.sid}"}`),this._writer.write(_).then(()=>this.onOpen())})})}write(n){this.writable=!1;for(let r=0;r<n.length;r++){const a=n[r],d=r===n.length-1;this._writer.write(a).then(()=>{d&&Ks(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var n;(n=this._transport)===null||n===void 0||n.close()}}const G1={websocket:W1,webtransport:H1,polling:F1},z1=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,q1=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Io(i){if(i.length>8e3)throw"URI too long";const n=i,r=i.indexOf("["),a=i.indexOf("]");r!=-1&&a!=-1&&(i=i.substring(0,r)+i.substring(r,a).replace(/:/g,";")+i.substring(a,i.length));let d=z1.exec(i||""),l={},_=14;for(;_--;)l[q1[_]]=d[_]||"";return r!=-1&&a!=-1&&(l.source=n,l.host=l.host.substring(1,l.host.length-1).replace(/;/g,":"),l.authority=l.authority.replace("[","").replace("]","").replace(/;/g,":"),l.ipv6uri=!0),l.pathNames=$1(l,l.path),l.queryKey=X1(l,l.query),l}function $1(i,n){const r=/\/{2,9}/g,a=n.replace(r,"/").split("/");return(n.slice(0,1)=="/"||n.length===0)&&a.splice(0,1),n.slice(-1)=="/"&&a.splice(a.length-1,1),a}function X1(i,n){const r={};return n.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(a,d,l){d&&(r[d]=l)}),r}const Lo=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ls=[];Lo&&addEventListener("offline",()=>{Ls.forEach(i=>i())},!1);class kn extends ot{constructor(n,r){if(super(),this.binaryType=N1,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,n&&typeof n=="object"&&(r=n,n=null),n){const a=Io(n);r.hostname=a.host,r.secure=a.protocol==="https"||a.protocol==="wss",r.port=a.port,a.query&&(r.query=a.query)}else r.host&&(r.hostname=Io(r.host).host);Qs(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(a=>{const d=a.prototype.name;this.transports.push(d),this._transportsByName[d]=a}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=P1(this.opts.query)),Lo&&(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"})},Ls.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(n){const r=Object.assign({},this.opts.query);r.EIO=fd,r.transport=n,this.id&&(r.sid=this.id);const a=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[n]);return new this._transportsByName[n](a)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const n=this.opts.rememberUpgrade&&kn.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(n);r.open(),this.setTransport(r)}setTransport(n){this.transport&&this.transport.removeAllListeners(),this.transport=n,n.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",kn.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",n),this.emitReserved("heartbeat"),n.type){case"open":this.onHandshake(JSON.parse(n.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const r=new Error("server error");r.code=n.data,this._onError(r);break;case"message":this.emitReserved("data",n.data),this.emitReserved("message",n.data);break}}onHandshake(n){this.emitReserved("handshake",n),this.id=n.sid,this.transport.query.sid=n.sid,this._pingInterval=n.pingInterval,this._pingTimeout=n.pingTimeout,this._maxPayload=n.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const n=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+n,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},n),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 n=this._getWritablePackets();this.transport.send(n),this._prevBufferLen=n.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let a=0;a<this.writeBuffer.length;a++){const d=this.writeBuffer[a].data;if(d&&(r+=k1(d)),a>0&&r>this._maxPayload)return this.writeBuffer.slice(0,a);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const n=Date.now()>this._pingTimeoutTime;return n&&(this._pingTimeoutTime=0,Ks(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),n}write(n,r,a){return this._sendPacket("message",n,r,a),this}send(n,r,a){return this._sendPacket("message",n,r,a),this}_sendPacket(n,r,a,d){if(typeof r=="function"&&(d=r,r=void 0),typeof a=="function"&&(d=a,a=null),this.readyState==="closing"||this.readyState==="closed")return;a=a||{},a.compress=a.compress!==!1;const l={type:n,data:r,options:a};this.emitReserved("packetCreate",l),this.writeBuffer.push(l),d&&this.once("flush",d),this.flush()}close(){const n=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),n()},a=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?a():n()}):this.upgrading?a():n()),this}_onError(n){if(kn.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",n),this._onClose("transport error",n)}_onClose(n,r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Lo&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const a=Ls.indexOf(this._offlineEventListener);a!==-1&&Ls.splice(a,1)}this.readyState="closed",this.id=null,this.emitReserved("close",n,r),this.writeBuffer=[],this._prevBufferLen=0}}}kn.protocol=fd;class Y1 extends kn{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let n=0;n<this._upgrades.length;n++)this._probe(this._upgrades[n])}_probe(n){let r=this.createTransport(n),a=!1;kn.priorWebsocketSuccess=!1;const d=()=>{a||(r.send([{type:"ping",data:"probe"}]),r.once("packet",x=>{if(!a)if(x.type==="pong"&&x.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;kn.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{a||this.readyState!=="closed"&&(p(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const y=new Error("probe error");y.transport=r.name,this.emitReserved("upgradeError",y)}}))};function l(){a||(a=!0,p(),r.close(),r=null)}const _=x=>{const y=new Error("probe error: "+x);y.transport=r.name,l(),this.emitReserved("upgradeError",y)};function v(){_("transport closed")}function u(){_("socket closed")}function m(x){r&&x.name!==r.name&&l()}const p=()=>{r.removeListener("open",d),r.removeListener("error",_),r.removeListener("close",v),this.off("close",u),this.off("upgrading",m)};r.once("open",d),r.once("error",_),r.once("close",v),this.once("close",u),this.once("upgrading",m),this._upgrades.indexOf("webtransport")!==-1&&n!=="webtransport"?this.setTimeoutFn(()=>{a||r.open()},200):r.open()}onHandshake(n){this._upgrades=this._filterUpgrades(n.upgrades),super.onHandshake(n)}_filterUpgrades(n){const r=[];for(let a=0;a<n.length;a++)~this.transports.indexOf(n[a])&&r.push(n[a]);return r}}let V1=class extends Y1{constructor(n,r={}){const a=typeof n=="object"?n:r;(!a.transports||a.transports&&typeof a.transports[0]=="string")&&(a.transports=(a.transports||["polling","websocket","webtransport"]).map(d=>G1[d]).filter(d=>!!d)),super(n,a)}};function K1(i,n="",r){let a=i;r=r||typeof location<"u"&&location,i==null&&(i=r.protocol+"//"+r.host),typeof i=="string"&&(i.charAt(0)==="/"&&(i.charAt(1)==="/"?i=r.protocol+i:i=r.host+i),/^(https?|wss?):\/\//.test(i)||(typeof r<"u"?i=r.protocol+"//"+i:i="https://"+i),a=Io(i)),a.port||(/^(http|ws)$/.test(a.protocol)?a.port="80":/^(http|ws)s$/.test(a.protocol)&&(a.port="443")),a.path=a.path||"/";const l=a.host.indexOf(":")!==-1?"["+a.host+"]":a.host;return a.id=a.protocol+"://"+l+":"+a.port+n,a.href=a.protocol+"://"+l+(r&&r.port===a.port?"":":"+a.port),a}const Q1=typeof ArrayBuffer=="function",J1=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,xd=Object.prototype.toString,Z1=typeof Blob=="function"||typeof Blob<"u"&&xd.call(Blob)==="[object BlobConstructor]",eb=typeof File=="function"||typeof File<"u"&&xd.call(File)==="[object FileConstructor]";function Ko(i){return Q1&&(i instanceof ArrayBuffer||J1(i))||Z1&&i instanceof Blob||eb&&i instanceof File}function Ds(i,n){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let r=0,a=i.length;r<a;r++)if(Ds(i[r]))return!0;return!1}if(Ko(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Ds(i.toJSON(),!0);for(const r in i)if(Object.prototype.hasOwnProperty.call(i,r)&&Ds(i[r]))return!0;return!1}function tb(i){const n=[],r=i.data,a=i;return a.data=Do(r,n),a.attachments=n.length,{packet:a,buffers:n}}function Do(i,n){if(!i)return i;if(Ko(i)){const r={_placeholder:!0,num:n.length};return n.push(i),r}else if(Array.isArray(i)){const r=new Array(i.length);for(let a=0;a<i.length;a++)r[a]=Do(i[a],n);return r}else if(typeof i=="object"&&!(i instanceof Date)){const r={};for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&(r[a]=Do(i[a],n));return r}return i}function nb(i,n){return i.data=Oo(i.data,n),delete i.attachments,i}function Oo(i,n){if(!i)return i;if(i&&i._placeholder===!0){if(typeof i.num=="number"&&i.num>=0&&i.num<n.length)return n[i.num];throw new Error("illegal attachments")}else if(Array.isArray(i))for(let r=0;r<i.length;r++)i[r]=Oo(i[r],n);else if(typeof i=="object")for(const r in i)Object.prototype.hasOwnProperty.call(i,r)&&(i[r]=Oo(i[r],n));return i}const rb=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],sb=5;var Be;(function(i){i[i.CONNECT=0]="CONNECT",i[i.DISCONNECT=1]="DISCONNECT",i[i.EVENT=2]="EVENT",i[i.ACK=3]="ACK",i[i.CONNECT_ERROR=4]="CONNECT_ERROR",i[i.BINARY_EVENT=5]="BINARY_EVENT",i[i.BINARY_ACK=6]="BINARY_ACK"})(Be||(Be={}));class ib{constructor(n){this.replacer=n}encode(n){return(n.type===Be.EVENT||n.type===Be.ACK)&&Ds(n)?this.encodeAsBinary({type:n.type===Be.EVENT?Be.BINARY_EVENT:Be.BINARY_ACK,nsp:n.nsp,data:n.data,id:n.id}):[this.encodeAsString(n)]}encodeAsString(n){let r=""+n.type;return(n.type===Be.BINARY_EVENT||n.type===Be.BINARY_ACK)&&(r+=n.attachments+"-"),n.nsp&&n.nsp!=="/"&&(r+=n.nsp+","),n.id!=null&&(r+=n.id),n.data!=null&&(r+=JSON.stringify(n.data,this.replacer)),r}encodeAsBinary(n){const r=tb(n),a=this.encodeAsString(r.packet),d=r.buffers;return d.unshift(a),d}}function Xc(i){return Object.prototype.toString.call(i)==="[object Object]"}class Qo extends ot{constructor(n){super(),this.reviver=n}add(n){let r;if(typeof n=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(n);const a=r.type===Be.BINARY_EVENT;a||r.type===Be.BINARY_ACK?(r.type=a?Be.EVENT:Be.ACK,this.reconstructor=new ob(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Ko(n)||n.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(n),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+n)}decodeString(n){let r=0;const a={type:Number(n.charAt(0))};if(Be[a.type]===void 0)throw new Error("unknown packet type "+a.type);if(a.type===Be.BINARY_EVENT||a.type===Be.BINARY_ACK){const l=r+1;for(;n.charAt(++r)!=="-"&&r!=n.length;);const _=n.substring(l,r);if(_!=Number(_)||n.charAt(r)!=="-")throw new Error("Illegal attachments");a.attachments=Number(_)}if(n.charAt(r+1)==="/"){const l=r+1;for(;++r&&!(n.charAt(r)===","||r===n.length););a.nsp=n.substring(l,r)}else a.nsp="/";const d=n.charAt(r+1);if(d!==""&&Number(d)==d){const l=r+1;for(;++r;){const _=n.charAt(r);if(_==null||Number(_)!=_){--r;break}if(r===n.length)break}a.id=Number(n.substring(l,r+1))}if(n.charAt(++r)){const l=this.tryParse(n.substr(r));if(Qo.isPayloadValid(a.type,l))a.data=l;else throw new Error("invalid payload")}return a}tryParse(n){try{return JSON.parse(n,this.reviver)}catch{return!1}}static isPayloadValid(n,r){switch(n){case Be.CONNECT:return Xc(r);case Be.DISCONNECT:return r===void 0;case Be.CONNECT_ERROR:return typeof r=="string"||Xc(r);case Be.EVENT:case Be.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&rb.indexOf(r[0])===-1);case Be.ACK:case Be.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class ob{constructor(n){this.packet=n,this.buffers=[],this.reconPack=n}takeBinaryData(n){if(this.buffers.push(n),this.buffers.length===this.reconPack.attachments){const r=nb(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const ab=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Qo,Encoder:ib,get PacketType(){return Be},protocol:sb},Symbol.toStringTag,{value:"Module"}));function Xt(i,n,r){return i.on(n,r),function(){i.off(n,r)}}const lb=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class vd extends ot{constructor(n,r,a){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=n,this.nsp=r,a&&a.auth&&(this.auth=a.auth),this._opts=Object.assign({},a),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const n=this.io;this.subs=[Xt(n,"open",this.onopen.bind(this)),Xt(n,"packet",this.onpacket.bind(this)),Xt(n,"error",this.onerror.bind(this)),Xt(n,"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(...n){return n.unshift("message"),this.emit.apply(this,n),this}emit(n,...r){var a,d,l;if(lb.hasOwnProperty(n))throw new Error('"'+n.toString()+'" is a reserved event name');if(r.unshift(n),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const _={type:Be.EVENT,data:r};if(_.options={},_.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const p=this.ids++,x=r.pop();this._registerAckCallback(p,x),_.id=p}const v=(d=(a=this.io.engine)===null||a===void 0?void 0:a.transport)===null||d===void 0?void 0:d.writable,u=this.connected&&!(!((l=this.io.engine)===null||l===void 0)&&l._hasPingExpired());return this.flags.volatile&&!v||(u?(this.notifyOutgoingListeners(_),this.packet(_)):this.sendBuffer.push(_)),this.flags={},this}_registerAckCallback(n,r){var a;const d=(a=this.flags.timeout)!==null&&a!==void 0?a:this._opts.ackTimeout;if(d===void 0){this.acks[n]=r;return}const l=this.io.setTimeoutFn(()=>{delete this.acks[n];for(let v=0;v<this.sendBuffer.length;v++)this.sendBuffer[v].id===n&&this.sendBuffer.splice(v,1);r.call(this,new Error("operation has timed out"))},d),_=(...v)=>{this.io.clearTimeoutFn(l),r.apply(this,v)};_.withError=!0,this.acks[n]=_}emitWithAck(n,...r){return new Promise((a,d)=>{const l=(_,v)=>_?d(_):a(v);l.withError=!0,r.push(l),this.emit(n,...r)})}_addToQueue(n){let r;typeof n[n.length-1]=="function"&&(r=n.pop());const a={id:this._queueSeq++,tryCount:0,pending:!1,args:n,flags:Object.assign({fromQueue:!0},this.flags)};n.push((d,...l)=>a!==this._queue[0]?void 0:(d!==null?a.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(d)):(this._queue.shift(),r&&r(null,...l)),a.pending=!1,this._drainQueue())),this._queue.push(a),this._drainQueue()}_drainQueue(n=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!n||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(n){n.nsp=this.nsp,this.io._packet(n)}onopen(){typeof this.auth=="function"?this.auth(n=>{this._sendConnectPacket(n)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(n){this.packet({type:Be.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},n):n})}onerror(n){this.connected||this.emitReserved("connect_error",n)}onclose(n,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",n,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(n=>{if(!this.sendBuffer.some(a=>String(a.id)===n)){const a=this.acks[n];delete this.acks[n],a.withError&&a.call(this,new Error("socket has been disconnected"))}})}onpacket(n){if(n.nsp===this.nsp)switch(n.type){case Be.CONNECT:n.data&&n.data.sid?this.onconnect(n.data.sid,n.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 Be.EVENT:case Be.BINARY_EVENT:this.onevent(n);break;case Be.ACK:case Be.BINARY_ACK:this.onack(n);break;case Be.DISCONNECT:this.ondisconnect();break;case Be.CONNECT_ERROR:this.destroy();const a=new Error(n.data.message);a.data=n.data.data,this.emitReserved("connect_error",a);break}}onevent(n){const r=n.data||[];n.id!=null&&r.push(this.ack(n.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(n){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const a of r)a.apply(this,n)}super.emit.apply(this,n),this._pid&&n.length&&typeof n[n.length-1]=="string"&&(this._lastOffset=n[n.length-1])}ack(n){const r=this;let a=!1;return function(...d){a||(a=!0,r.packet({type:Be.ACK,id:n,data:d}))}}onack(n){const r=this.acks[n.id];typeof r=="function"&&(delete this.acks[n.id],r.withError&&n.data.unshift(null),r.apply(this,n.data))}onconnect(n,r){this.id=n,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(n=>this.emitEvent(n)),this.receiveBuffer=[],this.sendBuffer.forEach(n=>{this.notifyOutgoingListeners(n),this.packet(n)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(n=>n()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Be.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(n){return this.flags.compress=n,this}get volatile(){return this.flags.volatile=!0,this}timeout(n){return this.flags.timeout=n,this}onAny(n){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(n),this}prependAny(n){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(n),this}offAny(n){if(!this._anyListeners)return this;if(n){const r=this._anyListeners;for(let a=0;a<r.length;a++)if(n===r[a])return r.splice(a,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(n){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(n),this}prependAnyOutgoing(n){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(n),this}offAnyOutgoing(n){if(!this._anyOutgoingListeners)return this;if(n){const r=this._anyOutgoingListeners;for(let a=0;a<r.length;a++)if(n===r[a])return r.splice(a,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(n){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const a of r)a.apply(this,n.data)}}}function ur(i){i=i||{},this.ms=i.min||100,this.max=i.max||1e4,this.factor=i.factor||2,this.jitter=i.jitter>0&&i.jitter<=1?i.jitter:0,this.attempts=0}ur.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var n=Math.random(),r=Math.floor(n*this.jitter*i);i=(Math.floor(n*10)&1)==0?i-r:i+r}return Math.min(i,this.max)|0};ur.prototype.reset=function(){this.attempts=0};ur.prototype.setMin=function(i){this.ms=i};ur.prototype.setMax=function(i){this.max=i};ur.prototype.setJitter=function(i){this.jitter=i};class Bo extends ot{constructor(n,r){var a;super(),this.nsps={},this.subs=[],n&&typeof n=="object"&&(r=n,n=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,Qs(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((a=r.randomizationFactor)!==null&&a!==void 0?a:.5),this.backoff=new ur({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=n;const d=r.parser||ab;this.encoder=new d.Encoder,this.decoder=new d.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(n){return arguments.length?(this._reconnection=!!n,n||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(n){return n===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=n,this)}reconnectionDelay(n){var r;return n===void 0?this._reconnectionDelay:(this._reconnectionDelay=n,(r=this.backoff)===null||r===void 0||r.setMin(n),this)}randomizationFactor(n){var r;return n===void 0?this._randomizationFactor:(this._randomizationFactor=n,(r=this.backoff)===null||r===void 0||r.setJitter(n),this)}reconnectionDelayMax(n){var r;return n===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=n,(r=this.backoff)===null||r===void 0||r.setMax(n),this)}timeout(n){return arguments.length?(this._timeout=n,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(n){if(~this._readyState.indexOf("open"))return this;this.engine=new V1(this.uri,this.opts);const r=this.engine,a=this;this._readyState="opening",this.skipReconnect=!1;const d=Xt(r,"open",function(){a.onopen(),n&&n()}),l=v=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",v),n?n(v):this.maybeReconnectOnOpen()},_=Xt(r,"error",l);if(this._timeout!==!1){const v=this._timeout,u=this.setTimeoutFn(()=>{d(),l(new Error("timeout")),r.close()},v);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(d),this.subs.push(_),this}connect(n){return this.open(n)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const n=this.engine;this.subs.push(Xt(n,"ping",this.onping.bind(this)),Xt(n,"data",this.ondata.bind(this)),Xt(n,"error",this.onerror.bind(this)),Xt(n,"close",this.onclose.bind(this)),Xt(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(n){try{this.decoder.add(n)}catch(r){this.onclose("parse error",r)}}ondecoded(n){Ks(()=>{this.emitReserved("packet",n)},this.setTimeoutFn)}onerror(n){this.emitReserved("error",n)}socket(n,r){let a=this.nsps[n];return a?this._autoConnect&&!a.active&&a.connect():(a=new vd(this,n,r),this.nsps[n]=a),a}_destroy(n){const r=Object.keys(this.nsps);for(const a of r)if(this.nsps[a].active)return;this._close()}_packet(n){const r=this.encoder.encode(n);for(let a=0;a<r.length;a++)this.engine.write(r[a],n.options)}cleanup(){this.subs.forEach(n=>n()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(n,r){var a;this.cleanup(),(a=this.engine)===null||a===void 0||a.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",n,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const n=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const a=this.setTimeoutFn(()=>{n.skipReconnect||(this.emitReserved("reconnect_attempt",n.backoff.attempts),!n.skipReconnect&&n.open(d=>{d?(n._reconnecting=!1,n.reconnect(),this.emitReserved("reconnect_error",d)):n.onreconnect()}))},r);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}}onreconnect(){const n=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",n)}}const Rr={};function Os(i,n){typeof i=="object"&&(n=i,i=void 0),n=n||{};const r=K1(i,n.path||"/socket.io"),a=r.source,d=r.id,l=r.path,_=Rr[d]&&l in Rr[d].nsps,v=n.forceNew||n["force new connection"]||n.multiplex===!1||_;let u;return v?u=new Bo(a,n):(Rr[d]||(Rr[d]=new Bo(a,n)),u=Rr[d]),r.query&&!n.query&&(n.query=r.queryKey),u.socket(r.path,n)}Object.assign(Os,{Manager:Bo,Socket:vd,io:Os,connect:Os});function cb(i,n){return(i[n]|i[n+1]<<8|i[n+2]<<16|i[n+3]<<24)>>>0}const Bs={H264:1748121140,H265:1748121141,AV1:6387249},{WritableStream:ub}=globalThis;class db{#e;#t;#n=0;#r=7;get byteAligned(){return this.#r===7}get ended(){return this.#n>=this.#e.length}constructor(n){this.#e=n,this.#t=n[0]}f1(){const n=this.#t>>this.#r;return this.#r-=1,this.#r<0&&(this.#n+=1,this.#r=7,this.#t=this.#e[this.#n]),n&1}f(n){let r=0;for(;n>0;n-=1)r<<=1,r|=this.f1();return r}skip(n){if(n<=this.#r+1){this.#n+=1,this.#r=7,this.#t=this.#e[this.#n];return}n-=this.#r+1,this.#n+=1;const r=n/8|0;r>0&&(this.#n+=r,n-=r*8),this.#r=7-n,this.#t=this.#e[this.#n]}readBytes(n){if(!this.byteAligned)throw new Error("Bytes must be byte-aligned");const r=this.#e.subarray(this.#n,this.#n+n);return this.#n+=n,this.#t=this.#e[this.#n],r}getPosition(){return[this.#n,this.#r]}setPosition([n,r]){this.#n=n,this.#r=r,this.#t=this.#e[n]}}const fb={SequenceHeader:1,TemporalDelimiter:2,FrameHeader:3,TileGroup:4,Metadata:5,Frame:6,RedundantFrameHeader:7,TileList:8,Padding:15},hb={Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,GenericFilm:8,Bt2020:9,Xyz:10,Smpte431:11,Smpte432:12,Ebu3213:22},pb={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},mb={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 gt extends db{static ObuType=fb;static ColorPrimaries=hb;static TransferCharacteristics=pb;static MatrixCoefficients=mb;#e=0;uvlc(){let n=0;for(;!this.f1();)n+=1;return n>=32?2**32-1:this.f(n)+(1<<n>>>0)-1}leb128(){if(!this.byteAligned)throw new Error("LEB128 must be byte-aligned");let n=0n;this.#e=0;for(let r=0n;r<8n;r+=1n){const a=this.f(8);if(n|=BigInt(a&127)<<7n*r,this.#e+=1,(a&128)==0)break}return n}*annexBBitstream(){for(;!this.ended;){const n=this.leb128();yield*this.temporalUnit(n)}}*temporalUnit(n){for(;n>0;){const r=this.leb128();n-=BigInt(this.#e),yield*this.frameUnit(r),n-=r}}*frameUnit(n){for(;n>0;){const r=this.leb128();n-=BigInt(this.#e);const a=this.openBitstreamUnit(r);a&&(yield a),n-=r}}#t=0;openBitstreamUnit(n){const r=this.obuHeader();let a;if(r.obu_has_size_field)a=this.leb128();else if(n!==void 0)a=n-1n-(r.obu_extension_flag?1n:0n);else throw new Error("obu_has_size_field must be true");const d=this.getPosition();if(r.obu_type!==gt.ObuType.SequenceHeader&&r.obu_type!==gt.ObuType.TemporalDelimiter&&this.#t!==0&&r.obu_extension_header){const u=!!(this.#t&1<<r.obu_extension_header.temporal_id),m=!!(this.#t&1<<r.obu_extension_header.spatial_id+8);if(!u||!m){this.skip(Number(a));return}}let l;switch(r.obu_type){case gt.ObuType.SequenceHeader:l=this.sequenceHeaderObu();break}const _=this.getPosition(),v=(_[0]-d[0])*8+(d[1]-_[1]);return a>0&&this.skip(Number(a)*8-v),{obu_header:r,obu_size:a,sequence_header_obu:l}}obuHeader(){if(!!this.f1())throw new Error("Invalid data");const r=this.f(4),a=!!this.f1(),d=!!this.f1();this.f1();let l;return a&&(l=this.obuExtensionHeader()),{obu_type:r,obu_extension_flag:a,obu_has_size_field:d,obu_extension_header:l}}obuExtensionHeader(){const n=this.f(3),r=this.f(2);return this.skip(3),{temporal_id:n,spatial_id:r}}static SelectScreenContentTools=2;static SelectIntegerMv=2;sequenceHeaderObu(){const n=this.f(3),r=!!this.f1(),a=!!this.f1();let d=!1,l,_=!1,v,u=!1,m=0;const p=[],x=[],y=[],b=[],N=[];let M,A;if(a)p[0]=0,x[0]=this.f(5),y[0]=0,b[0]=!1,N[0]=!1;else{d=!!this.f1(),d&&(l=this.timingInfo(),_=!!this.f1(),_&&(v=this.decoderModelInfo(),M=[])),u=!!this.f1(),u&&(A=[]),m=this.f(5);for(let D=0;D<=m;D+=1)p[D]=this.f(12),x[D]=this.f(5),x[D]>7?y[D]=this.f1():y[D]=0,_?(b[D]=!!this.f1(),b[D]&&(M[D]=this.operatingParametersInfo(v))):b[D]=!1,u&&(N[D]=!!this.f1(),N[D]&&(A[D]=this.f(4)))}const O=this.chooseOperatingPoint();this.#t=p[O];const L=this.f(4),P=this.f(4),j=this.f(L+1),z=this.f(P+1);let Q=!1,q,Y;a||(Q=!!this.f1(),Q&&(q=this.f(4),Y=this.f(3)));const B=!!this.f1(),C=!!this.f1(),R=!!this.f1();let se=!1,_e=!1,$=!1,X=!1,K=!1,ne=!1,oe=!1,ke=!1,G=gt.SelectScreenContentTools,J=!1,ue=gt.SelectIntegerMv,ie;a||(se=!!this.f1(),_e=!!this.f1(),$=!!this.f1(),X=!!this.f1(),K=!!this.f1(),K&&(ne=!!this.f1(),oe=!!this.f1()),ke=!!this.f1(),ke||(G=this.f1()),G>0&&(J=!!this.f1(),J||(ue=this.f1())),K&&(ie=this.f(3)));const Se=!!this.f1(),ae=!!this.f1(),ze=!!this.f1(),Qe=this.colorConfig(n),me=!!this.f1();return{seq_profile:n,still_picture:r,reduced_still_picture_header:a,timing_info_present_flag:d,timing_info:l,decoder_model_info_present_flag:_,decoder_model_info:v,initial_display_delay_present_flag:u,initial_display_delay_minus_1:A,operating_points_cnt_minus_1:m,operating_point_idc:p,seq_level_idx:x,seq_tier:y,decoder_model_present_for_this_op:b,operating_parameters_info:M,initial_display_delay_present_for_this_op:N,frame_width_bits_minus_1:L,frame_height_bits_minus_1:P,max_frame_width_minus_1:j,max_frame_height_minus_1:z,frame_id_numbers_present_flag:Q,delta_frame_id_length_minus_2:q,additional_frame_id_length_minus_1:Y,use_128x128_superblock:B,enable_filter_intra:C,enable_intra_edge_filter:R,enable_interintra_compound:se,enable_masked_compound:_e,enable_warped_motion:$,enable_dual_filter:X,enable_order_hint:K,enable_jnt_comp:ne,enable_ref_frame_mvs:oe,seq_choose_screen_content_tools:ke,seq_force_screen_content_tools:G,seq_choose_integer_mv:J,seq_force_integer_mv:ue,order_hint_bits_minus_1:ie,enable_superres:Se,enable_cdef:ae,enable_restoration:ze,color_config:Qe,film_grain_params_present:me}}searchSequenceHeaderObu(){for(;!this.ended;){const n=this.openBitstreamUnit();if(n&&n.sequence_header_obu)return n.sequence_header_obu}}timingInfo(){const n=this.f(32),r=this.f(32),a=!!this.f1();let d;return a&&(d=this.uvlc()),{num_units_in_display_tick:n,time_scale:r,equal_picture_interval:a,num_ticks_per_picture_minus_1:d}}decoderModelInfo(){const n=this.f(5),r=this.f(32),a=this.f(5),d=this.f(5);return{buffer_delay_length_minus_1:n,num_units_in_decoding_tick:r,buffer_removal_time_length_minus_1:a,frame_presentation_time_length_minus_1:d}}operatingParametersInfo(n){const r=n.buffer_delay_length_minus_1+1,a=this.f(r),d=this.f(r),l=!!this.f1();return{decoder_buffer_delay:a,encoder_buffer_delay:d,low_delay_mode_flag:l}}chooseOperatingPoint(){return 0}colorConfig(n){const r=!!this.f1();let a=!1,d=8;n===2&&r?(a=!!this.f1(),d=a?12:10):n<=2&&(d=r?10:8);let l=!1;n===1&&(l=!!this.f1());const _=!!this.f1();let v=gt.ColorPrimaries.Unspecified,u=gt.TransferCharacteristics.Unspecified,m=gt.MatrixCoefficients.Unspecified;_&&(v=this.f(8),u=this.f(8),m=this.f(8));let p=!1,x,y,b=0,N=!1;if(l)p=!!this.f1(),x=!0,y=!0;else{if(v===gt.ColorPrimaries.Bt709&&u===gt.TransferCharacteristics.Srgb&&m===gt.MatrixCoefficients.Identity)p=!0,x=!1,y=!1;else{switch(p=!!this.f1(),n){case 0:x=!0,y=!0;break;case 1:x=!1,y=!1;break;default:d==12?(x=!!this.f1(),x?y=!!this.f1():y=!1):(x=!0,y=!1);break}x&&y&&(b=this.f(2))}N=!!this.f1()}return{high_bitdepth:r,twelve_bit:a,BitDepth:d,mono_chrome:l,color_description_present_flag:_,color_primaries:v,transfer_characteristics:u,matrix_coefficients:m,color_range:p,subsampling_x:x,subsampling_y:y,chroma_sample_position:b,separate_uv_delta_q:N}}}function*bd(i){let n=-1,r=0,a=!1;for(let d=0;d<i.length;d+=1){const l=i[d];if(a){if(l>3)throw new Error("Invalid data");a=!1;continue}if(l===0){r+=1;continue}const _=r;if(r=0,n===-1){if(_>=2&&l===1){n=d+1;continue}throw new Error("Invalid data")}if(!(_<2)){if(l===1){yield i.subarray(n,d-_),n=d+1;continue}if(_>2)throw new Error("Invalid data");switch(l){case 2:throw new Error("Invalid data");case 3:a=!0;break}}}if(a)throw new Error("Invalid data");yield i.subarray(n,i.length)}class Js{#e;#t;#n;#r=0;#i=0;#s=7;#o=0;get byteLength(){return this.#t}get stopBitIndex(){return this.#n}get bytePosition(){return this.#i}get bitPosition(){return this.#s}get ended(){return this.#i>=this.#t&&this.#s<=this.#n}constructor(n){this.#e=n;for(let r=n.length-1;r>=0;r-=1){if(this.#e[r]===0)continue;const a=n[r];for(let d=0;d<8;d+=1)if((a>>d&1)===1){this.#t=r,this.#n=d,this.#l();return}}throw new Error("Stop bit not found")}#l(){if(this.#o=this.#e[this.#i],this.#r===2&&this.#o===3){this.#r=0,this.#i+=1,this.#l();return}this.#o===0?this.#r+=1:this.#r=0}next(){if(this.ended)throw new Error("Bit index out of bounds");const n=this.#o>>this.#s&1;return this.#s-=1,this.#s<0&&(this.#i+=1,this.#s=7,this.#l()),n}read(n){if(n>32)throw new Error("Read length too large");let r=0;for(let a=0;a<n;a+=1)r=r<<1|this.next();return r}#c(){if(this.#i>=this.#t&&this.#s<this.#n)throw new Error("Bit index out of bounds")}skip(n){if(n<=this.#s+1){this.#s-=n,this.#c();return}for(n-=this.#s+1,this.#i+=1,this.#s=7,this.#l(),this.#c();n>=8;n-=8)this.#i+=1,this.#l(),this.#c();this.#s=7-n,this.#c()}decodeExponentialGolombNumber(){let n=0;for(;this.next()===0;)n+=1;return n===0?0:(1<<n|this.read(n))-1}#d(){return{zeroCount:this.#r,bytePosition:this.#i,bitPosition:this.#s,byte:this.#o}}#a(n){this.#r=n.zeroCount,this.#i=n.bytePosition,this.#s=n.bitPosition,this.#o=n.byte}peek(n){const r=this.#d(),a=this.read(n);return this.#a(r),a}readBytes(n){const r=new Uint8Array(n);for(let a=0;a<n;a+=1)r[a]=this.read(8);return r}peekBytes(n){const r=this.#d(),a=this.readBytes(n);return this.#a(r),a}}function gb(i){const n=new Js(i);if(n.next()!==0)throw new Error("Invalid data");const r=n.read(2);if(n.read(5)!==7)throw new Error("Invalid data");if(r===0)throw new Error("Invalid data");const d=n.read(8),l=n.peek(8),_=!!n.next(),v=!!n.next(),u=!!n.next(),m=!!n.next(),p=!!n.next(),x=!!n.next();if(n.read(2)!==0)throw new Error("Invalid data");const y=n.read(8),b=n.decodeExponentialGolombNumber();if(d===100||d===110||d===122||d===244||d===44||d===83||d===86||d===118||d===128||d===138||d===139||d===134){const q=n.decodeExponentialGolombNumber();if(q===3&&n.next(),n.decodeExponentialGolombNumber(),n.decodeExponentialGolombNumber(),n.next(),!!n.next())for(let B=0;B<(q!==3?8:12);B+=1)n.next()}n.decodeExponentialGolombNumber();const N=n.decodeExponentialGolombNumber();if(N===0)n.decodeExponentialGolombNumber();else if(N===1){n.next(),n.decodeExponentialGolombNumber(),n.decodeExponentialGolombNumber();const q=n.decodeExponentialGolombNumber();for(let Y=0;Y<q;Y+=1)n.decodeExponentialGolombNumber()}n.decodeExponentialGolombNumber(),n.next();const M=n.decodeExponentialGolombNumber(),A=n.decodeExponentialGolombNumber(),O=n.next();O||n.next(),n.next();const L=!!n.next();let P,j,z,Q;return L?(P=n.decodeExponentialGolombNumber(),j=n.decodeExponentialGolombNumber(),z=n.decodeExponentialGolombNumber(),Q=n.decodeExponentialGolombNumber()):(P=0,j=0,z=0,Q=0),n.next(),{profile_idc:d,constraint_set:l,constraint_set0_flag:_,constraint_set1_flag:v,constraint_set2_flag:u,constraint_set3_flag:m,constraint_set4_flag:p,constraint_set5_flag:x,level_idc:y,seq_parameter_set_id:b,pic_width_in_mbs_minus1:M,pic_height_in_map_units_minus1:A,frame_mbs_only_flag:O,frame_cropping_flag:L,frame_crop_left_offset:P,frame_crop_right_offset:j,frame_crop_top_offset:z,frame_crop_bottom_offset:Q}}function _b(i){let n,r;for(const a of bd(i))switch(a[0]&31){case 7:if(n=a,r)return{sequenceParameterSet:n,pictureParameterSet:r};break;case 8:if(r=a,n)return{sequenceParameterSet:n,pictureParameterSet:r};break}throw new Error("Invalid data")}function xb(i){const{sequenceParameterSet:n,pictureParameterSet:r}=_b(i),{profile_idc:a,constraint_set:d,level_idc:l,pic_width_in_mbs_minus1:_,pic_height_in_map_units_minus1:v,frame_mbs_only_flag:u,frame_crop_left_offset:m,frame_crop_right_offset:p,frame_crop_top_offset:x,frame_crop_bottom_offset:y}=gb(n),b=(_+1)*16,N=(v+1)*(2-u)*16,M=m*2,A=p*2,O=x*2,L=y*2,P=b-M-A,j=N-O-L;return{pictureParameterSet:r,sequenceParameterSet:n,profileIndex:a,constraintSet:d,levelIndex:l,encodedWidth:b,encodedHeight:N,cropLeft:M,cropRight:A,cropTop:O,cropBottom:L,croppedWidth:P,croppedHeight:j}}function vb(i){switch(i){case 0:case 3:return 1;case 1:case 2:return 2;default:throw new Error("Invalid chroma_format_idc")}}function bb(i){switch(i){case 0:case 2:case 3:return 1;case 1:return 2;default:throw new Error("Invalid chroma_format_idc")}}function yb(i){const n=new Js(i);if(n.next()!==0)throw new Error("Invalid NALU header");const r=n.read(6),a=n.read(6),d=n.read(3);return{nal_unit_type:r,nuh_layer_id:a,nuh_temporal_id_plus1:d}}function wb(i){const n=new Js(i),r=n.read(4),a=!!n.next(),d=!!n.next(),l=n.read(6),_=n.read(3),v=!!n.next();n.skip(16);const u=yd(n,!0,_),m=!!n.next(),p=[],x=[],y=[];for(let C=m?0:_;C<=_;C+=1)p[C]=n.decodeExponentialGolombNumber(),x[C]=n.decodeExponentialGolombNumber(),y[C]=n.decodeExponentialGolombNumber();const b=n.read(6),N=n.decodeExponentialGolombNumber(),M=[];for(let C=1;C<=N;C+=1){M[C]=[];for(let R=0;R<=b;R+=1)M[C][R]=!!n.next()}const A=!!n.next();let O,L,P,j,z,Q,q,Y;if(A){O=n.read(32),L=n.read(32),P=!!n.next(),P&&(j=n.decodeExponentialGolombNumber()),z=n.decodeExponentialGolombNumber(),Q=[],q=[!0],Y=[];for(let C=0;C<z;C+=1)Q[C]=n.decodeExponentialGolombNumber(),C>0&&(q[C]=!!n.next()),Y[C]=wd(n,q[C],_)}const B=!!n.next();return{vps_video_parameter_set_id:r,vps_base_layer_internal_flag:a,vps_base_layer_available_flag:d,vps_max_layers_minus1:l,vps_max_sub_layers_minus1:_,vps_temporal_id_nesting_flag:v,profileTierLevel:u,vps_sub_layer_ordering_info_present_flag:m,vps_max_dec_pic_buffering_minus1:p,vps_max_num_reorder_pics:x,vps_max_latency_increase_plus1:y,vps_max_layer_id:b,vps_num_layer_sets_minus1:N,layer_id_included_flag:M,vps_timing_info_present_flag:A,vps_num_units_in_tick:O,vps_time_scale:L,vps_poc_proportional_to_timing_flag:P,vps_num_ticks_poc_diff_one_minus1:j,vps_num_hrd_parameters:z,hrd_layer_set_idx:Q,cprms_present_flag:q,hrdParameters:Y,vps_extension_flag:B}}function Eb(i){const n=new Js(i),r=n.read(4),a=n.read(3),d=!!n.next(),l=yd(n,!0,a),_=n.decodeExponentialGolombNumber(),v=n.decodeExponentialGolombNumber();let u;v===3&&(u=!!n.next());const m=n.decodeExponentialGolombNumber(),p=n.decodeExponentialGolombNumber(),x=!!n.next();let y,b,N,M;x&&(y=n.decodeExponentialGolombNumber(),b=n.decodeExponentialGolombNumber(),N=n.decodeExponentialGolombNumber(),M=n.decodeExponentialGolombNumber());const A=n.decodeExponentialGolombNumber(),O=n.decodeExponentialGolombNumber(),L=n.decodeExponentialGolombNumber(),P=[],j=[],z=[],Q=!!n.next();for(let pe=Q?0:a;pe<=a;pe+=1)P[pe]=n.decodeExponentialGolombNumber(),j[pe]=n.decodeExponentialGolombNumber(),z[pe]=n.decodeExponentialGolombNumber();const q=n.decodeExponentialGolombNumber(),Y=n.decodeExponentialGolombNumber(),B=n.decodeExponentialGolombNumber(),C=n.decodeExponentialGolombNumber(),R=n.decodeExponentialGolombNumber(),se=n.decodeExponentialGolombNumber(),_e=!!n.next();let $,X;_e&&($=!!n.next(),$&&(X=Sb(n)));const K=!!n.next(),ne=!!n.next(),oe=!!n.next();let ke,G,J,ue,ie;oe&&(ke=n.read(4),G=n.read(4),J=n.read(4),ue=n.read(4),ie=!!n.next());const Se=n.decodeExponentialGolombNumber(),ae=[];for(let pe=0;pe<Se;pe+=1)ae[pe]=Nb(n,pe,Se,ae);const ze=!!n.next();let Qe,me,D;if(ze){Qe=n.decodeExponentialGolombNumber(),me=[],D=[];for(let pe=0;pe<Qe;pe+=1)me[pe]=n.read(L+4),D[pe]=!!n.next()}const le=!!n.next(),he=!!n.next(),Fe=!!n.next();let We;Fe&&(We=Cb(n,a));const de=!!n.next();let Ne,ee,Z,Ee,je;if(de&&(Ne=!!n.next(),ee=!!n.next(),Z=!!n.next(),Ee=!!n.next(),je=n.read(4)),Ne)throw new Error("Not implemented");let fe;ee&&(fe=Rb(n));let xe;if(Z&&(xe=kb(n)),Ee)throw new Error("Not implemented");let Ce;if(je){Ce=[];let pe=0;for(;!n.ended;)Ce[pe]=!!n.next(),pe+=1}return{sps_video_parameter_set_id:r,sps_max_sub_layers_minus1:a,sps_temporal_id_nesting_flag:d,profileTierLevel:l,sps_seq_parameter_set_id:_,chroma_format_idc:v,separate_colour_plane_flag:u,pic_width_in_luma_samples:m,pic_height_in_luma_samples:p,conformance_window_flag:x,conf_win_left_offset:y,conf_win_right_offset:b,conf_win_top_offset:N,conf_win_bottom_offset:M,bit_depth_luma_minus8:A,bit_depth_chroma_minus8:O,log2_max_pic_order_cnt_lsb_minus4:L,sps_sub_layer_ordering_info_present_flag:Q,sps_max_dec_pic_buffering_minus1:P,sps_max_num_reorder_pics:j,sps_max_latency_increase_plus1:z,log2_min_luma_coding_block_size_minus3:q,log2_diff_max_min_luma_coding_block_size:Y,log2_min_luma_transform_block_size_minus2:B,log2_diff_max_min_luma_transform_block_size:C,max_transform_hierarchy_depth_inter:R,max_transform_hierarchy_depth_intra:se,scaling_list_enabled_flag:_e,sps_scaling_list_data_present_flag:$,scalingListData:X,amp_enabled_flag:K,sample_adaptive_offset_enabled_flag:ne,pcm_enabled_flag:oe,pcm_sample_bit_depth_luma_minus1:ke,pcm_sample_bit_depth_chroma_minus1:G,log2_min_pcm_luma_coding_block_size_minus3:J,log2_diff_max_min_pcm_luma_coding_block_size:ue,pcm_loop_filter_disabled_flag:ie,num_short_term_ref_pic_sets:Se,shortTermRefPicSets:ae,long_term_ref_pics_present_flag:ze,num_long_term_ref_pics_sps:Qe,lt_ref_pic_poc_lsb_sps:me,used_by_curr_pic_lt_sps_flag:D,sps_temporal_mvp_enabled_flag:le,strong_intra_smoothing_enabled_flag:he,vui_parameters_present_flag:Fe,vuiParameters:We,sps_extension_present_flag:de,sps_range_extension_flag:Ne,sps_multilayer_extension_flag:ee,sps_3d_extension_flag:Z,sps_scc_extension_flag:Ee,sps_extension_4bits:je,spsMultilayerExtension:fe,sps3dExtension:xe,sps_extension_data_flag:Ce}}function Yc(i){const n=i.read(2),r=!!i.next(),a=i.read(5),d=i.peekBytes(4),l=[];for(let Q=0;Q<32;Q+=1)l[Q]=!!i.next();const _=i.peekBytes(6),v=!!i.next(),u=!!i.next(),m=!!i.next(),p=!!i.next();let x,y,b,N,M,A,O,L,P,j;a===4||l[4]||a===5||l[5]||a===6||l[6]||a===7||l[7]||a===8||l[8]||a===9||l[9]||a===10||l[10]||a===11||l[11]?(x=!!i.next(),y=!!i.next(),b=!!i.next(),N=!!i.next(),M=!!i.next(),A=!!i.next(),O=!!i.next(),L=!!i.next(),P=!!i.next(),a===5||l[5]||a===9||l[9]||a===10||l[10]||a===11||l[11]?(j=!!i.next(),i.skip(33)):i.skip(34)):a===2||l[2]?(i.skip(7),L=!!i.next(),i.skip(35)):i.skip(43);let z;return a===1||l[1]||a===2||l[2]||a===3||l[3]||a===4||l[4]||a===5||l[5]||a===9||l[9]||a===11||l[11]?z=!!i.next():i.skip(1),{profile_space:n,tier_flag:r,profile_idc:a,profileCompatibilitySet:d,profile_compatibility_flag:l,constraintSet:_,progressive_source_flag:v,interlaced_source_flag:u,non_packed_constraint_flag:m,frame_only_constraint_flag:p,max_12bit_constraint_flag:x,max_10bit_constraint_flag:y,max_8bit_constraint_flag:b,max_422chroma_constraint_flag:N,max_420chroma_constraint_flag:M,max_monochrome_constraint_flag:A,intra_constraint_flag:O,one_picture_only_constraint_flag:L,lower_bit_rate_constraint_flag:P,max_14bit_constraint_flag:j,inbld_flag:z}}function yd(i,n,r){let a;a=Yc(i);const d=i.read(8),l=[],_=[];for(let m=0;m<r;m+=1)l[m]=!!i.next(),_[m]=!!i.next();if(r>0)for(let m=r;m<8;m+=1)i.read(2);const v=[],u=[];for(let m=0;m<r;m+=1)l[m]&&(v[m]=Yc(i)),_[m]&&(u[m]=i.read(8));return{generalProfileTier:a,general_level_idc:d,sub_layer_profile_present_flag:l,sub_layer_level_present_flag:_,subLayerProfileTier:v,sub_layer_level_idc:u}}function Sb(i){const n=[];for(let r=0;r<4;r+=1){n[r]=[];for(let a=0;a<6;a+=r===3?3:1)if(!!!i.next())i.decodeExponentialGolombNumber();else{let l=8;const _=Math.min(64,1<<4+(r<<1));r>1&&(l=i.decodeExponentialGolombNumber()+8),n[r][a]=[];for(let v=0;v<_;v+=1){const u=i.decodeExponentialGolombNumber();l=(l+u+256)%256,n[r][a][v]=l}}}return n}function Nb(i,n,r,a){let d=!1;n!==0&&(d=!!i.next());let l=0,_=!1,v=0;const u=[],m=[];let p=0,x=0;const y=[],b=[],N=[],M=[];if(d){n===r&&(l=i.decodeExponentialGolombNumber()),_=!!i.next(),v=i.decodeExponentialGolombNumber();const A=n-(l+1),O=a[A],L=O.num_negative_pics+O.num_positive_pics;for(let R=0;R<=L;R+=1)u[R]=!!i.next(),u[R]?m[R]=!0:m[R]=!!i.next();const P=(1-2*Number(_))*(v+1),j=[],z=[],Q=[],q=[];let Y=0;for(let R=0;R<O.num_negative_pics;R+=1)Y-=O.delta_poc_s0_minus1[R]+1,j[R]=Y;Y=0;for(let R=0;R<O.num_positive_pics;R+=1)Y+=O.delta_poc_s1_minus1[R]+1,z[R]=Y;let B=0;if(O.num_positive_pics>0)for(let R=O.num_positive_pics-1;R>=0;R-=1)Y=z[R]+P,Y<0&&m[O.num_negative_pics+R]&&(Q[B]=Y,b[B]=u[O.num_negative_pics+R],B+=1);P<0&&m[L]&&(Q[B]=P,b[B]=u[L],B+=1);for(let R=0;R<O.num_negative_pics;R+=1)Y=j[R]+P,Y<0&&m[R]&&(Q[B]=Y,b[B]=u[R],B+=1);p=B;let C=0;for(B=0;B<p;B+=1){const R=Q[B];y[B]=-(R-C-1),C=R}if(B=0,O.num_negative_pics>0)for(let R=O.num_negative_pics-1;R>=0;R-=1)Y=j[R]+P,Y>0&&m[R]&&(q[B]=Y,M[B]=u[R],B+=1);P>0&&m[L]&&(q[B]=P,M[B]=u[L],B+=1);for(let R=0;R<O.num_positive_pics;R+=1)Y=z[R]+P,Y>0&&m[O.num_negative_pics+R]&&(q[B]=Y,M[B]=u[O.num_negative_pics+R],B+=1);for(x=B,C=0,B=0;B<x;B+=1){const R=q[B];N[B]=R-C-1,C=R}}else{p=i.decodeExponentialGolombNumber(),x=i.decodeExponentialGolombNumber();for(let A=0;A<p;A+=1)y[A]=i.decodeExponentialGolombNumber(),b[A]=!!i.next();for(let A=0;A<x;A+=1)N[A]=i.decodeExponentialGolombNumber(),M[A]=!!i.next()}return{stRpsIdx:n,num_short_term_ref_pic_sets:r,inter_ref_pic_set_prediction_flag:d,delta_idx_minus1:l,delta_rps_sign:_,abs_delta_rps_minus1:v,used_by_curr_pic_flag:u,use_delta_flag:m,num_negative_pics:p,num_positive_pics:x,delta_poc_s0_minus1:y,used_by_curr_pic_s0_flag:b,delta_poc_s1_minus1:N,used_by_curr_pic_s1_flag:M}}function Cb(i,n){const r=!!i.next();let a,d,l;r&&(a=i.read(8),a===255&&(d=i.read(16),l=i.read(16)));const _=!!i.next();let v;_&&(v=!!i.next());const u=!!i.next();let m,p,x,y,b,N;u&&(m=i.read(3),p=!!i.next(),x=!!i.next(),x&&(y=i.read(8),b=i.read(8),N=i.read(8)));const M=!!i.next();let A,O;M&&(A=i.decodeExponentialGolombNumber(),O=i.decodeExponentialGolombNumber());const L=!!i.next(),P=!!i.next(),j=!!i.next(),z=!!i.next();let Q,q,Y,B;z&&(Q=i.decodeExponentialGolombNumber(),q=i.decodeExponentialGolombNumber(),Y=i.decodeExponentialGolombNumber(),B=i.decodeExponentialGolombNumber());const C=!!i.next();let R,se,_e,$,X,K;C&&(R=i.read(32),se=i.read(32),_e=!!i.next(),_e&&($=i.decodeExponentialGolombNumber()),X=!!i.next(),X&&(K=wd(i,!0,n)));const ne=!!i.next();let oe,ke,G,J,ue,ie,Se,ae;return ne&&(oe=!!i.next(),ke=!!i.next(),G=!!i.next(),J=i.decodeExponentialGolombNumber(),ue=i.decodeExponentialGolombNumber(),ie=i.decodeExponentialGolombNumber(),Se=i.decodeExponentialGolombNumber(),ae=i.decodeExponentialGolombNumber()),{aspect_ratio_info_present_flag:r,aspect_ratio_idc:a,sar_width:d,sar_height:l,overscan_info_present_flag:_,overscan_appropriate_flag:v,video_signal_type_present_flag:u,video_format:m,video_full_range_flag:p,colour_description_present_flag:x,colour_primaries:y,transfer_characteristics:b,matrix_coeffs:N,chroma_loc_info_present_flag:M,chroma_sample_loc_type_top_field:A,chroma_sample_loc_type_bottom_field:O,neutral_chroma_indication_flag:L,field_seq_flag:P,frame_field_info_present_flag:j,default_display_window_flag:z,def_disp_win_left_offset:Q,def_disp_win_right_offset:q,def_disp_win_top_offset:Y,def_disp_win_bottom_offset:B,vui_timing_info_present_flag:C,vui_num_units_in_tick:R,vui_time_scale:se,vui_poc_proportional_to_timing_flag:_e,vui_num_ticks_poc_diff_one_minus1:$,vui_hrd_parameters_present_flag:X,vui_hrd_parameters:K,bitstream_restriction_flag:ne,tiles_fixed_structure_flag:oe,motion_vectors_over_pic_boundaries_flag:ke,restricted_ref_pic_lists_flag:G,min_spatial_segmentation_idc:J,max_bytes_per_pic_denom:ue,max_bits_per_min_cu_denom:ie,log2_max_mv_length_horizontal:Se,log2_max_mv_length_vertical:ae}}function wd(i,n,r){let a,d,l,_,v,u,m,p,x,y,b,N,M;n&&(a=!!i.next(),d=!!i.next(),(a||d)&&(l=!!i.next(),l&&(_=i.read(8),v=i.read(5),u=!!i.next(),m=i.read(5)),p=i.read(4),x=i.read(4),l&&(y=i.read(4)),b=i.read(5),N=i.read(5),M=i.read(5)));const A=[],O=[],L=[],P=[],j=[],z=[],Q=[];for(let q=0;q<=r;q+=1)A[q]=!!i.next(),A[q]||(O[q]=!!i.next()),O[q]?L[q]=i.decodeExponentialGolombNumber():P[q]=!!i.next(),P[q]||(j[q]=i.decodeExponentialGolombNumber()),a&&(z[q]=Vc(i,q,Kc(j[q]))),d&&(Q[q]=Vc(i,q,Kc(j[q])));return{nal_hrd_parameters_present_flag:a,vcl_hrd_parameters_present_flag:d,sub_pic_hrd_params_present_flag:l,tick_divisor_minus2:_,du_cpb_removal_delay_increment_length_minus1:v,sub_pic_cpb_params_in_pic_timing_sei_flag:u,dpb_output_delay_du_length_minus1:m,bit_rate_scale:p,cpb_size_scale:x,cpb_size_du_scale:y,initial_cpb_removal_delay_length_minus1:b,au_cpb_removal_delay_length_minus1:N,dpb_output_delay_length_minus1:M,fixed_pic_rate_general_flag:A,fixed_pic_rate_within_cvs_flag:O,elemental_duration_in_tc_minus1:L,low_delay_hrd_flag:P,cpb_cnt_minus1:j,nalHrdParameters:z,vclHrdParameters:Q}}function Vc(i,n,r){const a=[],d=[],l=[],_=[],v=[];for(let u=0;u<r;u+=1)a[u]=i.decodeExponentialGolombNumber(),d[u]=i.decodeExponentialGolombNumber(),n>0&&(v[u]=!!i.next());return{bit_rate_value_minus1:a,cpb_size_value_minus1:d,cpb_size_du_value_minus1:l,bit_rate_du_value_minus1:_,cbr_flag:v}}function Kc(i){return i+1}function Tb(i){let n,r,a,d=0;for(const l of bd(i)){const _=yb(l),v={..._,data:l,rbsp:l.subarray(2)};switch(_.nal_unit_type){case 32:n=v;break;case 33:r=v;break;case 34:a=v;break;default:continue}if(d+=1,d===3)return{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:a}}throw new Error("Invalid data")}function Rb(i){return{inter_view_mv_vert_constraint_flag:!!i.next()}}function kb(i){const n=[],r=[];n[0]=!!i.next(),r[0]=!!i.next();const a=i.decodeExponentialGolombNumber(),d=!!i.next(),l=!!i.next(),_=!!i.next(),v=!!i.next();n[1]=!!i.next(),r[1]=!!i.next();const u=!!i.next(),m=i.decodeExponentialGolombNumber(),p=!!i.next(),x=!!i.next(),y=!!i.next(),b=!!i.next(),N=!!i.next();return{iv_di_mc_enabled_flag:n,iv_mv_scal_enabled_flag:r,log2_ivmc_sub_pb_size_minus3:a,iv_res_pred_enabled_flag:d,depth_ref_enabled_flag:l,vsp_mc_enabled_flag:_,dbbp_enabled_flag:v,tex_mc_enabled_flag:u,log2_texmc_sub_pb_size_minus3:m,intra_contour_enabled_flag:p,intra_dc_only_wedge_enabled_flag:x,cqt_cu_part_pred_enabled_flag:y,inter_dc_only_enabled_flag:b,skip_intra_enabled_flag:N}}function Ab(i){const{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:a}=Tb(i),{profileTierLevel:{generalProfileTier:{profile_space:d,tier_flag:l,profile_idc:_,profileCompatibilitySet:v,constraintSet:u},general_level_idc:m}}=wb(n.rbsp),{chroma_format_idc:p,pic_width_in_luma_samples:x,pic_height_in_luma_samples:y,conf_win_left_offset:b=0,conf_win_right_offset:N=0,conf_win_top_offset:M=0,conf_win_bottom_offset:A=0}=Eb(r.rbsp),O=vb(p),L=bb(p),P=x-O*(b+N),j=y-L*(M+A);return{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:a,generalProfileSpace:d,generalProfileIndex:_,generalProfileCompatibilitySet:v,generalTierFlag:l,generalLevelIndex:m,generalConstraintSet:u,encodedWidth:x,encodedHeight:y,cropLeft:b,cropRight:N,cropTop:M,cropBottom:A,croppedWidth:P,croppedHeight:j}}function Qc(i){return i.toString(16).toUpperCase()}function bo(i){return i.toString(16).toUpperCase().padStart(2,"0")}function kr(i){return i.toString(10).padStart(2,"0")}class jb{#e;#t;constructor(n,r){this.#e=n,this.#t=r}#n(n){const a=new gt(n).searchSequenceHeaderObu();if(!a)return;const{seq_profile:d,seq_level_idx:[l=0],max_frame_width_minus_1:_,max_frame_height_minus_1:v,color_config:{BitDepth:u,mono_chrome:m,subsampling_x:p,subsampling_y:x,chroma_sample_position:y,color_description_present_flag:b}}=a;let N,M,A,O;b?{color_primaries:N,transfer_characteristics:M,matrix_coefficients:A,color_range:O}=a.color_config:(N=gt.ColorPrimaries.Bt709,M=gt.TransferCharacteristics.Bt709,A=gt.MatrixCoefficients.Bt709,O=!1);const L=_+1,P=v+1;this.#t(L,P);const j=["av01",d.toString(16),kr(l)+(a.seq_tier[0]?"H":"M"),kr(u),m?"1":"0",(p?"1":"0")+(x?"1":"0")+y.toString(),kr(N),kr(M),kr(A),O?"1":"0"].join(".");this.#e.configure({codec:j,optimizeForLatency:!0})}decode(n){n.type!=="configuration"&&(this.#n(n.data),this.#e.decode(new EncodedVideoChunk({type:n.keyframe===!1?"delta":"key",timestamp:0,data:n.data})))}}class Ed{#e;#t;constructor(n){this.#t=n}decode(n){if(n.type==="configuration"){this.#e=n.data,this.configure(n.data);return}let r;this.#e!==void 0?(r=new Uint8Array(this.#e.length+n.data.length),r.set(this.#e,0),r.set(n.data,this.#e.length),this.#e=void 0):r=n.data,this.#t.decode(new EncodedVideoChunk({type:n.keyframe===!1?"delta":"key",timestamp:0,data:r}))}}class Pb extends Ed{#e;#t;constructor(n,r){super(n),this.#e=n,this.#t=r}configure(n){const{profileIndex:r,constraintSet:a,levelIndex:d,croppedWidth:l,croppedHeight:_}=xb(n);this.#t(l,_);const v="avc1."+bo(r)+bo(a)+bo(d);this.#e.configure({codec:v,optimizeForLatency:!0})}}class Mb extends Ed{#e;#t;constructor(n,r){super(n),this.#e=n,this.#t=r}configure(n){const{generalProfileSpace:r,generalProfileIndex:a,generalProfileCompatibilitySet:d,generalTierFlag:l,generalLevelIndex:_,generalConstraintSet:v,croppedWidth:u,croppedHeight:m}=Ab(n);this.#t(u,m);const p=["hev1",["","A","B","C"][r]+a.toString(),Qc(cb(d,0)),(l?"H":"L")+_.toString(),...Array.from(v,Qc)].join(".");this.#e.configure({codec:p,codedWidth:u,codedHeight:m,optimizeForLatency:!0})}}class Ib{listeners=[];constructor(){this.event=this.event.bind(this)}addEventListener(n){this.listeners.push(n);const r=()=>{const a=this.listeners.indexOf(n);a!==-1&&this.listeners.splice(a,1)};return r.dispose=r,r}event=(n,r,...a)=>{const d={listener:n,thisArg:r,args:a};return this.addEventListener(d)};fire(n){for(const r of this.listeners.slice())r.listener.apply(r.thisArg,[n,...r.args])}dispose(){this.listeners.length=0}}class Lb{#e;#t=new ReadableStream({start:n=>{this.#e=n},pull:n=>{n.enqueue(this.#r())}},{highWaterMark:0});#n=this.#t.getReader();#r;#i=0;#s;constructor(n,r){this.#r=n,this.#s=r}async borrow(){return(await this.#n.read()).value}return(n){this.#i<this.#s&&(this.#e.enqueue(n),this.#i+=1)}}class Db{#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(n){this.#e.width=n.displayWidth,this.#e.height=n.displayHeight;const r=await createImageBitmap(n);return this.#t.transferFromImageBitmap(r),this.#e instanceof OffscreenCanvas?await this.#e.convertToBlob({type:"image/png"}):new Promise((a,d)=>{this.#e.toBlob(l=>{l?a(l):d(new Error("Failed to convert canvas to blob"))},"image/png")})}}const Jc=new Lb(()=>new Db,4);class Zc{static get isSupported(){return typeof globalThis.VideoDecoder<"u"}static capabilities={h264:{},h265:{},av1:{}};#e;get codec(){return this.#e}#t;#n;get writable(){return this.#n}#r;#i;#s;get renderer(){return this.#s}#o=0;#l=0;get framesRendered(){return this.#l}#c=0;get framesSkipped(){return this.#c}#d=new Ib;get sizeChanged(){return this.#d.event}#a;#p=!1;#u;#f;#m=0;constructor({codec:n,renderer:r}){switch(this.#e=n,this.#s=r,this.#a=new VideoDecoder({output:a=>{if(this.#f?.close(),this.#f=a.clone(),this.#p){this.#u&&(this.#u.close(),this.#c+=1),this.#u=a;return}this.#_(a)},error:a=>{this.#g(a)}}),this.#e){case Bs.H264:this.#t=new Pb(this.#a,this.#h);break;case Bs.H265:this.#t=new Mb(this.#a,this.#h);break;case Bs.AV1:this.#t=new jb(this.#a,this.#h);break;default:throw new Error(`Unsupported codec: ${this.#e}`)}this.#n=new ub({start:a=>{this.#r?a.error(this.#r):this.#i=a},write:a=>{this.#t.decode(a)}}),this.#x()}#g(n){if(this.#i)try{this.#i.error(n)}catch{}else this.#r=n}async#_(n){try{if(this.#p=!0,this.#h(n.displayWidth,n.displayHeight),await this.#s.draw(n),this.#o+=1,n.close(),this.#u){const r=this.#u;this.#u=void 0,await this.#_(r)}this.#p=!1}catch(r){this.#g(r)}}#h=(n,r)=>{this.#s.setSize(n,r),this.#d.fire({width:n,height:r})};#x=()=>{this.#o>0&&(this.#l+=1,this.#c+=this.#o-1,this.#o=0),this.#m=requestAnimationFrame(this.#x)};async snapshot(){const n=this.#f;if(!n)return;const r=await Jc.borrow(),a=await r.capture(n);return Jc.return(r),a}dispose(){cancelAnimationFrame(this.#m),this.#a.state!=="closed"&&this.#a.close(),this.#u?.close(),this.#f?.close()}}var yo={exports:{}},wo={exports:{}},eu;function Jo(){return eu||(eu=1,(function(){function i(n,r){throw new Error("abstract")}i.prototype.drawFrame=function(n){throw new Error("abstract")},i.prototype.clear=function(){throw new Error("abstract")},wo.exports=i})()),wo.exports}var Eo={exports:{}},So={exports:{}},No={exports:{}},tu;function Ob(){return tu||(tu=1,(function(){function i(n){for(var r=0,a=n>>1;a!=0;)a=a>>1,r++;if(n!==1<<r)throw"chroma plane dimensions must be power of 2 ratio to luma plane dimensions; got "+n;return r}No.exports=i})()),No.exports}var nu;function Bb(){return nu||(nu=1,(function(){var i=Ob();function n(r,a){var d=r.format.width|0,l=r.format.height|0,_=i(r.format.width/r.format.chromaWidth)|0,v=i(r.format.height/r.format.chromaHeight)|0,u=r.y.bytes,m=r.u.bytes,p=r.v.bytes,x=r.y.stride|0,y=r.u.stride|0,b=r.v.stride|0,N=d<<2,M=0,A=0,O=0,L=0,P=0,j=0,z=0,Q=0,q=0,Y=0,B=0,C=0,R=0,se=0,_e=0,$=0,X=0,K=0;if(_==1&&v==1)for(z=0,Q=N,K=0,$=0;$<l;$+=2){for(A=$*x|0,O=A+x|0,L=K*y|0,P=K*b|0,_e=0;_e<d;_e+=2)q=m[L++]|0,Y=p[P++]|0,C=(409*Y|0)-57088|0,R=(100*q|0)+(208*Y|0)-34816|0,se=(516*q|0)-70912|0,B=298*u[A++]|0,a[z]=B+C>>8,a[z+1]=B-R>>8,a[z+2]=B+se>>8,z+=4,B=298*u[A++]|0,a[z]=B+C>>8,a[z+1]=B-R>>8,a[z+2]=B+se>>8,z+=4,B=298*u[O++]|0,a[Q]=B+C>>8,a[Q+1]=B-R>>8,a[Q+2]=B+se>>8,Q+=4,B=298*u[O++]|0,a[Q]=B+C>>8,a[Q+1]=B-R>>8,a[Q+2]=B+se>>8,Q+=4;z+=N,Q+=N,K++}else for(j=0,$=0;$<l;$++)for(X=0,K=$>>v,M=$*x|0,L=K*y|0,P=K*b|0,_e=0;_e<d;_e++)X=_e>>_,q=m[L+X]|0,Y=p[P+X]|0,C=(409*Y|0)-57088|0,R=(100*q|0)+(208*Y|0)-34816|0,se=(516*q|0)-70912|0,B=298*u[M++]|0,a[j]=B+C>>8,a[j+1]=B-R>>8,a[j+2]=B+se>>8,j+=4}So.exports={convertYCbCr:n}})()),So.exports}var ru;function Fb(){return ru||(ru=1,(function(){var i=Jo(),n=Bb();function r(a){var d=this,l=a.getContext("2d"),_=null,v=null,u=null;function m(x,y){_=l.createImageData(x,y);for(var b=_.data,N=x*y*4,M=0;M<N;M+=4)b[M+3]=255}function p(x,y){v=document.createElement("canvas"),v.width=x,v.height=y,u=v.getContext("2d")}return d.drawFrame=function(y){var b=y.format;(a.width!==b.displayWidth||a.height!==b.displayHeight)&&(a.width=b.displayWidth,a.height=b.displayHeight),(_===null||_.width!=b.width||_.height!=b.height)&&m(b.width,b.height),n.convertYCbCr(y,_.data);var N=b.cropWidth!=b.displayWidth||b.cropHeight!=b.displayHeight,M;N?(v||p(b.cropWidth,b.cropHeight),M=u):M=l,M.putImageData(_,-b.cropLeft,-b.cropTop,b.cropLeft,b.cropTop,b.cropWidth,b.cropHeight),N&&l.drawImage(v,0,0,b.displayWidth,b.displayHeight)},d.clear=function(){l.clearRect(0,0,a.width,a.height)},d}r.prototype=Object.create(i.prototype),Eo.exports=r})()),Eo.exports}var Co={exports:{}},To,su;function Ub(){return su||(su=1,To={vertex:`precision mediump float;
37
-
38
- attribute vec2 aPosition;
39
- attribute vec2 aLumaPosition;
40
- attribute vec2 aChromaPosition;
41
- varying vec2 vLumaPosition;
42
- varying vec2 vChromaPosition;
43
- void main() {
44
- gl_Position = vec4(aPosition, 0, 1);
45
- vLumaPosition = aLumaPosition;
46
- vChromaPosition = aChromaPosition;
47
- }
48
- `,fragment:`// inspired by https://github.com/mbebenita/Broadway/blob/master/Player/canvas.js
49
-
50
- precision mediump float;
51
-
52
- uniform sampler2D uTextureY;
53
- uniform sampler2D uTextureCb;
54
- uniform sampler2D uTextureCr;
55
- varying vec2 vLumaPosition;
56
- varying vec2 vChromaPosition;
57
- void main() {
58
- // Y, Cb, and Cr planes are uploaded as ALPHA textures.
59
- float fY = texture2D(uTextureY, vLumaPosition).w;
60
- float fCb = texture2D(uTextureCb, vChromaPosition).w;
61
- float fCr = texture2D(uTextureCr, vChromaPosition).w;
62
-
63
- // Premultipy the Y...
64
- float fYmul = fY * 1.1643828125;
65
-
66
- // And convert that to RGB!
67
- gl_FragColor = vec4(
68
- fYmul + 1.59602734375 * fCr - 0.87078515625,
69
- fYmul - 0.39176171875 * fCb - 0.81296875 * fCr + 0.52959375,
70
- fYmul + 2.017234375 * fCb - 1.081390625,
71
- 1
72
- );
73
- }
74
- `,vertexStripe:`precision mediump float;
75
-
76
- attribute vec2 aPosition;
77
- attribute vec2 aTexturePosition;
78
- varying vec2 vTexturePosition;
79
-
80
- void main() {
81
- gl_Position = vec4(aPosition, 0, 1);
82
- vTexturePosition = aTexturePosition;
83
- }
84
- `,fragmentStripe:`// extra 'stripe' texture fiddling to work around IE 11's poor performance on gl.LUMINANCE and gl.ALPHA textures
85
-
86
- precision mediump float;
87
-
88
- uniform sampler2D uStripe;
89
- uniform sampler2D uTexture;
90
- varying vec2 vTexturePosition;
91
- void main() {
92
- // Y, Cb, and Cr planes are mapped into a pseudo-RGBA texture
93
- // so we can upload them without expanding the bytes on IE 11
94
- // which doesn't allow LUMINANCE or ALPHA textures
95
- // The stripe textures mark which channel to keep for each pixel.
96
- // Each texture extraction will contain the relevant value in one
97
- // channel only.
98
-
99
- float fLuminance = dot(
100
- texture2D(uStripe, vTexturePosition),
101
- texture2D(uTexture, vTexturePosition)
102
- );
103
-
104
- gl_FragColor = vec4(0, 0, 0, fLuminance);
105
- }
106
- `}),To}var iu;function Wb(){return iu||(iu=1,(function(){var i=Jo(),n=Ub();function r(a){var d=this,l=r.contextForCanvas(a);if(l===null)throw new Error("WebGL unavailable");function _($,X){var K=l.createShader($);if(l.shaderSource(K,X),l.compileShader(K),!l.getShaderParameter(K,l.COMPILE_STATUS)){var ne=l.getShaderInfoLog(K);throw l.deleteShader(K),new Error("GL shader compilation for "+$+" failed: "+ne)}return K}var v,u,m=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),p={},x={},y={},b,N,M,A,O,L,P,j,z,Q;function q($,X){return(!p[$]||X)&&(p[$]=l.createTexture()),p[$]}function Y($,X,K,ne,oe){var ke=!p[$]||X,G=q($,X);if(l.activeTexture(l.TEXTURE0),r.stripe){var J=!p[$+"_temp"]||X,ue=q($+"_temp",X);l.bindTexture(l.TEXTURE_2D,ue),J?(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.NEAREST),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,K/4,ne,0,l.RGBA,l.UNSIGNED_BYTE,oe)):l.texSubImage2D(l.TEXTURE_2D,0,0,0,K/4,ne,l.RGBA,l.UNSIGNED_BYTE,oe);var ie=p[$+"_stripe"],Se=!ie||X;Se&&(ie=q($+"_stripe",X)),l.bindTexture(l.TEXTURE_2D,ie),Se&&(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.NEAREST),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,K,1,0,l.RGBA,l.UNSIGNED_BYTE,R(K)))}else l.bindTexture(l.TEXTURE_2D,G),ke?(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texImage2D(l.TEXTURE_2D,0,l.ALPHA,K,ne,0,l.ALPHA,l.UNSIGNED_BYTE,oe)):l.texSubImage2D(l.TEXTURE_2D,0,0,0,K,ne,l.ALPHA,l.UNSIGNED_BYTE,oe)}function B($,X,K,ne){var oe=p[$];l.useProgram(u);var ke=x[$];(!ke||X)&&(l.activeTexture(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,oe),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,K,ne,0,l.RGBA,l.UNSIGNED_BYTE,null),ke=x[$]=l.createFramebuffer()),l.bindFramebuffer(l.FRAMEBUFFER,ke),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,oe,0);var G=p[$+"_temp"];l.activeTexture(l.TEXTURE1),l.bindTexture(l.TEXTURE_2D,G),l.uniform1i(L,1);var J=p[$+"_stripe"];l.activeTexture(l.TEXTURE2),l.bindTexture(l.TEXTURE_2D,J),l.uniform1i(O,2),l.bindBuffer(l.ARRAY_BUFFER,b),l.enableVertexAttribArray(N),l.vertexAttribPointer(N,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,M),l.enableVertexAttribArray(A),l.vertexAttribPointer(A,2,l.FLOAT,!1,0,0),l.viewport(0,0,K,ne),l.drawArrays(l.TRIANGLES,0,m.length/2),l.bindFramebuffer(l.FRAMEBUFFER,null)}function C($,X,K){l.activeTexture(X),l.bindTexture(l.TEXTURE_2D,p[$]),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.LINEAR),l.uniform1i(l.getUniformLocation(v,$),K)}function R($){if(y[$])return y[$];for(var X=$,K=new Uint32Array(X),ne=0;ne<X;ne+=4)K[ne]=255,K[ne+1]=65280,K[ne+2]=16711680,K[ne+3]=4278190080;return y[$]=new Uint8Array(K.buffer)}function se($,X){var K=_(l.VERTEX_SHADER,$),ne=_(l.FRAGMENT_SHADER,X),oe=l.createProgram();if(l.attachShader(oe,K),l.attachShader(oe,ne),l.linkProgram(oe),!l.getProgramParameter(oe,l.LINK_STATUS)){var ke=l.getProgramInfoLog(oe);throw l.deleteProgram(oe),new Error("GL program linking failed: "+ke)}return oe}function _e(){if(r.stripe){u=se(n.vertexStripe,n.fragmentStripe),l.getAttribLocation(u,"aPosition"),M=l.createBuffer();var $=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);l.bindBuffer(l.ARRAY_BUFFER,M),l.bufferData(l.ARRAY_BUFFER,$,l.STATIC_DRAW),A=l.getAttribLocation(u,"aTexturePosition"),O=l.getUniformLocation(u,"uStripe"),L=l.getUniformLocation(u,"uTexture")}v=se(n.vertex,n.fragment),b=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,b),l.bufferData(l.ARRAY_BUFFER,m,l.STATIC_DRAW),N=l.getAttribLocation(v,"aPosition"),P=l.createBuffer(),j=l.getAttribLocation(v,"aLumaPosition"),z=l.createBuffer(),Q=l.getAttribLocation(v,"aChromaPosition")}return d.drawFrame=function($){var X=$.format,K=!v||a.width!==X.displayWidth||a.height!==X.displayHeight;if(K&&(a.width=X.displayWidth,a.height=X.displayHeight,d.clear()),v||_e(),K){var ne=function(oe,ke,G){var J=X.cropLeft/G,ue=(X.cropLeft+X.cropWidth)/G,ie=(X.cropTop+X.cropHeight)/X.height,Se=X.cropTop/X.height,ae=new Float32Array([J,ie,ue,ie,J,Se,J,Se,ue,ie,ue,Se]);l.bindBuffer(l.ARRAY_BUFFER,oe),l.bufferData(l.ARRAY_BUFFER,ae,l.STATIC_DRAW)};ne(P,j,$.y.stride),ne(z,Q,$.u.stride*X.width/X.chromaWidth)}Y("uTextureY",K,$.y.stride,X.height,$.y.bytes),Y("uTextureCb",K,$.u.stride,X.chromaHeight,$.u.bytes),Y("uTextureCr",K,$.v.stride,X.chromaHeight,$.v.bytes),r.stripe&&(B("uTextureY",K,$.y.stride,X.height),B("uTextureCb",K,$.u.stride,X.chromaHeight),B("uTextureCr",K,$.v.stride,X.chromaHeight)),l.useProgram(v),l.viewport(0,0,a.width,a.height),C("uTextureY",l.TEXTURE0,0),C("uTextureCb",l.TEXTURE1,1),C("uTextureCr",l.TEXTURE2,2),l.bindBuffer(l.ARRAY_BUFFER,b),l.enableVertexAttribArray(N),l.vertexAttribPointer(N,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,P),l.enableVertexAttribArray(j),l.vertexAttribPointer(j,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,z),l.enableVertexAttribArray(Q),l.vertexAttribPointer(Q,2,l.FLOAT,!1,0,0),l.drawArrays(l.TRIANGLES,0,m.length/2)},d.clear=function(){l.viewport(0,0,a.width,a.height),l.clearColor(0,0,0,0),l.clear(l.COLOR_BUFFER_BIT)},d.clear(),d}r.stripe=!1,r.contextForCanvas=function(a){var d={preferLowPowerToHighPerformance:!0,powerPreference:"low-power",failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!0};return a.getContext("webgl",d)||a.getContext("experimental-webgl",d)},r.isAvailable=function(){var a=document.createElement("canvas"),d;a.width=1,a.height=1;try{d=r.contextForCanvas(a)}catch{return!1}if(d){var l=d.TEXTURE0,_=4,v=4,u=d.createTexture(),m=new Uint8Array(_*v),p=r.stripe?_/4:_,x=r.stripe?d.RGBA:d.ALPHA,y=r.stripe?d.NEAREST:d.LINEAR;d.activeTexture(l),d.bindTexture(d.TEXTURE_2D,u),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,y),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,y),d.texImage2D(d.TEXTURE_2D,0,x,p,v,0,x,d.UNSIGNED_BYTE,m);var b=d.getError();return!b}else return!1},r.prototype=Object.create(i.prototype),Co.exports=r})()),Co.exports}var ou;function Hb(){return ou||(ou=1,(function(){var i=Jo(),n=Fb(),r=Wb(),a={FrameSink:i,SoftwareFrameSink:n,WebGLFrameSink:r,attach:function(d,l){l=l||{};var _="webGL"in l?l.webGL:r.isAvailable();return _?new r(d,l):new n(d,l)}};yo.exports=a})()),yo.exports}Hb();function Sd(){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 Nd{#e;get canvas(){return this.#e}constructor(n){n?this.#e=n:this.#e=Sd()}setSize(n,r){(this.#e.width!==n||this.#e.height!==r)&&(this.#e.width=n,this.#e.height=r)}}class Gb extends Nd{#e;constructor(n){super(n),this.#e=this.canvas.getContext("bitmaprenderer",{alpha:!1})}async draw(n){const r=await createImageBitmap(n);this.#e.transferFromImageBitmap(r)}}const zb=Promise.resolve();function au(i,n){const r={powerPreference:"low-power",alpha:!1,failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!!n};return i.getContext("webgl2",r)||i.getContext("webgl",r)}class Or extends Nd{static vertexShaderSource=`
107
- attribute vec2 xy;
108
-
109
- varying highp vec2 uv;
110
-
111
- void main(void) {
112
- gl_Position = vec4(xy, 0.0, 1.0);
113
- // Map vertex coordinates (-1 to +1) to UV coordinates (0 to 1).
114
- // UV coordinates are Y-flipped relative to vertex coordinates.
115
- uv = vec2((1.0 + xy.x) / 2.0, (1.0 - xy.y) / 2.0);
116
- }
117
- `;static fragmentShaderSource=`
118
- varying highp vec2 uv;
119
-
120
- uniform sampler2D texture;
121
-
122
- void main(void) {
123
- gl_FragColor = texture2D(texture, uv);
124
- }
125
- `;static get isSupported(){const n=Sd();return!!au(n)}#e;constructor(n,r){super(n);const a=au(this.canvas,r);if(!a)throw new Error("WebGL not supported");this.#e=a;const d=a.createShader(a.VERTEX_SHADER);if(a.shaderSource(d,Or.vertexShaderSource),a.compileShader(d),!a.getShaderParameter(d,a.COMPILE_STATUS))throw new Error(a.getShaderInfoLog(d));const l=a.createShader(a.FRAGMENT_SHADER);if(a.shaderSource(l,Or.fragmentShaderSource),a.compileShader(l),!a.getShaderParameter(l,a.COMPILE_STATUS))throw new Error(a.getShaderInfoLog(l));const _=a.createProgram();if(a.attachShader(_,d),a.attachShader(_,l),a.linkProgram(_),!a.getProgramParameter(_,a.LINK_STATUS))throw new Error(a.getProgramInfoLog(_));a.useProgram(_);const v=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,v),a.bufferData(a.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),a.STATIC_DRAW);const u=a.getAttribLocation(_,"xy");a.vertexAttribPointer(u,2,a.FLOAT,!1,0,0),a.enableVertexAttribArray(u);const m=a.createTexture();a.bindTexture(a.TEXTURE_2D,m),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE)}draw(n){const r=this.#e;return r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,n),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight),r.drawArrays(r.TRIANGLE_FAN,0,4),zb}}function lu(){return typeof window>"u"||!window.VideoDecoder?"browser_unsupported":window.isSecureContext?null:"insecure_context"}const Cd="webcodecs_warning_dismissed";function qb(){return!sessionStorage.getItem(Cd)}function $b(){sessionStorage.setItem(Cd,"true")}const cu=50,Xb=300;function Yb({deviceId:i,className:n,onFallback:r,fallbackTimeout:a=2e4,enableControl:d=!1,onTapSuccess:l,onTapError:_,onSwipeSuccess:v,onSwipeError:u,onStreamReady:m}){const p=E.useRef(null),x=E.useRef(null),y=E.useRef(null),b=E.useRef(null),N=E.useRef(null),M=E.useRef(null),A=E.useRef(null),O=E.useRef(!1),L=E.useRef(!1),P=E.useRef(r),j=E.useRef(a),z=E.useRef(m),[Q,q]=E.useState("connecting"),[Y,B]=E.useState(null),[C,R]=E.useState(null),[se,_e]=E.useState(null),$=E.useRef(!1),X=E.useRef(null),K=E.useRef(!1),ne=E.useRef(0),oe=E.useRef(null),ke=E.useRef(null),G=E.useRef(null),J=E.useRef(null);E.useEffect(()=>{P.current=r,j.current=a,z.current=m},[r,a,m]),E.useEffect(()=>{(async()=>{try{const Z=await hu(i);Z.success&&_e({width:Z.width,height:Z.height})}catch(Z){console.error("[ScrcpyPlayer] Failed to fetch device resolution:",Z)}})()},[i]);const ue=E.useCallback(()=>{const ee=b.current,Z=y.current;if(!ee||!Z||!C)return;const Ee=Z.clientWidth,je=Z.clientHeight,{width:fe,height:xe}=C,Ce=fe/xe;let pe=Ee,ct=Ee/Ce;ct>je&&(ct=je,pe=je*Ce),ee.width=fe,ee.height=xe,ee.style.width=`${pe}px`,ee.style.height=`${ct}px`},[C]);E.useEffect(()=>{const ee=()=>ue();return window.addEventListener("resize",ee),()=>window.removeEventListener("resize",ee)},[ue]),E.useEffect(()=>{ue()},[C,ue]);const ie=E.useCallback(async()=>{if(Or.isSupported){const Z=new Or;return{renderer:Z,element:Z.canvas}}const ee=new Gb;return{renderer:ee,element:ee.canvas}},[]),Se=E.useCallback(async ee=>{if(!Zc.isSupported){const je=lu()||"decoder_unsupported";throw P.current?.(je),new Error("Current browser does not support WebCodecs API. Please use the latest Chrome/Edge.")}const{renderer:Z,element:Ee}=await ie();return b.current=Ee,y.current&&!Ee.parentElement&&y.current.appendChild(Ee),new Zc({codec:ee,renderer:Z})},[ie]),ae=E.useCallback(()=>{O.current||(O.current=!0,N.current&&(clearTimeout(N.current),N.current=null))},[]),ze=E.useCallback(ee=>{let Z=!1,Ee=[];const je=new TransformStream({transform(xe,Ce){if(xe.type==="configuration"){Ce.enqueue(xe),Z=!0,Ee.length>0&&(Ee.forEach(pe=>Ce.enqueue(pe)),Ee=[]);return}if(xe.type==="data"&&!Z){Ee.push(xe);return}Ce.enqueue(xe)}});return new ReadableStream({start(xe){let Ce=!1;const pe=it=>{if(!Ce)try{ae();const Ve={...it,data:it.data instanceof Uint8Array?it.data:new Uint8Array(it.data)};xe.enqueue(Ve)}catch(Ve){console.error("[ScrcpyPlayer] Video enqueue error:",Ve),Ce=!0,wt()}},ct=it=>{Ce||(xe.error(new Error(it?.message||"Socket error")),Ce=!0,wt())},yt=()=>{Ce||(xe.close(),Ce=!0,wt())},wt=()=>{p.current?.off("video-data",pe),p.current?.off("error",ct),p.current?.off("disconnect",yt)};return p.current?.on("video-data",pe),p.current?.on("error",ct),p.current?.on("disconnect",yt),()=>{Ce=!0,wt()}}}).pipeThrough(je)},[ae]),Qe=E.useCallback((ee=!1)=>{if(ee&&(L.current=!0),x.current){try{x.current.dispose()}catch(Z){console.error("[ScrcpyPlayer] Failed to dispose decoder:",Z)}x.current=null}b.current=null,p.current&&(p.current.disconnect(),p.current=null),z.current?.(null),M.current&&(clearTimeout(M.current),M.current=null),N.current&&(clearTimeout(N.current),N.current=null),q("disconnected"),R(null),B(null)},[]),me=E.useCallback(()=>{Qe(!0),O.current=!1,q("connecting"),B(null);const ee=Os({path:"/socket.io",transports:["websocket"],timeout:1e4});p.current=ee,ee.on("connect",()=>{ee.emit("connect-device",{device_id:i,maxSize:1280,bitRate:4e6}),N.current=setTimeout(()=>{O.current||(q("error"),B("Video stream timeout"),L.current=!0,ee.close(),P.current?.())},j.current)}),ee.on("video-metadata",async Z=>{try{x.current&&(x.current.dispose(),x.current=null);const Ee=Z?.codec?Z.codec:Bs.H264;x.current=await Se(Ee),x.current.sizeChanged(({width:fe,height:xe})=>{R({width:fe,height:xe})}),ze(Z).pipeTo(x.current.writable).catch(fe=>{console.error("[ScrcpyPlayer] Video stream error:",fe)}),q("connected"),z.current?.({close:()=>ee.close()})}catch(Ee){console.error("[ScrcpyPlayer] Decoder initialization failed:",Ee),q("error"),B("Decoder initialization failed"),L.current=!0,ee.close();const je=lu()||"decoder_error";P.current?.(je)}}),ee.on("error",Z=>{console.error("[ScrcpyPlayer] Socket error:",Z),q("error"),B(Z?.message||"Socket error"),!L.current&&(z.current?.(null),M.current||(M.current=setTimeout(()=>{M.current=null,A.current?.()},3e3)))}),ee.on("disconnect",()=>{if(L.current){L.current=!1;return}q("disconnected"),z.current?.(null),M.current||(M.current=setTimeout(()=>{M.current=null,A.current?.()},3e3))})},[i,Qe,Se,ze]);E.useEffect(()=>{A.current=me},[me]),E.useEffect(()=>(queueMicrotask(()=>{me()}),()=>{ke.current&&(clearTimeout(ke.current),ke.current=null),G.current&&(clearTimeout(G.current),G.current=null),Qe(!0)}),[me,Qe]);const D=()=>{if(C)return{width:C.width,height:C.height};const ee=b.current;return ee?{width:ee.width,height:ee.height}:null},le=(ee,Z)=>{const Ee=b.current,je=D();if(!Ee||!je)return null;const fe=Ee.getBoundingClientRect();if(ee<fe.left||ee>fe.right||Z<fe.top||Z>fe.bottom)return null;const xe=ee-fe.left,Ce=Z-fe.top,pe=Math.round(xe/fe.width*je.width),ct=Math.round(Ce/fe.height*je.height),yt=se?se.width/je.width:1,wt=se?se.height/je.height:1;return{x:Math.round(pe*yt),y:Math.round(ct*wt)}},he=async ee=>{if(!d||Q!=="connected")return;const Z=le(ee.clientX,ee.clientY);if(Z){$.current=!0,K.current=!1,X.current={x:ee.clientX,y:ee.clientY};try{await Ax(Z.x,Z.y,i)}catch(Ee){console.error("[ScrcpyPlayer] Touch down failed:",Ee)}}},Fe=ee=>{if(!$.current||Q!=="connected")return;const Z=Date.now(),Ee=le(ee.clientX,ee.clientY);if(Ee){if(X.current){const je=ee.clientX-X.current.x,fe=ee.clientY-X.current.y;Math.hypot(je,fe)>4&&(K.current=!0)}if(oe.current=Ee,Z-ne.current<cu){ke.current||(ke.current=setTimeout(()=>{ke.current=null,oe.current&&(Ic(oe.current.x,oe.current.y,i).catch(je=>{console.error("[ScrcpyPlayer] Touch move failed:",je)}),oe.current=null,ne.current=Date.now())},cu));return}ne.current=Z,Ic(Ee.x,Ee.y,i).catch(je=>{console.error("[ScrcpyPlayer] Touch move failed:",je)})}},We=async ee=>{if(!$.current||Q!=="connected")return;const Z=le(ee.clientX,ee.clientY);if($.current=!1,X.current=null,!!Z)try{await Mc(Z.x,Z.y,i),K.current?v?.():l?.()}catch(Ee){const je=String(Ee);K.current?u?.(je):_?.(je)}},de=async ee=>{if(!$.current||Q!=="connected")return;const Z=le(ee.clientX,ee.clientY);if($.current=!1,X.current=null,!!Z)try{await Mc(Z.x,Z.y,i)}catch(Ee){console.error("[ScrcpyPlayer] Touch cancel failed:",Ee)}},Ne=ee=>{if(!d||Q!=="connected")return;ee.preventDefault();const Z=ee.deltaY;J.current||(J.current={deltaY:0}),J.current.deltaY+=Z,G.current&&clearTimeout(G.current),G.current=setTimeout(async()=>{const Ee=J.current;if(J.current=null,!Ee)return;const je=b.current,fe=D();if(!je||!fe)return;const xe=je.getBoundingClientRect(),Ce=xe.left+xe.width/2,pe=xe.top+xe.height/2,ct=le(Ce,pe);if(!ct)return;const yt=Math.max(Math.min(Ee.deltaY,600),-600),wt=pe+yt,it=le(Ce,wt);if(it)try{const Ve=await kx(ct.x,ct.y,it.x,it.y,300,i);Ve.success?v?.():u?.(Ve.error||"Scroll failed")}catch(Ve){u?.(String(Ve))}},Xb)};return o.jsx("div",{className:`relative w-full h-full flex items-center justify-center ${n||""}`,children:o.jsx("div",{ref:y,className:"relative w-full h-full flex items-center justify-center bg-slate-50 dark:bg-slate-900",onMouseDown:he,onMouseMove:Fe,onMouseUp:We,onMouseLeave:de,onWheel:Ne,children:Q!=="connected"&&o.jsxs("div",{className:"absolute inset-0 flex items-center justify-center text-slate-400",children:[Q==="connecting"&&"Connecting...",Q==="error"&&(Y||"Connection error"),Q==="disconnected"&&"Disconnected"]})})})}const Vb={compact:320,standard:400,wide:480,auto:"auto"};function Kb({currentWidth:i,onWidthChange:n}){const r=An(),a=_=>{n(Vb[_])},d=()=>{if(typeof i!="number")return;const _=Math.max(240,i-40);n(_)},l=()=>{if(typeof i!="number")return;const _=Math.min(640,i+40);n(_)};return o.jsxs("div",{className:"flex items-center gap-1 bg-popover/90 backdrop-blur rounded-xl p-1 shadow-lg border border-border",children:[typeof i=="number"&&o.jsxs(en,{children:[o.jsx(tn,{asChild:!0,children:o.jsx(we,{variant:"ghost",size:"sm",onClick:d,className:"h-7 w-7 p-0 rounded-lg",disabled:i<=240,children:o.jsx(pv,{className:"w-3 h-3"})})}),o.jsx(nn,{children:o.jsx("p",{children:r.deviceMonitor?.decreaseWidth||"Decrease width"})})]}),o.jsx(we,{variant:"ghost",size:"sm",onClick:()=>a("compact"),className:`h-7 px-2 text-xs rounded-lg transition-colors ${i===320?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:r.deviceMonitor?.compact||"Compact"}),o.jsx(we,{variant:"ghost",size:"sm",onClick:()=>a("standard"),className:`h-7 px-2 text-xs rounded-lg transition-colors ${i===400?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:r.deviceMonitor?.standard||"Standard"}),o.jsx(we,{variant:"ghost",size:"sm",onClick:()=>a("wide"),className:`h-7 px-2 text-xs rounded-lg transition-colors ${i===480?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:r.deviceMonitor?.wide||"Wide"}),o.jsxs(we,{variant:"ghost",size:"sm",onClick:()=>a("auto"),className:`h-7 px-2 text-xs rounded-lg transition-colors ${i==="auto"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[o.jsx(fv,{className:"w-3 h-3 mr-1"}),r.deviceMonitor?.auto||"Auto"]}),typeof i=="number"&&o.jsxs(en,{children:[o.jsx(tn,{asChild:!0,children:o.jsx(we,{variant:"ghost",size:"sm",onClick:l,className:"h-7 w-7 p-0 rounded-lg",disabled:i>=640,children:o.jsx(yu,{className:"w-3 h-3"})})}),o.jsx(nn,{children:o.jsx("p",{children:r.deviceMonitor?.increaseWidth||"Increase width"})})]})]})}function Qb({onResize:i,onResizeStart:n,onResizeEnd:r,minWidth:a=240,maxWidth:d=640,className:l=""}){const[_,v]=E.useState(!1),u=E.useRef(0),m=E.useRef(0),p=E.useRef(null),x=y=>{if(y.preventDefault(),v(!0),u.current=y.clientX,p.current?.parentElement){const b=p.current.parentElement.getBoundingClientRect();m.current=b.width}n?.()};return E.useEffect(()=>{if(!_)return;const y=N=>{const M=N.clientX-u.current,A=Math.min(d,Math.max(a,m.current+M));i(A-m.current)},b=()=>{v(!1),r?.()};return document.addEventListener("mousemove",y),document.addEventListener("mouseup",b),()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",b)}},[_,a,d,i,r]),o.jsx("div",{ref:p,className:`absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-primary/50 active:bg-primary transition-colors group ${_?"bg-primary":""} ${l}`,onMouseDown:x,children:o.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx("div",{className:"w-1 h-8 bg-primary rounded-full"})})})}function Jb(i,n){const[r,a]=E.useState(()=>{if(typeof window>"u")return n;try{const l=window.localStorage.getItem(i);return l?JSON.parse(l):n}catch(l){return console.error(`Error loading localStorage key "${i}":`,l),n}});return[r,l=>{try{const _=l instanceof Function?l(r):l;a(_),typeof window<"u"&&window.localStorage.setItem(i,JSON.stringify(_))}catch(_){console.error(`Error setting localStorage key "${i}":`,_)}}]}function Td({deviceId:i,serial:n,connectionType:r,isVisible:a=!0,className:d=""}){const l=An(),_=r==="remote",[v,u]=E.useState(null),[m,p]=E.useState(!_),[x,y]=E.useState(!1),[b,N]=E.useState(_?"screenshot":"auto"),[M,A]=E.useState(null),[O,L]=E.useState("success"),[P,j]=E.useState(!1),[z,Q]=E.useState(!1),[q,Y]=Jb("device-monitor-width",320),[B,C]=E.useState(null),[R,se]=E.useState(!1),_e=E.useRef(null),$=E.useRef(!1),X=E.useRef(null),K=E.useRef(null),ne=(me,D=2e3,le="success")=>{X.current&&clearTimeout(X.current),L(le),A(me),X.current=setTimeout(()=>{A(null)},D)},oe=()=>{K.current&&clearTimeout(K.current),j(!0)},ke=()=>{K.current=setTimeout(()=>{j(!1)},500)},G=()=>{Q(me=>!me)},J=me=>{Y(me)},ue=me=>{if(typeof q!="number")return;const D=Math.min(640,Math.max(240,q+me));Y(D)},ie=E.useCallback(me=>{_e.current=me},[]),Se=E.useCallback(me=>{y(!0),p(!1),C(me||null),b==="video"&&me&&qb()&&se(!0)},[b]),ae=me=>{N(me)};E.useEffect(()=>()=>{X.current&&clearTimeout(X.current),K.current&&clearTimeout(K.current),_e.current&&_e.current.close()},[]),E.useEffect(()=>{if(!i||!a||!(b==="screenshot"||b==="auto"&&x))return;const D=async()=>{if(!$.current){$.current=!0;try{const he=await hu(i);he.success&&u(he)}catch(he){console.error("Failed to fetch screenshot:",he)}finally{$.current=!1}}};D();const le=setInterval(D,500);return()=>clearInterval(le)},[i,x,b,a]);const ze=me=>({insecure_context:l.deviceMonitor?.requireHttpsOrLocalhost||"视频流需要 HTTPS 或 localhost 环境。建议下载桌面应用以获得完整功能。",browser_unsupported:l.deviceMonitor?.browserNotSupported||"当前浏览器不支持 WebCodecs API。请使用最新版 Chrome 或 Edge 浏览器。",decoder_error:l.deviceMonitor?.decoderInitFailed||"视频解码器初始化失败。",decoder_unsupported:l.deviceMonitor?.codecNotSupported||"设备编解码器不支持。"})[me]||l.deviceMonitor?.unknownError||"未知错误",Qe=typeof q=="number"?`${q}px`:"auto";return o.jsxs(Ys,{className:`flex-shrink-0 relative min-h-0 overflow-hidden bg-background ${d}`,style:{width:Qe,minWidth:typeof q=="number"?void 0:"240px",maxWidth:typeof q=="number"?void 0:"640px"},onMouseEnter:oe,onMouseLeave:ke,children:[typeof q=="number"&&o.jsx(Qb,{onResize:ue,minWidth:240,maxWidth:640,className:"z-20"}),o.jsx("div",{className:`absolute top-4 right-4 z-10 transition-opacity duration-200 ${P?"opacity-100":"opacity-0 pointer-events-none"}`,children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsxs("div",{className:`flex flex-col items-end gap-2 transition-all duration-300 ${z?"opacity-100 translate-x-0":"opacity-0 translate-x-4 pointer-events-none"}`,children:[o.jsxs("div",{className:"flex items-center gap-1 bg-popover/90 backdrop-blur rounded-xl p-1 shadow-lg border border-border",children:[!_&&o.jsx(we,{variant:"ghost",size:"sm",onClick:()=>ae("auto"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${b==="auto"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:l.devicePanel?.auto||"Auto"}),!_&&o.jsxs(we,{variant:"ghost",size:"sm",onClick:()=>ae("video"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${b==="video"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[o.jsx(Tv,{className:"w-3 h-3 mr-1"}),l.devicePanel?.video||"Video"]}),o.jsxs(we,{variant:"ghost",size:"sm",onClick:()=>ae("screenshot"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${b==="screenshot"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[o.jsx(Fc,{className:"w-3 h-3 mr-1"}),l.devicePanel?.image||"Image"]})]}),o.jsx(Kb,{currentWidth:q,onWidthChange:J})]}),o.jsx(we,{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:z?"Hide controls":"Show controls",children:z?o.jsx(wu,{className:"w-4 h-4"}):o.jsx(Nu,{className:"w-4 h-4"})})]})}),o.jsx("div",{className:"absolute bottom-4 left-4 z-10",children:o.jsxs(Hn,{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:[b==="auto"&&(l.devicePanel?.auto||"Auto"),b==="video"&&o.jsxs(o.Fragment,{children:[o.jsx(gv,{className:"w-3 h-3 mr-1"}),l.devicePanel?.video||"Video"]}),b==="screenshot"&&o.jsxs(o.Fragment,{children:[o.jsx(Fc,{className:"w-3 h-3 mr-1"}),l.devicePanel?.imageRefresh||"Screenshot"]})]})}),M&&o.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:[O==="error"&&o.jsx(_n,{className:"w-4 h-4"}),O==="tap"&&o.jsx(ov,{className:"w-4 h-4"}),O==="swipe"&&o.jsx(Vx,{className:"w-4 h-4"}),O==="success"&&o.jsx(Fr,{className:"w-4 h-4"}),o.jsx("span",{children:M})]}),b==="video"||b==="auto"&&m&&!x?o.jsxs(o.Fragment,{children:[R&&B&&o.jsx("div",{className:"absolute top-0 left-0 right-0 z-20 bg-amber-50/95 dark:bg-amber-950/95 border-b border-amber-200 dark:border-amber-800 backdrop-blur-sm",children:o.jsxs("div",{className:"px-4 py-3 flex items-start gap-3",children:[o.jsx(_n,{className:"w-5 h-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5"}),o.jsxs("div",{className:"flex-1 space-y-2",children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsx("p",{className:"text-sm font-medium text-amber-900 dark:text-amber-100",children:l.deviceMonitor?.videoUnavailableWarning||"视频流不可用"}),o.jsx(we,{variant:"ghost",size:"icon",className:"h-5 w-5 -mr-2 hover:bg-amber-100 dark:hover:bg-amber-900",onClick:()=>{se(!1),$b()},children:o.jsx(qx,{className:"w-3 h-3"})})]}),o.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:ze(B)}),B==="insecure_context"&&o.jsx(we,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>window.open("https://github.com/suyiiyii/AutoGLM-GUI/releases","_blank"),children:l.deviceMonitor?.downloadElectron||"下载桌面应用"})]})]})}),o.jsx(Yb,{deviceId:i,className:"w-full h-full",enableControl:!0,onFallback:Se,onTapSuccess:()=>ne(l.devicePanel?.tapped||"Tapped",2e3,"tap"),onTapError:me=>ne((l.devicePanel?.tapError||"Tap error: {error}").replace("{error}",me),3e3,"error"),onSwipeSuccess:()=>ne(l.devicePanel?.swiped||"Swiped",2e3,"swipe"),onSwipeError:me=>ne((l.devicePanel?.swipeError||"Swipe error: {error}").replace("{error}",me),3e3,"error"),onStreamReady:ie,fallbackTimeout:2e4})]}):o.jsx("div",{className:"w-full h-full flex items-center justify-center bg-muted/30 min-h-0",children:v&&v.success?o.jsxs("div",{className:"relative w-full h-full flex items-center justify-center min-h-0",children:[o.jsx("img",{src:`data:image/png;base64,${v.image}`,alt:"Device Screenshot",className:"max-w-full max-h-full object-contain",style:{width:v.width>v.height?"100%":"auto",height:v.width>v.height?"auto":"100%"}}),v.is_sensitive&&o.jsx("div",{className:"absolute top-12 right-2 px-2 py-1 bg-yellow-500 text-white text-xs rounded-lg",children:l.devicePanel?.sensitiveContent||"Sensitive Content"})]}):v?.error?o.jsxs("div",{className:"text-center text-destructive",children:[o.jsx(_n,{className:"w-8 h-8 mx-auto mb-2"}),o.jsx("p",{className:"font-medium",children:l.devicePanel?.screenshotFailed||"Screenshot Failed"}),o.jsx("p",{className:"text-xs mt-1 opacity-60",children:v.error})]}):o.jsxs("div",{className:"text-center text-muted-foreground",children:[o.jsx(Yt,{className:"w-8 h-8 mx-auto mb-2 animate-spin"}),o.jsx("p",{className:"text-sm",children:l.devicePanel?.loading||"Loading..."})]})})]})}function Zb(i,[n,r]){return Math.min(r,Math.max(n,i))}function ey(i,n){return E.useReducer((r,a)=>n[r][a]??r,i)}var Zo="ScrollArea",[Rd]=Xs(Zo),[ty,Ht]=Rd(Zo),kd=E.forwardRef((i,n)=>{const{__scopeScrollArea:r,type:a="hover",dir:d,scrollHideDelay:l=600,..._}=i,[v,u]=E.useState(null),[m,p]=E.useState(null),[x,y]=E.useState(null),[b,N]=E.useState(null),[M,A]=E.useState(null),[O,L]=E.useState(0),[P,j]=E.useState(0),[z,Q]=E.useState(!1),[q,Y]=E.useState(!1),B=xn(n,R=>u(R)),C=qo(d);return o.jsx(ty,{scope:r,type:a,dir:C,scrollHideDelay:l,scrollArea:v,viewport:m,onViewportChange:p,content:x,onContentChange:y,scrollbarX:b,onScrollbarXChange:N,scrollbarXEnabled:z,onScrollbarXEnabledChange:Q,scrollbarY:M,onScrollbarYChange:A,scrollbarYEnabled:q,onScrollbarYEnabledChange:Y,onCornerWidthChange:L,onCornerHeightChange:j,children:o.jsx(Vt.div,{dir:C,..._,ref:B,style:{position:"relative","--radix-scroll-area-corner-width":O+"px","--radix-scroll-area-corner-height":P+"px",...i.style}})})});kd.displayName=Zo;var Ad="ScrollAreaViewport",jd=E.forwardRef((i,n)=>{const{__scopeScrollArea:r,children:a,nonce:d,...l}=i,_=Ht(Ad,r),v=E.useRef(null),u=xn(n,v,_.onViewportChange);return o.jsxs(o.Fragment,{children:[o.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:d}),o.jsx(Vt.div,{"data-radix-scroll-area-viewport":"",...l,ref:u,style:{overflowX:_.scrollbarXEnabled?"scroll":"hidden",overflowY:_.scrollbarYEnabled?"scroll":"hidden",...i.style},children:o.jsx("div",{ref:_.onContentChange,style:{minWidth:"100%",display:"table"},children:a})})]})});jd.displayName=Ad;var on="ScrollAreaScrollbar",Pd=E.forwardRef((i,n)=>{const{forceMount:r,...a}=i,d=Ht(on,i.__scopeScrollArea),{onScrollbarXEnabledChange:l,onScrollbarYEnabledChange:_}=d,v=i.orientation==="horizontal";return E.useEffect(()=>(v?l(!0):_(!0),()=>{v?l(!1):_(!1)}),[v,l,_]),d.type==="hover"?o.jsx(ny,{...a,ref:n,forceMount:r}):d.type==="scroll"?o.jsx(ry,{...a,ref:n,forceMount:r}):d.type==="auto"?o.jsx(Md,{...a,ref:n,forceMount:r}):d.type==="always"?o.jsx(ea,{...a,ref:n}):null});Pd.displayName=on;var ny=E.forwardRef((i,n)=>{const{forceMount:r,...a}=i,d=Ht(on,i.__scopeScrollArea),[l,_]=E.useState(!1);return E.useEffect(()=>{const v=d.scrollArea;let u=0;if(v){const m=()=>{window.clearTimeout(u),_(!0)},p=()=>{u=window.setTimeout(()=>_(!1),d.scrollHideDelay)};return v.addEventListener("pointerenter",m),v.addEventListener("pointerleave",p),()=>{window.clearTimeout(u),v.removeEventListener("pointerenter",m),v.removeEventListener("pointerleave",p)}}},[d.scrollArea,d.scrollHideDelay]),o.jsx(Br,{present:r||l,children:o.jsx(Md,{"data-state":l?"visible":"hidden",...a,ref:n})})}),ry=E.forwardRef((i,n)=>{const{forceMount:r,...a}=i,d=Ht(on,i.__scopeScrollArea),l=i.orientation==="horizontal",_=ei(()=>u("SCROLL_END"),100),[v,u]=ey("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return E.useEffect(()=>{if(v==="idle"){const m=window.setTimeout(()=>u("HIDE"),d.scrollHideDelay);return()=>window.clearTimeout(m)}},[v,d.scrollHideDelay,u]),E.useEffect(()=>{const m=d.viewport,p=l?"scrollLeft":"scrollTop";if(m){let x=m[p];const y=()=>{const b=m[p];x!==b&&(u("SCROLL"),_()),x=b};return m.addEventListener("scroll",y),()=>m.removeEventListener("scroll",y)}},[d.viewport,l,u,_]),o.jsx(Br,{present:r||v!=="hidden",children:o.jsx(ea,{"data-state":v==="hidden"?"hidden":"visible",...a,ref:n,onPointerEnter:_t(i.onPointerEnter,()=>u("POINTER_ENTER")),onPointerLeave:_t(i.onPointerLeave,()=>u("POINTER_LEAVE"))})})}),Md=E.forwardRef((i,n)=>{const r=Ht(on,i.__scopeScrollArea),{forceMount:a,...d}=i,[l,_]=E.useState(!1),v=i.orientation==="horizontal",u=ei(()=>{if(r.viewport){const m=r.viewport.offsetWidth<r.viewport.scrollWidth,p=r.viewport.offsetHeight<r.viewport.scrollHeight;_(v?m:p)}},10);return lr(r.viewport,u),lr(r.content,u),o.jsx(Br,{present:a||l,children:o.jsx(ea,{"data-state":l?"visible":"hidden",...d,ref:n})})}),ea=E.forwardRef((i,n)=>{const{orientation:r="vertical",...a}=i,d=Ht(on,i.__scopeScrollArea),l=E.useRef(null),_=E.useRef(0),[v,u]=E.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),m=Bd(v.viewport,v.content),p={...a,sizes:v,onSizesChange:u,hasThumb:m>0&&m<1,onThumbChange:y=>l.current=y,onThumbPointerUp:()=>_.current=0,onThumbPointerDown:y=>_.current=y};function x(y,b){return cy(y,_.current,v,b)}return r==="horizontal"?o.jsx(sy,{...p,ref:n,onThumbPositionChange:()=>{if(d.viewport&&l.current){const y=d.viewport.scrollLeft,b=uu(y,v,d.dir);l.current.style.transform=`translate3d(${b}px, 0, 0)`}},onWheelScroll:y=>{d.viewport&&(d.viewport.scrollLeft=y)},onDragScroll:y=>{d.viewport&&(d.viewport.scrollLeft=x(y,d.dir))}}):r==="vertical"?o.jsx(iy,{...p,ref:n,onThumbPositionChange:()=>{if(d.viewport&&l.current){const y=d.viewport.scrollTop,b=uu(y,v);l.current.style.transform=`translate3d(0, ${b}px, 0)`}},onWheelScroll:y=>{d.viewport&&(d.viewport.scrollTop=y)},onDragScroll:y=>{d.viewport&&(d.viewport.scrollTop=x(y))}}):null}),sy=E.forwardRef((i,n)=>{const{sizes:r,onSizesChange:a,...d}=i,l=Ht(on,i.__scopeScrollArea),[_,v]=E.useState(),u=E.useRef(null),m=xn(n,u,l.onScrollbarXChange);return E.useEffect(()=>{u.current&&v(getComputedStyle(u.current))},[u]),o.jsx(Ld,{"data-orientation":"horizontal",...d,ref:m,sizes:r,style:{bottom:0,left:l.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:l.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Zs(r)+"px",...i.style},onThumbPointerDown:p=>i.onThumbPointerDown(p.x),onDragScroll:p=>i.onDragScroll(p.x),onWheelScroll:(p,x)=>{if(l.viewport){const y=l.viewport.scrollLeft+p.deltaX;i.onWheelScroll(y),Ud(y,x)&&p.preventDefault()}},onResize:()=>{u.current&&l.viewport&&_&&a({content:l.viewport.scrollWidth,viewport:l.viewport.offsetWidth,scrollbar:{size:u.current.clientWidth,paddingStart:$s(_.paddingLeft),paddingEnd:$s(_.paddingRight)}})}})}),iy=E.forwardRef((i,n)=>{const{sizes:r,onSizesChange:a,...d}=i,l=Ht(on,i.__scopeScrollArea),[_,v]=E.useState(),u=E.useRef(null),m=xn(n,u,l.onScrollbarYChange);return E.useEffect(()=>{u.current&&v(getComputedStyle(u.current))},[u]),o.jsx(Ld,{"data-orientation":"vertical",...d,ref:m,sizes:r,style:{top:0,right:l.dir==="ltr"?0:void 0,left:l.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Zs(r)+"px",...i.style},onThumbPointerDown:p=>i.onThumbPointerDown(p.y),onDragScroll:p=>i.onDragScroll(p.y),onWheelScroll:(p,x)=>{if(l.viewport){const y=l.viewport.scrollTop+p.deltaY;i.onWheelScroll(y),Ud(y,x)&&p.preventDefault()}},onResize:()=>{u.current&&l.viewport&&_&&a({content:l.viewport.scrollHeight,viewport:l.viewport.offsetHeight,scrollbar:{size:u.current.clientHeight,paddingStart:$s(_.paddingTop),paddingEnd:$s(_.paddingBottom)}})}})}),[oy,Id]=Rd(on),Ld=E.forwardRef((i,n)=>{const{__scopeScrollArea:r,sizes:a,hasThumb:d,onThumbChange:l,onThumbPointerUp:_,onThumbPointerDown:v,onThumbPositionChange:u,onDragScroll:m,onWheelScroll:p,onResize:x,...y}=i,b=Ht(on,r),[N,M]=E.useState(null),A=xn(n,B=>M(B)),O=E.useRef(null),L=E.useRef(""),P=b.viewport,j=a.content-a.viewport,z=Rn(p),Q=Rn(u),q=ei(x,10);function Y(B){if(O.current){const C=B.clientX-O.current.left,R=B.clientY-O.current.top;m({x:C,y:R})}}return E.useEffect(()=>{const B=C=>{const R=C.target;N?.contains(R)&&z(C,j)};return document.addEventListener("wheel",B,{passive:!1}),()=>document.removeEventListener("wheel",B,{passive:!1})},[P,N,j,z]),E.useEffect(Q,[a,Q]),lr(N,q),lr(b.content,q),o.jsx(oy,{scope:r,scrollbar:N,hasThumb:d,onThumbChange:Rn(l),onThumbPointerUp:Rn(_),onThumbPositionChange:Q,onThumbPointerDown:Rn(v),children:o.jsx(Vt.div,{...y,ref:A,style:{position:"absolute",...y.style},onPointerDown:_t(i.onPointerDown,B=>{B.button===0&&(B.target.setPointerCapture(B.pointerId),O.current=N.getBoundingClientRect(),L.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",b.viewport&&(b.viewport.style.scrollBehavior="auto"),Y(B))}),onPointerMove:_t(i.onPointerMove,Y),onPointerUp:_t(i.onPointerUp,B=>{const C=B.target;C.hasPointerCapture(B.pointerId)&&C.releasePointerCapture(B.pointerId),document.body.style.webkitUserSelect=L.current,b.viewport&&(b.viewport.style.scrollBehavior=""),O.current=null})})})}),qs="ScrollAreaThumb",Dd=E.forwardRef((i,n)=>{const{forceMount:r,...a}=i,d=Id(qs,i.__scopeScrollArea);return o.jsx(Br,{present:r||d.hasThumb,children:o.jsx(ay,{ref:n,...a})})}),ay=E.forwardRef((i,n)=>{const{__scopeScrollArea:r,style:a,...d}=i,l=Ht(qs,r),_=Id(qs,r),{onThumbPositionChange:v}=_,u=xn(n,x=>_.onThumbChange(x)),m=E.useRef(void 0),p=ei(()=>{m.current&&(m.current(),m.current=void 0)},100);return E.useEffect(()=>{const x=l.viewport;if(x){const y=()=>{if(p(),!m.current){const b=uy(x,v);m.current=b,v()}};return v(),x.addEventListener("scroll",y),()=>x.removeEventListener("scroll",y)}},[l.viewport,p,v]),o.jsx(Vt.div,{"data-state":_.hasThumb?"visible":"hidden",...d,ref:u,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...a},onPointerDownCapture:_t(i.onPointerDownCapture,x=>{const b=x.target.getBoundingClientRect(),N=x.clientX-b.left,M=x.clientY-b.top;_.onThumbPointerDown({x:N,y:M})}),onPointerUp:_t(i.onPointerUp,_.onThumbPointerUp)})});Dd.displayName=qs;var ta="ScrollAreaCorner",Od=E.forwardRef((i,n)=>{const r=Ht(ta,i.__scopeScrollArea),a=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&a?o.jsx(ly,{...i,ref:n}):null});Od.displayName=ta;var ly=E.forwardRef((i,n)=>{const{__scopeScrollArea:r,...a}=i,d=Ht(ta,r),[l,_]=E.useState(0),[v,u]=E.useState(0),m=!!(l&&v);return lr(d.scrollbarX,()=>{const p=d.scrollbarX?.offsetHeight||0;d.onCornerHeightChange(p),u(p)}),lr(d.scrollbarY,()=>{const p=d.scrollbarY?.offsetWidth||0;d.onCornerWidthChange(p),_(p)}),m?o.jsx(Vt.div,{...a,ref:n,style:{width:l,height:v,position:"absolute",right:d.dir==="ltr"?0:void 0,left:d.dir==="rtl"?0:void 0,bottom:0,...i.style}}):null});function $s(i){return i?parseInt(i,10):0}function Bd(i,n){const r=i/n;return isNaN(r)?0:r}function Zs(i){const n=Bd(i.viewport,i.content),r=i.scrollbar.paddingStart+i.scrollbar.paddingEnd,a=(i.scrollbar.size-r)*n;return Math.max(a,18)}function cy(i,n,r,a="ltr"){const d=Zs(r),l=d/2,_=n||l,v=d-_,u=r.scrollbar.paddingStart+_,m=r.scrollbar.size-r.scrollbar.paddingEnd-v,p=r.content-r.viewport,x=a==="ltr"?[0,p]:[p*-1,0];return Fd([u,m],x)(i)}function uu(i,n,r="ltr"){const a=Zs(n),d=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,l=n.scrollbar.size-d,_=n.content-n.viewport,v=l-a,u=r==="ltr"?[0,_]:[_*-1,0],m=Zb(i,u);return Fd([0,_],[0,v])(m)}function Fd(i,n){return r=>{if(i[0]===i[1]||n[0]===n[1])return n[0];const a=(n[1]-n[0])/(i[1]-i[0]);return n[0]+a*(r-i[0])}}function Ud(i,n){return i>0&&i<n}var uy=(i,n=()=>{})=>{let r={left:i.scrollLeft,top:i.scrollTop},a=0;return(function d(){const l={left:i.scrollLeft,top:i.scrollTop},_=r.left!==l.left,v=r.top!==l.top;(_||v)&&n(),r=l,a=window.requestAnimationFrame(d)})(),()=>window.cancelAnimationFrame(a)};function ei(i,n){const r=Rn(i),a=E.useRef(0);return E.useEffect(()=>()=>window.clearTimeout(a.current),[]),E.useCallback(()=>{window.clearTimeout(a.current),a.current=window.setTimeout(r,n)},[r,n])}function lr(i,n){const r=Rn(n);jx(()=>{let a=0;if(i){const d=new ResizeObserver(()=>{cancelAnimationFrame(a),a=window.requestAnimationFrame(r)});return d.observe(i),()=>{window.cancelAnimationFrame(a),d.unobserve(i)}}},[i,r])}var dy=kd,fy=jd,hy=Od;function Dr({className:i,children:n,...r}){return o.jsxs(dy,{"data-slot":"scroll-area",className:cr("relative",i),...r,children:[o.jsx(fy,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:n}),o.jsx(py,{}),o.jsx(hy,{})]})}function py({className:i,orientation:n="vertical",...r}){return o.jsx(Pd,{"data-slot":"scroll-area-scrollbar",orientation:n,className:cr("flex touch-none p-px transition-colors select-none",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",i),...r,children:o.jsx(Dd,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}function my(i){const n=new Date(i),a=new Date().getTime()-n.getTime(),d=Math.floor(a/6e4),l=Math.floor(a/36e5),_=Math.floor(a/864e5);return d<1?"Just now":d<60?`${d}m ago`:l<24?`${l}h ago`:_<7?`${_}d ago`:n.toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function gy(i){const n=Math.floor(i/1e3),r=Math.floor(n/60),a=n%60;return r===0?`${a}s`:`${r}m ${a}s`}function Wd({item:i,onSelect:n,onDelete:r}){const a=An(),d=l=>{l.stopPropagation(),confirm(a.history.deleteConfirm)&&r(i.id)};return o.jsx(Ys,{className:"hover:bg-slate-50 dark:hover:bg-slate-800/50 transition-colors cursor-pointer group",onClick:()=>n(i),children:o.jsxs("div",{className:"p-3 space-y-2",children:[o.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 line-clamp-2",children:i.task_text}),o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500 dark:text-slate-400",children:[o.jsx("span",{children:my(i.start_time)}),o.jsx("span",{children:"•"}),o.jsxs("span",{children:[i.steps," ",i.steps===1?"step":"steps"]}),o.jsx("span",{children:"•"}),o.jsx("span",{children:gy(i.duration_ms)})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Hn,{variant:i.success?"success":"destructive",className:"shrink-0",children:i.success?o.jsxs(o.Fragment,{children:[o.jsx(Fr,{className:"w-3 h-3 mr-1"}),a.history.success]}):o.jsxs(o.Fragment,{children:[o.jsx(_n,{className:"w-3 h-3 mr-1"}),a.history.failed]})}),o.jsx(we,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity text-slate-400 hover:text-red-500 dark:text-slate-500 dark:hover:text-red-400",onClick:d,title:a.history.deleteItem,children:o.jsx(bu,{className:"w-3 h-3"})})]})]})]})})}function _y({deviceId:i,deviceSerial:n,deviceName:r,deviceConnectionType:a,isConfigured:d}){const l=An(),[_,v]=E.useState([]),[u,m]=E.useState(""),[p,x]=E.useState(!1),[y,b]=E.useState(!1),[N,M]=E.useState(null),[A,O]=E.useState(!1),[L,P]=E.useState([]),[j,z]=E.useState([]),[Q,q]=E.useState(!1),Y=E.useRef(null),B=E.useRef(null),C=E.useRef(null),R=E.useRef(0),se=E.useRef(null),[_e,$]=E.useState(!0),[X,K]=E.useState(!1),ne=E.useRef(od.throttle(()=>{const D=C.current;if(!D)return;const le=80,he=D.scrollHeight-D.scrollTop-D.clientHeight,Fe=he<=1;$(Fe),he<=le&&K(!1)},100));E.useEffect(()=>{const D=ne.current;return()=>{D.cancel()}},[]),E.useEffect(()=>{A&&(async()=>{try{const le=await mu(n,20,0);P(le.records)}catch(le){console.error("Failed to load history:",le),P([])}})()},[A,n]);const oe=D=>{const le=[],he=D.messages.find(Ne=>Ne.role==="user");he?le.push({id:`${D.id}-user`,role:"user",content:he.content||D.task_text,timestamp:new Date(he.timestamp)}):le.push({id:`${D.id}-user`,role:"user",content:D.task_text,timestamp:new Date(D.start_time)});const Fe=[],We=[];D.messages.filter(Ne=>Ne.role==="assistant").forEach(Ne=>{Ne.thinking&&Fe.push(Ne.thinking),Ne.action&&We.push(Ne.action)});const de={id:`${D.id}-agent`,role:"assistant",content:D.final_message,timestamp:D.end_time?new Date(D.end_time):new Date(D.start_time),steps:D.steps,success:D.success,thinking:Fe,actions:We,isStreaming:!1};le.push(de),v(le),R.current=le.length,se.current=[de.id,de.content?.length??0,de.currentThinking?.length??0,de.thinking?JSON.stringify(de.thinking).length:0,de.steps??"",de.isStreaming?1:0].join("|"),K(!1),$(!0),O(!1)},ke=async()=>{if(confirm(l.history.clearAllConfirm))try{await _u(n),P([])}catch(D){console.error("Failed to clear history:",D)}},G=async D=>{try{await xu(n,D),P(le=>le.filter(he=>he.id!==D))}catch(le){console.error("Failed to delete history item:",le)}},J=E.useCallback(async()=>{const D=u.trim();if(!D||p)return;const le={id:Date.now().toString(),role:"user",content:D,timestamp:new Date};v(fe=>[...fe,le]),m(""),x(!0),M(null);const he=[],Fe=[];let We="";const de=[];let Ne=null;const ee=(Date.now()+1).toString(),Z={id:ee,role:"assistant",content:"",timestamp:new Date,thinking:[],actions:[],isStreaming:!0,currentThinking:""};v(fe=>[...fe,Z]);const Ee=()=>{if(de.length>0){const fe=de.join("");de.length=0,We+=fe,v(xe=>xe.map(Ce=>Ce.id===ee?{...Ce,currentThinking:We}:Ce))}Ne=null},je=Px(le.content,i,fe=>{de.push(fe.chunk),Ne===null&&(Ne=setTimeout(Ee,50))},fe=>{Ne!==null&&(clearTimeout(Ne),Ee());const xe=fe.thinking&&fe.thinking.length>0?fe.thinking:We;xe&&he.push(xe),We="",Fe.push(fe.action),v(Ce=>Ce.map(pe=>pe.id===ee?{...pe,thinking:[...he],actions:[...Fe],steps:fe.step,currentThinking:""}:pe))},fe=>{Ne!==null&&clearTimeout(Ne);const xe={...Z,content:fe.message,success:fe.success,isStreaming:!1,steps:fe.steps,thinking:[...he],actions:[...Fe],timestamp:new Date,currentThinking:void 0};v(Ce=>Ce.map(pe=>pe.id===ee?xe:pe)),x(!1),Y.current=null},fe=>{Ne!==null&&clearTimeout(Ne);const xe={...Z,content:`Error: ${fe.message}`,success:!1,isStreaming:!1,thinking:[...he],actions:[...Fe],timestamp:new Date,currentThinking:void 0};v(Ce=>Ce.map(pe=>pe.id===ee?xe:pe)),x(!1),M(fe.message),Y.current=null},fe=>{Ne!==null&&clearTimeout(Ne);const xe={...Z,content:fe.message||"Chat aborted by user",success:!1,isStreaming:!1,thinking:[...he],actions:[...Fe],timestamp:new Date,currentThinking:void 0};v(Ce=>Ce.map(pe=>pe.id===ee?xe:pe)),x(!1),Y.current=null});Y.current=je},[u,p,i]),ue=E.useCallback(async()=>{Y.current&&Y.current.close(),v([]),x(!1),M(null),K(!1),$(!0),Y.current=null,R.current=0,se.current=null,await Mx(i)},[i]),ie=E.useCallback(async()=>{if(Y.current){b(!0);try{Y.current&&(Y.current.close(),Y.current=null),v(D=>{const le=D[D.length-1];return le&&le.role==="assistant"&&le.isStreaming?D.map((he,Fe)=>Fe===D.length-1?{...he,content:he.content||l.chat.aborted,isStreaming:!1,success:!1,currentThinking:void 0}:he):D}),Ix(i).catch(D=>console.error("Backend abort failed:",D))}catch(D){console.error("Failed to abort chat:",D)}finally{x(!1),b(!1)}}},[i,l]),Se=E.useCallback(()=>{B.current?.scrollIntoView({behavior:"smooth"})},[]);E.useEffect(()=>{const D=_[_.length-1],le=D?.thinking?JSON.stringify(D.thinking).length:0,he=D?[D.id,D.content?.length??0,D.currentThinking?.length??0,le,D.steps??"",D.isStreaming?1:0].join("|"):null,Fe=_.length>R.current,We=he!==se.current&&_.length>0;if(R.current=_.length,se.current=he,_e){Se(),K(!1);return}if(_.length===0){K(!1);return}(Fe||We)&&K(!0)},[_,_e,Se]),E.useEffect(()=>()=>{Y.current&&Y.current.close()},[i]),E.useEffect(()=>{(async()=>{try{const le=await gu();z(le.workflows)}catch(le){console.error("Failed to load workflows:",le)}})()},[]);const ae=D=>{m(D.text),q(!1)},ze=()=>{ne.current()},Qe=()=>{Se(),K(!1),$(!0)},me=D=>{(D.metaKey||D.ctrlKey)&&D.key==="Enter"&&(D.preventDefault(),J())};return o.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[o.jsxs(Ys,{className:"flex-1 flex flex-col min-h-0 max-w-2xl",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:o.jsx(jr,{className:"h-5 w-5 text-[#1d9bf0]"})}),o.jsxs("div",{className:"group",children:[o.jsx("div",{className:"flex items-center gap-1",children:o.jsx("h2",{className:"font-bold text-slate-900 dark:text-slate-100",children:r})}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 font-mono",children:i})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(Us,{open:A,onOpenChange:O,children:[o.jsx(Ws,{asChild:!0,children:o.jsx(we,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300",title:l.history.title,children:o.jsx(Fs,{className:"h-4 w-4"})})}),o.jsxs(Hs,{className:"w-96 p-0",align:"end",sideOffset:8,children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[o.jsx("h3",{className:"font-semibold text-sm text-slate-900 dark:text-slate-100",children:l.history.title}),L.length>0&&o.jsx(we,{variant:"ghost",size:"sm",onClick:ke,className:"h-7 text-xs",children:l.history.clearAll})]}),o.jsx(Dr,{className:"h-[400px]",children:o.jsx("div",{className:"p-4 space-y-2",children:L.length>0?L.map(D=>o.jsx(Wd,{item:D,onSelect:oe,onDelete:G},D.id)):o.jsxs("div",{className:"text-center py-8",children:[o.jsx(Fs,{className:"h-12 w-12 text-slate-300 dark:text-slate-700 mx-auto mb-3"}),o.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:l.history.noHistory}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:l.history.noHistoryDescription})]})})})]})]}),!d&&o.jsxs(Hn,{variant:"warning",children:[o.jsx(_n,{className:"w-3 h-3 mr-1"}),l.devicePanel.noConfig]}),o.jsx(we,{variant:"ghost",size:"icon",onClick:ue,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:o.jsx(Cu,{className:"h-4 w-4"})})]})]}),N&&o.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:[o.jsx(_n,{className:"w-4 h-4 flex-shrink-0"}),N]}),o.jsxs("div",{className:"flex-1 min-h-0 relative",children:[o.jsxs("div",{className:"h-full overflow-y-auto p-4",ref:C,onScroll:ze,children:[_.length===0?o.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center min-h-[calc(100%-1rem)]",children:[o.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800 mb-4",children:o.jsx(jr,{className:"h-8 w-8 text-slate-400"})}),o.jsx("p",{className:"font-medium text-slate-900 dark:text-slate-100",children:l.devicePanel.readyToHelp}),o.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:l.devicePanel.describeTask})]}):_.map(D=>o.jsx("div",{className:`flex ${D.role==="user"?"justify-end":"justify-start"}`,children:D.role==="assistant"?o.jsxs("div",{className:"max-w-[85%] space-y-3",children:[D.thinking?.map((le,he)=>o.jsxs("div",{className:"bg-slate-100 dark:bg-slate-800 rounded-2xl rounded-tl-sm px-4 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:o.jsx(jr,{className:"h-3 w-3 text-[#1d9bf0]"})}),o.jsxs("span",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:["Step ",he+1]})]}),o.jsx("p",{className:"text-sm whitespace-pre-wrap text-slate-700 dark:text-slate-300",children:le}),D.actions?.[he]&&o.jsxs("details",{className:"mt-2 text-xs",children:[o.jsx("summary",{className:"cursor-pointer text-[#1d9bf0] hover:text-[#1a8cd8]",children:"View action"}),o.jsx("pre",{className:"mt-2 p-2 bg-slate-900 text-slate-200 rounded-lg overflow-x-auto text-xs",children:JSON.stringify(D.actions[he],null,2)})]})]},he)),D.currentThinking&&o.jsxs("div",{className:"bg-slate-100 dark:bg-slate-800 rounded-2xl rounded-tl-sm px-4 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:o.jsx(jr,{className:"h-3 w-3 text-[#1d9bf0] animate-pulse"})}),o.jsx("span",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:"Thinking..."})]}),o.jsxs("p",{className:"text-sm whitespace-pre-wrap text-slate-700 dark:text-slate-300",children:[D.currentThinking,o.jsx("span",{className:"inline-block w-1 h-4 ml-0.5 bg-[#1d9bf0] animate-pulse"})]})]}),D.content&&o.jsxs("div",{className:`
126
- rounded-2xl px-4 py-3 flex items-start gap-2
127
- ${D.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"}
128
- `,children:[o.jsx(Fr,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${D.success===!1?"text-red-500":"text-green-500"}`}),o.jsxs("div",{children:[o.jsx("p",{className:"whitespace-pre-wrap",children:D.content}),D.steps!==void 0&&o.jsxs("p",{className:"text-xs mt-2 opacity-60 text-slate-500 dark:text-slate-400",children:[D.steps," steps completed"]})]})]}),D.isStreaming&&o.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 dark:text-slate-400",children:[o.jsx(Yt,{className:"w-4 h-4 animate-spin"}),"Processing..."]})]}):o.jsxs("div",{className:"max-w-[75%]",children:[o.jsx("div",{className:"chat-bubble-user px-4 py-3",children:o.jsx("p",{className:"whitespace-pre-wrap",children:D.content})}),o.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-1 text-right",children:D.timestamp.toLocaleTimeString()})]})},D.id)),o.jsx("div",{ref:B})]}),X&&o.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-4 flex justify-center",children:o.jsx(we,{onClick:Qe,size:"sm",className:"pointer-events-auto shadow-lg bg-[#1d9bf0] text-white hover:bg-[#1a8cd8]","aria-label":l.devicePanel.newMessages,children:l.devicePanel.newMessages})})]}),o.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800",children:o.jsxs("div",{className:"flex items-end gap-3",children:[o.jsx(Eu,{value:u,onChange:D=>m(D.target.value),onKeyDown:me,placeholder:d?l.devicePanel.whatToDo:l.devicePanel.configureFirst,disabled:p,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),o.jsxs(en,{children:[o.jsx(tn,{asChild:!0,children:o.jsxs(Us,{open:Q,onOpenChange:q,children:[o.jsx(Ws,{asChild:!0,children:o.jsx(we,{variant:"outline",size:"icon",className:"h-10 w-10 flex-shrink-0",children:o.jsx(pu,{className:"w-4 h-4"})})}),o.jsx(Hs,{align:"start",className:"w-72 p-3",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx("h4",{className:"font-medium text-sm",children:l.workflows.selectWorkflow}),j.length===0?o.jsxs("div",{className:"text-sm text-slate-500 dark:text-slate-400 space-y-1",children:[o.jsx("p",{children:l.workflows.empty}),o.jsxs("p",{children:["前往"," ",o.jsx("a",{href:"/workflows",className:"text-primary underline",children:"工作流"})," ","页面创建。"]})]}):o.jsx(Dr,{className:"h-64",children:o.jsx("div",{className:"space-y-1",children:j.map(D=>o.jsxs("button",{onClick:()=>ae(D),className:"w-full text-left p-2 rounded hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[o.jsx("div",{className:"font-medium text-sm",children:D.name}),o.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-2",children:D.text})]},D.uuid))})})]})})]})}),o.jsx(nn,{side:"top",sideOffset:8,className:"max-w-xs",children:o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"font-medium",children:l.devicePanel.tooltips.workflowButton}),o.jsx("p",{className:"text-xs opacity-80",children:l.devicePanel.tooltips.workflowButtonDesc})]})})]}),p&&o.jsx(we,{onClick:ie,disabled:y,size:"icon",variant:"destructive",className:"h-10 w-10 rounded-full flex-shrink-0",title:l.chat.abortChat,children:y?o.jsx(Yt,{className:"h-4 w-4 animate-spin"}):o.jsx(ku,{className:"h-4 w-4"})}),!p&&o.jsx(we,{onClick:J,disabled:!u.trim(),size:"icon",variant:"twitter",className:"h-10 w-10 rounded-full flex-shrink-0",children:o.jsx(Tu,{className:"h-4 w-4"})})]})})]}),o.jsx(Td,{deviceId:i,serial:n,connectionType:a,isVisible:!0})]})}function xy({deviceId:i,deviceSerial:n,deviceName:r,deviceConnectionType:a,isVisible:d}){const l=An(),[_,v]=E.useState([]),[u,m]=E.useState(""),[p,x]=E.useState(!1),[y,b]=E.useState(!1),[N,M]=E.useState(null),A=E.useRef(null),O=E.useRef(null),L=E.useRef(null),[P,j]=E.useState([]),[z,Q]=E.useState(!1),[q,Y]=E.useState([]),[B,C]=E.useState(!1);E.useEffect(()=>{A.current?.scrollIntoView({behavior:"smooth"})},[_]),E.useEffect(()=>()=>{O.current&&O.current.close()},[]),E.useEffect(()=>{(async()=>{try{const J=await gu();j(J.workflows)}catch(J){console.error("Failed to load workflows:",J)}})()},[]),E.useEffect(()=>{B&&(async()=>{try{const J=await mu(n,20,0);Y(J.records)}catch(J){console.error("Failed to load history:",J),Y([])}})()},[B,n]);const R=G=>{m(G.text),Q(!1)},se=G=>{const J={id:`${G.id}-user`,role:"user",content:G.task_text,timestamp:new Date(G.start_time)},ue={id:`${G.id}-agent`,role:"assistant",content:G.final_message,timestamp:G.end_time?new Date(G.end_time):new Date(G.start_time),steps:[],success:G.success,isStreaming:!1};v([J,ue]),C(!1)},_e=async()=>{if(confirm(l.history?.clearAllConfirm||"Clear all history?"))try{await _u(n),Y([])}catch(G){console.error("Failed to clear history:",G)}},$=async G=>{try{await xu(n,G),Y(J=>J.filter(ue=>ue.id!==G))}catch(J){console.error("Failed to delete history item:",J)}},X=(G,J)=>{v(ue=>ue.map(ie=>ie.id===G?{...ie,steps:ie.steps?.map(Se=>Se.id===J?{...Se,isExpanded:!Se.isExpanded}:Se)}:ie))},K=E.useCallback(async()=>{const G=u.trim();if(!G||p)return;const J={id:Date.now().toString(),role:"user",content:G,timestamp:new Date};v(ae=>[...ae,J]),m(""),x(!0),M(null);const ue=(Date.now()+1).toString(),ie={id:ue,role:"assistant",content:"",timestamp:new Date,steps:[],isStreaming:!0};v(ae=>[...ae,ie]);const Se=new AbortController;L.current=Se;try{const ae=await fetch("/api/layered-agent/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:G,device_id:i,session_id:i}),signal:Se.signal});if(!ae.ok){let le=`HTTP error! status: ${ae.status}`;try{const he=await ae.json();he.detail&&(le=he.detail)}catch{}throw new Error(le)}const ze=ae.body?.getReader();if(!ze)throw new Error("No response body");const Qe=new TextDecoder;let me="";const D=[];for(;;){const{done:le,value:he}=await ze.read();if(le)break;me+=Qe.decode(he,{stream:!0});const Fe=me.split(`
129
- `);me=Fe.pop()||"";for(const We of Fe)if(We.startsWith("data: "))try{const de=JSON.parse(We.slice(6));if(de.type==="tool_call"){const Ne={id:`step-${Date.now()}-${Math.random()}`,type:"tool_call",content:de.tool_name==="chat"?"发送指令给 Phone Agent":de.tool_name==="list_devices"?"获取设备列表":`调用工具: ${de.tool_name}`,toolName:de.tool_name,toolArgs:de.tool_args||{},timestamp:new Date,isExpanded:!0};D.push(Ne),v(ee=>ee.map(Z=>Z.id===ue?{...Z,steps:[...D]}:Z))}else if(de.type==="tool_result"){const Ne={id:`step-${Date.now()}-${Math.random()}`,type:"tool_result",content:de.tool_name==="chat"?"Phone Agent 执行结果":`${de.tool_name} 结果`,toolResult:de.result,timestamp:new Date,isExpanded:!0};D.push(Ne),v(ee=>ee.map(Z=>Z.id===ue?{...Z,steps:[...D]}:Z))}else if(de.type==="message")v(Ne=>Ne.map(ee=>ee.id===ue?{...ee,content:de.content}:ee));else if(de.type==="done"){const Ne={...ie,content:de.content||"",isStreaming:!1,success:de.success,steps:[...D],timestamp:new Date};v(ee=>ee.map(Z=>Z.id===ue?Ne:Z))}else if(de.type==="error"){const Ne={...ie,content:`错误: ${de.message}`,isStreaming:!1,success:!1,steps:[...D],timestamp:new Date};v(ee=>ee.map(Z=>Z.id===ue?Ne:Z)),M(de.message)}}catch(de){console.error("Failed to parse SSE data:",de,We)}}v(le=>le.map(he=>he.id===ue&&he.isStreaming?{...he,isStreaming:!1,success:!0}:he))}catch(ae){if(ae instanceof Error&&ae.name==="AbortError"){console.log("Chat aborted by user");return}console.error("Chat error:",ae);const ze=vu(ae);M(ze),v(Qe=>Qe.map(me=>me.id===ue?{...me,content:`错误: ${ze}`,isStreaming:!1,success:!1}:me))}finally{x(!1),L.current=null}},[u,p,i]),ne=E.useCallback(()=>{if(L.current){b(!0);try{L.current.abort(),L.current=null,v(G=>{const J=G[G.length-1];return J&&J.role==="assistant"&&J.isStreaming?G.map((ue,ie)=>ie===G.length-1?{...ue,content:ue.content||l.chat?.aborted||"任务已中断",isStreaming:!1,success:!1}:ue):G}),Lx(async()=>{const{abortLayeredAgentChat:G}=await import("./index-CH4jPveL.js").then(J=>J.aq);return{abortLayeredAgentChat:G}},__vite__mapDeps([0,1])).then(({abortLayeredAgentChat:G})=>{G(i).catch(J=>console.error("Backend abort failed:",J))})}catch(G){console.error("Failed to abort chat:",G)}finally{x(!1),b(!1)}}},[l,i]),oe=E.useCallback(async()=>{L.current&&(L.current.abort(),L.current=null),v([]),M(null),O.current&&(O.current.close(),O.current=null);try{await fetch("/api/layered-agent/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:i})})}catch(G){console.warn("Failed to reset backend session:",G)}},[i]),ke=G=>{(G.metaKey||G.ctrlKey)&&G.key==="Enter"&&(G.preventDefault(),K())};return o.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[o.jsxs(Ys,{className:"flex-1 flex flex-col min-h-0 max-w-2xl overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-purple-500/10",children:o.jsx(Ro,{className:"h-5 w-5 text-purple-500"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"font-bold text-slate-900 dark:text-slate-100",children:l.chatkit?.title||"AI Agent"}),o.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[r," • ",l.chatkit?.layeredAgent||"分层代理模式"]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Hn,{variant:"secondary",className:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300",children:l.chatkit?.layeredAgent||"分层代理模式"}),o.jsxs(Us,{open:B,onOpenChange:C,children:[o.jsx(Ws,{asChild:!0,children:o.jsx(we,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300",title:l.history?.title||"History",children:o.jsx(Fs,{className:"h-4 w-4"})})}),o.jsxs(Hs,{className:"w-96 p-0",align:"end",sideOffset:8,children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[o.jsx("h3",{className:"font-semibold text-sm text-slate-900 dark:text-slate-100",children:l.history?.title||"History"}),q.length>0&&o.jsx(we,{variant:"ghost",size:"sm",onClick:_e,className:"h-7 text-xs",children:l.history?.clearAll||"Clear All"})]}),o.jsx(Dr,{className:"h-[400px]",children:o.jsx("div",{className:"p-4 space-y-2",children:q.length>0?q.map(G=>o.jsx(Wd,{item:G,onSelect:se,onDelete:$},G.id)):o.jsxs("div",{className:"text-center py-8",children:[o.jsx(Fs,{className:"h-12 w-12 text-slate-300 dark:text-slate-700 mx-auto mb-3"}),o.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:l.history?.noHistory||"No history yet"}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:l.history?.noHistoryDescription||"Your completed tasks will appear here"})]})})})]})]}),o.jsx(we,{variant:"ghost",size:"icon",onClick:oe,className:"h-8 w-8 rounded-full",title:"重置对话",children:o.jsx(Cu,{className:"h-4 w-4"})})]})]}),N&&o.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:[o.jsx(_n,{className:"w-4 h-4 flex-shrink-0"}),N]}),o.jsx(Dr,{className:"flex-1 min-h-0",children:o.jsxs("div",{className:"p-4 space-y-4",children:[_.length===0?o.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center py-12",children:[o.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-purple-100 dark:bg-purple-900/30 mb-4",children:o.jsx(Ro,{className:"h-8 w-8 text-purple-500"})}),o.jsx("p",{className:"font-medium text-slate-900 dark:text-slate-100",children:l.chatkit?.title||"分层代理模式"}),o.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400 max-w-xs",children:l.chatkit?.layeredAgentDesc||"决策模型负责规划任务,视觉模型负责执行。你可以看到每一步的执行过程。"})]}):_.map(G=>o.jsx("div",{className:"space-y-2",children:G.role==="user"?o.jsx("div",{className:"flex justify-end",children:o.jsxs("div",{className:"max-w-[80%]",children:[o.jsx("div",{className:"bg-purple-600 text-white px-4 py-2 rounded-2xl rounded-br-sm",children:o.jsx("p",{className:"whitespace-pre-wrap",children:G.content})}),o.jsx("p",{className:"text-xs text-slate-400 mt-1 text-right",children:G.timestamp.toLocaleTimeString()})]})}):o.jsxs("div",{className:"space-y-3",children:[G.steps&&G.steps.length>0&&o.jsx("div",{className:"space-y-2",children:G.steps.map((J,ue)=>o.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800/50 rounded-xl border border-slate-200 dark:border-slate-700 overflow-hidden",children:[o.jsxs("button",{onClick:()=>X(G.id,J.id),className:"w-full flex items-center justify-between p-3 hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:`flex h-6 w-6 items-center justify-center rounded-full text-xs font-medium ${J.type==="tool_call"?"bg-blue-100 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400":"bg-green-100 text-green-600 dark:bg-green-900/30 dark:text-green-400"}`,children:J.type==="tool_call"?o.jsx(Pv,{className:"w-3 h-3"}):o.jsx(Dx,{className:"w-3 h-3"})}),o.jsxs("span",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:["Step ",ue+1,": ",J.content]})]}),J.isExpanded?o.jsx(Zx,{className:"w-4 h-4 text-slate-400"}):o.jsx(Xx,{className:"w-4 h-4 text-slate-400"})]}),J.isExpanded&&o.jsxs("div",{className:"px-3 pb-3 space-y-2",children:[J.type==="tool_call"&&J.toolArgs&&o.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg p-3 text-sm",children:[o.jsx("p",{className:"text-xs text-slate-500 mb-1 font-medium",children:J.toolName==="chat"?"发送给 Phone Agent 的指令:":"工具参数:"}),J.toolName==="chat"?o.jsx("p",{className:"text-slate-700 dark:text-slate-300 whitespace-pre-wrap",children:J.toolArgs.message||JSON.stringify(J.toolArgs,null,2)}):o.jsx("pre",{className:"text-xs text-slate-600 dark:text-slate-400 overflow-x-auto",children:JSON.stringify(J.toolArgs,null,2)})]}),J.type==="tool_result"&&J.toolResult&&o.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg p-3 text-sm",children:[o.jsx("p",{className:"text-xs text-slate-500 mb-1 font-medium",children:"执行结果:"}),o.jsx("pre",{className:"text-xs text-slate-600 dark:text-slate-400 overflow-x-auto whitespace-pre-wrap",children:typeof J.toolResult=="string"?J.toolResult:JSON.stringify(J.toolResult,null,2)})]})]})]},J.id))}),G.content&&o.jsx("div",{className:"flex justify-start",children:o.jsx("div",{className:`max-w-[85%] rounded-2xl rounded-tl-sm px-4 py-3 ${G.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"}`,children:o.jsxs("div",{className:"flex items-start gap-2",children:[G.success!==void 0&&o.jsx(Fr,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${G.success?"text-green-500":"text-red-500"}`}),o.jsx("p",{className:"whitespace-pre-wrap",children:G.content})]})})}),G.isStreaming&&!G.content&&o.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500",children:[o.jsx(Yt,{className:"w-4 h-4 animate-spin"}),"正在思考和执行..."]})]})},G.id)),o.jsx("div",{ref:A})]})}),o.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800",children:o.jsxs("div",{className:"flex items-end gap-3",children:[o.jsx(Eu,{value:u,onChange:G=>m(G.target.value),onKeyDown:ke,placeholder:"描述你想要完成的任务... (Cmd+Enter 发送)",disabled:p,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),o.jsxs(en,{children:[o.jsx(tn,{asChild:!0,children:o.jsxs(Us,{open:z,onOpenChange:Q,children:[o.jsx(Ws,{asChild:!0,children:o.jsx(we,{variant:"outline",size:"icon",className:"h-10 w-10 flex-shrink-0",children:o.jsx(pu,{className:"w-4 h-4"})})}),o.jsx(Hs,{align:"start",className:"w-72 p-3",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx("h4",{className:"font-medium text-sm",children:l.workflows?.selectWorkflow||"Select Workflow"}),P.length===0?o.jsxs("div",{className:"text-sm text-slate-500 dark:text-slate-400 space-y-1",children:[o.jsx("p",{children:l.workflows?.empty||"No workflows yet"}),o.jsxs("p",{children:["前往"," ",o.jsx("a",{href:"/workflows",className:"text-primary underline",children:"工作流"})," ","页面创建。"]})]}):o.jsx(Dr,{className:"h-64",children:o.jsx("div",{className:"space-y-1",children:P.map(G=>o.jsxs("button",{onClick:()=>R(G),className:"w-full text-left p-2 rounded hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[o.jsx("div",{className:"font-medium text-sm",children:G.name}),o.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-2",children:G.text})]},G.uuid))})})]})})]})}),o.jsx(nn,{side:"top",sideOffset:8,className:"max-w-xs",children:o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"font-medium",children:l.devicePanel?.tooltips?.workflowButton||"Quick Workflow"}),o.jsx("p",{className:"text-xs opacity-80",children:l.devicePanel?.tooltips?.workflowButtonDesc||"Select a workflow to quickly fill in the task"})]})})]}),p&&o.jsx(we,{onClick:ne,disabled:y,size:"icon",variant:"destructive",className:"h-10 w-10 rounded-full flex-shrink-0",title:l.chat?.abortChat||"中断任务",children:y?o.jsx(Yt,{className:"h-4 w-4 animate-spin"}):o.jsx(ku,{className:"h-4 w-4"})}),!p&&o.jsx(we,{onClick:K,disabled:!u.trim(),size:"icon",className:"h-10 w-10 rounded-full flex-shrink-0 bg-purple-600 hover:bg-purple-700",children:o.jsx(Tu,{className:"h-4 w-4"})})]})})]}),o.jsx(Td,{deviceId:i,serial:n,connectionType:a,isVisible:d})]})}function vy({message:i,type:n="info",onClose:r,duration:a=3e3}){E.useEffect(()=>{const _=setTimeout(()=>{r()},a);return()=>clearTimeout(_)},[a,r]);const d={success:"bg-green-500",error:"bg-red-500",info:"bg-blue-500",warning:"bg-amber-500"},l={success:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})}),error:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})}),info:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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"})}),warning:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})};return o.jsx("div",{className:"fixed top-4 left-1/2 transform -translate-x-1/2 z-50 animate-fade-in-down",children:o.jsxs("div",{className:`${d[n]} text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3 min-w-[300px]`,children:[l[n],o.jsx("span",{className:"font-medium",children:i}),o.jsx("button",{onClick:r,className:"ml-auto hover:bg-white/20 rounded-full p-1 transition-colors",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]})})}const Ar=[{name:"bigmodel",config:{base_url:"https://open.bigmodel.cn/api/paas/v4",model_name:"autoglm-phone"},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"},apiKeyUrl:"https://www.modelscope.cn/my/myaccesstoken"},{name:"custom",config:{base_url:"",model_name:"autoglm-phone-9b"}}],by=[{name:"glm",displayName:"GLM Agent",description:"基于 GLM 模型优化,成熟稳定,适合大多数任务",icon:nv,defaultConfig:{}},{name:"mai",displayName:"MAI Agent",description:"阿里通义团队开发,支持多张历史截图上下文",icon:Su,defaultConfig:{history_n:3}}],yy=[{name:"bigmodel",config:{decision_base_url:"https://open.bigmodel.cn/api/paas/v4",decision_model_name:"glm-4.7"},apiKeyUrl:"https://bigmodel.cn/usercenter/proj-mgmt/apikeys"},{name:"modelscope",config:{decision_base_url:"https://api-inference.modelscope.cn/v1",decision_model_name:"Qwen/Qwen3-235B-A22B-Instruct-2507"},apiKeyUrl:"https://www.modelscope.cn/my/myaccesstoken"},{name:"custom",config:{decision_base_url:"",decision_model_name:""}}];function Py(){const i=An(),n=Ox.useSearch(),r=Bx(),[a,d]=E.useState([]),[l,_]=E.useState(""),[v,u]=E.useState(n.mode||"classic"),[m,p]=E.useState(!1),[x,y]=E.useState({message:"",type:"info",visible:!1}),b=(C,R="info")=>{y({message:C,type:R,visible:!0})},[N,M]=E.useState(null),[A,O]=E.useState(!1),[L,P]=E.useState(!1),[j,z]=E.useState({base_url:Ar[0].config.base_url,model_name:Ar[0].config.model_name,api_key:"",agent_type:"glm",agent_config_params:{},default_max_steps:100,layered_max_turns:50,decision_base_url:"",decision_model_name:"",decision_api_key:""});E.useEffect(()=>{(async()=>{try{const R=await Ux();M({base_url:R.base_url,model_name:R.model_name,api_key:R.api_key||void 0,agent_type:R.agent_type||"glm",agent_config_params:R.agent_config_params||void 0,default_max_steps:R.default_max_steps||100,layered_max_turns:R.layered_max_turns||50,decision_base_url:R.decision_base_url||void 0,decision_model_name:R.decision_model_name||void 0,decision_api_key:R.decision_api_key||void 0});const se=!R.base_url;z({base_url:se?Ar[0].config.base_url:R.base_url,model_name:se?Ar[0].config.model_name:R.model_name,api_key:R.api_key||"",agent_type:R.agent_type||"glm",agent_config_params:R.agent_config_params||{},default_max_steps:R.default_max_steps||100,layered_max_turns:R.layered_max_turns||50,decision_base_url:R.decision_base_url||"",decision_model_name:R.decision_model_name||"glm-4.7",decision_api_key:R.decision_api_key||""}),se&&O(!0)}catch(R){console.error("Failed to load config:",R),O(!0)}})()},[]);const Q=E.useCallback(async()=>{try{const R=(await Fx()).devices.filter(X=>X.state!=="disconnected"),se=new Map,_e=new Map;for(const X of R)if(X.serial){const K=_e.get(X.serial)||[];K.push(X),_e.set(X.serial,K)}else se.set(X.id,X);Array.from(_e.values()).forEach(X=>{const ne=X.find(oe=>oe.connection_type==="wifi")||X[0];se.set(ne.id,ne)});const $=Array.from(se.values());if(d($),$.length>0&&!m){const X=n.serial;if(X){const K=$.find(ne=>ne.serial===X);_(K?K.id:$[0].id)}else l||_($[0].id);p(!0)}l&&!$.find(X=>X.id===l)&&_($[0]?.id||"")}catch(C){console.error("Failed to load devices:",C)}},[l,m,n.serial]);E.useEffect(()=>{const C=setTimeout(()=>{Q()},0),R=setInterval(Q,3e3);return()=>{clearTimeout(C),clearInterval(R)}},[Q]),E.useEffect(()=>{const R=a.find(_e=>_e.id===l)?.serial;if(!m)return;(R!==n.serial||v!==n.mode)&&r({to:"/chat",search:{serial:R,mode:v},replace:!0})},[l,v,a,m,r,n.serial,n.mode]);const q=async()=>{if(!j.base_url){b(i.chat.baseUrlRequired,"error");return}try{await Wx({base_url:j.base_url,model_name:j.model_name||"autoglm-phone-9b",api_key:j.api_key||void 0,agent_type:j.agent_type,agent_config_params:Object.keys(j.agent_config_params).length>0?j.agent_config_params:void 0,default_max_steps:j.default_max_steps,layered_max_turns:j.layered_max_turns,decision_base_url:j.decision_base_url||void 0,decision_model_name:j.decision_model_name||void 0,decision_api_key:j.decision_api_key||void 0}),M({base_url:j.base_url,model_name:j.model_name,api_key:j.api_key||void 0,agent_type:j.agent_type,agent_config_params:Object.keys(j.agent_config_params).length>0?j.agent_config_params:void 0,default_max_steps:j.default_max_steps,layered_max_turns:j.layered_max_turns,decision_base_url:j.decision_base_url||void 0,decision_model_name:j.decision_model_name||void 0,decision_api_key:j.decision_api_key||void 0}),b(i.toasts.configSaved,"success");try{const C=await Hx();if(C.total===0)console.log("No agents to reinitialize");else if(C.success)b(`Configuration applied to ${C.succeeded.length} device(s)`,"success");else{const R=Object.keys(C.failed).length;b(`Configuration partially applied: ${C.succeeded.length}/${C.total} succeeded, ${R} failed`,"warning")}}catch(C){console.error("Failed to reinitialize agents:",C),b("Configuration saved, but failed to update devices. Please reinitialize manually.","warning")}O(!1)}catch(C){console.error("Failed to save config:",C),b(`Failed to save: ${vu(C)}`,"error")}},Y=async C=>{try{const R=await zx({device_id:C});R.success&&R.device_id?(_(R.device_id),b(i.toasts.wifiConnected,"success")):R.success||b(R.message||R.error||i.toasts.connectionFailed,"error")}catch(R){b(i.toasts.wifiConnectionError,"error"),console.error("Connect WiFi error:",R)}},B=async C=>{try{const R=await Gx(C);R.success?b(i.toasts.wifiDisconnected,"success"):b(R.message||R.error||i.toasts.disconnectFailed,"error")}catch(R){b(i.toasts.wifiDisconnectError,"error"),console.error("Disconnect WiFi error:",R)}};return o.jsxs("div",{className:"h-full flex relative min-h-0",children:[x.visible&&o.jsx(vy,{message:x.message,type:x.type,onClose:()=>y(C=>({...C,visible:!1}))}),o.jsx(Fo,{open:A,onOpenChange:O,children:o.jsxs(Uo,{className:"sm:max-w-md h-[75vh] flex flex-col",children:[o.jsxs(Wo,{className:"flex-shrink-0",children:[o.jsxs(Ho,{className:"flex items-center gap-2",children:[o.jsx(Ru,{className:"w-5 h-5 text-[#1d9bf0]"}),i.chat.configuration]}),o.jsx(Go,{children:i.chat.configureApi})]}),o.jsxs($u,{defaultValue:"vision",className:"flex-1 flex flex-col min-h-0",children:[o.jsxs(Xu,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[o.jsxs(Ir,{value:"vision",children:[o.jsx(mo,{className:"w-4 h-4 mr-2"}),i.chat.visionModelTab]}),o.jsxs(Ir,{value:"decision",children:[o.jsx(Su,{className:"w-4 h-4 mr-2"}),i.chat.decisionModelTab]})]}),o.jsxs(Lr,{value:"vision",className:"space-y-4 mt-4 overflow-y-auto flex-1 min-h-0",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{className:"text-sm font-medium",children:i.chat.selectPreset}),o.jsx("div",{className:"grid grid-cols-1 gap-2",children:Ar.map(C=>o.jsxs("div",{className:"relative",children:[o.jsxs("button",{type:"button",onClick:()=>z(R=>({...R,base_url:C.config.base_url,model_name:C.config.model_name})),className:`w-full text-left p-3 rounded-lg border transition-all ${j.base_url===C.config.base_url&&(C.name!=="custom"||C.name==="custom"&&j.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:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ko,{className:`w-4 h-4 ${j.base_url===C.config.base_url&&(C.name!=="custom"||C.name==="custom"&&j.base_url==="")?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),o.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:i.presetConfigs[C.name].name})]}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 ml-6",children:i.presetConfigs[C.name].description})]}),"apiKeyUrl"in C&&o.jsx("a",{href:C.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",onClick:R=>R.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:i.chat.getApiKey||"获取 API Key",children:o.jsx(Oc,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-[#1d9bf0] transition-colors"})})]},C.name))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(nt,{htmlFor:"base_url",children:[i.chat.baseUrl," *"]}),o.jsx(ht,{id:"base_url",value:j.base_url,onChange:C=>z({...j,base_url:C.target.value}),placeholder:"http://localhost:8080/v1"}),!j.base_url&&o.jsxs("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[o.jsx(_n,{className:"w-3 h-3"}),i.chat.baseUrlRequired]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{htmlFor:"api_key",children:i.chat.apiKey}),o.jsxs("div",{className:"relative",children:[o.jsx(ht,{id:"api_key",type:L?"text":"password",value:j.api_key,onChange:C=>z({...j,api_key:C.target.value}),placeholder:"Leave empty if not required",className:"pr-10"}),o.jsx(we,{type:"button",variant:"ghost",size:"icon",onClick:()=>P(!L),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:L?o.jsx(Bc,{className:"w-4 h-4 text-slate-400"}):o.jsx(mo,{className:"w-4 h-4 text-slate-400"})})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{htmlFor:"model_name",children:i.chat.modelName}),o.jsx(ht,{id:"model_name",value:j.model_name,onChange:C=>z({...j,model_name:C.target.value}),placeholder:"autoglm-phone-9b"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{className:"text-sm font-medium",children:i.chat.agentType||"Agent 类型"}),o.jsx("div",{className:"grid grid-cols-2 gap-2",children:by.map(C=>o.jsxs("button",{type:"button",onClick:()=>z(R=>({...R,agent_type:C.name,agent_config_params:C.defaultConfig})),className:`text-left p-3 rounded-lg border transition-all ${j.agent_type===C.name?"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:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(C.icon,{className:`w-4 h-4 ${j.agent_type===C.name?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),o.jsx("span",{className:`font-medium text-sm ${j.agent_type===C.name?"text-[#1d9bf0]":"text-slate-900 dark:text-slate-100"}`,children:C.displayName})]}),o.jsx("p",{className:`text-xs mt-1 ml-6 ${j.agent_type===C.name?"text-[#1d9bf0]/70":"text-slate-500 dark:text-slate-400"}`,children:C.description})]},C.name))})]}),j.agent_type==="mai"&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{htmlFor:"history_n",children:i.chat.history_n||"历史记录数量"}),o.jsx(ht,{id:"history_n",type:"number",min:1,max:10,value:j.agent_config_params?.history_n||3,onChange:C=>{const R=parseInt(C.target.value)||3;z(se=>({...se,agent_config_params:{...se.agent_config_params,history_n:R}}))},className:"w-full"}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:i.chat.history_n_hint||"包含的历史截图数量(1-10)"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{htmlFor:"default_max_steps",children:i.chat.maxSteps||"最大执行步数"}),o.jsx(ht,{id:"default_max_steps",type:"number",min:1,max:1e3,value:j.default_max_steps,onChange:C=>{const R=parseInt(C.target.value)||100;z(se=>({...se,default_max_steps:Math.min(1e3,Math.max(1,R))}))},className:"w-full"}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:i.chat.maxStepsHint||"单次任务最大执行步数(1-1000)"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{htmlFor:"layered_max_turns",children:"分层代理最大轮次"}),o.jsx(ht,{id:"layered_max_turns",type:"number",min:1,value:j.layered_max_turns,onChange:C=>{const R=parseInt(C.target.value)||50;z(se=>({...se,layered_max_turns:Math.max(1,R)}))},className:"w-full"}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"分层代理模式的最大轮次(最小值为1)"})]})]}),o.jsxs(Lr,{value:"decision",className:"space-y-4 mt-4 overflow-y-auto flex-1 min-h-0",children:[o.jsx("div",{className:"rounded-lg border border-indigo-200 bg-indigo-50 dark:border-indigo-900 dark:bg-indigo-950/30 p-3 text-sm text-indigo-900 dark:text-indigo-100",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(cv,{className:"mt-0.5 h-4 w-4 flex-shrink-0"}),o.jsx("div",{children:i.chat.decisionModelHint})]})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{className:"text-sm font-medium",children:i.chat.selectDecisionPreset}),o.jsx("div",{className:"grid grid-cols-1 gap-2",children:yy.map(C=>o.jsxs("div",{className:"relative",children:[o.jsxs("button",{type:"button",onClick:()=>z(R=>({...R,decision_base_url:C.config.decision_base_url,decision_model_name:C.config.decision_model_name})),className:`w-full text-left p-3 rounded-lg border transition-all ${j.decision_base_url===C.config.decision_base_url&&(C.name!=="custom"||C.name==="custom"&&j.decision_base_url==="")?"border-indigo-500 bg-indigo-50 dark:bg-indigo-950/50":"border-slate-200 dark:border-slate-700 hover:border-indigo-500/50 hover:bg-indigo-50 dark:hover:bg-indigo-950/30"}`,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ko,{className:`w-4 h-4 ${j.decision_base_url===C.config.decision_base_url&&(C.name!=="custom"||C.name==="custom"&&j.decision_base_url==="")?"text-indigo-600 dark:text-indigo-400":"text-slate-400 dark:text-slate-500"}`}),o.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:i.presetConfigs[C.name].name})]}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 ml-6",children:i.presetConfigs[C.name].description})]}),"apiKeyUrl"in C&&o.jsx("a",{href:C.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",onClick:R=>R.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:i.chat.getApiKey||"获取 API Key",children:o.jsx(Oc,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-indigo-600 dark:group-hover:text-indigo-400 transition-colors"})})]},C.name))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(nt,{htmlFor:"decision_base_url",children:[i.chat.decisionBaseUrl," *"]}),o.jsx(ht,{id:"decision_base_url",value:j.decision_base_url,onChange:C=>z({...j,decision_base_url:C.target.value}),placeholder:"http://localhost:8080/v1"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(nt,{htmlFor:"decision_api_key",children:i.chat.decisionApiKey}),o.jsxs("div",{className:"relative",children:[o.jsx(ht,{id:"decision_api_key",type:L?"text":"password",value:j.decision_api_key,onChange:C=>z({...j,decision_api_key:C.target.value}),placeholder:"sk-...",className:"pr-10"}),o.jsx(we,{type:"button",variant:"ghost",size:"icon",onClick:()=>P(!L),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:L?o.jsx(Bc,{className:"w-4 h-4 text-slate-400"}):o.jsx(mo,{className:"w-4 h-4 text-slate-400"})})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(nt,{htmlFor:"decision_model_name",children:[i.chat.decisionModelName," *"]}),o.jsx(ht,{id:"decision_model_name",value:j.decision_model_name,onChange:C=>z({...j,decision_model_name:C.target.value}),placeholder:""})]})]})]}),o.jsxs(zo,{className:"sm:justify-between gap-2 flex-shrink-0",children:[o.jsx(we,{variant:"outline",onClick:()=>{O(!1),N&&z({base_url:N.base_url,model_name:N.model_name,api_key:N.api_key||"",agent_type:N.agent_type||"glm",agent_config_params:N.agent_config_params||{},default_max_steps:N.default_max_steps||100,layered_max_turns:N.layered_max_turns||50,decision_base_url:N.decision_base_url||"",decision_model_name:N.decision_model_name||"glm-4.7",decision_api_key:N.decision_api_key||""})},children:i.chat.cancel}),o.jsxs(we,{onClick:q,variant:"twitter",children:[o.jsx(Fr,{className:"w-4 h-4 mr-2"}),i.chat.saveConfig]})]})]})}),o.jsx(m1,{devices:a,currentDeviceId:l,onSelectDevice:_,onOpenConfig:()=>O(!0),onConnectWifi:Y,onDisconnectWifi:B,onRefreshDevices:Q,showToast:b}),o.jsxs("div",{className:"flex-1 flex flex-col min-h-0 relative",children:[o.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-20",children:o.jsxs("div",{className:"flex items-center gap-0.5 bg-white/95 dark:bg-slate-800/95 backdrop-blur-sm rounded-full p-1 shadow-lg border border-slate-200 dark:border-slate-700",children:[o.jsxs(en,{children:[o.jsx(tn,{asChild:!0,children:o.jsxs("button",{onClick:()=>u("classic"),className:`flex items-center gap-1.5 px-4 py-2 rounded-full text-sm font-medium transition-all ${v==="classic"?"bg-slate-900 dark:bg-white text-white dark:text-slate-900 shadow-sm":"text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-700"}`,children:[o.jsx(jr,{className:"w-4 h-4"}),i.chatkit?.classicMode||"经典模式"]})}),o.jsx(nn,{side:"bottom",sideOffset:8,className:"max-w-xs",children:o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"font-medium",children:i.chatkit?.classicMode||"经典模式"}),o.jsx("p",{className:"text-xs opacity-80",children:i.chatkit?.classicModeDesc||"视觉模型直接执行任务"})]})})]}),o.jsxs(en,{children:[o.jsx(tn,{asChild:!0,children:o.jsxs("button",{onClick:()=>{u("chatkit")},className:`flex items-center gap-1.5 px-4 py-2 rounded-full text-sm font-medium transition-all ${v==="chatkit"?"bg-indigo-600 text-white shadow-sm":"text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-700"}`,children:[o.jsx(Ro,{className:"w-4 h-4"}),i.chatkit?.layeredMode||"分层代理"]})}),o.jsx(nn,{side:"bottom",sideOffset:8,className:"max-w-xs",children:o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"font-medium",children:i.chatkit?.layeredMode||"分层代理"}),o.jsx("p",{className:"text-xs opacity-80",children:i.chatkit?.layeredModeDesc||"规划层分解任务,执行层独立完成子任务"})]})})]})]})}),o.jsx("div",{className:"flex-1 flex items-stretch justify-center min-h-0 px-4 py-4 pt-16",children:a.length===0?o.jsx("div",{className:"flex-1 flex items-center justify-center bg-slate-50 dark:bg-slate-950",children:o.jsxs("div",{className:"text-center",children:[o.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:o.jsx("svg",{className:"w-10 h-10 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.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"})})}),o.jsx("h3",{className:"text-lg font-semibold text-slate-900 dark:text-slate-100 mb-2",children:i.chat.welcomeTitle}),o.jsx("p",{className:"text-slate-500 dark:text-slate-400",children:i.chat.connectDevice})]})}):a.map(C=>o.jsx("div",{className:`w-full max-w-7xl flex items-stretch justify-center min-h-0 ${C.id===l?"":"hidden"}`,children:v==="chatkit"?o.jsx("div",{className:"w-full flex items-stretch justify-center",children:o.jsx(xy,{deviceId:C.id,deviceSerial:C.serial,deviceName:C.model,deviceConnectionType:C.connection_type,isVisible:C.id===l})}):o.jsx("div",{className:"w-full flex items-stretch justify-center",children:o.jsx(_y,{deviceId:C.id,deviceSerial:C.serial,deviceName:C.model,deviceConnectionType:C.connection_type,isConfigured:!!N?.base_url})})},C.serial))})]})]})}export{Py as component};