tide-commander 1.105.0 → 1.106.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/assets/{BossLogsModal-NcPBOpUA.js → BossLogsModal-CevoUZKD.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-wTpzlbAl.js → BossSpawnModal-3nszeR-6.js} +1 -1
  3. package/dist/assets/{ControlsModal-ClVSLjHA.js → ControlsModal-DTWIyKiT.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-CT6xJG_D.js → DockerLogsModal-DDdFkyMX.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-uvY5-tsR.js → EmbeddedEditor-ijF6aHai.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-CqwDlJBF.js → GmailOAuthSetup-CGyttDBQ.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-B_aURcHz.js → GoogleOAuthSetup-D0_UY-SP.js} +1 -1
  8. package/dist/assets/{IframeModal-vIDqAr6c.js → IframeModal-ZuA4_NGi.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-DLqjoIr0.js → IntegrationsPanel-CcWE9fgo.js} +2 -2
  10. package/dist/assets/{LogViewerModal-D2BmPOPE.js → LogViewerModal-BsIlfAS6.js} +1 -1
  11. package/dist/assets/{MonitoringModal-CTlBb1vN.js → MonitoringModal-qe7HTBMo.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-C_ufK49i.js → PM2LogsModal-CTM9MO64.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-D6lZk-qB.js → RestoreArchivedAreaModal-Be51KtFf.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-C9qk31-O.js → Scene2DCanvas-Ckl3doTg.js} +1 -1
  15. package/dist/assets/{SceneManager-Cy-VIZio.js → SceneManager-D93P3IC2.js} +1 -1
  16. package/dist/assets/{SkillsPanel-CPHfwIbf.js → SkillsPanel-BTif9VLj.js} +1 -1
  17. package/dist/assets/{SlackMultiInstanceSetup-ovbYmgGj.js → SlackMultiInstanceSetup-ef2FlaRV.js} +1 -1
  18. package/dist/assets/{SpawnModal-BrpGn4WT.js → SpawnModal-DZn6T2BE.js} +1 -1
  19. package/dist/assets/{SubordinateAssignmentModal-C05s7poT.js → SubordinateAssignmentModal-BecahDmr.js} +1 -1
  20. package/dist/assets/{TriggerManagerPanel-D6pppFzY.js → TriggerManagerPanel-DFxMZCD6.js} +1 -1
  21. package/dist/assets/{WorkflowEditorPanel-DMAeoGhU.js → WorkflowEditorPanel-7BwlgK2_.js} +1 -1
  22. package/dist/assets/{index-1O-Fwdxd.js → index-BHWQkGRh.js} +2 -2
  23. package/dist/assets/{index-oEyGNYid.js → index-Bhu_7tgQ.js} +1 -1
  24. package/dist/assets/{index-Cy-Ffkrp.js → index-CWWrLFZt.js} +1 -1
  25. package/dist/assets/{index-XDOamjTz.js → index-D_0kg4Ar.js} +1 -1
  26. package/dist/assets/{index-DKZ6GfUT.js → index-DfprefSo.js} +1 -1
  27. package/dist/assets/index-QfWY_97i.js +1 -0
  28. package/dist/assets/{index-8u7NwbN0.js → index-pdcL9V_U.js} +1 -1
  29. package/dist/assets/index-vvRW2CVv.js +2 -0
  30. package/dist/assets/{index-YBUZBrvI.js → index-yI0Dut8N.js} +3 -3
  31. package/dist/assets/{main-BA8NAb8s.js → main-3di6rXWx.js} +85 -85
  32. package/dist/assets/main-DMFHbAkT.css +1 -0
  33. package/dist/assets/{web-bvY6IgCp.js → web-B2Vqfq-6.js} +1 -1
  34. package/dist/assets/{web-CKjqjynV.js → web-BrQwgVAD.js} +1 -1
  35. package/dist/assets/{web-DXe5QkoC.js → web-Dsm1bqFr.js} +1 -1
  36. package/dist/index.html +2 -2
  37. package/dist/src/packages/server/claude/session-loader.js +194 -13
  38. package/dist/src/packages/server/codex/json-event-parser.js +93 -4
  39. package/dist/src/packages/server/data/builtin-skills/boss-instructions.js +12 -0
  40. package/dist/src/packages/server/integrations/whatsapp/contact-name-cache.js +8 -2
  41. package/dist/src/packages/server/integrations/whatsapp/whatsapp-trigger-handler.js +10 -0
  42. package/dist/src/packages/server/services/agent-service.js +13 -0
  43. package/dist/src/packages/server/websocket/handlers/boss-response-handler.js +66 -11
  44. package/package.json +1 -1
  45. package/dist/assets/index-Cnt5MCXg.js +0 -2
  46. package/dist/assets/index-mJOJNl3S.js +0 -1
  47. package/dist/assets/main-F_wZVjHx.css +0 -1
