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.
- AutoGLM_GUI/agents/glm/agent.py +6 -1
- AutoGLM_GUI/agents/mai/agent.py +3 -0
- AutoGLM_GUI/agents/stream_runner.py +7 -2
- AutoGLM_GUI/api/agents.py +26 -1
- AutoGLM_GUI/api/history.py +27 -1
- AutoGLM_GUI/models/history.py +45 -1
- AutoGLM_GUI/scheduler_manager.py +52 -6
- AutoGLM_GUI/schemas.py +12 -0
- AutoGLM_GUI/static/assets/{about-BQm96DAl.js → about-CfwX1Cmc.js} +1 -1
- AutoGLM_GUI/static/assets/{alert-dialog-B42XxGPR.js → alert-dialog-CtGlN2IJ.js} +1 -1
- AutoGLM_GUI/static/assets/chat-BYa-foUI.js +129 -0
- AutoGLM_GUI/static/assets/{circle-alert-D4rSJh37.js → circle-alert-t08bEMPO.js} +1 -1
- AutoGLM_GUI/static/assets/{dialog-DZ78cEcj.js → dialog-FNwZJFwk.js} +1 -1
- AutoGLM_GUI/static/assets/eye-D0UPWCWC.js +1 -0
- AutoGLM_GUI/static/assets/history-CRo95B7i.js +1 -0
- AutoGLM_GUI/static/assets/{index-CmZSnDqc.js → index-BaLMSqd3.js} +1 -1
- AutoGLM_GUI/static/assets/{index-CssG-3TH.js → index-CTHbFvKl.js} +5 -5
- AutoGLM_GUI/static/assets/index-CV7jGxGm.css +1 -0
- AutoGLM_GUI/static/assets/{label-BCUzE_nm.js → label-DJFevVmr.js} +1 -1
- AutoGLM_GUI/static/assets/{logs-eoFxn5of.js → logs-RW09DyYY.js} +1 -1
- AutoGLM_GUI/static/assets/{popover-DLsuV5Sx.js → popover--JTJrE5v.js} +1 -1
- AutoGLM_GUI/static/assets/{scheduled-tasks-MyqGJvy_.js → scheduled-tasks-DTRKsQXF.js} +1 -1
- AutoGLM_GUI/static/assets/{square-pen-zGWYrdfj.js → square-pen-CPK_K680.js} +1 -1
- AutoGLM_GUI/static/assets/{textarea-BX6y7uM5.js → textarea-PRmVnWq5.js} +1 -1
- AutoGLM_GUI/static/assets/{workflows-CYFs6ssC.js → workflows-CdcsAoaT.js} +1 -1
- AutoGLM_GUI/static/index.html +2 -2
- {autoglm_gui-1.5.0.dist-info → autoglm_gui-1.5.1.dist-info}/METADATA +49 -7
- {autoglm_gui-1.5.0.dist-info → autoglm_gui-1.5.1.dist-info}/RECORD +31 -70
- AutoGLM_GUI/device_adapter.py +0 -263
- AutoGLM_GUI/static/assets/chat-C0L2gQYG.js +0 -129
- AutoGLM_GUI/static/assets/history-DFBv7TGc.js +0 -1
- AutoGLM_GUI/static/assets/index-Bzyv2yQ2.css +0 -1
- mai_agent/base.py +0 -137
- mai_agent/mai_grounding_agent.py +0 -263
- mai_agent/mai_naivigation_agent.py +0 -526
- mai_agent/prompt.py +0 -148
- mai_agent/unified_memory.py +0 -67
- mai_agent/utils.py +0 -73
- phone_agent/__init__.py +0 -12
- phone_agent/actions/__init__.py +0 -5
- phone_agent/actions/handler.py +0 -400
- phone_agent/actions/handler_ios.py +0 -278
- phone_agent/adb/__init__.py +0 -51
- phone_agent/adb/connection.py +0 -358
- phone_agent/adb/device.py +0 -253
- phone_agent/adb/input.py +0 -108
- phone_agent/adb/screenshot.py +0 -108
- phone_agent/agent.py +0 -253
- phone_agent/agent_ios.py +0 -277
- phone_agent/config/__init__.py +0 -53
- phone_agent/config/apps.py +0 -227
- phone_agent/config/apps_harmonyos.py +0 -256
- phone_agent/config/apps_ios.py +0 -339
- phone_agent/config/i18n.py +0 -81
- phone_agent/config/prompts.py +0 -80
- phone_agent/config/prompts_en.py +0 -79
- phone_agent/config/prompts_zh.py +0 -82
- phone_agent/config/timing.py +0 -167
- phone_agent/device_factory.py +0 -166
- phone_agent/hdc/__init__.py +0 -53
- phone_agent/hdc/connection.py +0 -384
- phone_agent/hdc/device.py +0 -269
- phone_agent/hdc/input.py +0 -145
- phone_agent/hdc/screenshot.py +0 -127
- phone_agent/model/__init__.py +0 -5
- phone_agent/model/client.py +0 -290
- phone_agent/xctest/__init__.py +0 -47
- phone_agent/xctest/connection.py +0 -379
- phone_agent/xctest/device.py +0 -472
- phone_agent/xctest/input.py +0 -311
- phone_agent/xctest/screenshot.py +0 -226
- {autoglm_gui-1.5.0.dist-info → autoglm_gui-1.5.1.dist-info}/WHEEL +0 -0
- {autoglm_gui-1.5.0.dist-info → autoglm_gui-1.5.1.dist-info}/entry_points.txt +0 -0
- {autoglm_gui-1.5.0.dist-info → autoglm_gui-1.5.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CTHbFvKl.js","assets/index-CV7jGxGm.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as qe,j as a,u as An,r as w,T as pn,t as mn,v as gn,f as Wn,B as Se,w as _x,x as $s,R as Xe,y as _n,z as Ec,A as nu,P as Vt,D as xt,E as ru,G as Tn,H as Or,b as ar,I as ks,J as xx,K as vx,L as bx,M as yx,N as wx,S as Cr,O as Sc,Q as Ex,U as Sx,V as Nx,W as su,X as Cx,Y as Nc,Z as Cc,_ as Tx,$ as Rx,a0 as kx,a1 as Ax,a2 as Px,a3 as Bs,a4 as iu,p as ou,l as au,q as lu,s as cu,a5 as uu,a6 as jx,a7 as Ix,a8 as Mx,a9 as Lx,aa as Dx,ab as Ox,ac as Bx,ad as Fx,ae as Ux,af as Wx}from"./index-CTHbFvKl.js";import{L as Zt,T as fu,D as du,d as hu,e as pu,f as mu,h as gu,g as _u,C as Xs}from"./dialog-FNwZJFwk.js";import{P as xu,L as st,I as wt}from"./label-DJFevVmr.js";import{C as vu,E as ho}from"./eye-D0UPWCWC.js";import{C as kn}from"./circle-alert-t08bEMPO.js";import{C as Tc,a as Rc,P as Fs,c as Us,d as Ws,b as Hx}from"./popover--JTJrE5v.js";import{T as bu}from"./textarea-PRmVnWq5.js";const Gx=[["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"}]],zx=qe("arrow-up-down",Gx);const qx=[["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"}]],yu=qe("brain",qx);const $x=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],wu=qe("chevron-left",$x);const Xx=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Yx=qe("chevron-up",Xx);const Vx=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Br=qe("circle-check",Vx);const Kx=[["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"}]],Qx=qe("cpu",Kx);const Jx=[["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"}]],kc=qe("external-link",Jx);const Zx=[["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"}]],Ac=qe("eye-off",Zx);const ev=[["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"}]],tv=qe("fingerprint-pattern",ev);const nv=[["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"}]],Pc=qe("image",nv);const rv=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],sv=qe("info",rv);const iv=[["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"}]],Co=qe("layers",iv);const ov=[["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"}]],av=qe("maximize",ov);const lv=[["path",{d:"M5 12h14",key:"1ays0h"}]],cv=qe("minus",lv);const uv=[["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"}]],fv=qe("monitor-play",uv);const dv=[["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"}]],hv=qe("plug",dv);const pv=[["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"}]],Eu=qe("rotate-ccw",pv);const mv=[["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"}]],Su=qe("send",mv);const gv=[["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"}]],To=qe("server",gv);const _v=[["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"}]],Nu=qe("settings",_v);const xv=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],js=qe("smartphone",xv);const vv=[["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=qe("sparkles",vv);const bv=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Cu=qe("square",bv);const yv=[["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"}]],wv=qe("video",yv);const Ev=[["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"}]],Sv=qe("wifi-off",Ev);const Nv=[["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"}]],Hs=qe("wifi",Nv);const Cv=[["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"}]],Tv=qe("wrench",Cv);function jc({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 Rv({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),[L,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}},q=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(js,{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(To,{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(Hs,{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(Se,{variant:"ghost",size:"icon",onClick:q,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(Hs,{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(Se,{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(Sv,{className:"w-3.5 h-3.5"})})}),a.jsx(gn,{children:a.jsx("p",{children:p.deviceCard.disconnectWifi})})]}),N&&a.jsx(Se,{variant:"ghost",size:"icon",onClick:async re=>{re.stopPropagation(),R(!0);try{await _x(n)}catch(me){console.error("Failed to remove remote device:",me)}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(fu,{className:"w-3.5 h-3.5"})})]})]})]}),a.jsx(jc,{isOpen:L,title:p.deviceCard.connectWifiTitle,content:p.deviceCard.connectWifiContent,onConfirm:C,onCancel:()=>B(!1)}),a.jsx(jc,{isOpen:I,title:p.deviceCard.disconnectWifiTitle,content:p.deviceCard.disconnectWifiContent,onConfirm:k,onCancel:()=>P(!1)})]})}function kv(i){const n=i+"CollectionProvider",[r,o]=$s(n),[u,l]=r(n,{collectionRef:{current:null},itemMap:new Map}),d=j=>{const{scope:R,children:L}=j,B=Xe.useRef(null),I=Xe.useRef(new Map).current;return a.jsx(u,{scope:R,itemMap:I,collectionRef:B,children:L})};d.displayName=n;const v=i+"CollectionSlot",h=Ec(v),g=Xe.forwardRef((j,R)=>{const{scope:L,children:B}=j,I=l(v,L),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=Ec(p),E=Xe.forwardRef((j,R)=>{const{scope:L,children:B,...I}=j,P=Xe.useRef(null),G=_n(R,P),Q=l(p,L);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 Av=w.createContext(void 0);function Oo(i){const n=w.useContext(Av);return i||n||"ltr"}var po="rovingFocusGroup.onEntryFocus",Pv={bubbles:!1,cancelable:!0},Fr="RovingFocusGroup",[Ro,Tu,jv]=kv(Fr),[Iv,Ru]=$s(Fr,[jv]),[Mv,Lv]=Iv(Fr),ku=w.forwardRef((i,n)=>a.jsx(Ro.Provider,{scope:i.__scopeRovingFocusGroup,children:a.jsx(Ro.Slot,{scope:i.__scopeRovingFocusGroup,children:a.jsx(Dv,{...i,ref:n})})}));ku.displayName=Fr;var Dv=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=Oo(l),[j,R]=ru({prop:d,defaultProp:v??null,onChange:h,caller:Fr}),[L,B]=w.useState(!1),I=Tn(g),P=Tu(r),G=w.useRef(!1),[Q,X]=w.useState(0);return w.useEffect(()=>{const q=b.current;if(q)return q.addEventListener(po,I),()=>q.removeEventListener(po,I)},[I]),a.jsx(Mv,{scope:r,orientation:o,dir:N,loop:u,currentTabStopId:j,onItemFocus:w.useCallback(q=>R(q),[R]),onItemShiftTab:w.useCallback(()=>B(!0),[]),onFocusableItemAdd:w.useCallback(()=>X(q=>q+1),[]),onFocusableItemRemove:w.useCallback(()=>X(q=>q-1),[]),children:a.jsx(Vt.div,{tabIndex:L||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,q=>{const F=!G.current;if(q.target===q.currentTarget&&F&&!L){const C=new CustomEvent(po,Pv);if(q.currentTarget.dispatchEvent(C),!C.defaultPrevented){const k=P().filter(K=>K.focusable),re=k.find(K=>K.active),me=k.find(K=>K.id===j),$=[re,me,...k].filter(Boolean).map(K=>K.ref.current);ju($,p)}}G.current=!1}),onBlur:xt(i.onBlur,()=>B(!1))})})}),Au="RovingFocusGroupItem",Pu=w.forwardRef((i,n)=>{const{__scopeRovingFocusGroup:r,focusable:o=!0,active:u=!1,tabStopId:l,children:d,...v}=i,h=nu(),g=l||h,p=Lv(Au,r),x=p.currentTabStopId===g,b=Tu(r),{onFocusableItemAdd:E,onFocusableItemRemove:N,currentTabStopId:j}=p;return w.useEffect(()=>{if(o)return E(),()=>N()},[o,E,N]),a.jsx(Ro.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 L=Fv(R,p.orientation,p.dir);if(L!==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(L==="last")I.reverse();else if(L==="prev"||L==="next"){L==="prev"&&I.reverse();const P=I.indexOf(R.currentTarget);I=p.loop?Uv(I,P+1):I.slice(P+1)}setTimeout(()=>ju(I))}}),children:typeof d=="function"?d({isCurrentTabStop:x,hasTabStop:j!=null}):d})})});Pu.displayName=Au;var Ov={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Bv(i,n){return n!=="rtl"?i:i==="ArrowLeft"?"ArrowRight":i==="ArrowRight"?"ArrowLeft":i}function Fv(i,n,r){const o=Bv(i.key,r);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return Ov[o]}function ju(i,n=!1){const r=document.activeElement;for(const o of i)if(o===r||(o.focus({preventScroll:n}),document.activeElement!==r))return}function Uv(i,n){return i.map((r,o)=>i[(n+o)%i.length])}var Wv=ku,Hv=Pu,Ys="Tabs",[Gv]=$s(Ys,[Ru]),Iu=Ru(),[zv,Bo]=Gv(Ys),Mu=w.forwardRef((i,n)=>{const{__scopeTabs:r,value:o,onValueChange:u,defaultValue:l,orientation:d="horizontal",dir:v,activationMode:h="automatic",...g}=i,p=Oo(v),[x,b]=ru({prop:o,onChange:u,defaultProp:l??"",caller:Ys});return a.jsx(zv,{scope:r,baseId:nu(),value:x,onValueChange:b,orientation:d,dir:p,activationMode:h,children:a.jsx(Vt.div,{dir:p,"data-orientation":d,...g,ref:n})})});Mu.displayName=Ys;var Lu="TabsList",Du=w.forwardRef((i,n)=>{const{__scopeTabs:r,loop:o=!0,...u}=i,l=Bo(Lu,r),d=Iu(r);return a.jsx(Wv,{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})})});Du.displayName=Lu;var Ou="TabsTrigger",Bu=w.forwardRef((i,n)=>{const{__scopeTabs:r,value:o,disabled:u=!1,...l}=i,d=Bo(Ou,r),v=Iu(r),h=Wu(d.baseId,o),g=Hu(d.baseId,o),p=o===d.value;return a.jsx(Hv,{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)})})})});Bu.displayName=Ou;var Fu="TabsContent",Uu=w.forwardRef((i,n)=>{const{__scopeTabs:r,value:o,forceMount:u,children:l,...d}=i,v=Bo(Fu,r),h=Wu(v.baseId,o),g=Hu(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(Or,{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})})});Uu.displayName=Fu;function Wu(i,n){return`${i}-trigger-${n}`}function Hu(i,n){return`${i}-content-${n}`}var qv=Mu,$v=Du,Xv=Bu,Yv=Uu;function Gu({className:i,...n}){return a.jsx(qv,{"data-slot":"tabs",className:ar("flex flex-col gap-2",i),...n})}function zu({className:i,...n}){return a.jsx($v,{"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(Xv,{"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 Mr({className:i,...n}){return a.jsx(Yv,{"data-slot":"tabs-content",className:ar("flex-1 outline-none",i),...n})}var Vv=Object.defineProperty,Gs=Object.getOwnPropertySymbols,qu=Object.prototype.hasOwnProperty,$u=Object.prototype.propertyIsEnumerable,Ic=(i,n,r)=>n in i?Vv(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,ko=(i,n)=>{for(var r in n||(n={}))qu.call(n,r)&&Ic(i,r,n[r]);if(Gs)for(var r of Gs(n))$u.call(n,r)&&Ic(i,r,n[r]);return i},Ao=(i,n)=>{var r={};for(var o in i)qu.call(i,o)&&n.indexOf(o)<0&&(r[o]=i[o]);if(i!=null&&Gs)for(var o of Gs(i))n.indexOf(o)<0&&$u.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 L=Ie.getNumDataCodewords(N,g)*8;u(R.length<=L),r(0,Math.min(4,L-R.length),R),r(0,(8-R.length%8)%8,R),u(R.length%8==0);for(let I=236;R.length<L;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 L=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,L);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 Kv={L:ir.QrCode.Ecc.LOW,M:ir.QrCode.Ecc.MEDIUM,Q:ir.QrCode.Ecc.QUARTILE,H:ir.QrCode.Ecc.HIGH},Xu=128,Yu="L",Vu="#FFFFFF",Ku="#000000",Qu=!1,Ju=1,Qv=4,Jv=0,Zv=.1;function Zu(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 ef(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 e1(i,n,r,o){if(o==null)return null;const u=i.length+r*2,l=Math.floor(n*Zv),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),L=Math.ceil(h+p-j);b={x:N,y:j,w:R,h:L}}const E=o.crossOrigin;return{x:g,y:p,h,w:v,excavation:b,opacity:x,crossOrigin:E}}function t1(i,n){return n!=null?Math.max(Math.floor(n),0):i?Qv:Jv}function tf({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,Kv[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=t1(o,u),j=E.length+N*2,R=e1(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 n1=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),r1=Xe.forwardRef(function(n,r){const o=n,{value:u,size:l=Xu,level:d=Yu,bgColor:v=Vu,fgColor:h=Ku,includeMargin:g=Qu,minVersion:p=Ju,boostLevel:x,marginSize:b,imageSettings:E}=o,j=Ao(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:R}=j,L=Ao(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:q,cells:F,numCells:C,calculatedImageSettings:k}=tf({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,$=Y.getContext("2d");if(!$)return;let K=F;const ie=P.current,ae=k!=null&&ie!==null&&ie.complete&&ie.naturalHeight!==0&&ie.naturalWidth!==0;ae&&k.excavation!=null&&(K=ef(F,k.excavation));const Te=window.devicePixelRatio||1;Y.height=Y.width=l*Te;const z=l/C*Te;$.scale(z,z),$.fillStyle=v,$.fillRect(0,0,C,C),$.fillStyle=h,n1?$.fill(new Path2D(Zu(K,q))):F.forEach(function(J,fe){J.forEach(function(ne,ye){ne&&$.fillRect(ye+q,fe+q,1,1)})}),k&&($.globalAlpha=k.opacity),ae&&$.drawImage(ie,k.x+q,k.y+q,k.w,k.h)}}),Xe.useEffect(()=>{X(!1)},[B]);const re=ko({height:l,width:l},R);let me=null;return B!=null&&(me=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",ko({style:re,height:l,width:l,ref:G,role:"img"},L)),me)});r1.displayName="QRCodeCanvas";var nf=Xe.forwardRef(function(n,r){const o=n,{value:u,size:l=Xu,level:d=Yu,bgColor:v=Vu,fgColor:h=Ku,includeMargin:g=Qu,minVersion:p=Ju,boostLevel:x,title:b,marginSize:E,imageSettings:N}=o,j=Ao(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:R,cells:L,numCells:B,calculatedImageSettings:I}=tf({value:u,level:d,minVersion:p,boostLevel:x,includeMargin:g,marginSize:E,imageSettings:N,size:l});let P=L,G=null;N!=null&&I!=null&&(I.excavation!=null&&(P=ef(L,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=Zu(P,R);return Xe.createElement("svg",ko({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)});nf.displayName="QRCodeSVG";var Pr={exports:{}};var s1=Pr.exports,Mc;function i1(){return Mc||(Mc=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,L=2,B=4,I=8,P=16,G=32,Q=64,X=128,q=256,F=512,C=30,k="...",re=800,me=16,Y=1,$=2,K=3,ie=1/0,ae=9007199254740991,Te=17976931348623157e292,z=NaN,J=4294967295,fe=J-1,ne=J>>>1,ye=[["ary",X],["bind",R],["bindKey",L],["curry",I],["curryRight",P],["flip",F],["partial",G],["partialRight",Q],["rearg",q]],Ne="[object Arguments]",Ge="[object Array]",Qe="[object AsyncFunction]",Be="[object Boolean]",O="[object Date]",de="[object DOMException]",ce="[object Error]",Fe="[object Function]",Ve="[object GeneratorFunction]",ue="[object Map]",be="[object Number]",Z="[object Null]",ee="[object Object]",we="[object Promise]",Le="[object Proxy]",le="[object RegExp]",ge="[object Set]",Ee="[object String]",he="[object Symbol]",ut="[object Undefined]",pt="[object WeakMap]",rt="[object WeakSet]",ot="[object ArrayBuffer]",at="[object DataView]",Pn="[object Float32Array]",Gn="[object Float64Array]",cr="[object Int8Array]",rn="[object Int16Array]",zn="[object Int32Array]",U="[object Uint8Array]",_e="[object Uint8ClampedArray]",It="[object Uint16Array]",ur="[object Uint32Array]",Ur=/\b__p \+= '';/g,Ff=/\b(__p \+=) '' \+/g,Uf=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Yo=/&(?:amp|lt|gt|quot|#39);/g,Vo=/[&<>"']/g,Wf=RegExp(Yo.source),Hf=RegExp(Vo.source),Gf=/<%-([\s\S]+?)%>/g,zf=/<%([\s\S]+?)%>/g,Ko=/<%=([\s\S]+?)%>/g,qf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$f=/^\w*$/,Xf=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ei=/[\\^$.*+?()[\]{}|]/g,Yf=RegExp(ei.source),ti=/^\s+/,Vf=/\s/,Kf=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Qf=/\{\n\/\* \[wrapped with (.+)\] \*/,Jf=/,? & /,Zf=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ed=/[()=,{}\[\]\/\s]/,td=/\\(\\)?/g,nd=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Qo=/\w*$/,rd=/^[-+]0x[0-9a-f]+$/i,sd=/^0b[01]+$/i,id=/^\[object .+?Constructor\]$/,od=/^0o[0-7]+$/i,ad=/^(?:0|[1-9]\d*)$/,ld=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Wr=/($^)/,cd=/['\n\r\u2028\u2029\\]/g,Hr="\\ud800-\\udfff",ud="\\u0300-\\u036f",fd="\\ufe20-\\ufe2f",dd="\\u20d0-\\u20ff",Jo=ud+fd+dd,Zo="\\u2700-\\u27bf",ea="a-z\\xdf-\\xf6\\xf8-\\xff",hd="\\xac\\xb1\\xd7\\xf7",pd="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",md="\\u2000-\\u206f",gd=" \\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",ta="A-Z\\xc0-\\xd6\\xd8-\\xde",na="\\ufe0e\\ufe0f",ra=hd+pd+md+gd,ni="['’]",_d="["+Hr+"]",sa="["+ra+"]",Gr="["+Jo+"]",ia="\\d+",xd="["+Zo+"]",oa="["+ea+"]",aa="[^"+Hr+ra+ia+Zo+ea+ta+"]",ri="\\ud83c[\\udffb-\\udfff]",vd="(?:"+Gr+"|"+ri+")",la="[^"+Hr+"]",si="(?:\\ud83c[\\udde6-\\uddff]){2}",ii="[\\ud800-\\udbff][\\udc00-\\udfff]",qn="["+ta+"]",ca="\\u200d",ua="(?:"+oa+"|"+aa+")",bd="(?:"+qn+"|"+aa+")",fa="(?:"+ni+"(?:d|ll|m|re|s|t|ve))?",da="(?:"+ni+"(?:D|LL|M|RE|S|T|VE))?",ha=vd+"?",pa="["+na+"]?",yd="(?:"+ca+"(?:"+[la,si,ii].join("|")+")"+pa+ha+")*",wd="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ed="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",ma=pa+ha+yd,Sd="(?:"+[xd,si,ii].join("|")+")"+ma,Nd="(?:"+[la+Gr+"?",Gr,si,ii,_d].join("|")+")",Cd=RegExp(ni,"g"),Td=RegExp(Gr,"g"),oi=RegExp(ri+"(?="+ri+")|"+Nd+ma,"g"),Rd=RegExp([qn+"?"+oa+"+"+fa+"(?="+[sa,qn,"$"].join("|")+")",bd+"+"+da+"(?="+[sa,qn+ua,"$"].join("|")+")",qn+"?"+ua+"+"+fa,qn+"+"+da,Ed,wd,ia,Sd].join("|"),"g"),kd=RegExp("["+ca+Hr+Jo+na+"]"),Ad=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Pd=["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"],jd=-1,Ye={};Ye[Pn]=Ye[Gn]=Ye[cr]=Ye[rn]=Ye[zn]=Ye[U]=Ye[_e]=Ye[It]=Ye[ur]=!0,Ye[Ne]=Ye[Ge]=Ye[ot]=Ye[Be]=Ye[at]=Ye[O]=Ye[ce]=Ye[Fe]=Ye[ue]=Ye[be]=Ye[ee]=Ye[le]=Ye[ge]=Ye[Ee]=Ye[pt]=!1;var $e={};$e[Ne]=$e[Ge]=$e[ot]=$e[at]=$e[Be]=$e[O]=$e[Pn]=$e[Gn]=$e[cr]=$e[rn]=$e[zn]=$e[ue]=$e[be]=$e[ee]=$e[le]=$e[ge]=$e[Ee]=$e[he]=$e[U]=$e[_e]=$e[It]=$e[ur]=!0,$e[ce]=$e[Fe]=$e[pt]=!1;var Id={À:"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"},Md={"&":"&","<":"<",">":">",'"':""","'":"'"},Ld={"&":"&","<":"<",">":">",""":'"',"'":"'"},Dd={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Od=parseFloat,Bd=parseInt,ga=typeof ks=="object"&&ks&&ks.Object===Object&&ks,Fd=typeof self=="object"&&self&&self.Object===Object&&self,dt=ga||Fd||Function("return this")(),ai=n&&!n.nodeType&&n,jn=ai&&!0&&i&&!i.nodeType&&i,_a=jn&&jn.exports===ai,li=_a&&ga.process,Mt=(function(){try{var T=jn&&jn.require&&jn.require("util").types;return T||li&&li.binding&&li.binding("util")}catch{}})(),xa=Mt&&Mt.isArrayBuffer,va=Mt&&Mt.isDate,ba=Mt&&Mt.isMap,ya=Mt&&Mt.isRegExp,wa=Mt&&Mt.isSet,Ea=Mt&&Mt.isTypedArray;function Tt(T,D,M){switch(M.length){case 0:return T.call(D);case 1:return T.call(D,M[0]);case 2:return T.call(D,M[0],M[1]);case 3:return T.call(D,M[0],M[1],M[2])}return T.apply(D,M)}function Ud(T,D,M,se){for(var Ce=-1,Ue=T==null?0:T.length;++Ce<Ue;){var lt=T[Ce];D(se,lt,M(lt),T)}return se}function Lt(T,D){for(var M=-1,se=T==null?0:T.length;++M<se&&D(T[M],M,T)!==!1;);return T}function Wd(T,D){for(var M=T==null?0:T.length;M--&&D(T[M],M,T)!==!1;);return T}function Sa(T,D){for(var M=-1,se=T==null?0:T.length;++M<se;)if(!D(T[M],M,T))return!1;return!0}function xn(T,D){for(var M=-1,se=T==null?0:T.length,Ce=0,Ue=[];++M<se;){var lt=T[M];D(lt,M,T)&&(Ue[Ce++]=lt)}return Ue}function zr(T,D){var M=T==null?0:T.length;return!!M&&$n(T,D,0)>-1}function ci(T,D,M){for(var se=-1,Ce=T==null?0:T.length;++se<Ce;)if(M(D,T[se]))return!0;return!1}function Ke(T,D){for(var M=-1,se=T==null?0:T.length,Ce=Array(se);++M<se;)Ce[M]=D(T[M],M,T);return Ce}function vn(T,D){for(var M=-1,se=D.length,Ce=T.length;++M<se;)T[Ce+M]=D[M];return T}function ui(T,D,M,se){var Ce=-1,Ue=T==null?0:T.length;for(se&&Ue&&(M=T[++Ce]);++Ce<Ue;)M=D(M,T[Ce],Ce,T);return M}function Hd(T,D,M,se){var Ce=T==null?0:T.length;for(se&&Ce&&(M=T[--Ce]);Ce--;)M=D(M,T[Ce],Ce,T);return M}function fi(T,D){for(var M=-1,se=T==null?0:T.length;++M<se;)if(D(T[M],M,T))return!0;return!1}var Gd=di("length");function zd(T){return T.split("")}function qd(T){return T.match(Zf)||[]}function Na(T,D,M){var se;return M(T,function(Ce,Ue,lt){if(D(Ce,Ue,lt))return se=Ue,!1}),se}function qr(T,D,M,se){for(var Ce=T.length,Ue=M+(se?1:-1);se?Ue--:++Ue<Ce;)if(D(T[Ue],Ue,T))return Ue;return-1}function $n(T,D,M){return D===D?rh(T,D,M):qr(T,Ca,M)}function $d(T,D,M,se){for(var Ce=M-1,Ue=T.length;++Ce<Ue;)if(se(T[Ce],D))return Ce;return-1}function Ca(T){return T!==T}function Ta(T,D){var M=T==null?0:T.length;return M?pi(T,D)/M:z}function di(T){return function(D){return D==null?r:D[T]}}function hi(T){return function(D){return T==null?r:T[D]}}function Ra(T,D,M,se,Ce){return Ce(T,function(Ue,lt,ze){M=se?(se=!1,Ue):D(M,Ue,lt,ze)}),M}function Xd(T,D){var M=T.length;for(T.sort(D);M--;)T[M]=T[M].value;return T}function pi(T,D){for(var M,se=-1,Ce=T.length;++se<Ce;){var Ue=D(T[se]);Ue!==r&&(M=M===r?Ue:M+Ue)}return M}function mi(T,D){for(var M=-1,se=Array(T);++M<T;)se[M]=D(M);return se}function Yd(T,D){return Ke(D,function(M){return[M,T[M]]})}function ka(T){return T&&T.slice(0,Ia(T)+1).replace(ti,"")}function Rt(T){return function(D){return T(D)}}function gi(T,D){return Ke(D,function(M){return T[M]})}function fr(T,D){return T.has(D)}function Aa(T,D){for(var M=-1,se=T.length;++M<se&&$n(D,T[M],0)>-1;);return M}function Pa(T,D){for(var M=T.length;M--&&$n(D,T[M],0)>-1;);return M}function Vd(T,D){for(var M=T.length,se=0;M--;)T[M]===D&&++se;return se}var Kd=hi(Id),Qd=hi(Md);function Jd(T){return"\\"+Dd[T]}function Zd(T,D){return T==null?r:T[D]}function Xn(T){return kd.test(T)}function eh(T){return Ad.test(T)}function th(T){for(var D,M=[];!(D=T.next()).done;)M.push(D.value);return M}function _i(T){var D=-1,M=Array(T.size);return T.forEach(function(se,Ce){M[++D]=[Ce,se]}),M}function ja(T,D){return function(M){return T(D(M))}}function bn(T,D){for(var M=-1,se=T.length,Ce=0,Ue=[];++M<se;){var lt=T[M];(lt===D||lt===p)&&(T[M]=p,Ue[Ce++]=M)}return Ue}function $r(T){var D=-1,M=Array(T.size);return T.forEach(function(se){M[++D]=se}),M}function nh(T){var D=-1,M=Array(T.size);return T.forEach(function(se){M[++D]=[se,se]}),M}function rh(T,D,M){for(var se=M-1,Ce=T.length;++se<Ce;)if(T[se]===D)return se;return-1}function sh(T,D,M){for(var se=M+1;se--;)if(T[se]===D)return se;return se}function Yn(T){return Xn(T)?oh(T):Gd(T)}function zt(T){return Xn(T)?ah(T):zd(T)}function Ia(T){for(var D=T.length;D--&&Vf.test(T.charAt(D)););return D}var ih=hi(Ld);function oh(T){for(var D=oi.lastIndex=0;oi.test(T);)++D;return D}function ah(T){return T.match(oi)||[]}function lh(T){return T.match(Rd)||[]}var ch=(function T(D){D=D==null?dt:Vn.defaults(dt.Object(),D,Vn.pick(dt,Pd));var M=D.Array,se=D.Date,Ce=D.Error,Ue=D.Function,lt=D.Math,ze=D.Object,xi=D.RegExp,uh=D.String,Dt=D.TypeError,Xr=M.prototype,fh=Ue.prototype,Kn=ze.prototype,Yr=D["__core-js_shared__"],Vr=fh.toString,He=Kn.hasOwnProperty,dh=0,Ma=(function(){var e=/[^.]+$/.exec(Yr&&Yr.keys&&Yr.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})(),Kr=Kn.toString,hh=Vr.call(ze),ph=dt._,mh=xi("^"+Vr.call(He).replace(ei,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Qr=_a?D.Buffer:r,yn=D.Symbol,Jr=D.Uint8Array,La=Qr?Qr.allocUnsafe:r,Zr=ja(ze.getPrototypeOf,ze),Da=ze.create,Oa=Kn.propertyIsEnumerable,es=Xr.splice,Ba=yn?yn.isConcatSpreadable:r,dr=yn?yn.iterator:r,In=yn?yn.toStringTag:r,ts=(function(){try{var e=Bn(ze,"defineProperty");return e({},"",{}),e}catch{}})(),gh=D.clearTimeout!==dt.clearTimeout&&D.clearTimeout,_h=se&&se.now!==dt.Date.now&&se.now,xh=D.setTimeout!==dt.setTimeout&&D.setTimeout,ns=lt.ceil,rs=lt.floor,vi=ze.getOwnPropertySymbols,vh=Qr?Qr.isBuffer:r,Fa=D.isFinite,bh=Xr.join,yh=ja(ze.keys,ze),ct=lt.max,mt=lt.min,wh=se.now,Eh=D.parseInt,Ua=lt.random,Sh=Xr.reverse,bi=Bn(D,"DataView"),hr=Bn(D,"Map"),yi=Bn(D,"Promise"),Qn=Bn(D,"Set"),pr=Bn(D,"WeakMap"),mr=Bn(ze,"create"),ss=pr&&new pr,Jn={},Nh=Fn(bi),Ch=Fn(hr),Th=Fn(yi),Rh=Fn(Qn),kh=Fn(pr),is=yn?yn.prototype:r,gr=is?is.valueOf:r,Wa=is?is.toString:r;function m(e){if(Ze(e)&&!Re(e)&&!(e instanceof Me)){if(e instanceof Ot)return e;if(He.call(e,"__wrapped__"))return Hl(e)}return new Ot(e)}var Zn=(function(){function e(){}return function(t){if(!Je(t))return{};if(Da)return Da(t);e.prototype=t;var s=new e;return e.prototype=r,s}})();function os(){}function Ot(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}m.templateSettings={escape:Gf,evaluate:zf,interpolate:Ko,variable:"",imports:{_:m}},m.prototype=os.prototype,m.prototype.constructor=m,Ot.prototype=Zn(os.prototype),Ot.prototype.constructor=Ot;function Me(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=J,this.__views__=[]}function Ah(){var e=new Me(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 Ph(){if(this.__filtered__){var e=new Me(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function jh(){var e=this.__wrapped__.value(),t=this.__dir__,s=Re(e),c=t<0,f=s?e.length:0,_=zp(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 fl(e,this.__actions__);var xe=[];e:for(;A--&&te<oe;){W+=t;for(var Ae=-1,ve=e[W];++Ae<V;){var je=H[Ae],De=je.iteratee,Pt=je.type,yt=De(ve);if(Pt==$)ve=yt;else if(!yt){if(Pt==Y)continue e;break e}}xe[te++]=ve}return xe}Me.prototype=Zn(os.prototype),Me.prototype.constructor=Me;function Mn(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 Ih(){this.__data__=mr?mr(null):{},this.size=0}function Mh(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function Lh(e){var t=this.__data__;if(mr){var s=t[e];return s===h?r:s}return He.call(t,e)?t[e]:r}function Dh(e){var t=this.__data__;return mr?t[e]!==r:He.call(t,e)}function Oh(e,t){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=mr&&t===r?h:t,this}Mn.prototype.clear=Ih,Mn.prototype.delete=Mh,Mn.prototype.get=Lh,Mn.prototype.has=Dh,Mn.prototype.set=Oh;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 Bh(){this.__data__=[],this.size=0}function Fh(e){var t=this.__data__,s=as(t,e);if(s<0)return!1;var c=t.length-1;return s==c?t.pop():es.call(t,s,1),--this.size,!0}function Uh(e){var t=this.__data__,s=as(t,e);return s<0?r:t[s][1]}function Wh(e){return as(this.__data__,e)>-1}function Hh(e,t){var s=this.__data__,c=as(s,e);return c<0?(++this.size,s.push([e,t])):s[c][1]=t,this}sn.prototype.clear=Bh,sn.prototype.delete=Fh,sn.prototype.get=Uh,sn.prototype.has=Wh,sn.prototype.set=Hh;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 Gh(){this.size=0,this.__data__={hash:new Mn,map:new(hr||sn),string:new Mn}}function zh(e){var t=vs(this,e).delete(e);return this.size-=t?1:0,t}function qh(e){return vs(this,e).get(e)}function $h(e){return vs(this,e).has(e)}function Xh(e,t){var s=vs(this,e),c=s.size;return s.set(e,t),this.size+=s.size==c?0:1,this}on.prototype.clear=Gh,on.prototype.delete=zh,on.prototype.get=qh,on.prototype.has=$h,on.prototype.set=Xh;function Ln(e){var t=-1,s=e==null?0:e.length;for(this.__data__=new on;++t<s;)this.add(e[t])}function Yh(e){return this.__data__.set(e,h),this}function Vh(e){return this.__data__.has(e)}Ln.prototype.add=Ln.prototype.push=Yh,Ln.prototype.has=Vh;function qt(e){var t=this.__data__=new sn(e);this.size=t.size}function Kh(){this.__data__=new sn,this.size=0}function Qh(e){var t=this.__data__,s=t.delete(e);return this.size=t.size,s}function Jh(e){return this.__data__.get(e)}function Zh(e){return this.__data__.has(e)}function ep(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=Kh,qt.prototype.delete=Qh,qt.prototype.get=Jh,qt.prototype.has=Zh,qt.prototype.set=ep;function Ha(e,t){var s=Re(e),c=!s&&Un(e),f=!s&&!c&&Cn(e),_=!s&&!c&&!f&&rr(e),y=s||c||f||_,S=y?mi(e.length,uh):[],A=S.length;for(var W in e)(t||He.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 Ga(e){var t=e.length;return t?e[ji(0,t-1)]:r}function tp(e,t){return bs(Et(e),Dn(t,0,e.length))}function np(e){return bs(Et(e))}function wi(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];(!(He.call(e,t)&&$t(c,s))||s===r&&!(t in e))&&an(e,t,s)}function as(e,t){for(var s=e.length;s--;)if($t(e[s][0],t))return s;return-1}function rp(e,t,s,c){return wn(e,function(f,_,y){t(c,f,s(f),y)}),c}function za(e,t){return e&&Qt(t,ft(t),e)}function sp(e,t){return e&&Qt(t,Nt(t),e)}function an(e,t,s){t=="__proto__"&&ts?ts(e,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):e[t]=s}function Ei(e,t){for(var s=-1,c=t.length,f=M(c),_=e==null;++s<c;)f[s]=_?r:ro(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=Re(e);if(H){if(y=$p(e),!S)return Et(e,y)}else{var V=gt(e),te=V==Fe||V==Ve;if(Cn(e))return pl(e,S);if(V==ee||V==Ne||te&&!f){if(y=A||te?{}:Il(e),!S)return A?Lp(e,sp(y,e)):Mp(e,za(y,e))}else{if(!$e[V])return f?e:{};y=Xp(e,V,S)}}_||(_=new qt);var oe=_.get(e);if(oe)return oe;_.set(e,y),lc(e)?e.forEach(function(ve){y.add(Bt(ve,t,s,ve,e,_))}):oc(e)&&e.forEach(function(ve,je){y.set(je,Bt(ve,t,s,je,e,_))});var xe=W?A?Gi:Hi:A?Nt:ft,Ae=H?r:xe(e);return Lt(Ae||e,function(ve,je){Ae&&(je=ve,ve=e[je]),_r(y,je,Bt(ve,t,s,je,e,_))}),y}function ip(e){var t=ft(e);return function(s){return qa(s,e,t)}}function qa(e,t,s){var c=s.length;if(e==null)return!c;for(e=ze(e);c--;){var f=s[c],_=t[f],y=e[f];if(y===r&&!(f in e)||!_(y))return!1}return!0}function $a(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,_=zr,y=!0,S=e.length,A=[],W=t.length;if(!S)return A;s&&(t=Ke(t,Rt(s))),c?(_=ci,y=!1):t.length>=u&&(_=fr,y=!1,t=new Ln(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=vl(Kt),Xa=vl(Ni,!0);function op(e,t){var s=!0;return wn(e,function(c,f,_){return s=!!t(c,f,_),s}),s}function ls(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 ap(e,t,s,c){var f=e.length;for(s=ke(s),s<0&&(s=-s>f?0:f+s),c=c===r||c>f?f:ke(c),c<0&&(c+=f),c=s>c?0:uc(c);s<c;)e[s++]=t;return e}function Ya(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=Vp),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 Si=bl(),Va=bl(!0);function Kt(e,t){return e&&Si(e,t,ft)}function Ni(e,t){return e&&Va(e,t,ft)}function cs(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 Ka(e,t,s){var c=t(e);return Re(e)?c:vn(c,s(e))}function vt(e){return e==null?e===r?ut:Z:In&&In in ze(e)?Gp(e):nm(e)}function Ci(e,t){return e>t}function lp(e,t){return e!=null&&He.call(e,t)}function cp(e,t){return e!=null&&t in ze(e)}function up(e,t,s){return e>=mt(t,s)&&e<ct(t,s)}function Ti(e,t,s){for(var c=s?ci:zr,f=e[0].length,_=e.length,y=_,S=M(_),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 Ln(y&&H):r}H=e[0];var V=-1,te=S[0];e:for(;++V<f&&W.length<A;){var oe=H[V],xe=t?t(oe):oe;if(oe=s||oe!==0?oe:0,!(te?fr(te,xe):c(W,xe,s))){for(y=_;--y;){var Ae=S[y];if(!(Ae?fr(Ae,xe):c(e[y],xe,s)))continue e}te&&te.push(xe),W.push(oe)}}return W}function fp(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=Ol(e,t);var c=e==null?e:e[Jt(Ut(t))];return c==null?r:Tt(c,e,s)}function Qa(e){return Ze(e)&&vt(e)==Ne}function dp(e){return Ze(e)&&vt(e)==ot}function hp(e){return Ze(e)&&vt(e)==O}function br(e,t,s,c,f){return e===t?!0:e==null||t==null||!Ze(e)&&!Ze(t)?e!==e&&t!==t:pp(e,t,s,c,br,f)}function pp(e,t,s,c,f,_){var y=Re(e),S=Re(t),A=y?Ge:gt(e),W=S?Ge:gt(t);A=A==Ne?ee:A,W=W==Ne?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)?Al(e,t,s,c,f,_):Wp(e,t,A,s,c,f,_);if(!(s&N)){var oe=H&&He.call(e,"__wrapped__"),xe=V&&He.call(t,"__wrapped__");if(oe||xe){var Ae=oe?e.value():e,ve=xe?t.value():t;return _||(_=new qt),f(Ae,ve,s,c,_)}}return te?(_||(_=new qt),Hp(e,t,s,c,f,_)):!1}function mp(e){return Ze(e)&>(e)==ue}function Ri(e,t,s,c){var f=s.length,_=f,y=!c;if(e==null)return!_;for(e=ze(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 Ja(e){if(!Je(e)||Qp(e))return!1;var t=fn(e)?mh:id;return t.test(Fn(e))}function gp(e){return Ze(e)&&vt(e)==le}function _p(e){return Ze(e)&>(e)==ge}function xp(e){return Ze(e)&&Cs(e.length)&&!!Ye[vt(e)]}function Za(e){return typeof e=="function"?e:e==null?Ct:typeof e=="object"?Re(e)?nl(e[0],e[1]):tl(e):yc(e)}function ki(e){if(!Er(e))return yh(e);var t=[];for(var s in ze(e))He.call(e,s)&&s!="constructor"&&t.push(s);return t}function vp(e){if(!Je(e))return tm(e);var t=Er(e),s=[];for(var c in e)c=="constructor"&&(t||!He.call(e,c))||s.push(c);return s}function Ai(e,t){return e<t}function el(e,t){var s=-1,c=St(e)?M(e.length):[];return wn(e,function(f,_,y){c[++s]=t(f,_,y)}),c}function tl(e){var t=qi(e);return t.length==1&&t[0][2]?Ll(t[0][0],t[0][1]):function(s){return s===e||Ri(s,e,t)}}function nl(e,t){return Xi(e)&&Ml(t)?Ll(Jt(e),t):function(s){var c=ro(s,e);return c===r&&c===t?so(s,e):br(t,c,N|j)}}function us(e,t,s,c,f){e!==t&&Si(t,function(_,y){if(f||(f=new qt),Je(_))bp(e,t,y,s,us,c,f);else{var S=c?c(Vi(e,y),_,y+"",e,t,f):r;S===r&&(S=_),wi(e,y,S)}},Nt)}function bp(e,t,s,c,f,_,y){var S=Vi(e,s),A=Vi(t,s),W=y.get(A);if(W){wi(e,s,W);return}var H=_?_(S,A,s+"",e,t,y):r,V=H===r;if(V){var te=Re(A),oe=!te&&Cn(A),xe=!te&&!oe&&rr(A);H=A,te||oe||xe?Re(S)?H=S:tt(S)?H=Et(S):oe?(V=!1,H=pl(A,!0)):xe?(V=!1,H=ml(A,!0)):H=[]:Nr(A)||Un(A)?(H=S,Un(S)?H=fc(S):(!Je(S)||fn(S))&&(H=Il(A))):V=!1}V&&(y.set(A,H),f(H,A,c,_,y),y.delete(A)),wi(e,s,H)}function rl(e,t){var s=e.length;if(s)return t+=t<0?s:0,un(t,s)?e[t]:r}function sl(e,t,s){t.length?t=Ke(t,function(_){return Re(_)?function(y){return On(y,_.length===1?_[0]:_)}:_}):t=[Ct];var c=-1;t=Ke(t,Rt(pe()));var f=el(e,function(_,y,S){var A=Ke(t,function(W){return W(_)});return{criteria:A,index:++c,value:_}});return Xd(f,function(_,y){return Ip(_,y,s)})}function yp(e,t){return il(e,t,function(s,c){return so(e,c)})}function il(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 wp(e){return function(t){return On(t,e)}}function Pi(e,t,s,c){var f=c?$d:$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&&es.call(S,A,1),es.call(e,A,1);return e}function ol(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)?es.call(e,f,1):Li(e,f)}}return e}function ji(e,t){return e+rs(Ua()*(t-e+1))}function Ep(e,t,s,c){for(var f=-1,_=ct(ns((t-e)/(s||1)),0),y=M(_);_--;)y[c?_:++f]=e,e+=s;return y}function Ii(e,t){var s="";if(!e||t<1||t>ae)return s;do t%2&&(s+=e),t=rs(t/2),t&&(e+=e);while(t);return s}function Pe(e,t){return Ki(Dl(e,t,Ct),e+"")}function Sp(e){return Ga(sr(e))}function Np(e,t){var s=sr(e);return bs(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 al=ss?function(e,t){return ss.set(e,t),e}:Ct,Cp=ts?function(e,t){return ts(e,"toString",{configurable:!0,enumerable:!1,value:oo(t),writable:!0})}:Ct;function Tp(e){return bs(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 _=M(f);++c<f;)_[c]=e[c+t];return _}function Rp(e,t){var s;return wn(e,function(c,f,_){return s=t(c,f,_),!s}),!!s}function fs(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 Mi(e,t,Ct,s)}function Mi(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=rs((f+_)/2),V=s(e[H]),te=V!==r,oe=V===null,xe=V===V,Ae=At(V);if(y)var ve=c||xe;else W?ve=xe&&(c||te):S?ve=xe&&te&&(c||!oe):A?ve=xe&&te&&!oe&&(c||!Ae):oe||Ae?ve=!1:ve=c?V<=t:V<t;ve?f=H+1:_=H}return mt(_,fe)}function ll(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 cl(e){return typeof e=="number"?e:At(e)?z:+e}function kt(e){if(typeof e=="string")return e;if(Re(e))return Ke(e,kt)+"";if(At(e))return Wa?Wa.call(e):"";var t=e+"";return t=="0"&&1/e==-ie?"-0":t}function En(e,t,s){var c=-1,f=zr,_=e.length,y=!0,S=[],A=S;if(s)y=!1,f=ci;else if(_>=u){var W=t?null:Fp(e);if(W)return $r(W);y=!1,f=fr,A=new Ln}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 Li(e,t){return t=Sn(t,e),e=Ol(e,t),e==null||delete e[Jt(Ut(t))]}function ul(e,t,s,c){return yr(e,t,s(On(e,t)),c)}function ds(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 fl(e,t){var s=e;return s instanceof Me&&(s=s.value()),ui(t,function(c,f){return f.func.apply(f.thisArg,vn([c],f.args))},s)}function Di(e,t,s){var c=e.length;if(c<2)return c?En(e[0]):[];for(var f=-1,_=M(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 dl(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 Oi(e){return tt(e)?e:[]}function Bi(e){return typeof e=="function"?e:Ct}function Sn(e,t){return Re(e)?e:Xi(e,t)?[e]:Wl(We(e))}var kp=Pe;function Nn(e,t,s){var c=e.length;return s=s===r?c:s,!t&&s>=c?e:Ft(e,t,s)}var hl=gh||function(e){return dt.clearTimeout(e)};function pl(e,t){if(t)return e.slice();var s=e.length,c=La?La(s):new e.constructor(s);return e.copy(c),c}function Fi(e){var t=new e.constructor(e.byteLength);return new Jr(t).set(new Jr(e)),t}function Ap(e,t){var s=t?Fi(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.byteLength)}function Pp(e){var t=new e.constructor(e.source,Qo.exec(e));return t.lastIndex=e.lastIndex,t}function jp(e){return gr?ze(gr.call(e)):{}}function ml(e,t){var s=t?Fi(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.length)}function gl(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 Ip(e,t,s){for(var c=-1,f=e.criteria,_=t.criteria,y=f.length,S=s.length;++c<y;){var A=gl(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 _l(e,t,s,c){for(var f=-1,_=e.length,y=s.length,S=-1,A=t.length,W=ct(_-y,0),H=M(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 xl(e,t,s,c){for(var f=-1,_=e.length,y=-1,S=s.length,A=-1,W=t.length,H=ct(_-S,0),V=M(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=M(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 Mp(e,t){return Qt(e,$i(e),t)}function Lp(e,t){return Qt(e,Pl(e),t)}function hs(e,t){return function(s,c){var f=Re(s)?Ud:rp,_=t?t():{};return f(s,e,pe(c,2),_)}}function er(e){return Pe(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=ze(t);++c<f;){var S=s[c];S&&e(t,S,c,_)}return t})}function vl(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=ze(s);(t?_--:++_<f)&&c(y[_],_,y)!==!1;);return s}}function bl(e){return function(t,s,c){for(var f=-1,_=ze(t),y=c(t),S=y.length;S--;){var A=y[e?S:++f];if(s(_[A],A,_)===!1)break}return t}}function Dp(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 yl(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 ui(vc(xc(t).replace(Cd,"")),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 Op(e,t,s){var c=wr(e);function f(){for(var _=arguments.length,y=M(_),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 Cl(e,t,ps,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 wl(e){return function(t,s,c){var f=ze(t);if(!St(t)){var _=pe(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 El(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&&xs(_)=="wrapper")var y=new Ot([],!0)}for(c=y?c:s;++c<s;){_=t[c];var S=xs(_),A=S=="wrapper"?zi(_):r;A&&Yi(A[0])&&A[1]==(X|I|G|q)&&!A[4].length&&A[9]==1?y=y[xs(A[0])].apply(y,A[3]):y=_.length==1&&Yi(_)?y[S]():y.thru(_)}return function(){var W=arguments,H=W[0];if(y&&W.length==1&&Re(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 ps(e,t,s,c,f,_,y,S,A,W){var H=t&X,V=t&R,te=t&L,oe=t&(I|P),xe=t&F,Ae=te?r:wr(e);function ve(){for(var je=arguments.length,De=M(je),Pt=je;Pt--;)De[Pt]=arguments[Pt];if(oe)var yt=nr(ve),jt=Vd(De,yt);if(c&&(De=_l(De,c,f,oe)),_&&(De=xl(De,_,y,oe)),je-=jt,oe&&je<W){var nt=bn(De,yt);return Cl(e,t,ps,ve.placeholder,s,De,nt,S,A,W-je)}var Xt=V?s:this,hn=te?Xt[e]:e;return je=De.length,S?De=rm(De,S):xe&&je>1&&De.reverse(),H&&A<je&&(De.length=A),this&&this!==dt&&this instanceof ve&&(hn=Ae||wr(hn)),hn.apply(Xt,De)}return ve}function Sl(e,t){return function(s,c){return fp(s,e,t(c),{})}}function ms(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=cl(s),c=cl(c)),f=e(s,c)}return f}}function Ui(e){return cn(function(t){return t=Ke(t,Rt(pe())),Pe(function(s){var c=this;return e(t,function(f){return Tt(f,c,s)})})})}function gs(e,t){t=t===r?" ":kt(t);var s=t.length;if(s<2)return s?Ii(t,e):t;var c=Ii(t,ns(e/Yn(t)));return Xn(t)?Nn(zt(c),0,e).join(""):c.slice(0,e)}function Bp(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=M(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 Nl(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),Ep(t,s,c,e)}}function _s(e){return function(t,s){return typeof t=="string"&&typeof s=="string"||(t=Wt(t),s=Wt(s)),e(t,s)}}function Cl(e,t,s,c,f,_,y,S,A,W){var H=t&I,V=H?y:r,te=H?r:y,oe=H?_:r,xe=H?r:_;t|=H?G:Q,t&=~(H?Q:G),t&B||(t&=-4);var Ae=[e,t,f,oe,V,xe,te,S,A,W],ve=s.apply(r,Ae);return Yi(e)&&Bl(ve,Ae),ve.placeholder=c,Fl(ve,e,t)}function Wi(e){var t=lt[e];return function(s,c){if(s=Wt(s),c=c==null?0:mt(ke(c),292),c&&Fa(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 Fp=Qn&&1/$r(new Qn([,-0]))[1]==ie?function(e){return new Qn(e)}:co;function Tl(e){return function(t){var s=gt(t);return s==ue?_i(t):s==ge?nh(t):Yd(t,e(t))}}function ln(e,t,s,c,f,_,y,S){var A=t&L;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:ct(ke(y),0),S=S===r?S:ke(S),W-=f?f.length:0,t&Q){var H=c,V=f;c=f=r}var te=A?r:zi(e),oe=[e,t,s,c,f,H,V,_,y,S];if(te&&em(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:ct(oe[9]-W,0),!S&&t&(I|P)&&(t&=-25),!t||t==R)var xe=Dp(e,t,s);else t==I||t==P?xe=Op(e,t,S):(t==G||t==(R|G))&&!f.length?xe=Bp(e,t,s,c):xe=ps.apply(r,oe);var Ae=te?al:Bl;return Fl(Ae(xe,oe),e,t)}function Rl(e,t,s,c){return e===r||$t(e,Kn[s])&&!He.call(c,s)?t:e}function kl(e,t,s,c,f,_){return Je(e)&&Je(t)&&(_.set(t,e),us(e,t,r,kl,_),_.delete(t)),e}function Up(e){return Nr(e)?r:e}function Al(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 Ln:r;for(_.set(e,t),_.set(t,e);++V<S;){var xe=e[V],Ae=t[V];if(c)var ve=y?c(Ae,xe,V,t,e,_):c(xe,Ae,V,e,t,_);if(ve!==r){if(ve)continue;te=!1;break}if(oe){if(!fi(t,function(je,De){if(!fr(oe,De)&&(xe===je||f(xe,je,s,c,_)))return oe.push(De)})){te=!1;break}}else if(!(xe===Ae||f(xe,Ae,s,c,_))){te=!1;break}}return _.delete(e),_.delete(t),te}function Wp(e,t,s,c,f,_,y){switch(s){case at:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case ot:return!(e.byteLength!=t.byteLength||!_(new Jr(e),new Jr(t)));case Be:case O:case be:return $t(+e,+t);case ce:return e.name==t.name&&e.message==t.message;case le:case Ee:return e==t+"";case ue:var S=_i;case ge:var A=c&N;if(S||(S=$r),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=Al(S(e),S(t),c,f,_,y);return y.delete(e),H;case he:if(gr)return gr.call(e)==gr.call(t)}return!1}function Hp(e,t,s,c,f,_){var y=s&N,S=Hi(e),A=S.length,W=Hi(t),H=W.length;if(A!=H&&!y)return!1;for(var V=A;V--;){var te=S[V];if(!(y?te in t:He.call(t,te)))return!1}var oe=_.get(e),xe=_.get(t);if(oe&&xe)return oe==t&&xe==e;var Ae=!0;_.set(e,t),_.set(t,e);for(var ve=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)){Ae=!1;break}ve||(ve=te=="constructor")}if(Ae&&!ve){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)&&(Ae=!1)}return _.delete(e),_.delete(t),Ae}function cn(e){return Ki(Dl(e,r,ql),e+"")}function Hi(e){return Ka(e,ft,$i)}function Gi(e){return Ka(e,Nt,Pl)}var zi=ss?function(e){return ss.get(e)}:co;function xs(e){for(var t=e.name+"",s=Jn[t],c=He.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=He.call(m,"placeholder")?m:e;return t.placeholder}function pe(){var e=m.iteratee||ao;return e=e===ao?Za:e,arguments.length?e(arguments[0],arguments[1]):e}function vs(e,t){var s=e.__data__;return Kp(t)?s[typeof t=="string"?"string":"hash"]:s.map}function qi(e){for(var t=ft(e),s=t.length;s--;){var c=t[s],f=e[c];t[s]=[c,f,Ml(f)]}return t}function Bn(e,t){var s=Zd(e,t);return Ja(s)?s:r}function Gp(e){var t=He.call(e,In),s=e[In];try{e[In]=r;var c=!0}catch{}var f=Kr.call(e);return c&&(t?e[In]=s:delete e[In]),f}var $i=vi?function(e){return e==null?[]:(e=ze(e),xn(vi(e),function(t){return Oa.call(e,t)}))}:uo,Pl=vi?function(e){for(var t=[];e;)vn(t,$i(e)),e=Zr(e);return t}:uo,gt=vt;(bi&>(new bi(new ArrayBuffer(1)))!=at||hr&>(new hr)!=ue||yi&>(yi.resolve())!=we||Qn&>(new Qn)!=ge||pr&>(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 Nh:return at;case Ch:return ue;case Th:return we;case Rh:return ge;case kh:return pt}return t});function zp(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=ct(e,t-y);break}}return{start:e,end:t}}function qp(e){var t=e.match(Qf);return t?t[1].split(Jf):[]}function jl(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&&Cs(f)&&un(y,f)&&(Re(e)||Un(e)))}function $p(e){var t=e.length,s=new e.constructor(t);return t&&typeof e[0]=="string"&&He.call(e,"index")&&(s.index=e.index,s.input=e.input),s}function Il(e){return typeof e.constructor=="function"&&!Er(e)?Zn(Zr(e)):{}}function Xp(e,t,s){var c=e.constructor;switch(t){case ot:return Fi(e);case Be:case O:return new c(+e);case at:return Ap(e,s);case Pn:case Gn:case cr:case rn:case zn:case U:case _e:case It:case ur:return ml(e,s);case ue:return new c;case be:case Ee:return new c(e);case le:return Pp(e);case ge:return new c;case he:return jp(e)}}function Yp(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(Kf,`{
|
|
7
|
+
/* [wrapped with `+t+`] */
|
|
8
|
+
`)}function Vp(e){return Re(e)||Un(e)||!!(Ba&&e&&e[Ba])}function un(e,t){var s=typeof e;return t=t??ae,!!t&&(s=="number"||s!="symbol"&&ad.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 Xi(e,t){if(Re(e))return!1;var s=typeof e;return s=="number"||s=="symbol"||s=="boolean"||e==null||At(e)?!0:$f.test(e)||!qf.test(e)||t!=null&&e in ze(t)}function Kp(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Yi(e){var t=xs(e),s=m[t];if(typeof s!="function"||!(t in Me.prototype))return!1;if(e===s)return!0;var c=zi(s);return!!c&&e===c[0]}function Qp(e){return!!Ma&&Ma in e}var Jp=Yr?fn:fo;function Er(e){var t=e&&e.constructor,s=typeof t=="function"&&t.prototype||Kn;return e===s}function Ml(e){return e===e&&!Je(e)}function Ll(e,t){return function(s){return s==null?!1:s[e]===t&&(t!==r||e in ze(s))}}function Zp(e){var t=Ss(e,function(c){return s.size===g&&s.clear(),c}),s=t.cache;return t}function em(e,t){var s=e[1],c=t[1],f=s|c,_=f<(R|L|X),y=c==X&&s==I||c==X&&s==q&&e[7].length<=t[8]||c==(X|q)&&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?_l(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?xl(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 tm(e){var t=[];if(e!=null)for(var s in ze(e))t.push(s);return t}function nm(e){return Kr.call(e)}function Dl(e,t,s){return t=ct(t===r?e.length-1:t,0),function(){for(var c=arguments,f=-1,_=ct(c.length-t,0),y=M(_);++f<_;)y[f]=c[t+f];f=-1;for(var S=M(t+1);++f<t;)S[f]=c[f];return S[t]=s(y),Tt(e,this,S)}}function Ol(e,t){return t.length<2?e:On(e,Ft(t,0,-1))}function rm(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 Vi(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var Bl=Ul(al),Sr=xh||function(e,t){return dt.setTimeout(e,t)},Ki=Ul(Cp);function Fl(e,t,s){var c=t+"";return Ki(e,Yp(c,sm(qp(c),s)))}function Ul(e){var t=0,s=0;return function(){var c=wh(),f=me-(c-s);if(s=c,f>0){if(++t>=re)return arguments[0]}else t=0;return e.apply(r,arguments)}}function bs(e,t){var s=-1,c=e.length,f=c-1;for(t=t===r?c:t;++s<t;){var _=ji(s,f),y=e[_];e[_]=e[s],e[s]=y}return e.length=t,e}var Wl=Zp(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Xf,function(s,c,f,_){t.push(f?_.replace(td,"$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 Vr.call(e)}catch{}try{return e+""}catch{}}return""}function sm(e,t){return Lt(ye,function(s){var c="_."+s[0];t&s[1]&&!zr(e,c)&&e.push(c)}),e.sort()}function Hl(e){if(e instanceof Me)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 im(e,t,s){(s?bt(e,t,s):t===r)?t=1:t=ct(ke(t),0);var c=e==null?0:e.length;if(!c||t<1)return[];for(var f=0,_=0,y=M(ns(c/t));f<c;)y[_++]=Ft(e,f,f+=t);return y}function om(e){for(var t=-1,s=e==null?0:e.length,c=0,f=[];++t<s;){var _=e[t];_&&(f[c++]=_)}return f}function am(){var e=arguments.length;if(!e)return[];for(var t=M(e-1),s=arguments[0],c=e;c--;)t[c-1]=arguments[c];return vn(Re(s)?Et(s):[s],ht(t,1))}var lm=Pe(function(e,t){return tt(e)?xr(e,ht(t,1,tt,!0)):[]}),cm=Pe(function(e,t){var s=Ut(t);return tt(s)&&(s=r),tt(e)?xr(e,ht(t,1,tt,!0),pe(s,2)):[]}),um=Pe(function(e,t){var s=Ut(t);return tt(s)&&(s=r),tt(e)?xr(e,ht(t,1,tt,!0),r,s):[]});function fm(e,t,s){var c=e==null?0:e.length;return c?(t=s||t===r?1:ke(t),Ft(e,t<0?0:t,c)):[]}function dm(e,t,s){var c=e==null?0:e.length;return c?(t=s||t===r?1:ke(t),t=c-t,Ft(e,0,t<0?0:t)):[]}function hm(e,t){return e&&e.length?ds(e,pe(t,3),!0,!0):[]}function pm(e,t){return e&&e.length?ds(e,pe(t,3),!0):[]}function mm(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),ap(e,t,s,c)):[]}function Gl(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=s==null?0:ke(s);return f<0&&(f=ct(c+f,0)),qr(e,pe(t,3),f)}function zl(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=c-1;return s!==r&&(f=ke(s),f=s<0?ct(c+f,0):mt(f,c-1)),qr(e,pe(t,3),f,!0)}function ql(e){var t=e==null?0:e.length;return t?ht(e,1):[]}function gm(e){var t=e==null?0:e.length;return t?ht(e,ie):[]}function _m(e,t){var s=e==null?0:e.length;return s?(t=t===r?1:ke(t),ht(e,t)):[]}function xm(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 $l(e){return e&&e.length?e[0]:r}function vm(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=s==null?0:ke(s);return f<0&&(f=ct(c+f,0)),$n(e,t,f)}function bm(e){var t=e==null?0:e.length;return t?Ft(e,0,-1):[]}var ym=Pe(function(e){var t=Ke(e,Oi);return t.length&&t[0]===e[0]?Ti(t):[]}),wm=Pe(function(e){var t=Ut(e),s=Ke(e,Oi);return t===Ut(s)?t=r:s.pop(),s.length&&s[0]===e[0]?Ti(s,pe(t,2)):[]}),Em=Pe(function(e){var t=Ut(e),s=Ke(e,Oi);return t=typeof t=="function"?t:r,t&&s.pop(),s.length&&s[0]===e[0]?Ti(s,r,t):[]});function Sm(e,t){return e==null?"":bh.call(e,t)}function Ut(e){var t=e==null?0:e.length;return t?e[t-1]:r}function Nm(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=c;return s!==r&&(f=ke(s),f=f<0?ct(c+f,0):mt(f,c-1)),t===t?sh(e,t,f):qr(e,Ca,f,!0)}function Cm(e,t){return e&&e.length?rl(e,ke(t)):r}var Tm=Pe(Xl);function Xl(e,t){return e&&e.length&&t&&t.length?Pi(e,t):e}function Rm(e,t,s){return e&&e.length&&t&&t.length?Pi(e,t,pe(s,2)):e}function km(e,t,s){return e&&e.length&&t&&t.length?Pi(e,t,r,s):e}var Am=cn(function(e,t){var s=e==null?0:e.length,c=Ei(e,t);return ol(e,Ke(t,function(f){return un(f,s)?+f:f}).sort(gl)),c});function Pm(e,t){var s=[];if(!(e&&e.length))return s;var c=-1,f=[],_=e.length;for(t=pe(t,3);++c<_;){var y=e[c];t(y,c,e)&&(s.push(y),f.push(c))}return ol(e,f),s}function Qi(e){return e==null?e:Sh.call(e)}function jm(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:ke(t),s=s===r?c:ke(s)),Ft(e,t,s)):[]}function Im(e,t){return fs(e,t)}function Mm(e,t,s){return Mi(e,t,pe(s,2))}function Lm(e,t){var s=e==null?0:e.length;if(s){var c=fs(e,t);if(c<s&&$t(e[c],t))return c}return-1}function Dm(e,t){return fs(e,t,!0)}function Om(e,t,s){return Mi(e,t,pe(s,2),!0)}function Bm(e,t){var s=e==null?0:e.length;if(s){var c=fs(e,t,!0)-1;if($t(e[c],t))return c}return-1}function Fm(e){return e&&e.length?ll(e):[]}function Um(e,t){return e&&e.length?ll(e,pe(t,2)):[]}function Wm(e){var t=e==null?0:e.length;return t?Ft(e,1,t):[]}function Hm(e,t,s){return e&&e.length?(t=s||t===r?1:ke(t),Ft(e,0,t<0?0:t)):[]}function Gm(e,t,s){var c=e==null?0:e.length;return c?(t=s||t===r?1:ke(t),t=c-t,Ft(e,t<0?0:t,c)):[]}function zm(e,t){return e&&e.length?ds(e,pe(t,3),!1,!0):[]}function qm(e,t){return e&&e.length?ds(e,pe(t,3)):[]}var $m=Pe(function(e){return En(ht(e,1,tt,!0))}),Xm=Pe(function(e){var t=Ut(e);return tt(t)&&(t=r),En(ht(e,1,tt,!0),pe(t,2))}),Ym=Pe(function(e){var t=Ut(e);return t=typeof t=="function"?t:r,En(ht(e,1,tt,!0),r,t)});function Vm(e){return e&&e.length?En(e):[]}function Km(e,t){return e&&e.length?En(e,pe(t,2)):[]}function Qm(e,t){return t=typeof t=="function"?t:r,e&&e.length?En(e,r,t):[]}function Ji(e){if(!(e&&e.length))return[];var t=0;return e=xn(e,function(s){if(tt(s))return t=ct(s.length,t),!0}),mi(t,function(s){return Ke(e,di(s))})}function Yl(e,t){if(!(e&&e.length))return[];var s=Ji(e);return t==null?s:Ke(s,function(c){return Tt(t,r,c)})}var Jm=Pe(function(e,t){return tt(e)?xr(e,t):[]}),Zm=Pe(function(e){return Di(xn(e,tt))}),e0=Pe(function(e){var t=Ut(e);return tt(t)&&(t=r),Di(xn(e,tt),pe(t,2))}),t0=Pe(function(e){var t=Ut(e);return t=typeof t=="function"?t:r,Di(xn(e,tt),r,t)}),n0=Pe(Ji);function r0(e,t){return dl(e||[],t||[],_r)}function s0(e,t){return dl(e||[],t||[],yr)}var i0=Pe(function(e){var t=e.length,s=t>1?e[t-1]:r;return s=typeof s=="function"?(e.pop(),s):r,Yl(e,s)});function Vl(e){var t=m(e);return t.__chain__=!0,t}function o0(e,t){return t(e),e}function ys(e,t){return t(e)}var a0=cn(function(e){var t=e.length,s=t?e[0]:0,c=this.__wrapped__,f=function(_){return Ei(_,e)};return t>1||this.__actions__.length||!(c instanceof Me)||!un(s)?this.thru(f):(c=c.slice(s,+s+(t?1:0)),c.__actions__.push({func:ys,args:[f],thisArg:r}),new Ot(c,this.__chain__).thru(function(_){return t&&!_.length&&_.push(r),_}))});function l0(){return Vl(this)}function c0(){return new Ot(this.value(),this.__chain__)}function u0(){this.__values__===r&&(this.__values__=cc(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function f0(){return this}function d0(e){for(var t,s=this;s instanceof os;){var c=Hl(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 h0(){var e=this.__wrapped__;if(e instanceof Me){var t=e;return this.__actions__.length&&(t=new Me(this)),t=t.reverse(),t.__actions__.push({func:ys,args:[Qi],thisArg:r}),new Ot(t,this.__chain__)}return this.thru(Qi)}function p0(){return fl(this.__wrapped__,this.__actions__)}var m0=hs(function(e,t,s){He.call(e,s)?++e[s]:an(e,s,1)});function g0(e,t,s){var c=Re(e)?Sa:op;return s&&bt(e,t,s)&&(t=r),c(e,pe(t,3))}function _0(e,t){var s=Re(e)?xn:Ya;return s(e,pe(t,3))}var x0=wl(Gl),v0=wl(zl);function b0(e,t){return ht(ws(e,t),1)}function y0(e,t){return ht(ws(e,t),ie)}function w0(e,t,s){return s=s===r?1:ke(s),ht(ws(e,t),s)}function Kl(e,t){var s=Re(e)?Lt:wn;return s(e,pe(t,3))}function Ql(e,t){var s=Re(e)?Wd:Xa;return s(e,pe(t,3))}var E0=hs(function(e,t,s){He.call(e,s)?e[s].push(t):an(e,s,[t])});function S0(e,t,s,c){e=St(e)?e:sr(e),s=s&&!c?ke(s):0;var f=e.length;return s<0&&(s=ct(f+s,0)),Ts(e)?s<=f&&e.indexOf(t,s)>-1:!!f&&$n(e,t,s)>-1}var N0=Pe(function(e,t,s){var c=-1,f=typeof t=="function",_=St(e)?M(e.length):[];return wn(e,function(y){_[++c]=f?Tt(t,y,s):vr(y,t,s)}),_}),C0=hs(function(e,t,s){an(e,s,t)});function ws(e,t){var s=Re(e)?Ke:el;return s(e,pe(t,3))}function T0(e,t,s,c){return e==null?[]:(Re(t)||(t=t==null?[]:[t]),s=c?r:s,Re(s)||(s=s==null?[]:[s]),sl(e,t,s))}var R0=hs(function(e,t,s){e[s?0:1].push(t)},function(){return[[],[]]});function k0(e,t,s){var c=Re(e)?ui:Ra,f=arguments.length<3;return c(e,pe(t,4),s,f,wn)}function A0(e,t,s){var c=Re(e)?Hd:Ra,f=arguments.length<3;return c(e,pe(t,4),s,f,Xa)}function P0(e,t){var s=Re(e)?xn:Ya;return s(e,Ns(pe(t,3)))}function j0(e){var t=Re(e)?Ga:Sp;return t(e)}function I0(e,t,s){(s?bt(e,t,s):t===r)?t=1:t=ke(t);var c=Re(e)?tp:Np;return c(e,t)}function M0(e){var t=Re(e)?np:Tp;return t(e)}function L0(e){if(e==null)return 0;if(St(e))return Ts(e)?Yn(e):e.length;var t=gt(e);return t==ue||t==ge?e.size:ki(e).length}function D0(e,t,s){var c=Re(e)?fi:Rp;return s&&bt(e,t,s)&&(t=r),c(e,pe(t,3))}var O0=Pe(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]]),sl(e,ht(t,1),[])}),Es=_h||function(){return dt.Date.now()};function B0(e,t){if(typeof t!="function")throw new Dt(d);return e=ke(e),function(){if(--e<1)return t.apply(this,arguments)}}function Jl(e,t,s){return t=s?r:t,t=e&&t==null?e.length:t,ln(e,X,r,r,r,r,t)}function Zl(e,t){var s;if(typeof t!="function")throw new Dt(d);return e=ke(e),function(){return--e>0&&(s=t.apply(this,arguments)),e<=1&&(t=r),s}}var Zi=Pe(function(e,t,s){var c=R;if(s.length){var f=bn(s,nr(Zi));c|=G}return ln(e,c,t,s,f)}),ec=Pe(function(e,t,s){var c=R|L;if(s.length){var f=bn(s,nr(ec));c|=G}return ln(t,c,e,s,f)});function tc(e,t,s){t=s?r:t;var c=ln(e,I,r,r,r,r,r,t);return c.placeholder=tc.placeholder,c}function nc(e,t,s){t=s?r:t;var c=ln(e,P,r,r,r,r,r,t);return c.placeholder=nc.placeholder,c}function rc(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?ct(Wt(s.maxWait)||0,t):_,te="trailing"in s?!!s.trailing:te);function oe(nt){var Xt=c,hn=f;return c=f=r,W=nt,y=e.apply(hn,Xt),y}function xe(nt){return W=nt,S=Sr(je,t),H?oe(nt):y}function Ae(nt){var Xt=nt-A,hn=nt-W,wc=t-Xt;return V?mt(wc,_-hn):wc}function ve(nt){var Xt=nt-A,hn=nt-W;return A===r||Xt>=t||Xt<0||V&&hn>=_}function je(){var nt=Es();if(ve(nt))return De(nt);S=Sr(je,Ae(nt))}function De(nt){return S=r,te&&c?oe(nt):(c=f=r,y)}function Pt(){S!==r&&hl(S),W=0,c=A=f=S=r}function yt(){return S===r?y:De(Es())}function jt(){var nt=Es(),Xt=ve(nt);if(c=arguments,f=this,A=nt,Xt){if(S===r)return xe(A);if(V)return hl(S),S=Sr(je,t),oe(A)}return S===r&&(S=Sr(je,t)),y}return jt.cancel=Pt,jt.flush=yt,jt}var F0=Pe(function(e,t){return $a(e,1,t)}),U0=Pe(function(e,t,s){return $a(e,Wt(t)||0,s)});function W0(e){return ln(e,F)}function Ss(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(Ss.Cache||on),s}Ss.Cache=on;function Ns(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 H0(e){return Zl(2,e)}var G0=kp(function(e,t){t=t.length==1&&Re(t[0])?Ke(t[0],Rt(pe())):Ke(ht(t,1),Rt(pe()));var s=t.length;return Pe(function(c){for(var f=-1,_=mt(c.length,s);++f<_;)c[f]=t[f].call(this,c[f]);return Tt(e,this,c)})}),eo=Pe(function(e,t){var s=bn(t,nr(eo));return ln(e,G,r,t,s)}),sc=Pe(function(e,t){var s=bn(t,nr(sc));return ln(e,Q,r,t,s)}),z0=cn(function(e,t){return ln(e,q,r,r,r,t)});function q0(e,t){if(typeof e!="function")throw new Dt(d);return t=t===r?t:ke(t),Pe(e,t)}function $0(e,t){if(typeof e!="function")throw new Dt(d);return t=t==null?0:ct(ke(t),0),Pe(function(s){var c=s[t],f=Nn(s,0,t);return c&&vn(f,c),Tt(e,this,f)})}function X0(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),rc(e,t,{leading:c,maxWait:t,trailing:f})}function Y0(e){return Jl(e,1)}function V0(e,t){return eo(Bi(t),e)}function K0(){if(!arguments.length)return[];var e=arguments[0];return Re(e)?e:[e]}function Q0(e){return Bt(e,E)}function J0(e,t){return t=typeof t=="function"?t:r,Bt(e,E,t)}function Z0(e){return Bt(e,x|E)}function eg(e,t){return t=typeof t=="function"?t:r,Bt(e,x|E,t)}function tg(e,t){return t==null||qa(e,t,ft(t))}function $t(e,t){return e===t||e!==e&&t!==t}var ng=_s(Ci),rg=_s(function(e,t){return e>=t}),Un=Qa((function(){return arguments})())?Qa:function(e){return Ze(e)&&He.call(e,"callee")&&!Oa.call(e,"callee")},Re=M.isArray,sg=xa?Rt(xa):dp;function St(e){return e!=null&&Cs(e.length)&&!fn(e)}function tt(e){return Ze(e)&&St(e)}function ig(e){return e===!0||e===!1||Ze(e)&&vt(e)==Be}var Cn=vh||fo,og=va?Rt(va):hp;function ag(e){return Ze(e)&&e.nodeType===1&&!Nr(e)}function lg(e){if(e==null)return!0;if(St(e)&&(Re(e)||typeof e=="string"||typeof e.splice=="function"||Cn(e)||rr(e)||Un(e)))return!e.length;var t=gt(e);if(t==ue||t==ge)return!e.size;if(Er(e))return!ki(e).length;for(var s in e)if(He.call(e,s))return!1;return!0}function cg(e,t){return br(e,t)}function ug(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 to(e){if(!Ze(e))return!1;var t=vt(e);return t==ce||t==de||typeof e.message=="string"&&typeof e.name=="string"&&!Nr(e)}function fg(e){return typeof e=="number"&&Fa(e)}function fn(e){if(!Je(e))return!1;var t=vt(e);return t==Fe||t==Ve||t==Qe||t==Le}function ic(e){return typeof e=="number"&&e==ke(e)}function Cs(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=ae}function Je(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function Ze(e){return e!=null&&typeof e=="object"}var oc=ba?Rt(ba):mp;function dg(e,t){return e===t||Ri(e,t,qi(t))}function hg(e,t,s){return s=typeof s=="function"?s:r,Ri(e,t,qi(t),s)}function pg(e){return ac(e)&&e!=+e}function mg(e){if(Jp(e))throw new Ce(l);return Ja(e)}function gg(e){return e===null}function _g(e){return e==null}function ac(e){return typeof e=="number"||Ze(e)&&vt(e)==be}function Nr(e){if(!Ze(e)||vt(e)!=ee)return!1;var t=Zr(e);if(t===null)return!0;var s=He.call(t,"constructor")&&t.constructor;return typeof s=="function"&&s instanceof s&&Vr.call(s)==hh}var no=ya?Rt(ya):gp;function xg(e){return ic(e)&&e>=-ae&&e<=ae}var lc=wa?Rt(wa):_p;function Ts(e){return typeof e=="string"||!Re(e)&&Ze(e)&&vt(e)==Ee}function At(e){return typeof e=="symbol"||Ze(e)&&vt(e)==he}var rr=Ea?Rt(Ea):xp;function vg(e){return e===r}function bg(e){return Ze(e)&>(e)==pt}function yg(e){return Ze(e)&&vt(e)==rt}var wg=_s(Ai),Eg=_s(function(e,t){return e<=t});function cc(e){if(!e)return[];if(St(e))return Ts(e)?zt(e):Et(e);if(dr&&e[dr])return th(e[dr]());var t=gt(e),s=t==ue?_i:t==ge?$r: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*Te}return e===e?e:0}function ke(e){var t=dn(e),s=t%1;return t===t?s?t-s:t:0}function uc(e){return e?Dn(ke(e),0,J):0}function Wt(e){if(typeof e=="number")return e;if(At(e))return z;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=ka(e);var s=sd.test(e);return s||od.test(e)?Bd(e.slice(2),s?2:8):rd.test(e)?z:+e}function fc(e){return Qt(e,Nt(e))}function Sg(e){return e?Dn(ke(e),-ae,ae):e===0?e:0}function We(e){return e==null?"":kt(e)}var Ng=er(function(e,t){if(Er(t)||St(t)){Qt(t,ft(t),e);return}for(var s in t)He.call(t,s)&&_r(e,s,t[s])}),dc=er(function(e,t){Qt(t,Nt(t),e)}),Rs=er(function(e,t,s,c){Qt(t,Nt(t),e,c)}),Cg=er(function(e,t,s,c){Qt(t,ft(t),e,c)}),Tg=cn(Ei);function Rg(e,t){var s=Zn(e);return t==null?s:za(s,t)}var kg=Pe(function(e,t){e=ze(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])&&!He.call(e,W))&&(e[W]=_[W])}return e}),Ag=Pe(function(e){return e.push(r,kl),Tt(hc,r,e)});function Pg(e,t){return Na(e,pe(t,3),Kt)}function jg(e,t){return Na(e,pe(t,3),Ni)}function Ig(e,t){return e==null?e:Si(e,pe(t,3),Nt)}function Mg(e,t){return e==null?e:Va(e,pe(t,3),Nt)}function Lg(e,t){return e&&Kt(e,pe(t,3))}function Dg(e,t){return e&&Ni(e,pe(t,3))}function Og(e){return e==null?[]:cs(e,ft(e))}function Bg(e){return e==null?[]:cs(e,Nt(e))}function ro(e,t,s){var c=e==null?r:On(e,t);return c===r?s:c}function Fg(e,t){return e!=null&&jl(e,t,lp)}function so(e,t){return e!=null&&jl(e,t,cp)}var Ug=Sl(function(e,t,s){t!=null&&typeof t.toString!="function"&&(t=Kr.call(t)),e[t]=s},oo(Ct)),Wg=Sl(function(e,t,s){t!=null&&typeof t.toString!="function"&&(t=Kr.call(t)),He.call(e,t)?e[t].push(s):e[t]=[s]},pe),Hg=Pe(vr);function ft(e){return St(e)?Ha(e):ki(e)}function Nt(e){return St(e)?Ha(e,!0):vp(e)}function Gg(e,t){var s={};return t=pe(t,3),Kt(e,function(c,f,_){an(s,t(c,f,_),c)}),s}function zg(e,t){var s={};return t=pe(t,3),Kt(e,function(c,f,_){an(s,f,t(c,f,_))}),s}var qg=er(function(e,t,s){us(e,t,s)}),hc=er(function(e,t,s,c){us(e,t,s,c)}),$g=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,Gi(e),s),c&&(s=Bt(s,x|b|E,Up));for(var f=t.length;f--;)Li(s,t[f]);return s});function Xg(e,t){return pc(e,Ns(pe(t)))}var Yg=cn(function(e,t){return e==null?{}:yp(e,t)});function pc(e,t){if(e==null)return{};var s=Ke(Gi(e),function(c){return[c]});return t=pe(t),il(e,s,function(c,f){return t(c,f[0])})}function Vg(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 Kg(e,t,s){return e==null?e:yr(e,t,s)}function Qg(e,t,s,c){return c=typeof c=="function"?c:r,e==null?e:yr(e,t,s,c)}var mc=Tl(ft),gc=Tl(Nt);function Jg(e,t,s){var c=Re(e),f=c||Cn(e)||rr(e);if(t=pe(t,4),s==null){var _=e&&e.constructor;f?s=c?new _:[]:Je(e)?s=fn(_)?Zn(Zr(e)):{}:s={}}return(f?Lt:Kt)(e,function(y,S,A){return t(s,y,S,A)}),s}function Zg(e,t){return e==null?!0:Li(e,t)}function e_(e,t,s){return e==null?e:ul(e,t,Bi(s))}function t_(e,t,s,c){return c=typeof c=="function"?c:r,e==null?e:ul(e,t,Bi(s),c)}function sr(e){return e==null?[]:gi(e,ft(e))}function n_(e){return e==null?[]:gi(e,Nt(e))}function r_(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 s_(e,t,s){return t=dn(t),s===r?(s=t,t=0):s=dn(s),e=Wt(e),up(e,t,s)}function i_(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=Ua();return mt(e+f*(t-e+Od("1e-"+((f+"").length-1))),t)}return ji(e,t)}var o_=tr(function(e,t,s){return t=t.toLowerCase(),e+(s?_c(t):t)});function _c(e){return io(We(e).toLowerCase())}function xc(e){return e=We(e),e&&e.replace(ld,Kd).replace(Td,"")}function a_(e,t,s){e=We(e),t=kt(t);var c=e.length;s=s===r?c:Dn(ke(s),0,c);var f=s;return s-=t.length,s>=0&&e.slice(s,f)==t}function l_(e){return e=We(e),e&&Hf.test(e)?e.replace(Vo,Qd):e}function c_(e){return e=We(e),e&&Yf.test(e)?e.replace(ei,"\\$&"):e}var u_=tr(function(e,t,s){return e+(s?"-":"")+t.toLowerCase()}),f_=tr(function(e,t,s){return e+(s?" ":"")+t.toLowerCase()}),d_=yl("toLowerCase");function h_(e,t,s){e=We(e),t=ke(t);var c=t?Yn(e):0;if(!t||c>=t)return e;var f=(t-c)/2;return gs(rs(f),s)+e+gs(ns(f),s)}function p_(e,t,s){e=We(e),t=ke(t);var c=t?Yn(e):0;return t&&c<t?e+gs(t-c,s):e}function m_(e,t,s){e=We(e),t=ke(t);var c=t?Yn(e):0;return t&&c<t?gs(t-c,s)+e:e}function g_(e,t,s){return s||t==null?t=0:t&&(t=+t),Eh(We(e).replace(ti,""),t||0)}function __(e,t,s){return(s?bt(e,t,s):t===r)?t=1:t=ke(t),Ii(We(e),t)}function x_(){var e=arguments,t=We(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var v_=tr(function(e,t,s){return e+(s?"_":"")+t.toLowerCase()});function b_(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&&!no(t))&&(t=kt(t),!t&&Xn(e))?Nn(zt(e),0,s):e.split(t,s)):[]}var y_=tr(function(e,t,s){return e+(s?" ":"")+io(t)});function w_(e,t,s){return e=We(e),s=s==null?0:Dn(ke(s),0,e.length),t=kt(t),e.slice(s,s+t.length)==t}function E_(e,t,s){var c=m.templateSettings;s&&bt(e,t,s)&&(t=r),e=We(e),t=Rs({},t,c,Rl);var f=Rs({},t.imports,c.imports,Rl),_=ft(f),y=gi(f,_),S,A,W=0,H=t.interpolate||Wr,V="__p += '",te=xi((t.escape||Wr).source+"|"+H.source+"|"+(H===Ko?nd:Wr).source+"|"+(t.evaluate||Wr).source+"|$","g"),oe="//# sourceURL="+(He.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++jd+"]")+`
|
|
9
|
+
`;e.replace(te,function(ve,je,De,Pt,yt,jt){return De||(De=Pt),V+=e.slice(W,jt).replace(cd,Jd),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+ve.length,ve}),V+=`';
|
|
16
|
+
`;var xe=He.call(t,"variable")&&t.variable;if(!xe)V=`with (obj) {
|
|
17
|
+
`+V+`
|
|
18
|
+
}
|
|
19
|
+
`;else if(ed.test(xe))throw new Ce(v);V=(A?V.replace(Ur,""):V).replace(Ff,"$1").replace(Uf,"$1;"),V="function("+(xe||"obj")+`) {
|
|
20
|
+
`+(xe?"":`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 Ae=bc(function(){return Ue(_,oe+"return "+V).apply(r,y)});if(Ae.source=V,to(Ae))throw Ae;return Ae}function S_(e){return We(e).toLowerCase()}function N_(e){return We(e).toUpperCase()}function C_(e,t,s){if(e=We(e),e&&(s||t===r))return ka(e);if(!e||!(t=kt(t)))return e;var c=zt(e),f=zt(t),_=Aa(c,f),y=Pa(c,f)+1;return Nn(c,_,y).join("")}function T_(e,t,s){if(e=We(e),e&&(s||t===r))return e.slice(0,Ia(e)+1);if(!e||!(t=kt(t)))return e;var c=zt(e),f=Pa(c,zt(t))+1;return Nn(c,0,f).join("")}function R_(e,t,s){if(e=We(e),e&&(s||t===r))return e.replace(ti,"");if(!e||!(t=kt(t)))return e;var c=zt(e),f=Aa(c,zt(t));return Nn(c,f).join("")}function k_(e,t){var s=C,c=k;if(Je(t)){var f="separator"in t?t.separator:f;s="length"in t?ke(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),no(f)){if(e.slice(S).search(f)){var W,H=A;for(f.global||(f=xi(f.source,We(Qo.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 A_(e){return e=We(e),e&&Wf.test(e)?e.replace(Yo,ih):e}var P_=tr(function(e,t,s){return e+(s?" ":"")+t.toUpperCase()}),io=yl("toUpperCase");function vc(e,t,s){return e=We(e),t=s?r:t,t===r?eh(e)?lh(e):qd(e):e.match(t)||[]}var bc=Pe(function(e,t){try{return Tt(e,r,t)}catch(s){return to(s)?s:new Ce(s)}}),j_=cn(function(e,t){return Lt(t,function(s){s=Jt(s),an(e,s,Zi(e[s],e))}),e});function I_(e){var t=e==null?0:e.length,s=pe();return e=t?Ke(e,function(c){if(typeof c[1]!="function")throw new Dt(d);return[s(c[0]),c[1]]}):[],Pe(function(c){for(var f=-1;++f<t;){var _=e[f];if(Tt(_[0],this,c))return Tt(_[1],this,c)}})}function M_(e){return ip(Bt(e,x))}function oo(e){return function(){return e}}function L_(e,t){return e==null||e!==e?t:e}var D_=El(),O_=El(!0);function Ct(e){return e}function ao(e){return Za(typeof e=="function"?e:Bt(e,x))}function B_(e){return tl(Bt(e,x))}function F_(e,t){return nl(e,Bt(t,x))}var U_=Pe(function(e,t){return function(s){return vr(s,e,t)}}),W_=Pe(function(e,t){return function(s){return vr(e,s,t)}});function lo(e,t,s){var c=ft(t),f=cs(t,c);s==null&&!(Je(t)&&(f.length||!c.length))&&(s=t,t=e,e=this,f=cs(t,ft(t)));var _=!(Je(s)&&"chain"in s)||!!s.chain,y=fn(e);return Lt(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 H_(){return dt._===this&&(dt._=ph),this}function co(){}function G_(e){return e=ke(e),Pe(function(t){return rl(t,e)})}var z_=Ui(Ke),q_=Ui(Sa),$_=Ui(fi);function yc(e){return Xi(e)?di(Jt(e)):wp(e)}function X_(e){return function(t){return e==null?r:On(e,t)}}var Y_=Nl(),V_=Nl(!0);function uo(){return[]}function fo(){return!1}function K_(){return{}}function Q_(){return""}function J_(){return!0}function Z_(e,t){if(e=ke(e),e<1||e>ae)return[];var s=J,c=mt(e,J);t=pe(t),e-=J;for(var f=mi(c,t);++s<e;)t(s);return f}function ex(e){return Re(e)?Ke(e,Jt):At(e)?[e]:Et(Wl(We(e)))}function tx(e){var t=++dh;return We(e)+t}var nx=ms(function(e,t){return e+t},0),rx=Wi("ceil"),sx=ms(function(e,t){return e/t},1),ix=Wi("floor");function ox(e){return e&&e.length?ls(e,Ct,Ci):r}function ax(e,t){return e&&e.length?ls(e,pe(t,2),Ci):r}function lx(e){return Ta(e,Ct)}function cx(e,t){return Ta(e,pe(t,2))}function ux(e){return e&&e.length?ls(e,Ct,Ai):r}function fx(e,t){return e&&e.length?ls(e,pe(t,2),Ai):r}var dx=ms(function(e,t){return e*t},1),hx=Wi("round"),px=ms(function(e,t){return e-t},0);function mx(e){return e&&e.length?pi(e,Ct):0}function gx(e,t){return e&&e.length?pi(e,pe(t,2)):0}return m.after=B0,m.ary=Jl,m.assign=Ng,m.assignIn=dc,m.assignInWith=Rs,m.assignWith=Cg,m.at=Tg,m.before=Zl,m.bind=Zi,m.bindAll=j_,m.bindKey=ec,m.castArray=K0,m.chain=Vl,m.chunk=im,m.compact=om,m.concat=am,m.cond=I_,m.conforms=M_,m.constant=oo,m.countBy=m0,m.create=Rg,m.curry=tc,m.curryRight=nc,m.debounce=rc,m.defaults=kg,m.defaultsDeep=Ag,m.defer=F0,m.delay=U0,m.difference=lm,m.differenceBy=cm,m.differenceWith=um,m.drop=fm,m.dropRight=dm,m.dropRightWhile=hm,m.dropWhile=pm,m.fill=mm,m.filter=_0,m.flatMap=b0,m.flatMapDeep=y0,m.flatMapDepth=w0,m.flatten=ql,m.flattenDeep=gm,m.flattenDepth=_m,m.flip=W0,m.flow=D_,m.flowRight=O_,m.fromPairs=xm,m.functions=Og,m.functionsIn=Bg,m.groupBy=E0,m.initial=bm,m.intersection=ym,m.intersectionBy=wm,m.intersectionWith=Em,m.invert=Ug,m.invertBy=Wg,m.invokeMap=N0,m.iteratee=ao,m.keyBy=C0,m.keys=ft,m.keysIn=Nt,m.map=ws,m.mapKeys=Gg,m.mapValues=zg,m.matches=B_,m.matchesProperty=F_,m.memoize=Ss,m.merge=qg,m.mergeWith=hc,m.method=U_,m.methodOf=W_,m.mixin=lo,m.negate=Ns,m.nthArg=G_,m.omit=$g,m.omitBy=Xg,m.once=H0,m.orderBy=T0,m.over=z_,m.overArgs=G0,m.overEvery=q_,m.overSome=$_,m.partial=eo,m.partialRight=sc,m.partition=R0,m.pick=Yg,m.pickBy=pc,m.property=yc,m.propertyOf=X_,m.pull=Tm,m.pullAll=Xl,m.pullAllBy=Rm,m.pullAllWith=km,m.pullAt=Am,m.range=Y_,m.rangeRight=V_,m.rearg=z0,m.reject=P0,m.remove=Pm,m.rest=q0,m.reverse=Qi,m.sampleSize=I0,m.set=Kg,m.setWith=Qg,m.shuffle=M0,m.slice=jm,m.sortBy=O0,m.sortedUniq=Fm,m.sortedUniqBy=Um,m.split=b_,m.spread=$0,m.tail=Wm,m.take=Hm,m.takeRight=Gm,m.takeRightWhile=zm,m.takeWhile=qm,m.tap=o0,m.throttle=X0,m.thru=ys,m.toArray=cc,m.toPairs=mc,m.toPairsIn=gc,m.toPath=ex,m.toPlainObject=fc,m.transform=Jg,m.unary=Y0,m.union=$m,m.unionBy=Xm,m.unionWith=Ym,m.uniq=Vm,m.uniqBy=Km,m.uniqWith=Qm,m.unset=Zg,m.unzip=Ji,m.unzipWith=Yl,m.update=e_,m.updateWith=t_,m.values=sr,m.valuesIn=n_,m.without=Jm,m.words=vc,m.wrap=V0,m.xor=Zm,m.xorBy=e0,m.xorWith=t0,m.zip=n0,m.zipObject=r0,m.zipObjectDeep=s0,m.zipWith=i0,m.entries=mc,m.entriesIn=gc,m.extend=dc,m.extendWith=Rs,lo(m,m),m.add=nx,m.attempt=bc,m.camelCase=o_,m.capitalize=_c,m.ceil=rx,m.clamp=r_,m.clone=Q0,m.cloneDeep=Z0,m.cloneDeepWith=eg,m.cloneWith=J0,m.conformsTo=tg,m.deburr=xc,m.defaultTo=L_,m.divide=sx,m.endsWith=a_,m.eq=$t,m.escape=l_,m.escapeRegExp=c_,m.every=g0,m.find=x0,m.findIndex=Gl,m.findKey=Pg,m.findLast=v0,m.findLastIndex=zl,m.findLastKey=jg,m.floor=ix,m.forEach=Kl,m.forEachRight=Ql,m.forIn=Ig,m.forInRight=Mg,m.forOwn=Lg,m.forOwnRight=Dg,m.get=ro,m.gt=ng,m.gte=rg,m.has=Fg,m.hasIn=so,m.head=$l,m.identity=Ct,m.includes=S0,m.indexOf=vm,m.inRange=s_,m.invoke=Hg,m.isArguments=Un,m.isArray=Re,m.isArrayBuffer=sg,m.isArrayLike=St,m.isArrayLikeObject=tt,m.isBoolean=ig,m.isBuffer=Cn,m.isDate=og,m.isElement=ag,m.isEmpty=lg,m.isEqual=cg,m.isEqualWith=ug,m.isError=to,m.isFinite=fg,m.isFunction=fn,m.isInteger=ic,m.isLength=Cs,m.isMap=oc,m.isMatch=dg,m.isMatchWith=hg,m.isNaN=pg,m.isNative=mg,m.isNil=_g,m.isNull=gg,m.isNumber=ac,m.isObject=Je,m.isObjectLike=Ze,m.isPlainObject=Nr,m.isRegExp=no,m.isSafeInteger=xg,m.isSet=lc,m.isString=Ts,m.isSymbol=At,m.isTypedArray=rr,m.isUndefined=vg,m.isWeakMap=bg,m.isWeakSet=yg,m.join=Sm,m.kebabCase=u_,m.last=Ut,m.lastIndexOf=Nm,m.lowerCase=f_,m.lowerFirst=d_,m.lt=wg,m.lte=Eg,m.max=ox,m.maxBy=ax,m.mean=lx,m.meanBy=cx,m.min=ux,m.minBy=fx,m.stubArray=uo,m.stubFalse=fo,m.stubObject=K_,m.stubString=Q_,m.stubTrue=J_,m.multiply=dx,m.nth=Cm,m.noConflict=H_,m.noop=co,m.now=Es,m.pad=h_,m.padEnd=p_,m.padStart=m_,m.parseInt=g_,m.random=i_,m.reduce=k0,m.reduceRight=A0,m.repeat=__,m.replace=x_,m.result=Vg,m.round=hx,m.runInContext=T,m.sample=j0,m.size=L0,m.snakeCase=v_,m.some=D0,m.sortedIndex=Im,m.sortedIndexBy=Mm,m.sortedIndexOf=Lm,m.sortedLastIndex=Dm,m.sortedLastIndexBy=Om,m.sortedLastIndexOf=Bm,m.startCase=y_,m.startsWith=w_,m.subtract=px,m.sum=mx,m.sumBy=gx,m.template=E_,m.times=Z_,m.toFinite=dn,m.toInteger=ke,m.toLength=uc,m.toLower=S_,m.toNumber=Wt,m.toSafeInteger=Sg,m.toString=We,m.toUpper=N_,m.trim=C_,m.trimEnd=T_,m.trimStart=R_,m.truncate=k_,m.unescape=A_,m.uniqueId=tx,m.upperCase=P_,m.upperFirst=io,m.each=Kl,m.eachRight=Ql,m.first=$l,lo(m,(function(){var e={};return Kt(m,function(t,s){He.call(m.prototype,s)||(e[s]=t)}),e})(),{chain:!1}),m.VERSION=o,Lt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){m[e].placeholder=m}),Lt(["drop","take"],function(e,t){Me.prototype[e]=function(s){s=s===r?1:ct(ke(s),0);var c=this.__filtered__&&!t?new Me(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},Me.prototype[e+"Right"]=function(s){return this.reverse()[e](s).reverse()}}),Lt(["filter","map","takeWhile"],function(e,t){var s=t+1,c=s==Y||s==K;Me.prototype[e]=function(f){var _=this.clone();return _.__iteratees__.push({iteratee:pe(f,3),type:s}),_.__filtered__=_.__filtered__||c,_}}),Lt(["head","last"],function(e,t){var s="take"+(t?"Right":"");Me.prototype[e]=function(){return this[s](1).value()[0]}}),Lt(["initial","tail"],function(e,t){var s="drop"+(t?"":"Right");Me.prototype[e]=function(){return this.__filtered__?new Me(this):this[s](1)}}),Me.prototype.compact=function(){return this.filter(Ct)},Me.prototype.find=function(e){return this.filter(e).head()},Me.prototype.findLast=function(e){return this.reverse().find(e)},Me.prototype.invokeMap=Pe(function(e,t){return typeof e=="function"?new Me(this):this.map(function(s){return vr(s,e,t)})}),Me.prototype.reject=function(e){return this.filter(Ns(pe(e)))},Me.prototype.slice=function(e,t){e=ke(e);var s=this;return s.__filtered__&&(e>0||t<0)?new Me(s):(e<0?s=s.takeRight(-e):e&&(s=s.drop(e)),t!==r&&(t=ke(t),s=t<0?s.dropRight(-t):s.take(t-e)),s)},Me.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Me.prototype.toArray=function(){return this.take(J)},Kt(Me.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 Me,W=S[0],H=A||Re(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,xe=_&&!te,Ae=A&&!oe;if(!_&&H){y=Ae?y:new Me(this);var ve=e.apply(y,S);return ve.__actions__.push({func:ys,args:[V],thisArg:r}),new Ot(ve,te)}return xe&&Ae?e.apply(this,S):(ve=this.thru(V),xe?c?ve.value()[0]:ve.value():ve)})}),Lt(["pop","push","shift","sort","splice","unshift"],function(e){var t=Xr[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(Re(_)?_:[],f)}return this[s](function(y){return t.apply(Re(y)?y:[],f)})}}),Kt(Me.prototype,function(e,t){var s=m[t];if(s){var c=s.name+"";He.call(Jn,c)||(Jn[c]=[]),Jn[c].push({name:t,func:s})}}),Jn[ps(r,L).name]=[{name:"wrapper",func:r}],Me.prototype.clone=Ah,Me.prototype.reverse=Ph,Me.prototype.value=jh,m.prototype.at=a0,m.prototype.chain=l0,m.prototype.commit=c0,m.prototype.next=u0,m.prototype.plant=d0,m.prototype.reverse=h0,m.prototype.toJSON=m.prototype.valueOf=m.prototype.value=p0,m.prototype.first=m.prototype.head,dr&&(m.prototype[dr]=f0),m}),Vn=ch();jn?((jn.exports=Vn)._=Vn,ai._=Vn):dt._=Vn}).call(s1)})(Pr,Pr.exports)),Pr.exports}var rf=i1();const o1=xx(rf);function a1(i,n){const[r,o]=w.useState(i),u=w.useRef(o1.debounce(o,n)),l=w.useCallback(d=>{u.current(d)},[]);return[r,l]}const l1=[{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}],c1=()=>{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 u1({devices:i,currentDeviceId:n,onSelectDevice:r,onOpenConfig:o,onConnectWifi:u,onDisconnectWifi:l}){const d=An(),[v,h]=w.useState(c1),[g,p]=w.useState(!1),[x,b]=w.useState(""),[E,N]=w.useState("5555"),[j,R]=w.useState(""),[L,B]=w.useState(""),[I,P]=w.useState("custom"),[G,Q]=w.useState("direct"),[X,q]=w.useState(""),[F,C]=w.useState(""),[k,re]=w.useState("5555"),[me,Y]=w.useState(""),[$,K]=w.useState(!1),[ie,ae]=w.useState([]),[Te,z]=a1(!1,300),[J,fe]=w.useState(""),[ne,ye]=w.useState(null),[Ne,Ge]=w.useState(!1),Qe=w.useRef(null),[Be,O]=w.useState(""),[de,ce]=w.useState(""),[Fe,Ve]=w.useState(!1),[ue,be]=w.useState([]),[Z,ee]=w.useState(null),[we,Le]=w.useState(!1);w.useEffect(()=>{localStorage.setItem("sidebar-collapsed",JSON.stringify(v))},[v]),w.useEffect(()=>{const U=_e=>{(_e.metaKey||_e.ctrlKey)&&_e.key==="b"&&(_e.preventDefault(),h(!v))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[v]);const le=()=>{h(!v)},ge=U=>/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/.test(U)?U.split(".").every(ur=>{const Ur=parseInt(ur,10);return Ur>=0&&Ur<=255}):!1,Ee=U=>{const _e=parseInt(U,10);return!isNaN(_e)&&_e>=1&&_e<=65535},he=U=>/^\d{6}$/.test(U),ut=async()=>{R(""),B("");let U=!1;if(ge(x)||(R(d.deviceSidebar.invalidIpError),U=!0),Ee(E)||(B(d.deviceSidebar.invalidPortError),U=!0),!U){K(!0);try{const _e=await Sc({ip:x,port:parseInt(E,10)});_e.success?(p(!1),b(""),N("5555")):R(_e.message||d.toasts.wifiManualConnectError)}catch{R(d.toasts.wifiManualConnectError)}finally{K(!1)}}},pt=async()=>{Y(""),R(""),B("");let U=!1;if(ge(x)||(R(d.deviceSidebar.invalidIpError),U=!0),Ee(F)||(B(d.deviceSidebar.invalidPortError),U=!0),Ee(k)||(B(d.deviceSidebar.invalidPortError),U=!0),he(X)||(Y(d.deviceSidebar.invalidPairingCodeError),U=!0),!U){K(!0);try{const _e=await Ex({ip:x,pairing_port:parseInt(F,10),pairing_code:X,connection_port:parseInt(k,10)});_e.success?(p(!1),b(""),N("5555"),q(""),C(""),re("5555"),Q("direct")):_e.error==="invalid_pairing_code"?Y(_e.message):_e.error==="invalid_ip"?R(_e.message):R(_e.message||d.toasts.wifiPairError)}catch{R(d.toasts.wifiPairError)}finally{K(!1)}}},rt=w.useCallback(()=>{Qe.current!==null&&(clearInterval(Qe.current),Qe.current=null)},[]),ot=w.useCallback(U=>{rt(),Qe.current=window.setInterval(async()=>{try{const _e=await vx(U);ye(It=>It?{...It,status:_e.status}:null),["connected","timeout","error"].includes(_e.status)&&(rt(),_e.status==="connected"&&setTimeout(()=>{p(!1),ye(null)},2e3))}catch(_e){console.error("[QR Pairing] Status poll failed:",_e)}},1e3)},[rt]),at=w.useCallback(async()=>{Ge(!0);try{const U=await bx();U.success&&U.qr_payload&&U.session_id&&(ye({sessionId:U.session_id,payload:U.qr_payload,status:"listening",expiresAt:U.expires_at??Date.now()+12e4}),ot(U.session_id))}catch(U){console.error("[QR Pairing] Generation failed:",U)}finally{Ge(!1)}},[ot]),Pn=w.useCallback(async()=>{if(ne)try{await yx(ne.sessionId),ye(null),rt()}catch(U){console.error("[QR Pairing] Cancel failed:",U)}},[ne,rt]),Gn=async()=>{if(ce(""),!Be.trim()){ce(d.deviceSidebar.remoteUrlRequired||"请输入远程服务器地址");return}if(!Be.startsWith("http://")&&!Be.startsWith("https://")){ce(d.deviceSidebar.remoteUrlInvalid||"地址必须以 http:// 或 https:// 开头");return}Ve(!0);try{const U=await Sx({base_url:Be,timeout:5});U.success?(be(U.devices),ee(null)):(ce(U.message||"发现设备失败"),be([]))}catch{ce("连接失败,请检查地址是否正确"),be([])}finally{Ve(!1)}},cr=async()=>{if(Z){Le(!0);try{const U=await Nx({base_url:Be,device_id:Z});U.success?(p(!1),O(""),be([]),ee(null)):ce(U.message||d.toasts.remoteDeviceAddError)}catch{ce(d.toasts.remoteDeviceAddError)}finally{Le(!1)}}};w.useEffect(()=>{(!g||G!=="pair")&&(ne&&ne.status==="listening"&&Pn(),rt())},[g,G,ne,rt,Pn]),w.useEffect(()=>()=>{rt()},[rt]),w.useEffect(()=>{g&&G==="pair"&&!ne&&!Ne&&at()},[g,G,ne,Ne,at]);const rn=w.useCallback(async()=>{z(!0),fe("");try{const U=await wx();U.success?ae(U.devices):(fe(U.error||d.deviceSidebar.scanError.replace("{error}","Unknown error")),ae([]))}catch(U){fe(d.deviceSidebar.scanError.replace("{error}",String(U))),ae([])}finally{z(!1)}},[d.deviceSidebar.scanError,z]),zn=async(U,_e)=>{if(!_e&&!U.has_pairing){K(!0),R("");try{const It=await Sc({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 _e&&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(Se,{variant:"outline",size:"icon",onClick:le,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(vu,{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(Se,{variant:"ghost",size:"icon",onClick:le,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(wu,{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(hv,{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(Rv,{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(Se,{variant:"outline",onClick:()=>p(!0),className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[a.jsx(xu,{className:"h-4 w-4"}),d.deviceSidebar.addDevice]}),a.jsxs(Se,{variant:"outline",onClick:o,className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[a.jsx(Nu,{className:"h-4 w-4"}),d.deviceSidebar.settings]})]}),a.jsx(du,{open:g,onOpenChange:p,children:a.jsxs(hu,{className:"sm:max-w-md max-h-[80vh] overflow-y-auto",children:[a.jsxs(pu,{children:[a.jsx(mu,{children:d.deviceSidebar.manualConnectTitle}),a.jsx(gu,{children:d.deviceSidebar.manualConnectDescription})]}),a.jsxs(Gu,{value:G,onValueChange:Q,className:"w-full",children:[a.jsxs(zu,{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(Mr,{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(Se,{variant:"outline",size:"sm",onClick:rn,disabled:Te,className:"h-8",children:Te?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(_e=>!_e.has_pairing);return!Te&&U.length===0?a.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[a.jsx(Hs,{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(_e=>a.jsx("button",{onClick:()=>zn(_e,!1),disabled:$,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(js,{className:"h-4 w-4 text-[#1d9bf0]"}),a.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:_e.name})]}),a.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[_e.ip,":",_e.port]})]})})},`${_e.ip}:${_e.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(st,{children:d.deviceSidebar.emulatorPreset}),a.jsx("div",{className:"grid grid-cols-3 gap-2",children:l1.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(st,{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"&&ut(),className:j?"border-red-500":""})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(st,{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"&&ut(),className:L?"border-red-500":""}),L&&a.jsx("p",{className:"text-sm text-red-500",children:L})]}),a.jsx(Se,{onClick:ut,disabled:$,className:"w-full",children:$?d.common.loading:d.deviceSidebar.connect})]})]}),a.jsxs(Mr,{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(Se,{variant:"outline",size:"sm",onClick:rn,disabled:Te,className:"h-8",children:Te?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(_e=>_e.has_pairing);return!Te&&U.length===0?a.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[a.jsx(Hs,{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(_e=>a.jsx("button",{onClick:()=>zn(_e,!0),disabled:$,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(js,{className:"h-4 w-4 text-[#1d9bf0]"}),a.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:_e.name})]}),a.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[_e.ip,":",_e.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})]})]})})},`${_e.ip}:${_e.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(nf,{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(Tc,{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(Rc,{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(Rc,{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(Se,{variant:"outline",onClick:at,className:"flex-1",children:d.deviceSidebar.qrRegenerate}),ne.status==="listening"&&a.jsx(Se,{variant:"outline",onClick:Pn,className:"flex-1",children:d.common.cancel}),ne.status==="connected"&&a.jsx(Se,{onClick:()=>p(!1),className:"flex-1",children:d.common.confirm})]})]})}),!ne&&Ne&&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(st,{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(st,{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:L?"border-red-500":""}),L&&a.jsx("p",{className:"text-sm text-red-500",children:L})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(st,{htmlFor:"pairing-code",children:d.deviceSidebar.pairingCode}),a.jsx(wt,{id:"pairing-code",type:"text",placeholder:"123456",maxLength:6,value:X,onChange:U=>q(U.target.value.replace(/\D/g,"")),onKeyDown:U=>U.key==="Enter"&&pt(),className:me?"border-red-500":""}),me&&a.jsx("p",{className:"text-sm text-red-500",children:me})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(st,{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(Se,{onClick:pt,disabled:$,className:"w-full",children:$?d.common.loading:d.deviceSidebar.pairAndConnect})]})]}),a.jsxs(Mr,{value:"remote",className:"space-y-4 mt-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(st,{htmlFor:"remote-url",children:d.deviceSidebar.remoteUrl||"远程服务器地址"}),a.jsx(wt,{id:"remote-url",placeholder:"http://192.168.1.100:8001",value:Be,onChange:U=>{O(U.target.value),ce("")},disabled:Fe,onKeyDown:U=>U.key==="Enter"&&Gn(),className:de?"border-red-500":""}),de&&a.jsx("p",{className:"text-sm text-red-500",children:de}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:d.deviceSidebar.remoteUrlHint||"运行 Device Agent Server 的地址"}),a.jsx(Se,{onClick:Gn,disabled:Fe||!Be,className:"w-full",children:Fe?"正在发现...":"发现设备"})]}),ue.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(st,{children:"可用设备"}),a.jsx("div",{className:"space-y-2",children:ue.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(js,{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(Tc,{className:"h-4 w-4 text-[#1d9bf0]"})]})},U.device_id))})]}),Z&&a.jsx(Se,{onClick:cr,disabled:we,className:"w-full",children:we?"正在连接...":"连接远程设备"})]})]}),a.jsx(_u,{children:a.jsx(Se,{variant:"outline",onClick:()=>{p(!1),R(""),B(""),Y(""),fe(""),b(""),N("5555"),q(""),C(""),re("5555"),Q("direct"),ae([])},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 Is=Object.create(null);Object.keys(tn).forEach(i=>{Is[tn[i]]=i});const Po={type:"error",data:"parser error"},sf=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",of=typeof ArrayBuffer=="function",af=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i&&i.buffer instanceof ArrayBuffer,Fo=({type:i,data:n},r,o)=>sf&&n instanceof Blob?r?o(n):Lc(n,o):of&&(n instanceof ArrayBuffer||af(n))?r?o(n):Lc(new Blob([n]),o):o(tn[i]+(n||"")),Lc=(i,n)=>{const r=new FileReader;return r.onload=function(){const o=r.result.split(",")[1];n("b"+(o||""))},r.readAsDataURL(i)};function Dc(i){return i instanceof Uint8Array?i:i instanceof ArrayBuffer?new Uint8Array(i):new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}let mo;function f1(i,n){if(sf&&i.data instanceof Blob)return i.data.arrayBuffer().then(Dc).then(n);if(of&&(i.data instanceof ArrayBuffer||af(i.data)))return n(Dc(i.data));Fo(i,!1,r=>{mo||(mo=new TextEncoder),n(mo.encode(r))})}const Oc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",jr=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let i=0;i<Oc.length;i++)jr[Oc.charCodeAt(i)]=i;const d1=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},h1=typeof ArrayBuffer=="function",Uo=(i,n)=>{if(typeof i!="string")return{type:"message",data:lf(i,n)};const r=i.charAt(0);return r==="b"?{type:"message",data:p1(i.substring(1),n)}:Is[r]?i.length>1?{type:Is[r],data:i.substring(1)}:{type:Is[r]}:Po},p1=(i,n)=>{if(h1){const r=d1(i);return lf(r,n)}else return{base64:!0,data:i}},lf=(i,n)=>{switch(n){case"blob":return i instanceof Blob?i:new Blob([i]);case"arraybuffer":default:return i instanceof ArrayBuffer?i:i.buffer}},cf="",m1=(i,n)=>{const r=i.length,o=new Array(r);let u=0;i.forEach((l,d)=>{Fo(l,!1,v=>{o[d]=v,++u===r&&n(o.join(cf))})})},g1=(i,n)=>{const r=i.split(cf),o=[];for(let u=0;u<r.length;u++){const l=Uo(r[u],n);if(o.push(l),l.type==="error")break}return o};function _1(){return new TransformStream({transform(i,n){f1(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 go;function As(i){return i.reduce((n,r)=>n+r.length,0)}function Ps(i,n){if(i[0].length===n)return i.shift();const r=new Uint8Array(n);let 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 x1(i,n){go||(go=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(As(r)<1)break;const h=Ps(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(As(r)<2)break;const h=Ps(r,2);u=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),o=3}else if(o===2){if(As(r)<8)break;const h=Ps(r,8),g=new DataView(h.buffer,h.byteOffset,h.length),p=g.getUint32(0);if(p>Math.pow(2,21)-1){v.enqueue(Po);break}u=p*Math.pow(2,32)+g.getUint32(4),o=3}else{if(As(r)<u)break;const h=Ps(r,u);v.enqueue(Uo(l?h:go.decode(h),n)),o=0}if(u===0||u>i){v.enqueue(Po);break}}}})}const uf=4;function it(i){if(i)return v1(i)}function v1(i){for(var n in it.prototype)i[n]=it.prototype[n];return i}it.prototype.on=it.prototype.addEventListener=function(i,n){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(n),this};it.prototype.once=function(i,n){function r(){this.off(i,r),n.apply(this,arguments)}return r.fn=n,this.on(i,r),this};it.prototype.off=it.prototype.removeListener=it.prototype.removeAllListeners=it.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};it.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};it.prototype.emitReserved=it.prototype.emit;it.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};it.prototype.hasListeners=function(i){return!!this.listeners(i).length};const Vs=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")(),b1="arraybuffer";function ff(i,...n){return n.reduce((r,o)=>(i.hasOwnProperty(o)&&(r[o]=i[o]),r),{})}const y1=Ht.setTimeout,w1=Ht.clearTimeout;function Ks(i,n){n.useNativeTimers?(i.setTimeoutFn=y1.bind(Ht),i.clearTimeoutFn=w1.bind(Ht)):(i.setTimeoutFn=Ht.setTimeout.bind(Ht),i.clearTimeoutFn=Ht.clearTimeout.bind(Ht))}const E1=1.33;function S1(i){return typeof i=="string"?N1(i):Math.ceil((i.byteLength||i.size)*E1)}function N1(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 df(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function C1(i){let n="";for(let r in i)i.hasOwnProperty(r)&&(n.length&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(i[r]));return n}function T1(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 R1 extends Error{constructor(n,r,o){super(n),this.description=r,this.context=o,this.type="TransportError"}}class Wo extends it{constructor(n){super(),this.writable=!1,Ks(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 R1(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=Uo(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=C1(n);return r.length?"?"+r:""}}class k1 extends Wo{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)};g1(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,m1(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]=df()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(n,r)}}let hf=!1;try{hf=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const A1=hf;function P1(){}class j1 extends k1{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 it{constructor(n,r,o){super(),this.createRequest=n,Ks(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=ff(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=P1,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",Bc);else if(typeof addEventListener=="function"){const i="onpagehide"in Ht?"pagehide":"unload";addEventListener(i,Bc,!1)}}function Bc(){for(let i in en.requests)en.requests.hasOwnProperty(i)&&en.requests[i].abort()}const I1=(function(){const i=pf({xdomain:!1});return i&&i.responseType!==null})();class M1 extends j1{constructor(n){super(n);const r=n&&n.forceBase64;this.supportsBinary=I1&&!r}request(n={}){return Object.assign(n,{xd:this.xd},this.opts),new en(pf,this.uri(),n)}}function pf(i){const n=i.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!n||A1))return new XMLHttpRequest}catch{}if(!n)try{return new Ht[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const mf=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class L1 extends Wo{get name(){return"websocket"}doOpen(){const n=this.uri(),r=this.opts.protocols,o=mf?{}:ff(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;Fo(o,this.supportsBinary,l=>{try{this.doWrite(o,l)}catch{}u&&Vs(()=>{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]=df()),this.supportsBinary||(r.b64=1),this.createUri(n,r)}}const _o=Ht.WebSocket||Ht.MozWebSocket;class D1 extends L1{createSocket(n,r,o){return mf?new _o(n,r,o):r?new _o(n,r):new _o(n)}doWrite(n,r){this.ws.send(r)}}class O1 extends Wo{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=x1(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=n.readable.pipeThrough(r).getReader(),u=_1();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&&Vs(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var n;(n=this._transport)===null||n===void 0||n.close()}}const B1={websocket:D1,webtransport:O1,polling:M1},F1=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,U1=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function jo(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=F1.exec(i||""),l={},d=14;for(;d--;)l[U1[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=W1(l,l.path),l.queryKey=H1(l,l.query),l}function W1(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 H1(i,n){const r={};return n.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,u,l){u&&(r[u]=l)}),r}const Io=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ms=[];Io&&addEventListener("offline",()=>{Ms.forEach(i=>i())},!1);class Rn extends it{constructor(n,r){if(super(),this.binaryType=b1,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=jo(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=jo(r.host).host);Ks(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=T1(this.opts.query)),Io&&(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"})},Ms.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(n){const r=Object.assign({},this.opts.query);r.EIO=uf,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+=S1(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,Vs(()=>{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(),Io&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=Ms.indexOf(this._offlineEventListener);o!==-1&&Ms.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",n,r),this.writeBuffer=[],this._prevBufferLen=0}}}Rn.protocol=uf;class G1 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 z1=class extends G1{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=>B1[u]).filter(u=>!!u)),super(n,o)}};function q1(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=jo(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 $1=typeof ArrayBuffer=="function",X1=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,gf=Object.prototype.toString,Y1=typeof Blob=="function"||typeof Blob<"u"&&gf.call(Blob)==="[object BlobConstructor]",V1=typeof File=="function"||typeof File<"u"&&gf.call(File)==="[object FileConstructor]";function Ho(i){return $1&&(i instanceof ArrayBuffer||X1(i))||Y1&&i instanceof Blob||V1&&i instanceof File}function Ls(i,n){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let r=0,o=i.length;r<o;r++)if(Ls(i[r]))return!0;return!1}if(Ho(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Ls(i.toJSON(),!0);for(const r in i)if(Object.prototype.hasOwnProperty.call(i,r)&&Ls(i[r]))return!0;return!1}function K1(i){const n=[],r=i.data,o=i;return o.data=Mo(r,n),o.attachments=n.length,{packet:o,buffers:n}}function Mo(i,n){if(!i)return i;if(Ho(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]=Mo(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]=Mo(i[o],n));return r}return i}function Q1(i,n){return i.data=Lo(i.data,n),delete i.attachments,i}function Lo(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]=Lo(i[r],n);else if(typeof i=="object")for(const r in i)Object.prototype.hasOwnProperty.call(i,r)&&(i[r]=Lo(i[r],n));return i}const J1=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Z1=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 eb{constructor(n){this.replacer=n}encode(n){return(n.type===Oe.EVENT||n.type===Oe.ACK)&&Ls(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=K1(n),o=this.encodeAsString(r.packet),u=r.buffers;return u.unshift(o),u}}function Fc(i){return Object.prototype.toString.call(i)==="[object Object]"}class Go extends it{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 tb(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Ho(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(Go.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 Fc(r);case Oe.DISCONNECT:return r===void 0;case Oe.CONNECT_ERROR:return typeof r=="string"||Fc(r);case Oe.EVENT:case Oe.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&J1.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 tb{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=Q1(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const nb=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Go,Encoder:eb,get PacketType(){return Oe},protocol:Z1},Symbol.toStringTag,{value:"Module"}));function Yt(i,n,r){return i.on(n,r),function(){i.off(n,r)}}const rb=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class _f extends it{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(rb.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 Do extends it{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,Ks(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||nb;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 z1(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){Vs(()=>{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 _f(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 Ds(i,n){typeof i=="object"&&(n=i,i=void 0),n=n||{};const r=q1(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 Do(o,n):(Tr[u]||(Tr[u]=new Do(o,n)),h=Tr[u]),r.query&&!n.query&&(n.query=r.queryKey),h.socket(r.path,n)}Object.assign(Ds,{Manager:Do,Socket:_f,io:Ds,connect:Ds});function sb(i,n){return(i[n]|i[n+1]<<8|i[n+2]<<16|i[n+3]<<24)>>>0}const Os={H264:1748121140,H265:1748121141,AV1:6387249},{WritableStream:ib}=globalThis;class ob{#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 ab={SequenceHeader:1,TemporalDelimiter:2,FrameHeader:3,TileGroup:4,Metadata:5,Frame:6,RedundantFrameHeader:7,TileList:8,Padding:15},lb={Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,GenericFilm:8,Bt2020:9,Xyz:10,Smpte431:11,Smpte432:12,Ebu3213:22},cb={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},ub={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 ob{static ObuType=ab;static ColorPrimaries=lb;static TransferCharacteristics=cb;static MatrixCoefficients=ub;#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 O=0;O<=g;O+=1)p[O]=this.f(12),x[O]=this.f(5),x[O]>7?b[O]=this.f1():b[O]=0,d?(E[O]=!!this.f1(),E[O]&&(j[O]=this.operatingParametersInfo(v))):E[O]=!1,h&&(N[O]=!!this.f1(),N[O]&&(R[O]=this.f(4)))}const L=this.chooseOperatingPoint();this.#t=p[L];const B=this.f(4),I=this.f(4),P=this.f(B+1),G=this.f(I+1);let Q=!1,X,q;o||(Q=!!this.f1(),Q&&(X=this.f(4),q=this.f(3)));const F=!!this.f1(),C=!!this.f1(),k=!!this.f1();let re=!1,me=!1,Y=!1,$=!1,K=!1,ie=!1,ae=!1,Te=!1,z=_t.SelectScreenContentTools,J=!1,fe=_t.SelectIntegerMv,ne;o||(re=!!this.f1(),me=!!this.f1(),Y=!!this.f1(),$=!!this.f1(),K=!!this.f1(),K&&(ie=!!this.f1(),ae=!!this.f1()),Te=!!this.f1(),Te||(z=this.f1()),z>0&&(J=!!this.f1(),J||(fe=this.f1())),K&&(ne=this.f(3)));const ye=!!this.f1(),Ne=!!this.f1(),Ge=!!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:q,use_128x128_superblock:F,enable_filter_intra:C,enable_intra_edge_filter:k,enable_interintra_compound:re,enable_masked_compound:me,enable_warped_motion:Y,enable_dual_filter:$,enable_order_hint:K,enable_jnt_comp:ie,enable_ref_frame_mvs:ae,seq_choose_screen_content_tools:Te,seq_force_screen_content_tools:z,seq_choose_integer_mv:J,seq_force_integer_mv:fe,order_hint_bits_minus_1:ne,enable_superres:ye,enable_cdef:Ne,enable_restoration:Ge,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*xf(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 Qs{#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 fb(i){const n=new Qs(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 q=0;q<X;q+=1)n.decodeExponentialGolombNumber()}n.decodeExponentialGolombNumber(),n.next();const j=n.decodeExponentialGolombNumber(),R=n.decodeExponentialGolombNumber(),L=n.next();L||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:L,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 db(i){let n,r;for(const o of xf(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 hb(i){const{sequenceParameterSet:n,pictureParameterSet:r}=db(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}=fb(n),E=(d+1)*16,N=(v+1)*(2-h)*16,j=g*2,R=p*2,L=x*2,B=b*2,I=E-j-R,P=N-L-B;return{pictureParameterSet:r,sequenceParameterSet:n,profileIndex:o,constraintSet:u,levelIndex:l,encodedWidth:E,encodedHeight:N,cropLeft:j,cropRight:R,cropTop:L,cropBottom:B,croppedWidth:I,croppedHeight:P}}function pb(i){switch(i){case 0:case 3:return 1;case 1:case 2:return 2;default:throw new Error("Invalid chroma_format_idc")}}function mb(i){switch(i){case 0:case 2:case 3:return 1;case 1:return 2;default:throw new Error("Invalid chroma_format_idc")}}function gb(i){const n=new Qs(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 _b(i){const n=new Qs(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=vf(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 L,B,I,P,G,Q,X,q;if(R){L=n.read(32),B=n.read(32),I=!!n.next(),I&&(P=n.decodeExponentialGolombNumber()),G=n.decodeExponentialGolombNumber(),Q=[],X=[!0],q=[];for(let C=0;C<G;C+=1)Q[C]=n.decodeExponentialGolombNumber(),C>0&&(X[C]=!!n.next()),q[C]=bf(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:L,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:q,vps_extension_flag:F}}function xb(i){const n=new Qs(i),r=n.read(4),o=n.read(3),u=!!n.next(),l=vf(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(),L=n.decodeExponentialGolombNumber(),B=n.decodeExponentialGolombNumber(),I=[],P=[],G=[],Q=!!n.next();for(let he=Q?0:o;he<=o;he+=1)I[he]=n.decodeExponentialGolombNumber(),P[he]=n.decodeExponentialGolombNumber(),G[he]=n.decodeExponentialGolombNumber();const X=n.decodeExponentialGolombNumber(),q=n.decodeExponentialGolombNumber(),F=n.decodeExponentialGolombNumber(),C=n.decodeExponentialGolombNumber(),k=n.decodeExponentialGolombNumber(),re=n.decodeExponentialGolombNumber(),me=!!n.next();let Y,$;me&&(Y=!!n.next(),Y&&($=vb(n)));const K=!!n.next(),ie=!!n.next(),ae=!!n.next();let Te,z,J,fe,ne;ae&&(Te=n.read(4),z=n.read(4),J=n.read(4),fe=n.read(4),ne=!!n.next());const ye=n.decodeExponentialGolombNumber(),Ne=[];for(let he=0;he<ye;he+=1)Ne[he]=bb(n,he,ye,Ne);const Ge=!!n.next();let Qe,Be,O;if(Ge){Qe=n.decodeExponentialGolombNumber(),Be=[],O=[];for(let he=0;he<Qe;he+=1)Be[he]=n.read(B+4),O[he]=!!n.next()}const de=!!n.next(),ce=!!n.next(),Fe=!!n.next();let Ve;Fe&&(Ve=yb(n,o));const ue=!!n.next();let be,Z,ee,we,Le;if(ue&&(be=!!n.next(),Z=!!n.next(),ee=!!n.next(),we=!!n.next(),Le=n.read(4)),be)throw new Error("Not implemented");let le;Z&&(le=Eb(n));let ge;if(ee&&(ge=Sb(n)),we)throw new Error("Not implemented");let Ee;if(Le){Ee=[];let he=0;for(;!n.ended;)Ee[he]=!!n.next(),he+=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:L,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:q,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:me,sps_scaling_list_data_present_flag:Y,scalingListData:$,amp_enabled_flag:K,sample_adaptive_offset_enabled_flag:ie,pcm_enabled_flag:ae,pcm_sample_bit_depth_luma_minus1:Te,pcm_sample_bit_depth_chroma_minus1:z,log2_min_pcm_luma_coding_block_size_minus3:J,log2_diff_max_min_pcm_luma_coding_block_size:fe,pcm_loop_filter_disabled_flag:ne,num_short_term_ref_pic_sets:ye,shortTermRefPicSets:Ne,long_term_ref_pics_present_flag:Ge,num_long_term_ref_pics_sps:Qe,lt_ref_pic_poc_lsb_sps:Be,used_by_curr_pic_lt_sps_flag:O,sps_temporal_mvp_enabled_flag:de,strong_intra_smoothing_enabled_flag:ce,vui_parameters_present_flag:Fe,vuiParameters:Ve,sps_extension_present_flag:ue,sps_range_extension_flag:be,sps_multilayer_extension_flag:Z,sps_3d_extension_flag:ee,sps_scc_extension_flag:we,sps_extension_4bits:Le,spsMultilayerExtension:le,sps3dExtension:ge,sps_extension_data_flag:Ee}}function Uc(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,L,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(),L=!!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:L,one_picture_only_constraint_flag:B,lower_bit_rate_constraint_flag:I,max_14bit_constraint_flag:P,inbld_flag:G}}function vf(i,n,r){let o;o=Uc(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]=Uc(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 vb(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 bb(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),L=o[R],B=L.num_negative_pics+L.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 q=0;for(let k=0;k<L.num_negative_pics;k+=1)q-=L.delta_poc_s0_minus1[k]+1,P[k]=q;q=0;for(let k=0;k<L.num_positive_pics;k+=1)q+=L.delta_poc_s1_minus1[k]+1,G[k]=q;let F=0;if(L.num_positive_pics>0)for(let k=L.num_positive_pics-1;k>=0;k-=1)q=G[k]+I,q<0&&g[L.num_negative_pics+k]&&(Q[F]=q,E[F]=h[L.num_negative_pics+k],F+=1);I<0&&g[B]&&(Q[F]=I,E[F]=h[B],F+=1);for(let k=0;k<L.num_negative_pics;k+=1)q=P[k]+I,q<0&&g[k]&&(Q[F]=q,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,L.num_negative_pics>0)for(let k=L.num_negative_pics-1;k>=0;k-=1)q=P[k]+I,q>0&&g[k]&&(X[F]=q,j[F]=h[k],F+=1);I>0&&g[B]&&(X[F]=I,j[F]=h[B],F+=1);for(let k=0;k<L.num_positive_pics;k+=1)q=G[k]+I,q>0&&g[L.num_negative_pics+k]&&(X[F]=q,j[F]=h[L.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 yb(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,L;j&&(R=i.decodeExponentialGolombNumber(),L=i.decodeExponentialGolombNumber());const B=!!i.next(),I=!!i.next(),P=!!i.next(),G=!!i.next();let Q,X,q,F;G&&(Q=i.decodeExponentialGolombNumber(),X=i.decodeExponentialGolombNumber(),q=i.decodeExponentialGolombNumber(),F=i.decodeExponentialGolombNumber());const C=!!i.next();let k,re,me,Y,$,K;C&&(k=i.read(32),re=i.read(32),me=!!i.next(),me&&(Y=i.decodeExponentialGolombNumber()),$=!!i.next(),$&&(K=bf(i,!0,n)));const ie=!!i.next();let ae,Te,z,J,fe,ne,ye,Ne;return ie&&(ae=!!i.next(),Te=!!i.next(),z=!!i.next(),J=i.decodeExponentialGolombNumber(),fe=i.decodeExponentialGolombNumber(),ne=i.decodeExponentialGolombNumber(),ye=i.decodeExponentialGolombNumber(),Ne=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:L,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:q,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:me,vui_num_ticks_poc_diff_one_minus1:Y,vui_hrd_parameters_present_flag:$,vui_hrd_parameters:K,bitstream_restriction_flag:ie,tiles_fixed_structure_flag:ae,motion_vectors_over_pic_boundaries_flag:Te,restricted_ref_pic_lists_flag:z,min_spatial_segmentation_idc:J,max_bytes_per_pic_denom:fe,max_bits_per_min_cu_denom:ne,log2_max_mv_length_horizontal:ye,log2_max_mv_length_vertical:Ne}}function bf(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=[],L=[],B=[],I=[],P=[],G=[],Q=[];for(let X=0;X<=r;X+=1)R[X]=!!i.next(),R[X]||(L[X]=!!i.next()),L[X]?B[X]=i.decodeExponentialGolombNumber():I[X]=!!i.next(),I[X]||(P[X]=i.decodeExponentialGolombNumber()),o&&(G[X]=Wc(i,X,Hc(P[X]))),u&&(Q[X]=Wc(i,X,Hc(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:L,elemental_duration_in_tc_minus1:B,low_delay_hrd_flag:I,cpb_cnt_minus1:P,nalHrdParameters:G,vclHrdParameters:Q}}function Wc(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 Hc(i){return i+1}function wb(i){let n,r,o,u=0;for(const l of xf(i)){const d=gb(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 Eb(i){return{inter_view_mv_vert_constraint_flag:!!i.next()}}function Sb(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 Nb(i){const{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:o}=wb(i),{profileTierLevel:{generalProfileTier:{profile_space:u,tier_flag:l,profile_idc:d,profileCompatibilitySet:v,constraintSet:h},general_level_idc:g}}=_b(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}=xb(r.rbsp),L=pb(p),B=mb(p),I=x-L*(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 Gc(i){return i.toString(16).toUpperCase()}function xo(i){return i.toString(16).toUpperCase().padStart(2,"0")}function Rr(i){return i.toString(10).padStart(2,"0")}class Cb{#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,L;E?{color_primaries:N,transfer_characteristics:j,matrix_coefficients:R,color_range:L}=o.color_config:(N=_t.ColorPrimaries.Bt709,j=_t.TransferCharacteristics.Bt709,R=_t.MatrixCoefficients.Bt709,L=!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),L?"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 yf{#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 Tb extends yf{#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}=hb(n);this.#t(l,d);const v="avc1."+xo(r)+xo(o)+xo(u);this.#e.configure({codec:v,optimizeForLatency:!0})}}class Rb extends yf{#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}=Nb(n);this.#t(h,g);const p=["hev1",["","A","B","C"][r]+o.toString(),Gc(sb(u,0)),(l?"H":"L")+d.toString(),...Array.from(v,Gc)].join(".");this.#e.configure({codec:p,codedWidth:h,codedHeight:g,optimizeForLatency:!0})}}class kb{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 Ab{#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 Pb{#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 zc=new Ab(()=>new Pb,4);class qc{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 kb;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 Os.H264:this.#t=new Tb(this.#a,this.#h);break;case Os.H265:this.#t=new Rb(this.#a,this.#h);break;case Os.AV1:this.#t=new Cb(this.#a,this.#h);break;default:throw new Error(`Unsupported codec: ${this.#e}`)}this.#n=new ib({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 zc.borrow(),o=await r.capture(n);return zc.return(r),o}dispose(){cancelAnimationFrame(this.#m),this.#a.state!=="closed"&&this.#a.close(),this.#u?.close(),this.#d?.close()}}var vo={exports:{}},bo={exports:{}},$c;function zo(){return $c||($c=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")},bo.exports=i})()),bo.exports}var yo={exports:{}},wo={exports:{}},Eo={exports:{}},Xc;function jb(){return Xc||(Xc=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}Eo.exports=i})()),Eo.exports}var Yc;function Ib(){return Yc||(Yc=1,(function(){var i=jb();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,L=0,B=0,I=0,P=0,G=0,Q=0,X=0,q=0,F=0,C=0,k=0,re=0,me=0,Y=0,$=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,L=R+x|0,B=K*b|0,I=K*E|0,me=0;me<u;me+=2)X=g[B++]|0,q=p[I++]|0,C=(409*q|0)-57088|0,k=(100*X|0)+(208*q|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[L++]|0,o[Q]=F+C>>8,o[Q+1]=F-k>>8,o[Q+2]=F+re>>8,Q+=4,F=298*h[L++]|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($=0,K=Y>>v,j=Y*x|0,B=K*b|0,I=K*E|0,me=0;me<u;me++)$=me>>d,X=g[B+$]|0,q=p[I+$]|0,C=(409*q|0)-57088|0,k=(100*X|0)+(208*q|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}wo.exports={convertYCbCr:n}})()),wo.exports}var Vc;function Mb(){return Vc||(Vc=1,(function(){var i=zo(),n=Ib();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),yo.exports=r})()),yo.exports}var So={exports:{}},No,Kc;function Lb(){return Kc||(Kc=1,No={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
|
+
`}),No}var Qc;function Db(){return Qc||(Qc=1,(function(){var i=zo(),n=Lb();function r(o){var u=this,l=r.contextForCanvas(o);if(l===null)throw new Error("WebGL unavailable");function d(Y,$){var K=l.createShader(Y);if(l.shaderSource(K,$),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,L,B,I,P,G,Q;function X(Y,$){return(!p[Y]||$)&&(p[Y]=l.createTexture()),p[Y]}function q(Y,$,K,ie,ae){var Te=!p[Y]||$,z=X(Y,$);if(l.activeTexture(l.TEXTURE0),r.stripe){var J=!p[Y+"_temp"]||$,fe=X(Y+"_temp",$);l.bindTexture(l.TEXTURE_2D,fe),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,ae)):l.texSubImage2D(l.TEXTURE_2D,0,0,0,K/4,ie,l.RGBA,l.UNSIGNED_BYTE,ae);var ne=p[Y+"_stripe"],ye=!ne||$;ye&&(ne=X(Y+"_stripe",$)),l.bindTexture(l.TEXTURE_2D,ne),ye&&(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,z),Te?(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,ae)):l.texSubImage2D(l.TEXTURE_2D,0,0,0,K,ie,l.ALPHA,l.UNSIGNED_BYTE,ae)}function F(Y,$,K,ie){var ae=p[Y];l.useProgram(h);var Te=x[Y];(!Te||$)&&(l.activeTexture(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,ae),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),Te=x[Y]=l.createFramebuffer()),l.bindFramebuffer(l.FRAMEBUFFER,Te),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,ae,0);var z=p[Y+"_temp"];l.activeTexture(l.TEXTURE1),l.bindTexture(l.TEXTURE_2D,z),l.uniform1i(B,1);var J=p[Y+"_stripe"];l.activeTexture(l.TEXTURE2),l.bindTexture(l.TEXTURE_2D,J),l.uniform1i(L,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,$,K){l.activeTexture($),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 $=Y,K=new Uint32Array($),ie=0;ie<$;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,$){var K=d(l.VERTEX_SHADER,Y),ie=d(l.FRAGMENT_SHADER,$),ae=l.createProgram();if(l.attachShader(ae,K),l.attachShader(ae,ie),l.linkProgram(ae),!l.getProgramParameter(ae,l.LINK_STATUS)){var Te=l.getProgramInfoLog(ae);throw l.deleteProgram(ae),new Error("GL program linking failed: "+Te)}return ae}function me(){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"),L=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 $=Y.format,K=!v||o.width!==$.displayWidth||o.height!==$.displayHeight;if(K&&(o.width=$.displayWidth,o.height=$.displayHeight,u.clear()),v||me(),K){var ie=function(ae,Te,z){var J=$.cropLeft/z,fe=($.cropLeft+$.cropWidth)/z,ne=($.cropTop+$.cropHeight)/$.height,ye=$.cropTop/$.height,Ne=new Float32Array([J,ne,fe,ne,J,ye,J,ye,fe,ne,fe,ye]);l.bindBuffer(l.ARRAY_BUFFER,ae),l.bufferData(l.ARRAY_BUFFER,Ne,l.STATIC_DRAW)};ie(I,P,Y.y.stride),ie(G,Q,Y.u.stride*$.width/$.chromaWidth)}q("uTextureY",K,Y.y.stride,$.height,Y.y.bytes),q("uTextureCb",K,Y.u.stride,$.chromaHeight,Y.u.bytes),q("uTextureCr",K,Y.v.stride,$.chromaHeight,Y.v.bytes),r.stripe&&(F("uTextureY",K,Y.y.stride,$.height),F("uTextureCb",K,Y.u.stride,$.chromaHeight),F("uTextureCr",K,Y.v.stride,$.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),So.exports=r})()),So.exports}var Jc;function Ob(){return Jc||(Jc=1,(function(){var i=zo(),n=Mb(),r=Db(),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)}};vo.exports=o})()),vo.exports}Ob();function wf(){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 Ef{#e;get canvas(){return this.#e}constructor(n){n?this.#e=n:this.#e=wf()}setSize(n,r){(this.#e.width!==n||this.#e.height!==r)&&(this.#e.width=n,this.#e.height=r)}}class Bb extends Ef{#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 Fb=Promise.resolve();function Zc(i,n){const r={powerPreference:"low-power",alpha:!1,failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!!n};return i.getContext("webgl2",r)||i.getContext("webgl",r)}class Dr extends Ef{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=wf();return!!Zc(n)}#e;constructor(n,r){super(n);const o=Zc(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,Dr.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,Dr.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),Fb}}const eu=50,Ub=300;function Wb({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),L=w.useRef(!1),B=w.useRef(!1),I=w.useRef(r),P=w.useRef(o),G=w.useRef(g),[Q,X]=w.useState("connecting"),[q,F]=w.useState(null),[C,k]=w.useState(null),[re,me]=w.useState(null),Y=w.useRef(!1),$=w.useRef(null),K=w.useRef(!1),ie=w.useRef(0),ae=w.useRef(null),Te=w.useRef(null),z=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 su(i);ee.success&&me({width:ee.width,height:ee.height})}catch(ee){console.error("[ScrcpyPlayer] Failed to fetch device resolution:",ee)}})()},[i]);const fe=w.useCallback(()=>{const Z=E.current,ee=b.current;if(!Z||!ee||!C)return;const we=ee.clientWidth,Le=ee.clientHeight,{width:le,height:ge}=C,Ee=le/ge;let he=we,ut=we/Ee;ut>Le&&(ut=Le,he=Le*Ee),Z.width=le,Z.height=ge,Z.style.width=`${he}px`,Z.style.height=`${ut}px`},[C]);w.useEffect(()=>{const Z=()=>fe();return window.addEventListener("resize",Z),()=>window.removeEventListener("resize",Z)},[fe]),w.useEffect(()=>{fe()},[C,fe]);const ne=w.useCallback(async()=>{if(Dr.isSupported){const ee=new Dr;return{renderer:ee,element:ee.canvas}}const Z=new Bb;return{renderer:Z,element:Z.canvas}},[]),ye=w.useCallback(async Z=>{if(!qc.isSupported)throw new Error("Current browser does not support WebCodecs API. Please use the latest Chrome/Edge.");const{renderer:ee,element:we}=await ne();return E.current=we,b.current&&!we.parentElement&&b.current.appendChild(we),new qc({codec:Z,renderer:ee})},[ne]),Ne=w.useCallback(()=>{L.current||(L.current=!0,N.current&&(clearTimeout(N.current),N.current=null))},[]),Ge=w.useCallback(Z=>{let ee=!1,we=[];const Le=new TransformStream({transform(ge,Ee){if(ge.type==="configuration"){Ee.enqueue(ge),ee=!0,we.length>0&&(we.forEach(he=>Ee.enqueue(he)),we=[]);return}if(ge.type==="data"&&!ee){we.push(ge);return}Ee.enqueue(ge)}});return new ReadableStream({start(ge){let Ee=!1;const he=ot=>{if(!Ee)try{Ne();const at={...ot,data:ot.data instanceof Uint8Array?ot.data:new Uint8Array(ot.data)};ge.enqueue(at)}catch(at){console.error("[ScrcpyPlayer] Video enqueue error:",at),Ee=!0,rt()}},ut=ot=>{Ee||(ge.error(new Error(ot?.message||"Socket error")),Ee=!0,rt())},pt=()=>{Ee||(ge.close(),Ee=!0,rt())},rt=()=>{p.current?.off("video-data",he),p.current?.off("error",ut),p.current?.off("disconnect",pt)};return p.current?.on("video-data",he),p.current?.on("error",ut),p.current?.on("disconnect",pt),()=>{Ee=!0,rt()}}}).pipeThrough(Le)},[Ne]),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),L.current=!1,X("connecting"),F(null);const Z=Ds({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(()=>{L.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 we=ee?.codec?ee.codec:Os.H264;x.current=await ye(we),x.current.sizeChanged(({width:le,height:ge})=>{k({width:le,height:ge})}),Ge(ee).pipeTo(x.current.writable).catch(le=>{console.error("[ScrcpyPlayer] Video stream error:",le)}),X("connected"),G.current?.({close:()=>Z.close()})}catch(we){console.error("[ScrcpyPlayer] Decoder initialization failed:",we),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,ye,Ge]);w.useEffect(()=>{R.current=Be},[Be]),w.useEffect(()=>(queueMicrotask(()=>{Be()}),()=>{Te.current&&(clearTimeout(Te.current),Te.current=null),z.current&&(clearTimeout(z.current),z.current=null),Qe(!0)}),[Be,Qe]);const O=()=>{if(C)return{width:C.width,height:C.height};const Z=E.current;return Z?{width:Z.width,height:Z.height}:null},de=(Z,ee)=>{const we=E.current,Le=O();if(!we||!Le)return null;const le=we.getBoundingClientRect();if(Z<le.left||Z>le.right||ee<le.top||ee>le.bottom)return null;const ge=Z-le.left,Ee=ee-le.top,he=Math.round(ge/le.width*Le.width),ut=Math.round(Ee/le.height*Le.height),pt=re?re.width/Le.width:1,rt=re?re.height/Le.height:1;return{x:Math.round(he*pt),y:Math.round(ut*rt)}},ce=async Z=>{if(!u||Q!=="connected")return;const ee=de(Z.clientX,Z.clientY);if(ee){Y.current=!0,K.current=!1,$.current={x:Z.clientX,y:Z.clientY};try{await Tx(ee.x,ee.y,i)}catch(we){console.error("[ScrcpyPlayer] Touch down failed:",we)}}},Fe=Z=>{if(!Y.current||Q!=="connected")return;const ee=Date.now(),we=de(Z.clientX,Z.clientY);if(we){if($.current){const Le=Z.clientX-$.current.x,le=Z.clientY-$.current.y;Math.hypot(Le,le)>4&&(K.current=!0)}if(ae.current=we,ee-ie.current<eu){Te.current||(Te.current=setTimeout(()=>{Te.current=null,ae.current&&(Cc(ae.current.x,ae.current.y,i).catch(Le=>{console.error("[ScrcpyPlayer] Touch move failed:",Le)}),ae.current=null,ie.current=Date.now())},eu));return}ie.current=ee,Cc(we.x,we.y,i).catch(Le=>{console.error("[ScrcpyPlayer] Touch move failed:",Le)})}},Ve=async Z=>{if(!Y.current||Q!=="connected")return;const ee=de(Z.clientX,Z.clientY);if(Y.current=!1,$.current=null,!!ee)try{await Nc(ee.x,ee.y,i),K.current?v?.():l?.()}catch(we){const Le=String(we);K.current?h?.(Le):d?.(Le)}},ue=async Z=>{if(!Y.current||Q!=="connected")return;const ee=de(Z.clientX,Z.clientY);if(Y.current=!1,$.current=null,!!ee)try{await Nc(ee.x,ee.y,i)}catch(we){console.error("[ScrcpyPlayer] Touch cancel failed:",we)}},be=Z=>{if(!u||Q!=="connected")return;Z.preventDefault();const ee=Z.deltaY;J.current||(J.current={deltaY:0}),J.current.deltaY+=ee,z.current&&clearTimeout(z.current),z.current=setTimeout(async()=>{const we=J.current;if(J.current=null,!we)return;const Le=E.current,le=O();if(!Le||!le)return;const ge=Le.getBoundingClientRect(),Ee=ge.left+ge.width/2,he=ge.top+ge.height/2,ut=de(Ee,he);if(!ut)return;const pt=Math.max(Math.min(we.deltaY,600),-600),rt=he+pt,ot=de(Ee,rt);if(ot)try{const at=await Cx(ut.x,ut.y,ot.x,ot.y,300,i);at.success?v?.():h?.(at.error||"Scroll failed")}catch(at){h?.(String(at))}},Ub)};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:ce,onMouseMove:Fe,onMouseUp:Ve,onMouseLeave:ue,onWheel:be,children:Q!=="connected"&&a.jsxs("div",{className:"absolute inset-0 flex items-center justify-center text-slate-400",children:[Q==="connecting"&&"Connecting...",Q==="error"&&(q||"Connection error"),Q==="disconnected"&&"Disconnected"]})})})}const Hb={compact:320,standard:400,wide:480,auto:"auto"};function Gb({currentWidth:i,onWidthChange:n}){const r=An(),o=d=>{n(Hb[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(Se,{variant:"ghost",size:"sm",onClick:u,className:"h-7 w-7 p-0 rounded-lg",disabled:i<=240,children:a.jsx(cv,{className:"w-3 h-3"})})}),a.jsx(gn,{children:a.jsx("p",{children:r.deviceMonitor?.decreaseWidth||"Decrease width"})})]}),a.jsx(Se,{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(Se,{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(Se,{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(Se,{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(av,{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(Se,{variant:"ghost",size:"sm",onClick:l,className:"h-7 w-7 p-0 rounded-lg",disabled:i>=640,children:a.jsx(xu,{className:"w-3 h-3"})})}),a.jsx(gn,{children:a.jsx("p",{children:r.deviceMonitor?.increaseWidth||"Increase width"})})]})]})}function zb({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 qb(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 Sf({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),[L,B]=w.useState("success"),[I,P]=w.useState(!1),[G,Q]=w.useState(!1),[X,q]=qb("device-monitor-width",320),F=w.useRef(null),C=w.useRef(!1),k=w.useRef(null),re=w.useRef(null),me=(ne,ye=2e3,Ne="success")=>{k.current&&clearTimeout(k.current),B(Ne),R(ne),k.current=setTimeout(()=>{R(null)},ye)},Y=()=>{re.current&&clearTimeout(re.current),P(!0)},$=()=>{re.current=setTimeout(()=>{P(!1)},500)},K=()=>{Q(ne=>!ne)},ie=ne=>{q(ne)},ae=ne=>{if(typeof X!="number")return;const ye=Math.min(640,Math.max(240,X+ne));q(ye)},Te=w.useCallback(ne=>{F.current=ne},[]),z=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 ye=async()=>{if(!C.current){C.current=!0;try{const Ge=await su(i);Ge.success&&h(Ge)}catch(Ge){console.error("Failed to fetch screenshot:",Ge)}finally{C.current=!1}}};ye();const Ne=setInterval(ye,500);return()=>clearInterval(Ne)},[i,x,E,o]);const fe=typeof X=="number"?`${X}px`:"auto";return a.jsxs(Xs,{className:`flex-shrink-0 relative min-h-0 overflow-hidden bg-background ${u}`,style:{width:fe,minWidth:typeof X=="number"?void 0:"240px",maxWidth:typeof X=="number"?void 0:"640px"},onMouseEnter:Y,onMouseLeave:$,children:[typeof X=="number"&&a.jsx(zb,{onResize:ae,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(Se,{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(Se,{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(wv,{className:"w-3 h-3 mr-1"}),l.devicePanel?.video||"Video"]}),a.jsxs(Se,{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(Pc,{className:"w-3 h-3 mr-1"}),l.devicePanel?.image||"Image"]})]}),a.jsx(Gb,{currentWidth:X,onWidthChange:ie})]}),a.jsx(Se,{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(vu,{className:"w-4 h-4"}):a.jsx(wu,{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(fv,{className:"w-3 h-3 mr-1"}),l.devicePanel?.video||"Video"]}),E==="screenshot"&&a.jsxs(a.Fragment,{children:[a.jsx(Pc,{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:[L==="error"&&a.jsx(kn,{className:"w-4 h-4"}),L==="tap"&&a.jsx(tv,{className:"w-4 h-4"}),L==="swipe"&&a.jsx(zx,{className:"w-4 h-4"}),L==="success"&&a.jsx(Br,{className:"w-4 h-4"}),a.jsx("span",{children:j})]}),E==="video"||E==="auto"&&g&&!x?a.jsx(Wb,{deviceId:i,className:"w-full h-full",enableControl:!0,onFallback:z,onTapSuccess:()=>me(l.devicePanel?.tapped||"Tapped",2e3,"tap"),onTapError:ne=>me((l.devicePanel?.tapError||"Tap error: {error}").replace("{error}",ne),3e3,"error"),onSwipeSuccess:()=>me(l.devicePanel?.swiped||"Swiped",2e3,"swipe"),onSwipeError:ne=>me((l.devicePanel?.swipeError||"Swipe error: {error}").replace("{error}",ne),3e3,"error"),onStreamReady:Te,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 $b(i,[n,r]){return Math.min(r,Math.max(n,i))}function Xb(i,n){return w.useReducer((r,o)=>n[r][o]??r,i)}var qo="ScrollArea",[Nf]=$s(qo),[Yb,Gt]=Nf(qo),Cf=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),[L,B]=w.useState(0),[I,P]=w.useState(0),[G,Q]=w.useState(!1),[X,q]=w.useState(!1),F=_n(n,k=>h(k)),C=Oo(u);return a.jsx(Yb,{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:q,onCornerWidthChange:B,onCornerHeightChange:P,children:a.jsx(Vt.div,{dir:C,...d,ref:F,style:{position:"relative","--radix-scroll-area-corner-width":L+"px","--radix-scroll-area-corner-height":I+"px",...i.style}})})});Cf.displayName=qo;var Tf="ScrollAreaViewport",Rf=w.forwardRef((i,n)=>{const{__scopeScrollArea:r,children:o,nonce:u,...l}=i,d=Gt(Tf,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})})]})});Rf.displayName=Tf;var nn="ScrollAreaScrollbar",kf=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(Vb,{...o,ref:n,forceMount:r}):u.type==="scroll"?a.jsx(Kb,{...o,ref:n,forceMount:r}):u.type==="auto"?a.jsx(Af,{...o,ref:n,forceMount:r}):u.type==="always"?a.jsx($o,{...o,ref:n}):null});kf.displayName=nn;var Vb=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(Or,{present:r||l,children:a.jsx(Af,{"data-state":l?"visible":"hidden",...o,ref:n})})}),Kb=w.forwardRef((i,n)=>{const{forceMount:r,...o}=i,u=Gt(nn,i.__scopeScrollArea),l=i.orientation==="horizontal",d=Zs(()=>h("SCROLL_END"),100),[v,h]=Xb("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(Or,{present:r||v!=="hidden",children:a.jsx($o,{"data-state":v==="hidden"?"hidden":"visible",...o,ref:n,onPointerEnter:xt(i.onPointerEnter,()=>h("POINTER_ENTER")),onPointerLeave:xt(i.onPointerLeave,()=>h("POINTER_LEAVE"))})})}),Af=w.forwardRef((i,n)=>{const r=Gt(nn,i.__scopeScrollArea),{forceMount:o,...u}=i,[l,d]=w.useState(!1),v=i.orientation==="horizontal",h=Zs(()=>{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(Or,{present:o||l,children:a.jsx($o,{"data-state":l?"visible":"hidden",...u,ref:n})})}),$o=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 ny(b,d.current,v,E)}return r==="horizontal"?a.jsx(Qb,{...p,ref:n,onThumbPositionChange:()=>{if(u.viewport&&l.current){const b=u.viewport.scrollLeft,E=tu(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(Jb,{...p,ref:n,onThumbPositionChange:()=>{if(u.viewport&&l.current){const b=u.viewport.scrollTop,E=tu(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}),Qb=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(jf,{"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":Js(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),Of(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:qs(d.paddingLeft),paddingEnd:qs(d.paddingRight)}})}})}),Jb=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(jf,{"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":Js(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),Of(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:qs(d.paddingTop),paddingEnd:qs(d.paddingBottom)}})}})}),[Zb,Pf]=Nf(nn),jf=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)),L=w.useRef(null),B=w.useRef(""),I=E.viewport,P=o.content-o.viewport,G=Tn(p),Q=Tn(h),X=Zs(x,10);function q(F){if(L.current){const C=F.clientX-L.current.left,k=F.clientY-L.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(Zb,{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),L.current=N.getBoundingClientRect(),B.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",E.viewport&&(E.viewport.style.scrollBehavior="auto"),q(F))}),onPointerMove:xt(i.onPointerMove,q),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=""),L.current=null})})})}),zs="ScrollAreaThumb",If=w.forwardRef((i,n)=>{const{forceMount:r,...o}=i,u=Pf(zs,i.__scopeScrollArea);return a.jsx(Or,{present:r||u.hasThumb,children:a.jsx(ey,{ref:n,...o})})}),ey=w.forwardRef((i,n)=>{const{__scopeScrollArea:r,style:o,...u}=i,l=Gt(zs,r),d=Pf(zs,r),{onThumbPositionChange:v}=d,h=_n(n,x=>d.onThumbChange(x)),g=w.useRef(void 0),p=Zs(()=>{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=ry(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)})});If.displayName=zs;var Xo="ScrollAreaCorner",Mf=w.forwardRef((i,n)=>{const r=Gt(Xo,i.__scopeScrollArea),o=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&o?a.jsx(ty,{...i,ref:n}):null});Mf.displayName=Xo;var ty=w.forwardRef((i,n)=>{const{__scopeScrollArea:r,...o}=i,u=Gt(Xo,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 qs(i){return i?parseInt(i,10):0}function Lf(i,n){const r=i/n;return isNaN(r)?0:r}function Js(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 ny(i,n,r,o="ltr"){const u=Js(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 Df([h,g],x)(i)}function tu(i,n,r="ltr"){const o=Js(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=$b(i,h);return Df([0,d],[0,v])(g)}function Df(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 Of(i,n){return i>0&&i<n}var ry=(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 Zs(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);Rx(()=>{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 sy=Cf,iy=Rf,oy=Mf;function Lr({className:i,children:n,...r}){return a.jsxs(sy,{"data-slot":"scroll-area",className:ar("relative",i),...r,children:[a.jsx(iy,{"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(ay,{}),a.jsx(oy,{})]})}function ay({className:i,orientation:n="vertical",...r}){return a.jsx(kf,{"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(If,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}function ly(i){const n=new Date(i),o=new Date().getTime()-n.getTime(),u=Math.floor(o/6e4),l=Math.floor(o/36e5),d=Math.floor(o/864e5);return u<1?"Just now":u<60?`${u}m ago`:l<24?`${l}h ago`:d<7?`${d}d ago`:n.toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function cy(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 Bf({item:i,onSelect:n,onDelete:r}){const o=An(),u=l=>{l.stopPropagation(),confirm(o.history.deleteConfirm)&&r(i.id)};return a.jsx(Xs,{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.task_text}),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:ly(i.start_time)}),a.jsx("span",{children:"•"}),a.jsxs("span",{children:[i.steps," ",i.steps===1?"step":"steps"]}),a.jsx("span",{children:"•"}),a.jsx("span",{children:cy(i.duration_ms)})]}),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(Br,{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(Se,{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(fu,{className:"w-3 h-3"})})]})]})]})})}function uy({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,L]=w.useState(!1),[B,I]=w.useState([]),[P,G]=w.useState([]),[Q,X]=w.useState(!1),q=w.useRef(null),F=w.useRef(null),C=w.useRef(null),k=w.useRef(0),re=w.useRef(null),[me,Y]=w.useState(!0),[$,K]=w.useState(!1),ie=w.useRef(rf.throttle(()=>{const O=C.current;if(!O)return;const de=80,ce=O.scrollHeight-O.scrollTop-O.clientHeight,Fe=ce<=1;Y(Fe),ce<=de&&K(!1)},100));w.useEffect(()=>{const O=ie.current;return()=>{O.cancel()}},[]),w.useEffect(()=>{R&&(async()=>{try{const de=await ou(n,20,0);I(de.records)}catch(de){console.error("Failed to load history:",de),I([])}})()},[R,n]);const ae=O=>{const de=[],ce=O.messages.find(be=>be.role==="user");ce?de.push({id:`${O.id}-user`,role:"user",content:ce.content||O.task_text,timestamp:new Date(ce.timestamp)}):de.push({id:`${O.id}-user`,role:"user",content:O.task_text,timestamp:new Date(O.start_time)});const Fe=[],Ve=[];O.messages.filter(be=>be.role==="assistant").forEach(be=>{be.thinking&&Fe.push(be.thinking),be.action&&Ve.push(be.action)});const ue={id:`${O.id}-agent`,role:"assistant",content:O.final_message,timestamp:O.end_time?new Date(O.end_time):new Date(O.start_time),steps:O.steps,success:O.success,thinking:Fe,actions:Ve,isStreaming:!1};de.push(ue),v(de),k.current=de.length,re.current=[ue.id,ue.content?.length??0,ue.currentThinking?.length??0,ue.thinking?JSON.stringify(ue.thinking).length:0,ue.steps??"",ue.isStreaming?1:0].join("|"),K(!1),Y(!0),L(!1)},Te=async()=>{if(confirm(l.history.clearAllConfirm))try{await lu(n),I([])}catch(O){console.error("Failed to clear history:",O)}},z=async O=>{try{await cu(n,O),I(de=>de.filter(ce=>ce.id!==O))}catch(de){console.error("Failed to delete history item:",de)}},J=w.useCallback(async()=>{const O=h.trim();if(!O||p)return;const de={id:Date.now().toString(),role:"user",content:O,timestamp:new Date};v(le=>[...le,de]),g(""),x(!0),j(null);const ce=[],Fe=[];let Ve="";const ue=[];let be=null;const Z=(Date.now()+1).toString(),ee={id:Z,role:"assistant",content:"",timestamp:new Date,thinking:[],actions:[],isStreaming:!0,currentThinking:""};v(le=>[...le,ee]);const we=()=>{if(ue.length>0){const le=ue.join("");ue.length=0,Ve+=le,v(ge=>ge.map(Ee=>Ee.id===Z?{...Ee,currentThinking:Ve}:Ee))}be=null},Le=kx(de.content,i,le=>{ue.push(le.chunk),be===null&&(be=setTimeout(we,50))},le=>{be!==null&&(clearTimeout(be),we());const ge=le.thinking&&le.thinking.length>0?le.thinking:Ve;ge&&ce.push(ge),Ve="",Fe.push(le.action),v(Ee=>Ee.map(he=>he.id===Z?{...he,thinking:[...ce],actions:[...Fe],steps:le.step,currentThinking:""}:he))},le=>{be!==null&&clearTimeout(be);const ge={...ee,content:le.message,success:le.success,isStreaming:!1,steps:le.steps,thinking:[...ce],actions:[...Fe],timestamp:new Date,currentThinking:void 0};v(Ee=>Ee.map(he=>he.id===Z?ge:he)),x(!1),q.current=null},le=>{be!==null&&clearTimeout(be);const ge={...ee,content:`Error: ${le.message}`,success:!1,isStreaming:!1,thinking:[...ce],actions:[...Fe],timestamp:new Date,currentThinking:void 0};v(Ee=>Ee.map(he=>he.id===Z?ge:he)),x(!1),j(le.message),q.current=null},le=>{be!==null&&clearTimeout(be);const ge={...ee,content:le.message||"Chat aborted by user",success:!1,isStreaming:!1,thinking:[...ce],actions:[...Fe],timestamp:new Date,currentThinking:void 0};v(Ee=>Ee.map(he=>he.id===Z?ge:he)),x(!1),q.current=null});q.current=Le},[h,p,i]),fe=w.useCallback(async()=>{q.current&&q.current.close(),v([]),x(!1),j(null),K(!1),Y(!0),q.current=null,k.current=0,re.current=null,await Ax(i)},[i]),ne=w.useCallback(async()=>{if(q.current){E(!0);try{q.current&&(q.current.close(),q.current=null),v(O=>{const de=O[O.length-1];return de&&de.role==="assistant"&&de.isStreaming?O.map((ce,Fe)=>Fe===O.length-1?{...ce,content:ce.content||l.chat.aborted,isStreaming:!1,success:!1,currentThinking:void 0}:ce):O}),Px(i).catch(O=>console.error("Backend abort failed:",O))}catch(O){console.error("Failed to abort chat:",O)}finally{x(!1),E(!1)}}},[i,l]),ye=w.useCallback(()=>{F.current?.scrollIntoView({behavior:"smooth"})},[]);w.useEffect(()=>{const O=d[d.length-1],de=O?.thinking?JSON.stringify(O.thinking).length:0,ce=O?[O.id,O.content?.length??0,O.currentThinking?.length??0,de,O.steps??"",O.isStreaming?1:0].join("|"):null,Fe=d.length>k.current,Ve=ce!==re.current&&d.length>0;if(k.current=d.length,re.current=ce,me){ye(),K(!1);return}if(d.length===0){K(!1);return}(Fe||Ve)&&K(!0)},[d,me,ye]),w.useEffect(()=>()=>{q.current&&q.current.close()},[i]),w.useEffect(()=>{(async()=>{try{const de=await au();G(de.workflows)}catch(de){console.error("Failed to load workflows:",de)}})()},[]);const Ne=O=>{g(O.text),X(!1)},Ge=()=>{ie.current()},Qe=()=>{ye(),K(!1),Y(!0)},Be=O=>{(O.metaKey||O.ctrlKey)&&O.key==="Enter"&&(O.preventDefault(),J())};return a.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[a.jsxs(Xs,{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(Fs,{open:R,onOpenChange:L,children:[a.jsx(Us,{asChild:!0,children:a.jsx(Se,{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(Bs,{className:"h-4 w-4"})})}),a.jsxs(Ws,{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(Se,{variant:"ghost",size:"sm",onClick:Te,className:"h-7 text-xs",children:l.history.clearAll})]}),a.jsx(Lr,{className:"h-[400px]",children:a.jsx("div",{className:"p-4 space-y-2",children:B.length>0?B.map(O=>a.jsx(Bf,{item:O,onSelect:ae,onDelete:z},O.id)):a.jsxs("div",{className:"text-center py-8",children:[a.jsx(Bs,{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(Se,{variant:"ghost",size:"icon",onClick:fe,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(Eu,{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:Ge,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(O=>a.jsx("div",{className:`flex ${O.role==="user"?"justify-end":"justify-start"}`,children:O.role==="assistant"?a.jsxs("div",{className:"max-w-[85%] space-y-3",children:[O.thinking?.map((de,ce)=>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 ",ce+1]})]}),a.jsx("p",{className:"text-sm whitespace-pre-wrap text-slate-700 dark:text-slate-300",children:de}),O.actions?.[ce]&&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(O.actions[ce],null,2)})]})]},ce)),O.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:[O.currentThinking,a.jsx("span",{className:"inline-block w-1 h-4 ml-0.5 bg-[#1d9bf0] animate-pulse"})]})]}),O.content&&a.jsxs("div",{className:`
|
|
126
|
+
rounded-2xl px-4 py-3 flex items-start gap-2
|
|
127
|
+
${O.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(Br,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${O.success===!1?"text-red-500":"text-green-500"}`}),a.jsxs("div",{children:[a.jsx("p",{className:"whitespace-pre-wrap",children:O.content}),O.steps!==void 0&&a.jsxs("p",{className:"text-xs mt-2 opacity-60 text-slate-500 dark:text-slate-400",children:[O.steps," steps completed"]})]})]}),O.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:O.content})}),a.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-1 text-right",children:O.timestamp.toLocaleTimeString()})]})},O.id)),a.jsx("div",{ref:F})]}),$&&a.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-4 flex justify-center",children:a.jsx(Se,{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(bu,{value:h,onChange:O=>g(O.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(Fs,{open:Q,onOpenChange:X,children:[a.jsx(Us,{asChild:!0,children:a.jsx(Se,{variant:"outline",size:"icon",className:"h-10 w-10 flex-shrink-0",children:a.jsx(iu,{className:"w-4 h-4"})})}),a.jsx(Ws,{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(Lr,{className:"h-64",children:a.jsx("div",{className:"space-y-1",children:P.map(O=>a.jsxs("button",{onClick:()=>Ne(O),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:O.name}),a.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-2",children:O.text})]},O.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(Se,{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(Cu,{className:"h-4 w-4"})}),!p&&a.jsx(Se,{onClick:J,disabled:!h.trim(),size:"icon",variant:"twitter",className:"h-10 w-10 rounded-full flex-shrink-0",children:a.jsx(Su,{className:"h-4 w-4"})})]})})]}),a.jsx(Sf,{deviceId:i,serial:n,connectionType:o,isVisible:!0})]})}function fy({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),L=w.useRef(null),B=w.useRef(null),[I,P]=w.useState([]),[G,Q]=w.useState(!1),[X,q]=w.useState([]),[F,C]=w.useState(!1);w.useEffect(()=>{R.current?.scrollIntoView({behavior:"smooth"})},[d]),w.useEffect(()=>()=>{L.current&&L.current.close()},[]),w.useEffect(()=>{(async()=>{try{const J=await au();P(J.workflows)}catch(J){console.error("Failed to load workflows:",J)}})()},[]),w.useEffect(()=>{F&&(async()=>{try{const J=await ou(n,20,0);q(J.records)}catch(J){console.error("Failed to load history:",J),q([])}})()},[F,n]);const k=z=>{g(z.text),Q(!1)},re=z=>{const J={id:`${z.id}-user`,role:"user",content:z.task_text,timestamp:new Date(z.start_time)},fe={id:`${z.id}-agent`,role:"assistant",content:z.final_message,timestamp:z.end_time?new Date(z.end_time):new Date(z.start_time),steps:[],success:z.success,isStreaming:!1};v([J,fe]),C(!1)},me=async()=>{if(confirm(l.history?.clearAllConfirm||"Clear all history?"))try{await lu(n),q([])}catch(z){console.error("Failed to clear history:",z)}},Y=async z=>{try{await cu(n,z),q(J=>J.filter(fe=>fe.id!==z))}catch(J){console.error("Failed to delete history item:",J)}},$=(z,J)=>{v(fe=>fe.map(ne=>ne.id===z?{...ne,steps:ne.steps?.map(ye=>ye.id===J?{...ye,isExpanded:!ye.isExpanded}:ye)}:ne))},K=w.useCallback(async()=>{const z=h.trim();if(!z||p)return;const J={id:Date.now().toString(),role:"user",content:z,timestamp:new Date};v(Ne=>[...Ne,J]),g(""),x(!0),j(null);const fe=(Date.now()+1).toString(),ne={id:fe,role:"assistant",content:"",timestamp:new Date,steps:[],isStreaming:!0};v(Ne=>[...Ne,ne]);const ye=new AbortController;B.current=ye;try{const Ne=await fetch("/api/layered-agent/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:z,device_id:i,session_id:i}),signal:ye.signal});if(!Ne.ok){let de=`HTTP error! status: ${Ne.status}`;try{const ce=await Ne.json();ce.detail&&(de=ce.detail)}catch{}throw new Error(de)}const Ge=Ne.body?.getReader();if(!Ge)throw new Error("No response body");const Qe=new TextDecoder;let Be="";const O=[];for(;;){const{done:de,value:ce}=await Ge.read();if(de)break;Be+=Qe.decode(ce,{stream:!0});const Fe=Be.split(`
|
|
129
|
+
`);Be=Fe.pop()||"";for(const Ve of Fe)if(Ve.startsWith("data: "))try{const ue=JSON.parse(Ve.slice(6));if(ue.type==="tool_call"){const be={id:`step-${Date.now()}-${Math.random()}`,type:"tool_call",content:ue.tool_name==="chat"?"发送指令给 Phone Agent":ue.tool_name==="list_devices"?"获取设备列表":`调用工具: ${ue.tool_name}`,toolName:ue.tool_name,toolArgs:ue.tool_args||{},timestamp:new Date,isExpanded:!0};O.push(be),v(Z=>Z.map(ee=>ee.id===fe?{...ee,steps:[...O]}:ee))}else if(ue.type==="tool_result"){const be={id:`step-${Date.now()}-${Math.random()}`,type:"tool_result",content:ue.tool_name==="chat"?"Phone Agent 执行结果":`${ue.tool_name} 结果`,toolResult:ue.result,timestamp:new Date,isExpanded:!0};O.push(be),v(Z=>Z.map(ee=>ee.id===fe?{...ee,steps:[...O]}:ee))}else if(ue.type==="message")v(be=>be.map(Z=>Z.id===fe?{...Z,content:ue.content}:Z));else if(ue.type==="done"){const be={...ne,content:ue.content||"",isStreaming:!1,success:ue.success,steps:[...O],timestamp:new Date};v(Z=>Z.map(ee=>ee.id===fe?be:ee))}else if(ue.type==="error"){const be={...ne,content:`错误: ${ue.message}`,isStreaming:!1,success:!1,steps:[...O],timestamp:new Date};v(Z=>Z.map(ee=>ee.id===fe?be:ee)),j(ue.message)}}catch(ue){console.error("Failed to parse SSE data:",ue,Ve)}}v(de=>de.map(ce=>ce.id===fe&&ce.isStreaming?{...ce,isStreaming:!1,success:!0}:ce))}catch(Ne){if(Ne instanceof Error&&Ne.name==="AbortError"){console.log("Chat aborted by user");return}console.error("Chat error:",Ne);const Ge=uu(Ne);j(Ge),v(Qe=>Qe.map(Be=>Be.id===fe?{...Be,content:`错误: ${Ge}`,isStreaming:!1,success:!1}:Be))}finally{x(!1),B.current=null}},[h,p,i]),ie=w.useCallback(()=>{if(B.current){E(!0);try{B.current.abort(),B.current=null,v(z=>{const J=z[z.length-1];return J&&J.role==="assistant"&&J.isStreaming?z.map((fe,ne)=>ne===z.length-1?{...fe,content:fe.content||l.chat?.aborted||"任务已中断",isStreaming:!1,success:!1}:fe):z}),jx(async()=>{const{abortLayeredAgentChat:z}=await import("./index-CTHbFvKl.js").then(J=>J.ap);return{abortLayeredAgentChat:z}},__vite__mapDeps([0,1])).then(({abortLayeredAgentChat:z})=>{z(i).catch(J=>console.error("Backend abort failed:",J))})}catch(z){console.error("Failed to abort chat:",z)}finally{x(!1),E(!1)}}},[l,i]),ae=w.useCallback(async()=>{B.current&&(B.current.abort(),B.current=null),v([]),j(null),L.current&&(L.current.close(),L.current=null);try{await fetch("/api/layered-agent/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:i})})}catch(z){console.warn("Failed to reset backend session:",z)}},[i]),Te=z=>{(z.metaKey||z.ctrlKey)&&z.key==="Enter"&&(z.preventDefault(),K())};return a.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[a.jsxs(Xs,{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(Co,{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(Fs,{open:F,onOpenChange:C,children:[a.jsx(Us,{asChild:!0,children:a.jsx(Se,{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(Bs,{className:"h-4 w-4"})})}),a.jsxs(Ws,{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(Se,{variant:"ghost",size:"sm",onClick:me,className:"h-7 text-xs",children:l.history?.clearAll||"Clear All"})]}),a.jsx(Lr,{className:"h-[400px]",children:a.jsx("div",{className:"p-4 space-y-2",children:X.length>0?X.map(z=>a.jsx(Bf,{item:z,onSelect:re,onDelete:Y},z.id)):a.jsxs("div",{className:"text-center py-8",children:[a.jsx(Bs,{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(Se,{variant:"ghost",size:"icon",onClick:ae,className:"h-8 w-8 rounded-full",title:"重置对话",children:a.jsx(Eu,{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(Lr,{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(Co,{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(z=>a.jsx("div",{className:"space-y-2",children:z.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:z.content})}),a.jsx("p",{className:"text-xs text-slate-400 mt-1 text-right",children:z.timestamp.toLocaleTimeString()})]})}):a.jsxs("div",{className:"space-y-3",children:[z.steps&&z.steps.length>0&&a.jsx("div",{className:"space-y-2",children:z.steps.map((J,fe)=>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:()=>$(z.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(Tv,{className:"w-3 h-3"}):a.jsx(Ix,{className:"w-3 h-3"})}),a.jsxs("span",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:["Step ",fe+1,": ",J.content]})]}),J.isExpanded?a.jsx(Yx,{className:"w-4 h-4 text-slate-400"}):a.jsx(Hx,{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))}),z.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 ${z.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:[z.success!==void 0&&a.jsx(Br,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${z.success?"text-green-500":"text-red-500"}`}),a.jsx("p",{className:"whitespace-pre-wrap",children:z.content})]})})}),z.isStreaming&&!z.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"}),"正在思考和执行..."]})]})},z.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(bu,{value:h,onChange:z=>g(z.target.value),onKeyDown:Te,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(Fs,{open:G,onOpenChange:Q,children:[a.jsx(Us,{asChild:!0,children:a.jsx(Se,{variant:"outline",size:"icon",className:"h-10 w-10 flex-shrink-0",children:a.jsx(iu,{className:"w-4 h-4"})})}),a.jsx(Ws,{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(Lr,{className:"h-64",children:a.jsx("div",{className:"space-y-1",children:I.map(z=>a.jsxs("button",{onClick:()=>k(z),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:z.name}),a.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-2",children:z.text})]},z.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(Se,{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(Cu,{className:"h-4 w-4"})}),!p&&a.jsx(Se,{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(Su,{className:"h-4 w-4"})})]})})]}),a.jsx(Sf,{deviceId:i,serial:n,connectionType:o,isVisible:u})]})}function dy({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"}}],hy=[{name:"glm",displayName:"GLM Agent",description:"基于 GLM 模型优化,成熟稳定,适合大多数任务",icon:Qx,defaultConfig:{}},{name:"mai",displayName:"MAI Agent",description:"阿里通义团队开发,支持多张历史截图上下文",icon:yu,defaultConfig:{history_n:3}}],py=[{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 Ny(){const i=An(),n=Mx.useSearch(),r=Lx(),[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,L]=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 Ox();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&&L(!0)}catch(k){console.error("Failed to load config:",k),L(!0)}})()},[]);const Q=w.useCallback(async()=>{try{const k=(await Dx()).devices.filter($=>$.state!=="disconnected"),re=new Map,me=new Map;for(const $ of k)if($.serial){const K=me.get($.serial)||[];K.push($),me.set($.serial,K)}else re.set($.id,$);Array.from(me.values()).forEach($=>{const ie=$.find(ae=>ae.connection_type==="wifi")||$[0];re.set(ie.id,ie)});const Y=Array.from(re.values());if(u(Y),Y.length>0&&!g){const $=n.serial;if($){const K=Y.find(ie=>ie.serial===$);d(K?K.id:Y[0].id)}else l||d(Y[0].id);p(!0)}l&&!Y.find($=>$.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(me=>me.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 Bx({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 Fx();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")}L(!1)}catch(C){console.error("Failed to save config:",C),E(`Failed to save: ${uu(C)}`,"error")}},q=async C=>{try{const k=await Wx({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 Ux(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(dy,{message:x.message,type:x.type,onClose:()=>b(C=>({...C,visible:!1}))}),a.jsx(du,{open:R,onOpenChange:L,children:a.jsxs(hu,{className:"sm:max-w-md h-[75vh] flex flex-col",children:[a.jsxs(pu,{className:"flex-shrink-0",children:[a.jsxs(mu,{className:"flex items-center gap-2",children:[a.jsx(Nu,{className:"w-5 h-5 text-[#1d9bf0]"}),i.chat.configuration]}),a.jsx(gu,{children:i.chat.configureApi})]}),a.jsxs(Gu,{defaultValue:"vision",className:"flex-1 flex flex-col min-h-0",children:[a.jsxs(zu,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[a.jsxs(Ir,{value:"vision",children:[a.jsx(ho,{className:"w-4 h-4 mr-2"}),i.chat.visionModelTab]}),a.jsxs(Ir,{value:"decision",children:[a.jsx(yu,{className:"w-4 h-4 mr-2"}),i.chat.decisionModelTab]})]}),a.jsxs(Mr,{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(st,{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(To,{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(kc,{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(st,{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(st,{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(Se,{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(Ac,{className:"w-4 h-4 text-slate-400"}):a.jsx(ho,{className:"w-4 h-4 text-slate-400"})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(st,{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(st,{className:"text-sm font-medium",children:i.chat.agentType||"Agent 类型"}),a.jsx("div",{className:"grid grid-cols-2 gap-2",children:hy.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(st,{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(st,{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(Mr,{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(sv,{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(st,{className:"text-sm font-medium",children:i.chat.selectDecisionPreset}),a.jsx("div",{className:"grid grid-cols-1 gap-2",children:py.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(To,{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(kc,{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(st,{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(st,{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(Se,{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(Ac,{className:"w-4 h-4 text-slate-400"}):a.jsx(ho,{className:"w-4 h-4 text-slate-400"})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(st,{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(_u,{className:"sm:justify-between gap-2 flex-shrink-0",children:[a.jsx(Se,{variant:"outline",onClick:()=>{L(!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(Se,{onClick:X,variant:"twitter",children:[a.jsx(Br,{className:"w-4 h-4 mr-2"}),i.chat.saveConfig]})]})]})}),a.jsx(u1,{devices:o,currentDeviceId:l,onSelectDevice:d,onOpenConfig:()=>L(!0),onConnectWifi:q,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(Co,{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(fy,{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(uy,{deviceId:C.id,deviceSerial:C.serial,deviceName:C.model,deviceConnectionType:C.connection_type,isConfigured:!!N?.base_url})})},C.serial))})]})]})}export{Ny as component};
|