tide-commander 1.166.0 → 1.167.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 +15 -0
- package/dist/assets/{BossLogsModal-CsMSjCZp.js → BossLogsModal-CLmSG1H0.js} +1 -1
- package/dist/assets/BossSpawnModal-DZlB8KRy.js +1 -0
- package/dist/assets/ControlsModal-B1-STBnD.js +1 -0
- package/dist/assets/DockerLogsModal-CWnhsG_r.js +2 -0
- package/dist/assets/{EmbeddedEditor-n2QnK4hA.js → EmbeddedEditor-5po-iz0Q.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-DhKifdH0.js → GmailOAuthSetup-BB10r44e.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-D14lS0lT.js → GoogleOAuthSetup-CW_Ib5kq.js} +1 -1
- package/dist/assets/{IframeModal-c2Go5TIq.js → IframeModal-CPt5x5fr.js} +1 -1
- package/dist/assets/IntegrationsPanel-CO-5iHtn.js +2 -0
- package/dist/assets/{LogViewerModal-onBz0hK3.js → LogViewerModal-DicJq6l-.js} +1 -1
- package/dist/assets/{MonitoringModal-D58Oka-L.js → MonitoringModal-B3nwcYZn.js} +1 -1
- package/dist/assets/{PM2LogsModal-DtEHMB6v.js → PM2LogsModal-Viw6fBjN.js} +2 -2
- package/dist/assets/RestoreArchivedAreaModal-BVH9wxhk.js +1 -0
- package/dist/assets/Scene2DCanvas-D6TCimYq.js +1 -0
- package/dist/assets/SceneManager-BdJs75zx.js +104 -0
- package/dist/assets/{SkillsPanel-aK_Vhyhx.js → SkillsPanel-D1WonIBN.js} +1 -1
- package/dist/assets/{SlackMultiInstanceSetup-CR9tuDCR.js → SlackMultiInstanceSetup-DSTZ5Hry.js} +1 -1
- package/dist/assets/SpawnModal-DUpIkQ08.js +1 -0
- package/dist/assets/StatisticsModal-BoDgM_8E.js +1 -0
- package/dist/assets/SubordinateAssignmentModal-LysAkNGy.js +1 -0
- package/dist/assets/{TriggerManagerPanel-CtDALyfM.js → TriggerManagerPanel-BHxmBRvy.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-CEYKw625.js → WorkflowEditorPanel-BHayKmMV.js} +1 -1
- package/dist/assets/abnfDiagram-VRR7QNED-DBZ5EpAj.js +1 -0
- package/dist/assets/arc-UCe2q9lp.js +1 -0
- package/dist/assets/architectureDiagram-ZJ3FMSHR-D5zOdUA8.js +36 -0
- package/dist/assets/{area-logos-HooY4aHb.js → area-logos-4nlUPBxf.js} +1 -1
- package/dist/assets/blockDiagram-677ZJIJ3-7S-qZlh0.js +132 -0
- package/dist/assets/c4Diagram-LMCZKHZV-CgLv5SCO.js +10 -0
- package/dist/assets/channel-C59jtig-.js +1 -0
- package/dist/assets/chunk-2Q5K7J3B-J08qsAGr.js +1 -0
- package/dist/assets/chunk-32BRIVSS-Xy5D5wu7.js +1 -0
- package/dist/assets/chunk-5VM5RSS4-DqhmRB6E.js +15 -0
- package/dist/assets/chunk-EX3LRPZG-QE89_WgA.js +231 -0
- package/dist/assets/chunk-JWPE2WC7-YSc_ua_g.js +1 -0
- package/dist/assets/chunk-MOJQB5TN-CcH7NM7I.js +88 -0
- package/dist/assets/chunk-RYQCIY6F-CndQTJJ1.js +1 -0
- package/dist/assets/chunk-V7JOEXUC-Dauixo5p.js +206 -0
- package/dist/assets/chunk-VR4S4FIN-BBU6oFw0.js +1 -0
- package/dist/assets/chunk-XXDRQBXY-DXMolb4D.js +1 -0
- package/dist/assets/classDiagram-OUVF2IWQ-DHvVmqF9.js +1 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-DHvVmqF9.js +1 -0
- package/dist/assets/cose-bilkent-JH36ORCC-Dd9IB924.js +1 -0
- package/dist/assets/cynefin-VYW2F7L2-BQxwdSSb.js +178 -0
- package/dist/assets/cynefinDiagram-TSTJHNR4-BLnxgd0m.js +62 -0
- package/dist/assets/cytoscape.esm-DTSO7Bv0.js +331 -0
- package/dist/assets/dagre-VKFMJZFB-BZ7fXVWR.js +4 -0
- package/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/assets/diagram-FQU43EPY-BFQ1xjHE.js +3 -0
- package/dist/assets/diagram-G47NLZAW-sXsGErM6.js +24 -0
- package/dist/assets/diagram-NH7WQ7WH-D6SPifDp.js +24 -0
- package/dist/assets/diagram-OA4YK3LP-Mu16f_2g.js +30 -0
- package/dist/assets/diagram-WEI45ONY-3BTJg43I.js +41 -0
- package/dist/assets/ebnfDiagram-CCIWWBDH-BGl2hs1X.js +1 -0
- package/dist/assets/erDiagram-Q63AITRT-D03B1rgc.js +85 -0
- package/dist/assets/flowDiagram-23GEKE2U-BCaZJGGE.js +156 -0
- package/dist/assets/ganttDiagram-NO4QXBWP-DrTSQR9G.js +292 -0
- package/dist/assets/gitGraphDiagram-IHSO6WYX-BvrZLcji.js +106 -0
- package/dist/assets/graph-C9eacEi8.js +1 -0
- package/dist/assets/index-B7l8Nsf8.js +1 -0
- package/dist/assets/index-BK7LL53p.js +1 -0
- package/dist/assets/index-CJ6x10Zs.js +2 -0
- package/dist/assets/index-D6btqUwj.js +2 -0
- package/dist/assets/{index-BSPc0AE-.js → index-DAXUzeVz.js} +6 -6
- package/dist/assets/{index-BxPFO5EJ.js → index-DcD9tVKJ.js} +3 -3
- package/dist/assets/{index-DdCk239w.js → index-Dzup44Dy.js} +6 -6
- package/dist/assets/index-JEgWBCoB.js +1 -0
- package/dist/assets/index-J_xWyk3Q.js +1 -0
- package/dist/assets/infoDiagram-FWYZ7A6U-Bw9k-wkS.js +2 -0
- package/dist/assets/init-Gi6I4Gst.js +1 -0
- package/dist/assets/ishikawaDiagram-FXEZZL3T-C2oVKtw0.js +70 -0
- package/dist/assets/journeyDiagram-5HDEW3XC-pRpwSEa5.js +139 -0
- package/dist/assets/kanban-definition-HUTT4EX6-CYq_poR1.js +89 -0
- package/dist/assets/katex-C5jXJg4s.js +257 -0
- package/dist/assets/layout-DEXfKzaS.js +1 -0
- package/dist/assets/linear-DLT2RlFJ.js +1 -0
- package/dist/assets/{main-D6IBl2Xu.js → main-06kmV-SQ.js} +125 -125
- package/dist/assets/map-Czzmt4hB.js +1 -0
- package/dist/assets/mermaid.core-DmOBz9SE.js +314 -0
- package/dist/assets/mindmap-definition-LN4V7U3C-DzucjpI_.js +96 -0
- package/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/assets/pegDiagram-2B236MQR-CIf_bLf4.js +1 -0
- package/dist/assets/pieDiagram-ENE6RG2P-Dh9HXeSf.js +39 -0
- package/dist/assets/quadrantDiagram-ABIIQ3AL-B5hZRZ5w.js +7 -0
- package/dist/assets/railroadDiagram-RFXS5EU6-B1oWAO1u.js +1 -0
- package/dist/assets/requirementDiagram-TGXJPOKE-Cg7bjm4O.js +84 -0
- package/dist/assets/sankeyDiagram-HTMAVEWB-TLCrcbtk.js +40 -0
- package/dist/assets/sequenceDiagram-DBY2YBRQ-BD3b_psw.js +162 -0
- package/dist/assets/sizeCapture-X5ZJPWSS-D26nx1uQ.js +1 -0
- package/dist/assets/stateDiagram-2N3HPSRC-CIwRQUnK.js +1 -0
- package/dist/assets/stateDiagram-v2-6OUMAXLB-C5qcZ4o1.js +1 -0
- package/dist/assets/swimlanes-5IMT3BWC-DYbes851.js +2 -0
- package/dist/assets/swimlanesDiagram-G3AALYLV-Ke-NRRIa.js +8 -0
- package/dist/assets/timeline-definition-FHXFAJF6-Fr9U6JU6.js +120 -0
- package/dist/assets/{vendor-three-Chj50gSY.js → vendor-three-3OKhI9bz.js} +1 -1
- package/dist/assets/vennDiagram-L72KCM5P-Cns-KLq7.js +34 -0
- package/dist/assets/wardleyDiagram-EHGQE667-DHA7rD9Z.js +78 -0
- package/dist/assets/{web-BVrXaF9j.js → web-B7c8sthS.js} +1 -1
- package/dist/assets/{web-B6Lyhp8u.js → web-C05qFIA-.js} +1 -1
- package/dist/assets/{web-DQi4Jy_X.js → web-Dja1kfLs.js} +1 -1
- package/dist/assets/xychartDiagram-FW5EYKEG-DCnL05Wq.js +7 -0
- package/dist/build-info.json +1 -1
- package/dist/index.html +2 -2
- package/dist/src/packages/server/claude/runner/watchdog.js +27 -0
- package/dist/src/packages/server/codex/app-server/codex-app-server-runner.js +34 -4
- package/dist/src/packages/server/data/builtin-skills/index.js +2 -0
- package/dist/src/packages/server/data/builtin-skills/mermaid-diagrams.js +76 -0
- package/dist/src/packages/server/opencode/server/opencode-server-process.js +102 -7
- package/dist/src/packages/server/opencode/server/opencode-server-runner.js +13 -0
- package/dist/src/packages/server/services/agent-service.js +7 -0
- package/dist/src/packages/server/services/runtime-events.js +1 -0
- package/package.json +2 -1
- package/dist/assets/BossSpawnModal-Z6ZZuraP.js +0 -1
- package/dist/assets/ControlsModal-UAWrBPnS.js +0 -1
- package/dist/assets/DockerLogsModal-Dvk09sbP.js +0 -2
- package/dist/assets/IntegrationsPanel-CkZyLCWN.js +0 -2
- package/dist/assets/RestoreArchivedAreaModal-BKgjpTYA.js +0 -1
- package/dist/assets/Scene2DCanvas-BSe1eM97.js +0 -1
- package/dist/assets/SceneManager-Bv_J6Asr.js +0 -104
- package/dist/assets/SpawnModal-BGoN5C1p.js +0 -1
- package/dist/assets/StatisticsModal-BY9pHl-m.js +0 -1
- package/dist/assets/SubordinateAssignmentModal-2bO3Y-zS.js +0 -1
- package/dist/assets/index-BTaesMkc.js +0 -1
- package/dist/assets/index-CCZsNuvk.js +0 -1
- package/dist/assets/index-CUfnGcms.js +0 -2
- package/dist/assets/index-CwjljR04.js +0 -1
- package/dist/assets/index-DPJj90PK.js +0 -2
- package/dist/assets/index-I8PSiTLl.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as ns,b5 as as,b6 as ts,b7 as ls,b8 as os,r as t,_ as De,S as oe,b9 as is,ba as ie,A as Ie,k as ce,i as cs,s as v,n as rs,j as e,bb as ds,a9 as _e,bc as x,bd as ps,be as re,I as de,aT as T,aR as H,bf as ms,bg as J,aS as pe,bh as me,bi as us,$ as hs}from"./main-D6IBl2Xu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function Le(d,j){const S=j.filter(C=>!d.has(C));return S.length===0?`${j[Math.floor(Math.random()*j.length)]}-${Date.now()%1e3}`:S[Math.floor(Math.random()*S.length)]}function gs({isOpen:d,onClose:j,onSpawnStart:S,onSpawnEnd:C,spawnPosition:$e,spawnAreaId:N}){const{t:n}=ns(["terminal","common"]),P=as(),p=ts(),ue=ls(),X=ue.length>0?ue:os,[m,b]=t.useState(""),[k,F]=t.useState(()=>De(oe.LAST_CWD)),[i,M]=t.useState("scout"),[he,I]=t.useState(!1),[Te,R]=t.useState(!1),[we,Y]=t.useState(!1),[xe,fe]=t.useState(""),[y,Q]=t.useState([]),[E,O]=t.useState(null),[Pe,ge]=t.useState(!1),[_,je]=t.useState(""),[h,Fe]=t.useState(""),[U,Re]=t.useState(!1),[z,Oe]=t.useState("bypass"),[o,G]=t.useState("claude"),[f,A]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[V,Z]=t.useState(new Set),[ee,Ne]=t.useState("claude-opus-4-8[1m]"),[se,be]=t.useState("xHigh"),[ne,Ue]=t.useState("gpt-5.6-luna"),[ae,ze]=t.useState("minimax/MiniMax-M1-80k"),[te,Ge]=t.useState(is),[ve,qe]=t.useState(""),[D,We]=t.useState(""),q=t.useRef(null),Se=t.useRef(!1),L=t.useCallback(()=>{window.__spawnModalAreaContext=null},[]),w=t.useMemo(()=>P.filter(s=>s.enabled),[P]),Be=["full-notifications","streaming-exec","task-label","report-task-to-boss","agent-tracking","agent-memory","send-message-to-agent"];t.useEffect(()=>{if(d&&!Se.current){if(w.length>0){const l=w.filter(r=>Be.includes(r.slug)).map(r=>r.id);l.length>0&&Z(new Set(l))}const a=De(oe.DEFAULT_AGENT_CLASS);if(a==="random"){const r=[...Object.keys(us),...p.map(u=>u.id)];M(r[Math.floor(Math.random()*r.length)])}else M(a||"scout")}Se.current=d},[d,w,p]);const Ce=t.useMemo(()=>{if(!D.trim())return w;const s=D.toLowerCase();return w.filter(a=>a.name.toLowerCase().includes(s)||a.description.toLowerCase().includes(s)||a.slug.toLowerCase().includes(s))},[w,D]),Ke=t.useCallback(s=>{Z(a=>{const l=new Set(a);return l.has(s)?l.delete(s):l.add(s),l})},[]);t.useMemo(()=>w.filter(s=>s.assignedAgentClasses.includes(i)),[w,i]);const He=t.useMemo(()=>{var a;const s=p.find(l=>l.id===i);return(a=s==null?void 0:s.defaultSkillIds)!=null&&a.length?P.filter(l=>s.defaultSkillIds.includes(l.id)):[]},[p,i,P]),ke=t.useMemo(()=>{if(!_.trim())return y;const s=_.toLowerCase();return y.filter(a=>a.sessionId.toLowerCase().includes(s)||a.projectPath.toLowerCase().includes(s)||a.firstMessage&&a.firstMessage.toLowerCase().includes(s))},[y,_]),W=t.useMemo(()=>{if(!h.trim())return p;const s=h.toLowerCase();return p.filter(a=>a.name.toLowerCase().includes(s)||a.description.toLowerCase().includes(s)||a.id.toLowerCase().includes(s))},[p,h]),B=t.useMemo(()=>{if(!h.trim())return ie;const s=h.toLowerCase();return ie.filter(a=>{const l=Ie[a.id];return a.name.toLowerCase().includes(s)||a.id.toLowerCase().includes(s)||l.description.toLowerCase().includes(s)})},[h]);t.useEffect(()=>{if(!d||!h.trim())return;const s=[...W.map(a=>a.id),...B.map(a=>a.id)];s.length===1&&s[0]!==i&&M(s[0])},[d,h,W,B,i]);const c=t.useMemo(()=>p.find(s=>s.id===i),[p,i]),Je=t.useMemo(()=>{if(c!=null&&c.model)return c.model},[c]),Xe=t.useMemo(()=>{if(c!=null&&c.customModelPath)return ce(`/api/custom-models/${c.id}`)},[c]),Ye=c==null?void 0:c.modelScale,Qe=t.useMemo(()=>c?"scout":i,[i,c]),K=t.useCallback(async s=>{ge(!0);try{const a=s?ce(`/api/agents/claude-sessions?cwd=${encodeURIComponent(s)}`):ce("/api/agents/claude-sessions"),r=await(await cs(a)).json();Q(r.sessions||[])}catch(a){console.error("Failed to fetch sessions:",a),Q([])}finally{ge(!1)}},[]);t.useEffect(()=>{d?K(k||void 0):(Q([]),O(null),je(""))},[d,K]),t.useEffect(()=>{if(!d)return;const s=setTimeout(()=>{K(k||void 0),O(null)},300);return()=>clearTimeout(s)},[k,d,K]),t.useEffect(()=>{if(!d||!N)return;const s=v.getState().areas.get(N);if(s!=null&&s.directories&&s.directories.length>0){F(s.directories[0]);return}const a=Array.from(v.getState().agents.values()).filter(g=>{var $;return(($=v.getAreaForAgent(g.id))==null?void 0:$.id)===N&&g.cwd});if(a.length===0)return;const l=new Map;for(const g of a)l.set(g.cwd,(l.get(g.cwd)||0)+1);let r="",u=0;for(const[g,$]of l)$>u&&(r=g,u=$);r&&F(r)},[d,N]),t.useEffect(()=>{if(d){const s=new Set(Array.from(v.getState().agents.values()).map(u=>u.name)),a=Le(s,X),l=p.find(u=>u.id===i),r=l?`${l.name} ${a}`:a;b(r),q.current&&(q.current.focus(),q.current.select())}},[d,X]),t.useEffect(()=>{if(!d)return;const s=p.find(a=>a.id===i);if(s){const a=p.find(l=>m.startsWith(l.name+" "));if(a){const l=m.substring(a.name.length+1);b(`${s.name} ${l}`)}else b(`${s.name} ${m}`)}else{const a=p.find(l=>m.startsWith(l.name+" "));if(a){const l=m.substring(a.name.length+1);b(l)}}},[i]),t.useEffect(()=>{i==="boss"&&Ne("claude-opus-4-8[1m]")},[i]);const Ve=()=>{var r;console.log("[SpawnModal] handleSpawn called"),R(!1);const s=E&&((r=y.find(u=>u.sessionId===E))==null?void 0:r.projectPath)||k;if(console.log("[SpawnModal] Effective CWD:",s),console.log("[SpawnModal] Agent name:",m),console.log("[SpawnModal] Agent class:",i),console.log("[SpawnModal] Permission mode:",z),console.log("[SpawnModal] Provider:",o),console.log("[SpawnModal] Use Chrome:",U),console.log("[SpawnModal] Session ID:",E||"none"),!s.trim()){console.error("[SpawnModal] Empty CWD, showing error"),R(!0);return}if(!m.trim()){console.log("[SpawnModal] Empty name, regenerating");const u=new Set(Array.from(v.getState().agents.values()).map(g=>g.name));b(Le(u,X));return}hs(oe.LAST_CWD,s),I(!0),S();const a=Array.from(V),l=ve.trim()||void 0;console.log("[SpawnModal] Calling store.spawnAgent with:",{name:m.trim(),class:i,cwd:s.trim(),sessionId:E||void 0,useChrome:o==="claude"?U:!1,permissionMode:z,provider:o,codexConfig:o==="codex"?f:void 0,codexModel:o==="codex"?ne:void 0,opencodeModel:o==="opencode"?ae:void 0,grokModel:o==="grok"?te:void 0,initialSkillIds:a,model:o==="claude"?ee:void 0,customInstructions:l?`${l.length} chars`:void 0,spawnAreaId:N||void 0}),window.__spawnModalAreaContext=N?{areaId:N}:null,v.spawnAgent(m.trim(),i,s.trim(),$e||void 0,E||void 0,o==="claude"?U:!1,z,a,o,o==="codex"?f:void 0,o==="codex"?ne:void 0,o==="claude"?ee:void 0,l,o==="claude"||o==="grok"?se:void 0,o==="opencode"?ae:void 0,o==="grok"?te:void 0)},Me=()=>{console.log("[SpawnModal] Agent creation successful"),I(!1),b(""),Z(new Set),L(),C(),j()},ye=()=>{console.error("[SpawnModal] Agent creation failed"),I(!1),R(!0),L(),C()},Ee=s=>{console.log("[SpawnModal] Directory not found:",s),I(!1),fe(s),Y(!0),C()},Ae=()=>{Y(!1),I(!0),S(),v.createDirectoryAndSpawn(xe,m.trim(),i)},le=()=>{Y(!1),fe(""),L()};t.useEffect(()=>(window.__spawnModalSuccess=Me,window.__spawnModalError=ye,window.__spawnModalDirNotFound=Ee,()=>{L(),delete window.__spawnModalSuccess,delete window.__spawnModalError,delete window.__spawnModalDirNotFound}),[m,i,Me,ye,Ee,L]);const{handleMouseDown:Ze,handleClick:es}=rs(j),ss=s=>{s.key==="Escape"&&j()};return!d&&!we?null:we?e.jsx("div",{className:"modal-overlay visible",onClick:le,onKeyDown:s=>{s.key==="Escape"&&le(),s.key==="Enter"&&Ae()},children:e.jsxs("div",{className:"modal confirm-modal",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:n("terminal:spawn.directoryNotFound")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:n("terminal:spawn.directoryNotExist")}),e.jsx("code",{className:"confirm-modal-path",children:xe}),e.jsx("p",{children:n("terminal:spawn.wouldYouCreate")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:le,children:n("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:Ae,autoFocus:!0,children:n("terminal:spawn.createDirectory")})]})]})}):e.jsx("div",{className:`modal-overlay ${d?"visible":""}`,onMouseDown:Ze,onClick:es,onKeyDown:ss,children:e.jsxs("div",{className:"modal spawn-modal",children:[e.jsx("div",{className:"modal-header",children:n("terminal:spawn.deployTitle")}),e.jsxs("div",{className:"modal-body spawn-modal-body",children:[e.jsxs("div",{className:"spawn-section",children:[e.jsxs("div",{className:"spawn-section-header",children:[e.jsx("h4",{className:"spawn-section-title",children:n("terminal:spawn.agentClass")}),e.jsx("span",{className:"spawn-section-hint",children:(c==null?void 0:c.name)||i})]}),e.jsxs("div",{className:"spawn-top-section",children:[e.jsxs("div",{className:"spawn-preview-compact",children:[e.jsx(ds,{agentClass:Qe,modelFile:Je,customModelUrl:Xe,modelScale:Ye,width:110,height:130}),e.jsx("div",{className:"spawn-preview-label",children:(c==null?void 0:c.name)||i})]}),e.jsxs("div",{className:"spawn-class-section",children:[p.length+ie.length>6&&e.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:n("terminal:spawn.filterClasses"),value:h,onChange:s=>Fe(s.target.value)}),e.jsxs("div",{className:"class-selector-inline",children:[W.map(s=>e.jsxs("button",{className:`class-chip ${i===s.id?"selected":""}`,onClick:()=>M(s.id),title:s.description,children:[e.jsx(_e,{classId:s.id,size:18,className:"class-chip-icon"}),e.jsx("span",{className:"class-chip-name",children:s.name})]},s.id)),B.map(s=>{const a=Ie[s.id];return e.jsxs("button",{className:`class-chip ${i===s.id?"selected":""}`,onClick:()=>M(s.id),title:a.description,children:[e.jsx(_e,{classId:s.id,size:18,className:"class-chip-icon"}),e.jsx("span",{className:"class-chip-name",children:s.name})]},s.id)}),h&&W.length===0&&B.length===0&&e.jsx("div",{className:"class-search-empty",children:n("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),e.jsxs("div",{className:"spawn-form-row",children:[e.jsxs("div",{className:"spawn-field",children:[e.jsx("label",{className:"spawn-label",children:n("common:labels.name")}),e.jsx("input",{ref:q,type:"text",className:"spawn-input",placeholder:n("terminal:spawn.agentNamePlaceholder"),value:m,onChange:s=>b(s.target.value)})]}),e.jsxs("div",{className:"spawn-field spawn-field-wide",children:[e.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.workingDir"),e.jsx(x,{text:n("terminal:spawn.helpWorkingDir"),title:n("terminal:spawn.workingDir"),position:"top",size:"sm"})]}),e.jsx(ps,{value:k,onChange:s=>{F(s),R(!1)},placeholder:n("terminal:spawn.workingDirPlaceholder"),className:`spawn-input ${Te?"error":""}`,directoriesOnly:!0})]})]})]}),e.jsxs("div",{className:"spawn-section",children:[e.jsx("div",{className:"spawn-section-header",children:e.jsx("h4",{className:"spawn-section-title",children:n("terminal:spawn.selectRuntime")})}),e.jsxs("div",{className:"spawn-form-row",children:[e.jsxs("div",{className:"spawn-field",children:[e.jsxs("label",{className:"spawn-label",children:[n("common:labels.runtime"),e.jsx(x,{text:n("terminal:spawn.helpRuntime"),title:n("terminal:spawn.runtimeTitle"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"spawn-select-row",children:[e.jsxs("button",{className:`spawn-select-btn ${o==="claude"?"selected":""}`,onClick:()=>G("claude"),title:n("terminal:spawn.useClaudeCli"),children:[e.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),e.jsx("span",{children:"Claude"})]}),e.jsxs("button",{className:`spawn-select-btn ${o==="codex"?"selected":""}`,onClick:()=>G("codex"),title:n("terminal:spawn.useCodexCli"),children:[e.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),e.jsx("span",{children:"Codex"})]}),e.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${o==="opencode"?"selected":""}`,onClick:()=>G("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[e.jsx("img",{src:"/assets/opencode.svg",alt:"OpenCode",className:"spawn-provider-icon"}),e.jsx("span",{children:"OpenCode"})]}),e.jsxs("button",{className:`spawn-select-btn spawn-select-btn--grok ${o==="grok"?"selected":""}`,onClick:()=>G("grok"),title:"Use Grok CLI (headless)",children:[e.jsx("img",{src:"/assets/grok.png",alt:"Grok",className:"spawn-provider-icon"}),e.jsx("span",{children:"Grok"})]})]})]}),e.jsxs("div",{className:"spawn-field",children:[e.jsxs("label",{className:"spawn-label",children:[n("common:labels.permissions"),e.jsx(x,{text:n("terminal:spawn.helpPermission"),title:n("terminal:spawn.permissionMode"),position:"top",size:"sm"})]}),e.jsx("div",{className:"spawn-select-row",children:Object.keys(re).map(s=>e.jsxs("button",{className:`spawn-select-btn ${z===s?"selected":""}`,onClick:()=>Oe(s),title:re[s].description,children:[e.jsx("span",{children:e.jsx(de,{name:s==="bypass"?"bolt":"lock",size:12})}),e.jsx("span",{children:re[s].label})]},s))})]})]}),e.jsx("div",{className:"spawn-form-row",children:e.jsxs("div",{className:"spawn-field",children:[e.jsxs("label",{className:"spawn-label",children:[n("common:labels.model"),e.jsx(x,{text:n("terminal:spawn.helpModel"),title:n("terminal:spawn.modelTitle"),position:"top",size:"sm"})]}),o==="claude"?e.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(T).filter(s=>!T[s].deprecated).map(s=>e.jsxs("button",{className:`spawn-select-btn ${ee===s?"selected":""}`,onClick:()=>Ne(s),title:T[s].description,children:[e.jsx("span",{children:T[s].icon}),e.jsx("span",{children:T[s].label})]},s))}):o==="codex"?e.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(H).map(s=>e.jsxs("button",{className:`spawn-select-btn ${ne===s?"selected":""}`,onClick:()=>Ue(s),title:H[s].description,children:[e.jsx("span",{children:H[s].icon}),e.jsx("span",{children:H[s].label})]},s))}):o==="opencode"?e.jsx(ms,{value:ae,onChange:ze,inputId:"spawn-opencode-model"}):o==="grok"?e.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(J).map(s=>e.jsxs("button",{className:`spawn-select-btn ${te===s?"selected":""}`,onClick:()=>Ge(s),title:J[s].description,children:[e.jsx("span",{children:J[s].icon}),e.jsx("span",{children:J[s].label})]},s))}):e.jsx("div",{className:"spawn-inline-hint",children:n("terminal:spawn.chooseCodexModel")})]})}),e.jsxs("div",{className:"spawn-form-row",children:[(o==="claude"||o==="grok")&&e.jsxs("div",{className:"spawn-field",children:[e.jsx("label",{className:"spawn-label",children:"Effort"}),e.jsxs("div",{className:"spawn-select-row spawn-select-row--effort",children:[e.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${se===void 0?"selected":""}`,onClick:()=>be(void 0),title:"Use default effort level",children:e.jsx("span",{children:"Default"})}),Object.keys(pe).map(s=>e.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${se===s?"selected":""}`,onClick:()=>be(s),title:pe[s].description,children:e.jsx("span",{children:pe[s].label})},s))]})]}),e.jsxs("div",{className:"spawn-field",children:[e.jsx("label",{className:"spawn-label",children:n("terminal:spawn.browser")}),e.jsxs("label",{className:"spawn-checkbox",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:s=>Re(s.target.checked),disabled:o!=="claude"}),e.jsxs("span",{children:[e.jsx(de,{name:"globe",size:12})," ",n("terminal:spawn.chromeBrowser")]}),e.jsx(x,{text:n(o==="claude"?"terminal:spawn.helpChrome":"terminal:spawn.helpChromeDisabled"),title:n("terminal:spawn.chromeBrowser"),position:"top",size:"sm"})]})]})]}),o==="codex"&&e.jsxs("div",{className:"codex-config-section",children:[e.jsx("div",{className:"codex-config-title",children:n("terminal:spawn.codex.configuration")}),e.jsxs("div",{className:"codex-config-options",children:[e.jsxs("div",{className:"codex-option-group",children:[e.jsxs("label",{className:"spawn-checkbox",children:[e.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:s=>A(a=>({...a,fullAuto:s.target.checked}))}),e.jsx("span",{children:n("terminal:spawn.codex.fullAuto")}),e.jsx(x,{text:n("terminal:spawn.helpFullAuto"),title:n("terminal:spawn.fullAutoTitle"),position:"top",size:"sm"})]}),e.jsxs("label",{className:"spawn-checkbox",children:[e.jsx("input",{type:"checkbox",checked:!!f.search,onChange:s=>A(a=>({...a,search:s.target.checked}))}),e.jsx("span",{children:n("terminal:spawn.codex.search")}),e.jsx(x,{text:n("terminal:spawn.helpSearch"),title:n("terminal:spawn.searchTitle"),position:"top",size:"sm"})]})]}),f.fullAuto===!1&&e.jsxs("div",{className:"codex-option-group",children:[e.jsx("div",{className:"codex-option-header",children:n("terminal:spawn.codex.restrictions")}),e.jsxs("select",{className:"spawn-input codex-select",value:f.sandbox||"workspace-write",onChange:s=>A(a=>({...a,sandbox:s.target.value})),children:[e.jsxs("option",{value:"read-only",children:["📖 ",n("terminal:spawn.codex.sandboxReadOnly")]}),e.jsxs("option",{value:"workspace-write",children:["✏️ ",n("terminal:spawn.codex.sandboxWorkspaceWrite")]}),e.jsxs("option",{value:"danger-full-access",children:["⚡ ",n("terminal:spawn.codex.sandboxDangerFullAccess")]})]}),e.jsxs("select",{className:"spawn-input codex-select",value:f.approvalMode||"on-request",onChange:s=>A(a=>({...a,approvalMode:s.target.value})),children:[e.jsxs("option",{value:"untrusted",children:["🔒 ",n("terminal:spawn.codex.approvalsUntrusted")]}),e.jsxs("option",{value:"on-failure",children:["⚠️ ",n("terminal:spawn.codex.approvalsOnFailure")]}),e.jsxs("option",{value:"on-request",children:["🤔 ",n("terminal:spawn.codex.approvalsOnRequest")]}),e.jsxs("option",{value:"never",children:["✅ ",n("terminal:spawn.codex.approvalsNever")]})]})]}),e.jsxs("div",{className:"codex-option-group",children:[e.jsx("div",{className:"codex-option-header",children:n("terminal:spawn.codex.profile")}),e.jsx("input",{type:"text",className:"spawn-input codex-profile-input",placeholder:n("terminal:spawn.codex.profilePlaceholder"),value:f.profile||"",onChange:s=>A(a=>({...a,profile:s.target.value||void 0}))})]}),e.jsxs("div",{className:"codex-option-group",children:[e.jsx("div",{className:"codex-option-header",children:n("terminal:spawn.codex.reasoningEffort")}),e.jsxs("select",{className:"spawn-input codex-select",value:f.reasoningEffort||"",onChange:s=>A(a=>({...a,reasoningEffort:s.target.value||void 0})),children:[e.jsx("option",{value:"",children:n("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(me).map(s=>e.jsxs("option",{value:s,children:[me[s].icon," ",me[s].label]},s))]})]})]})]})]}),w.length>0&&e.jsxs("div",{className:"spawn-section spawn-skills-section",children:[e.jsxs("div",{className:"spawn-section-header",children:[e.jsxs("h4",{className:"spawn-section-title",children:[n("terminal:spawn.skills"),e.jsx(x,{text:n("terminal:spawn.helpSkills"),title:n("terminal:spawn.skillsTitle"),position:"top",size:"sm"})]}),e.jsxs("span",{className:"spawn-section-hint",children:[V.size," selected · ",n("common:labels.optional")]})]}),w.length>6&&e.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:n("terminal:spawn.filterSkills"),value:D,onChange:s=>We(s.target.value)}),e.jsxs("div",{className:"spawn-skills-inline",children:[Ce.map(s=>{const a=V.has(s.id);return He.some(r=>r.id===s.id)?null:e.jsxs("button",{className:`spawn-skill-chip ${a?"selected":""}`,onClick:()=>Ke(s.id),title:s.description,children:[a&&e.jsx("span",{className:"spawn-skill-check",children:e.jsx(de,{name:"check",size:10})}),e.jsx("span",{children:s.name}),s.builtin&&e.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},s.id)}),D&&Ce.length===0&&e.jsx("div",{className:"skill-search-empty",children:n("terminal:spawn.noSkillsMatch",{query:D})})]})]}),e.jsxs("details",{className:"spawn-advanced",children:[e.jsxs("summary",{children:[n("terminal:spawn.customInstructions")," & ",n("terminal:spawn.linkSession")]}),e.jsxs("div",{className:"spawn-advanced-body",children:[e.jsxs("div",{className:"spawn-custom-instructions-section",children:[e.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.customInstructions")," ",e.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]}),e.jsx(x,{text:n("terminal:spawn.helpCustomInstructions"),title:n("terminal:spawn.customInstructions"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:n("terminal:spawn.customInstructionsPlaceholder"),value:ve,onChange:s=>qe(s.target.value),rows:3})]}),e.jsxs("div",{className:"spawn-sessions-section",children:[e.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.linkSession")," ",e.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]}),e.jsx(x,{text:n("terminal:spawn.helpLinkSession"),title:n("terminal:spawn.linkSessionTitle"),position:"top",size:"sm"})]}),y.length>0&&e.jsx("input",{type:"text",className:"spawn-input session-search-input",placeholder:n("terminal:spawn.searchSessions"),value:_,onChange:s=>je(s.target.value)}),e.jsx("div",{className:"sessions-list",children:Pe?e.jsx("div",{className:"sessions-loading",children:n("terminal:spawn.loadingSessions")}):y.length===0?e.jsx("div",{className:"sessions-empty",children:n("terminal:spawn.noSessions")}):ke.length===0?e.jsx("div",{className:"sessions-empty",children:n("terminal:spawn.noSessionsMatch",{query:_})}):ke.map(s=>{const a=E===s.sessionId,l=Date.now()-new Date(s.lastModified).getTime(),r=l<6e4?n("common:time.justNow"):l<36e5?n("common:time.minutesAgo",{count:Math.floor(l/6e4)}):l<864e5?n("common:time.hoursAgo",{count:Math.floor(l/36e5)}):n("common:time.daysAgo",{count:Math.floor(l/864e5)});return e.jsxs("div",{className:`session-item ${a?"selected":""}`,onClick:()=>{a?O(null):(O(s.sessionId),F(s.projectPath))},children:[e.jsxs("div",{className:"session-item-header",children:[e.jsx("span",{className:"session-item-path",children:s.projectPath}),e.jsx("span",{className:"session-item-age",children:r})]}),e.jsx("div",{className:"session-item-preview",children:s.firstMessage||n("terminal:spawn.messagesCount",{count:s.messageCount})})]},s.sessionId)})})]})]})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:j,children:n("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:Ve,disabled:he,children:n(he?"common:buttons.deploying":"common:buttons2.deploy")})]})]})})}export{gs as SpawnModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as R,n as U,aq as j,da as B,db as F,j as t,bB as G,I,c9 as k}from"./main-D6IBl2Xu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const b=["#6ab8c8","#c89a5a","#9a80c0","#5cb88a","#c85a5a","#c87a9a","#c8c87a","#5a8fd4","#d45a5a","#8a6fbf"],P=14,w=720,C=260,p={top:16,right:20,bottom:42,left:64};function W(){const i=new Date;return i.setHours(0,0,0,0),i.getTime()}function $(i){if(!i)return"N/A";try{return new Date(i).toLocaleString()}catch{return"N/A"}}function q(i,s){if(i.length===0||s<=0)return"conic-gradient(rgba(50, 50, 62, 0.95) 0deg 360deg)";let a=0;return`conic-gradient(${i.map((h,l)=>{const c=a,n=h.tokens.total/s*360;return a+=n,`${b[l%b.length]} ${c.toFixed(2)}deg ${a.toFixed(2)}deg`}).join(", ")})`}function E(i){const[,s,a]=i.split("-");return!s||!a?i:`${s}/${a}`}function z(i){const s=(i==null?void 0:i.days)??[];if(s.length===0)return[];const a=new Map;for(const l of s)for(const c of l.agents){const n=a.get(c.agentId)??{agentName:c.agentName,total:0};n.total+=c.tokens.total,a.set(c.agentId,n)}const r={id:"general",name:"General",color:"#f1fa8c",values:s.map(l=>l.totalTokens),total:s.reduce((l,c)=>l+c.totalTokens,0),peak:Math.max(0,...s.map(l=>l.totalTokens)),isTotal:!0},h=[...a.entries()].sort((l,c)=>c[1].total-l[1].total).map(([l,c],n)=>({id:l,name:c.agentName,color:b[n%b.length],values:s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}),total:c.total,peak:Math.max(0,...s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}))}));return[r,...h].filter(l=>l.total>0)}function Y(i){if(i<=0)return 1;const s=10**Math.floor(Math.log10(i)),a=i/s;return(a<=1?1:a<=2?2:a<=5?5:10)*s}function H(i,s,a,r){const h=p.left,l=p.top,c=w-p.left-p.right,n=C-p.top-p.bottom,u=i<=1?h+c/2:h+s/(i-1)*c,d=l+n-a/r*n;return{x:u,y:d}}function X(i,s){return i.map((a,r)=>{const{x:h,y:l}=H(i.length,r,a,s);return`${h.toFixed(2)},${l.toFixed(2)}`}).join(" ")}function J(i,s=28){return i.length<=s?i:`${i.slice(0,s-1)}...`}function K({summary:i}){const[s,a]=j.useState(null),r=i.days,h=z(i),l=Math.max(1,...h.flatMap(e=>e.values)),c=Y(l),n=p.left,u=p.top,d=w-p.left-p.right,x=C-p.top-p.bottom,f=[0,.5,1],M=Math.max(1,Math.ceil(r.length/5)),v=190,y=86,g=s?Math.min(Math.max(s.x+12,8),w-v-8):0,_=s?Math.min(Math.max(s.y-y-10,8),C-y-8):0;return t.jsxs("div",{className:"statistics-line-chart",children:[t.jsxs("svg",{className:"statistics-line-chart__svg",viewBox:`0 0 ${w} ${C}`,role:"img","aria-label":"Daily Claude token usage by agent",preserveAspectRatio:"xMidYMid meet",onMouseLeave:()=>a(null),children:[f.map(e=>{const m=u+x-e*x;return t.jsxs("g",{children:[t.jsx("line",{className:"statistics-line-chart__grid",x1:n,y1:m,x2:n+d,y2:m}),t.jsx("text",{className:"statistics-line-chart__axis-label",x:n-10,y:m+4,textAnchor:"end",children:k(Math.round(c*e))})]},e)}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u,x2:n,y2:u+x}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u+x,x2:n+d,y2:u+x}),r.map((e,m)=>{if(m!==0&&m!==r.length-1&&m%M!==0)return null;const o=r.length<=1?n+d/2:n+m/(r.length-1)*d;return t.jsx("text",{className:"statistics-line-chart__axis-label",x:o,y:C-14,textAnchor:"middle",children:E(e.date)},e.date)}),h.map(e=>t.jsx("polyline",{className:e.isTotal?"statistics-line-chart__line statistics-line-chart__line--total":"statistics-line-chart__line",points:X(e.values,c),fill:"none",stroke:e.color,strokeWidth:e.isTotal?3:2,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("title",{children:`${e.name}: ${e.peak.toLocaleString()} peak daily tokens`})},e.id)),h.map(e=>e.values.map((m,o)=>{var L,D,V,A;const{x:N,y:S}=H(r.length,o,m,c),T={id:`${e.id}-${(L=r[o])==null?void 0:L.date}`,date:((D=r[o])==null?void 0:D.date)??"",name:e.name,color:e.color,value:m,total:e.total,peak:e.peak,x:N,y:S};return t.jsxs("g",{children:[t.jsx("circle",{className:"statistics-line-chart__point",cx:N,cy:S,r:e.isTotal?3.4:2.6,fill:e.color}),t.jsx("circle",{className:"statistics-line-chart__point-hit",cx:N,cy:S,r:10,tabIndex:0,role:"button","aria-label":`${e.name} ${(V=r[o])==null?void 0:V.date}: ${m.toLocaleString()} tokens`,onMouseEnter:()=>a(T),onFocus:()=>a(T),onBlur:()=>a(null)})]},`${e.id}-${(A=r[o])==null?void 0:A.date}`)})),s&&t.jsxs("g",{className:"statistics-line-chart__tooltip",children:[t.jsx("line",{className:"statistics-line-chart__hover-line",x1:s.x,y1:u,x2:s.x,y2:u+x}),t.jsx("circle",{className:"statistics-line-chart__hover-point",cx:s.x,cy:s.y,r:5,fill:s.color}),t.jsx("rect",{className:"statistics-line-chart__tooltip-box",x:g,y:_,width:v,height:y,rx:6}),t.jsx("text",{className:"statistics-line-chart__tooltip-title",x:g+10,y:_+18,children:E(s.date)}),t.jsx("text",{className:"statistics-line-chart__tooltip-name",x:g+10,y:_+34,children:J(s.name)}),t.jsxs("text",{className:"statistics-line-chart__tooltip-value",x:g+10,y:_+52,children:["Daily: ",k(s.value)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+10,y:_+68,children:["Peak: ",k(s.peak)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+100,y:_+68,children:["Total: ",k(s.total)]})]})]}),t.jsx("div",{className:"statistics-line-chart__legend",children:h.map(e=>t.jsxs("div",{className:"statistics-line-chart__legend-item",title:`${e.name}: peak ${e.peak.toLocaleString()} daily tokens, ${e.total.toLocaleString()} period tokens`,children:[t.jsx("span",{className:"statistics-line-chart__legend-swatch",style:{backgroundColor:e.color}}),t.jsx("span",{children:e.name}),t.jsx("strong",{children:k(e.peak)})]},e.id))})]})}function tt({isOpen:i,onClose:s}){const{t:a}=R(["terminal","common"]),{handleMouseDown:r,handleClick:h}=U(s),[l,c]=j.useState(null),[n,u]=j.useState(null),[d,x]=j.useState(!1),[f,M]=j.useState(null),v=j.useMemo(()=>W(),[]),y=j.useCallback(async()=>{x(!0),M(null);try{const o=Date.now(),[N,S]=await Promise.all([B({since:v,until:o}),F({days:P,until:o})]);c(N),u(S)}catch(o){M((o==null?void 0:o.message)||"Error")}finally{x(!1)}},[v]);if(j.useEffect(()=>{i&&y()},[i,y]),!i)return null;const g=(l==null?void 0:l.entries)??[],_=(l==null?void 0:l.totalTokens)??0,e=q(g,_),m=((n==null?void 0:n.days)??[]).some(o=>o.totalTokens>0);return t.jsx(G,{children:t.jsx("div",{className:"modal-overlay visible",onMouseDown:r,onClick:h,children:t.jsxs("div",{className:"modal statistics-modal",children:[t.jsxs("div",{className:"modal-header statistics-modal__header",children:[t.jsxs("div",{className:"statistics-modal__title",children:[t.jsx("span",{className:"statistics-modal__icon",children:t.jsx(I,{name:"dashboard",size:15})}),t.jsx("span",{children:a("terminal:statistics.title",{defaultValue:"Statistics"})})]}),t.jsx("button",{className:"modal-close statistics-modal__close",onClick:s,title:a("common:buttons.close"),children:"×"})]}),t.jsxs("div",{className:"modal-body statistics-modal__body",children:[t.jsxs("section",{className:"statistics-panel",children:[t.jsxs("div",{className:"statistics-panel__header",children:[t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.usageByAgent",{defaultValue:"Claude usage today"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.usageByAgentSubtitle",{defaultValue:"Input + cache creation + cache read + output tokens, deduped by Claude request id"})})]}),t.jsx("button",{type:"button",className:"statistics-panel__refresh",onClick:y,disabled:d,title:a("terminal:statistics.refresh",{defaultValue:"Refresh usage"}),children:t.jsx(I,{name:"refresh",size:14})})]}),d&&!l&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&f&&t.jsx("div",{className:"statistics-panel__empty statistics-panel__empty--error",children:a("terminal:statistics.error",{defaultValue:"Failed to load usage: {{error}}",error:f})}),!f&&l&&g.length===0&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.empty",{defaultValue:"No Claude token usage found for today."})}),!f&&l&&g.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"statistics-panel__layout",children:[t.jsx("div",{className:"statistics-panel__chart-wrap",children:t.jsx("div",{className:"statistics-panel__pie",style:{background:e},role:"img","aria-label":a("terminal:statistics.pieLabel",{defaultValue:"Claude token usage by agent"}),children:t.jsxs("div",{className:"statistics-panel__pie-hole",children:[t.jsx("strong",{children:k(_)}),t.jsx("span",{children:a("terminal:statistics.total",{defaultValue:"total"})})]})})}),t.jsx("div",{className:"statistics-panel__list",children:g.map((o,N)=>t.jsxs("div",{className:"statistics-panel__row",title:`${o.agentName}: ${o.tokens.total.toLocaleString()} tokens`,children:[t.jsx("span",{className:"statistics-panel__swatch",style:{backgroundColor:b[N%b.length]}}),t.jsxs("div",{className:"statistics-panel__row-main",children:[t.jsx("div",{className:"statistics-panel__row-name",children:o.agentName}),t.jsxs("div",{className:"statistics-panel__row-meta",children:[o.requestCount.toLocaleString()," ",a("terminal:statistics.requests",{defaultValue:"requests"})," / ",o.percent,"%"]})]}),t.jsx("strong",{children:k(o.tokens.total)})]},o.agentId))})]}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(l.since),until:$(l.until)})})]})]}),t.jsxs("section",{className:"statistics-panel",children:[t.jsx("div",{className:"statistics-panel__header",children:t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.dailyUsage",{defaultValue:"Daily usage by agent"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.dailyUsageSubtitle",{defaultValue:"General token usage by day plus one line for each Claude agent."})})]})}),d&&!n&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&!f&&n&&!m&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.dailyEmpty",{defaultValue:"No Claude token usage found for recent days."})}),!f&&n&&m&&t.jsxs(t.Fragment,{children:[t.jsx(K,{summary:n}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(n.since),until:$(n.until)})})]})]})]})]})})})}export{tt as StatisticsModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as L,aC as $,ar as D,r as m,j as s,bj as N,a9 as S,I as g,s as J}from"./main-D6IBl2Xu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function M({isOpen:l,bossId:r,onClose:o}){var j;const{t:a}=L(["terminal","common"]),f=$(),n=D(r),[i,c]=m.useState(new Set),[u,b]=m.useState(!1),d=Array.from(f.values()).filter(e=>e.class!=="boss"&&(!e.bossId||e.bossId===r));m.useEffect(()=>{l&&n&&c(new Set(n.subordinateIds||[]))},[l,n]);const y=()=>{b(!0),J.assignSubordinates(r,Array.from(i)),setTimeout(()=>{b(!1),o()},300)},A=e=>{const t=new Set(i);t.has(e)?t.delete(e):t.add(e),c(t)},C=()=>{c(new Set(d.map(e=>e.id)))},p=()=>{c(new Set)},w=e=>{e.target===e.currentTarget&&o()},k=e=>{e.key==="Escape"&&o()};if(!l||!n)return null;const E=N.boss,h=((j=n.subordinateIds)==null?void 0:j.length)||0,I=i.size,x=JSON.stringify([...n.subordinateIds||[]].sort())!==JSON.stringify([...i].sort());return s.jsx("div",{className:`modal-overlay ${l?"visible":""}`,onClick:w,onKeyDown:k,children:s.jsxs("div",{className:"modal subordinate-assignment-modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("span",{className:"boss-header-icon",style:{color:E.color},children:s.jsx(S,{agent:n,size:22})}),a("terminal:team.manageTeam"),": ",n.name]}),s.jsxs("div",{className:"modal-body subordinate-assignment-body",children:[s.jsxs("div",{className:"subordinate-assignment-info",children:[s.jsx("p",{children:a("terminal:team.selectAgents")}),s.jsxs("div",{className:"subordinate-assignment-actions",children:[s.jsx("button",{className:"btn btn-small",onClick:C,children:a("common:buttons.selectAll")}),s.jsx("button",{className:"btn btn-small",onClick:p,children:a("common:buttons.clearAll")})]})]}),s.jsx("div",{className:"subordinates-list",children:d.length===0?s.jsx("div",{className:"subordinates-empty",children:a("terminal:team.noAgentsAvailable")}):d.map(e=>{var v;const t=i.has(e.id),T=N[e.class],z=(v=n.subordinateIds)==null?void 0:v.includes(e.id);return s.jsxs("div",{className:`subordinate-item ${t?"selected":""}`,onClick:()=>A(e.id),children:[s.jsx("div",{className:"subordinate-checkbox",children:t?s.jsx(g,{name:"check",size:12}):null}),s.jsx("div",{className:"subordinate-icon",style:{color:T.color},children:s.jsx(S,{agent:e,size:18})}),s.jsxs("div",{className:"subordinate-info",children:[s.jsx("div",{className:"subordinate-name",children:e.name}),s.jsx("div",{className:"subordinate-class",children:e.class})]}),s.jsx("div",{className:`subordinate-status status-${e.status}`,children:e.status}),z&&s.jsx("div",{className:"subordinate-badge",children:a("common:status.current")})]},e.id)})}),s.jsx("div",{className:"subordinate-assignment-summary",children:x?s.jsxs("span",{className:"summary-changed",children:[h," ",s.jsx(g,{name:"arrow-right",size:11})," ",I," ",a("terminal:team.subordinates").toLowerCase()]}):s.jsxs("span",{className:"summary-unchanged",children:[h," ",a("terminal:team.subordinates").toLowerCase()]})})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:o,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-boss",onClick:y,disabled:u||!x,children:a(u?"common:status.saving":"terminal:team.saveTeam")})]})]})})}export{M as SubordinateAssignmentModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as l,j as e,I as _,u as J,bl as is,ag as os,bm as xs,bn as bs,s as C,bo as js,bd as vs,bp as ys,C as fe,K as Q,L as Z,i as me,k as he,bq as ws,br as Ns,bs as ks,bt as Ss,bu as Cs,bv as As,bw as Ts,bx as ls,by as Es,bz as Ps,bA as _s,J as Is,X as $s,bB as Se,a9 as Ls,bC as cs,bD as Ds,bE as He,bF as Os,bG as Fs,bH as zs,bI as Rs,bJ as Bs,bK as Ms,bL as Us,as as Vs,b6 as Ks,_ as Hs,S as ke,bM as Ws,bN as qs,bO as Gs,bP as Ys,b8 as Js,bQ as Zs,bR as Xs,bS as Qs,bT as et,bU as Ue,$ as $e,bi as st,bV as Ve,bW as tt,bX as at,a5 as nt,m as it,bY as ot,bZ as lt,b_ as ct}from"./main-D6IBl2Xu.js";import{g as rt,d as dt,u as ut}from"./area-logos-HooY4aHb.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const rs="tide-toolbox-collapse";function pt(s,a){try{const t=localStorage.getItem(`${rs}-${s}`);if(t!==null)return t==="true"}catch{}return a}function mt(s,a){try{localStorage.setItem(`${rs}-${s}`,String(a))}catch{}}function q({title:s,storageKey:a,defaultOpen:t=!1,forceOpen:i=!1,children:c,headerExtra:r}){const[d,f]=l.useState(()=>a?pt(a,t):t),o=()=>{const w=!d;f(w),a&&mt(a,w)},m=i||d;return e.jsxs("div",{className:`collapsible-section ${m?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:o,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(_,{name:m?"caret-down":"caret-right",size:10})})]})]}),m&&e.jsx("div",{className:"collapsible-content",children:c})]})}function ht({area:s,isSelected:a,onClick:t,onDelete:i}){const{t:c}=J(["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:i,title:c("config:areas.deleteArea"),children:"×"})]})}function gt({building:s,isSelected:a,onClick:t,onEdit:i}){var f;const{t:c}=J(["config"]),r=((f=s.pm2Status)==null?void 0:f.ports)||[],d=(o,m)=>{o.stopPropagation(),window.open(`http://${window.location.hostname}:${m}`,"_blank")};return e.jsxs("div",{className:`building-item ${a?"selected":""}`,onClick:t,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:is[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx(_,{name:os(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(o=>e.jsxs("a",{href:`http://${window.location.hostname}:${o}`,className:"building-port-link",onClick:m=>d(m,o),title:`Open :${o}`,children:[":",o]},o))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:o=>{o.stopPropagation(),i()},title:c("config:buildings.editBuilding"),children:e.jsx(_,{name:"gear",size:14})})]})}function ft({building:s,onClose:a,onOpenModal:t}){var m,w,j,g,T,y,E,v;const{t:i}=J(["config","common"]),r=xs().get(s.id)||[],d=bs[s.style||"server-rack"],f=u=>{C.sendBuildingCommand(s.id,u)},o=u=>{window.open(u,"_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(_,{name:os(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:is[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:i("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:i("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:i("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:i("config:buildings.actions")}),e.jsxs("div",{className:"building-editor-actions",children:[e.jsxs("button",{className:"building-editor-action-btn start",onClick:()=>f("start"),disabled:!((m=s.commands)!=null&&m.start)||s.status==="running",title:((w=s.commands)==null?void 0:w.start)||i("config:buildings.noStartCommand"),children:[e.jsx(_,{name:"play",size:12})," ",i("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)||i("config:buildings.noStopCommand"),children:[e.jsx(_,{name:"stop",size:12,weight:"fill"})," ",i("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)||i("config:buildings.noRestartCommand"),children:[e.jsx(_,{name:"refresh",size:12})," ",i("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)||i("config:buildings.noHealthCheck"),children:[e.jsx(_,{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:i("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((u,k)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>o(u.url),title:u.url,children:[e.jsx(_,{name:"link",size:12})," ",u.label||u.url]},k))})]}),r.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsxs("div",{className:"building-editor-section-title",children:[i("config:buildings.recentLogs"),e.jsx("button",{className:"building-editor-clear-logs",onClick:()=>C.clearBuildingLogs(s.id),title:i("common:buttons.clear"),children:i("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:r.slice(-5).map((u,k)=>e.jsx("div",{className:"building-editor-log-entry",children:u},k))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:t,children:[e.jsx(_,{name:"gear",size:12})," ",i("config:buildings.fullSettings")]})})]})}const xt=[{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 bt({area:s,onClose:a,onOpenFolder:t}){var te;const{t:i}=J(["config","common"]),[c,r]=l.useState(s.name),[d,f]=l.useState(s.prompt||""),[o,m]=l.useState(!1),[w,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=N=>{const D=N.target.value;r(D),C.updateArea(s.id,{name:D})},v=N=>{C.updateArea(s.id,{color:N})},u=N=>{const D=N.target.value;f(D),C.updateArea(s.id,{prompt:D})},k=()=>{w.trim()&&(C.addDirectoryToArea(s.id,w.trim()),j(""),m(!1))},F=(N,D)=>{D.stopPropagation(),C.removeDirectoryFromArea(s.id,N)},O=()=>{C.bringAreaToFront(s.id)},K=()=>{C.sendAreaToBack(s.id)},H=l.useCallback(()=>{let N=2,D=2;s.type==="rectangle"&&s.width&&s.height?(N=s.width,D=s.height):s.type==="circle"&&s.radius&&(N=s.radius*1.414,D=s.radius*1.414);const B=Math.min(N,D)*.4;return{width:Math.round(B*10)/10,height:Math.round(B*10)/10}},[s.type,s.width,s.height,s.radius]),W=async N=>{var B;const D=(B=N.target.files)==null?void 0:B[0];if(D){T(!0);try{const p=await ut(s.id,D),x=H();C.updateArea(s.id,{logo:{filename:p.filename,position:"center",width:x.width,height:x.height,keepAspectRatio:!0,opacity:.8}})}catch(p){console.error("Failed to upload logo:",p)}finally{T(!1),y.current&&(y.current.value="")}}},R=async()=>{try{await dt(s.id),C.updateArea(s.id,{logo:void 0})}catch(N){console.error("Failed to remove logo:",N)}},G=N=>{s.logo&&C.updateArea(s.id,{logo:{...s.logo,position:N}})},h=N=>{if(!s.logo)return;const D=parseFloat(N.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const B=s.logo.height/s.logo.width;C.updateArea(s.id,{logo:{...s.logo,width:D,height:Math.round(D*B*10)/10}})}else C.updateArea(s.id,{logo:{...s.logo,width:D}})},I=N=>{if(!s.logo)return;const D=parseFloat(N.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const B=s.logo.width/s.logo.height;C.updateArea(s.id,{logo:{...s.logo,height:D,width:Math.round(D*B*10)/10}})}else C.updateArea(s.id,{logo:{...s.logo,height:D}})},M=()=>{s.logo&&C.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},U=N=>{s.logo&&C.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(N.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:i("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:i("common:labels.name")}),e.jsx("input",{type:"text",className:"area-editor-input",value:c,onChange:E,placeholder:i("config:areas.areaName")})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:i("config:areas.color")}),e.jsx("div",{className:"color-picker-row",children:js.map(N=>e.jsx("button",{type:"button",className:`color-swatch ${s.color===N?"selected":""}`,style:{backgroundColor:N},onClick:()=>v(N),"aria-label":`Set area color ${N}`,"aria-pressed":s.color===N,title:N},N))})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:i("config:areas.layer")}),e.jsxs("div",{className:"area-layer-buttons",children:[e.jsxs("button",{className:"area-layer-btn",onClick:O,title:i("config:areas.bringToFront"),children:[e.jsx(_,{name:"arrow-up",size:12})," ",i("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:K,title:i("config:areas.sendToBack"),children:[e.jsx(_,{name:"arrow-down",size:12})," ",i("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:i("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:rt(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:R,children:i("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var N;return(N=y.current)==null?void 0:N.click()},disabled:g,children:g?"...":e.jsx(_,{name:"refresh",size:12})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:i("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:xt.map(({key:N,labelKey:D})=>{var B;return e.jsx("button",{className:`area-logo-pos-btn ${((B=s.logo)==null?void 0:B.position)===N?"active":""}`,onClick:()=>G(N),children:i(`config:areas.${D}`)},N)})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:i("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:i("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:i("config:areas.logoHeight")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.height,onChange:I,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-aspect-label",title:i("config:areas.keepAspectRatio"),children:[e.jsx("input",{type:"checkbox",checked:s.logo.keepAspectRatio,onChange:M}),i("config:areas.keepAspectRatio")]})]})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:i("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:U,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 N;return(N=y.current)==null?void 0:N.click()},disabled:g,children:g?"...":i("config:areas.uploadLogo")}),e.jsx("input",{ref:y,type:"file",accept:"image/*",style:{display:"none"},onChange:W})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:i("config:areas.folders",{count:s.directories.length})}),e.jsxs("div",{className:"area-folders-list",children:[s.directories.map(N=>e.jsxs("div",{className:"area-folder-item",title:N,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>t==null?void 0:t(s.id),title:i("config:areas.openFolder"),children:e.jsx(_,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:N.split("/").pop()||N}),e.jsx("button",{className:"area-folder-remove",onClick:D=>F(N,D),title:i("config:areas.removeFolder"),children:"×"})]},N)),o?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(vs,{value:w,onChange:j,onSubmit:k,placeholder:i("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:k,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>m(!0),children:i("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:i("config:areas.prompt","Prompt")}),e.jsx("textarea",{className:"area-editor-input",value:d,onChange:u,placeholder:i("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:i("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:i("config:areas.assignedAgents",{count:s.assignedAgentIds.length})}),e.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:i("config:areas.rightClickUnassign")})]})]})}function jt(){const{t:s}=J(["config","common"]),a=ys(),[t,i]=l.useState(!1),[c,r]=l.useState(null),[d,f]=l.useState({name:"",key:"",value:"",description:""}),[o,m]=l.useState(null),w=()=>{i(!0),r(null),f({name:"",key:"",value:"",description:""})},j=u=>{r(u.id),i(!1),f({name:u.name,key:u.key,value:u.value,description:u.description||""})},g=()=>{i(!1),r(null),f({name:"",key:"",value:"",description:""})},T=()=>{!d.name.trim()||!d.key.trim()||(c?C.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}):C.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=u=>{m(u)},E=()=>{o&&(C.deleteSecret(o),c===o&&g())},v=u=>{navigator.clipboard.writeText(`{{${u}}}`)};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(u=>e.jsxs("div",{className:`secret-item ${c===u.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:u.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>v(u.key),title:s("config:secrets.copyPlaceholder"),children:`{{${u.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>j(u),title:s("common:buttons.edit"),children:e.jsx(_,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>y(u.id),title:s("common:buttons.delete"),children:"×"})]})]}),u.description&&e.jsx("div",{className:"secret-item-description",children:u.description})]},u.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:u=>f({...d,name:u.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:u=>f({...d,key:u.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:u=>f({...d,value:u.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:u=>f({...d,description:u.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:w,children:s("config:secrets.addSecret")}),e.jsx(fe,{isOpen:o!==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:()=>m(null)})]})}async function vt(){const s=Q(),a=await fetch(`${Z()}/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 yt(s){const a=Q(),t=await fetch(`${Z()}/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=Q(),a=await fetch(`${Z()}/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 Nt(){const s=Q(),a=await fetch(`${Z()}/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 kt(s){const a=Q(),t=await fetch(`${Z()}/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 St(){const s=Q(),a=await fetch(`${Z()}/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 Ct(s){const a=Q(),t=await fetch(`${Z()}/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 At(){const s=Q(),a=await fetch(`${Z()}/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 Tt(s){const a=Q(),t=await fetch(`${Z()}/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 Et(){const s=Q(),a=await fetch(`${Z()}/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 Pt(s){const a=Q(),t=await fetch(`${Z()}/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 _t(){const s=Q(),a=await fetch(`${Z()}/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 It(s){const a=Q(),t=await fetch(`${Z()}/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 $t(){const s=Q(),a=await fetch(`${Z()}/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 Lt(s){const a=Q(),t=await fetch(`${Z()}/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 Dt(){const s=Q(),a=await fetch(`${Z()}/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 Ot(s){const a=Q(),t=await fetch(`${Z()}/api/agents/system-settings/backup`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({enabled:s})});if(!t.ok){const i=await t.json().catch(()=>({}));throw new Error(i.error||`Failed to update backup setting: ${t.statusText}`)}return t.json()}function Ft({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:i=>a(i.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function zt(){const{t:s}=J(["config","common"]),[a,t]=l.useState([]),[i,c]=l.useState(new Set),[r,d]=l.useState(new Set),[f,o]=l.useState(!1),[m,w]=l.useState(!1),[j,g]=l.useState(null),[T,y]=l.useState(null),[E,v]=l.useState(null),[u,k]=l.useState(null),[F,O]=l.useState(!1),[K,H]=l.useState(null);l.useEffect(()=>{me(he("/api/config/categories")).then(p=>p.json()).then(p=>{const x=Array.isArray(p)?p:[];t(x),c(new Set(x.map(L=>L.id)))}).catch(p=>console.error("Failed to fetch config categories:",p))},[]),l.useEffect(()=>{Dt().then(k).catch(p=>{console.error("Failed to fetch backup status:",p),H(p.message||"Failed to fetch backup status")})},[]);const W=async p=>{if(!F){O(!0),H(null);try{const x=await Ot(p);k(x)}catch(x){H(x.message||"Failed to update backup setting")}finally{O(!1)}}},R=p=>{c(x=>{const L=new Set(x);return L.has(p)?L.delete(p):L.add(p),L})},G=p=>{d(x=>{const L=new Set(x);return L.has(p)?L.delete(p):L.add(p),L})},h=()=>c(new Set(a.map(p=>p.id))),I=()=>c(new Set),M=()=>{T&&d(new Set(T.categories.map(p=>p.id)))},U=()=>d(new Set),te=async()=>{var p;if(i.size!==0){o(!0),v(null);try{const x=Array.from(i).join(","),L=await me(he(`/api/config/export?categories=${x}`));if(!L.ok)throw new Error("Export failed");const X=await L.blob(),ne=window.URL.createObjectURL(X),P=document.createElement("a");P.href=ne;const S=L.headers.get("Content-Disposition"),ee=((p=S==null?void 0:S.match(/filename="(.+)"/))==null?void 0:p[1])||"tide-commander-config.zip";P.download=ee,document.body.appendChild(P),P.click(),document.body.removeChild(P),window.URL.revokeObjectURL(ne),v({type:"success",text:s("config:data.exportSuccess")})}catch(x){v({type:"error",text:x.message||"Export failed"})}finally{o(!1)}}},N=async p=>{var L;const x=(L=p.target.files)==null?void 0:L[0];if(x){g(x),v(null),y(null),d(new Set);try{const X=await me(he("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await x.arrayBuffer()});if(!X.ok){const S=await X.json();throw new Error(S.error||"Failed to preview config file")}const ne=await X.json(),P=Array.isArray(ne.categories)?ne.categories:[];y({...ne,categories:P}),d(new Set(P.map(S=>S.id)))}catch(X){v({type:"error",text:X.message||"Failed to read config file"}),g(null)}}},D=async()=>{if(!(!j||r.size===0)){w(!0),v(null);try{const p=Array.from(r).join(","),x=await me(he(`/api/config/import?categories=${p}`),{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(p){v({type:"error",text:p.message||"Import failed"})}finally{w(!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(Ft,{checked:!!(u!=null&&u.enabled),disabled:F||!u,onChange:W})]}),e.jsxs("div",{className:"data-backup-info",children:[u?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Saves a compressed snapshot of your data every hour to"," ",e.jsx("code",{children:u.backupDir}),". Identical snapshots are skipped. Keeps the 8 newest plus one from each of the 2 most recent prior days."]}),!u.scriptExists&&e.jsxs("div",{style:{marginTop:6,color:"var(--dracula-red, #ff5555)"},children:["Backup script not found at ",e.jsx("code",{children:u.scriptPath})]}),u.lastRunAt&&e.jsxs("div",{style:{marginTop:6},children:["Last run: ",new Date(u.lastRunAt).toLocaleString(),u.lastRunOk===!0&&" — ok",u.lastRunOk===!1&&u.lastRunError&&e.jsxs("span",{style:{color:"var(--dracula-red, #ff5555)"},children:[" — ",u.lastRunError]})]})]}):e.jsx("div",{children:"Loading backup status…"}),K&&e.jsx("div",{className:"data-message data-message-error",style:{marginTop:6},children:K})]})]}),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:I,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:a.map(p=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:i.has(p.id),onChange:()=>R(p.id)}),e.jsx("span",{className:"data-category-name",children:p.name})]},p.id))}),e.jsx("button",{className:"data-action-btn export",onClick:te,disabled:f||i.size===0,children:f?s("config:data.exporting"):s("config:data.exportCount",{count:i.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:M,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:U,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:T.categories.map(p=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:r.has(p.id),onChange:()=>G(p.id)}),e.jsx("span",{className:"data-category-name",children:p.name}),p.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",p.fileCount," ",s("config:data.files"),")"]})]},p.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:m||r.size===0,children:m?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:N,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}function Rt(){const[s,a]=l.useState(()=>ws()),t=i=>{a(i);const c=Cs(i);As(c)};return e.jsx("div",{className:"theme-selector",children:e.jsx("div",{className:"theme-selector-grid",children:Ns.map(i=>e.jsxs("button",{className:`theme-option ${s===i.id?"active":""}`,onClick:()=>t(i.id),title:i.description,children:[e.jsx("div",{className:"theme-preview",children:e.jsxs("div",{className:"theme-preview-bg",style:{backgroundColor:i.colors.bgPrimary},children:[e.jsx("div",{className:"theme-preview-accent",style:{backgroundColor:i.colors.accentBlue}}),e.jsx("div",{className:"theme-preview-claude",style:{backgroundColor:i.colors.accentClaude}})]})}),e.jsx("span",{className:"theme-name",children:i.name})]},i.id))})})}function Bt(){const{t:s}=J(["config"]),{installInfo:a,phase:t,output:i,error:c,newVersion:r,autoRestart:d,refreshInstallInfo:f,runUpdate:o,reset:m}=Ts(),[w,j]=l.useState(!1),g=l.useRef(null);l.useEffect(()=>{f()},[f]),l.useEffect(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)},[i]);const T=l.useCallback(()=>{j(!0)},[]),y=l.useCallback(()=>{j(!1)},[]),E=l.useCallback(()=>{j(!1),o()},[o]),v=l.useCallback(()=>{m(),j(!1),f()},[m,f]),u=ls.isNativePlatform(),k=s(u?"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:k}),t==="idle"&&!w&&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"&&w&&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:i||"..."}),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")})})]})]}):u?null:e.jsxs("div",{className:"about-autoupdate",children:[e.jsx("div",{className:"about-autoupdate-title",children:k}),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})]})]}):u?null:e.jsxs("div",{className:"about-autoupdate",children:[e.jsx("div",{className:"about-autoupdate-title",children:k}),e.jsx("div",{className:"about-autoupdate-devnote",children:s("config:about.autoUpdateDevMode")})]}):null}function Mt(){const{t:s}=J(["config"]),[a,t]=l.useState(null),[i,c]=l.useState(!1),[r,d]=l.useState(null);l.useEffect(()=>{Es().then(t).catch(w=>d(w.message))},[]);const f=l.useCallback(async w=>{if(!i){c(!0),d(null);try{t(await Ps(w))}catch(j){d(j.message)}finally{c(!1)}}},[i]),o=ls.isNativePlatform(),m=s(o?"config:about.unattendedServerTitle":"config:about.unattendedTitle");return!a&&!r?null:a?o&&!a.supported?null:e.jsxs("div",{className:"about-autoupdate",children:[e.jsx("div",{className:"about-autoupdate-title",children:m}),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:i||!a.supported,onChange:w=>void f(w.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})]}):o?null:e.jsxs("div",{className:"about-autoupdate",children:[e.jsx("div",{className:"about-autoupdate-title",children:m}),e.jsx("div",{className:"about-update-error",children:r})]})}function Ut(){var F;const{t:s}=J(["config"]),{isAndroid:a,supported:t,otaActive:i,bundleState:c,serverInfo:r,infoError:d,updateAvailable:f,phase:o,progress:m,error:w,autoSync:j,checkNow:g,syncNow:T,resetToBundled:y,setAutoSync:E}=_s(),[v,u]=l.useState(null),k=l.useRef(g);return k.current=g,l.useEffect(()=>{a&&(k.current(!1),Is.getInfo().then(O=>u(O.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:[i?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")}),w&&e.jsx("div",{className:"about-update-error",children:w}),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:O=>E(O.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:o!=="idle"||!r,children:o==="syncing"?s("config:webBundle.syncingPct",{percent:m??0}):s("config:webBundle.syncNow")}),i&&e.jsx("button",{className:"about-update-btn changelog",onClick:()=>void y(),children:s("config:webBundle.reset")})]})]})}function Vt(){const{t:s}=J(["config"]),{updateAvailable:a,updateInfo:t,recentReleases:i,isChecking:c,error:r,currentVersion:d,isAndroid:f,downloadPhase:o,downloadProgress:m,checkForUpdate:w,downloadAndInstall:j,openReleasePage:g}=ks(),[T,y]=l.useState(!1),E=u=>u?`${(u/(1024*1024)).toFixed(1)} MB`:"",v=u=>new Date(u).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(_,{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(Bt,{}),e.jsx(Mt,{}),e.jsx(Ut,{}),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:o!=="idle",children:o==="downloading"?s("config:appUpdateBanner.downloadingPct",{percent:m??0}):s(o==="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:()=>w(!0),disabled:c,children:c?"...":s("config:about.check")})]}),i.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:i.map(u=>e.jsxs("a",{href:u.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:`about-release-item ${u.version===`v${d}`||u.version===d?"current":""}`,children:[e.jsx("span",{className:"about-release-version",children:u.version}),e.jsx("span",{className:"about-release-date",children:v(u.publishedAt)})]},u.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(_,{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(Ss,{onClose:()=>y(!1)})]})}const Kt={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅",docx:"📄",whatsapp:"📱"};function Ht({onOpenModal:s}){const[a,t]=l.useState([]),[i,c]=l.useState(!0),r=l.useCallback(async()=>{try{const d=await me(he("/api/integrations"));if(!d.ok)return;const f=await d.json();t(f)}catch{}finally{c(!1)}},[]);return l.useEffect(()=>{r()},[r]),i?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=Kt[d.id]||"🔌",o=!!d.status.error,m=d.status.connected,w=o?"#f38ba8":m?"#a6e3a1":"#fab387",j=o?"Error":m?"Connected":"Setup Required",g=o?"✗":m?"✓":"⚠";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:w,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 Ce(s){return`/api/system/${s}-credentials`}async function Ae(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 Wt(s){const a=await me(he(Ce(s)));if(!a.ok)throw new Error(await Ae(a,`Failed to list ${s} credentials: ${a.status}`));return await a.json()}async function Ze(s,a,t={}){const i=await me(he(`${Ce(s)}/switch`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,stashActiveAs:t.stashActiveAs})});if(!i.ok)throw new Error(await Ae(i,`Failed to switch ${s} credentials: ${i.status}`));return await i.json()}async function Xe(s,a,t={}){const i=await me(he(`${Ce(s)}/save`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,force:t.force})});if(!i.ok)throw new Error(await Ae(i,`Failed to save ${s} credentials: ${i.status}`));return await i.json()}async function qt(s,a,t){const i=await me(he(`${Ce(s)}/rename`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:a,to:t})});if(!i.ok)throw new Error(await Ae(i,`Failed to rename ${s} credentials: ${i.status}`));return await i.json()}async function Gt(s,a){const t=await me(he(`${Ce(s)}/${encodeURIComponent(a)}`),{method:"DELETE"});if(!t.ok)throw new Error(await Ae(t,`Failed to delete ${s} credentials: ${t.status}`));return await t.json()}const Le={grok:"Grok",codex:"Codex"};function Yt(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 Jt({profile:s,busy:a,onUse:t,onRename:i,onDelete:c}){const{t:r}=J(["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:Yt(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:()=>i(s.name),style:{padding:"4px 8px",fontSize:"11px"},title:r("terminal:credentials.rename"),children:e.jsx(_,{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(_,{name:"trash",size:12})})]})]})}function Qe({provider:s,onSwitched:a,compact:t}){var U,te,N,D,B;const{t:i}=J(["terminal","common"]),[c,r]=l.useState(null),[d,f]=l.useState(!1),[o,m]=l.useState(!1),[w,j]=l.useState(null),[g,T]=l.useState(""),[y,E]=l.useState(""),[v,u]=l.useState(null),[k,F]=l.useState(null),O=l.useCallback(async()=>{f(!0),j(null);try{r(await Wt(s))}catch(p){j(p instanceof Error?p.message:String(p))}finally{f(!1)}},[s]);l.useEffect(()=>{O()},[O]);const K=p=>r(p),H=!!((U=c==null?void 0:c.active)!=null&&U.valid&&!c.active.matchesNamed),W=async p=>{if(j(null),F(null),H){u(p);return}m(!0);try{const x=await Ze(s,p);r({provider:s,dir:(c==null?void 0:c.dir)??"",active:x.active,profiles:x.profiles}),F(i("terminal:credentials.switched",{name:p})),u(null),a==null||a()}catch(x){j(x instanceof Error?x.message:String(x))}finally{m(!1)}},R=async()=>{if(!v)return;const p=y.trim();if(!p){j(i("terminal:credentials.stashRequired"));return}m(!0),j(null);try{const x=await Ze(s,v,{stashActiveAs:p});r({provider:s,dir:(c==null?void 0:c.dir)??"",active:x.active,profiles:x.profiles}),F(x.stashedAs?i("terminal:credentials.switchedWithStash",{name:v,stash:x.stashedAs}):i("terminal:credentials.switched",{name:v})),u(null),E(""),a==null||a()}catch(x){j(x instanceof Error?x.message:String(x))}finally{m(!1)}},G=async()=>{const p=g.trim();if(!p){j(i("terminal:credentials.nameRequired"));return}m(!0),j(null),F(null);try{K(await Xe(s,p)),T(""),F(i("terminal:credentials.saved",{name:p}))}catch(x){const L=x instanceof Error?x.message:String(x);if(/already exists/i.test(L)&&window.confirm(i("terminal:credentials.confirmOverwrite",{name:p})))try{K(await Xe(s,p,{force:!0})),T(""),F(i("terminal:credentials.saved",{name:p})),m(!1);return}catch(X){j(X instanceof Error?X.message:String(X)),m(!1);return}j(L)}finally{m(!1)}},h=async p=>{const x=window.prompt(i("terminal:credentials.renamePrompt",{name:p}),p);if(!(!x||x.trim()===p)){m(!0),j(null);try{K(await qt(s,p,x.trim())),F(i("terminal:credentials.renamed",{from:p,to:x.trim()}))}catch(L){j(L instanceof Error?L.message:String(L))}finally{m(!1)}}},I=async p=>{if(window.confirm(i("terminal:credentials.confirmDelete",{name:p}))){m(!0),j(null);try{K(await Gt(s,p)),F(i("terminal:credentials.deleted",{name:p}))}catch(x){j(x instanceof Error?x.message:String(x))}finally{m(!1)}}},M=c!=null&&c.active?c.active.matchesNamed?c.active.matchesNamed:i("terminal:credentials.unsavedActive"):i("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:i("terminal:credentials.providerTitle",{provider:Le[s],defaultValue:`${Le[s]} Accounts`})}),e.jsxs("div",{style:{fontSize:"12px",marginTop:"4px"},children:[i("terminal:credentials.current",{name:M}),((te=c==null?void 0:c.active)==null?void 0:te.email)&&e.jsxs("span",{style:{color:"var(--text-secondary)"},children:[" · ",c.active.email]}),((N=c==null?void 0:c.active)==null?void 0:N.label)&&e.jsxs("span",{style:{color:"var(--text-secondary)"},children:[" (",c.active.label,")"]})]})]}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>void O(),disabled:d||o,style:{padding:"4px 10px",fontSize:"11px",display:"inline-flex",gap:"6px",alignItems:"center"},title:i("common:buttons.refresh"),children:e.jsx("span",{style:{display:"inline-block",animation:d?"spin 1s linear infinite":"none"},children:e.jsx(_,{name:"refresh",size:12})})})]}),e.jsx("p",{style:{fontSize:"11px",color:"var(--text-secondary)",margin:"0 0 10px",lineHeight:1.45},children:i("terminal:credentials.providerHelp",{provider:Le[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 ${Le[s]} account when you hit rate limits — same as renaming the file manually.`})}),w&&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:w}),k&&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:k}),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:i("terminal:credentials.stashPrompt",{name:v})}),e.jsxs("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:[e.jsx("input",{type:"text",value:y,onChange:p=>E(p.target.value),placeholder:i("terminal:credentials.stashPlaceholder"),disabled:o,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:o,onClick:()=>void R(),style:{padding:"6px 12px",fontSize:"12px"},children:i("terminal:credentials.confirmSwitch")}),e.jsx("button",{type:"button",className:"btn btn-secondary",disabled:o,onClick:()=>u(null),style:{padding:"6px 12px",fontSize:"12px"},children:i("common:buttons.cancel")})]})]}),d&&!c&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--text-secondary)",padding:"8px 0"},children:[i("common:status.loading"),"…"]}),c&&c.profiles.length===0&&e.jsx("div",{style:{fontSize:"12px",color:"var(--text-muted)",marginBottom:"10px"},children:i("terminal:credentials.noProfiles")}),c==null?void 0:c.profiles.map(p=>e.jsx(Jt,{profile:p,busy:o,onUse:x=>void W(x),onRename:x=>void h(x),onDelete:x=>void I(x)},p.name)),e.jsxs("div",{style:{display:"flex",gap:"6px",marginTop:"10px",flexWrap:"wrap",alignItems:"center"},children:[e.jsx("input",{type:"text",value:g,onChange:p=>T(p.target.value),placeholder:i("terminal:credentials.savePlaceholder"),disabled:o||!((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:o||!((B=c==null?void 0:c.active)!=null&&B.valid)||!g.trim(),onClick:()=>void G(),style:{padding:"6px 12px",fontSize:"12px"},children:i("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 De="__global__";function Zt({isOpen:s,onClose:a,initialAgentId:t}){const{t:i}=J(["config"]),c=$s(),[r,d]=l.useState(""),[f,o]=l.useState(""),[m,w]=l.useState(!1),[j,g]=l.useState(""),[T,y]=l.useState(""),[E,v]=l.useState(null),[u,k]=l.useState(null),[F,O]=l.useState(!1),[K,H]=l.useState(!1),[W,R]=l.useState(!1),[G,h]=l.useState(null),I=l.useMemo(()=>[...c].sort((P,S)=>P.name.localeCompare(S.name)),[c]),M=l.useMemo(()=>c.find(P=>P.id===r),[c,r]),U=r===De;l.useEffect(()=>{if(!s)return;const P=t&&c.some(S=>S.id===t)?t:De;d(P),w(!1),vt().then(S=>o(S)).catch(()=>o("")).finally(()=>w(!0))},[s]),l.useEffect(()=>{const P=r===De?f:(M==null?void 0:M.customPrompt)??"";g(P),y(P),O(!1),v(null),k(null)},[r,m]);const te=P=>{const S=P.target.value;g(S),O(S!==T),v(null),k(null)},N=async()=>{if(r)try{v(null),k(null),U?(await yt(j),o(j),k(i("config:systemPrompt.savedGlobal"))):(C.updateAgentProperties(r,{customPrompt:j}),k(i("config:systemPrompt.saved"))),y(j),O(!1)}catch(P){v(P instanceof Error?P.message:"Failed to save system prompt")}},D=()=>{H(!0)},B=async()=>{if(r)try{v(null),k(null),U?(await wt(),o(""),k(i("config:systemPrompt.clearedGlobal"))):(C.updateAgentProperties(r,{customPrompt:""}),k(i("config:systemPrompt.cleared"))),g(""),y(""),O(!1)}catch(P){v(P instanceof Error?P.message:"Failed to clear system prompt")}},p=()=>{g(T),O(!1),v(null),k(null)},x=P=>{if(P!==r){if(F){h(P),R(!0);return}d(P)}},L=()=>{if(F){h(null),R(!0);return}a()},X=()=>{if(R(!1),G){const P=G;h(null),d(P)}else a()},ne=P=>{P.key==="Escape"&&(P.preventDefault(),L())};return s?e.jsxs(Se,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:L,children:e.jsxs("div",{className:"system-prompt-modal",onClick:P=>P.stopPropagation(),onKeyDown:ne,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:i("config:systemPrompt.title")}),e.jsx("button",{className:"modal-close",onClick:L,"aria-label":"Close",children:e.jsx(_,{name:"close",size:16})})]}),e.jsxs("div",{className:"modal-body",children:[e.jsx("p",{className:"modal-description",children:i("config:systemPrompt.description")}),e.jsxs("div",{className:"agent-picker",children:[e.jsx("label",{htmlFor:"system-prompt-agent",className:"editor-label",children:i("config:systemPrompt.agentLabel")}),e.jsxs("div",{className:"agent-picker-row",children:[U?e.jsx(_,{name:"globe",size:20,className:"agent-picker-icon"}):M&&e.jsx(Ls,{classId:M.class,size:20,className:"agent-picker-icon"}),e.jsxs("select",{id:"system-prompt-agent",className:"agent-picker-select",value:r,onChange:P=>x(P.target.value),children:[e.jsxs("option",{value:De,children:[i("config:systemPrompt.globalOption"),f?" • ✦":""]}),I.map(P=>e.jsxs("option",{value:P.id,children:[P.name,P.customPrompt?" • ✦":""]},P.id))]})]})]}),E&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(_,{name:"warn",size:14})}),E]}),u&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(_,{name:"check",size:14})}),u]}),e.jsxs("div",{className:"editor-wrapper",children:[e.jsxs("div",{className:"editor-header",children:[e.jsx("label",{htmlFor:"prompt-input",className:"editor-label",children:i("config:systemPrompt.editPrompt")}),e.jsxs("span",{className:"char-count",children:[j.length," ",i("config:systemPrompt.characters")]})]}),e.jsx("textarea",{id:"prompt-input",className:"prompt-editor",value:j,onChange:te,placeholder:i("config:systemPrompt.placeholder"),rows:18,disabled:U&&!m,autoFocus:!0}),e.jsx("div",{className:"editor-hint",children:i(U?"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:i("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:p,disabled:!F,children:i("config:systemPrompt.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:N,disabled:!F||!r,children:i("config:systemPrompt.save")})]})]})]})}),e.jsx(fe,{isOpen:K,title:i("config:systemPrompt.clear"),message:i(U?"config:systemPrompt.confirmClearGlobal":"config:systemPrompt.confirmClear"),confirmLabel:i("config:systemPrompt.clear"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{B()},onClose:()=>H(!1)}),e.jsx(fe,{isOpen:W,title:"Unsaved Changes",message:"You have unsaved changes for this agent. Discard them?",confirmLabel:"Discard",cancelLabel:"Keep editing",variant:"danger",onConfirm:X,onClose:()=>{R(!1),h(null)}})]}):null}const es={enabled:!1,baseUrl:"",defaultSessionId:"",webhookVerifyToken:"",showIncomingToasts:!0},Xt=2500,Qt=12e4;function ss(s){return{enabled:s.enabled??!1,baseUrl:s.baseUrl??"",defaultSessionId:s.defaultSessionId??"",webhookVerifyToken:s.webhookVerifyToken??"",showIncomingToasts:s.showIncomingToasts??!0}}function ea(s,a){return s.enabled===a.enabled&&s.baseUrl===a.baseUrl&&s.defaultSessionId===a.defaultSessionId&&s.webhookVerifyToken===a.webhookVerifyToken&&s.showIncomingToasts===a.showIncomingToasts}function sa({isOpen:s,onClose:a}){const{t}=J(["config"]),[i,c]=l.useState(es),[r,d]=l.useState(es),[f,o]=l.useState(!1),[m,w]=l.useState([]),[j,g]=l.useState(!0),[T,y]=l.useState(null),[E,v]=l.useState(null),[u,k]=l.useState(""),[F,O]=l.useState(!1),[K,H]=l.useState(""),[W,R]=l.useState(null),[G,h]=l.useState(null),[I,M]=l.useState(null),U=l.useRef(null),te=l.useRef(0),[N,D]=l.useState(""),[B,p]=l.useState(""),[x,L]=l.useState(null),[X,ne]=l.useState(!1),[P,S]=l.useState(!1),[ee,ie]=l.useState(!1),[re,oe]=l.useState(!1),[ge,ye]=l.useState(null),je=!ea(i,r),de=l.useCallback(()=>{U.current&&(clearTimeout(U.current),U.current=null)},[]),Te=l.useCallback(async()=>{try{g(!0),y(null),v(null);const[b,V]=await Promise.all([cs(),Ds()]),se=ss(b);if(c(se),d(se),o(!!V.configured),V.configured)try{const ce=await He();w(Array.isArray(ce)?ce:[])}catch{w([])}else w([])}catch(b){y(b instanceof Error?b.message:t("config:whatsapp.errors.loadFailed"))}finally{g(!1)}},[t]),xe=l.useCallback(async()=>{try{const b=await He();w(Array.isArray(b)?b:[])}catch{}},[]);l.useEffect(()=>(s?Te():(de(),R(null),h(null),M(null),k(""),O(!1),L(null)),()=>{de()}),[s,Te,de]);const ue=(b,V)=>{c(se=>({...se,[b]:V})),y(null),v(null)},$=async()=>{try{y(null),v(null);const b=await Bs({enabled:i.enabled,baseUrl:i.baseUrl.trim(),defaultSessionId:i.defaultSessionId.trim(),webhookVerifyToken:i.webhookVerifyToken,showIncomingToasts:i.showIncomingToasts});window.dispatchEvent(new CustomEvent("tide:whatsapp-config-updated"));const V=ss(b);c(V),d(V),v(t("config:whatsapp.saved"))}catch(b){y(b instanceof Error?b.message:t("config:whatsapp.errors.saveFailed"))}},Ee=()=>{c(r),y(null),v(null)},le=()=>{if(je){S(!0);return}a()},Fe=b=>{b.key==="Escape"&&(b.preventDefault(),le())},Pe=async()=>{const b=u.trim();if(b)try{y(null),v(null),await Fs(b),k(""),O(!1),o(!0),v(t("config:whatsapp.apiKeySaved"))}catch(V){y(V instanceof Error?V.message:t("config:whatsapp.errors.apiKeySaveFailed"))}},ze=()=>{ie(!0)},Re=async()=>{try{y(null),v(null),await Ms(),o(!1),v(t("config:whatsapp.apiKeyCleared"))}catch(b){y(b instanceof Error?b.message:t("config:whatsapp.errors.apiKeyClearFailed"))}},we=l.useCallback(async b=>{if(Date.now()>te.current){M(t("config:whatsapp.pairingTimeout")),R(null),h(null),de(),xe();return}try{const V=await Os(b);if(V.status&&["connected","paired","open","ready"].includes(V.status.toLowerCase())){M(t("config:whatsapp.pairingSuccess")),R(null),h(null),de(),xe();return}const ce=V.qrUrl??V.qr??null;ce&&h(ce)}catch(V){M(V instanceof Error?V.message:t("config:whatsapp.errors.qrFetchFailed"))}U.current=setTimeout(()=>{we(b)},Xt)},[xe,de,t]),_e=async()=>{const b=K.trim();if(b)try{y(null),v(null),M(null),h(null),de(),await zs(b),H(""),R(b),te.current=Date.now()+Qt,we(b),xe()}catch(V){y(V instanceof Error?V.message:t("config:whatsapp.errors.sessionCreateFailed"))}},Ne=()=>{de(),R(null),h(null),M(null)},Be=b=>{ye(b),oe(!0)},Me=async()=>{if(ge)try{y(null),v(null),await Us(ge),W===ge&&Ne(),xe(),v(t("config:whatsapp.sessionDeleted"))}catch(b){y(b instanceof Error?b.message:t("config:whatsapp.errors.sessionDeleteFailed"))}finally{ye(null)}},Ie=async()=>{const b=N.trim(),V=B.trim();if(!(!b||!V))try{ne(!0),L(null);const se=i.defaultSessionId.trim()||void 0;await Rs(b,V,se),L({kind:"success",text:t("config:whatsapp.testSent")})}catch(se){L({kind:"error",text:se instanceof Error?se.message:t("config:whatsapp.errors.testSendFailed")})}finally{ne(!1)}};return s?e.jsxs(Se,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:le,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:le,"aria-label":"Close",children:e.jsx(_,{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(_,{name:"warn",size:14})}),T]}),E&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(_,{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:i.enabled,onChange:b=>ue("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:i.showIncomingToasts,onChange:b=>ue("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:i.baseUrl,onChange:b=>ue("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:i.defaultSessionId,onChange:b=>ue("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:i.webhookVerifyToken,onChange:b=>ue("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(_,{name:"check",size:12})," ",t("config:whatsapp.configured")]}):e.jsxs("span",{className:"wa-status wa-status-warn",children:[e.jsx(_,{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:u,onChange:b=>k(b.target.value)}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>O(b=>!b),title:t(F?"config:whatsapp.hideKey":"config:whatsapp.showKey"),children:e.jsx(_,{name:F?"eye-closed":"eye",size:14})}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:Pe,disabled:!u.trim(),children:t("config:whatsapp.saveKey")}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:ze,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(m)||m.length===0?e.jsx("div",{className:"wa-empty",children:t("config:whatsapp.noSessions")}):m.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:()=>Be(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:K,onChange:b=>H(b.target.value),onKeyDown:b=>{b.key==="Enter"&&_e()}}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:_e,disabled:!K.trim()||W!==null,children:t("config:whatsapp.addSession")})]}),W&&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:W})}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Ne,children:t("config:whatsapp.cancelPairing")})]}),G?e.jsx("div",{className:"wa-qr-image",children:e.jsx("img",{src:G,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")})]})]}),I&&!W&&e.jsx("div",{className:"wa-pairing-message",children:I})]}),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:N,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=>p(b.target.value)})]}),e.jsx("div",{className:"wa-field-inline wa-field-end",children:e.jsx("button",{type:"button",className:"btn btn-primary",onClick:Ie,disabled:!N.trim()||!B.trim()||X,children:t(X?"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(_,{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:le,children:t("config:whatsapp.close")}),e.jsx("button",{className:"btn btn-secondary",onClick:Ee,disabled:!je||j,children:t("config:whatsapp.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:$,disabled:!je||j,children:t("config:whatsapp.save")})]})]})]})}),e.jsx(fe,{isOpen:P,title:t("config:whatsapp.unsavedTitle"),message:t("config:whatsapp.unsavedMessage"),confirmLabel:t("config:whatsapp.closeAnyway"),cancelLabel:t("config:whatsapp.keepEditing"),variant:"danger",onConfirm:()=>{S(!1),a()},onClose:()=>S(!1)}),e.jsx(fe,{isOpen:ee,title:t("config:whatsapp.clearKey"),message:t("config:whatsapp.confirmClearKey"),confirmLabel:t("config:whatsapp.clearKey"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{Re()},onClose:()=>ie(!1)}),e.jsx(fe,{isOpen:re,title:t("config:whatsapp.deleteSession"),message:t("config:whatsapp.confirmDeleteSession",{id:ge??""}),confirmLabel:t("config:whatsapp.deleteSession"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{Me()},onClose:()=>{oe(!1),ye(null)}})]}):null}const ds=["messages","statusChanges","taskComplete","errors","planReady","agentSpawned","agentStopped"];function We(s=!1){const a=Q(),t={};return a&&(t.Authorization=`Bearer ${a}`),s&&(t["Content-Type"]="application/json"),t}async function qe(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 ta(){const s=await fetch(`${Z()}/api/whatsapp/notification-config`,{headers:We()});if(!s.ok)throw new Error(await qe(s,"Failed to fetch WhatsApp notification config"));return s.json()}async function aa(s){const a=await fetch(`${Z()}/api/whatsapp/notification-config`,{method:"PATCH",headers:We(!0),body:JSON.stringify(s)});if(!a.ok)throw new Error(await qe(a,"Failed to update WhatsApp notification config"));return a.json()}async function na(){const s=await fetch(`${Z()}/api/whatsapp/notification-config`,{method:"DELETE",headers:We()});if(!s.ok)throw new Error(await qe(s,"Failed to reset WhatsApp notification config"));return s.json()}const Oe={messages:!0,statusChanges:!0,taskComplete:!0,errors:!0,planReady:!0,agentSpawned:!0,agentStopped:!0},ts={filter:{...Oe},recipient:""};function ia(s,a){if(s.recipient!==a.recipient)return!1;for(const t of ds)if(s.filter[t]!==a.filter[t])return!1;return!0}function oa({isOpen:s,onClose:a}){const{t}=J(["config"]),[i,c]=l.useState(ts),[r,d]=l.useState(ts),[f,o]=l.useState(!0),[m,w]=l.useState(null),[j,g]=l.useState(null),[T,y]=l.useState(!1),[E,v]=l.useState(!1),u=!ia(i,r),k=l.useCallback(async()=>{try{o(!0),w(null),g(null);const h=await ta(),I={filter:{...Oe,...h.filter},recipient:h.recipient??""};c(I),d(I)}catch(h){w(h instanceof Error?h.message:t("config:whatsappNotifications.errors.loadFailed"))}finally{o(!1)}},[t]);l.useEffect(()=>{s&&k()},[s,k]);const F=(h,I)=>{c(M=>({...M,filter:{...M.filter,[h]:I}})),w(null),g(null)},O=h=>{c(I=>({...I,recipient:h})),w(null),g(null)},K=async()=>{try{w(null),g(null);const h=await aa({filter:i.filter,recipient:i.recipient.trim()}),I={filter:{...Oe,...h.filter},recipient:h.recipient??""};c(I),d(I),g(t("config:whatsappNotifications.saved"))}catch(h){w(h instanceof Error?h.message:t("config:whatsappNotifications.errors.saveFailed"))}},H=()=>{c(r),w(null),g(null)},W=async()=>{try{w(null),g(null);const h=await na(),I={filter:{...Oe,...h.filter},recipient:h.recipient??""};c(I),d(I),g(t("config:whatsappNotifications.resetDone"))}catch(h){w(h instanceof Error?h.message:t("config:whatsappNotifications.errors.resetFailed"))}},R=()=>{if(u){y(!0);return}a()},G=h=>{h.key==="Escape"&&(h.preventDefault(),R())};return s?e.jsxs(Se,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:R,children:e.jsxs("div",{className:"whatsapp-notifications-modal",onClick:h=>h.stopPropagation(),onKeyDown:G,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:t("config:whatsappNotifications.title")}),e.jsx("button",{className:"modal-close",onClick:R,"aria-label":"Close",children:e.jsx(_,{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")}),m&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(_,{name:"warn",size:14})}),m]}),j&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(_,{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:i.recipient,onChange:h=>O(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")}),ds.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:i.filter[h],onChange:I=>F(h,I.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:R,children:t("config:whatsappNotifications.close")}),e.jsx("button",{className:"btn btn-secondary",onClick:H,disabled:!u||f,children:t("config:whatsappNotifications.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:K,disabled:!u||f,children:t("config:whatsappNotifications.save")})]})]})]})}),e.jsx(fe,{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(fe,{isOpen:E,title:t("config:whatsappNotifications.resetToDefaults"),message:t("config:whatsappNotifications.confirmReset"),confirmLabel:t("config:whatsappNotifications.resetToDefaults"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{W(),v(!1)},onClose:()=>v(!1)})]}):null}function us(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 la(s,a=Date.now()){const t=s*1e3,i=a-t;if(i<0)return as(t);const c=Math.floor(i/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`:as(t)}function as(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function ca(s){const a=s*1e3;return new Date(a).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function ps(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 ra(s,a){return s.length<=a?s:s.slice(0,Math.max(0,a-1)).trimEnd()+"…"}function da({chats:s,selectedChatId:a,loading:t,error:i,onSelect:c,onRefresh:r,now:d}){const{t:f}=J(["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:"⟳"})]}),i&&e.jsx("div",{className:"whatsapp-history-chatlist__error",children:i}),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&&!i&&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(o=>{const m=ps(o.lastMessageType),w=o.lastMessagePreview||`[${o.lastMessageType}]`,j=o.chatId===a,g=us(o.chatId),T=o.isGroup?o.groupName:o.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(o.chatId),children:[e.jsxs("div",{className:"whatsapp-history-chatlist__row",children:[e.jsx("span",{className:"whatsapp-history-chatlist__name",title:o.chatId,children:y}),e.jsx("span",{className:"whatsapp-history-chatlist__time",children:la(o.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:[o.lastDirection==="outbound"&&e.jsx("span",{className:"whatsapp-history-chatlist__direction",children:"↗ "}),m&&e.jsxs("span",{className:"whatsapp-history-chatlist__preview-icon",children:[m," "]}),ra(w,40)]}),o.unreadCount>0&&e.jsx("span",{className:"whatsapp-history-chatlist__unread",children:o.unreadCount})]})]})},o.chatId)})})]})}function ua({message:s}){const a=s.direction==="outbound"?"outbound":"inbound",t=ps(s.messageType),i=(s.body??"").trim(),c=i.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:i}):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:ca(s.timestamp)})]})})}const pa=["all","inbound","outbound"],ma=["all","text","image","audio","video","document","sticker","location","contact","reaction","unknown"];function ha({direction:s,type:a,onDirectionChange:t,onTypeChange:i,disabled:c}){const{t:r}=J(["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:pa.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=>i(d.target.value),disabled:c,children:ma.map(d=>e.jsx("option",{value:d,children:r(`config:whatsappHistory.typeValues.${d}`)},d))})]})]})}const ga=80;function fa({chatId:s,messages:a,loading:t,loadingMore:i,error:c,hasMore:r,direction:d,type:f,onDirectionChange:o,onTypeChange:m,onLoadMore:w}){const{t:j}=J(["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 k=g.current.scrollHeight-E.current;E.current=null,k>0&&(g.current.scrollTop+=k)},[a.length]);const v=l.useCallback(()=>{!r||i||t||(g.current&&(E.current=g.current.scrollHeight),w())},[r,i,t,w]),u=l.useCallback(k=>{if(!y.current)return;k.currentTarget.scrollTop<=ga&&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:us(s)}),e.jsx(ha,{direction:d,type:f,onDirectionChange:o,onTypeChange:m,disabled:t})]}),e.jsxs("div",{className:"whatsapp-history-messages__scroll",ref:g,onScroll:u,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:i||t,children:j(i?"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(k=>e.jsx(ua,{message:k},xa(k)))]})]}):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 xa(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 ms(){const s=Q(),a={};return s&&(a.Authorization=`Bearer ${s}`),a}async function hs(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 ba(s){const a=`${Z()}/api/whatsapp/chats/${encodeURIComponent(s)}`,t=await fetch(a,{headers:ms()});if(!t.ok)throw new Error(await hs(t,"Failed to fetch WhatsApp chats"));return t.json()}async function ns(s,a,t={}){const i=new URLSearchParams;t.cursor&&i.set("cursor",t.cursor),typeof t.limit=="number"&&i.set("limit",String(t.limit)),t.direction&&i.set("direction",t.direction),t.type&&i.set("type",t.type);const c=i.toString(),r=`${Z()}/api/whatsapp/chats/${encodeURIComponent(s)}/${encodeURIComponent(a)}/messages${c?`?${c}`:""}`,d=await fetch(r,{headers:ms()});if(!d.ok)throw new Error(await hs(d,"Failed to fetch WhatsApp messages"));return d.json()}const ja=50;function va({isOpen:s,onClose:a}){const{t}=J(["config"]),[i,c]=l.useState([]),[r,d]=l.useState(null),[f,o]=l.useState(null),[m,w]=l.useState([]),[j,g]=l.useState(!1),[T,y]=l.useState(null),[E,v]=l.useState(null),[u,k]=l.useState([]),[F,O]=l.useState(!1),[K,H]=l.useState(!1),[W,R]=l.useState(null),[G,h]=l.useState(null),[I,M]=l.useState("all"),[U,te]=l.useState("all"),[N,D]=l.useState(()=>Date.now()),B=l.useRef(0);l.useEffect(()=>{if(!s)return;const S=window.setInterval(()=>D(Date.now()),6e4);return()=>window.clearInterval(S)},[s]),l.useEffect(()=>{if(!s)return;let S=!1;return(async()=>{var ee;try{o(null);const[ie,re]=await Promise.all([He().catch(()=>[]),cs().catch(()=>null)]);if(S)return;c(ie);const oe=(re==null?void 0:re.defaultSessionId)||((ee=ie[0])==null?void 0:ee.id)||null;d(ge=>ge??oe)}catch(ie){if(S)return;o(ie instanceof Error?ie.message:String(ie))}})(),()=>{S=!0}},[s]);const p=l.useCallback(async S=>{g(!0),y(null);try{const ee=await ba(S);w(ee.chats)}catch(ee){y(ee instanceof Error?ee.message:String(ee))}finally{g(!1)}},[]);l.useEffect(()=>{!s||!r||(v(null),k([]),h(null),p(r))},[s,r,p]);const x=l.useMemo(()=>{const S={limit:ja};return I!=="all"&&(S.direction=I),U!=="all"&&(S.type=U),S},[I,U]),L=l.useCallback(async(S,ee,ie)=>{const re=++B.current;O(!0),R(null),k([]),h(null);try{const oe=await ns(S,ee,ie);if(re!==B.current)return;k([...oe.messages].reverse()),h(oe.nextCursor)}catch(oe){if(re!==B.current)return;R(oe instanceof Error?oe.message:String(oe))}finally{re===B.current&&O(!1)}},[]);l.useEffect(()=>{!s||!r||!E||L(r,E,x)},[s,r,E,x,L]);const X=l.useCallback(async()=>{if(!(!r||!E||!G)){H(!0),R(null);try{const S=await ns(r,E,{...x,cursor:G});k(ee=>[...[...S.messages].reverse(),...ee]),h(S.nextCursor)}catch(S){R(S instanceof Error?S.message:String(S))}finally{H(!1)}}},[r,E,G,x]),ne=l.useCallback(()=>{r&&p(r)},[r,p]),P=l.useCallback(S=>{S.key==="Escape"&&(S.preventDefault(),a())},[a]);return s?e.jsx(Se,{children:e.jsx("div",{className:"modal-overlay visible",onClick:a,children:e.jsxs("div",{className:"whatsapp-history-modal",onClick:S=>S.stopPropagation(),onKeyDown:P,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:S=>d(S.target.value||null),disabled:i.length===0,children:[i.length===0&&e.jsx("option",{value:"",children:t("config:whatsappHistory.noSessions")}),i.map(S=>e.jsxs("option",{value:S.id,children:[S.id,S.pairedNumber?` (${S.pairedNumber})`:""]},S.id))]})]})}),e.jsx("button",{className:"modal-close",onClick:a,"aria-label":"Close",children:e.jsx(_,{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(da,{chats:m,selectedChatId:E,loading:j,error:T,onSelect:v,onRefresh:ne,now:N}),e.jsx(fa,{chatId:E,messages:u,loading:F,loadingMore:K,error:W,hasMore:G!==null,direction:I,type:U,onDirectionChange:M,onTypeChange:te,onLoadMore:X})]})]})})}):null}function ya({isOpen:s,onClose:a,onOpenConfig:t,onOpenNotifications:i,onOpenHistory:c}){const{t:r}=J(["config"]);if(l.useEffect(()=>{if(!s)return;const f=o=>{o.key==="Escape"&&(o.preventDefault(),a())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s,a]),!s)return null;const d=f=>{a(),f()};return e.jsx(Se,{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(_,{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(_,{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(i),children:[e.jsx("span",{className:"whatsapp-hub-modal__option-icon",children:e.jsx(_,{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(_,{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 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:"🌙"}],Na=[{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:"🔴"}],ka=[{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:"👎"}],Sa=[{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:"💜"}],Ca=[{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"}],Aa=[{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"}],Ta={showTrees:"trees",showBushes:"bushes",showHouse:"house",showLamps:"lamps",showGrass:"grass",showClouds:"clouds"},Ea={none:"grass","pokemon-stadium":"pokemon"},Pa={"emote-yes":"yes","emote-no":"no"},_a={"":"auto","#4a90d9":"dayBlue","#0a1a2a":"night","#ff6b35":"sunset","#1a0a2e":"purple","#2d5a27":"matrix","#8b0000":"blood","#000000":"void"};function ae({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 ve({options:s,value:a,onChange:t,iconOnly:i=!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}),!i&&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(),i=a.toLowerCase(),c=t.indexOf(i);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 Ia=[{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"]},{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"]}],Ke=[{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 $a({config:s,onChange:a,searchQuery:t="",onOpenIntegrationsModal:i,onOpenMonitoringModal:c,onOpenStatisticsModal:r,onOpenWorkflowEditor:d,onOpenTriggerManager:f}){var Ye;const{t:o}=J(["config","common"]),m=Vs(),w=Ks(),[j,g]=l.useState(()=>Hs(ke.DEFAULT_AGENT_CLASS)||"scout"),T=Ws(),y=qs(),[E,v]=l.useState(m.historyLimit),[u,k]=l.useState(()=>Gs()),[F,O]=l.useState(!1),[K,H]=l.useState(""),[W,R]=l.useState(()=>Q()),[G,h]=l.useState(!1),[I,M]=l.useState(!1),[U,te]=l.useState(""),[N,D]=l.useState(!1),[B,p]=l.useState(!1),[x,L]=l.useState(!1),[X,ne]=l.useState(!1),[P,S]=l.useState(!1),[ee,ie]=l.useState(""),[re,oe]=l.useState(!1);l.useEffect(()=>{St().then(ie).catch(()=>{})},[]),l.useEffect(()=>{Nt().then(n=>{n!==m.experimentalEchoPrompt&&C.updateSettings({experimentalEchoPrompt:n})}).catch(()=>{})},[]),l.useEffect(()=>{At().then(n=>{n!==m.tmuxMode&&C.updateSettings({tmuxMode:n})}).catch(()=>{})},[]),l.useEffect(()=>{Et().then(n=>{n!==m.interactiveMode&&C.updateSettings({interactiveMode:n})}).catch(()=>{})},[]),l.useEffect(()=>{_t().then(n=>{n!==m.codexAppServerMode&&C.updateSettings({codexAppServerMode:n})}).catch(()=>{})},[]),l.useEffect(()=>{$t().then(n=>{n!==m.opencodeServerMode&&C.updateSettings({opencodeServerMode:n})}).catch(()=>{})},[]),l.useEffect(()=>Ys(n=>{k(n),O(!1)}),[]);const ge=wa.map(n=>({...n,label:o(`config:time.${n.value}`)})),ye=Na.map(n=>({...n,label:o(`config:floor.${Ea[n.value]||n.value}`)})),je=ka.map(n=>({...n,label:o(`config:animation.${Pa[n.value]||n.value}`)})),de=Sa.map(n=>({...n,label:o(`config:colorMode.${n.value}`)})),Te=Ca.map(n=>({...n,label:o(`config:terrain.${Ta[n.key]}`)})),xe=Aa.map(n=>({...n,label:o(`config:sky.${_a[n.value??""]}`)})),ue=t.trim()?Ia.filter(n=>{const z=t.toLowerCase();return n.title.toLowerCase().includes(z)||n.keywords.some(pe=>pe.toLowerCase().includes(z))}).map(n=>n.id):null,$=n=>ue?ue.includes(n):!0,Ee=$("integrations"),le=m.customAgentNames||[],Fe=le.length>0?le:Js,Pe=()=>{const n=U.trim();n&&!le.includes(n)&&(C.updateSettings({customAgentNames:[...le,n]}),te(""))},ze=n=>{C.updateSettings({customAgentNames:le.filter(z=>z!==n)})},Re=()=>{C.updateSettings({customAgentNames:[]})},we=()=>{const n=K.trim();if(n){if(u.includes(n)){H("");return}k([...u,n]),O(!0),H("")}},_e=n=>{k(u.filter((z,pe)=>pe!==n)),O(!0)},Ne=(n,z)=>{const pe=n+z;if(pe<0||pe>=u.length)return;const be=u.slice();[be[n],be[pe]]=[be[pe],be[n]],k(be),O(!0)},Be=()=>{at(u),O(!1),Ve()},Me=n=>{R(n),h(!0)},Ie=()=>{$e(ke.AUTH_TOKEN,W),h(!1),Ve()},b=n=>{ie(n),oe(!0)},V=()=>{Ct(ee).catch(()=>{}),oe(!1)},se=n=>{a({...s,terrain:{...s.terrain,...n}})},ce=n=>{a({...s,modelStyle:{...s.modelStyle,...n}})},Ge=n=>{a({...s,animations:{...s.animations,...n}})},gs=n=>{v(n),C.updateSettings({historyLimit:n})},fs=n=>{const z=s.terrain[n];typeof z=="boolean"&&se({[n]:!z})},Y=t.trim().length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-section",children:[ue&&ue.length===0&&e.jsx("div",{className:"config-no-results",children:o("config:noResults",{query:t})}),$("general")&&e.jsxs(q,{title:o("config:sections.general"),storageKey:"general",defaultOpen:!0,forceOpen:Y&&$("general"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("config:general.history"),query:t})}),e.jsx("input",{type:"number",className:"config-input config-input-sm",value:E,onChange:n=>gs(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:o("config:general.hideCosts"),query:t})}),e.jsx(ae,{checked:m.hideCost,onChange:n=>C.updateSettings({hideCost:n})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:o("config:general.streamTextLiveTitle"),children:e.jsx(A,{text:o("config:general.streamTextLive"),query:t})}),e.jsx(ae,{checked:m.streamTextLive!==!1,onChange:n=>C.updateSettings({streamTextLive: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=>Qs(n.target.value),children:Zs.map(n=>e.jsx("option",{value:n,children:Xs[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=>et(parseInt(n.target.value,10)||0)})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("config:general.grid"),query:t})}),e.jsx(ae,{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:o("config:general.showFPS"),query:t})}),e.jsx(ae,{checked:m.showFPS,onChange:n=>C.updateSettings({showFPS:n})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("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:o("config:general.powerSaving"),query:t})," ",e.jsx(_,{name:"bolt",size:12})]}),e.jsx(ae,{checked:m.powerSaving,onChange:n=>C.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:o("config:general.lowPowerMode"),query:t})," ",e.jsx(_,{name:"bolt",size:12})]}),e.jsx(ae,{checked:m.lowPowerMode===!0,onChange:n=>C.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:o("config:general.tmuxMode"),query:t})}),e.jsx(ae,{checked:m.tmuxMode,onChange:async n=>{C.updateSettings({tmuxMode:n});try{await Tt(n)}catch(z){console.error("Failed to sync tmux mode setting to server:",z)}}})]}),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:o("config:general.interactiveMode"),query:t})," ",e.jsx(_,{name:"bolt",size:12})]}),e.jsx(ae,{checked:m.interactiveMode,onChange:async n=>{C.updateSettings({interactiveMode:n});try{await Pt(n)}catch(z){console.error("Failed to sync interactive mode setting to server:",z)}}})]}),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:o("config:general.codexAppServerMode"),query:t})," ",e.jsx(_,{name:"bolt",size:12})]}),e.jsx(ae,{checked:m.codexAppServerMode,onChange:async n=>{C.updateSettings({codexAppServerMode:n});try{await It(n)}catch(z){console.error("Failed to sync codex app-server mode setting to server:",z)}}})]}),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:o("config:general.opencodeServerMode"),query:t})," ",e.jsx(_,{name:"bolt",size:12})]}),e.jsx(ae,{checked:m.opencodeServerMode,onChange:async n=>{C.updateSettings({opencodeServerMode:n});try{await Lt(n)}catch(z){console.error("Failed to sync opencode server mode setting to server:",z)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("config:general.vibrationIntensity"),query:t})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"5",step:"1",value:m.vibrationIntensity,onChange:n=>C.updateSettings({vibrationIntensity:parseInt(n.target.value)})}),e.jsx("span",{className:"config-value",children:m.vibrationIntensity===0?o("config:vibrationValues.off"):m.vibrationIntensity===1?o("config:vibrationValues.ultraLight"):m.vibrationIntensity===2?o("config:vibrationValues.veryLight"):m.vibrationIntensity===3?o("config:vibrationValues.light"):m.vibrationIntensity===4?o("config:vibrationValues.medium"):o("config:vibrationValues.heavy")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("config:general.externalEditor"),query:t})}),e.jsx("input",{type:"text",className:"config-input",placeholder:o("config:general.externalEditorPlaceholder"),value:m.externalEditorCommand||"",onChange:n=>C.updateSettings({externalEditorCommand:n.target.value})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("config:general.tabTitle"),query:t})}),e.jsx("input",{type:"text",className:"config-input",placeholder:o("config:general.tabTitlePlaceholder"),value:m.tabTitle||"",onChange:n=>C.updateSettings({tabTitle:n.target.value})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("config:general.language"),query:t})}),e.jsx(ve,{options:Ke,value:localStorage.getItem("tide-commander-language-mode")==="manual"?((Ye=Ke.find(n=>n.value!=="auto"&&Ue.language.startsWith(n.value.split("-")[0])))==null?void 0:Ye.value)||"en":"auto",onChange:n=>{var z;if(n==="auto"){localStorage.setItem("tide-commander-language-mode","auto");const pe=navigator.language,be=((z=Ke.find(Je=>Je.value!=="auto"&&pe.startsWith(Je.value.split("-")[0])))==null?void 0:z.value)||"en";Ue.changeLanguage(be)}else localStorage.setItem("tide-commander-language-mode","manual"),Ue.changeLanguage(n)}})]})]}),$("agentNames")&&e.jsx(q,{title:o("config:sections.agentNames"),storageKey:"agentNames",defaultOpen:!1,forceOpen:Y&&$("agentNames"),children:e.jsxs("div",{className:"agent-names-section",children:[e.jsx("span",{className:"config-hint",children:le.length>0?o("config:agentNames.customConfigured",{count:le.length}):o("config:agentNames.usingDefaults")}),e.jsxs("div",{className:"agent-names-input-row",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",placeholder:o("config:agentNames.addPlaceholder"),value:U,onChange:n=>te(n.target.value),onKeyDown:n=>{n.key==="Enter"&&Pe()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:Pe,disabled:!U.trim(),title:o("config:agentNames.addName"),children:"+"})]}),e.jsx("div",{className:"agent-names-list",children:Fe.map((n,z)=>e.jsxs("div",{className:"agent-name-chip",children:[e.jsx("span",{className:"agent-name-text",children:n}),le.length>0&&e.jsx("button",{className:"agent-name-remove",onClick:()=>ze(n),title:o("common:buttons.remove"),children:"x"})]},`${n}-${z}`))}),le.length>0&&e.jsx("button",{className:"config-btn config-btn-link",onClick:Re,children:o("common:buttons.resetToDefaults")})]})}),$("defaultClass")&&e.jsx(q,{title:"Default Spawn Class",storageKey:"defaultClass",defaultOpen:!1,forceOpen:Y&&$("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"),$e(ke.DEFAULT_AGENT_CLASS,"random")},children:e.jsx("span",{className:"agent-name-text",children:"🎲 Random"})}),Object.entries(st).map(([n,z])=>e.jsx("div",{className:`agent-name-chip${j===n?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{g(n),$e(ke.DEFAULT_AGENT_CLASS,n)},children:e.jsxs("span",{className:"agent-name-text",children:[z.icon," ",n.charAt(0).toUpperCase()+n.slice(1)]})},n)),w.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),$e(ke.DEFAULT_AGENT_CLASS,n.id)},children:e.jsxs("span",{className:"agent-name-text",children:[n.icon," ",n.name]})},n.id))]})]})}),$("appearance")&&e.jsx(q,{title:o("config:sections.appearance"),storageKey:"appearance",defaultOpen:!1,forceOpen:Y&&$("appearance"),children:e.jsx(Rt,{})}),$("connection")&&e.jsxs(q,{title:o("config:sections.connection"),storageKey:"connection",defaultOpen:!1,forceOpen:Y&&$("connection"),children:[e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("config:connection.backendUrl"),query:t})}),e.jsx("div",{className:"backend-urls-list",children:u.map((n,z)=>e.jsxs("div",{className:"backend-url-row",children:[e.jsx("span",{className:"backend-url-priority",title:o("config:connection.priorityLabel",{defaultValue:"Priority"}),children:z+1}),e.jsx("span",{className:"backend-url-text",title:n,children:n}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>Ne(z,-1),disabled:z===0,title:o("config:connection.moveUp",{defaultValue:"Move up"}),children:"↑"}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>Ne(z,1),disabled:z===u.length-1,title:o("config:connection.moveDown",{defaultValue:"Move down"}),children:"↓"}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>_e(z),title:o("common:buttons.remove"),children:"x"})]},`${n}-${z}`))}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:K,onChange:n=>H(n.target.value),placeholder:o("config:connection.addUrlPlaceholder",{defaultValue:"http://host:port"}),onKeyDown:n=>{n.key==="Enter"&&we()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:we,disabled:!K.trim(),title:o("config:connection.addUrl",{defaultValue:"Add URL"}),children:"+"}),F&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:Be,title:o("config:connection.saveAndReconnect"),children:o("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:o("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:o("config:connection.authToken"),query:t})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:I?"text":"password",className:"config-input config-input-full",value:W,onChange:n=>Me(n.target.value),placeholder:o("config:connection.tokenPlaceholder"),onKeyDown:n=>{n.key==="Enter"&&G&&Ie()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>M(!I),title:o(I?"config:connection.hideToken":"config:connection.showToken"),children:e.jsx(_,{name:I?"eye-closed":"eye",size:14})}),G&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:Ie,title:o("config:connection.saveAndReconnect"),children:o("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:o("config:connection.tokenRequired")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("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:ee,onChange:n=>b(n.target.value),placeholder:o("config:connection.codexBinaryPathPlaceholder"),onKeyDown:n=>{n.key==="Enter"&&re&&V()}}),re&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:V,children:o("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:o("config:connection.codexBinaryPathHint")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("common:buttons.reconnect"),query:t})}),e.jsx("button",{className:"config-btn",onClick:()=>Ve(),title:"Force reconnect to server",children:o("common:buttons.reconnect")})]})]}),$("scene")&&e.jsxs(q,{title:o("config:sections.scene"),storageKey:"scene",defaultOpen:!1,forceOpen:Y&&$("scene"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("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:o("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:o("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:o("config:scene.show2DTaskLabels",{defaultValue:"Show 2D task labels"}),query:t})}),e.jsx(ae,{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:o("config:scene.time"),query:t})}),e.jsx(ve,{options:ge,value:s.timeMode,onChange:n=>a({...s,timeMode:n}),iconOnly:!0})]})]}),$("terrain")&&e.jsxs(q,{title:o("config:sections.terrain"),storageKey:"terrain",defaultOpen:!1,forceOpen:Y&&$("terrain"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("config:terrainSettings.simpleMode",{defaultValue:"Simple Mode"}),query:t})}),e.jsx(ae,{checked:s.terrain.simpleMode??!1,onChange:n=>se({simpleMode:n})})]}),e.jsx("div",{className:"terrain-icons",style:{opacity:s.terrain.simpleMode?.4:1,pointerEvents:s.terrain.simpleMode?"none":"auto"},children:Te.map(n=>e.jsx("button",{className:`terrain-icon-btn ${s.terrain[n.key]?"active":""}`,onClick:()=>fs(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:o("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=>se({fogDensity:parseFloat(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.fogDensity===0?o("config:fogValues.off"):s.terrain.fogDensity<=1?o("config:fogValues.low"):o("config:fogValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("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=>se({brightness:parseFloat(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.brightness<=.5?o("config:brightnessValues.dark"):s.terrain.brightness<=1.2?o("config:brightnessValues.normal"):o("config:brightnessValues.bright")})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("config:terrainSettings.floor"),query:t})}),e.jsx(ve,{options:ye,value:s.terrain.floorStyle,onChange:n=>se({floorStyle:n}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("config:terrainSettings.sky"),query:t})}),e.jsx("div",{className:"sky-color-selector",children:xe.map(n=>e.jsx("button",{className:`sky-color-btn ${s.terrain.skyColor===n.value?"active":""}`,onClick:()=>se({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:o("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=>se({battlefieldSize:parseInt(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.battlefieldSize})]})]}),$("modelStyle")&&e.jsxs(q,{title:o("config:sections.modelStyle"),storageKey:"modelStyle",defaultOpen:!1,forceOpen:Y&&$("modelStyle"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("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=>ce({saturation:parseFloat(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.saturation<=.3?o("config:saturationValues.gray"):s.modelStyle.saturation<=1.2?o("config:saturationValues.normal"):o("config:saturationValues.vivid")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("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=>ce({roughness:parseFloat(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.roughness<0?o("config:roughnessValues.auto"):s.modelStyle.roughness<=.3?o("config:roughnessValues.glossy"):s.modelStyle.roughness<=.7?o("config:roughnessValues.normal"):o("config:roughnessValues.matte")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("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=>ce({metalness:parseFloat(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.metalness<0?o("config:metalnessValues.auto"):s.modelStyle.metalness<=.3?o("config:metalnessValues.plastic"):s.modelStyle.metalness<=.7?o("config:metalnessValues.mixed"):o("config:metalnessValues.metal")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("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=>ce({emissiveBoost:parseFloat(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.emissiveBoost<=.1?o("config:glowValues.off"):s.modelStyle.emissiveBoost<=.4?o("config:glowValues.low"):s.modelStyle.emissiveBoost<=.7?o("config:glowValues.med"):o("config:glowValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("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=>ce({envMapIntensity:parseFloat(n.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.envMapIntensity<0?o("config:reflectionValues.auto"):s.modelStyle.envMapIntensity<=.3?o("config:reflectionValues.low"):s.modelStyle.envMapIntensity<=1?o("config:reflectionValues.normal"):o("config:reflectionValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("config:modelStyleSettings.wireframe"),query:t})}),e.jsx(ae,{checked:s.modelStyle.wireframe,onChange:n=>ce({wireframe:n})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("config:modelStyleSettings.colorMode"),query:t})}),e.jsx(ve,{options:de,value:s.modelStyle.colorMode,onChange:n=>ce({colorMode:n}),iconOnly:!0})]})]}),$("animations")&&e.jsxs(q,{title:o("config:sections.animations"),storageKey:"animations",defaultOpen:!1,forceOpen:Y&&$("animations"),children:[e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("config:animationSettings.idle"),query:t})}),e.jsx(ve,{options:je,value:s.animations.idleAnimation,onChange:n=>Ge({idleAnimation:n}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("config:animationSettings.working"),query:t})}),e.jsx(ve,{options:je,value:s.animations.workingAnimation,onChange:n=>Ge({workingAnimation:n}),iconOnly:!0})]})]}),$("secrets")&&e.jsx(q,{title:o("config:sections.secrets"),storageKey:"secrets",defaultOpen:!1,forceOpen:Y&&$("secrets"),children:e.jsx(jt,{})}),$("claudeAccounts")&&e.jsx(q,{title:o("config:sections.claudeAccounts",{defaultValue:"Claude Accounts"}),storageKey:"claudeAccounts",defaultOpen:!1,forceOpen:Y&&$("claudeAccounts"),children:e.jsx(tt,{})}),$("grokAccounts")&&e.jsx(q,{title:o("config:sections.grokAccounts",{defaultValue:"Grok Accounts"}),storageKey:"grokAccounts",defaultOpen:!1,forceOpen:Y&&$("grokAccounts"),children:e.jsx(Qe,{provider:"grok"})}),$("codexAccounts")&&e.jsx(q,{title:o("config:sections.codexAccounts",{defaultValue:"Codex Accounts"}),storageKey:"codexAccounts",defaultOpen:!1,forceOpen:Y&&$("codexAccounts"),children:e.jsx(Qe,{provider:"codex"})}),$("systemPrompt")&&e.jsx(q,{title:o("config:sections.systemPrompt"),storageKey:"systemPrompt",defaultOpen:!1,forceOpen:Y&&$("systemPrompt"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(A,{text:o("config:systemPrompt.title"),query:t})}),e.jsx("button",{className:"config-button",onClick:()=>D(!0),children:o("config:systemPrompt.editPrompt")})]})}),$("data")&&e.jsx(q,{title:o("config:sections.data"),storageKey:"data",defaultOpen:!1,forceOpen:Y&&$("data"),children:e.jsx(zt,{})}),Ee&&e.jsx(q,{title:o("config:sections.integrations"),storageKey:"integrations",defaultOpen:!1,forceOpen:Y&&Ee,children:e.jsx(Ht,{onOpenModal:n=>{n==="whatsapp"?S(!0):i==null||i(n)}})}),$("workflows")&&e.jsxs(q,{title:"Workflows",storageKey:"workflows",defaultOpen:!1,forceOpen:Y&&$("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(q,{title:"Triggers",storageKey:"triggers",defaultOpen:!1,forceOpen:Y&&$("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(q,{title:"Monitoring",storageKey:"monitoring",defaultOpen:!1,forceOpen:Y&&$("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(q,{title:"Statistics",storageKey:"statistics",defaultOpen:!1,forceOpen:Y&&$("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(q,{title:o("config:sections.experimental"),storageKey:"experimental",defaultOpen:!1,forceOpen:Y&&$("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:o("config:experimental.2dView"),query:t})," ",e.jsx(_,{name:"map",size:12})]}),e.jsx(ae,{checked:m.experimental2DView,onChange:n=>C.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:o("config:experimental.voiceAssistant"),query:t})," ",e.jsx(_,{name:"microphone",size:12})]}),e.jsx(ae,{checked:m.experimentalVoiceAssistant,onChange:n=>C.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:o("config:experimental.tts"),query:t})," ",e.jsx(_,{name:"speaker-on",size:12})]}),e.jsx(ae,{checked:m.experimentalTTS,onChange:n=>C.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:o("config:experimental.echoPrompt"),query:t})}),e.jsx(ae,{checked:m.experimentalEchoPrompt,onChange:async n=>{C.updateSettings({experimentalEchoPrompt:n});try{await kt(n)}catch(z){console.error("Failed to sync echo prompt setting to server:",z)}}})]}),e.jsx("span",{className:"config-hint",children:o("config:experimental.hint")})]}),$("about")&&e.jsx(q,{title:o("config:sections.about"),storageKey:"about",defaultOpen:!1,forceOpen:Y&&$("about"),children:e.jsx(Vt,{})})]}),e.jsx(Zt,{isOpen:N,onClose:()=>D(!1)}),e.jsx(sa,{isOpen:B,onClose:()=>p(!1)}),e.jsx(oa,{isOpen:x,onClose:()=>L(!1)}),e.jsx(va,{isOpen:X,onClose:()=>ne(!1)}),e.jsx(ya,{isOpen:P,onClose:()=>S(!1),onOpenConfig:()=>p(!0),onOpenNotifications:()=>L(!0),onOpenHistory:()=>ne(!0)})]})}function za({onConfigChange:s,onToolChange:a,config:t,isOpen:i,onClose:c,onOpenBuildingModal:r,onOpenAreaExplorer:d,onOpenIntegrationsModal:f,onOpenMonitoringModal:o,onOpenStatisticsModal:m,onOpenWorkflowEditor:w,onOpenTriggerManager:j}){const{t:g}=J(["config","common"]),T=nt(),y=it(),E=ot(),v=lt(),u=ct(),k=Array.from(T.values()),F=Array.from(y.values()),[O,K]=l.useState(""),H=l.useRef(null);if(l.useEffect(()=>{const h=I=>{I.key==="Escape"&&i&&c()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[i,c]),l.useEffect(()=>{if(i&&H.current){if(typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches)return;const I=setTimeout(()=>{var M;(M=H.current)==null||M.focus()},50);return()=>clearTimeout(I)}},[i]),!i)return null;const W=h=>{a(u===h?null:h)},R=h=>{C.selectArea(v===h?null:h),a("select")},G=(h,I)=>{h.stopPropagation(),C.deleteArea(I)};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:H,type:"text",placeholder:g("config:searchPlaceholder"),value:O,onChange:h=>K(h.target.value),className:"toolbox-search-input"}),O&&e.jsx("button",{className:"toolbox-search-clear",onClick:()=>K(""),children:"×"})]}),e.jsxs("div",{className:"toolbox-content",children:[e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsxs(q,{title:g("config:areas.title",{count:k.length}),storageKey:"areas",children:[e.jsxs("div",{className:"tool-buttons",children:[e.jsx("button",{className:`tool-btn ${u==="select"?"active":""}`,onClick:()=>W("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 ${u==="rectangle"?"active":""}`,onClick:()=>W("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 ${u==="circle"?"active":""}`,onClick:()=>W("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:k.length===0?e.jsx("div",{className:"areas-empty",children:g("config:areas.drawToCreate")}):k.map(h=>e.jsx(ht,{area:h,isSelected:v===h.id,onClick:()=>R(h.id),onDelete:I=>G(I,h.id)},h.id))})]})}),v&&e.jsx(bt,{area:T.get(v),onClose:()=>C.selectArea(null),onOpenFolder:d}),e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsx(q,{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(gt,{building:h,isSelected:E.has(h.id),onClick:()=>{C.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],I=y.get(h);return I?e.jsx(ft,{building:I,onClose:()=>C.selectBuilding(null),onOpenModal:()=>r==null?void 0:r(h)}):null})(),e.jsx($a,{config:t,onChange:s,searchQuery:O,onOpenIntegrationsModal:f,onOpenMonitoringModal:o,onOpenStatisticsModal:m,onOpenWorkflowEditor:w,onOpenTriggerManager:j})]})]})]})}export{za as Toolbox};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aq as ts,u as rs,aU as _s,aV as vs,aW as Is,j as s,I as U,a9 as $s,aX as Es,aY as Ds,aZ as Ms,a_ as Ls,r as o,ag as Xs,aC as Ss,m as Ps,a5 as Ys,Y as Rs,a$ as Gs,b0 as Us,b1 as Fs,b2 as Zs,b3 as Hs,s as M,b4 as Ws,t as G}from"./main-D6IBl2Xu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const bs=ts.memo(({agent:a,isSelected:z,isKeyboardFocused:F=!1,onSelect:L,onDoubleClick:r,onChat:g,onFocus:h,onKill:w,onDragStart:X})=>{const{t:x}=rs(["dashboard","common"]),S=_s().has(a.id),N=vs(a.status),Z=Is(a),j=Ls(Z),I=a.taskLabel?s.jsxs(s.Fragment,{children:[s.jsx(U,{name:"task",size:12})," ",a.taskLabel]}):a.currentTask||a.lastAssignedTask,m=a.status==="idle"&&a.lastActivity>0,[,H]=ts.useState(0);return ts.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>H(q=>q+1),15e3);return()=>window.clearInterval(b)},[m]),s.jsxs("div",{className:`dash-card dash-card--${N} ${z?"dash-card--selected":""} ${F?"dash-card--keyboard-focused":""}`,"data-agent-id":a.id,onClick:()=>L(a.id),onDoubleClick:b=>{b.stopPropagation(),r(a.id)},onDragStart:b=>{X==null||X(a),b.dataTransfer.effectAllowed="move"},draggable:!0,title:x("cards.doubleClickHint"),children:[s.jsxs("div",{className:"dash-card__row1",children:[s.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${N}`}),s.jsx("span",{className:"dash-card__name",children:a.name}),s.jsxs("span",{className:"dash-card__class",children:[s.jsx($s,{agent:a,size:14})," ",a.class]}),s.jsxs("span",{className:`dash-card__provider dash-card__provider--${a.provider}`,children:[s.jsx(U,{name:a.provider==="codex"||a.provider==="opencode"||a.provider==="grok"?"status-pending":"robot",size:11,weight:a.provider==="codex"||a.provider==="opencode"||a.provider==="grok"?"fill":"regular",color:a.provider==="codex"?"#a16207":a.provider==="opencode"?"#4ade80":a.provider==="grok"?"#6366f1":void 0})," ",a.provider]}),S&&s.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),s.jsxs("div",{className:"dash-card__row2",children:[s.jsx("span",{className:`dash-card__status dash-card__status--${N}`,children:S?"Unseen":a.status}),s.jsxs("div",{className:"dash-card__context",children:[s.jsx("div",{className:"dash-card__context-bar",children:s.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${j}`,style:{width:`${Z}%`}})}),s.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${j}`,children:[Z,"%"]})]})]}),s.jsxs("div",{className:"dash-card__row3",children:[s.jsxs("span",{className:"dash-card__workdir",title:a.cwd,children:[s.jsx(U,{name:"folder",size:11})," ",a.cwd.split("/").pop()||a.cwd]}),m&&s.jsxs("span",{className:"dash-card__idle-time",style:{color:Ms(a.lastActivity)},title:Ds(a.lastActivity),children:[s.jsx(U,{name:"status-waiting-input",size:10})," ",Es(a.lastActivity)]})]}),I&&s.jsx("div",{className:"dash-card__row4",children:s.jsx("span",{className:"dash-card__task",children:I})}),s.jsxs("div",{className:"dash-card__actions",children:[g&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:b=>{b.stopPropagation(),g(a.id)},title:x("cards.openTerminal"),children:x("cards.chat")}),w&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:b=>{b.stopPropagation(),w(a.id)},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});bs.displayName="AgentCard";const fs=({buildings:a,onSelectBuilding:z})=>{const{t:F}=rs(["dashboard"]),L=o.useMemo(()=>Array.from(a.values()).sort((r,g)=>r.name.localeCompare(g.name)),[a]);return s.jsxs("div",{className:"dashboard-view__buildings",children:[s.jsxs("div",{className:"dashboard-view__buildings-header",children:[s.jsx("span",{className:"dashboard-view__buildings-title",children:F("buildings.title")}),s.jsx("span",{className:"dashboard-view__buildings-count",children:L.length})]}),s.jsx("div",{className:"dashboard-view__buildings-row",children:L.map(r=>{const g=vs(r.status),h=Xs(r.type);return s.jsxs("button",{className:`dash-pill dash-pill--${g}`,onClick:()=>z==null?void 0:z(r.id),title:`${r.name} (${r.type}) - ${r.status}`,children:[s.jsx("span",{className:"dash-pill__icon",children:s.jsx(U,{name:h,size:14})}),s.jsx("span",{className:"dash-pill__name",children:r.name}),s.jsx("span",{className:`dash-pill__dot dash-pill__dot--${g}`})]},r.id)})})]})};fs.displayName="BuildingPills";function qs({onSelectAgent:a,onFocusAgent:z,onKillAgent:F,onSelectBuilding:L,onOpenTerminal:r,onFocusZone:g}){const{t:h}=rs(["dashboard","common"]),w=Ss(),X=Ps(),x=Ys(),ns=Rs(),S=_s(),[N,Z]=o.useState(""),[j,I]=o.useState("all"),[m,H]=o.useState("zone"),[b,q]=o.useState(new Set),[k,J]=o.useState(null),[ws,B]=o.useState(null),[P,Q]=o.useState(!1),[p,W]=o.useState(null),K=o.useMemo(()=>{const e=Array.from(w.values());return{total:e.length,working:e.filter(d=>d.status==="working"||d.status==="waiting"||d.status==="waiting_permission").length,idle:e.filter(d=>d.status==="idle").length,error:e.filter(d=>d.status==="error"||d.status==="offline"||d.status==="orphaned").length}},[w]),is=o.useMemo(()=>m==="zone"?Gs(w,x):m==="status"?Us(w,S):Fs(w),[w,x,m,S]),T=o.useMemo(()=>{const e=N.toLowerCase().trim(),d=is.map(l=>({...l,agents:l.agents.filter(_=>{if(j==="working"){if(_.status!=="working"&&_.status!=="waiting"&&_.status!=="waiting_permission")return!1}else if(j==="error"&&_.status!=="error"&&_.status!=="offline"&&_.status!=="orphaned")return!1;return!(e&&!_.name.toLowerCase().includes(e)&&!_.class.toLowerCase().includes(e))})}));return m==="zone"?d:d.filter(l=>l.agents.length>0)},[is,j,N,m]),O=o.useCallback(e=>e.area?`area:${e.area.id}`:`${m}:${e.label}`,[m]),ss=o.useMemo(()=>T.map(e=>({...e,sortedAgents:m==="status"?Zs(e.agents,{prioritizeRecentlyIdle:!0}):Hs(e.agents)})),[T,m]),C=o.useMemo(()=>{const e=[];return ss.forEach(d=>{const l=O(d);b.has(l)||e.push(...d.sortedAgents)}),e},[ss,b,O]),ps=o.useCallback(e=>{q(d=>{const l=new Set(d);return l.has(e)?l.delete(e):l.add(e),l})},[]),gs=o.useCallback(e=>{r==null||r(e)},[r]),xs=o.useCallback(e=>{a==null||a(e),Q(!0),W(e)},[a]),js=o.useCallback(e=>{r==null||r(e)},[r]),Ns=o.useCallback(e=>{J(e)},[]),ks=o.useCallback((e,d)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",B(d)},[]),Cs=o.useCallback(()=>{B(null)},[]),ys=o.useCallback(e=>{if(!k)return;if(e===null){const $=M.getState(),t=Array.from($.areas.values()).find(n=>n.assignedAgentIds.includes(k.id));t&&M.unassignAgentFromArea(k.id,t.id),J(null),B(null);return}const d=x.get(e);if(!d)return;const l=Array.from(w.values()),_=Ws(d,l,k.position);M.updateAgent({...k,position:{...k.position,x:_.x,z:_.z}}),M.assignAgentToArea(k.id,e),J(null),B(null)},[k,x,w]);return o.useEffect(()=>{if(C.length===0){Q(!1),W(null);return}P&&(!p||!C.some(e=>e.id===p))&&(W(C[0].id),a==null||a(C[0].id))},[C,P,p,a]),o.useEffect(()=>{const e=t=>t instanceof HTMLElement?t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable:!1,d=t=>t instanceof HTMLElement?!!t.closest(".guake-terminal")||t.classList.contains("guake-input")||t.classList.contains("agent-panel-input"):!1,l=t=>{const n=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(A=>A.dataset.agentId===t);n==null||n.scrollIntoView({block:"nearest",inline:"nearest"})},_=(t,n)=>{var os,cs,ls,us,hs,ms;const A=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(i=>{const u=i.dataset.agentId;if(!u)return null;const y=i.getBoundingClientRect();return{id:u,centerX:y.left+y.width/2,centerY:y.top+y.height/2,height:y.height}}).filter(i=>i!==null).sort((i,u)=>i.centerY-u.centerY||i.centerX-u.centerX);if(A.length===0)return t;const es=A.reduce((i,u)=>i+u.height,0)/A.length,as=Math.max(18,es*.6),f=[];for(const i of A){const u=f[f.length-1];if(!u){f.push([{id:i.id,centerX:i.centerX,centerY:i.centerY}]);continue}const y=u.reduce((As,zs)=>As+zs.centerY,0)/u.length;Math.abs(i.centerY-y)<=as?u.push({id:i.id,centerX:i.centerX,centerY:i.centerY}):f.push([{id:i.id,centerX:i.centerX,centerY:i.centerY}])}f.forEach(i=>i.sort((u,y)=>u.centerX-y.centerX));const Y=f.findIndex(i=>i.some(u=>u.id===t));if(Y===-1)return((cs=(os=f[0])==null?void 0:os[0])==null?void 0:cs.id)??t;const E=f[Y],v=E.findIndex(i=>i.id===t);if(v===-1)return((us=(ls=f[0])==null?void 0:ls[0])==null?void 0:us.id)??t;if(n==="left")return((hs=E[Math.max(0,v-1)])==null?void 0:hs.id)??t;if(n==="right")return((ms=E[Math.min(E.length-1,v+1)])==null?void 0:ms.id)??t;const V=n==="up"?Math.max(0,Y-1):Math.min(f.length-1,Y+1),c=f[V],R=E[v].centerX;let D=c[0],ds=Math.abs(D.centerX-R);for(const i of c){const u=Math.abs(i.centerX-R);u<ds&&(D=i,ds=u)}return(D==null?void 0:D.id)??t},$=t=>{const n=M.getShortcuts(),A=n.find(c=>c.id==="dashboard-selector-toggle"),es=n.find(c=>c.id==="dashboard-vim-left"),as=n.find(c=>c.id==="dashboard-vim-down"),f=n.find(c=>c.id==="dashboard-vim-up"),Y=n.find(c=>c.id==="dashboard-vim-right"),E=n.find(c=>c.id==="open-terminal"),v=M.getState();if(e(t.target))if(!v.terminalOpen&&d(t.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(G(t,A)){if(C.length===0)return;t.preventDefault(),t.stopPropagation(),Q(!0),W(c=>{const R=c&&C.some(D=>D.id===c)?c:C[0].id;return a==null||a(R),window.setTimeout(()=>l(R),0),R});return}const V=G(t,es)||t.key==="ArrowLeft"?"left":G(t,as)||t.key==="ArrowDown"?"down":G(t,f)||t.key==="ArrowUp"?"up":G(t,Y)||t.key==="ArrowRight"?"right":null;if(V&&P&&p){t.preventDefault(),t.stopPropagation();const c=_(p,V);c!==p&&(W(c),a==null||a(c),window.setTimeout(()=>l(c),0));return}if(G(t,E)){if(v.terminalOpen)return;if(P&&p&&v.agents.has(p)){t.preventDefault(),r==null||r(p);return}if(v.selectedAgentIds.size===1){t.preventDefault();const c=Array.from(v.selectedAgentIds)[0];r==null||r(c);return}if(v.lastSelectedAgentId&&v.agents.has(v.lastSelectedAgentId)){t.preventDefault(),r==null||r(v.lastSelectedAgentId);return}}};return document.addEventListener("keydown",$,!0),()=>document.removeEventListener("keydown",$,!0)},[C,P,p,r,a]),o.useEffect(()=>{const e=document.activeElement;e instanceof HTMLElement&&e.closest(".guake-terminal")&&!M.getState().terminalOpen&&e.blur()},[]),s.jsxs("div",{className:"dashboard-view",children:[s.jsxs("div",{className:"dashboard-view__topbar",children:[s.jsxs("div",{className:"dashboard-view__metrics",children:[s.jsxs("button",{className:`dashboard-view__metric-btn ${j==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.total}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:labels.agents")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${j==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("working"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.working}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.working")})]}),s.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.idle}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.idle")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${j==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("error"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.error}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.error")})]})]}),s.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:h("searchPlaceholder"),value:N,onChange:e=>Z(e.target.value)})]}),s.jsxs("div",{className:"dashboard-view__grouping",children:[s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>H("zone"),children:h("grouping.byZone")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>H("status"),children:h("grouping.byStatus")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>H("activity"),children:h("grouping.byActivity")})]}),s.jsxs("div",{className:"dashboard-view__content",children:[ss.map(e=>{const d=O(e),l=b.has(d),_=e.sortedAgents,$=e.agents.filter(n=>n.status==="working"||n.status==="waiting"||n.status==="waiting_permission").length,t=e.agents.filter(n=>S.has(n.id)).length;return s.jsxs("div",{className:`dashboard-view__zone ${ws===(e.area?e.area.id:null)&&k?"dashboard-view__zone--drag-over":""}`,onDragOver:n=>ks(n,e.area?e.area.id:null),onDragLeave:Cs,onDrop:()=>ys(e.area?e.area.id:null),children:[s.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>ps(d),children:[s.jsxs("div",{className:"dashboard-view__zone-left",children:[s.jsx("span",{className:`dashboard-view__zone-chevron ${l?"dashboard-view__zone-chevron--collapsed":""}`,children:s.jsx(U,{name:"caret-down",size:12})}),s.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:e.color}}),s.jsx("span",{className:"dashboard-view__zone-name",children:e.label}),s.jsxs("span",{className:"dashboard-view__zone-count",children:[h("agentCount",{count:e.agents.length}),$>0&&s.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",$," ",h("working")]}),t>0&&s.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",t," Unseen"]})]})]}),e.area&&g&&s.jsx("button",{className:"dashboard-view__zone-focus",onClick:n=>{n.stopPropagation(),g(e.area.id)},title:h("focusZone"),children:h("focusZone")})]}),!l&&s.jsx("div",{className:"dashboard-view__zone-grid",children:_.map(n=>s.jsx(bs,{agent:n,isSelected:ns.has(n.id),isKeyboardFocused:P&&p===n.id,onSelect:xs,onDoubleClick:gs,onChat:js,onFocus:z,onKill:F,onDragStart:Ns},n.id))})]},d)}),T.length===0&&s.jsx("div",{className:"dashboard-view__empty",children:N?h("noAgentsMatching",{search:N}):h("noAgentsSpawned")}),X.size>0&&s.jsx(fs,{buildings:X,onSelectBuilding:L})]})]})}export{qs as DashboardView};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-BVrXaF9j.js","assets/main-D6IBl2Xu.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-BzGnAbiA.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{dc as e,cf as o}from"./main-D6IBl2Xu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";var i;(function(r){r.Heavy="HEAVY",r.Medium="MEDIUM",r.Light="LIGHT"})(i||(i={}));var t;(function(r){r.Success="SUCCESS",r.Warning="WARNING",r.Error="ERROR"})(t||(t={}));const c=e("Haptics",{web:()=>o(()=>import("./web-BVrXaF9j.js"),__vite__mapDeps([0,1,2,3,4])).then(r=>new r.HapticsWeb)});export{c as Haptics,i as ImpactStyle,t as NotificationType};
|