@@ -1 +1 @@
1
- import{u as M,f as N,r as m,s as u,j as r}from"./main-BA8NAb8s.js";import{L as v}from"./LogViewerModal-D2BmPOPE.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function C(o){const n=["#3498db","#2ecc71","#9b59b6","#e67e22","#1abc9c","#e74c3c","#f1c40f","#00bcd4"];let a=0;for(let t=0;t<o.length;t++)a=o.charCodeAt(t)+((a<<5)-a);return n[Math.abs(a)%n.length]}function k({building:o,isOpen:n,onClose:a}){const{t}=M(["terminal","common"]),{bossStreamingLogs:b,buildings:f}=N(),l=b.get(o.id)||[],[i,d]=m.useState(null),c=o.subordinateBuildingIds||[],g=c.map(e=>f.get(e)).filter(e=>e!==void 0);m.useEffect(()=>(n&&c.length>0&&u.startBossLogStreaming(o.id),()=>{o.id&&u.stopBossLogStreaming(o.id)}),[n,o.id,c.length]);const h=m.useMemo(()=>{const e=new Set;return l.forEach(s=>e.add(s.subordinateName)),Array.from(e)},[l]),p=m.useMemo(()=>(i?l.filter(s=>s.subordinateName===i):l).map((s,j)=>({text:s.chunk,lineNumber:j+1,sourceLabel:s.subordinateName,sourceColor:C(s.subordinateName),isError:s.isError})),[l,i]),x=g.some(e=>{var s;return(s=e.pm2)==null?void 0:s.enabled}),S=h.length>1?r.jsxs("select",{className:"toolbar-btn source-filter",value:i||"",onChange:e=>d(e.target.value||null),children:[r.jsx("option",{value:"",children:t("terminal:logs.allSources")}),h.map(e=>r.jsx("option",{value:e,children:e},e))]}):void 0,L=i?r.jsxs("div",{className:"shortcut",style:{marginLeft:"auto"},children:[r.jsxs("span",{children:[t("terminal:logs.filtered"),": ",i]}),r.jsx("button",{style:{background:"transparent",border:"none",color:"inherit",cursor:"pointer",marginLeft:"0.5rem"},onClick:()=>d(null),children:"x"})]}):void 0;return r.jsx(v,{isOpen:n,onClose:a,title:`${o.name} - ${t("terminal:logs.bossLogs")}`,icon:"👑",lines:p,isStreaming:c.length>0,streamingIndicatorLabel:`${g.length} ${t("terminal:logs.units")}`,onClear:()=>u.clearBossStreamingLogs(o.id),emptyMessage:x?l.length===0?t("terminal:logs.waitingForLogs"):t("terminal:logs.noMatchingLogs"):t("terminal:logs.noPM2Subordinates"),extraToolbar:S,extraFooter:L,modalClassName:"boss-logs-modal"})}export{k as BossLogsModal};
1
+ import{u as M,f as N,r as m,s as u,j as r}from"./main-3di6rXWx.js";import{L as v}from"./LogViewerModal-BsIlfAS6.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function C(o){const n=["#3498db","#2ecc71","#9b59b6","#e67e22","#1abc9c","#e74c3c","#f1c40f","#00bcd4"];let a=0;for(let t=0;t<o.length;t++)a=o.charCodeAt(t)+((a<<5)-a);return n[Math.abs(a)%n.length]}function k({building:o,isOpen:n,onClose:a}){const{t}=M(["terminal","common"]),{bossStreamingLogs:b,buildings:f}=N(),l=b.get(o.id)||[],[i,d]=m.useState(null),c=o.subordinateBuildingIds||[],g=c.map(e=>f.get(e)).filter(e=>e!==void 0);m.useEffect(()=>(n&&c.length>0&&u.startBossLogStreaming(o.id),()=>{o.id&&u.stopBossLogStreaming(o.id)}),[n,o.id,c.length]);const h=m.useMemo(()=>{const e=new Set;return l.forEach(s=>e.add(s.subordinateName)),Array.from(e)},[l]),p=m.useMemo(()=>(i?l.filter(s=>s.subordinateName===i):l).map((s,j)=>({text:s.chunk,lineNumber:j+1,sourceLabel:s.subordinateName,sourceColor:C(s.subordinateName),isError:s.isError})),[l,i]),x=g.some(e=>{var s;return(s=e.pm2)==null?void 0:s.enabled}),S=h.length>1?r.jsxs("select",{className:"toolbar-btn source-filter",value:i||"",onChange:e=>d(e.target.value||null),children:[r.jsx("option",{value:"",children:t("terminal:logs.allSources")}),h.map(e=>r.jsx("option",{value:e,children:e},e))]}):void 0,L=i?r.jsxs("div",{className:"shortcut",style:{marginLeft:"auto"},children:[r.jsxs("span",{children:[t("terminal:logs.filtered"),": ",i]}),r.jsx("button",{style:{background:"transparent",border:"none",color:"inherit",cursor:"pointer",marginLeft:"0.5rem"},onClick:()=>d(null),children:"x"})]}):void 0;return r.jsx(v,{isOpen:n,onClose:a,title:`${o.name} - ${t("terminal:logs.bossLogs")}`,icon:"👑",lines:p,isStreaming:c.length>0,streamingIndicatorLabel:`${g.length} ${t("terminal:logs.units")}`,onClear:()=>u.clearBossStreamingLogs(o.id),emptyMessage:x?l.length===0?t("terminal:logs.waitingForLogs"):t("terminal:logs.noMatchingLogs"):t("terminal:logs.noPM2Subordinates"),extraToolbar:S,extraFooter:L,modalClassName:"boss-logs-modal"})}export{k as BossLogsModal};
@@ -1 +1 @@
1
- import{u as Be,aj as Oe,aH as Re,aG as Te,r as t,J as re,S as G,aT as O,l as Fe,s as v,aK as W,A as de,aU as C,j as s,_ as y,aM as Pe,aO as ze,I as R,aP as K,as as A,aq as T,aR as H,K as Ue}from"./main-BA8NAb8s.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function ue(d){const x=C.filter(E=>!d.has(`Boss ${E}`));return x.length===0?`Boss ${C[Math.floor(Math.random()*C.length)]}-${Date.now()%1e3}`:`Boss ${x[Math.floor(Math.random()*x.length)]}`}function Ke({isOpen:d,onClose:x,onSpawnStart:E,onSpawnEnd:F,spawnPosition:me,spawnAreaId:N}){const{t:n}=Be(["terminal","common"]),J=Oe(),c=Re(),$=Te(),[u,p]=t.useState(""),[L,P]=t.useState(()=>re(G.LAST_CWD)),[r,I]=t.useState("boss"),[X,V]=t.useState(!1),[pe,_]=t.useState(!1),[Y,he]=t.useState(!0),[Q,xe]=t.useState("bypass"),[m,z]=t.useState("claude"),[f,g]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[Z,we]=t.useState("opus[1m]"),[ee,fe]=t.useState("gpt-5.3-codex"),[k,D]=t.useState(new Set),[se,U]=t.useState(new Set),[h,be]=t.useState(""),[S,je]=t.useState(""),[ae,Ne]=t.useState(""),B=t.useRef(null),q=t.useRef(!1),ne=t.useRef(!1),b=t.useMemo(()=>$.filter(e=>e.enabled),[$]),le=t.useMemo(()=>{if(!S.trim())return b;const e=S.toLowerCase();return b.filter(a=>a.name.toLowerCase().includes(e)||a.description.toLowerCase().includes(e)||a.slug.toLowerCase().includes(e))},[b,S]),ge=t.useMemo(()=>{var a;const e=c.find(l=>l.id===r);return(a=e==null?void 0:e.defaultSkillIds)!=null&&a.length?$.filter(l=>e.defaultSkillIds.includes(l.id)):[]},[c,r,$]),Se=["full-notifications","streaming-exec","task-label","report-task-to-boss","send-message-to-agent"];t.useEffect(()=>{if(d&&!ne.current){if(b.length>0){const l=b.filter(i=>Se.includes(i.slug)).map(i=>i.id);l.length>0&&U(new Set(l))}if(re(G.DEFAULT_AGENT_CLASS)==="random"){const i=[...Object.keys(O).filter(j=>j!=="boss"),...c.map(j=>j.id)];i.length>0&&I(i[Math.floor(Math.random()*i.length)])}}ne.current=d},[d,b,c]);const ve=t.useCallback(e=>{U(a=>{const l=new Set(a);return l.has(e)?l.delete(e):l.add(e),l})},[]),o=t.useMemo(()=>c.find(e=>e.id===r),[c,r]),Ce=t.useMemo(()=>{if(o!=null&&o.model)return o.model},[o]),ke=t.useMemo(()=>{if(o!=null&&o.customModelPath)return Fe(`/api/custom-models/${o.id}`)},[o]),Me=o==null?void 0:o.modelScale,ye=t.useMemo(()=>o?"scout":r==="boss"?"architect":r,[r,o]);t.useEffect(()=>{if(!d||!N)return;const e=v.getState().areas.get(N);if(e!=null&&e.directories&&e.directories.length>0){P(e.directories[0]);return}const a=Array.from(v.getState().agents.values()).filter(w=>{var M;return((M=v.getAreaForAgent(w.id))==null?void 0:M.id)===N&&w.cwd});if(a.length===0)return;const l=new Map;for(const w of a)l.set(w.cwd,(l.get(w.cwd)||0)+1);let i="",j=0;for(const[w,M]of l)M>j&&(i=w,j=M);i&&P(i)},[d,N]);const te=t.useMemo(()=>Array.from(J.values()).filter(e=>!e.isBoss&&e.class!=="boss"&&!e.bossId),[J]),ie=t.useMemo(()=>{if(!h.trim())return c;const e=h.toLowerCase();return c.filter(a=>a.name.toLowerCase().includes(e)||a.description.toLowerCase().includes(e)||a.id.toLowerCase().includes(e))},[c,h]),ce=t.useMemo(()=>{if(!h.trim())return W;const e=h.toLowerCase();return W.filter(a=>{const l=de[a.id];return l?a.name.toLowerCase().includes(e)||a.id.toLowerCase().includes(e)||l.description.toLowerCase().includes(e):!1})},[h]),oe=t.useMemo(()=>{if(!h.trim())return!0;const e=h.toLowerCase(),a=O.boss;return"boss".includes(e)||a.description.toLowerCase().includes(e)},[h]);t.useEffect(()=>{if(d&&!q.current){q.current=!0;const e=new Set(Array.from(v.getState().agents.values()).map(l=>l.name)),a=c.find(l=>l.id===r);if(a){const l=C.filter(i=>!e.has(`${a.name} ${i}`));if(l.length===0){const i=C[Math.floor(Math.random()*C.length)];p(`${a.name} ${i}-${Date.now()%1e3}`)}else p(`${a.name} ${l[Math.floor(Math.random()*l.length)]}`)}else p(ue(e));D(new Set),B.current&&(B.current.focus(),B.current.select())}else d||(q.current=!1)},[d]),t.useEffect(()=>{if(!d)return;const e=c.find(a=>a.id===r);if(e)if(u.startsWith("Boss ")){const a=u.substring(5);p(`${e.name} ${a}`)}else{const a=c.find(l=>u.startsWith(l.name+" "));if(a){const l=u.substring(a.name.length+1);p(`${e.name} ${l}`)}else p(`${e.name} ${u}`)}else{const a=c.find(l=>u.startsWith(l.name+" "));if(a){const l=u.substring(a.name.length+1);p(`Boss ${l}`)}else u.startsWith("Boss ")||p(`Boss ${u}`)}},[r]);const Ae=()=>{if(_(!1),!L.trim()){_(!0);return}if(!u.trim()){const l=new Set(Array.from(v.getState().agents.values()).map(i=>i.name));p(ue(l));return}Ue(G.LAST_CWD,L),E(),window.__spawnModalAreaContext=N?{areaId:N}:null;const e=ae.trim()||void 0,a=Array.from(se);v.spawnBossAgent(u.trim(),r,L.trim(),me||void 0,Array.from(k),m==="claude"?Y:!1,Q,m,m==="codex"?f:void 0,m==="codex"?ee:void 0,m==="claude"?Z:void 0,e,a),p(""),D(new Set),U(new Set),F(),x()},Ee=()=>{V(!1),p(""),D(new Set),F(),x()},$e=()=>{V(!1),_(!0),F()};t.useEffect(()=>(window.__bossSpawnModalSuccess=Ee,window.__bossSpawnModalError=$e,()=>{delete window.__bossSpawnModalSuccess,delete window.__bossSpawnModalError}),[u]);const Le=e=>{e.target===e.currentTarget&&x()},Ie=e=>{e.key==="Escape"&&x()},_e=e=>{const a=new Set(k);a.has(e)?a.delete(e):a.add(e),D(a)};if(!d)return null;const De=O.boss;return s.jsx("div",{className:`modal-overlay ${d?"visible":""}`,onClick:Le,onKeyDown:Ie,children:s.jsxs("div",{className:"modal boss-spawn-modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx(y,{classId:"boss",size:22,className:"boss-header-icon"}),n("terminal:spawn.deployBossTitle")]}),s.jsxs("div",{className:"modal-body spawn-modal-body",children:[s.jsxs("div",{className:"spawn-top-section",children:[s.jsx("div",{className:"spawn-preview-compact",children:s.jsx(Pe,{agentClass:ye,modelFile:Ce,customModelUrl:ke,modelScale:Me,width:100,height:120})}),s.jsxs("div",{className:"spawn-class-section",children:[s.jsx("div",{className:"spawn-class-label",children:n("terminal:spawn.bossClass")}),c.length+W.length+1>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:n("terminal:spawn.filterClasses"),value:h,onChange:e=>be(e.target.value)}),s.jsxs("div",{className:"class-selector-inline",children:[ie.map(e=>s.jsxs("button",{className:`class-chip ${r===e.id?"selected":""}`,onClick:()=>I(e.id),title:e.description,children:[s.jsx(y,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)),oe&&s.jsxs("button",{className:`class-chip ${r==="boss"?"selected":""}`,onClick:()=>I("boss"),title:De.description,children:[s.jsx(y,{classId:"boss",size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:n("terminal:spawn.bossClassName")})]}),ce.map(e=>{const a=de[e.id];return a?s.jsxs("button",{className:`class-chip ${r===e.id?"selected":""}`,onClick:()=>I(e.id),title:a.description,children:[s.jsx(y,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id):null}),h&&ie.length===0&&!oe&&ce.length===0&&s.jsx("div",{className:"class-search-empty",children:n("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),s.jsxs("div",{className:"spawn-form-section",children:[s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.name")}),s.jsx("input",{ref:B,type:"text",className:"spawn-input",placeholder:n("terminal:spawn.bossNamePlaceholder"),value:u,onChange:e=>p(e.target.value)})]}),s.jsxs("div",{className:"spawn-field spawn-field-wide",children:[s.jsx("label",{className:"spawn-label",children:n("terminal:spawn.workingDir")}),s.jsx(ze,{value:L,onChange:e=>{P(e),_(!1)},placeholder:n("terminal:spawn.workingDirPlaceholder"),className:"spawn-input",hasError:pe,directoriesOnly:!0})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.runtime")}),s.jsxs("div",{className:"spawn-select-row",children:[s.jsxs("button",{className:`spawn-select-btn ${m==="claude"?"selected":""}`,onClick:()=>z("claude"),title:n("terminal:spawn.useClaudeCli"),children:[s.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),s.jsx("span",{children:"Claude"})]}),s.jsxs("button",{className:`spawn-select-btn ${m==="codex"?"selected":""}`,onClick:()=>z("codex"),title:n("terminal:spawn.useCodexCli"),children:[s.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),s.jsx("span",{children:"Codex"})]}),s.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${m==="opencode"?"selected":""}`,onClick:()=>z("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("span",{children:s.jsx(R,{name:"status-pending",size:14,weight:"fill",color:"#4ade80"})}),s.jsx("span",{children:"OpenCode"})]})]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.permissions")}),s.jsx("div",{className:"spawn-select-row",children:Object.keys(K).map(e=>s.jsxs("button",{className:`spawn-select-btn ${Q===e?"selected":""}`,onClick:()=>xe(e),title:K[e].description,children:[s.jsx("span",{children:s.jsx(R,{name:e==="bypass"?"bolt":"lock",size:14})}),s.jsx("span",{children:K[e].label})]},e))})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.model")}),m==="claude"?s.jsx("div",{className:"spawn-select-row",children:Object.keys(A).filter(e=>!A[e].deprecated).map(e=>s.jsxs("button",{className:`spawn-select-btn ${Z===e?"selected":""}`,onClick:()=>we(e),title:A[e].description,children:[s.jsx("span",{children:A[e].icon}),s.jsx("span",{children:A[e].label})]},e))}):m==="codex"?s.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(T).map(e=>s.jsxs("button",{className:`spawn-select-btn ${ee===e?"selected":""}`,onClick:()=>fe(e),title:T[e].description,children:[s.jsx("span",{children:T[e].icon}),s.jsx("span",{children:T[e].label})]},e))}):m==="opencode"?s.jsx("input",{type:"text",className:"spawn-input",defaultValue:"minimax/MiniMax-M1-80k",placeholder:"provider/model (e.g., minimax/MiniMax-M1-80k)"}):s.jsx("div",{className:"spawn-inline-hint",children:n("terminal:spawn.codex.configuration")})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.browser")}),s.jsx("div",{className:"spawn-form-row spawn-options-row",children:s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:Y,onChange:e=>he(e.target.checked),disabled:m!=="claude"}),s.jsx("span",{children:n("terminal:spawn.chromeBrowser")})]})})]})]}),m==="codex"&&s.jsx("div",{className:"spawn-form-row",children:s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("terminal:spawn.codex.config")}),s.jsxs("div",{className:"spawn-options-row",style:{display:"flex",flexDirection:"column",gap:8},children:[s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:e=>g(a=>({...a,fullAuto:e.target.checked}))}),s.jsx("span",{children:n("terminal:spawn.codex.useFullAuto")})]}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:!!f.search,onChange:e=>g(a=>({...a,search:e.target.checked}))}),s.jsx("span",{children:n("terminal:spawn.codex.enableSearch")})]}),f.fullAuto===!1&&s.jsxs(s.Fragment,{children:[s.jsxs("select",{className:"spawn-input",value:f.sandbox||"workspace-write",onChange:e=>g(a=>({...a,sandbox:e.target.value})),children:[s.jsx("option",{value:"read-only",children:n("terminal:spawn.codex.sandboxReadOnly")}),s.jsx("option",{value:"workspace-write",children:n("terminal:spawn.codex.sandboxWorkspaceWrite")}),s.jsx("option",{value:"danger-full-access",children:n("terminal:spawn.codex.sandboxDangerFullAccess")})]}),s.jsxs("select",{className:"spawn-input",value:f.approvalMode||"on-request",onChange:e=>g(a=>({...a,approvalMode:e.target.value})),children:[s.jsx("option",{value:"untrusted",children:n("terminal:spawn.codex.approvalsUntrusted")}),s.jsx("option",{value:"on-failure",children:n("terminal:spawn.codex.approvalsOnFailure")}),s.jsx("option",{value:"on-request",children:n("terminal:spawn.codex.approvalsOnRequest")}),s.jsx("option",{value:"never",children:n("terminal:spawn.codex.approvalsNever")})]})]}),s.jsx("input",{type:"text",className:"spawn-input",placeholder:n("terminal:spawn.codex.profileOptional"),value:f.profile||"",onChange:e=>g(a=>({...a,profile:e.target.value||void 0}))}),s.jsxs("select",{className:"spawn-input",value:f.reasoningEffort||"",onChange:e=>g(a=>({...a,reasoningEffort:e.target.value||void 0})),children:[s.jsx("option",{value:"",children:n("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(H).map(e=>s.jsxs("option",{value:e,children:[H[e].icon," ",n("terminal:spawn.codex.reasoningEffort"),": ",H[e].label]},e))]})]})]})}),b.length>0&&s.jsxs("div",{className:"spawn-skills-section",children:[s.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.skills")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]})]}),b.length>6&&s.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:n("terminal:spawn.filterSkills"),value:S,onChange:e=>je(e.target.value)}),s.jsxs("div",{className:"spawn-skills-inline",children:[le.map(e=>{const a=se.has(e.id);return ge.some(i=>i.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${a?"selected":""}`,onClick:()=>ve(e.id),title:e.description,children:[a&&s.jsx("span",{className:"spawn-skill-check",children:s.jsx(R,{name:"check",size:12})}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),S&&le.length===0&&s.jsx("div",{className:"skill-search-empty",children:n("terminal:spawn.noSkillsMatch",{query:S})})]})]}),s.jsxs("div",{className:"spawn-custom-instructions-section",children:[s.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.customInstructions")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]})]}),s.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:n("terminal:spawn.customInstructionsBossPlaceholder"),value:ae,onChange:e=>Ne(e.target.value),rows:3})]}),s.jsxs("div",{className:"spawn-subordinates-section",children:[s.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.initialSubordinates")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]})]}),s.jsx("div",{className:"subordinates-selector-compact",children:te.length===0?s.jsx("div",{className:"subordinates-empty",children:n("terminal:spawn.noAvailableAgents")}):te.map(e=>{const a=k.has(e.id),l=O[e.class],i=c.find(w=>w.id===e.class),j=l||i||{color:"#888888"};return s.jsxs("button",{className:`subordinate-chip ${a?"selected":""}`,onClick:()=>_e(e.id),children:[a&&s.jsx("span",{className:"subordinate-check",children:s.jsx(R,{name:"check",size:12})}),s.jsx("span",{className:"subordinate-chip-icon",style:{color:j.color},children:s.jsx(y,{classId:e.class,size:16})}),s.jsx("span",{className:"subordinate-chip-name",children:e.name})]},e.id)})}),k.size>0&&s.jsxs("div",{className:"subordinates-count",children:[k.size," ",n("common:labels.selected").toLowerCase()]})]})]})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:x,children:n("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-boss",onClick:Ae,disabled:X,children:n(X?"common:buttons.deploying":"common:buttons2.deployBoss")})]})]})})}export{Ke as BossSpawnModal};
1
+ import{u as Be,aj as Oe,aH as Re,aG as Te,r as t,J as re,S as G,aT as O,l as Fe,s as v,aK as W,A as de,aU as C,j as s,_ as y,aM as Pe,aO as ze,I as R,aP as K,as as A,aq as T,aR as H,K as Ue}from"./main-3di6rXWx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function ue(d){const x=C.filter(E=>!d.has(`Boss ${E}`));return x.length===0?`Boss ${C[Math.floor(Math.random()*C.length)]}-${Date.now()%1e3}`:`Boss ${x[Math.floor(Math.random()*x.length)]}`}function Ke({isOpen:d,onClose:x,onSpawnStart:E,onSpawnEnd:F,spawnPosition:me,spawnAreaId:N}){const{t:n}=Be(["terminal","common"]),J=Oe(),c=Re(),$=Te(),[u,p]=t.useState(""),[L,P]=t.useState(()=>re(G.LAST_CWD)),[r,I]=t.useState("boss"),[X,V]=t.useState(!1),[pe,_]=t.useState(!1),[Y,he]=t.useState(!0),[Q,xe]=t.useState("bypass"),[m,z]=t.useState("claude"),[f,g]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[Z,we]=t.useState("opus[1m]"),[ee,fe]=t.useState("gpt-5.3-codex"),[k,D]=t.useState(new Set),[se,U]=t.useState(new Set),[h,be]=t.useState(""),[S,je]=t.useState(""),[ae,Ne]=t.useState(""),B=t.useRef(null),q=t.useRef(!1),ne=t.useRef(!1),b=t.useMemo(()=>$.filter(e=>e.enabled),[$]),le=t.useMemo(()=>{if(!S.trim())return b;const e=S.toLowerCase();return b.filter(a=>a.name.toLowerCase().includes(e)||a.description.toLowerCase().includes(e)||a.slug.toLowerCase().includes(e))},[b,S]),ge=t.useMemo(()=>{var a;const e=c.find(l=>l.id===r);return(a=e==null?void 0:e.defaultSkillIds)!=null&&a.length?$.filter(l=>e.defaultSkillIds.includes(l.id)):[]},[c,r,$]),Se=["full-notifications","streaming-exec","task-label","report-task-to-boss","send-message-to-agent"];t.useEffect(()=>{if(d&&!ne.current){if(b.length>0){const l=b.filter(i=>Se.includes(i.slug)).map(i=>i.id);l.length>0&&U(new Set(l))}if(re(G.DEFAULT_AGENT_CLASS)==="random"){const i=[...Object.keys(O).filter(j=>j!=="boss"),...c.map(j=>j.id)];i.length>0&&I(i[Math.floor(Math.random()*i.length)])}}ne.current=d},[d,b,c]);const ve=t.useCallback(e=>{U(a=>{const l=new Set(a);return l.has(e)?l.delete(e):l.add(e),l})},[]),o=t.useMemo(()=>c.find(e=>e.id===r),[c,r]),Ce=t.useMemo(()=>{if(o!=null&&o.model)return o.model},[o]),ke=t.useMemo(()=>{if(o!=null&&o.customModelPath)return Fe(`/api/custom-models/${o.id}`)},[o]),Me=o==null?void 0:o.modelScale,ye=t.useMemo(()=>o?"scout":r==="boss"?"architect":r,[r,o]);t.useEffect(()=>{if(!d||!N)return;const e=v.getState().areas.get(N);if(e!=null&&e.directories&&e.directories.length>0){P(e.directories[0]);return}const a=Array.from(v.getState().agents.values()).filter(w=>{var M;return((M=v.getAreaForAgent(w.id))==null?void 0:M.id)===N&&w.cwd});if(a.length===0)return;const l=new Map;for(const w of a)l.set(w.cwd,(l.get(w.cwd)||0)+1);let i="",j=0;for(const[w,M]of l)M>j&&(i=w,j=M);i&&P(i)},[d,N]);const te=t.useMemo(()=>Array.from(J.values()).filter(e=>!e.isBoss&&e.class!=="boss"&&!e.bossId),[J]),ie=t.useMemo(()=>{if(!h.trim())return c;const e=h.toLowerCase();return c.filter(a=>a.name.toLowerCase().includes(e)||a.description.toLowerCase().includes(e)||a.id.toLowerCase().includes(e))},[c,h]),ce=t.useMemo(()=>{if(!h.trim())return W;const e=h.toLowerCase();return W.filter(a=>{const l=de[a.id];return l?a.name.toLowerCase().includes(e)||a.id.toLowerCase().includes(e)||l.description.toLowerCase().includes(e):!1})},[h]),oe=t.useMemo(()=>{if(!h.trim())return!0;const e=h.toLowerCase(),a=O.boss;return"boss".includes(e)||a.description.toLowerCase().includes(e)},[h]);t.useEffect(()=>{if(d&&!q.current){q.current=!0;const e=new Set(Array.from(v.getState().agents.values()).map(l=>l.name)),a=c.find(l=>l.id===r);if(a){const l=C.filter(i=>!e.has(`${a.name} ${i}`));if(l.length===0){const i=C[Math.floor(Math.random()*C.length)];p(`${a.name} ${i}-${Date.now()%1e3}`)}else p(`${a.name} ${l[Math.floor(Math.random()*l.length)]}`)}else p(ue(e));D(new Set),B.current&&(B.current.focus(),B.current.select())}else d||(q.current=!1)},[d]),t.useEffect(()=>{if(!d)return;const e=c.find(a=>a.id===r);if(e)if(u.startsWith("Boss ")){const a=u.substring(5);p(`${e.name} ${a}`)}else{const a=c.find(l=>u.startsWith(l.name+" "));if(a){const l=u.substring(a.name.length+1);p(`${e.name} ${l}`)}else p(`${e.name} ${u}`)}else{const a=c.find(l=>u.startsWith(l.name+" "));if(a){const l=u.substring(a.name.length+1);p(`Boss ${l}`)}else u.startsWith("Boss ")||p(`Boss ${u}`)}},[r]);const Ae=()=>{if(_(!1),!L.trim()){_(!0);return}if(!u.trim()){const l=new Set(Array.from(v.getState().agents.values()).map(i=>i.name));p(ue(l));return}Ue(G.LAST_CWD,L),E(),window.__spawnModalAreaContext=N?{areaId:N}:null;const e=ae.trim()||void 0,a=Array.from(se);v.spawnBossAgent(u.trim(),r,L.trim(),me||void 0,Array.from(k),m==="claude"?Y:!1,Q,m,m==="codex"?f:void 0,m==="codex"?ee:void 0,m==="claude"?Z:void 0,e,a),p(""),D(new Set),U(new Set),F(),x()},Ee=()=>{V(!1),p(""),D(new Set),F(),x()},$e=()=>{V(!1),_(!0),F()};t.useEffect(()=>(window.__bossSpawnModalSuccess=Ee,window.__bossSpawnModalError=$e,()=>{delete window.__bossSpawnModalSuccess,delete window.__bossSpawnModalError}),[u]);const Le=e=>{e.target===e.currentTarget&&x()},Ie=e=>{e.key==="Escape"&&x()},_e=e=>{const a=new Set(k);a.has(e)?a.delete(e):a.add(e),D(a)};if(!d)return null;const De=O.boss;return s.jsx("div",{className:`modal-overlay ${d?"visible":""}`,onClick:Le,onKeyDown:Ie,children:s.jsxs("div",{className:"modal boss-spawn-modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx(y,{classId:"boss",size:22,className:"boss-header-icon"}),n("terminal:spawn.deployBossTitle")]}),s.jsxs("div",{className:"modal-body spawn-modal-body",children:[s.jsxs("div",{className:"spawn-top-section",children:[s.jsx("div",{className:"spawn-preview-compact",children:s.jsx(Pe,{agentClass:ye,modelFile:Ce,customModelUrl:ke,modelScale:Me,width:100,height:120})}),s.jsxs("div",{className:"spawn-class-section",children:[s.jsx("div",{className:"spawn-class-label",children:n("terminal:spawn.bossClass")}),c.length+W.length+1>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:n("terminal:spawn.filterClasses"),value:h,onChange:e=>be(e.target.value)}),s.jsxs("div",{className:"class-selector-inline",children:[ie.map(e=>s.jsxs("button",{className:`class-chip ${r===e.id?"selected":""}`,onClick:()=>I(e.id),title:e.description,children:[s.jsx(y,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)),oe&&s.jsxs("button",{className:`class-chip ${r==="boss"?"selected":""}`,onClick:()=>I("boss"),title:De.description,children:[s.jsx(y,{classId:"boss",size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:n("terminal:spawn.bossClassName")})]}),ce.map(e=>{const a=de[e.id];return a?s.jsxs("button",{className:`class-chip ${r===e.id?"selected":""}`,onClick:()=>I(e.id),title:a.description,children:[s.jsx(y,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id):null}),h&&ie.length===0&&!oe&&ce.length===0&&s.jsx("div",{className:"class-search-empty",children:n("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),s.jsxs("div",{className:"spawn-form-section",children:[s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.name")}),s.jsx("input",{ref:B,type:"text",className:"spawn-input",placeholder:n("terminal:spawn.bossNamePlaceholder"),value:u,onChange:e=>p(e.target.value)})]}),s.jsxs("div",{className:"spawn-field spawn-field-wide",children:[s.jsx("label",{className:"spawn-label",children:n("terminal:spawn.workingDir")}),s.jsx(ze,{value:L,onChange:e=>{P(e),_(!1)},placeholder:n("terminal:spawn.workingDirPlaceholder"),className:"spawn-input",hasError:pe,directoriesOnly:!0})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.runtime")}),s.jsxs("div",{className:"spawn-select-row",children:[s.jsxs("button",{className:`spawn-select-btn ${m==="claude"?"selected":""}`,onClick:()=>z("claude"),title:n("terminal:spawn.useClaudeCli"),children:[s.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),s.jsx("span",{children:"Claude"})]}),s.jsxs("button",{className:`spawn-select-btn ${m==="codex"?"selected":""}`,onClick:()=>z("codex"),title:n("terminal:spawn.useCodexCli"),children:[s.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),s.jsx("span",{children:"Codex"})]}),s.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${m==="opencode"?"selected":""}`,onClick:()=>z("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("span",{children:s.jsx(R,{name:"status-pending",size:14,weight:"fill",color:"#4ade80"})}),s.jsx("span",{children:"OpenCode"})]})]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.permissions")}),s.jsx("div",{className:"spawn-select-row",children:Object.keys(K).map(e=>s.jsxs("button",{className:`spawn-select-btn ${Q===e?"selected":""}`,onClick:()=>xe(e),title:K[e].description,children:[s.jsx("span",{children:s.jsx(R,{name:e==="bypass"?"bolt":"lock",size:14})}),s.jsx("span",{children:K[e].label})]},e))})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.model")}),m==="claude"?s.jsx("div",{className:"spawn-select-row",children:Object.keys(A).filter(e=>!A[e].deprecated).map(e=>s.jsxs("button",{className:`spawn-select-btn ${Z===e?"selected":""}`,onClick:()=>we(e),title:A[e].description,children:[s.jsx("span",{children:A[e].icon}),s.jsx("span",{children:A[e].label})]},e))}):m==="codex"?s.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(T).map(e=>s.jsxs("button",{className:`spawn-select-btn ${ee===e?"selected":""}`,onClick:()=>fe(e),title:T[e].description,children:[s.jsx("span",{children:T[e].icon}),s.jsx("span",{children:T[e].label})]},e))}):m==="opencode"?s.jsx("input",{type:"text",className:"spawn-input",defaultValue:"minimax/MiniMax-M1-80k",placeholder:"provider/model (e.g., minimax/MiniMax-M1-80k)"}):s.jsx("div",{className:"spawn-inline-hint",children:n("terminal:spawn.codex.configuration")})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.browser")}),s.jsx("div",{className:"spawn-form-row spawn-options-row",children:s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:Y,onChange:e=>he(e.target.checked),disabled:m!=="claude"}),s.jsx("span",{children:n("terminal:spawn.chromeBrowser")})]})})]})]}),m==="codex"&&s.jsx("div",{className:"spawn-form-row",children:s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("terminal:spawn.codex.config")}),s.jsxs("div",{className:"spawn-options-row",style:{display:"flex",flexDirection:"column",gap:8},children:[s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:e=>g(a=>({...a,fullAuto:e.target.checked}))}),s.jsx("span",{children:n("terminal:spawn.codex.useFullAuto")})]}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:!!f.search,onChange:e=>g(a=>({...a,search:e.target.checked}))}),s.jsx("span",{children:n("terminal:spawn.codex.enableSearch")})]}),f.fullAuto===!1&&s.jsxs(s.Fragment,{children:[s.jsxs("select",{className:"spawn-input",value:f.sandbox||"workspace-write",onChange:e=>g(a=>({...a,sandbox:e.target.value})),children:[s.jsx("option",{value:"read-only",children:n("terminal:spawn.codex.sandboxReadOnly")}),s.jsx("option",{value:"workspace-write",children:n("terminal:spawn.codex.sandboxWorkspaceWrite")}),s.jsx("option",{value:"danger-full-access",children:n("terminal:spawn.codex.sandboxDangerFullAccess")})]}),s.jsxs("select",{className:"spawn-input",value:f.approvalMode||"on-request",onChange:e=>g(a=>({...a,approvalMode:e.target.value})),children:[s.jsx("option",{value:"untrusted",children:n("terminal:spawn.codex.approvalsUntrusted")}),s.jsx("option",{value:"on-failure",children:n("terminal:spawn.codex.approvalsOnFailure")}),s.jsx("option",{value:"on-request",children:n("terminal:spawn.codex.approvalsOnRequest")}),s.jsx("option",{value:"never",children:n("terminal:spawn.codex.approvalsNever")})]})]}),s.jsx("input",{type:"text",className:"spawn-input",placeholder:n("terminal:spawn.codex.profileOptional"),value:f.profile||"",onChange:e=>g(a=>({...a,profile:e.target.value||void 0}))}),s.jsxs("select",{className:"spawn-input",value:f.reasoningEffort||"",onChange:e=>g(a=>({...a,reasoningEffort:e.target.value||void 0})),children:[s.jsx("option",{value:"",children:n("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(H).map(e=>s.jsxs("option",{value:e,children:[H[e].icon," ",n("terminal:spawn.codex.reasoningEffort"),": ",H[e].label]},e))]})]})]})}),b.length>0&&s.jsxs("div",{className:"spawn-skills-section",children:[s.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.skills")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]})]}),b.length>6&&s.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:n("terminal:spawn.filterSkills"),value:S,onChange:e=>je(e.target.value)}),s.jsxs("div",{className:"spawn-skills-inline",children:[le.map(e=>{const a=se.has(e.id);return ge.some(i=>i.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${a?"selected":""}`,onClick:()=>ve(e.id),title:e.description,children:[a&&s.jsx("span",{className:"spawn-skill-check",children:s.jsx(R,{name:"check",size:12})}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),S&&le.length===0&&s.jsx("div",{className:"skill-search-empty",children:n("terminal:spawn.noSkillsMatch",{query:S})})]})]}),s.jsxs("div",{className:"spawn-custom-instructions-section",children:[s.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.customInstructions")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]})]}),s.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:n("terminal:spawn.customInstructionsBossPlaceholder"),value:ae,onChange:e=>Ne(e.target.value),rows:3})]}),s.jsxs("div",{className:"spawn-subordinates-section",children:[s.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.initialSubordinates")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]})]}),s.jsx("div",{className:"subordinates-selector-compact",children:te.length===0?s.jsx("div",{className:"subordinates-empty",children:n("terminal:spawn.noAvailableAgents")}):te.map(e=>{const a=k.has(e.id),l=O[e.class],i=c.find(w=>w.id===e.class),j=l||i||{color:"#888888"};return s.jsxs("button",{className:`subordinate-chip ${a?"selected":""}`,onClick:()=>_e(e.id),children:[a&&s.jsx("span",{className:"subordinate-check",children:s.jsx(R,{name:"check",size:12})}),s.jsx("span",{className:"subordinate-chip-icon",style:{color:j.color},children:s.jsx(y,{classId:e.class,size:16})}),s.jsx("span",{className:"subordinate-chip-name",children:e.name})]},e.id)})}),k.size>0&&s.jsxs("div",{className:"subordinates-count",children:[k.size," ",n("common:labels.selected").toLowerCase()]})]})]})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:x,children:n("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-boss",onClick:Ae,disabled:X,children:n(X?"common:buttons.deploying":"common:buttons2.deployBoss")})]})]})})}export{Ke as BossSpawnModal};
@@ -1 +1 @@
1
- import{u as K,f as H,b_ as Z,b$ as Q,r as m,ad as J,h as ee,bZ as D,c0 as V,c1 as se,j as e,c2 as te,C as ae,s as y,c3 as G,c4 as U}from"./main-BA8NAb8s.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const W={global:"terminal:controls.contextGlobal",commander:"terminal:controls.contextCommander",toolbox:"terminal:controls.contextToolbox"},ne={global:"terminal:controls.contextGlobalDesc",commander:"terminal:controls.contextCommanderDesc",toolbox:"terminal:controls.contextToolboxDesc"},Y={camera:["camera-pan","camera-orbit","camera-rotate","camera-zoom","camera-tilt"],interaction:["primary-action","selection-box","context-menu","move-command"]},re={camera:"terminal:controls.cameraControls",interaction:"terminal:controls.interaction"};function ue({isOpen:s,onClose:r}){const{t:a}=K(["terminal","common"]),l=H(),o=Z(),h=Q(),[x,b]=m.useState("keyboard"),[j,g]=m.useState(""),[p,C]=m.useState("all"),[d,f]=m.useState(!1),[c,v]=m.useState(null),u=J.useRef(null),{handleMouseDown:P,handleClick:S}=ee(r);if(m.useEffect(()=>{if(!s||d)return;const t=n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),r())};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[s,r,d]),m.useEffect(()=>{s||(g(""),f(!1),v(null))},[s]),m.useEffect(()=>{if(!s||!d)return;const t=n=>{if(n.key==="Escape"){n.preventDefault(),n.stopPropagation(),f(!1),v(null);return}if(["Control","Alt","Shift","Meta"].includes(n.key))return;n.preventDefault(),n.stopPropagation();let i=n.key;n.code.startsWith("Key")&&n.code.length===4?i=n.code.charAt(3).toLowerCase():n.code.startsWith("Digit")&&n.code.length===6?i=n.code.charAt(5):n.code==="Space"&&(i="Space"),v({key:i,modifiers:{ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey,meta:n.metaKey}})};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[s,d]),!s)return null;const F=l.shortcuts.filter(t=>{const n=a(`terminal:controls.shortcuts.${t.id}.name`,{defaultValue:t.name}),i=a(`terminal:controls.shortcuts.${t.id}.description`,{defaultValue:t.description});if(d&&c){const R=w=>w===" "||w==="Space"?"Space":w.length===1?w.toLowerCase():w,B=R(t.key),L=R(c.key);if(!(L.length===1&&/^[a-zA-Z]$/.test(B)?`Key${B.toUpperCase()}`==`Key${L.toUpperCase()}`:B===L))return!1;const M=t.modifiers,T=c.modifiers;return(M.ctrl||!1)===(T.ctrl||!1)&&(M.alt||!1)===(T.alt||!1)&&(M.shift||!1)===(T.shift||!1)&&(M.meta||!1)===(T.meta||!1)}if(!j)return!0;const k=j.toLowerCase();return n.toLowerCase().includes(k)||i.toLowerCase().includes(k)||D(t).toLowerCase().includes(k)}),E=Array.from(l.agents.values()).map(t=>t).filter(t=>t.shortcut&&t.shortcut.trim().length>0).filter(t=>{const n=V(t.shortcut).toLowerCase();if(d&&c){const k={key:c.key,code:c.key.length===1&&/^[a-zA-Z]$/.test(c.key)?`Key${c.key.toUpperCase()}`:c.key.length===1&&/^[0-9]$/.test(c.key)?`Digit${c.key}`:c.key==="Space"?"Space":c.key,ctrlKey:!!c.modifiers.ctrl,altKey:!!c.modifiers.alt,shiftKey:!!c.modifiers.shift,metaKey:!!c.modifiers.meta};return se(k,t.shortcut)}if(!j)return!0;const i=j.toLowerCase();return t.name.toLowerCase().includes(i)||n.toLowerCase().includes(i)}),O=F.reduce((t,n)=>(t[n.context]||(t[n.context]=[]),t[n.context].push(n),t),{}),_=(t,n)=>{y.updateShortcut(t,n)},[N,z]=m.useState(null),$=()=>{z(x)},I=()=>{N==="keyboard"?y.resetShortcuts():(N==="mouse"||N==="trackpad")&&y.resetMouseControls()},X=N==="keyboard"?"terminal:controls.confirmResetKeyboard":N==="mouse"?"terminal:controls.confirmResetMouse":"terminal:controls.confirmResetTrackpad",A=["global","commander","toolbox"],q=o.bindings.reduce((t,n)=>(Y.camera.includes(n.action)?t.camera.push(n):Y.interaction.includes(n.action)&&t.interaction.push(n),t),{camera:[],interaction:[]});return e.jsxs("div",{className:"shortcuts-modal-overlay",onMouseDown:P,onClick:S,children:[e.jsxs("div",{className:"shortcuts-modal controls-modal",children:[e.jsxs("div",{className:"shortcuts-modal-header",children:[e.jsxs("div",{className:"shortcuts-modal-title",children:[e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),e.jsx("span",{children:a("terminal:controls.title")})]}),e.jsx("button",{className:"shortcuts-modal-close",onClick:r,children:"×"})]}),e.jsxs("div",{className:"controls-main-tabs",children:[e.jsxs("button",{className:`controls-main-tab ${x==="keyboard"?"active":""}`,onClick:()=>b("keyboard"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M6 12h.01M18 12h.01M8 16h8"})]}),a("terminal:controls.keyboard")]}),e.jsxs("button",{className:`controls-main-tab ${x==="mouse"?"active":""}`,onClick:()=>b("mouse"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"6",y:"3",width:"12",height:"18",rx:"6"}),e.jsx("line",{x1:"12",y1:"7",x2:"12",y2:"11"})]}),a("terminal:controls.mouse")]}),e.jsxs("button",{className:`controls-main-tab ${x==="trackpad"?"active":""}`,onClick:()=>b("trackpad"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),a("terminal:controls.trackpad")]})]}),x==="keyboard"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[d?e.jsxs("div",{className:"shortcuts-search find-by-shortcut-active",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M6 12h.01M18 12h.01M8 16h8"})]}),c?e.jsxs("span",{className:"find-by-shortcut-display",children:[D({key:c.key,modifiers:c.modifiers}),e.jsx("button",{className:"shortcuts-search-clear",onClick:()=>v(null),children:"×"})]}):e.jsx("span",{className:"find-by-shortcut-prompt",children:a("terminal:controls.pressKeyCombination")})]}):e.jsxs("div",{className:"shortcuts-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:u,type:"text",placeholder:a("terminal:controls.searchShortcuts"),value:j,onChange:t=>g(t.target.value),autoFocus:!0}),j&&e.jsx("button",{className:"shortcuts-search-clear",onClick:()=>g(""),children:"×"})]}),e.jsx("button",{className:`shortcuts-find-by-key-btn ${d?"active":""}`,onClick:()=>{f(!d),v(null),g("")},title:a(d?"terminal:controls.switchToTextSearch":"terminal:controls.findByPressingKeys"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M6 12h.01M18 12h.01M8 16h8"})]})}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:$,children:a("common:buttons.reset")})]}),e.jsxs("div",{className:"shortcuts-context-tabs",children:[e.jsxs("button",{className:`shortcuts-context-tab ${p==="all"?"active":""}`,onClick:()=>C("all"),children:[a("common:labels.all"),e.jsx("span",{className:"shortcuts-context-tab-count",children:F.length})]}),A.map(t=>{var i;const n=((i=O[t])==null?void 0:i.length)||0;return e.jsxs("button",{className:`shortcuts-context-tab ${p===t?"active":""}`,onClick:()=>C(t),children:[a(W[t]),e.jsx("span",{className:"shortcuts-context-tab-count",children:n})]},t)})]}),e.jsxs("div",{className:"shortcuts-modal-content",children:[A.map(t=>{const n=O[t]||[];return n.length===0||p!=="all"&&p!==t?null:e.jsxs("div",{className:"shortcuts-context-group",children:[p==="all"&&e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:a(W[t])}),e.jsx("span",{className:"shortcuts-context-description",children:a(ne[t])})]}),e.jsx("div",{className:"shortcuts-grid",children:n.map(i=>e.jsxs("div",{className:"shortcut-item",children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:a(`terminal:controls.shortcuts.${i.id}.name`,{defaultValue:i.name})}),e.jsx("span",{className:"shortcut-item-description",children:a(`terminal:controls.shortcuts.${i.id}.description`,{defaultValue:i.description})})]}),e.jsx(te,{shortcut:i,onUpdate:k=>_(i.id,k)})]},i.id))})]},t)}),F.length===0&&E.length===0&&e.jsx("div",{className:"shortcuts-empty",children:d?c?e.jsx("p",{children:a("terminal:controls.noShortcutBoundTo",{keys:D({key:c.key,modifiers:c.modifiers})})}):e.jsx("p",{children:a("terminal:controls.pressKeyCombinationToFind")}):e.jsx("p",{children:a("terminal:controls.noShortcutsFound",{query:j})})}),E.length>0&&(p==="all"||p==="global")&&e.jsxs("div",{className:"shortcuts-context-group",children:[p==="all"&&e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:"Agent Terminal Shortcuts"}),e.jsx("span",{className:"shortcuts-context-description",children:"Per-agent global shortcuts that open the guake terminal"})]}),e.jsx("div",{className:"shortcuts-grid",children:E.map(t=>e.jsxs("div",{className:"shortcut-item",children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:t.name}),e.jsx("span",{className:"shortcut-item-description",children:"Open terminal for this agent"})]}),e.jsx("div",{className:"key-capture-container",children:e.jsx("button",{className:"key-capture-input disabled",disabled:!0,children:e.jsx("span",{className:"key-capture-value",children:V(t.shortcut)})})})]},t.id))})]})]})]}),x==="mouse"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[e.jsx("span",{className:"mouse-controls-subtitle",children:a("terminal:controls.cameraAndInteraction")}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:$,children:a("common:buttons.reset")})]}),e.jsxs("div",{className:"shortcuts-modal-content mouse-controls-content",children:[e.jsx("div",{className:"mouse-controls-bindings",children:Object.entries(q).map(([t,n])=>e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsx("div",{className:"shortcuts-context-header",children:e.jsx("span",{className:"shortcuts-context-label",children:a(re[t])})}),e.jsx("div",{className:"shortcuts-grid",children:n.map(i=>e.jsx(le,{binding:i},i.id))})]},t))}),e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:a("terminal:controls.sensitivity")}),e.jsx("span",{className:"shortcuts-context-description",children:a("terminal:controls.adjustCameraSpeed")})]}),e.jsx(oe,{sensitivity:o.sensitivity})]})]})]}),x==="trackpad"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[e.jsx("span",{className:"mouse-controls-subtitle",children:a("terminal:controls.trackpadGestureSettings")}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:$,children:a("common:buttons.reset")})]}),e.jsx("div",{className:"shortcuts-modal-content trackpad-controls-content",children:e.jsx(ce,{config:h})})]}),e.jsx("div",{className:"shortcuts-modal-footer",children:e.jsx("span",{className:"shortcuts-modal-hint",children:a(x==="keyboard"?d?"terminal:controls.hintFindByShortcut":"terminal:controls.hintKeyboard":x==="mouse"?"terminal:controls.hintMouse":"terminal:controls.hintTrackpad")})})]}),e.jsx(ae,{isOpen:N!==null,title:a("common:buttons.resetToDefaults"),message:a(X),confirmLabel:a("common:buttons.reset"),cancelLabel:a("common:buttons.cancel"),variant:"danger",onConfirm:I,onClose:()=>z(null)})]})}function le({binding:s}){const{t:r}=K(["terminal"]),a=Z(),[l,o]=m.useState(!1),[h,x]=m.useState(null);m.useEffect(()=>{if(!l)return;const d=u=>{u.preventDefault(),u.stopPropagation();const S={0:"left",1:"middle",2:"right",3:"back",4:"forward"}[u.button];S&&x({button:S,modifiers:{ctrl:u.ctrlKey,alt:u.altKey,shift:u.shiftKey,meta:u.metaKey}})},f=u=>{u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),o(!1),x(null))},c=()=>{h&&G(a.bindings,h,s.id).length===0&&y.updateMouseBinding(s.id,{button:h.button,modifiers:h.modifiers}),o(!1),x(null)},v=setTimeout(()=>{document.addEventListener("mousedown",d,!0),document.addEventListener("keydown",f,!0),document.addEventListener("click",c,!0)},100);return()=>{clearTimeout(v),document.removeEventListener("mousedown",d,!0),document.removeEventListener("keydown",f,!0),document.removeEventListener("click",c,!0)}},[l,h,s.id,a.bindings]);const b=h?G(a.bindings,h,s.id):[],j=r(`terminal:controls.mouseBindings.${s.id}.name`,{defaultValue:s.name}),g=r(`terminal:controls.mouseBindings.${s.id}.description`,{defaultValue:s.description}),p=d=>r(`terminal:controls.mouseButtons.${d}`,{defaultValue:d}),C=h?U({...s,...h},p):U(s,p);return e.jsxs("div",{className:`shortcut-item ${s.enabled?"":"disabled"}`,children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:j}),e.jsx("span",{className:"shortcut-item-description",children:g})]}),e.jsxs("div",{className:"key-capture-container",children:[e.jsx("button",{className:`key-capture-input ${l?"capturing":""} ${b.length>0?"conflict":""}`,onClick:()=>o(!0),children:l?h?e.jsx("span",{className:"key-capture-value",style:{color:"#f1fa8c"},children:C}):e.jsx("span",{style:{color:"#6272a4",fontStyle:"italic"},children:r("terminal:controls.clickToCapture")}):e.jsx("span",{className:"key-capture-value",children:C})}),b.length>0&&e.jsxs("span",{className:"key-capture-conflict",children:[r("terminal:controls.conflicts"),": ",b.map(d=>r(`terminal:controls.mouseBindings.${d.id}.name`,{defaultValue:d.name})).join(", ")]})]})]})}function oe({sensitivity:s}){const{t:r}=K(["terminal"]),a=m.useCallback((l,o)=>{y.updateCameraSensitivity({[l]:o})},[]);return e.jsxs("div",{className:"sensitivity-inline-settings",children:[e.jsxs("div",{className:"sensitivity-sliders",children:[e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.panSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.panSpeed,onChange:l=>a("panSpeed",parseFloat(l.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[s.panSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.orbitSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.orbitSpeed,onChange:l=>a("orbitSpeed",parseFloat(l.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[s.orbitSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.zoomSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.zoomSpeed,onChange:l=>a("zoomSpeed",parseFloat(l.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[s.zoomSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.smoothing")}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:s.smoothing,onChange:l=>a("smoothing",parseFloat(l.target.value))}),e.jsx("span",{className:"sensitivity-slider-value",children:s.smoothing.toFixed(1)})]})]}),e.jsxs("div",{className:"sensitivity-checkboxes-inline",children:[e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertPanX,onChange:l=>a("invertPanX",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertPanX")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertPanY,onChange:l=>a("invertPanY",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertPanY")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertOrbitX,onChange:l=>a("invertOrbitX",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertOrbitX")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertOrbitY,onChange:l=>a("invertOrbitY",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertOrbitY")})]})]})]})}function ce({config:s}){const{t:r}=K(["terminal"]),a=m.useCallback((o,h)=>{y.updateTrackpadConfig({[o]:h})},[]),l=m.useCallback((o,h)=>{y.updateTrackpadConfig({sensitivity:{[o]:h}})},[]);return e.jsxs("div",{className:"trackpad-settings",children:[e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:r("terminal:controls.trackpadGestures")}),e.jsx("span",{className:"shortcuts-context-description",children:r("terminal:controls.enableTrackpadSupport")})]}),e.jsx("div",{className:"trackpad-toggle-row",children:e.jsxs("label",{className:"trackpad-toggle",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:o=>a("enabled",o.target.checked)}),e.jsx("span",{className:"trackpad-toggle-label",children:r("terminal:controls.enableTrackpadGestures")})]})})]}),e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:r("terminal:controls.gestureControls")}),e.jsx("span",{className:"shortcuts-context-description",children:r("terminal:controls.enableDisableGestures")})]}),e.jsxs("div",{className:"trackpad-gestures-grid",children:[e.jsxs("label",{className:`trackpad-gesture-item ${s.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:s.pinchToZoom,onChange:o=>a("pinchToZoom",o.target.checked),disabled:!s.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:r("terminal:controls.pinchToZoom")}),e.jsx("span",{className:"trackpad-gesture-desc",children:r("terminal:controls.pinchToZoomDesc")})]})]}),e.jsxs("label",{className:`trackpad-gesture-item ${s.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:s.twoFingerPan,onChange:o=>a("twoFingerPan",o.target.checked),disabled:!s.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:r("terminal:controls.twoFingerPan")}),e.jsx("span",{className:"trackpad-gesture-desc",children:r("terminal:controls.twoFingerPanDesc")})]})]}),e.jsxs("label",{className:`trackpad-gesture-item ${s.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:s.shiftTwoFingerOrbit,onChange:o=>a("shiftTwoFingerOrbit",o.target.checked),disabled:!s.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:r("terminal:controls.shiftTwoFingerOrbit")}),e.jsx("span",{className:"trackpad-gesture-desc",children:r("terminal:controls.shiftTwoFingerOrbitDesc")})]})]})]})]}),e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:r("terminal:controls.sensitivity")}),e.jsx("span",{className:"shortcuts-context-description",children:r("terminal:controls.adjustGestureSensitivity")})]}),e.jsxs("div",{className:"trackpad-sensitivity-sliders",children:[e.jsxs("div",{className:`trackpad-slider-row ${!s.enabled||!s.pinchToZoom?"disabled":""}`,children:[e.jsx("label",{children:r("terminal:controls.zoom")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.sensitivity.zoom,onChange:o=>l("zoom",parseFloat(o.target.value)),disabled:!s.enabled||!s.pinchToZoom}),e.jsxs("span",{className:"trackpad-slider-value",children:[s.sensitivity.zoom.toFixed(1),"x"]})]}),e.jsxs("div",{className:`trackpad-slider-row ${!s.enabled||!s.twoFingerPan?"disabled":""}`,children:[e.jsx("label",{children:r("terminal:controls.pan")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.sensitivity.pan,onChange:o=>l("pan",parseFloat(o.target.value)),disabled:!s.enabled||!s.twoFingerPan}),e.jsxs("span",{className:"trackpad-slider-value",children:[s.sensitivity.pan.toFixed(1),"x"]})]}),e.jsxs("div",{className:`trackpad-slider-row ${!s.enabled||!s.shiftTwoFingerOrbit?"disabled":""}`,children:[e.jsx("label",{children:r("terminal:controls.orbit")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.sensitivity.orbit,onChange:o=>l("orbit",parseFloat(o.target.value)),disabled:!s.enabled||!s.shiftTwoFingerOrbit}),e.jsxs("span",{className:"trackpad-slider-value",children:[s.sensitivity.orbit.toFixed(1),"x"]})]})]})]})]})}export{ue as ControlsModal};
1
+ import{u as K,f as H,b_ as Z,b$ as Q,r as m,ad as J,h as ee,bZ as D,c0 as V,c1 as se,j as e,c2 as te,C as ae,s as y,c3 as G,c4 as U}from"./main-3di6rXWx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const W={global:"terminal:controls.contextGlobal",commander:"terminal:controls.contextCommander",toolbox:"terminal:controls.contextToolbox"},ne={global:"terminal:controls.contextGlobalDesc",commander:"terminal:controls.contextCommanderDesc",toolbox:"terminal:controls.contextToolboxDesc"},Y={camera:["camera-pan","camera-orbit","camera-rotate","camera-zoom","camera-tilt"],interaction:["primary-action","selection-box","context-menu","move-command"]},re={camera:"terminal:controls.cameraControls",interaction:"terminal:controls.interaction"};function ue({isOpen:s,onClose:r}){const{t:a}=K(["terminal","common"]),l=H(),o=Z(),h=Q(),[x,b]=m.useState("keyboard"),[j,g]=m.useState(""),[p,C]=m.useState("all"),[d,f]=m.useState(!1),[c,v]=m.useState(null),u=J.useRef(null),{handleMouseDown:P,handleClick:S}=ee(r);if(m.useEffect(()=>{if(!s||d)return;const t=n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),r())};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[s,r,d]),m.useEffect(()=>{s||(g(""),f(!1),v(null))},[s]),m.useEffect(()=>{if(!s||!d)return;const t=n=>{if(n.key==="Escape"){n.preventDefault(),n.stopPropagation(),f(!1),v(null);return}if(["Control","Alt","Shift","Meta"].includes(n.key))return;n.preventDefault(),n.stopPropagation();let i=n.key;n.code.startsWith("Key")&&n.code.length===4?i=n.code.charAt(3).toLowerCase():n.code.startsWith("Digit")&&n.code.length===6?i=n.code.charAt(5):n.code==="Space"&&(i="Space"),v({key:i,modifiers:{ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey,meta:n.metaKey}})};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[s,d]),!s)return null;const F=l.shortcuts.filter(t=>{const n=a(`terminal:controls.shortcuts.${t.id}.name`,{defaultValue:t.name}),i=a(`terminal:controls.shortcuts.${t.id}.description`,{defaultValue:t.description});if(d&&c){const R=w=>w===" "||w==="Space"?"Space":w.length===1?w.toLowerCase():w,B=R(t.key),L=R(c.key);if(!(L.length===1&&/^[a-zA-Z]$/.test(B)?`Key${B.toUpperCase()}`==`Key${L.toUpperCase()}`:B===L))return!1;const M=t.modifiers,T=c.modifiers;return(M.ctrl||!1)===(T.ctrl||!1)&&(M.alt||!1)===(T.alt||!1)&&(M.shift||!1)===(T.shift||!1)&&(M.meta||!1)===(T.meta||!1)}if(!j)return!0;const k=j.toLowerCase();return n.toLowerCase().includes(k)||i.toLowerCase().includes(k)||D(t).toLowerCase().includes(k)}),E=Array.from(l.agents.values()).map(t=>t).filter(t=>t.shortcut&&t.shortcut.trim().length>0).filter(t=>{const n=V(t.shortcut).toLowerCase();if(d&&c){const k={key:c.key,code:c.key.length===1&&/^[a-zA-Z]$/.test(c.key)?`Key${c.key.toUpperCase()}`:c.key.length===1&&/^[0-9]$/.test(c.key)?`Digit${c.key}`:c.key==="Space"?"Space":c.key,ctrlKey:!!c.modifiers.ctrl,altKey:!!c.modifiers.alt,shiftKey:!!c.modifiers.shift,metaKey:!!c.modifiers.meta};return se(k,t.shortcut)}if(!j)return!0;const i=j.toLowerCase();return t.name.toLowerCase().includes(i)||n.toLowerCase().includes(i)}),O=F.reduce((t,n)=>(t[n.context]||(t[n.context]=[]),t[n.context].push(n),t),{}),_=(t,n)=>{y.updateShortcut(t,n)},[N,z]=m.useState(null),$=()=>{z(x)},I=()=>{N==="keyboard"?y.resetShortcuts():(N==="mouse"||N==="trackpad")&&y.resetMouseControls()},X=N==="keyboard"?"terminal:controls.confirmResetKeyboard":N==="mouse"?"terminal:controls.confirmResetMouse":"terminal:controls.confirmResetTrackpad",A=["global","commander","toolbox"],q=o.bindings.reduce((t,n)=>(Y.camera.includes(n.action)?t.camera.push(n):Y.interaction.includes(n.action)&&t.interaction.push(n),t),{camera:[],interaction:[]});return e.jsxs("div",{className:"shortcuts-modal-overlay",onMouseDown:P,onClick:S,children:[e.jsxs("div",{className:"shortcuts-modal controls-modal",children:[e.jsxs("div",{className:"shortcuts-modal-header",children:[e.jsxs("div",{className:"shortcuts-modal-title",children:[e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),e.jsx("span",{children:a("terminal:controls.title")})]}),e.jsx("button",{className:"shortcuts-modal-close",onClick:r,children:"×"})]}),e.jsxs("div",{className:"controls-main-tabs",children:[e.jsxs("button",{className:`controls-main-tab ${x==="keyboard"?"active":""}`,onClick:()=>b("keyboard"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M6 12h.01M18 12h.01M8 16h8"})]}),a("terminal:controls.keyboard")]}),e.jsxs("button",{className:`controls-main-tab ${x==="mouse"?"active":""}`,onClick:()=>b("mouse"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"6",y:"3",width:"12",height:"18",rx:"6"}),e.jsx("line",{x1:"12",y1:"7",x2:"12",y2:"11"})]}),a("terminal:controls.mouse")]}),e.jsxs("button",{className:`controls-main-tab ${x==="trackpad"?"active":""}`,onClick:()=>b("trackpad"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),a("terminal:controls.trackpad")]})]}),x==="keyboard"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[d?e.jsxs("div",{className:"shortcuts-search find-by-shortcut-active",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M6 12h.01M18 12h.01M8 16h8"})]}),c?e.jsxs("span",{className:"find-by-shortcut-display",children:[D({key:c.key,modifiers:c.modifiers}),e.jsx("button",{className:"shortcuts-search-clear",onClick:()=>v(null),children:"×"})]}):e.jsx("span",{className:"find-by-shortcut-prompt",children:a("terminal:controls.pressKeyCombination")})]}):e.jsxs("div",{className:"shortcuts-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:u,type:"text",placeholder:a("terminal:controls.searchShortcuts"),value:j,onChange:t=>g(t.target.value),autoFocus:!0}),j&&e.jsx("button",{className:"shortcuts-search-clear",onClick:()=>g(""),children:"×"})]}),e.jsx("button",{className:`shortcuts-find-by-key-btn ${d?"active":""}`,onClick:()=>{f(!d),v(null),g("")},title:a(d?"terminal:controls.switchToTextSearch":"terminal:controls.findByPressingKeys"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M6 12h.01M18 12h.01M8 16h8"})]})}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:$,children:a("common:buttons.reset")})]}),e.jsxs("div",{className:"shortcuts-context-tabs",children:[e.jsxs("button",{className:`shortcuts-context-tab ${p==="all"?"active":""}`,onClick:()=>C("all"),children:[a("common:labels.all"),e.jsx("span",{className:"shortcuts-context-tab-count",children:F.length})]}),A.map(t=>{var i;const n=((i=O[t])==null?void 0:i.length)||0;return e.jsxs("button",{className:`shortcuts-context-tab ${p===t?"active":""}`,onClick:()=>C(t),children:[a(W[t]),e.jsx("span",{className:"shortcuts-context-tab-count",children:n})]},t)})]}),e.jsxs("div",{className:"shortcuts-modal-content",children:[A.map(t=>{const n=O[t]||[];return n.length===0||p!=="all"&&p!==t?null:e.jsxs("div",{className:"shortcuts-context-group",children:[p==="all"&&e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:a(W[t])}),e.jsx("span",{className:"shortcuts-context-description",children:a(ne[t])})]}),e.jsx("div",{className:"shortcuts-grid",children:n.map(i=>e.jsxs("div",{className:"shortcut-item",children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:a(`terminal:controls.shortcuts.${i.id}.name`,{defaultValue:i.name})}),e.jsx("span",{className:"shortcut-item-description",children:a(`terminal:controls.shortcuts.${i.id}.description`,{defaultValue:i.description})})]}),e.jsx(te,{shortcut:i,onUpdate:k=>_(i.id,k)})]},i.id))})]},t)}),F.length===0&&E.length===0&&e.jsx("div",{className:"shortcuts-empty",children:d?c?e.jsx("p",{children:a("terminal:controls.noShortcutBoundTo",{keys:D({key:c.key,modifiers:c.modifiers})})}):e.jsx("p",{children:a("terminal:controls.pressKeyCombinationToFind")}):e.jsx("p",{children:a("terminal:controls.noShortcutsFound",{query:j})})}),E.length>0&&(p==="all"||p==="global")&&e.jsxs("div",{className:"shortcuts-context-group",children:[p==="all"&&e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:"Agent Terminal Shortcuts"}),e.jsx("span",{className:"shortcuts-context-description",children:"Per-agent global shortcuts that open the guake terminal"})]}),e.jsx("div",{className:"shortcuts-grid",children:E.map(t=>e.jsxs("div",{className:"shortcut-item",children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:t.name}),e.jsx("span",{className:"shortcut-item-description",children:"Open terminal for this agent"})]}),e.jsx("div",{className:"key-capture-container",children:e.jsx("button",{className:"key-capture-input disabled",disabled:!0,children:e.jsx("span",{className:"key-capture-value",children:V(t.shortcut)})})})]},t.id))})]})]})]}),x==="mouse"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[e.jsx("span",{className:"mouse-controls-subtitle",children:a("terminal:controls.cameraAndInteraction")}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:$,children:a("common:buttons.reset")})]}),e.jsxs("div",{className:"shortcuts-modal-content mouse-controls-content",children:[e.jsx("div",{className:"mouse-controls-bindings",children:Object.entries(q).map(([t,n])=>e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsx("div",{className:"shortcuts-context-header",children:e.jsx("span",{className:"shortcuts-context-label",children:a(re[t])})}),e.jsx("div",{className:"shortcuts-grid",children:n.map(i=>e.jsx(le,{binding:i},i.id))})]},t))}),e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:a("terminal:controls.sensitivity")}),e.jsx("span",{className:"shortcuts-context-description",children:a("terminal:controls.adjustCameraSpeed")})]}),e.jsx(oe,{sensitivity:o.sensitivity})]})]})]}),x==="trackpad"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[e.jsx("span",{className:"mouse-controls-subtitle",children:a("terminal:controls.trackpadGestureSettings")}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:$,children:a("common:buttons.reset")})]}),e.jsx("div",{className:"shortcuts-modal-content trackpad-controls-content",children:e.jsx(ce,{config:h})})]}),e.jsx("div",{className:"shortcuts-modal-footer",children:e.jsx("span",{className:"shortcuts-modal-hint",children:a(x==="keyboard"?d?"terminal:controls.hintFindByShortcut":"terminal:controls.hintKeyboard":x==="mouse"?"terminal:controls.hintMouse":"terminal:controls.hintTrackpad")})})]}),e.jsx(ae,{isOpen:N!==null,title:a("common:buttons.resetToDefaults"),message:a(X),confirmLabel:a("common:buttons.reset"),cancelLabel:a("common:buttons.cancel"),variant:"danger",onConfirm:I,onClose:()=>z(null)})]})}function le({binding:s}){const{t:r}=K(["terminal"]),a=Z(),[l,o]=m.useState(!1),[h,x]=m.useState(null);m.useEffect(()=>{if(!l)return;const d=u=>{u.preventDefault(),u.stopPropagation();const S={0:"left",1:"middle",2:"right",3:"back",4:"forward"}[u.button];S&&x({button:S,modifiers:{ctrl:u.ctrlKey,alt:u.altKey,shift:u.shiftKey,meta:u.metaKey}})},f=u=>{u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),o(!1),x(null))},c=()=>{h&&G(a.bindings,h,s.id).length===0&&y.updateMouseBinding(s.id,{button:h.button,modifiers:h.modifiers}),o(!1),x(null)},v=setTimeout(()=>{document.addEventListener("mousedown",d,!0),document.addEventListener("keydown",f,!0),document.addEventListener("click",c,!0)},100);return()=>{clearTimeout(v),document.removeEventListener("mousedown",d,!0),document.removeEventListener("keydown",f,!0),document.removeEventListener("click",c,!0)}},[l,h,s.id,a.bindings]);const b=h?G(a.bindings,h,s.id):[],j=r(`terminal:controls.mouseBindings.${s.id}.name`,{defaultValue:s.name}),g=r(`terminal:controls.mouseBindings.${s.id}.description`,{defaultValue:s.description}),p=d=>r(`terminal:controls.mouseButtons.${d}`,{defaultValue:d}),C=h?U({...s,...h},p):U(s,p);return e.jsxs("div",{className:`shortcut-item ${s.enabled?"":"disabled"}`,children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:j}),e.jsx("span",{className:"shortcut-item-description",children:g})]}),e.jsxs("div",{className:"key-capture-container",children:[e.jsx("button",{className:`key-capture-input ${l?"capturing":""} ${b.length>0?"conflict":""}`,onClick:()=>o(!0),children:l?h?e.jsx("span",{className:"key-capture-value",style:{color:"#f1fa8c"},children:C}):e.jsx("span",{style:{color:"#6272a4",fontStyle:"italic"},children:r("terminal:controls.clickToCapture")}):e.jsx("span",{className:"key-capture-value",children:C})}),b.length>0&&e.jsxs("span",{className:"key-capture-conflict",children:[r("terminal:controls.conflicts"),": ",b.map(d=>r(`terminal:controls.mouseBindings.${d.id}.name`,{defaultValue:d.name})).join(", ")]})]})]})}function oe({sensitivity:s}){const{t:r}=K(["terminal"]),a=m.useCallback((l,o)=>{y.updateCameraSensitivity({[l]:o})},[]);return e.jsxs("div",{className:"sensitivity-inline-settings",children:[e.jsxs("div",{className:"sensitivity-sliders",children:[e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.panSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.panSpeed,onChange:l=>a("panSpeed",parseFloat(l.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[s.panSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.orbitSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.orbitSpeed,onChange:l=>a("orbitSpeed",parseFloat(l.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[s.orbitSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.zoomSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.zoomSpeed,onChange:l=>a("zoomSpeed",parseFloat(l.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[s.zoomSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.smoothing")}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:s.smoothing,onChange:l=>a("smoothing",parseFloat(l.target.value))}),e.jsx("span",{className:"sensitivity-slider-value",children:s.smoothing.toFixed(1)})]})]}),e.jsxs("div",{className:"sensitivity-checkboxes-inline",children:[e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertPanX,onChange:l=>a("invertPanX",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertPanX")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertPanY,onChange:l=>a("invertPanY",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertPanY")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertOrbitX,onChange:l=>a("invertOrbitX",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertOrbitX")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertOrbitY,onChange:l=>a("invertOrbitY",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertOrbitY")})]})]})]})}function ce({config:s}){const{t:r}=K(["terminal"]),a=m.useCallback((o,h)=>{y.updateTrackpadConfig({[o]:h})},[]),l=m.useCallback((o,h)=>{y.updateTrackpadConfig({sensitivity:{[o]:h}})},[]);return e.jsxs("div",{className:"trackpad-settings",children:[e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:r("terminal:controls.trackpadGestures")}),e.jsx("span",{className:"shortcuts-context-description",children:r("terminal:controls.enableTrackpadSupport")})]}),e.jsx("div",{className:"trackpad-toggle-row",children:e.jsxs("label",{className:"trackpad-toggle",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:o=>a("enabled",o.target.checked)}),e.jsx("span",{className:"trackpad-toggle-label",children:r("terminal:controls.enableTrackpadGestures")})]})})]}),e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:r("terminal:controls.gestureControls")}),e.jsx("span",{className:"shortcuts-context-description",children:r("terminal:controls.enableDisableGestures")})]}),e.jsxs("div",{className:"trackpad-gestures-grid",children:[e.jsxs("label",{className:`trackpad-gesture-item ${s.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:s.pinchToZoom,onChange:o=>a("pinchToZoom",o.target.checked),disabled:!s.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:r("terminal:controls.pinchToZoom")}),e.jsx("span",{className:"trackpad-gesture-desc",children:r("terminal:controls.pinchToZoomDesc")})]})]}),e.jsxs("label",{className:`trackpad-gesture-item ${s.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:s.twoFingerPan,onChange:o=>a("twoFingerPan",o.target.checked),disabled:!s.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:r("terminal:controls.twoFingerPan")}),e.jsx("span",{className:"trackpad-gesture-desc",children:r("terminal:controls.twoFingerPanDesc")})]})]}),e.jsxs("label",{className:`trackpad-gesture-item ${s.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:s.shiftTwoFingerOrbit,onChange:o=>a("shiftTwoFingerOrbit",o.target.checked),disabled:!s.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:r("terminal:controls.shiftTwoFingerOrbit")}),e.jsx("span",{className:"trackpad-gesture-desc",children:r("terminal:controls.shiftTwoFingerOrbitDesc")})]})]})]})]}),e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:r("terminal:controls.sensitivity")}),e.jsx("span",{className:"shortcuts-context-description",children:r("terminal:controls.adjustGestureSensitivity")})]}),e.jsxs("div",{className:"trackpad-sensitivity-sliders",children:[e.jsxs("div",{className:`trackpad-slider-row ${!s.enabled||!s.pinchToZoom?"disabled":""}`,children:[e.jsx("label",{children:r("terminal:controls.zoom")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.sensitivity.zoom,onChange:o=>l("zoom",parseFloat(o.target.value)),disabled:!s.enabled||!s.pinchToZoom}),e.jsxs("span",{className:"trackpad-slider-value",children:[s.sensitivity.zoom.toFixed(1),"x"]})]}),e.jsxs("div",{className:`trackpad-slider-row ${!s.enabled||!s.twoFingerPan?"disabled":""}`,children:[e.jsx("label",{children:r("terminal:controls.pan")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.sensitivity.pan,onChange:o=>l("pan",parseFloat(o.target.value)),disabled:!s.enabled||!s.twoFingerPan}),e.jsxs("span",{className:"trackpad-slider-value",children:[s.sensitivity.pan.toFixed(1),"x"]})]}),e.jsxs("div",{className:`trackpad-slider-row ${!s.enabled||!s.shiftTwoFingerOrbit?"disabled":""}`,children:[e.jsx("label",{children:r("terminal:controls.orbit")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.sensitivity.orbit,onChange:o=>l("orbit",parseFloat(o.target.value)),disabled:!s.enabled||!s.shiftTwoFingerOrbit}),e.jsxs("span",{className:"trackpad-slider-value",children:[s.sensitivity.orbit.toFixed(1),"x"]})]})]})]})]})}export{ue as ControlsModal};
@@ -1,2 +1,2 @@
1
- import{u as p,f as L,r as n,s as r,j as x}from"./main-BA8NAb8s.js";import{L as S}from"./LogViewerModal-D2BmPOPE.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function M({building:e,isOpen:o,onClose:m}){var a;const{t:i}=p(["terminal"]),{streamingBuildingLogs:c,streamingBuildingIds:g}=L(),s=c.get(e.id)||"",d=g.has(e.id);n.useEffect(()=>{var t;return o&&((t=e.docker)!=null&&t.enabled)&&r.startLogStreaming(e.id,200),()=>{e.id&&r.stopLogStreaming(e.id)}},[o,e.id,(a=e.docker)==null?void 0:a.enabled]);const f=n.useMemo(()=>s.split(`
1
+ import{u as p,f as L,r as n,s as r,j as x}from"./main-3di6rXWx.js";import{L as S}from"./LogViewerModal-BsIlfAS6.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function M({building:e,isOpen:o,onClose:m}){var a;const{t:i}=p(["terminal"]),{streamingBuildingLogs:c,streamingBuildingIds:g}=L(),s=c.get(e.id)||"",d=g.has(e.id);n.useEffect(()=>{var t;return o&&((t=e.docker)!=null&&t.enabled)&&r.startLogStreaming(e.id,200),()=>{e.id&&r.stopLogStreaming(e.id)}},[o,e.id,(a=e.docker)==null?void 0:a.enabled]);const f=n.useMemo(()=>s.split(`
2
2
  `).map((t,l)=>({text:t,lineNumber:l+1})),[s]);return x.jsx(S,{isOpen:o,onClose:m,title:`${e.name} - ${i("terminal:logs.dockerLogs")}`,icon:"🐳",lines:f,isStreaming:d,onClear:()=>r.clearStreamingLogs(e.id)})}export{M as DockerLogsModal};
@@ -1,4 +1,4 @@
1
- import{r as ot,j as Tt}from"./main-BA8NAb8s.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";let Hs=[],mQ=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,O=0;e<t.length;e++)(e%2?mQ:Hs).push(O=O+t[e])})();function wX(t){if(t<768)return!1;for(let e=0,O=Hs.length;;){let i=e+O>>1;if(t<Hs[i])O=i;else if(t>=mQ[i])e=i+1;else return!0;if(e==O)return!1}}function Ju(t){return t>=127462&&t<=127487}const ef=8205;function TX(t,e,O=!0,i=!0){return(O?PQ:xX)(t,e,i)}function PQ(t,e,O){if(e==t.length)return e;e&&SQ(t.charCodeAt(e))&&XQ(t.charCodeAt(e-1))&&e--;let i=zo(t,e);for(e+=tf(i);e<t.length;){let n=zo(t,e);if(i==ef||n==ef||O&&wX(n))e+=tf(n),i=n;else if(Ju(n)){let r=0,a=e-2;for(;a>=0&&Ju(zo(t,a));)r++,a-=2;if(r%2==0)break;e+=2}else break}return e}function xX(t,e,O){for(;e>0;){let i=PQ(t,e-2,O);if(i<e)return i;e--}return 0}function zo(t,e){let O=t.charCodeAt(e);if(!XQ(O)||e+1==t.length)return O;let i=t.charCodeAt(e+1);return SQ(i)?(O-55296<<10)+(i-56320)+65536:O}function SQ(t){return t>=56320&&t<57344}function XQ(t){return t>=55296&&t<56320}function tf(t){return t<65536?1:2}class Oe{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,O,i){[e,O]=zi(this,e,O);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(O,this.length,n,1),qt.from(n,this.length-(O-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,O=this.length){[e,O]=zi(this,e,O);let i=[];return this.decompose(e,O,i,0),qt.from(i,O-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let O=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new mn(this),r=new mn(e);for(let a=O,o=O;;){if(n.next(a),r.next(a),a=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(o+=n.value.length,n.done||o>=i)return!0}}iter(e=1){return new mn(this,e)}iterRange(e,O=this.length){return new bQ(this,e,O)}iterLines(e,O){let i;if(e==null)i=this.iter();else{O==null&&(O=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,O==this.lines+1?this.length:O<=1?0:this.line(O-1).to))}return new yQ(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Oe.empty:e.length<=32?new ge(e):qt.from(ge.split(e,[]))}}class ge extends Oe{constructor(e,O=vX(e)){super(),this.text=e,this.length=O}get lines(){return this.text.length}get children(){return null}lineInner(e,O,i,n){for(let r=0;;r++){let a=this.text[r],o=n+a.length;if((O?i:o)>=e)return new _X(n,o,i,a);n=o+1,i++}}decompose(e,O,i,n){let r=e<=0&&O>=this.length?this:new ge(Of(this.text,e,O),Math.min(O,this.length)-Math.max(0,e));if(n&1){let a=i.pop(),o=Nr(r.text,a.text.slice(),0,r.length);if(o.length<=32)i.push(new ge(o,a.length+r.length));else{let s=o.length>>1;i.push(new ge(o.slice(0,s)),new ge(o.slice(s)))}}else i.push(r)}replace(e,O,i){if(!(i instanceof ge))return super.replace(e,O,i);[e,O]=zi(this,e,O);let n=Nr(this.text,Nr(i.text,Of(this.text,0,e)),O),r=this.length+i.length-(O-e);return n.length<=32?new ge(n,r):qt.from(ge.split(n,[]),r)}sliceString(e,O=this.length,i=`
1
+ import{r as ot,j as Tt}from"./main-3di6rXWx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";let Hs=[],mQ=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,O=0;e<t.length;e++)(e%2?mQ:Hs).push(O=O+t[e])})();function wX(t){if(t<768)return!1;for(let e=0,O=Hs.length;;){let i=e+O>>1;if(t<Hs[i])O=i;else if(t>=mQ[i])e=i+1;else return!0;if(e==O)return!1}}function Ju(t){return t>=127462&&t<=127487}const ef=8205;function TX(t,e,O=!0,i=!0){return(O?PQ:xX)(t,e,i)}function PQ(t,e,O){if(e==t.length)return e;e&&SQ(t.charCodeAt(e))&&XQ(t.charCodeAt(e-1))&&e--;let i=zo(t,e);for(e+=tf(i);e<t.length;){let n=zo(t,e);if(i==ef||n==ef||O&&wX(n))e+=tf(n),i=n;else if(Ju(n)){let r=0,a=e-2;for(;a>=0&&Ju(zo(t,a));)r++,a-=2;if(r%2==0)break;e+=2}else break}return e}function xX(t,e,O){for(;e>0;){let i=PQ(t,e-2,O);if(i<e)return i;e--}return 0}function zo(t,e){let O=t.charCodeAt(e);if(!XQ(O)||e+1==t.length)return O;let i=t.charCodeAt(e+1);return SQ(i)?(O-55296<<10)+(i-56320)+65536:O}function SQ(t){return t>=56320&&t<57344}function XQ(t){return t>=55296&&t<56320}function tf(t){return t<65536?1:2}class Oe{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,O,i){[e,O]=zi(this,e,O);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(O,this.length,n,1),qt.from(n,this.length-(O-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,O=this.length){[e,O]=zi(this,e,O);let i=[];return this.decompose(e,O,i,0),qt.from(i,O-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let O=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new mn(this),r=new mn(e);for(let a=O,o=O;;){if(n.next(a),r.next(a),a=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(o+=n.value.length,n.done||o>=i)return!0}}iter(e=1){return new mn(this,e)}iterRange(e,O=this.length){return new bQ(this,e,O)}iterLines(e,O){let i;if(e==null)i=this.iter();else{O==null&&(O=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,O==this.lines+1?this.length:O<=1?0:this.line(O-1).to))}return new yQ(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Oe.empty:e.length<=32?new ge(e):qt.from(ge.split(e,[]))}}class ge extends Oe{constructor(e,O=vX(e)){super(),this.text=e,this.length=O}get lines(){return this.text.length}get children(){return null}lineInner(e,O,i,n){for(let r=0;;r++){let a=this.text[r],o=n+a.length;if((O?i:o)>=e)return new _X(n,o,i,a);n=o+1,i++}}decompose(e,O,i,n){let r=e<=0&&O>=this.length?this:new ge(Of(this.text,e,O),Math.min(O,this.length)-Math.max(0,e));if(n&1){let a=i.pop(),o=Nr(r.text,a.text.slice(),0,r.length);if(o.length<=32)i.push(new ge(o,a.length+r.length));else{let s=o.length>>1;i.push(new ge(o.slice(0,s)),new ge(o.slice(s)))}}else i.push(r)}replace(e,O,i){if(!(i instanceof ge))return super.replace(e,O,i);[e,O]=zi(this,e,O);let n=Nr(this.text,Nr(i.text,Of(this.text,0,e)),O),r=this.length+i.length-(O-e);return n.length<=32?new ge(n,r):qt.from(ge.split(n,[]),r)}sliceString(e,O=this.length,i=`
2
2
  `){[e,O]=zi(this,e,O);let n="";for(let r=0,a=0;r<=O&&a<this.text.length;a++){let o=this.text[a],s=r+o.length;r>e&&a&&(n+=i),e<s&&O>r&&(n+=o.slice(Math.max(0,e-r),O-r)),r=s+1}return n}flatten(e){for(let O of this.text)e.push(O)}scanIdentical(){return 0}static split(e,O){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,i.length==32&&(O.push(new ge(i,n)),i=[],n=-1);return n>-1&&O.push(new ge(i,n)),O}}class qt extends Oe{constructor(e,O){super(),this.children=e,this.length=O,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,O,i,n){for(let r=0;;r++){let a=this.children[r],o=n+a.length,s=i+a.lines-1;if((O?s:o)>=e)return a.lineInner(e,O,i,n);n=o+1,i=s+1}}decompose(e,O,i,n){for(let r=0,a=0;a<=O&&r<this.children.length;r++){let o=this.children[r],s=a+o.length;if(e<=s&&O>=a){let l=n&((a<=e?1:0)|(s>=O?2:0));a>=e&&s<=O&&!l?i.push(o):o.decompose(e-a,O-a,i,l)}a=s+1}}replace(e,O,i){if([e,O]=zi(this,e,O),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let a=this.children[n],o=r+a.length;if(e>=r&&O<=o){let s=a.replace(e-r,O-r,i),l=this.lines-a.lines+s.lines;if(s.lines<l>>4&&s.lines>l>>6){let c=this.children.slice();return c[n]=s,new qt(c,this.length-(O-e)+i.length)}return super.replace(r,o,s)}r=o+1}return super.replace(e,O,i)}sliceString(e,O=this.length,i=`
3
3
  `){[e,O]=zi(this,e,O);let n="";for(let r=0,a=0;r<this.children.length&&a<=O;r++){let o=this.children[r],s=a+o.length;a>e&&r&&(n+=i),e<s&&O>a&&(n+=o.sliceString(e-a,O-a,i)),a=s+1}return n}flatten(e){for(let O of this.children)O.flatten(e)}scanIdentical(e,O){if(!(e instanceof qt))return 0;let i=0,[n,r,a,o]=O>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=O,r+=O){if(n==a||r==o)return i;let s=this.children[n],l=e.children[r];if(s!=l)return i+s.scanIdentical(l,O);i+=s.length+1}}static from(e,O=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let $ of e)$.flatten(d);return new ge(d,O)}let n=Math.max(32,i>>5),r=n<<1,a=n>>1,o=[],s=0,l=-1,c=[];function u(d){let $;if(d.lines>r&&d instanceof qt)for(let Q of d.children)u(Q);else d.lines>a&&(s>a||!s)?(f(),o.push(d)):d instanceof ge&&s&&($=c[c.length-1])instanceof ge&&d.lines+$.lines<=32?(s+=d.lines,l+=d.length+1,c[c.length-1]=new ge($.text.concat(d.text),$.length+1+d.length)):(s+d.lines>n&&f(),s+=d.lines,l+=d.length+1,c.push(d))}function f(){s!=0&&(o.push(c.length==1?c[0]:qt.from(c,l)),l=-1,s=c.length=0)}for(let d of e)u(d);return f(),o.length==1?o[0]:new qt(o,O)}}Oe.empty=new ge([""],0);function vX(t){let e=-1;for(let O of t)e+=O.length+1;return e}function Nr(t,e,O=0,i=1e9){for(let n=0,r=0,a=!0;r<t.length&&n<=i;r++){let o=t[r],s=n+o.length;s>=O&&(s>i&&(o=o.slice(0,i-n)),n<O&&(o=o.slice(O-n)),a?(e[e.length-1]+=o,a=!1):e.push(o)),n=s+1}return e}function Of(t,e,O){return Nr(t,[""],e,O)}class mn{constructor(e,O=1){this.dir=O,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[O>0?1:(e instanceof ge?e.text.length:e.children.length)<<1]}nextInner(e,O){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],a=r>>1,o=n instanceof ge?n.text.length:n.children.length;if(a==(O>0?o:0)){if(i==0)return this.done=!0,this.value="",this;O>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(O>0?0:1)){if(this.offsets[i]+=O,e==0)return this.lineBreak=!0,this.value=`
4
4
  `,this;e--}else if(n instanceof ge){let s=n.text[a+(O<0?-1:0)];if(this.offsets[i]+=O,s.length>Math.max(0,e))return this.value=e==0?s:O>0?s.slice(e):s.slice(0,s.length-e),this;e-=s.length}else{let s=n.children[a+(O<0?-1:0)];e>s.length?(e-=s.length,this.offsets[i]+=O):(O<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(O>0?1:(s instanceof ge?s.text.length:s.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class bQ{constructor(e,O,i){this.value="",this.done=!1,this.cursor=new mn(e,O>i?-1:1),this.pos=O>i?e.length:0,this.from=Math.min(O,i),this.to=Math.max(O,i)}nextInner(e,O){if(O<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,O<0?this.pos-this.to:this.from-this.pos);let i=O<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*O,this.value=n.length<=i?n:O<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class yQ{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:O,lineBreak:i,value:n}=this.inner.next(e);return O&&this.afterBreak?(this.value="",this.afterBreak=!1):O?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Oe.prototype[Symbol.iterator]=function(){return this.iter()},mn.prototype[Symbol.iterator]=bQ.prototype[Symbol.iterator]=yQ.prototype[Symbol.iterator]=function(){return this});let _X=class{constructor(e,O,i,n){this.from=e,this.to=O,this.number=i,this.text=n}get length(){return this.to-this.from}};function zi(t,e,O){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,O))]}function we(t,e,O=!0,i=!0){return TX(t,e,O,i)}function YX(t){return t>=56320&&t<57344}function RX(t){return t>=55296&&t<56320}function ci(t,e){let O=t.charCodeAt(e);if(!RX(O)||e+1==t.length)return O;let i=t.charCodeAt(e+1);return YX(i)?(O-55296<<10)+(i-56320)+65536:O}function kQ(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function er(t){return t<65536?1:2}const Ks=/\r\n?|\n/;var ze=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(ze||(ze={}));class Gt{constructor(e){this.sections=e}get length(){let e=0;for(let O=0;O<this.sections.length;O+=2)e+=this.sections[O];return e}get newLength(){let e=0;for(let O=0;O<this.sections.length;O+=2){let i=this.sections[O+1];e+=i<0?this.sections[O]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let O=0,i=0,n=0;O<this.sections.length;){let r=this.sections[O++],a=this.sections[O++];a<0?(e(i,n,r),n+=r):n+=a,i+=r}}iterChangedRanges(e,O=!1){Js(this,e,O)}get invertedDesc(){let e=[];for(let O=0;O<this.sections.length;){let i=this.sections[O++],n=this.sections[O++];n<0?e.push(i,n):e.push(n,i)}return new Gt(e)}composeDesc(e){return this.empty?e:e.empty?this:wQ(this,e)}mapDesc(e,O=!1){return e.empty?this:el(this,e,O)}mapPos(e,O=-1,i=ze.Simple){let n=0,r=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],l=n+o;if(s<0){if(l>e)return r+(e-n);r+=o}else{if(i!=ze.Simple&&l>=e&&(i==ze.TrackDel&&n<e&&l>e||i==ze.TrackBefore&&n<e||i==ze.TrackAfter&&l>e))return null;if(l>e||l==e&&O<0&&!o)return e==n||O<0?r:r+s;r+=s}n=l}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,O=e){for(let i=0,n=0;i<this.sections.length&&n<=O;){let r=this.sections[i++],a=this.sections[i++],o=n+r;if(a>=0&&n<=O&&o>=e)return n<e&&o>O?"cover":!0;n=o}return!1}toString(){let e="";for(let O=0;O<this.sections.length;){let i=this.sections[O++],n=this.sections[O++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(O=>typeof O!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Gt(e)}static create(e){return new Gt(e)}}class Xe extends Gt{constructor(e,O){super(e),this.inserted=O}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Js(this,(O,i,n,r,a)=>e=e.replace(n,n+(i-O),a),!1),e}mapDesc(e,O=!1){return el(this,e,O,!0)}invert(e){let O=this.sections.slice(),i=[];for(let n=0,r=0;n<O.length;n+=2){let a=O[n],o=O[n+1];if(o>=0){O[n]=o,O[n+1]=a;let s=n>>1;for(;i.length<s;)i.push(Oe.empty);i.push(a?e.slice(r,r+a):Oe.empty)}r+=a}return new Xe(O,i)}compose(e){return this.empty?e:e.empty?this:wQ(this,e,!0)}map(e,O=!1){return e.empty?this:el(this,e,O,!0)}iterChanges(e,O=!1){Js(this,e,O)}get desc(){return Gt.create(this.sections)}filter(e){let O=[],i=[],n=[],r=new Yn(this);e:for(let a=0,o=0;;){let s=a==e.length?1e9:e[a++];for(;o<s||o==s&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,s-o);Re(n,c,-1);let u=r.ins==-1?-1:r.off==0?r.ins:0;Re(O,c,u),u>0&&PO(i,O,r.text),r.forward(c),o+=c}let l=e[a++];for(;o<l;){if(r.done)break e;let c=Math.min(r.len,l-o);Re(O,c,-1),Re(n,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),o+=c}}return{changes:new Xe(O,i),filtered:Gt.create(n)}}toJSON(){let e=[];for(let O=0;O<this.sections.length;O+=2){let i=this.sections[O],n=this.sections[O+1];n<0?e.push(i):n==0?e.push([i]):e.push([i].concat(this.inserted[O>>1].toJSON()))}return e}static of(e,O,i){let n=[],r=[],a=0,o=null;function s(c=!1){if(!c&&!n.length)return;a<O&&Re(n,O-a,-1);let u=new Xe(n,r);o=o?o.compose(u.map(o)):u,n=[],r=[],a=0}function l(c){if(Array.isArray(c))for(let u of c)l(u);else if(c instanceof Xe){if(c.length!=O)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${O})`);s(),o=o?o.compose(c.map(o)):c}else{let{from:u,to:f=u,insert:d}=c;if(u>f||u<0||f>O)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${O})`);let $=d?typeof d=="string"?Oe.of(d.split(i||Ks)):d:Oe.empty,Q=$.length;if(u==f&&Q==0)return;u<a&&s(),u>a&&Re(n,u-a,-1),Re(n,f-u,Q),PO(r,n,$),a=f}}return l(e),s(!o),o}static empty(e){return new Xe(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let O=[],i=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r=="number")O.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((a,o)=>o&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)O.push(r[0],0);else{for(;i.length<n;)i.push(Oe.empty);i[n]=Oe.of(r.slice(1)),O.push(r[0],i[n].length)}}}return new Xe(O,i)}static createSet(e,O){return new Xe(e,O)}}function Re(t,e,O,i=!1){if(e==0&&O<=0)return;let n=t.length-2;n>=0&&O<=0&&O==t[n+1]?t[n]+=e:n>=0&&e==0&&t[n]==0?t[n+1]+=O:i?(t[n]+=e,t[n+1]+=O):t.push(e,O)}function PO(t,e,O){if(O.length==0)return;let i=e.length-2>>1;if(i<t.length)t[t.length-1]=t[t.length-1].append(O);else{for(;t.length<i;)t.push(Oe.empty);t.push(O)}}function Js(t,e,O){let i=t.inserted;for(let n=0,r=0,a=0;a<t.sections.length;){let o=t.sections[a++],s=t.sections[a++];if(s<0)n+=o,r+=o;else{let l=n,c=r,u=Oe.empty;for(;l+=o,c+=s,s&&i&&(u=u.append(i[a-2>>1])),!(O||a==t.sections.length||t.sections[a+1]<0);)o=t.sections[a++],s=t.sections[a++];e(n,l,r,c,u),n=l,r=c}}}function el(t,e,O,i=!1){let n=[],r=i?[]:null,a=new Yn(t),o=new Yn(e);for(let s=-1;;){if(a.done&&o.len||o.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&o.ins==-1){let l=Math.min(a.len,o.len);Re(n,l,-1),a.forward(l),o.forward(l)}else if(o.ins>=0&&(a.ins<0||s==a.i||a.off==0&&(o.len<a.len||o.len==a.len&&!O))){let l=o.len;for(Re(n,o.ins,-1);l;){let c=Math.min(a.len,l);a.ins>=0&&s<a.i&&a.len<=c&&(Re(n,0,a.ins),r&&PO(r,n,a.text),s=a.i),a.forward(c),l-=c}o.next()}else if(a.ins>=0){let l=0,c=a.len;for(;c;)if(o.ins==-1){let u=Math.min(c,o.len);l+=u,c-=u,o.forward(u)}else if(o.ins==0&&o.len<c)c-=o.len,o.next();else break;Re(n,l,s<a.i?a.ins:0),r&&s<a.i&&PO(r,n,a.text),s=a.i,a.forward(a.len-c)}else{if(a.done&&o.done)return r?Xe.createSet(n,r):Gt.create(n);throw new Error("Mismatched change set lengths")}}}function wQ(t,e,O=!1){let i=[],n=O?[]:null,r=new Yn(t),a=new Yn(e);for(let o=!1;;){if(r.done&&a.done)return n?Xe.createSet(i,n):Gt.create(i);if(r.ins==0)Re(i,r.len,0,o),r.next();else if(a.len==0&&!a.done)Re(i,0,a.ins,o),n&&PO(n,i,a.text),a.next();else{if(r.done||a.done)throw new Error("Mismatched change set lengths");{let s=Math.min(r.len2,a.len),l=i.length;if(r.ins==-1){let c=a.ins==-1?-1:a.off?0:a.ins;Re(i,s,c,o),n&&c&&PO(n,i,a.text)}else a.ins==-1?(Re(i,r.off?0:r.len,s,o),n&&PO(n,i,r.textBit(s))):(Re(i,r.off?0:r.len,a.off?0:a.ins,o),n&&!a.off&&PO(n,i,a.text));o=(r.ins>s||a.ins>=0&&a.len>s)&&(o||i.length>l),r.forward2(s),a.forward(s)}}}}class Yn{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,O=this.i-2>>1;return O>=e.length?Oe.empty:e[O]}textBit(e){let{inserted:O}=this.set,i=this.i-2>>1;return i>=O.length&&!e?Oe.empty:O[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class DO{constructor(e,O,i){this.from=e,this.to=O,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,O=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,O):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new DO(i,n,this.flags)}extend(e,O=e,i=0){if(e<=this.anchor&&O>=this.anchor)return y.range(e,O,void 0,void 0,i);let n=Math.abs(e-this.anchor)>Math.abs(O-this.anchor)?e:O;return y.range(this.anchor,n,void 0,void 0,i)}eq(e,O=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!O||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return y.range(e.anchor,e.head)}static create(e,O,i){return new DO(e,O,i)}}class y{constructor(e,O){this.ranges=e,this.mainIndex=O}map(e,O=-1){return e.empty?this:y.create(this.ranges.map(i=>i.map(e,O)),this.mainIndex)}eq(e,O=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],O))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new y([this.main],0)}addRange(e,O=!0){return y.create([e].concat(this.ranges),O?0:this.mainIndex+1)}replaceRange(e,O=this.mainIndex){let i=this.ranges.slice();return i[O]=e,y.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new y(e.ranges.map(O=>DO.fromJSON(O)),e.main)}static single(e,O=e){return new y([y.range(e,O)],0)}static create(e,O=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<e.length;n++){let r=e[n];if(r.empty?r.from<=i:r.from<i)return y.normalized(e.slice(),O);i=r.to}return new y(e,O)}static cursor(e,O=0,i,n){return DO.create(e,e,(O==0?0:O<0?8:16)|(i==null?7:Math.min(6,i))|(n??16777215)<<6)}static range(e,O,i,n,r){let a=(i??16777215)<<6|(n==null?7:Math.min(6,n));return!r&&e!=O&&(r=O<e?1:-1),O<e?DO.create(O,e,48|a):DO.create(e,O,(r?r<0?8:16:0)|a)}static normalized(e,O=0){let i=e[O];e.sort((n,r)=>n.from-r.from),O=e.indexOf(i);for(let n=1;n<e.length;n++){let r=e[n],a=e[n-1];if(r.empty?r.from<=a.to:r.from<a.to){let o=a.from,s=Math.max(r.to,a.to);n<=O&&O--,e.splice(--n,2,r.anchor>r.head?y.range(s,o):y.range(o,s))}}return new y(e,O)}}function TQ(t,e){for(let O of t.ranges)if(O.to>e)throw new RangeError("Selection points outside of document")}let vc=0;class E{constructor(e,O,i,n,r){this.combine=e,this.compareInput=O,this.compare=i,this.isStatic=n,this.id=vc++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new E(e.combine||(O=>O),e.compareInput||((O,i)=>O===i),e.compare||(e.combine?(O,i)=>O===i:_c),!!e.static,e.enables)}of(e){return new Br([],this,0,e)}compute(e,O){if(this.isStatic)throw new Error("Can't compute a static facet");return new Br(e,this,1,O)}computeN(e,O){if(this.isStatic)throw new Error("Can't compute a static facet");return new Br(e,this,2,O)}from(e,O){return O||(O=i=>i),this.compute([e],i=>O(i.field(e)))}}function _c(t,e){return t==e||t.length==e.length&&t.every((O,i)=>O===e[i])}class Br{constructor(e,O,i,n){this.dependencies=e,this.facet=O,this.type=i,this.value=n,this.id=vc++}dynamicSlot(e){var O;let i=this.value,n=this.facet.compareInput,r=this.id,a=e[r]>>1,o=this.type==2,s=!1,l=!1,c=[];for(let u of this.dependencies)u=="doc"?s=!0:u=="selection"?l=!0:(((O=e[u.id])!==null&&O!==void 0?O:1)&1)==0&&c.push(e[u.id]);return{create(u){return u.values[a]=i(u),1},update(u,f){if(s&&f.docChanged||l&&(f.docChanged||f.selection)||tl(u,c)){let d=i(u);if(o?!nf(d,u.values[a],n):!n(d,u.values[a]))return u.values[a]=d,1}return 0},reconfigure:(u,f)=>{let d,$=f.config.address[r];if($!=null){let Q=fa(f,$);if(this.dependencies.every(p=>p instanceof E?f.facet(p)===u.facet(p):p instanceof rt?f.field(p,!1)==u.field(p,!1):!0)||(o?nf(d=i(u),Q,n):n(d=i(u),Q)))return u.values[a]=Q,0}else d=i(u);return u.values[a]=d,1}}}}function nf(t,e,O){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!O(t[i],e[i]))return!1;return!0}function tl(t,e){let O=!1;for(let i of e)Pn(t,i)&1&&(O=!0);return O}function ZX(t,e,O){let i=O.map(s=>t[s.id]),n=O.map(s=>s.type),r=i.filter(s=>!(s&1)),a=t[e.id]>>1;function o(s){let l=[];for(let c=0;c<i.length;c++){let u=fa(s,i[c]);if(n[c]==2)for(let f of u)l.push(f);else l.push(u)}return e.combine(l)}return{create(s){for(let l of i)Pn(s,l);return s.values[a]=o(s),1},update(s,l){if(!tl(s,r))return 0;let c=o(s);return e.compare(c,s.values[a])?0:(s.values[a]=c,1)},reconfigure(s,l){let c=tl(s,i),u=l.config.facets[e.id],f=l.facet(e);if(u&&!c&&_c(O,u))return s.values[a]=f,0;let d=o(s);return e.compare(d,f)?(s.values[a]=f,0):(s.values[a]=d,1)}}}const Qr=E.define({static:!0});class rt{constructor(e,O,i,n,r){this.id=e,this.createF=O,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(e){let O=new rt(vc++,e.create,e.update,e.compare||((i,n)=>i===n),e);return e.provide&&(O.provides=e.provide(O)),O}create(e){let O=e.facet(Qr).find(i=>i.field==this);return((O==null?void 0:O.create)||this.createF)(e)}slot(e){let O=e[this.id]>>1;return{create:i=>(i.values[O]=this.create(i),1),update:(i,n)=>{let r=i.values[O],a=this.updateF(r,n);return this.compareF(r,a)?0:(i.values[O]=a,1)},reconfigure:(i,n)=>{let r=i.facet(Qr),a=n.facet(Qr),o;return(o=r.find(s=>s.field==this))&&o!=a.find(s=>s.field==this)?(i.values[O]=o.create(i),1):n.config.address[this.id]!=null?(i.values[O]=n.field(this),0):(i.values[O]=this.create(i),1)}}}init(e){return[this,Qr.of({field:this,create:e})]}get extension(){return this}}const GO={lowest:4,low:3,default:2,high:1,highest:0};function Ji(t){return e=>new xQ(e,t)}const ui={highest:Ji(GO.highest),high:Ji(GO.high),default:Ji(GO.default),low:Ji(GO.low),lowest:Ji(GO.lowest)};class xQ{constructor(e,O){this.inner=e,this.prec=O}}class Fa{of(e){return new Ol(this,e)}reconfigure(e){return Fa.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Ol{constructor(e,O){this.compartment=e,this.inner=O}}class ua{constructor(e,O,i,n,r,a){for(this.base=e,this.compartments=O,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let O=this.address[e.id];return O==null?e.default:this.staticValues[O>>1]}static resolve(e,O,i){let n=[],r=Object.create(null),a=new Map;for(let f of zX(e,O,a))f instanceof rt?n.push(f):(r[f.facet.id]||(r[f.facet.id]=[])).push(f);let o=Object.create(null),s=[],l=[];for(let f of n)o[f.id]=l.length<<1,l.push(d=>f.slot(d));let c=i==null?void 0:i.config.facets;for(let f in r){let d=r[f],$=d[0].facet,Q=c&&c[f]||[];if(d.every(p=>p.type==0))if(o[$.id]=s.length<<1|1,_c(Q,d))s.push(i.facet($));else{let p=$.combine(d.map(m=>m.value));s.push(i&&$.compare(p,i.facet($))?i.facet($):p)}else{for(let p of d)p.type==0?(o[p.id]=s.length<<1|1,s.push(p.value)):(o[p.id]=l.length<<1,l.push(m=>p.dynamicSlot(m)));o[$.id]=l.length<<1,l.push(p=>ZX(p,$,d))}}let u=l.map(f=>f(o));return new ua(e,a,u,o,s,r)}}function zX(t,e,O){let i=[[],[],[],[],[]],n=new Map;function r(a,o){let s=n.get(a);if(s!=null){if(s<=o)return;let l=i[s].indexOf(a);l>-1&&i[s].splice(l,1),a instanceof Ol&&O.delete(a.compartment)}if(n.set(a,o),Array.isArray(a))for(let l of a)r(l,o);else if(a instanceof Ol){if(O.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let l=e.get(a.compartment)||a.inner;O.set(a.compartment,l),r(l,o)}else if(a instanceof xQ)r(a.inner,a.prec);else if(a instanceof rt)i[o].push(a),a.provides&&r(a.provides,o);else if(a instanceof Br)i[o].push(a),a.facet.extensions&&r(a.facet.extensions,GO.default);else{let l=a.extension;if(!l)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(l,o)}}return r(t,GO.default),i.reduce((a,o)=>a.concat(o))}function Pn(t,e){if(e&1)return 2;let O=e>>1,i=t.status[O];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;t.status[O]=4;let n=t.computeSlot(t,t.config.dynamicSlots[O]);return t.status[O]=2|n}function fa(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const vQ=E.define(),il=E.define({combine:t=>t.some(e=>e),static:!0}),_Q=E.define({combine:t=>t.length?t[0]:void 0,static:!0}),YQ=E.define(),RQ=E.define(),ZQ=E.define(),zQ=E.define({combine:t=>t.length?t[0]:!1});class uO{constructor(e,O){this.type=e,this.value=O}static define(){return new qX}}class qX{of(e){return new uO(this,e)}}class UX{constructor(e){this.map=e}of(e){return new ie(this,e)}}class ie{constructor(e,O){this.type=e,this.value=O}map(e){let O=this.type.map(this.value,e);return O===void 0?void 0:O==this.value?this:new ie(this.type,O)}is(e){return this.type==e}static define(e={}){return new UX(e.map||(O=>O))}static mapEffects(e,O){if(!e.length)return e;let i=[];for(let n of e){let r=n.map(O);r&&i.push(r)}return i}}ie.reconfigure=ie.define();ie.appendConfig=ie.define();class Pe{constructor(e,O,i,n,r,a){this.startState=e,this.changes=O,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=a,this._doc=null,this._state=null,i&&TQ(i,O.newLength),r.some(o=>o.type==Pe.time)||(this.annotations=r.concat(Pe.time.of(Date.now())))}static create(e,O,i,n,r,a){return new Pe(e,O,i,n,r,a)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let O of this.annotations)if(O.type==e)return O.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let O=this.annotation(Pe.userEvent);return!!(O&&(O==e||O.length>e.length&&O.slice(0,e.length)==e&&O[e.length]=="."))}}Pe.time=uO.define();Pe.userEvent=uO.define();Pe.addToHistory=uO.define();Pe.remote=uO.define();function VX(t,e){let O=[];for(let i=0,n=0;;){let r,a;if(i<t.length&&(n==e.length||e[n]>=t[i]))r=t[i++],a=t[i++];else if(n<e.length)r=e[n++],a=e[n++];else return O;!O.length||O[O.length-1]<r?O.push(r,a):O[O.length-1]<a&&(O[O.length-1]=a)}}function qQ(t,e,O){var i;let n,r,a;return O?(n=e.changes,r=Xe.empty(e.changes.length),a=t.changes.compose(e.changes)):(n=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),a=t.changes.compose(n)),{changes:a,selection:e.selection?e.selection.map(r):(i=t.selection)===null||i===void 0?void 0:i.map(n),effects:ie.mapEffects(t.effects,n).concat(ie.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function nl(t,e,O){let i=e.selection,n=Ti(e.annotations);return e.userEvent&&(n=n.concat(Pe.userEvent.of(e.userEvent))),{changes:e.changes instanceof Xe?e.changes:Xe.of(e.changes||[],O,t.facet(_Q)),selection:i&&(i instanceof y?i:y.single(i.anchor,i.head)),effects:Ti(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function UQ(t,e,O){let i=nl(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(O=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(O=!1);let a=!!e[r].sequential;i=qQ(i,nl(t,e[r],a?i.changes.newLength:t.doc.length),a)}let n=Pe.create(t,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return jX(O?WX(n):n)}function WX(t){let e=t.startState,O=!0;for(let n of e.facet(YQ)){let r=n(t);if(r===!1){O=!1;break}Array.isArray(r)&&(O=O===!0?r:VX(O,r))}if(O!==!0){let n,r;if(O===!1)r=t.changes.invertedDesc,n=Xe.empty(e.doc.length);else{let a=t.changes.filter(O);n=a.changes,r=a.filtered.mapDesc(a.changes).invertedDesc}t=Pe.create(e,n,t.selection&&t.selection.map(r),ie.mapEffects(t.effects,r),t.annotations,t.scrollIntoView)}let i=e.facet(RQ);for(let n=i.length-1;n>=0;n--){let r=i[n](t);r instanceof Pe?t=r:Array.isArray(r)&&r.length==1&&r[0]instanceof Pe?t=r[0]:t=UQ(e,Ti(r),!1)}return t}function jX(t){let e=t.startState,O=e.facet(ZQ),i=t;for(let n=O.length-1;n>=0;n--){let r=O[n](t);r&&Object.keys(r).length&&(i=qQ(i,nl(e,r,t.changes.newLength),!0))}return i==t?t:Pe.create(e,t.changes,t.selection,i.effects,i.annotations,i.scrollIntoView)}const EX=[];function Ti(t){return t==null?EX:Array.isArray(t)?t:[t]}var de=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(de||(de={}));const CX=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let rl;try{rl=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function GX(t){if(rl)return rl.test(t);for(let e=0;e<t.length;e++){let O=t[e];if(/\w/.test(O)||O>"€"&&(O.toUpperCase()!=O.toLowerCase()||CX.test(O)))return!0}return!1}function AX(t){return e=>{if(!/\S/.test(e))return de.Space;if(GX(e))return de.Word;for(let O=0;O<t.length;O++)if(e.indexOf(t[O])>-1)return de.Word;return de.Other}}class re{constructor(e,O,i,n,r,a){this.config=e,this.doc=O,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,a&&(a._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)Pn(this,o<<1);this.computeSlot=null}field(e,O=!0){let i=this.config.address[e.id];if(i==null){if(O)throw new RangeError("Field is not present in this state");return}return Pn(this,i),fa(this,i)}update(...e){return UQ(this,e,!0)}applyTransaction(e){let O=this.config,{base:i,compartments:n}=O;for(let o of e.effects)o.is(Fa.reconfigure)?(O&&(n=new Map,O.compartments.forEach((s,l)=>n.set(l,s)),O=null),n.set(o.value.compartment,o.value.extension)):o.is(ie.reconfigure)?(O=null,i=o.value):o.is(ie.appendConfig)&&(O=null,i=Ti(i).concat(o.value));let r;O?r=e.startState.values.slice():(O=ua.resolve(i,n,this),r=new re(O,this.doc,this.selection,O.dynamicSlots.map(()=>null),(s,l)=>l.reconfigure(s,this),null).values);let a=e.startState.facet(il)?e.newSelection:e.newSelection.asSingle();new re(O,e.newDoc,a,r,(o,s)=>s.update(o,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(O=>({changes:{from:O.from,to:O.to,insert:e},range:y.cursor(O.from+e.length)}))}changeByRange(e){let O=this.selection,i=e(O.ranges[0]),n=this.changes(i.changes),r=[i.range],a=Ti(i.effects);for(let o=1;o<O.ranges.length;o++){let s=e(O.ranges[o]),l=this.changes(s.changes),c=l.map(n);for(let f=0;f<o;f++)r[f]=r[f].map(c);let u=n.mapDesc(l,!0);r.push(s.range.map(u)),n=n.compose(c),a=ie.mapEffects(a,c).concat(ie.mapEffects(Ti(s.effects),u))}return{changes:n,selection:y.create(r,O.mainIndex),effects:a}}changes(e=[]){return e instanceof Xe?e:Xe.of(e,this.doc.length,this.facet(re.lineSeparator))}toText(e){return Oe.of(e.split(this.facet(re.lineSeparator)||Ks))}sliceDoc(e=0,O=this.doc.length){return this.doc.sliceString(e,O,this.lineBreak)}facet(e){let O=this.config.address[e.id];return O==null?e.default:(Pn(this,O),fa(this,O))}toJSON(e){let O={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof rt&&this.config.address[n.id]!=null&&(O[i]=n.spec.toJSON(this.field(e[i]),this))}return O}static fromJSON(e,O={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let a=i[r],o=e[r];n.push(a.init(s=>a.spec.fromJSON(o,s)))}}return re.create({doc:e.doc,selection:y.fromJSON(e.selection),extensions:O.extensions?n.concat([O.extensions]):n})}static create(e={}){let O=ua.resolve(e.extensions||[],new Map),i=e.doc instanceof Oe?e.doc:Oe.of((e.doc||"").split(O.staticFacet(re.lineSeparator)||Ks)),n=e.selection?e.selection instanceof y?e.selection:y.single(e.selection.anchor,e.selection.head):y.single(0);return TQ(n,i.length),O.staticFacet(il)||(n=n.asSingle()),new re(O,i,n,O.dynamicSlots.map(()=>null),(r,a)=>a.create(r),null)}get tabSize(){return this.facet(re.tabSize)}get lineBreak(){return this.facet(re.lineSeparator)||`
@@ -1,4 +1,4 @@
1
- import{r as t,aL as S,l as y,j as e,I as L}from"./main-BA8NAb8s.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function oe({integration:o,onSave:f,onCancel:z}){const[r,I]=t.useState(o.values.authMethod||"oauth2"),[g,B]=t.useState(o.values.clientId||""),[v,q]=t.useState(""),[w,K]=t.useState(o.values.redirectBaseUrl||""),[m,$]=t.useState(""),[j,Y]=t.useState(o.values.impersonateEmail||""),[p,E]=t.useState(String(o.values.pollingIntervalMs??3e4)),[x,O]=t.useState(o.values.defaultApprovalKeywords||"approved,aprobado,autorizado,yes,ok"),[M,G]=t.useState(null),[n,T]=t.useState(null),[c,d]=t.useState(!1),[P,i]=t.useState(null),[U,F]=t.useState(!1),[H,J]=t.useState(!1),[N,W]=t.useState(!1),[b,h]=t.useState(o.status.connected?"connected":"credentials"),k=r==="oauth2"&&o.values.clientId==="********"&&o.values.clientSecret==="********",s=t.useRef(null),_=t.useRef(o.status.connected),u=t.useCallback(async()=>{try{const a=await S(y("/api/email/status"));if(a.ok){const l=await a.json();T(l),l.authenticated&&(h("connected"),s.current&&(clearInterval(s.current),s.current=null))}}catch(a){console.error("Failed to fetch Gmail status:",a)}},[]);t.useEffect(()=>{const a=o.status.connected,l=_.current;a&&!l&&b!=="connected"?h("connected"):!a&&l&&b==="connected"&&h("credentials"),_.current=a},[o.status.connected]),t.useEffect(()=>(u(),()=>{s.current&&clearInterval(s.current)}),[u]);const R=async()=>{const a=await S(y("/api/email/auth/url"));if(!a.ok){const A=await a.json().catch(()=>({}));throw new Error(A.error||`HTTP ${a.status}`)}const l=await a.json();if(!l.url)throw new Error("OAuth URL is empty");G(l.url),i(null),h("authorize"),s.current&&clearInterval(s.current),s.current=setInterval(u,3e3)},X=async()=>{d(!0),i(null);try{await R()}catch(a){i(a instanceof Error?a.message:"Failed to get OAuth URL")}finally{d(!1)}},Q=async()=>{if(!g.trim()){i("Client ID is required");return}d(!0),i(null);try{const a={authMethod:"oauth2",redirectBaseUrl:w.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x};g.trim()&&g.trim()!=="********"&&(a.clientId=g.trim()),v.trim()&&v.trim()!=="********"&&(a.clientSecret=v.trim()),await f(a),await R()}catch(a){const l=a instanceof Error?a.message:"Failed to get OAuth URL";i(l)}finally{d(!1)}},V=async()=>{if(!m.trim()){i("Service Account JSON is required");return}if(!j.trim()){i("Impersonate Email is required");return}try{const a=JSON.parse(m.trim());if(!a.client_email||!a.private_key){i("Service Account JSON must contain client_email and private_key");return}}catch{i("Invalid JSON in Service Account field");return}d(!0),i(null);try{await f({authMethod:"service_account",serviceAccountJson:m.trim(),impersonateEmail:j.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x}),await new Promise(a=>setTimeout(a,1e3)),await u()}catch(a){const l=a instanceof Error?a.message:"Failed to save service account";i(l)}finally{d(!1)}},Z=async()=>{F(!0),i(null);try{await f({pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x})}catch(a){i(a instanceof Error?a.message:"Failed to save settings")}finally{F(!1)}},ee=async()=>{const a=!(n!=null&&n.pollingActive);J(!0),i(null);try{const l=a?"/api/email/polling/start":"/api/email/polling/stop",A=a?{intervalMs:parseInt(p)||3e4}:{},C=await S(y(l),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)});if(!C.ok){const te=await C.json().catch(()=>({}));throw new Error(te.error||`HTTP ${C.status}`)}await u()}catch(l){i(l instanceof Error?l.message:"Failed to toggle polling")}finally{J(!1)}},ae=async()=>{d(!0),i(null);try{await f({refreshToken:"",serviceAccountJson:"",impersonateEmail:""}),T(null),G(null),h("credentials"),await u()}catch(a){i(a instanceof Error?a.message:"Failed to disconnect")}finally{d(!1)}},D=!!o.values.serviceAccountJson;return e.jsxs("div",{className:"gmail-oauth-setup",children:[P&&e.jsx("div",{className:"gmail-oauth-error",children:P}),b==="credentials"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsxs("div",{className:"gmail-oauth-field",style:{marginBottom:24},children:[e.jsx("label",{className:"integration-field-label",children:"Authentication Method"}),e.jsxs("div",{className:"gmail-auth-method-selector",children:[e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${r==="oauth2"?"active":""}`,onClick:()=>{I("oauth2"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:e.jsx(L,{name:"key",size:14})}),e.jsx("span",{className:"gmail-auth-method-label",children:"OAuth 2.0"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Browser login flow"})]}),e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${r==="service_account"?"active":""}`,onClick:()=>{I("service_account"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:e.jsx(L,{name:"robot",size:14})}),e.jsx("span",{className:"gmail-auth-method-label",children:"Service Account"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Domain-wide delegation"})]})]})]}),r==="oauth2"&&k&&!N&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Google OAuth Credentials"}),e.jsxs("div",{className:"gmail-oauth-shared-banner",children:[e.jsxs("div",{className:"gmail-oauth-shared-title",children:[e.jsx("span",{children:"✓"}),e.jsx("span",{children:"Credentials already configured"})]}),e.jsx("div",{className:"gmail-oauth-shared-body",children:"Existing Google OAuth credentials (Client ID and Secret) are saved in your secrets store — they're shared between Gmail, Calendar, and Drive. You may still need to re-authorize once so the refresh token grants Gmail access."})]})]}),r==="oauth2"&&(!k||N)&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Google OAuth Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Create OAuth2 credentials in the"," ",e.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"Google Cloud Console"}),". Enable the Gmail API and (optionally) the Calendar API. Set the redirect URI to:"," ",e.jsx("code",{className:"gmail-oauth-code",children:w.trim()?`${w.trim().replace(/\/$/,"")}/api/email/auth/callback`:y("/api/email/auth/callback")})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client ID ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"text",className:"integration-field-input",value:g,placeholder:"xxxx.apps.googleusercontent.com",onChange:a=>B(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client Secret ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"password",className:"integration-field-input",value:v,placeholder:o.values.clientSecret?"(saved)":"Enter client secret",onChange:a=>q(a.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"OAuth Redirect Base URL"}),e.jsx("input",{type:"text",className:"integration-field-input",value:w,placeholder:"http://localhost:6200",onChange:a=>K(a.target.value),autoComplete:"off"}),e.jsxs("span",{className:"integration-field-description",children:["Override the base URL used to build the OAuth redirect (e.g. ",e.jsx("code",{children:"http://commander.local:10003"}),"). Leave empty to use the server's local address. Google does not accept raw IPs — use a domain (you can map one in ",e.jsx("code",{children:"/etc/hosts"}),")."]})]})]}),r==="service_account"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Service Account Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Use a Google service account with"," ",e.jsx("a",{href:"https://admin.google.com/ac/owl/domainwidedelegation",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"domain-wide delegation"})," ","enabled. The service account must be authorized for Gmail scopes in Google Workspace Admin."]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Service Account JSON ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:m,placeholder:D?"(saved — paste new JSON to replace)":"Paste the full service account JSON key file contents",onChange:a=>$(a.target.value),rows:6,spellCheck:!1}),e.jsx("span",{className:"integration-field-description",children:"The JSON key file downloaded from Google Cloud Console containing client_email and private_key."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Impersonate Email ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"email",className:"integration-field-input",value:j,placeholder:"user@yourdomain.com",onChange:a=>Y(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"The email address to impersonate via domain-wide delegation. Must be a user in your Google Workspace domain."})]})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>E(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"How often to check for new emails. Default: 30000 (30s)."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:x,onChange:a=>O(a.target.value),rows:2}),e.jsx("span",{className:"integration-field-description",children:"Comma-separated keywords that indicate email approval."})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:z,children:"Cancel"}),r==="oauth2"&&k&&!N?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"integration-btn secondary",onClick:()=>W(!0),disabled:c,children:"Edit credentials"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:X,disabled:c,children:c?"Loading...":"Authorize with existing credentials"})]}):r==="oauth2"?e.jsx("button",{type:"button",className:"integration-btn save",onClick:Q,disabled:c||!g.trim(),children:c?"Saving...":"Save & Authorize"}):e.jsx("button",{type:"button",className:"integration-btn save",onClick:V,disabled:c||!j.trim()||!m.trim()&&!D,children:c?"Connecting...":"Save & Connect"})]})]}),b==="authorize"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Authorize Gmail Access"}),e.jsx("p",{className:"gmail-oauth-help",children:"Click the link below to authorize Tide Commander to access your Gmail account. After granting access, you will be redirected back and the connection will be established automatically."}),M&&e.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-authorize-btn",children:"Authorize with Google"}),e.jsxs("div",{className:"gmail-oauth-waiting",children:[e.jsx("span",{className:"gmail-oauth-spinner"}),e.jsx("span",{children:"Waiting for authorization to complete..."})]}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:()=>{s.current&&(clearInterval(s.current),s.current=null),h("credentials")},children:"Back"})})]}),b==="connected"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Gmail Connected"}),e.jsxs("div",{className:"gmail-oauth-connected-info",children:[e.jsx("span",{className:"gmail-oauth-connected-badge",children:"Connected"}),(n==null?void 0:n.emailAddress)&&e.jsx("span",{className:"gmail-oauth-email",children:n.emailAddress}),e.jsx("span",{className:"gmail-oauth-auth-type",children:r==="service_account"?"Service Account":"OAuth 2.0"})]}),e.jsxs("div",{className:"gmail-polling-toggle-row",children:[e.jsxs("div",{className:"gmail-polling-toggle-info",children:[e.jsx("div",{className:"gmail-polling-toggle-label",children:"Automatic Polling"}),e.jsx("div",{className:"gmail-polling-toggle-status",children:n!=null&&n.pollingActive?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"gmail-polling-dot active"}),"Active",n.lastChecked&&e.jsxs("span",{className:"gmail-polling-last",children:["— last checked ",new Date(n.lastChecked).toLocaleTimeString()]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"gmail-polling-dot paused"}),"Paused — new emails will not be ingested"]})})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":!!(n!=null&&n.pollingActive),"aria-label":"Toggle automatic polling",className:`gmail-polling-switch ${n!=null&&n.pollingActive?"on":"off"}`,onClick:ee,disabled:H,children:e.jsx("span",{className:"gmail-polling-switch-thumb"})})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>E(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:x,onChange:a=>O(a.target.value),rows:2})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:z,children:"Close"}),e.jsx("button",{type:"button",className:"integration-btn",style:{backgroundColor:"#f38ba8",color:"#1e1e2e"},onClick:ae,disabled:c,children:c?"Disconnecting...":"Disconnect"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:Z,disabled:U,children:U?"Saving...":"Save Settings"})]})]}),e.jsx("style",{children:`
1
+ import{r as t,aL as S,l as y,j as e,I as L}from"./main-3di6rXWx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function oe({integration:o,onSave:f,onCancel:z}){const[r,I]=t.useState(o.values.authMethod||"oauth2"),[g,B]=t.useState(o.values.clientId||""),[v,q]=t.useState(""),[w,K]=t.useState(o.values.redirectBaseUrl||""),[m,$]=t.useState(""),[j,Y]=t.useState(o.values.impersonateEmail||""),[p,E]=t.useState(String(o.values.pollingIntervalMs??3e4)),[x,O]=t.useState(o.values.defaultApprovalKeywords||"approved,aprobado,autorizado,yes,ok"),[M,G]=t.useState(null),[n,T]=t.useState(null),[c,d]=t.useState(!1),[P,i]=t.useState(null),[U,F]=t.useState(!1),[H,J]=t.useState(!1),[N,W]=t.useState(!1),[b,h]=t.useState(o.status.connected?"connected":"credentials"),k=r==="oauth2"&&o.values.clientId==="********"&&o.values.clientSecret==="********",s=t.useRef(null),_=t.useRef(o.status.connected),u=t.useCallback(async()=>{try{const a=await S(y("/api/email/status"));if(a.ok){const l=await a.json();T(l),l.authenticated&&(h("connected"),s.current&&(clearInterval(s.current),s.current=null))}}catch(a){console.error("Failed to fetch Gmail status:",a)}},[]);t.useEffect(()=>{const a=o.status.connected,l=_.current;a&&!l&&b!=="connected"?h("connected"):!a&&l&&b==="connected"&&h("credentials"),_.current=a},[o.status.connected]),t.useEffect(()=>(u(),()=>{s.current&&clearInterval(s.current)}),[u]);const R=async()=>{const a=await S(y("/api/email/auth/url"));if(!a.ok){const A=await a.json().catch(()=>({}));throw new Error(A.error||`HTTP ${a.status}`)}const l=await a.json();if(!l.url)throw new Error("OAuth URL is empty");G(l.url),i(null),h("authorize"),s.current&&clearInterval(s.current),s.current=setInterval(u,3e3)},X=async()=>{d(!0),i(null);try{await R()}catch(a){i(a instanceof Error?a.message:"Failed to get OAuth URL")}finally{d(!1)}},Q=async()=>{if(!g.trim()){i("Client ID is required");return}d(!0),i(null);try{const a={authMethod:"oauth2",redirectBaseUrl:w.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x};g.trim()&&g.trim()!=="********"&&(a.clientId=g.trim()),v.trim()&&v.trim()!=="********"&&(a.clientSecret=v.trim()),await f(a),await R()}catch(a){const l=a instanceof Error?a.message:"Failed to get OAuth URL";i(l)}finally{d(!1)}},V=async()=>{if(!m.trim()){i("Service Account JSON is required");return}if(!j.trim()){i("Impersonate Email is required");return}try{const a=JSON.parse(m.trim());if(!a.client_email||!a.private_key){i("Service Account JSON must contain client_email and private_key");return}}catch{i("Invalid JSON in Service Account field");return}d(!0),i(null);try{await f({authMethod:"service_account",serviceAccountJson:m.trim(),impersonateEmail:j.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x}),await new Promise(a=>setTimeout(a,1e3)),await u()}catch(a){const l=a instanceof Error?a.message:"Failed to save service account";i(l)}finally{d(!1)}},Z=async()=>{F(!0),i(null);try{await f({pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x})}catch(a){i(a instanceof Error?a.message:"Failed to save settings")}finally{F(!1)}},ee=async()=>{const a=!(n!=null&&n.pollingActive);J(!0),i(null);try{const l=a?"/api/email/polling/start":"/api/email/polling/stop",A=a?{intervalMs:parseInt(p)||3e4}:{},C=await S(y(l),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)});if(!C.ok){const te=await C.json().catch(()=>({}));throw new Error(te.error||`HTTP ${C.status}`)}await u()}catch(l){i(l instanceof Error?l.message:"Failed to toggle polling")}finally{J(!1)}},ae=async()=>{d(!0),i(null);try{await f({refreshToken:"",serviceAccountJson:"",impersonateEmail:""}),T(null),G(null),h("credentials"),await u()}catch(a){i(a instanceof Error?a.message:"Failed to disconnect")}finally{d(!1)}},D=!!o.values.serviceAccountJson;return e.jsxs("div",{className:"gmail-oauth-setup",children:[P&&e.jsx("div",{className:"gmail-oauth-error",children:P}),b==="credentials"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsxs("div",{className:"gmail-oauth-field",style:{marginBottom:24},children:[e.jsx("label",{className:"integration-field-label",children:"Authentication Method"}),e.jsxs("div",{className:"gmail-auth-method-selector",children:[e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${r==="oauth2"?"active":""}`,onClick:()=>{I("oauth2"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:e.jsx(L,{name:"key",size:14})}),e.jsx("span",{className:"gmail-auth-method-label",children:"OAuth 2.0"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Browser login flow"})]}),e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${r==="service_account"?"active":""}`,onClick:()=>{I("service_account"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:e.jsx(L,{name:"robot",size:14})}),e.jsx("span",{className:"gmail-auth-method-label",children:"Service Account"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Domain-wide delegation"})]})]})]}),r==="oauth2"&&k&&!N&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Google OAuth Credentials"}),e.jsxs("div",{className:"gmail-oauth-shared-banner",children:[e.jsxs("div",{className:"gmail-oauth-shared-title",children:[e.jsx("span",{children:"✓"}),e.jsx("span",{children:"Credentials already configured"})]}),e.jsx("div",{className:"gmail-oauth-shared-body",children:"Existing Google OAuth credentials (Client ID and Secret) are saved in your secrets store — they're shared between Gmail, Calendar, and Drive. You may still need to re-authorize once so the refresh token grants Gmail access."})]})]}),r==="oauth2"&&(!k||N)&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Google OAuth Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Create OAuth2 credentials in the"," ",e.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"Google Cloud Console"}),". Enable the Gmail API and (optionally) the Calendar API. Set the redirect URI to:"," ",e.jsx("code",{className:"gmail-oauth-code",children:w.trim()?`${w.trim().replace(/\/$/,"")}/api/email/auth/callback`:y("/api/email/auth/callback")})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client ID ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"text",className:"integration-field-input",value:g,placeholder:"xxxx.apps.googleusercontent.com",onChange:a=>B(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client Secret ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"password",className:"integration-field-input",value:v,placeholder:o.values.clientSecret?"(saved)":"Enter client secret",onChange:a=>q(a.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"OAuth Redirect Base URL"}),e.jsx("input",{type:"text",className:"integration-field-input",value:w,placeholder:"http://localhost:6200",onChange:a=>K(a.target.value),autoComplete:"off"}),e.jsxs("span",{className:"integration-field-description",children:["Override the base URL used to build the OAuth redirect (e.g. ",e.jsx("code",{children:"http://commander.local:10003"}),"). Leave empty to use the server's local address. Google does not accept raw IPs — use a domain (you can map one in ",e.jsx("code",{children:"/etc/hosts"}),")."]})]})]}),r==="service_account"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Service Account Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Use a Google service account with"," ",e.jsx("a",{href:"https://admin.google.com/ac/owl/domainwidedelegation",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"domain-wide delegation"})," ","enabled. The service account must be authorized for Gmail scopes in Google Workspace Admin."]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Service Account JSON ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:m,placeholder:D?"(saved — paste new JSON to replace)":"Paste the full service account JSON key file contents",onChange:a=>$(a.target.value),rows:6,spellCheck:!1}),e.jsx("span",{className:"integration-field-description",children:"The JSON key file downloaded from Google Cloud Console containing client_email and private_key."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Impersonate Email ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"email",className:"integration-field-input",value:j,placeholder:"user@yourdomain.com",onChange:a=>Y(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"The email address to impersonate via domain-wide delegation. Must be a user in your Google Workspace domain."})]})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>E(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"How often to check for new emails. Default: 30000 (30s)."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:x,onChange:a=>O(a.target.value),rows:2}),e.jsx("span",{className:"integration-field-description",children:"Comma-separated keywords that indicate email approval."})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:z,children:"Cancel"}),r==="oauth2"&&k&&!N?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"integration-btn secondary",onClick:()=>W(!0),disabled:c,children:"Edit credentials"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:X,disabled:c,children:c?"Loading...":"Authorize with existing credentials"})]}):r==="oauth2"?e.jsx("button",{type:"button",className:"integration-btn save",onClick:Q,disabled:c||!g.trim(),children:c?"Saving...":"Save & Authorize"}):e.jsx("button",{type:"button",className:"integration-btn save",onClick:V,disabled:c||!j.trim()||!m.trim()&&!D,children:c?"Connecting...":"Save & Connect"})]})]}),b==="authorize"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Authorize Gmail Access"}),e.jsx("p",{className:"gmail-oauth-help",children:"Click the link below to authorize Tide Commander to access your Gmail account. After granting access, you will be redirected back and the connection will be established automatically."}),M&&e.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-authorize-btn",children:"Authorize with Google"}),e.jsxs("div",{className:"gmail-oauth-waiting",children:[e.jsx("span",{className:"gmail-oauth-spinner"}),e.jsx("span",{children:"Waiting for authorization to complete..."})]}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:()=>{s.current&&(clearInterval(s.current),s.current=null),h("credentials")},children:"Back"})})]}),b==="connected"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Gmail Connected"}),e.jsxs("div",{className:"gmail-oauth-connected-info",children:[e.jsx("span",{className:"gmail-oauth-connected-badge",children:"Connected"}),(n==null?void 0:n.emailAddress)&&e.jsx("span",{className:"gmail-oauth-email",children:n.emailAddress}),e.jsx("span",{className:"gmail-oauth-auth-type",children:r==="service_account"?"Service Account":"OAuth 2.0"})]}),e.jsxs("div",{className:"gmail-polling-toggle-row",children:[e.jsxs("div",{className:"gmail-polling-toggle-info",children:[e.jsx("div",{className:"gmail-polling-toggle-label",children:"Automatic Polling"}),e.jsx("div",{className:"gmail-polling-toggle-status",children:n!=null&&n.pollingActive?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"gmail-polling-dot active"}),"Active",n.lastChecked&&e.jsxs("span",{className:"gmail-polling-last",children:["— last checked ",new Date(n.lastChecked).toLocaleTimeString()]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"gmail-polling-dot paused"}),"Paused — new emails will not be ingested"]})})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":!!(n!=null&&n.pollingActive),"aria-label":"Toggle automatic polling",className:`gmail-polling-switch ${n!=null&&n.pollingActive?"on":"off"}`,onClick:ee,disabled:H,children:e.jsx("span",{className:"gmail-polling-switch-thumb"})})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>E(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:x,onChange:a=>O(a.target.value),rows:2})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:z,children:"Close"}),e.jsx("button",{type:"button",className:"integration-btn",style:{backgroundColor:"#f38ba8",color:"#1e1e2e"},onClick:ae,disabled:c,children:c?"Disconnecting...":"Disconnect"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:Z,disabled:U,children:U?"Saving...":"Save Settings"})]})]}),e.jsx("style",{children:`
2
2
  .gmail-oauth-setup {
3
3
  padding: 0;
4
4
  }
@@ -1,4 +1,4 @@
1
- import{r as t,aL as w,l as v,j as e}from"./main-BA8NAb8s.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function B({integration:o,onSave:j,onCancel:h}){const[l,C]=t.useState(o.values.GOOGLE_CLIENT_ID||""),[p,E]=t.useState(""),[b,S]=t.useState(o.values.GOOGLE_REDIRECT_BASE_URL||""),[y,G]=t.useState(null),[g,O]=t.useState(null),[c,u]=t.useState(!1),[N,s]=t.useState(null),[A,z]=t.useState(!1),L=o.values.GOOGLE_CLIENT_ID==="********"&&o.values.GOOGLE_CLIENT_SECRET==="********",[x,f]=t.useState(o.status.connected?"connected":"credentials"),r=t.useRef(null),m=t.useCallback(async()=>{try{const n={gmail:"/api/email/status","google-calendar":"/api/calendar/status","google-drive":"/api/drive/status"}[o.id]||"/api/calendar/status",i=await w(v(n));if(i.ok){const d=await i.json();O(d),d.authenticated&&(f("connected"),r.current&&(clearInterval(r.current),r.current=null))}}catch(a){console.error("Failed to fetch Google auth status:",a)}},[o.id]);t.useEffect(()=>(m(),()=>{r.current&&clearInterval(r.current)}),[m]);const k=async()=>{const n={gmail:"/api/email/auth/url","google-calendar":"/api/calendar/auth/url","google-drive":"/api/drive/auth/url"}[o.id]||"/api/calendar/auth/url",i=await w(v(n));if(!i.ok){const _=await i.json().catch(()=>({}));throw new Error(_.error||`HTTP ${i.status}`)}const d=await i.json();if(!d.url)throw new Error("OAuth URL is empty");G(d.url),s(null),f("authorize"),r.current&&clearInterval(r.current),r.current=setInterval(m,3e3)},I=async()=>{u(!0),s(null);try{await k()}catch(a){s(a instanceof Error?a.message:"Failed to get OAuth URL")}finally{u(!1)}},R=async()=>{if(!l.trim()){s("Client ID is required");return}u(!0),s(null);try{const a={GOOGLE_REDIRECT_BASE_URL:b.trim()};l.trim()&&l.trim()!=="********"&&(a.GOOGLE_CLIENT_ID=l.trim()),p.trim()&&(a.GOOGLE_CLIENT_SECRET=p.trim()),console.log("Saving Google OAuth config...",a),await j(a),console.log("Config saved successfully"),await k()}catch(a){const n=a instanceof Error?a.message:"Failed to get OAuth URL";console.error("Error in handleSaveCredentials:",n,a),s(n)}finally{u(!1)}};return e.jsxs("div",{className:"google-oauth-setup",children:[N&&e.jsx("div",{className:"google-oauth-error",children:N}),x==="credentials"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Google OAuth Credentials"}),L&&!A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"google-oauth-shared-banner",children:[e.jsxs("div",{className:"google-oauth-shared-title",children:[e.jsx("span",{children:"✓"}),e.jsx("span",{children:"Credentials already configured"})]}),e.jsx("div",{className:"google-oauth-shared-body",children:"Existing Google OAuth credentials (Client ID and Secret) are saved in your secrets store — they're shared between Gmail, Calendar, and Drive. You may still need to re-authorize once so the refresh token grants access to this service."})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:h,children:"Cancel"}),e.jsx("button",{type:"button",className:"integration-btn secondary",onClick:()=>z(!0),disabled:c,children:"Edit credentials"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:I,disabled:c,children:c?"Loading...":"Authorize with existing credentials"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"google-oauth-help",children:["Create OAuth2 credentials in the"," ",e.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"google-oauth-link",children:"Google Cloud Console"}),". Enable the relevant API (Gmail, Calendar, or Drive). Set the redirect URI to:"," ",e.jsx("code",{className:"google-oauth-code",children:(()=>{const a=o.id==="gmail"?"/api/email/auth/callback":o.id==="google-drive"?"/api/drive/auth/callback":"/api/calendar/auth/callback",n=b.trim();return n?`${n.replace(/\/$/,"")}${a}`:v(a)})()})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client ID ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"text",className:"integration-field-input",value:l,placeholder:"xxxx.apps.googleusercontent.com",onChange:a=>C(a.target.value)})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client Secret ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"password",className:"integration-field-input",value:p,placeholder:o.values.GOOGLE_CLIENT_SECRET?"(saved)":"Enter client secret",onChange:a=>E(a.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"OAuth Redirect Base URL"}),e.jsx("input",{type:"text",className:"integration-field-input",value:b,placeholder:"http://localhost:6200",onChange:a=>S(a.target.value),autoComplete:"off"}),e.jsxs("span",{className:"integration-field-description",style:{display:"block",marginTop:7,color:"#7f849c",fontSize:12},children:["Override the base URL used to build the OAuth redirect (e.g. ",e.jsx("code",{children:"http://commander.local:10003"}),"). Shared across Gmail, Calendar, and Drive. Leave empty to use the server's local address. Google does not accept raw IPs — use a domain (you can map one in ",e.jsx("code",{children:"/etc/hosts"}),")."]})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:h,children:"Cancel"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:R,disabled:c||!l.trim(),children:c?"Saving...":"Save & Authorize"})]})]})]}),x==="authorize"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Authorize Google Access"}),e.jsx("p",{className:"google-oauth-help",children:"Click the link below to authorize Tide Commander to access your Google account. After granting access, you will be redirected back and the connection will be established automatically."}),y&&e.jsx("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:"google-oauth-authorize-btn",children:"Authorize with Google"}),e.jsxs("div",{className:"google-oauth-waiting",children:[e.jsx("span",{className:"google-oauth-spinner"}),e.jsx("span",{children:"Waiting for authorization to complete..."})]}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:()=>{r.current&&(clearInterval(r.current),r.current=null),f("credentials")},children:"Back"})})]}),x==="connected"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Google Connected"}),e.jsxs("div",{className:"google-oauth-connected-info",children:[e.jsx("span",{className:"google-oauth-connected-badge",children:"Connected"}),(g==null?void 0:g.emailAddress)&&e.jsx("span",{className:"google-oauth-email",children:g.emailAddress})]}),e.jsx("p",{className:"google-oauth-help",children:"Your Google account has been successfully connected."}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:async()=>{await j({}),h()},children:"Close"})})]}),e.jsx("style",{children:`
1
+ import{r as t,aL as w,l as v,j as e}from"./main-3di6rXWx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function B({integration:o,onSave:j,onCancel:h}){const[l,C]=t.useState(o.values.GOOGLE_CLIENT_ID||""),[p,E]=t.useState(""),[b,S]=t.useState(o.values.GOOGLE_REDIRECT_BASE_URL||""),[y,G]=t.useState(null),[g,O]=t.useState(null),[c,u]=t.useState(!1),[N,s]=t.useState(null),[A,z]=t.useState(!1),L=o.values.GOOGLE_CLIENT_ID==="********"&&o.values.GOOGLE_CLIENT_SECRET==="********",[x,f]=t.useState(o.status.connected?"connected":"credentials"),r=t.useRef(null),m=t.useCallback(async()=>{try{const n={gmail:"/api/email/status","google-calendar":"/api/calendar/status","google-drive":"/api/drive/status"}[o.id]||"/api/calendar/status",i=await w(v(n));if(i.ok){const d=await i.json();O(d),d.authenticated&&(f("connected"),r.current&&(clearInterval(r.current),r.current=null))}}catch(a){console.error("Failed to fetch Google auth status:",a)}},[o.id]);t.useEffect(()=>(m(),()=>{r.current&&clearInterval(r.current)}),[m]);const k=async()=>{const n={gmail:"/api/email/auth/url","google-calendar":"/api/calendar/auth/url","google-drive":"/api/drive/auth/url"}[o.id]||"/api/calendar/auth/url",i=await w(v(n));if(!i.ok){const _=await i.json().catch(()=>({}));throw new Error(_.error||`HTTP ${i.status}`)}const d=await i.json();if(!d.url)throw new Error("OAuth URL is empty");G(d.url),s(null),f("authorize"),r.current&&clearInterval(r.current),r.current=setInterval(m,3e3)},I=async()=>{u(!0),s(null);try{await k()}catch(a){s(a instanceof Error?a.message:"Failed to get OAuth URL")}finally{u(!1)}},R=async()=>{if(!l.trim()){s("Client ID is required");return}u(!0),s(null);try{const a={GOOGLE_REDIRECT_BASE_URL:b.trim()};l.trim()&&l.trim()!=="********"&&(a.GOOGLE_CLIENT_ID=l.trim()),p.trim()&&(a.GOOGLE_CLIENT_SECRET=p.trim()),console.log("Saving Google OAuth config...",a),await j(a),console.log("Config saved successfully"),await k()}catch(a){const n=a instanceof Error?a.message:"Failed to get OAuth URL";console.error("Error in handleSaveCredentials:",n,a),s(n)}finally{u(!1)}};return e.jsxs("div",{className:"google-oauth-setup",children:[N&&e.jsx("div",{className:"google-oauth-error",children:N}),x==="credentials"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Google OAuth Credentials"}),L&&!A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"google-oauth-shared-banner",children:[e.jsxs("div",{className:"google-oauth-shared-title",children:[e.jsx("span",{children:"✓"}),e.jsx("span",{children:"Credentials already configured"})]}),e.jsx("div",{className:"google-oauth-shared-body",children:"Existing Google OAuth credentials (Client ID and Secret) are saved in your secrets store — they're shared between Gmail, Calendar, and Drive. You may still need to re-authorize once so the refresh token grants access to this service."})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:h,children:"Cancel"}),e.jsx("button",{type:"button",className:"integration-btn secondary",onClick:()=>z(!0),disabled:c,children:"Edit credentials"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:I,disabled:c,children:c?"Loading...":"Authorize with existing credentials"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"google-oauth-help",children:["Create OAuth2 credentials in the"," ",e.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"google-oauth-link",children:"Google Cloud Console"}),". Enable the relevant API (Gmail, Calendar, or Drive). Set the redirect URI to:"," ",e.jsx("code",{className:"google-oauth-code",children:(()=>{const a=o.id==="gmail"?"/api/email/auth/callback":o.id==="google-drive"?"/api/drive/auth/callback":"/api/calendar/auth/callback",n=b.trim();return n?`${n.replace(/\/$/,"")}${a}`:v(a)})()})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client ID ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"text",className:"integration-field-input",value:l,placeholder:"xxxx.apps.googleusercontent.com",onChange:a=>C(a.target.value)})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client Secret ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"password",className:"integration-field-input",value:p,placeholder:o.values.GOOGLE_CLIENT_SECRET?"(saved)":"Enter client secret",onChange:a=>E(a.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"OAuth Redirect Base URL"}),e.jsx("input",{type:"text",className:"integration-field-input",value:b,placeholder:"http://localhost:6200",onChange:a=>S(a.target.value),autoComplete:"off"}),e.jsxs("span",{className:"integration-field-description",style:{display:"block",marginTop:7,color:"#7f849c",fontSize:12},children:["Override the base URL used to build the OAuth redirect (e.g. ",e.jsx("code",{children:"http://commander.local:10003"}),"). Shared across Gmail, Calendar, and Drive. Leave empty to use the server's local address. Google does not accept raw IPs — use a domain (you can map one in ",e.jsx("code",{children:"/etc/hosts"}),")."]})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:h,children:"Cancel"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:R,disabled:c||!l.trim(),children:c?"Saving...":"Save & Authorize"})]})]})]}),x==="authorize"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Authorize Google Access"}),e.jsx("p",{className:"google-oauth-help",children:"Click the link below to authorize Tide Commander to access your Google account. After granting access, you will be redirected back and the connection will be established automatically."}),y&&e.jsx("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:"google-oauth-authorize-btn",children:"Authorize with Google"}),e.jsxs("div",{className:"google-oauth-waiting",children:[e.jsx("span",{className:"google-oauth-spinner"}),e.jsx("span",{children:"Waiting for authorization to complete..."})]}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:()=>{r.current&&(clearInterval(r.current),r.current=null),f("credentials")},children:"Back"})})]}),x==="connected"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Google Connected"}),e.jsxs("div",{className:"google-oauth-connected-info",children:[e.jsx("span",{className:"google-oauth-connected-badge",children:"Connected"}),(g==null?void 0:g.emailAddress)&&e.jsx("span",{className:"google-oauth-email",children:g.emailAddress})]}),e.jsx("p",{className:"google-oauth-help",children:"Your Google account has been successfully connected."}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:async()=>{await j({}),h()},children:"Close"})})]}),e.jsx("style",{children:`
2
2
  .google-oauth-setup {
3
3
  padding: 0;
4
4
  }
