tide-commander 1.45.0 → 1.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{BossLogsModal-N4CnX-0x.js → BossLogsModal-BIFXXaaq.js} +1 -1
- package/dist/assets/BossSpawnModal-CL4eQrBS.js +1 -0
- package/dist/assets/{ControlsModal-Cr5klRxS.js → ControlsModal-DX_FqPx7.js} +1 -1
- package/dist/assets/{DockerLogsModal-D6U9obTe.js → DockerLogsModal-SoHgFfH1.js} +1 -1
- package/dist/assets/{EmbeddedEditor-Bnm-9Q73.js → EmbeddedEditor-Dx6Y7JM3.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-GoKvyYWS.js → GmailOAuthSetup-K-SZcqrr.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-D3sAGlZq.js → GoogleOAuthSetup-BfpfXmbM.js} +1 -1
- package/dist/assets/{IframeModal-DQqev6_V.js → IframeModal-BAgB3UQ3.js} +1 -1
- package/dist/assets/IntegrationsPanel-B1nXTZW8.js +2 -0
- package/dist/assets/{LogViewerModal-DB0xx-oB.js → LogViewerModal-4do7lATm.js} +1 -1
- package/dist/assets/{MonitoringModal-BspW74kP.js → MonitoringModal-OAExiDTA.js} +1 -1
- package/dist/assets/{PM2LogsModal-Cz4GZtyl.js → PM2LogsModal-DnA2AsIM.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-KCCSJy3B.js → RestoreArchivedAreaModal-C0ADFzsM.js} +1 -1
- package/dist/assets/{SaveSnapshotModal-DqZ1JedM.js → SaveSnapshotModal-Ct4aW93y.js} +1 -1
- package/dist/assets/Scene2DCanvas-C5mj6yGY.js +1 -0
- package/dist/assets/{SceneManager-DggU0iAh.js → SceneManager-CPtKPGZP.js} +1 -1
- package/dist/assets/SkillsPanel-B0XFw3Ae.js +28 -0
- package/dist/assets/SnapshotManager-0NaWlDXc.js +1 -0
- package/dist/assets/SpawnModal-BOJQ1pln.js +1 -0
- package/dist/assets/SubordinateAssignmentModal-BuzBY1CB.js +1 -0
- package/dist/assets/{SupervisorPanel-CxId5lI7.js → SupervisorPanel-B2_2QYL0.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-BCzGGCPD.js → TriggerManagerPanel-CUD10Dg9.js} +2 -2
- package/dist/assets/{WorkflowEditorPanel-BmNCGmxP.js → WorkflowEditorPanel-qfjb7ozq.js} +2 -2
- package/dist/assets/{index-CcYTUJp1.js → index-BfXYjLRr.js} +4 -4
- package/dist/assets/{index-Sej69v19.js → index-BzvQBrQn.js} +3 -3
- package/dist/assets/{index-COBkxsEU.js → index-CKitMIQJ.js} +1 -1
- package/dist/assets/{index-CvJuv-ho.js → index-CTdXoSNs.js} +2 -2
- package/dist/assets/{index-Bhb-rse9.js → index-D0e5Zn8j.js} +3 -3
- package/dist/assets/{index-C9B8kaWK.js → index-DFTYc8O3.js} +1 -1
- package/dist/assets/index-K6Ld2Man.js +1 -0
- package/dist/assets/{index-8WVMR823.js → index-RddWDRes.js} +1 -1
- package/dist/assets/{main-DjGrMNoB.css → main-Ch2CJGT4.css} +1 -1
- package/dist/assets/{main-6CnCKW13.js → main-D3GShQ8B.js} +78 -78
- package/dist/assets/{web-CrUhsC9T.js → web-D0MII38C.js} +1 -1
- package/dist/assets/{web-RTEsf66y.js → web-bLUMZcn-.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/src/packages/server/data/index.js +25 -0
- package/dist/src/packages/server/routes/config.js +7 -0
- package/dist/src/packages/server/routes/custom-class-icons.js +138 -0
- package/dist/src/packages/server/routes/index.js +2 -0
- package/dist/src/packages/server/services/custom-class-service.js +7 -2
- package/package.json +1 -1
- package/dist/assets/BossSpawnModal-4CPjS2xn.js +0 -1
- package/dist/assets/IntegrationsPanel-C9hWD7mO.js +0 -2
- package/dist/assets/Scene2DCanvas-MRhWT6EA.js +0 -1
- package/dist/assets/SkillsPanel-DZC0Im2z.js +0 -28
- package/dist/assets/SnapshotManager-3LQMRFLh.js +0 -1
- package/dist/assets/SpawnModal-C_e6q2uv.js +0 -1
- package/dist/assets/SubordinateAssignmentModal-BZdSk9WL.js +0 -1
- package/dist/assets/index-B8SWRPUd.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{I as ce,r as n,W as h,l as p,j as e}from"./main-D3GShQ8B.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const pe=[{value:"webhook",label:"Webhook"},{value:"cron",label:"Cron"},{value:"slack",label:"Slack"},{value:"email",label:"Email"},{value:"jira",label:"Jira"}],xe=[{value:"structural",label:"Structural",desc:"Field-based matching (fast, free)"},{value:"llm",label:"LLM",desc:"Semantic matching via LLM (flexible, costs tokens)"},{value:"hybrid",label:"Hybrid",desc:"Structural pre-filter + LLM (recommended)"}],he=[{value:"structural",label:"Structural"},{value:"llm",label:"LLM"}],w=()=>({name:"",description:"",type:"webhook",agentId:"",promptTemplate:"",enabled:!0,matchMode:"structural",extractionMode:"structural",config:{method:"POST"}});function me({isOpen:C,onClose:E}){var H,U,W,_,J,$,V,G,X,q,Y,K;const T=ce(),[R,Q]=n.useState([]),[y,j]=n.useState("list"),[s,u]=n.useState(w()),[d,S]=n.useState(!1),[F,z]=n.useState(!1),[L,c]=n.useState(null),[O,Z]=n.useState([]),[g,ee]=n.useState(null),[k,te]=n.useState(`{
|
|
2
2
|
|
|
3
|
-
}`),[r,f]=n.useState(null),[B,I]=n.useState(!1),[N,P]=n.useState([]),x=n.useCallback(async()=>{try{const t=await h(p("/api/triggers"));if(t.ok){const a=await t.json();Q(a)}}catch(t){console.error("Failed to load triggers:",t)}},[]),v=n.useCallback(async t=>{try{const a=await h(p(`/api/triggers/${t}/events?limit=20`));if(a.ok){const i=await a.json();Z(i)}}catch(a){console.error("Failed to load trigger history:",a)}},[]);n.useEffect(()=>{C&&x()},[C,x]),n.useEffect(()=>{g&&v(g)},[g,v]);const le=n.useCallback(async()=>{z(!0),c(null);try{const t=d?p(`/api/triggers/${s.id}`):p("/api/triggers"),b=await h(t,{method:d?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!b.ok){const de=await b.json();throw new Error(de.error||"Failed to save trigger")}await x(),j("list"),u(w()),S(!1)}catch(t){c(t instanceof Error?t.message:"Save failed")}finally{z(!1)}},[s,d,x]),ae=n.useCallback(async t=>{try{await h(p(`/api/triggers/${t}`),{method:"DELETE"}),await x()}catch(a){console.error("Failed to delete trigger:",a)}},[x]),se=n.useCallback(async t=>{try{await h(p(`/api/triggers/${t.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!t.enabled})}),await x()}catch(a){console.error("Failed to toggle trigger:",a)}},[x]),ie=n.useCallback(async t=>{try{await h(p(`/api/triggers/${t}/fire`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({variables:{}})}),g===t&&await v(t)}catch(a){console.error("Failed to test fire trigger:",a)}},[g,v]),ne=n.useCallback(async()=>{if(s.id){I(!0),f(null);try{let t;try{t=JSON.parse(k)}catch{f({structuralMatch:void 0,extractedVariables:{},wouldFire:!1}),c("Invalid JSON payload");return}const a=await h(p(`/api/triggers/${s.id}/test-match`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payload:t})});if(a.ok){const i=await a.json();f(i),c(null)}else{const i=await a.json();c(i.error||"Test match failed")}}catch(t){c(t instanceof Error?t.message:"Test match failed")}finally{I(!1)}}},[s.id,k]),re=n.useCallback(async t=>{var a;try{const i=await h(p("/api/triggers/validate-cron"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expression:t,timezone:((a=s.config)==null?void 0:a.timezone)||"UTC"})});if(i.ok){const b=await i.json();P(b.valid?b.nextFires:[])}}catch{P([])}},[s]),D=n.useCallback(t=>{t?(u({...t}),S(!0)):(u(w()),S(!1)),f(null),c(null),j("edit")},[]),o=n.useCallback((t,a)=>{u(i=>({...i,[t]:a}))},[]),m=n.useCallback((t,a)=>{u(i=>({...i,config:{...i.config,[t]:a}}))},[]),M=n.useCallback((t,a)=>{u(i=>({...i,llmMatch:{...i.llmMatch||{prompt:""},[t]:a}}))},[]),A=n.useCallback((t,a)=>{u(i=>({...i,llmExtract:{...i.llmExtract||{prompt:"",variables:[]},[t]:a}}))},[]),oe=n.useMemo(()=>Array.from(T.values()).map(t=>({id:t.id,name:t.name})),[T]);return C?e.jsx("div",{style:l.overlay,onClick:E,children:e.jsxs("div",{style:l.panel,onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:l.header,children:[e.jsx("h2",{style:l.title,children:y==="list"?"Triggers":d?"Edit Trigger":"New Trigger"}),e.jsxs("div",{style:l.headerActions,children:[y==="list"&&e.jsx("button",{style:l.addBtn,onClick:()=>D(),children:"+ New Trigger"}),y==="edit"&&e.jsx("button",{style:l.backBtn,onClick:()=>{j("list"),f(null),c(null)},children:"Back"}),e.jsx("button",{style:l.closeBtn,onClick:E,children:"X"})]})]}),L&&e.jsx("div",{style:l.error,children:L}),y==="list"&&e.jsx("div",{style:l.content,children:R.length===0?e.jsx("div",{style:l.empty,children:"No triggers configured. Create one to get started."}):R.map(t=>{var a;return e.jsxs("div",{style:{...l.triggerCard,borderLeftColor:t.status==="error"?"#e74c3c":t.enabled?"#2ecc71":"#95a5a6"},onClick:()=>{ee(t.id),D(t)},children:[e.jsxs("div",{style:l.cardHeader,children:[e.jsxs("div",{style:l.cardTitle,children:[e.jsx("span",{style:l.typeTag,children:t.type}),e.jsx("span",{children:t.name}),t.matchMode!=="structural"&&e.jsx("span",{style:l.matchTag,children:t.matchMode})]}),e.jsxs("div",{style:l.cardActions,children:[e.jsx("button",{style:l.smallBtn,onClick:i=>{i.stopPropagation(),se(t)},children:t.enabled?"Disable":"Enable"}),e.jsx("button",{style:l.smallBtn,onClick:i=>{i.stopPropagation(),ie(t.id)},children:"Test Fire"}),e.jsx("button",{style:{...l.smallBtn,color:"#e74c3c"},onClick:i=>{i.stopPropagation(),ae(t.id)},children:"Delete"})]})]}),e.jsxs("div",{style:l.cardMeta,children:[e.jsxs("span",{children:["Agent: ",((a=T.get(t.agentId))==null?void 0:a.name)||t.agentId]}),e.jsxs("span",{children:["Fires: ",t.fireCount]}),t.lastFiredAt&&e.jsxs("span",{children:["Last: ",new Date(t.lastFiredAt).toLocaleString()]}),t.status==="error"&&t.lastError&&e.jsxs("span",{style:{color:"#e74c3c"},children:["Error: ",t.lastError]})]})]},t.id)})}),y==="edit"&&e.jsx("div",{style:l.content,children:e.jsxs("div",{style:l.form,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Name"}),e.jsx("input",{style:l.input,value:s.name||"",onChange:t=>o("name",t.target.value),placeholder:"My Trigger"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Description"}),e.jsx("input",{style:l.input,value:s.description||"",onChange:t=>o("description",t.target.value),placeholder:"Optional description"})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Type"}),e.jsx("select",{style:l.select,value:s.type||"webhook",onChange:t=>{const a=t.target.value;o("type",a),a==="webhook"?o("config",{method:"POST"}):a==="cron"?o("config",{expression:"0 9 * * MON-FRI",timezone:"UTC"}):o("config",{})},children:pe.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Agent"}),e.jsxs("select",{style:l.select,value:s.agentId||"",onChange:t=>o("agentId",t.target.value),children:[e.jsx("option",{value:"",children:"Select agent..."}),oe.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Prompt Template"}),e.jsx("textarea",{style:l.textarea,value:s.promptTemplate||"",onChange:t=>o("promptTemplate",t.target.value),placeholder:"Message sent to agent. Use {{variable}} for interpolation.",rows:4})]}),s.type==="webhook"&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Webhook Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Method"}),e.jsxs("select",{style:l.select,value:((H=s.config)==null?void 0:H.method)||"POST",onChange:t=>m("method",t.target.value),children:[e.jsx("option",{value:"POST",children:"POST"}),e.jsx("option",{value:"PUT",children:"PUT"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Secret (HMAC)"}),e.jsx("input",{style:l.input,type:"password",value:((U=s.config)==null?void 0:U.secret)||"",onChange:t=>m("secret",t.target.value||void 0),placeholder:"Optional HMAC secret"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Extract Fields (comma-separated JSON paths)"}),e.jsx("input",{style:l.input,value:((W=(_=s.config)==null?void 0:_.extractFields)==null?void 0:W.join(", "))||"",onChange:t=>m("extractFields",t.target.value.split(",").map(a=>a.trim()).filter(Boolean)),placeholder:"body.release_name, body.version"})]}),d&&s.id&&e.jsxs("div",{style:l.webhookUrl,children:[e.jsx("label",{style:l.label,children:"Webhook URL"}),e.jsx("code",{style:l.code,children:`${window.location.origin}/api/triggers/webhook/${s.id}`})]})]}),s.type==="cron"&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Cron Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Expression"}),e.jsx("input",{style:l.input,value:((J=s.config)==null?void 0:J.expression)||"",onChange:t=>{m("expression",t.target.value),t.target.value&&re(t.target.value)},placeholder:"0 9 * * MON-FRI"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Timezone"}),e.jsx("input",{style:l.input,value:((V=s.config)==null?void 0:V.timezone)||"UTC",onChange:t=>m("timezone",t.target.value),placeholder:"America/Mexico_City"})]})]}),N.length>0&&e.jsxs("div",{style:l.nextFires,children:[e.jsx("label",{style:l.label,children:"Next fires:"}),N.map((t,a)=>e.jsx("div",{style:l.nextFireItem,children:new Date(t).toLocaleString()},a))]})]}),e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Match Mode"}),e.jsx("div",{style:l.modeSelector,children:xe.map(t=>e.jsxs("button",{style:{...l.modeBtn,...s.matchMode===t.value?l.modeBtnActive:{}},onClick:()=>o("matchMode",t.value),children:[e.jsx("strong",{children:t.label}),e.jsx("span",{style:l.modeDesc,children:t.desc})]},t.value))}),(s.matchMode==="llm"||s.matchMode==="hybrid")&&e.jsxs("div",{style:l.llmConfig,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"LLM Match Prompt"}),e.jsx("textarea",{style:l.textarea,value:(($=s.llmMatch)==null?void 0:$.prompt)||"",onChange:t=>M("prompt",t.target.value),placeholder:"Does this message request a release deployment?",rows:3})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Model"}),e.jsxs("select",{style:l.select,value:((G=s.llmMatch)==null?void 0:G.model)||"haiku",onChange:t=>M("model",t.target.value),children:[e.jsx("option",{value:"haiku",children:"Haiku (fast, cheap)"}),e.jsx("option",{value:"sonnet",children:"Sonnet (balanced)"}),e.jsx("option",{value:"opus",children:"Opus (powerful)"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Min Confidence"}),e.jsx("input",{style:l.input,type:"number",min:"0",max:"1",step:"0.1",value:((X=s.llmMatch)==null?void 0:X.minConfidence)??0,onChange:t=>M("minConfidence",parseFloat(t.target.value))})]})]})]})]}),e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Extraction Mode"}),e.jsx("div",{style:l.row,children:he.map(t=>e.jsx("button",{style:{...l.modeBtn,...s.extractionMode===t.value?l.modeBtnActive:{}},onClick:()=>o("extractionMode",t.value),children:t.label},t.value))}),s.extractionMode==="llm"&&e.jsxs("div",{style:l.llmConfig,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Extraction Instructions"}),e.jsx("textarea",{style:l.textarea,value:((q=s.llmExtract)==null?void 0:q.prompt)||"",onChange:t=>A("prompt",t.target.value),placeholder:"Extract: release version, affected systems, urgency",rows:3})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Variable Names (comma-separated)"}),e.jsx("input",{style:l.input,value:((K=(Y=s.llmExtract)==null?void 0:Y.variables)==null?void 0:K.join(", "))||"",onChange:t=>A("variables",t.target.value.split(",").map(a=>a.trim()).filter(Boolean)),placeholder:"release_name, affected_systems, urgency"})]})]})]}),d&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Test Match"}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Sample Event Payload (JSON)"}),e.jsx("textarea",{style:l.textarea,value:k,onChange:t=>te(t.target.value),rows:4})]}),e.jsx("button",{style:l.testBtn,onClick:ne,disabled:B,children:B?"Testing...":"Test Match"}),r&&e.jsxs("div",{style:l.testResult,children:[e.jsx("div",{style:{...l.testResultHeader,color:r.wouldFire?"#2ecc71":"#e74c3c"},children:r.wouldFire?"WOULD FIRE":"WOULD NOT FIRE"}),r.structuralMatch!==void 0&&e.jsxs("div",{children:["Structural: ",r.structuralMatch?"Match":"No match"]}),r.llmMatch&&e.jsxs("div",{style:l.llmResult,children:[e.jsxs("div",{children:["LLM: ",r.llmMatch.match?"Match":"No match"]}),e.jsxs("div",{children:["Confidence: ",(r.llmMatch.confidence*100).toFixed(0),"%"]}),e.jsxs("div",{children:["Reason: ",r.llmMatch.reason]}),e.jsxs("div",{style:l.llmMeta,children:["Model: ",r.llmMatch.model," | Tokens: ",r.llmMatch.tokensUsed," | Latency: ",r.llmMatch.durationMs,"ms"]})]}),Object.keys(r.extractedVariables).length>0&&e.jsxs("div",{children:[e.jsx("div",{style:l.label,children:"Extracted Variables:"}),Object.entries(r.extractedVariables).map(([t,a])=>e.jsxs("div",{style:l.varRow,children:[e.jsx("code",{children:t}),": ",a]},t))]})]})]}),d&&O.length>0&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Recent Fires"}),e.jsx("div",{style:l.historyList,children:O.map((t,a)=>{const i=t.llm_match_result?JSON.parse(t.llm_match_result):null;return e.jsxs("div",{style:l.historyItem,children:[e.jsxs("div",{style:l.historyHeader,children:[e.jsx("span",{style:{color:t.status==="delivered"?"#2ecc71":t.status==="failed"?"#e74c3c":"#f39c12"},children:t.status}),e.jsx("span",{children:new Date(t.fired_at).toLocaleString()}),t.duration_ms&&e.jsxs("span",{children:[t.duration_ms,"ms"]})]}),t.error&&e.jsx("div",{style:{color:"#e74c3c",fontSize:"12px"},children:t.error}),i&&e.jsxs("div",{style:l.llmMeta,children:["LLM: ",i.match?"match":"no match"," (",(i.confidence*100).toFixed(0),"%) - ",i.reason]})]},t.id||a)})})]}),e.jsxs("div",{style:l.actions,children:[e.jsx("button",{style:l.cancelBtn,onClick:()=>{j("list"),c(null)},children:"Cancel"}),e.jsx("button",{style:l.saveBtn,onClick:le,disabled:F||!s.name||!s.agentId,children:F?"Saving...":d?"Update":"Create"})]})]})})]})}):null}const l={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},panel:{background:"#1e1e2e",borderRadius:"12px",width:"680px",maxHeight:"85vh",display:"flex",flexDirection:"column",color:"#cdd6f4",boxShadow:"0 8px 32px rgba(0,0,0,0.4)"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid #313244"},title:{margin:0,fontSize:"18px",fontWeight:600},headerActions:{display:"flex",gap:"8px"},content:{overflow:"auto",padding:"16px 20px",flex:1},empty:{textAlign:"center",padding:"40px",color:"#6c7086"},error:{background:"#45252a",color:"#f38ba8",padding:"8px 20px",fontSize:"13px"},triggerCard:{background:"#181825",borderRadius:"8px",padding:"12px 16px",marginBottom:"8px",borderLeft:"3px solid",cursor:"pointer",transition:"background 0.15s"},cardHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},cardTitle:{display:"flex",alignItems:"center",gap:"8px",fontWeight:500},typeTag:{background:"#313244",padding:"2px 6px",borderRadius:"4px",fontSize:"11px",textTransform:"uppercase"},matchTag:{background:"#45475a",padding:"2px 6px",borderRadius:"4px",fontSize:"10px",color:"#a6e3a1"},cardActions:{display:"flex",gap:"6px"},cardMeta:{display:"flex",gap:"16px",marginTop:"8px",fontSize:"12px",color:"#6c7086"},form:{display:"flex",flexDirection:"column",gap:"12px"},field:{display:"flex",flexDirection:"column",gap:"4px",flex:1},row:{display:"flex",gap:"12px"},label:{fontSize:"12px",color:"#a6adc8",fontWeight:500},input:{background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 10px",color:"#cdd6f4",fontSize:"13px",outline:"none"},select:{background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 10px",color:"#cdd6f4",fontSize:"13px",outline:"none"},textarea:{background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 10px",color:"#cdd6f4",fontSize:"13px",outline:"none",fontFamily:"monospace",resize:"vertical"},section:{borderTop:"1px solid #313244",paddingTop:"12px"},sectionTitle:{margin:"0 0 8px",fontSize:"14px",fontWeight:600,color:"#a6adc8"},modeSelector:{display:"flex",gap:"8px",marginBottom:"8px"},modeBtn:{flex:1,background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px",color:"#cdd6f4",cursor:"pointer",textAlign:"left",display:"flex",flexDirection:"column",gap:"2px",fontSize:"12px"},modeBtnActive:{borderColor:"#89b4fa",background:"#1e3a5f"},modeDesc:{fontSize:"10px",color:"#6c7086"},llmConfig:{background:"#181825",borderRadius:"6px",padding:"12px",display:"flex",flexDirection:"column",gap:"8px"},webhookUrl:{marginTop:"8px"},code:{background:"#313244",padding:"6px 10px",borderRadius:"4px",fontSize:"12px",display:"block",wordBreak:"break-all",color:"#89b4fa"},nextFires:{marginTop:"8px"},nextFireItem:{fontSize:"12px",color:"#a6e3a1",padding:"2px 0"},testBtn:{background:"#89b4fa",border:"none",borderRadius:"6px",padding:"8px 16px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:"13px"},testResult:{background:"#181825",borderRadius:"6px",padding:"12px",marginTop:"8px",fontSize:"13px",display:"flex",flexDirection:"column",gap:"6px"},testResultHeader:{fontWeight:700,fontSize:"14px"},llmResult:{display:"flex",flexDirection:"column",gap:"2px"},llmMeta:{fontSize:"11px",color:"#6c7086",marginTop:"2px"},varRow:{fontSize:"12px",padding:"2px 0"},historyList:{display:"flex",flexDirection:"column",gap:"6px",maxHeight:"200px",overflow:"auto"},historyItem:{background:"#181825",borderRadius:"4px",padding:"8px 10px",fontSize:"12px"},historyHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},actions:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"16px",paddingTop:"12px",borderTop:"1px solid #313244"},addBtn:{background:"#89b4fa",border:"none",borderRadius:"6px",padding:"6px 14px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:"13px"},backBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:"6px",padding:"6px 14px",color:"#cdd6f4",cursor:"pointer",fontSize:"13px"},closeBtn:{background:"transparent",border:"none",color:"#6c7086",cursor:"pointer",fontSize:"16px",padding:"4px 8px"},smallBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:"4px",padding:"3px 8px",color:"#cdd6f4",cursor:"pointer",fontSize:"11px"},saveBtn:{background:"#a6e3a1",border:"none",borderRadius:"6px",padding:"8px 20px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:"13px"},cancelBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 20px",color:"#cdd6f4",cursor:"pointer",fontSize:"13px"}};export{me as TriggerManagerPanel,me as default};
|
|
3
|
+
}`),[r,f]=n.useState(null),[B,I]=n.useState(!1),[N,P]=n.useState([]),x=n.useCallback(async()=>{try{const t=await h(p("/api/triggers"));if(t.ok){const a=await t.json();Q(a)}}catch(t){console.error("Failed to load triggers:",t)}},[]),v=n.useCallback(async t=>{try{const a=await h(p(`/api/triggers/${t}/events?limit=20`));if(a.ok){const i=await a.json();Z(i)}}catch(a){console.error("Failed to load trigger history:",a)}},[]);n.useEffect(()=>{C&&x()},[C,x]),n.useEffect(()=>{g&&v(g)},[g,v]);const le=n.useCallback(async()=>{z(!0),c(null);try{const t=d?p(`/api/triggers/${s.id}`):p("/api/triggers"),b=await h(t,{method:d?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!b.ok){const de=await b.json();throw new Error(de.error||"Failed to save trigger")}await x(),j("list"),u(w()),S(!1)}catch(t){c(t instanceof Error?t.message:"Save failed")}finally{z(!1)}},[s,d,x]),ae=n.useCallback(async t=>{try{await h(p(`/api/triggers/${t}`),{method:"DELETE"}),await x()}catch(a){console.error("Failed to delete trigger:",a)}},[x]),se=n.useCallback(async t=>{try{await h(p(`/api/triggers/${t.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!t.enabled})}),await x()}catch(a){console.error("Failed to toggle trigger:",a)}},[x]),ie=n.useCallback(async t=>{try{await h(p(`/api/triggers/${t}/fire`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({variables:{}})}),g===t&&await v(t)}catch(a){console.error("Failed to test fire trigger:",a)}},[g,v]),ne=n.useCallback(async()=>{if(s.id){I(!0),f(null);try{let t;try{t=JSON.parse(k)}catch{f({structuralMatch:void 0,extractedVariables:{},wouldFire:!1}),c("Invalid JSON payload");return}const a=await h(p(`/api/triggers/${s.id}/test-match`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payload:t})});if(a.ok){const i=await a.json();f(i),c(null)}else{const i=await a.json();c(i.error||"Test match failed")}}catch(t){c(t instanceof Error?t.message:"Test match failed")}finally{I(!1)}}},[s.id,k]),re=n.useCallback(async t=>{var a;try{const i=await h(p("/api/triggers/validate-cron"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expression:t,timezone:((a=s.config)==null?void 0:a.timezone)||"UTC"})});if(i.ok){const b=await i.json();P(b.valid?b.nextFires:[])}}catch{P([])}},[s]),D=n.useCallback(t=>{t?(u({...t}),S(!0)):(u(w()),S(!1)),f(null),c(null),j("edit")},[]),o=n.useCallback((t,a)=>{u(i=>({...i,[t]:a}))},[]),m=n.useCallback((t,a)=>{u(i=>({...i,config:{...i.config,[t]:a}}))},[]),M=n.useCallback((t,a)=>{u(i=>({...i,llmMatch:{...i.llmMatch||{prompt:""},[t]:a}}))},[]),A=n.useCallback((t,a)=>{u(i=>({...i,llmExtract:{...i.llmExtract||{prompt:"",variables:[]},[t]:a}}))},[]),oe=n.useMemo(()=>Array.from(T.values()).map(t=>({id:t.id,name:t.name})),[T]);return C?e.jsx("div",{style:l.overlay,onClick:E,children:e.jsxs("div",{style:l.panel,onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:l.header,children:[e.jsx("h2",{style:l.title,children:y==="list"?"Triggers":d?"Edit Trigger":"New Trigger"}),e.jsxs("div",{style:l.headerActions,children:[y==="list"&&e.jsx("button",{style:l.addBtn,onClick:()=>D(),children:"+ New Trigger"}),y==="edit"&&e.jsx("button",{style:l.backBtn,onClick:()=>{j("list"),f(null),c(null)},children:"Back"}),e.jsx("button",{style:l.closeBtn,onClick:E,children:"X"})]})]}),L&&e.jsx("div",{style:l.error,children:L}),y==="list"&&e.jsx("div",{style:l.content,children:R.length===0?e.jsx("div",{style:l.empty,children:"No triggers configured. Create one to get started."}):R.map(t=>{var a;return e.jsxs("div",{style:{...l.triggerCard,borderLeftColor:t.status==="error"?"#e74c3c":t.enabled?"#2ecc71":"#95a5a6"},onClick:()=>{ee(t.id),D(t)},children:[e.jsxs("div",{style:l.cardHeader,children:[e.jsxs("div",{style:l.cardTitle,children:[e.jsx("span",{style:l.typeTag,children:t.type}),e.jsx("span",{children:t.name}),t.matchMode!=="structural"&&e.jsx("span",{style:l.matchTag,children:t.matchMode})]}),e.jsxs("div",{style:l.cardActions,children:[e.jsx("button",{style:l.smallBtn,onClick:i=>{i.stopPropagation(),se(t)},children:t.enabled?"Disable":"Enable"}),e.jsx("button",{style:l.smallBtn,onClick:i=>{i.stopPropagation(),ie(t.id)},children:"Test Fire"}),e.jsx("button",{style:{...l.smallBtn,color:"#e74c3c"},onClick:i=>{i.stopPropagation(),ae(t.id)},children:"Delete"})]})]}),e.jsxs("div",{style:l.cardMeta,children:[e.jsxs("span",{children:["Agent: ",((a=T.get(t.agentId))==null?void 0:a.name)||t.agentId]}),e.jsxs("span",{children:["Fires: ",t.fireCount]}),t.lastFiredAt&&e.jsxs("span",{children:["Last: ",new Date(t.lastFiredAt).toLocaleString()]}),t.status==="error"&&t.lastError&&e.jsxs("span",{style:{color:"#e74c3c"},children:["Error: ",t.lastError]})]})]},t.id)})}),y==="edit"&&e.jsx("div",{style:l.content,children:e.jsxs("div",{style:l.form,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Name"}),e.jsx("input",{style:l.input,value:s.name||"",onChange:t=>o("name",t.target.value),placeholder:"My Trigger"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Description"}),e.jsx("input",{style:l.input,value:s.description||"",onChange:t=>o("description",t.target.value),placeholder:"Optional description"})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Type"}),e.jsx("select",{style:l.select,value:s.type||"webhook",onChange:t=>{const a=t.target.value;o("type",a),a==="webhook"?o("config",{method:"POST"}):a==="cron"?o("config",{expression:"0 9 * * MON-FRI",timezone:"UTC"}):o("config",{})},children:pe.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Agent"}),e.jsxs("select",{style:l.select,value:s.agentId||"",onChange:t=>o("agentId",t.target.value),children:[e.jsx("option",{value:"",children:"Select agent..."}),oe.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Prompt Template"}),e.jsx("textarea",{style:l.textarea,value:s.promptTemplate||"",onChange:t=>o("promptTemplate",t.target.value),placeholder:"Message sent to agent. Use {{variable}} for interpolation.",rows:4})]}),s.type==="webhook"&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Webhook Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Method"}),e.jsxs("select",{style:l.select,value:((H=s.config)==null?void 0:H.method)||"POST",onChange:t=>m("method",t.target.value),children:[e.jsx("option",{value:"POST",children:"POST"}),e.jsx("option",{value:"PUT",children:"PUT"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Secret (HMAC)"}),e.jsx("input",{style:l.input,type:"password",value:((U=s.config)==null?void 0:U.secret)||"",onChange:t=>m("secret",t.target.value||void 0),placeholder:"Optional HMAC secret"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Extract Fields (comma-separated JSON paths)"}),e.jsx("input",{style:l.input,value:((_=(W=s.config)==null?void 0:W.extractFields)==null?void 0:_.join(", "))||"",onChange:t=>m("extractFields",t.target.value.split(",").map(a=>a.trim()).filter(Boolean)),placeholder:"body.release_name, body.version"})]}),d&&s.id&&e.jsxs("div",{style:l.webhookUrl,children:[e.jsx("label",{style:l.label,children:"Webhook URL"}),e.jsx("code",{style:l.code,children:`${window.location.origin}/api/triggers/webhook/${s.id}`})]})]}),s.type==="cron"&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Cron Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Expression"}),e.jsx("input",{style:l.input,value:((J=s.config)==null?void 0:J.expression)||"",onChange:t=>{m("expression",t.target.value),t.target.value&&re(t.target.value)},placeholder:"0 9 * * MON-FRI"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Timezone"}),e.jsx("input",{style:l.input,value:(($=s.config)==null?void 0:$.timezone)||"UTC",onChange:t=>m("timezone",t.target.value),placeholder:"America/Mexico_City"})]})]}),N.length>0&&e.jsxs("div",{style:l.nextFires,children:[e.jsx("label",{style:l.label,children:"Next fires:"}),N.map((t,a)=>e.jsx("div",{style:l.nextFireItem,children:new Date(t).toLocaleString()},a))]})]}),e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Match Mode"}),e.jsx("div",{style:l.modeSelector,children:xe.map(t=>e.jsxs("button",{style:{...l.modeBtn,...s.matchMode===t.value?l.modeBtnActive:{}},onClick:()=>o("matchMode",t.value),children:[e.jsx("strong",{children:t.label}),e.jsx("span",{style:l.modeDesc,children:t.desc})]},t.value))}),(s.matchMode==="llm"||s.matchMode==="hybrid")&&e.jsxs("div",{style:l.llmConfig,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"LLM Match Prompt"}),e.jsx("textarea",{style:l.textarea,value:((V=s.llmMatch)==null?void 0:V.prompt)||"",onChange:t=>M("prompt",t.target.value),placeholder:"Does this message request a release deployment?",rows:3})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Model"}),e.jsxs("select",{style:l.select,value:((G=s.llmMatch)==null?void 0:G.model)||"haiku",onChange:t=>M("model",t.target.value),children:[e.jsx("option",{value:"haiku",children:"Haiku (fast, cheap)"}),e.jsx("option",{value:"sonnet",children:"Sonnet (balanced)"}),e.jsx("option",{value:"opus",children:"Opus (powerful)"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Min Confidence"}),e.jsx("input",{style:l.input,type:"number",min:"0",max:"1",step:"0.1",value:((X=s.llmMatch)==null?void 0:X.minConfidence)??0,onChange:t=>M("minConfidence",parseFloat(t.target.value))})]})]})]})]}),e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Extraction Mode"}),e.jsx("div",{style:l.row,children:he.map(t=>e.jsx("button",{style:{...l.modeBtn,...s.extractionMode===t.value?l.modeBtnActive:{}},onClick:()=>o("extractionMode",t.value),children:t.label},t.value))}),s.extractionMode==="llm"&&e.jsxs("div",{style:l.llmConfig,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Extraction Instructions"}),e.jsx("textarea",{style:l.textarea,value:((q=s.llmExtract)==null?void 0:q.prompt)||"",onChange:t=>A("prompt",t.target.value),placeholder:"Extract: release version, affected systems, urgency",rows:3})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Variable Names (comma-separated)"}),e.jsx("input",{style:l.input,value:((K=(Y=s.llmExtract)==null?void 0:Y.variables)==null?void 0:K.join(", "))||"",onChange:t=>A("variables",t.target.value.split(",").map(a=>a.trim()).filter(Boolean)),placeholder:"release_name, affected_systems, urgency"})]})]})]}),d&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Test Match"}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Sample Event Payload (JSON)"}),e.jsx("textarea",{style:l.textarea,value:k,onChange:t=>te(t.target.value),rows:4})]}),e.jsx("button",{style:l.testBtn,onClick:ne,disabled:B,children:B?"Testing...":"Test Match"}),r&&e.jsxs("div",{style:l.testResult,children:[e.jsx("div",{style:{...l.testResultHeader,color:r.wouldFire?"#2ecc71":"#e74c3c"},children:r.wouldFire?"WOULD FIRE":"WOULD NOT FIRE"}),r.structuralMatch!==void 0&&e.jsxs("div",{children:["Structural: ",r.structuralMatch?"Match":"No match"]}),r.llmMatch&&e.jsxs("div",{style:l.llmResult,children:[e.jsxs("div",{children:["LLM: ",r.llmMatch.match?"Match":"No match"]}),e.jsxs("div",{children:["Confidence: ",(r.llmMatch.confidence*100).toFixed(0),"%"]}),e.jsxs("div",{children:["Reason: ",r.llmMatch.reason]}),e.jsxs("div",{style:l.llmMeta,children:["Model: ",r.llmMatch.model," | Tokens: ",r.llmMatch.tokensUsed," | Latency: ",r.llmMatch.durationMs,"ms"]})]}),Object.keys(r.extractedVariables).length>0&&e.jsxs("div",{children:[e.jsx("div",{style:l.label,children:"Extracted Variables:"}),Object.entries(r.extractedVariables).map(([t,a])=>e.jsxs("div",{style:l.varRow,children:[e.jsx("code",{children:t}),": ",a]},t))]})]})]}),d&&O.length>0&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Recent Fires"}),e.jsx("div",{style:l.historyList,children:O.map((t,a)=>{const i=t.llm_match_result?JSON.parse(t.llm_match_result):null;return e.jsxs("div",{style:l.historyItem,children:[e.jsxs("div",{style:l.historyHeader,children:[e.jsx("span",{style:{color:t.status==="delivered"?"#2ecc71":t.status==="failed"?"#e74c3c":"#f39c12"},children:t.status}),e.jsx("span",{children:new Date(t.fired_at).toLocaleString()}),t.duration_ms&&e.jsxs("span",{children:[t.duration_ms,"ms"]})]}),t.error&&e.jsx("div",{style:{color:"#e74c3c",fontSize:"12px"},children:t.error}),i&&e.jsxs("div",{style:l.llmMeta,children:["LLM: ",i.match?"match":"no match"," (",(i.confidence*100).toFixed(0),"%) - ",i.reason]})]},t.id||a)})})]}),e.jsxs("div",{style:l.actions,children:[e.jsx("button",{style:l.cancelBtn,onClick:()=>{j("list"),c(null)},children:"Cancel"}),e.jsx("button",{style:l.saveBtn,onClick:le,disabled:F||!s.name||!s.agentId,children:F?"Saving...":d?"Update":"Create"})]})]})})]})}):null}const l={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},panel:{background:"#1e1e2e",borderRadius:"12px",width:"680px",maxHeight:"85vh",display:"flex",flexDirection:"column",color:"#cdd6f4",boxShadow:"0 8px 32px rgba(0,0,0,0.4)"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid #313244"},title:{margin:0,fontSize:"18px",fontWeight:600},headerActions:{display:"flex",gap:"8px"},content:{overflow:"auto",padding:"16px 20px",flex:1},empty:{textAlign:"center",padding:"40px",color:"#6c7086"},error:{background:"#45252a",color:"#f38ba8",padding:"8px 20px",fontSize:"13px"},triggerCard:{background:"#181825",borderRadius:"8px",padding:"12px 16px",marginBottom:"8px",borderLeft:"3px solid",cursor:"pointer",transition:"background 0.15s"},cardHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},cardTitle:{display:"flex",alignItems:"center",gap:"8px",fontWeight:500},typeTag:{background:"#313244",padding:"2px 6px",borderRadius:"4px",fontSize:"11px",textTransform:"uppercase"},matchTag:{background:"#45475a",padding:"2px 6px",borderRadius:"4px",fontSize:"10px",color:"#a6e3a1"},cardActions:{display:"flex",gap:"6px"},cardMeta:{display:"flex",gap:"16px",marginTop:"8px",fontSize:"12px",color:"#6c7086"},form:{display:"flex",flexDirection:"column",gap:"12px"},field:{display:"flex",flexDirection:"column",gap:"4px",flex:1},row:{display:"flex",gap:"12px"},label:{fontSize:"12px",color:"#a6adc8",fontWeight:500},input:{background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 10px",color:"#cdd6f4",fontSize:"13px",outline:"none"},select:{background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 10px",color:"#cdd6f4",fontSize:"13px",outline:"none"},textarea:{background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 10px",color:"#cdd6f4",fontSize:"13px",outline:"none",fontFamily:"monospace",resize:"vertical"},section:{borderTop:"1px solid #313244",paddingTop:"12px"},sectionTitle:{margin:"0 0 8px",fontSize:"14px",fontWeight:600,color:"#a6adc8"},modeSelector:{display:"flex",gap:"8px",marginBottom:"8px"},modeBtn:{flex:1,background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px",color:"#cdd6f4",cursor:"pointer",textAlign:"left",display:"flex",flexDirection:"column",gap:"2px",fontSize:"12px"},modeBtnActive:{borderColor:"#89b4fa",background:"#1e3a5f"},modeDesc:{fontSize:"10px",color:"#6c7086"},llmConfig:{background:"#181825",borderRadius:"6px",padding:"12px",display:"flex",flexDirection:"column",gap:"8px"},webhookUrl:{marginTop:"8px"},code:{background:"#313244",padding:"6px 10px",borderRadius:"4px",fontSize:"12px",display:"block",wordBreak:"break-all",color:"#89b4fa"},nextFires:{marginTop:"8px"},nextFireItem:{fontSize:"12px",color:"#a6e3a1",padding:"2px 0"},testBtn:{background:"#89b4fa",border:"none",borderRadius:"6px",padding:"8px 16px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:"13px"},testResult:{background:"#181825",borderRadius:"6px",padding:"12px",marginTop:"8px",fontSize:"13px",display:"flex",flexDirection:"column",gap:"6px"},testResultHeader:{fontWeight:700,fontSize:"14px"},llmResult:{display:"flex",flexDirection:"column",gap:"2px"},llmMeta:{fontSize:"11px",color:"#6c7086",marginTop:"2px"},varRow:{fontSize:"12px",padding:"2px 0"},historyList:{display:"flex",flexDirection:"column",gap:"6px",maxHeight:"200px",overflow:"auto"},historyItem:{background:"#181825",borderRadius:"4px",padding:"8px 10px",fontSize:"12px"},historyHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},actions:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"16px",paddingTop:"12px",borderTop:"1px solid #313244"},addBtn:{background:"#89b4fa",border:"none",borderRadius:"6px",padding:"6px 14px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:"13px"},backBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:"6px",padding:"6px 14px",color:"#cdd6f4",cursor:"pointer",fontSize:"13px"},closeBtn:{background:"transparent",border:"none",color:"#6c7086",cursor:"pointer",fontSize:"16px",padding:"4px 8px"},smallBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:"4px",padding:"3px 8px",color:"#cdd6f4",cursor:"pointer",fontSize:"11px"},saveBtn:{background:"#a6e3a1",border:"none",borderRadius:"6px",padding:"8px 20px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:"13px"},cancelBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 20px",color:"#cdd6f4",cursor:"pointer",fontSize:"13px"}};export{me as TriggerManagerPanel,me as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as x,
|
|
1
|
+
import{r as x,W as M,l as P,j as e,I as J}from"./main-D3GShQ8B.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const H=[{id:"intake",name:"Intake",type:"action",description:"Gather CC details from the developer via Slack",action:{type:"agent_task",agentId:"",promptTemplate:`A developer has requested a new CC (Control de Cambios). Here is their message:
|
|
2
2
|
{{trigger.slack.message}}
|
|
3
3
|
From: {{trigger.slack.user}} (Slack ID: {{trigger.slack.userId}})
|
|
4
4
|
|
|
@@ -39,4 +39,4 @@ Send a Slack reminder and ask {{requester_name}} to confirm they are ready.
|
|
|
39
39
|
Wait for their confirmation reply.`,skills:["slack-messaging"]},transitions:[{id:"t-confirmed",name:"Dev Confirmed",targetStateId:"release-started",condition:{type:"agent_complete"}}],position:{x:100,y:960}},{id:"release-started",name:"Release Started",type:"action",description:"Announce release start via email, Slack, and Jira",action:{type:"agent_task",agentId:"",promptTemplate:`The developer has confirmed ready.
|
|
40
40
|
1. Reply in approval email thread: release is starting now.
|
|
41
41
|
2. Send Slack message confirming release started.
|
|
42
|
-
3. Update Jira ticket status to "In Progress" or "Done".`,skills:["email-gmail","slack-messaging","jira-service-desk"]},transitions:[{id:"t-done",name:"Release Complete",targetStateId:"end",condition:{type:"agent_complete"}}],position:{x:100,y:1060}},{id:"end",name:"End",type:"end",description:"CC process complete",transitions:[],position:{x:100,y:1160}}],Y=[{name:"requester_name",type:"string",description:"Developer requesting the release",required:!0},{name:"requester_email",type:"email",description:"Requester email",required:!0},{name:"requester_slack_id",type:"string",description:"Requester Slack user ID"},{name:"release_name",type:"string",description:"Release version/name",required:!0},{name:"release_description",type:"string",description:"What is being released"},{name:"affected_systems",type:"string",description:"Systems impacted"},{name:"release_date",type:"date",description:"Scheduled release date",required:!0},{name:"release_time",type:"string",description:"Scheduled release time",required:!0},{name:"is_urgent",type:"boolean",description:"Whether this is an urgent release"},{name:"additional_attendees",type:"string",description:"Other people to invite (comma-separated emails)"},{name:"jira_ticket_key",type:"string",description:"Jira ticket key (e.g. SD-1234)"},{name:"jira_ticket_url",type:"string",description:"Full Jira ticket URL"},{name:"cc_file_path",type:"string",description:"Path to generated CC document"},{name:"email_thread_id",type:"string",description:"Gmail thread ID for approval chain"},{name:"calendar_event_id",type:"string",description:"Google Calendar event ID"},{name:"approval_status",type:"json",description:"Current approval status"}],G=200,N=60,B=20,V={action:"#89b4fa",decision:"#f9e2af",wait:"#cba6f7",end:"#a6e3a1"},E={action:"Action",decision:"Decision",wait:"Wait",end:"End"},X={agent_complete:"Agent Complete",trigger_fired:"Trigger Fired",variable_check:"Variable Check",timeout:"Timeout",manual:"Manual",cron:"Cron"};function le({isOpen:n,onClose:g}){const[v,r]=x.useState([]),[l,y]=x.useState(null),[p,s]=x.useState("list"),[i,u]=x.useState(!0),[c,b]=x.useState(null),T=x.useCallback(async()=>{u(!0);try{const o=await M(P("/api/workflows/definitions"));o.ok&&r(await o.json())}catch{b("Failed to load workflows")}finally{u(!1)}},[]);x.useEffect(()=>{n&&T()},[n,T]);const R=()=>{const o={id:`wf-${Date.now()}`,name:"New Workflow",description:"",version:1,variables:[],states:[{id:"start",name:"Start",type:"action",transitions:[],position:{x:300,y:60}},{id:"end",name:"End",type:"end",transitions:[],position:{x:300,y:260}}],initialStateId:"start",createdAt:Date.now(),updatedAt:Date.now()};y(o),s("editor")},D=()=>{const o={id:`wf-cc-${Date.now()}`,name:"CC (Control de Cambios)",description:"Full CC process: intake, Jira ticket, document, approval, release",version:1,variables:[...Y],states:H.map(m=>({...m,transitions:[...m.transitions]})),initialStateId:"intake",createdAt:Date.now(),updatedAt:Date.now()};y(o),s("editor")},d=async o=>{try{v.find(I=>I.id===o.id)?await M(P(`/api/workflows/definitions/${o.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}):await M(P("/api/workflows/definitions"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),await T()}catch{b("Failed to save workflow")}};return n?e.jsx("div",{style:t.overlay,children:e.jsxs("div",{style:t.panel,children:[e.jsxs("div",{style:t.header,children:[e.jsx("h2",{style:t.title,children:p==="list"?"Workflow Definitions":(l==null?void 0:l.name)||"Editor"}),e.jsxs("div",{style:{display:"flex",gap:8},children:[p==="editor"&&e.jsx("button",{style:t.btnSecondary,onClick:()=>s("list"),children:"Back to List"}),e.jsx("button",{style:t.btnClose,onClick:g,children:"Close"})]})]}),p==="list"&&e.jsx(K,{workflows:v,loading:i,error:c,onSelect:o=>{y(o),s("editor")},onCreate:R,onLoadCC:D}),p==="editor"&&l&&e.jsx(Q,{workflow:l,onChange:y,onSave:d})]})}):null}function K({workflows:n,loading:g,error:v,onSelect:r,onCreate:l,onLoadCC:y}){return e.jsxs("div",{style:t.content,children:[e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:16},children:[e.jsx("button",{style:t.btnPrimary,onClick:l,children:"New Workflow"}),e.jsx("button",{style:t.btnSecondary,onClick:y,children:"Load CC Template"})]}),g&&e.jsx("div",{style:{color:"#a6adc8"},children:"Loading..."}),v&&e.jsx("div",{style:{color:"#f38ba8"},children:v}),n.map(p=>e.jsxs("div",{style:t.card,onClick:()=>r(p),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{style:{color:"#cdd6f4",fontWeight:600,fontSize:14},children:p.name}),e.jsxs("span",{style:{color:"#a6adc8",fontSize:11},children:["v",p.version," | ",p.states.length," states"]})]}),p.description&&e.jsx("div",{style:{color:"#a6adc8",fontSize:12,marginTop:4},children:p.description})]},p.id)),!g&&n.length===0&&e.jsx("div",{style:{color:"#6c7086",textAlign:"center",padding:40},children:"No workflows yet. Create one or load the CC template."})]})}function Q({workflow:n,onChange:g,onSave:v}){const[r,l]=x.useState(null),[y,p]=x.useState(null),[s,i]=x.useState("none"),[u,c]=x.useState(null),[b,T]=x.useState(!1),R=x.useRef(null),D=x.useRef(n);D.current=n;const d=J(),o=x.useMemo(()=>Array.from(d.values()).map(a=>({id:a.id,name:a.name})),[d]),m=n.states.find(a=>a.id===r),I=x.useCallback(()=>{for(const a of n.states){const f=a.transitions.find(h=>h.id===y);if(f)return{state:a,transition:f}}return null},[n,y]),C=a=>{g({...n,states:a,updatedAt:Date.now()})},k=(a,f)=>{C(n.states.map(h=>h.id===a?{...h,...f}:h))},_=a=>{const f=`state-${Date.now()}`,h={id:f,name:`New ${E[a]}`,type:a,transitions:[],position:{x:300,y:n.states.length*100+60}};C([...n.states,h]),l(f),i("state")},S=a=>{const f=n.states.filter(h=>h.id!==a).map(h=>({...h,transitions:h.transitions.filter(j=>j.targetStateId!==a)}));C(f),l(null),i("none")},w=(a,f)=>{const h=`t-${Date.now()}`;C(n.states.map(j=>j.id!==a?j:{...j,transitions:[...j.transitions,{id:h,name:"New Transition",targetStateId:f,condition:{type:"agent_complete"}}]})),p(h),i("transition")},L=(a,f,h)=>{C(n.states.map(j=>j.id!==a?j:{...j,transitions:j.transitions.map(W=>W.id===f?{...W,...h}:W)}))},A=(a,f)=>{C(n.states.map(h=>h.id!==a?h:{...h,transitions:h.transitions.filter(j=>j.id!==f)})),p(null),i("none")},q=x.useCallback((a,f,h)=>{const j=D.current,W=j.states.map(z=>{if(z.id!==a)return z;const $=z.position||{x:0,y:0};return{...z,position:{x:Math.round(($.x+f)/B)*B,y:Math.round(($.y+h)/B)*B}}});g({...j,states:W,updatedAt:Date.now()})},[g]),O=a=>{u?(u!==a&&w(u,a),c(null)):(l(a),p(null),i("state"))},F=async()=>{T(!0);try{await v(n)}finally{T(!1)}};return e.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[e.jsxs("div",{style:t.toolbar,children:[e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:10,textTransform:"uppercase",marginBottom:6,letterSpacing:1},children:"Add State"}),["action","decision","wait","end"].map(a=>e.jsx("button",{style:{...t.toolBtn,borderLeft:`3px solid ${V[a]}`},onClick:()=>_(a),children:E[a]},a))]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:10,textTransform:"uppercase",marginBottom:6,letterSpacing:1},children:"Tools"}),e.jsx("button",{style:{...t.toolBtn,background:u?"#45475a":"transparent"},onClick:()=>c(u?null:r||null),title:"Click a source state, then click a target state",children:u?"Drawing... (click target)":"Draw Transition"})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:10,textTransform:"uppercase",marginBottom:6,letterSpacing:1},children:"Panels"}),e.jsxs("button",{style:t.toolBtn,onClick:()=>i(s==="variables"?"none":"variables"),children:["Variables (",n.variables.length,")"]}),e.jsx("button",{style:t.toolBtn,onClick:()=>i(s==="settings"?"none":"settings"),children:"Settings"})]}),e.jsx("div",{style:{marginTop:"auto"},children:e.jsx("button",{style:t.btnPrimary,onClick:F,disabled:b,children:b?"Saving...":"Save"})})]}),e.jsx("div",{style:t.canvas,ref:R,children:e.jsx(Z,{states:n.states,initialStateId:n.initialStateId,selectedStateId:r,drawingFrom:u,onStateClick:O,onStateDrag:q,onTransitionClick:a=>{p(a),i("transition")},selectedTransitionId:y})}),s!=="none"&&e.jsxs("div",{style:t.sidePanel,children:[s==="state"&&m&&e.jsx(U,{state:m,agents:o,isInitial:n.initialStateId===m.id,onUpdate:a=>k(m.id,a),onDelete:()=>S(m.id),onSetInitial:()=>g({...n,initialStateId:m.id}),onStartDrawing:()=>c(m.id),onClose:()=>i("none")}),s==="transition"&&y&&(()=>{const a=I();return a?e.jsx(ee,{transition:a.transition,parentState:a.state,allStates:n.states,variables:n.variables,onUpdate:f=>L(a.state.id,a.transition.id,f),onDelete:()=>A(a.state.id,a.transition.id),onClose:()=>i("none")}):null})(),s==="variables"&&e.jsx(te,{variables:n.variables,onChange:a=>g({...n,variables:a}),onClose:()=>i("none")}),s==="settings"&&e.jsx(ie,{workflow:n,onChange:g,onClose:()=>i("none")})]})]})}function Z({states:n,initialStateId:g,selectedStateId:v,drawingFrom:r,onStateClick:l,onStateDrag:y,onTransitionClick:p,selectedTransitionId:s}){const i=x.useRef(y);i.current=y;const u=x.useRef(!1),c=(d,o)=>{if(d.button!==0)return;d.stopPropagation();const m=d.currentTarget,I=d.clientX,C=d.clientY;let k=0,_=0,S=!1;const w=A=>{k=A.clientX-I,_=A.clientY-C,!S&&(Math.abs(k)>3||Math.abs(_)>3)&&(S=!0,m.style.zIndex="100",m.style.cursor="grabbing"),S&&(m.style.transform=`translate(${k}px, ${_}px)`)},L=()=>{window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",L),m.style.transform="",m.style.zIndex="",m.style.cursor="",S&&(u.current=!0,i.current(o,k,_))};window.addEventListener("mousemove",w),window.addEventListener("mouseup",L)},b=(d,o)=>{if(d.stopPropagation(),u.current){u.current=!1;return}l(o)},T=Math.max(...n.map(d=>{var o;return(((o=d.position)==null?void 0:o.x)??0)+G}),600)+100,R=Math.max(...n.map(d=>{var o;return(((o=d.position)==null?void 0:o.y)??0)+N}),400)+100,D=d=>{var o;return(((o=d.position)==null?void 0:o.x)??0)+G/2};return e.jsxs("div",{style:{position:"relative",width:T,height:R,minWidth:"100%",minHeight:"100%"},children:[e.jsxs("svg",{style:{position:"absolute",top:0,left:0,width:T,height:R,pointerEvents:"none"},children:[e.jsxs("defs",{children:[e.jsx("marker",{id:"arrow",markerWidth:"10",markerHeight:"7",refX:"10",refY:"3.5",orient:"auto",children:e.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#6c7086"})}),e.jsx("marker",{id:"arrow-selected",markerWidth:"10",markerHeight:"7",refX:"10",refY:"3.5",orient:"auto",children:e.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#89b4fa"})})]}),n.flatMap(d=>d.transitions.map(o=>{var L,A;const m=n.find(q=>q.id===o.targetStateId);if(!m)return null;const I=D(d),C=(((L=d.position)==null?void 0:L.y)??0)+N,k=D(m),_=((A=m.position)==null?void 0:A.y)??0,S=o.id===s,w=(C+_)/2;return e.jsxs("g",{style:{pointerEvents:"stroke",cursor:"pointer"},onClick:()=>p(o.id),children:[e.jsx("path",{d:`M ${I} ${C} C ${I} ${w}, ${k} ${w}, ${k} ${_}`,fill:"none",stroke:S?"#89b4fa":"#6c7086",strokeWidth:S?2.5:1.5,markerEnd:`url(#${S?"arrow-selected":"arrow"})`}),e.jsx("text",{x:(I+k)/2+8,y:w,fill:S?"#89b4fa":"#6c7086",fontSize:10,dominantBaseline:"middle",children:o.name})]},o.id)}))]}),n.map(d=>{var k,_;const o=d.id===v,m=d.id===g,I=r&&r!==d.id,C=V[d.type];return e.jsxs("div",{style:{position:"absolute",left:((k=d.position)==null?void 0:k.x)??0,top:((_=d.position)==null?void 0:_.y)??0,width:G,height:N,borderRadius:d.type==="decision"?8:d.type==="end"?30:8,background:o?"rgba(137,180,250,0.12)":"#313244",border:`2px solid ${o?"#89b4fa":I?"#a6e3a1":C}`,cursor:r?"crosshair":"grab",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",userSelect:"none",boxShadow:o?"0 0 12px rgba(137,180,250,0.2)":"none",transition:"box-shadow 0.15s"},onMouseDown:S=>c(S,d.id),onClick:S=>b(S,d.id),children:[m&&e.jsx("div",{style:{position:"absolute",top:-8,left:8,fontSize:9,color:"#a6e3a1",fontWeight:600,background:"#1e1e2e",padding:"0 4px",borderRadius:3},children:"START"}),e.jsx("div",{style:{color:C,fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:E[d.type]}),e.jsx("div",{style:{color:"#cdd6f4",fontSize:12,fontWeight:600,textAlign:"center",padding:"0 8px",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",maxWidth:G-16},children:d.name})]},d.id)})]})}function U({state:n,agents:g,isInitial:v,onUpdate:r,onDelete:l,onSetInitial:y,onStartDrawing:p,onClose:s}){const i=n.action,u=c=>{r({action:{...i,...c}})};return e.jsxs("div",{children:[e.jsxs("div",{style:t.sidePanelHeader,children:[e.jsxs("span",{style:{color:V[n.type],fontWeight:600},children:[E[n.type]," State"]}),e.jsx("button",{style:t.btnClose,onClick:s,children:"x"})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Name"}),e.jsx("input",{style:t.fieldInput,value:n.name,onChange:c=>r({name:c.target.value})})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Description"}),e.jsx("textarea",{style:{...t.fieldInput,height:60,resize:"vertical"},value:n.description||"",onChange:c=>r({description:c.target.value})})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Type"}),e.jsx("select",{style:t.fieldInput,value:n.type,onChange:c=>r({type:c.target.value}),children:Object.entries(E).map(([c,b])=>e.jsx("option",{value:c,children:b},c))})]}),n.type!=="end"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{...t.fieldLabel,marginTop:12,marginBottom:8,fontSize:11,color:"#a6adc8",textTransform:"uppercase",letterSpacing:1},children:"Action"}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Action Type"}),e.jsxs("select",{style:t.fieldInput,value:(i==null?void 0:i.type)||"agent_task",onChange:c=>{const b=c.target.value;b==="agent_task"?r({action:{type:"agent_task",agentId:"",promptTemplate:"",skills:[]}}):b==="wait_for_trigger"?r({action:{type:"wait_for_trigger",timeoutMs:36e5}}):b==="set_variables"?r({action:{type:"set_variables",assignments:{}}}):b==="trigger_setup"&&r({action:{type:"trigger_setup",triggerConfig:{}}})},children:[e.jsx("option",{value:"agent_task",children:"Agent Task"}),e.jsx("option",{value:"wait_for_trigger",children:"Wait for Trigger"}),e.jsx("option",{value:"set_variables",children:"Set Variables"}),e.jsx("option",{value:"trigger_setup",children:"Trigger Setup"})]})]}),(i==null?void 0:i.type)==="agent_task"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Agent"}),e.jsxs("select",{style:t.fieldInput,value:i.agentId,onChange:c=>u({agentId:c.target.value}),children:[e.jsx("option",{value:"",children:"Select agent..."}),g.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))]})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Prompt Template"}),e.jsx("textarea",{style:{...t.fieldInput,height:120,fontFamily:"monospace",fontSize:11,resize:"vertical"},value:i.promptTemplate,onChange:c=>u({promptTemplate:c.target.value}),placeholder:"Use {{variable}} for interpolation"})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Skills (comma-separated)"}),e.jsx("input",{style:t.fieldInput,value:(i.skills||[]).join(", "),onChange:c=>u({skills:c.target.value.split(",").map(b=>b.trim()).filter(Boolean)}),placeholder:"slack-messaging, jira-service-desk"})]})]}),(i==null?void 0:i.type)==="wait_for_trigger"&&e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Timeout (ms)"}),e.jsx("input",{type:"number",style:t.fieldInput,value:i.timeoutMs||"",onChange:c=>u({timeoutMs:c.target.value?Number(c.target.value):void 0})})]}),(i==null?void 0:i.type)==="set_variables"&&e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Assignments (JSON)"}),e.jsx("textarea",{style:{...t.fieldInput,height:80,fontFamily:"monospace",fontSize:11},value:JSON.stringify(i.assignments||{},null,2),onChange:c=>{try{u({assignments:JSON.parse(c.target.value)})}catch{}}})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:16,flexWrap:"wrap"},children:[!v&&e.jsx("button",{style:t.btnSecondary,onClick:y,children:"Set as Start"}),e.jsx("button",{style:t.btnSecondary,onClick:p,children:"Add Transition From Here"}),n.type!=="end"&&!v&&e.jsx("button",{style:{...t.btnSecondary,color:"#f38ba8",borderColor:"#f38ba8"},onClick:l,children:"Delete"})]})]})}function ee({transition:n,parentState:g,allStates:v,variables:r,onUpdate:l,onDelete:y,onClose:p}){const s=n.condition;return e.jsxs("div",{children:[e.jsxs("div",{style:t.sidePanelHeader,children:[e.jsx("span",{style:{color:"#89b4fa",fontWeight:600},children:"Transition"}),e.jsx("button",{style:t.btnClose,onClick:p,children:"x"})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Name"}),e.jsx("input",{style:t.fieldInput,value:n.name,onChange:i=>l({name:i.target.value})})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"From"}),e.jsx("div",{style:{color:"#cdd6f4",fontSize:12,padding:"6px 0"},children:g.name})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Target State"}),e.jsx("select",{style:t.fieldInput,value:n.targetStateId,onChange:i=>l({targetStateId:i.target.value}),children:v.filter(i=>i.id!==g.id).map(i=>e.jsx("option",{value:i.id,children:i.name},i.id))})]}),e.jsx("div",{style:{...t.fieldLabel,marginTop:12,marginBottom:8,fontSize:11,color:"#a6adc8",textTransform:"uppercase",letterSpacing:1},children:"Condition"}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Condition Type"}),e.jsx("select",{style:t.fieldInput,value:s.type,onChange:i=>{const u=i.target.value;u==="agent_complete"?l({condition:{type:"agent_complete"}}):u==="trigger_fired"?l({condition:{type:"trigger_fired"}}):u==="variable_check"?l({condition:{type:"variable_check",variable:"",operator:"equals",value:""}}):u==="timeout"?l({condition:{type:"timeout",afterMs:36e5}}):u==="manual"?l({condition:{type:"manual"}}):u==="cron"&&l({condition:{type:"cron",expression:"* * * * *"}})},children:Object.entries(X).map(([i,u])=>e.jsx("option",{value:i,children:u},i))})]}),s.type==="variable_check"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Variable"}),e.jsxs("select",{style:t.fieldInput,value:s.variable,onChange:i=>l({condition:{...s,variable:i.target.value}}),children:[e.jsx("option",{value:"",children:"Select..."}),r.map(i=>e.jsx("option",{value:i.name,children:i.name},i.name))]})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Operator"}),e.jsxs("select",{style:t.fieldInput,value:s.operator,onChange:i=>l({condition:{...s,operator:i.target.value}}),children:[e.jsx("option",{value:"equals",children:"Equals"}),e.jsx("option",{value:"not_equals",children:"Not Equals"}),e.jsx("option",{value:"contains",children:"Contains"}),e.jsx("option",{value:"greater_than",children:"Greater Than"}),e.jsx("option",{value:"less_than",children:"Less Than"}),e.jsx("option",{value:"is_true",children:"Is True"})]})]}),s.operator!=="is_true"&&e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Value"}),e.jsx("input",{style:t.fieldInput,value:String(s.value??""),onChange:i=>l({condition:{...s,value:i.target.value}})})]})]}),s.type==="timeout"&&e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Timeout (ms)"}),e.jsx("input",{type:"number",style:t.fieldInput,value:s.afterMs,onChange:i=>l({condition:{...s,afterMs:Number(i.target.value)}})})]}),s.type==="cron"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Cron Expression"}),e.jsx("input",{style:t.fieldInput,value:s.expression,onChange:i=>l({condition:{...s,expression:i.target.value}}),placeholder:"*/5 * * * *"})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Timezone"}),e.jsx("input",{style:t.fieldInput,value:s.timezone||"",onChange:i=>l({condition:{...s,timezone:i.target.value}}),placeholder:"UTC"})]})]}),s.type==="trigger_fired"&&e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Trigger ID (optional)"}),e.jsx("input",{style:t.fieldInput,value:s.triggerId||"",onChange:i=>l({condition:{...s,triggerId:i.target.value||void 0}})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx("button",{style:{...t.btnSecondary,color:"#f38ba8",borderColor:"#f38ba8"},onClick:y,children:"Delete Transition"})})]})}function te({variables:n,onChange:g,onClose:v}){const r=()=>{g([...n,{name:"",type:"string",description:""}])},l=(p,s)=>{g(n.map((i,u)=>u===p?{...i,...s}:i))},y=p=>{g(n.filter((s,i)=>i!==p))};return e.jsxs("div",{children:[e.jsxs("div",{style:t.sidePanelHeader,children:[e.jsxs("span",{style:{color:"#cba6f7",fontWeight:600},children:["Variables (",n.length,")"]}),e.jsx("button",{style:t.btnClose,onClick:v,children:"x"})]}),n.map((p,s)=>e.jsxs("div",{style:{marginBottom:12,padding:8,background:"#313244",borderRadius:6},children:[e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:4},children:[e.jsx("input",{style:{...t.fieldInput,flex:1},value:p.name,onChange:i=>l(s,{name:i.target.value}),placeholder:"Variable name"}),e.jsxs("select",{style:{...t.fieldInput,width:80},value:p.type,onChange:i=>l(s,{type:i.target.value}),children:[e.jsx("option",{value:"string",children:"string"}),e.jsx("option",{value:"number",children:"number"}),e.jsx("option",{value:"boolean",children:"boolean"}),e.jsx("option",{value:"date",children:"date"}),e.jsx("option",{value:"email",children:"email"}),e.jsx("option",{value:"json",children:"json"})]}),e.jsx("button",{style:{...t.btnClose,padding:"2px 6px"},onClick:()=>y(s),children:"x"})]}),e.jsx("input",{style:{...t.fieldInput,fontSize:11},value:p.description||"",onChange:i=>l(s,{description:i.target.value}),placeholder:"Description"}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,marginTop:4,color:"#a6adc8",fontSize:11},children:[e.jsx("input",{type:"checkbox",checked:!!p.required,onChange:i=>l(s,{required:i.target.checked})}),"Required"]})]},s)),e.jsx("button",{style:t.btnSecondary,onClick:r,children:"Add Variable"})]})}function ie({workflow:n,onChange:g,onClose:v}){return e.jsxs("div",{children:[e.jsxs("div",{style:t.sidePanelHeader,children:[e.jsx("span",{style:{color:"#cdd6f4",fontWeight:600},children:"Settings"}),e.jsx("button",{style:t.btnClose,onClick:v,children:"x"})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Name"}),e.jsx("input",{style:t.fieldInput,value:n.name,onChange:r=>g({...n,name:r.target.value})})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Description"}),e.jsx("textarea",{style:{...t.fieldInput,height:60,resize:"vertical"},value:n.description||"",onChange:r=>g({...n,description:r.target.value})})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Initial State"}),e.jsx("select",{style:t.fieldInput,value:n.initialStateId,onChange:r=>g({...n,initialStateId:r.target.value}),children:n.states.map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Color"}),e.jsx("input",{type:"color",value:n.color||"#89b4fa",onChange:r=>g({...n,color:r.target.value}),style:{width:40,height:30,padding:0,border:"none",cursor:"pointer"}})]}),e.jsxs("div",{style:{color:"#6c7086",fontSize:11,marginTop:16},children:["Version: ",n.version," | States: ",n.states.length," | Transitions: ",n.states.reduce((r,l)=>r+l.transitions.length,0)]})]})}const t={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.6)",zIndex:1e3,display:"flex",justifyContent:"center",alignItems:"center"},panel:{background:"#1e1e2e",borderRadius:12,border:"1px solid #313244",width:"95vw",height:"90vh",display:"flex",flexDirection:"column",overflow:"hidden"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 20px",borderBottom:"1px solid #313244",flexShrink:0},title:{color:"#cdd6f4",fontSize:16,fontWeight:600,margin:0},content:{padding:20,flex:1,overflow:"auto"},card:{background:"#313244",borderRadius:8,padding:"12px 16px",marginBottom:8,cursor:"pointer",border:"1px solid transparent",transition:"border-color 0.15s"},toolbar:{width:180,borderRight:"1px solid #313244",padding:12,display:"flex",flexDirection:"column",flexShrink:0,overflow:"auto"},toolBtn:{display:"block",width:"100%",background:"transparent",border:"1px solid #45475a",borderRadius:6,padding:"6px 10px",color:"#cdd6f4",fontSize:11,cursor:"pointer",textAlign:"left",marginBottom:4},canvas:{flex:1,overflow:"auto",background:"#181825",position:"relative",backgroundImage:"radial-gradient(circle, #313244 1px, transparent 1px)",backgroundSize:"20px 20px"},sidePanel:{width:300,borderLeft:"1px solid #313244",padding:12,overflow:"auto",flexShrink:0},sidePanelHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12,paddingBottom:8,borderBottom:"1px solid #313244"},fieldGroup:{marginBottom:10},fieldLabel:{display:"block",color:"#a6adc8",fontSize:11,marginBottom:4},fieldInput:{display:"block",width:"100%",background:"#313244",border:"1px solid #45475a",borderRadius:6,padding:"6px 8px",color:"#cdd6f4",fontSize:12,outline:"none",boxSizing:"border-box"},btnPrimary:{background:"#89b4fa",border:"none",borderRadius:6,padding:"8px 16px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:12,width:"100%"},btnSecondary:{background:"transparent",border:"1px solid #45475a",borderRadius:6,padding:"6px 12px",color:"#cdd6f4",cursor:"pointer",fontSize:11},btnClose:{background:"transparent",border:"none",color:"#6c7086",cursor:"pointer",fontSize:14,padding:"4px 8px"}};export{le as WorkflowEditorPanel};
|
|
42
|
+
3. Update Jira ticket status to "In Progress" or "Done".`,skills:["email-gmail","slack-messaging","jira-service-desk"]},transitions:[{id:"t-done",name:"Release Complete",targetStateId:"end",condition:{type:"agent_complete"}}],position:{x:100,y:1060}},{id:"end",name:"End",type:"end",description:"CC process complete",transitions:[],position:{x:100,y:1160}}],Y=[{name:"requester_name",type:"string",description:"Developer requesting the release",required:!0},{name:"requester_email",type:"email",description:"Requester email",required:!0},{name:"requester_slack_id",type:"string",description:"Requester Slack user ID"},{name:"release_name",type:"string",description:"Release version/name",required:!0},{name:"release_description",type:"string",description:"What is being released"},{name:"affected_systems",type:"string",description:"Systems impacted"},{name:"release_date",type:"date",description:"Scheduled release date",required:!0},{name:"release_time",type:"string",description:"Scheduled release time",required:!0},{name:"is_urgent",type:"boolean",description:"Whether this is an urgent release"},{name:"additional_attendees",type:"string",description:"Other people to invite (comma-separated emails)"},{name:"jira_ticket_key",type:"string",description:"Jira ticket key (e.g. SD-1234)"},{name:"jira_ticket_url",type:"string",description:"Full Jira ticket URL"},{name:"cc_file_path",type:"string",description:"Path to generated CC document"},{name:"email_thread_id",type:"string",description:"Gmail thread ID for approval chain"},{name:"calendar_event_id",type:"string",description:"Google Calendar event ID"},{name:"approval_status",type:"json",description:"Current approval status"}],G=200,N=60,B=20,V={action:"#89b4fa",decision:"#f9e2af",wait:"#cba6f7",end:"#a6e3a1"},E={action:"Action",decision:"Decision",wait:"Wait",end:"End"},X={agent_complete:"Agent Complete",trigger_fired:"Trigger Fired",variable_check:"Variable Check",timeout:"Timeout",manual:"Manual",cron:"Cron"};function le({isOpen:n,onClose:g}){const[v,r]=x.useState([]),[l,y]=x.useState(null),[p,s]=x.useState("list"),[i,u]=x.useState(!0),[c,b]=x.useState(null),T=x.useCallback(async()=>{u(!0);try{const o=await M(P("/api/workflows/definitions"));o.ok&&r(await o.json())}catch{b("Failed to load workflows")}finally{u(!1)}},[]);x.useEffect(()=>{n&&T()},[n,T]);const W=()=>{const o={id:`wf-${Date.now()}`,name:"New Workflow",description:"",version:1,variables:[],states:[{id:"start",name:"Start",type:"action",transitions:[],position:{x:300,y:60}},{id:"end",name:"End",type:"end",transitions:[],position:{x:300,y:260}}],initialStateId:"start",createdAt:Date.now(),updatedAt:Date.now()};y(o),s("editor")},D=()=>{const o={id:`wf-cc-${Date.now()}`,name:"CC (Control de Cambios)",description:"Full CC process: intake, Jira ticket, document, approval, release",version:1,variables:[...Y],states:H.map(m=>({...m,transitions:[...m.transitions]})),initialStateId:"intake",createdAt:Date.now(),updatedAt:Date.now()};y(o),s("editor")},d=async o=>{try{v.find(I=>I.id===o.id)?await M(P(`/api/workflows/definitions/${o.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}):await M(P("/api/workflows/definitions"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),await T()}catch{b("Failed to save workflow")}};return n?e.jsx("div",{style:t.overlay,children:e.jsxs("div",{style:t.panel,children:[e.jsxs("div",{style:t.header,children:[e.jsx("h2",{style:t.title,children:p==="list"?"Workflow Definitions":(l==null?void 0:l.name)||"Editor"}),e.jsxs("div",{style:{display:"flex",gap:8},children:[p==="editor"&&e.jsx("button",{style:t.btnSecondary,onClick:()=>s("list"),children:"Back to List"}),e.jsx("button",{style:t.btnClose,onClick:g,children:"Close"})]})]}),p==="list"&&e.jsx(K,{workflows:v,loading:i,error:c,onSelect:o=>{y(o),s("editor")},onCreate:W,onLoadCC:D}),p==="editor"&&l&&e.jsx(Q,{workflow:l,onChange:y,onSave:d})]})}):null}function K({workflows:n,loading:g,error:v,onSelect:r,onCreate:l,onLoadCC:y}){return e.jsxs("div",{style:t.content,children:[e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:16},children:[e.jsx("button",{style:t.btnPrimary,onClick:l,children:"New Workflow"}),e.jsx("button",{style:t.btnSecondary,onClick:y,children:"Load CC Template"})]}),g&&e.jsx("div",{style:{color:"#a6adc8"},children:"Loading..."}),v&&e.jsx("div",{style:{color:"#f38ba8"},children:v}),n.map(p=>e.jsxs("div",{style:t.card,onClick:()=>r(p),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{style:{color:"#cdd6f4",fontWeight:600,fontSize:14},children:p.name}),e.jsxs("span",{style:{color:"#a6adc8",fontSize:11},children:["v",p.version," | ",p.states.length," states"]})]}),p.description&&e.jsx("div",{style:{color:"#a6adc8",fontSize:12,marginTop:4},children:p.description})]},p.id)),!g&&n.length===0&&e.jsx("div",{style:{color:"#6c7086",textAlign:"center",padding:40},children:"No workflows yet. Create one or load the CC template."})]})}function Q({workflow:n,onChange:g,onSave:v}){const[r,l]=x.useState(null),[y,p]=x.useState(null),[s,i]=x.useState("none"),[u,c]=x.useState(null),[b,T]=x.useState(!1),W=x.useRef(null),D=x.useRef(n);D.current=n;const d=J(),o=x.useMemo(()=>Array.from(d.values()).map(a=>({id:a.id,name:a.name})),[d]),m=n.states.find(a=>a.id===r),I=x.useCallback(()=>{for(const a of n.states){const f=a.transitions.find(h=>h.id===y);if(f)return{state:a,transition:f}}return null},[n,y]),C=a=>{g({...n,states:a,updatedAt:Date.now()})},k=(a,f)=>{C(n.states.map(h=>h.id===a?{...h,...f}:h))},_=a=>{const f=`state-${Date.now()}`,h={id:f,name:`New ${E[a]}`,type:a,transitions:[],position:{x:300,y:n.states.length*100+60}};C([...n.states,h]),l(f),i("state")},S=a=>{const f=n.states.filter(h=>h.id!==a).map(h=>({...h,transitions:h.transitions.filter(j=>j.targetStateId!==a)}));C(f),l(null),i("none")},w=(a,f)=>{const h=`t-${Date.now()}`;C(n.states.map(j=>j.id!==a?j:{...j,transitions:[...j.transitions,{id:h,name:"New Transition",targetStateId:f,condition:{type:"agent_complete"}}]})),p(h),i("transition")},L=(a,f,h)=>{C(n.states.map(j=>j.id!==a?j:{...j,transitions:j.transitions.map(R=>R.id===f?{...R,...h}:R)}))},A=(a,f)=>{C(n.states.map(h=>h.id!==a?h:{...h,transitions:h.transitions.filter(j=>j.id!==f)})),p(null),i("none")},q=x.useCallback((a,f,h)=>{const j=D.current,R=j.states.map(z=>{if(z.id!==a)return z;const $=z.position||{x:0,y:0};return{...z,position:{x:Math.round(($.x+f)/B)*B,y:Math.round(($.y+h)/B)*B}}});g({...j,states:R,updatedAt:Date.now()})},[g]),O=a=>{u?(u!==a&&w(u,a),c(null)):(l(a),p(null),i("state"))},F=async()=>{T(!0);try{await v(n)}finally{T(!1)}};return e.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[e.jsxs("div",{style:t.toolbar,children:[e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:10,textTransform:"uppercase",marginBottom:6,letterSpacing:1},children:"Add State"}),["action","decision","wait","end"].map(a=>e.jsx("button",{style:{...t.toolBtn,borderLeft:`3px solid ${V[a]}`},onClick:()=>_(a),children:E[a]},a))]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:10,textTransform:"uppercase",marginBottom:6,letterSpacing:1},children:"Tools"}),e.jsx("button",{style:{...t.toolBtn,background:u?"#45475a":"transparent"},onClick:()=>c(u?null:r||null),title:"Click a source state, then click a target state",children:u?"Drawing... (click target)":"Draw Transition"})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:10,textTransform:"uppercase",marginBottom:6,letterSpacing:1},children:"Panels"}),e.jsxs("button",{style:t.toolBtn,onClick:()=>i(s==="variables"?"none":"variables"),children:["Variables (",n.variables.length,")"]}),e.jsx("button",{style:t.toolBtn,onClick:()=>i(s==="settings"?"none":"settings"),children:"Settings"})]}),e.jsx("div",{style:{marginTop:"auto"},children:e.jsx("button",{style:t.btnPrimary,onClick:F,disabled:b,children:b?"Saving...":"Save"})})]}),e.jsx("div",{style:t.canvas,ref:W,children:e.jsx(Z,{states:n.states,initialStateId:n.initialStateId,selectedStateId:r,drawingFrom:u,onStateClick:O,onStateDrag:q,onTransitionClick:a=>{p(a),i("transition")},selectedTransitionId:y})}),s!=="none"&&e.jsxs("div",{style:t.sidePanel,children:[s==="state"&&m&&e.jsx(U,{state:m,agents:o,isInitial:n.initialStateId===m.id,onUpdate:a=>k(m.id,a),onDelete:()=>S(m.id),onSetInitial:()=>g({...n,initialStateId:m.id}),onStartDrawing:()=>c(m.id),onClose:()=>i("none")}),s==="transition"&&y&&(()=>{const a=I();return a?e.jsx(ee,{transition:a.transition,parentState:a.state,allStates:n.states,variables:n.variables,onUpdate:f=>L(a.state.id,a.transition.id,f),onDelete:()=>A(a.state.id,a.transition.id),onClose:()=>i("none")}):null})(),s==="variables"&&e.jsx(te,{variables:n.variables,onChange:a=>g({...n,variables:a}),onClose:()=>i("none")}),s==="settings"&&e.jsx(ie,{workflow:n,onChange:g,onClose:()=>i("none")})]})]})}function Z({states:n,initialStateId:g,selectedStateId:v,drawingFrom:r,onStateClick:l,onStateDrag:y,onTransitionClick:p,selectedTransitionId:s}){const i=x.useRef(y);i.current=y;const u=x.useRef(!1),c=(d,o)=>{if(d.button!==0)return;d.stopPropagation();const m=d.currentTarget,I=d.clientX,C=d.clientY;let k=0,_=0,S=!1;const w=A=>{k=A.clientX-I,_=A.clientY-C,!S&&(Math.abs(k)>3||Math.abs(_)>3)&&(S=!0,m.style.zIndex="100",m.style.cursor="grabbing"),S&&(m.style.transform=`translate(${k}px, ${_}px)`)},L=()=>{window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",L),m.style.transform="",m.style.zIndex="",m.style.cursor="",S&&(u.current=!0,i.current(o,k,_))};window.addEventListener("mousemove",w),window.addEventListener("mouseup",L)},b=(d,o)=>{if(d.stopPropagation(),u.current){u.current=!1;return}l(o)},T=Math.max(...n.map(d=>{var o;return(((o=d.position)==null?void 0:o.x)??0)+G}),600)+100,W=Math.max(...n.map(d=>{var o;return(((o=d.position)==null?void 0:o.y)??0)+N}),400)+100,D=d=>{var o;return(((o=d.position)==null?void 0:o.x)??0)+G/2};return e.jsxs("div",{style:{position:"relative",width:T,height:W,minWidth:"100%",minHeight:"100%"},children:[e.jsxs("svg",{style:{position:"absolute",top:0,left:0,width:T,height:W,pointerEvents:"none"},children:[e.jsxs("defs",{children:[e.jsx("marker",{id:"arrow",markerWidth:"10",markerHeight:"7",refX:"10",refY:"3.5",orient:"auto",children:e.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#6c7086"})}),e.jsx("marker",{id:"arrow-selected",markerWidth:"10",markerHeight:"7",refX:"10",refY:"3.5",orient:"auto",children:e.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#89b4fa"})})]}),n.flatMap(d=>d.transitions.map(o=>{var L,A;const m=n.find(q=>q.id===o.targetStateId);if(!m)return null;const I=D(d),C=(((L=d.position)==null?void 0:L.y)??0)+N,k=D(m),_=((A=m.position)==null?void 0:A.y)??0,S=o.id===s,w=(C+_)/2;return e.jsxs("g",{style:{pointerEvents:"stroke",cursor:"pointer"},onClick:()=>p(o.id),children:[e.jsx("path",{d:`M ${I} ${C} C ${I} ${w}, ${k} ${w}, ${k} ${_}`,fill:"none",stroke:S?"#89b4fa":"#6c7086",strokeWidth:S?2.5:1.5,markerEnd:`url(#${S?"arrow-selected":"arrow"})`}),e.jsx("text",{x:(I+k)/2+8,y:w,fill:S?"#89b4fa":"#6c7086",fontSize:10,dominantBaseline:"middle",children:o.name})]},o.id)}))]}),n.map(d=>{var k,_;const o=d.id===v,m=d.id===g,I=r&&r!==d.id,C=V[d.type];return e.jsxs("div",{style:{position:"absolute",left:((k=d.position)==null?void 0:k.x)??0,top:((_=d.position)==null?void 0:_.y)??0,width:G,height:N,borderRadius:d.type==="decision"?8:d.type==="end"?30:8,background:o?"rgba(137,180,250,0.12)":"#313244",border:`2px solid ${o?"#89b4fa":I?"#a6e3a1":C}`,cursor:r?"crosshair":"grab",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",userSelect:"none",boxShadow:o?"0 0 12px rgba(137,180,250,0.2)":"none",transition:"box-shadow 0.15s"},onMouseDown:S=>c(S,d.id),onClick:S=>b(S,d.id),children:[m&&e.jsx("div",{style:{position:"absolute",top:-8,left:8,fontSize:9,color:"#a6e3a1",fontWeight:600,background:"#1e1e2e",padding:"0 4px",borderRadius:3},children:"START"}),e.jsx("div",{style:{color:C,fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:E[d.type]}),e.jsx("div",{style:{color:"#cdd6f4",fontSize:12,fontWeight:600,textAlign:"center",padding:"0 8px",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",maxWidth:G-16},children:d.name})]},d.id)})]})}function U({state:n,agents:g,isInitial:v,onUpdate:r,onDelete:l,onSetInitial:y,onStartDrawing:p,onClose:s}){const i=n.action,u=c=>{r({action:{...i,...c}})};return e.jsxs("div",{children:[e.jsxs("div",{style:t.sidePanelHeader,children:[e.jsxs("span",{style:{color:V[n.type],fontWeight:600},children:[E[n.type]," State"]}),e.jsx("button",{style:t.btnClose,onClick:s,children:"x"})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Name"}),e.jsx("input",{style:t.fieldInput,value:n.name,onChange:c=>r({name:c.target.value})})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Description"}),e.jsx("textarea",{style:{...t.fieldInput,height:60,resize:"vertical"},value:n.description||"",onChange:c=>r({description:c.target.value})})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Type"}),e.jsx("select",{style:t.fieldInput,value:n.type,onChange:c=>r({type:c.target.value}),children:Object.entries(E).map(([c,b])=>e.jsx("option",{value:c,children:b},c))})]}),n.type!=="end"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{...t.fieldLabel,marginTop:12,marginBottom:8,fontSize:11,color:"#a6adc8",textTransform:"uppercase",letterSpacing:1},children:"Action"}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Action Type"}),e.jsxs("select",{style:t.fieldInput,value:(i==null?void 0:i.type)||"agent_task",onChange:c=>{const b=c.target.value;b==="agent_task"?r({action:{type:"agent_task",agentId:"",promptTemplate:"",skills:[]}}):b==="wait_for_trigger"?r({action:{type:"wait_for_trigger",timeoutMs:36e5}}):b==="set_variables"?r({action:{type:"set_variables",assignments:{}}}):b==="trigger_setup"&&r({action:{type:"trigger_setup",triggerConfig:{}}})},children:[e.jsx("option",{value:"agent_task",children:"Agent Task"}),e.jsx("option",{value:"wait_for_trigger",children:"Wait for Trigger"}),e.jsx("option",{value:"set_variables",children:"Set Variables"}),e.jsx("option",{value:"trigger_setup",children:"Trigger Setup"})]})]}),(i==null?void 0:i.type)==="agent_task"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Agent"}),e.jsxs("select",{style:t.fieldInput,value:i.agentId,onChange:c=>u({agentId:c.target.value}),children:[e.jsx("option",{value:"",children:"Select agent..."}),g.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))]})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Prompt Template"}),e.jsx("textarea",{style:{...t.fieldInput,height:120,fontFamily:"monospace",fontSize:11,resize:"vertical"},value:i.promptTemplate,onChange:c=>u({promptTemplate:c.target.value}),placeholder:"Use {{variable}} for interpolation"})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Skills (comma-separated)"}),e.jsx("input",{style:t.fieldInput,value:(i.skills||[]).join(", "),onChange:c=>u({skills:c.target.value.split(",").map(b=>b.trim()).filter(Boolean)}),placeholder:"slack-messaging, jira-service-desk"})]})]}),(i==null?void 0:i.type)==="wait_for_trigger"&&e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Timeout (ms)"}),e.jsx("input",{type:"number",style:t.fieldInput,value:i.timeoutMs||"",onChange:c=>u({timeoutMs:c.target.value?Number(c.target.value):void 0})})]}),(i==null?void 0:i.type)==="set_variables"&&e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Assignments (JSON)"}),e.jsx("textarea",{style:{...t.fieldInput,height:80,fontFamily:"monospace",fontSize:11},value:JSON.stringify(i.assignments||{},null,2),onChange:c=>{try{u({assignments:JSON.parse(c.target.value)})}catch{}}})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:16,flexWrap:"wrap"},children:[!v&&e.jsx("button",{style:t.btnSecondary,onClick:y,children:"Set as Start"}),e.jsx("button",{style:t.btnSecondary,onClick:p,children:"Add Transition From Here"}),n.type!=="end"&&!v&&e.jsx("button",{style:{...t.btnSecondary,color:"#f38ba8",borderColor:"#f38ba8"},onClick:l,children:"Delete"})]})]})}function ee({transition:n,parentState:g,allStates:v,variables:r,onUpdate:l,onDelete:y,onClose:p}){const s=n.condition;return e.jsxs("div",{children:[e.jsxs("div",{style:t.sidePanelHeader,children:[e.jsx("span",{style:{color:"#89b4fa",fontWeight:600},children:"Transition"}),e.jsx("button",{style:t.btnClose,onClick:p,children:"x"})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Name"}),e.jsx("input",{style:t.fieldInput,value:n.name,onChange:i=>l({name:i.target.value})})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"From"}),e.jsx("div",{style:{color:"#cdd6f4",fontSize:12,padding:"6px 0"},children:g.name})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Target State"}),e.jsx("select",{style:t.fieldInput,value:n.targetStateId,onChange:i=>l({targetStateId:i.target.value}),children:v.filter(i=>i.id!==g.id).map(i=>e.jsx("option",{value:i.id,children:i.name},i.id))})]}),e.jsx("div",{style:{...t.fieldLabel,marginTop:12,marginBottom:8,fontSize:11,color:"#a6adc8",textTransform:"uppercase",letterSpacing:1},children:"Condition"}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Condition Type"}),e.jsx("select",{style:t.fieldInput,value:s.type,onChange:i=>{const u=i.target.value;u==="agent_complete"?l({condition:{type:"agent_complete"}}):u==="trigger_fired"?l({condition:{type:"trigger_fired"}}):u==="variable_check"?l({condition:{type:"variable_check",variable:"",operator:"equals",value:""}}):u==="timeout"?l({condition:{type:"timeout",afterMs:36e5}}):u==="manual"?l({condition:{type:"manual"}}):u==="cron"&&l({condition:{type:"cron",expression:"* * * * *"}})},children:Object.entries(X).map(([i,u])=>e.jsx("option",{value:i,children:u},i))})]}),s.type==="variable_check"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Variable"}),e.jsxs("select",{style:t.fieldInput,value:s.variable,onChange:i=>l({condition:{...s,variable:i.target.value}}),children:[e.jsx("option",{value:"",children:"Select..."}),r.map(i=>e.jsx("option",{value:i.name,children:i.name},i.name))]})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Operator"}),e.jsxs("select",{style:t.fieldInput,value:s.operator,onChange:i=>l({condition:{...s,operator:i.target.value}}),children:[e.jsx("option",{value:"equals",children:"Equals"}),e.jsx("option",{value:"not_equals",children:"Not Equals"}),e.jsx("option",{value:"contains",children:"Contains"}),e.jsx("option",{value:"greater_than",children:"Greater Than"}),e.jsx("option",{value:"less_than",children:"Less Than"}),e.jsx("option",{value:"is_true",children:"Is True"})]})]}),s.operator!=="is_true"&&e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Value"}),e.jsx("input",{style:t.fieldInput,value:String(s.value??""),onChange:i=>l({condition:{...s,value:i.target.value}})})]})]}),s.type==="timeout"&&e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Timeout (ms)"}),e.jsx("input",{type:"number",style:t.fieldInput,value:s.afterMs,onChange:i=>l({condition:{...s,afterMs:Number(i.target.value)}})})]}),s.type==="cron"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Cron Expression"}),e.jsx("input",{style:t.fieldInput,value:s.expression,onChange:i=>l({condition:{...s,expression:i.target.value}}),placeholder:"*/5 * * * *"})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Timezone"}),e.jsx("input",{style:t.fieldInput,value:s.timezone||"",onChange:i=>l({condition:{...s,timezone:i.target.value}}),placeholder:"UTC"})]})]}),s.type==="trigger_fired"&&e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Trigger ID (optional)"}),e.jsx("input",{style:t.fieldInput,value:s.triggerId||"",onChange:i=>l({condition:{...s,triggerId:i.target.value||void 0}})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx("button",{style:{...t.btnSecondary,color:"#f38ba8",borderColor:"#f38ba8"},onClick:y,children:"Delete Transition"})})]})}function te({variables:n,onChange:g,onClose:v}){const r=()=>{g([...n,{name:"",type:"string",description:""}])},l=(p,s)=>{g(n.map((i,u)=>u===p?{...i,...s}:i))},y=p=>{g(n.filter((s,i)=>i!==p))};return e.jsxs("div",{children:[e.jsxs("div",{style:t.sidePanelHeader,children:[e.jsxs("span",{style:{color:"#cba6f7",fontWeight:600},children:["Variables (",n.length,")"]}),e.jsx("button",{style:t.btnClose,onClick:v,children:"x"})]}),n.map((p,s)=>e.jsxs("div",{style:{marginBottom:12,padding:8,background:"#313244",borderRadius:6},children:[e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:4},children:[e.jsx("input",{style:{...t.fieldInput,flex:1},value:p.name,onChange:i=>l(s,{name:i.target.value}),placeholder:"Variable name"}),e.jsxs("select",{style:{...t.fieldInput,width:80},value:p.type,onChange:i=>l(s,{type:i.target.value}),children:[e.jsx("option",{value:"string",children:"string"}),e.jsx("option",{value:"number",children:"number"}),e.jsx("option",{value:"boolean",children:"boolean"}),e.jsx("option",{value:"date",children:"date"}),e.jsx("option",{value:"email",children:"email"}),e.jsx("option",{value:"json",children:"json"})]}),e.jsx("button",{style:{...t.btnClose,padding:"2px 6px"},onClick:()=>y(s),children:"x"})]}),e.jsx("input",{style:{...t.fieldInput,fontSize:11},value:p.description||"",onChange:i=>l(s,{description:i.target.value}),placeholder:"Description"}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,marginTop:4,color:"#a6adc8",fontSize:11},children:[e.jsx("input",{type:"checkbox",checked:!!p.required,onChange:i=>l(s,{required:i.target.checked})}),"Required"]})]},s)),e.jsx("button",{style:t.btnSecondary,onClick:r,children:"Add Variable"})]})}function ie({workflow:n,onChange:g,onClose:v}){return e.jsxs("div",{children:[e.jsxs("div",{style:t.sidePanelHeader,children:[e.jsx("span",{style:{color:"#cdd6f4",fontWeight:600},children:"Settings"}),e.jsx("button",{style:t.btnClose,onClick:v,children:"x"})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Name"}),e.jsx("input",{style:t.fieldInput,value:n.name,onChange:r=>g({...n,name:r.target.value})})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Description"}),e.jsx("textarea",{style:{...t.fieldInput,height:60,resize:"vertical"},value:n.description||"",onChange:r=>g({...n,description:r.target.value})})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Initial State"}),e.jsx("select",{style:t.fieldInput,value:n.initialStateId,onChange:r=>g({...n,initialStateId:r.target.value}),children:n.states.map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))})]}),e.jsxs("div",{style:t.fieldGroup,children:[e.jsx("label",{style:t.fieldLabel,children:"Color"}),e.jsx("input",{type:"color",value:n.color||"#89b4fa",onChange:r=>g({...n,color:r.target.value}),style:{width:40,height:30,padding:0,border:"none",cursor:"pointer"}})]}),e.jsxs("div",{style:{color:"#6c7086",fontSize:11,marginTop:16},children:["Version: ",n.version," | States: ",n.states.length," | Transitions: ",n.states.reduce((r,l)=>r+l.transitions.length,0)]})]})}const t={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.6)",zIndex:1e3,display:"flex",justifyContent:"center",alignItems:"center"},panel:{background:"#1e1e2e",borderRadius:12,border:"1px solid #313244",width:"95vw",height:"90vh",display:"flex",flexDirection:"column",overflow:"hidden"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 20px",borderBottom:"1px solid #313244",flexShrink:0},title:{color:"#cdd6f4",fontSize:16,fontWeight:600,margin:0},content:{padding:20,flex:1,overflow:"auto"},card:{background:"#313244",borderRadius:8,padding:"12px 16px",marginBottom:8,cursor:"pointer",border:"1px solid transparent",transition:"border-color 0.15s"},toolbar:{width:180,borderRight:"1px solid #313244",padding:12,display:"flex",flexDirection:"column",flexShrink:0,overflow:"auto"},toolBtn:{display:"block",width:"100%",background:"transparent",border:"1px solid #45475a",borderRadius:6,padding:"6px 10px",color:"#cdd6f4",fontSize:11,cursor:"pointer",textAlign:"left",marginBottom:4},canvas:{flex:1,overflow:"auto",background:"#181825",position:"relative",backgroundImage:"radial-gradient(circle, #313244 1px, transparent 1px)",backgroundSize:"20px 20px"},sidePanel:{width:300,borderLeft:"1px solid #313244",padding:12,overflow:"auto",flexShrink:0},sidePanelHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12,paddingBottom:8,borderBottom:"1px solid #313244"},fieldGroup:{marginBottom:10},fieldLabel:{display:"block",color:"#a6adc8",fontSize:11,marginBottom:4},fieldInput:{display:"block",width:"100%",background:"#313244",border:"1px solid #45475a",borderRadius:6,padding:"6px 8px",color:"#cdd6f4",fontSize:12,outline:"none",boxSizing:"border-box"},btnPrimary:{background:"#89b4fa",border:"none",borderRadius:6,padding:"8px 16px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:12,width:"100%"},btnSecondary:{background:"transparent",border:"1px solid #45475a",borderRadius:6,padding:"6px 12px",color:"#cdd6f4",cursor:"pointer",fontSize:11},btnClose:{background:"transparent",border:"none",color:"#6c7086",cursor:"pointer",fontSize:14,padding:"4px 8px"}};export{le as WorkflowEditorPanel};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{am as sa,u as E,j as e,Y as v,ap as Fs,aq as $s,Z as He,s as P,ar as Ms,D as V,a8 as ee,a9 as Ge,f as aa,as as ta,r as o,U as na,S as la,h as ia,aa as Ke}from"./main-D3GShQ8B.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ra=[{value:"",labelKey:"terminal:building.colorDefault"},{value:"#2a2a3a",labelKey:"terminal:building.colorDarkGray"},{value:"#3a2a2a",labelKey:"terminal:building.colorDarkRed"},{value:"#2a3a2a",labelKey:"terminal:building.colorDarkGreen"},{value:"#2a2a4a",labelKey:"terminal:building.colorDarkBlue"},{value:"#3a3a2a",labelKey:"terminal:building.colorDarkYellow"},{value:"#3a2a3a",labelKey:"terminal:building.colorDarkPurple"},{value:"#2a3a3a",labelKey:"terminal:building.colorDarkCyan"},{value:"#4a3a3a",labelKey:"terminal:building.colorWarmBrown"},{value:"#3a4a4a",labelKey:"terminal:building.colorCoolSteel"}];function oa(a){return sa.t(a)}function qe(a){if(a===0)return"0 B";const l=1024,c=["B","KB","MB","GB"],h=Math.floor(Math.log(a)/Math.log(l));return parseFloat((a/Math.pow(l,h)).toFixed(1))+" "+c[h]}function ca(a){const c=Date.now()-a,h=Math.floor(c/(1e3*60*60)),t=Math.floor(c%(1e3*60*60)/(1e3*60));return h>0?`${h}h ${t}m`:`${t}m`}const Us={30:"#1a1a1a",31:"#e74c3c",32:"#2ecc71",33:"#f39c12",34:"#3498db",35:"#9b59b6",36:"#00bcd4",37:"#ecf0f1",90:"#7f8c8d",91:"#ff6b6b",92:"#4ade80",93:"#fbbf24",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"};function Ks(a){const l=[],c=/\x1B\[([0-9;]*)m/g;let h=0,t=null,r;for(;(r=c.exec(a))!==null;){if(r.index>h){const m=a.slice(h,r.index);t?l.push(e.jsx("span",{style:{color:t},children:m},l.length)):l.push(m)}const g=r[1].split(";").map(Number);for(const m of g)m===0||m===39?t=null:Us[m]&&(t=Us[m]);h=c.lastIndex}if(h<a.length){const g=a.slice(h);t?l.push(e.jsx("span",{style:{color:t},children:g},l.length)):l.push(g)}return l.length>0?l:[a]}function ma({buildingName:a,onClose:l,onConfirm:c}){const{t:h}=E(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:l,children:e.jsxs("div",{className:"modal confirm-modal",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:h("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:h("terminal:building.deleteConfirm",{name:a})}),e.jsx("p",{className:"confirm-modal-note",children:h("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:l,children:h("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:c,autoFocus:!0,children:h("common:buttons.delete")})]})]})})}function da({usePM2:a,setUsePM2:l}){const{t:c}=E(["terminal"]);return e.jsxs("div",{className:"form-section pm2-toggle-section",children:[e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",className:"toggle-input",checked:a,onChange:h=>l(h.target.checked)}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})}),e.jsxs("span",{className:"toggle-label",children:[e.jsx("span",{className:"pm2-badge",children:"PM2"}),c("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:c("terminal:building.pm2Hint")})]})}function ua({usePM2:a,pm2Script:l,setPm2Script:c,pm2Args:h,setPm2Args:t,pm2Interpreter:r,setPm2Interpreter:g,pm2InterpreterArgs:m,setPm2InterpreterArgs:d,pm2Env:s,setPm2Env:u,isEditMode:b,building:x,handleCommand:N}){var y;const{t:p}=E(["terminal","common"]);return a?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:p("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Script"),e.jsx(v,{text:p("terminal:building.helpPm2Script"),title:p("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:l,onChange:j=>c(j.target.value),placeholder:"npm, java, python, ./app.js",required:a})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Arguments"),e.jsx(v,{text:p("terminal:building.helpPm2Arguments"),title:p("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:h,onChange:j=>t(j.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Interpreter"),e.jsx(v,{text:p("terminal:building.helpPm2Interpreter"),title:p("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:r,onChange:j=>g(j.target.value),children:Object.keys(Fs).map(j=>e.jsx("option",{value:j,children:Fs[j].label},j))})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2InterpArgs"),e.jsx(v,{text:p("terminal:building.helpPm2InterpArgs"),title:p("terminal:building.pm2InterpArgs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:m,onChange:j=>d(j.target.value),placeholder:"-jar (for Java)"})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Environment"),e.jsx(v,{text:p("terminal:building.helpPm2Environment"),title:p("terminal:building.pm2Environment"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:s,onChange:j=>u(j.target.value),placeholder:`KEY=value
|
|
2
2
|
SERVER_PORT=7201
|
|
3
3
|
NODE_ENV=production`,rows:3})]}),e.jsx("div",{className:"pm2-examples",children:e.jsxs("details",{children:[e.jsx("summary",{children:p("terminal:building.pm2Examples")}),e.jsxs("div",{className:"pm2-examples-content",children:[e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Node.js:"})," Script: ",e.jsx("code",{children:"npm"}),", Args: ",e.jsx("code",{children:"run dev"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Symfony:"})," Script: ",e.jsx("code",{children:"symfony"}),", Args: ",e.jsx("code",{children:"serve --no-daemon"}),", Interpreter: ",e.jsx("code",{children:"None"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Java JAR:"})," Script: ",e.jsx("code",{children:"app.jar"}),", Interpreter: ",e.jsx("code",{children:"Java"}),", Interp. Args: ",e.jsx("code",{children:"-jar"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Python:"})," Script: ",e.jsx("code",{children:"app.py"}),", Interpreter: ",e.jsx("code",{children:"Python 3"})]})]})]})}),b&&(x==null?void 0:x.pm2Status)&&e.jsx("div",{className:"pm2-status-display",children:e.jsxs("div",{className:"pm2-status-row",children:[e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"PID"}),e.jsx("span",{className:"pm2-metric-value",children:x.pm2Status.pid||"-"})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"CPU"}),e.jsxs("span",{className:"pm2-metric-value",children:[((y=x.pm2Status.cpu)==null?void 0:y.toFixed(1))||"0","%"]})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"MEM"}),e.jsx("span",{className:"pm2-metric-value",children:qe(x.pm2Status.memory||0)})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Restarts"}),e.jsx("span",{className:"pm2-metric-value",children:x.pm2Status.restarts||0})]}),x.pm2Status.uptime&&e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Uptime"}),e.jsx("span",{className:"pm2-metric-value",children:ca(x.pm2Status.uptime)})]})]})}),b&&e.jsxs("div",{className:"pm2-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>N("start"),children:p("common:buttons.start")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>N("stop"),children:p("common:buttons.stop")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>N("restart"),children:p("terminal:buildingAction.restart")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>N("logs"),children:p("terminal:logs.title")})]})]}):null}function pa({dockerMode:a,setDockerMode:l,dockerImage:c,setDockerImage:h,dockerContainerName:t,setDockerContainerName:r,dockerCommand:g,setDockerCommand:m,dockerPorts:d,setDockerPorts:s,dockerVolumes:u,setDockerVolumes:b,dockerNetwork:x,setDockerNetwork:N,dockerRestart:p,setDockerRestart:y,dockerPull:j,setDockerPull:F,dockerEnv:$,setDockerEnv:z,dockerComposePath:Y,setDockerComposePath:M,dockerComposeProject:J,setDockerComposeProject:U,dockerComposeServices:W,setDockerComposeServices:K,selectedExistingContainer:R,setSelectedExistingContainer:H,dockerContainersList:O,isEditMode:T,building:k,handleCommand:L}){const{t:A}=E(["config","common"]);return e.jsxs("div",{className:"form-section docker-config-section",children:[e.jsx("label",{className:"form-label",children:A("config:buildings.dockerConfig")}),e.jsxs("div",{className:"docker-mode-selector",children:[e.jsxs("label",{className:`docker-mode-option ${a==="container"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"container",checked:a==="container",onChange:()=>l("container")}),e.jsx("span",{className:"docker-mode-icon",children:"📦"}),e.jsx("span",{className:"docker-mode-label",children:"Container"}),e.jsx("span",{className:"docker-mode-desc",children:"Create a new container"})]}),e.jsxs("label",{className:`docker-mode-option ${a==="compose"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"compose",checked:a==="compose",onChange:()=>l("compose")}),e.jsx("span",{className:"docker-mode-icon",children:"🛠"}),e.jsx("span",{className:"docker-mode-label",children:"Compose"}),e.jsx("span",{className:"docker-mode-desc",children:"Manage multiple services"})]}),e.jsxs("label",{className:`docker-mode-option ${a==="existing"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"existing",checked:a==="existing",onChange:()=>l("existing")}),e.jsx("span",{className:"docker-mode-icon",children:"🔎"}),e.jsx("span",{className:"docker-mode-label",children:"Existing"}),e.jsx("span",{className:"docker-mode-desc",children:"Adopt existing container"})]})]}),a==="container"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Image:",e.jsx(v,{text:"Docker image to run, e.g., nginx:latest, redis:alpine, my-app:v1",title:"Image",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:c,onChange:n=>h(n.target.value),placeholder:"nginx:latest",required:!0})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Container Name:",e.jsx(v,{text:"Custom name for the container. If empty, auto-generated based on building name.",title:"Container Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:n=>r(n.target.value),placeholder:"Auto-generated (tc-{name}-{id})"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Command:",e.jsx(v,{text:"Override the default container command. Leave empty to use image's CMD.",title:"Command Override",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:n=>m(n.target.value),placeholder:"Optional command override"})]}),e.jsxs("div",{className:"form-section docker-ports-section",children:[e.jsxs("label",{className:"form-label",children:["Port Mappings",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>s([...d,""]),children:"+ Add"})]}),d.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const D=[...d];D[C]=B.target.value,s(D)},placeholder:"8080:80 or 3000"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>s(d.filter((B,D)=>D!==C)),children:"x"})]},C)),d.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host:container (e.g., 8080:80) or same port (e.g., 3000)"})]}),e.jsxs("div",{className:"form-section docker-volumes-section",children:[e.jsxs("label",{className:"form-label",children:["Volume Mounts",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>b([...u,""]),children:"+ Add"})]}),u.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const D=[...u];D[C]=B.target.value,b(D)},placeholder:"./data:/app/data or /host/path:/container/path"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>b(u.filter((B,D)=>D!==C)),children:"x"})]},C)),u.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host_path:container_path (relative paths resolved from working directory)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Network:",e.jsx(v,{text:"Docker network to connect to. Leave empty for default bridge network.",title:"Network",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:x,onChange:n=>N(n.target.value),placeholder:"bridge (default)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Restart Policy:",e.jsx(v,{text:"When should Docker restart the container automatically?",title:"Restart Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:p,onChange:n=>y(n.target.value),children:Object.keys($s).map(n=>e.jsx("option",{value:n,children:$s[n].label},n))})]})]}),a==="compose"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Compose File:",e.jsx(v,{text:"Path to docker-compose.yml file, relative to working directory.",title:"Compose File",position:"top",size:"sm"})]}),e.jsx(He,{value:Y,onChange:M,placeholder:"docker-compose.yml",className:"form-input",directoriesOnly:!1})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Project Name:",e.jsx(v,{text:"Override the compose project name. Leave empty for auto-generated name.",title:"Project Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:J,onChange:n=>U(n.target.value),placeholder:"Auto-generated"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Services:",e.jsx(v,{text:"Specific services to manage (comma-separated). Leave empty for all services.",title:"Services",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:W,onChange:n=>K(n.target.value),placeholder:"All services (or: api, db, redis)"})]})]}),a==="existing"&&e.jsxs("div",{className:"docker-existing-section",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Select Container:",e.jsx(v,{text:"Choose an existing Docker container to monitor and control. The container will not be deleted when removing the building.",title:"Existing Container",position:"top",size:"sm"})]}),e.jsxs("div",{className:"docker-existing-select-wrapper",children:[e.jsxs("select",{className:"form-input form-select",value:R,onChange:n=>H(n.target.value),required:a==="existing",children:[e.jsx("option",{value:"",children:"Select a container..."}),O.map(n=>e.jsxs("option",{value:n.name,children:[n.name," (",n.image,") - ",n.state]},n.id))]}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.requestDockerContainersList(),title:"Refresh container list",children:"↻"})]})]}),O.length===0&&e.jsx("div",{className:"form-hint docker-existing-hint",children:"No containers found. Make sure Docker is running and you have containers available."}),R&&e.jsx("div",{className:"docker-existing-info",children:(()=>{const n=O.find(C=>C.name===R);return n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Image:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.image})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Status:"}),e.jsx("span",{className:`docker-existing-info-value docker-status-${n.status}`,children:n.state})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"ID:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.id.slice(0,12)})]}),n.ports.length>0&&e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Ports:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.ports.map(C=>`${C.host}:${C.container}/${C.protocol}`).join(", ")})]})]}):null})()}),e.jsx("div",{className:"form-hint",children:"Note: Existing containers will not be deleted when you remove this building."})]}),a!=="existing"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Pull Policy:",e.jsx(v,{text:"When to pull images: always, only if missing, or never.",title:"Pull Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:j,onChange:n=>F(n.target.value),children:Object.keys(Ms).map(n=>e.jsx("option",{value:n,children:Ms[n].label},n))})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:["Environment:",e.jsx(v,{text:"Environment variables in KEY=value format, one per line.",title:"Environment Variables",position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:$,onChange:n=>z(n.target.value),placeholder:`KEY=value
|
|
4
4
|
DATABASE_URL=postgres://...
|
|
5
|
-
NODE_ENV=production`,rows:3})]})]}),T&&(k==null?void 0:k.dockerStatus)&&e.jsxs("div",{className:"docker-status-display",children:[e.jsxs("div",{className:"docker-status-row",children:[e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"ID"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.containerId||"-"})]}),e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"Status"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.status||"-"})]}),k.dockerStatus.health&&k.dockerStatus.health!=="none"&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"Health"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.health})]}),k.dockerStatus.cpu!==void 0&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"CPU"}),e.jsxs("span",{className:"docker-metric-value",children:[k.dockerStatus.cpu.toFixed(1),"%"]})]}),k.dockerStatus.memory!==void 0&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"MEM"}),e.jsxs("span",{className:"docker-metric-value",children:[qe(k.dockerStatus.memory),k.dockerStatus.memoryLimit?` / ${qe(k.dockerStatus.memoryLimit)}`:""]})]})]}),k.dockerStatus.ports&&k.dockerStatus.ports.length>0&&e.jsxs("div",{className:"docker-ports-row",children:[e.jsx("span",{className:"docker-metric-label",children:"Ports:"}),k.dockerStatus.ports.map((n,C)=>e.jsxs("a",{href:`http://localhost:${n.host}`,target:"_blank",rel:"noopener noreferrer",className:"docker-port-link",children:[n.host,":",n.container,"/",n.protocol]},C))]}),k.dockerStatus.services&&k.dockerStatus.services.length>0&&e.jsxs("div",{className:"docker-services-status",children:[e.jsx("span",{className:"docker-metric-label",children:"Services:"}),e.jsx("div",{className:"docker-services-grid",children:k.dockerStatus.services.map((n,C)=>e.jsxs("div",{className:"docker-service-item",children:[e.jsx("span",{className:"docker-service-indicator",style:{backgroundColor:n.status==="running"?"#4ade80":"#f87171"}}),e.jsx("span",{className:"docker-service-name",children:n.name}),e.jsx("span",{className:"docker-service-status",children:n.status})]},C))})]})]}),T&&e.jsxs("div",{className:"docker-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>L("start"),children:"Start"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>L("stop"),children:"Stop"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>L("restart"),children:"Restart"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>L("logs"),children:"Logs"})]})]})}function ha({dbConnections:a,setDbConnections:l,activeDbConnectionId:c,setActiveDbConnectionId:h}){const{t}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section database-config-section",children:[e.jsxs("label",{className:"form-label",children:[t("terminal:building.dbConnections"),e.jsx(v,{text:t("terminal:building.helpDbConnections"),title:t("terminal:building.dbConnections"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>{const r={id:`conn_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,name:`Connection ${a.length+1}`,engine:"mysql",host:"localhost",port:3306,username:"root"};l([...a,r]),c||h(r.id)},children:t("terminal:database.addConnection")})]}),a.length===0&&e.jsx("div",{className:"form-hint",children:t("terminal:building.dbGetStarted")}),a.map((r,g)=>e.jsxs("div",{className:"db-connection-card",children:[e.jsxs("div",{className:"db-connection-header",children:[e.jsxs("label",{className:"db-connection-active",children:[e.jsx("input",{type:"radio",name:"activeConnection",checked:c===r.id,onChange:()=>h(r.id)}),t("common:labels.default"),e.jsx(v,{text:t("terminal:building.helpDbDefault"),position:"top",size:"sm"})]}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>{const m=a.filter(d=>d.id!==r.id);l(m),c===r.id&&m.length>0?h(m[0].id):m.length===0&&h(void 0)},children:t("common:buttons.remove")})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("common:labels.name")}),e.jsx("input",{type:"text",className:"form-input",value:r.name,onChange:m=>{const d=[...a];d[g]={...r,name:m.target.value},l(d)},placeholder:"My Database"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:t("terminal:building.dbEngine")}),e.jsx("select",{className:"form-input form-select",value:r.engine,onChange:m=>{const d=m.target.value,s=[...a];s[g]={...r,engine:d,port:V[d].defaultPort},l(s)},children:Object.keys(V).map(m=>e.jsxs("option",{value:m,children:[V[m].icon," ",V[m].label]},m))})]})]}),r.engine==="sqlite"?e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbFilepath")}),e.jsx("input",{type:"text",className:"form-input",value:r.filepath||"",onChange:m=>{const d=[...a];d[g]={...r,filepath:m.target.value||void 0},l(d)},placeholder:"/path/to/database.db"})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbHost")}),e.jsx("input",{type:"text",className:"form-input",value:r.host,onChange:m=>{const d=[...a];d[g]={...r,host:m.target.value},l(d)},placeholder:"localhost"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:t("terminal:building.dbPort")}),e.jsx("input",{type:"number",className:"form-input",value:r.port,onChange:m=>{const d=[...a];d[g]={...r,port:parseInt(m.target.value)||V[r.engine].defaultPort},l(d)}})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("terminal:building.dbUsername")}),e.jsx("input",{type:"text",className:"form-input",value:r.username,onChange:m=>{const d=[...a];d[g]={...r,username:m.target.value},l(d)},placeholder:"root"})]}),e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("terminal:building.dbPassword")}),e.jsx("input",{type:"password",className:"form-input",value:r.password||"",onChange:m=>{const d=[...a];d[g]={...r,password:m.target.value||void 0},l(d)},placeholder:"Optional"})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbDefaultDatabase")}),e.jsx("input",{type:"text",className:"form-input",value:r.database||"",onChange:m=>{const d=[...a];d[g]={...r,database:m.target.value||void 0},l(d)},placeholder:"Optional - select after connecting"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsxs("label",{children:["SSL",e.jsx(v,{text:t("terminal:building.helpDbSsl"),position:"top",size:"sm"})]}),e.jsxs("label",{className:"toggle-switch toggle-switch--small",children:[e.jsx("input",{type:"checkbox",checked:r.ssl||!1,onChange:m=>{const d=[...a];d[g]={...r,ssl:m.target.checked},l(d)}}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})})]})]})]})]})]},r.id)),a.length>0&&e.jsx("div",{className:"form-hint",children:t("terminal:building.dbAfterSaving")})]})}function xa({buildings:a,buildingId:l,subordinateBuildingIds:c,setSubordinateBuildingIds:h,isEditMode:t,showBossLogs:r,setShowBossLogs:g,currentBossLogs:m,bossLogsContainerRef:d}){const{t:s}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section boss-building-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.managedBuildings"),e.jsx(v,{text:s("terminal:building.helpManagedBuildings"),title:s("terminal:building.managedBuildings"),position:"top",size:"sm"})]}),e.jsx("div",{className:"form-hint",children:s("terminal:building.managedBuildingsHint")}),e.jsxs("div",{className:"subordinate-buildings-list",children:[Array.from(a.values()).filter(u=>u.id!==l&&u.type!=="boss"&&u.type!=="link"&&u.type!=="folder").map(u=>e.jsxs("label",{className:"subordinate-building-item",children:[e.jsx("input",{type:"checkbox",checked:c.includes(u.id),onChange:b=>{b.target.checked?h([...c,u.id]):h(c.filter(x=>x!==u.id))}}),e.jsx("span",{className:"subordinate-building-icon",children:ee[u.type].icon}),e.jsx("span",{className:"subordinate-building-name",children:u.name}),e.jsx("span",{className:"subordinate-building-status",style:{backgroundColor:Ge[u.status]}})]},u.id)),Array.from(a.values()).filter(u=>u.id!==l&&u.type!=="boss"&&u.type!=="link"&&u.type!=="folder").length===0&&e.jsx("div",{className:"form-hint no-buildings-hint",children:s("terminal:building.noManageableBuildings")})]}),t&&c.length>0&&e.jsxs("div",{className:"boss-building-actions",children:[e.jsxs("div",{className:"boss-actions-header",children:[s("terminal:building.bulkActions"),e.jsx(v,{text:s("terminal:building.helpBulkActions"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"boss-actions-row",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>P.sendBossBuildingCommand(l,"start_all"),children:s("terminal:building.startAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>P.sendBossBuildingCommand(l,"stop_all"),children:s("terminal:building.stopAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>P.sendBossBuildingCommand(l,"restart_all"),children:s("terminal:building.restartAll")}),e.jsx("button",{type:"button",className:`btn btn-sm ${r?"btn-primary":""}`,onClick:()=>{r?(P.stopBossLogStreaming(l),g(!1)):(P.startBossLogStreaming(l),g(!0))},children:s(r?"terminal:building.hideLogs":"terminal:building.unifiedLogs")})]}),e.jsxs("div",{className:"boss-subordinates-status",children:[e.jsx("div",{className:"boss-status-header",children:s("terminal:building.statusOverview")}),e.jsx("div",{className:"boss-status-grid",children:c.map(u=>{const b=a.get(u);return b?e.jsxs("div",{className:"boss-status-item",children:[e.jsx("span",{className:"boss-status-indicator",style:{backgroundColor:Ge[b.status]}}),e.jsx("span",{className:"boss-status-name",children:b.name}),e.jsx("span",{className:"boss-status-label",children:b.status})]},u):null})})]})]}),t&&r&&e.jsxs("div",{className:"form-section boss-logs-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.unifiedLogs"),e.jsx(v,{text:s("terminal:building.helpUnifiedLogs"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.clearBossStreamingLogs(l),children:s("common:buttons.clear")})]}),e.jsxs("div",{className:"boss-logs-container",ref:d,children:[m.map((u,b)=>e.jsxs("div",{className:"boss-log-entry",children:[e.jsxs("span",{className:"boss-log-source",children:["[",u.subordinateName,"]"]}),e.jsx("span",{className:"boss-log-content",children:Ks(u.chunk)})]},b)),m.length===0&&e.jsx("div",{className:"boss-logs-empty",children:s("terminal:building.waitingForLogs")})]})]})]})}function ba({startCmd:a,setStartCmd:l,stopCmd:c,setStopCmd:h,restartCmd:t,setRestartCmd:r,healthCheckCmd:g,setHealthCheckCmd:m,logsCmd:d,setLogsCmd:s,isEditMode:u,handleCommand:b}){const{t:x}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section commands-section",children:[e.jsxs("label",{className:"form-label",children:[x("terminal:building.commands"),e.jsx(v,{text:x("terminal:building.helpCommands"),title:x("terminal:building.commands"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"command-inputs",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdStart"),e.jsx(v,{text:x("terminal:building.helpCmdStart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:a,onChange:N=>l(N.target.value),placeholder:"npm run dev"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>b("start"),disabled:!a,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdStop"),e.jsx(v,{text:x("terminal:building.helpCmdStop"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:c,onChange:N=>h(N.target.value),placeholder:"pkill -f 'npm run dev'"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>b("stop"),disabled:!c,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdRestart"),e.jsx(v,{text:x("terminal:building.helpCmdRestart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:N=>r(N.target.value),placeholder:"npm run restart"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>b("restart"),disabled:!t,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdHealthCheck"),e.jsx(v,{text:x("terminal:building.helpCmdHealthCheck"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:N=>m(N.target.value),placeholder:"curl -s http://localhost:3000/health"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>b("healthCheck"),disabled:!g,children:x("terminal:building.check")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdLogs"),e.jsx(v,{text:x("terminal:building.helpCmdLogs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:d,onChange:N=>s(N.target.value),placeholder:"tail -n 100 /var/log/app.log"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>b("logs"),children:x("terminal:building.fetch")})]})]})]})}const ja=[{value:"",label:"Default ($SHELL)"},{value:"/bin/bash",label:"Bash"},{value:"/bin/zsh",label:"Zsh"},{value:"/usr/bin/fish",label:"Fish"},{value:"/bin/sh",label:"sh"}];function ga({terminalShell:a,setTerminalShell:l,terminalPort:c,setTerminalPort:h,terminalSaveSession:t,setTerminalSaveSession:r,terminalArgs:g,setTerminalArgs:m,isEditMode:d,building:s,handleCommand:u,onOpenTerminal:b,onOpenBelow:x}){const{t:N}=E(["config"]),p=(s==null?void 0:s.status)==="running",y=s==null?void 0:s.terminalStatus;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:N("config:buildings.terminalConfig",{defaultValue:"Terminal Configuration"})}),e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalShell",{defaultValue:"Shell"})}),e.jsx("select",{className:"form-input",value:a,onChange:j=>l(j.target.value),children:ja.map(j=>e.jsx("option",{value:j.value,children:j.label},j.value))})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalPort",{defaultValue:"Port"})}),e.jsx("input",{type:"number",className:"form-input",value:c,onChange:j=>h(j.target.value),placeholder:"Auto",min:1024,max:65535})]})]}),e.jsx("div",{className:"form-row",style:{marginTop:"8px"},children:e.jsxs("label",{className:"form-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:j=>r(j.target.checked)}),e.jsx("span",{children:N("config:buildings.terminalSaveSession",{defaultValue:"Persist session (tmux)"})})]})}),e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalArgs",{defaultValue:"Extra ttyd args"})}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:j=>m(j.target.value),placeholder:"--client-option titleFixed=Terminal"}),e.jsx("div",{className:"form-hint",children:"Additional command-line arguments passed to ttyd"})]})]}),d&&s&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:N("config:buildings.terminalControls",{defaultValue:"Terminal Controls"})}),y&&e.jsxs("div",{className:"building-runtime-info",children:[e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Proxy"}),e.jsx("span",{className:"runtime-value",style:{color:"#4a9eff"},children:y.url})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"PID"}),e.jsx("span",{className:"runtime-value",children:y.pid})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Port"}),e.jsx("span",{className:"runtime-value",children:y.port})]}),y.tmuxSession&&e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Session"}),e.jsx("span",{className:"runtime-value",children:y.tmuxSession})]})]}),e.jsxs("div",{className:"building-actions",style:{marginTop:"8px"},children:[!p&&e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>u("start"),children:"▶ Start"}),p&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>u("restart"),children:"🔄 Restart"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>u("stop"),children:"⏹ Stop"}),(y==null?void 0:y.url)&&e.jsxs(e.Fragment,{children:[b&&e.jsx("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>b(y.url),children:"🖥 Modal"}),x&&s&&e.jsx("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>x(s.id),children:"⬇ Below"})]})]})]})]})]})}function va({logs:a,buildingId:l,logsContainerRef:c}){return e.jsxs("div",{className:"form-section logs-section",children:[e.jsxs("label",{className:"form-label",children:["Logs",e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.clearBuildingLogs(l),children:"Clear"})]}),e.jsx("div",{className:"logs-container",ref:c,children:a.map((h,t)=>e.jsx("pre",{className:"log-entry",children:Ks(h)},t))})]})}function Ca({isOpen:a,onClose:l,buildingId:c,initialPosition:h}){const{t}=E(["config","common"]),{buildings:r,buildingLogs:g,bossStreamingLogs:m}=aa(),d=ta(),s=c?r.get(c):null,u=c?m.get(c)||[]:[],b=!!s,[x,N]=o.useState(""),[p,y]=o.useState("server"),[j,F]=o.useState("server-rack"),[$,z]=o.useState(""),[Y,M]=o.useState(""),[J,U]=o.useState(""),[W,K]=o.useState(""),[R,H]=o.useState(""),[O,T]=o.useState(""),[k,L]=o.useState(""),[A,n]=o.useState([]),[C,B]=o.useState(!1),[D,se]=o.useState(""),[G,X]=o.useState(1),[q,ae]=o.useState(!1),[Ve,te]=o.useState(""),[Ye,ne]=o.useState(""),[Je,le]=o.useState(""),[We,ie]=o.useState(""),[Xe,re]=o.useState(""),[Hs,oe]=o.useState(!1),[w,ce]=o.useState("container"),[me,de]=o.useState(""),[Ze,ue]=o.useState(""),[pe,he]=o.useState(""),[xe,be]=o.useState([]),[je,ge]=o.useState([]),[Qe,ve]=o.useState(""),[Ne,fe]=o.useState(""),[ke,ye]=o.useState(""),[es,Ce]=o.useState("unless-stopped"),[ss,Se]=o.useState("missing"),[we,Pe]=o.useState(""),[De,Ee]=o.useState(""),[Le,Ae]=o.useState(""),[Be,ze]=o.useState([]),[Gs,qs]=o.useState(!1),[Re,Oe]=o.useState([]),[as,Te]=o.useState(void 0),[ts,_e]=o.useState(""),[Ie,Fe]=o.useState(""),[ns,$e]=o.useState(!1),[ls,Me]=o.useState(""),is=o.useRef(null),Vs=o.useRef(null),Z=o.useRef(null);o.useEffect(()=>{var i,f,S,_,ms,ds,us,ps,hs,xs,bs,js,gs,vs,Ns,fs,ks,ys,Cs,Ss,ws,Ps,Ds,Es,Ls,As,Bs,zs,Rs,Os,Ts,_s,Is;a&&(s?(N(s.name),y(s.type),F(s.style||"server-rack"),z(s.color||""),M(s.cwd||""),U(((i=s.commands)==null?void 0:i.start)||""),K(((f=s.commands)==null?void 0:f.stop)||""),H(((S=s.commands)==null?void 0:S.restart)||""),T(((_=s.commands)==null?void 0:_.healthCheck)||""),L(((ms=s.commands)==null?void 0:ms.logs)||""),n(s.urls||[]),se(s.folderPath||""),X(s.scale||1),ae(((ds=s.pm2)==null?void 0:ds.enabled)||!1),te(((us=s.pm2)==null?void 0:us.script)||""),ne(((ps=s.pm2)==null?void 0:ps.args)||""),le(((hs=s.pm2)==null?void 0:hs.interpreter)||""),ie(((xs=s.pm2)==null?void 0:xs.interpreterArgs)||""),re((bs=s.pm2)!=null&&bs.env?Object.entries(s.pm2.env).map(([I,Ue])=>`${I}=${Ue}`).join(`
|
|
5
|
+
NODE_ENV=production`,rows:3})]})]}),T&&(k==null?void 0:k.dockerStatus)&&e.jsxs("div",{className:"docker-status-display",children:[e.jsxs("div",{className:"docker-status-row",children:[e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"ID"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.containerId||"-"})]}),e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"Status"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.status||"-"})]}),k.dockerStatus.health&&k.dockerStatus.health!=="none"&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"Health"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.health})]}),k.dockerStatus.cpu!==void 0&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"CPU"}),e.jsxs("span",{className:"docker-metric-value",children:[k.dockerStatus.cpu.toFixed(1),"%"]})]}),k.dockerStatus.memory!==void 0&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"MEM"}),e.jsxs("span",{className:"docker-metric-value",children:[qe(k.dockerStatus.memory),k.dockerStatus.memoryLimit?` / ${qe(k.dockerStatus.memoryLimit)}`:""]})]})]}),k.dockerStatus.ports&&k.dockerStatus.ports.length>0&&e.jsxs("div",{className:"docker-ports-row",children:[e.jsx("span",{className:"docker-metric-label",children:"Ports:"}),k.dockerStatus.ports.map((n,C)=>e.jsxs("a",{href:`http://localhost:${n.host}`,target:"_blank",rel:"noopener noreferrer",className:"docker-port-link",children:[n.host,":",n.container,"/",n.protocol]},C))]}),k.dockerStatus.services&&k.dockerStatus.services.length>0&&e.jsxs("div",{className:"docker-services-status",children:[e.jsx("span",{className:"docker-metric-label",children:"Services:"}),e.jsx("div",{className:"docker-services-grid",children:k.dockerStatus.services.map((n,C)=>e.jsxs("div",{className:"docker-service-item",children:[e.jsx("span",{className:"docker-service-indicator",style:{backgroundColor:n.status==="running"?"#4ade80":"#f87171"}}),e.jsx("span",{className:"docker-service-name",children:n.name}),e.jsx("span",{className:"docker-service-status",children:n.status})]},C))})]})]}),T&&e.jsxs("div",{className:"docker-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>L("start"),children:"Start"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>L("stop"),children:"Stop"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>L("restart"),children:"Restart"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>L("logs"),children:"Logs"})]})]})}function ha({dbConnections:a,setDbConnections:l,activeDbConnectionId:c,setActiveDbConnectionId:h}){const{t}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section database-config-section",children:[e.jsxs("label",{className:"form-label",children:[t("terminal:building.dbConnections"),e.jsx(v,{text:t("terminal:building.helpDbConnections"),title:t("terminal:building.dbConnections"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>{const r={id:`conn_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,name:`Connection ${a.length+1}`,engine:"mysql",host:"localhost",port:3306,username:"root"};l([...a,r]),c||h(r.id)},children:t("terminal:database.addConnection")})]}),a.length===0&&e.jsx("div",{className:"form-hint",children:t("terminal:building.dbGetStarted")}),a.map((r,g)=>e.jsxs("div",{className:"db-connection-card",children:[e.jsxs("div",{className:"db-connection-header",children:[e.jsxs("label",{className:"db-connection-active",children:[e.jsx("input",{type:"radio",name:"activeConnection",checked:c===r.id,onChange:()=>h(r.id)}),t("common:labels.default"),e.jsx(v,{text:t("terminal:building.helpDbDefault"),position:"top",size:"sm"})]}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>{const m=a.filter(d=>d.id!==r.id);l(m),c===r.id&&m.length>0?h(m[0].id):m.length===0&&h(void 0)},children:t("common:buttons.remove")})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("common:labels.name")}),e.jsx("input",{type:"text",className:"form-input",value:r.name,onChange:m=>{const d=[...a];d[g]={...r,name:m.target.value},l(d)},placeholder:"My Database"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:t("terminal:building.dbEngine")}),e.jsx("select",{className:"form-input form-select",value:r.engine,onChange:m=>{const d=m.target.value,s=[...a];s[g]={...r,engine:d,port:V[d].defaultPort},l(s)},children:Object.keys(V).map(m=>e.jsxs("option",{value:m,children:[V[m].icon," ",V[m].label]},m))})]})]}),r.engine==="sqlite"?e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbFilepath")}),e.jsx("input",{type:"text",className:"form-input",value:r.filepath||"",onChange:m=>{const d=[...a];d[g]={...r,filepath:m.target.value||void 0},l(d)},placeholder:"/path/to/database.db"})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbHost")}),e.jsx("input",{type:"text",className:"form-input",value:r.host,onChange:m=>{const d=[...a];d[g]={...r,host:m.target.value},l(d)},placeholder:"localhost"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:t("terminal:building.dbPort")}),e.jsx("input",{type:"number",className:"form-input",value:r.port,onChange:m=>{const d=[...a];d[g]={...r,port:parseInt(m.target.value)||V[r.engine].defaultPort},l(d)}})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("terminal:building.dbUsername")}),e.jsx("input",{type:"text",className:"form-input",value:r.username,onChange:m=>{const d=[...a];d[g]={...r,username:m.target.value},l(d)},placeholder:"root"})]}),e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("terminal:building.dbPassword")}),e.jsx("input",{type:"password",className:"form-input",value:r.password||"",onChange:m=>{const d=[...a];d[g]={...r,password:m.target.value||void 0},l(d)},placeholder:"Optional"})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbDefaultDatabase")}),e.jsx("input",{type:"text",className:"form-input",value:r.database||"",onChange:m=>{const d=[...a];d[g]={...r,database:m.target.value||void 0},l(d)},placeholder:"Optional - select after connecting"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsxs("label",{children:["SSL",e.jsx(v,{text:t("terminal:building.helpDbSsl"),position:"top",size:"sm"})]}),e.jsxs("label",{className:"toggle-switch toggle-switch--small",children:[e.jsx("input",{type:"checkbox",checked:r.ssl||!1,onChange:m=>{const d=[...a];d[g]={...r,ssl:m.target.checked},l(d)}}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})})]})]})]})]})]},r.id)),a.length>0&&e.jsx("div",{className:"form-hint",children:t("terminal:building.dbAfterSaving")})]})}function xa({buildings:a,buildingId:l,subordinateBuildingIds:c,setSubordinateBuildingIds:h,isEditMode:t,showBossLogs:r,setShowBossLogs:g,currentBossLogs:m,bossLogsContainerRef:d}){const{t:s}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section boss-building-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.managedBuildings"),e.jsx(v,{text:s("terminal:building.helpManagedBuildings"),title:s("terminal:building.managedBuildings"),position:"top",size:"sm"})]}),e.jsx("div",{className:"form-hint",children:s("terminal:building.managedBuildingsHint")}),e.jsxs("div",{className:"subordinate-buildings-list",children:[Array.from(a.values()).filter(u=>u.id!==l&&u.type!=="boss"&&u.type!=="link"&&u.type!=="folder").map(u=>e.jsxs("label",{className:"subordinate-building-item",children:[e.jsx("input",{type:"checkbox",checked:c.includes(u.id),onChange:b=>{b.target.checked?h([...c,u.id]):h(c.filter(x=>x!==u.id))}}),e.jsx("span",{className:"subordinate-building-icon",children:ee[u.type].icon}),e.jsx("span",{className:"subordinate-building-name",children:u.name}),e.jsx("span",{className:"subordinate-building-status",style:{backgroundColor:Ge[u.status]}})]},u.id)),Array.from(a.values()).filter(u=>u.id!==l&&u.type!=="boss"&&u.type!=="link"&&u.type!=="folder").length===0&&e.jsx("div",{className:"form-hint no-buildings-hint",children:s("terminal:building.noManageableBuildings")})]}),t&&c.length>0&&e.jsxs("div",{className:"boss-building-actions",children:[e.jsxs("div",{className:"boss-actions-header",children:[s("terminal:building.bulkActions"),e.jsx(v,{text:s("terminal:building.helpBulkActions"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"boss-actions-row",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>P.sendBossBuildingCommand(l,"start_all"),children:s("terminal:building.startAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>P.sendBossBuildingCommand(l,"stop_all"),children:s("terminal:building.stopAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>P.sendBossBuildingCommand(l,"restart_all"),children:s("terminal:building.restartAll")}),e.jsx("button",{type:"button",className:`btn btn-sm ${r?"btn-primary":""}`,onClick:()=>{r?(P.stopBossLogStreaming(l),g(!1)):(P.startBossLogStreaming(l),g(!0))},children:s(r?"terminal:building.hideLogs":"terminal:building.unifiedLogs")})]}),e.jsxs("div",{className:"boss-subordinates-status",children:[e.jsx("div",{className:"boss-status-header",children:s("terminal:building.statusOverview")}),e.jsx("div",{className:"boss-status-grid",children:c.map(u=>{const b=a.get(u);return b?e.jsxs("div",{className:"boss-status-item",children:[e.jsx("span",{className:"boss-status-indicator",style:{backgroundColor:Ge[b.status]}}),e.jsx("span",{className:"boss-status-name",children:b.name}),e.jsx("span",{className:"boss-status-label",children:b.status})]},u):null})})]})]}),t&&r&&e.jsxs("div",{className:"form-section boss-logs-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.unifiedLogs"),e.jsx(v,{text:s("terminal:building.helpUnifiedLogs"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.clearBossStreamingLogs(l),children:s("common:buttons.clear")})]}),e.jsxs("div",{className:"boss-logs-container",ref:d,children:[m.map((u,b)=>e.jsxs("div",{className:"boss-log-entry",children:[e.jsxs("span",{className:"boss-log-source",children:["[",u.subordinateName,"]"]}),e.jsx("span",{className:"boss-log-content",children:Ks(u.chunk)})]},b)),m.length===0&&e.jsx("div",{className:"boss-logs-empty",children:s("terminal:building.waitingForLogs")})]})]})]})}function ba({startCmd:a,setStartCmd:l,stopCmd:c,setStopCmd:h,restartCmd:t,setRestartCmd:r,healthCheckCmd:g,setHealthCheckCmd:m,logsCmd:d,setLogsCmd:s,isEditMode:u,handleCommand:b}){const{t:x}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section commands-section",children:[e.jsxs("label",{className:"form-label",children:[x("terminal:building.commands"),e.jsx(v,{text:x("terminal:building.helpCommands"),title:x("terminal:building.commands"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"command-inputs",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdStart"),e.jsx(v,{text:x("terminal:building.helpCmdStart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:a,onChange:N=>l(N.target.value),placeholder:"npm run dev"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>b("start"),disabled:!a,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdStop"),e.jsx(v,{text:x("terminal:building.helpCmdStop"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:c,onChange:N=>h(N.target.value),placeholder:"pkill -f 'npm run dev'"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>b("stop"),disabled:!c,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdRestart"),e.jsx(v,{text:x("terminal:building.helpCmdRestart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:N=>r(N.target.value),placeholder:"npm run restart"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>b("restart"),disabled:!t,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdHealthCheck"),e.jsx(v,{text:x("terminal:building.helpCmdHealthCheck"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:N=>m(N.target.value),placeholder:"curl -s http://localhost:3000/health"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>b("healthCheck"),disabled:!g,children:x("terminal:building.check")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdLogs"),e.jsx(v,{text:x("terminal:building.helpCmdLogs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:d,onChange:N=>s(N.target.value),placeholder:"tail -n 100 /var/log/app.log"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>b("logs"),children:x("terminal:building.fetch")})]})]})]})}const ja=[{value:"",label:"Default ($SHELL)"},{value:"/bin/bash",label:"Bash"},{value:"/bin/zsh",label:"Zsh"},{value:"/usr/bin/fish",label:"Fish"},{value:"/bin/sh",label:"sh"}];function ga({terminalShell:a,setTerminalShell:l,terminalPort:c,setTerminalPort:h,terminalSaveSession:t,setTerminalSaveSession:r,terminalArgs:g,setTerminalArgs:m,isEditMode:d,building:s,handleCommand:u,onOpenTerminal:b,onOpenBelow:x}){const{t:N}=E(["config"]),p=(s==null?void 0:s.status)==="running",y=s==null?void 0:s.terminalStatus;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:N("config:buildings.terminalConfig",{defaultValue:"Terminal Configuration"})}),e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalShell",{defaultValue:"Shell"})}),e.jsx("select",{className:"form-input",value:a,onChange:j=>l(j.target.value),children:ja.map(j=>e.jsx("option",{value:j.value,children:j.label},j.value))})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalPort",{defaultValue:"Port"})}),e.jsx("input",{type:"number",className:"form-input",value:c,onChange:j=>h(j.target.value),placeholder:"Auto",min:1024,max:65535})]})]}),e.jsx("div",{className:"form-row",style:{marginTop:"8px"},children:e.jsxs("label",{className:"form-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:j=>r(j.target.checked)}),e.jsx("span",{children:N("config:buildings.terminalSaveSession",{defaultValue:"Persist session (tmux)"})})]})}),e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalArgs",{defaultValue:"Extra ttyd args"})}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:j=>m(j.target.value),placeholder:"--client-option titleFixed=Terminal"}),e.jsx("div",{className:"form-hint",children:"Additional command-line arguments passed to ttyd"})]})]}),d&&s&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:N("config:buildings.terminalControls",{defaultValue:"Terminal Controls"})}),y&&e.jsxs("div",{className:"building-runtime-info",children:[e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Proxy"}),e.jsx("span",{className:"runtime-value",style:{color:"#4a9eff"},children:y.url})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"PID"}),e.jsx("span",{className:"runtime-value",children:y.pid})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Port"}),e.jsx("span",{className:"runtime-value",children:y.port})]}),y.tmuxSession&&e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Session"}),e.jsx("span",{className:"runtime-value",children:y.tmuxSession})]})]}),e.jsxs("div",{className:"building-actions",style:{marginTop:"8px"},children:[!p&&e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>u("start"),children:"▶ Start"}),p&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>u("restart"),children:"🔄 Restart"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>u("stop"),children:"⏹ Stop"}),(y==null?void 0:y.url)&&e.jsxs(e.Fragment,{children:[b&&e.jsx("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>b(y.url),children:"🖥 Modal"}),x&&s&&e.jsx("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>x(s.id),children:"⬇ Below"})]})]})]})]})]})}function va({logs:a,buildingId:l,logsContainerRef:c}){return e.jsxs("div",{className:"form-section logs-section",children:[e.jsxs("label",{className:"form-label",children:["Logs",e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.clearBuildingLogs(l),children:"Clear"})]}),e.jsx("div",{className:"logs-container",ref:c,children:a.map((h,t)=>e.jsx("pre",{className:"log-entry",children:Ks(h)},t))})]})}function Ca({isOpen:a,onClose:l,buildingId:c,initialPosition:h}){const{t}=E(["config","common"]),{buildings:r,buildingLogs:g,bossStreamingLogs:m}=aa(),d=ta(),s=c?r.get(c):null,u=c?m.get(c)||[]:[],b=!!s,[x,N]=o.useState(""),[p,y]=o.useState("server"),[j,F]=o.useState("server-rack"),[$,z]=o.useState(""),[Y,M]=o.useState(""),[J,U]=o.useState(""),[W,K]=o.useState(""),[R,H]=o.useState(""),[O,T]=o.useState(""),[k,L]=o.useState(""),[A,n]=o.useState([]),[C,B]=o.useState(!1),[D,se]=o.useState(""),[G,Z]=o.useState(1),[q,ae]=o.useState(!1),[Ve,te]=o.useState(""),[Ye,ne]=o.useState(""),[Je,le]=o.useState(""),[We,ie]=o.useState(""),[Ze,re]=o.useState(""),[Hs,oe]=o.useState(!1),[w,ce]=o.useState("container"),[me,de]=o.useState(""),[Qe,ue]=o.useState(""),[pe,he]=o.useState(""),[xe,be]=o.useState([]),[je,ge]=o.useState([]),[Xe,ve]=o.useState(""),[Ne,fe]=o.useState(""),[ke,ye]=o.useState(""),[es,Ce]=o.useState("unless-stopped"),[ss,Se]=o.useState("missing"),[we,Pe]=o.useState(""),[De,Ee]=o.useState(""),[Le,Ae]=o.useState(""),[Be,ze]=o.useState([]),[Gs,qs]=o.useState(!1),[Re,Oe]=o.useState([]),[as,Te]=o.useState(void 0),[ts,_e]=o.useState(""),[Ie,Fe]=o.useState(""),[ns,$e]=o.useState(!1),[ls,Me]=o.useState(""),is=o.useRef(null),Vs=o.useRef(null),Q=o.useRef(null);o.useEffect(()=>{var i,f,S,_,ms,ds,us,ps,hs,xs,bs,js,gs,vs,Ns,fs,ks,ys,Cs,Ss,ws,Ps,Ds,Es,Ls,As,Bs,zs,Rs,Os,Ts,_s,Is;a&&(s?(N(s.name),y(s.type),F(s.style||"server-rack"),z(s.color||""),M(s.cwd||""),U(((i=s.commands)==null?void 0:i.start)||""),K(((f=s.commands)==null?void 0:f.stop)||""),H(((S=s.commands)==null?void 0:S.restart)||""),T(((_=s.commands)==null?void 0:_.healthCheck)||""),L(((ms=s.commands)==null?void 0:ms.logs)||""),n(s.urls||[]),se(s.folderPath||""),Z(s.scale||1),ae(((ds=s.pm2)==null?void 0:ds.enabled)||!1),te(((us=s.pm2)==null?void 0:us.script)||""),ne(((ps=s.pm2)==null?void 0:ps.args)||""),le(((hs=s.pm2)==null?void 0:hs.interpreter)||""),ie(((xs=s.pm2)==null?void 0:xs.interpreterArgs)||""),re((bs=s.pm2)!=null&&bs.env?Object.entries(s.pm2.env).map(([I,Ue])=>`${I}=${Ue}`).join(`
|
|
6
6
|
`):""),ce(((js=s.docker)==null?void 0:js.mode)||"container"),de(((gs=s.docker)==null?void 0:gs.mode)==="existing"&&((vs=s.docker)==null?void 0:vs.containerName)||""),ue(((Ns=s.docker)==null?void 0:Ns.image)||""),he(((fs=s.docker)==null?void 0:fs.containerName)||""),be(((ks=s.docker)==null?void 0:ks.ports)||[]),ge(((ys=s.docker)==null?void 0:ys.volumes)||[]),ve((Cs=s.docker)!=null&&Cs.env?Object.entries(s.docker.env).map(([I,Ue])=>`${I}=${Ue}`).join(`
|
|
7
|
-
`):""),fe(((Ss=s.docker)==null?void 0:Ss.network)||""),ye(((ws=s.docker)==null?void 0:ws.command)||""),Ce(((Ps=s.docker)==null?void 0:Ps.restart)||"unless-stopped"),Se(((Ds=s.docker)==null?void 0:Ds.pull)||"missing"),Pe(((Es=s.docker)==null?void 0:Es.composePath)||""),Ee(((Ls=s.docker)==null?void 0:Ls.composeProject)||""),Ae(((Bs=(As=s.docker)==null?void 0:As.services)==null?void 0:Bs.join(", "))||""),ze(s.subordinateBuildingIds||[]),Oe(((zs=s.database)==null?void 0:zs.connections)||[]),Te((Rs=s.database)==null?void 0:Rs.activeConnectionId),_e(((Os=s.terminal)==null?void 0:Os.shell)||""),Fe((Ts=s.terminal)!=null&&Ts.port?String(s.terminal.port):""),$e(((_s=s.terminal)==null?void 0:_s.saveSession)||!1),Me(((Is=s.terminal)==null?void 0:Is.args)||"")):(N("New Server"),y("server"),F("server-rack"),z(""),M(na(la.LAST_CWD)),U(""),K(""),H(""),T(""),L(""),n([]),se(""),
|
|
8
|
-
`).map(f=>f.trim()).filter(f=>f&&f.includes("=")).map(f=>{const S=f.indexOf("=");return[f.slice(0,S),f.slice(S+1)]}))},Ys=i=>{i.preventDefault();const f={name:x,type:p,style:j,color:$||void 0,position:h||(s==null?void 0:s.position)||{x:0,z:0},cwd:Y||void 0,folderPath:D||void 0,commands:q?void 0:{start:J||void 0,stop:W||void 0,restart:R||void 0,healthCheck:O||void 0,logs:k||void 0},pm2:q?{enabled:!0,script:Ve,args:Ye||void 0,interpreter:Je||void 0,interpreterArgs:We||void 0,env:rs(
|
|
7
|
+
`):""),fe(((Ss=s.docker)==null?void 0:Ss.network)||""),ye(((ws=s.docker)==null?void 0:ws.command)||""),Ce(((Ps=s.docker)==null?void 0:Ps.restart)||"unless-stopped"),Se(((Ds=s.docker)==null?void 0:Ds.pull)||"missing"),Pe(((Es=s.docker)==null?void 0:Es.composePath)||""),Ee(((Ls=s.docker)==null?void 0:Ls.composeProject)||""),Ae(((Bs=(As=s.docker)==null?void 0:As.services)==null?void 0:Bs.join(", "))||""),ze(s.subordinateBuildingIds||[]),Oe(((zs=s.database)==null?void 0:zs.connections)||[]),Te((Rs=s.database)==null?void 0:Rs.activeConnectionId),_e(((Os=s.terminal)==null?void 0:Os.shell)||""),Fe((Ts=s.terminal)!=null&&Ts.port?String(s.terminal.port):""),$e(((_s=s.terminal)==null?void 0:_s.saveSession)||!1),Me(((Is=s.terminal)==null?void 0:Is.args)||"")):(N("New Server"),y("server"),F("server-rack"),z(""),M(na(la.LAST_CWD)),U(""),K(""),H(""),T(""),L(""),n([]),se(""),Z(1),ae(!1),te(""),ne(""),le(""),ie(""),re(""),ce("container"),de(""),ue(""),he(""),be([]),ge([]),ve(""),fe(""),ye(""),Ce("unless-stopped"),Se("missing"),Pe(""),Ee(""),Ae(""),ze([]),Oe([]),Te(void 0),_e(""),Fe(""),$e(!1),Me("")),setTimeout(()=>{var I;return(I=is.current)==null?void 0:I.focus()},100))},[a,s]),o.useEffect(()=>{Q.current&&(Q.current.scrollTop=Q.current.scrollHeight)},[g]),o.useEffect(()=>{p==="docker"&&w==="existing"&&P.requestDockerContainersList()},[p,w]);const rs=i=>{if(i.trim())return Object.fromEntries(i.trim().split(`
|
|
8
|
+
`).map(f=>f.trim()).filter(f=>f&&f.includes("=")).map(f=>{const S=f.indexOf("=");return[f.slice(0,S),f.slice(S+1)]}))},Ys=i=>{i.preventDefault();const f={name:x,type:p,style:j,color:$||void 0,position:h||(s==null?void 0:s.position)||{x:0,z:0},cwd:Y||void 0,folderPath:D||void 0,commands:q?void 0:{start:J||void 0,stop:W||void 0,restart:R||void 0,healthCheck:O||void 0,logs:k||void 0},pm2:q?{enabled:!0,script:Ve,args:Ye||void 0,interpreter:Je||void 0,interpreterArgs:We||void 0,env:rs(Ze)}:void 0,docker:p==="docker"?{enabled:!0,mode:w,image:w==="container"?Qe:void 0,containerName:w==="container"&&pe?pe:w==="existing"&&me?me:void 0,ports:w==="container"&&xe.length>0?xe:void 0,volumes:w==="container"&&je.length>0?je:void 0,env:rs(Xe),network:w==="container"&&Ne?Ne:void 0,command:w==="container"&&ke?ke:void 0,restart:w==="container"?es:void 0,pull:w!=="existing"?ss:void 0,composePath:w==="compose"&&we?we:void 0,composeProject:w==="compose"&&De?De:void 0,services:w==="compose"&&Le?Le.split(",").map(S=>S.trim()).filter(S=>S):void 0}:void 0,urls:A.length>0?A:void 0,scale:G!==1?G:void 0,subordinateBuildingIds:p==="boss"&&Be.length>0?Be:void 0,database:p==="database"&&Re.length>0?{connections:Re,activeConnectionId:as}:void 0,terminal:p==="terminal"?{enabled:!0,shell:ts||void 0,port:Ie?parseInt(Ie,10):void 0,saveSession:ns||void 0,args:ls||void 0}:void 0};b&&c?P.updateBuilding(c,f):P.createBuilding(f),l()},Js=()=>{oe(!0)},Ws=()=>{c&&(P.deleteBuilding(c),oe(!1),l())},X=i=>{c&&(P.sendBuildingCommand(c,i),i==="logs"&&B(!0))},Zs=()=>{n([...A,{label:"",url:""}])},Qs=i=>{n(A.filter((f,S)=>S!==i))},os=(i,f,S)=>{const _=[...A];_[i]={..._[i],[f]:S},n(_)},{handleMouseDown:Xs,handleClick:ea}=ia(l);if(!a)return null;const cs=c?P.getBuildingLogs(c):[];return e.jsxs("div",{className:"modal-overlay visible",onMouseDown:Xs,onClick:ea,children:[e.jsxs("div",{className:"modal building-config-modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("span",{children:t(b?"config:buildings.editBuilding":"config:buildings.addBuilding")}),b&&s&&e.jsx("span",{className:"building-status-badge",style:{backgroundColor:Ge[s.status]},children:s.status})]}),e.jsxs("form",{onSubmit:Ys,children:[e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.name")}),e.jsx("input",{ref:is,type:"text",className:"form-input",value:x,onChange:i=>N(i.target.value),placeholder:t("config:buildings.namePlaceholder"),required:!0})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.type")}),e.jsx("div",{className:"building-type-selector",children:Object.keys(ee).map(i=>e.jsxs("button",{type:"button",className:`building-type-btn ${p===i?"active":""}`,onClick:()=>y(i),title:ee[i].description,children:[e.jsx("span",{className:"building-type-icon",children:ee[i].icon}),e.jsx("span",{className:"building-type-name",children:i})]},i))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("config:buildings.style")}),e.jsx("div",{className:"building-style-selector",children:Object.keys(Ke).map(i=>e.jsxs("button",{type:"button",className:`building-style-btn ${j===i?"active":""}`,onClick:()=>F(i),title:Ke[i].description,children:[e.jsx("span",{className:"building-style-preview","data-style":i}),e.jsx("span",{className:"building-style-name",children:Ke[i].label})]},i))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.color")}),e.jsxs("div",{className:"building-color-selector",children:[ra.map(i=>e.jsx("button",{type:"button",className:`building-color-btn ${$===i.value?"active":""}`,onClick:()=>z(i.value),title:oa(i.labelKey),style:i.value?{backgroundColor:i.value}:void 0,children:!i.value&&e.jsx("span",{className:"color-default-icon",children:"⚙"})},i.value||"default")),e.jsx("input",{type:"color",className:"building-color-picker",value:$||"#2a2a3a",onChange:i=>z(i.target.value),title:"Custom color"})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.size")}),e.jsxs("div",{className:"building-size-control",children:[e.jsxs("div",{className:"size-slider-row",children:[e.jsx("input",{type:"range",className:"size-slider",min:"0",max:"100",step:"1",value:Math.log(G/.1)/Math.log(100)*100,onChange:i=>{const f=parseFloat(i.target.value),S=.1*Math.pow(100,f/100);Z(Math.round(S*100)/100)}}),e.jsxs("span",{className:"size-value",children:[G.toFixed(2),"x"]})]}),e.jsx("div",{className:"size-presets",children:[.5,.75,1,1.25,1.5,2].map(i=>e.jsxs("button",{type:"button",className:`size-preset-btn ${G===i?"active":""}`,onClick:()=>Z(i),children:[i,"x"]},i))})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("config:buildings.directory")}),e.jsx(He,{value:Y,onChange:M,placeholder:"/path/to/project",className:"form-input",directoriesOnly:!0})]}),p==="folder"&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("config:buildings.folderPath")}),e.jsx(He,{value:D,onChange:se,placeholder:"/path/to/folder",className:"form-input",directoriesOnly:!0}),e.jsx("div",{className:"form-hint",children:"Click this building to open the file explorer at this path"})]}),p==="boss"&&e.jsx(xa,{buildings:r,buildingId:c,subordinateBuildingIds:Be,setSubordinateBuildingIds:ze,isEditMode:b,showBossLogs:Gs,setShowBossLogs:qs,currentBossLogs:u,bossLogsContainerRef:Vs}),p==="database"&&e.jsx(ha,{dbConnections:Re,setDbConnections:Oe,activeDbConnectionId:as,setActiveDbConnectionId:Te}),p==="server"&&e.jsx(da,{usePM2:q,setUsePM2:ae}),p==="server"&&e.jsx(ua,{usePM2:q,pm2Script:Ve,setPm2Script:te,pm2Args:Ye,setPm2Args:ne,pm2Interpreter:Je,setPm2Interpreter:le,pm2InterpreterArgs:We,setPm2InterpreterArgs:ie,pm2Env:Ze,setPm2Env:re,isEditMode:b,building:s??null,handleCommand:X}),p==="docker"&&e.jsx(pa,{dockerMode:w,setDockerMode:ce,dockerImage:Qe,setDockerImage:ue,dockerContainerName:pe,setDockerContainerName:he,dockerCommand:ke,setDockerCommand:ye,dockerPorts:xe,setDockerPorts:be,dockerVolumes:je,setDockerVolumes:ge,dockerNetwork:Ne,setDockerNetwork:fe,dockerRestart:es,setDockerRestart:Ce,dockerPull:ss,setDockerPull:Se,dockerEnv:Xe,setDockerEnv:ve,dockerComposePath:we,setDockerComposePath:Pe,dockerComposeProject:De,setDockerComposeProject:Ee,dockerComposeServices:Le,setDockerComposeServices:Ae,selectedExistingContainer:me,setSelectedExistingContainer:de,dockerContainersList:d,isEditMode:b,building:s??null,handleCommand:X}),p==="terminal"&&e.jsx(ga,{terminalShell:ts,setTerminalShell:_e,terminalPort:Ie,setTerminalPort:Fe,terminalSaveSession:ns,setTerminalSaveSession:$e,terminalArgs:ls,setTerminalArgs:Me,isEditMode:b,building:s??null,handleCommand:X,onOpenTerminal:()=>{s!=null&&s.id&&window.dispatchEvent(new CustomEvent("tide:open-iframe-modal",{detail:{buildingId:s.id}}))},onOpenBelow:i=>{window.dispatchEvent(new CustomEvent("tide:open-bottom-terminal",{detail:{buildingId:i}}))}}),p==="server"&&!q&&e.jsx(ba,{startCmd:J,setStartCmd:U,stopCmd:W,setStopCmd:K,restartCmd:R,setRestartCmd:H,healthCheckCmd:O,setHealthCheckCmd:T,logsCmd:k,setLogsCmd:L,isEditMode:b,handleCommand:X}),e.jsxs("div",{className:"form-section",children:[e.jsxs("label",{className:"form-label",children:[t("config:buildings.links"),e.jsxs("button",{type:"button",className:"btn btn-sm btn-add",onClick:Zs,children:["+ ",t("common:buttons.add")]})]}),A.map((i,f)=>e.jsxs("div",{className:"url-row",children:[e.jsx("input",{type:"text",className:"form-input url-label",value:i.label,onChange:S=>os(f,"label",S.target.value),placeholder:"Label"}),e.jsx("input",{type:"text",className:"form-input url-value",value:i.url,onChange:S=>os(f,"url",S.target.value),placeholder:"https://..."}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>Qs(f),children:"x"})]},f))]}),b&&C&&cs.length>0&&e.jsx(va,{logs:cs,buildingId:c,logsContainerRef:Q})]}),e.jsxs("div",{className:"modal-footer",children:[b&&e.jsx("button",{type:"button",className:"btn btn-danger",onClick:Js,children:t("common:buttons.delete")}),e.jsx("div",{className:"footer-spacer"}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:l,children:t("common:buttons.cancel")}),e.jsx("button",{type:"submit",className:"btn btn-primary",children:t(b?"common:buttons.save":"common:buttons.create")})]})]})]}),Hs&&s&&e.jsx(ma,{buildingName:s.name,onClose:()=>oe(!1),onConfirm:Ws})]})}export{Ca as BuildingConfigModal};
|