tide-commander 1.173.0 → 1.174.0
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.
- package/CHANGELOG.md +16 -0
- package/dist/assets/{BossLogsModal-CBbYIcmk.js → BossLogsModal-CsjhF9hQ.js} +1 -1
- package/dist/assets/{BossSpawnModal-mqO0bqI3.js → BossSpawnModal-DRgrZpYr.js} +1 -1
- package/dist/assets/{ControlsModal-DRWAndqm.js → ControlsModal-zYwhMaaL.js} +1 -1
- package/dist/assets/{DockerLogsModal-Catj2vnw.js → DockerLogsModal-D7bewBqJ.js} +1 -1
- package/dist/assets/{EmbeddedEditor-DrU-0mcv.js → EmbeddedEditor-IxYwI5JV.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-ClH4Ti8M.js → GmailOAuthSetup-CfOuUZnu.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-DzEW1VPc.js → GoogleOAuthSetup-Cw1tGSti.js} +1 -1
- package/dist/assets/{IframeModal-DI2I97DN.js → IframeModal-Bi8MNGZY.js} +1 -1
- package/dist/assets/{IntegrationsPanel-uBgaeaN4.js → IntegrationsPanel-01iVXM-l.js} +2 -2
- package/dist/assets/{LogViewerModal-DEk6a3MU.js → LogViewerModal-BXhxgz7Z.js} +1 -1
- package/dist/assets/{MonitoringModal-CW1pJX2H.js → MonitoringModal-Gf0AkCEl.js} +1 -1
- package/dist/assets/{PM2LogsModal-D63l1i7M.js → PM2LogsModal-BfoL_mEK.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-BJJgrCY1.js → RestoreArchivedAreaModal-Ctss__a9.js} +1 -1
- package/dist/assets/{Scene2DCanvas-Dz0w5m9M.js → Scene2DCanvas-BuCW0Zaw.js} +1 -1
- package/dist/assets/{SceneManager-BT7VCD1K.js → SceneManager-BFnKKU1I.js} +1 -1
- package/dist/assets/{SkillsPanel-CHVpVb_S.js → SkillsPanel-D7kJE7eT.js} +1 -1
- package/dist/assets/{SlackMultiInstanceSetup-C6hbDYF8.js → SlackMultiInstanceSetup-Hp7r3YK0.js} +1 -1
- package/dist/assets/{SpawnModal-DeVjD40h.js → SpawnModal-Dq9P-FdI.js} +1 -1
- package/dist/assets/{StatisticsModal-BqfqHv59.js → StatisticsModal-BQOkmrmY.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-O4Z7Cz9Z.js → SubordinateAssignmentModal-D2-IpRLn.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-D3naOIKU.js → TriggerManagerPanel-BCZhLuoZ.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-BwEje9F2.js → WorkflowEditorPanel-BEjublaK.js} +1 -1
- package/dist/assets/{abnfDiagram-VRR7QNED-BnX9M_l1.js → abnfDiagram-VRR7QNED-jjWEEISc.js} +1 -1
- package/dist/assets/{arc-B98XIPkA.js → arc-xqT5-bwQ.js} +1 -1
- package/dist/assets/{architectureDiagram-ZJ3FMSHR-z0p1zeVp.js → architectureDiagram-ZJ3FMSHR-BXEbOurL.js} +1 -1
- package/dist/assets/{area-logos-BlHb9N60.js → area-logos-BH-HM2a-.js} +1 -1
- package/dist/assets/{blockDiagram-677ZJIJ3-BWTjM4OP.js → blockDiagram-677ZJIJ3-D-0HVLDv.js} +1 -1
- package/dist/assets/{c4Diagram-LMCZKHZV-BN-RLbsx.js → c4Diagram-LMCZKHZV-BK39PXfT.js} +1 -1
- package/dist/assets/channel-BgBFpxsT.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-J8czO6cK.js → chunk-2Q5K7J3B-CuW4NYbO.js} +1 -1
- package/dist/assets/{chunk-32BRIVSS-DcjMRNYF.js → chunk-32BRIVSS-eJLo7W-b.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-Crw64l4u.js → chunk-5VM5RSS4-E2Yaai0b.js} +1 -1
- package/dist/assets/{chunk-EX3LRPZG-B5Lsva5g.js → chunk-EX3LRPZG-9uAbQnMb.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-CTg-i7tl.js → chunk-JWPE2WC7-kKtXyMkv.js} +1 -1
- package/dist/assets/{chunk-MOJQB5TN-CTA3M-fz.js → chunk-MOJQB5TN-DPN5ReJ7.js} +1 -1
- package/dist/assets/{chunk-RYQCIY6F-DGSloSAP.js → chunk-RYQCIY6F-d3yFo4Hu.js} +1 -1
- package/dist/assets/{chunk-V7JOEXUC-Kl0jzqRs.js → chunk-V7JOEXUC--3A8oVa7.js} +1 -1
- package/dist/assets/{chunk-VR4S4FIN-DUBYW8P6.js → chunk-VR4S4FIN-KpHuZy9_.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-CKd0SGRp.js → chunk-XXDRQBXY-hpU30gZQ.js} +1 -1
- package/dist/assets/classDiagram-OUVF2IWQ-CXHgnAgF.js +1 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-CXHgnAgF.js +1 -0
- package/dist/assets/{cose-bilkent-JH36ORCC-Bx7FzDmP.js → cose-bilkent-JH36ORCC-DOhYmYxe.js} +1 -1
- package/dist/assets/{cynefin-VYW2F7L2-D_802RhG.js → cynefin-VYW2F7L2-UDH0NYTi.js} +1 -1
- package/dist/assets/{cynefinDiagram-TSTJHNR4-DvV0UVdX.js → cynefinDiagram-TSTJHNR4-DnGUiXaD.js} +1 -1
- package/dist/assets/{dagre-VKFMJZFB-DmwiPoSS.js → dagre-VKFMJZFB-BQ6C_GWY.js} +1 -1
- package/dist/assets/{diagram-FQU43EPY-BoB63t2v.js → diagram-FQU43EPY-CREz1035.js} +1 -1
- package/dist/assets/{diagram-G47NLZAW-ePwVyPPx.js → diagram-G47NLZAW-9Jr7GbsE.js} +1 -1
- package/dist/assets/{diagram-NH7WQ7WH-93SgaDsB.js → diagram-NH7WQ7WH-DtN5x74X.js} +1 -1
- package/dist/assets/{diagram-OA4YK3LP-Duv0bz9_.js → diagram-OA4YK3LP-UuOi8FAP.js} +1 -1
- package/dist/assets/{diagram-WEI45ONY-D_gBmxsF.js → diagram-WEI45ONY-CWiUGHfM.js} +1 -1
- package/dist/assets/{ebnfDiagram-CCIWWBDH-DmCjLqB8.js → ebnfDiagram-CCIWWBDH-3eMfQx1G.js} +1 -1
- package/dist/assets/{erDiagram-Q63AITRT-C7DVczCi.js → erDiagram-Q63AITRT-DYzSgp8n.js} +1 -1
- package/dist/assets/{flowDiagram-23GEKE2U-CntlTJhB.js → flowDiagram-23GEKE2U-DBLDGx8O.js} +1 -1
- package/dist/assets/{ganttDiagram-NO4QXBWP-BJaP3f8c.js → ganttDiagram-NO4QXBWP-Dv7Uyp2U.js} +1 -1
- package/dist/assets/{gitGraphDiagram-IHSO6WYX-sXbdlVf7.js → gitGraphDiagram-IHSO6WYX-leeHrOrC.js} +1 -1
- package/dist/assets/index-Bnk8mX62.js +2 -0
- package/dist/assets/{index-DoGCnLY7.js → index-BrN1fSea.js} +1 -1
- package/dist/assets/{index-SgBYac_x.js → index-CFiAyn9P.js} +3 -3
- package/dist/assets/{index-DjKhiPyo.js → index-Cpf2LUXa.js} +1 -1
- package/dist/assets/{index-DcbMrq45.js → index-CtGcfchE.js} +1 -1
- package/dist/assets/{index-CEVxHO1l.js → index-DY2LUL1D.js} +1 -1
- package/dist/assets/{index-CphBmiCu.js → index-fP8UTiVP.js} +2 -2
- package/dist/assets/index-jlRDILHc.js +1 -0
- package/dist/assets/{index-DCi30YpP.js → index-lHF2zw41.js} +1 -1
- package/dist/assets/{infoDiagram-FWYZ7A6U-CJv_LwPw.js → infoDiagram-FWYZ7A6U-B23FL64X.js} +1 -1
- package/dist/assets/{ishikawaDiagram-FXEZZL3T-DFA-gmAE.js → ishikawaDiagram-FXEZZL3T-BPsjNXWV.js} +1 -1
- package/dist/assets/{journeyDiagram-5HDEW3XC-g34VUhUW.js → journeyDiagram-5HDEW3XC-3jqJYemY.js} +1 -1
- package/dist/assets/{kanban-definition-HUTT4EX6-BSLcy8ss.js → kanban-definition-HUTT4EX6-rHfIfWqi.js} +1 -1
- package/dist/assets/{linear-CJ2gmqDn.js → linear-CvofFTBe.js} +1 -1
- package/dist/assets/main-CZA5Uyu6.css +1 -0
- package/dist/assets/{main-BJyKMAws.js → main-ts-uUN3p.js} +140 -140
- package/dist/assets/{mermaid.core-B2NKK92f.js → mermaid.core-BuuQCwr7.js} +4 -4
- package/dist/assets/{mindmap-definition-LN4V7U3C-DZ_fS0Zl.js → mindmap-definition-LN4V7U3C-CdMbsouS.js} +1 -1
- package/dist/assets/{pegDiagram-2B236MQR-B6Ne9z7p.js → pegDiagram-2B236MQR-Cl7drnf-.js} +1 -1
- package/dist/assets/{pieDiagram-ENE6RG2P-BImcUdhE.js → pieDiagram-ENE6RG2P-CrfvJw6b.js} +1 -1
- package/dist/assets/{quadrantDiagram-ABIIQ3AL-D7-GQD5e.js → quadrantDiagram-ABIIQ3AL-D6Z7VqX6.js} +1 -1
- package/dist/assets/{railroadDiagram-RFXS5EU6-BYjxxvCx.js → railroadDiagram-RFXS5EU6-DBhqTpwY.js} +1 -1
- package/dist/assets/{requirementDiagram-TGXJPOKE-CiOTbB25.js → requirementDiagram-TGXJPOKE-DjYygiNl.js} +1 -1
- package/dist/assets/{sankeyDiagram-HTMAVEWB-C4Rbu3Sv.js → sankeyDiagram-HTMAVEWB-Cb8su5H6.js} +1 -1
- package/dist/assets/{sequenceDiagram-DBY2YBRQ-DEABSAV_.js → sequenceDiagram-DBY2YBRQ-DH326uFa.js} +1 -1
- package/dist/assets/{sizeCapture-X5ZJPWSS-CZBA_W2b.js → sizeCapture-X5ZJPWSS-BA-8zei3.js} +1 -1
- package/dist/assets/{stateDiagram-2N3HPSRC-BHLbOxTQ.js → stateDiagram-2N3HPSRC-DM412fD5.js} +1 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-BZJwjeVk.js +1 -0
- package/dist/assets/{swimlanes-5IMT3BWC-CJjOKChv.js → swimlanes-5IMT3BWC-BouPQ02z.js} +2 -2
- package/dist/assets/swimlanesDiagram-G3AALYLV-BRQaNmpd.js +8 -0
- package/dist/assets/{timeline-definition-FHXFAJF6-DoXmI-Kj.js → timeline-definition-FHXFAJF6-CHbeQn6a.js} +1 -1
- package/dist/assets/{vennDiagram-L72KCM5P-C-YtoSnj.js → vennDiagram-L72KCM5P-HSzYjTi7.js} +1 -1
- package/dist/assets/{wardleyDiagram-EHGQE667-BPF7gIEN.js → wardleyDiagram-EHGQE667-DvrdmzxK.js} +1 -1
- package/dist/assets/{web-D8JEI42A.js → web-BvtZvOK9.js} +1 -1
- package/dist/assets/{web-3UvoGn6w.js → web-DT7q-yw_.js} +1 -1
- package/dist/assets/{web-DX9ZsjGf.js → web-DwD7eqxR.js} +1 -1
- package/dist/assets/{xychartDiagram-FW5EYKEG-DU_V6gS6.js → xychartDiagram-FW5EYKEG-DgSgkHvg.js} +1 -1
- package/dist/build-info.json +1 -1
- package/dist/index.html +2 -2
- package/dist/src/packages/server/claude/backend.js +75 -11
- package/dist/src/packages/server/routes/custom-sounds.js +170 -0
- package/dist/src/packages/server/routes/index.js +2 -0
- package/dist/src/packages/server/services/runtime-events.js +29 -1
- package/dist/src/packages/server/websocket/handlers/command-handler.js +13 -0
- package/package.json +1 -1
- package/dist/assets/channel-_aXjvsrM.js +0 -1
- package/dist/assets/classDiagram-OUVF2IWQ-C3mw035V.js +0 -1
- package/dist/assets/classDiagram-v2-EOCWNBFH-C3mw035V.js +0 -1
- package/dist/assets/index-D-ukGa4L.js +0 -2
- package/dist/assets/index-DHHWZZzJ.js +0 -1
- package/dist/assets/main-h6n299s0.css +0 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-QKyiJ7_J.js +0 -1
- package/dist/assets/swimlanesDiagram-G3AALYLV-czrVdfrM.js +0 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as l,j as e,I,u as Z,b$ as js,ad as vs,c0 as Ds,c2 as Fs,s as k,cF as Rs,F as zs,cG as Bs,X as je,K as ee,aR as Q,c as de,d as ue,cH as Ms,cI as Us,cJ as Vs,cK as Ks,cL as Hs,cM as qs,cN as Ws,cO as ys,cP as Gs,cQ as Ys,cR as Js,aQ as Xs,an as Zs,a2 as $e,n as Qs,cS as ws,cT as et,cU as es,cV as st,cW as tt,cX as at,cY as nt,cZ as it,c_ as ot,c$ as lt,bj as ct,k as rt,m as dt,S as _e,d0 as ut,d1 as pt,d2 as mt,d3 as Ge,d4 as ht,d5 as gt,B as ft,d6 as xt,d7 as bt,d8 as jt,d9 as vt,da as Ns,db as rs,dc as ks,dd as yt,de as wt,df as Ie,dg as Nt,dh as Ye,di as ds,bX as Je,w as ze,v as kt,dj as Xe,dk as St,dl as Ct,dm as At,dn as Tt,_ as Et,f as Pt,dp as _t,dq as It,dr as $t}from"./main-ts-uUN3p.js";import{g as Ot,d as Lt,u as Dt}from"./area-logos-BH-HM2a-.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.js";const Ss="tide-toolbox-collapse";function Ft(s,a){try{const t=localStorage.getItem(`${Ss}-${s}`);if(t!==null)return t==="true"}catch{}return a}function Rt(s,a){try{localStorage.setItem(`${Ss}-${s}`,String(a))}catch{}}function G({title:s,storageKey:a,defaultOpen:t=!1,forceOpen:o=!1,children:c,headerExtra:r}){const[d,f]=l.useState(()=>a?Ft(a,t):t),i=()=>{const N=!d;f(N),a&&Rt(a,N)},u=o||d;return e.jsxs("div",{className:`collapsible-section ${u?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:i,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[r,e.jsx("span",{className:"collapsible-arrow",children:e.jsx(I,{name:u?"caret-down":"caret-right",size:10})})]})]}),u&&e.jsx("div",{className:"collapsible-content",children:c})]})}function zt({area:s,isSelected:a,onClick:t,onDelete:o}){const{t:c}=Z(["config","common"]),r=s.assignedAgentIds.length,d=s.type==="rectangle"?c("config:areas.rect"):c("config:areas.circle");return e.jsxs("div",{className:`area-item ${a?"selected":""}`,onClick:t,children:[e.jsx("div",{className:"area-color-dot",style:{backgroundColor:s.color}}),e.jsxs("div",{className:"area-info",children:[e.jsx("div",{className:"area-name",children:s.name}),e.jsxs("div",{className:"area-meta",children:[d," ",r>0&&`• ${r} ${r>1?c("common:labels.agents").toLowerCase():c("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:c("config:areas.deleteArea"),children:"×"})]})}function Bt({building:s,isSelected:a,onClick:t,onEdit:o}){var f;const{t:c}=Z(["config"]),r=((f=s.pm2Status)==null?void 0:f.ports)||[],d=(i,u)=>{i.stopPropagation(),window.open(`http://${window.location.hostname}:${u}`,"_blank")};return e.jsxs("div",{className:`building-item ${a?"selected":""}`,onClick:t,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:js[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx(I,{name:vs(s.type),size:16})}),e.jsxs("div",{className:"building-info",children:[e.jsx("div",{className:"building-name",children:s.name}),e.jsxs("div",{className:"building-meta",children:[s.type,r.length>0&&e.jsx("span",{className:"building-ports",children:r.map(i=>e.jsxs("a",{href:`http://${window.location.hostname}:${i}`,className:"building-port-link",onClick:u=>d(u,i),title:`Open :${i}`,children:[":",i]},i))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:i=>{i.stopPropagation(),o()},title:c("config:buildings.editBuilding"),children:e.jsx(I,{name:"gear",size:14})})]})}function Mt({building:s,onClose:a,onOpenModal:t}){var u,N,j,g,T,y,E,v;const{t:o}=Z(["config","common"]),r=Ds().get(s.id)||[],d=Fs[s.style||"server-rack"],f=p=>{k.sendBuildingCommand(s.id,p)},i=p=>{window.open(p,"_blank")};return e.jsxs("div",{className:"building-editor",children:[e.jsxs("div",{className:"building-editor-header",children:[e.jsxs("div",{className:"building-editor-title-row",children:[e.jsx("span",{className:"building-editor-icon",children:e.jsx(I,{name:vs(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:js[s.status]},children:s.status})]}),e.jsx("button",{className:"building-editor-close",onClick:a,children:"×"})]}),e.jsx("div",{className:"building-editor-section",children:e.jsxs("div",{className:"building-editor-info-grid",children:[e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("common:labels.type")}),e.jsx("span",{className:"building-editor-info-value",children:s.type})]}),e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.style")}),e.jsx("span",{className:"building-editor-info-value",children:d.label})]}),s.cwd&&e.jsxs("div",{className:"building-editor-info-item building-editor-info-wide",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.directory")}),e.jsx("span",{className:"building-editor-info-value building-editor-cwd",title:s.cwd,children:s.cwd.split("/").pop()||s.cwd})]})]})}),s.type==="server"&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.actions")}),e.jsxs("div",{className:"building-editor-actions",children:[e.jsxs("button",{className:"building-editor-action-btn start",onClick:()=>f("start"),disabled:!((u=s.commands)!=null&&u.start)||s.status==="running",title:((N=s.commands)==null?void 0:N.start)||o("config:buildings.noStartCommand"),children:[e.jsx(I,{name:"play",size:12})," ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>f("stop"),disabled:!((j=s.commands)!=null&&j.stop)||s.status==="stopped",title:((g=s.commands)==null?void 0:g.stop)||o("config:buildings.noStopCommand"),children:[e.jsx(I,{name:"stop",size:12,weight:"fill"})," ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>f("restart"),disabled:!((T=s.commands)!=null&&T.restart),title:((y=s.commands)==null?void 0:y.restart)||o("config:buildings.noRestartCommand"),children:[e.jsx(I,{name:"refresh",size:12})," ",o("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>f("healthCheck"),disabled:!((E=s.commands)!=null&&E.healthCheck),title:((v=s.commands)==null?void 0:v.healthCheck)||o("config:buildings.noHealthCheck"),children:[e.jsx(I,{name:"heart",size:12})," Health"]})]})]}),s.urls&&s.urls.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((p,S)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>i(p.url),title:p.url,children:[e.jsx(I,{name:"link",size:12})," ",p.label||p.url]},S))})]}),r.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsxs("div",{className:"building-editor-section-title",children:[o("config:buildings.recentLogs"),e.jsx("button",{className:"building-editor-clear-logs",onClick:()=>k.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:r.slice(-5).map((p,S)=>e.jsx("div",{className:"building-editor-log-entry",children:p},S))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:t,children:[e.jsx(I,{name:"gear",size:12})," ",o("config:buildings.fullSettings")]})})]})}const Ut=[{key:"center",labelKey:"posCenter"},{key:"top-left",labelKey:"posTopLeft"},{key:"top-right",labelKey:"posTopRight"},{key:"bottom-left",labelKey:"posBottomLeft"},{key:"bottom-right",labelKey:"posBottomRight"}];function Vt({area:s,onClose:a,onOpenFolder:t}){var te;const{t:o}=Z(["config","common"]),[c,r]=l.useState(s.name),[d,f]=l.useState(s.prompt||""),[i,u]=l.useState(!1),[N,j]=l.useState(""),[g,T]=l.useState(!1),y=l.useRef(null);l.useEffect(()=>{r(s.name)},[s.id,s.name]),l.useEffect(()=>{f(s.prompt||"")},[s.id,s.prompt]);const E=w=>{const D=w.target.value;r(D),k.updateArea(s.id,{name:D})},v=w=>{k.updateArea(s.id,{color:w})},p=w=>{const D=w.target.value;f(D),k.updateArea(s.id,{prompt:D})},S=()=>{N.trim()&&(k.addDirectoryToArea(s.id,N.trim()),j(""),u(!1))},F=(w,D)=>{D.stopPropagation(),k.removeDirectoryFromArea(s.id,w)},R=()=>{k.bringAreaToFront(s.id)},q=()=>{k.sendAreaToBack(s.id)},W=l.useCallback(()=>{let w=2,D=2;s.type==="rectangle"&&s.width&&s.height?(w=s.width,D=s.height):s.type==="circle"&&s.radius&&(w=s.radius*1.414,D=s.radius*1.414);const B=Math.min(w,D)*.4;return{width:Math.round(B*10)/10,height:Math.round(B*10)/10}},[s.type,s.width,s.height,s.radius]),Y=async w=>{var B;const D=(B=w.target.files)==null?void 0:B[0];if(D){T(!0);try{const m=await Dt(s.id,D),x=W();k.updateArea(s.id,{logo:{filename:m.filename,position:"center",width:x.width,height:x.height,keepAspectRatio:!0,opacity:.8}})}catch(m){console.error("Failed to upload logo:",m)}finally{T(!1),y.current&&(y.current.value="")}}},M=async()=>{try{await Lt(s.id),k.updateArea(s.id,{logo:void 0})}catch(w){console.error("Failed to remove logo:",w)}},U=w=>{s.logo&&k.updateArea(s.id,{logo:{...s.logo,position:w}})},h=w=>{if(!s.logo)return;const D=parseFloat(w.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const B=s.logo.height/s.logo.width;k.updateArea(s.id,{logo:{...s.logo,width:D,height:Math.round(D*B*10)/10}})}else k.updateArea(s.id,{logo:{...s.logo,width:D}})},O=w=>{if(!s.logo)return;const D=parseFloat(w.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const B=s.logo.width/s.logo.height;k.updateArea(s.id,{logo:{...s.logo,height:D,width:Math.round(D*B*10)/10}})}else k.updateArea(s.id,{logo:{...s.logo,height:D}})},z=()=>{s.logo&&k.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},K=w=>{s.logo&&k.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(w.target.value)}})};return e.jsxs("div",{className:"area-editor",children:[e.jsxs("div",{className:"area-editor-header",children:[e.jsx("span",{className:"area-editor-title",children:o("config:areas.editArea")}),e.jsx("button",{className:"area-editor-close",onClick:a,children:"×"})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("common:labels.name")}),e.jsx("input",{type:"text",className:"area-editor-input",value:c,onChange:E,placeholder:o("config:areas.areaName")})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.color")}),e.jsx("div",{className:"color-picker-row",children:Rs.map(w=>e.jsx("button",{type:"button",className:`color-swatch ${s.color===w?"selected":""}`,style:{backgroundColor:w},onClick:()=>v(w),"aria-label":`Set area color ${w}`,"aria-pressed":s.color===w,title:w},w))})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.layer")}),e.jsxs("div",{className:"area-layer-buttons",children:[e.jsxs("button",{className:"area-layer-btn",onClick:R,title:o("config:areas.bringToFront"),children:[e.jsx(I,{name:"arrow-up",size:12})," ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:q,title:o("config:areas.sendToBack"),children:[e.jsx(I,{name:"arrow-down",size:12})," ",o("config:areas.back")]})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(te=s.logo)!=null&&te.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:Ot(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:M,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var w;return(w=y.current)==null?void 0:w.click()},disabled:g,children:g?"...":e.jsx(I,{name:"refresh",size:12})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:Ut.map(({key:w,labelKey:D})=>{var B;return e.jsx("button",{className:`area-logo-pos-btn ${((B=s.logo)==null?void 0:B.position)===w?"active":""}`,onClick:()=>U(w),children:o(`config:areas.${D}`)},w)})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoSize")}),e.jsxs("div",{className:"area-logo-size-row",children:[e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoWidth")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.width,onChange:h,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoHeight")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.height,onChange:O,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-aspect-label",title:o("config:areas.keepAspectRatio"),children:[e.jsx("input",{type:"checkbox",checked:s.logo.keepAspectRatio,onChange:z}),o("config:areas.keepAspectRatio")]})]})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoOpacity")}),e.jsxs("div",{className:"area-logo-opacity-row",children:[e.jsx("input",{type:"range",min:0,max:1,step:.05,value:s.logo.opacity??.8,onChange:K,className:"area-logo-opacity-slider"}),e.jsxs("span",{className:"area-logo-opacity-value",children:[Math.round((s.logo.opacity??.8)*100),"%"]})]})]})]}):e.jsx("button",{className:"area-logo-upload-btn",onClick:()=>{var w;return(w=y.current)==null?void 0:w.click()},disabled:g,children:g?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:y,type:"file",accept:"image/*",style:{display:"none"},onChange:Y})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.folders",{count:s.directories.length})}),e.jsxs("div",{className:"area-folders-list",children:[s.directories.map(w=>e.jsxs("div",{className:"area-folder-item",title:w,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>t==null?void 0:t(s.id),title:o("config:areas.openFolder"),children:e.jsx(I,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:w.split("/").pop()||w}),e.jsx("button",{className:"area-folder-remove",onClick:D=>F(w,D),title:o("config:areas.removeFolder"),children:"×"})]},w)),i?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(zs,{value:N,onChange:j,onSubmit:S,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:S,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>u(!0),children:o("config:areas.addFolder")})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.prompt","Prompt")}),e.jsx("textarea",{className:"area-editor-input",value:d,onChange:p,placeholder:o("config:areas.promptPlaceholder","System prompt for agents in this area..."),rows:4,style:{resize:"vertical",fontFamily:"monospace",fontSize:12}}),e.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4},children:o("config:areas.promptHint","This prompt is injected into agents assigned to this area. Takes effect on next context refresh.")})]}),s.assignedAgentIds.length>0&&e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.assignedAgents",{count:s.assignedAgentIds.length})}),e.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:o("config:areas.rightClickUnassign")})]})]})}function Kt(){const{t:s}=Z(["config","common"]),a=Bs(),[t,o]=l.useState(!1),[c,r]=l.useState(null),[d,f]=l.useState({name:"",key:"",value:"",description:""}),[i,u]=l.useState(null),N=()=>{o(!0),r(null),f({name:"",key:"",value:"",description:""})},j=p=>{r(p.id),o(!1),f({name:p.name,key:p.key,value:p.value,description:p.description||""})},g=()=>{o(!1),r(null),f({name:"",key:"",value:"",description:""})},T=()=>{!d.name.trim()||!d.key.trim()||(c?k.updateSecret(c,{name:d.name.trim(),key:d.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:d.value,description:d.description.trim()||void 0}):k.createSecret({name:d.name.trim(),key:d.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:d.value,description:d.description.trim()||void 0}),g())},y=p=>{u(p)},E=()=>{i&&(k.deleteSecret(i),c===i&&g())},v=p=>{navigator.clipboard.writeText(`{{${p}}}`)};return e.jsxs("div",{className:"secrets-section",children:[e.jsx("div",{className:"secrets-description",children:s("config:secrets.description",{placeholder:"{{KEY}}"})}),e.jsx("div",{className:"secrets-list",children:a.length===0&&!t?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):a.map(p=>e.jsxs("div",{className:`secret-item ${c===p.id?"editing":""}`,children:[e.jsxs("div",{className:"secret-item-header",children:[e.jsxs("div",{className:"secret-item-info",children:[e.jsx("span",{className:"secret-item-name",children:p.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>v(p.key),title:s("config:secrets.copyPlaceholder"),children:`{{${p.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>j(p),title:s("common:buttons.edit"),children:e.jsx(I,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>y(p.id),title:s("common:buttons.delete"),children:"×"})]})]}),p.description&&e.jsx("div",{className:"secret-item-description",children:p.description})]},p.id))}),(t||c)&&e.jsxs("div",{className:"secret-form",children:[e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.name")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.namePlaceholder"),value:d.name,onChange:p=>f({...d,name:p.target.value}),autoFocus:!0})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:"Key"}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.keyPlaceholder"),value:d.key,onChange:p=>f({...d,key:p.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${d.key||"KEY"}}}`})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("config:secrets.secretValue")}),e.jsx("input",{type:"password",className:"secret-form-input",placeholder:s("config:secrets.valuePlaceholder"),value:d.value,onChange:p=>f({...d,value:p.target.value})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.description")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.descriptionPlaceholder"),value:d.description,onChange:p=>f({...d,description:p.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:g,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:T,disabled:!d.name.trim()||!d.key.trim(),children:s(c?"config:secrets.update":"common:buttons.add")})]})]}),!t&&!c&&e.jsx("button",{className:"secrets-add-btn",onClick:N,children:s("config:secrets.addSecret")}),e.jsx(je,{isOpen:i!==null,title:s("common:buttons.delete"),message:s("config:secrets.deleteConfirm"),confirmLabel:s("common:buttons.delete"),cancelLabel:s("common:buttons.cancel"),variant:"danger",onConfirm:E,onClose:()=>u(null)})]})}async function Ht(){const s=ee(),a=await fetch(`${Q()}/api/agents/system-settings/prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch system prompt: ${a.statusText}`);return(await a.json()).prompt||""}async function qt(s){const a=ee(),t=await fetch(`${Q()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({prompt:s})});if(!t.ok)throw new Error(`Failed to update system prompt: ${t.statusText}`)}async function Wt(){const s=ee(),a=await fetch(`${Q()}/api/agents/system-settings/prompt`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to clear system prompt: ${a.statusText}`)}async function Gt(){const s=ee(),a=await fetch(`${Q()}/api/agents/system-settings/echo-prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch echo prompt setting: ${a.statusText}`);return(await a.json()).enabled||!1}async function Yt(s){const a=ee(),t=await fetch(`${Q()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({enabled:s})});if(!t.ok)throw new Error(`Failed to update echo prompt setting: ${t.statusText}`)}async function Jt(){const s=ee(),a=await fetch(`${Q()}/api/agents/system-settings/codex-binary`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch codex binary path: ${a.statusText}`);return(await a.json()).path||""}async function Xt(s){const a=ee(),t=await fetch(`${Q()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({path:s})});if(!t.ok)throw new Error(`Failed to update codex binary path: ${t.statusText}`)}async function Zt(){const s=ee(),a=await fetch(`${Q()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch tmux mode setting: ${a.statusText}`);return(await a.json()).enabled||!1}async function Qt(s){const a=ee(),t=await fetch(`${Q()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({enabled:s})});if(!t.ok)throw new Error(`Failed to update tmux mode setting: ${t.statusText}`)}async function ea(){const s=ee(),a=await fetch(`${Q()}/api/agents/system-settings/interactive-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch interactive mode setting: ${a.statusText}`);return(await a.json()).enabled||!1}async function sa(s){const a=ee(),t=await fetch(`${Q()}/api/agents/system-settings/interactive-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({enabled:s})});if(!t.ok)throw new Error(`Failed to update interactive mode setting: ${t.statusText}`)}async function ta(){const s=ee(),a=await fetch(`${Q()}/api/agents/system-settings/codex-app-server-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch codex app-server mode setting: ${a.statusText}`);return(await a.json()).enabled||!1}async function aa(s){const a=ee(),t=await fetch(`${Q()}/api/agents/system-settings/codex-app-server-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({enabled:s})});if(!t.ok)throw new Error(`Failed to update codex app-server mode setting: ${t.statusText}`)}async function na(){const s=ee(),a=await fetch(`${Q()}/api/agents/system-settings/opencode-server-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch opencode server mode setting: ${a.statusText}`);return(await a.json()).enabled||!1}async function ia(s){const a=ee(),t=await fetch(`${Q()}/api/agents/system-settings/opencode-server-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({enabled:s})});if(!t.ok)throw new Error(`Failed to update opencode server mode setting: ${t.statusText}`)}async function oa(){const s=ee(),a=await fetch(`${Q()}/api/agents/system-settings/backup`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch backup status: ${a.statusText}`);return a.json()}async function la(s){const a=ee(),t=await fetch(`${Q()}/api/agents/system-settings/backup`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({enabled:s})});if(!t.ok){const o=await t.json().catch(()=>({}));throw new Error(o.error||`Failed to update backup setting: ${t.statusText}`)}return t.json()}function ca({checked:s,onChange:a,disabled:t}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,disabled:t,onChange:o=>a(o.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function ra(){const{t:s}=Z(["config","common"]),[a,t]=l.useState([]),[o,c]=l.useState(new Set),[r,d]=l.useState(new Set),[f,i]=l.useState(!1),[u,N]=l.useState(!1),[j,g]=l.useState(null),[T,y]=l.useState(null),[E,v]=l.useState(null),[p,S]=l.useState(null),[F,R]=l.useState(!1),[q,W]=l.useState(null);l.useEffect(()=>{de(ue("/api/config/categories")).then(m=>m.json()).then(m=>{const x=Array.isArray(m)?m:[];t(x),c(new Set(x.map(L=>L.id)))}).catch(m=>console.error("Failed to fetch config categories:",m))},[]),l.useEffect(()=>{oa().then(S).catch(m=>{console.error("Failed to fetch backup status:",m),W(m.message||"Failed to fetch backup status")})},[]);const Y=async m=>{if(!F){R(!0),W(null);try{const x=await la(m);S(x)}catch(x){W(x.message||"Failed to update backup setting")}finally{R(!1)}}},M=m=>{c(x=>{const L=new Set(x);return L.has(m)?L.delete(m):L.add(m),L})},U=m=>{d(x=>{const L=new Set(x);return L.has(m)?L.delete(m):L.add(m),L})},h=()=>c(new Set(a.map(m=>m.id))),O=()=>c(new Set),z=()=>{T&&d(new Set(T.categories.map(m=>m.id)))},K=()=>d(new Set),te=async()=>{var m;if(o.size!==0){i(!0),v(null);try{const x=Array.from(o).join(","),L=await de(ue(`/api/config/export?categories=${x}`));if(!L.ok)throw new Error("Export failed");const J=await L.blob(),ne=window.URL.createObjectURL(J),_=document.createElement("a");_.href=ne;const C=L.headers.get("Content-Disposition"),ae=((m=C==null?void 0:C.match(/filename="(.+)"/))==null?void 0:m[1])||"tide-commander-config.zip";_.download=ae,document.body.appendChild(_),_.click(),document.body.removeChild(_),window.URL.revokeObjectURL(ne),v({type:"success",text:s("config:data.exportSuccess")})}catch(x){v({type:"error",text:x.message||"Export failed"})}finally{i(!1)}}},w=async m=>{var L;const x=(L=m.target.files)==null?void 0:L[0];if(x){g(x),v(null),y(null),d(new Set);try{const J=await de(ue("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await x.arrayBuffer()});if(!J.ok){const C=await J.json();throw new Error(C.error||"Failed to preview config file")}const ne=await J.json(),_=Array.isArray(ne.categories)?ne.categories:[];y({...ne,categories:_}),d(new Set(_.map(C=>C.id)))}catch(J){v({type:"error",text:J.message||"Failed to read config file"}),g(null)}}},D=async()=>{if(!(!j||r.size===0)){N(!0),v(null);try{const m=Array.from(r).join(","),x=await de(ue(`/api/config/import?categories=${m}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await j.arrayBuffer()}),L=await x.json();if(!x.ok)throw new Error(L.error||"Import failed");v({type:"success",text:L.message||s("config:data.importSuccess")}),g(null),y(null),d(new Set)}catch(m){v({type:"error",text:m.message||"Import failed"})}finally{N(!1)}}},B=()=>{g(null),y(null),d(new Set),v(null)};return e.jsxs("div",{className:"data-section",children:[E&&e.jsx("div",{className:`data-message data-message-${E.type}`,children:E.text}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:"Hourly Backups"}),e.jsx(ca,{checked:!!(p!=null&&p.enabled),disabled:F||!p,onChange:Y})]}),e.jsxs("div",{className:"data-backup-info",children:[p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Saves a compressed snapshot of your data every hour to"," ",e.jsx("code",{children:p.backupDir}),". Identical snapshots are skipped. Keeps the 8 newest plus one from each of the 2 most recent prior days."]}),!p.scriptExists&&e.jsxs("div",{style:{marginTop:6,color:"var(--dracula-red, #ff5555)"},children:["Backup script not found at ",e.jsx("code",{children:p.scriptPath})]}),p.lastRunAt&&e.jsxs("div",{style:{marginTop:6},children:["Last run: ",new Date(p.lastRunAt).toLocaleString(),p.lastRunOk===!0&&" — ok",p.lastRunOk===!1&&p.lastRunError&&e.jsxs("span",{style:{color:"var(--dracula-red, #ff5555)"},children:[" — ",p.lastRunError]})]})]}):e.jsx("div",{children:"Loading backup status…"}),q&&e.jsx("div",{className:"data-message data-message-error",style:{marginTop:6},children:q})]})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:s("config:data.exportData")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:h,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:O,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:a.map(m=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(m.id),onChange:()=>M(m.id)}),e.jsx("span",{className:"data-category-name",children:m.name})]},m.id))}),e.jsx("button",{className:"data-action-btn export",onClick:te,disabled:f||o.size===0,children:f?s("config:data.exporting"):s("config:data.exportCount",{count:o.size})})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsx("div",{className:"data-subsection-header",children:e.jsx("span",{className:"data-subsection-title",children:s("config:data.importData")})}),j?T?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:j.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(T.exportedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-subtitle",children:s("config:data.selectToImport")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:z,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:K,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:T.categories.map(m=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:r.has(m.id),onChange:()=>U(m.id)}),e.jsx("span",{className:"data-category-name",children:m.name}),m.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",m.fileCount," ",s("config:data.files"),")"]})]},m.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:B,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:D,disabled:u||r.size===0,children:u?s("config:data.importing"):s("config:data.importCount",{count:r.size})})]})]}):e.jsx("div",{className:"data-loading",children:s("config:data.readingFile")}):e.jsxs("label",{className:"data-file-input",children:[e.jsx("input",{type:"file",accept:".zip",onChange:w,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}function da(){const[s,a]=l.useState(()=>Ms()),t=o=>{a(o);const c=Hs(o);qs(c)};return e.jsx("div",{className:"theme-selector",children:e.jsx("div",{className:"theme-selector-grid",children:Us.map(o=>e.jsxs("button",{className:`theme-option ${s===o.id?"active":""}`,onClick:()=>t(o.id),title:o.description,children:[e.jsx("div",{className:"theme-preview",children:e.jsxs("div",{className:"theme-preview-bg",style:{backgroundColor:o.colors.bgPrimary},children:[e.jsx("div",{className:"theme-preview-accent",style:{backgroundColor:o.colors.accentBlue}}),e.jsx("div",{className:"theme-preview-claude",style:{backgroundColor:o.colors.accentClaude}})]})}),e.jsx("span",{className:"theme-name",children:o.name})]},o.id))})})}function ua(){const{t:s}=Z(["config"]),{installInfo:a,phase:t,output:o,error:c,newVersion:r,autoRestart:d,refreshInstallInfo:f,runUpdate:i,reset:u}=Ws(),[N,j]=l.useState(!1),g=l.useRef(null);l.useEffect(()=>{f()},[f]),l.useEffect(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)},[o]);const T=l.useCallback(()=>{j(!0)},[]),y=l.useCallback(()=>{j(!1)},[]),E=l.useCallback(()=>{j(!1),i()},[i]),v=l.useCallback(()=>{u(),j(!1),f()},[u,f]),p=ys.isNativePlatform(),S=s(p?"config:about.autoUpdateServerTitle":"config:about.autoUpdateTitle");return a?a.isGlobalInstall?a.autoUpdateSupported?!a.updateAvailable&&t==="idle"?null:e.jsxs("div",{className:"about-autoupdate",children:[e.jsx("div",{className:"about-autoupdate-title",children:S}),t==="idle"&&!N&&a.updateAvailable&&e.jsxs("div",{className:"about-autoupdate-row",children:[e.jsxs("span",{className:"about-autoupdate-versions",children:[e.jsx("span",{className:"about-autoupdate-current",children:a.currentVersion}),e.jsx("span",{className:"about-autoupdate-arrow",children:"→"}),e.jsx("span",{className:"about-autoupdate-latest",children:a.latestVersion})]}),e.jsx("button",{className:"about-update-btn download",onClick:T,children:s("config:about.autoUpdateButton")})]}),t==="idle"&&N&&e.jsxs("div",{className:"about-autoupdate-confirm",children:[e.jsx("div",{className:"about-autoupdate-confirm-title",children:s("config:about.autoUpdateConfirmTitle")}),e.jsx("div",{className:"about-autoupdate-confirm-body",children:s("config:about.autoUpdateConfirmBody")}),e.jsxs("div",{className:"about-autoupdate-confirm-actions",children:[e.jsx("button",{className:"about-update-btn changelog",onClick:y,children:s("config:about.autoUpdateCancel")}),e.jsx("button",{className:"about-update-btn download",onClick:E,children:s("config:about.autoUpdateConfirm")})]})]}),(t==="running"||t==="success"||t==="failed")&&e.jsxs("div",{className:"about-autoupdate-stream",children:[e.jsxs("div",{className:"about-autoupdate-stream-title",children:[t==="running"&&s("config:about.autoUpdateRunning"),t==="success"&&s("config:about.autoUpdateSuccess"),t==="failed"&&s("config:about.autoUpdateFailed")]}),e.jsx("pre",{ref:g,className:"about-autoupdate-output",children:o||"..."}),t==="success"&&e.jsxs("div",{className:"about-autoupdate-success-hint",children:[r&&e.jsxs("div",{className:"about-autoupdate-newversion",children:["v",r]}),e.jsx("div",{children:s(d?"config:about.autoUpdateReconnectHint":"config:about.autoUpdateRestartHint")})]}),t==="failed"&&c&&e.jsx("div",{className:"about-update-error",children:c}),(t==="success"||t==="failed")&&e.jsx("div",{className:"about-autoupdate-stream-actions",children:e.jsx("button",{className:"about-update-btn changelog",onClick:v,children:s("config:about.autoUpdateClose")})})]})]}):p?null:e.jsxs("div",{className:"about-autoupdate",children:[e.jsx("div",{className:"about-autoupdate-title",children:S}),e.jsx("div",{className:"about-autoupdate-devnote",children:s("config:about.autoUpdatePackageManagerNotice",{pm:a.packageManager})}),a.suggestedManualCommand&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"about-autoupdate-manualhint",children:s("config:about.autoUpdateManualCommand")}),e.jsx("pre",{className:"about-autoupdate-manualcmd",children:a.suggestedManualCommand})]})]}):p?null:e.jsxs("div",{className:"about-autoupdate",children:[e.jsx("div",{className:"about-autoupdate-title",children:S}),e.jsx("div",{className:"about-autoupdate-devnote",children:s("config:about.autoUpdateDevMode")})]}):null}function pa(){const{t:s}=Z(["config"]),[a,t]=l.useState(null),[o,c]=l.useState(!1),[r,d]=l.useState(null);l.useEffect(()=>{Gs().then(t).catch(N=>d(N.message))},[]);const f=l.useCallback(async N=>{if(!o){c(!0),d(null);try{t(await Ys(N))}catch(j){d(j.message)}finally{c(!1)}}},[o]),i=ys.isNativePlatform(),u=s(i?"config:about.unattendedServerTitle":"config:about.unattendedTitle");return!a&&!r?null:a?i&&!a.supported?null:e.jsxs("div",{className:"about-autoupdate",children:[e.jsx("div",{className:"about-autoupdate-title",children:u}),e.jsxs("div",{className:"about-autoupdate-row",children:[e.jsx("span",{className:"about-autoupdate-devnote",children:s("config:about.unattendedDesc")}),e.jsxs("label",{className:"config-toggle",style:a.supported?void 0:{opacity:.5},children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:a.enabled,disabled:o||!a.supported,onChange:N=>void f(N.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})]}),!a.supported&&e.jsx("div",{className:"about-autoupdate-devnote",children:s("config:about.unattendedUnsupported")}),a.supported&&a.enabled&&a.pendingRestartVersion&&e.jsx("div",{className:"about-autoupdate-devnote",children:s("config:about.unattendedPendingRestart",{version:a.pendingRestartVersion})}),a.supported&&a.enabled&&!a.pendingRestartVersion&&a.lastResult&&e.jsx("div",{className:"about-autoupdate-devnote",children:a.lastResult}),r&&e.jsx("div",{className:"about-update-error",children:r})]}):i?null:e.jsxs("div",{className:"about-autoupdate",children:[e.jsx("div",{className:"about-autoupdate-title",children:u}),e.jsx("div",{className:"about-update-error",children:r})]})}function ma(){var F;const{t:s}=Z(["config"]),{isAndroid:a,supported:t,otaActive:o,bundleState:c,serverInfo:r,infoError:d,updateAvailable:f,phase:i,progress:u,error:N,autoSync:j,checkNow:g,syncNow:T,resetToBundled:y,setAutoSync:E}=Js(),[v,p]=l.useState(null),S=l.useRef(g);return S.current=g,l.useEffect(()=>{a&&(S.current(!1),Xs.getInfo().then(R=>p(R.version)).catch(()=>{}))},[a]),!a||t===!1?null:e.jsxs("div",{className:"about-autoupdate",children:[e.jsx("div",{className:"about-autoupdate-title",children:s("config:webBundle.title")}),e.jsxs("div",{className:"about-autoupdate-devnote",children:[o?s("config:webBundle.sourceOta",{hash:((F=c==null?void 0:c.hash)==null?void 0:F.slice(0,8))??"?"}):s("config:webBundle.sourceBundled"),v&&` · ${s("config:webBundle.apkVersion",{version:v})}`]}),r?e.jsxs("div",{className:"about-autoupdate-devnote",children:[s("config:webBundle.serverBundle",{version:r.version,hash:r.hash.slice(0,8)})," — ",s(f?"config:webBundle.updateAvailable":"config:webBundle.upToDate")]}):d&&e.jsx("div",{className:"about-autoupdate-devnote",children:s("config:webBundle.serverUnavailable")}),N&&e.jsx("div",{className:"about-update-error",children:N}),e.jsxs("div",{className:"about-autoupdate-row",children:[e.jsx("span",{className:"about-autoupdate-devnote",children:s("config:webBundle.autoSync")}),e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:j,onChange:R=>E(R.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})]}),e.jsxs("div",{className:"about-update-actions",children:[e.jsx("button",{className:"about-update-btn download",onClick:()=>void T(),disabled:i!=="idle"||!r,children:i==="syncing"?s("config:webBundle.syncingPct",{percent:u??0}):s("config:webBundle.syncNow")}),o&&e.jsx("button",{className:"about-update-btn changelog",onClick:()=>void y(),children:s("config:webBundle.reset")})]})]})}function ha(){const{t:s}=Z(["config"]),{updateAvailable:a,updateInfo:t,recentReleases:o,isChecking:c,error:r,currentVersion:d,isAndroid:f,downloadPhase:i,downloadProgress:u,checkForUpdate:N,downloadAndInstall:j,openReleasePage:g}=Vs(),[T,y]=l.useState(!1),E=p=>p?`${(p/(1024*1024)).toFixed(1)} MB`:"",v=p=>new Date(p).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"});return e.jsxs("div",{className:"about-section",children:[e.jsxs("div",{className:"about-logo",children:[e.jsx("span",{className:"about-logo-icon",children:e.jsx(I,{name:"waves",size:24})}),e.jsx("span",{className:"about-logo-text",children:"Tide Commander"})]}),e.jsxs("div",{className:"about-version",children:[e.jsx("span",{className:"about-version-label",children:s("config:about.version")}),e.jsxs("div",{className:"about-version-info",children:[e.jsx("span",{className:"about-version-value",children:d}),a&&t?e.jsx("span",{className:"about-version-update-badge",onClick:g,title:`Update available: ${t.version}`,children:t.version}):e.jsxs("a",{href:"https://github.com/deivid11/tide-commander/releases",target:"_blank",rel:"noopener noreferrer",className:"about-version-status",children:["(",s("config:about.updated"),")"]})]})]}),e.jsx(ua,{}),e.jsx(pa,{}),e.jsx(ma,{}),e.jsx("div",{className:"about-changelog-row",children:e.jsx("button",{className:"about-update-btn changelog",onClick:()=>y(!0),children:s("config:about.changelog")})}),e.jsxs("div",{className:"about-update",children:[a&&t?e.jsxs("div",{className:"about-update-available",children:[e.jsxs("div",{className:"about-update-header",children:[e.jsx("span",{className:"about-update-badge",children:s("config:about.updateAvailable")}),e.jsx("span",{className:"about-update-version",children:t.version})]}),t.apkSize&&e.jsxs("div",{className:"about-update-size",children:[s("config:about.sizeLabel"),": ",E(t.apkSize)]}),r&&e.jsx("div",{className:"about-update-error",children:r}),e.jsxs("div",{className:"about-update-actions",children:[e.jsx("button",{className:"about-update-btn changelog",onClick:g,children:s("config:about.changelog")}),f&&t.apkUrl?e.jsx("button",{className:"about-update-btn download",onClick:()=>void j(),disabled:i!=="idle",children:i==="downloading"?s("config:appUpdateBanner.downloadingPct",{percent:u??0}):s(i==="installing"?"config:appUpdateBanner.installHint":"config:about.downloadAPK")}):e.jsx("button",{className:"about-update-btn download",onClick:g,children:s("config:about.viewRelease")})]})]}):e.jsxs("div",{className:"about-update-check",children:[e.jsx("span",{className:"about-update-status",children:s(c?"config:about.checkingUpdates":"config:about.upToDate")}),e.jsx("button",{className:"about-update-btn check",onClick:()=>N(!0),disabled:c,children:c?"...":s("config:about.check")})]}),o.length>0&&e.jsxs("div",{className:"about-releases",children:[e.jsx("div",{className:"about-releases-title",children:s("config:about.recentReleases")}),e.jsx("div",{className:"about-releases-list",children:o.map(p=>e.jsxs("a",{href:p.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:`about-release-item ${p.version===`v${d}`||p.version===d?"current":""}`,children:[e.jsx("span",{className:"about-release-version",children:p.version}),e.jsx("span",{className:"about-release-date",children:v(p.publishedAt)})]},p.version))})]})]}),e.jsx("div",{className:"about-description",children:s("config:about.tagline")}),e.jsxs("div",{className:"about-principles",children:[e.jsx("div",{className:"about-principles-title",children:s("config:about.corePrinciples")}),e.jsxs("ul",{className:"about-principles-list",children:[e.jsx("li",{children:s("config:about.principle1")}),e.jsx("li",{children:s("config:about.principle2")}),e.jsx("li",{children:s("config:about.principle3")}),e.jsx("li",{children:s("config:about.principle4")})]})]}),e.jsx("div",{className:"about-links",children:e.jsxs("a",{href:"https://github.com/deivid11/tide-commander",target:"_blank",rel:"noopener noreferrer",className:"about-link",children:[e.jsx("span",{className:"about-link-icon",children:e.jsx(I,{name:"package",size:14})}),e.jsx("span",{children:s("config:about.repository")})]})}),e.jsxs("div",{className:"about-credits",children:[e.jsx("div",{className:"about-credits-title",children:s("config:about.specialThanks")}),e.jsxs("div",{className:"about-credit-item",children:[e.jsx("a",{href:"https://kenney.nl",target:"_blank",rel:"noopener noreferrer",className:"about-credit-link",children:"Kenney.nl"}),e.jsx("span",{className:"about-credit-desc",children:s("config:about.kenneyCredit")})]}),e.jsxs("div",{className:"about-credit-item",children:[e.jsx("a",{href:"https://claude.ai/code",target:"_blank",rel:"noopener noreferrer",className:"about-credit-link",children:"Claude Code"}),e.jsx("span",{className:"about-credit-desc",children:s("config:about.claudeCodeCredit")})]})]}),T&&e.jsx(Ks,{onClose:()=>y(!1)})]})}const ga={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅",docx:"📄",whatsapp:"📱"};function fa({onOpenModal:s}){const[a,t]=l.useState([]),[o,c]=l.useState(!0),r=l.useCallback(async()=>{try{const d=await de(ue("/api/integrations"));if(!d.ok)return;const f=await d.json();t(f)}catch{}finally{c(!1)}},[]);return l.useEffect(()=>{r()},[r]),o?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"Loading..."}):a.length===0?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"No integrations available."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[a.map(d=>{const f=ga[d.id]||"🔌",i=!!d.status.error,u=d.status.connected,N=i?"#f38ba8":u?"#a6e3a1":"#fab387",j=i?"Error":u?"Connected":"Setup Required",g=i?"✗":u?"✓":"⚠";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"3px 8px",borderRadius:4,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)",fontSize:12,minHeight:26},children:[e.jsx("span",{style:{fontSize:13,flexShrink:0},children:f}),e.jsx("span",{style:{flex:1,minWidth:0,color:"var(--text-primary, #cdd6f4)",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:d.name}),e.jsx("span",{style:{color:N,fontSize:10,fontWeight:500,whiteSpace:"nowrap"},title:j,children:g}),e.jsx("button",{onClick:()=>s(d.id),title:`Configure ${d.name}`,style:{background:"none",border:"none",cursor:"pointer",padding:"1px 3px",fontSize:12,color:"var(--text-secondary, #a6adc8)",borderRadius:3,flexShrink:0,lineHeight:1},onMouseEnter:T=>{T.target.style.color="var(--text-primary, #cdd6f4)"},onMouseLeave:T=>{T.target.style.color="var(--text-secondary, #a6adc8)"},children:"⚙️"})]},d.id)}),e.jsx("button",{onClick:()=>s(),style:{background:"none",border:"1px dashed var(--border, #313244)",borderRadius:4,padding:"3px 8px",cursor:"pointer",color:"var(--text-secondary, #a6adc8)",fontSize:11,textAlign:"center",marginTop:2},onMouseEnter:d=>{d.target.style.borderColor="var(--accent, #89b4fa)",d.target.style.color="var(--accent, #89b4fa)"},onMouseLeave:d=>{d.target.style.borderColor="var(--border, #313244)",d.target.style.color="var(--text-secondary, #a6adc8)"},children:"Manage All Integrations"})]})}function Oe(s){return`/api/system/${s}-credentials`}async function Le(s,a){try{const t=await s.json();if(t!=null&&t.error&&typeof t.error=="string")return t.error}catch{}return a}async function xa(s){const a=await de(ue(Oe(s)));if(!a.ok)throw new Error(await Le(a,`Failed to list ${s} credentials: ${a.status}`));return await a.json()}async function us(s,a,t={}){const o=await de(ue(`${Oe(s)}/switch`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,stashActiveAs:t.stashActiveAs})});if(!o.ok)throw new Error(await Le(o,`Failed to switch ${s} credentials: ${o.status}`));return await o.json()}async function ps(s,a,t={}){const o=await de(ue(`${Oe(s)}/save`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,force:t.force})});if(!o.ok)throw new Error(await Le(o,`Failed to save ${s} credentials: ${o.status}`));return await o.json()}async function ba(s,a,t){const o=await de(ue(`${Oe(s)}/rename`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:a,to:t})});if(!o.ok)throw new Error(await Le(o,`Failed to rename ${s} credentials: ${o.status}`));return await o.json()}async function ja(s,a){const t=await de(ue(`${Oe(s)}/${encodeURIComponent(a)}`),{method:"DELETE"});if(!t.ok)throw new Error(await Le(t,`Failed to delete ${s} credentials: ${t.status}`));return await t.json()}const Be={grok:"Grok",codex:"Codex"};function va(s){if(s==null||!Number.isFinite(s))return"—";const a=new Date(s);return Number.isNaN(a.getTime())?"—":a.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ya({profile:s,busy:a,onUse:t,onRename:o,onDelete:c}){const{t:r}=Z(["terminal","common"]),d=s.expiresAt!=null&&s.expiresAt<=Date.now(),f=[s.label,s.email].filter(Boolean).join(" · ");return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"8px 10px",background:s.isActive?"rgba(74, 158, 255, 0.1)":"var(--bg-tertiary, var(--bg-secondary))",border:s.isActive?"1px solid rgba(74, 158, 255, 0.45)":"1px solid var(--border-color)",borderRadius:"6px",marginBottom:"6px"},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontWeight:600,fontSize:"13px"},children:s.name}),s.isActive&&e.jsx("span",{style:{fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.4px",color:"#4a9eff",border:"1px solid rgba(74, 158, 255, 0.5)",borderRadius:"4px",padding:"1px 6px"},children:r("terminal:credentials.activeBadge")}),!s.valid&&e.jsx("span",{style:{fontSize:"10px",color:"#ff8a8a"},children:r("terminal:credentials.invalid")})]}),e.jsxs("div",{style:{fontSize:"11px",color:"var(--text-secondary)",marginTop:"2px"},children:[f,s.expiresAt!=null&&e.jsxs("span",{style:{color:d?"#ff8a8a":void 0},children:[f?" · ":"",r("terminal:credentials.tokenExpires",{time:va(s.expiresAt)})]})]})]}),e.jsxs("div",{style:{display:"flex",gap:"4px",flexShrink:0},children:[!s.isActive&&e.jsx("button",{type:"button",className:"btn btn-primary",disabled:a||!s.valid,onClick:()=>t(s.name),style:{padding:"4px 10px",fontSize:"11px"},title:r("terminal:credentials.useTitle"),children:r("terminal:credentials.use")}),e.jsx("button",{type:"button",className:"btn btn-secondary",disabled:a,onClick:()=>o(s.name),style:{padding:"4px 8px",fontSize:"11px"},title:r("terminal:credentials.rename"),children:e.jsx(I,{name:"edit",size:12})}),e.jsx("button",{type:"button",className:"btn btn-secondary",disabled:a,onClick:()=>c(s.name),style:{padding:"4px 8px",fontSize:"11px",color:"#ff8a8a"},title:r("terminal:credentials.delete"),children:e.jsx(I,{name:"trash",size:12})})]})]})}function ms({provider:s,onSwitched:a,compact:t}){var K,te,w,D,B;const{t:o}=Z(["terminal","common"]),[c,r]=l.useState(null),[d,f]=l.useState(!1),[i,u]=l.useState(!1),[N,j]=l.useState(null),[g,T]=l.useState(""),[y,E]=l.useState(""),[v,p]=l.useState(null),[S,F]=l.useState(null),R=l.useCallback(async()=>{f(!0),j(null);try{r(await xa(s))}catch(m){j(m instanceof Error?m.message:String(m))}finally{f(!1)}},[s]);l.useEffect(()=>{R()},[R]);const q=m=>r(m),W=!!((K=c==null?void 0:c.active)!=null&&K.valid&&!c.active.matchesNamed),Y=async m=>{if(j(null),F(null),W){p(m);return}u(!0);try{const x=await us(s,m);r({provider:s,dir:(c==null?void 0:c.dir)??"",active:x.active,profiles:x.profiles}),F(o("terminal:credentials.switched",{name:m})),p(null),a==null||a()}catch(x){j(x instanceof Error?x.message:String(x))}finally{u(!1)}},M=async()=>{if(!v)return;const m=y.trim();if(!m){j(o("terminal:credentials.stashRequired"));return}u(!0),j(null);try{const x=await us(s,v,{stashActiveAs:m});r({provider:s,dir:(c==null?void 0:c.dir)??"",active:x.active,profiles:x.profiles}),F(x.stashedAs?o("terminal:credentials.switchedWithStash",{name:v,stash:x.stashedAs}):o("terminal:credentials.switched",{name:v})),p(null),E(""),a==null||a()}catch(x){j(x instanceof Error?x.message:String(x))}finally{u(!1)}},U=async()=>{const m=g.trim();if(!m){j(o("terminal:credentials.nameRequired"));return}u(!0),j(null),F(null);try{q(await ps(s,m)),T(""),F(o("terminal:credentials.saved",{name:m}))}catch(x){const L=x instanceof Error?x.message:String(x);if(/already exists/i.test(L)&&window.confirm(o("terminal:credentials.confirmOverwrite",{name:m})))try{q(await ps(s,m,{force:!0})),T(""),F(o("terminal:credentials.saved",{name:m})),u(!1);return}catch(J){j(J instanceof Error?J.message:String(J)),u(!1);return}j(L)}finally{u(!1)}},h=async m=>{const x=window.prompt(o("terminal:credentials.renamePrompt",{name:m}),m);if(!(!x||x.trim()===m)){u(!0),j(null);try{q(await ba(s,m,x.trim())),F(o("terminal:credentials.renamed",{from:m,to:x.trim()}))}catch(L){j(L instanceof Error?L.message:String(L))}finally{u(!1)}}},O=async m=>{if(window.confirm(o("terminal:credentials.confirmDelete",{name:m}))){u(!0),j(null);try{q(await ja(s,m)),F(o("terminal:credentials.deleted",{name:m}))}catch(x){j(x instanceof Error?x.message:String(x))}finally{u(!1)}}},z=c!=null&&c.active?c.active.matchesNamed?c.active.matchesNamed:o("terminal:credentials.unsavedActive"):o("terminal:credentials.noActive");return e.jsxs("div",{className:"claude-credentials-panel",style:{marginTop:t?"12px":"0",paddingTop:t?"12px":"0",borderTop:t?"1px solid var(--border-color)":void 0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"10px",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.5px"},children:o("terminal:credentials.providerTitle",{provider:Be[s],defaultValue:`${Be[s]} Accounts`})}),e.jsxs("div",{style:{fontSize:"12px",marginTop:"4px"},children:[o("terminal:credentials.current",{name:z}),((te=c==null?void 0:c.active)==null?void 0:te.email)&&e.jsxs("span",{style:{color:"var(--text-secondary)"},children:[" · ",c.active.email]}),((w=c==null?void 0:c.active)==null?void 0:w.label)&&e.jsxs("span",{style:{color:"var(--text-secondary)"},children:[" (",c.active.label,")"]})]})]}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>void R(),disabled:d||i,style:{padding:"4px 10px",fontSize:"11px",display:"inline-flex",gap:"6px",alignItems:"center"},title:o("common:buttons.refresh"),children:e.jsx("span",{style:{display:"inline-block",animation:d?"spin 1s linear infinite":"none"},children:e.jsx(I,{name:"refresh",size:12})})})]}),e.jsx("p",{style:{fontSize:"11px",color:"var(--text-secondary)",margin:"0 0 10px",lineHeight:1.45},children:o("terminal:credentials.providerHelp",{provider:Be[s],dir:(c==null?void 0:c.dir)??`~/.${s}`,defaultValue:`Named copies of ${(c==null?void 0:c.dir)??`~/.${s}`}/auth.json. Switch the active ${Be[s]} account when you hit rate limits — same as renaming the file manually.`})}),N&&e.jsx("div",{style:{padding:"8px 10px",marginBottom:"8px",background:"rgba(255, 74, 74, 0.08)",border:"1px solid rgba(255, 74, 74, 0.3)",borderRadius:"6px",color:"#ff8a8a",fontSize:"12px"},children:N}),S&&e.jsx("div",{style:{padding:"8px 10px",marginBottom:"8px",background:"rgba(74, 255, 158, 0.08)",border:"1px solid rgba(74, 255, 158, 0.3)",borderRadius:"6px",color:"#7dffb0",fontSize:"12px"},children:S}),v&&e.jsxs("div",{style:{padding:"10px 12px",marginBottom:"10px",background:"rgba(255, 158, 74, 0.08)",border:"1px solid rgba(255, 158, 74, 0.35)",borderRadius:"6px"},children:[e.jsx("div",{style:{fontSize:"12px",marginBottom:"8px",lineHeight:1.45},children:o("terminal:credentials.stashPrompt",{name:v})}),e.jsxs("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:[e.jsx("input",{type:"text",value:y,onChange:m=>E(m.target.value),placeholder:o("terminal:credentials.stashPlaceholder"),disabled:i,style:{flex:1,minWidth:"120px",padding:"6px 8px",fontSize:"12px",borderRadius:"4px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)"}}),e.jsx("button",{type:"button",className:"btn btn-primary",disabled:i,onClick:()=>void M(),style:{padding:"6px 12px",fontSize:"12px"},children:o("terminal:credentials.confirmSwitch")}),e.jsx("button",{type:"button",className:"btn btn-secondary",disabled:i,onClick:()=>p(null),style:{padding:"6px 12px",fontSize:"12px"},children:o("common:buttons.cancel")})]})]}),d&&!c&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--text-secondary)",padding:"8px 0"},children:[o("common:status.loading"),"…"]}),c&&c.profiles.length===0&&e.jsx("div",{style:{fontSize:"12px",color:"var(--text-muted)",marginBottom:"10px"},children:o("terminal:credentials.noProfiles")}),c==null?void 0:c.profiles.map(m=>e.jsx(ya,{profile:m,busy:i,onUse:x=>void Y(x),onRename:x=>void h(x),onDelete:x=>void O(x)},m.name)),e.jsxs("div",{style:{display:"flex",gap:"6px",marginTop:"10px",flexWrap:"wrap",alignItems:"center"},children:[e.jsx("input",{type:"text",value:g,onChange:m=>T(m.target.value),placeholder:o("terminal:credentials.savePlaceholder"),disabled:i||!((D=c==null?void 0:c.active)!=null&&D.valid),style:{flex:1,minWidth:"140px",padding:"6px 8px",fontSize:"12px",borderRadius:"4px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)"}}),e.jsx("button",{type:"button",className:"btn btn-secondary",disabled:i||!((B=c==null?void 0:c.active)!=null&&B.valid)||!g.trim(),onClick:()=>void U(),style:{padding:"6px 12px",fontSize:"12px"},children:o("terminal:credentials.saveActive")})]}),(c==null?void 0:c.dir)&&e.jsx("div",{style:{fontSize:"10px",color:"var(--text-muted)",marginTop:"8px",wordBreak:"break-all"},children:c.dir})]})}const Me="__global__";function wa({isOpen:s,onClose:a,initialAgentId:t}){const{t:o}=Z(["config"]),c=Zs(),[r,d]=l.useState(""),[f,i]=l.useState(""),[u,N]=l.useState(!1),[j,g]=l.useState(""),[T,y]=l.useState(""),[E,v]=l.useState(null),[p,S]=l.useState(null),[F,R]=l.useState(!1),[q,W]=l.useState(!1),[Y,M]=l.useState(!1),[U,h]=l.useState(null),O=l.useMemo(()=>[...c].sort((_,C)=>_.name.localeCompare(C.name)),[c]),z=l.useMemo(()=>c.find(_=>_.id===r),[c,r]),K=r===Me;l.useEffect(()=>{if(!s)return;const _=t&&c.some(C=>C.id===t)?t:Me;d(_),N(!1),Ht().then(C=>i(C)).catch(()=>i("")).finally(()=>N(!0))},[s]),l.useEffect(()=>{const _=r===Me?f:(z==null?void 0:z.customPrompt)??"";g(_),y(_),R(!1),v(null),S(null)},[r,u]);const te=_=>{const C=_.target.value;g(C),R(C!==T),v(null),S(null)},w=async()=>{if(r)try{v(null),S(null),K?(await qt(j),i(j),S(o("config:systemPrompt.savedGlobal"))):(k.updateAgentProperties(r,{customPrompt:j}),S(o("config:systemPrompt.saved"))),y(j),R(!1)}catch(_){v(_ instanceof Error?_.message:"Failed to save system prompt")}},D=()=>{W(!0)},B=async()=>{if(r)try{v(null),S(null),K?(await Wt(),i(""),S(o("config:systemPrompt.clearedGlobal"))):(k.updateAgentProperties(r,{customPrompt:""}),S(o("config:systemPrompt.cleared"))),g(""),y(""),R(!1)}catch(_){v(_ instanceof Error?_.message:"Failed to clear system prompt")}},m=()=>{g(T),R(!1),v(null),S(null)},x=_=>{if(_!==r){if(F){h(_),M(!0);return}d(_)}},L=()=>{if(F){h(null),M(!0);return}a()},J=()=>{if(M(!1),U){const _=U;h(null),d(_)}else a()},ne=_=>{_.key==="Escape"&&(_.preventDefault(),L())};return s?e.jsxs($e,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:L,children:e.jsxs("div",{className:"system-prompt-modal",onClick:_=>_.stopPropagation(),onKeyDown:ne,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:o("config:systemPrompt.title")}),e.jsx("button",{className:"modal-close",onClick:L,"aria-label":"Close",children:e.jsx(I,{name:"close",size:16})})]}),e.jsxs("div",{className:"modal-body",children:[e.jsx("p",{className:"modal-description",children:o("config:systemPrompt.description")}),e.jsxs("div",{className:"agent-picker",children:[e.jsx("label",{htmlFor:"system-prompt-agent",className:"editor-label",children:o("config:systemPrompt.agentLabel")}),e.jsxs("div",{className:"agent-picker-row",children:[K?e.jsx(I,{name:"globe",size:20,className:"agent-picker-icon"}):z&&e.jsx(Qs,{classId:z.class,size:20,className:"agent-picker-icon"}),e.jsxs("select",{id:"system-prompt-agent",className:"agent-picker-select",value:r,onChange:_=>x(_.target.value),children:[e.jsxs("option",{value:Me,children:[o("config:systemPrompt.globalOption"),f?" • ✦":""]}),O.map(_=>e.jsxs("option",{value:_.id,children:[_.name,_.customPrompt?" • ✦":""]},_.id))]})]})]}),E&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(I,{name:"warn",size:14})}),E]}),p&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(I,{name:"check",size:14})}),p]}),e.jsxs("div",{className:"editor-wrapper",children:[e.jsxs("div",{className:"editor-header",children:[e.jsx("label",{htmlFor:"prompt-input",className:"editor-label",children:o("config:systemPrompt.editPrompt")}),e.jsxs("span",{className:"char-count",children:[j.length," ",o("config:systemPrompt.characters")]})]}),e.jsx("textarea",{id:"prompt-input",className:"prompt-editor",value:j,onChange:te,placeholder:o("config:systemPrompt.placeholder"),rows:18,disabled:K&&!u,autoFocus:!0}),e.jsx("div",{className:"editor-hint",children:o(K?"config:systemPrompt.hintGlobal":"config:systemPrompt.hint")})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left",children:e.jsx("button",{className:"btn btn-danger",onClick:D,disabled:!j||!r,children:o("config:systemPrompt.clear")})}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:L,children:"Close"}),e.jsx("button",{className:"btn btn-secondary",onClick:m,disabled:!F,children:o("config:systemPrompt.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:w,disabled:!F||!r,children:o("config:systemPrompt.save")})]})]})]})}),e.jsx(je,{isOpen:q,title:o("config:systemPrompt.clear"),message:o(K?"config:systemPrompt.confirmClearGlobal":"config:systemPrompt.confirmClear"),confirmLabel:o("config:systemPrompt.clear"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{B()},onClose:()=>W(!1)}),e.jsx(je,{isOpen:Y,title:"Unsaved Changes",message:"You have unsaved changes for this agent. Discard them?",confirmLabel:"Discard",cancelLabel:"Keep editing",variant:"danger",onConfirm:J,onClose:()=>{M(!1),h(null)}})]}):null}const hs={enabled:!1,baseUrl:"",defaultSessionId:"",webhookVerifyToken:"",showIncomingToasts:!0},Na=2500,ka=12e4;function gs(s){return{enabled:s.enabled??!1,baseUrl:s.baseUrl??"",defaultSessionId:s.defaultSessionId??"",webhookVerifyToken:s.webhookVerifyToken??"",showIncomingToasts:s.showIncomingToasts??!0}}function Sa(s,a){return s.enabled===a.enabled&&s.baseUrl===a.baseUrl&&s.defaultSessionId===a.defaultSessionId&&s.webhookVerifyToken===a.webhookVerifyToken&&s.showIncomingToasts===a.showIncomingToasts}function Ca({isOpen:s,onClose:a}){const{t}=Z(["config"]),[o,c]=l.useState(hs),[r,d]=l.useState(hs),[f,i]=l.useState(!1),[u,N]=l.useState([]),[j,g]=l.useState(!0),[T,y]=l.useState(null),[E,v]=l.useState(null),[p,S]=l.useState(""),[F,R]=l.useState(!1),[q,W]=l.useState(""),[Y,M]=l.useState(null),[U,h]=l.useState(null),[O,z]=l.useState(null),K=l.useRef(null),te=l.useRef(0),[w,D]=l.useState(""),[B,m]=l.useState(""),[x,L]=l.useState(null),[J,ne]=l.useState(!1),[_,C]=l.useState(!1),[ae,ie]=l.useState(!1),[pe,oe]=l.useState(!1),[ge,ke]=l.useState(null),Ae=!Sa(o,r),me=l.useCallback(()=>{K.current&&(clearTimeout(K.current),K.current=null)},[]),Te=l.useCallback(async()=>{try{g(!0),y(null),v(null);const[b,H]=await Promise.all([ws(),et()]),ce=gs(b);if(c(ce),d(ce),i(!!H.configured),H.configured)try{const ye=await es();N(Array.isArray(ye)?ye:[])}catch{N([])}else N([])}catch(b){y(b instanceof Error?b.message:t("config:whatsapp.errors.loadFailed"))}finally{g(!1)}},[t]),fe=l.useCallback(async()=>{try{const b=await es();N(Array.isArray(b)?b:[])}catch{}},[]);l.useEffect(()=>(s?Te():(me(),M(null),h(null),z(null),S(""),R(!1),L(null)),()=>{me()}),[s,Te,me]);const xe=(b,H)=>{c(ce=>({...ce,[b]:H})),y(null),v(null)},De=async()=>{try{y(null),v(null);const b=await it({enabled:o.enabled,baseUrl:o.baseUrl.trim(),defaultSessionId:o.defaultSessionId.trim(),webhookVerifyToken:o.webhookVerifyToken,showIncomingToasts:o.showIncomingToasts});window.dispatchEvent(new CustomEvent("tide:whatsapp-config-updated"));const H=gs(b);c(H),d(H),v(t("config:whatsapp.saved"))}catch(b){y(b instanceof Error?b.message:t("config:whatsapp.errors.saveFailed"))}},Ve=()=>{c(r),y(null),v(null)},Se=()=>{if(Ae){C(!0);return}a()},Fe=b=>{b.key==="Escape"&&(b.preventDefault(),Se())},Ke=async()=>{const b=p.trim();if(b)try{y(null),v(null),await tt(b),S(""),R(!1),i(!0),v(t("config:whatsapp.apiKeySaved"))}catch(H){y(H instanceof Error?H.message:t("config:whatsapp.errors.apiKeySaveFailed"))}},He=()=>{ie(!0)},qe=async()=>{try{y(null),v(null),await ot(),i(!1),v(t("config:whatsapp.apiKeyCleared"))}catch(b){y(b instanceof Error?b.message:t("config:whatsapp.errors.apiKeyClearFailed"))}},ve=l.useCallback(async b=>{if(Date.now()>te.current){z(t("config:whatsapp.pairingTimeout")),M(null),h(null),me(),fe();return}try{const H=await st(b);if(H.status&&["connected","paired","open","ready"].includes(H.status.toLowerCase())){z(t("config:whatsapp.pairingSuccess")),M(null),h(null),me(),fe();return}const ye=H.qrUrl??H.qr??null;ye&&h(ye)}catch(H){z(H instanceof Error?H.message:t("config:whatsapp.errors.qrFetchFailed"))}K.current=setTimeout(()=>{ve(b)},Na)},[fe,me,t]),$=async()=>{const b=q.trim();if(b)try{y(null),v(null),z(null),h(null),me(),await at(b),W(""),M(b),te.current=Date.now()+ka,ve(b),fe()}catch(H){y(H instanceof Error?H.message:t("config:whatsapp.errors.sessionCreateFailed"))}},Ee=()=>{me(),M(null),h(null),z(null)},he=b=>{ke(b),oe(!0)},We=async()=>{if(ge)try{y(null),v(null),await lt(ge),Y===ge&&Ee(),fe(),v(t("config:whatsapp.sessionDeleted"))}catch(b){y(b instanceof Error?b.message:t("config:whatsapp.errors.sessionDeleteFailed"))}finally{ke(null)}},Re=async()=>{const b=w.trim(),H=B.trim();if(!(!b||!H))try{ne(!0),L(null);const ce=o.defaultSessionId.trim()||void 0;await nt(b,H,ce),L({kind:"success",text:t("config:whatsapp.testSent")})}catch(ce){L({kind:"error",text:ce instanceof Error?ce.message:t("config:whatsapp.errors.testSendFailed")})}finally{ne(!1)}};return s?e.jsxs($e,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:Se,children:e.jsxs("div",{className:"whatsapp-config-modal",onClick:b=>b.stopPropagation(),onKeyDown:Fe,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:t("config:whatsapp.title")}),e.jsx("button",{className:"modal-close",onClick:Se,"aria-label":"Close",children:e.jsx(I,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:j?e.jsxs("div",{className:"loading-state",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:t("config:whatsapp.loading")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"modal-description",children:t("config:whatsapp.description")}),T&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(I,{name:"warn",size:14})}),T]}),E&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(I,{name:"check",size:14})}),E]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:t("config:whatsapp.sections.general")}),e.jsxs("div",{className:"wa-field wa-field-row",children:[e.jsx("label",{htmlFor:"wa-enabled",className:"wa-label",children:t("config:whatsapp.enabled")}),e.jsxs("label",{className:"wa-toggle",children:[e.jsx("input",{id:"wa-enabled",type:"checkbox",checked:o.enabled,onChange:b=>xe("enabled",b.target.checked)}),e.jsx("span",{className:"wa-toggle-track",children:e.jsx("span",{className:"wa-toggle-thumb"})})]})]}),e.jsxs("div",{className:"wa-field wa-field-row",children:[e.jsx("label",{htmlFor:"wa-show-toasts",className:"wa-label",children:t("config:whatsapp.showIncomingToasts")}),e.jsxs("label",{className:"wa-toggle",children:[e.jsx("input",{id:"wa-show-toasts",type:"checkbox",checked:o.showIncomingToasts,onChange:b=>xe("showIncomingToasts",b.target.checked)}),e.jsx("span",{className:"wa-toggle-track",children:e.jsx("span",{className:"wa-toggle-thumb"})})]})]}),e.jsx("span",{className:"wa-hint",children:t("config:whatsapp.showIncomingToastsHelp")}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-base-url",className:"wa-label",children:t("config:whatsapp.baseUrl")}),e.jsx("input",{id:"wa-base-url",type:"text",className:"wa-input",placeholder:"http://localhost:3007",value:o.baseUrl,onChange:b=>xe("baseUrl",b.target.value)})]}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-default-session",className:"wa-label",children:t("config:whatsapp.defaultSessionId")}),e.jsx("input",{id:"wa-default-session",type:"text",className:"wa-input",placeholder:t("config:whatsapp.defaultSessionIdPlaceholder"),value:o.defaultSessionId,onChange:b=>xe("defaultSessionId",b.target.value)})]}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-webhook-token",className:"wa-label",children:t("config:whatsapp.webhookVerifyToken")}),e.jsx("input",{id:"wa-webhook-token",type:"text",className:"wa-input",placeholder:t("config:whatsapp.webhookVerifyTokenPlaceholder"),value:o.webhookVerifyToken,onChange:b=>xe("webhookVerifyToken",b.target.value)})]})]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:t("config:whatsapp.sections.apiKey")}),e.jsx("div",{className:"wa-key-status",children:f?e.jsxs("span",{className:"wa-status wa-status-ok",children:[e.jsx(I,{name:"check",size:12})," ",t("config:whatsapp.configured")]}):e.jsxs("span",{className:"wa-status wa-status-warn",children:[e.jsx(I,{name:"warn",size:12})," ",t("config:whatsapp.notConfigured")]})}),e.jsxs("div",{className:"wa-field wa-field-inline",children:[e.jsx("input",{type:F?"text":"password",className:"wa-input",placeholder:t("config:whatsapp.apiKeyPlaceholder"),value:p,onChange:b=>S(b.target.value)}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>R(b=>!b),title:t(F?"config:whatsapp.hideKey":"config:whatsapp.showKey"),children:e.jsx(I,{name:F?"eye-closed":"eye",size:14})}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:Ke,disabled:!p.trim(),children:t("config:whatsapp.saveKey")}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:He,disabled:!f,children:t("config:whatsapp.clearKey")})]}),e.jsx("span",{className:"wa-hint",children:t("config:whatsapp.apiKeyHint")})]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:t("config:whatsapp.sections.sessions")}),e.jsx("div",{className:"wa-sessions-list",children:!Array.isArray(u)||u.length===0?e.jsx("div",{className:"wa-empty",children:t("config:whatsapp.noSessions")}):u.map(b=>e.jsxs("div",{className:"wa-session-row",children:[e.jsxs("div",{className:"wa-session-info",children:[e.jsx("span",{className:"wa-session-id",children:b.id}),e.jsx("span",{className:`wa-session-status status-${(b.status??"unknown").toLowerCase()}`,children:b.status||"—"}),b.pairedNumber&&e.jsx("span",{className:"wa-session-paired",children:b.pairedNumber})]}),e.jsx("button",{type:"button",className:"btn btn-danger btn-sm",onClick:()=>he(b.id),children:t("config:whatsapp.deleteSession")})]},b.id))}),e.jsxs("div",{className:"wa-field wa-field-inline",children:[e.jsx("input",{type:"text",className:"wa-input",placeholder:t("config:whatsapp.addSessionPlaceholder"),value:q,onChange:b=>W(b.target.value),onKeyDown:b=>{b.key==="Enter"&&$()}}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:$,disabled:!q.trim()||Y!==null,children:t("config:whatsapp.addSession")})]}),Y&&e.jsxs("div",{className:"wa-qr-panel",children:[e.jsxs("div",{className:"wa-qr-header",children:[e.jsx("span",{children:t("config:whatsapp.qrPrompt",{id:Y})}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Ee,children:t("config:whatsapp.cancelPairing")})]}),U?e.jsx("div",{className:"wa-qr-image",children:e.jsx("img",{src:U,alt:"WhatsApp pairing QR code"})}):e.jsxs("div",{className:"wa-qr-loading",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:t("config:whatsapp.waitingForQr")})]})]}),O&&!Y&&e.jsx("div",{className:"wa-pairing-message",children:O})]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:t("config:whatsapp.sections.testMessage")}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-test-to",className:"wa-label",children:t("config:whatsapp.testTo")}),e.jsx("input",{id:"wa-test-to",type:"text",className:"wa-input",placeholder:t("config:whatsapp.testToPlaceholder"),value:w,onChange:b=>D(b.target.value)})]}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-test-message",className:"wa-label",children:t("config:whatsapp.testMessageBody")}),e.jsx("textarea",{id:"wa-test-message",className:"wa-textarea",rows:4,placeholder:t("config:whatsapp.testMessageBodyPlaceholder"),value:B,onChange:b=>m(b.target.value)})]}),e.jsx("div",{className:"wa-field-inline wa-field-end",children:e.jsx("button",{type:"button",className:"btn btn-primary",onClick:Re,disabled:!w.trim()||!B.trim()||J,children:t(J?"config:whatsapp.sending":"config:whatsapp.sendTest")})}),x&&e.jsxs("div",{className:`alert ${x.kind==="success"?"alert-success":"alert-error"}`,children:[e.jsx("span",{className:"alert-icon",children:e.jsx(I,{name:x.kind==="success"?"check":"warn",size:14})}),x.text]})]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left"}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:Se,children:t("config:whatsapp.close")}),e.jsx("button",{className:"btn btn-secondary",onClick:Ve,disabled:!Ae||j,children:t("config:whatsapp.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:De,disabled:!Ae||j,children:t("config:whatsapp.save")})]})]})]})}),e.jsx(je,{isOpen:_,title:t("config:whatsapp.unsavedTitle"),message:t("config:whatsapp.unsavedMessage"),confirmLabel:t("config:whatsapp.closeAnyway"),cancelLabel:t("config:whatsapp.keepEditing"),variant:"danger",onConfirm:()=>{C(!1),a()},onClose:()=>C(!1)}),e.jsx(je,{isOpen:ae,title:t("config:whatsapp.clearKey"),message:t("config:whatsapp.confirmClearKey"),confirmLabel:t("config:whatsapp.clearKey"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{qe()},onClose:()=>ie(!1)}),e.jsx(je,{isOpen:pe,title:t("config:whatsapp.deleteSession"),message:t("config:whatsapp.confirmDeleteSession",{id:ge??""}),confirmLabel:t("config:whatsapp.deleteSession"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{We()},onClose:()=>{oe(!1),ke(null)}})]}):null}const Cs=["messages","statusChanges","taskComplete","errors","planReady","agentSpawned","agentStopped"];function ss(s=!1){const a=ee(),t={};return a&&(t.Authorization=`Bearer ${a}`),s&&(t["Content-Type"]="application/json"),t}async function ts(s,a){try{const t=await s.json();if(t&&typeof t.error=="string")return t.error;if(t&&typeof t.message=="string")return t.message}catch{}return`${a}: ${s.statusText}`}async function Aa(){const s=await fetch(`${Q()}/api/whatsapp/notification-config`,{headers:ss()});if(!s.ok)throw new Error(await ts(s,"Failed to fetch WhatsApp notification config"));return s.json()}async function Ta(s){const a=await fetch(`${Q()}/api/whatsapp/notification-config`,{method:"PATCH",headers:ss(!0),body:JSON.stringify(s)});if(!a.ok)throw new Error(await ts(a,"Failed to update WhatsApp notification config"));return a.json()}async function Ea(){const s=await fetch(`${Q()}/api/whatsapp/notification-config`,{method:"DELETE",headers:ss()});if(!s.ok)throw new Error(await ts(s,"Failed to reset WhatsApp notification config"));return s.json()}const Ue={messages:!0,statusChanges:!0,taskComplete:!0,errors:!0,planReady:!0,agentSpawned:!0,agentStopped:!0},fs={filter:{...Ue},recipient:""};function Pa(s,a){if(s.recipient!==a.recipient)return!1;for(const t of Cs)if(s.filter[t]!==a.filter[t])return!1;return!0}function _a({isOpen:s,onClose:a}){const{t}=Z(["config"]),[o,c]=l.useState(fs),[r,d]=l.useState(fs),[f,i]=l.useState(!0),[u,N]=l.useState(null),[j,g]=l.useState(null),[T,y]=l.useState(!1),[E,v]=l.useState(!1),p=!Pa(o,r),S=l.useCallback(async()=>{try{i(!0),N(null),g(null);const h=await Aa(),O={filter:{...Ue,...h.filter},recipient:h.recipient??""};c(O),d(O)}catch(h){N(h instanceof Error?h.message:t("config:whatsappNotifications.errors.loadFailed"))}finally{i(!1)}},[t]);l.useEffect(()=>{s&&S()},[s,S]);const F=(h,O)=>{c(z=>({...z,filter:{...z.filter,[h]:O}})),N(null),g(null)},R=h=>{c(O=>({...O,recipient:h})),N(null),g(null)},q=async()=>{try{N(null),g(null);const h=await Ta({filter:o.filter,recipient:o.recipient.trim()}),O={filter:{...Ue,...h.filter},recipient:h.recipient??""};c(O),d(O),g(t("config:whatsappNotifications.saved"))}catch(h){N(h instanceof Error?h.message:t("config:whatsappNotifications.errors.saveFailed"))}},W=()=>{c(r),N(null),g(null)},Y=async()=>{try{N(null),g(null);const h=await Ea(),O={filter:{...Ue,...h.filter},recipient:h.recipient??""};c(O),d(O),g(t("config:whatsappNotifications.resetDone"))}catch(h){N(h instanceof Error?h.message:t("config:whatsappNotifications.errors.resetFailed"))}},M=()=>{if(p){y(!0);return}a()},U=h=>{h.key==="Escape"&&(h.preventDefault(),M())};return s?e.jsxs($e,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:M,children:e.jsxs("div",{className:"whatsapp-notifications-modal",onClick:h=>h.stopPropagation(),onKeyDown:U,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:t("config:whatsappNotifications.title")}),e.jsx("button",{className:"modal-close",onClick:M,"aria-label":"Close",children:e.jsx(I,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:f?e.jsxs("div",{className:"loading-state",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:t("config:whatsappNotifications.loading")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"modal-description",children:t("config:whatsappNotifications.description")}),u&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(I,{name:"warn",size:14})}),u]}),j&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(I,{name:"check",size:14})}),j]}),e.jsxs("section",{className:"wan-section",children:[e.jsx("h3",{className:"wan-section-title",children:t("config:whatsappNotifications.sections.recipient")}),e.jsxs("div",{className:"wan-field",children:[e.jsx("label",{htmlFor:"wan-recipient",className:"wan-label",children:t("config:whatsappNotifications.recipientLabel")}),e.jsx("input",{id:"wan-recipient",type:"text",className:"wan-input",placeholder:t("config:whatsappNotifications.recipientPlaceholder"),value:o.recipient,onChange:h=>R(h.target.value)}),e.jsx("span",{className:"wan-hint",children:t("config:whatsappNotifications.recipientHint")})]})]}),e.jsxs("section",{className:"wan-section",children:[e.jsx("h3",{className:"wan-section-title",children:t("config:whatsappNotifications.sections.events")}),e.jsx("p",{className:"wan-section-hint",children:t("config:whatsappNotifications.eventsHint")}),Cs.map(h=>e.jsxs("div",{className:"wan-toggle-row",children:[e.jsxs("div",{className:"wan-toggle-info",children:[e.jsx("span",{className:"wan-toggle-title",children:t(`config:whatsappNotifications.events.${h}.title`)}),e.jsx("span",{className:"wan-toggle-help",children:t(`config:whatsappNotifications.events.${h}.help`)})]}),e.jsxs("label",{className:"wan-toggle",children:[e.jsx("input",{type:"checkbox",checked:o.filter[h],onChange:O=>F(h,O.target.checked)}),e.jsx("span",{className:"wan-toggle-track",children:e.jsx("span",{className:"wan-toggle-thumb"})})]})]},h))]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left",children:e.jsx("button",{className:"btn btn-danger",onClick:()=>v(!0),disabled:f,children:t("config:whatsappNotifications.resetToDefaults")})}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:M,children:t("config:whatsappNotifications.close")}),e.jsx("button",{className:"btn btn-secondary",onClick:W,disabled:!p||f,children:t("config:whatsappNotifications.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:q,disabled:!p||f,children:t("config:whatsappNotifications.save")})]})]})]})}),e.jsx(je,{isOpen:T,title:t("config:whatsappNotifications.unsavedTitle"),message:t("config:whatsappNotifications.unsavedMessage"),confirmLabel:t("config:whatsappNotifications.closeAnyway"),cancelLabel:t("config:whatsappNotifications.keepEditing"),variant:"danger",onConfirm:()=>{y(!1),a()},onClose:()=>y(!1)}),e.jsx(je,{isOpen:E,title:t("config:whatsappNotifications.resetToDefaults"),message:t("config:whatsappNotifications.confirmReset"),confirmLabel:t("config:whatsappNotifications.resetToDefaults"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{Y(),v(!1)},onClose:()=>v(!1)})]}):null}function As(s){const a=s.replace(/@.*$/,"");return/^\d{10,15}$/.test(a)?a.startsWith("521")&&a.length===13?`+52 1 ${a.slice(3,5)} ${a.slice(5,9)} ${a.slice(9)}`:a.startsWith("52")&&a.length===12?`+52 ${a.slice(2,4)} ${a.slice(4,8)} ${a.slice(8)}`:a.startsWith("1")&&a.length===11?`+1 ${a.slice(1,4)} ${a.slice(4,7)} ${a.slice(7)}`:`+${a}`:s}function Ia(s,a=Date.now()){const t=s*1e3,o=a-t;if(o<0)return xs(t);const c=Math.floor(o/6e4);if(c<1)return"now";if(c<60)return`${c}m`;const r=Math.floor(c/60);if(r<24)return`${r}h`;const d=Math.floor(r/24);return d===1?"yesterday":d<7?`${d}d`:xs(t)}function xs(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function $a(s){const a=s*1e3;return new Date(a).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function Ts(s){switch(s){case"image":return"📷";case"audio":return"🎤";case"video":return"📹";case"document":return"📎";case"location":return"📍";case"contact":return"👤";case"sticker":return"🌟";case"reaction":return"👍";case"unknown":return"❓";case"text":default:return null}}function Oa(s,a){return s.length<=a?s:s.slice(0,Math.max(0,a-1)).trimEnd()+"…"}function La({chats:s,selectedChatId:a,loading:t,error:o,onSelect:c,onRefresh:r,now:d}){const{t:f}=Z(["config","common"]);return e.jsxs("div",{className:"whatsapp-history-chatlist",children:[e.jsxs("div",{className:"whatsapp-history-chatlist__header",children:[e.jsx("span",{className:"whatsapp-history-chatlist__title",children:f("config:whatsappHistory.chats")}),e.jsx("button",{type:"button",className:"whatsapp-history-chatlist__refresh",onClick:r,disabled:t,"aria-label":f("config:whatsappHistory.refresh"),title:f("config:whatsappHistory.refresh"),children:"⟳"})]}),o&&e.jsx("div",{className:"whatsapp-history-chatlist__error",children:o}),t&&s.length===0&&e.jsxs("div",{className:"whatsapp-history-chatlist__loading",children:[e.jsx("span",{className:"spinner"}),e.jsx("span",{children:f("config:whatsappHistory.loadingChats")})]}),!t&&!o&&s.length===0&&e.jsx("div",{className:"whatsapp-history-chatlist__empty",children:f("config:whatsappHistory.emptyChats")}),e.jsx("ul",{className:"whatsapp-history-chatlist__items",children:s.map(i=>{const u=Ts(i.lastMessageType),N=i.lastMessagePreview||`[${i.lastMessageType}]`,j=i.chatId===a,g=As(i.chatId),T=i.isGroup?i.groupName:i.fromName,y=T||g,E=!!T&&T!==g;return e.jsx("li",{className:`whatsapp-history-chatlist__item ${j?"is-selected":""}`,children:e.jsxs("button",{type:"button",className:"whatsapp-history-chatlist__button",onClick:()=>c(i.chatId),children:[e.jsxs("div",{className:"whatsapp-history-chatlist__row",children:[e.jsx("span",{className:"whatsapp-history-chatlist__name",title:i.chatId,children:y}),e.jsx("span",{className:"whatsapp-history-chatlist__time",children:Ia(i.lastTimestamp,d)})]}),E&&e.jsx("div",{className:"whatsapp-history-chatlist__row whatsapp-history-chatlist__row--jid",children:e.jsx("span",{className:"whatsapp-history-chatlist__jid",children:g})}),e.jsxs("div",{className:"whatsapp-history-chatlist__row whatsapp-history-chatlist__row--secondary",children:[e.jsxs("span",{className:"whatsapp-history-chatlist__preview",children:[i.lastDirection==="outbound"&&e.jsx("span",{className:"whatsapp-history-chatlist__direction",children:"↗ "}),u&&e.jsxs("span",{className:"whatsapp-history-chatlist__preview-icon",children:[u," "]}),Oa(N,40)]}),i.unreadCount>0&&e.jsx("span",{className:"whatsapp-history-chatlist__unread",children:i.unreadCount})]})]})},i.chatId)})})]})}function Da({message:s}){const a=s.direction==="outbound"?"outbound":"inbound",t=Ts(s.messageType),o=(s.body??"").trim(),c=o.length>0,r=c?null:`[${s.messageType}]`;return e.jsx("div",{className:`whatsapp-history-bubble whatsapp-history-bubble--${a}`,children:e.jsxs("div",{className:"whatsapp-history-bubble__inner",children:[t&&e.jsx("span",{className:"whatsapp-history-bubble__type-icon",title:s.messageType,children:t}),c?e.jsx("span",{className:"whatsapp-history-bubble__body",children:o}):e.jsx("span",{className:"whatsapp-history-bubble__placeholder",children:r}),s.audioTranscription&&e.jsxs("span",{className:"whatsapp-history-bubble__transcription",children:["“",s.audioTranscription,"”"]}),s.mediaPath&&e.jsx("a",{className:"whatsapp-history-bubble__media-link",href:s.mediaPath,target:"_blank",rel:"noopener noreferrer",children:s.mediaFilename||"open media"}),e.jsx("span",{className:"whatsapp-history-bubble__time",children:$a(s.timestamp)})]})})}const Fa=["all","inbound","outbound"],Ra=["all","text","image","audio","video","document","sticker","location","contact","reaction","unknown"];function za({direction:s,type:a,onDirectionChange:t,onTypeChange:o,disabled:c}){const{t:r}=Z(["config"]);return e.jsxs("div",{className:"whatsapp-history-filters",children:[e.jsxs("label",{className:"whatsapp-history-filters__field",children:[e.jsx("span",{children:r("config:whatsappHistory.direction")}),e.jsx("select",{value:s,onChange:d=>t(d.target.value),disabled:c,children:Fa.map(d=>e.jsx("option",{value:d,children:r(`config:whatsappHistory.directionValues.${d}`)},d))})]}),e.jsxs("label",{className:"whatsapp-history-filters__field",children:[e.jsx("span",{children:r("config:whatsappHistory.type")}),e.jsx("select",{value:a,onChange:d=>o(d.target.value),disabled:c,children:Ra.map(d=>e.jsx("option",{value:d,children:r(`config:whatsappHistory.typeValues.${d}`)},d))})]})]})}const Ba=80;function Ma({chatId:s,messages:a,loading:t,loadingMore:o,error:c,hasMore:r,direction:d,type:f,onDirectionChange:i,onTypeChange:u,onLoadMore:N}){const{t:j}=Z(["config"]),g=l.useRef(null),T=l.useRef(null),y=l.useRef(!1),E=l.useRef(null);l.useEffect(()=>{T.current!==s&&(T.current=s,y.current=!1)},[s]),l.useLayoutEffect(()=>{g.current&&(y.current||a.length!==0&&(g.current.scrollTop=g.current.scrollHeight,y.current=!0))},[s,a.length]),l.useLayoutEffect(()=>{if(!g.current||E.current===null)return;const S=g.current.scrollHeight-E.current;E.current=null,S>0&&(g.current.scrollTop+=S)},[a.length]);const v=l.useCallback(()=>{!r||o||t||(g.current&&(E.current=g.current.scrollHeight),N())},[r,o,t,N]),p=l.useCallback(S=>{if(!y.current)return;S.currentTarget.scrollTop<=Ba&&v()},[v]);return s?e.jsxs("div",{className:"whatsapp-history-messages",children:[e.jsxs("div",{className:"whatsapp-history-messages__header",children:[e.jsx("div",{className:"whatsapp-history-messages__title",children:As(s)}),e.jsx(za,{direction:d,type:f,onDirectionChange:i,onTypeChange:u,disabled:t})]}),e.jsxs("div",{className:"whatsapp-history-messages__scroll",ref:g,onScroll:p,children:[r&&e.jsx("div",{className:"whatsapp-history-messages__load-more-row",children:e.jsx("button",{type:"button",className:"whatsapp-history-messages__load-more",onClick:v,disabled:o||t,children:j(o?"config:whatsappHistory.loadingOlder":"config:whatsappHistory.loadOlder")})}),c&&e.jsx("div",{className:"whatsapp-history-messages__error",children:c}),t&&a.length===0&&e.jsxs("div",{className:"whatsapp-history-messages__loading",children:[e.jsx("span",{className:"spinner"}),e.jsx("span",{children:j("config:whatsappHistory.loadingMessages")})]}),!t&&!c&&a.length===0&&e.jsx("div",{className:"whatsapp-history-messages__empty",children:j("config:whatsappHistory.emptyMessages")}),a.map(S=>e.jsx(Da,{message:S},Ua(S)))]})]}):e.jsx("div",{className:"whatsapp-history-messages whatsapp-history-messages--empty",children:e.jsx("div",{className:"whatsapp-history-messages__placeholder",children:j("config:whatsappHistory.selectChat")})})}function Ua(s){return typeof s.id=="number"?`id:${s.id}`:s.messageId?`mid:${s.messageId}`:`t:${s.timestamp}:${s.fromJid}:${(s.body??"").slice(0,16)}`}function Es(){const s=ee(),a={};return s&&(a.Authorization=`Bearer ${s}`),a}async function Ps(s,a){try{const t=await s.json();if(t&&typeof t.error=="string")return t.error;if(t&&typeof t.message=="string")return t.message}catch{}return`${a}: ${s.statusText}`}async function Va(s){const a=`${Q()}/api/whatsapp/chats/${encodeURIComponent(s)}`,t=await fetch(a,{headers:Es()});if(!t.ok)throw new Error(await Ps(t,"Failed to fetch WhatsApp chats"));return t.json()}async function bs(s,a,t={}){const o=new URLSearchParams;t.cursor&&o.set("cursor",t.cursor),typeof t.limit=="number"&&o.set("limit",String(t.limit)),t.direction&&o.set("direction",t.direction),t.type&&o.set("type",t.type);const c=o.toString(),r=`${Q()}/api/whatsapp/chats/${encodeURIComponent(s)}/${encodeURIComponent(a)}/messages${c?`?${c}`:""}`,d=await fetch(r,{headers:Es()});if(!d.ok)throw new Error(await Ps(d,"Failed to fetch WhatsApp messages"));return d.json()}const Ka=50;function Ha({isOpen:s,onClose:a}){const{t}=Z(["config"]),[o,c]=l.useState([]),[r,d]=l.useState(null),[f,i]=l.useState(null),[u,N]=l.useState([]),[j,g]=l.useState(!1),[T,y]=l.useState(null),[E,v]=l.useState(null),[p,S]=l.useState([]),[F,R]=l.useState(!1),[q,W]=l.useState(!1),[Y,M]=l.useState(null),[U,h]=l.useState(null),[O,z]=l.useState("all"),[K,te]=l.useState("all"),[w,D]=l.useState(()=>Date.now()),B=l.useRef(0);l.useEffect(()=>{if(!s)return;const C=window.setInterval(()=>D(Date.now()),6e4);return()=>window.clearInterval(C)},[s]),l.useEffect(()=>{if(!s)return;let C=!1;return(async()=>{var ae;try{i(null);const[ie,pe]=await Promise.all([es().catch(()=>[]),ws().catch(()=>null)]);if(C)return;c(ie);const oe=(pe==null?void 0:pe.defaultSessionId)||((ae=ie[0])==null?void 0:ae.id)||null;d(ge=>ge??oe)}catch(ie){if(C)return;i(ie instanceof Error?ie.message:String(ie))}})(),()=>{C=!0}},[s]);const m=l.useCallback(async C=>{g(!0),y(null);try{const ae=await Va(C);N(ae.chats)}catch(ae){y(ae instanceof Error?ae.message:String(ae))}finally{g(!1)}},[]);l.useEffect(()=>{!s||!r||(v(null),S([]),h(null),m(r))},[s,r,m]);const x=l.useMemo(()=>{const C={limit:Ka};return O!=="all"&&(C.direction=O),K!=="all"&&(C.type=K),C},[O,K]),L=l.useCallback(async(C,ae,ie)=>{const pe=++B.current;R(!0),M(null),S([]),h(null);try{const oe=await bs(C,ae,ie);if(pe!==B.current)return;S([...oe.messages].reverse()),h(oe.nextCursor)}catch(oe){if(pe!==B.current)return;M(oe instanceof Error?oe.message:String(oe))}finally{pe===B.current&&R(!1)}},[]);l.useEffect(()=>{!s||!r||!E||L(r,E,x)},[s,r,E,x,L]);const J=l.useCallback(async()=>{if(!(!r||!E||!U)){W(!0),M(null);try{const C=await bs(r,E,{...x,cursor:U});S(ae=>[...[...C.messages].reverse(),...ae]),h(C.nextCursor)}catch(C){M(C instanceof Error?C.message:String(C))}finally{W(!1)}}},[r,E,U,x]),ne=l.useCallback(()=>{r&&m(r)},[r,m]),_=l.useCallback(C=>{C.key==="Escape"&&(C.preventDefault(),a())},[a]);return s?e.jsx($e,{children:e.jsx("div",{className:"modal-overlay visible",onClick:a,children:e.jsxs("div",{className:"whatsapp-history-modal",onClick:C=>C.stopPropagation(),onKeyDown:_,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:t("config:whatsappHistory.title")}),e.jsx("div",{className:"whatsapp-history-modal__session",children:e.jsxs("label",{children:[e.jsx("span",{children:t("config:whatsappHistory.session")}),e.jsxs("select",{value:r??"",onChange:C=>d(C.target.value||null),disabled:o.length===0,children:[o.length===0&&e.jsx("option",{value:"",children:t("config:whatsappHistory.noSessions")}),o.map(C=>e.jsxs("option",{value:C.id,children:[C.id,C.pairedNumber?` (${C.pairedNumber})`:""]},C.id))]})]})}),e.jsx("button",{className:"modal-close",onClick:a,"aria-label":"Close",children:e.jsx(I,{name:"close",size:16})})]}),f&&e.jsx("div",{className:"whatsapp-history-modal__alert",children:f}),e.jsxs("div",{className:"whatsapp-history-modal__body",children:[e.jsx(La,{chats:u,selectedChatId:E,loading:j,error:T,onSelect:v,onRefresh:ne,now:w}),e.jsx(Ma,{chatId:E,messages:p,loading:F,loadingMore:q,error:Y,hasMore:U!==null,direction:O,type:K,onDirectionChange:z,onTypeChange:te,onLoadMore:J})]})]})})}):null}function qa({isOpen:s,onClose:a,onOpenConfig:t,onOpenNotifications:o,onOpenHistory:c}){const{t:r}=Z(["config"]);if(l.useEffect(()=>{if(!s)return;const f=i=>{i.key==="Escape"&&(i.preventDefault(),a())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s,a]),!s)return null;const d=f=>{a(),f()};return e.jsx($e,{children:e.jsx("div",{className:"modal-overlay visible",onClick:a,children:e.jsxs("div",{className:"whatsapp-hub-modal",onClick:f=>f.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("h2",{children:[e.jsx("span",{className:"whatsapp-hub-modal__icon",children:"📱"}),r("config:whatsappHub.title",{defaultValue:"WhatsApp"})]}),e.jsx("button",{className:"modal-close",onClick:a,"aria-label":"Close",children:e.jsx(I,{name:"close",size:16})})]}),e.jsxs("div",{className:"modal-body",children:[e.jsx("p",{className:"whatsapp-hub-modal__intro",children:r("config:whatsappHub.intro",{defaultValue:"Pick what you want to manage for the WhatsApp integration."})}),e.jsxs("div",{className:"whatsapp-hub-modal__options",children:[e.jsxs("button",{type:"button",className:"whatsapp-hub-modal__option",onClick:()=>d(t),children:[e.jsx("span",{className:"whatsapp-hub-modal__option-icon",children:e.jsx(I,{name:"gear",size:18})}),e.jsxs("span",{className:"whatsapp-hub-modal__option-text",children:[e.jsx("span",{className:"whatsapp-hub-modal__option-title",children:r("config:whatsappHub.config",{defaultValue:"Integration config"})}),e.jsx("span",{className:"whatsapp-hub-modal__option-desc",children:r("config:whatsappHub.configDesc",{defaultValue:"Server URL, API key, sessions and pairing."})})]})]}),e.jsxs("button",{type:"button",className:"whatsapp-hub-modal__option",onClick:()=>d(o),children:[e.jsx("span",{className:"whatsapp-hub-modal__option-icon",children:e.jsx(I,{name:"bell",size:18})}),e.jsxs("span",{className:"whatsapp-hub-modal__option-text",children:[e.jsx("span",{className:"whatsapp-hub-modal__option-title",children:r("config:whatsappHub.notifications",{defaultValue:"Notifications"})}),e.jsx("span",{className:"whatsapp-hub-modal__option-desc",children:r("config:whatsappHub.notificationsDesc",{defaultValue:"Which agent events get forwarded and to whom."})})]})]}),e.jsxs("button",{type:"button",className:"whatsapp-hub-modal__option",onClick:()=>d(c),children:[e.jsx("span",{className:"whatsapp-hub-modal__option-icon",children:e.jsx(I,{name:"hourglass",size:18})}),e.jsxs("span",{className:"whatsapp-hub-modal__option-text",children:[e.jsx("span",{className:"whatsapp-hub-modal__option-title",children:r("config:whatsappHub.history",{defaultValue:"History"})}),e.jsx("span",{className:"whatsapp-hub-modal__option-desc",children:r("config:whatsappHub.historyDesc",{defaultValue:"Browse persisted chats and messages."})})]})]})]})]})]})})})}const Ze=[{kind:"question",settingKey:"toneQuestion",label:"Agent asks you something",when:"A question, a plan to approve, or a permission request. Repeats twice up front, then every 10s until you answer (stops after 2 min).",sound:"Two taps, then a rising bend",play:ks},{kind:"notification",settingKey:"toneNotification",label:"Agent sends a notification",when:"Any agent notification: task complete, error, or a heads-up.",sound:"Soft two-note chime",play:Ns},{kind:"completion",settingKey:"toneCompletion",label:"Agent finishes working",when:"An agent stops working and goes idle.",sound:"Gentle descending arpeggio",play:yt}],Wa=[{value:"auto",label:"Auto",icon:"🕐"},{value:"dawn",label:"Dawn",icon:"🌅"},{value:"day",label:"Day",icon:"☀️"},{value:"dusk",label:"Dusk",icon:"🌇"},{value:"night",label:"Night",icon:"🌙"}],Ga=[{value:"none",label:"Grass",icon:"🌱"},{value:"concrete",label:"Concrete",icon:"🏗️"},{value:"galactic",label:"Galactic",icon:"🌌"},{value:"metal",label:"Metal",icon:"⚙️"},{value:"hex",label:"Hex",icon:"⬡"},{value:"circuit",label:"Circuit",icon:"🔌"},{value:"pokemon-stadium",label:"Pokemon",icon:"🔴"}],Ya=[{value:"static",label:"Static",icon:"🧍"},{value:"idle",label:"Idle",icon:"🚶"},{value:"walk",label:"Walk",icon:"🚶♂️"},{value:"sprint",label:"Sprint",icon:"🏃"},{value:"jump",label:"Jump",icon:"⬆️"},{value:"fall",label:"Fall",icon:"⬇️"},{value:"crouch",label:"Crouch",icon:"🧎"},{value:"sit",label:"Sit",icon:"🪑"},{value:"die",label:"Die",icon:"💀"},{value:"emote-yes",label:"Yes",icon:"👍"},{value:"emote-no",label:"No",icon:"👎"}],Ja=[{value:"normal",label:"Normal",icon:"🎨"},{value:"bw",label:"B&W",icon:"⬛"},{value:"sepia",label:"Sepia",icon:"🟤"},{value:"cool",label:"Cool",icon:"❄️"},{value:"warm",label:"Warm",icon:"🔥"},{value:"neon",label:"Neon",icon:"💜"}],Xa=[{key:"showTrees",icon:"🌳",label:"Trees"},{key:"showBushes",icon:"🌿",label:"Bushes"},{key:"showHouse",icon:"🏠",label:"House"},{key:"showLamps",icon:"💡",label:"Lamps"},{key:"showGrass",icon:"🟩",label:"Grass"},{key:"showClouds",icon:"☁️",label:"Clouds"}],Za=[{value:null,label:"Auto",color:"linear-gradient(135deg, #4a90d9 0%, #0a1a2a 100%)"},{value:"#4a90d9",label:"Day Blue",color:"#4a90d9"},{value:"#0a1a2a",label:"Night",color:"#0a1a2a"},{value:"#ff6b35",label:"Sunset",color:"#ff6b35"},{value:"#1a0a2e",label:"Purple",color:"#1a0a2e"},{value:"#2d5a27",label:"Matrix",color:"#2d5a27"},{value:"#8b0000",label:"Blood",color:"#8b0000"},{value:"#000000",label:"Void",color:"#000000"}],Qa={showTrees:"trees",showBushes:"bushes",showHouse:"house",showLamps:"lamps",showGrass:"grass",showClouds:"clouds"},en={none:"grass","pokemon-stadium":"pokemon"},sn={"emote-yes":"yes","emote-no":"no"},tn={"":"auto","#4a90d9":"dayBlue","#0a1a2a":"night","#ff6b35":"sunset","#1a0a2e":"purple","#2d5a27":"matrix","#8b0000":"blood","#000000":"void"};function se({checked:s,onChange:a}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,onChange:t=>a(t.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function Ce({options:s,value:a,onChange:t,iconOnly:o=!1}){return e.jsx("div",{className:"chip-selector",children:s.map(c=>e.jsxs("button",{className:`chip ${a===c.value?"active":""}`,onClick:()=>t(c.value),title:c.label,children:[e.jsx("span",{className:"chip-icon",children:c.icon}),!o&&e.jsx("span",{className:"chip-label",children:c.label})]},c.value))})}function A({text:s,query:a}){if(!a.trim())return e.jsx(e.Fragment,{children:s});const t=s.toLowerCase(),o=a.toLowerCase(),c=t.indexOf(o);if(c===-1)return e.jsx(e.Fragment,{children:s});const r=s.slice(0,c),d=s.slice(c,c+a.length),f=s.slice(c+a.length);return e.jsxs(e.Fragment,{children:[r,e.jsx("mark",{className:"search-highlight",children:d}),f]})}const an=[{id:"general",title:"General",keywords:["history","hide costs","grid","fps","power saving","low power","battery","bajo consumo","performance","limit","editor","external editor","language","idioma","语言","vibration","haptic","intensity","tab title","tmux","process persistence","interactive","tui","terminal","experimental","claude","stream","streaming","word by word","live text","grok","codex","app-server","app server","opencode","serve","hover","preview","tooltip","ctrl","popup","vista previa","sound","sounds","sonido","sonidos","notification","notifications","notificacion","notificaciones","volume","volumen","tone","tones","tono","chime","alert","cue","audio","mute","silence","dock","activity","recent","notification sound","silenciar","custom sound","upload sound","alerta"]},{id:"agentNames",title:"Agent Names",keywords:["agent","names","custom","characters","rename"]},{id:"defaultClass",title:"Default Spawn Class",keywords:["default","class","spawn","agent","scout","builder","random"]},{id:"appearance",title:"Appearance",keywords:["theme","appearance","color","dark","light","style","look"]},{id:"connection",title:"Connection",keywords:["backend","url","auth","token","reconnect","server","api","connect","codex","opencode","binary","path"]},{id:"scene",title:"Scene",keywords:["character","size","indicator","scale","time","dawn","day","dusk","night","auto"]},{id:"terrain",title:"Terrain",keywords:["trees","bushes","house","lamps","grass","clouds","fog","brightness","floor","sky","color","environment","battlefield","size","grid","simple","minimal","dark","clean"]},{id:"modelStyle",title:"Agent Model Style",keywords:["saturation","roughness","metalness","glow","emissive","reflections","wireframe","color mode","material","shader"]},{id:"animations",title:"Animations",keywords:["idle","working","animation","walk","run","sprint","jump","sit","crouch"]},{id:"secrets",title:"Secrets",keywords:["secrets","api","key","password","credentials","env","environment"]},{id:"claudeAccounts",title:"Claude Accounts",keywords:["claude","accounts","credentials","oauth","rate limit","session","david","profile","switch account","subscription"]},{id:"grokAccounts",title:"Grok Accounts",keywords:["grok","xai","x.ai","accounts","credentials","oauth","session","profile","switch account","subscription"]},{id:"codexAccounts",title:"Codex Accounts",keywords:["codex","openai","chatgpt","accounts","credentials","oauth","session","profile","switch account","subscription"]},{id:"systemPrompt",title:"System Prompt",keywords:["system","prompt","global","instructions","ai","agent","rules","guidelines"]},{id:"data",title:"Data",keywords:["export","import","backup","restore","save","load","json"]},{id:"integrations",title:"Integrations",keywords:["integrations","integraciones","plugins","gmail","slack","jira","calendar","docx","email","whatsapp","notifications","notification","baileys","history","historial","chat","messages","inbox","config","setup"]},{id:"workflows",title:"Workflows",keywords:["workflow","automation","state machine","editor","actions","transitions","pipeline"]},{id:"triggers",title:"Triggers",keywords:["trigger","event","webhook","cron","slack","email","jira","matching","fire"]},{id:"monitoring",title:"Monitoring",keywords:["monitoring","logs","triggers","events","history","workflow","traces","audit","timeline"]},{id:"statistics",title:"Statistics",keywords:["statistics","stats","usage","tokens","token","claude","chart","graph","pie","cost"]},{id:"experimental",title:"Experimental",keywords:["experimental","2d","view","voice","assistant","speech","tts","text to speech","echo","prompt","duplicate"]},{id:"about",title:"About",keywords:["about","version","update","credits","github","releases"]}],Qe=[{value:"auto",label:"Auto",icon:"🌐"},{value:"en",label:"English",icon:"🇺🇸"},{value:"zh-CN",label:"中文",icon:"🇨🇳"},{value:"es",label:"Español",icon:"🇪🇸"},{value:"hi",label:"हिन्दी",icon:"🇮🇳"},{value:"pt",label:"Português",icon:"🇧🇷"},{value:"ru",label:"Русский",icon:"🇷🇺"},{value:"ja",label:"日本語",icon:"🇯🇵"},{value:"de",label:"Deutsch",icon:"🇩🇪"},{value:"fr",label:"Français",icon:"🇫🇷"},{value:"it",label:"Italiano",icon:"🇮🇹"}];function nn({config:s,onChange:a,searchQuery:t="",onOpenIntegrationsModal:o,onOpenMonitoringModal:c,onOpenStatisticsModal:r,onOpenWorkflowEditor:d,onOpenTriggerManager:f}){var ls;const{t:i}=Z(["config","common"]),u=ct(),N=rt(),[j,g]=l.useState(()=>dt(_e.DEFAULT_AGENT_CLASS)||"scout"),T=ut(),y=pt(),[E,v]=l.useState(()=>mt()),[p,S]=l.useState(null),[F,R]=l.useState(null);l.useEffect(()=>{Ge().then(v)},[]);const q=async(n,P)=>{R(null),S(n);try{const V=await de(ue(`/api/custom-sounds/${n}`),{method:"POST",headers:{"Content-Type":P.type||"audio/mpeg"},body:P});if(!V.ok){const re=await V.json().catch(()=>({error:`Upload failed (${V.status})`}));throw new Error(re.error||`Upload failed (${V.status})`)}const le=await Ge();v({...le});const be=Ze.find(re=>re.kind===n);be&&k.updateSettings({[be.settingKey]:Ie}),Ye(Ie,u.notificationSoundVolume,n)}catch(V){R(V instanceof Error?V.message:"Upload failed")}finally{S(null)}},W=async n=>{R(null);try{await de(ue(`/api/custom-sounds/${n}`),{method:"DELETE"}),Ct({[n]:null});const P=await Ge();v({...P});const V=Ze.find(le=>le.kind===n);V&&k.getSettings()[V.settingKey]===Ie&&k.updateSettings({[V.settingKey]:At[n]})}catch(P){R(P instanceof Error?P.message:"Failed to reset sound")}},[Y,M]=l.useState(u.historyLimit),[U,h]=l.useState(()=>ht()),[O,z]=l.useState(!1),[K,te]=l.useState(""),[w,D]=l.useState(()=>ee()),[B,m]=l.useState(!1),[x,L]=l.useState(!1),[J,ne]=l.useState(""),[_,C]=l.useState(!1),[ae,ie]=l.useState(!1),[pe,oe]=l.useState(!1),[ge,ke]=l.useState(!1),[Ae,me]=l.useState(!1),[Te,fe]=l.useState(""),[xe,De]=l.useState(!1);l.useEffect(()=>{Jt().then(fe).catch(()=>{})},[]),l.useEffect(()=>{Gt().then(n=>{n!==u.experimentalEchoPrompt&&k.updateSettings({experimentalEchoPrompt:n})}).catch(()=>{})},[]),l.useEffect(()=>{Zt().then(n=>{n!==u.tmuxMode&&k.updateSettings({tmuxMode:n})}).catch(()=>{})},[]),l.useEffect(()=>{ea().then(n=>{n!==u.interactiveMode&&k.updateSettings({interactiveMode:n})}).catch(()=>{})},[]),l.useEffect(()=>{ta().then(n=>{n!==u.codexAppServerMode&&k.updateSettings({codexAppServerMode:n})}).catch(()=>{})},[]),l.useEffect(()=>{na().then(n=>{n!==u.opencodeServerMode&&k.updateSettings({opencodeServerMode:n})}).catch(()=>{})},[]),l.useEffect(()=>gt(n=>{h(n),z(!1)}),[]);const Ve=Wa.map(n=>({...n,label:i(`config:time.${n.value}`)})),Se=Ga.map(n=>({...n,label:i(`config:floor.${en[n.value]||n.value}`)})),Fe=Ya.map(n=>({...n,label:i(`config:animation.${sn[n.value]||n.value}`)})),Ke=Ja.map(n=>({...n,label:i(`config:colorMode.${n.value}`)})),He=Xa.map(n=>({...n,label:i(`config:terrain.${Qa[n.key]}`)})),qe=Za.map(n=>({...n,label:i(`config:sky.${tn[n.value??""]}`)})),ve=t.trim()?an.filter(n=>{const P=t.toLowerCase();return n.title.toLowerCase().includes(P)||n.keywords.some(V=>V.toLowerCase().includes(P))}).map(n=>n.id):null,$=n=>ve?ve.includes(n):!0,Ee=$("integrations"),he=u.customAgentNames||[],We=he.length>0?he:ft,Re=()=>{const n=J.trim();n&&!he.includes(n)&&(k.updateSettings({customAgentNames:[...he,n]}),ne(""))},b=n=>{k.updateSettings({customAgentNames:he.filter(P=>P!==n)})},H=()=>{k.updateSettings({customAgentNames:[]})},ce=()=>{const n=K.trim();if(n){if(U.includes(n)){te("");return}h([...U,n]),z(!0),te("")}},ye=n=>{h(U.filter((P,V)=>V!==n)),z(!0)},as=(n,P)=>{const V=n+P;if(V<0||V>=U.length)return;const le=U.slice();[le[n],le[V]]=[le[V],le[n]],h(le),z(!0)},_s=()=>{Tt(U),z(!1),Xe()},Is=n=>{D(n),m(!0)},ns=()=>{ze(_e.AUTH_TOKEN,w),m(!1),Xe()},$s=n=>{fe(n),De(!0)},is=()=>{Xt(Te).catch(()=>{}),De(!1)},we=n=>{a({...s,terrain:{...s.terrain,...n}})},Ne=n=>{a({...s,modelStyle:{...s.modelStyle,...n}})},os=n=>{a({...s,animations:{...s.animations,...n}})},Os=n=>{M(n),k.updateSettings({historyLimit:n})},Ls=n=>{const P=s.terrain[n];typeof P=="boolean"&&we({[n]:!P})},X=t.trim().length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-section",children:[ve&&ve.length===0&&e.jsx("div",{className:"config-no-results",children:i("config:noResults",{query:t})}),$("general")&&e.jsxs(G,{title:i("config:sections.general"),storageKey:"general",defaultOpen:!0,forceOpen:X&&$("general"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:general.history"),query:t})}),e.jsx("input",{type:"number",className:"config-input config-input-sm",value:Y,onChange:n=>Os(parseInt(n.target.value)||100),min:50,max:2e3,step:50})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:general.hideCosts"),query:t})}),e.jsx(se,{checked:u.hideCost,onChange:n=>k.updateSettings({hideCost:n})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:i("config:general.streamTextLiveTitle"),children:e.jsx(A,{text:i("config:general.streamTextLive"),query:t})}),e.jsx(se,{checked:u.streamTextLive!==!1,onChange:n=>k.updateSettings({streamTextLive:n})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:i("config:general.toolHoverPreviewTitle"),children:e.jsx(A,{text:i("config:general.toolHoverPreview"),query:t})}),e.jsx(se,{checked:u.toolHoverPreview!==!1,onChange:n=>k.updateSettings({toolHoverPreview:n})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:"Where the strip of recently-active and currently-working agent thumbnails sits.",children:e.jsx(A,{text:"Agent activity dock",query:t})}),e.jsx("select",{className:"config-select",value:T,onChange:n=>jt(n.target.value),children:xt.map(n=>e.jsx("option",{value:n,children:bt[n]},n))})]}),T!=="hidden"&&e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:"How many recently-active agents the dock shows alongside the ones working right now. 0 shows only working agents.",children:e.jsx(A,{text:"Recent agents in dock",query:t})}),e.jsx("input",{type:"number",className:"config-input config-input-sm",value:y,min:0,max:20,step:1,onChange:n=>vt(parseInt(n.target.value,10)||0)})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:general.grid"),query:t})}),e.jsx(se,{checked:s.gridVisible,onChange:n=>a({...s,gridVisible:n})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:general.showFPS"),query:t})}),e.jsx(se,{checked:u.showFPS,onChange:n=>k.updateSettings({showFPS:n})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:general.fpsLimit"),query:t})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"120",step:"10",value:s.fpsLimit,onChange:n=>a({...s,fpsLimit:parseInt(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.fpsLimit===0?"∞":s.fpsLimit})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Experimental: Reduce FPS when idle to save power",children:[e.jsx(A,{text:i("config:general.powerSaving"),query:t})," ",e.jsx(I,{name:"bolt",size:12})]}),e.jsx(se,{checked:u.powerSaving,onChange:n=>k.updateSettings({powerSaving:n})})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Battery saver for mobile: caps scene FPS (20 active / 5 idle), freezes decorative animations and disables word-by-word streaming. Off = normal mode.",children:[e.jsx(A,{text:i("config:general.lowPowerMode"),query:t})," ",e.jsx(I,{name:"bolt",size:12})]}),e.jsx(se,{checked:u.lowPowerMode===!0,onChange:n=>k.updateSettings({lowPowerMode:n})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:"Wrap agent processes in tmux sessions so they survive server restarts (requires tmux installed)",children:e.jsx(A,{text:i("config:general.tmuxMode"),query:t})}),e.jsx(se,{checked:u.tmuxMode,onChange:async n=>{k.updateSettings({tmuxMode:n});try{await Qt(n)}catch(P){console.error("Failed to sync tmux mode setting to server:",P)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Experimental: run Claude agents as the real interactive `claude` TUI inside tmux, reconstructing the conversation from the session transcript (requires tmux). Takes effect on server restart.",children:[e.jsx(A,{text:i("config:general.interactiveMode"),query:t})," ",e.jsx(I,{name:"bolt",size:12})]}),e.jsx(se,{checked:u.interactiveMode,onChange:async n=>{k.updateSettings({interactiveMode:n});try{await sa(n)}catch(P){console.error("Failed to sync interactive mode setting to server:",P)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Experimental: run Codex agents through a persistent `codex app-server` so replies stream word-by-word (token deltas) instead of appearing as one block. The app-server runs detached and survives commander restarts — in-flight turns keep running and reconnect automatically. Applies to new Codex turns; no server restart needed to toggle.",children:[e.jsx(A,{text:i("config:general.codexAppServerMode"),query:t})," ",e.jsx(I,{name:"bolt",size:12})]}),e.jsx(se,{checked:u.codexAppServerMode,onChange:async n=>{k.updateSettings({codexAppServerMode:n});try{await aa(n)}catch(P){console.error("Failed to sync codex app-server mode setting to server:",P)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Experimental: run OpenCode agents through a persistent, detached `opencode serve` HTTP server so replies stream word-by-word (token deltas over SSE) instead of appearing as one block. The server survives commander restarts — in-flight turns keep running and reconnect automatically. Applies to new OpenCode turns; no server restart needed to toggle.",children:[e.jsx(A,{text:i("config:general.opencodeServerMode"),query:t})," ",e.jsx(I,{name:"bolt",size:12})]}),e.jsx(se,{checked:u.opencodeServerMode,onChange:async n=>{k.updateSettings({opencodeServerMode:n});try{await ia(n)}catch(P){console.error("Failed to sync opencode server mode setting to server:",P)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:general.vibrationIntensity"),query:t})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"5",step:"1",value:u.vibrationIntensity,onChange:n=>k.updateSettings({vibrationIntensity:parseInt(n.target.value)})}),e.jsx("span",{className:"config-value",children:u.vibrationIntensity===0?i("config:vibrationValues.off"):u.vibrationIntensity===1?i("config:vibrationValues.ultraLight"):u.vibrationIntensity===2?i("config:vibrationValues.veryLight"):u.vibrationIntensity===3?i("config:vibrationValues.light"):u.vibrationIntensity===4?i("config:vibrationValues.medium"):i("config:vibrationValues.heavy")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:"Play pleasant sounds: a chime for agent notifications, a distinctive rising cue when an agent asks you a question (repeats until answered), and a resolving cue when an agent finishes its work.",children:e.jsx(A,{text:"Notification sounds",query:t})}),e.jsx(se,{checked:u.notificationSoundEnabled,onChange:n=>{k.updateSettings({notificationSoundEnabled:n}),n&&Ns(u.notificationSoundVolume,u.toneNotification)}})]}),u.notificationSoundEnabled&&e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:"Notification sound volume",query:t})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:rs,step:"1",value:u.notificationSoundVolume,onChange:n=>{const P=parseInt(n.target.value);k.updateSettings({notificationSoundVolume:P}),ks(P,u.toneQuestion)}}),e.jsx("span",{className:"config-value",children:u.notificationSoundVolume===0?i("config:vibrationValues.off"):`${u.notificationSoundVolume}/${rs}`})]}),u.notificationSoundEnabled&&u.notificationSoundVolume>0&&e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:"Sounds per event",query:t})}),e.jsx("div",{className:"config-sound-hint",children:'Pick a tone for each event — or upload your own file (mp3, wav, ogg, m4a — max 5MB), which is stored on the commander so every device hears it. "None" silences that event.'}),Ze.map(n=>{var be;const P=!!E[n.kind],V=u[n.settingKey],le=P&&V===Ie;return e.jsxs("div",{className:"config-sound-row",children:[e.jsxs("div",{className:"config-sound-info",children:[e.jsxs("div",{className:"config-sound-head",children:[e.jsx("span",{className:"config-sound-name",children:n.label}),e.jsx("span",{className:`config-sound-badge${le?" custom":""}`,children:le?"Your file":((be=wt(V))==null?void 0:be.label)??n.sound})]}),e.jsx("div",{className:"config-sound-when",children:n.when})]}),e.jsxs("div",{className:"config-sound-actions",children:[e.jsxs("select",{className:"config-select",value:V,onChange:re=>{const Pe=re.target.value;k.updateSettings({[n.settingKey]:Pe}),Ye(Pe,u.notificationSoundVolume,n.kind)},children:[P&&e.jsx("option",{value:Ie,children:"Your uploaded file"}),Nt.map(re=>e.jsx("option",{value:re.id,children:re.label},re.id))]}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>void Ye(V,u.notificationSoundVolume,n.kind),disabled:ds(V),title:ds(V)?"This event is silenced — pick a tone to hear it":"Hear the sound that plays for this event",children:"▶"}),e.jsxs("label",{className:"config-btn config-btn-sm config-sound-upload",title:"Replace this sound with your own audio file (mp3, wav, ogg, m4a — max 5MB)",children:[p===n.kind?"Uploading…":"Upload",e.jsx("input",{type:"file",accept:"audio/*",style:{display:"none"},onChange:re=>{var cs;const Pe=(cs=re.target.files)==null?void 0:cs[0];re.target.value="",Pe&&q(n.kind,Pe)}})]}),P&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>void W(n.kind),title:"Delete your file and go back to a built-in tone",children:"Reset"})]})]},n.kind)}),F&&e.jsx("div",{className:"config-sound-error",children:F})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:general.externalEditor"),query:t})}),e.jsx("input",{type:"text",className:"config-input",placeholder:i("config:general.externalEditorPlaceholder"),value:u.externalEditorCommand||"",onChange:n=>k.updateSettings({externalEditorCommand:n.target.value})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:general.tabTitle"),query:t})}),e.jsx("input",{type:"text",className:"config-input",placeholder:i("config:general.tabTitlePlaceholder"),value:u.tabTitle||"",onChange:n=>k.updateSettings({tabTitle:n.target.value})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:general.language"),query:t})}),e.jsx(Ce,{options:Qe,value:localStorage.getItem("tide-commander-language-mode")==="manual"?((ls=Qe.find(n=>n.value!=="auto"&&Je.language.startsWith(n.value.split("-")[0])))==null?void 0:ls.value)||"en":"auto",onChange:n=>{var P;if(n==="auto"){localStorage.setItem("tide-commander-language-mode","auto");const V=navigator.language,le=((P=Qe.find(be=>be.value!=="auto"&&V.startsWith(be.value.split("-")[0])))==null?void 0:P.value)||"en";Je.changeLanguage(le)}else localStorage.setItem("tide-commander-language-mode","manual"),Je.changeLanguage(n)}})]})]}),$("agentNames")&&e.jsx(G,{title:i("config:sections.agentNames"),storageKey:"agentNames",defaultOpen:!1,forceOpen:X&&$("agentNames"),children:e.jsxs("div",{className:"agent-names-section",children:[e.jsx("span",{className:"config-hint",children:he.length>0?i("config:agentNames.customConfigured",{count:he.length}):i("config:agentNames.usingDefaults")}),e.jsxs("div",{className:"agent-names-input-row",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",placeholder:i("config:agentNames.addPlaceholder"),value:J,onChange:n=>ne(n.target.value),onKeyDown:n=>{n.key==="Enter"&&Re()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:Re,disabled:!J.trim(),title:i("config:agentNames.addName"),children:"+"})]}),e.jsx("div",{className:"agent-names-list",children:We.map((n,P)=>e.jsxs("div",{className:"agent-name-chip",children:[e.jsx("span",{className:"agent-name-text",children:n}),he.length>0&&e.jsx("button",{className:"agent-name-remove",onClick:()=>b(n),title:i("common:buttons.remove"),children:"x"})]},`${n}-${P}`))}),he.length>0&&e.jsx("button",{className:"config-btn config-btn-link",onClick:H,children:i("common:buttons.resetToDefaults")})]})}),$("defaultClass")&&e.jsx(G,{title:"Default Spawn Class",storageKey:"defaultClass",defaultOpen:!1,forceOpen:X&&$("defaultClass"),children:e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-hint",children:'Class pre-selected when the spawn modal opens. "Random" picks a different class each time.'}),e.jsxs("div",{className:"agent-names-list",style:{flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:[e.jsx("div",{className:`agent-name-chip${j==="random"?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{g("random"),ze(_e.DEFAULT_AGENT_CLASS,"random")},children:e.jsx("span",{className:"agent-name-text",children:"🎲 Random"})}),Object.entries(kt).map(([n,P])=>e.jsx("div",{className:`agent-name-chip${j===n?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{g(n),ze(_e.DEFAULT_AGENT_CLASS,n)},children:e.jsxs("span",{className:"agent-name-text",children:[P.icon," ",n.charAt(0).toUpperCase()+n.slice(1)]})},n)),N.map(n=>e.jsx("div",{className:`agent-name-chip${j===n.id?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{g(n.id),ze(_e.DEFAULT_AGENT_CLASS,n.id)},children:e.jsxs("span",{className:"agent-name-text",children:[n.icon," ",n.name]})},n.id))]})]})}),$("appearance")&&e.jsx(G,{title:i("config:sections.appearance"),storageKey:"appearance",defaultOpen:!1,forceOpen:X&&$("appearance"),children:e.jsx(da,{})}),$("connection")&&e.jsxs(G,{title:i("config:sections.connection"),storageKey:"connection",defaultOpen:!1,forceOpen:X&&$("connection"),children:[e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:connection.backendUrl"),query:t})}),e.jsx("div",{className:"backend-urls-list",children:U.map((n,P)=>e.jsxs("div",{className:"backend-url-row",children:[e.jsx("span",{className:"backend-url-priority",title:i("config:connection.priorityLabel",{defaultValue:"Priority"}),children:P+1}),e.jsx("span",{className:"backend-url-text",title:n,children:n}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>as(P,-1),disabled:P===0,title:i("config:connection.moveUp",{defaultValue:"Move up"}),children:"↑"}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>as(P,1),disabled:P===U.length-1,title:i("config:connection.moveDown",{defaultValue:"Move down"}),children:"↓"}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>ye(P),title:i("common:buttons.remove"),children:"x"})]},`${n}-${P}`))}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:K,onChange:n=>te(n.target.value),placeholder:i("config:connection.addUrlPlaceholder",{defaultValue:"http://host:port"}),onKeyDown:n=>{n.key==="Enter"&&ce()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:ce,disabled:!K.trim(),title:i("config:connection.addUrl",{defaultValue:"Add URL"}),children:"+"}),O&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:_s,title:i("config:connection.saveAndReconnect"),children:i("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:i("config:connection.urlsHint",{defaultValue:"Tried in order on connect; the first reachable host wins. Leave empty for auto-detect."})})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:connection.authToken"),query:t})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:x?"text":"password",className:"config-input config-input-full",value:w,onChange:n=>Is(n.target.value),placeholder:i("config:connection.tokenPlaceholder"),onKeyDown:n=>{n.key==="Enter"&&B&&ns()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>L(!x),title:i(x?"config:connection.hideToken":"config:connection.showToken"),children:e.jsx(I,{name:x?"eye-closed":"eye",size:14})}),B&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:ns,title:i("config:connection.saveAndReconnect"),children:i("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:i("config:connection.tokenRequired")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:connection.codexBinaryPath"),query:t})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:Te,onChange:n=>$s(n.target.value),placeholder:i("config:connection.codexBinaryPathPlaceholder"),onKeyDown:n=>{n.key==="Enter"&&xe&&is()}}),xe&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:is,children:i("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:i("config:connection.codexBinaryPathHint")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("common:buttons.reconnect"),query:t})}),e.jsx("button",{className:"config-btn",onClick:()=>Xe(),title:"Force reconnect to server",children:i("common:buttons.reconnect")})]})]}),$("scene")&&e.jsxs(G,{title:i("config:sections.scene"),storageKey:"scene",defaultOpen:!1,forceOpen:X&&$("scene"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:scene.characterSize"),query:t})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"3.0",step:"0.1",value:s.characterScale,onChange:n=>a({...s,characterScale:parseFloat(n.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.characterScale.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:scene.scale2d",{defaultValue:"2D Scale"}),query:t})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale2d,onChange:n=>a({...s,scale2d:parseFloat(n.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale2d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:scene.scale3d",{defaultValue:"3D Scale"}),query:t})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale3d,onChange:n=>a({...s,scale3d:parseFloat(n.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale3d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:scene.show2DTaskLabels",{defaultValue:"Show 2D task labels"}),query:t})}),e.jsx(se,{checked:s.show2DTaskLabels,onChange:n=>a({...s,show2DTaskLabels:n})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:scene.time"),query:t})}),e.jsx(Ce,{options:Ve,value:s.timeMode,onChange:n=>a({...s,timeMode:n}),iconOnly:!0})]})]}),$("terrain")&&e.jsxs(G,{title:i("config:sections.terrain"),storageKey:"terrain",defaultOpen:!1,forceOpen:X&&$("terrain"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:terrainSettings.simpleMode",{defaultValue:"Simple Mode"}),query:t})}),e.jsx(se,{checked:s.terrain.simpleMode??!1,onChange:n=>we({simpleMode:n})})]}),e.jsx("div",{className:"terrain-icons",style:{opacity:s.terrain.simpleMode?.4:1,pointerEvents:s.terrain.simpleMode?"none":"auto"},children:He.map(n=>e.jsx("button",{className:`terrain-icon-btn ${s.terrain[n.key]?"active":""}`,onClick:()=>Ls(n.key),title:n.label,children:n.icon},n.key))}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:terrainSettings.fog"),query:t})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.terrain.fogDensity,onChange:n=>we({fogDensity:parseFloat(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.fogDensity===0?i("config:fogValues.off"):s.terrain.fogDensity<=1?i("config:fogValues.low"):i("config:fogValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:terrainSettings.brightness"),query:t})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.2",max:"2",step:"0.1",value:s.terrain.brightness,onChange:n=>we({brightness:parseFloat(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.brightness<=.5?i("config:brightnessValues.dark"):s.terrain.brightness<=1.2?i("config:brightnessValues.normal"):i("config:brightnessValues.bright")})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:terrainSettings.floor"),query:t})}),e.jsx(Ce,{options:Se,value:s.terrain.floorStyle,onChange:n=>we({floorStyle:n}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:terrainSettings.sky"),query:t})}),e.jsx("div",{className:"sky-color-selector",children:qe.map(n=>e.jsx("button",{className:`sky-color-btn ${s.terrain.skyColor===n.value?"active":""}`,onClick:()=>we({skyColor:n.value}),title:n.label,style:{background:n.color}},n.value??"auto"))})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:terrainSettings.battlefieldSize"),query:t})}),e.jsx("input",{type:"range",className:"config-slider",min:"30",max:"200",step:"10",value:s.terrain.battlefieldSize,onChange:n=>we({battlefieldSize:parseInt(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.battlefieldSize})]})]}),$("modelStyle")&&e.jsxs(G,{title:i("config:sections.modelStyle"),storageKey:"modelStyle",defaultOpen:!1,forceOpen:X&&$("modelStyle"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:modelStyleSettings.saturation"),query:t})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.modelStyle.saturation,onChange:n=>Ne({saturation:parseFloat(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.saturation<=.3?i("config:saturationValues.gray"):s.modelStyle.saturation<=1.2?i("config:saturationValues.normal"):i("config:saturationValues.vivid")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:modelStyleSettings.roughness"),query:t})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.roughness,onChange:n=>Ne({roughness:parseFloat(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.roughness<0?i("config:roughnessValues.auto"):s.modelStyle.roughness<=.3?i("config:roughnessValues.glossy"):s.modelStyle.roughness<=.7?i("config:roughnessValues.normal"):i("config:roughnessValues.matte")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:modelStyleSettings.metalness"),query:t})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.metalness,onChange:n=>Ne({metalness:parseFloat(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.metalness<0?i("config:metalnessValues.auto"):s.modelStyle.metalness<=.3?i("config:metalnessValues.plastic"):s.modelStyle.metalness<=.7?i("config:metalnessValues.mixed"):i("config:metalnessValues.metal")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:modelStyleSettings.glow"),query:t})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"1",step:"0.05",value:s.modelStyle.emissiveBoost,onChange:n=>Ne({emissiveBoost:parseFloat(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.emissiveBoost<=.1?i("config:glowValues.off"):s.modelStyle.emissiveBoost<=.4?i("config:glowValues.low"):s.modelStyle.emissiveBoost<=.7?i("config:glowValues.med"):i("config:glowValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:modelStyleSettings.reflections"),query:t})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"2",step:"0.1",value:s.modelStyle.envMapIntensity,onChange:n=>Ne({envMapIntensity:parseFloat(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.envMapIntensity<0?i("config:reflectionValues.auto"):s.modelStyle.envMapIntensity<=.3?i("config:reflectionValues.low"):s.modelStyle.envMapIntensity<=1?i("config:reflectionValues.normal"):i("config:reflectionValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:modelStyleSettings.wireframe"),query:t})}),e.jsx(se,{checked:s.modelStyle.wireframe,onChange:n=>Ne({wireframe:n})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:modelStyleSettings.colorMode"),query:t})}),e.jsx(Ce,{options:Ke,value:s.modelStyle.colorMode,onChange:n=>Ne({colorMode:n}),iconOnly:!0})]})]}),$("animations")&&e.jsxs(G,{title:i("config:sections.animations"),storageKey:"animations",defaultOpen:!1,forceOpen:X&&$("animations"),children:[e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:animationSettings.idle"),query:t})}),e.jsx(Ce,{options:Fe,value:s.animations.idleAnimation,onChange:n=>os({idleAnimation:n}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:animationSettings.working"),query:t})}),e.jsx(Ce,{options:Fe,value:s.animations.workingAnimation,onChange:n=>os({workingAnimation:n}),iconOnly:!0})]})]}),$("secrets")&&e.jsx(G,{title:i("config:sections.secrets"),storageKey:"secrets",defaultOpen:!1,forceOpen:X&&$("secrets"),children:e.jsx(Kt,{})}),$("claudeAccounts")&&e.jsx(G,{title:i("config:sections.claudeAccounts",{defaultValue:"Claude Accounts"}),storageKey:"claudeAccounts",defaultOpen:!1,forceOpen:X&&$("claudeAccounts"),children:e.jsx(St,{})}),$("grokAccounts")&&e.jsx(G,{title:i("config:sections.grokAccounts",{defaultValue:"Grok Accounts"}),storageKey:"grokAccounts",defaultOpen:!1,forceOpen:X&&$("grokAccounts"),children:e.jsx(ms,{provider:"grok"})}),$("codexAccounts")&&e.jsx(G,{title:i("config:sections.codexAccounts",{defaultValue:"Codex Accounts"}),storageKey:"codexAccounts",defaultOpen:!1,forceOpen:X&&$("codexAccounts"),children:e.jsx(ms,{provider:"codex"})}),$("systemPrompt")&&e.jsx(G,{title:i("config:sections.systemPrompt"),storageKey:"systemPrompt",defaultOpen:!1,forceOpen:X&&$("systemPrompt"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:i("config:systemPrompt.title"),query:t})}),e.jsx("button",{className:"config-button",onClick:()=>C(!0),children:i("config:systemPrompt.editPrompt")})]})}),$("data")&&e.jsx(G,{title:i("config:sections.data"),storageKey:"data",defaultOpen:!1,forceOpen:X&&$("data"),children:e.jsx(ra,{})}),Ee&&e.jsx(G,{title:i("config:sections.integrations"),storageKey:"integrations",defaultOpen:!1,forceOpen:X&&Ee,children:e.jsx(fa,{onOpenModal:n=>{n==="whatsapp"?me(!0):o==null||o(n)}})}),$("workflows")&&e.jsxs(G,{title:"Workflows",storageKey:"workflows",defaultOpen:!1,forceOpen:X&&$("workflows"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(A,{text:"Create and manage automated workflow pipelines with visual state machine editor",query:t})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>d==null?void 0:d(),children:"Open Workflow Editor"})})]}),$("triggers")&&e.jsxs(G,{title:"Triggers",storageKey:"triggers",defaultOpen:!1,forceOpen:X&&$("triggers"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(A,{text:"Create and manage event-driven triggers that fire agents with templates",query:t})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>f==null?void 0:f(),children:"Open Trigger Manager"})})]}),$("monitoring")&&e.jsxs(G,{title:"Monitoring",storageKey:"monitoring",defaultOpen:!1,forceOpen:X&&$("monitoring"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(A,{text:"View event logs, trigger history, workflow traces, and system stats",query:t})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>c==null?void 0:c(),children:"Open Monitoring & Logs"})})]}),$("statistics")&&e.jsxs(G,{title:"Statistics",storageKey:"statistics",defaultOpen:!1,forceOpen:X&&$("statistics"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(A,{text:"View token usage charts and system-wide agent statistics",query:t})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>r==null?void 0:r(),children:"Open Statistics"})})]}),$("experimental")&&e.jsxs(G,{title:i("config:sections.experimental"),storageKey:"experimental",defaultOpen:!1,forceOpen:X&&$("experimental"),children:[e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Lightweight 2D top-down view for better performance",children:[e.jsx(A,{text:i("config:experimental.2dView"),query:t})," ",e.jsx(I,{name:"map",size:12})]}),e.jsx(se,{checked:u.experimental2DView,onChange:n=>k.updateSettings({experimental2DView:n})})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Voice assistant for hands-free agent control",children:[e.jsx(A,{text:i("config:experimental.voiceAssistant"),query:t})," ",e.jsx(I,{name:"microphone",size:12})]}),e.jsx(se,{checked:u.experimentalVoiceAssistant,onChange:n=>k.updateSettings({experimentalVoiceAssistant:n})})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Text-to-speech for reading agent responses",children:[e.jsx(A,{text:i("config:experimental.tts"),query:t})," ",e.jsx(I,{name:"speaker-on",size:12})]}),e.jsx(se,{checked:u.experimentalTTS,onChange:n=>k.updateSettings({experimentalTTS:n})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:"Duplicate system prompt for improved LLM attention coverage. Increases input token usage.",children:e.jsx(A,{text:i("config:experimental.echoPrompt"),query:t})}),e.jsx(se,{checked:u.experimentalEchoPrompt,onChange:async n=>{k.updateSettings({experimentalEchoPrompt:n});try{await Yt(n)}catch(P){console.error("Failed to sync echo prompt setting to server:",P)}}})]}),e.jsx("span",{className:"config-hint",children:i("config:experimental.hint")})]}),$("about")&&e.jsx(G,{title:i("config:sections.about"),storageKey:"about",defaultOpen:!1,forceOpen:X&&$("about"),children:e.jsx(ha,{})})]}),e.jsx(wa,{isOpen:_,onClose:()=>C(!1)}),e.jsx(Ca,{isOpen:ae,onClose:()=>ie(!1)}),e.jsx(_a,{isOpen:pe,onClose:()=>oe(!1)}),e.jsx(Ha,{isOpen:ge,onClose:()=>ke(!1)}),e.jsx(qa,{isOpen:Ae,onClose:()=>me(!1),onOpenConfig:()=>ie(!0),onOpenNotifications:()=>oe(!0),onOpenHistory:()=>ke(!0)})]})}function dn({onConfigChange:s,onToolChange:a,config:t,isOpen:o,onClose:c,onOpenBuildingModal:r,onOpenAreaExplorer:d,onOpenIntegrationsModal:f,onOpenMonitoringModal:i,onOpenStatisticsModal:u,onOpenWorkflowEditor:N,onOpenTriggerManager:j}){const{t:g}=Z(["config","common"]),T=Et(),y=Pt(),E=_t(),v=It(),p=$t(),S=Array.from(T.values()),F=Array.from(y.values()),[R,q]=l.useState(""),W=l.useRef(null);if(l.useEffect(()=>{const h=O=>{O.key==="Escape"&&o&&c()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[o,c]),l.useEffect(()=>{if(o&&W.current){if(typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches)return;const O=setTimeout(()=>{var z;(z=W.current)==null||z.focus()},50);return()=>clearTimeout(O)}},[o]),!o)return null;const Y=h=>{a(p===h?null:h)},M=h=>{k.selectArea(v===h?null:h),a("select")},U=(h,O)=>{h.stopPropagation(),k.deleteArea(O)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"toolbox-backdrop",onClick:c}),e.jsxs("aside",{className:"toolbox",children:[e.jsxs("div",{className:"toolbox-header",children:[e.jsx("span",{children:g("config:title")}),e.jsx("button",{className:"toolbox-close-btn",onClick:c,title:g("common:buttons.close"),children:"×"})]}),e.jsxs("div",{className:"toolbox-search",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{ref:W,type:"text",placeholder:g("config:searchPlaceholder"),value:R,onChange:h=>q(h.target.value),className:"toolbox-search-input"}),R&&e.jsx("button",{className:"toolbox-search-clear",onClick:()=>q(""),children:"×"})]}),e.jsxs("div",{className:"toolbox-content",children:[e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsxs(G,{title:g("config:areas.title",{count:S.length}),storageKey:"areas",children:[e.jsxs("div",{className:"tool-buttons",children:[e.jsx("button",{className:`tool-btn ${p==="select"?"active":""}`,onClick:()=>Y("select"),title:g("config:tools.select"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"})})})}),e.jsx("button",{className:`tool-btn ${p==="rectangle"?"active":""}`,onClick:()=>Y("rectangle"),title:g("config:tools.rectangle"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})})})}),e.jsx("button",{className:`tool-btn ${p==="circle"?"active":""}`,onClick:()=>Y("circle"),title:g("config:tools.circle"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("circle",{cx:"12",cy:"12",r:"9"})})})})]}),e.jsx("div",{className:"areas-list",children:S.length===0?e.jsx("div",{className:"areas-empty",children:g("config:areas.drawToCreate")}):S.map(h=>e.jsx(zt,{area:h,isSelected:v===h.id,onClick:()=>M(h.id),onDelete:O=>U(O,h.id)},h.id))})]})}),v&&e.jsx(Vt,{area:T.get(v),onClose:()=>k.selectArea(null),onOpenFolder:d}),e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsx(G,{title:g("config:buildings.title",{count:F.length}),storageKey:"buildings",headerExtra:e.jsx("button",{className:"add-building-btn",onClick:h=>{h.stopPropagation(),r==null||r()},title:g("config:buildings.addBuilding"),children:"+"}),children:e.jsx("div",{className:"buildings-list",children:F.length===0?e.jsx("div",{className:"buildings-empty",children:g("config:buildings.clickToAdd")}):F.map(h=>e.jsx(Bt,{building:h,isSelected:E.has(h.id),onClick:()=>{k.selectBuilding(E.has(h.id)?null:h.id)},onEdit:()=>r==null?void 0:r(h.id)},h.id))})})}),E.size===1&&(()=>{const h=Array.from(E)[0],O=y.get(h);return O?e.jsx(Mt,{building:O,onClose:()=>k.selectBuilding(null),onOpenModal:()=>r==null?void 0:r(h)}):null})(),e.jsx(nn,{config:t,onChange:s,searchQuery:R,onOpenIntegrationsModal:f,onOpenMonitoringModal:i,onOpenStatisticsModal:u,onOpenWorkflowEditor:N,onOpenTriggerManager:j})]})]})]})}export{dn as Toolbox};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{as as He,r as t,s as I,d as ye,at as Ee,c as Oe,j as e,I as O,u as fe,au as _e,av as Te,aw as Be,ax as Ue,ay as Ke,az as We,a3 as De,aA as Ve,aB as Ge,aC as qe,aD as Ye,z as Je,m as Me,S as le,F as Xe,C as Qe,n as Ze,w as Ie,x as et,_ as tt,aE as st,al as X,aF as nt}from"./main-
|
|
1
|
+
import{as as He,r as t,s as I,d as ye,at as Ee,c as Oe,j as e,I as O,u as fe,au as _e,av as Te,aw as Be,ax as Ue,ay as Ke,az as We,a3 as De,aA as Ve,aB as Ge,aC as qe,aD as Ye,z as Je,m as Me,S as le,F as Xe,C as Qe,n as Ze,w as Ie,x as et,_ as tt,aE as st,al as X,aF as nt}from"./main-ts-uUN3p.js";import{FileExplorerPanel as at}from"./index-CFiAyn9P.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.js";const Se={status:"all",activity:"all",sort:"activity"},ct={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=3,lt={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ot=12e4;function rt(s){return s.trim().replace(/\r\n/g,`
|
|
2
2
|
`)}function $e(s,a){return`${s}:${rt(a)}`}function it(s,a,c,f){if(s.uuid&&a.has(s.uuid))return!1;if(s.uuid)return!0;const p=s.isUserPrompt?"user":"assistant",d=$e(p,s.text),M=s.timestamp||0,A=c.get(d);return A!==void 0&&Math.abs(M-A)<=ot?!1:M>f}function dt({isOpen:s,agents:a}){const c=He(),[f,p]=t.useState(new Map),d=t.useRef(new Set);t.useRef(a);const M=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),A=t.useMemo(()=>Array.from(a.values()).map(j=>`${j.id}:${j.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{s||(d.current.clear(),p(new Map))},[s]),t.useEffect(()=>{if(!s)return;const j=new Set(Array.from(a.keys()));for(const i of d.current)j.has(i)||d.current.delete(i);let h=null;c>0&&(h=I.preserveOutputs(),d.current.clear());const v=async(i,k,$=0)=>{if(d.current.add(i.id),$>0&&await new Promise(x=>setTimeout(x,$)),p(x=>{const b=new Map(x);return b.set(i.id,{agentId:i.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),b}),!i.sessionId){k&&k.length>0&&I.mergeOutputsWithHistory(i.id,[],k),p(x=>{const b=new Map(x);return b.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),b});return}try{const b=await(await Oe(ye(`/api/agents/${i.id}/history?limit=${Ee}&offset=0`))).json(),P=b.messages||[],W=P.length>0?Math.max(...P.map(w=>w.timestamp?new Date(w.timestamp).getTime():0)):0,Y=new Set(P.map(w=>w.uuid).filter(w=>!!w)),V=new Map;for(const w of P){if(w.type!=="user"&&w.type!=="assistant")continue;const o=$e(w.type,w.content),L=w.timestamp?new Date(w.timestamp).getTime():0,K=V.get(o)??0;L>K&&V.set(o,L)}const G=I.getOutputs(i.id),U=(k&&k.length>0?[...k,...G]:G).filter(w=>it(w,Y,V,W));I.clearOutputs(i.id);for(const w of U)I.addOutput(i.id,w);p(w=>{const o=new Map(w);return o.set(i.id,{agentId:i.id,messages:P,loading:!1,hasMore:b.hasMore||!1,totalCount:b.totalCount||0}),o})}catch(x){if(console.error(`Failed to load history for ${i.name}:`,x),k&&k.length>0){I.clearOutputs(i.id);for(const b of k)I.addOutput(i.id,b)}p(b=>{const P=new Map(b);return P.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),P})}},u=c>0?500:0,D=Array.from(a.values());for(const i of D)if(!d.current.has(i.id)){const k=h==null?void 0:h.get(i.id);v(i,k,u)}},[s,M,A,c]);const R=t.useRef(a),N=t.useRef(f);R.current=a,N.current=f;const C=t.useCallback(async j=>{const h=R.current.get(j),v=N.current.get(j);if(!(h!=null&&h.sessionId)||!v||!v.hasMore)return;const u=v.messages.length;try{const i=await(await fetch(ye(`/api/agents/${j}/history?limit=${Ee}&offset=${u}`))).json();i.messages&&i.messages.length>0&&p(k=>{const $=new Map(k),x=k.get(j);return x&&$.set(j,{...x,messages:[...i.messages,...x.messages],hasMore:i.hasMore||!1}),$})}catch(D){console.error(`Failed to load more history for agent ${j}:`,D)}},[]),E=t.useCallback(j=>{d.current.delete(j),p(h=>{const v=new Map(h),u=h.get(j);return u&&v.set(j,{...u,messages:[],hasMore:!1,totalCount:0,loading:!1}),v})},[]);return{histories:f,loadMoreHistory:C,clearAgentHistory:E}}function ut({command:s,onCommandChange:a,useTextarea:c,forceTextarea:f,onForceTextarea:p,onSend:d,canSend:M,attachedFiles:A,onAddFile:R,onRemoveFile:N,uploadFile:C,onAddPastedText:E,placeholder:j="Message...",className:h="",compact:v=!1,inputRef:u}){const D=t.useRef(null),i=t.useRef(null),k=t.useRef(c);t.useEffect(()=>{if(c&&!k.current&&i.current){const o=i.current;o.focus(),o.selectionStart=o.selectionEnd=o.value.length}k.current=c},[c]),t.useEffect(()=>{const o=i.current;if(!o||!c)return;o.style.height="auto";const L=v?120:180,K=Math.min(o.scrollHeight,L);o.style.height=`${K}px`},[s,c,v]);const $=t.useCallback(async o=>{const L=o.clipboardData.items;for(const _ of L)if(_.type.startsWith("image/")){o.preventDefault();const F=_.getAsFile();if(F){const z=await C(F);z&&R(z)}return}const K=o.clipboardData.files;if(K.length>0){o.preventDefault();for(const _ of K){const F=await C(_);F&&R(F)}return}const B=o.clipboardData.getData("text"),te=(B.match(/\n/g)||[]).length+1;if(te>5){o.preventDefault();const F=`[Pasted text #${E(B)} +${te} lines]`,z=o.target,se=z.selectionStart||0,ae=z.selectionEnd||0,ne=s.slice(0,se)+F+s.slice(ae);a(ne),c||p(!0)}},[s,a,c,p,C,R,E]),x=t.useCallback(async o=>{const L=o.target.files;if(L){for(const K of L){const B=await C(K);B&&R(B)}D.current&&(D.current.value="")}},[C,R]),b=t.useCallback(o=>{if(o.key==="Enter"&&o.shiftKey){c||(o.preventDefault(),p(!0));return}o.key==="Enter"&&(o.preventDefault(),d())},[c,p,d]),P=t.useCallback(o=>{},[]),W=t.useCallback(o=>{o.button===1&&(o.preventDefault(),o.stopPropagation())},[]),Y=t.useCallback(o=>{i.current=o,u==null||u(o)},[u]),V=v?"agent-panel-input":"guake-input",G=v?"agent-panel-input-container":"guake-input-container",Q=v?"agent-panel-attach-btn":"guake-attach-btn",U=v?"agent-panel-send-btn":"",w=c?v?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[A.length>0&&e.jsx("div",{className:v?"agent-panel-attachments":"guake-attachments",children:A.map(o=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${o.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:e.jsx(O,{name:o.isImage?"file":"paperclip",size:12})}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:o.path,children:o.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(o.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>N(o.id),title:"Remove",children:"×"})]},o.id))}),e.jsxs("div",{className:`${V} ${w} ${h}`,children:[e.jsx("input",{ref:D,type:"file",multiple:!0,onChange:x,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:G,onAuxClick:W,children:[e.jsx("button",{className:Q,onClick:()=>{var o;return(o=D.current)==null?void 0:o.click()},title:"Attach file (or paste image)",children:e.jsx(O,{name:"paperclip",size:14})}),c?e.jsx("textarea",{ref:Y,placeholder:j,value:s,onChange:o=>a(o.target.value),onKeyDown:b,onPaste:$,onMouseDown:P}):e.jsx("input",{ref:u,type:"text",placeholder:j,value:s,onChange:o=>a(o.target.value),onKeyDown:b,onPaste:$,onMouseDown:P}),e.jsx("button",{className:U,onClick:d,disabled:!M,title:"Send",children:e.jsx(O,{name:"send",size:14})})]})]})]})}function mt(s){const a=Math.floor(s/1e3),c=Math.floor(a/60),f=a%60;return`${c}:${f.toString().padStart(2,"0")}`}const ft=t.memo(function({agentId:a,isWorking:c,timestamp:f}){const{t:p}=fe(["terminal"]),[d,M]=t.useState(0);return t.useEffect(()=>{if(!c||!f){M(0);return}M(Date.now()-f);const A=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(A)},[c,f]),c?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:mt(d)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>I.stopAgent(a),title:p("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:e.jsx(O,{name:"stop",size:12,weight:"fill"})}),e.jsx("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function pt({agent:s,history:a,outputs:c,isExpanded:f,isFocused:p,advancedView:d,onExpand:M,onFocus:A,inputRef:R,onLoadMore:N,onClearHistory:C}){const{t:E}=fe(["terminal","common"]),j=_e(s.id),h=t.useRef(null),[v,u]=t.useState(!1),D=t.useRef(0),i=t.useRef(!1),[k,$]=t.useState(!0),[x,b]=t.useState(!1),[P,W]=t.useState(null),[Y,V]=t.useState(null),[G,Q]=t.useState(null);Te(`commander-image-modal-${s.id}`,P!==null,()=>W(null));const{command:U,setCommand:w,forceTextarea:o,setForceTextarea:L,useTextarea:K,setPastedTexts:B,incrementPastedCount:te,resetPastedCount:_,attachedFiles:F,setAttachedFiles:z,removeAttachedFile:se,uploadFile:ae,expandPastedTexts:ne}=Be({selectedAgentId:s.id}),ce=U.trim().length>0||F.length>0,n=Ue({outputs:c,viewMode:d?"advanced":"simple"}),l=t.useMemo(()=>{const S=Ke(s);return{usedPercent:S.usedPercent,freePercent:S.freePercent,hasData:!!s.contextStats,totalTokens:S.totalTokens,contextWindow:S.contextWindow}},[s.contextStats,s.contextUsed,s.contextLimit]),g=t.useCallback(()=>{!v&&(a!=null&&a.hasMore)&&N&&(u(!0),D.current=h.current?h.current.scrollHeight-h.current.scrollTop:0,N())},[v,a==null?void 0:a.hasMore,N]);t.useEffect(()=>{v&&a&&!a.loading&&u(!1)},[a,v]);const m=t.useCallback(()=>{i.current=!0,$(!1)},[]),T=t.useRef(f),Z=t.useRef(p);t.useEffect(()=>{(f&&!T.current||p&&!Z.current)&&(i.current=!1,$(!0),b(!0)),T.current=f,Z.current=p},[f,p]);const ee=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{ee.current&&!(a!=null&&a.loading)&&(i.current=!1,$(!0),b(!0)),ee.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!x)return;const S=h.current;if(!S)return;const y=performance.now();let H=0,ue=-1,be;const Re=()=>{const{scrollTop:Fe,scrollHeight:Ne,clientHeight:Le}=S,ze=Ne-Fe-Le<=2;if(Math.abs(Ne-ue)<=1&&ze?H+=1:H=0,ue=Ne,H>=3){b(!1);return}if(performance.now()-y>5e3){b(!1);return}be=requestAnimationFrame(Re)};return be=requestAnimationFrame(Re),()=>cancelAnimationFrame(be)},[x]),t.useEffect(()=>{i.current||$(!0)},[n.length]);const q=t.useCallback(()=>!1,[]),ie=t.useCallback(S=>{const y=te();return B(H=>new Map(H).set(y,S)),y},[te,B]),he=t.useCallback(S=>{z(y=>[...y,S])},[z]),xe=t.useCallback(()=>{if(!ce)return;if(U.trim()==="/clear"&&F.length===0){I.clearContext(s.id),C(),w(""),L(!1),B(new Map),z([]),_();return}let S=ne(U.trim());if(F.length>0){const y=F.map(H=>H.isImage?`[Image: ${H.path}]`:`[File: ${H.path}]`).join(`
|
|
3
3
|
`);S=S?`${S}
|
|
4
4
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as a,l as s,F as n,e as i}from"./mermaid.core-
|
|
1
|
+
import{_ as a,l as s,F as n,e as i}from"./mermaid.core-BuuQCwr7.js";import{p}from"./cynefin-VYW2F7L2-UDH0NYTi.js";import"./main-ts-uUN3p.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.js";var g={parse:a(async r=>{const e=await p("info",r);s.debug(e)},"parse")},v={version:"11.16.0"},d=a(()=>v.version,"getVersion"),m={getVersion:d},c=a((r,e,o)=>{s.debug(`rendering info diagram
|
|
2
2
|
`+r);const t=n(e);i(t,100,400,!0),t.append("g").append("text").attr("x",100).attr("y",40).attr("class","version").attr("font-size",32).style("text-anchor","middle").text(`v${o}`)},"draw"),l={draw:c},y={parser:g,db:m,renderer:l};export{y as diagram};
|
package/dist/assets/{ishikawaDiagram-FXEZZL3T-DFA-gmAE.js → ishikawaDiagram-FXEZZL3T-BPsjNXWV.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as o,c as ot,a1 as ut,F as dt,al as yt,q as ft,k as pt,o as it,a as gt,b as kt,g as mt,s as wt,p as _t,e as bt}from"./mermaid.core-
|
|
1
|
+
import{_ as o,c as ot,a1 as ut,F as dt,al as yt,q as ft,k as pt,o as it,a as gt,b as kt,g as mt,s as wt,p as _t,e as bt}from"./mermaid.core-BuuQCwr7.js";import"./main-ts-uUN3p.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.js";var tt=(function(){var e=o(function(M,t,s,i){for(s=s||{},i=M.length;i--;s[M[i]]=t);return s},"o"),h=[1,4],r=[1,14],a=[1,12],l=[1,13],y=[6,7,8],f=[1,20],d=[1,18],m=[1,19],c=[6,7,11],k=[1,6,13,14],g=[1,23],_=[1,24],x=[1,6,7,11,13,14],N={trace:o(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ishikawa:4,spaceLines:5,SPACELINE:6,NL:7,ISHIKAWA:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,TEXT:14,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"ISHIKAWA",11:"EOF",13:"SPACELIST",14:"TEXT"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,1],[12,1],[12,1]],performAction:o(function(t,s,i,u,p,n,v){var w=n.length-1;switch(p){case 6:case 7:return u;case 15:u.addNode(n[w-1].length,n[w].trim());break;case 16:u.addNode(0,n[w].trim());break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:h},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:h},{6:r,7:[1,10],9:9,12:11,13:a,14:l},e(y,[2,3]),{1:[2,2]},e(y,[2,4]),e(y,[2,5]),{1:[2,6],6:r,12:15,13:a,14:l},{6:r,9:16,12:11,13:a,14:l},{6:f,7:d,10:17,11:m},e(c,[2,18],{14:[1,21]}),e(c,[2,16]),e(c,[2,17]),{6:f,7:d,10:22,11:m},{1:[2,7],6:r,12:15,13:a,14:l},e(k,[2,14],{7:g,11:_}),e(x,[2,8]),e(x,[2,9]),e(x,[2,10]),e(c,[2,15]),e(k,[2,13],{7:g,11:_}),e(x,[2,11]),e(x,[2,12])],defaultActions:{2:[2,1],6:[2,2]},parseError:o(function(t,s){if(s.recoverable)this.trace(t);else{var i=new Error(t);throw i.hash=s,i}},"parseError"),parse:o(function(t){var s=this,i=[0],u=[],p=[null],n=[],v=this.table,w="",I=0,S=0,L=2,E=1,R=n.slice.call(arguments,1),b=Object.create(this.lexer),C={yy:{}};for(var W in this.yy)Object.prototype.hasOwnProperty.call(this.yy,W)&&(C.yy[W]=this.yy[W]);b.setInput(t,C.yy),C.yy.lexer=b,C.yy.parser=this,typeof b.yylloc>"u"&&(b.yylloc={});var T=b.yylloc;n.push(T);var D=b.options&&b.options.ranges;typeof C.yy.parseError=="function"?this.parseError=C.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function j(P){i.length=i.length-2*P,p.length=p.length-P,n.length=n.length-P}o(j,"popStack");function z(){var P;return P=u.pop()||b.lex()||E,typeof P!="number"&&(P instanceof Array&&(u=P,P=u.pop()),P=s.symbols_[P]||P),P}o(z,"lex");for(var A,F,B,K,H={},X,V,et,Y;;){if(F=i[i.length-1],this.defaultActions[F]?B=this.defaultActions[F]:((A===null||typeof A>"u")&&(A=z()),B=v[F]&&v[F][A]),typeof B>"u"||!B.length||!B[0]){var Q="";Y=[];for(X in v[F])this.terminals_[X]&&X>L&&Y.push("'"+this.terminals_[X]+"'");b.showPosition?Q="Parse error on line "+(I+1)+`:
|
|
2
2
|
`+b.showPosition()+`
|
|
3
3
|
Expecting `+Y.join(", ")+", got '"+(this.terminals_[A]||A)+"'":Q="Parse error on line "+(I+1)+": Unexpected "+(A==E?"end of input":"'"+(this.terminals_[A]||A)+"'"),this.parseError(Q,{text:b.match,token:this.terminals_[A]||A,line:b.yylineno,loc:T,expected:Y})}if(B[0]instanceof Array&&B.length>1)throw new Error("Parse Error: multiple actions possible at state: "+F+", token: "+A);switch(B[0]){case 1:i.push(A),p.push(b.yytext),n.push(b.yylloc),i.push(B[1]),A=null,S=b.yyleng,w=b.yytext,I=b.yylineno,T=b.yylloc;break;case 2:if(V=this.productions_[B[1]][1],H.$=p[p.length-V],H._$={first_line:n[n.length-(V||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(V||1)].first_column,last_column:n[n.length-1].last_column},D&&(H._$.range=[n[n.length-(V||1)].range[0],n[n.length-1].range[1]]),K=this.performAction.apply(H,[w,S,I,C.yy,B[1],p,n].concat(R)),typeof K<"u")return K;V&&(i=i.slice(0,-1*V*2),p=p.slice(0,-1*V),n=n.slice(0,-1*V)),i.push(this.productions_[B[1]][0]),p.push(H.$),n.push(H._$),et=v[i[i.length-2]][i[i.length-1]],i.push(et);break;case 3:return!0}}return!0},"parse")},O=(function(){var M={EOF:1,parseError:o(function(s,i){if(this.yy.parser)this.yy.parser.parseError(s,i);else throw new Error(s)},"parseError"),setInput:o(function(t,s){return this.yy=s||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:o(function(){var t=this._input[0];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;var s=t.match(/(?:\r\n?|\n).*/g);return s?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},"input"),unput:o(function(t){var s=t.length,i=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-s),this.offset-=s;var u=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var p=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===u.length?this.yylloc.first_column:0)+u[u.length-i.length].length-i[0].length:this.yylloc.first_column-s},this.options.ranges&&(this.yylloc.range=[p[0],p[0]+this.yyleng-s]),this.yyleng=this.yytext.length,this},"unput"),more:o(function(){return this._more=!0,this},"more"),reject:o(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
4
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:o(function(t){this.unput(this.match.slice(t))},"less"),pastInput:o(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:o(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:o(function(){var t=this.pastInput(),s=new Array(t.length+1).join("-");return t+this.upcomingInput()+`
|
package/dist/assets/{journeyDiagram-5HDEW3XC-g34VUhUW.js → journeyDiagram-5HDEW3XC-3jqJYemY.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as gt}from"./chunk-5VM5RSS4-
|
|
1
|
+
import{g as gt}from"./chunk-5VM5RSS4-E2Yaai0b.js";import{a as mt,g as lt,h as xt,d as kt}from"./chunk-32BRIVSS-eJLo7W-b.js";import{g as _t,s as vt,a as bt,b as wt,p as Tt,o as St,_ as s,c as R,d as X,e as $t,q as Mt}from"./mermaid.core-BuuQCwr7.js";import{d as it}from"./arc-xqT5-bwQ.js";import"./main-ts-uUN3p.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.js";var U=(function(){var t=s(function(h,r,n,l){for(n=n||{},l=h.length;l--;n[h[l]]=r);return n},"o"),e=[6,8,10,11,12,14,16,17,18],a=[1,9],f=[1,10],i=[1,11],u=[1,12],p=[1,13],o=[1,14],g={trace:s(function(){},"trace"),yy:{},symbols_:{error:2,start:3,journey:4,document:5,EOF:6,line:7,SPACE:8,statement:9,NEWLINE:10,title:11,acc_title:12,acc_title_value:13,acc_descr:14,acc_descr_value:15,acc_descr_multiline_value:16,section:17,taskName:18,taskData:19,$accept:0,$end:1},terminals_:{2:"error",4:"journey",6:"EOF",8:"SPACE",10:"NEWLINE",11:"title",12:"acc_title",13:"acc_title_value",14:"acc_descr",15:"acc_descr_value",16:"acc_descr_multiline_value",17:"section",18:"taskName",19:"taskData"},productions_:[0,[3,3],[5,0],[5,2],[7,2],[7,1],[7,1],[7,1],[9,1],[9,2],[9,2],[9,1],[9,1],[9,2]],performAction:s(function(r,n,l,y,d,c,v){var k=c.length-1;switch(d){case 1:return c[k-1];case 2:this.$=[];break;case 3:c[k-1].push(c[k]),this.$=c[k-1];break;case 4:case 5:this.$=c[k];break;case 6:case 7:this.$=[];break;case 8:y.setDiagramTitle(c[k].substr(6)),this.$=c[k].substr(6);break;case 9:this.$=c[k].trim(),y.setAccTitle(this.$);break;case 10:case 11:this.$=c[k].trim(),y.setAccDescription(this.$);break;case 12:y.addSection(c[k].substr(8)),this.$=c[k].substr(8);break;case 13:y.addTask(c[k-1],c[k]),this.$="task";break}},"anonymous"),table:[{3:1,4:[1,2]},{1:[3]},t(e,[2,2],{5:3}),{6:[1,4],7:5,8:[1,6],9:7,10:[1,8],11:a,12:f,14:i,16:u,17:p,18:o},t(e,[2,7],{1:[2,1]}),t(e,[2,3]),{9:15,11:a,12:f,14:i,16:u,17:p,18:o},t(e,[2,5]),t(e,[2,6]),t(e,[2,8]),{13:[1,16]},{15:[1,17]},t(e,[2,11]),t(e,[2,12]),{19:[1,18]},t(e,[2,4]),t(e,[2,9]),t(e,[2,10]),t(e,[2,13])],defaultActions:{},parseError:s(function(r,n){if(n.recoverable)this.trace(r);else{var l=new Error(r);throw l.hash=n,l}},"parseError"),parse:s(function(r){var n=this,l=[0],y=[],d=[null],c=[],v=this.table,k="",C=0,Q=0,yt=2,D=1,dt=c.slice.call(arguments,1),_=Object.create(this.lexer),I={yy:{}};for(var O in this.yy)Object.prototype.hasOwnProperty.call(this.yy,O)&&(I.yy[O]=this.yy[O]);_.setInput(r,I.yy),I.yy.lexer=_,I.yy.parser=this,typeof _.yylloc>"u"&&(_.yylloc={});var Y=_.yylloc;c.push(Y);var ft=_.options&&_.options.ranges;typeof I.yy.parseError=="function"?this.parseError=I.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function pt(w){l.length=l.length-2*w,d.length=d.length-w,c.length=c.length-w}s(pt,"popStack");function tt(){var w;return w=y.pop()||_.lex()||D,typeof w!="number"&&(w instanceof Array&&(y=w,w=y.pop()),w=n.symbols_[w]||w),w}s(tt,"lex");for(var b,A,T,q,F={},N,M,et,z;;){if(A=l[l.length-1],this.defaultActions[A]?T=this.defaultActions[A]:((b===null||typeof b>"u")&&(b=tt()),T=v[A]&&v[A][b]),typeof T>"u"||!T.length||!T[0]){var H="";z=[];for(N in v[A])this.terminals_[N]&&N>yt&&z.push("'"+this.terminals_[N]+"'");_.showPosition?H="Parse error on line "+(C+1)+`:
|
|
2
2
|
`+_.showPosition()+`
|
|
3
3
|
Expecting `+z.join(", ")+", got '"+(this.terminals_[b]||b)+"'":H="Parse error on line "+(C+1)+": Unexpected "+(b==D?"end of input":"'"+(this.terminals_[b]||b)+"'"),this.parseError(H,{text:_.match,token:this.terminals_[b]||b,line:_.yylineno,loc:Y,expected:z})}if(T[0]instanceof Array&&T.length>1)throw new Error("Parse Error: multiple actions possible at state: "+A+", token: "+b);switch(T[0]){case 1:l.push(b),d.push(_.yytext),c.push(_.yylloc),l.push(T[1]),b=null,Q=_.yyleng,k=_.yytext,C=_.yylineno,Y=_.yylloc;break;case 2:if(M=this.productions_[T[1]][1],F.$=d[d.length-M],F._$={first_line:c[c.length-(M||1)].first_line,last_line:c[c.length-1].last_line,first_column:c[c.length-(M||1)].first_column,last_column:c[c.length-1].last_column},ft&&(F._$.range=[c[c.length-(M||1)].range[0],c[c.length-1].range[1]]),q=this.performAction.apply(F,[k,Q,C,I.yy,T[1],d,c].concat(dt)),typeof q<"u")return q;M&&(l=l.slice(0,-1*M*2),d=d.slice(0,-1*M),c=c.slice(0,-1*M)),l.push(this.productions_[T[1]][0]),d.push(F.$),c.push(F._$),et=v[l[l.length-2]][l[l.length-1]],l.push(et);break;case 3:return!0}}return!0},"parse")},m=(function(){var h={EOF:1,parseError:s(function(n,l){if(this.yy.parser)this.yy.parser.parseError(n,l);else throw new Error(n)},"parseError"),setInput:s(function(r,n){return this.yy=n||this.yy||{},this._input=r,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:s(function(){var r=this._input[0];this.yytext+=r,this.yyleng++,this.offset++,this.match+=r,this.matched+=r;var n=r.match(/(?:\r\n?|\n).*/g);return n?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),r},"input"),unput:s(function(r){var n=r.length,l=r.split(/(?:\r\n?|\n)/g);this._input=r+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-n),this.offset-=n;var y=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),l.length-1&&(this.yylineno-=l.length-1);var d=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:l?(l.length===y.length?this.yylloc.first_column:0)+y[y.length-l.length].length-l[0].length:this.yylloc.first_column-n},this.options.ranges&&(this.yylloc.range=[d[0],d[0]+this.yyleng-n]),this.yyleng=this.yytext.length,this},"unput"),more:s(function(){return this._more=!0,this},"more"),reject:s(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
4
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:s(function(r){this.unput(this.match.slice(r))},"less"),pastInput:s(function(){var r=this.matched.substr(0,this.matched.length-this.match.length);return(r.length>20?"...":"")+r.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:s(function(){var r=this.match;return r.length<20&&(r+=this._input.substr(0,20-r.length)),(r.substr(0,20)+(r.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:s(function(){var r=this.pastInput(),n=new Array(r.length+1).join("-");return r+this.upcomingInput()+`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as c,l as te,c as W,F as fe,af as ye,ag as be,ah as me,ad as _e,D as K,i as G,Y as ke,Z as Ee,aa as Se,ab as le,ac as ce}from"./mermaid.core-
|
|
1
|
+
import{_ as c,l as te,c as W,F as fe,af as ye,ag as be,ah as me,ad as _e,D as K,i as G,Y as ke,Z as Ee,aa as Se,ab as le,ac as ce}from"./mermaid.core-BuuQCwr7.js";import{g as Ne}from"./chunk-5VM5RSS4-E2Yaai0b.js";import"./main-ts-uUN3p.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.js";var $=(function(){var t=c(function(_,s,n,a){for(n=n||{},a=_.length;a--;n[_[a]]=s);return n},"o"),g=[1,4],d=[1,13],r=[1,12],p=[1,15],k=[1,16],f=[1,20],h=[1,19],L=[6,7,8],C=[1,26],w=[1,24],N=[1,25],i=[6,7,11],M=[1,31],x=[6,7,11,24],P=[1,6,13,16,17,20,23],U=[1,35],j=[1,36],A=[1,6,7,11,13,16,17,20,23],H=[1,38],V={trace:c(function(){},"trace"),yy:{},symbols_:{error:2,start:3,mindMap:4,spaceLines:5,SPACELINE:6,NL:7,KANBAN:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,node:14,shapeData:15,ICON:16,CLASS:17,nodeWithId:18,nodeWithoutId:19,NODE_DSTART:20,NODE_DESCR:21,NODE_DEND:22,NODE_ID:23,SHAPE_DATA:24,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"KANBAN",11:"EOF",13:"SPACELIST",16:"ICON",17:"CLASS",20:"NODE_DSTART",21:"NODE_DESCR",22:"NODE_DEND",23:"NODE_ID",24:"SHAPE_DATA"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,3],[12,2],[12,2],[12,2],[12,1],[12,2],[12,1],[12,1],[12,1],[12,1],[14,1],[14,1],[19,3],[18,1],[18,4],[15,2],[15,1]],performAction:c(function(s,n,a,o,u,e,B){var l=e.length-1;switch(u){case 6:case 7:return o;case 8:o.getLogger().trace("Stop NL ");break;case 9:o.getLogger().trace("Stop EOF ");break;case 11:o.getLogger().trace("Stop NL2 ");break;case 12:o.getLogger().trace("Stop EOF2 ");break;case 15:o.getLogger().info("Node: ",e[l-1].id),o.addNode(e[l-2].length,e[l-1].id,e[l-1].descr,e[l-1].type,e[l]);break;case 16:o.getLogger().info("Node: ",e[l].id),o.addNode(e[l-1].length,e[l].id,e[l].descr,e[l].type);break;case 17:o.getLogger().trace("Icon: ",e[l]),o.decorateNode({icon:e[l]});break;case 18:case 23:o.decorateNode({class:e[l]});break;case 19:o.getLogger().trace("SPACELIST");break;case 20:o.getLogger().trace("Node: ",e[l-1].id),o.addNode(0,e[l-1].id,e[l-1].descr,e[l-1].type,e[l]);break;case 21:o.getLogger().trace("Node: ",e[l].id),o.addNode(0,e[l].id,e[l].descr,e[l].type);break;case 22:o.decorateNode({icon:e[l]});break;case 27:o.getLogger().trace("node found ..",e[l-2]),this.$={id:e[l-1],descr:e[l-1],type:o.getType(e[l-2],e[l])};break;case 28:this.$={id:e[l],descr:e[l],type:0};break;case 29:o.getLogger().trace("node found ..",e[l-3]),this.$={id:e[l-3],descr:e[l-1],type:o.getType(e[l-2],e[l])};break;case 30:this.$=e[l-1]+e[l];break;case 31:this.$=e[l];break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:g},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:g},{6:d,7:[1,10],9:9,12:11,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},t(L,[2,3]),{1:[2,2]},t(L,[2,4]),t(L,[2,5]),{1:[2,6],6:d,12:21,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},{6:d,9:22,12:11,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},{6:C,7:w,10:23,11:N},t(i,[2,24],{18:17,19:18,14:27,16:[1,28],17:[1,29],20:f,23:h}),t(i,[2,19]),t(i,[2,21],{15:30,24:M}),t(i,[2,22]),t(i,[2,23]),t(x,[2,25]),t(x,[2,26]),t(x,[2,28],{20:[1,32]}),{21:[1,33]},{6:C,7:w,10:34,11:N},{1:[2,7],6:d,12:21,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},t(P,[2,14],{7:U,11:j}),t(A,[2,8]),t(A,[2,9]),t(A,[2,10]),t(i,[2,16],{15:37,24:M}),t(i,[2,17]),t(i,[2,18]),t(i,[2,20],{24:H}),t(x,[2,31]),{21:[1,39]},{22:[1,40]},t(P,[2,13],{7:U,11:j}),t(A,[2,11]),t(A,[2,12]),t(i,[2,15],{24:H}),t(x,[2,30]),{22:[1,41]},t(x,[2,27]),t(x,[2,29])],defaultActions:{2:[2,1],6:[2,2]},parseError:c(function(s,n){if(n.recoverable)this.trace(s);else{var a=new Error(s);throw a.hash=n,a}},"parseError"),parse:c(function(s){var n=this,a=[0],o=[],u=[null],e=[],B=this.table,l="",z=0,ie=0,ue=2,re=1,ge=e.slice.call(arguments,1),m=Object.create(this.lexer),T={yy:{}};for(var J in this.yy)Object.prototype.hasOwnProperty.call(this.yy,J)&&(T.yy[J]=this.yy[J]);m.setInput(s,T.yy),T.yy.lexer=m,T.yy.parser=this,typeof m.yylloc>"u"&&(m.yylloc={});var Z=m.yylloc;e.push(Z);var de=m.options&&m.options.ranges;typeof T.yy.parseError=="function"?this.parseError=T.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function pe(S){a.length=a.length-2*S,u.length=u.length-S,e.length=e.length-S}c(pe,"popStack");function ae(){var S;return S=o.pop()||m.lex()||re,typeof S!="number"&&(S instanceof Array&&(o=S,S=o.pop()),S=n.symbols_[S]||S),S}c(ae,"lex");for(var E,R,v,q,F={},X,I,oe,Y;;){if(R=a[a.length-1],this.defaultActions[R]?v=this.defaultActions[R]:((E===null||typeof E>"u")&&(E=ae()),v=B[R]&&B[R][E]),typeof v>"u"||!v.length||!v[0]){var Q="";Y=[];for(X in B[R])this.terminals_[X]&&X>ue&&Y.push("'"+this.terminals_[X]+"'");m.showPosition?Q="Parse error on line "+(z+1)+`:
|
|
2
2
|
`+m.showPosition()+`
|
|
3
3
|
Expecting `+Y.join(", ")+", got '"+(this.terminals_[E]||E)+"'":Q="Parse error on line "+(z+1)+": Unexpected "+(E==re?"end of input":"'"+(this.terminals_[E]||E)+"'"),this.parseError(Q,{text:m.match,token:this.terminals_[E]||E,line:m.yylineno,loc:Z,expected:Y})}if(v[0]instanceof Array&&v.length>1)throw new Error("Parse Error: multiple actions possible at state: "+R+", token: "+E);switch(v[0]){case 1:a.push(E),u.push(m.yytext),e.push(m.yylloc),a.push(v[1]),E=null,ie=m.yyleng,l=m.yytext,z=m.yylineno,Z=m.yylloc;break;case 2:if(I=this.productions_[v[1]][1],F.$=u[u.length-I],F._$={first_line:e[e.length-(I||1)].first_line,last_line:e[e.length-1].last_line,first_column:e[e.length-(I||1)].first_column,last_column:e[e.length-1].last_column},de&&(F._$.range=[e[e.length-(I||1)].range[0],e[e.length-1].range[1]]),q=this.performAction.apply(F,[l,ie,z,T.yy,v[1],u,e].concat(ge)),typeof q<"u")return q;I&&(a=a.slice(0,-1*I*2),u=u.slice(0,-1*I),e=e.slice(0,-1*I)),a.push(this.productions_[v[1]][0]),u.push(F.$),e.push(F._$),oe=B[a[a.length-2]][a[a.length-1]],a.push(oe);break;case 3:return!0}}return!0},"parse")},y=(function(){var _={EOF:1,parseError:c(function(n,a){if(this.yy.parser)this.yy.parser.parseError(n,a);else throw new Error(n)},"parseError"),setInput:c(function(s,n){return this.yy=n||this.yy||{},this._input=s,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:c(function(){var s=this._input[0];this.yytext+=s,this.yyleng++,this.offset++,this.match+=s,this.matched+=s;var n=s.match(/(?:\r\n?|\n).*/g);return n?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),s},"input"),unput:c(function(s){var n=s.length,a=s.split(/(?:\r\n?|\n)/g);this._input=s+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-n),this.offset-=n;var o=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),a.length-1&&(this.yylineno-=a.length-1);var u=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:a?(a.length===o.length?this.yylloc.first_column:0)+o[o.length-a.length].length-a[0].length:this.yylloc.first_column-n},this.options.ranges&&(this.yylloc.range=[u[0],u[0]+this.yyleng-n]),this.yyleng=this.yytext.length,this},"unput"),more:c(function(){return this._more=!0,this},"more"),reject:c(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
4
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:c(function(s){this.unput(this.match.slice(s))},"less"),pastInput:c(function(){var s=this.matched.substr(0,this.matched.length-this.match.length);return(s.length>20?"...":"")+s.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:c(function(){var s=this.match;return s.length<20&&(s+=this._input.substr(0,20-s.length)),(s.substr(0,20)+(s.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:c(function(){var s=this.pastInput(),n=new Array(s.length+1).join("-");return s+this.upcomingInput()+`
|