@@ -1 +1 @@
1
- import{u as K,r as a,j as e}from"./main-BA8NAb8s.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function se({url:l,title:W,isOpen:g,onClose:I,initialWidth:H=480,initialHeight:B=360,minWidth:M=320,minHeight:b=240}){const{t:n}=K(["terminal","common"]),[Z,h]=a.useState(!0),[L,k]=a.useState(!1),[o,$]=a.useState({width:H,height:B}),[s,y]=a.useState(null),[f,z]=a.useState(1),[O,R]=a.useState(!1),[T,X]=a.useState(!1),N=a.useRef(null),U=a.useRef(null),d=a.useRef(null),r=a.useRef(null);a.useEffect(()=>{if(g&&!s){const t=Math.max(50,(window.innerWidth-o.width)/2),c=Math.max(50,(window.innerHeight-o.height)/2);y({x:t,y:c})}},[g,s,o.width,o.height]),a.useEffect(()=>{h(!0),k(!1)},[l]);const A=a.useCallback(()=>{h(!1)},[]),V=a.useCallback(()=>{h(!1),k(!0)},[]),Y=a.useCallback(()=>{N.current&&(h(!0),k(!1),N.current.src=l)},[l]),_=a.useCallback(()=>{window.open(l,"_blank")},[l]),q=a.useCallback(()=>{z(t=>Math.min(2,t+.25))},[]),F=a.useCallback(()=>{z(t=>Math.max(.25,t-.25))},[]),G=a.useCallback(()=>{z(1)},[]),J=a.useCallback(t=>{if(t.target.closest(".iframe-modal-btn"))return;t.preventDefault(),R(!0),d.current={startX:t.clientX,startY:t.clientY,startPosX:(s==null?void 0:s.x)??0,startPosY:(s==null?void 0:s.y)??0};const c=m=>{if(!d.current)return;const w=m.clientX-d.current.startX,j=m.clientY-d.current.startY;y({x:Math.max(0,Math.min(window.innerWidth-100,d.current.startPosX+w)),y:Math.max(0,Math.min(window.innerHeight-50,d.current.startPosY+j))})},x=()=>{d.current=null,R(!1),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",x)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",x)},[s]),i=a.useCallback((t,c)=>{t.preventDefault(),t.stopPropagation(),X(!0);const x={startX:t.clientX,startY:t.clientY,startW:o.width,startH:o.height,startPosX:(s==null?void 0:s.x)??0,startPosY:(s==null?void 0:s.y)??0,direction:c};r.current=x;const m=j=>{if(!r.current)return;const p=j.clientX-r.current.startX,C=j.clientY-r.current.startY,v=r.current.direction;let E=r.current.startW,D=r.current.startH,P=r.current.startPosX,S=r.current.startPosY;if(v.includes("e")&&(E=Math.max(M,r.current.startW+p)),v.includes("w")){const u=r.current.startW-p;u>=M&&(E=u,P=r.current.startPosX+p)}if(v.includes("s")&&(D=Math.max(b,r.current.startH+C)),v.includes("n")){const u=r.current.startH-C;u>=b&&(D=u,S=r.current.startPosY+C)}$({width:E,height:D}),y({x:P,y:S})},w=()=>{r.current=null,X(!1),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",w)},[o,s,M,b]);return g?e.jsxs("div",{ref:U,className:`iframe-modal ${O?"dragging":""} ${T?"resizing":""}`,style:{left:(s==null?void 0:s.x)??0,top:(s==null?void 0:s.y)??0,width:o.width,height:o.height},children:[e.jsxs("div",{className:"iframe-modal-toolbar",onMouseDown:J,children:[e.jsx("div",{className:"iframe-modal-title",title:l,children:W||l}),e.jsxs("div",{className:"iframe-modal-actions",children:[e.jsx("button",{className:"iframe-modal-btn",onClick:F,title:n("terminal:iframeModal.zoomOut"),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("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),e.jsxs("button",{className:"iframe-modal-btn iframe-modal-zoom-label",onClick:G,title:n("terminal:iframeModal.resetZoom"),children:[Math.round(f*100),"%"]}),e.jsx("button",{className:"iframe-modal-btn",onClick:q,title:n("terminal:iframeModal.zoomIn"),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("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),e.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),e.jsx("div",{className:"iframe-modal-separator"}),e.jsx("button",{className:"iframe-modal-btn",onClick:Y,title:n("terminal:iframeModal.refresh"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M23 4v6h-6M1 20v-6h6"}),e.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]})}),e.jsx("button",{className:"iframe-modal-btn",onClick:_,title:n("terminal:iframeModal.openInBrowser"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}),e.jsx("button",{className:"iframe-modal-btn iframe-modal-close",onClick:I,title:n("common:buttons.close"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),e.jsxs("div",{className:"iframe-modal-content",children:[Z&&e.jsxs("div",{className:"iframe-modal-loading",children:[e.jsx("div",{className:"iframe-modal-spinner"}),e.jsx("span",{children:n("common:status.loading")})]}),L&&e.jsxs("div",{className:"iframe-modal-error",children:[e.jsx("span",{children:n("terminal:iframeModal.failedToLoad")}),e.jsx("button",{onClick:Y,children:n("terminal:iframeModal.retry")})]}),e.jsx("iframe",{ref:N,src:l,className:"iframe-modal-frame",onLoad:A,onError:V,style:{display:L?"none":"block",transform:`scale(${f})`,transformOrigin:"top left",width:`${100/f}%`,height:`${100/f}%`}})]}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-n",onMouseDown:t=>i(t,"n")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-s",onMouseDown:t=>i(t,"s")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-e",onMouseDown:t=>i(t,"e")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-w",onMouseDown:t=>i(t,"w")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-ne",onMouseDown:t=>i(t,"ne")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-nw",onMouseDown:t=>i(t,"nw")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-se",onMouseDown:t=>i(t,"se")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-sw",onMouseDown:t=>i(t,"sw")})]}):null}export{se as IframeModal,se as default};
1
+ import{u as K,r as a,j as e}from"./main-3di6rXWx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function se({url:l,title:W,isOpen:g,onClose:I,initialWidth:H=480,initialHeight:B=360,minWidth:M=320,minHeight:b=240}){const{t:n}=K(["terminal","common"]),[Z,h]=a.useState(!0),[L,k]=a.useState(!1),[o,$]=a.useState({width:H,height:B}),[s,y]=a.useState(null),[f,z]=a.useState(1),[O,R]=a.useState(!1),[T,X]=a.useState(!1),N=a.useRef(null),U=a.useRef(null),d=a.useRef(null),r=a.useRef(null);a.useEffect(()=>{if(g&&!s){const t=Math.max(50,(window.innerWidth-o.width)/2),c=Math.max(50,(window.innerHeight-o.height)/2);y({x:t,y:c})}},[g,s,o.width,o.height]),a.useEffect(()=>{h(!0),k(!1)},[l]);const A=a.useCallback(()=>{h(!1)},[]),V=a.useCallback(()=>{h(!1),k(!0)},[]),Y=a.useCallback(()=>{N.current&&(h(!0),k(!1),N.current.src=l)},[l]),_=a.useCallback(()=>{window.open(l,"_blank")},[l]),q=a.useCallback(()=>{z(t=>Math.min(2,t+.25))},[]),F=a.useCallback(()=>{z(t=>Math.max(.25,t-.25))},[]),G=a.useCallback(()=>{z(1)},[]),J=a.useCallback(t=>{if(t.target.closest(".iframe-modal-btn"))return;t.preventDefault(),R(!0),d.current={startX:t.clientX,startY:t.clientY,startPosX:(s==null?void 0:s.x)??0,startPosY:(s==null?void 0:s.y)??0};const c=m=>{if(!d.current)return;const w=m.clientX-d.current.startX,j=m.clientY-d.current.startY;y({x:Math.max(0,Math.min(window.innerWidth-100,d.current.startPosX+w)),y:Math.max(0,Math.min(window.innerHeight-50,d.current.startPosY+j))})},x=()=>{d.current=null,R(!1),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",x)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",x)},[s]),i=a.useCallback((t,c)=>{t.preventDefault(),t.stopPropagation(),X(!0);const x={startX:t.clientX,startY:t.clientY,startW:o.width,startH:o.height,startPosX:(s==null?void 0:s.x)??0,startPosY:(s==null?void 0:s.y)??0,direction:c};r.current=x;const m=j=>{if(!r.current)return;const p=j.clientX-r.current.startX,C=j.clientY-r.current.startY,v=r.current.direction;let E=r.current.startW,D=r.current.startH,P=r.current.startPosX,S=r.current.startPosY;if(v.includes("e")&&(E=Math.max(M,r.current.startW+p)),v.includes("w")){const u=r.current.startW-p;u>=M&&(E=u,P=r.current.startPosX+p)}if(v.includes("s")&&(D=Math.max(b,r.current.startH+C)),v.includes("n")){const u=r.current.startH-C;u>=b&&(D=u,S=r.current.startPosY+C)}$({width:E,height:D}),y({x:P,y:S})},w=()=>{r.current=null,X(!1),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",w)},[o,s,M,b]);return g?e.jsxs("div",{ref:U,className:`iframe-modal ${O?"dragging":""} ${T?"resizing":""}`,style:{left:(s==null?void 0:s.x)??0,top:(s==null?void 0:s.y)??0,width:o.width,height:o.height},children:[e.jsxs("div",{className:"iframe-modal-toolbar",onMouseDown:J,children:[e.jsx("div",{className:"iframe-modal-title",title:l,children:W||l}),e.jsxs("div",{className:"iframe-modal-actions",children:[e.jsx("button",{className:"iframe-modal-btn",onClick:F,title:n("terminal:iframeModal.zoomOut"),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("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),e.jsxs("button",{className:"iframe-modal-btn iframe-modal-zoom-label",onClick:G,title:n("terminal:iframeModal.resetZoom"),children:[Math.round(f*100),"%"]}),e.jsx("button",{className:"iframe-modal-btn",onClick:q,title:n("terminal:iframeModal.zoomIn"),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("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),e.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),e.jsx("div",{className:"iframe-modal-separator"}),e.jsx("button",{className:"iframe-modal-btn",onClick:Y,title:n("terminal:iframeModal.refresh"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M23 4v6h-6M1 20v-6h6"}),e.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]})}),e.jsx("button",{className:"iframe-modal-btn",onClick:_,title:n("terminal:iframeModal.openInBrowser"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}),e.jsx("button",{className:"iframe-modal-btn iframe-modal-close",onClick:I,title:n("common:buttons.close"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),e.jsxs("div",{className:"iframe-modal-content",children:[Z&&e.jsxs("div",{className:"iframe-modal-loading",children:[e.jsx("div",{className:"iframe-modal-spinner"}),e.jsx("span",{children:n("common:status.loading")})]}),L&&e.jsxs("div",{className:"iframe-modal-error",children:[e.jsx("span",{children:n("terminal:iframeModal.failedToLoad")}),e.jsx("button",{onClick:Y,children:n("terminal:iframeModal.retry")})]}),e.jsx("iframe",{ref:N,src:l,className:"iframe-modal-frame",onLoad:A,onError:V,style:{display:L?"none":"block",transform:`scale(${f})`,transformOrigin:"top left",width:`${100/f}%`,height:`${100/f}%`}})]}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-n",onMouseDown:t=>i(t,"n")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-s",onMouseDown:t=>i(t,"s")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-e",onMouseDown:t=>i(t,"e")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-w",onMouseDown:t=>i(t,"w")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-ne",onMouseDown:t=>i(t,"ne")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-nw",onMouseDown:t=>i(t,"nw")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-se",onMouseDown:t=>i(t,"se")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-sw",onMouseDown:t=>i(t,"sw")})]}):null}export{se as IframeModal,se as default};