autoglm-gui 1.5.0__py3-none-any.whl → 1.5.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. AutoGLM_GUI/agents/glm/agent.py +6 -1
  2. AutoGLM_GUI/agents/mai/agent.py +3 -0
  3. AutoGLM_GUI/agents/stream_runner.py +7 -2
  4. AutoGLM_GUI/api/agents.py +26 -1
  5. AutoGLM_GUI/api/history.py +27 -1
  6. AutoGLM_GUI/models/history.py +45 -1
  7. AutoGLM_GUI/scheduler_manager.py +52 -6
  8. AutoGLM_GUI/schemas.py +12 -0
  9. AutoGLM_GUI/static/assets/{about-BQm96DAl.js → about-CfwX1Cmc.js} +1 -1
  10. AutoGLM_GUI/static/assets/{alert-dialog-B42XxGPR.js → alert-dialog-CtGlN2IJ.js} +1 -1
  11. AutoGLM_GUI/static/assets/chat-BYa-foUI.js +129 -0
  12. AutoGLM_GUI/static/assets/{circle-alert-D4rSJh37.js → circle-alert-t08bEMPO.js} +1 -1
  13. AutoGLM_GUI/static/assets/{dialog-DZ78cEcj.js → dialog-FNwZJFwk.js} +1 -1
  14. AutoGLM_GUI/static/assets/eye-D0UPWCWC.js +1 -0
  15. AutoGLM_GUI/static/assets/history-CRo95B7i.js +1 -0
  16. AutoGLM_GUI/static/assets/{index-CmZSnDqc.js → index-BaLMSqd3.js} +1 -1
  17. AutoGLM_GUI/static/assets/{index-CssG-3TH.js → index-CTHbFvKl.js} +5 -5
  18. AutoGLM_GUI/static/assets/index-CV7jGxGm.css +1 -0
  19. AutoGLM_GUI/static/assets/{label-BCUzE_nm.js → label-DJFevVmr.js} +1 -1
  20. AutoGLM_GUI/static/assets/{logs-eoFxn5of.js → logs-RW09DyYY.js} +1 -1
  21. AutoGLM_GUI/static/assets/{popover-DLsuV5Sx.js → popover--JTJrE5v.js} +1 -1
  22. AutoGLM_GUI/static/assets/{scheduled-tasks-MyqGJvy_.js → scheduled-tasks-DTRKsQXF.js} +1 -1
  23. AutoGLM_GUI/static/assets/{square-pen-zGWYrdfj.js → square-pen-CPK_K680.js} +1 -1
  24. AutoGLM_GUI/static/assets/{textarea-BX6y7uM5.js → textarea-PRmVnWq5.js} +1 -1
  25. AutoGLM_GUI/static/assets/{workflows-CYFs6ssC.js → workflows-CdcsAoaT.js} +1 -1
  26. AutoGLM_GUI/static/index.html +2 -2
  27. {autoglm_gui-1.5.0.dist-info → autoglm_gui-1.5.1.dist-info}/METADATA +49 -7
  28. {autoglm_gui-1.5.0.dist-info → autoglm_gui-1.5.1.dist-info}/RECORD +31 -70
  29. AutoGLM_GUI/device_adapter.py +0 -263
  30. AutoGLM_GUI/static/assets/chat-C0L2gQYG.js +0 -129
  31. AutoGLM_GUI/static/assets/history-DFBv7TGc.js +0 -1
  32. AutoGLM_GUI/static/assets/index-Bzyv2yQ2.css +0 -1
  33. mai_agent/base.py +0 -137
  34. mai_agent/mai_grounding_agent.py +0 -263
  35. mai_agent/mai_naivigation_agent.py +0 -526
  36. mai_agent/prompt.py +0 -148
  37. mai_agent/unified_memory.py +0 -67
  38. mai_agent/utils.py +0 -73
  39. phone_agent/__init__.py +0 -12
  40. phone_agent/actions/__init__.py +0 -5
  41. phone_agent/actions/handler.py +0 -400
  42. phone_agent/actions/handler_ios.py +0 -278
  43. phone_agent/adb/__init__.py +0 -51
  44. phone_agent/adb/connection.py +0 -358
  45. phone_agent/adb/device.py +0 -253
  46. phone_agent/adb/input.py +0 -108
  47. phone_agent/adb/screenshot.py +0 -108
  48. phone_agent/agent.py +0 -253
  49. phone_agent/agent_ios.py +0 -277
  50. phone_agent/config/__init__.py +0 -53
  51. phone_agent/config/apps.py +0 -227
  52. phone_agent/config/apps_harmonyos.py +0 -256
  53. phone_agent/config/apps_ios.py +0 -339
  54. phone_agent/config/i18n.py +0 -81
  55. phone_agent/config/prompts.py +0 -80
  56. phone_agent/config/prompts_en.py +0 -79
  57. phone_agent/config/prompts_zh.py +0 -82
  58. phone_agent/config/timing.py +0 -167
  59. phone_agent/device_factory.py +0 -166
  60. phone_agent/hdc/__init__.py +0 -53
  61. phone_agent/hdc/connection.py +0 -384
  62. phone_agent/hdc/device.py +0 -269
  63. phone_agent/hdc/input.py +0 -145
  64. phone_agent/hdc/screenshot.py +0 -127
  65. phone_agent/model/__init__.py +0 -5
  66. phone_agent/model/client.py +0 -290
  67. phone_agent/xctest/__init__.py +0 -47
  68. phone_agent/xctest/connection.py +0 -379
  69. phone_agent/xctest/device.py +0 -472
  70. phone_agent/xctest/input.py +0 -311
  71. phone_agent/xctest/screenshot.py +0 -226
  72. {autoglm_gui-1.5.0.dist-info → autoglm_gui-1.5.1.dist-info}/WHEEL +0 -0
  73. {autoglm_gui-1.5.0.dist-info → autoglm_gui-1.5.1.dist-info}/entry_points.txt +0 -0
  74. {autoglm_gui-1.5.0.dist-info → autoglm_gui-1.5.1.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-CssG-3TH.js","assets/index-Bzyv2yQ2.css"])))=>i.map(i=>d[i]);
2
- import{o as ze,j as a,u as An,r as w,T as pn,t as mn,v as gn,f as Wn,B as we,w as vx,x as Ys,R as Xe,y as _n,z as Nc,A as su,P as Vt,D as xt,E as iu,G as Tn,H as Fr,b as ar,I as Ps,J as bx,K as yx,L as wx,M as Ex,N as Sx,S as Cr,O as Cc,Q as Nx,U as Cx,V as Tx,W as ou,X as Rx,Y as Tc,Z as Rc,_ as kx,$ as Ax,a0 as Px,a1 as jx,a2 as Ix,a3 as Us,a4 as au,l as lu,a5 as cu,a6 as Lx,a7 as Mx,a8 as Dx,a9 as Ox,aa as Bx,ab as Fx,ac as Ux,ad as Wx,ae as Hx,af as Gx}from"./index-CssG-3TH.js";import{L as Zt,T as uu,D as fu,d as du,e as hu,f as pu,h as mu,g as gu,C as Vs}from"./dialog-DZ78cEcj.js";import{P as _u,L as it,I as wt}from"./label-BCUzE_nm.js";import{C as kn}from"./circle-alert-D4rSJh37.js";import{C as kc,a as Ac,P as Ws,b as Hs,d as Gs,c as zx}from"./popover-DLsuV5Sx.js";import{T as xu}from"./textarea-BX6y7uM5.js";const qx=[["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"}]],$x=ze("arrow-up-down",qx);const Xx=[["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"}]],vu=ze("brain",Xx);const Yx=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],bu=ze("chevron-left",Yx);const Vx=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],yu=ze("chevron-right",Vx);const Kx=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Qx=ze("chevron-up",Kx);const Jx=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ur=ze("circle-check",Jx);const Zx=[["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"}]],ev=ze("cpu",Zx);const tv=[["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"}]],Pc=ze("external-link",tv);const nv=[["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"}]],jc=ze("eye-off",nv);const rv=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],mo=ze("eye",rv);const sv=[["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"}]],iv=ze("fingerprint-pattern",sv);const ov=[["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"}]],Ic=ze("image",ov);const av=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],lv=ze("info",av);const cv=[["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=ze("layers",cv);const uv=[["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=ze("maximize",uv);const dv=[["path",{d:"M5 12h14",key:"1ays0h"}]],hv=ze("minus",dv);const pv=[["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"}]],mv=ze("monitor-play",pv);const gv=[["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"}]],_v=ze("plug",gv);const xv=[["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"}]],wu=ze("rotate-ccw",xv);const vv=[["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"}]],Eu=ze("send",vv);const bv=[["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=ze("server",bv);const yv=[["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"}]],Su=ze("settings",yv);const wv=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Ls=ze("smartphone",wv);const Ev=[["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"}]],Ar=ze("sparkles",Ev);const Sv=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Nu=ze("square",Sv);const Nv=[["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"}]],Cv=ze("video",Nv);const Tv=[["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"}]],Rv=ze("wifi-off",Tv);const kv=[["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"}]],zs=ze("wifi",kv);const Av=[["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=ze("wrench",Av);function Lc({isOpen:i,title:n,content:r,onConfirm:o,onCancel:u,confirmText:l="确认",cancelText:d="取消"}){return i?a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm animate-in fade-in duration-200",children:a.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-xl max-w-md w-full overflow-hidden transform transition-all animate-in zoom-in-95 duration-200",onClick:v=>v.stopPropagation(),children:[a.jsxs("div",{className:"p-6",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:n}),a.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm leading-relaxed whitespace-pre-wrap",children:r})]}),a.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 px-6 py-4 flex justify-end gap-3",children:[a.jsx("button",{onClick:v=>{v.stopPropagation(),u()},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:d}),a.jsx("button",{onClick:v=>{v.stopPropagation(),o()},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 jv({id:i,serial:n,model:r,status:o,connectionType:u,agent:l,isActive:d,onClick:v,onConnectWifi:h,onDisconnectWifi:g}){const p=An(),x=o==="device",b=u==="usb",E=u==="wifi",N=u==="remote",[j,R]=w.useState(!1),[M,B]=w.useState(!1),[I,P]=w.useState(!1),G=r||p.deviceCard.unknownDevice,Q=()=>{if(!x||!l)return"status-agent-none";switch(l.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"}},X=()=>{if(!x||!l)return p.deviceCard.statusTooltip.none;switch(l.state){case"idle":return p.deviceCard.statusTooltip.idle;case"busy":return p.deviceCard.statusTooltip.busy;case"error":return p.deviceCard.statusTooltip.error;case"initializing":return p.deviceCard.statusTooltip.initializing;default:return p.deviceCard.statusTooltip.none}},z=re=>{re.stopPropagation(),!(j||!h)&&B(!0)},F=re=>{re.stopPropagation(),!(j||!g)&&P(!0)},C=async()=>{B(!1),R(!0);try{h&&await h()}finally{R(!1)}},k=async()=>{P(!1),R(!0);try{g&&await g()}finally{R(!1)}};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:v,role:"button",tabIndex:0,onKeyDown:re=>{(re.key==="Enter"||re.key===" ")&&v()},className:`
3
- group relative w-full text-left p-4 rounded-xl transition-all duration-200 cursor-pointer
4
- border-2
5
- ${d?"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:[d&&a.jsx("div",{className:"absolute left-0 top-2 bottom-2 w-1 bg-[#1d9bf0] rounded-r"}),a.jsxs("div",{className:"flex items-center gap-3 pl-2",children:[a.jsxs(pn,{children:[a.jsx(mn,{asChild:!0,children:a.jsx("div",{className:`relative flex-shrink-0 ${Q()} w-3 h-3 rounded-full transition-all cursor-help ${d?"scale-110":""}`})}),a.jsx(gn,{side:"right",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("p",{className:"font-medium",children:[p.deviceCard.statusTooltip.title,X()]}),a.jsxs("div",{className:"text-xs opacity-80 space-y-0.5",children:[a.jsx("p",{children:p.deviceCard.statusTooltip.legend.green}),a.jsx("p",{children:p.deviceCard.statusTooltip.legend.yellow}),a.jsx("p",{children:p.deviceCard.statusTooltip.legend.red}),a.jsx("p",{children:p.deviceCard.statusTooltip.legend.gray})]})]})})]}),a.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-0.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ls,{className:`w-4 h-4 flex-shrink-0 ${d?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:`font-semibold text-sm truncate ${d?"text-slate-900 dark:text-slate-100":"text-slate-700 dark:text-slate-300"}`,children:G})]}),a.jsx("span",{className:`text-xs font-mono truncate ${d?"text-slate-500 dark:text-slate-400":"text-slate-400 dark:text-slate-500"}`,children:r||i})]}),a.jsx("div",{className:"flex-shrink-0 flex flex-col items-end gap-1",children:N?a.jsxs(Wn,{variant:"outline",className:"text-xs border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",children:[a.jsx(ko,{className:"w-2.5 h-2.5 mr-1"}),p.deviceCard.remote||"Remote"]}):E?a.jsxs(Wn,{variant:"outline",className:"text-xs border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",children:[a.jsx(zs,{className:"w-2.5 h-2.5 mr-1"}),p.deviceCard.wifi||"WiFi"]}):b?a.jsx(Wn,{variant:"outline",className:"text-xs border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",children:"USB"}):null}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h&&b&&a.jsxs(pn,{children:[a.jsx(mn,{asChild:!0,children:a.jsx(we,{variant:"ghost",size:"icon",onClick:z,disabled:j,className:"h-7 w-7 text-slate-400 hover:text-[#1d9bf0]",children:j?a.jsx(Zt,{className:"w-3.5 h-3.5 animate-spin"}):a.jsx(zs,{className:"w-3.5 h-3.5"})})}),a.jsx(gn,{children:a.jsx("p",{children:p.deviceCard.connectViaWifi})})]}),g&&E&&a.jsxs(pn,{children:[a.jsx(mn,{asChild:!0,children:a.jsx(we,{variant:"ghost",size:"icon",onClick:F,disabled:j,className:"h-7 w-7 text-slate-400 hover:text-orange-500",children:j?a.jsx(Zt,{className:"w-3.5 h-3.5 animate-spin"}):a.jsx(Rv,{className:"w-3.5 h-3.5"})})}),a.jsx(gn,{children:a.jsx("p",{children:p.deviceCard.disconnectWifi})})]}),N&&a.jsx(we,{variant:"ghost",size:"icon",onClick:async re=>{re.stopPropagation(),R(!0);try{await vx(n)}catch(pe){console.error("Failed to remove remote device:",pe)}finally{R(!1)}},disabled:j,className:"h-7 w-7 text-slate-400 hover:text-red-500",title:p.deviceCard.removeRemote||"移除远程设备",children:j?a.jsx(Zt,{className:"w-3.5 h-3.5 animate-spin"}):a.jsx(uu,{className:"w-3.5 h-3.5"})})]})]})]}),a.jsx(Lc,{isOpen:M,title:p.deviceCard.connectWifiTitle,content:p.deviceCard.connectWifiContent,onConfirm:C,onCancel:()=>B(!1)}),a.jsx(Lc,{isOpen:I,title:p.deviceCard.disconnectWifiTitle,content:p.deviceCard.disconnectWifiContent,onConfirm:k,onCancel:()=>P(!1)})]})}function Iv(i){const n=i+"CollectionProvider",[r,o]=Ys(n),[u,l]=r(n,{collectionRef:{current:null},itemMap:new Map}),d=j=>{const{scope:R,children:M}=j,B=Xe.useRef(null),I=Xe.useRef(new Map).current;return a.jsx(u,{scope:R,itemMap:I,collectionRef:B,children:M})};d.displayName=n;const v=i+"CollectionSlot",h=Nc(v),g=Xe.forwardRef((j,R)=>{const{scope:M,children:B}=j,I=l(v,M),P=_n(R,I.collectionRef);return a.jsx(h,{ref:P,children:B})});g.displayName=v;const p=i+"CollectionItemSlot",x="data-radix-collection-item",b=Nc(p),E=Xe.forwardRef((j,R)=>{const{scope:M,children:B,...I}=j,P=Xe.useRef(null),G=_n(R,P),Q=l(p,M);return Xe.useEffect(()=>(Q.itemMap.set(P,{ref:P,...I}),()=>void Q.itemMap.delete(P))),a.jsx(b,{[x]:"",ref:G,children:B})});E.displayName=p;function N(j){const R=l(i+"CollectionConsumer",j);return Xe.useCallback(()=>{const B=R.collectionRef.current;if(!B)return[];const I=Array.from(B.querySelectorAll(`[${x}]`));return Array.from(R.itemMap.values()).sort((Q,X)=>I.indexOf(Q.ref.current)-I.indexOf(X.ref.current))},[R.collectionRef,R.itemMap])}return[{Provider:d,Slot:g,ItemSlot:E},N,o]}var Lv=w.createContext(void 0);function Fo(i){const n=w.useContext(Lv);return i||n||"ltr"}var go="rovingFocusGroup.onEntryFocus",Mv={bubbles:!1,cancelable:!0},Wr="RovingFocusGroup",[Ao,Cu,Dv]=Iv(Wr),[Ov,Tu]=Ys(Wr,[Dv]),[Bv,Fv]=Ov(Wr),Ru=w.forwardRef((i,n)=>a.jsx(Ao.Provider,{scope:i.__scopeRovingFocusGroup,children:a.jsx(Ao.Slot,{scope:i.__scopeRovingFocusGroup,children:a.jsx(Uv,{...i,ref:n})})}));Ru.displayName=Wr;var Uv=w.forwardRef((i,n)=>{const{__scopeRovingFocusGroup:r,orientation:o,loop:u=!1,dir:l,currentTabStopId:d,defaultCurrentTabStopId:v,onCurrentTabStopIdChange:h,onEntryFocus:g,preventScrollOnEntryFocus:p=!1,...x}=i,b=w.useRef(null),E=_n(n,b),N=Fo(l),[j,R]=iu({prop:d,defaultProp:v??null,onChange:h,caller:Wr}),[M,B]=w.useState(!1),I=Tn(g),P=Cu(r),G=w.useRef(!1),[Q,X]=w.useState(0);return w.useEffect(()=>{const z=b.current;if(z)return z.addEventListener(go,I),()=>z.removeEventListener(go,I)},[I]),a.jsx(Bv,{scope:r,orientation:o,dir:N,loop:u,currentTabStopId:j,onItemFocus:w.useCallback(z=>R(z),[R]),onItemShiftTab:w.useCallback(()=>B(!0),[]),onFocusableItemAdd:w.useCallback(()=>X(z=>z+1),[]),onFocusableItemRemove:w.useCallback(()=>X(z=>z-1),[]),children:a.jsx(Vt.div,{tabIndex:M||Q===0?-1:0,"data-orientation":o,...x,ref:E,style:{outline:"none",...i.style},onMouseDown:xt(i.onMouseDown,()=>{G.current=!0}),onFocus:xt(i.onFocus,z=>{const F=!G.current;if(z.target===z.currentTarget&&F&&!M){const C=new CustomEvent(go,Mv);if(z.currentTarget.dispatchEvent(C),!C.defaultPrevented){const k=P().filter(K=>K.focusable),re=k.find(K=>K.active),pe=k.find(K=>K.id===j),q=[re,pe,...k].filter(Boolean).map(K=>K.ref.current);Pu(q,p)}}G.current=!1}),onBlur:xt(i.onBlur,()=>B(!1))})})}),ku="RovingFocusGroupItem",Au=w.forwardRef((i,n)=>{const{__scopeRovingFocusGroup:r,focusable:o=!0,active:u=!1,tabStopId:l,children:d,...v}=i,h=su(),g=l||h,p=Fv(ku,r),x=p.currentTabStopId===g,b=Cu(r),{onFocusableItemAdd:E,onFocusableItemRemove:N,currentTabStopId:j}=p;return w.useEffect(()=>{if(o)return E(),()=>N()},[o,E,N]),a.jsx(Ao.ItemSlot,{scope:r,id:g,focusable:o,active:u,children:a.jsx(Vt.span,{tabIndex:x?0:-1,"data-orientation":p.orientation,...v,ref:n,onMouseDown:xt(i.onMouseDown,R=>{o?p.onItemFocus(g):R.preventDefault()}),onFocus:xt(i.onFocus,()=>p.onItemFocus(g)),onKeyDown:xt(i.onKeyDown,R=>{if(R.key==="Tab"&&R.shiftKey){p.onItemShiftTab();return}if(R.target!==R.currentTarget)return;const M=Gv(R,p.orientation,p.dir);if(M!==void 0){if(R.metaKey||R.ctrlKey||R.altKey||R.shiftKey)return;R.preventDefault();let I=b().filter(P=>P.focusable).map(P=>P.ref.current);if(M==="last")I.reverse();else if(M==="prev"||M==="next"){M==="prev"&&I.reverse();const P=I.indexOf(R.currentTarget);I=p.loop?zv(I,P+1):I.slice(P+1)}setTimeout(()=>Pu(I))}}),children:typeof d=="function"?d({isCurrentTabStop:x,hasTabStop:j!=null}):d})})});Au.displayName=ku;var Wv={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Hv(i,n){return n!=="rtl"?i:i==="ArrowLeft"?"ArrowRight":i==="ArrowRight"?"ArrowLeft":i}function Gv(i,n,r){const o=Hv(i.key,r);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return Wv[o]}function Pu(i,n=!1){const r=document.activeElement;for(const o of i)if(o===r||(o.focus({preventScroll:n}),document.activeElement!==r))return}function zv(i,n){return i.map((r,o)=>i[(n+o)%i.length])}var qv=Ru,$v=Au,Ks="Tabs",[Xv]=Ys(Ks,[Tu]),ju=Tu(),[Yv,Uo]=Xv(Ks),Iu=w.forwardRef((i,n)=>{const{__scopeTabs:r,value:o,onValueChange:u,defaultValue:l,orientation:d="horizontal",dir:v,activationMode:h="automatic",...g}=i,p=Fo(v),[x,b]=iu({prop:o,onChange:u,defaultProp:l??"",caller:Ks});return a.jsx(Yv,{scope:r,baseId:su(),value:x,onValueChange:b,orientation:d,dir:p,activationMode:h,children:a.jsx(Vt.div,{dir:p,"data-orientation":d,...g,ref:n})})});Iu.displayName=Ks;var Lu="TabsList",Mu=w.forwardRef((i,n)=>{const{__scopeTabs:r,loop:o=!0,...u}=i,l=Uo(Lu,r),d=ju(r);return a.jsx(qv,{asChild:!0,...d,orientation:l.orientation,dir:l.dir,loop:o,children:a.jsx(Vt.div,{role:"tablist","aria-orientation":l.orientation,...u,ref:n})})});Mu.displayName=Lu;var Du="TabsTrigger",Ou=w.forwardRef((i,n)=>{const{__scopeTabs:r,value:o,disabled:u=!1,...l}=i,d=Uo(Du,r),v=ju(r),h=Uu(d.baseId,o),g=Wu(d.baseId,o),p=o===d.value;return a.jsx($v,{asChild:!0,...v,focusable:!u,active:p,children:a.jsx(Vt.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":g,"data-state":p?"active":"inactive","data-disabled":u?"":void 0,disabled:u,id:h,...l,ref:n,onMouseDown:xt(i.onMouseDown,x=>{!u&&x.button===0&&x.ctrlKey===!1?d.onValueChange(o):x.preventDefault()}),onKeyDown:xt(i.onKeyDown,x=>{[" ","Enter"].includes(x.key)&&d.onValueChange(o)}),onFocus:xt(i.onFocus,()=>{const x=d.activationMode!=="manual";!p&&!u&&x&&d.onValueChange(o)})})})});Ou.displayName=Du;var Bu="TabsContent",Fu=w.forwardRef((i,n)=>{const{__scopeTabs:r,value:o,forceMount:u,children:l,...d}=i,v=Uo(Bu,r),h=Uu(v.baseId,o),g=Wu(v.baseId,o),p=o===v.value,x=w.useRef(p);return w.useEffect(()=>{const b=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(b)},[]),a.jsx(Fr,{present:u||p,children:({present:b})=>a.jsx(Vt.div,{"data-state":p?"active":"inactive","data-orientation":v.orientation,role:"tabpanel","aria-labelledby":h,hidden:!b,id:g,tabIndex:0,...d,ref:n,style:{...i.style,animationDuration:x.current?"0s":void 0},children:b&&l})})});Fu.displayName=Bu;function Uu(i,n){return`${i}-trigger-${n}`}function Wu(i,n){return`${i}-content-${n}`}var Vv=Iu,Kv=Mu,Qv=Ou,Jv=Fu;function Hu({className:i,...n}){return a.jsx(Vv,{"data-slot":"tabs",className:ar("flex flex-col gap-2",i),...n})}function Gu({className:i,...n}){return a.jsx(Kv,{"data-slot":"tabs-list",className:ar("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 a.jsx(Qv,{"data-slot":"tabs-trigger",className:ar("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 a.jsx(Jv,{"data-slot":"tabs-content",className:ar("flex-1 outline-none",i),...n})}var Zv=Object.defineProperty,qs=Object.getOwnPropertySymbols,zu=Object.prototype.hasOwnProperty,qu=Object.prototype.propertyIsEnumerable,Mc=(i,n,r)=>n in i?Zv(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,Po=(i,n)=>{for(var r in n||(n={}))zu.call(n,r)&&Mc(i,r,n[r]);if(qs)for(var r of qs(n))qu.call(n,r)&&Mc(i,r,n[r]);return i},jo=(i,n)=>{var r={};for(var o in i)zu.call(i,o)&&n.indexOf(o)<0&&(r[o]=i[o]);if(i!=null&&qs)for(var o of qs(i))n.indexOf(o)<0&&qu.call(i,o)&&(r[o]=i[o]);return r};var Hn;(i=>{const n=class Ie{constructor(h,g,p,x){if(this.version=h,this.errorCorrectionLevel=g,this.modules=[],this.isFunction=[],h<Ie.MIN_VERSION||h>Ie.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=h*4+17;let b=[];for(let N=0;N<this.size;N++)b.push(!1);for(let N=0;N<this.size;N++)this.modules.push(b.slice()),this.isFunction.push(b.slice());this.drawFunctionPatterns();const E=this.addEccAndInterleave(p);if(this.drawCodewords(E),x==-1){let N=1e9;for(let j=0;j<8;j++){this.applyMask(j),this.drawFormatBits(j);const R=this.getPenaltyScore();R<N&&(x=j,N=R),this.applyMask(j)}}u(0<=x&&x<=7),this.mask=x,this.applyMask(x),this.drawFormatBits(x),this.isFunction=[]}static encodeText(h,g){const p=i.QrSegment.makeSegments(h);return Ie.encodeSegments(p,g)}static encodeBinary(h,g){const p=i.QrSegment.makeBytes(h);return Ie.encodeSegments([p],g)}static encodeSegments(h,g,p=1,x=40,b=-1,E=!0){if(!(Ie.MIN_VERSION<=p&&p<=x&&x<=Ie.MAX_VERSION)||b<-1||b>7)throw new RangeError("Invalid value");let N,j;for(N=p;;N++){const I=Ie.getNumDataCodewords(N,g)*8,P=d.getTotalBits(h,N);if(P<=I){j=P;break}if(N>=x)throw new RangeError("Data too long")}for(const I of[Ie.Ecc.MEDIUM,Ie.Ecc.QUARTILE,Ie.Ecc.HIGH])E&&j<=Ie.getNumDataCodewords(N,I)*8&&(g=I);let R=[];for(const I of h){r(I.mode.modeBits,4,R),r(I.numChars,I.mode.numCharCountBits(N),R);for(const P of I.getData())R.push(P)}u(R.length==j);const M=Ie.getNumDataCodewords(N,g)*8;u(R.length<=M),r(0,Math.min(4,M-R.length),R),r(0,(8-R.length%8)%8,R),u(R.length%8==0);for(let I=236;R.length<M;I^=253)r(I,8,R);let B=[];for(;B.length*8<R.length;)B.push(0);return R.forEach((I,P)=>B[P>>>3]|=I<<7-(P&7)),new Ie(N,g,B,b)}getModule(h,g){return 0<=h&&h<this.size&&0<=g&&g<this.size&&this.modules[g][h]}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 h=this.getAlignmentPatternPositions(),g=h.length;for(let p=0;p<g;p++)for(let x=0;x<g;x++)p==0&&x==0||p==0&&x==g-1||p==g-1&&x==0||this.drawAlignmentPattern(h[p],h[x]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(h){const g=this.errorCorrectionLevel.formatBits<<3|h;let p=g;for(let b=0;b<10;b++)p=p<<1^(p>>>9)*1335;const x=(g<<10|p)^21522;u(x>>>15==0);for(let b=0;b<=5;b++)this.setFunctionModule(8,b,o(x,b));this.setFunctionModule(8,7,o(x,6)),this.setFunctionModule(8,8,o(x,7)),this.setFunctionModule(7,8,o(x,8));for(let b=9;b<15;b++)this.setFunctionModule(14-b,8,o(x,b));for(let b=0;b<8;b++)this.setFunctionModule(this.size-1-b,8,o(x,b));for(let b=8;b<15;b++)this.setFunctionModule(8,this.size-15+b,o(x,b));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let h=this.version;for(let p=0;p<12;p++)h=h<<1^(h>>>11)*7973;const g=this.version<<12|h;u(g>>>18==0);for(let p=0;p<18;p++){const x=o(g,p),b=this.size-11+p%3,E=Math.floor(p/3);this.setFunctionModule(b,E,x),this.setFunctionModule(E,b,x)}}drawFinderPattern(h,g){for(let p=-4;p<=4;p++)for(let x=-4;x<=4;x++){const b=Math.max(Math.abs(x),Math.abs(p)),E=h+x,N=g+p;0<=E&&E<this.size&&0<=N&&N<this.size&&this.setFunctionModule(E,N,b!=2&&b!=4)}}drawAlignmentPattern(h,g){for(let p=-2;p<=2;p++)for(let x=-2;x<=2;x++)this.setFunctionModule(h+x,g+p,Math.max(Math.abs(x),Math.abs(p))!=1)}setFunctionModule(h,g,p){this.modules[g][h]=p,this.isFunction[g][h]=!0}addEccAndInterleave(h){const g=this.version,p=this.errorCorrectionLevel;if(h.length!=Ie.getNumDataCodewords(g,p))throw new RangeError("Invalid argument");const x=Ie.NUM_ERROR_CORRECTION_BLOCKS[p.ordinal][g],b=Ie.ECC_CODEWORDS_PER_BLOCK[p.ordinal][g],E=Math.floor(Ie.getNumRawDataModules(g)/8),N=x-E%x,j=Math.floor(E/x);let R=[];const M=Ie.reedSolomonComputeDivisor(b);for(let I=0,P=0;I<x;I++){let G=h.slice(P,P+j-b+(I<N?0:1));P+=G.length;const Q=Ie.reedSolomonComputeRemainder(G,M);I<N&&G.push(0),R.push(G.concat(Q))}let B=[];for(let I=0;I<R[0].length;I++)R.forEach((P,G)=>{(I!=j-b||G>=N)&&B.push(P[I])});return u(B.length==E),B}drawCodewords(h){if(h.length!=Math.floor(Ie.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let g=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 b=0;b<2;b++){const E=p-b,j=(p+1&2)==0?this.size-1-x:x;!this.isFunction[j][E]&&g<h.length*8&&(this.modules[j][E]=o(h[g>>>3],7-(g&7)),g++)}}u(g==h.length*8)}applyMask(h){if(h<0||h>7)throw new RangeError("Mask value out of range");for(let g=0;g<this.size;g++)for(let p=0;p<this.size;p++){let x;switch(h){case 0:x=(p+g)%2==0;break;case 1:x=g%2==0;break;case 2:x=p%3==0;break;case 3:x=(p+g)%3==0;break;case 4:x=(Math.floor(p/3)+Math.floor(g/2))%2==0;break;case 5:x=p*g%2+p*g%3==0;break;case 6:x=(p*g%2+p*g%3)%2==0;break;case 7:x=((p+g)%2+p*g%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[g][p]&&x&&(this.modules[g][p]=!this.modules[g][p])}}getPenaltyScore(){let h=0;for(let b=0;b<this.size;b++){let E=!1,N=0,j=[0,0,0,0,0,0,0];for(let R=0;R<this.size;R++)this.modules[b][R]==E?(N++,N==5?h+=Ie.PENALTY_N1:N>5&&h++):(this.finderPenaltyAddHistory(N,j),E||(h+=this.finderPenaltyCountPatterns(j)*Ie.PENALTY_N3),E=this.modules[b][R],N=1);h+=this.finderPenaltyTerminateAndCount(E,N,j)*Ie.PENALTY_N3}for(let b=0;b<this.size;b++){let E=!1,N=0,j=[0,0,0,0,0,0,0];for(let R=0;R<this.size;R++)this.modules[R][b]==E?(N++,N==5?h+=Ie.PENALTY_N1:N>5&&h++):(this.finderPenaltyAddHistory(N,j),E||(h+=this.finderPenaltyCountPatterns(j)*Ie.PENALTY_N3),E=this.modules[R][b],N=1);h+=this.finderPenaltyTerminateAndCount(E,N,j)*Ie.PENALTY_N3}for(let b=0;b<this.size-1;b++)for(let E=0;E<this.size-1;E++){const N=this.modules[b][E];N==this.modules[b][E+1]&&N==this.modules[b+1][E]&&N==this.modules[b+1][E+1]&&(h+=Ie.PENALTY_N2)}let g=0;for(const b of this.modules)g=b.reduce((E,N)=>E+(N?1:0),g);const p=this.size*this.size,x=Math.ceil(Math.abs(g*20-p*10)/p)-1;return u(0<=x&&x<=9),h+=x*Ie.PENALTY_N4,u(0<=h&&h<=2568888),h}getAlignmentPatternPositions(){if(this.version==1)return[];{const h=Math.floor(this.version/7)+2,g=this.version==32?26:Math.ceil((this.version*4+4)/(h*2-2))*2;let p=[6];for(let x=this.size-7;p.length<h;x-=g)p.splice(1,0,x);return p}}static getNumRawDataModules(h){if(h<Ie.MIN_VERSION||h>Ie.MAX_VERSION)throw new RangeError("Version number out of range");let g=(16*h+128)*h+64;if(h>=2){const p=Math.floor(h/7)+2;g-=(25*p-10)*p-55,h>=7&&(g-=36)}return u(208<=g&&g<=29648),g}static getNumDataCodewords(h,g){return Math.floor(Ie.getNumRawDataModules(h)/8)-Ie.ECC_CODEWORDS_PER_BLOCK[g.ordinal][h]*Ie.NUM_ERROR_CORRECTION_BLOCKS[g.ordinal][h]}static reedSolomonComputeDivisor(h){if(h<1||h>255)throw new RangeError("Degree out of range");let g=[];for(let x=0;x<h-1;x++)g.push(0);g.push(1);let p=1;for(let x=0;x<h;x++){for(let b=0;b<g.length;b++)g[b]=Ie.reedSolomonMultiply(g[b],p),b+1<g.length&&(g[b]^=g[b+1]);p=Ie.reedSolomonMultiply(p,2)}return g}static reedSolomonComputeRemainder(h,g){let p=g.map(x=>0);for(const x of h){const b=x^p.shift();p.push(0),g.forEach((E,N)=>p[N]^=Ie.reedSolomonMultiply(E,b))}return p}static reedSolomonMultiply(h,g){if(h>>>8||g>>>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^=(g>>>x&1)*h;return u(p>>>8==0),p}finderPenaltyCountPatterns(h){const g=h[1];u(g<=this.size*3);const p=g>0&&h[2]==g&&h[3]==g*3&&h[4]==g&&h[5]==g;return(p&&h[0]>=g*4&&h[6]>=g?1:0)+(p&&h[6]>=g*4&&h[0]>=g?1:0)}finderPenaltyTerminateAndCount(h,g,p){return h&&(this.finderPenaltyAddHistory(g,p),g=0),g+=this.size,this.finderPenaltyAddHistory(g,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(h,g){g[0]==0&&(h+=this.size),g.pop(),g.unshift(h)}};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,h,g){if(h<0||h>31||v>>>h)throw new RangeError("Value out of range");for(let p=h-1;p>=0;p--)g.push(v>>>p&1)}function o(v,h){return(v>>>h&1)!=0}function u(v){if(!v)throw new Error("Assertion error")}const l=class et{constructor(h,g,p){if(this.mode=h,this.numChars=g,this.bitData=p,g<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(h){let g=[];for(const p of h)r(p,8,g);return new et(et.Mode.BYTE,h.length,g)}static makeNumeric(h){if(!et.isNumeric(h))throw new RangeError("String contains non-numeric characters");let g=[];for(let p=0;p<h.length;){const x=Math.min(h.length-p,3);r(parseInt(h.substring(p,p+x),10),x*3+1,g),p+=x}return new et(et.Mode.NUMERIC,h.length,g)}static makeAlphanumeric(h){if(!et.isAlphanumeric(h))throw new RangeError("String contains unencodable characters in alphanumeric mode");let g=[],p;for(p=0;p+2<=h.length;p+=2){let x=et.ALPHANUMERIC_CHARSET.indexOf(h.charAt(p))*45;x+=et.ALPHANUMERIC_CHARSET.indexOf(h.charAt(p+1)),r(x,11,g)}return p<h.length&&r(et.ALPHANUMERIC_CHARSET.indexOf(h.charAt(p)),6,g),new et(et.Mode.ALPHANUMERIC,h.length,g)}static makeSegments(h){return h==""?[]:et.isNumeric(h)?[et.makeNumeric(h)]:et.isAlphanumeric(h)?[et.makeAlphanumeric(h)]:[et.makeBytes(et.toUtf8ByteArray(h))]}static makeEci(h){let g=[];if(h<0)throw new RangeError("ECI assignment value out of range");if(h<128)r(h,8,g);else if(h<16384)r(2,2,g),r(h,14,g);else if(h<1e6)r(6,3,g),r(h,21,g);else throw new RangeError("ECI assignment value out of range");return new et(et.Mode.ECI,0,g)}static isNumeric(h){return et.NUMERIC_REGEX.test(h)}static isAlphanumeric(h){return et.ALPHANUMERIC_REGEX.test(h)}getData(){return this.bitData.slice()}static getTotalBits(h,g){let p=0;for(const x of h){const b=x.mode.numCharCountBits(g);if(x.numChars>=1<<b)return 1/0;p+=4+b+x.bitData.length}return p}static toUtf8ByteArray(h){h=encodeURI(h);let g=[];for(let p=0;p<h.length;p++)h.charAt(p)!="%"?g.push(h.charCodeAt(p)):(g.push(parseInt(h.substring(p+1,p+3),16)),p+=2);return g}};l.NUMERIC_REGEX=/^[0-9]*$/,l.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,l.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let d=l;i.QrSegment=l})(Hn||(Hn={}));(i=>{(n=>{const r=class{constructor(u,l){this.ordinal=u,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={}))})(Hn||(Hn={}));(i=>{(n=>{const r=class{constructor(u,l){this.modeBits=u,this.numBitsCharCount=l}numCharCountBits(u){return this.numBitsCharCount[Math.floor((u+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={}))})(Hn||(Hn={}));var ir=Hn;var e1={L:ir.QrCode.Ecc.LOW,M:ir.QrCode.Ecc.MEDIUM,Q:ir.QrCode.Ecc.QUARTILE,H:ir.QrCode.Ecc.HIGH},$u=128,Xu="L",Yu="#FFFFFF",Vu="#000000",Ku=!1,Qu=1,t1=4,n1=0,r1=.1;function Ju(i,n=0){const r=[];return i.forEach(function(o,u){let l=null;o.forEach(function(d,v){if(!d&&l!==null){r.push(`M${l+n} ${u+n}h${v-l}v1H${l+n}z`),l=null;return}if(v===o.length-1){if(!d)return;l===null?r.push(`M${v+n},${u+n} h1v1H${v+n}z`):r.push(`M${l+n},${u+n} h${v+1-l}v1H${l+n}z`);return}d&&l===null&&(l=v)})}),r.join("")}function Zu(i,n){return i.slice().map((r,o)=>o<n.y||o>=n.y+n.h?r:r.map((u,l)=>l<n.x||l>=n.x+n.w?u:!1))}function s1(i,n,r,o){if(o==null)return null;const u=i.length+r*2,l=Math.floor(n*r1),d=u/n,v=(o.width||l)*d,h=(o.height||l)*d,g=o.x==null?i.length/2-v/2:o.x*d,p=o.y==null?i.length/2-h/2:o.y*d,x=o.opacity==null?1:o.opacity;let b=null;if(o.excavate){let N=Math.floor(g),j=Math.floor(p),R=Math.ceil(v+g-N),M=Math.ceil(h+p-j);b={x:N,y:j,w:R,h:M}}const E=o.crossOrigin;return{x:g,y:p,h,w:v,excavation:b,opacity:x,crossOrigin:E}}function i1(i,n){return n!=null?Math.max(Math.floor(n),0):i?t1:n1}function ef({value:i,level:n,minVersion:r,includeMargin:o,marginSize:u,imageSettings:l,size:d,boostLevel:v}){let h=Xe.useMemo(()=>{const N=(Array.isArray(i)?i:[i]).reduce((j,R)=>(j.push(...ir.QrSegment.makeSegments(R)),j),[]);return ir.QrCode.encodeSegments(N,e1[n],r,void 0,void 0,v)},[i,n,r,v]);const{cells:g,margin:p,numCells:x,calculatedImageSettings:b}=Xe.useMemo(()=>{let E=h.getModules();const N=i1(o,u),j=E.length+N*2,R=s1(E,d,N,l);return{cells:E,margin:N,numCells:j,calculatedImageSettings:R}},[h,d,l,o,u]);return{qrcode:h,margin:p,cells:g,numCells:x,calculatedImageSettings:b}}var o1=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),a1=Xe.forwardRef(function(n,r){const o=n,{value:u,size:l=$u,level:d=Xu,bgColor:v=Yu,fgColor:h=Vu,includeMargin:g=Ku,minVersion:p=Qu,boostLevel:x,marginSize:b,imageSettings:E}=o,j=jo(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:R}=j,M=jo(j,["style"]),B=E?.src,I=Xe.useRef(null),P=Xe.useRef(null),G=Xe.useCallback(Y=>{I.current=Y,typeof r=="function"?r(Y):r&&(r.current=Y)},[r]),[Q,X]=Xe.useState(!1),{margin:z,cells:F,numCells:C,calculatedImageSettings:k}=ef({value:u,level:d,minVersion:p,boostLevel:x,includeMargin:g,marginSize:b,imageSettings:E,size:l});Xe.useEffect(()=>{if(I.current!=null){const Y=I.current,q=Y.getContext("2d");if(!q)return;let K=F;const ie=P.current,le=k!=null&&ie!==null&&ie.complete&&ie.naturalHeight!==0&&ie.naturalWidth!==0;le&&k.excavation!=null&&(K=Zu(F,k.excavation));const Ce=window.devicePixelRatio||1;Y.height=Y.width=l*Ce;const $=l/C*Ce;q.scale($,$),q.fillStyle=v,q.fillRect(0,0,C,C),q.fillStyle=h,o1?q.fill(new Path2D(Ju(K,z))):F.forEach(function(J,ue){J.forEach(function(ne,be){ne&&q.fillRect(be+z,ue+z,1,1)})}),k&&(q.globalAlpha=k.opacity),le&&q.drawImage(ie,k.x+z,k.y+z,k.w,k.h)}}),Xe.useEffect(()=>{X(!1)},[B]);const re=Po({height:l,width:l},R);let pe=null;return B!=null&&(pe=Xe.createElement("img",{src:B,key:B,style:{display:"none"},onLoad:()=>{X(!0)},ref:P,crossOrigin:k?.crossOrigin})),Xe.createElement(Xe.Fragment,null,Xe.createElement("canvas",Po({style:re,height:l,width:l,ref:G,role:"img"},M)),pe)});a1.displayName="QRCodeCanvas";var tf=Xe.forwardRef(function(n,r){const o=n,{value:u,size:l=$u,level:d=Xu,bgColor:v=Yu,fgColor:h=Vu,includeMargin:g=Ku,minVersion:p=Qu,boostLevel:x,title:b,marginSize:E,imageSettings:N}=o,j=jo(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:R,cells:M,numCells:B,calculatedImageSettings:I}=ef({value:u,level:d,minVersion:p,boostLevel:x,includeMargin:g,marginSize:E,imageSettings:N,size:l});let P=M,G=null;N!=null&&I!=null&&(I.excavation!=null&&(P=Zu(M,I.excavation)),G=Xe.createElement("image",{href:N.src,height:I.h,width:I.w,x:I.x+R,y:I.y+R,preserveAspectRatio:"none",opacity:I.opacity,crossOrigin:I.crossOrigin}));const Q=Ju(P,R);return Xe.createElement("svg",Po({height:l,width:l,viewBox:`0 0 ${B} ${B}`,ref:r,role:"img"},j),!!b&&Xe.createElement("title",null,b),Xe.createElement("path",{fill:v,d:`M0,0 h${B}v${B}H0z`,shapeRendering:"crispEdges"}),Xe.createElement("path",{fill:h,d:Q,shapeRendering:"crispEdges"}),G)});tf.displayName="QRCodeSVG";var Pr={exports:{}};var l1=Pr.exports,Dc;function c1(){return Dc||(Dc=1,(function(i,n){(function(){var r,o="4.17.21",u=200,l="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",d="Expected a function",v="Invalid `variable` option passed into `_.template`",h="__lodash_hash_undefined__",g=500,p="__lodash_placeholder__",x=1,b=2,E=4,N=1,j=2,R=1,M=2,B=4,I=8,P=16,G=32,Q=64,X=128,z=256,F=512,C=30,k="...",re=800,pe=16,Y=1,q=2,K=3,ie=1/0,le=9007199254740991,Ce=17976931348623157e292,$=NaN,J=4294967295,ue=J-1,ne=J>>>1,be=[["ary",X],["bind",R],["bindKey",M],["curry",I],["curryRight",P],["flip",F],["partial",G],["partialRight",Q],["rearg",z]],Ee="[object Arguments]",He="[object Array]",Qe="[object AsyncFunction]",Be="[object Boolean]",D="[object Date]",Se="[object DOMException]",ae="[object Error]",Fe="[object Function]",tt="[object GeneratorFunction]",ve="[object Map]",Pe="[object Number]",Z="[object Null]",ee="[object Object]",de="[object Promise]",Me="[object Proxy]",ce="[object RegExp]",fe="[object Set]",ye="[object String]",xe="[object Symbol]",Ve="[object Undefined]",pt="[object WeakMap]",st="[object WeakSet]",at="[object ArrayBuffer]",lt="[object DataView]",Pn="[object Float32Array]",Gn="[object Float64Array]",cr="[object Int8Array]",rn="[object Int16Array]",zn="[object Int32Array]",U="[object Uint8Array]",me="[object Uint8ClampedArray]",It="[object Uint16Array]",ur="[object Uint32Array]",Hr=/\b__p \+= '';/g,Wf=/\b(__p \+=) '' \+/g,Hf=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ko=/&(?:amp|lt|gt|quot|#39);/g,Qo=/[&<>"']/g,Gf=RegExp(Ko.source),zf=RegExp(Qo.source),qf=/<%-([\s\S]+?)%>/g,$f=/<%([\s\S]+?)%>/g,Jo=/<%=([\s\S]+?)%>/g,Xf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Yf=/^\w*$/,Vf=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ni=/[\\^$.*+?()[\]{}|]/g,Kf=RegExp(ni.source),ri=/^\s+/,Qf=/\s/,Jf=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Zf=/\{\n\/\* \[wrapped with (.+)\] \*/,ed=/,? & /,td=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,nd=/[()=,{}\[\]\/\s]/,rd=/\\(\\)?/g,sd=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Zo=/\w*$/,id=/^[-+]0x[0-9a-f]+$/i,od=/^0b[01]+$/i,ad=/^\[object .+?Constructor\]$/,ld=/^0o[0-7]+$/i,cd=/^(?:0|[1-9]\d*)$/,ud=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Gr=/($^)/,fd=/['\n\r\u2028\u2029\\]/g,zr="\\ud800-\\udfff",dd="\\u0300-\\u036f",hd="\\ufe20-\\ufe2f",pd="\\u20d0-\\u20ff",ea=dd+hd+pd,ta="\\u2700-\\u27bf",na="a-z\\xdf-\\xf6\\xf8-\\xff",md="\\xac\\xb1\\xd7\\xf7",gd="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",_d="\\u2000-\\u206f",xd=" \\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",ra="A-Z\\xc0-\\xd6\\xd8-\\xde",sa="\\ufe0e\\ufe0f",ia=md+gd+_d+xd,si="['’]",vd="["+zr+"]",oa="["+ia+"]",qr="["+ea+"]",aa="\\d+",bd="["+ta+"]",la="["+na+"]",ca="[^"+zr+ia+aa+ta+na+ra+"]",ii="\\ud83c[\\udffb-\\udfff]",yd="(?:"+qr+"|"+ii+")",ua="[^"+zr+"]",oi="(?:\\ud83c[\\udde6-\\uddff]){2}",ai="[\\ud800-\\udbff][\\udc00-\\udfff]",qn="["+ra+"]",fa="\\u200d",da="(?:"+la+"|"+ca+")",wd="(?:"+qn+"|"+ca+")",ha="(?:"+si+"(?:d|ll|m|re|s|t|ve))?",pa="(?:"+si+"(?:D|LL|M|RE|S|T|VE))?",ma=yd+"?",ga="["+sa+"]?",Ed="(?:"+fa+"(?:"+[ua,oi,ai].join("|")+")"+ga+ma+")*",Sd="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Nd="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",_a=ga+ma+Ed,Cd="(?:"+[bd,oi,ai].join("|")+")"+_a,Td="(?:"+[ua+qr+"?",qr,oi,ai,vd].join("|")+")",Rd=RegExp(si,"g"),kd=RegExp(qr,"g"),li=RegExp(ii+"(?="+ii+")|"+Td+_a,"g"),Ad=RegExp([qn+"?"+la+"+"+ha+"(?="+[oa,qn,"$"].join("|")+")",wd+"+"+pa+"(?="+[oa,qn+da,"$"].join("|")+")",qn+"?"+da+"+"+ha,qn+"+"+pa,Nd,Sd,aa,Cd].join("|"),"g"),Pd=RegExp("["+fa+zr+ea+sa+"]"),jd=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Id=["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"],Ld=-1,Ye={};Ye[Pn]=Ye[Gn]=Ye[cr]=Ye[rn]=Ye[zn]=Ye[U]=Ye[me]=Ye[It]=Ye[ur]=!0,Ye[Ee]=Ye[He]=Ye[at]=Ye[Be]=Ye[lt]=Ye[D]=Ye[ae]=Ye[Fe]=Ye[ve]=Ye[Pe]=Ye[ee]=Ye[ce]=Ye[fe]=Ye[ye]=Ye[pt]=!1;var $e={};$e[Ee]=$e[He]=$e[at]=$e[lt]=$e[Be]=$e[D]=$e[Pn]=$e[Gn]=$e[cr]=$e[rn]=$e[zn]=$e[ve]=$e[Pe]=$e[ee]=$e[ce]=$e[fe]=$e[ye]=$e[xe]=$e[U]=$e[me]=$e[It]=$e[ur]=!0,$e[ae]=$e[Fe]=$e[pt]=!1;var Md={À:"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"},Dd={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Od={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Bd={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Fd=parseFloat,Ud=parseInt,xa=typeof Ps=="object"&&Ps&&Ps.Object===Object&&Ps,Wd=typeof self=="object"&&self&&self.Object===Object&&self,dt=xa||Wd||Function("return this")(),ci=n&&!n.nodeType&&n,jn=ci&&!0&&i&&!i.nodeType&&i,va=jn&&jn.exports===ci,ui=va&&xa.process,Lt=(function(){try{var T=jn&&jn.require&&jn.require("util").types;return T||ui&&ui.binding&&ui.binding("util")}catch{}})(),ba=Lt&&Lt.isArrayBuffer,ya=Lt&&Lt.isDate,wa=Lt&&Lt.isMap,Ea=Lt&&Lt.isRegExp,Sa=Lt&&Lt.isSet,Na=Lt&&Lt.isTypedArray;function Tt(T,O,L){switch(L.length){case 0:return T.call(O);case 1:return T.call(O,L[0]);case 2:return T.call(O,L[0],L[1]);case 3:return T.call(O,L[0],L[1],L[2])}return T.apply(O,L)}function Hd(T,O,L,se){for(var Ne=-1,Ue=T==null?0:T.length;++Ne<Ue;){var ct=T[Ne];O(se,ct,L(ct),T)}return se}function Mt(T,O){for(var L=-1,se=T==null?0:T.length;++L<se&&O(T[L],L,T)!==!1;);return T}function Gd(T,O){for(var L=T==null?0:T.length;L--&&O(T[L],L,T)!==!1;);return T}function Ca(T,O){for(var L=-1,se=T==null?0:T.length;++L<se;)if(!O(T[L],L,T))return!1;return!0}function xn(T,O){for(var L=-1,se=T==null?0:T.length,Ne=0,Ue=[];++L<se;){var ct=T[L];O(ct,L,T)&&(Ue[Ne++]=ct)}return Ue}function $r(T,O){var L=T==null?0:T.length;return!!L&&$n(T,O,0)>-1}function fi(T,O,L){for(var se=-1,Ne=T==null?0:T.length;++se<Ne;)if(L(O,T[se]))return!0;return!1}function Ke(T,O){for(var L=-1,se=T==null?0:T.length,Ne=Array(se);++L<se;)Ne[L]=O(T[L],L,T);return Ne}function vn(T,O){for(var L=-1,se=O.length,Ne=T.length;++L<se;)T[Ne+L]=O[L];return T}function di(T,O,L,se){var Ne=-1,Ue=T==null?0:T.length;for(se&&Ue&&(L=T[++Ne]);++Ne<Ue;)L=O(L,T[Ne],Ne,T);return L}function zd(T,O,L,se){var Ne=T==null?0:T.length;for(se&&Ne&&(L=T[--Ne]);Ne--;)L=O(L,T[Ne],Ne,T);return L}function hi(T,O){for(var L=-1,se=T==null?0:T.length;++L<se;)if(O(T[L],L,T))return!0;return!1}var qd=pi("length");function $d(T){return T.split("")}function Xd(T){return T.match(td)||[]}function Ta(T,O,L){var se;return L(T,function(Ne,Ue,ct){if(O(Ne,Ue,ct))return se=Ue,!1}),se}function Xr(T,O,L,se){for(var Ne=T.length,Ue=L+(se?1:-1);se?Ue--:++Ue<Ne;)if(O(T[Ue],Ue,T))return Ue;return-1}function $n(T,O,L){return O===O?ih(T,O,L):Xr(T,Ra,L)}function Yd(T,O,L,se){for(var Ne=L-1,Ue=T.length;++Ne<Ue;)if(se(T[Ne],O))return Ne;return-1}function Ra(T){return T!==T}function ka(T,O){var L=T==null?0:T.length;return L?gi(T,O)/L:$}function pi(T){return function(O){return O==null?r:O[T]}}function mi(T){return function(O){return T==null?r:T[O]}}function Aa(T,O,L,se,Ne){return Ne(T,function(Ue,ct,qe){L=se?(se=!1,Ue):O(L,Ue,ct,qe)}),L}function Vd(T,O){var L=T.length;for(T.sort(O);L--;)T[L]=T[L].value;return T}function gi(T,O){for(var L,se=-1,Ne=T.length;++se<Ne;){var Ue=O(T[se]);Ue!==r&&(L=L===r?Ue:L+Ue)}return L}function _i(T,O){for(var L=-1,se=Array(T);++L<T;)se[L]=O(L);return se}function Kd(T,O){return Ke(O,function(L){return[L,T[L]]})}function Pa(T){return T&&T.slice(0,Ma(T)+1).replace(ri,"")}function Rt(T){return function(O){return T(O)}}function xi(T,O){return Ke(O,function(L){return T[L]})}function fr(T,O){return T.has(O)}function ja(T,O){for(var L=-1,se=T.length;++L<se&&$n(O,T[L],0)>-1;);return L}function Ia(T,O){for(var L=T.length;L--&&$n(O,T[L],0)>-1;);return L}function Qd(T,O){for(var L=T.length,se=0;L--;)T[L]===O&&++se;return se}var Jd=mi(Md),Zd=mi(Dd);function eh(T){return"\\"+Bd[T]}function th(T,O){return T==null?r:T[O]}function Xn(T){return Pd.test(T)}function nh(T){return jd.test(T)}function rh(T){for(var O,L=[];!(O=T.next()).done;)L.push(O.value);return L}function vi(T){var O=-1,L=Array(T.size);return T.forEach(function(se,Ne){L[++O]=[Ne,se]}),L}function La(T,O){return function(L){return T(O(L))}}function bn(T,O){for(var L=-1,se=T.length,Ne=0,Ue=[];++L<se;){var ct=T[L];(ct===O||ct===p)&&(T[L]=p,Ue[Ne++]=L)}return Ue}function Yr(T){var O=-1,L=Array(T.size);return T.forEach(function(se){L[++O]=se}),L}function sh(T){var O=-1,L=Array(T.size);return T.forEach(function(se){L[++O]=[se,se]}),L}function ih(T,O,L){for(var se=L-1,Ne=T.length;++se<Ne;)if(T[se]===O)return se;return-1}function oh(T,O,L){for(var se=L+1;se--;)if(T[se]===O)return se;return se}function Yn(T){return Xn(T)?lh(T):qd(T)}function zt(T){return Xn(T)?ch(T):$d(T)}function Ma(T){for(var O=T.length;O--&&Qf.test(T.charAt(O)););return O}var ah=mi(Od);function lh(T){for(var O=li.lastIndex=0;li.test(T);)++O;return O}function ch(T){return T.match(li)||[]}function uh(T){return T.match(Ad)||[]}var fh=(function T(O){O=O==null?dt:Vn.defaults(dt.Object(),O,Vn.pick(dt,Id));var L=O.Array,se=O.Date,Ne=O.Error,Ue=O.Function,ct=O.Math,qe=O.Object,bi=O.RegExp,dh=O.String,Dt=O.TypeError,Vr=L.prototype,hh=Ue.prototype,Kn=qe.prototype,Kr=O["__core-js_shared__"],Qr=hh.toString,Ge=Kn.hasOwnProperty,ph=0,Da=(function(){var e=/[^.]+$/.exec(Kr&&Kr.keys&&Kr.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})(),Jr=Kn.toString,mh=Qr.call(qe),gh=dt._,_h=bi("^"+Qr.call(Ge).replace(ni,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Zr=va?O.Buffer:r,yn=O.Symbol,es=O.Uint8Array,Oa=Zr?Zr.allocUnsafe:r,ts=La(qe.getPrototypeOf,qe),Ba=qe.create,Fa=Kn.propertyIsEnumerable,ns=Vr.splice,Ua=yn?yn.isConcatSpreadable:r,dr=yn?yn.iterator:r,In=yn?yn.toStringTag:r,rs=(function(){try{var e=Bn(qe,"defineProperty");return e({},"",{}),e}catch{}})(),xh=O.clearTimeout!==dt.clearTimeout&&O.clearTimeout,vh=se&&se.now!==dt.Date.now&&se.now,bh=O.setTimeout!==dt.setTimeout&&O.setTimeout,ss=ct.ceil,is=ct.floor,yi=qe.getOwnPropertySymbols,yh=Zr?Zr.isBuffer:r,Wa=O.isFinite,wh=Vr.join,Eh=La(qe.keys,qe),ut=ct.max,mt=ct.min,Sh=se.now,Nh=O.parseInt,Ha=ct.random,Ch=Vr.reverse,wi=Bn(O,"DataView"),hr=Bn(O,"Map"),Ei=Bn(O,"Promise"),Qn=Bn(O,"Set"),pr=Bn(O,"WeakMap"),mr=Bn(qe,"create"),os=pr&&new pr,Jn={},Th=Fn(wi),Rh=Fn(hr),kh=Fn(Ei),Ah=Fn(Qn),Ph=Fn(pr),as=yn?yn.prototype:r,gr=as?as.valueOf:r,Ga=as?as.toString:r;function m(e){if(Ze(e)&&!Te(e)&&!(e instanceof Le)){if(e instanceof Ot)return e;if(Ge.call(e,"__wrapped__"))return zl(e)}return new Ot(e)}var Zn=(function(){function e(){}return function(t){if(!Je(t))return{};if(Ba)return Ba(t);e.prototype=t;var s=new e;return e.prototype=r,s}})();function ls(){}function Ot(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}m.templateSettings={escape:qf,evaluate:$f,interpolate:Jo,variable:"",imports:{_:m}},m.prototype=ls.prototype,m.prototype.constructor=m,Ot.prototype=Zn(ls.prototype),Ot.prototype.constructor=Ot;function Le(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=J,this.__views__=[]}function jh(){var e=new Le(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 Ih(){if(this.__filtered__){var e=new Le(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Lh(){var e=this.__wrapped__.value(),t=this.__dir__,s=Te(e),c=t<0,f=s?e.length:0,_=$p(0,f,this.__views__),y=_.start,S=_.end,A=S-y,W=c?S:y-1,H=this.__iteratees__,V=H.length,te=0,oe=mt(A,this.__takeCount__);if(!s||!c&&f==A&&oe==A)return hl(e,this.__actions__);var ge=[];e:for(;A--&&te<oe;){W+=t;for(var ke=-1,_e=e[W];++ke<V;){var je=H[ke],De=je.iteratee,Pt=je.type,yt=De(_e);if(Pt==q)_e=yt;else if(!yt){if(Pt==Y)continue e;break e}}ge[te++]=_e}return ge}Le.prototype=Zn(ls.prototype),Le.prototype.constructor=Le;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 Mh(){this.__data__=mr?mr(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(mr){var s=t[e];return s===h?r:s}return Ge.call(t,e)?t[e]:r}function Bh(e){var t=this.__data__;return mr?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]=mr&&t===r?h:t,this}Ln.prototype.clear=Mh,Ln.prototype.delete=Dh,Ln.prototype.get=Oh,Ln.prototype.has=Bh,Ln.prototype.set=Fh;function sn(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=cs(t,e);if(s<0)return!1;var c=t.length-1;return s==c?t.pop():ns.call(t,s,1),--this.size,!0}function Hh(e){var t=this.__data__,s=cs(t,e);return s<0?r:t[s][1]}function Gh(e){return cs(this.__data__,e)>-1}function zh(e,t){var s=this.__data__,c=cs(s,e);return c<0?(++this.size,s.push([e,t])):s[c][1]=t,this}sn.prototype.clear=Uh,sn.prototype.delete=Wh,sn.prototype.get=Hh,sn.prototype.has=Gh,sn.prototype.set=zh;function on(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(hr||sn),string:new Ln}}function $h(e){var t=ys(this,e).delete(e);return this.size-=t?1:0,t}function Xh(e){return ys(this,e).get(e)}function Yh(e){return ys(this,e).has(e)}function Vh(e,t){var s=ys(this,e),c=s.size;return s.set(e,t),this.size+=s.size==c?0:1,this}on.prototype.clear=qh,on.prototype.delete=$h,on.prototype.get=Xh,on.prototype.has=Yh,on.prototype.set=Vh;function Mn(e){var t=-1,s=e==null?0:e.length;for(this.__data__=new on;++t<s;)this.add(e[t])}function Kh(e){return this.__data__.set(e,h),this}function Qh(e){return this.__data__.has(e)}Mn.prototype.add=Mn.prototype.push=Kh,Mn.prototype.has=Qh;function qt(e){var t=this.__data__=new sn(e);this.size=t.size}function Jh(){this.__data__=new sn,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 sn){var c=s.__data__;if(!hr||c.length<u-1)return c.push([e,t]),this.size=++s.size,this;s=this.__data__=new on(c)}return s.set(e,t),this.size=s.size,this}qt.prototype.clear=Jh,qt.prototype.delete=Zh,qt.prototype.get=ep,qt.prototype.has=tp,qt.prototype.set=np;function za(e,t){var s=Te(e),c=!s&&Un(e),f=!s&&!c&&Cn(e),_=!s&&!c&&!f&&rr(e),y=s||c||f||_,S=y?_i(e.length,dh):[],A=S.length;for(var W in e)(t||Ge.call(e,W))&&!(y&&(W=="length"||f&&(W=="offset"||W=="parent")||_&&(W=="buffer"||W=="byteLength"||W=="byteOffset")||un(W,A)))&&S.push(W);return S}function qa(e){var t=e.length;return t?e[Li(0,t-1)]:r}function rp(e,t){return ws(Et(e),Dn(t,0,e.length))}function sp(e){return ws(Et(e))}function Si(e,t,s){(s!==r&&!$t(e[t],s)||s===r&&!(t in e))&&an(e,t,s)}function _r(e,t,s){var c=e[t];(!(Ge.call(e,t)&&$t(c,s))||s===r&&!(t in e))&&an(e,t,s)}function cs(e,t){for(var s=e.length;s--;)if($t(e[s][0],t))return s;return-1}function ip(e,t,s,c){return wn(e,function(f,_,y){t(c,f,s(f),y)}),c}function $a(e,t){return e&&Qt(t,ft(t),e)}function op(e,t){return e&&Qt(t,Nt(t),e)}function an(e,t,s){t=="__proto__"&&rs?rs(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=L(c),_=e==null;++s<c;)f[s]=_?r:io(e,t[s]);return f}function Dn(e,t,s){return e===e&&(s!==r&&(e=e<=s?e:s),t!==r&&(e=e>=t?e:t)),e}function Bt(e,t,s,c,f,_){var y,S=t&x,A=t&b,W=t&E;if(s&&(y=f?s(e,c,f,_):s(e)),y!==r)return y;if(!Je(e))return e;var H=Te(e);if(H){if(y=Yp(e),!S)return Et(e,y)}else{var V=gt(e),te=V==Fe||V==tt;if(Cn(e))return gl(e,S);if(V==ee||V==Ee||te&&!f){if(y=A||te?{}:Ml(e),!S)return A?Op(e,op(y,e)):Dp(e,$a(y,e))}else{if(!$e[V])return f?e:{};y=Vp(e,V,S)}}_||(_=new qt);var oe=_.get(e);if(oe)return oe;_.set(e,y),uc(e)?e.forEach(function(_e){y.add(Bt(_e,t,s,_e,e,_))}):lc(e)&&e.forEach(function(_e,je){y.set(je,Bt(_e,t,s,je,e,_))});var ge=W?A?qi:zi:A?Nt:ft,ke=H?r:ge(e);return Mt(ke||e,function(_e,je){ke&&(je=_e,_e=e[je]),_r(y,je,Bt(_e,t,s,je,e,_))}),y}function ap(e){var t=ft(e);return function(s){return Xa(s,e,t)}}function Xa(e,t,s){var c=s.length;if(e==null)return!c;for(e=qe(e);c--;){var f=s[c],_=t[f],y=e[f];if(y===r&&!(f in e)||!_(y))return!1}return!0}function Ya(e,t,s){if(typeof e!="function")throw new Dt(d);return Sr(function(){e.apply(r,s)},t)}function xr(e,t,s,c){var f=-1,_=$r,y=!0,S=e.length,A=[],W=t.length;if(!S)return A;s&&(t=Ke(t,Rt(s))),c?(_=fi,y=!1):t.length>=u&&(_=fr,y=!1,t=new Mn(t));e:for(;++f<S;){var H=e[f],V=s==null?H:s(H);if(H=c||H!==0?H:0,y&&V===V){for(var te=W;te--;)if(t[te]===V)continue e;A.push(H)}else _(t,V,c)||A.push(H)}return A}var wn=yl(Kt),Va=yl(Ti,!0);function lp(e,t){var s=!0;return wn(e,function(c,f,_){return s=!!t(c,f,_),s}),s}function us(e,t,s){for(var c=-1,f=e.length;++c<f;){var _=e[c],y=t(_);if(y!=null&&(S===r?y===y&&!At(y):s(y,S)))var S=y,A=_}return A}function cp(e,t,s,c){var f=e.length;for(s=Re(s),s<0&&(s=-s>f?0:f+s),c=c===r||c>f?f:Re(c),c<0&&(c+=f),c=s>c?0:dc(c);s<c;)e[s++]=t;return e}function Ka(e,t){var s=[];return wn(e,function(c,f,_){t(c,f,_)&&s.push(c)}),s}function ht(e,t,s,c,f){var _=-1,y=e.length;for(s||(s=Qp),f||(f=[]);++_<y;){var S=e[_];t>0&&s(S)?t>1?ht(S,t-1,s,c,f):vn(f,S):c||(f[f.length]=S)}return f}var Ci=wl(),Qa=wl(!0);function Kt(e,t){return e&&Ci(e,t,ft)}function Ti(e,t){return e&&Qa(e,t,ft)}function fs(e,t){return xn(t,function(s){return fn(e[s])})}function On(e,t){t=Sn(t,e);for(var s=0,c=t.length;e!=null&&s<c;)e=e[Jt(t[s++])];return s&&s==c?e:r}function Ja(e,t,s){var c=t(e);return Te(e)?c:vn(c,s(e))}function vt(e){return e==null?e===r?Ve:Z: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 fp(e,t){return e!=null&&t in qe(e)}function dp(e,t,s){return e>=mt(t,s)&&e<ut(t,s)}function ki(e,t,s){for(var c=s?fi:$r,f=e[0].length,_=e.length,y=_,S=L(_),A=1/0,W=[];y--;){var H=e[y];y&&t&&(H=Ke(H,Rt(t))),A=mt(H.length,A),S[y]=!s&&(t||f>=120&&H.length>=120)?new Mn(y&&H):r}H=e[0];var V=-1,te=S[0];e:for(;++V<f&&W.length<A;){var oe=H[V],ge=t?t(oe):oe;if(oe=s||oe!==0?oe:0,!(te?fr(te,ge):c(W,ge,s))){for(y=_;--y;){var ke=S[y];if(!(ke?fr(ke,ge):c(e[y],ge,s)))continue e}te&&te.push(ge),W.push(oe)}}return W}function hp(e,t,s,c){return Kt(e,function(f,_,y){t(c,s(f),_,y)}),c}function vr(e,t,s){t=Sn(t,e),e=Fl(e,t);var c=e==null?e:e[Jt(Ut(t))];return c==null?r:Tt(c,e,s)}function Za(e){return Ze(e)&&vt(e)==Ee}function pp(e){return Ze(e)&&vt(e)==at}function mp(e){return Ze(e)&&vt(e)==D}function br(e,t,s,c,f){return e===t?!0:e==null||t==null||!Ze(e)&&!Ze(t)?e!==e&&t!==t:gp(e,t,s,c,br,f)}function gp(e,t,s,c,f,_){var y=Te(e),S=Te(t),A=y?He:gt(e),W=S?He:gt(t);A=A==Ee?ee:A,W=W==Ee?ee:W;var H=A==ee,V=W==ee,te=A==W;if(te&&Cn(e)){if(!Cn(t))return!1;y=!0,H=!1}if(te&&!H)return _||(_=new qt),y||rr(e)?jl(e,t,s,c,f,_):Gp(e,t,A,s,c,f,_);if(!(s&N)){var oe=H&&Ge.call(e,"__wrapped__"),ge=V&&Ge.call(t,"__wrapped__");if(oe||ge){var ke=oe?e.value():e,_e=ge?t.value():t;return _||(_=new qt),f(ke,_e,s,c,_)}}return te?(_||(_=new qt),zp(e,t,s,c,f,_)):!1}function _p(e){return Ze(e)&&gt(e)==ve}function Ai(e,t,s,c){var f=s.length,_=f,y=!c;if(e==null)return!_;for(e=qe(e);f--;){var S=s[f];if(y&&S[2]?S[1]!==e[S[0]]:!(S[0]in e))return!1}for(;++f<_;){S=s[f];var A=S[0],W=e[A],H=S[1];if(y&&S[2]){if(W===r&&!(A in e))return!1}else{var V=new qt;if(c)var te=c(W,H,A,e,t,V);if(!(te===r?br(H,W,N|j,c,V):te))return!1}}return!0}function el(e){if(!Je(e)||Zp(e))return!1;var t=fn(e)?_h:ad;return t.test(Fn(e))}function xp(e){return Ze(e)&&vt(e)==ce}function vp(e){return Ze(e)&&gt(e)==fe}function bp(e){return Ze(e)&&Rs(e.length)&&!!Ye[vt(e)]}function tl(e){return typeof e=="function"?e:e==null?Ct:typeof e=="object"?Te(e)?sl(e[0],e[1]):rl(e):Ec(e)}function Pi(e){if(!Er(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(!Je(e))return rm(e);var t=Er(e),s=[];for(var c in e)c=="constructor"&&(t||!Ge.call(e,c))||s.push(c);return s}function ji(e,t){return e<t}function nl(e,t){var s=-1,c=St(e)?L(e.length):[];return wn(e,function(f,_,y){c[++s]=t(f,_,y)}),c}function rl(e){var t=Xi(e);return t.length==1&&t[0][2]?Ol(t[0][0],t[0][1]):function(s){return s===e||Ai(s,e,t)}}function sl(e,t){return Vi(e)&&Dl(t)?Ol(Jt(e),t):function(s){var c=io(s,e);return c===r&&c===t?oo(s,e):br(t,c,N|j)}}function ds(e,t,s,c,f){e!==t&&Ci(t,function(_,y){if(f||(f=new qt),Je(_))wp(e,t,y,s,ds,c,f);else{var S=c?c(Qi(e,y),_,y+"",e,t,f):r;S===r&&(S=_),Si(e,y,S)}},Nt)}function wp(e,t,s,c,f,_,y){var S=Qi(e,s),A=Qi(t,s),W=y.get(A);if(W){Si(e,s,W);return}var H=_?_(S,A,s+"",e,t,y):r,V=H===r;if(V){var te=Te(A),oe=!te&&Cn(A),ge=!te&&!oe&&rr(A);H=A,te||oe||ge?Te(S)?H=S:nt(S)?H=Et(S):oe?(V=!1,H=gl(A,!0)):ge?(V=!1,H=_l(A,!0)):H=[]:Nr(A)||Un(A)?(H=S,Un(S)?H=hc(S):(!Je(S)||fn(S))&&(H=Ml(A))):V=!1}V&&(y.set(A,H),f(H,A,c,_,y),y.delete(A)),Si(e,s,H)}function il(e,t){var s=e.length;if(s)return t+=t<0?s:0,un(t,s)?e[t]:r}function ol(e,t,s){t.length?t=Ke(t,function(_){return Te(_)?function(y){return On(y,_.length===1?_[0]:_)}:_}):t=[Ct];var c=-1;t=Ke(t,Rt(he()));var f=nl(e,function(_,y,S){var A=Ke(t,function(W){return W(_)});return{criteria:A,index:++c,value:_}});return Vd(f,function(_,y){return Mp(_,y,s)})}function Ep(e,t){return al(e,t,function(s,c){return oo(e,c)})}function al(e,t,s){for(var c=-1,f=t.length,_={};++c<f;){var y=t[c],S=On(e,y);s(S,y)&&yr(_,Sn(y,e),S)}return _}function Sp(e){return function(t){return On(t,e)}}function Ii(e,t,s,c){var f=c?Yd:$n,_=-1,y=t.length,S=e;for(e===t&&(t=Et(t)),s&&(S=Ke(e,Rt(s)));++_<y;)for(var A=0,W=t[_],H=s?s(W):W;(A=f(S,H,A,c))>-1;)S!==e&&ns.call(S,A,1),ns.call(e,A,1);return e}function ll(e,t){for(var s=e?t.length:0,c=s-1;s--;){var f=t[s];if(s==c||f!==_){var _=f;un(f)?ns.call(e,f,1):Oi(e,f)}}return e}function Li(e,t){return e+is(Ha()*(t-e+1))}function Np(e,t,s,c){for(var f=-1,_=ut(ss((t-e)/(s||1)),0),y=L(_);_--;)y[c?_:++f]=e,e+=s;return y}function Mi(e,t){var s="";if(!e||t<1||t>le)return s;do t%2&&(s+=e),t=is(t/2),t&&(e+=e);while(t);return s}function Ae(e,t){return Ji(Bl(e,t,Ct),e+"")}function Cp(e){return qa(sr(e))}function Tp(e,t){var s=sr(e);return ws(s,Dn(t,0,s.length))}function yr(e,t,s,c){if(!Je(e))return e;t=Sn(t,e);for(var f=-1,_=t.length,y=_-1,S=e;S!=null&&++f<_;){var A=Jt(t[f]),W=s;if(A==="__proto__"||A==="constructor"||A==="prototype")return e;if(f!=y){var H=S[A];W=c?c(H,A,S):r,W===r&&(W=Je(H)?H:un(t[f+1])?[]:{})}_r(S,A,W),S=S[A]}return e}var cl=os?function(e,t){return os.set(e,t),e}:Ct,Rp=rs?function(e,t){return rs(e,"toString",{configurable:!0,enumerable:!1,value:lo(t),writable:!0})}:Ct;function kp(e){return ws(sr(e))}function Ft(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 _=L(f);++c<f;)_[c]=e[c+t];return _}function Ap(e,t){var s;return wn(e,function(c,f,_){return s=t(c,f,_),!s}),!!s}function hs(e,t,s){var c=0,f=e==null?c:e.length;if(typeof t=="number"&&t===t&&f<=ne){for(;c<f;){var _=c+f>>>1,y=e[_];y!==null&&!At(y)&&(s?y<=t:y<t)?c=_+1:f=_}return f}return Di(e,t,Ct,s)}function Di(e,t,s,c){var f=0,_=e==null?0:e.length;if(_===0)return 0;t=s(t);for(var y=t!==t,S=t===null,A=At(t),W=t===r;f<_;){var H=is((f+_)/2),V=s(e[H]),te=V!==r,oe=V===null,ge=V===V,ke=At(V);if(y)var _e=c||ge;else W?_e=ge&&(c||te):S?_e=ge&&te&&(c||!oe):A?_e=ge&&te&&!oe&&(c||!ke):oe||ke?_e=!1:_e=c?V<=t:V<t;_e?f=H+1:_=H}return mt(_,ue)}function ul(e,t){for(var s=-1,c=e.length,f=0,_=[];++s<c;){var y=e[s],S=t?t(y):y;if(!s||!$t(S,A)){var A=S;_[f++]=y===0?0:y}}return _}function fl(e){return typeof e=="number"?e:At(e)?$:+e}function kt(e){if(typeof e=="string")return e;if(Te(e))return Ke(e,kt)+"";if(At(e))return Ga?Ga.call(e):"";var t=e+"";return t=="0"&&1/e==-ie?"-0":t}function En(e,t,s){var c=-1,f=$r,_=e.length,y=!0,S=[],A=S;if(s)y=!1,f=fi;else if(_>=u){var W=t?null:Wp(e);if(W)return Yr(W);y=!1,f=fr,A=new Mn}else A=t?[]:S;e:for(;++c<_;){var H=e[c],V=t?t(H):H;if(H=s||H!==0?H:0,y&&V===V){for(var te=A.length;te--;)if(A[te]===V)continue e;t&&A.push(V),S.push(H)}else f(A,V,s)||(A!==S&&A.push(V),S.push(H))}return S}function Oi(e,t){return t=Sn(t,e),e=Fl(e,t),e==null||delete e[Jt(Ut(t))]}function dl(e,t,s,c){return yr(e,t,s(On(e,t)),c)}function ps(e,t,s,c){for(var f=e.length,_=c?f:-1;(c?_--:++_<f)&&t(e[_],_,e););return s?Ft(e,c?0:_,c?_+1:f):Ft(e,c?_+1:0,c?f:_)}function hl(e,t){var s=e;return s instanceof Le&&(s=s.value()),di(t,function(c,f){return f.func.apply(f.thisArg,vn([c],f.args))},s)}function Bi(e,t,s){var c=e.length;if(c<2)return c?En(e[0]):[];for(var f=-1,_=L(c);++f<c;)for(var y=e[f],S=-1;++S<c;)S!=f&&(_[f]=xr(_[f]||y,e[S],t,s));return En(ht(_,1),t,s)}function pl(e,t,s){for(var c=-1,f=e.length,_=t.length,y={};++c<f;){var S=c<_?t[c]:r;s(y,e[c],S)}return y}function Fi(e){return nt(e)?e:[]}function Ui(e){return typeof e=="function"?e:Ct}function Sn(e,t){return Te(e)?e:Vi(e,t)?[e]:Gl(We(e))}var Pp=Ae;function Nn(e,t,s){var c=e.length;return s=s===r?c:s,!t&&s>=c?e:Ft(e,t,s)}var ml=xh||function(e){return dt.clearTimeout(e)};function gl(e,t){if(t)return e.slice();var s=e.length,c=Oa?Oa(s):new e.constructor(s);return e.copy(c),c}function Wi(e){var t=new e.constructor(e.byteLength);return new es(t).set(new es(e)),t}function jp(e,t){var s=t?Wi(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.byteLength)}function Ip(e){var t=new e.constructor(e.source,Zo.exec(e));return t.lastIndex=e.lastIndex,t}function Lp(e){return gr?qe(gr.call(e)):{}}function _l(e,t){var s=t?Wi(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.length)}function xl(e,t){if(e!==t){var s=e!==r,c=e===null,f=e===e,_=At(e),y=t!==r,S=t===null,A=t===t,W=At(t);if(!S&&!W&&!_&&e>t||_&&y&&A&&!S&&!W||c&&y&&A||!s&&A||!f)return 1;if(!c&&!_&&!W&&e<t||W&&s&&f&&!c&&!_||S&&s&&f||!y&&f||!A)return-1}return 0}function Mp(e,t,s){for(var c=-1,f=e.criteria,_=t.criteria,y=f.length,S=s.length;++c<y;){var A=xl(f[c],_[c]);if(A){if(c>=S)return A;var W=s[c];return A*(W=="desc"?-1:1)}}return e.index-t.index}function vl(e,t,s,c){for(var f=-1,_=e.length,y=s.length,S=-1,A=t.length,W=ut(_-y,0),H=L(A+W),V=!c;++S<A;)H[S]=t[S];for(;++f<y;)(V||f<_)&&(H[s[f]]=e[f]);for(;W--;)H[S++]=e[f++];return H}function bl(e,t,s,c){for(var f=-1,_=e.length,y=-1,S=s.length,A=-1,W=t.length,H=ut(_-S,0),V=L(H+W),te=!c;++f<H;)V[f]=e[f];for(var oe=f;++A<W;)V[oe+A]=t[A];for(;++y<S;)(te||f<_)&&(V[oe+s[y]]=e[f++]);return V}function Et(e,t){var s=-1,c=e.length;for(t||(t=L(c));++s<c;)t[s]=e[s];return t}function Qt(e,t,s,c){var f=!s;s||(s={});for(var _=-1,y=t.length;++_<y;){var S=t[_],A=c?c(s[S],e[S],S,s,e):r;A===r&&(A=e[S]),f?an(s,S,A):_r(s,S,A)}return s}function Dp(e,t){return Qt(e,Yi(e),t)}function Op(e,t){return Qt(e,Il(e),t)}function ms(e,t){return function(s,c){var f=Te(s)?Hd:ip,_=t?t():{};return f(s,e,he(c,2),_)}}function er(e){return Ae(function(t,s){var c=-1,f=s.length,_=f>1?s[f-1]:r,y=f>2?s[2]:r;for(_=e.length>3&&typeof _=="function"?(f--,_):r,y&&bt(s[0],s[1],y)&&(_=f<3?r:_,f=1),t=qe(t);++c<f;){var S=s[c];S&&e(t,S,c,_)}return t})}function yl(e,t){return function(s,c){if(s==null)return s;if(!St(s))return e(s,c);for(var f=s.length,_=t?f:-1,y=qe(s);(t?_--:++_<f)&&c(y[_],_,y)!==!1;);return s}}function wl(e){return function(t,s,c){for(var f=-1,_=qe(t),y=c(t),S=y.length;S--;){var A=y[e?S:++f];if(s(_[A],A,_)===!1)break}return t}}function Bp(e,t,s){var c=t&R,f=wr(e);function _(){var y=this&&this!==dt&&this instanceof _?f:e;return y.apply(c?s:this,arguments)}return _}function El(e){return function(t){t=We(t);var s=Xn(t)?zt(t):r,c=s?s[0]:t.charAt(0),f=s?Nn(s,1).join(""):t.slice(1);return c[e]()+f}}function tr(e){return function(t){return di(yc(bc(t).replace(Rd,"")),e,"")}}function wr(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=Zn(e.prototype),c=e.apply(s,t);return Je(c)?c:s}}function Fp(e,t,s){var c=wr(e);function f(){for(var _=arguments.length,y=L(_),S=_,A=nr(f);S--;)y[S]=arguments[S];var W=_<3&&y[0]!==A&&y[_-1]!==A?[]:bn(y,A);if(_-=W.length,_<s)return Rl(e,t,gs,f.placeholder,r,y,W,r,r,s-_);var H=this&&this!==dt&&this instanceof f?c:e;return Tt(H,this,y)}return f}function Sl(e){return function(t,s,c){var f=qe(t);if(!St(t)){var _=he(s,3);t=ft(t),s=function(S){return _(f[S],S,f)}}var y=e(t,s,c);return y>-1?f[_?t[y]:y]:r}}function Nl(e){return cn(function(t){var s=t.length,c=s,f=Ot.prototype.thru;for(e&&t.reverse();c--;){var _=t[c];if(typeof _!="function")throw new Dt(d);if(f&&!y&&bs(_)=="wrapper")var y=new Ot([],!0)}for(c=y?c:s;++c<s;){_=t[c];var S=bs(_),A=S=="wrapper"?$i(_):r;A&&Ki(A[0])&&A[1]==(X|I|G|z)&&!A[4].length&&A[9]==1?y=y[bs(A[0])].apply(y,A[3]):y=_.length==1&&Ki(_)?y[S]():y.thru(_)}return function(){var W=arguments,H=W[0];if(y&&W.length==1&&Te(H))return y.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 gs(e,t,s,c,f,_,y,S,A,W){var H=t&X,V=t&R,te=t&M,oe=t&(I|P),ge=t&F,ke=te?r:wr(e);function _e(){for(var je=arguments.length,De=L(je),Pt=je;Pt--;)De[Pt]=arguments[Pt];if(oe)var yt=nr(_e),jt=Qd(De,yt);if(c&&(De=vl(De,c,f,oe)),_&&(De=bl(De,_,y,oe)),je-=jt,oe&&je<W){var rt=bn(De,yt);return Rl(e,t,gs,_e.placeholder,s,De,rt,S,A,W-je)}var Xt=V?s:this,hn=te?Xt[e]:e;return je=De.length,S?De=im(De,S):ge&&je>1&&De.reverse(),H&&A<je&&(De.length=A),this&&this!==dt&&this instanceof _e&&(hn=ke||wr(hn)),hn.apply(Xt,De)}return _e}function Cl(e,t){return function(s,c){return hp(s,e,t(c),{})}}function _s(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=fl(s),c=fl(c)),f=e(s,c)}return f}}function Hi(e){return cn(function(t){return t=Ke(t,Rt(he())),Ae(function(s){var c=this;return e(t,function(f){return Tt(f,c,s)})})})}function xs(e,t){t=t===r?" ":kt(t);var s=t.length;if(s<2)return s?Mi(t,e):t;var c=Mi(t,ss(e/Yn(t)));return Xn(t)?Nn(zt(c),0,e).join(""):c.slice(0,e)}function Up(e,t,s,c){var f=t&R,_=wr(e);function y(){for(var S=-1,A=arguments.length,W=-1,H=c.length,V=L(H+A),te=this&&this!==dt&&this instanceof y?_:e;++W<H;)V[W]=c[W];for(;A--;)V[W++]=arguments[++S];return Tt(te,f?s:this,V)}return y}function Tl(e){return function(t,s,c){return c&&typeof c!="number"&&bt(t,s,c)&&(s=c=r),t=dn(t),s===r?(s=t,t=0):s=dn(s),c=c===r?t<s?1:-1:dn(c),Np(t,s,c,e)}}function vs(e){return function(t,s){return typeof t=="string"&&typeof s=="string"||(t=Wt(t),s=Wt(s)),e(t,s)}}function Rl(e,t,s,c,f,_,y,S,A,W){var H=t&I,V=H?y:r,te=H?r:y,oe=H?_:r,ge=H?r:_;t|=H?G:Q,t&=~(H?Q:G),t&B||(t&=-4);var ke=[e,t,f,oe,V,ge,te,S,A,W],_e=s.apply(r,ke);return Ki(e)&&Ul(_e,ke),_e.placeholder=c,Wl(_e,e,t)}function Gi(e){var t=ct[e];return function(s,c){if(s=Wt(s),c=c==null?0:mt(Re(c),292),c&&Wa(s)){var f=(We(s)+"e").split("e"),_=t(f[0]+"e"+(+f[1]+c));return f=(We(_)+"e").split("e"),+(f[0]+"e"+(+f[1]-c))}return t(s)}}var Wp=Qn&&1/Yr(new Qn([,-0]))[1]==ie?function(e){return new Qn(e)}:fo;function kl(e){return function(t){var s=gt(t);return s==ve?vi(t):s==fe?sh(t):Kd(t,e(t))}}function ln(e,t,s,c,f,_,y,S){var A=t&M;if(!A&&typeof e!="function")throw new Dt(d);var W=c?c.length:0;if(W||(t&=-97,c=f=r),y=y===r?y:ut(Re(y),0),S=S===r?S:Re(S),W-=f?f.length:0,t&Q){var H=c,V=f;c=f=r}var te=A?r:$i(e),oe=[e,t,s,c,f,H,V,_,y,S];if(te&&nm(oe,te),e=oe[0],t=oe[1],s=oe[2],c=oe[3],f=oe[4],S=oe[9]=oe[9]===r?A?0:e.length:ut(oe[9]-W,0),!S&&t&(I|P)&&(t&=-25),!t||t==R)var ge=Bp(e,t,s);else t==I||t==P?ge=Fp(e,t,S):(t==G||t==(R|G))&&!f.length?ge=Up(e,t,s,c):ge=gs.apply(r,oe);var ke=te?cl:Ul;return Wl(ke(ge,oe),e,t)}function Al(e,t,s,c){return e===r||$t(e,Kn[s])&&!Ge.call(c,s)?t:e}function Pl(e,t,s,c,f,_){return Je(e)&&Je(t)&&(_.set(t,e),ds(e,t,r,Pl,_),_.delete(t)),e}function Hp(e){return Nr(e)?r:e}function jl(e,t,s,c,f,_){var y=s&N,S=e.length,A=t.length;if(S!=A&&!(y&&A>S))return!1;var W=_.get(e),H=_.get(t);if(W&&H)return W==t&&H==e;var V=-1,te=!0,oe=s&j?new Mn:r;for(_.set(e,t),_.set(t,e);++V<S;){var ge=e[V],ke=t[V];if(c)var _e=y?c(ke,ge,V,t,e,_):c(ge,ke,V,e,t,_);if(_e!==r){if(_e)continue;te=!1;break}if(oe){if(!hi(t,function(je,De){if(!fr(oe,De)&&(ge===je||f(ge,je,s,c,_)))return oe.push(De)})){te=!1;break}}else if(!(ge===ke||f(ge,ke,s,c,_))){te=!1;break}}return _.delete(e),_.delete(t),te}function Gp(e,t,s,c,f,_,y){switch(s){case lt:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case at:return!(e.byteLength!=t.byteLength||!_(new es(e),new es(t)));case Be:case D:case Pe:return $t(+e,+t);case ae:return e.name==t.name&&e.message==t.message;case ce:case ye:return e==t+"";case ve:var S=vi;case fe:var A=c&N;if(S||(S=Yr),e.size!=t.size&&!A)return!1;var W=y.get(e);if(W)return W==t;c|=j,y.set(e,t);var H=jl(S(e),S(t),c,f,_,y);return y.delete(e),H;case xe:if(gr)return gr.call(e)==gr.call(t)}return!1}function zp(e,t,s,c,f,_){var y=s&N,S=zi(e),A=S.length,W=zi(t),H=W.length;if(A!=H&&!y)return!1;for(var V=A;V--;){var te=S[V];if(!(y?te in t:Ge.call(t,te)))return!1}var oe=_.get(e),ge=_.get(t);if(oe&&ge)return oe==t&&ge==e;var ke=!0;_.set(e,t),_.set(t,e);for(var _e=y;++V<A;){te=S[V];var je=e[te],De=t[te];if(c)var Pt=y?c(De,je,te,t,e,_):c(je,De,te,e,t,_);if(!(Pt===r?je===De||f(je,De,s,c,_):Pt)){ke=!1;break}_e||(_e=te=="constructor")}if(ke&&!_e){var yt=e.constructor,jt=t.constructor;yt!=jt&&"constructor"in e&&"constructor"in t&&!(typeof yt=="function"&&yt instanceof yt&&typeof jt=="function"&&jt instanceof jt)&&(ke=!1)}return _.delete(e),_.delete(t),ke}function cn(e){return Ji(Bl(e,r,Xl),e+"")}function zi(e){return Ja(e,ft,Yi)}function qi(e){return Ja(e,Nt,Il)}var $i=os?function(e){return os.get(e)}:fo;function bs(e){for(var t=e.name+"",s=Jn[t],c=Ge.call(Jn,t)?s.length:0;c--;){var f=s[c],_=f.func;if(_==null||_==e)return f.name}return t}function nr(e){var t=Ge.call(m,"placeholder")?m:e;return t.placeholder}function he(){var e=m.iteratee||co;return e=e===co?tl:e,arguments.length?e(arguments[0],arguments[1]):e}function ys(e,t){var s=e.__data__;return Jp(t)?s[typeof t=="string"?"string":"hash"]:s.map}function Xi(e){for(var t=ft(e),s=t.length;s--;){var c=t[s],f=e[c];t[s]=[c,f,Dl(f)]}return t}function Bn(e,t){var s=th(e,t);return el(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=Jr.call(e);return c&&(t?e[In]=s:delete e[In]),f}var Yi=yi?function(e){return e==null?[]:(e=qe(e),xn(yi(e),function(t){return Fa.call(e,t)}))}:ho,Il=yi?function(e){for(var t=[];e;)vn(t,Yi(e)),e=ts(e);return t}:ho,gt=vt;(wi&&gt(new wi(new ArrayBuffer(1)))!=lt||hr&&gt(new hr)!=ve||Ei&&gt(Ei.resolve())!=de||Qn&&gt(new Qn)!=fe||pr&&gt(new pr)!=pt)&&(gt=function(e){var t=vt(e),s=t==ee?e.constructor:r,c=s?Fn(s):"";if(c)switch(c){case Th:return lt;case Rh:return ve;case kh:return de;case Ah:return fe;case Ph:return pt}return t});function $p(e,t,s){for(var c=-1,f=s.length;++c<f;){var _=s[c],y=_.size;switch(_.type){case"drop":e+=y;break;case"dropRight":t-=y;break;case"take":t=mt(t,e+y);break;case"takeRight":e=ut(e,t-y);break}}return{start:e,end:t}}function Xp(e){var t=e.match(Zf);return t?t[1].split(ed):[]}function Ll(e,t,s){t=Sn(t,e);for(var c=-1,f=t.length,_=!1;++c<f;){var y=Jt(t[c]);if(!(_=e!=null&&s(e,y)))break;e=e[y]}return _||++c!=f?_:(f=e==null?0:e.length,!!f&&Rs(f)&&un(y,f)&&(Te(e)||Un(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 Ml(e){return typeof e.constructor=="function"&&!Er(e)?Zn(ts(e)):{}}function Vp(e,t,s){var c=e.constructor;switch(t){case at:return Wi(e);case Be:case D:return new c(+e);case lt:return jp(e,s);case Pn:case Gn:case cr:case rn:case zn:case U:case me:case It:case ur:return _l(e,s);case ve:return new c;case Pe:case ye:return new c(e);case ce:return Ip(e);case fe:return new c;case xe:return Lp(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(Jf,`{
7
- /* [wrapped with `+t+`] */
8
- `)}function Qp(e){return Te(e)||Un(e)||!!(Ua&&e&&e[Ua])}function un(e,t){var s=typeof e;return t=t??le,!!t&&(s=="number"||s!="symbol"&&cd.test(e))&&e>-1&&e%1==0&&e<t}function bt(e,t,s){if(!Je(s))return!1;var c=typeof t;return(c=="number"?St(s)&&un(t,s.length):c=="string"&&t in s)?$t(s[t],e):!1}function Vi(e,t){if(Te(e))return!1;var s=typeof e;return s=="number"||s=="symbol"||s=="boolean"||e==null||At(e)?!0:Yf.test(e)||!Xf.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=bs(e),s=m[t];if(typeof s!="function"||!(t in Le.prototype))return!1;if(e===s)return!0;var c=$i(s);return!!c&&e===c[0]}function Zp(e){return!!Da&&Da in e}var em=Kr?fn:po;function Er(e){var t=e&&e.constructor,s=typeof t=="function"&&t.prototype||Kn;return e===s}function Dl(e){return e===e&&!Je(e)}function Ol(e,t){return function(s){return s==null?!1:s[e]===t&&(t!==r||e in qe(s))}}function tm(e){var t=Cs(e,function(c){return s.size===g&&s.clear(),c}),s=t.cache;return t}function nm(e,t){var s=e[1],c=t[1],f=s|c,_=f<(R|M|X),y=c==X&&s==I||c==X&&s==z&&e[7].length<=t[8]||c==(X|z)&&t[7].length<=t[8]&&s==I;if(!(_||y))return e;c&R&&(e[2]=t[2],f|=s&R?0:B);var S=t[3];if(S){var A=e[3];e[3]=A?vl(A,S,t[4]):S,e[4]=A?bn(e[3],p):t[4]}return S=t[5],S&&(A=e[5],e[5]=A?bl(A,S,t[6]):S,e[6]=A?bn(e[5],p):t[6]),S=t[7],S&&(e[7]=S),c&X&&(e[8]=e[8]==null?t[8]:mt(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 Jr.call(e)}function Bl(e,t,s){return t=ut(t===r?e.length-1:t,0),function(){for(var c=arguments,f=-1,_=ut(c.length-t,0),y=L(_);++f<_;)y[f]=c[t+f];f=-1;for(var S=L(t+1);++f<t;)S[f]=c[f];return S[t]=s(y),Tt(e,this,S)}}function Fl(e,t){return t.length<2?e:On(e,Ft(t,0,-1))}function im(e,t){for(var s=e.length,c=mt(t.length,s),f=Et(e);c--;){var _=t[c];e[c]=un(_,s)?f[_]:r}return e}function Qi(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var Ul=Hl(cl),Sr=bh||function(e,t){return dt.setTimeout(e,t)},Ji=Hl(Rp);function Wl(e,t,s){var c=t+"";return Ji(e,Kp(c,om(Xp(c),s)))}function Hl(e){var t=0,s=0;return function(){var c=Sh(),f=pe-(c-s);if(s=c,f>0){if(++t>=re)return arguments[0]}else t=0;return e.apply(r,arguments)}}function ws(e,t){var s=-1,c=e.length,f=c-1;for(t=t===r?c:t;++s<t;){var _=Li(s,f),y=e[_];e[_]=e[s],e[s]=y}return e.length=t,e}var Gl=tm(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Vf,function(s,c,f,_){t.push(f?_.replace(rd,"$1"):c||s)}),t});function Jt(e){if(typeof e=="string"||At(e))return e;var t=e+"";return t=="0"&&1/e==-ie?"-0":t}function Fn(e){if(e!=null){try{return Qr.call(e)}catch{}try{return e+""}catch{}}return""}function om(e,t){return Mt(be,function(s){var c="_."+s[0];t&s[1]&&!$r(e,c)&&e.push(c)}),e.sort()}function zl(e){if(e instanceof Le)return e.clone();var t=new Ot(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?bt(e,t,s):t===r)?t=1:t=ut(Re(t),0);var c=e==null?0:e.length;if(!c||t<1)return[];for(var f=0,_=0,y=L(ss(c/t));f<c;)y[_++]=Ft(e,f,f+=t);return y}function lm(e){for(var t=-1,s=e==null?0:e.length,c=0,f=[];++t<s;){var _=e[t];_&&(f[c++]=_)}return f}function cm(){var e=arguments.length;if(!e)return[];for(var t=L(e-1),s=arguments[0],c=e;c--;)t[c-1]=arguments[c];return vn(Te(s)?Et(s):[s],ht(t,1))}var um=Ae(function(e,t){return nt(e)?xr(e,ht(t,1,nt,!0)):[]}),fm=Ae(function(e,t){var s=Ut(t);return nt(s)&&(s=r),nt(e)?xr(e,ht(t,1,nt,!0),he(s,2)):[]}),dm=Ae(function(e,t){var s=Ut(t);return nt(s)&&(s=r),nt(e)?xr(e,ht(t,1,nt,!0),r,s):[]});function hm(e,t,s){var c=e==null?0:e.length;return c?(t=s||t===r?1:Re(t),Ft(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:Re(t),t=c-t,Ft(e,0,t<0?0:t)):[]}function mm(e,t){return e&&e.length?ps(e,he(t,3),!0,!0):[]}function gm(e,t){return e&&e.length?ps(e,he(t,3),!0):[]}function _m(e,t,s,c){var f=e==null?0:e.length;return f?(s&&typeof s!="number"&&bt(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:Re(s);return f<0&&(f=ut(c+f,0)),Xr(e,he(t,3),f)}function $l(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=c-1;return s!==r&&(f=Re(s),f=s<0?ut(c+f,0):mt(f,c-1)),Xr(e,he(t,3),f,!0)}function Xl(e){var t=e==null?0:e.length;return t?ht(e,1):[]}function xm(e){var t=e==null?0:e.length;return t?ht(e,ie):[]}function vm(e,t){var s=e==null?0:e.length;return s?(t=t===r?1:Re(t),ht(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 Yl(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:Re(s);return f<0&&(f=ut(c+f,0)),$n(e,t,f)}function wm(e){var t=e==null?0:e.length;return t?Ft(e,0,-1):[]}var Em=Ae(function(e){var t=Ke(e,Fi);return t.length&&t[0]===e[0]?ki(t):[]}),Sm=Ae(function(e){var t=Ut(e),s=Ke(e,Fi);return t===Ut(s)?t=r:s.pop(),s.length&&s[0]===e[0]?ki(s,he(t,2)):[]}),Nm=Ae(function(e){var t=Ut(e),s=Ke(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 Ut(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=Re(s),f=f<0?ut(c+f,0):mt(f,c-1)),t===t?oh(e,t,f):Xr(e,Ra,f,!0)}function Rm(e,t){return e&&e.length?il(e,Re(t)):r}var km=Ae(Vl);function Vl(e,t){return e&&e.length&&t&&t.length?Ii(e,t):e}function Am(e,t,s){return e&&e.length&&t&&t.length?Ii(e,t,he(s,2)):e}function Pm(e,t,s){return e&&e.length&&t&&t.length?Ii(e,t,r,s):e}var jm=cn(function(e,t){var s=e==null?0:e.length,c=Ni(e,t);return ll(e,Ke(t,function(f){return un(f,s)?+f:f}).sort(xl)),c});function Im(e,t){var s=[];if(!(e&&e.length))return s;var c=-1,f=[],_=e.length;for(t=he(t,3);++c<_;){var y=e[c];t(y,c,e)&&(s.push(y),f.push(c))}return ll(e,f),s}function Zi(e){return e==null?e:Ch.call(e)}function Lm(e,t,s){var c=e==null?0:e.length;return c?(s&&typeof s!="number"&&bt(e,t,s)?(t=0,s=c):(t=t==null?0:Re(t),s=s===r?c:Re(s)),Ft(e,t,s)):[]}function Mm(e,t){return hs(e,t)}function Dm(e,t,s){return Di(e,t,he(s,2))}function Om(e,t){var s=e==null?0:e.length;if(s){var c=hs(e,t);if(c<s&&$t(e[c],t))return c}return-1}function Bm(e,t){return hs(e,t,!0)}function Fm(e,t,s){return Di(e,t,he(s,2),!0)}function Um(e,t){var s=e==null?0:e.length;if(s){var c=hs(e,t,!0)-1;if($t(e[c],t))return c}return-1}function Wm(e){return e&&e.length?ul(e):[]}function Hm(e,t){return e&&e.length?ul(e,he(t,2)):[]}function Gm(e){var t=e==null?0:e.length;return t?Ft(e,1,t):[]}function zm(e,t,s){return e&&e.length?(t=s||t===r?1:Re(t),Ft(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:Re(t),t=c-t,Ft(e,t<0?0:t,c)):[]}function $m(e,t){return e&&e.length?ps(e,he(t,3),!1,!0):[]}function Xm(e,t){return e&&e.length?ps(e,he(t,3)):[]}var Ym=Ae(function(e){return En(ht(e,1,nt,!0))}),Vm=Ae(function(e){var t=Ut(e);return nt(t)&&(t=r),En(ht(e,1,nt,!0),he(t,2))}),Km=Ae(function(e){var t=Ut(e);return t=typeof t=="function"?t:r,En(ht(e,1,nt,!0),r,t)});function Qm(e){return e&&e.length?En(e):[]}function Jm(e,t){return e&&e.length?En(e,he(t,2)):[]}function Zm(e,t){return t=typeof t=="function"?t:r,e&&e.length?En(e,r,t):[]}function eo(e){if(!(e&&e.length))return[];var t=0;return e=xn(e,function(s){if(nt(s))return t=ut(s.length,t),!0}),_i(t,function(s){return Ke(e,pi(s))})}function Kl(e,t){if(!(e&&e.length))return[];var s=eo(e);return t==null?s:Ke(s,function(c){return Tt(t,r,c)})}var e0=Ae(function(e,t){return nt(e)?xr(e,t):[]}),t0=Ae(function(e){return Bi(xn(e,nt))}),n0=Ae(function(e){var t=Ut(e);return nt(t)&&(t=r),Bi(xn(e,nt),he(t,2))}),r0=Ae(function(e){var t=Ut(e);return t=typeof t=="function"?t:r,Bi(xn(e,nt),r,t)}),s0=Ae(eo);function i0(e,t){return pl(e||[],t||[],_r)}function o0(e,t){return pl(e||[],t||[],yr)}var a0=Ae(function(e){var t=e.length,s=t>1?e[t-1]:r;return s=typeof s=="function"?(e.pop(),s):r,Kl(e,s)});function Ql(e){var t=m(e);return t.__chain__=!0,t}function l0(e,t){return t(e),e}function Es(e,t){return t(e)}var c0=cn(function(e){var t=e.length,s=t?e[0]:0,c=this.__wrapped__,f=function(_){return Ni(_,e)};return t>1||this.__actions__.length||!(c instanceof Le)||!un(s)?this.thru(f):(c=c.slice(s,+s+(t?1:0)),c.__actions__.push({func:Es,args:[f],thisArg:r}),new Ot(c,this.__chain__).thru(function(_){return t&&!_.length&&_.push(r),_}))});function u0(){return Ql(this)}function f0(){return new Ot(this.value(),this.__chain__)}function d0(){this.__values__===r&&(this.__values__=fc(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 ls;){var c=zl(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 Le){var t=e;return this.__actions__.length&&(t=new Le(this)),t=t.reverse(),t.__actions__.push({func:Es,args:[Zi],thisArg:r}),new Ot(t,this.__chain__)}return this.thru(Zi)}function g0(){return hl(this.__wrapped__,this.__actions__)}var _0=ms(function(e,t,s){Ge.call(e,s)?++e[s]:an(e,s,1)});function x0(e,t,s){var c=Te(e)?Ca:lp;return s&&bt(e,t,s)&&(t=r),c(e,he(t,3))}function v0(e,t){var s=Te(e)?xn:Ka;return s(e,he(t,3))}var b0=Sl(ql),y0=Sl($l);function w0(e,t){return ht(Ss(e,t),1)}function E0(e,t){return ht(Ss(e,t),ie)}function S0(e,t,s){return s=s===r?1:Re(s),ht(Ss(e,t),s)}function Jl(e,t){var s=Te(e)?Mt:wn;return s(e,he(t,3))}function Zl(e,t){var s=Te(e)?Gd:Va;return s(e,he(t,3))}var N0=ms(function(e,t,s){Ge.call(e,s)?e[s].push(t):an(e,s,[t])});function C0(e,t,s,c){e=St(e)?e:sr(e),s=s&&!c?Re(s):0;var f=e.length;return s<0&&(s=ut(f+s,0)),ks(e)?s<=f&&e.indexOf(t,s)>-1:!!f&&$n(e,t,s)>-1}var T0=Ae(function(e,t,s){var c=-1,f=typeof t=="function",_=St(e)?L(e.length):[];return wn(e,function(y){_[++c]=f?Tt(t,y,s):vr(y,t,s)}),_}),R0=ms(function(e,t,s){an(e,s,t)});function Ss(e,t){var s=Te(e)?Ke:nl;return s(e,he(t,3))}function k0(e,t,s,c){return e==null?[]:(Te(t)||(t=t==null?[]:[t]),s=c?r:s,Te(s)||(s=s==null?[]:[s]),ol(e,t,s))}var A0=ms(function(e,t,s){e[s?0:1].push(t)},function(){return[[],[]]});function P0(e,t,s){var c=Te(e)?di:Aa,f=arguments.length<3;return c(e,he(t,4),s,f,wn)}function j0(e,t,s){var c=Te(e)?zd:Aa,f=arguments.length<3;return c(e,he(t,4),s,f,Va)}function I0(e,t){var s=Te(e)?xn:Ka;return s(e,Ts(he(t,3)))}function L0(e){var t=Te(e)?qa:Cp;return t(e)}function M0(e,t,s){(s?bt(e,t,s):t===r)?t=1:t=Re(t);var c=Te(e)?rp:Tp;return c(e,t)}function D0(e){var t=Te(e)?sp:kp;return t(e)}function O0(e){if(e==null)return 0;if(St(e))return ks(e)?Yn(e):e.length;var t=gt(e);return t==ve||t==fe?e.size:Pi(e).length}function B0(e,t,s){var c=Te(e)?hi:Ap;return s&&bt(e,t,s)&&(t=r),c(e,he(t,3))}var F0=Ae(function(e,t){if(e==null)return[];var s=t.length;return s>1&&bt(e,t[0],t[1])?t=[]:s>2&&bt(t[0],t[1],t[2])&&(t=[t[0]]),ol(e,ht(t,1),[])}),Ns=vh||function(){return dt.Date.now()};function U0(e,t){if(typeof t!="function")throw new Dt(d);return e=Re(e),function(){if(--e<1)return t.apply(this,arguments)}}function ec(e,t,s){return t=s?r:t,t=e&&t==null?e.length:t,ln(e,X,r,r,r,r,t)}function tc(e,t){var s;if(typeof t!="function")throw new Dt(d);return e=Re(e),function(){return--e>0&&(s=t.apply(this,arguments)),e<=1&&(t=r),s}}var to=Ae(function(e,t,s){var c=R;if(s.length){var f=bn(s,nr(to));c|=G}return ln(e,c,t,s,f)}),nc=Ae(function(e,t,s){var c=R|M;if(s.length){var f=bn(s,nr(nc));c|=G}return ln(t,c,e,s,f)});function rc(e,t,s){t=s?r:t;var c=ln(e,I,r,r,r,r,r,t);return c.placeholder=rc.placeholder,c}function sc(e,t,s){t=s?r:t;var c=ln(e,P,r,r,r,r,r,t);return c.placeholder=sc.placeholder,c}function ic(e,t,s){var c,f,_,y,S,A,W=0,H=!1,V=!1,te=!0;if(typeof e!="function")throw new Dt(d);t=Wt(t)||0,Je(s)&&(H=!!s.leading,V="maxWait"in s,_=V?ut(Wt(s.maxWait)||0,t):_,te="trailing"in s?!!s.trailing:te);function oe(rt){var Xt=c,hn=f;return c=f=r,W=rt,y=e.apply(hn,Xt),y}function ge(rt){return W=rt,S=Sr(je,t),H?oe(rt):y}function ke(rt){var Xt=rt-A,hn=rt-W,Sc=t-Xt;return V?mt(Sc,_-hn):Sc}function _e(rt){var Xt=rt-A,hn=rt-W;return A===r||Xt>=t||Xt<0||V&&hn>=_}function je(){var rt=Ns();if(_e(rt))return De(rt);S=Sr(je,ke(rt))}function De(rt){return S=r,te&&c?oe(rt):(c=f=r,y)}function Pt(){S!==r&&ml(S),W=0,c=A=f=S=r}function yt(){return S===r?y:De(Ns())}function jt(){var rt=Ns(),Xt=_e(rt);if(c=arguments,f=this,A=rt,Xt){if(S===r)return ge(A);if(V)return ml(S),S=Sr(je,t),oe(A)}return S===r&&(S=Sr(je,t)),y}return jt.cancel=Pt,jt.flush=yt,jt}var W0=Ae(function(e,t){return Ya(e,1,t)}),H0=Ae(function(e,t,s){return Ya(e,Wt(t)||0,s)});function G0(e){return ln(e,F)}function Cs(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new Dt(d);var s=function(){var c=arguments,f=t?t.apply(this,c):c[0],_=s.cache;if(_.has(f))return _.get(f);var y=e.apply(this,c);return s.cache=_.set(f,y)||_,y};return s.cache=new(Cs.Cache||on),s}Cs.Cache=on;function Ts(e){if(typeof e!="function")throw new Dt(d);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 tc(2,e)}var q0=Pp(function(e,t){t=t.length==1&&Te(t[0])?Ke(t[0],Rt(he())):Ke(ht(t,1),Rt(he()));var s=t.length;return Ae(function(c){for(var f=-1,_=mt(c.length,s);++f<_;)c[f]=t[f].call(this,c[f]);return Tt(e,this,c)})}),no=Ae(function(e,t){var s=bn(t,nr(no));return ln(e,G,r,t,s)}),oc=Ae(function(e,t){var s=bn(t,nr(oc));return ln(e,Q,r,t,s)}),$0=cn(function(e,t){return ln(e,z,r,r,r,t)});function X0(e,t){if(typeof e!="function")throw new Dt(d);return t=t===r?t:Re(t),Ae(e,t)}function Y0(e,t){if(typeof e!="function")throw new Dt(d);return t=t==null?0:ut(Re(t),0),Ae(function(s){var c=s[t],f=Nn(s,0,t);return c&&vn(f,c),Tt(e,this,f)})}function V0(e,t,s){var c=!0,f=!0;if(typeof e!="function")throw new Dt(d);return Je(s)&&(c="leading"in s?!!s.leading:c,f="trailing"in s?!!s.trailing:f),ic(e,t,{leading:c,maxWait:t,trailing:f})}function K0(e){return ec(e,1)}function Q0(e,t){return no(Ui(t),e)}function J0(){if(!arguments.length)return[];var e=arguments[0];return Te(e)?e:[e]}function Z0(e){return Bt(e,E)}function eg(e,t){return t=typeof t=="function"?t:r,Bt(e,E,t)}function tg(e){return Bt(e,x|E)}function ng(e,t){return t=typeof t=="function"?t:r,Bt(e,x|E,t)}function rg(e,t){return t==null||Xa(e,t,ft(t))}function $t(e,t){return e===t||e!==e&&t!==t}var sg=vs(Ri),ig=vs(function(e,t){return e>=t}),Un=Za((function(){return arguments})())?Za:function(e){return Ze(e)&&Ge.call(e,"callee")&&!Fa.call(e,"callee")},Te=L.isArray,og=ba?Rt(ba):pp;function St(e){return e!=null&&Rs(e.length)&&!fn(e)}function nt(e){return Ze(e)&&St(e)}function ag(e){return e===!0||e===!1||Ze(e)&&vt(e)==Be}var Cn=yh||po,lg=ya?Rt(ya):mp;function cg(e){return Ze(e)&&e.nodeType===1&&!Nr(e)}function ug(e){if(e==null)return!0;if(St(e)&&(Te(e)||typeof e=="string"||typeof e.splice=="function"||Cn(e)||rr(e)||Un(e)))return!e.length;var t=gt(e);if(t==ve||t==fe)return!e.size;if(Er(e))return!Pi(e).length;for(var s in e)if(Ge.call(e,s))return!1;return!0}function fg(e,t){return br(e,t)}function dg(e,t,s){s=typeof s=="function"?s:r;var c=s?s(e,t):r;return c===r?br(e,t,r,s):!!c}function ro(e){if(!Ze(e))return!1;var t=vt(e);return t==ae||t==Se||typeof e.message=="string"&&typeof e.name=="string"&&!Nr(e)}function hg(e){return typeof e=="number"&&Wa(e)}function fn(e){if(!Je(e))return!1;var t=vt(e);return t==Fe||t==tt||t==Qe||t==Me}function ac(e){return typeof e=="number"&&e==Re(e)}function Rs(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=le}function Je(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function Ze(e){return e!=null&&typeof e=="object"}var lc=wa?Rt(wa):_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 cc(e)&&e!=+e}function _g(e){if(em(e))throw new Ne(l);return el(e)}function xg(e){return e===null}function vg(e){return e==null}function cc(e){return typeof e=="number"||Ze(e)&&vt(e)==Pe}function Nr(e){if(!Ze(e)||vt(e)!=ee)return!1;var t=ts(e);if(t===null)return!0;var s=Ge.call(t,"constructor")&&t.constructor;return typeof s=="function"&&s instanceof s&&Qr.call(s)==mh}var so=Ea?Rt(Ea):xp;function bg(e){return ac(e)&&e>=-le&&e<=le}var uc=Sa?Rt(Sa):vp;function ks(e){return typeof e=="string"||!Te(e)&&Ze(e)&&vt(e)==ye}function At(e){return typeof e=="symbol"||Ze(e)&&vt(e)==xe}var rr=Na?Rt(Na):bp;function yg(e){return e===r}function wg(e){return Ze(e)&&gt(e)==pt}function Eg(e){return Ze(e)&&vt(e)==st}var Sg=vs(ji),Ng=vs(function(e,t){return e<=t});function fc(e){if(!e)return[];if(St(e))return ks(e)?zt(e):Et(e);if(dr&&e[dr])return rh(e[dr]());var t=gt(e),s=t==ve?vi:t==fe?Yr:sr;return s(e)}function dn(e){if(!e)return e===0?e:0;if(e=Wt(e),e===ie||e===-ie){var t=e<0?-1:1;return t*Ce}return e===e?e:0}function Re(e){var t=dn(e),s=t%1;return t===t?s?t-s:t:0}function dc(e){return e?Dn(Re(e),0,J):0}function Wt(e){if(typeof e=="number")return e;if(At(e))return $;if(Je(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Je(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Pa(e);var s=od.test(e);return s||ld.test(e)?Ud(e.slice(2),s?2:8):id.test(e)?$:+e}function hc(e){return Qt(e,Nt(e))}function Cg(e){return e?Dn(Re(e),-le,le):e===0?e:0}function We(e){return e==null?"":kt(e)}var Tg=er(function(e,t){if(Er(t)||St(t)){Qt(t,ft(t),e);return}for(var s in t)Ge.call(t,s)&&_r(e,s,t[s])}),pc=er(function(e,t){Qt(t,Nt(t),e)}),As=er(function(e,t,s,c){Qt(t,Nt(t),e,c)}),Rg=er(function(e,t,s,c){Qt(t,ft(t),e,c)}),kg=cn(Ni);function Ag(e,t){var s=Zn(e);return t==null?s:$a(s,t)}var Pg=Ae(function(e,t){e=qe(e);var s=-1,c=t.length,f=c>2?t[2]:r;for(f&&bt(t[0],t[1],f)&&(c=1);++s<c;)for(var _=t[s],y=Nt(_),S=-1,A=y.length;++S<A;){var W=y[S],H=e[W];(H===r||$t(H,Kn[W])&&!Ge.call(e,W))&&(e[W]=_[W])}return e}),jg=Ae(function(e){return e.push(r,Pl),Tt(mc,r,e)});function Ig(e,t){return Ta(e,he(t,3),Kt)}function Lg(e,t){return Ta(e,he(t,3),Ti)}function Mg(e,t){return e==null?e:Ci(e,he(t,3),Nt)}function Dg(e,t){return e==null?e:Qa(e,he(t,3),Nt)}function Og(e,t){return e&&Kt(e,he(t,3))}function Bg(e,t){return e&&Ti(e,he(t,3))}function Fg(e){return e==null?[]:fs(e,ft(e))}function Ug(e){return e==null?[]:fs(e,Nt(e))}function io(e,t,s){var c=e==null?r:On(e,t);return c===r?s:c}function Wg(e,t){return e!=null&&Ll(e,t,up)}function oo(e,t){return e!=null&&Ll(e,t,fp)}var Hg=Cl(function(e,t,s){t!=null&&typeof t.toString!="function"&&(t=Jr.call(t)),e[t]=s},lo(Ct)),Gg=Cl(function(e,t,s){t!=null&&typeof t.toString!="function"&&(t=Jr.call(t)),Ge.call(e,t)?e[t].push(s):e[t]=[s]},he),zg=Ae(vr);function ft(e){return St(e)?za(e):Pi(e)}function Nt(e){return St(e)?za(e,!0):yp(e)}function qg(e,t){var s={};return t=he(t,3),Kt(e,function(c,f,_){an(s,t(c,f,_),c)}),s}function $g(e,t){var s={};return t=he(t,3),Kt(e,function(c,f,_){an(s,f,t(c,f,_))}),s}var Xg=er(function(e,t,s){ds(e,t,s)}),mc=er(function(e,t,s,c){ds(e,t,s,c)}),Yg=cn(function(e,t){var s={};if(e==null)return s;var c=!1;t=Ke(t,function(_){return _=Sn(_,e),c||(c=_.length>1),_}),Qt(e,qi(e),s),c&&(s=Bt(s,x|b|E,Hp));for(var f=t.length;f--;)Oi(s,t[f]);return s});function Vg(e,t){return gc(e,Ts(he(t)))}var Kg=cn(function(e,t){return e==null?{}:Ep(e,t)});function gc(e,t){if(e==null)return{};var s=Ke(qi(e),function(c){return[c]});return t=he(t),al(e,s,function(c,f){return t(c,f[0])})}function Qg(e,t,s){t=Sn(t,e);var c=-1,f=t.length;for(f||(f=1,e=r);++c<f;){var _=e==null?r:e[Jt(t[c])];_===r&&(c=f,_=s),e=fn(_)?_.call(e):_}return e}function Jg(e,t,s){return e==null?e:yr(e,t,s)}function Zg(e,t,s,c){return c=typeof c=="function"?c:r,e==null?e:yr(e,t,s,c)}var _c=kl(ft),xc=kl(Nt);function e_(e,t,s){var c=Te(e),f=c||Cn(e)||rr(e);if(t=he(t,4),s==null){var _=e&&e.constructor;f?s=c?new _:[]:Je(e)?s=fn(_)?Zn(ts(e)):{}:s={}}return(f?Mt:Kt)(e,function(y,S,A){return t(s,y,S,A)}),s}function t_(e,t){return e==null?!0:Oi(e,t)}function n_(e,t,s){return e==null?e:dl(e,t,Ui(s))}function r_(e,t,s,c){return c=typeof c=="function"?c:r,e==null?e:dl(e,t,Ui(s),c)}function sr(e){return e==null?[]:xi(e,ft(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=Wt(s),s=s===s?s:0),t!==r&&(t=Wt(t),t=t===t?t:0),Dn(Wt(e),t,s)}function o_(e,t,s){return t=dn(t),s===r?(s=t,t=0):s=dn(s),e=Wt(e),dp(e,t,s)}function a_(e,t,s){if(s&&typeof s!="boolean"&&bt(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=dn(e),t===r?(t=e,e=0):t=dn(t)),e>t){var c=e;e=t,t=c}if(s||e%1||t%1){var f=Ha();return mt(e+f*(t-e+Fd("1e-"+((f+"").length-1))),t)}return Li(e,t)}var l_=tr(function(e,t,s){return t=t.toLowerCase(),e+(s?vc(t):t)});function vc(e){return ao(We(e).toLowerCase())}function bc(e){return e=We(e),e&&e.replace(ud,Jd).replace(kd,"")}function c_(e,t,s){e=We(e),t=kt(t);var c=e.length;s=s===r?c:Dn(Re(s),0,c);var f=s;return s-=t.length,s>=0&&e.slice(s,f)==t}function u_(e){return e=We(e),e&&zf.test(e)?e.replace(Qo,Zd):e}function f_(e){return e=We(e),e&&Kf.test(e)?e.replace(ni,"\\$&"):e}var d_=tr(function(e,t,s){return e+(s?"-":"")+t.toLowerCase()}),h_=tr(function(e,t,s){return e+(s?" ":"")+t.toLowerCase()}),p_=El("toLowerCase");function m_(e,t,s){e=We(e),t=Re(t);var c=t?Yn(e):0;if(!t||c>=t)return e;var f=(t-c)/2;return xs(is(f),s)+e+xs(ss(f),s)}function g_(e,t,s){e=We(e),t=Re(t);var c=t?Yn(e):0;return t&&c<t?e+xs(t-c,s):e}function __(e,t,s){e=We(e),t=Re(t);var c=t?Yn(e):0;return t&&c<t?xs(t-c,s)+e:e}function x_(e,t,s){return s||t==null?t=0:t&&(t=+t),Nh(We(e).replace(ri,""),t||0)}function v_(e,t,s){return(s?bt(e,t,s):t===r)?t=1:t=Re(t),Mi(We(e),t)}function b_(){var e=arguments,t=We(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var y_=tr(function(e,t,s){return e+(s?"_":"")+t.toLowerCase()});function w_(e,t,s){return s&&typeof s!="number"&&bt(e,t,s)&&(t=s=r),s=s===r?J:s>>>0,s?(e=We(e),e&&(typeof t=="string"||t!=null&&!so(t))&&(t=kt(t),!t&&Xn(e))?Nn(zt(e),0,s):e.split(t,s)):[]}var E_=tr(function(e,t,s){return e+(s?" ":"")+ao(t)});function S_(e,t,s){return e=We(e),s=s==null?0:Dn(Re(s),0,e.length),t=kt(t),e.slice(s,s+t.length)==t}function N_(e,t,s){var c=m.templateSettings;s&&bt(e,t,s)&&(t=r),e=We(e),t=As({},t,c,Al);var f=As({},t.imports,c.imports,Al),_=ft(f),y=xi(f,_),S,A,W=0,H=t.interpolate||Gr,V="__p += '",te=bi((t.escape||Gr).source+"|"+H.source+"|"+(H===Jo?sd:Gr).source+"|"+(t.evaluate||Gr).source+"|$","g"),oe="//# sourceURL="+(Ge.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Ld+"]")+`
9
- `;e.replace(te,function(_e,je,De,Pt,yt,jt){return De||(De=Pt),V+=e.slice(W,jt).replace(fd,eh),je&&(S=!0,V+=`' +
10
- __e(`+je+`) +
11
- '`),yt&&(A=!0,V+=`';
12
- `+yt+`;
13
- __p += '`),De&&(V+=`' +
14
- ((__t = (`+De+`)) == null ? '' : __t) +
15
- '`),W=jt+_e.length,_e}),V+=`';
16
- `;var ge=Ge.call(t,"variable")&&t.variable;if(!ge)V=`with (obj) {
17
- `+V+`
18
- }
19
- `;else if(nd.test(ge))throw new Ne(v);V=(A?V.replace(Hr,""):V).replace(Wf,"$1").replace(Hf,"$1;"),V="function("+(ge||"obj")+`) {
20
- `+(ge?"":`obj || (obj = {});
21
- `)+"var __t, __p = ''"+(S?", __e = _.escape":"")+(A?`, __j = Array.prototype.join;
22
- function print() { __p += __j.call(arguments, '') }
23
- `:`;
24
- `)+V+`return __p
25
- }`;var ke=wc(function(){return Ue(_,oe+"return "+V).apply(r,y)});if(ke.source=V,ro(ke))throw ke;return ke}function C_(e){return We(e).toLowerCase()}function T_(e){return We(e).toUpperCase()}function R_(e,t,s){if(e=We(e),e&&(s||t===r))return Pa(e);if(!e||!(t=kt(t)))return e;var c=zt(e),f=zt(t),_=ja(c,f),y=Ia(c,f)+1;return Nn(c,_,y).join("")}function k_(e,t,s){if(e=We(e),e&&(s||t===r))return e.slice(0,Ma(e)+1);if(!e||!(t=kt(t)))return e;var c=zt(e),f=Ia(c,zt(t))+1;return Nn(c,0,f).join("")}function A_(e,t,s){if(e=We(e),e&&(s||t===r))return e.replace(ri,"");if(!e||!(t=kt(t)))return e;var c=zt(e),f=ja(c,zt(t));return Nn(c,f).join("")}function P_(e,t){var s=C,c=k;if(Je(t)){var f="separator"in t?t.separator:f;s="length"in t?Re(t.length):s,c="omission"in t?kt(t.omission):c}e=We(e);var _=e.length;if(Xn(e)){var y=zt(e);_=y.length}if(s>=_)return e;var S=s-Yn(c);if(S<1)return c;var A=y?Nn(y,0,S).join(""):e.slice(0,S);if(f===r)return A+c;if(y&&(S+=A.length-S),so(f)){if(e.slice(S).search(f)){var W,H=A;for(f.global||(f=bi(f.source,We(Zo.exec(f))+"g")),f.lastIndex=0;W=f.exec(H);)var V=W.index;A=A.slice(0,V===r?S:V)}}else if(e.indexOf(kt(f),S)!=S){var te=A.lastIndexOf(f);te>-1&&(A=A.slice(0,te))}return A+c}function j_(e){return e=We(e),e&&Gf.test(e)?e.replace(Ko,ah):e}var I_=tr(function(e,t,s){return e+(s?" ":"")+t.toUpperCase()}),ao=El("toUpperCase");function yc(e,t,s){return e=We(e),t=s?r:t,t===r?nh(e)?uh(e):Xd(e):e.match(t)||[]}var wc=Ae(function(e,t){try{return Tt(e,r,t)}catch(s){return ro(s)?s:new Ne(s)}}),L_=cn(function(e,t){return Mt(t,function(s){s=Jt(s),an(e,s,to(e[s],e))}),e});function M_(e){var t=e==null?0:e.length,s=he();return e=t?Ke(e,function(c){if(typeof c[1]!="function")throw new Dt(d);return[s(c[0]),c[1]]}):[],Ae(function(c){for(var f=-1;++f<t;){var _=e[f];if(Tt(_[0],this,c))return Tt(_[1],this,c)}})}function D_(e){return ap(Bt(e,x))}function lo(e){return function(){return e}}function O_(e,t){return e==null||e!==e?t:e}var B_=Nl(),F_=Nl(!0);function Ct(e){return e}function co(e){return tl(typeof e=="function"?e:Bt(e,x))}function U_(e){return rl(Bt(e,x))}function W_(e,t){return sl(e,Bt(t,x))}var H_=Ae(function(e,t){return function(s){return vr(s,e,t)}}),G_=Ae(function(e,t){return function(s){return vr(e,s,t)}});function uo(e,t,s){var c=ft(t),f=fs(t,c);s==null&&!(Je(t)&&(f.length||!c.length))&&(s=t,t=e,e=this,f=fs(t,ft(t)));var _=!(Je(s)&&"chain"in s)||!!s.chain,y=fn(e);return Mt(f,function(S){var A=t[S];e[S]=A,y&&(e.prototype[S]=function(){var W=this.__chain__;if(_||W){var H=e(this.__wrapped__),V=H.__actions__=Et(this.__actions__);return V.push({func:A,args:arguments,thisArg:e}),H.__chain__=W,H}return A.apply(e,vn([this.value()],arguments))})}),e}function z_(){return dt._===this&&(dt._=gh),this}function fo(){}function q_(e){return e=Re(e),Ae(function(t){return il(t,e)})}var $_=Hi(Ke),X_=Hi(Ca),Y_=Hi(hi);function Ec(e){return Vi(e)?pi(Jt(e)):Sp(e)}function V_(e){return function(t){return e==null?r:On(e,t)}}var K_=Tl(),Q_=Tl(!0);function ho(){return[]}function po(){return!1}function J_(){return{}}function Z_(){return""}function ex(){return!0}function tx(e,t){if(e=Re(e),e<1||e>le)return[];var s=J,c=mt(e,J);t=he(t),e-=J;for(var f=_i(c,t);++s<e;)t(s);return f}function nx(e){return Te(e)?Ke(e,Jt):At(e)?[e]:Et(Gl(We(e)))}function rx(e){var t=++ph;return We(e)+t}var sx=_s(function(e,t){return e+t},0),ix=Gi("ceil"),ox=_s(function(e,t){return e/t},1),ax=Gi("floor");function lx(e){return e&&e.length?us(e,Ct,Ri):r}function cx(e,t){return e&&e.length?us(e,he(t,2),Ri):r}function ux(e){return ka(e,Ct)}function fx(e,t){return ka(e,he(t,2))}function dx(e){return e&&e.length?us(e,Ct,ji):r}function hx(e,t){return e&&e.length?us(e,he(t,2),ji):r}var px=_s(function(e,t){return e*t},1),mx=Gi("round"),gx=_s(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,he(t,2)):0}return m.after=U0,m.ary=ec,m.assign=Tg,m.assignIn=pc,m.assignInWith=As,m.assignWith=Rg,m.at=kg,m.before=tc,m.bind=to,m.bindAll=L_,m.bindKey=nc,m.castArray=J0,m.chain=Ql,m.chunk=am,m.compact=lm,m.concat=cm,m.cond=M_,m.conforms=D_,m.constant=lo,m.countBy=_0,m.create=Ag,m.curry=rc,m.curryRight=sc,m.debounce=ic,m.defaults=Pg,m.defaultsDeep=jg,m.defer=W0,m.delay=H0,m.difference=um,m.differenceBy=fm,m.differenceWith=dm,m.drop=hm,m.dropRight=pm,m.dropRightWhile=mm,m.dropWhile=gm,m.fill=_m,m.filter=v0,m.flatMap=w0,m.flatMapDeep=E0,m.flatMapDepth=S0,m.flatten=Xl,m.flattenDeep=xm,m.flattenDepth=vm,m.flip=G0,m.flow=B_,m.flowRight=F_,m.fromPairs=bm,m.functions=Fg,m.functionsIn=Ug,m.groupBy=N0,m.initial=wm,m.intersection=Em,m.intersectionBy=Sm,m.intersectionWith=Nm,m.invert=Hg,m.invertBy=Gg,m.invokeMap=T0,m.iteratee=co,m.keyBy=R0,m.keys=ft,m.keysIn=Nt,m.map=Ss,m.mapKeys=qg,m.mapValues=$g,m.matches=U_,m.matchesProperty=W_,m.memoize=Cs,m.merge=Xg,m.mergeWith=mc,m.method=H_,m.methodOf=G_,m.mixin=uo,m.negate=Ts,m.nthArg=q_,m.omit=Yg,m.omitBy=Vg,m.once=z0,m.orderBy=k0,m.over=$_,m.overArgs=q0,m.overEvery=X_,m.overSome=Y_,m.partial=no,m.partialRight=oc,m.partition=A0,m.pick=Kg,m.pickBy=gc,m.property=Ec,m.propertyOf=V_,m.pull=km,m.pullAll=Vl,m.pullAllBy=Am,m.pullAllWith=Pm,m.pullAt=jm,m.range=K_,m.rangeRight=Q_,m.rearg=$0,m.reject=I0,m.remove=Im,m.rest=X0,m.reverse=Zi,m.sampleSize=M0,m.set=Jg,m.setWith=Zg,m.shuffle=D0,m.slice=Lm,m.sortBy=F0,m.sortedUniq=Wm,m.sortedUniqBy=Hm,m.split=w_,m.spread=Y0,m.tail=Gm,m.take=zm,m.takeRight=qm,m.takeRightWhile=$m,m.takeWhile=Xm,m.tap=l0,m.throttle=V0,m.thru=Es,m.toArray=fc,m.toPairs=_c,m.toPairsIn=xc,m.toPath=nx,m.toPlainObject=hc,m.transform=e_,m.unary=K0,m.union=Ym,m.unionBy=Vm,m.unionWith=Km,m.uniq=Qm,m.uniqBy=Jm,m.uniqWith=Zm,m.unset=t_,m.unzip=eo,m.unzipWith=Kl,m.update=n_,m.updateWith=r_,m.values=sr,m.valuesIn=s_,m.without=e0,m.words=yc,m.wrap=Q0,m.xor=t0,m.xorBy=n0,m.xorWith=r0,m.zip=s0,m.zipObject=i0,m.zipObjectDeep=o0,m.zipWith=a0,m.entries=_c,m.entriesIn=xc,m.extend=pc,m.extendWith=As,uo(m,m),m.add=sx,m.attempt=wc,m.camelCase=l_,m.capitalize=vc,m.ceil=ix,m.clamp=i_,m.clone=Z0,m.cloneDeep=tg,m.cloneDeepWith=ng,m.cloneWith=eg,m.conformsTo=rg,m.deburr=bc,m.defaultTo=O_,m.divide=ox,m.endsWith=c_,m.eq=$t,m.escape=u_,m.escapeRegExp=f_,m.every=x0,m.find=b0,m.findIndex=ql,m.findKey=Ig,m.findLast=y0,m.findLastIndex=$l,m.findLastKey=Lg,m.floor=ax,m.forEach=Jl,m.forEachRight=Zl,m.forIn=Mg,m.forInRight=Dg,m.forOwn=Og,m.forOwnRight=Bg,m.get=io,m.gt=sg,m.gte=ig,m.has=Wg,m.hasIn=oo,m.head=Yl,m.identity=Ct,m.includes=C0,m.indexOf=ym,m.inRange=o_,m.invoke=zg,m.isArguments=Un,m.isArray=Te,m.isArrayBuffer=og,m.isArrayLike=St,m.isArrayLikeObject=nt,m.isBoolean=ag,m.isBuffer=Cn,m.isDate=lg,m.isElement=cg,m.isEmpty=ug,m.isEqual=fg,m.isEqualWith=dg,m.isError=ro,m.isFinite=hg,m.isFunction=fn,m.isInteger=ac,m.isLength=Rs,m.isMap=lc,m.isMatch=pg,m.isMatchWith=mg,m.isNaN=gg,m.isNative=_g,m.isNil=vg,m.isNull=xg,m.isNumber=cc,m.isObject=Je,m.isObjectLike=Ze,m.isPlainObject=Nr,m.isRegExp=so,m.isSafeInteger=bg,m.isSet=uc,m.isString=ks,m.isSymbol=At,m.isTypedArray=rr,m.isUndefined=yg,m.isWeakMap=wg,m.isWeakSet=Eg,m.join=Cm,m.kebabCase=d_,m.last=Ut,m.lastIndexOf=Tm,m.lowerCase=h_,m.lowerFirst=p_,m.lt=Sg,m.lte=Ng,m.max=lx,m.maxBy=cx,m.mean=ux,m.meanBy=fx,m.min=dx,m.minBy=hx,m.stubArray=ho,m.stubFalse=po,m.stubObject=J_,m.stubString=Z_,m.stubTrue=ex,m.multiply=px,m.nth=Rm,m.noConflict=z_,m.noop=fo,m.now=Ns,m.pad=m_,m.padEnd=g_,m.padStart=__,m.parseInt=x_,m.random=a_,m.reduce=P0,m.reduceRight=j0,m.repeat=v_,m.replace=b_,m.result=Qg,m.round=mx,m.runInContext=T,m.sample=L0,m.size=O0,m.snakeCase=y_,m.some=B0,m.sortedIndex=Mm,m.sortedIndexBy=Dm,m.sortedIndexOf=Om,m.sortedLastIndex=Bm,m.sortedLastIndexBy=Fm,m.sortedLastIndexOf=Um,m.startCase=E_,m.startsWith=S_,m.subtract=gx,m.sum=_x,m.sumBy=xx,m.template=N_,m.times=tx,m.toFinite=dn,m.toInteger=Re,m.toLength=dc,m.toLower=C_,m.toNumber=Wt,m.toSafeInteger=Cg,m.toString=We,m.toUpper=T_,m.trim=R_,m.trimEnd=k_,m.trimStart=A_,m.truncate=P_,m.unescape=j_,m.uniqueId=rx,m.upperCase=I_,m.upperFirst=ao,m.each=Jl,m.eachRight=Zl,m.first=Yl,uo(m,(function(){var e={};return Kt(m,function(t,s){Ge.call(m.prototype,s)||(e[s]=t)}),e})(),{chain:!1}),m.VERSION=o,Mt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){m[e].placeholder=m}),Mt(["drop","take"],function(e,t){Le.prototype[e]=function(s){s=s===r?1:ut(Re(s),0);var c=this.__filtered__&&!t?new Le(this):this.clone();return c.__filtered__?c.__takeCount__=mt(s,c.__takeCount__):c.__views__.push({size:mt(s,J),type:e+(c.__dir__<0?"Right":"")}),c},Le.prototype[e+"Right"]=function(s){return this.reverse()[e](s).reverse()}}),Mt(["filter","map","takeWhile"],function(e,t){var s=t+1,c=s==Y||s==K;Le.prototype[e]=function(f){var _=this.clone();return _.__iteratees__.push({iteratee:he(f,3),type:s}),_.__filtered__=_.__filtered__||c,_}}),Mt(["head","last"],function(e,t){var s="take"+(t?"Right":"");Le.prototype[e]=function(){return this[s](1).value()[0]}}),Mt(["initial","tail"],function(e,t){var s="drop"+(t?"":"Right");Le.prototype[e]=function(){return this.__filtered__?new Le(this):this[s](1)}}),Le.prototype.compact=function(){return this.filter(Ct)},Le.prototype.find=function(e){return this.filter(e).head()},Le.prototype.findLast=function(e){return this.reverse().find(e)},Le.prototype.invokeMap=Ae(function(e,t){return typeof e=="function"?new Le(this):this.map(function(s){return vr(s,e,t)})}),Le.prototype.reject=function(e){return this.filter(Ts(he(e)))},Le.prototype.slice=function(e,t){e=Re(e);var s=this;return s.__filtered__&&(e>0||t<0)?new Le(s):(e<0?s=s.takeRight(-e):e&&(s=s.drop(e)),t!==r&&(t=Re(t),s=t<0?s.dropRight(-t):s.take(t-e)),s)},Le.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Le.prototype.toArray=function(){return this.take(J)},Kt(Le.prototype,function(e,t){var s=/^(?:filter|find|map|reject)|While$/.test(t),c=/^(?:head|last)$/.test(t),f=m[c?"take"+(t=="last"?"Right":""):t],_=c||/^find/.test(t);f&&(m.prototype[t]=function(){var y=this.__wrapped__,S=c?[1]:arguments,A=y instanceof Le,W=S[0],H=A||Te(y),V=function(je){var De=f.apply(m,vn([je],S));return c&&te?De[0]:De};H&&s&&typeof W=="function"&&W.length!=1&&(A=H=!1);var te=this.__chain__,oe=!!this.__actions__.length,ge=_&&!te,ke=A&&!oe;if(!_&&H){y=ke?y:new Le(this);var _e=e.apply(y,S);return _e.__actions__.push({func:Es,args:[V],thisArg:r}),new Ot(_e,te)}return ge&&ke?e.apply(this,S):(_e=this.thru(V),ge?c?_e.value()[0]:_e.value():_e)})}),Mt(["pop","push","shift","sort","splice","unshift"],function(e){var t=Vr[e],s=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",c=/^(?:pop|shift)$/.test(e);m.prototype[e]=function(){var f=arguments;if(c&&!this.__chain__){var _=this.value();return t.apply(Te(_)?_:[],f)}return this[s](function(y){return t.apply(Te(y)?y:[],f)})}}),Kt(Le.prototype,function(e,t){var s=m[t];if(s){var c=s.name+"";Ge.call(Jn,c)||(Jn[c]=[]),Jn[c].push({name:t,func:s})}}),Jn[gs(r,M).name]=[{name:"wrapper",func:r}],Le.prototype.clone=jh,Le.prototype.reverse=Ih,Le.prototype.value=Lh,m.prototype.at=c0,m.prototype.chain=u0,m.prototype.commit=f0,m.prototype.next=d0,m.prototype.plant=p0,m.prototype.reverse=m0,m.prototype.toJSON=m.prototype.valueOf=m.prototype.value=g0,m.prototype.first=m.prototype.head,dr&&(m.prototype[dr]=h0),m}),Vn=fh();jn?((jn.exports=Vn)._=Vn,ci._=Vn):dt._=Vn}).call(l1)})(Pr,Pr.exports)),Pr.exports}var nf=c1();const u1=bx(nf);function f1(i,n){const[r,o]=w.useState(i),u=w.useRef(u1.debounce(o,n)),l=w.useCallback(d=>{u.current(d)},[]);return[r,l]}const d1=[{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}],h1=()=>{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 p1({devices:i,currentDeviceId:n,onSelectDevice:r,onOpenConfig:o,onConnectWifi:u,onDisconnectWifi:l}){const d=An(),[v,h]=w.useState(h1),[g,p]=w.useState(!1),[x,b]=w.useState(""),[E,N]=w.useState("5555"),[j,R]=w.useState(""),[M,B]=w.useState(""),[I,P]=w.useState("custom"),[G,Q]=w.useState("direct"),[X,z]=w.useState(""),[F,C]=w.useState(""),[k,re]=w.useState("5555"),[pe,Y]=w.useState(""),[q,K]=w.useState(!1),[ie,le]=w.useState([]),[Ce,$]=f1(!1,300),[J,ue]=w.useState(""),[ne,be]=w.useState(null),[Ee,He]=w.useState(!1),Qe=w.useRef(null),[Be,D]=w.useState(""),[Se,ae]=w.useState(""),[Fe,tt]=w.useState(!1),[ve,Pe]=w.useState([]),[Z,ee]=w.useState(null),[de,Me]=w.useState(!1);w.useEffect(()=>{localStorage.setItem("sidebar-collapsed",JSON.stringify(v))},[v]),w.useEffect(()=>{const U=me=>{(me.metaKey||me.ctrlKey)&&me.key==="b"&&(me.preventDefault(),h(!v))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[v]);const ce=()=>{h(!v)},fe=U=>/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/.test(U)?U.split(".").every(ur=>{const Hr=parseInt(ur,10);return Hr>=0&&Hr<=255}):!1,ye=U=>{const me=parseInt(U,10);return!isNaN(me)&&me>=1&&me<=65535},xe=U=>/^\d{6}$/.test(U),Ve=async()=>{R(""),B("");let U=!1;if(fe(x)||(R(d.deviceSidebar.invalidIpError),U=!0),ye(E)||(B(d.deviceSidebar.invalidPortError),U=!0),!U){K(!0);try{const me=await Cc({ip:x,port:parseInt(E,10)});me.success?(p(!1),b(""),N("5555")):R(me.message||d.toasts.wifiManualConnectError)}catch{R(d.toasts.wifiManualConnectError)}finally{K(!1)}}},pt=async()=>{Y(""),R(""),B("");let U=!1;if(fe(x)||(R(d.deviceSidebar.invalidIpError),U=!0),ye(F)||(B(d.deviceSidebar.invalidPortError),U=!0),ye(k)||(B(d.deviceSidebar.invalidPortError),U=!0),xe(X)||(Y(d.deviceSidebar.invalidPairingCodeError),U=!0),!U){K(!0);try{const me=await Nx({ip:x,pairing_port:parseInt(F,10),pairing_code:X,connection_port:parseInt(k,10)});me.success?(p(!1),b(""),N("5555"),z(""),C(""),re("5555"),Q("direct")):me.error==="invalid_pairing_code"?Y(me.message):me.error==="invalid_ip"?R(me.message):R(me.message||d.toasts.wifiPairError)}catch{R(d.toasts.wifiPairError)}finally{K(!1)}}},st=w.useCallback(()=>{Qe.current!==null&&(clearInterval(Qe.current),Qe.current=null)},[]),at=w.useCallback(U=>{st(),Qe.current=window.setInterval(async()=>{try{const me=await yx(U);be(It=>It?{...It,status:me.status}:null),["connected","timeout","error"].includes(me.status)&&(st(),me.status==="connected"&&setTimeout(()=>{p(!1),be(null)},2e3))}catch(me){console.error("[QR Pairing] Status poll failed:",me)}},1e3)},[st]),lt=w.useCallback(async()=>{He(!0);try{const U=await wx();U.success&&U.qr_payload&&U.session_id&&(be({sessionId:U.session_id,payload:U.qr_payload,status:"listening",expiresAt:U.expires_at??Date.now()+12e4}),at(U.session_id))}catch(U){console.error("[QR Pairing] Generation failed:",U)}finally{He(!1)}},[at]),Pn=w.useCallback(async()=>{if(ne)try{await Ex(ne.sessionId),be(null),st()}catch(U){console.error("[QR Pairing] Cancel failed:",U)}},[ne,st]),Gn=async()=>{if(ae(""),!Be.trim()){ae(d.deviceSidebar.remoteUrlRequired||"请输入远程服务器地址");return}if(!Be.startsWith("http://")&&!Be.startsWith("https://")){ae(d.deviceSidebar.remoteUrlInvalid||"地址必须以 http:// 或 https:// 开头");return}tt(!0);try{const U=await Cx({base_url:Be,timeout:5});U.success?(Pe(U.devices),ee(null)):(ae(U.message||"发现设备失败"),Pe([]))}catch{ae("连接失败,请检查地址是否正确"),Pe([])}finally{tt(!1)}},cr=async()=>{if(Z){Me(!0);try{const U=await Tx({base_url:Be,device_id:Z});U.success?(p(!1),D(""),Pe([]),ee(null)):ae(U.message||d.toasts.remoteDeviceAddError)}catch{ae(d.toasts.remoteDeviceAddError)}finally{Me(!1)}}};w.useEffect(()=>{(!g||G!=="pair")&&(ne&&ne.status==="listening"&&Pn(),st())},[g,G,ne,st,Pn]),w.useEffect(()=>()=>{st()},[st]),w.useEffect(()=>{g&&G==="pair"&&!ne&&!Ee&&lt()},[g,G,ne,Ee,lt]);const rn=w.useCallback(async()=>{$(!0),ue("");try{const U=await Sx();U.success?le(U.devices):(ue(U.error||d.deviceSidebar.scanError.replace("{error}","Unknown error")),le([]))}catch(U){ue(d.deviceSidebar.scanError.replace("{error}",String(U))),le([])}finally{$(!1)}},[d.deviceSidebar.scanError,$]),zn=async(U,me)=>{if(!me&&!U.has_pairing){K(!0),R("");try{const It=await Cc({ip:U.ip,port:U.port});It.success?p(!1):R(It.message||d.toasts.wifiManualConnectError)}catch(It){R(d.toasts.wifiManualConnectError),console.error("[DeviceSidebar] Error connecting:",It)}finally{K(!1)}}else me&&U.has_pairing&&(b(U.ip),C(U.pairing_port?String(U.pairing_port):""),re(String(U.port)),setTimeout(()=>{document.getElementById("pairing-code")?.focus()},100))};return w.useEffect(()=>{if(g){rn();const U=setInterval(()=>{rn()},5e3);return()=>{clearInterval(U)}}},[g,rn]),a.jsxs(a.Fragment,{children:[v&&a.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:a.jsx(yu,{className:"h-4 w-4"})}),a.jsxs("div",{className:`
26
- ${v?"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:[a.jsxs("div",{className:"flex items-center justify-between p-4",children:[a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("div",{children:[a.jsx("h2",{className:"text-base font-bold text-slate-900 dark:text-slate-100",children:"AutoGLM"}),a.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[i.length," ",(i.length===1,d.deviceSidebar.devices)]})]})}),a.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:a.jsx(bu,{className:"h-4 w-4"})})]}),a.jsx(Cr,{className:"mx-4"}),a.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-2 min-h-0",children:i.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800",children:a.jsx(_v,{className:"h-8 w-8 text-slate-400"})}),a.jsx("p",{className:"mt-4 font-medium text-slate-900 dark:text-slate-100",children:d.deviceSidebar.noDevicesConnected}),a.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:d.deviceSidebar.clickToRefresh})]}):i.map(U=>a.jsx(jv,{id:U.id,serial:U.serial,model:U.model,status:U.status,connectionType:U.connection_type,agent:U.agent,isActive:n===U.id,onClick:()=>r(U.id),onConnectWifi:async()=>{await u(U.id)},onDisconnectWifi:async()=>{await l(U.id)}},U.id))}),a.jsx(Cr,{className:"mx-4"}),a.jsxs("div",{className:"p-3 space-y-2",children:[a.jsxs(we,{variant:"outline",onClick:()=>p(!0),className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[a.jsx(_u,{className:"h-4 w-4"}),d.deviceSidebar.addDevice]}),a.jsxs(we,{variant:"outline",onClick:o,className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[a.jsx(Su,{className:"h-4 w-4"}),d.deviceSidebar.settings]})]}),a.jsx(fu,{open:g,onOpenChange:p,children:a.jsxs(du,{className:"sm:max-w-md max-h-[80vh] overflow-y-auto",children:[a.jsxs(hu,{children:[a.jsx(pu,{children:d.deviceSidebar.manualConnectTitle}),a.jsx(mu,{children:d.deviceSidebar.manualConnectDescription})]}),a.jsxs(Hu,{value:G,onValueChange:Q,className:"w-full",children:[a.jsxs(Gu,{className:"grid w-full grid-cols-3",children:[a.jsx(Ir,{value:"direct",children:d.deviceSidebar.directConnectTab}),a.jsx(Ir,{value:"pair",children:d.deviceSidebar.pairTab}),a.jsx(Ir,{value:"remote",children:d.deviceSidebar.remoteTab||"远程设备"})]}),a.jsxs(Lr,{value:"direct",className:"space-y-4 mt-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h3",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:d.deviceSidebar.discoveredDevices}),a.jsx(we,{variant:"outline",size:"sm",onClick:rn,disabled:Ce,className:"h-8",children:Ce?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"mr-2 h-3 w-3 animate-spin rounded-full border-2 border-slate-400 border-t-transparent"}),d.deviceSidebar.scanning]}):d.deviceSidebar.scanAgain})]}),J&&a.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:a.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:J})}),(()=>{const U=ie.filter(me=>!me.has_pairing);return!Ce&&U.length===0?a.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[a.jsx(zs,{className:"mx-auto h-8 w-8 text-slate-400"}),a.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:d.deviceSidebar.noDirectDevices})]}):U.length>0?a.jsx("div",{className:"space-y-2",children:U.map(me=>a.jsx("button",{onClick:()=>zn(me,!1),disabled:q,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:a.jsx("div",{className:"flex items-start justify-between",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ls,{className:"h-4 w-4 text-[#1d9bf0]"}),a.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:me.name})]}),a.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[me.ip,":",me.port]})]})})},`${me.ip}:${me.port}`))}):null})(),j&&G==="direct"&&a.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:a.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:j})}),a.jsxs("div",{className:"relative my-4",children:[a.jsx(Cr,{}),a.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:d.deviceSidebar.orManualConnect})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{children:d.deviceSidebar.emulatorPreset}),a.jsx("div",{className:"grid grid-cols-3 gap-2",children:d1.map(U=>a.jsx("button",{onClick:()=>{P(U.id),U.id!=="custom"&&(b(U.ip),N(String(U.port))),R(""),B("")},className:`rounded-lg border p-2 text-xs text-center transition-colors ${I===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:d.deviceSidebar[U.nameKey]||U.nameKey},U.id))})]}),a.jsx("div",{className:"rounded-lg bg-blue-50 dark:bg-blue-950/20 p-3 text-sm",children:a.jsx("p",{className:"text-blue-800 dark:text-blue-200",children:d.deviceSidebar.emulatorNote})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{htmlFor:"ip",children:d.deviceSidebar.ipAddress}),a.jsx(wt,{id:"ip",placeholder:"192.168.1.100",value:x,onChange:U=>{b(U.target.value),I!=="custom"&&P("custom")},onKeyDown:U=>U.key==="Enter"&&Ve(),className:j?"border-red-500":""})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{htmlFor:"port",children:d.deviceSidebar.port}),a.jsx(wt,{id:"port",type:"number",value:E,onChange:U=>{N(U.target.value),I!=="custom"&&P("custom")},onKeyDown:U=>U.key==="Enter"&&Ve(),className:M?"border-red-500":""}),M&&a.jsx("p",{className:"text-sm text-red-500",children:M})]}),a.jsx(we,{onClick:Ve,disabled:q,className:"w-full",children:q?d.common.loading:d.deviceSidebar.connect})]})]}),a.jsxs(Lr,{value:"pair",className:"space-y-4 mt-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h3",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:d.deviceSidebar.discoveredDevices}),a.jsx(we,{variant:"outline",size:"sm",onClick:rn,disabled:Ce,className:"h-8",children:Ce?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"mr-2 h-3 w-3 animate-spin rounded-full border-2 border-slate-400 border-t-transparent"}),d.deviceSidebar.scanning]}):d.deviceSidebar.scanAgain})]}),J&&a.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:a.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:J})}),(()=>{const U=ie.filter(me=>me.has_pairing);return!Ce&&U.length===0?a.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[a.jsx(zs,{className:"mx-auto h-8 w-8 text-slate-400"}),a.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:d.deviceSidebar.noPairingDevices})]}):U.length>0?a.jsx("div",{className:"space-y-2",children:U.map(me=>a.jsx("button",{onClick:()=>zn(me,!0),disabled:q,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:a.jsx("div",{className:"flex items-start justify-between",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ls,{className:"h-4 w-4 text-[#1d9bf0]"}),a.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:me.name})]}),a.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[me.ip,":",me.port]}),a.jsxs("div",{className:"mt-2 flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400",children:[a.jsx(kn,{className:"h-3 w-3"}),a.jsx("span",{children:d.deviceSidebar.pairingRequired})]})]})})},`${me.ip}:${me.port}`))}):null})(),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"relative my-4",children:[a.jsx(Cr,{}),a.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:d.deviceSidebar.orQrPair})]}),a.jsxs("div",{className:"rounded-lg bg-purple-50 dark:bg-purple-950/20 p-3 text-sm",children:[a.jsx("p",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:d.deviceSidebar.qrPairingTitle}),a.jsxs("ol",{className:"space-y-1 text-purple-700 dark:text-purple-300 text-xs",children:[a.jsx("li",{children:d.deviceSidebar.qrStep1}),a.jsx("li",{children:d.deviceSidebar.qrStep2}),a.jsx("li",{children:d.deviceSidebar.qrStep3})]})]}),ne&&a.jsx("div",{className:"rounded-lg border border-slate-200 dark:border-slate-700 p-4 bg-white dark:bg-slate-900",children:a.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[a.jsx("div",{className:"bg-white p-4 rounded-lg",children:a.jsx(tf,{value:ne.payload,size:200,level:"M"})}),a.jsxs("div",{className:"flex items-center gap-2",children:[ne.status==="listening"&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"h-2 w-2 rounded-full bg-blue-500 animate-pulse"}),a.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:d.deviceSidebar.qrWaitingForScan})]}),ne.status==="pairing"&&a.jsxs(a.Fragment,{children:[a.jsx(Zt,{className:"h-4 w-4 animate-spin text-blue-500"}),a.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:d.deviceSidebar.qrPairing})]}),ne.status==="connected"&&a.jsxs(a.Fragment,{children:[a.jsx(kc,{className:"h-4 w-4 text-green-500"}),a.jsx("span",{className:"text-sm text-green-600 dark:text-green-400",children:d.deviceSidebar.qrConnected})]}),ne.status==="timeout"&&a.jsxs(a.Fragment,{children:[a.jsx(Ac,{className:"h-4 w-4 text-amber-500"}),a.jsx("span",{className:"text-sm text-amber-600 dark:text-amber-400",children:d.deviceSidebar.qrTimeout})]}),ne.status==="error"&&a.jsxs(a.Fragment,{children:[a.jsx(Ac,{className:"h-4 w-4 text-red-500"}),a.jsx("span",{className:"text-sm text-red-600 dark:text-red-400",children:d.deviceSidebar.qrError})]})]}),a.jsxs("div",{className:"flex gap-2 w-full",children:[(ne.status==="timeout"||ne.status==="error")&&a.jsx(we,{variant:"outline",onClick:lt,className:"flex-1",children:d.deviceSidebar.qrRegenerate}),ne.status==="listening"&&a.jsx(we,{variant:"outline",onClick:Pn,className:"flex-1",children:d.common.cancel}),ne.status==="connected"&&a.jsx(we,{onClick:()=>p(!1),className:"flex-1",children:d.common.confirm})]})]})}),!ne&&Ee&&a.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-slate-600 dark:text-slate-400",children:[a.jsx(Zt,{className:"h-4 w-4 animate-spin"}),a.jsx("span",{className:"text-sm",children:d.common.loading})]})]}),a.jsxs("div",{className:"relative my-4",children:[a.jsx(Cr,{}),a.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:d.deviceSidebar.orManualPair})]}),a.jsxs("div",{className:"rounded-lg bg-blue-50 dark:bg-blue-950/20 p-3 text-sm",children:[a.jsx("p",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:d.deviceSidebar.pairingInstructions}),a.jsxs("ol",{className:"space-y-1 text-blue-700 dark:text-blue-300 text-xs",children:[a.jsx("li",{children:d.deviceSidebar.pairingStep1}),a.jsx("li",{children:d.deviceSidebar.pairingStep2}),a.jsx("li",{children:d.deviceSidebar.pairingStep3}),a.jsx("li",{children:d.deviceSidebar.pairingStep4})]}),a.jsx("p",{className:"mt-2 text-xs text-blue-600 dark:text-blue-400",children:d.deviceSidebar.pairingNote})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{htmlFor:"pair-ip",children:d.deviceSidebar.ipAddress}),a.jsx(wt,{id:"pair-ip",placeholder:"192.168.1.100",value:x,onChange:U=>b(U.target.value),className:j?"border-red-500":""}),j&&G==="pair"&&a.jsx("p",{className:"text-sm text-red-500",children:j})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{htmlFor:"pairing-port",children:d.deviceSidebar.pairingPort}),a.jsx(wt,{id:"pairing-port",type:"number",placeholder:"37831",value:F,onChange:U=>C(U.target.value),className:M?"border-red-500":""}),M&&a.jsx("p",{className:"text-sm text-red-500",children:M})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{htmlFor:"pairing-code",children:d.deviceSidebar.pairingCode}),a.jsx(wt,{id:"pairing-code",type:"text",placeholder:"123456",maxLength:6,value:X,onChange:U=>z(U.target.value.replace(/\D/g,"")),onKeyDown:U=>U.key==="Enter"&&pt(),className:pe?"border-red-500":""}),pe&&a.jsx("p",{className:"text-sm text-red-500",children:pe})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{htmlFor:"connection-port",children:d.deviceSidebar.connectionPort}),a.jsx(wt,{id:"connection-port",type:"number",value:k,onChange:U=>re(U.target.value),onKeyDown:U=>U.key==="Enter"&&pt()})]}),a.jsx(we,{onClick:pt,disabled:q,className:"w-full",children:q?d.common.loading:d.deviceSidebar.pairAndConnect})]})]}),a.jsxs(Lr,{value:"remote",className:"space-y-4 mt-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{htmlFor:"remote-url",children:d.deviceSidebar.remoteUrl||"远程服务器地址"}),a.jsx(wt,{id:"remote-url",placeholder:"http://192.168.1.100:8001",value:Be,onChange:U=>{D(U.target.value),ae("")},disabled:Fe,onKeyDown:U=>U.key==="Enter"&&Gn(),className:Se?"border-red-500":""}),Se&&a.jsx("p",{className:"text-sm text-red-500",children:Se}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:d.deviceSidebar.remoteUrlHint||"运行 Device Agent Server 的地址"}),a.jsx(we,{onClick:Gn,disabled:Fe||!Be,className:"w-full",children:Fe?"正在发现...":"发现设备"})]}),ve.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{children:"可用设备"}),a.jsx("div",{className:"space-y-2",children:ve.map(U=>a.jsx("button",{onClick:()=>ee(U.device_id),className:`
34
- w-full rounded-lg border p-3 text-left transition-colors
35
- ${Z===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:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ls,{className:"h-4 w-4 text-[#1d9bf0]"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"font-medium text-sm",children:U.device_id}),a.jsxs("p",{className:"text-xs text-slate-500",children:[U.model," · ",U.platform]})]}),Z===U.device_id&&a.jsx(kc,{className:"h-4 w-4 text-[#1d9bf0]"})]})},U.device_id))})]}),Z&&a.jsx(we,{onClick:cr,disabled:de,className:"w-full",children:de?"正在连接...":"连接远程设备"})]})]}),a.jsx(gu,{children:a.jsx(we,{variant:"outline",onClick:()=>{p(!1),R(""),B(""),Y(""),ue(""),b(""),N("5555"),z(""),C(""),re("5555"),Q("direct"),le([])},children:d.common.cancel})})]})})]})]})}const tn=Object.create(null);tn.open="0";tn.close="1";tn.ping="2";tn.pong="3";tn.message="4";tn.upgrade="5";tn.noop="6";const Ms=Object.create(null);Object.keys(tn).forEach(i=>{Ms[tn[i]]=i});const Io={type:"error",data:"parser error"},rf=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",sf=typeof ArrayBuffer=="function",of=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i&&i.buffer instanceof ArrayBuffer,Wo=({type:i,data:n},r,o)=>rf&&n instanceof Blob?r?o(n):Oc(n,o):sf&&(n instanceof ArrayBuffer||of(n))?r?o(n):Oc(new Blob([n]),o):o(tn[i]+(n||"")),Oc=(i,n)=>{const r=new FileReader;return r.onload=function(){const o=r.result.split(",")[1];n("b"+(o||""))},r.readAsDataURL(i)};function Bc(i){return i instanceof Uint8Array?i:i instanceof ArrayBuffer?new Uint8Array(i):new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}let _o;function m1(i,n){if(rf&&i.data instanceof Blob)return i.data.arrayBuffer().then(Bc).then(n);if(sf&&(i.data instanceof ArrayBuffer||of(i.data)))return n(Bc(i.data));Wo(i,!1,r=>{_o||(_o=new TextEncoder),n(_o.encode(r))})}const Fc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",jr=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let i=0;i<Fc.length;i++)jr[Fc.charCodeAt(i)]=i;const g1=i=>{let n=i.length*.75,r=i.length,o,u=0,l,d,v,h;i[i.length-1]==="="&&(n--,i[i.length-2]==="="&&n--);const g=new ArrayBuffer(n),p=new Uint8Array(g);for(o=0;o<r;o+=4)l=jr[i.charCodeAt(o)],d=jr[i.charCodeAt(o+1)],v=jr[i.charCodeAt(o+2)],h=jr[i.charCodeAt(o+3)],p[u++]=l<<2|d>>4,p[u++]=(d&15)<<4|v>>2,p[u++]=(v&3)<<6|h&63;return g},_1=typeof ArrayBuffer=="function",Ho=(i,n)=>{if(typeof i!="string")return{type:"message",data:af(i,n)};const r=i.charAt(0);return r==="b"?{type:"message",data:x1(i.substring(1),n)}:Ms[r]?i.length>1?{type:Ms[r],data:i.substring(1)}:{type:Ms[r]}:Io},x1=(i,n)=>{if(_1){const r=g1(i);return af(r,n)}else return{base64:!0,data:i}},af=(i,n)=>{switch(n){case"blob":return i instanceof Blob?i:new Blob([i]);case"arraybuffer":default:return i instanceof ArrayBuffer?i:i.buffer}},lf="",v1=(i,n)=>{const r=i.length,o=new Array(r);let u=0;i.forEach((l,d)=>{Wo(l,!1,v=>{o[d]=v,++u===r&&n(o.join(lf))})})},b1=(i,n)=>{const r=i.split(lf),o=[];for(let u=0;u<r.length;u++){const l=Ho(r[u],n);if(o.push(l),l.type==="error")break}return o};function y1(){return new TransformStream({transform(i,n){m1(i,r=>{const o=r.length;let u;if(o<126)u=new Uint8Array(1),new DataView(u.buffer).setUint8(0,o);else if(o<65536){u=new Uint8Array(3);const l=new DataView(u.buffer);l.setUint8(0,126),l.setUint16(1,o)}else{u=new Uint8Array(9);const l=new DataView(u.buffer);l.setUint8(0,127),l.setBigUint64(1,BigInt(o))}i.data&&typeof i.data!="string"&&(u[0]|=128),n.enqueue(u),n.enqueue(r)})}})}let xo;function js(i){return i.reduce((n,r)=>n+r.length,0)}function Is(i,n){if(i[0].length===n)return i.shift();const r=new Uint8Array(n);let o=0;for(let u=0;u<n;u++)r[u]=i[0][o++],o===i[0].length&&(i.shift(),o=0);return i.length&&o<i[0].length&&(i[0]=i[0].slice(o)),r}function w1(i,n){xo||(xo=new TextDecoder);const r=[];let o=0,u=-1,l=!1;return new TransformStream({transform(d,v){for(r.push(d);;){if(o===0){if(js(r)<1)break;const h=Is(r,1);l=(h[0]&128)===128,u=h[0]&127,u<126?o=3:u===126?o=1:o=2}else if(o===1){if(js(r)<2)break;const h=Is(r,2);u=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),o=3}else if(o===2){if(js(r)<8)break;const h=Is(r,8),g=new DataView(h.buffer,h.byteOffset,h.length),p=g.getUint32(0);if(p>Math.pow(2,21)-1){v.enqueue(Io);break}u=p*Math.pow(2,32)+g.getUint32(4),o=3}else{if(js(r)<u)break;const h=Is(r,u);v.enqueue(Ho(l?h:xo.decode(h),n)),o=0}if(u===0||u>i){v.enqueue(Io);break}}}})}const cf=4;function ot(i){if(i)return E1(i)}function E1(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 o,u=0;u<r.length;u++)if(o=r[u],o===n||o.fn===n){r.splice(u,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],o=1;o<arguments.length;o++)n[o-1]=arguments[o];if(r){r=r.slice(0);for(var o=0,u=r.length;o<u;++o)r[o].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 Qs=typeof Promise=="function"&&typeof Promise.resolve=="function"?n=>Promise.resolve().then(n):(n,r)=>r(n,0),Ht=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),S1="arraybuffer";function uf(i,...n){return n.reduce((r,o)=>(i.hasOwnProperty(o)&&(r[o]=i[o]),r),{})}const N1=Ht.setTimeout,C1=Ht.clearTimeout;function Js(i,n){n.useNativeTimers?(i.setTimeoutFn=N1.bind(Ht),i.clearTimeoutFn=C1.bind(Ht)):(i.setTimeoutFn=Ht.setTimeout.bind(Ht),i.clearTimeoutFn=Ht.clearTimeout.bind(Ht))}const T1=1.33;function R1(i){return typeof i=="string"?k1(i):Math.ceil((i.byteLength||i.size)*T1)}function k1(i){let n=0,r=0;for(let o=0,u=i.length;o<u;o++)n=i.charCodeAt(o),n<128?r+=1:n<2048?r+=2:n<55296||n>=57344?r+=3:(o++,r+=4);return r}function ff(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function A1(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 o=0,u=r.length;o<u;o++){let l=r[o].split("=");n[decodeURIComponent(l[0])]=decodeURIComponent(l[1])}return n}class j1 extends Error{constructor(n,r,o){super(n),this.description=r,this.context=o,this.type="TransportError"}}class Go extends ot{constructor(n){super(),this.writable=!1,Js(this,n),this.opts=n,this.query=n.query,this.socket=n.socket,this.supportsBinary=!n.forceBase64}onError(n,r,o){return super.emitReserved("error",new j1(n,r,o)),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=Ho(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=A1(n);return r.length?"?"+r:""}}class I1 extends Go{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 o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||r()})),this.writable||(o++,this.once("drain",function(){--o||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(n){const r=o=>{if(this.readyState==="opening"&&o.type==="open"&&this.onOpen(),o.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(o)};b1(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,v1(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]=ff()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(n,r)}}let df=!1;try{df=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const L1=df;function M1(){}class D1 extends I1{constructor(n){if(super(n),typeof location<"u"){const r=location.protocol==="https:";let o=location.port;o||(o=r?"443":"80"),this.xd=typeof location<"u"&&n.hostname!==location.hostname||o!==n.port}}doWrite(n,r){const o=this.request({method:"POST",data:n});o.on("success",r),o.on("error",(u,l)=>{this.onError("xhr post error",u,l)})}doPoll(){const n=this.request();n.on("data",this.onData.bind(this)),n.on("error",(r,o)=>{this.onError("xhr poll error",r,o)}),this.pollXhr=n}}class en extends ot{constructor(n,r,o){super(),this.createRequest=n,Js(this,o),this._opts=o,this._method=o.method||"GET",this._uri=r,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var n;const r=uf(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(r);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let u in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(u)&&o.setRequestHeader(u,this._opts.extraHeaders[u])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(n=this._opts.cookieJar)===null||n===void 0||n.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var u;o.readyState===3&&((u=this._opts.cookieJar)===null||u===void 0||u.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(u){this.setTimeoutFn(()=>{this._onError(u)},0);return}typeof document<"u"&&(this._index=en.requestsCount++,en.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=M1,n)try{this._xhr.abort()}catch{}typeof document<"u"&&delete en.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()}}en.requestsCount=0;en.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Uc);else if(typeof addEventListener=="function"){const i="onpagehide"in Ht?"pagehide":"unload";addEventListener(i,Uc,!1)}}function Uc(){for(let i in en.requests)en.requests.hasOwnProperty(i)&&en.requests[i].abort()}const O1=(function(){const i=hf({xdomain:!1});return i&&i.responseType!==null})();class B1 extends D1{constructor(n){super(n);const r=n&&n.forceBase64;this.supportsBinary=O1&&!r}request(n={}){return Object.assign(n,{xd:this.xd},this.opts),new en(hf,this.uri(),n)}}function hf(i){const n=i.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!n||L1))return new XMLHttpRequest}catch{}if(!n)try{return new Ht[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const pf=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class F1 extends Go{get name(){return"websocket"}doOpen(){const n=this.uri(),r=this.opts.protocols,o=pf?{}:uf(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(o.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(n,r,o)}catch(u){return this.emitReserved("error",u)}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 o=n[r],u=r===n.length-1;Wo(o,this.supportsBinary,l=>{try{this.doWrite(o,l)}catch{}u&&Qs(()=>{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]=ff()),this.supportsBinary||(r.b64=1),this.createUri(n,r)}}const vo=Ht.WebSocket||Ht.MozWebSocket;class U1 extends F1{createSocket(n,r,o){return pf?new vo(n,r,o):r?new vo(n,r):new vo(n)}doWrite(n,r){this.ws.send(r)}}class W1 extends Go{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=w1(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=n.readable.pipeThrough(r).getReader(),u=y1();u.readable.pipeTo(n.writable),this._writer=u.writable.getWriter();const l=()=>{o.read().then(({done:v,value:h})=>{v||(this.onPacket(h),l())}).catch(v=>{})};l();const d={type:"open"};this.query.sid&&(d.data=`{"sid":"${this.query.sid}"}`),this._writer.write(d).then(()=>this.onOpen())})})}write(n){this.writable=!1;for(let r=0;r<n.length;r++){const o=n[r],u=r===n.length-1;this._writer.write(o).then(()=>{u&&Qs(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var n;(n=this._transport)===null||n===void 0||n.close()}}const H1={websocket:U1,webtransport:W1,polling:B1},G1=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,z1=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Lo(i){if(i.length>8e3)throw"URI too long";const n=i,r=i.indexOf("["),o=i.indexOf("]");r!=-1&&o!=-1&&(i=i.substring(0,r)+i.substring(r,o).replace(/:/g,";")+i.substring(o,i.length));let u=G1.exec(i||""),l={},d=14;for(;d--;)l[z1[d]]=u[d]||"";return r!=-1&&o!=-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=q1(l,l.path),l.queryKey=$1(l,l.query),l}function q1(i,n){const r=/\/{2,9}/g,o=n.replace(r,"/").split("/");return(n.slice(0,1)=="/"||n.length===0)&&o.splice(0,1),n.slice(-1)=="/"&&o.splice(o.length-1,1),o}function $1(i,n){const r={};return n.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,u,l){u&&(r[u]=l)}),r}const Mo=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ds=[];Mo&&addEventListener("offline",()=>{Ds.forEach(i=>i())},!1);class Rn extends ot{constructor(n,r){if(super(),this.binaryType=S1,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 o=Lo(n);r.hostname=o.host,r.secure=o.protocol==="https"||o.protocol==="wss",r.port=o.port,o.query&&(r.query=o.query)}else r.host&&(r.hostname=Lo(r.host).host);Js(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(o=>{const u=o.prototype.name;this.transports.push(u),this._transportsByName[u]=o}),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)),Mo&&(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"})},Ds.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(n){const r=Object.assign({},this.opts.query);r.EIO=cf,r.transport=n,this.id&&(r.sid=this.id);const o=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](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const n=this.opts.rememberUpgrade&&Rn.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",Rn.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 o=0;o<this.writeBuffer.length;o++){const u=this.writeBuffer[o].data;if(u&&(r+=R1(u)),o>0&&r>this._maxPayload)return this.writeBuffer.slice(0,o);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const n=Date.now()>this._pingTimeoutTime;return n&&(this._pingTimeoutTime=0,Qs(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),n}write(n,r,o){return this._sendPacket("message",n,r,o),this}send(n,r,o){return this._sendPacket("message",n,r,o),this}_sendPacket(n,r,o,u){if(typeof r=="function"&&(u=r,r=void 0),typeof o=="function"&&(u=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const l={type:n,data:r,options:o};this.emitReserved("packetCreate",l),this.writeBuffer.push(l),u&&this.once("flush",u),this.flush()}close(){const n=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),n()},o=()=>{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?o():n()}):this.upgrading?o():n()),this}_onError(n){if(Rn.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(),Mo&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=Ds.indexOf(this._offlineEventListener);o!==-1&&Ds.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",n,r),this.writeBuffer=[],this._prevBufferLen=0}}}Rn.protocol=cf;class X1 extends Rn{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),o=!1;Rn.priorWebsocketSuccess=!1;const u=()=>{o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",x=>{if(!o)if(x.type==="pong"&&x.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;Rn.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(p(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const b=new Error("probe error");b.transport=r.name,this.emitReserved("upgradeError",b)}}))};function l(){o||(o=!0,p(),r.close(),r=null)}const d=x=>{const b=new Error("probe error: "+x);b.transport=r.name,l(),this.emitReserved("upgradeError",b)};function v(){d("transport closed")}function h(){d("socket closed")}function g(x){r&&x.name!==r.name&&l()}const p=()=>{r.removeListener("open",u),r.removeListener("error",d),r.removeListener("close",v),this.off("close",h),this.off("upgrading",g)};r.once("open",u),r.once("error",d),r.once("close",v),this.once("close",h),this.once("upgrading",g),this._upgrades.indexOf("webtransport")!==-1&&n!=="webtransport"?this.setTimeoutFn(()=>{o||r.open()},200):r.open()}onHandshake(n){this._upgrades=this._filterUpgrades(n.upgrades),super.onHandshake(n)}_filterUpgrades(n){const r=[];for(let o=0;o<n.length;o++)~this.transports.indexOf(n[o])&&r.push(n[o]);return r}}let Y1=class extends X1{constructor(n,r={}){const o=typeof n=="object"?n:r;(!o.transports||o.transports&&typeof o.transports[0]=="string")&&(o.transports=(o.transports||["polling","websocket","webtransport"]).map(u=>H1[u]).filter(u=>!!u)),super(n,o)}};function V1(i,n="",r){let o=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),o=Lo(i)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const l=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+l+":"+o.port+n,o.href=o.protocol+"://"+l+(r&&r.port===o.port?"":":"+o.port),o}const K1=typeof ArrayBuffer=="function",Q1=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,mf=Object.prototype.toString,J1=typeof Blob=="function"||typeof Blob<"u"&&mf.call(Blob)==="[object BlobConstructor]",Z1=typeof File=="function"||typeof File<"u"&&mf.call(File)==="[object FileConstructor]";function zo(i){return K1&&(i instanceof ArrayBuffer||Q1(i))||J1&&i instanceof Blob||Z1&&i instanceof File}function Os(i,n){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let r=0,o=i.length;r<o;r++)if(Os(i[r]))return!0;return!1}if(zo(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Os(i.toJSON(),!0);for(const r in i)if(Object.prototype.hasOwnProperty.call(i,r)&&Os(i[r]))return!0;return!1}function eb(i){const n=[],r=i.data,o=i;return o.data=Do(r,n),o.attachments=n.length,{packet:o,buffers:n}}function Do(i,n){if(!i)return i;if(zo(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 o=0;o<i.length;o++)r[o]=Do(i[o],n);return r}else if(typeof i=="object"&&!(i instanceof Date)){const r={};for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=Do(i[o],n));return r}return i}function tb(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 nb=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],rb=5;var Oe;(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"})(Oe||(Oe={}));class sb{constructor(n){this.replacer=n}encode(n){return(n.type===Oe.EVENT||n.type===Oe.ACK)&&Os(n)?this.encodeAsBinary({type:n.type===Oe.EVENT?Oe.BINARY_EVENT:Oe.BINARY_ACK,nsp:n.nsp,data:n.data,id:n.id}):[this.encodeAsString(n)]}encodeAsString(n){let r=""+n.type;return(n.type===Oe.BINARY_EVENT||n.type===Oe.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=eb(n),o=this.encodeAsString(r.packet),u=r.buffers;return u.unshift(o),u}}function Wc(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 o=r.type===Oe.BINARY_EVENT;o||r.type===Oe.BINARY_ACK?(r.type=o?Oe.EVENT:Oe.ACK,this.reconstructor=new ib(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(zo(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 o={type:Number(n.charAt(0))};if(Oe[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===Oe.BINARY_EVENT||o.type===Oe.BINARY_ACK){const l=r+1;for(;n.charAt(++r)!=="-"&&r!=n.length;);const d=n.substring(l,r);if(d!=Number(d)||n.charAt(r)!=="-")throw new Error("Illegal attachments");o.attachments=Number(d)}if(n.charAt(r+1)==="/"){const l=r+1;for(;++r&&!(n.charAt(r)===","||r===n.length););o.nsp=n.substring(l,r)}else o.nsp="/";const u=n.charAt(r+1);if(u!==""&&Number(u)==u){const l=r+1;for(;++r;){const d=n.charAt(r);if(d==null||Number(d)!=d){--r;break}if(r===n.length)break}o.id=Number(n.substring(l,r+1))}if(n.charAt(++r)){const l=this.tryParse(n.substr(r));if(qo.isPayloadValid(o.type,l))o.data=l;else throw new Error("invalid payload")}return o}tryParse(n){try{return JSON.parse(n,this.reviver)}catch{return!1}}static isPayloadValid(n,r){switch(n){case Oe.CONNECT:return Wc(r);case Oe.DISCONNECT:return r===void 0;case Oe.CONNECT_ERROR:return typeof r=="string"||Wc(r);case Oe.EVENT:case Oe.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&nb.indexOf(r[0])===-1);case Oe.ACK:case Oe.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class ib{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=tb(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const ob=Object.freeze(Object.defineProperty({__proto__:null,Decoder:qo,Encoder:sb,get PacketType(){return Oe},protocol:rb},Symbol.toStringTag,{value:"Module"}));function Yt(i,n,r){return i.on(n,r),function(){i.off(n,r)}}const ab=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class gf extends ot{constructor(n,r,o){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,o&&o.auth&&(this.auth=o.auth),this._opts=Object.assign({},o),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const n=this.io;this.subs=[Yt(n,"open",this.onopen.bind(this)),Yt(n,"packet",this.onpacket.bind(this)),Yt(n,"error",this.onerror.bind(this)),Yt(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 o,u,l;if(ab.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 d={type:Oe.EVENT,data:r};if(d.options={},d.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const p=this.ids++,x=r.pop();this._registerAckCallback(p,x),d.id=p}const v=(u=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||u===void 0?void 0:u.writable,h=this.connected&&!(!((l=this.io.engine)===null||l===void 0)&&l._hasPingExpired());return this.flags.volatile&&!v||(h?(this.notifyOutgoingListeners(d),this.packet(d)):this.sendBuffer.push(d)),this.flags={},this}_registerAckCallback(n,r){var o;const u=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(u===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"))},u),d=(...v)=>{this.io.clearTimeoutFn(l),r.apply(this,v)};d.withError=!0,this.acks[n]=d}emitWithAck(n,...r){return new Promise((o,u)=>{const l=(d,v)=>d?u(d):o(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 o={id:this._queueSeq++,tryCount:0,pending:!1,args:n,flags:Object.assign({fromQueue:!0},this.flags)};n.push((u,...l)=>o!==this._queue[0]?void 0:(u!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(u)):(this._queue.shift(),r&&r(null,...l)),o.pending=!1,this._drainQueue())),this._queue.push(o),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:Oe.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(o=>String(o.id)===n)){const o=this.acks[n];delete this.acks[n],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(n){if(n.nsp===this.nsp)switch(n.type){case Oe.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 Oe.EVENT:case Oe.BINARY_EVENT:this.onevent(n);break;case Oe.ACK:case Oe.BINARY_ACK:this.onack(n);break;case Oe.DISCONNECT:this.ondisconnect();break;case Oe.CONNECT_ERROR:this.destroy();const o=new Error(n.data.message);o.data=n.data.data,this.emitReserved("connect_error",o);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 o of r)o.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 o=!1;return function(...u){o||(o=!0,r.packet({type:Oe.ACK,id:n,data:u}))}}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:Oe.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 o=0;o<r.length;o++)if(n===r[o])return r.splice(o,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 o=0;o<r.length;o++)if(n===r[o])return r.splice(o,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 o of r)o.apply(this,n.data)}}}function lr(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}lr.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};lr.prototype.reset=function(){this.attempts=0};lr.prototype.setMin=function(i){this.ms=i};lr.prototype.setMax=function(i){this.max=i};lr.prototype.setJitter=function(i){this.jitter=i};class Bo extends ot{constructor(n,r){var o;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,Js(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((o=r.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new lr({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=n;const u=r.parser||ob;this.encoder=new u.Encoder,this.decoder=new u.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 Y1(this.uri,this.opts);const r=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const u=Yt(r,"open",function(){o.onopen(),n&&n()}),l=v=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",v),n?n(v):this.maybeReconnectOnOpen()},d=Yt(r,"error",l);if(this._timeout!==!1){const v=this._timeout,h=this.setTimeoutFn(()=>{u(),l(new Error("timeout")),r.close()},v);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(u),this.subs.push(d),this}connect(n){return this.open(n)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const n=this.engine;this.subs.push(Yt(n,"ping",this.onping.bind(this)),Yt(n,"data",this.ondata.bind(this)),Yt(n,"error",this.onerror.bind(this)),Yt(n,"close",this.onclose.bind(this)),Yt(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){Qs(()=>{this.emitReserved("packet",n)},this.setTimeoutFn)}onerror(n){this.emitReserved("error",n)}socket(n,r){let o=this.nsps[n];return o?this._autoConnect&&!o.active&&o.connect():(o=new gf(this,n,r),this.nsps[n]=o),o}_destroy(n){const r=Object.keys(this.nsps);for(const o of r)if(this.nsps[o].active)return;this._close()}_packet(n){const r=this.encoder.encode(n);for(let o=0;o<r.length;o++)this.engine.write(r[o],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 o;this.cleanup(),(o=this.engine)===null||o===void 0||o.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 o=this.setTimeoutFn(()=>{n.skipReconnect||(this.emitReserved("reconnect_attempt",n.backoff.attempts),!n.skipReconnect&&n.open(u=>{u?(n._reconnecting=!1,n.reconnect(),this.emitReserved("reconnect_error",u)):n.onreconnect()}))},r);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const n=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",n)}}const Tr={};function Bs(i,n){typeof i=="object"&&(n=i,i=void 0),n=n||{};const r=V1(i,n.path||"/socket.io"),o=r.source,u=r.id,l=r.path,d=Tr[u]&&l in Tr[u].nsps,v=n.forceNew||n["force new connection"]||n.multiplex===!1||d;let h;return v?h=new Bo(o,n):(Tr[u]||(Tr[u]=new Bo(o,n)),h=Tr[u]),r.query&&!n.query&&(n.query=r.queryKey),h.socket(r.path,n)}Object.assign(Bs,{Manager:Bo,Socket:gf,io:Bs,connect:Bs});function lb(i,n){return(i[n]|i[n+1]<<8|i[n+2]<<16|i[n+3]<<24)>>>0}const Fs={H264:1748121140,H265:1748121141,AV1:6387249},{WritableStream:cb}=globalThis;class ub{#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},db={Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,GenericFilm:8,Bt2020:9,Xyz:10,Smpte431:11,Smpte432:12,Ebu3213:22},hb={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},pb={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 _t extends ub{static ObuType=fb;static ColorPrimaries=db;static TransferCharacteristics=hb;static MatrixCoefficients=pb;#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 o=this.f(8);if(n|=BigInt(o&127)<<7n*r,this.#e+=1,(o&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 o=this.openBitstreamUnit(r);o&&(yield o),n-=r}}#t=0;openBitstreamUnit(n){const r=this.obuHeader();let o;if(r.obu_has_size_field)o=this.leb128();else if(n!==void 0)o=n-1n-(r.obu_extension_flag?1n:0n);else throw new Error("obu_has_size_field must be true");const u=this.getPosition();if(r.obu_type!==_t.ObuType.SequenceHeader&&r.obu_type!==_t.ObuType.TemporalDelimiter&&this.#t!==0&&r.obu_extension_header){const h=!!(this.#t&1<<r.obu_extension_header.temporal_id),g=!!(this.#t&1<<r.obu_extension_header.spatial_id+8);if(!h||!g){this.skip(Number(o));return}}let l;switch(r.obu_type){case _t.ObuType.SequenceHeader:l=this.sequenceHeaderObu();break}const d=this.getPosition(),v=(d[0]-u[0])*8+(u[1]-d[1]);return o>0&&this.skip(Number(o)*8-v),{obu_header:r,obu_size:o,sequence_header_obu:l}}obuHeader(){if(!!this.f1())throw new Error("Invalid data");const r=this.f(4),o=!!this.f1(),u=!!this.f1();this.f1();let l;return o&&(l=this.obuExtensionHeader()),{obu_type:r,obu_extension_flag:o,obu_has_size_field:u,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(),o=!!this.f1();let u=!1,l,d=!1,v,h=!1,g=0;const p=[],x=[],b=[],E=[],N=[];let j,R;if(o)p[0]=0,x[0]=this.f(5),b[0]=0,E[0]=!1,N[0]=!1;else{u=!!this.f1(),u&&(l=this.timingInfo(),d=!!this.f1(),d&&(v=this.decoderModelInfo(),j=[])),h=!!this.f1(),h&&(R=[]),g=this.f(5);for(let D=0;D<=g;D+=1)p[D]=this.f(12),x[D]=this.f(5),x[D]>7?b[D]=this.f1():b[D]=0,d?(E[D]=!!this.f1(),E[D]&&(j[D]=this.operatingParametersInfo(v))):E[D]=!1,h&&(N[D]=!!this.f1(),N[D]&&(R[D]=this.f(4)))}const M=this.chooseOperatingPoint();this.#t=p[M];const B=this.f(4),I=this.f(4),P=this.f(B+1),G=this.f(I+1);let Q=!1,X,z;o||(Q=!!this.f1(),Q&&(X=this.f(4),z=this.f(3)));const F=!!this.f1(),C=!!this.f1(),k=!!this.f1();let re=!1,pe=!1,Y=!1,q=!1,K=!1,ie=!1,le=!1,Ce=!1,$=_t.SelectScreenContentTools,J=!1,ue=_t.SelectIntegerMv,ne;o||(re=!!this.f1(),pe=!!this.f1(),Y=!!this.f1(),q=!!this.f1(),K=!!this.f1(),K&&(ie=!!this.f1(),le=!!this.f1()),Ce=!!this.f1(),Ce||($=this.f1()),$>0&&(J=!!this.f1(),J||(ue=this.f1())),K&&(ne=this.f(3)));const be=!!this.f1(),Ee=!!this.f1(),He=!!this.f1(),Qe=this.colorConfig(n),Be=!!this.f1();return{seq_profile:n,still_picture:r,reduced_still_picture_header:o,timing_info_present_flag:u,timing_info:l,decoder_model_info_present_flag:d,decoder_model_info:v,initial_display_delay_present_flag:h,initial_display_delay_minus_1:R,operating_points_cnt_minus_1:g,operating_point_idc:p,seq_level_idx:x,seq_tier:b,decoder_model_present_for_this_op:E,operating_parameters_info:j,initial_display_delay_present_for_this_op:N,frame_width_bits_minus_1:B,frame_height_bits_minus_1:I,max_frame_width_minus_1:P,max_frame_height_minus_1:G,frame_id_numbers_present_flag:Q,delta_frame_id_length_minus_2:X,additional_frame_id_length_minus_1:z,use_128x128_superblock:F,enable_filter_intra:C,enable_intra_edge_filter:k,enable_interintra_compound:re,enable_masked_compound:pe,enable_warped_motion:Y,enable_dual_filter:q,enable_order_hint:K,enable_jnt_comp:ie,enable_ref_frame_mvs:le,seq_choose_screen_content_tools:Ce,seq_force_screen_content_tools:$,seq_choose_integer_mv:J,seq_force_integer_mv:ue,order_hint_bits_minus_1:ne,enable_superres:be,enable_cdef:Ee,enable_restoration:He,color_config:Qe,film_grain_params_present:Be}}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),o=!!this.f1();let u;return o&&(u=this.uvlc()),{num_units_in_display_tick:n,time_scale:r,equal_picture_interval:o,num_ticks_per_picture_minus_1:u}}decoderModelInfo(){const n=this.f(5),r=this.f(32),o=this.f(5),u=this.f(5);return{buffer_delay_length_minus_1:n,num_units_in_decoding_tick:r,buffer_removal_time_length_minus_1:o,frame_presentation_time_length_minus_1:u}}operatingParametersInfo(n){const r=n.buffer_delay_length_minus_1+1,o=this.f(r),u=this.f(r),l=!!this.f1();return{decoder_buffer_delay:o,encoder_buffer_delay:u,low_delay_mode_flag:l}}chooseOperatingPoint(){return 0}colorConfig(n){const r=!!this.f1();let o=!1,u=8;n===2&&r?(o=!!this.f1(),u=o?12:10):n<=2&&(u=r?10:8);let l=!1;n===1&&(l=!!this.f1());const d=!!this.f1();let v=_t.ColorPrimaries.Unspecified,h=_t.TransferCharacteristics.Unspecified,g=_t.MatrixCoefficients.Unspecified;d&&(v=this.f(8),h=this.f(8),g=this.f(8));let p=!1,x,b,E=0,N=!1;if(l)p=!!this.f1(),x=!0,b=!0;else{if(v===_t.ColorPrimaries.Bt709&&h===_t.TransferCharacteristics.Srgb&&g===_t.MatrixCoefficients.Identity)p=!0,x=!1,b=!1;else{switch(p=!!this.f1(),n){case 0:x=!0,b=!0;break;case 1:x=!1,b=!1;break;default:u==12?(x=!!this.f1(),x?b=!!this.f1():b=!1):(x=!0,b=!1);break}x&&b&&(E=this.f(2))}N=!!this.f1()}return{high_bitdepth:r,twelve_bit:o,BitDepth:u,mono_chrome:l,color_description_present_flag:d,color_primaries:v,transfer_characteristics:h,matrix_coefficients:g,color_range:p,subsampling_x:x,subsampling_y:b,chroma_sample_position:E,separate_uv_delta_q:N}}}function*_f(i){let n=-1,r=0,o=!1;for(let u=0;u<i.length;u+=1){const l=i[u];if(o){if(l>3)throw new Error("Invalid data");o=!1;continue}if(l===0){r+=1;continue}const d=r;if(r=0,n===-1){if(d>=2&&l===1){n=u+1;continue}throw new Error("Invalid data")}if(!(d<2)){if(l===1){yield i.subarray(n,u-d),n=u+1;continue}if(d>2)throw new Error("Invalid data");switch(l){case 2:throw new Error("Invalid data");case 3:o=!0;break}}}if(o)throw new Error("Invalid data");yield i.subarray(n,i.length)}class Zs{#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 o=n[r];for(let u=0;u<8;u+=1)if((o>>u&1)===1){this.#t=r,this.#n=u,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 o=0;o<n;o+=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}#f(){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.#f(),o=this.read(n);return this.#a(r),o}readBytes(n){const r=new Uint8Array(n);for(let o=0;o<n;o+=1)r[o]=this.read(8);return r}peekBytes(n){const r=this.#f(),o=this.readBytes(n);return this.#a(r),o}}function mb(i){const n=new Zs(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 u=n.read(8),l=n.peek(8),d=!!n.next(),v=!!n.next(),h=!!n.next(),g=!!n.next(),p=!!n.next(),x=!!n.next();if(n.read(2)!==0)throw new Error("Invalid data");const b=n.read(8),E=n.decodeExponentialGolombNumber();if(u===100||u===110||u===122||u===244||u===44||u===83||u===86||u===118||u===128||u===138||u===139||u===134){const X=n.decodeExponentialGolombNumber();if(X===3&&n.next(),n.decodeExponentialGolombNumber(),n.decodeExponentialGolombNumber(),n.next(),!!n.next())for(let F=0;F<(X!==3?8:12);F+=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 X=n.decodeExponentialGolombNumber();for(let z=0;z<X;z+=1)n.decodeExponentialGolombNumber()}n.decodeExponentialGolombNumber(),n.next();const j=n.decodeExponentialGolombNumber(),R=n.decodeExponentialGolombNumber(),M=n.next();M||n.next(),n.next();const B=!!n.next();let I,P,G,Q;return B?(I=n.decodeExponentialGolombNumber(),P=n.decodeExponentialGolombNumber(),G=n.decodeExponentialGolombNumber(),Q=n.decodeExponentialGolombNumber()):(I=0,P=0,G=0,Q=0),n.next(),{profile_idc:u,constraint_set:l,constraint_set0_flag:d,constraint_set1_flag:v,constraint_set2_flag:h,constraint_set3_flag:g,constraint_set4_flag:p,constraint_set5_flag:x,level_idc:b,seq_parameter_set_id:E,pic_width_in_mbs_minus1:j,pic_height_in_map_units_minus1:R,frame_mbs_only_flag:M,frame_cropping_flag:B,frame_crop_left_offset:I,frame_crop_right_offset:P,frame_crop_top_offset:G,frame_crop_bottom_offset:Q}}function gb(i){let n,r;for(const o of _f(i))switch(o[0]&31){case 7:if(n=o,r)return{sequenceParameterSet:n,pictureParameterSet:r};break;case 8:if(r=o,n)return{sequenceParameterSet:n,pictureParameterSet:r};break}throw new Error("Invalid data")}function _b(i){const{sequenceParameterSet:n,pictureParameterSet:r}=gb(i),{profile_idc:o,constraint_set:u,level_idc:l,pic_width_in_mbs_minus1:d,pic_height_in_map_units_minus1:v,frame_mbs_only_flag:h,frame_crop_left_offset:g,frame_crop_right_offset:p,frame_crop_top_offset:x,frame_crop_bottom_offset:b}=mb(n),E=(d+1)*16,N=(v+1)*(2-h)*16,j=g*2,R=p*2,M=x*2,B=b*2,I=E-j-R,P=N-M-B;return{pictureParameterSet:r,sequenceParameterSet:n,profileIndex:o,constraintSet:u,levelIndex:l,encodedWidth:E,encodedHeight:N,cropLeft:j,cropRight:R,cropTop:M,cropBottom:B,croppedWidth:I,croppedHeight:P}}function xb(i){switch(i){case 0:case 3:return 1;case 1:case 2:return 2;default:throw new Error("Invalid chroma_format_idc")}}function vb(i){switch(i){case 0:case 2:case 3:return 1;case 1:return 2;default:throw new Error("Invalid chroma_format_idc")}}function bb(i){const n=new Zs(i);if(n.next()!==0)throw new Error("Invalid NALU header");const r=n.read(6),o=n.read(6),u=n.read(3);return{nal_unit_type:r,nuh_layer_id:o,nuh_temporal_id_plus1:u}}function yb(i){const n=new Zs(i),r=n.read(4),o=!!n.next(),u=!!n.next(),l=n.read(6),d=n.read(3),v=!!n.next();n.skip(16);const h=xf(n,!0,d),g=!!n.next(),p=[],x=[],b=[];for(let C=g?0:d;C<=d;C+=1)p[C]=n.decodeExponentialGolombNumber(),x[C]=n.decodeExponentialGolombNumber(),b[C]=n.decodeExponentialGolombNumber();const E=n.read(6),N=n.decodeExponentialGolombNumber(),j=[];for(let C=1;C<=N;C+=1){j[C]=[];for(let k=0;k<=E;k+=1)j[C][k]=!!n.next()}const R=!!n.next();let M,B,I,P,G,Q,X,z;if(R){M=n.read(32),B=n.read(32),I=!!n.next(),I&&(P=n.decodeExponentialGolombNumber()),G=n.decodeExponentialGolombNumber(),Q=[],X=[!0],z=[];for(let C=0;C<G;C+=1)Q[C]=n.decodeExponentialGolombNumber(),C>0&&(X[C]=!!n.next()),z[C]=vf(n,X[C],d)}const F=!!n.next();return{vps_video_parameter_set_id:r,vps_base_layer_internal_flag:o,vps_base_layer_available_flag:u,vps_max_layers_minus1:l,vps_max_sub_layers_minus1:d,vps_temporal_id_nesting_flag:v,profileTierLevel:h,vps_sub_layer_ordering_info_present_flag:g,vps_max_dec_pic_buffering_minus1:p,vps_max_num_reorder_pics:x,vps_max_latency_increase_plus1:b,vps_max_layer_id:E,vps_num_layer_sets_minus1:N,layer_id_included_flag:j,vps_timing_info_present_flag:R,vps_num_units_in_tick:M,vps_time_scale:B,vps_poc_proportional_to_timing_flag:I,vps_num_ticks_poc_diff_one_minus1:P,vps_num_hrd_parameters:G,hrd_layer_set_idx:Q,cprms_present_flag:X,hrdParameters:z,vps_extension_flag:F}}function wb(i){const n=new Zs(i),r=n.read(4),o=n.read(3),u=!!n.next(),l=xf(n,!0,o),d=n.decodeExponentialGolombNumber(),v=n.decodeExponentialGolombNumber();let h;v===3&&(h=!!n.next());const g=n.decodeExponentialGolombNumber(),p=n.decodeExponentialGolombNumber(),x=!!n.next();let b,E,N,j;x&&(b=n.decodeExponentialGolombNumber(),E=n.decodeExponentialGolombNumber(),N=n.decodeExponentialGolombNumber(),j=n.decodeExponentialGolombNumber());const R=n.decodeExponentialGolombNumber(),M=n.decodeExponentialGolombNumber(),B=n.decodeExponentialGolombNumber(),I=[],P=[],G=[],Q=!!n.next();for(let xe=Q?0:o;xe<=o;xe+=1)I[xe]=n.decodeExponentialGolombNumber(),P[xe]=n.decodeExponentialGolombNumber(),G[xe]=n.decodeExponentialGolombNumber();const X=n.decodeExponentialGolombNumber(),z=n.decodeExponentialGolombNumber(),F=n.decodeExponentialGolombNumber(),C=n.decodeExponentialGolombNumber(),k=n.decodeExponentialGolombNumber(),re=n.decodeExponentialGolombNumber(),pe=!!n.next();let Y,q;pe&&(Y=!!n.next(),Y&&(q=Eb(n)));const K=!!n.next(),ie=!!n.next(),le=!!n.next();let Ce,$,J,ue,ne;le&&(Ce=n.read(4),$=n.read(4),J=n.read(4),ue=n.read(4),ne=!!n.next());const be=n.decodeExponentialGolombNumber(),Ee=[];for(let xe=0;xe<be;xe+=1)Ee[xe]=Sb(n,xe,be,Ee);const He=!!n.next();let Qe,Be,D;if(He){Qe=n.decodeExponentialGolombNumber(),Be=[],D=[];for(let xe=0;xe<Qe;xe+=1)Be[xe]=n.read(B+4),D[xe]=!!n.next()}const Se=!!n.next(),ae=!!n.next(),Fe=!!n.next();let tt;Fe&&(tt=Nb(n,o));const ve=!!n.next();let Pe,Z,ee,de,Me;if(ve&&(Pe=!!n.next(),Z=!!n.next(),ee=!!n.next(),de=!!n.next(),Me=n.read(4)),Pe)throw new Error("Not implemented");let ce;Z&&(ce=Tb(n));let fe;if(ee&&(fe=Rb(n)),de)throw new Error("Not implemented");let ye;if(Me){ye=[];let xe=0;for(;!n.ended;)ye[xe]=!!n.next(),xe+=1}return{sps_video_parameter_set_id:r,sps_max_sub_layers_minus1:o,sps_temporal_id_nesting_flag:u,profileTierLevel:l,sps_seq_parameter_set_id:d,chroma_format_idc:v,separate_colour_plane_flag:h,pic_width_in_luma_samples:g,pic_height_in_luma_samples:p,conformance_window_flag:x,conf_win_left_offset:b,conf_win_right_offset:E,conf_win_top_offset:N,conf_win_bottom_offset:j,bit_depth_luma_minus8:R,bit_depth_chroma_minus8:M,log2_max_pic_order_cnt_lsb_minus4:B,sps_sub_layer_ordering_info_present_flag:Q,sps_max_dec_pic_buffering_minus1:I,sps_max_num_reorder_pics:P,sps_max_latency_increase_plus1:G,log2_min_luma_coding_block_size_minus3:X,log2_diff_max_min_luma_coding_block_size:z,log2_min_luma_transform_block_size_minus2:F,log2_diff_max_min_luma_transform_block_size:C,max_transform_hierarchy_depth_inter:k,max_transform_hierarchy_depth_intra:re,scaling_list_enabled_flag:pe,sps_scaling_list_data_present_flag:Y,scalingListData:q,amp_enabled_flag:K,sample_adaptive_offset_enabled_flag:ie,pcm_enabled_flag:le,pcm_sample_bit_depth_luma_minus1:Ce,pcm_sample_bit_depth_chroma_minus1:$,log2_min_pcm_luma_coding_block_size_minus3:J,log2_diff_max_min_pcm_luma_coding_block_size:ue,pcm_loop_filter_disabled_flag:ne,num_short_term_ref_pic_sets:be,shortTermRefPicSets:Ee,long_term_ref_pics_present_flag:He,num_long_term_ref_pics_sps:Qe,lt_ref_pic_poc_lsb_sps:Be,used_by_curr_pic_lt_sps_flag:D,sps_temporal_mvp_enabled_flag:Se,strong_intra_smoothing_enabled_flag:ae,vui_parameters_present_flag:Fe,vuiParameters:tt,sps_extension_present_flag:ve,sps_range_extension_flag:Pe,sps_multilayer_extension_flag:Z,sps_3d_extension_flag:ee,sps_scc_extension_flag:de,sps_extension_4bits:Me,spsMultilayerExtension:ce,sps3dExtension:fe,sps_extension_data_flag:ye}}function Hc(i){const n=i.read(2),r=!!i.next(),o=i.read(5),u=i.peekBytes(4),l=[];for(let Q=0;Q<32;Q+=1)l[Q]=!!i.next();const d=i.peekBytes(6),v=!!i.next(),h=!!i.next(),g=!!i.next(),p=!!i.next();let x,b,E,N,j,R,M,B,I,P;o===4||l[4]||o===5||l[5]||o===6||l[6]||o===7||l[7]||o===8||l[8]||o===9||l[9]||o===10||l[10]||o===11||l[11]?(x=!!i.next(),b=!!i.next(),E=!!i.next(),N=!!i.next(),j=!!i.next(),R=!!i.next(),M=!!i.next(),B=!!i.next(),I=!!i.next(),o===5||l[5]||o===9||l[9]||o===10||l[10]||o===11||l[11]?(P=!!i.next(),i.skip(33)):i.skip(34)):o===2||l[2]?(i.skip(7),B=!!i.next(),i.skip(35)):i.skip(43);let G;return o===1||l[1]||o===2||l[2]||o===3||l[3]||o===4||l[4]||o===5||l[5]||o===9||l[9]||o===11||l[11]?G=!!i.next():i.skip(1),{profile_space:n,tier_flag:r,profile_idc:o,profileCompatibilitySet:u,profile_compatibility_flag:l,constraintSet:d,progressive_source_flag:v,interlaced_source_flag:h,non_packed_constraint_flag:g,frame_only_constraint_flag:p,max_12bit_constraint_flag:x,max_10bit_constraint_flag:b,max_8bit_constraint_flag:E,max_422chroma_constraint_flag:N,max_420chroma_constraint_flag:j,max_monochrome_constraint_flag:R,intra_constraint_flag:M,one_picture_only_constraint_flag:B,lower_bit_rate_constraint_flag:I,max_14bit_constraint_flag:P,inbld_flag:G}}function xf(i,n,r){let o;o=Hc(i);const u=i.read(8),l=[],d=[];for(let g=0;g<r;g+=1)l[g]=!!i.next(),d[g]=!!i.next();if(r>0)for(let g=r;g<8;g+=1)i.read(2);const v=[],h=[];for(let g=0;g<r;g+=1)l[g]&&(v[g]=Hc(i)),d[g]&&(h[g]=i.read(8));return{generalProfileTier:o,general_level_idc:u,sub_layer_profile_present_flag:l,sub_layer_level_present_flag:d,subLayerProfileTier:v,sub_layer_level_idc:h}}function Eb(i){const n=[];for(let r=0;r<4;r+=1){n[r]=[];for(let o=0;o<6;o+=r===3?3:1)if(!!!i.next())i.decodeExponentialGolombNumber();else{let l=8;const d=Math.min(64,1<<4+(r<<1));r>1&&(l=i.decodeExponentialGolombNumber()+8),n[r][o]=[];for(let v=0;v<d;v+=1){const h=i.decodeExponentialGolombNumber();l=(l+h+256)%256,n[r][o][v]=l}}}return n}function Sb(i,n,r,o){let u=!1;n!==0&&(u=!!i.next());let l=0,d=!1,v=0;const h=[],g=[];let p=0,x=0;const b=[],E=[],N=[],j=[];if(u){n===r&&(l=i.decodeExponentialGolombNumber()),d=!!i.next(),v=i.decodeExponentialGolombNumber();const R=n-(l+1),M=o[R],B=M.num_negative_pics+M.num_positive_pics;for(let k=0;k<=B;k+=1)h[k]=!!i.next(),h[k]?g[k]=!0:g[k]=!!i.next();const I=(1-2*Number(d))*(v+1),P=[],G=[],Q=[],X=[];let z=0;for(let k=0;k<M.num_negative_pics;k+=1)z-=M.delta_poc_s0_minus1[k]+1,P[k]=z;z=0;for(let k=0;k<M.num_positive_pics;k+=1)z+=M.delta_poc_s1_minus1[k]+1,G[k]=z;let F=0;if(M.num_positive_pics>0)for(let k=M.num_positive_pics-1;k>=0;k-=1)z=G[k]+I,z<0&&g[M.num_negative_pics+k]&&(Q[F]=z,E[F]=h[M.num_negative_pics+k],F+=1);I<0&&g[B]&&(Q[F]=I,E[F]=h[B],F+=1);for(let k=0;k<M.num_negative_pics;k+=1)z=P[k]+I,z<0&&g[k]&&(Q[F]=z,E[F]=h[k],F+=1);p=F;let C=0;for(F=0;F<p;F+=1){const k=Q[F];b[F]=-(k-C-1),C=k}if(F=0,M.num_negative_pics>0)for(let k=M.num_negative_pics-1;k>=0;k-=1)z=P[k]+I,z>0&&g[k]&&(X[F]=z,j[F]=h[k],F+=1);I>0&&g[B]&&(X[F]=I,j[F]=h[B],F+=1);for(let k=0;k<M.num_positive_pics;k+=1)z=G[k]+I,z>0&&g[M.num_negative_pics+k]&&(X[F]=z,j[F]=h[M.num_negative_pics+k],F+=1);for(x=F,C=0,F=0;F<x;F+=1){const k=X[F];N[F]=k-C-1,C=k}}else{p=i.decodeExponentialGolombNumber(),x=i.decodeExponentialGolombNumber();for(let R=0;R<p;R+=1)b[R]=i.decodeExponentialGolombNumber(),E[R]=!!i.next();for(let R=0;R<x;R+=1)N[R]=i.decodeExponentialGolombNumber(),j[R]=!!i.next()}return{stRpsIdx:n,num_short_term_ref_pic_sets:r,inter_ref_pic_set_prediction_flag:u,delta_idx_minus1:l,delta_rps_sign:d,abs_delta_rps_minus1:v,used_by_curr_pic_flag:h,use_delta_flag:g,num_negative_pics:p,num_positive_pics:x,delta_poc_s0_minus1:b,used_by_curr_pic_s0_flag:E,delta_poc_s1_minus1:N,used_by_curr_pic_s1_flag:j}}function Nb(i,n){const r=!!i.next();let o,u,l;r&&(o=i.read(8),o===255&&(u=i.read(16),l=i.read(16)));const d=!!i.next();let v;d&&(v=!!i.next());const h=!!i.next();let g,p,x,b,E,N;h&&(g=i.read(3),p=!!i.next(),x=!!i.next(),x&&(b=i.read(8),E=i.read(8),N=i.read(8)));const j=!!i.next();let R,M;j&&(R=i.decodeExponentialGolombNumber(),M=i.decodeExponentialGolombNumber());const B=!!i.next(),I=!!i.next(),P=!!i.next(),G=!!i.next();let Q,X,z,F;G&&(Q=i.decodeExponentialGolombNumber(),X=i.decodeExponentialGolombNumber(),z=i.decodeExponentialGolombNumber(),F=i.decodeExponentialGolombNumber());const C=!!i.next();let k,re,pe,Y,q,K;C&&(k=i.read(32),re=i.read(32),pe=!!i.next(),pe&&(Y=i.decodeExponentialGolombNumber()),q=!!i.next(),q&&(K=vf(i,!0,n)));const ie=!!i.next();let le,Ce,$,J,ue,ne,be,Ee;return ie&&(le=!!i.next(),Ce=!!i.next(),$=!!i.next(),J=i.decodeExponentialGolombNumber(),ue=i.decodeExponentialGolombNumber(),ne=i.decodeExponentialGolombNumber(),be=i.decodeExponentialGolombNumber(),Ee=i.decodeExponentialGolombNumber()),{aspect_ratio_info_present_flag:r,aspect_ratio_idc:o,sar_width:u,sar_height:l,overscan_info_present_flag:d,overscan_appropriate_flag:v,video_signal_type_present_flag:h,video_format:g,video_full_range_flag:p,colour_description_present_flag:x,colour_primaries:b,transfer_characteristics:E,matrix_coeffs:N,chroma_loc_info_present_flag:j,chroma_sample_loc_type_top_field:R,chroma_sample_loc_type_bottom_field:M,neutral_chroma_indication_flag:B,field_seq_flag:I,frame_field_info_present_flag:P,default_display_window_flag:G,def_disp_win_left_offset:Q,def_disp_win_right_offset:X,def_disp_win_top_offset:z,def_disp_win_bottom_offset:F,vui_timing_info_present_flag:C,vui_num_units_in_tick:k,vui_time_scale:re,vui_poc_proportional_to_timing_flag:pe,vui_num_ticks_poc_diff_one_minus1:Y,vui_hrd_parameters_present_flag:q,vui_hrd_parameters:K,bitstream_restriction_flag:ie,tiles_fixed_structure_flag:le,motion_vectors_over_pic_boundaries_flag:Ce,restricted_ref_pic_lists_flag:$,min_spatial_segmentation_idc:J,max_bytes_per_pic_denom:ue,max_bits_per_min_cu_denom:ne,log2_max_mv_length_horizontal:be,log2_max_mv_length_vertical:Ee}}function vf(i,n,r){let o,u,l,d,v,h,g,p,x,b,E,N,j;n&&(o=!!i.next(),u=!!i.next(),(o||u)&&(l=!!i.next(),l&&(d=i.read(8),v=i.read(5),h=!!i.next(),g=i.read(5)),p=i.read(4),x=i.read(4),l&&(b=i.read(4)),E=i.read(5),N=i.read(5),j=i.read(5)));const R=[],M=[],B=[],I=[],P=[],G=[],Q=[];for(let X=0;X<=r;X+=1)R[X]=!!i.next(),R[X]||(M[X]=!!i.next()),M[X]?B[X]=i.decodeExponentialGolombNumber():I[X]=!!i.next(),I[X]||(P[X]=i.decodeExponentialGolombNumber()),o&&(G[X]=Gc(i,X,zc(P[X]))),u&&(Q[X]=Gc(i,X,zc(P[X])));return{nal_hrd_parameters_present_flag:o,vcl_hrd_parameters_present_flag:u,sub_pic_hrd_params_present_flag:l,tick_divisor_minus2:d,du_cpb_removal_delay_increment_length_minus1:v,sub_pic_cpb_params_in_pic_timing_sei_flag:h,dpb_output_delay_du_length_minus1:g,bit_rate_scale:p,cpb_size_scale:x,cpb_size_du_scale:b,initial_cpb_removal_delay_length_minus1:E,au_cpb_removal_delay_length_minus1:N,dpb_output_delay_length_minus1:j,fixed_pic_rate_general_flag:R,fixed_pic_rate_within_cvs_flag:M,elemental_duration_in_tc_minus1:B,low_delay_hrd_flag:I,cpb_cnt_minus1:P,nalHrdParameters:G,vclHrdParameters:Q}}function Gc(i,n,r){const o=[],u=[],l=[],d=[],v=[];for(let h=0;h<r;h+=1)o[h]=i.decodeExponentialGolombNumber(),u[h]=i.decodeExponentialGolombNumber(),n>0&&(v[h]=!!i.next());return{bit_rate_value_minus1:o,cpb_size_value_minus1:u,cpb_size_du_value_minus1:l,bit_rate_du_value_minus1:d,cbr_flag:v}}function zc(i){return i+1}function Cb(i){let n,r,o,u=0;for(const l of _f(i)){const d=bb(l),v={...d,data:l,rbsp:l.subarray(2)};switch(d.nal_unit_type){case 32:n=v;break;case 33:r=v;break;case 34:o=v;break;default:continue}if(u+=1,u===3)return{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:o}}throw new Error("Invalid data")}function Tb(i){return{inter_view_mv_vert_constraint_flag:!!i.next()}}function Rb(i){const n=[],r=[];n[0]=!!i.next(),r[0]=!!i.next();const o=i.decodeExponentialGolombNumber(),u=!!i.next(),l=!!i.next(),d=!!i.next(),v=!!i.next();n[1]=!!i.next(),r[1]=!!i.next();const h=!!i.next(),g=i.decodeExponentialGolombNumber(),p=!!i.next(),x=!!i.next(),b=!!i.next(),E=!!i.next(),N=!!i.next();return{iv_di_mc_enabled_flag:n,iv_mv_scal_enabled_flag:r,log2_ivmc_sub_pb_size_minus3:o,iv_res_pred_enabled_flag:u,depth_ref_enabled_flag:l,vsp_mc_enabled_flag:d,dbbp_enabled_flag:v,tex_mc_enabled_flag:h,log2_texmc_sub_pb_size_minus3:g,intra_contour_enabled_flag:p,intra_dc_only_wedge_enabled_flag:x,cqt_cu_part_pred_enabled_flag:b,inter_dc_only_enabled_flag:E,skip_intra_enabled_flag:N}}function kb(i){const{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:o}=Cb(i),{profileTierLevel:{generalProfileTier:{profile_space:u,tier_flag:l,profile_idc:d,profileCompatibilitySet:v,constraintSet:h},general_level_idc:g}}=yb(n.rbsp),{chroma_format_idc:p,pic_width_in_luma_samples:x,pic_height_in_luma_samples:b,conf_win_left_offset:E=0,conf_win_right_offset:N=0,conf_win_top_offset:j=0,conf_win_bottom_offset:R=0}=wb(r.rbsp),M=xb(p),B=vb(p),I=x-M*(E+N),P=b-B*(j+R);return{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:o,generalProfileSpace:u,generalProfileIndex:d,generalProfileCompatibilitySet:v,generalTierFlag:l,generalLevelIndex:g,generalConstraintSet:h,encodedWidth:x,encodedHeight:b,cropLeft:E,cropRight:N,cropTop:j,cropBottom:R,croppedWidth:I,croppedHeight:P}}function qc(i){return i.toString(16).toUpperCase()}function bo(i){return i.toString(16).toUpperCase().padStart(2,"0")}function Rr(i){return i.toString(10).padStart(2,"0")}class Ab{#e;#t;constructor(n,r){this.#e=n,this.#t=r}#n(n){const o=new _t(n).searchSequenceHeaderObu();if(!o)return;const{seq_profile:u,seq_level_idx:[l=0],max_frame_width_minus_1:d,max_frame_height_minus_1:v,color_config:{BitDepth:h,mono_chrome:g,subsampling_x:p,subsampling_y:x,chroma_sample_position:b,color_description_present_flag:E}}=o;let N,j,R,M;E?{color_primaries:N,transfer_characteristics:j,matrix_coefficients:R,color_range:M}=o.color_config:(N=_t.ColorPrimaries.Bt709,j=_t.TransferCharacteristics.Bt709,R=_t.MatrixCoefficients.Bt709,M=!1);const B=d+1,I=v+1;this.#t(B,I);const P=["av01",u.toString(16),Rr(l)+(o.seq_tier[0]?"H":"M"),Rr(h),g?"1":"0",(p?"1":"0")+(x?"1":"0")+b.toString(),Rr(N),Rr(j),Rr(R),M?"1":"0"].join(".");this.#e.configure({codec:P,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 bf{#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 bf{#e;#t;constructor(n,r){super(n),this.#e=n,this.#t=r}configure(n){const{profileIndex:r,constraintSet:o,levelIndex:u,croppedWidth:l,croppedHeight:d}=_b(n);this.#t(l,d);const v="avc1."+bo(r)+bo(o)+bo(u);this.#e.configure({codec:v,optimizeForLatency:!0})}}class jb extends bf{#e;#t;constructor(n,r){super(n),this.#e=n,this.#t=r}configure(n){const{generalProfileSpace:r,generalProfileIndex:o,generalProfileCompatibilitySet:u,generalTierFlag:l,generalLevelIndex:d,generalConstraintSet:v,croppedWidth:h,croppedHeight:g}=kb(n);this.#t(h,g);const p=["hev1",["","A","B","C"][r]+o.toString(),qc(lb(u,0)),(l?"H":"L")+d.toString(),...Array.from(v,qc)].join(".");this.#e.configure({codec:p,codedWidth:h,codedHeight:g,optimizeForLatency:!0})}}class Ib{listeners=[];constructor(){this.event=this.event.bind(this)}addEventListener(n){this.listeners.push(n);const r=()=>{const o=this.listeners.indexOf(n);o!==-1&&this.listeners.splice(o,1)};return r.dispose=r,r}event=(n,r,...o)=>{const u={listener:n,thisArg:r,args:o};return this.addEventListener(u)};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 Mb{#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((o,u)=>{this.#e.toBlob(l=>{l?o(l):u(new Error("Failed to convert canvas to blob"))},"image/png")})}}const $c=new Lb(()=>new Mb,4);class Xc{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}#f=new Ib;get sizeChanged(){return this.#f.event}#a;#p=!1;#u;#d;#m=0;constructor({codec:n,renderer:r}){switch(this.#e=n,this.#s=r,this.#a=new VideoDecoder({output:o=>{if(this.#d?.close(),this.#d=o.clone(),this.#p){this.#u&&(this.#u.close(),this.#c+=1),this.#u=o;return}this.#_(o)},error:o=>{this.#g(o)}}),this.#e){case Fs.H264:this.#t=new Pb(this.#a,this.#h);break;case Fs.H265:this.#t=new jb(this.#a,this.#h);break;case Fs.AV1:this.#t=new Ab(this.#a,this.#h);break;default:throw new Error(`Unsupported codec: ${this.#e}`)}this.#n=new cb({start:o=>{this.#r?o.error(this.#r):this.#i=o},write:o=>{this.#t.decode(o)}}),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.#f.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.#d;if(!n)return;const r=await $c.borrow(),o=await r.capture(n);return $c.return(r),o}dispose(){cancelAnimationFrame(this.#m),this.#a.state!=="closed"&&this.#a.close(),this.#u?.close(),this.#d?.close()}}var yo={exports:{}},wo={exports:{}},Yc;function $o(){return Yc||(Yc=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:{}},Vc;function Db(){return Vc||(Vc=1,(function(){function i(n){for(var r=0,o=n>>1;o!=0;)o=o>>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 Kc;function Ob(){return Kc||(Kc=1,(function(){var i=Db();function n(r,o){var u=r.format.width|0,l=r.format.height|0,d=i(r.format.width/r.format.chromaWidth)|0,v=i(r.format.height/r.format.chromaHeight)|0,h=r.y.bytes,g=r.u.bytes,p=r.v.bytes,x=r.y.stride|0,b=r.u.stride|0,E=r.v.stride|0,N=u<<2,j=0,R=0,M=0,B=0,I=0,P=0,G=0,Q=0,X=0,z=0,F=0,C=0,k=0,re=0,pe=0,Y=0,q=0,K=0;if(d==1&&v==1)for(G=0,Q=N,K=0,Y=0;Y<l;Y+=2){for(R=Y*x|0,M=R+x|0,B=K*b|0,I=K*E|0,pe=0;pe<u;pe+=2)X=g[B++]|0,z=p[I++]|0,C=(409*z|0)-57088|0,k=(100*X|0)+(208*z|0)-34816|0,re=(516*X|0)-70912|0,F=298*h[R++]|0,o[G]=F+C>>8,o[G+1]=F-k>>8,o[G+2]=F+re>>8,G+=4,F=298*h[R++]|0,o[G]=F+C>>8,o[G+1]=F-k>>8,o[G+2]=F+re>>8,G+=4,F=298*h[M++]|0,o[Q]=F+C>>8,o[Q+1]=F-k>>8,o[Q+2]=F+re>>8,Q+=4,F=298*h[M++]|0,o[Q]=F+C>>8,o[Q+1]=F-k>>8,o[Q+2]=F+re>>8,Q+=4;G+=N,Q+=N,K++}else for(P=0,Y=0;Y<l;Y++)for(q=0,K=Y>>v,j=Y*x|0,B=K*b|0,I=K*E|0,pe=0;pe<u;pe++)q=pe>>d,X=g[B+q]|0,z=p[I+q]|0,C=(409*z|0)-57088|0,k=(100*X|0)+(208*z|0)-34816|0,re=(516*X|0)-70912|0,F=298*h[j++]|0,o[P]=F+C>>8,o[P+1]=F-k>>8,o[P+2]=F+re>>8,P+=4}So.exports={convertYCbCr:n}})()),So.exports}var Qc;function Bb(){return Qc||(Qc=1,(function(){var i=$o(),n=Ob();function r(o){var u=this,l=o.getContext("2d"),d=null,v=null,h=null;function g(x,b){d=l.createImageData(x,b);for(var E=d.data,N=x*b*4,j=0;j<N;j+=4)E[j+3]=255}function p(x,b){v=document.createElement("canvas"),v.width=x,v.height=b,h=v.getContext("2d")}return u.drawFrame=function(b){var E=b.format;(o.width!==E.displayWidth||o.height!==E.displayHeight)&&(o.width=E.displayWidth,o.height=E.displayHeight),(d===null||d.width!=E.width||d.height!=E.height)&&g(E.width,E.height),n.convertYCbCr(b,d.data);var N=E.cropWidth!=E.displayWidth||E.cropHeight!=E.displayHeight,j;N?(v||p(E.cropWidth,E.cropHeight),j=h):j=l,j.putImageData(d,-E.cropLeft,-E.cropTop,E.cropLeft,E.cropTop,E.cropWidth,E.cropHeight),N&&l.drawImage(v,0,0,E.displayWidth,E.displayHeight)},u.clear=function(){l.clearRect(0,0,o.width,o.height)},u}r.prototype=Object.create(i.prototype),Eo.exports=r})()),Eo.exports}var Co={exports:{}},To,Jc;function Fb(){return Jc||(Jc=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 Zc;function Ub(){return Zc||(Zc=1,(function(){var i=$o(),n=Fb();function r(o){var u=this,l=r.contextForCanvas(o);if(l===null)throw new Error("WebGL unavailable");function d(Y,q){var K=l.createShader(Y);if(l.shaderSource(K,q),l.compileShader(K),!l.getShaderParameter(K,l.COMPILE_STATUS)){var ie=l.getShaderInfoLog(K);throw l.deleteShader(K),new Error("GL shader compilation for "+Y+" failed: "+ie)}return K}var v,h,g=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),p={},x={},b={},E,N,j,R,M,B,I,P,G,Q;function X(Y,q){return(!p[Y]||q)&&(p[Y]=l.createTexture()),p[Y]}function z(Y,q,K,ie,le){var Ce=!p[Y]||q,$=X(Y,q);if(l.activeTexture(l.TEXTURE0),r.stripe){var J=!p[Y+"_temp"]||q,ue=X(Y+"_temp",q);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,ie,0,l.RGBA,l.UNSIGNED_BYTE,le)):l.texSubImage2D(l.TEXTURE_2D,0,0,0,K/4,ie,l.RGBA,l.UNSIGNED_BYTE,le);var ne=p[Y+"_stripe"],be=!ne||q;be&&(ne=X(Y+"_stripe",q)),l.bindTexture(l.TEXTURE_2D,ne),be&&(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,k(K)))}else l.bindTexture(l.TEXTURE_2D,$),Ce?(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,ie,0,l.ALPHA,l.UNSIGNED_BYTE,le)):l.texSubImage2D(l.TEXTURE_2D,0,0,0,K,ie,l.ALPHA,l.UNSIGNED_BYTE,le)}function F(Y,q,K,ie){var le=p[Y];l.useProgram(h);var Ce=x[Y];(!Ce||q)&&(l.activeTexture(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,le),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,ie,0,l.RGBA,l.UNSIGNED_BYTE,null),Ce=x[Y]=l.createFramebuffer()),l.bindFramebuffer(l.FRAMEBUFFER,Ce),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,le,0);var $=p[Y+"_temp"];l.activeTexture(l.TEXTURE1),l.bindTexture(l.TEXTURE_2D,$),l.uniform1i(B,1);var J=p[Y+"_stripe"];l.activeTexture(l.TEXTURE2),l.bindTexture(l.TEXTURE_2D,J),l.uniform1i(M,2),l.bindBuffer(l.ARRAY_BUFFER,E),l.enableVertexAttribArray(N),l.vertexAttribPointer(N,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,j),l.enableVertexAttribArray(R),l.vertexAttribPointer(R,2,l.FLOAT,!1,0,0),l.viewport(0,0,K,ie),l.drawArrays(l.TRIANGLES,0,g.length/2),l.bindFramebuffer(l.FRAMEBUFFER,null)}function C(Y,q,K){l.activeTexture(q),l.bindTexture(l.TEXTURE_2D,p[Y]),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,Y),K)}function k(Y){if(b[Y])return b[Y];for(var q=Y,K=new Uint32Array(q),ie=0;ie<q;ie+=4)K[ie]=255,K[ie+1]=65280,K[ie+2]=16711680,K[ie+3]=4278190080;return b[Y]=new Uint8Array(K.buffer)}function re(Y,q){var K=d(l.VERTEX_SHADER,Y),ie=d(l.FRAGMENT_SHADER,q),le=l.createProgram();if(l.attachShader(le,K),l.attachShader(le,ie),l.linkProgram(le),!l.getProgramParameter(le,l.LINK_STATUS)){var Ce=l.getProgramInfoLog(le);throw l.deleteProgram(le),new Error("GL program linking failed: "+Ce)}return le}function pe(){if(r.stripe){h=re(n.vertexStripe,n.fragmentStripe),l.getAttribLocation(h,"aPosition"),j=l.createBuffer();var Y=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);l.bindBuffer(l.ARRAY_BUFFER,j),l.bufferData(l.ARRAY_BUFFER,Y,l.STATIC_DRAW),R=l.getAttribLocation(h,"aTexturePosition"),M=l.getUniformLocation(h,"uStripe"),B=l.getUniformLocation(h,"uTexture")}v=re(n.vertex,n.fragment),E=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,E),l.bufferData(l.ARRAY_BUFFER,g,l.STATIC_DRAW),N=l.getAttribLocation(v,"aPosition"),I=l.createBuffer(),P=l.getAttribLocation(v,"aLumaPosition"),G=l.createBuffer(),Q=l.getAttribLocation(v,"aChromaPosition")}return u.drawFrame=function(Y){var q=Y.format,K=!v||o.width!==q.displayWidth||o.height!==q.displayHeight;if(K&&(o.width=q.displayWidth,o.height=q.displayHeight,u.clear()),v||pe(),K){var ie=function(le,Ce,$){var J=q.cropLeft/$,ue=(q.cropLeft+q.cropWidth)/$,ne=(q.cropTop+q.cropHeight)/q.height,be=q.cropTop/q.height,Ee=new Float32Array([J,ne,ue,ne,J,be,J,be,ue,ne,ue,be]);l.bindBuffer(l.ARRAY_BUFFER,le),l.bufferData(l.ARRAY_BUFFER,Ee,l.STATIC_DRAW)};ie(I,P,Y.y.stride),ie(G,Q,Y.u.stride*q.width/q.chromaWidth)}z("uTextureY",K,Y.y.stride,q.height,Y.y.bytes),z("uTextureCb",K,Y.u.stride,q.chromaHeight,Y.u.bytes),z("uTextureCr",K,Y.v.stride,q.chromaHeight,Y.v.bytes),r.stripe&&(F("uTextureY",K,Y.y.stride,q.height),F("uTextureCb",K,Y.u.stride,q.chromaHeight),F("uTextureCr",K,Y.v.stride,q.chromaHeight)),l.useProgram(v),l.viewport(0,0,o.width,o.height),C("uTextureY",l.TEXTURE0,0),C("uTextureCb",l.TEXTURE1,1),C("uTextureCr",l.TEXTURE2,2),l.bindBuffer(l.ARRAY_BUFFER,E),l.enableVertexAttribArray(N),l.vertexAttribPointer(N,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,I),l.enableVertexAttribArray(P),l.vertexAttribPointer(P,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,G),l.enableVertexAttribArray(Q),l.vertexAttribPointer(Q,2,l.FLOAT,!1,0,0),l.drawArrays(l.TRIANGLES,0,g.length/2)},u.clear=function(){l.viewport(0,0,o.width,o.height),l.clearColor(0,0,0,0),l.clear(l.COLOR_BUFFER_BIT)},u.clear(),u}r.stripe=!1,r.contextForCanvas=function(o){var u={preferLowPowerToHighPerformance:!0,powerPreference:"low-power",failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!0};return o.getContext("webgl",u)||o.getContext("experimental-webgl",u)},r.isAvailable=function(){var o=document.createElement("canvas"),u;o.width=1,o.height=1;try{u=r.contextForCanvas(o)}catch{return!1}if(u){var l=u.TEXTURE0,d=4,v=4,h=u.createTexture(),g=new Uint8Array(d*v),p=r.stripe?d/4:d,x=r.stripe?u.RGBA:u.ALPHA,b=r.stripe?u.NEAREST:u.LINEAR;u.activeTexture(l),u.bindTexture(u.TEXTURE_2D,h),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,b),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,b),u.texImage2D(u.TEXTURE_2D,0,x,p,v,0,x,u.UNSIGNED_BYTE,g);var E=u.getError();return!E}else return!1},r.prototype=Object.create(i.prototype),Co.exports=r})()),Co.exports}var eu;function Wb(){return eu||(eu=1,(function(){var i=$o(),n=Bb(),r=Ub(),o={FrameSink:i,SoftwareFrameSink:n,WebGLFrameSink:r,attach:function(u,l){l=l||{};var d="webGL"in l?l.webGL:r.isAvailable();return d?new r(u,l):new n(u,l)}};yo.exports=o})()),yo.exports}Wb();function yf(){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 wf{#e;get canvas(){return this.#e}constructor(n){n?this.#e=n:this.#e=yf()}setSize(n,r){(this.#e.width!==n||this.#e.height!==r)&&(this.#e.width=n,this.#e.height=r)}}class Hb extends wf{#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 Gb=Promise.resolve();function tu(i,n){const r={powerPreference:"low-power",alpha:!1,failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!!n};return i.getContext("webgl2",r)||i.getContext("webgl",r)}class Br extends wf{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=yf();return!!tu(n)}#e;constructor(n,r){super(n);const o=tu(this.canvas,r);if(!o)throw new Error("WebGL not supported");this.#e=o;const u=o.createShader(o.VERTEX_SHADER);if(o.shaderSource(u,Br.vertexShaderSource),o.compileShader(u),!o.getShaderParameter(u,o.COMPILE_STATUS))throw new Error(o.getShaderInfoLog(u));const l=o.createShader(o.FRAGMENT_SHADER);if(o.shaderSource(l,Br.fragmentShaderSource),o.compileShader(l),!o.getShaderParameter(l,o.COMPILE_STATUS))throw new Error(o.getShaderInfoLog(l));const d=o.createProgram();if(o.attachShader(d,u),o.attachShader(d,l),o.linkProgram(d),!o.getProgramParameter(d,o.LINK_STATUS))throw new Error(o.getProgramInfoLog(d));o.useProgram(d);const v=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,v),o.bufferData(o.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),o.STATIC_DRAW);const h=o.getAttribLocation(d,"xy");o.vertexAttribPointer(h,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(h);const g=o.createTexture();o.bindTexture(o.TEXTURE_2D,g),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE)}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),Gb}}const nu=50,zb=300;function qb({deviceId:i,className:n,onFallback:r,fallbackTimeout:o=2e4,enableControl:u=!1,onTapSuccess:l,onTapError:d,onSwipeSuccess:v,onSwipeError:h,onStreamReady:g}){const p=w.useRef(null),x=w.useRef(null),b=w.useRef(null),E=w.useRef(null),N=w.useRef(null),j=w.useRef(null),R=w.useRef(null),M=w.useRef(!1),B=w.useRef(!1),I=w.useRef(r),P=w.useRef(o),G=w.useRef(g),[Q,X]=w.useState("connecting"),[z,F]=w.useState(null),[C,k]=w.useState(null),[re,pe]=w.useState(null),Y=w.useRef(!1),q=w.useRef(null),K=w.useRef(!1),ie=w.useRef(0),le=w.useRef(null),Ce=w.useRef(null),$=w.useRef(null),J=w.useRef(null);w.useEffect(()=>{I.current=r,P.current=o,G.current=g},[r,o,g]),w.useEffect(()=>{(async()=>{try{const ee=await ou(i);ee.success&&pe({width:ee.width,height:ee.height})}catch(ee){console.error("[ScrcpyPlayer] Failed to fetch device resolution:",ee)}})()},[i]);const ue=w.useCallback(()=>{const Z=E.current,ee=b.current;if(!Z||!ee||!C)return;const de=ee.clientWidth,Me=ee.clientHeight,{width:ce,height:fe}=C,ye=ce/fe;let xe=de,Ve=de/ye;Ve>Me&&(Ve=Me,xe=Me*ye),Z.width=ce,Z.height=fe,Z.style.width=`${xe}px`,Z.style.height=`${Ve}px`},[C]);w.useEffect(()=>{const Z=()=>ue();return window.addEventListener("resize",Z),()=>window.removeEventListener("resize",Z)},[ue]),w.useEffect(()=>{ue()},[C,ue]);const ne=w.useCallback(async()=>{if(Br.isSupported){const ee=new Br;return{renderer:ee,element:ee.canvas}}const Z=new Hb;return{renderer:Z,element:Z.canvas}},[]),be=w.useCallback(async Z=>{if(!Xc.isSupported)throw new Error("Current browser does not support WebCodecs API. Please use the latest Chrome/Edge.");const{renderer:ee,element:de}=await ne();return E.current=de,b.current&&!de.parentElement&&b.current.appendChild(de),new Xc({codec:Z,renderer:ee})},[ne]),Ee=w.useCallback(()=>{M.current||(M.current=!0,N.current&&(clearTimeout(N.current),N.current=null))},[]),He=w.useCallback(Z=>{let ee=!1,de=[];const Me=new TransformStream({transform(fe,ye){if(fe.type==="configuration"){ye.enqueue(fe),ee=!0,de.length>0&&(de.forEach(xe=>ye.enqueue(xe)),de=[]);return}if(fe.type==="data"&&!ee){de.push(fe);return}ye.enqueue(fe)}});return new ReadableStream({start(fe){let ye=!1;const xe=at=>{if(!ye)try{Ee();const lt={...at,data:at.data instanceof Uint8Array?at.data:new Uint8Array(at.data)};fe.enqueue(lt)}catch(lt){console.error("[ScrcpyPlayer] Video enqueue error:",lt),ye=!0,st()}},Ve=at=>{ye||(fe.error(new Error(at?.message||"Socket error")),ye=!0,st())},pt=()=>{ye||(fe.close(),ye=!0,st())},st=()=>{p.current?.off("video-data",xe),p.current?.off("error",Ve),p.current?.off("disconnect",pt)};return p.current?.on("video-data",xe),p.current?.on("error",Ve),p.current?.on("disconnect",pt),()=>{ye=!0,st()}}}).pipeThrough(Me)},[Ee]),Qe=w.useCallback((Z=!1)=>{if(Z&&(B.current=!0),x.current){try{x.current.dispose()}catch(ee){console.error("[ScrcpyPlayer] Failed to dispose decoder:",ee)}x.current=null}E.current=null,p.current&&(p.current.disconnect(),p.current=null),G.current?.(null),j.current&&(clearTimeout(j.current),j.current=null),N.current&&(clearTimeout(N.current),N.current=null),X("disconnected"),k(null),F(null)},[]),Be=w.useCallback(()=>{Qe(!0),M.current=!1,X("connecting"),F(null);const Z=Bs({path:"/socket.io",transports:["websocket"],timeout:1e4});p.current=Z,Z.on("connect",()=>{Z.emit("connect-device",{device_id:i,maxSize:1280,bitRate:4e6}),N.current=setTimeout(()=>{M.current||(X("error"),F("Video stream timeout"),B.current=!0,Z.close(),I.current?.())},P.current)}),Z.on("video-metadata",async ee=>{try{x.current&&(x.current.dispose(),x.current=null);const de=ee?.codec?ee.codec:Fs.H264;x.current=await be(de),x.current.sizeChanged(({width:ce,height:fe})=>{k({width:ce,height:fe})}),He(ee).pipeTo(x.current.writable).catch(ce=>{console.error("[ScrcpyPlayer] Video stream error:",ce)}),X("connected"),G.current?.({close:()=>Z.close()})}catch(de){console.error("[ScrcpyPlayer] Decoder initialization failed:",de),X("error"),F("Decoder initialization failed"),B.current=!0,Z.close(),I.current?.()}}),Z.on("error",ee=>{console.error("[ScrcpyPlayer] Socket error:",ee),X("error"),F(ee?.message||"Socket error"),!B.current&&(G.current?.(null),j.current||(j.current=setTimeout(()=>{j.current=null,R.current?.()},3e3)))}),Z.on("disconnect",()=>{if(B.current){B.current=!1;return}X("disconnected"),G.current?.(null),j.current||(j.current=setTimeout(()=>{j.current=null,R.current?.()},3e3))})},[i,Qe,be,He]);w.useEffect(()=>{R.current=Be},[Be]),w.useEffect(()=>(queueMicrotask(()=>{Be()}),()=>{Ce.current&&(clearTimeout(Ce.current),Ce.current=null),$.current&&(clearTimeout($.current),$.current=null),Qe(!0)}),[Be,Qe]);const D=()=>{if(C)return{width:C.width,height:C.height};const Z=E.current;return Z?{width:Z.width,height:Z.height}:null},Se=(Z,ee)=>{const de=E.current,Me=D();if(!de||!Me)return null;const ce=de.getBoundingClientRect();if(Z<ce.left||Z>ce.right||ee<ce.top||ee>ce.bottom)return null;const fe=Z-ce.left,ye=ee-ce.top,xe=Math.round(fe/ce.width*Me.width),Ve=Math.round(ye/ce.height*Me.height),pt=re?re.width/Me.width:1,st=re?re.height/Me.height:1;return{x:Math.round(xe*pt),y:Math.round(Ve*st)}},ae=async Z=>{if(!u||Q!=="connected")return;const ee=Se(Z.clientX,Z.clientY);if(ee){Y.current=!0,K.current=!1,q.current={x:Z.clientX,y:Z.clientY};try{await kx(ee.x,ee.y,i)}catch(de){console.error("[ScrcpyPlayer] Touch down failed:",de)}}},Fe=Z=>{if(!Y.current||Q!=="connected")return;const ee=Date.now(),de=Se(Z.clientX,Z.clientY);if(de){if(q.current){const Me=Z.clientX-q.current.x,ce=Z.clientY-q.current.y;Math.hypot(Me,ce)>4&&(K.current=!0)}if(le.current=de,ee-ie.current<nu){Ce.current||(Ce.current=setTimeout(()=>{Ce.current=null,le.current&&(Rc(le.current.x,le.current.y,i).catch(Me=>{console.error("[ScrcpyPlayer] Touch move failed:",Me)}),le.current=null,ie.current=Date.now())},nu));return}ie.current=ee,Rc(de.x,de.y,i).catch(Me=>{console.error("[ScrcpyPlayer] Touch move failed:",Me)})}},tt=async Z=>{if(!Y.current||Q!=="connected")return;const ee=Se(Z.clientX,Z.clientY);if(Y.current=!1,q.current=null,!!ee)try{await Tc(ee.x,ee.y,i),K.current?v?.():l?.()}catch(de){const Me=String(de);K.current?h?.(Me):d?.(Me)}},ve=async Z=>{if(!Y.current||Q!=="connected")return;const ee=Se(Z.clientX,Z.clientY);if(Y.current=!1,q.current=null,!!ee)try{await Tc(ee.x,ee.y,i)}catch(de){console.error("[ScrcpyPlayer] Touch cancel failed:",de)}},Pe=Z=>{if(!u||Q!=="connected")return;Z.preventDefault();const ee=Z.deltaY;J.current||(J.current={deltaY:0}),J.current.deltaY+=ee,$.current&&clearTimeout($.current),$.current=setTimeout(async()=>{const de=J.current;if(J.current=null,!de)return;const Me=E.current,ce=D();if(!Me||!ce)return;const fe=Me.getBoundingClientRect(),ye=fe.left+fe.width/2,xe=fe.top+fe.height/2,Ve=Se(ye,xe);if(!Ve)return;const pt=Math.max(Math.min(de.deltaY,600),-600),st=xe+pt,at=Se(ye,st);if(at)try{const lt=await Rx(Ve.x,Ve.y,at.x,at.y,300,i);lt.success?v?.():h?.(lt.error||"Scroll failed")}catch(lt){h?.(String(lt))}},zb)};return a.jsx("div",{className:`relative w-full h-full flex items-center justify-center ${n||""}`,children:a.jsx("div",{ref:b,className:"relative w-full h-full flex items-center justify-center bg-slate-50 dark:bg-slate-900",onMouseDown:ae,onMouseMove:Fe,onMouseUp:tt,onMouseLeave:ve,onWheel:Pe,children:Q!=="connected"&&a.jsxs("div",{className:"absolute inset-0 flex items-center justify-center text-slate-400",children:[Q==="connecting"&&"Connecting...",Q==="error"&&(z||"Connection error"),Q==="disconnected"&&"Disconnected"]})})})}const $b={compact:320,standard:400,wide:480,auto:"auto"};function Xb({currentWidth:i,onWidthChange:n}){const r=An(),o=d=>{n($b[d])},u=()=>{if(typeof i!="number")return;const d=Math.max(240,i-40);n(d)},l=()=>{if(typeof i!="number")return;const d=Math.min(640,i+40);n(d)};return a.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"&&a.jsxs(pn,{children:[a.jsx(mn,{asChild:!0,children:a.jsx(we,{variant:"ghost",size:"sm",onClick:u,className:"h-7 w-7 p-0 rounded-lg",disabled:i<=240,children:a.jsx(hv,{className:"w-3 h-3"})})}),a.jsx(gn,{children:a.jsx("p",{children:r.deviceMonitor?.decreaseWidth||"Decrease width"})})]}),a.jsx(we,{variant:"ghost",size:"sm",onClick:()=>o("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"}),a.jsx(we,{variant:"ghost",size:"sm",onClick:()=>o("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"}),a.jsx(we,{variant:"ghost",size:"sm",onClick:()=>o("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"}),a.jsxs(we,{variant:"ghost",size:"sm",onClick:()=>o("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:[a.jsx(fv,{className:"w-3 h-3 mr-1"}),r.deviceMonitor?.auto||"Auto"]}),typeof i=="number"&&a.jsxs(pn,{children:[a.jsx(mn,{asChild:!0,children:a.jsx(we,{variant:"ghost",size:"sm",onClick:l,className:"h-7 w-7 p-0 rounded-lg",disabled:i>=640,children:a.jsx(_u,{className:"w-3 h-3"})})}),a.jsx(gn,{children:a.jsx("p",{children:r.deviceMonitor?.increaseWidth||"Increase width"})})]})]})}function Yb({onResize:i,onResizeStart:n,onResizeEnd:r,minWidth:o=240,maxWidth:u=640,className:l=""}){const[d,v]=w.useState(!1),h=w.useRef(0),g=w.useRef(0),p=w.useRef(null),x=b=>{if(b.preventDefault(),v(!0),h.current=b.clientX,p.current?.parentElement){const E=p.current.parentElement.getBoundingClientRect();g.current=E.width}n?.()};return w.useEffect(()=>{if(!d)return;const b=N=>{const j=N.clientX-h.current,R=Math.min(u,Math.max(o,g.current+j));i(R-g.current)},E=()=>{v(!1),r?.()};return document.addEventListener("mousemove",b),document.addEventListener("mouseup",E),()=>{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",E)}},[d,o,u,i,r]),a.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 ${d?"bg-primary":""} ${l}`,onMouseDown:x,children:a.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx("div",{className:"w-1 h-8 bg-primary rounded-full"})})})}function Vb(i,n){const[r,o]=w.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 d=l instanceof Function?l(r):l;o(d),typeof window<"u"&&window.localStorage.setItem(i,JSON.stringify(d))}catch(d){console.error(`Error setting localStorage key "${i}":`,d)}}]}function Ef({deviceId:i,serial:n,connectionType:r,isVisible:o=!0,className:u=""}){const l=An(),d=r==="remote",[v,h]=w.useState(null),[g,p]=w.useState(!d),[x,b]=w.useState(!1),[E,N]=w.useState(d?"screenshot":"auto"),[j,R]=w.useState(null),[M,B]=w.useState("success"),[I,P]=w.useState(!1),[G,Q]=w.useState(!1),[X,z]=Vb("device-monitor-width",320),F=w.useRef(null),C=w.useRef(!1),k=w.useRef(null),re=w.useRef(null),pe=(ne,be=2e3,Ee="success")=>{k.current&&clearTimeout(k.current),B(Ee),R(ne),k.current=setTimeout(()=>{R(null)},be)},Y=()=>{re.current&&clearTimeout(re.current),P(!0)},q=()=>{re.current=setTimeout(()=>{P(!1)},500)},K=()=>{Q(ne=>!ne)},ie=ne=>{z(ne)},le=ne=>{if(typeof X!="number")return;const be=Math.min(640,Math.max(240,X+ne));z(be)},Ce=w.useCallback(ne=>{F.current=ne},[]),$=w.useCallback(()=>{b(!0),p(!1)},[]),J=ne=>{N(ne)};w.useEffect(()=>()=>{k.current&&clearTimeout(k.current),re.current&&clearTimeout(re.current),F.current&&F.current.close()},[]),w.useEffect(()=>{if(!i||!o||!(E==="screenshot"||E==="auto"&&x))return;const be=async()=>{if(!C.current){C.current=!0;try{const He=await ou(i);He.success&&h(He)}catch(He){console.error("Failed to fetch screenshot:",He)}finally{C.current=!1}}};be();const Ee=setInterval(be,500);return()=>clearInterval(Ee)},[i,x,E,o]);const ue=typeof X=="number"?`${X}px`:"auto";return a.jsxs(Vs,{className:`flex-shrink-0 relative min-h-0 overflow-hidden bg-background ${u}`,style:{width:ue,minWidth:typeof X=="number"?void 0:"240px",maxWidth:typeof X=="number"?void 0:"640px"},onMouseEnter:Y,onMouseLeave:q,children:[typeof X=="number"&&a.jsx(Yb,{onResize:le,minWidth:240,maxWidth:640,className:"z-20"}),a.jsx("div",{className:`absolute top-4 right-4 z-10 transition-opacity duration-200 ${I?"opacity-100":"opacity-0 pointer-events-none"}`,children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsxs("div",{className:`flex flex-col items-end gap-2 transition-all duration-300 ${G?"opacity-100 translate-x-0":"opacity-0 translate-x-4 pointer-events-none"}`,children:[a.jsxs("div",{className:"flex items-center gap-1 bg-popover/90 backdrop-blur rounded-xl p-1 shadow-lg border border-border",children:[!d&&a.jsx(we,{variant:"ghost",size:"sm",onClick:()=>J("auto"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${E==="auto"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:l.devicePanel?.auto||"Auto"}),!d&&a.jsxs(we,{variant:"ghost",size:"sm",onClick:()=>J("video"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${E==="video"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[a.jsx(Cv,{className:"w-3 h-3 mr-1"}),l.devicePanel?.video||"Video"]}),a.jsxs(we,{variant:"ghost",size:"sm",onClick:()=>J("screenshot"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${E==="screenshot"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[a.jsx(Ic,{className:"w-3 h-3 mr-1"}),l.devicePanel?.image||"Image"]})]}),a.jsx(Xb,{currentWidth:X,onWidthChange:ie})]}),a.jsx(we,{variant:"ghost",size:"icon",onClick:K,className:"h-8 w-8 rounded-full bg-popover/90 backdrop-blur border border-border shadow-lg hover:bg-accent",title:G?"Hide controls":"Show controls",children:G?a.jsx(yu,{className:"w-4 h-4"}):a.jsx(bu,{className:"w-4 h-4"})})]})}),a.jsx("div",{className:"absolute bottom-4 left-4 z-10",children:a.jsxs(Wn,{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:[E==="auto"&&(l.devicePanel?.auto||"Auto"),E==="video"&&a.jsxs(a.Fragment,{children:[a.jsx(mv,{className:"w-3 h-3 mr-1"}),l.devicePanel?.video||"Video"]}),E==="screenshot"&&a.jsxs(a.Fragment,{children:[a.jsx(Ic,{className:"w-3 h-3 mr-1"}),l.devicePanel?.imageRefresh||"Screenshot"]})]})}),j&&a.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:[M==="error"&&a.jsx(kn,{className:"w-4 h-4"}),M==="tap"&&a.jsx(iv,{className:"w-4 h-4"}),M==="swipe"&&a.jsx($x,{className:"w-4 h-4"}),M==="success"&&a.jsx(Ur,{className:"w-4 h-4"}),a.jsx("span",{children:j})]}),E==="video"||E==="auto"&&g&&!x?a.jsx(qb,{deviceId:i,className:"w-full h-full",enableControl:!0,onFallback:$,onTapSuccess:()=>pe(l.devicePanel?.tapped||"Tapped",2e3,"tap"),onTapError:ne=>pe((l.devicePanel?.tapError||"Tap error: {error}").replace("{error}",ne),3e3,"error"),onSwipeSuccess:()=>pe(l.devicePanel?.swiped||"Swiped",2e3,"swipe"),onSwipeError:ne=>pe((l.devicePanel?.swipeError||"Swipe error: {error}").replace("{error}",ne),3e3,"error"),onStreamReady:Ce,fallbackTimeout:2e4}):a.jsx("div",{className:"w-full h-full flex items-center justify-center bg-muted/30 min-h-0",children:v&&v.success?a.jsxs("div",{className:"relative w-full h-full flex items-center justify-center min-h-0",children:[a.jsx("img",{src:`data:image/png;base64,${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&&a.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?a.jsxs("div",{className:"text-center text-destructive",children:[a.jsx(kn,{className:"w-8 h-8 mx-auto mb-2"}),a.jsx("p",{className:"font-medium",children:l.devicePanel?.screenshotFailed||"Screenshot Failed"}),a.jsx("p",{className:"text-xs mt-1 opacity-60",children:v.error})]}):a.jsxs("div",{className:"text-center text-muted-foreground",children:[a.jsx(Zt,{className:"w-8 h-8 mx-auto mb-2 animate-spin"}),a.jsx("p",{className:"text-sm",children:l.devicePanel?.loading||"Loading..."})]})})]})}function Kb(i,[n,r]){return Math.min(r,Math.max(n,i))}function Qb(i,n){return w.useReducer((r,o)=>n[r][o]??r,i)}var Xo="ScrollArea",[Sf]=Ys(Xo),[Jb,Gt]=Sf(Xo),Nf=w.forwardRef((i,n)=>{const{__scopeScrollArea:r,type:o="hover",dir:u,scrollHideDelay:l=600,...d}=i,[v,h]=w.useState(null),[g,p]=w.useState(null),[x,b]=w.useState(null),[E,N]=w.useState(null),[j,R]=w.useState(null),[M,B]=w.useState(0),[I,P]=w.useState(0),[G,Q]=w.useState(!1),[X,z]=w.useState(!1),F=_n(n,k=>h(k)),C=Fo(u);return a.jsx(Jb,{scope:r,type:o,dir:C,scrollHideDelay:l,scrollArea:v,viewport:g,onViewportChange:p,content:x,onContentChange:b,scrollbarX:E,onScrollbarXChange:N,scrollbarXEnabled:G,onScrollbarXEnabledChange:Q,scrollbarY:j,onScrollbarYChange:R,scrollbarYEnabled:X,onScrollbarYEnabledChange:z,onCornerWidthChange:B,onCornerHeightChange:P,children:a.jsx(Vt.div,{dir:C,...d,ref:F,style:{position:"relative","--radix-scroll-area-corner-width":M+"px","--radix-scroll-area-corner-height":I+"px",...i.style}})})});Nf.displayName=Xo;var Cf="ScrollAreaViewport",Tf=w.forwardRef((i,n)=>{const{__scopeScrollArea:r,children:o,nonce:u,...l}=i,d=Gt(Cf,r),v=w.useRef(null),h=_n(n,v,d.onViewportChange);return a.jsxs(a.Fragment,{children:[a.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:u}),a.jsx(Vt.div,{"data-radix-scroll-area-viewport":"",...l,ref:h,style:{overflowX:d.scrollbarXEnabled?"scroll":"hidden",overflowY:d.scrollbarYEnabled?"scroll":"hidden",...i.style},children:a.jsx("div",{ref:d.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});Tf.displayName=Cf;var nn="ScrollAreaScrollbar",Rf=w.forwardRef((i,n)=>{const{forceMount:r,...o}=i,u=Gt(nn,i.__scopeScrollArea),{onScrollbarXEnabledChange:l,onScrollbarYEnabledChange:d}=u,v=i.orientation==="horizontal";return w.useEffect(()=>(v?l(!0):d(!0),()=>{v?l(!1):d(!1)}),[v,l,d]),u.type==="hover"?a.jsx(Zb,{...o,ref:n,forceMount:r}):u.type==="scroll"?a.jsx(ey,{...o,ref:n,forceMount:r}):u.type==="auto"?a.jsx(kf,{...o,ref:n,forceMount:r}):u.type==="always"?a.jsx(Yo,{...o,ref:n}):null});Rf.displayName=nn;var Zb=w.forwardRef((i,n)=>{const{forceMount:r,...o}=i,u=Gt(nn,i.__scopeScrollArea),[l,d]=w.useState(!1);return w.useEffect(()=>{const v=u.scrollArea;let h=0;if(v){const g=()=>{window.clearTimeout(h),d(!0)},p=()=>{h=window.setTimeout(()=>d(!1),u.scrollHideDelay)};return v.addEventListener("pointerenter",g),v.addEventListener("pointerleave",p),()=>{window.clearTimeout(h),v.removeEventListener("pointerenter",g),v.removeEventListener("pointerleave",p)}}},[u.scrollArea,u.scrollHideDelay]),a.jsx(Fr,{present:r||l,children:a.jsx(kf,{"data-state":l?"visible":"hidden",...o,ref:n})})}),ey=w.forwardRef((i,n)=>{const{forceMount:r,...o}=i,u=Gt(nn,i.__scopeScrollArea),l=i.orientation==="horizontal",d=ti(()=>h("SCROLL_END"),100),[v,h]=Qb("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 w.useEffect(()=>{if(v==="idle"){const g=window.setTimeout(()=>h("HIDE"),u.scrollHideDelay);return()=>window.clearTimeout(g)}},[v,u.scrollHideDelay,h]),w.useEffect(()=>{const g=u.viewport,p=l?"scrollLeft":"scrollTop";if(g){let x=g[p];const b=()=>{const E=g[p];x!==E&&(h("SCROLL"),d()),x=E};return g.addEventListener("scroll",b),()=>g.removeEventListener("scroll",b)}},[u.viewport,l,h,d]),a.jsx(Fr,{present:r||v!=="hidden",children:a.jsx(Yo,{"data-state":v==="hidden"?"hidden":"visible",...o,ref:n,onPointerEnter:xt(i.onPointerEnter,()=>h("POINTER_ENTER")),onPointerLeave:xt(i.onPointerLeave,()=>h("POINTER_LEAVE"))})})}),kf=w.forwardRef((i,n)=>{const r=Gt(nn,i.__scopeScrollArea),{forceMount:o,...u}=i,[l,d]=w.useState(!1),v=i.orientation==="horizontal",h=ti(()=>{if(r.viewport){const g=r.viewport.offsetWidth<r.viewport.scrollWidth,p=r.viewport.offsetHeight<r.viewport.scrollHeight;d(v?g:p)}},10);return or(r.viewport,h),or(r.content,h),a.jsx(Fr,{present:o||l,children:a.jsx(Yo,{"data-state":l?"visible":"hidden",...u,ref:n})})}),Yo=w.forwardRef((i,n)=>{const{orientation:r="vertical",...o}=i,u=Gt(nn,i.__scopeScrollArea),l=w.useRef(null),d=w.useRef(0),[v,h]=w.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),g=Lf(v.viewport,v.content),p={...o,sizes:v,onSizesChange:h,hasThumb:g>0&&g<1,onThumbChange:b=>l.current=b,onThumbPointerUp:()=>d.current=0,onThumbPointerDown:b=>d.current=b};function x(b,E){return oy(b,d.current,v,E)}return r==="horizontal"?a.jsx(ty,{...p,ref:n,onThumbPositionChange:()=>{if(u.viewport&&l.current){const b=u.viewport.scrollLeft,E=ru(b,v,u.dir);l.current.style.transform=`translate3d(${E}px, 0, 0)`}},onWheelScroll:b=>{u.viewport&&(u.viewport.scrollLeft=b)},onDragScroll:b=>{u.viewport&&(u.viewport.scrollLeft=x(b,u.dir))}}):r==="vertical"?a.jsx(ny,{...p,ref:n,onThumbPositionChange:()=>{if(u.viewport&&l.current){const b=u.viewport.scrollTop,E=ru(b,v);l.current.style.transform=`translate3d(0, ${E}px, 0)`}},onWheelScroll:b=>{u.viewport&&(u.viewport.scrollTop=b)},onDragScroll:b=>{u.viewport&&(u.viewport.scrollTop=x(b))}}):null}),ty=w.forwardRef((i,n)=>{const{sizes:r,onSizesChange:o,...u}=i,l=Gt(nn,i.__scopeScrollArea),[d,v]=w.useState(),h=w.useRef(null),g=_n(n,h,l.onScrollbarXChange);return w.useEffect(()=>{h.current&&v(getComputedStyle(h.current))},[h]),a.jsx(Pf,{"data-orientation":"horizontal",...u,ref:g,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":ei(r)+"px",...i.style},onThumbPointerDown:p=>i.onThumbPointerDown(p.x),onDragScroll:p=>i.onDragScroll(p.x),onWheelScroll:(p,x)=>{if(l.viewport){const b=l.viewport.scrollLeft+p.deltaX;i.onWheelScroll(b),Df(b,x)&&p.preventDefault()}},onResize:()=>{h.current&&l.viewport&&d&&o({content:l.viewport.scrollWidth,viewport:l.viewport.offsetWidth,scrollbar:{size:h.current.clientWidth,paddingStart:Xs(d.paddingLeft),paddingEnd:Xs(d.paddingRight)}})}})}),ny=w.forwardRef((i,n)=>{const{sizes:r,onSizesChange:o,...u}=i,l=Gt(nn,i.__scopeScrollArea),[d,v]=w.useState(),h=w.useRef(null),g=_n(n,h,l.onScrollbarYChange);return w.useEffect(()=>{h.current&&v(getComputedStyle(h.current))},[h]),a.jsx(Pf,{"data-orientation":"vertical",...u,ref:g,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":ei(r)+"px",...i.style},onThumbPointerDown:p=>i.onThumbPointerDown(p.y),onDragScroll:p=>i.onDragScroll(p.y),onWheelScroll:(p,x)=>{if(l.viewport){const b=l.viewport.scrollTop+p.deltaY;i.onWheelScroll(b),Df(b,x)&&p.preventDefault()}},onResize:()=>{h.current&&l.viewport&&d&&o({content:l.viewport.scrollHeight,viewport:l.viewport.offsetHeight,scrollbar:{size:h.current.clientHeight,paddingStart:Xs(d.paddingTop),paddingEnd:Xs(d.paddingBottom)}})}})}),[ry,Af]=Sf(nn),Pf=w.forwardRef((i,n)=>{const{__scopeScrollArea:r,sizes:o,hasThumb:u,onThumbChange:l,onThumbPointerUp:d,onThumbPointerDown:v,onThumbPositionChange:h,onDragScroll:g,onWheelScroll:p,onResize:x,...b}=i,E=Gt(nn,r),[N,j]=w.useState(null),R=_n(n,F=>j(F)),M=w.useRef(null),B=w.useRef(""),I=E.viewport,P=o.content-o.viewport,G=Tn(p),Q=Tn(h),X=ti(x,10);function z(F){if(M.current){const C=F.clientX-M.current.left,k=F.clientY-M.current.top;g({x:C,y:k})}}return w.useEffect(()=>{const F=C=>{const k=C.target;N?.contains(k)&&G(C,P)};return document.addEventListener("wheel",F,{passive:!1}),()=>document.removeEventListener("wheel",F,{passive:!1})},[I,N,P,G]),w.useEffect(Q,[o,Q]),or(N,X),or(E.content,X),a.jsx(ry,{scope:r,scrollbar:N,hasThumb:u,onThumbChange:Tn(l),onThumbPointerUp:Tn(d),onThumbPositionChange:Q,onThumbPointerDown:Tn(v),children:a.jsx(Vt.div,{...b,ref:R,style:{position:"absolute",...b.style},onPointerDown:xt(i.onPointerDown,F=>{F.button===0&&(F.target.setPointerCapture(F.pointerId),M.current=N.getBoundingClientRect(),B.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",E.viewport&&(E.viewport.style.scrollBehavior="auto"),z(F))}),onPointerMove:xt(i.onPointerMove,z),onPointerUp:xt(i.onPointerUp,F=>{const C=F.target;C.hasPointerCapture(F.pointerId)&&C.releasePointerCapture(F.pointerId),document.body.style.webkitUserSelect=B.current,E.viewport&&(E.viewport.style.scrollBehavior=""),M.current=null})})})}),$s="ScrollAreaThumb",jf=w.forwardRef((i,n)=>{const{forceMount:r,...o}=i,u=Af($s,i.__scopeScrollArea);return a.jsx(Fr,{present:r||u.hasThumb,children:a.jsx(sy,{ref:n,...o})})}),sy=w.forwardRef((i,n)=>{const{__scopeScrollArea:r,style:o,...u}=i,l=Gt($s,r),d=Af($s,r),{onThumbPositionChange:v}=d,h=_n(n,x=>d.onThumbChange(x)),g=w.useRef(void 0),p=ti(()=>{g.current&&(g.current(),g.current=void 0)},100);return w.useEffect(()=>{const x=l.viewport;if(x){const b=()=>{if(p(),!g.current){const E=ay(x,v);g.current=E,v()}};return v(),x.addEventListener("scroll",b),()=>x.removeEventListener("scroll",b)}},[l.viewport,p,v]),a.jsx(Vt.div,{"data-state":d.hasThumb?"visible":"hidden",...u,ref:h,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:xt(i.onPointerDownCapture,x=>{const E=x.target.getBoundingClientRect(),N=x.clientX-E.left,j=x.clientY-E.top;d.onThumbPointerDown({x:N,y:j})}),onPointerUp:xt(i.onPointerUp,d.onThumbPointerUp)})});jf.displayName=$s;var Vo="ScrollAreaCorner",If=w.forwardRef((i,n)=>{const r=Gt(Vo,i.__scopeScrollArea),o=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&o?a.jsx(iy,{...i,ref:n}):null});If.displayName=Vo;var iy=w.forwardRef((i,n)=>{const{__scopeScrollArea:r,...o}=i,u=Gt(Vo,r),[l,d]=w.useState(0),[v,h]=w.useState(0),g=!!(l&&v);return or(u.scrollbarX,()=>{const p=u.scrollbarX?.offsetHeight||0;u.onCornerHeightChange(p),h(p)}),or(u.scrollbarY,()=>{const p=u.scrollbarY?.offsetWidth||0;u.onCornerWidthChange(p),d(p)}),g?a.jsx(Vt.div,{...o,ref:n,style:{width:l,height:v,position:"absolute",right:u.dir==="ltr"?0:void 0,left:u.dir==="rtl"?0:void 0,bottom:0,...i.style}}):null});function Xs(i){return i?parseInt(i,10):0}function Lf(i,n){const r=i/n;return isNaN(r)?0:r}function ei(i){const n=Lf(i.viewport,i.content),r=i.scrollbar.paddingStart+i.scrollbar.paddingEnd,o=(i.scrollbar.size-r)*n;return Math.max(o,18)}function oy(i,n,r,o="ltr"){const u=ei(r),l=u/2,d=n||l,v=u-d,h=r.scrollbar.paddingStart+d,g=r.scrollbar.size-r.scrollbar.paddingEnd-v,p=r.content-r.viewport,x=o==="ltr"?[0,p]:[p*-1,0];return Mf([h,g],x)(i)}function ru(i,n,r="ltr"){const o=ei(n),u=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,l=n.scrollbar.size-u,d=n.content-n.viewport,v=l-o,h=r==="ltr"?[0,d]:[d*-1,0],g=Kb(i,h);return Mf([0,d],[0,v])(g)}function Mf(i,n){return r=>{if(i[0]===i[1]||n[0]===n[1])return n[0];const o=(n[1]-n[0])/(i[1]-i[0]);return n[0]+o*(r-i[0])}}function Df(i,n){return i>0&&i<n}var ay=(i,n=()=>{})=>{let r={left:i.scrollLeft,top:i.scrollTop},o=0;return(function u(){const l={left:i.scrollLeft,top:i.scrollTop},d=r.left!==l.left,v=r.top!==l.top;(d||v)&&n(),r=l,o=window.requestAnimationFrame(u)})(),()=>window.cancelAnimationFrame(o)};function ti(i,n){const r=Tn(i),o=w.useRef(0);return w.useEffect(()=>()=>window.clearTimeout(o.current),[]),w.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(r,n)},[r,n])}function or(i,n){const r=Tn(n);Ax(()=>{let o=0;if(i){const u=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(r)});return u.observe(i),()=>{window.cancelAnimationFrame(o),u.unobserve(i)}}},[i,r])}var ly=Nf,cy=Tf,uy=If;function Mr({className:i,children:n,...r}){return a.jsxs(ly,{"data-slot":"scroll-area",className:ar("relative",i),...r,children:[a.jsx(cy,{"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}),a.jsx(fy,{}),a.jsx(uy,{})]})}function fy({className:i,orientation:n="vertical",...r}){return a.jsx(Rf,{"data-slot":"scroll-area-scrollbar",orientation:n,className:ar("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:a.jsx(jf,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const dy=100,hy=20;function Dr(i,n,r,o){return{id:Date.now().toString(),deviceId:i||"unknown",deviceName:n||"Unknown Device",taskText:r?.content||"No task description",success:o?.success??!1,steps:o?.steps??0,startTime:r?.timestamp||new Date,endTime:o?.timestamp||new Date,duration:(o?.timestamp?.getTime()||Date.now())-(r?.timestamp?.getTime()||Date.now()),thinking:o?.thinking??[],actions:o?.actions??[],finalMessage:o?.content||"No result message",errorMessage:o?.success===!1?o?.content||"Unknown error":void 0}}function Or(i,n){try{const r=`history-${i}`,o=localStorage.getItem(r),u=o?JSON.parse(o):[];u.unshift(n);const l=u.slice(0,dy);localStorage.setItem(r,JSON.stringify(l))}catch(r){if(r instanceof Error&&r.name==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old history");try{const o=`history-${i}`,u=localStorage.getItem(o),d=(u?JSON.parse(u):[]).slice(0,hy);d.unshift(n),localStorage.setItem(o,JSON.stringify(d))}catch(o){console.error("Failed to save history even after reduction:",o)}}else console.warn("Failed to save history:",r)}}function Of(i){try{const n=`history-${i}`,r=localStorage.getItem(n);return r?JSON.parse(r).map(u=>({...u,startTime:new Date(u.startTime),endTime:new Date(u.endTime)})):[]}catch(n){return console.warn("Failed to load history:",n),[]}}function Bf(i,n){try{const r=`history-${i}`,o=localStorage.getItem(r);if(!o)return;const l=JSON.parse(o).filter(d=>d.id!==n);localStorage.setItem(r,JSON.stringify(l))}catch(r){console.warn("Failed to delete history item:",r)}}function Ff(i){try{const n=`history-${i}`;localStorage.removeItem(n)}catch(n){console.warn("Failed to clear history:",n)}}function py(i){const r=new Date().getTime()-i.getTime(),o=Math.floor(r/6e4),u=Math.floor(r/36e5),l=Math.floor(r/864e5);return o<1?"Just now":o<60?`${o}m ago`:u<24?`${u}h ago`:l<7?`${l}d ago`:i.toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function my(i){const n=Math.floor(i/1e3),r=Math.floor(n/60),o=n%60;return r===0?`${o}s`:`${r}m ${o}s`}function Uf({item:i,onSelect:n,onDelete:r}){const o=An(),u=l=>{l.stopPropagation(),confirm(o.history.deleteConfirm)&&r(i.id)};return a.jsx(Vs,{className:"hover:bg-slate-50 dark:hover:bg-slate-800/50 transition-colors cursor-pointer group",onClick:()=>n(i),children:a.jsxs("div",{className:"p-3 space-y-2",children:[a.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 line-clamp-2",children:i.taskText}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500 dark:text-slate-400",children:[a.jsx("span",{children:py(i.startTime)}),a.jsx("span",{children:"•"}),a.jsxs("span",{children:[i.steps," ",i.steps===1?"step":"steps"]}),a.jsx("span",{children:"•"}),a.jsx("span",{children:my(i.duration)})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Wn,{variant:i.success?"success":"destructive",className:"shrink-0",children:i.success?a.jsxs(a.Fragment,{children:[a.jsx(Ur,{className:"w-3 h-3 mr-1"}),o.history.success]}):a.jsxs(a.Fragment,{children:[a.jsx(kn,{className:"w-3 h-3 mr-1"}),o.history.failed]})}),a.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:u,title:o.history.deleteItem,children:a.jsx(uu,{className:"w-3 h-3"})})]})]})]})})}function gy({deviceId:i,deviceSerial:n,deviceName:r,deviceConnectionType:o,isConfigured:u}){const l=An(),[d,v]=w.useState([]),[h,g]=w.useState(""),[p,x]=w.useState(!1),[b,E]=w.useState(!1),[N,j]=w.useState(null),[R,M]=w.useState(!1),[B,I]=w.useState([]),[P,G]=w.useState([]),[Q,X]=w.useState(!1),z=w.useRef(null),F=w.useRef(null),C=w.useRef(null),k=w.useRef(0),re=w.useRef(null),[pe,Y]=w.useState(!0),[q,K]=w.useState(!1),ie=w.useRef(nf.throttle(()=>{const D=C.current;if(!D)return;const Se=80,ae=D.scrollHeight-D.scrollTop-D.clientHeight,Fe=ae<=1;Y(Fe),ae<=Se&&K(!1)},100));w.useEffect(()=>{const D=ie.current;return()=>{D.cancel()}},[]),w.useEffect(()=>{if(R){const D=Of(n);I(D)}},[R,n]);const le=D=>{const Se={id:`${D.id}-user`,role:"user",content:D.taskText,timestamp:D.startTime},ae={id:`${D.id}-agent`,role:"assistant",content:D.finalMessage,timestamp:D.endTime,steps:D.steps,success:D.success,thinking:D.thinking,actions:D.actions,isStreaming:!1},Fe=[Se,ae];v(Fe),k.current=Fe.length,re.current=[ae.id,ae.content?.length??0,ae.currentThinking?.length??0,ae.thinking?JSON.stringify(ae.thinking).length:0,ae.steps??"",ae.isStreaming?1:0].join("|"),K(!1),Y(!0),M(!1)},Ce=()=>{confirm(l.history.clearAllConfirm)&&(Ff(n),I([]))},$=D=>{Bf(n,D),I(Se=>Se.filter(ae=>ae.id!==D))},J=w.useCallback(async()=>{const D=h.trim();if(!D||p)return;const Se={id:Date.now().toString(),role:"user",content:D,timestamp:new Date};v(ce=>[...ce,Se]),g(""),x(!0),j(null);const ae=[],Fe=[];let tt="";const ve=[];let Pe=null;const Z=(Date.now()+1).toString(),ee={id:Z,role:"assistant",content:"",timestamp:new Date,thinking:[],actions:[],isStreaming:!0,currentThinking:""};v(ce=>[...ce,ee]);const de=()=>{if(ve.length>0){const ce=ve.join("");ve.length=0,tt+=ce,v(fe=>fe.map(ye=>ye.id===Z?{...ye,currentThinking:tt}:ye))}Pe=null},Me=Px(Se.content,i,ce=>{ve.push(ce.chunk),Pe===null&&(Pe=setTimeout(de,50))},ce=>{Pe!==null&&(clearTimeout(Pe),de());const fe=ce.thinking&&ce.thinking.length>0?ce.thinking:tt;fe&&ae.push(fe),tt="",Fe.push(ce.action),v(ye=>ye.map(xe=>xe.id===Z?{...xe,thinking:[...ae],actions:[...Fe],steps:ce.step,currentThinking:""}:xe))},ce=>{Pe!==null&&clearTimeout(Pe);const fe={...ee,content:ce.message,success:ce.success,isStreaming:!1,steps:ce.steps,thinking:[...ae],actions:[...Fe],timestamp:new Date,currentThinking:void 0};v(xe=>xe.map(Ve=>Ve.id===Z?fe:Ve)),x(!1),z.current=null;const ye=Dr(n,r,Se,fe);Or(n,ye)},ce=>{Pe!==null&&clearTimeout(Pe);const fe={...ee,content:`Error: ${ce.message}`,success:!1,isStreaming:!1,thinking:[...ae],actions:[...Fe],timestamp:new Date,currentThinking:void 0};v(xe=>xe.map(Ve=>Ve.id===Z?fe:Ve)),x(!1),j(ce.message),z.current=null;const ye=Dr(n,r,Se,fe);Or(n,ye)},ce=>{Pe!==null&&clearTimeout(Pe);const fe={...ee,content:ce.message||"Chat aborted by user",success:!1,isStreaming:!1,thinking:[...ae],actions:[...Fe],timestamp:new Date,currentThinking:void 0};v(ye=>ye.map(xe=>xe.id===Z?fe:xe)),x(!1),z.current=null});z.current=Me},[h,p,i,n,r]),ue=w.useCallback(async()=>{z.current&&z.current.close(),v([]),x(!1),j(null),K(!1),Y(!0),z.current=null,k.current=0,re.current=null,await jx(i)},[i]),ne=w.useCallback(async()=>{if(z.current){E(!0);try{z.current&&(z.current.close(),z.current=null),v(D=>{const Se=D[D.length-1];return Se&&Se.role==="assistant"&&Se.isStreaming?D.map((ae,Fe)=>Fe===D.length-1?{...ae,content:ae.content||l.chat.aborted,isStreaming:!1,success:!1,currentThinking:void 0}:ae):D}),Ix(i).catch(D=>console.error("Backend abort failed:",D))}catch(D){console.error("Failed to abort chat:",D)}finally{x(!1),E(!1)}}},[i,l]),be=w.useCallback(()=>{F.current?.scrollIntoView({behavior:"smooth"})},[]);w.useEffect(()=>{const D=d[d.length-1],Se=D?.thinking?JSON.stringify(D.thinking).length:0,ae=D?[D.id,D.content?.length??0,D.currentThinking?.length??0,Se,D.steps??"",D.isStreaming?1:0].join("|"):null,Fe=d.length>k.current,tt=ae!==re.current&&d.length>0;if(k.current=d.length,re.current=ae,pe){be(),K(!1);return}if(d.length===0){K(!1);return}(Fe||tt)&&K(!0)},[d,pe,be]),w.useEffect(()=>()=>{z.current&&z.current.close()},[i]),w.useEffect(()=>{(async()=>{try{const Se=await lu();G(Se.workflows)}catch(Se){console.error("Failed to load workflows:",Se)}})()},[]);const Ee=D=>{g(D.text),X(!1)},He=()=>{ie.current()},Qe=()=>{be(),K(!1),Y(!0)},Be=D=>{(D.metaKey||D.ctrlKey)&&D.key==="Enter"&&(D.preventDefault(),J())};return a.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[a.jsxs(Vs,{className:"flex-1 flex flex-col min-h-0 max-w-2xl",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:a.jsx(Ar,{className:"h-5 w-5 text-[#1d9bf0]"})}),a.jsxs("div",{className:"group",children:[a.jsx("div",{className:"flex items-center gap-1",children:a.jsx("h2",{className:"font-bold text-slate-900 dark:text-slate-100",children:r})}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 font-mono",children:i})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Ws,{open:R,onOpenChange:M,children:[a.jsx(Hs,{asChild:!0,children:a.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:a.jsx(Us,{className:"h-4 w-4"})})}),a.jsxs(Gs,{className:"w-96 p-0",align:"end",sideOffset:8,children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[a.jsx("h3",{className:"font-semibold text-sm text-slate-900 dark:text-slate-100",children:l.history.title}),B.length>0&&a.jsx(we,{variant:"ghost",size:"sm",onClick:Ce,className:"h-7 text-xs",children:l.history.clearAll})]}),a.jsx(Mr,{className:"h-[400px]",children:a.jsx("div",{className:"p-4 space-y-2",children:B.length>0?B.map(D=>a.jsx(Uf,{item:D,onSelect:le,onDelete:$},D.id)):a.jsxs("div",{className:"text-center py-8",children:[a.jsx(Us,{className:"h-12 w-12 text-slate-300 dark:text-slate-700 mx-auto mb-3"}),a.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:l.history.noHistory}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:l.history.noHistoryDescription})]})})})]})]}),!u&&a.jsxs(Wn,{variant:"warning",children:[a.jsx(kn,{className:"w-3 h-3 mr-1"}),l.devicePanel.noConfig]}),a.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:a.jsx(wu,{className:"h-4 w-4"})})]})]}),N&&a.jsxs("div",{className:"mx-4 mt-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl text-sm text-red-600 dark:text-red-400 flex items-center gap-2",children:[a.jsx(kn,{className:"w-4 h-4 flex-shrink-0"}),N]}),a.jsxs("div",{className:"flex-1 min-h-0 relative",children:[a.jsxs("div",{className:"h-full overflow-y-auto p-4",ref:C,onScroll:He,children:[d.length===0?a.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center min-h-[calc(100%-1rem)]",children:[a.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800 mb-4",children:a.jsx(Ar,{className:"h-8 w-8 text-slate-400"})}),a.jsx("p",{className:"font-medium text-slate-900 dark:text-slate-100",children:l.devicePanel.readyToHelp}),a.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:l.devicePanel.describeTask})]}):d.map(D=>a.jsx("div",{className:`flex ${D.role==="user"?"justify-end":"justify-start"}`,children:D.role==="assistant"?a.jsxs("div",{className:"max-w-[85%] space-y-3",children:[D.thinking?.map((Se,ae)=>a.jsxs("div",{className:"bg-slate-100 dark:bg-slate-800 rounded-2xl rounded-tl-sm px-4 py-3",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:a.jsx(Ar,{className:"h-3 w-3 text-[#1d9bf0]"})}),a.jsxs("span",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:["Step ",ae+1]})]}),a.jsx("p",{className:"text-sm whitespace-pre-wrap text-slate-700 dark:text-slate-300",children:Se}),D.actions?.[ae]&&a.jsxs("details",{className:"mt-2 text-xs",children:[a.jsx("summary",{className:"cursor-pointer text-[#1d9bf0] hover:text-[#1a8cd8]",children:"View action"}),a.jsx("pre",{className:"mt-2 p-2 bg-slate-900 text-slate-200 rounded-lg overflow-x-auto text-xs",children:JSON.stringify(D.actions[ae],null,2)})]})]},ae)),D.currentThinking&&a.jsxs("div",{className:"bg-slate-100 dark:bg-slate-800 rounded-2xl rounded-tl-sm px-4 py-3",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:a.jsx(Ar,{className:"h-3 w-3 text-[#1d9bf0] animate-pulse"})}),a.jsx("span",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:"Thinking..."})]}),a.jsxs("p",{className:"text-sm whitespace-pre-wrap text-slate-700 dark:text-slate-300",children:[D.currentThinking,a.jsx("span",{className:"inline-block w-1 h-4 ml-0.5 bg-[#1d9bf0] animate-pulse"})]})]}),D.content&&a.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:[a.jsx(Ur,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${D.success===!1?"text-red-500":"text-green-500"}`}),a.jsxs("div",{children:[a.jsx("p",{className:"whitespace-pre-wrap",children:D.content}),D.steps!==void 0&&a.jsxs("p",{className:"text-xs mt-2 opacity-60 text-slate-500 dark:text-slate-400",children:[D.steps," steps completed"]})]})]}),D.isStreaming&&a.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 dark:text-slate-400",children:[a.jsx(Zt,{className:"w-4 h-4 animate-spin"}),"Processing..."]})]}):a.jsxs("div",{className:"max-w-[75%]",children:[a.jsx("div",{className:"chat-bubble-user px-4 py-3",children:a.jsx("p",{className:"whitespace-pre-wrap",children:D.content})}),a.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-1 text-right",children:D.timestamp.toLocaleTimeString()})]})},D.id)),a.jsx("div",{ref:F})]}),q&&a.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-4 flex justify-center",children:a.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})})]}),a.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800",children:a.jsxs("div",{className:"flex items-end gap-3",children:[a.jsx(xu,{value:h,onChange:D=>g(D.target.value),onKeyDown:Be,placeholder:u?l.devicePanel.whatToDo:l.devicePanel.configureFirst,disabled:p,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),a.jsxs(pn,{children:[a.jsx(mn,{asChild:!0,children:a.jsxs(Ws,{open:Q,onOpenChange:X,children:[a.jsx(Hs,{asChild:!0,children:a.jsx(we,{variant:"outline",size:"icon",className:"h-10 w-10 flex-shrink-0",children:a.jsx(au,{className:"w-4 h-4"})})}),a.jsx(Gs,{align:"start",className:"w-72 p-3",children:a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"font-medium text-sm",children:l.workflows.selectWorkflow}),P.length===0?a.jsxs("div",{className:"text-sm text-slate-500 dark:text-slate-400 space-y-1",children:[a.jsx("p",{children:l.workflows.empty}),a.jsxs("p",{children:["前往"," ",a.jsx("a",{href:"/workflows",className:"text-primary underline",children:"工作流"})," ","页面创建。"]})]}):a.jsx(Mr,{className:"h-64",children:a.jsx("div",{className:"space-y-1",children:P.map(D=>a.jsxs("button",{onClick:()=>Ee(D),className:"w-full text-left p-2 rounded hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[a.jsx("div",{className:"font-medium text-sm",children:D.name}),a.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-2",children:D.text})]},D.uuid))})})]})})]})}),a.jsx(gn,{side:"top",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:l.devicePanel.tooltips.workflowButton}),a.jsx("p",{className:"text-xs opacity-80",children:l.devicePanel.tooltips.workflowButtonDesc})]})})]}),p&&a.jsx(we,{onClick:ne,disabled:b,size:"icon",variant:"destructive",className:"h-10 w-10 rounded-full flex-shrink-0",title:l.chat.abortChat,children:b?a.jsx(Zt,{className:"h-4 w-4 animate-spin"}):a.jsx(Nu,{className:"h-4 w-4"})}),!p&&a.jsx(we,{onClick:J,disabled:!h.trim(),size:"icon",variant:"twitter",className:"h-10 w-10 rounded-full flex-shrink-0",children:a.jsx(Eu,{className:"h-4 w-4"})})]})})]}),a.jsx(Ef,{deviceId:i,serial:n,connectionType:o,isVisible:!0})]})}function _y({deviceId:i,deviceSerial:n,deviceName:r,deviceConnectionType:o,isVisible:u}){const l=An(),[d,v]=w.useState([]),[h,g]=w.useState(""),[p,x]=w.useState(!1),[b,E]=w.useState(!1),[N,j]=w.useState(null),R=w.useRef(null),M=w.useRef(null),B=w.useRef(null),[I,P]=w.useState([]),[G,Q]=w.useState(!1),[X,z]=w.useState([]),[F,C]=w.useState(!1);w.useEffect(()=>{R.current?.scrollIntoView({behavior:"smooth"})},[d]),w.useEffect(()=>()=>{M.current&&M.current.close()},[]),w.useEffect(()=>{(async()=>{try{const J=await lu();P(J.workflows)}catch(J){console.error("Failed to load workflows:",J)}})()},[]),w.useEffect(()=>{if(F){const $=Of(n);z($)}},[F,n]);const k=$=>{g($.text),Q(!1)},re=$=>{const J={id:`${$.id}-user`,role:"user",content:$.taskText,timestamp:$.startTime},ue={id:`${$.id}-agent`,role:"assistant",content:$.finalMessage,timestamp:$.endTime,steps:[],success:$.success,isStreaming:!1};v([J,ue]),C(!1)},pe=()=>{confirm(l.history?.clearAllConfirm||"Clear all history?")&&(Ff(n),z([]))},Y=$=>{Bf(n,$),z(J=>J.filter(ue=>ue.id!==$))},q=($,J)=>{v(ue=>ue.map(ne=>ne.id===$?{...ne,steps:ne.steps?.map(be=>be.id===J?{...be,isExpanded:!be.isExpanded}:be)}:ne))},K=w.useCallback(async()=>{const $=h.trim();if(!$||p)return;const J={id:Date.now().toString(),role:"user",content:$,timestamp:new Date};v(Ee=>[...Ee,J]),g(""),x(!0),j(null);const ue=(Date.now()+1).toString(),ne={id:ue,role:"assistant",content:"",timestamp:new Date,steps:[],isStreaming:!0};v(Ee=>[...Ee,ne]);const be=new AbortController;B.current=be;try{const Ee=await fetch("/api/layered-agent/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:$,device_id:i,session_id:i}),signal:be.signal});if(!Ee.ok){let Se=`HTTP error! status: ${Ee.status}`;try{const ae=await Ee.json();ae.detail&&(Se=ae.detail)}catch{}throw new Error(Se)}const He=Ee.body?.getReader();if(!He)throw new Error("No response body");const Qe=new TextDecoder;let Be="";const D=[];for(;;){const{done:Se,value:ae}=await He.read();if(Se)break;Be+=Qe.decode(ae,{stream:!0});const Fe=Be.split(`
129
- `);Be=Fe.pop()||"";for(const tt of Fe)if(tt.startsWith("data: "))try{const ve=JSON.parse(tt.slice(6));if(ve.type==="tool_call"){const Pe={id:`step-${Date.now()}-${Math.random()}`,type:"tool_call",content:ve.tool_name==="chat"?"发送指令给 Phone Agent":ve.tool_name==="list_devices"?"获取设备列表":`调用工具: ${ve.tool_name}`,toolName:ve.tool_name,toolArgs:ve.tool_args||{},timestamp:new Date,isExpanded:!0};D.push(Pe),v(Z=>Z.map(ee=>ee.id===ue?{...ee,steps:[...D]}:ee))}else if(ve.type==="tool_result"){const Pe={id:`step-${Date.now()}-${Math.random()}`,type:"tool_result",content:ve.tool_name==="chat"?"Phone Agent 执行结果":`${ve.tool_name} 结果`,toolResult:ve.result,timestamp:new Date,isExpanded:!0};D.push(Pe),v(Z=>Z.map(ee=>ee.id===ue?{...ee,steps:[...D]}:ee))}else if(ve.type==="message")v(Pe=>Pe.map(Z=>Z.id===ue?{...Z,content:ve.content}:Z));else if(ve.type==="done"){const Pe={...ne,content:ve.content||"",isStreaming:!1,success:ve.success,steps:[...D],timestamp:new Date};v(ee=>ee.map(de=>de.id===ue?Pe:de));const Z=Dr(n,r,J,{content:ve.content||"",timestamp:new Date,success:ve.success,steps:D.length});Or(n,Z)}else if(ve.type==="error"){const Pe={...ne,content:`错误: ${ve.message}`,isStreaming:!1,success:!1,steps:[...D],timestamp:new Date};v(ee=>ee.map(de=>de.id===ue?Pe:de)),j(ve.message);const Z=Dr(n,r,J,{content:`错误: ${ve.message}`,timestamp:new Date,success:!1,steps:D.length});Or(n,Z)}}catch(ve){console.error("Failed to parse SSE data:",ve,tt)}}v(Se=>Se.map(ae=>ae.id===ue&&ae.isStreaming?{...ae,isStreaming:!1,success:!0}:ae))}catch(Ee){if(Ee instanceof Error&&Ee.name==="AbortError"){console.log("Chat aborted by user");return}console.error("Chat error:",Ee);const He=cu(Ee);j(He),v(Be=>Be.map(D=>D.id===ue?{...D,content:`错误: ${He}`,isStreaming:!1,success:!1}:D));const Qe=Dr(n,r,J,{content:`错误: ${He}`,timestamp:new Date,success:!1,steps:0});Or(n,Qe)}finally{x(!1),B.current=null}},[h,p,i,n,r]),ie=w.useCallback(()=>{if(B.current){E(!0);try{B.current.abort(),B.current=null,v($=>{const J=$[$.length-1];return J&&J.role==="assistant"&&J.isStreaming?$.map((ue,ne)=>ne===$.length-1?{...ue,content:ue.content||l.chat?.aborted||"任务已中断",isStreaming:!1,success:!1}:ue):$}),Lx(async()=>{const{abortLayeredAgentChat:$}=await import("./index-CssG-3TH.js").then(J=>J.ap);return{abortLayeredAgentChat:$}},__vite__mapDeps([0,1])).then(({abortLayeredAgentChat:$})=>{$(i).catch(J=>console.error("Backend abort failed:",J))})}catch($){console.error("Failed to abort chat:",$)}finally{x(!1),E(!1)}}},[l,i]),le=w.useCallback(async()=>{B.current&&(B.current.abort(),B.current=null),v([]),j(null),M.current&&(M.current.close(),M.current=null);try{await fetch("/api/layered-agent/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:i})})}catch($){console.warn("Failed to reset backend session:",$)}},[i]),Ce=$=>{($.metaKey||$.ctrlKey)&&$.key==="Enter"&&($.preventDefault(),K())};return a.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[a.jsxs(Vs,{className:"flex-1 flex flex-col min-h-0 max-w-2xl overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-purple-500/10",children:a.jsx(Ro,{className:"h-5 w-5 text-purple-500"})}),a.jsxs("div",{children:[a.jsx("h2",{className:"font-bold text-slate-900 dark:text-slate-100",children:l.chatkit?.title||"AI Agent"}),a.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[r," • ",l.chatkit?.layeredAgent||"分层代理模式"]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Wn,{variant:"secondary",className:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300",children:l.chatkit?.layeredAgent||"分层代理模式"}),a.jsxs(Ws,{open:F,onOpenChange:C,children:[a.jsx(Hs,{asChild:!0,children:a.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:a.jsx(Us,{className:"h-4 w-4"})})}),a.jsxs(Gs,{className:"w-96 p-0",align:"end",sideOffset:8,children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[a.jsx("h3",{className:"font-semibold text-sm text-slate-900 dark:text-slate-100",children:l.history?.title||"History"}),X.length>0&&a.jsx(we,{variant:"ghost",size:"sm",onClick:pe,className:"h-7 text-xs",children:l.history?.clearAll||"Clear All"})]}),a.jsx(Mr,{className:"h-[400px]",children:a.jsx("div",{className:"p-4 space-y-2",children:X.length>0?X.map($=>a.jsx(Uf,{item:$,onSelect:re,onDelete:Y},$.id)):a.jsxs("div",{className:"text-center py-8",children:[a.jsx(Us,{className:"h-12 w-12 text-slate-300 dark:text-slate-700 mx-auto mb-3"}),a.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:l.history?.noHistory||"No history yet"}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:l.history?.noHistoryDescription||"Your completed tasks will appear here"})]})})})]})]}),a.jsx(we,{variant:"ghost",size:"icon",onClick:le,className:"h-8 w-8 rounded-full",title:"重置对话",children:a.jsx(wu,{className:"h-4 w-4"})})]})]}),N&&a.jsxs("div",{className:"mx-4 mt-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl text-sm text-red-600 dark:text-red-400 flex items-center gap-2",children:[a.jsx(kn,{className:"w-4 h-4 flex-shrink-0"}),N]}),a.jsx(Mr,{className:"flex-1 min-h-0",children:a.jsxs("div",{className:"p-4 space-y-4",children:[d.length===0?a.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center py-12",children:[a.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:a.jsx(Ro,{className:"h-8 w-8 text-purple-500"})}),a.jsx("p",{className:"font-medium text-slate-900 dark:text-slate-100",children:l.chatkit?.title||"分层代理模式"}),a.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400 max-w-xs",children:l.chatkit?.layeredAgentDesc||"决策模型负责规划任务,视觉模型负责执行。你可以看到每一步的执行过程。"})]}):d.map($=>a.jsx("div",{className:"space-y-2",children:$.role==="user"?a.jsx("div",{className:"flex justify-end",children:a.jsxs("div",{className:"max-w-[80%]",children:[a.jsx("div",{className:"bg-purple-600 text-white px-4 py-2 rounded-2xl rounded-br-sm",children:a.jsx("p",{className:"whitespace-pre-wrap",children:$.content})}),a.jsx("p",{className:"text-xs text-slate-400 mt-1 text-right",children:$.timestamp.toLocaleTimeString()})]})}):a.jsxs("div",{className:"space-y-3",children:[$.steps&&$.steps.length>0&&a.jsx("div",{className:"space-y-2",children:$.steps.map((J,ue)=>a.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800/50 rounded-xl border border-slate-200 dark:border-slate-700 overflow-hidden",children:[a.jsxs("button",{onClick:()=>q($.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:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.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"?a.jsx(Pv,{className:"w-3 h-3"}):a.jsx(Mx,{className:"w-3 h-3"})}),a.jsxs("span",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:["Step ",ue+1,": ",J.content]})]}),J.isExpanded?a.jsx(Qx,{className:"w-4 h-4 text-slate-400"}):a.jsx(zx,{className:"w-4 h-4 text-slate-400"})]}),J.isExpanded&&a.jsxs("div",{className:"px-3 pb-3 space-y-2",children:[J.type==="tool_call"&&J.toolArgs&&a.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg p-3 text-sm",children:[a.jsx("p",{className:"text-xs text-slate-500 mb-1 font-medium",children:J.toolName==="chat"?"发送给 Phone Agent 的指令:":"工具参数:"}),J.toolName==="chat"?a.jsx("p",{className:"text-slate-700 dark:text-slate-300 whitespace-pre-wrap",children:J.toolArgs.message||JSON.stringify(J.toolArgs,null,2)}):a.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&&a.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg p-3 text-sm",children:[a.jsx("p",{className:"text-xs text-slate-500 mb-1 font-medium",children:"执行结果:"}),a.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))}),$.content&&a.jsx("div",{className:"flex justify-start",children:a.jsx("div",{className:`max-w-[85%] rounded-2xl rounded-tl-sm px-4 py-3 ${$.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:a.jsxs("div",{className:"flex items-start gap-2",children:[$.success!==void 0&&a.jsx(Ur,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${$.success?"text-green-500":"text-red-500"}`}),a.jsx("p",{className:"whitespace-pre-wrap",children:$.content})]})})}),$.isStreaming&&!$.content&&a.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500",children:[a.jsx(Zt,{className:"w-4 h-4 animate-spin"}),"正在思考和执行..."]})]})},$.id)),a.jsx("div",{ref:R})]})}),a.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800",children:a.jsxs("div",{className:"flex items-end gap-3",children:[a.jsx(xu,{value:h,onChange:$=>g($.target.value),onKeyDown:Ce,placeholder:"描述你想要完成的任务... (Cmd+Enter 发送)",disabled:p,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),a.jsxs(pn,{children:[a.jsx(mn,{asChild:!0,children:a.jsxs(Ws,{open:G,onOpenChange:Q,children:[a.jsx(Hs,{asChild:!0,children:a.jsx(we,{variant:"outline",size:"icon",className:"h-10 w-10 flex-shrink-0",children:a.jsx(au,{className:"w-4 h-4"})})}),a.jsx(Gs,{align:"start",className:"w-72 p-3",children:a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"font-medium text-sm",children:l.workflows?.selectWorkflow||"Select Workflow"}),I.length===0?a.jsxs("div",{className:"text-sm text-slate-500 dark:text-slate-400 space-y-1",children:[a.jsx("p",{children:l.workflows?.empty||"No workflows yet"}),a.jsxs("p",{children:["前往"," ",a.jsx("a",{href:"/workflows",className:"text-primary underline",children:"工作流"})," ","页面创建。"]})]}):a.jsx(Mr,{className:"h-64",children:a.jsx("div",{className:"space-y-1",children:I.map($=>a.jsxs("button",{onClick:()=>k($),className:"w-full text-left p-2 rounded hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[a.jsx("div",{className:"font-medium text-sm",children:$.name}),a.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-2",children:$.text})]},$.uuid))})})]})})]})}),a.jsx(gn,{side:"top",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:l.devicePanel?.tooltips?.workflowButton||"Quick Workflow"}),a.jsx("p",{className:"text-xs opacity-80",children:l.devicePanel?.tooltips?.workflowButtonDesc||"Select a workflow to quickly fill in the task"})]})})]}),p&&a.jsx(we,{onClick:ie,disabled:b,size:"icon",variant:"destructive",className:"h-10 w-10 rounded-full flex-shrink-0",title:l.chat?.abortChat||"中断任务",children:b?a.jsx(Zt,{className:"h-4 w-4 animate-spin"}):a.jsx(Nu,{className:"h-4 w-4"})}),!p&&a.jsx(we,{onClick:K,disabled:!h.trim(),size:"icon",className:"h-10 w-10 rounded-full flex-shrink-0 bg-purple-600 hover:bg-purple-700",children:a.jsx(Eu,{className:"h-4 w-4"})})]})})]}),a.jsx(Ef,{deviceId:i,serial:n,connectionType:o,isVisible:u})]})}function xy({message:i,type:n="info",onClose:r,duration:o=3e3}){w.useEffect(()=>{const d=setTimeout(()=>{r()},o);return()=>clearTimeout(d)},[o,r]);const u={success:"bg-green-500",error:"bg-red-500",info:"bg-blue-500",warning:"bg-amber-500"},l={success:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})}),error:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})}),info:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),warning:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"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 a.jsx("div",{className:"fixed top-4 left-1/2 transform -translate-x-1/2 z-50 animate-fade-in-down",children:a.jsxs("div",{className:`${u[n]} text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3 min-w-[300px]`,children:[l[n],a.jsx("span",{className:"font-medium",children:i}),a.jsx("button",{onClick:r,className:"ml-auto hover:bg-white/20 rounded-full p-1 transition-colors",children:a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]})})}const kr=[{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"}}],vy=[{name:"glm",displayName:"GLM Agent",description:"基于 GLM 模型优化,成熟稳定,适合大多数任务",icon:ev,defaultConfig:{}},{name:"mai",displayName:"MAI Agent",description:"阿里通义团队开发,支持多张历史截图上下文",icon:vu,defaultConfig:{history_n:3}}],by=[{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 Ay(){const i=An(),n=Dx.useSearch(),r=Ox(),[o,u]=w.useState([]),[l,d]=w.useState(""),[v,h]=w.useState(n.mode||"classic"),[g,p]=w.useState(!1),[x,b]=w.useState({message:"",type:"info",visible:!1}),E=(C,k="info")=>{b({message:C,type:k,visible:!0})},[N,j]=w.useState(null),[R,M]=w.useState(!1),[B,I]=w.useState(!1),[P,G]=w.useState({base_url:kr[0].config.base_url,model_name:kr[0].config.model_name,api_key:"",agent_type:"glm",agent_config_params:{},default_max_steps:100,decision_base_url:"",decision_model_name:"",decision_api_key:""});w.useEffect(()=>{(async()=>{try{const k=await Fx();j({base_url:k.base_url,model_name:k.model_name,api_key:k.api_key||void 0,agent_type:k.agent_type||"glm",agent_config_params:k.agent_config_params||void 0,default_max_steps:k.default_max_steps||100,decision_base_url:k.decision_base_url||void 0,decision_model_name:k.decision_model_name||void 0,decision_api_key:k.decision_api_key||void 0});const re=!k.base_url;G({base_url:re?kr[0].config.base_url:k.base_url,model_name:re?kr[0].config.model_name:k.model_name,api_key:k.api_key||"",agent_type:k.agent_type||"glm",agent_config_params:k.agent_config_params||{},default_max_steps:k.default_max_steps||100,decision_base_url:k.decision_base_url||"",decision_model_name:k.decision_model_name||"glm-4.7",decision_api_key:k.decision_api_key||""}),re&&M(!0)}catch(k){console.error("Failed to load config:",k),M(!0)}})()},[]);const Q=w.useCallback(async()=>{try{const k=(await Bx()).devices.filter(q=>q.state!=="disconnected"),re=new Map,pe=new Map;for(const q of k)if(q.serial){const K=pe.get(q.serial)||[];K.push(q),pe.set(q.serial,K)}else re.set(q.id,q);Array.from(pe.values()).forEach(q=>{const ie=q.find(le=>le.connection_type==="wifi")||q[0];re.set(ie.id,ie)});const Y=Array.from(re.values());if(u(Y),Y.length>0&&!g){const q=n.serial;if(q){const K=Y.find(ie=>ie.serial===q);d(K?K.id:Y[0].id)}else l||d(Y[0].id);p(!0)}l&&!Y.find(q=>q.id===l)&&d(Y[0]?.id||"")}catch(C){console.error("Failed to load devices:",C)}},[l,g,n.serial]);w.useEffect(()=>{const C=setTimeout(()=>{Q()},0),k=setInterval(Q,3e3);return()=>{clearTimeout(C),clearInterval(k)}},[Q]),w.useEffect(()=>{const k=o.find(pe=>pe.id===l)?.serial;if(!g)return;(k!==n.serial||v!==n.mode)&&r({to:"/chat",search:{serial:k,mode:v},replace:!0})},[l,v,o,g,r,n.serial,n.mode]);const X=async()=>{if(!P.base_url){E(i.chat.baseUrlRequired,"error");return}try{await Ux({base_url:P.base_url,model_name:P.model_name||"autoglm-phone-9b",api_key:P.api_key||void 0,agent_type:P.agent_type,agent_config_params:Object.keys(P.agent_config_params).length>0?P.agent_config_params:void 0,default_max_steps:P.default_max_steps,decision_base_url:P.decision_base_url||void 0,decision_model_name:P.decision_model_name||void 0,decision_api_key:P.decision_api_key||void 0}),j({base_url:P.base_url,model_name:P.model_name,api_key:P.api_key||void 0,agent_type:P.agent_type,agent_config_params:Object.keys(P.agent_config_params).length>0?P.agent_config_params:void 0,default_max_steps:P.default_max_steps,decision_base_url:P.decision_base_url||void 0,decision_model_name:P.decision_model_name||void 0,decision_api_key:P.decision_api_key||void 0}),E(i.toasts.configSaved,"success");try{const C=await Wx();if(C.total===0)console.log("No agents to reinitialize");else if(C.success)E(`Configuration applied to ${C.succeeded.length} device(s)`,"success");else{const k=Object.keys(C.failed).length;E(`Configuration partially applied: ${C.succeeded.length}/${C.total} succeeded, ${k} failed`,"warning")}}catch(C){console.error("Failed to reinitialize agents:",C),E("Configuration saved, but failed to update devices. Please reinitialize manually.","warning")}M(!1)}catch(C){console.error("Failed to save config:",C),E(`Failed to save: ${cu(C)}`,"error")}},z=async C=>{try{const k=await Gx({device_id:C});k.success&&k.device_id?(d(k.device_id),E(i.toasts.wifiConnected,"success")):k.success||E(k.message||k.error||i.toasts.connectionFailed,"error")}catch(k){E(i.toasts.wifiConnectionError,"error"),console.error("Connect WiFi error:",k)}},F=async C=>{try{const k=await Hx(C);k.success?E(i.toasts.wifiDisconnected,"success"):E(k.message||k.error||i.toasts.disconnectFailed,"error")}catch(k){E(i.toasts.wifiDisconnectError,"error"),console.error("Disconnect WiFi error:",k)}};return a.jsxs("div",{className:"h-full flex relative min-h-0",children:[x.visible&&a.jsx(xy,{message:x.message,type:x.type,onClose:()=>b(C=>({...C,visible:!1}))}),a.jsx(fu,{open:R,onOpenChange:M,children:a.jsxs(du,{className:"sm:max-w-md h-[75vh] flex flex-col",children:[a.jsxs(hu,{className:"flex-shrink-0",children:[a.jsxs(pu,{className:"flex items-center gap-2",children:[a.jsx(Su,{className:"w-5 h-5 text-[#1d9bf0]"}),i.chat.configuration]}),a.jsx(mu,{children:i.chat.configureApi})]}),a.jsxs(Hu,{defaultValue:"vision",className:"flex-1 flex flex-col min-h-0",children:[a.jsxs(Gu,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[a.jsxs(Ir,{value:"vision",children:[a.jsx(mo,{className:"w-4 h-4 mr-2"}),i.chat.visionModelTab]}),a.jsxs(Ir,{value:"decision",children:[a.jsx(vu,{className:"w-4 h-4 mr-2"}),i.chat.decisionModelTab]})]}),a.jsxs(Lr,{value:"vision",className:"space-y-4 mt-4 overflow-y-auto flex-1 min-h-0",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{className:"text-sm font-medium",children:i.chat.selectPreset}),a.jsx("div",{className:"grid grid-cols-1 gap-2",children:kr.map(C=>a.jsxs("div",{className:"relative",children:[a.jsxs("button",{type:"button",onClick:()=>G(k=>({...k,base_url:C.config.base_url,model_name:C.config.model_name})),className:`w-full text-left p-3 rounded-lg border transition-all ${P.base_url===C.config.base_url&&(C.name!=="custom"||C.name==="custom"&&P.base_url==="")?"border-[#1d9bf0] bg-[#1d9bf0]/5":"border-slate-200 dark:border-slate-700 hover:border-[#1d9bf0]/50 hover:bg-slate-50 dark:hover:bg-slate-800/50"}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ko,{className:`w-4 h-4 ${P.base_url===C.config.base_url&&(C.name!=="custom"||C.name==="custom"&&P.base_url==="")?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:i.presetConfigs[C.name].name})]}),a.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&&a.jsx("a",{href:C.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",onClick:k=>k.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:a.jsx(Pc,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-[#1d9bf0] transition-colors"})})]},C.name))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(it,{htmlFor:"base_url",children:[i.chat.baseUrl," *"]}),a.jsx(wt,{id:"base_url",value:P.base_url,onChange:C=>G({...P,base_url:C.target.value}),placeholder:"http://localhost:8080/v1"}),!P.base_url&&a.jsxs("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[a.jsx(kn,{className:"w-3 h-3"}),i.chat.baseUrlRequired]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{htmlFor:"api_key",children:i.chat.apiKey}),a.jsxs("div",{className:"relative",children:[a.jsx(wt,{id:"api_key",type:B?"text":"password",value:P.api_key,onChange:C=>G({...P,api_key:C.target.value}),placeholder:"Leave empty if not required",className:"pr-10"}),a.jsx(we,{type:"button",variant:"ghost",size:"icon",onClick:()=>I(!B),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:B?a.jsx(jc,{className:"w-4 h-4 text-slate-400"}):a.jsx(mo,{className:"w-4 h-4 text-slate-400"})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{htmlFor:"model_name",children:i.chat.modelName}),a.jsx(wt,{id:"model_name",value:P.model_name,onChange:C=>G({...P,model_name:C.target.value}),placeholder:"autoglm-phone-9b"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{className:"text-sm font-medium",children:i.chat.agentType||"Agent 类型"}),a.jsx("div",{className:"grid grid-cols-2 gap-2",children:vy.map(C=>a.jsxs("button",{type:"button",onClick:()=>G(k=>({...k,agent_type:C.name,agent_config_params:C.defaultConfig})),className:`text-left p-3 rounded-lg border transition-all ${P.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:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(C.icon,{className:`w-4 h-4 ${P.agent_type===C.name?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:`font-medium text-sm ${P.agent_type===C.name?"text-[#1d9bf0]":"text-slate-900 dark:text-slate-100"}`,children:C.displayName})]}),a.jsx("p",{className:`text-xs mt-1 ml-6 ${P.agent_type===C.name?"text-[#1d9bf0]/70":"text-slate-500 dark:text-slate-400"}`,children:C.description})]},C.name))})]}),P.agent_type==="mai"&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{htmlFor:"history_n",children:i.chat.history_n||"历史记录数量"}),a.jsx(wt,{id:"history_n",type:"number",min:1,max:10,value:P.agent_config_params?.history_n||3,onChange:C=>{const k=parseInt(C.target.value)||3;G(re=>({...re,agent_config_params:{...re.agent_config_params,history_n:k}}))},className:"w-full"}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:i.chat.history_n_hint||"包含的历史截图数量(1-10)"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{htmlFor:"default_max_steps",children:i.chat.maxSteps||"最大执行步数"}),a.jsx(wt,{id:"default_max_steps",type:"number",min:1,max:1e3,value:P.default_max_steps,onChange:C=>{const k=parseInt(C.target.value)||100;G(re=>({...re,default_max_steps:Math.min(1e3,Math.max(1,k))}))},className:"w-full"}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:i.chat.maxStepsHint||"单次任务最大执行步数(1-1000)"})]})]}),a.jsxs(Lr,{value:"decision",className:"space-y-4 mt-4 overflow-y-auto flex-1 min-h-0",children:[a.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:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(lv,{className:"mt-0.5 h-4 w-4 flex-shrink-0"}),a.jsx("div",{children:i.chat.decisionModelHint})]})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{className:"text-sm font-medium",children:i.chat.selectDecisionPreset}),a.jsx("div",{className:"grid grid-cols-1 gap-2",children:by.map(C=>a.jsxs("div",{className:"relative",children:[a.jsxs("button",{type:"button",onClick:()=>G(k=>({...k,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 ${P.decision_base_url===C.config.decision_base_url&&(C.name!=="custom"||C.name==="custom"&&P.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:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ko,{className:`w-4 h-4 ${P.decision_base_url===C.config.decision_base_url&&(C.name!=="custom"||C.name==="custom"&&P.decision_base_url==="")?"text-indigo-600 dark:text-indigo-400":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:i.presetConfigs[C.name].name})]}),a.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&&a.jsx("a",{href:C.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",onClick:k=>k.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:a.jsx(Pc,{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))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(it,{htmlFor:"decision_base_url",children:[i.chat.decisionBaseUrl," *"]}),a.jsx(wt,{id:"decision_base_url",value:P.decision_base_url,onChange:C=>G({...P,decision_base_url:C.target.value}),placeholder:"http://localhost:8080/v1"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(it,{htmlFor:"decision_api_key",children:i.chat.decisionApiKey}),a.jsxs("div",{className:"relative",children:[a.jsx(wt,{id:"decision_api_key",type:B?"text":"password",value:P.decision_api_key,onChange:C=>G({...P,decision_api_key:C.target.value}),placeholder:"sk-...",className:"pr-10"}),a.jsx(we,{type:"button",variant:"ghost",size:"icon",onClick:()=>I(!B),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:B?a.jsx(jc,{className:"w-4 h-4 text-slate-400"}):a.jsx(mo,{className:"w-4 h-4 text-slate-400"})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(it,{htmlFor:"decision_model_name",children:[i.chat.decisionModelName," *"]}),a.jsx(wt,{id:"decision_model_name",value:P.decision_model_name,onChange:C=>G({...P,decision_model_name:C.target.value}),placeholder:""})]})]})]}),a.jsxs(gu,{className:"sm:justify-between gap-2 flex-shrink-0",children:[a.jsx(we,{variant:"outline",onClick:()=>{M(!1),N&&G({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,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}),a.jsxs(we,{onClick:X,variant:"twitter",children:[a.jsx(Ur,{className:"w-4 h-4 mr-2"}),i.chat.saveConfig]})]})]})}),a.jsx(p1,{devices:o,currentDeviceId:l,onSelectDevice:d,onOpenConfig:()=>M(!0),onConnectWifi:z,onDisconnectWifi:F}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 relative",children:[a.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-20",children:a.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:[a.jsxs(pn,{children:[a.jsx(mn,{asChild:!0,children:a.jsxs("button",{onClick:()=>h("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:[a.jsx(Ar,{className:"w-4 h-4"}),i.chatkit?.classicMode||"经典模式"]})}),a.jsx(gn,{side:"bottom",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:i.chatkit?.classicMode||"经典模式"}),a.jsx("p",{className:"text-xs opacity-80",children:i.chatkit?.classicModeDesc||"视觉模型直接执行任务"})]})})]}),a.jsxs(pn,{children:[a.jsx(mn,{asChild:!0,children:a.jsxs("button",{onClick:()=>{h("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:[a.jsx(Ro,{className:"w-4 h-4"}),i.chatkit?.layeredMode||"分层代理"]})}),a.jsx(gn,{side:"bottom",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:i.chatkit?.layeredMode||"分层代理"}),a.jsx("p",{className:"text-xs opacity-80",children:i.chatkit?.layeredModeDesc||"规划层分解任务,执行层独立完成子任务"})]})})]})]})}),a.jsx("div",{className:"flex-1 flex items-stretch justify-center min-h-0 px-4 py-4 pt-16",children:o.length===0?a.jsx("div",{className:"flex-1 flex items-center justify-center bg-slate-50 dark:bg-slate-950",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800 mx-auto mb-4",children:a.jsx("svg",{className:"w-10 h-10 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),a.jsx("h3",{className:"text-lg font-semibold text-slate-900 dark:text-slate-100 mb-2",children:i.chat.welcomeTitle}),a.jsx("p",{className:"text-slate-500 dark:text-slate-400",children:i.chat.connectDevice})]})}):o.map(C=>a.jsx("div",{className:`w-full max-w-7xl flex items-stretch justify-center min-h-0 ${C.id===l?"":"hidden"}`,children:v==="chatkit"?a.jsx("div",{className:"w-full flex items-stretch justify-center",children:a.jsx(_y,{deviceId:C.id,deviceSerial:C.serial,deviceName:C.model,deviceConnectionType:C.connection_type,isVisible:C.id===l})}):a.jsx("div",{className:"w-full flex items-stretch justify-center",children:a.jsx(gy,{deviceId:C.id,deviceSerial:C.serial,deviceName:C.model,deviceConnectionType:C.connection_type,isConfigured:!!N?.base_url})})},C.serial))})]})]})}export{Ay as component};