impactus-swarm 0.0.479 → 0.0.480

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impactus-swarm",
3
- "version": "0.0.479",
3
+ "version": "0.0.480",
4
4
  "description": "AI-powered terminal swarm orchestration platform",
5
5
  "type": "module",
6
6
  "bin": {
@@ -2074,4 +2074,4 @@ Descreva as instrucoes do comando aqui.
2074
2074
  `;O(z),w(z),S(!1);return}(async()=>{try{const z=await t("agentStore.readFile",{id:e.id});O(z.content),w(z.content)}catch{O(""),w("")}finally{S(!1)}})()},[t,e.id,n]);function I(z){return`${zXe(z)}
2075
2075
 
2076
2076
  ${z.body}`}function V(z){if(k==="codigo"&&z!=="codigo"){const j=IV(T);if(j){const{frontmatter:W,body:L}=j;if(W.name){const Y=ax(a);W.name!==Y&&s(W.name)}W.description!==void 0&&c(W.description),W.model!==void 0?d(W.model):d("inherit"),W.tools!==void 0?m(W.tools):m(""),O(L.replace(/^\n/,""))}}if(z==="codigo"){const j=I({displayName:a,description:o,model:u,tools:h,body:g});_(j)}Q(z)}function D(){if(k==="codigo"){const z=IV(T);if(z){const{frontmatter:j,body:W}=z;return{displayName:j.name||a,description:j.description||o,model:j.model||"inherit",tools:j.tools||"",body:W.replace(/^\n/,"")}}}return{displayName:a,description:o,model:u,tools:h,body:g}}async function X(){A("");const z=D();if(!ax(z.displayName)){A("Nome invalido: deve conter letras ou numeros.");return}if(!z.description.trim()){A("Descricao e obrigatoria.");return}$(!0);try{if(n){const W=await t("agentStore.save",{name:e.name,displayName:z.displayName,description:z.description,model:z.model,tools:z.tools});await t("agentStore.writeFile",{id:W.id,content:z.body})}else(z.displayName!==e.displayName||z.description!==e.description||z.model!==e.model||z.tools!==e.tools)&&await t("agentStore.update",{id:e.id,displayName:z.displayName,description:z.description,model:z.model,tools:z.tools}),z.body!==b&&(await t("agentStore.writeFile",{id:e.id,content:z.body}),w(z.body));i==null||i(),r()}catch{}finally{$(!1)}}const q=(z,j)=>l.jsx("button",{onClick:()=>V(z),className:`rounded px-2 py-0.5 text-[10px] font-medium ${k===z?"bg-[var(--ui-accent)] text-white":"text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]"}`,children:j});return l.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/50",onClick:r,children:l.jsxs("div",{className:"relative flex w-full max-w-4xl flex-col rounded-lg border border-[var(--ui-border)] bg-[var(--ui-surface)] shadow-2xl",style:{maxHeight:"85vh"},onClick:z=>z.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--ui-border)] px-5 py-3",children:[l.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4 text-[var(--ui-accent)]",children:l.jsx("path",{d:"M2.695 14.763l-1.262 3.154a.5.5 0 00.65.65l3.155-1.262a4 4 0 001.343-.885L17.5 5.5a2.121 2.121 0 00-3-3L3.58 13.42a4 4 0 00-.885 1.343z"})}),l.jsx("h3",{className:"text-sm font-semibold text-[var(--ui-text)]",children:n?"Criar Agente":`Editar Agente: ${e.displayName}`}),l.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[M&&l.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-amber-400",children:[l.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-amber-400"}),"Alteracoes nao salvas"]}),q("editor","Editor"),q("codigo","Codigo"),q("preview","Preview"),l.jsx("button",{onClick:r,className:"rounded p-1 text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] hover:bg-[var(--ui-bg)]",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-4 w-4",children:l.jsx("path",{d:"M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"})})})]})]}),k!=="codigo"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex gap-3 border-b border-[var(--ui-border)] px-5 py-3",children:[l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{className:"mb-1 block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Nome"}),l.jsx("input",{value:a,onChange:z=>s(z.target.value),placeholder:"Ex: Agente de Review",className:"w-full rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2.5 py-1.5 text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]"})]}),l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{className:"mb-1 block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Descricao curta"}),l.jsx("input",{value:o,onChange:z=>c(z.target.value),placeholder:"Breve descricao do agente",className:"w-full rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2.5 py-1.5 text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]"})]})]}),l.jsxs("div",{className:"flex gap-3 border-b border-[var(--ui-border)] px-5 py-3",children:[l.jsxs("div",{className:"w-40",children:[l.jsx("label",{className:"mb-1 block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Modelo"}),l.jsx("select",{value:u,onChange:z=>d(z.target.value),className:"w-full rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2.5 py-1.5 text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]",children:LXe.map(z=>l.jsx("option",{value:z.value,children:z.label},z.value))})]}),l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{className:"mb-1 block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Tools (separadas por virgula)"}),l.jsx("input",{value:h,onChange:z=>m(z.target.value),placeholder:"Ex: Read, Write, Bash, Grep",className:"w-full rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2.5 py-1.5 text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]"})]})]})]}),l.jsx("div",{className:"flex-1 overflow-auto p-4",style:{minHeight:300},children:v?l.jsx(xt,{className:"text-xs text-[var(--ui-text-muted)]",children:"Carregando arquivo..."}):k==="editor"?l.jsx("textarea",{value:g,onChange:z=>O(z.target.value),className:"h-full w-full resize-none rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] p-3 font-mono text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]",style:{minHeight:270},spellCheck:!1,placeholder:"Escreva o system prompt do agente em Markdown..."}):k==="codigo"?l.jsx("textarea",{value:T,onChange:z=>_(z.target.value),className:"h-full w-full resize-none rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] p-3 font-mono text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]",style:{minHeight:270},spellCheck:!1,placeholder:"Arquivo .md completo com frontmatter YAML..."}):l.jsxs("div",{className:"rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] p-4 space-y-3",children:[l.jsxs("div",{className:"rounded border border-[var(--ui-border)] bg-[var(--ui-surface)] px-3 py-2 font-mono text-[10px] text-[var(--ui-text-muted)]",children:[l.jsx("div",{className:"mb-1 text-[9px] uppercase tracking-widest text-[var(--ui-text-muted)] opacity-60",children:"frontmatter"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-[var(--ui-accent)]",children:"name:"})," ",l.jsx("span",{className:"text-[var(--ui-text)]",children:ax(a)||"(vazio)"})]}),l.jsxs("div",{children:[l.jsx("span",{className:"text-[var(--ui-accent)]",children:"description:"})," ",l.jsx("span",{className:"text-[var(--ui-text)]",children:o||"(vazio)"})]}),u&&u!=="inherit"&&l.jsxs("div",{children:[l.jsx("span",{className:"text-[var(--ui-accent)]",children:"model:"})," ",l.jsx("span",{className:"text-[var(--ui-text)]",children:u})]}),h.trim()&&l.jsxs("div",{children:[l.jsx("span",{className:"text-[var(--ui-accent)]",children:"tools:"})," ",l.jsx("span",{className:"text-[var(--ui-text)]",children:h})]})]}),l.jsx("div",{className:"prose-sm text-xs text-[var(--ui-text)]",dangerouslySetInnerHTML:{__html:DXe(g)}})]})}),l.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--ui-border)] px-5 py-3",children:[R&&l.jsx("span",{className:"mr-auto text-[10px] text-red-400",children:R}),l.jsx("button",{onClick:r,className:"rounded border border-[var(--ui-border)] px-3 py-1.5 text-xs text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]",children:"Cancelar"}),l.jsx("button",{onClick:X,disabled:N,className:"rounded bg-[var(--ui-accent)] px-3 py-1.5 text-xs font-medium text-white hover:opacity-90 disabled:opacity-50",children:N?"Salvando...":"Salvar"})]})]})})}function XXe(t){try{return new Date(t).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"2-digit"})}catch{return"--"}}function qXe({send:t}){const[e,n]=C.useState([]),[r,i]=C.useState(!0),[a,s]=C.useState(""),[o,c]=C.useState(null),[u,d]=C.useState(null),[h,m]=C.useState(!1),g=C.useCallback(async()=>{try{const S=await t("agentStore.list",{});n(S)}catch{n([])}finally{i(!1)}},[t]);C.useEffect(()=>{g()},[g]);const O=C.useMemo(()=>{if(!a.trim())return e;const S=a.toLowerCase();return e.filter(k=>k.displayName.toLowerCase().includes(S)||k.name.toLowerCase().includes(S)||k.description.toLowerCase().includes(S)||k.model.toLowerCase().includes(S))},[e,a]);async function b(){u&&(await t("agentStore.delete",{id:u}),d(null),g())}async function w(S){await t("agentStore.duplicate",{id:S}),g()}function v(){m(!0),c({id:"",name:`custom-agent-${Date.now()}`,displayName:"Novo Agente Personalizado",description:"",model:"inherit",tools:"",hasFile:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()})}return l.jsxs("div",{className:"p-5 space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"text-sm font-semibold text-[var(--ui-text)]",children:"Agents"}),l.jsx("div",{className:"flex items-center gap-2",children:l.jsx(De,{label:"Criar um novo agente personalizado do zero",side:"bottom",children:l.jsx("button",{onClick:v,className:"rounded border border-[var(--ui-border)] px-3 py-1.5 text-xs text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]",children:"Criar Agente"})})})]}),!r&&e.length>0&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--ui-text-muted)]",children:l.jsx("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),l.jsx("input",{value:a,onChange:S=>s(S.target.value),placeholder:"Filtrar agentes por nome, modelo ou descricao...",className:"w-full rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] py-1.5 pl-8 pr-3 text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]"})]}),l.jsxs("span",{className:"text-[10px] text-[var(--ui-text-muted)]",children:[O.length," de ",e.length]})]}),r&&l.jsx(xt,{className:"text-xs text-[var(--ui-text-muted)]",children:"Carregando..."}),!r&&e.length===0&&l.jsx("div",{className:"rounded-lg border border-dashed border-[var(--ui-border)] p-8 text-center",children:l.jsx("p",{className:"text-xs text-[var(--ui-text-muted)]",children:"Nenhum agente salvo. Crie um agente personalizado para comecar."})}),!r&&e.length>0&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-3 rounded bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:[l.jsx("span",{className:"w-44",children:"Nome"}),l.jsx("span",{className:"w-24",children:"Modelo"}),l.jsx("span",{className:"flex-1 min-w-0",children:"Tools"}),l.jsx("span",{className:"w-10 text-center",children:"Arq."}),l.jsx("span",{className:"w-20 text-center",children:"Adicionada"}),l.jsx("span",{className:"w-24 text-right",children:"Acoes"})]}),O.map(S=>l.jsxs("div",{className:"flex items-center gap-3 rounded border border-[var(--ui-border)] bg-[var(--ui-surface)] px-3 py-2 transition-colors hover:border-[var(--ui-accent)]/30",children:[l.jsx("span",{className:"w-44 truncate text-xs font-medium text-[var(--ui-text)]",children:S.displayName}),l.jsx("span",{className:"w-24",children:l.jsx("code",{className:"rounded bg-[var(--ui-bg)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--ui-text)]",children:S.model||"inherit"})}),l.jsx("span",{className:"flex-1 min-w-0 truncate text-[10px] text-[var(--ui-text-muted)]",children:S.tools||"--"}),l.jsx(De,{label:S.hasFile?"Arquivo .md salvo localmente":"Sem arquivo local",side:"top",children:l.jsx("span",{className:"w-10 flex justify-center",children:S.hasFile?l.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-green-400"}):l.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-[var(--ui-border)]"})})}),l.jsx(De,{label:`Adicionado em ${new Date(S.createdAt).toLocaleString("pt-BR")}`,side:"top",children:l.jsx("span",{className:"w-20 text-center text-[10px] text-[var(--ui-text-muted)]",children:XXe(S.createdAt)})}),l.jsxs("div",{className:"flex w-24 items-center justify-end gap-0.5",children:[l.jsx(De,{label:"Editar agente",side:"top",children:l.jsx("button",{onClick:()=>c(S),className:"rounded p-1 text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] hover:bg-[var(--ui-bg)]",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3 w-3",children:l.jsx("path",{d:"M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L3.463 11.098a.25.25 0 00-.064.108l-.593 2.076 2.076-.593a.25.25 0 00.108-.064l8.61-8.61a.25.25 0 000-.354l-1.086-1.086-.087.087.087-.087z"})})})}),l.jsx(De,{label:"Duplicar agente",side:"top",children:l.jsx("button",{onClick:()=>w(S.id),className:"rounded p-1 text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] hover:bg-[var(--ui-bg)]",children:l.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3 w-3",children:[l.jsx("path",{d:"M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"}),l.jsx("path",{d:"M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"})]})})}),l.jsx(De,{label:"Excluir agente",side:"top",children:l.jsx("button",{onClick:()=>d(S.id),className:"rounded p-1 text-[var(--ui-text-muted)] hover:text-red-400 hover:bg-[var(--ui-bg)]",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3 w-3",children:l.jsx("path",{d:"M5.75 1a.75.75 0 00-.75.75V3H2a.75.75 0 000 1.5h.5l.627 8.77A1.75 1.75 0 004.872 15h6.256a1.75 1.75 0 001.745-1.73L13.5 4.5H14A.75.75 0 0014 3h-3V1.75A.75.75 0 0010.25 1h-4.5zM6.5 3V2.5h3V3h-3zm-2 1.5h7.022l-.618 8.638a.25.25 0 01-.249.362H5.345a.25.25 0 01-.249-.362L4.478 4.5H4.5z"})})})})]})]},S.id)),O.length===0&&a&&l.jsxs("div",{className:"px-3 py-6 text-center text-xs text-[var(--ui-text-muted)]",children:['Nenhum agente encontrado para "',a,'"']})]}),o&&l.jsx(IXe,{send:t,agent:o,isNew:h,onClose:()=>{c(null),m(!1)},onSaved:()=>{m(!1),g()}}),u&&l.jsx(ng,{title:"Excluir Agente",message:"Tem certeza que deseja excluir este agente? Esta acao nao pode ser desfeita.",confirmLabel:"Excluir",variant:"danger",onConfirm:b,onCancel:()=>d(null)})]})}const VXe=/^[a-z0-9_-]+$/;function IQ(t){return t.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9\s_-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function XV(t){return t?Object.entries(t).map(([e,n])=>({key:e,value:n})):[]}function XQ(t){const e={};for(const{key:n,value:r}of t){const i=n.trim();i&&(e[i]=r)}return e}function BXe({send:t,mcp:e,onClose:n,onSaved:r}){const i=e!==null,[a,s]=C.useState((e==null?void 0:e.name)??""),[o,c]=C.useState((e==null?void 0:e.displayName)??""),[u,d]=C.useState((e==null?void 0:e.description)??""),[h,m]=C.useState((e==null?void 0:e.transport)??"stdio"),[g,O]=C.useState((e==null?void 0:e.command)??""),[b,w]=C.useState(e!=null&&e.args?[...e.args]:[]),[v,S]=C.useState(""),[k,Q]=C.useState(XV(e==null?void 0:e.env)),[T,_]=C.useState((e==null?void 0:e.url)??""),[N,$]=C.useState(XV(e==null?void 0:e.headers)),[R,A]=C.useState(e!=null&&e.timeoutMs?String(e.timeoutMs):""),[M,I]=C.useState(e!=null&&e.tags?[...e.tags]:[]),[V,D]=C.useState(""),[X,q]=C.useState(!1),[z,j]=C.useState("");function W(){const se=v.trim();se&&(w([...b,se]),S(""))}function L(se){w(b.filter((te,ne)=>ne!==se))}function Y(){const se=V.trim();if(!se||M.includes(se)){D("");return}I([...M,se]),D("")}function F(se){I(M.filter((te,ne)=>ne!==se))}function Z(se,te,ne,oe){te(se.map((K,pe)=>pe===ne?{...K,...oe}:K))}function G(se,te){te([...se,{key:"",value:""}])}function re(se,te,ne){te(se.filter((oe,K)=>K!==ne))}async function ae(){if(j(""),!o.trim()){j("Nome de exibicao e obrigatorio.");return}const se=i?(e==null?void 0:e.name)??"":a.trim()||IQ(o);if(!i){if(!se){j("Nome (slug) e obrigatorio.");return}if(!VXe.test(se)){j("Slug invalido. Use apenas a-z, 0-9, _ e -.");return}}if(h==="stdio"){if(!g.trim()){j("Comando e obrigatorio para transporte stdio.");return}}else if(!T.trim()){j("URL e obrigatoria para transporte http/sse.");return}const te=R.trim()?Number(R):void 0;if(te!==void 0&&(!Number.isFinite(te)||te<=0)){j("Timeout deve ser um numero positivo (ms).");return}const ne={displayName:o.trim(),description:u.trim()||void 0,transport:h,timeoutMs:te,tags:M.length>0?M:void 0};h==="stdio"?(ne.command=g.trim(),ne.args=b.length>0?b:void 0,ne.env=k.length>0?XQ(k):void 0,ne.url=void 0,ne.headers=void 0):(ne.url=T.trim(),ne.headers=N.length>0?XQ(N):void 0,ne.command=void 0,ne.args=void 0,ne.env=k.length>0?XQ(k):void 0),q(!0);try{i&&e?await t("mcpStore.update",{id:e.id,...ne}):await t("mcpStore.save",{name:se,...ne}),r==null||r(),n()}catch(oe){j((oe==null?void 0:oe.message)||"Falha ao salvar MCP.")}finally{q(!1)}}return l.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/50",onClick:n,children:l.jsxs("div",{className:"relative flex max-h-[90vh] w-full max-w-3xl flex-col rounded-lg border border-[var(--ui-border)] bg-[var(--ui-surface)] shadow-2xl",onClick:se=>se.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--ui-border)] px-5 py-3",children:[l.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4 text-[var(--ui-accent)]",children:l.jsx("path",{d:"M3 4a1 1 0 011-1h12a1 1 0 011 1v12a1 1 0 01-1 1H4a1 1 0 01-1-1V4zm2 1v10h10V5H5zm2 2h6v2H7V7zm0 4h6v2H7v-2z"})}),l.jsx("h3",{className:"text-sm font-semibold text-[var(--ui-text)]",children:i?`Editar MCP: ${e==null?void 0:e.displayName}`:"Adicionar MCP"}),l.jsx("button",{onClick:n,className:"ml-auto rounded p-1 text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] hover:bg-[var(--ui-bg)]",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-4 w-4",children:l.jsx("path",{d:"M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"})})})]}),l.jsxs("div",{className:"space-y-3 overflow-y-auto px-5 py-4",children:[l.jsxs("div",{className:"flex gap-3",children:[l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{className:"mb-1 block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Nome de exibicao"}),l.jsx("input",{value:o,onChange:se=>{c(se.target.value),!i&&!a&&s(IQ(se.target.value))},placeholder:"Ex: GitHub MCP",className:"w-full rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2.5 py-1.5 text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]"})]}),l.jsxs("div",{className:"w-56",children:[l.jsxs("label",{className:"mb-1 block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:["Slug ",i&&l.jsx("span",{className:"text-[var(--ui-text-muted)]",children:"(nao editavel)"})]}),l.jsx("input",{value:i?(e==null?void 0:e.name)??"":a,onChange:se=>s(IQ(se.target.value)),disabled:i,placeholder:"github-mcp",className:"w-full rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2.5 py-1.5 font-mono text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)] disabled:opacity-60"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Descricao"}),l.jsx("input",{value:u,onChange:se=>d(se.target.value),placeholder:"Breve descricao do servidor",className:"w-full rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2.5 py-1.5 text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Transporte"}),l.jsx("div",{className:"flex gap-2",children:["stdio","http","sse"].map(se=>l.jsxs("label",{className:`flex cursor-pointer items-center gap-1.5 rounded border px-2.5 py-1 text-xs ${h===se?"border-[var(--ui-accent)] bg-[var(--ui-accent)]/10 text-[var(--ui-text)]":"border-[var(--ui-border)] text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]"}`,children:[l.jsx("input",{type:"radio",name:"mcp-transport",checked:h===se,onChange:()=>m(se),className:"h-3 w-3"}),se]},se))})]}),h==="stdio"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Comando"}),l.jsx("input",{value:g,onChange:se=>O(se.target.value),placeholder:"npx | uvx | node",className:"w-full rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2.5 py-1.5 font-mono text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Argumentos"}),l.jsxs("div",{className:"flex gap-1",children:[l.jsx("input",{value:v,onChange:se=>S(se.target.value),onKeyDown:se=>{se.key==="Enter"&&(se.preventDefault(),W())},placeholder:"-y @modelcontextprotocol/server-github",className:"flex-1 rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2.5 py-1.5 font-mono text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]"}),l.jsx("button",{onClick:W,className:"rounded border border-[var(--ui-border)] px-2 py-1 text-xs text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]",children:"+"})]}),b.length>0&&l.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:b.map((se,te)=>l.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-[var(--ui-bg)] px-2 py-0.5 font-mono text-[10px] text-[var(--ui-text)]",children:[se,l.jsx("button",{onClick:()=>L(te),className:"text-[var(--ui-text-muted)] hover:text-red-400",children:"x"})]},te))})]})]}),h!=="stdio"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"URL"}),l.jsx("input",{value:T,onChange:se=>_(se.target.value),placeholder:"https://example.com/mcp",className:"w-full rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2.5 py-1.5 font-mono text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]"})]}),l.jsx(qV,{label:"Headers",items:N,onAdd:()=>G(N,$),onRemove:se=>re(N,$,se),onChange:(se,te)=>Z(N,$,se,te),keyPlaceholder:"Authorization",valuePlaceholder:"Bearer ..."})]}),l.jsx(qV,{label:"Variaveis de ambiente",items:k,onAdd:()=>G(k,Q),onRemove:se=>re(k,Q,se),onChange:(se,te)=>Z(k,Q,se,te),keyPlaceholder:"GITHUB_TOKEN",valuePlaceholder:"ghp_..."}),l.jsxs("div",{className:"flex gap-3",children:[l.jsxs("div",{className:"w-40",children:[l.jsx("label",{className:"mb-1 block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Timeout (ms)"}),l.jsx("input",{value:R,onChange:se=>A(se.target.value.replace(/[^0-9]/g,"")),placeholder:"30000",className:"w-full rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2.5 py-1.5 text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]"})]}),l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{className:"mb-1 block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Tags"}),l.jsxs("div",{className:"flex gap-1",children:[l.jsx("input",{value:V,onChange:se=>D(se.target.value),onKeyDown:se=>{se.key==="Enter"&&(se.preventDefault(),Y())},placeholder:"dev, github",className:"flex-1 rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2.5 py-1.5 text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]"}),l.jsx("button",{onClick:Y,className:"rounded border border-[var(--ui-border)] px-2 py-1 text-xs text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]",children:"+"})]}),M.length>0&&l.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:M.map((se,te)=>l.jsxs("span",{className:"flex items-center gap-1 rounded-full border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2 py-0.5 text-[10px] text-[var(--ui-text)]",children:[se,l.jsx("button",{onClick:()=>F(te),className:"text-[var(--ui-text-muted)] hover:text-red-400",children:"x"})]},se))})]})]})]}),l.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--ui-border)] px-5 py-3",children:[z&&l.jsx("p",{className:"mr-auto text-xs text-red-500",children:z}),l.jsx("button",{onClick:n,className:"rounded border border-[var(--ui-border)] px-3 py-1.5 text-xs text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]",children:"Cancelar"}),l.jsx("button",{onClick:ae,disabled:X||!o.trim(),className:"rounded bg-[var(--ui-accent)] px-3 py-1.5 text-xs font-medium text-white hover:opacity-90 disabled:opacity-50",children:X?"Salvando...":"Salvar"})]})]})})}function qV({label:t,items:e,onAdd:n,onRemove:r,onChange:i,keyPlaceholder:a,valuePlaceholder:s}){return l.jsxs("div",{children:[l.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[l.jsx("label",{className:"block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:t}),l.jsx("button",{onClick:n,className:"rounded border border-[var(--ui-border)] px-2 py-0.5 text-[10px] text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]",children:"+ Adicionar"})]}),e.length===0?l.jsx("p",{className:"text-[10px] text-[var(--ui-text-muted)]",children:"Nenhum item."}):l.jsx("div",{className:"space-y-1",children:e.map((o,c)=>l.jsxs("div",{className:"flex gap-1",children:[l.jsx("input",{value:o.key,onChange:u=>i(c,{key:u.target.value}),placeholder:a||"Chave",className:"w-1/3 rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2 py-1 font-mono text-[11px] text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]"}),l.jsx("input",{value:o.value,onChange:u=>i(c,{value:u.target.value}),placeholder:s||"Valor",className:"flex-1 rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2 py-1 font-mono text-[11px] text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]"}),l.jsx("button",{onClick:()=>r(c),className:"rounded border border-[var(--ui-border)] px-2 py-1 text-[10px] text-[var(--ui-text-muted)] hover:text-red-400",children:"x"})]},c))})]})}function ZXe(t){if(t.transport==="stdio"){const n={type:"stdio",command:t.command??""};return t.args&&t.args.length>0&&(n.args=t.args),t.env&&Object.keys(t.env).length>0&&(n.env=t.env),t.timeoutMs&&(n.timeout=t.timeoutMs),n}const e={type:t.transport,url:t.url??""};return t.headers&&Object.keys(t.headers).length>0&&(e.headers=t.headers),t.timeoutMs&&(e.timeout=t.timeoutMs),e}function CO(t){const e={};for(const n of t)e[n.name]=ZXe(n);return JSON.stringify({mcpServers:e},null,2)}function WXe(t){const e=[t];return[{cli:"claude",label:"Claude Code",filename:".mcp.json",content:CO(e),language:"json"},{cli:"cursor",label:"Cursor",filename:".cursor/mcp.json",content:CO(e),language:"json"},{cli:"gemini",label:"Gemini",filename:".gemini/settings.json",content:CO(e),language:"json"},{cli:"opencode",label:"OpenCode",filename:".opencode/mcp.json",content:CO(e),language:"json"},{cli:"codex",label:"Codex",filename:".codex/config.toml",content:`# TOML preview available in the agent workspace after provisioning.
2077
- # Server key: `+t.name,language:"text"}]}function UXe({mcp:t,onClose:e,onEdit:n}){var d;const r=C.useMemo(()=>WXe(t),[t]),[i,a]=C.useState(((d=r[0])==null?void 0:d.cli)??"claude"),[s,o]=C.useState(!1),c=r.find(h=>h.cli===i)??r[0];function u(){c&&(navigator.clipboard.writeText(c.content).catch(()=>{}),o(!0),setTimeout(()=>o(!1),1500))}return l.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/50",onClick:e,children:l.jsxs("div",{className:"relative flex max-h-[90vh] w-full max-w-3xl flex-col rounded-lg border border-[var(--ui-border)] bg-[var(--ui-surface)] shadow-2xl",onClick:h=>h.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--ui-border)] px-5 py-3",children:[l.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4 text-[var(--ui-accent)]",children:l.jsx("path",{d:"M3 4a1 1 0 011-1h12a1 1 0 011 1v12a1 1 0 01-1 1H4a1 1 0 01-1-1V4zm2 1v10h10V5H5z"})}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--ui-text)]",children:t.displayName}),l.jsx("p",{className:"truncate text-[10px] font-mono text-[var(--ui-text-muted)]",children:t.name})]}),l.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[n&&l.jsx("button",{onClick:()=>n(t),className:"rounded border border-[var(--ui-border)] px-2 py-1 text-[10px] text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]",children:"Editar"}),l.jsx("button",{onClick:e,className:"rounded p-1 text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] hover:bg-[var(--ui-bg)]",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-4 w-4",children:l.jsx("path",{d:"M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"})})})]})]}),l.jsxs("div",{className:"space-y-4 overflow-y-auto px-5 py-4",children:[l.jsx("div",{className:"rounded border border-[var(--ui-border)] overflow-hidden",children:l.jsx("table",{className:"w-full text-xs",children:l.jsxs("tbody",{children:[l.jsxs("tr",{className:"border-b border-[var(--ui-border)]",children:[l.jsx("td",{className:"w-28 bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Transporte"}),l.jsx("td",{className:"px-3 py-2 font-mono text-[var(--ui-text)]",children:t.transport})]}),t.description&&l.jsxs("tr",{className:"border-b border-[var(--ui-border)]",children:[l.jsx("td",{className:"bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Descricao"}),l.jsx("td",{className:"px-3 py-2 text-[var(--ui-text)]",children:t.description})]}),t.transport==="stdio"?l.jsxs(l.Fragment,{children:[l.jsxs("tr",{className:"border-b border-[var(--ui-border)]",children:[l.jsx("td",{className:"bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Comando"}),l.jsx("td",{className:"px-3 py-2 font-mono text-[var(--ui-text)]",children:t.command||"--"})]}),l.jsxs("tr",{className:"border-b border-[var(--ui-border)]",children:[l.jsx("td",{className:"bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Args"}),l.jsx("td",{className:"px-3 py-2 font-mono text-[var(--ui-text)]",children:t.args&&t.args.length>0?t.args.join(" "):l.jsx("span",{className:"italic text-[var(--ui-text-muted)]",children:"(nenhum)"})})]})]}):l.jsxs("tr",{className:"border-b border-[var(--ui-border)]",children:[l.jsx("td",{className:"bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"URL"}),l.jsx("td",{className:"px-3 py-2 font-mono text-[var(--ui-text)] break-all",children:t.url||"--"})]}),t.timeoutMs&&l.jsxs("tr",{className:"border-b border-[var(--ui-border)]",children:[l.jsx("td",{className:"bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Timeout"}),l.jsxs("td",{className:"px-3 py-2 text-[var(--ui-text)]",children:[t.timeoutMs," ms"]})]}),t.tags&&t.tags.length>0&&l.jsxs("tr",{children:[l.jsx("td",{className:"bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Tags"}),l.jsx("td",{className:"px-3 py-2",children:l.jsx("div",{className:"flex flex-wrap gap-1",children:t.tags.map(h=>l.jsx("span",{className:"rounded-full border border-[var(--ui-border)] px-1.5 py-0.5 text-[10px] text-[var(--ui-text-muted)]",children:h},h))})})]})]})})}),l.jsxs("div",{children:[l.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[l.jsx("label",{className:"block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Preview por CLI"}),l.jsx("button",{onClick:u,className:"rounded border border-[var(--ui-border)] px-2 py-0.5 text-[10px] text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]",children:s?"Copiado!":"Copiar"})]}),l.jsx("div",{className:"flex items-center gap-1 border-b border-[var(--ui-border)]",children:r.map(h=>l.jsx("button",{onClick:()=>a(h.cli),className:`rounded-t px-2.5 py-1 text-[10px] font-medium ${i===h.cli?"bg-[var(--ui-bg)] text-[var(--ui-text)] border border-b-0 border-[var(--ui-border)]":"text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]"}`,children:h.label},h.cli))}),c&&l.jsxs("div",{children:[l.jsx("p",{className:"mt-1 mb-1 text-[10px] font-mono text-[var(--ui-text-muted)]",children:c.filename}),l.jsx("pre",{className:"rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] p-3 font-mono text-[11px] text-[var(--ui-text)] overflow-auto max-h-[40vh]",children:c.content})]})]})]}),l.jsx("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--ui-border)] px-5 py-3",children:l.jsx("button",{onClick:e,className:"rounded border border-[var(--ui-border)] px-3 py-1.5 text-xs text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]",children:"Fechar"})})]})})}function YXe(t){try{return new Date(t).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"2-digit"})}catch{return"--"}}const FXe=[{value:"all",label:"Todos"},{value:"stdio",label:"stdio"},{value:"http",label:"http"},{value:"sse",label:"sse"}];function GXe({send:t}){const[e,n]=C.useState([]),[r,i]=C.useState(!0),[a,s]=C.useState(""),[o,c]=C.useState("all"),[u,d]=C.useState(""),[h,m]=C.useState(null),[g,O]=C.useState(null),[b,w]=C.useState(null),v=C.useCallback(async()=>{try{const _=await t("mcpStore.list",{}),N=Array.isArray(_)?_:_.mcps;n(N??[])}catch{n([])}finally{i(!1)}},[t]);C.useEffect(()=>{v()},[v]);const S=C.useMemo(()=>{const _=new Set;return e.forEach(N=>(N.tags||[]).forEach($=>_.add($))),Array.from(_).sort()},[e]),k=C.useMemo(()=>{const _=a.trim().toLowerCase();return e.filter(N=>o!=="all"&&N.transport!==o||u&&!(N.tags||[]).includes(u)?!1:_?N.displayName.toLowerCase().includes(_)||N.name.toLowerCase().includes(_)||(N.description||"").toLowerCase().includes(_)||(N.command||"").toLowerCase().includes(_)||(N.url||"").toLowerCase().includes(_):!0)},[e,a,o,u]);async function Q(){b&&(await t("mcpStore.delete",{id:b}),w(null),v())}async function T(_){await t("mcpStore.duplicate",{id:_}),v()}return l.jsxs("div",{className:"p-5 space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"text-sm font-semibold text-[var(--ui-text)]",children:"MCPs"}),l.jsx("div",{className:"flex items-center gap-2",children:l.jsx(De,{label:"Criar um novo servidor MCP",side:"bottom",children:l.jsx("button",{onClick:()=>m("new"),className:"rounded border border-[var(--ui-border)] px-3 py-1.5 text-xs text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]",children:"Adicionar MCP"})})})]}),!r&&e.length>0&&l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsxs("div",{className:"relative flex-1 min-w-[180px]",children:[l.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--ui-text-muted)]",children:l.jsx("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),l.jsx("input",{value:a,onChange:_=>s(_.target.value),placeholder:"Filtrar MCPs por nome, url ou descricao...",className:"w-full rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] py-1.5 pl-8 pr-3 text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]"})]}),l.jsx("select",{value:o,onChange:_=>c(_.target.value),className:"rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2 py-1.5 text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]",children:FXe.map(_=>l.jsxs("option",{value:_.value,children:["Transporte: ",_.label]},_.value))}),S.length>0&&l.jsxs("select",{value:u,onChange:_=>d(_.target.value),className:"rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2 py-1.5 text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]",children:[l.jsx("option",{value:"",children:"Todas as tags"}),S.map(_=>l.jsx("option",{value:_,children:_},_))]}),l.jsxs("span",{className:"text-[10px] text-[var(--ui-text-muted)]",children:[k.length," de ",e.length]})]}),r&&l.jsx(xt,{className:"text-xs text-[var(--ui-text-muted)]",children:"Carregando..."}),!r&&e.length===0&&l.jsx("div",{className:"rounded-lg border border-dashed border-[var(--ui-border)] p-8 text-center",children:l.jsx("p",{className:"text-xs text-[var(--ui-text-muted)]",children:"Nenhum MCP salvo. Adicione um servidor MCP para conectar ferramentas externas aos agentes."})}),!r&&e.length>0&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-3 rounded bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:[l.jsx("span",{className:"w-40",children:"Nome"}),l.jsx("span",{className:"w-20",children:"Transporte"}),l.jsx("span",{className:"flex-1 min-w-0",children:"Alvo"}),l.jsx("span",{className:"w-32",children:"Tags"}),l.jsx("span",{className:"w-20 text-center",children:"Adicionado"}),l.jsx("span",{className:"w-28 text-right",children:"Acoes"})]}),k.map(_=>l.jsxs("div",{className:"flex items-center gap-3 rounded border border-[var(--ui-border)] bg-[var(--ui-surface)] px-3 py-2 transition-colors hover:border-[var(--ui-accent)]/30",children:[l.jsxs("div",{className:"w-40 min-w-0",children:[l.jsx("div",{className:"truncate text-xs font-medium text-[var(--ui-text)]",children:_.displayName}),l.jsx("div",{className:"truncate text-[10px] text-[var(--ui-text-muted)] font-mono",children:_.name})]}),l.jsx("span",{className:"w-20",children:l.jsx("code",{className:"rounded bg-[var(--ui-bg)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--ui-text)]",children:_.transport})}),l.jsx("div",{className:"flex flex-1 min-w-0 items-center gap-1",children:l.jsx("code",{className:"flex-1 truncate rounded bg-[var(--ui-bg)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--ui-text)]",children:_.transport==="stdio"?`${_.command||""}${_.args&&_.args.length>0?" "+_.args.join(" "):""}`:_.url||"--"})}),l.jsxs("div",{className:"w-32 flex flex-wrap gap-0.5",children:[(_.tags||[]).slice(0,3).map(N=>l.jsx("span",{className:"rounded-full border border-[var(--ui-border)] px-1.5 py-0.5 text-[9px] text-[var(--ui-text-muted)]",children:N},N)),(_.tags||[]).length>3&&l.jsxs("span",{className:"text-[9px] text-[var(--ui-text-muted)]",children:["+",(_.tags||[]).length-3]})]}),l.jsx(De,{label:`Adicionado em ${new Date(_.createdAt).toLocaleString("pt-BR")}`,side:"top",children:l.jsx("span",{className:"w-20 text-center text-[10px] text-[var(--ui-text-muted)]",children:YXe(_.createdAt)})}),l.jsxs("div",{className:"flex w-28 items-center justify-end gap-0.5",children:[l.jsx(De,{label:"Ver detalhes",side:"top",children:l.jsx("button",{onClick:()=>O(_),className:"rounded p-1 text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] hover:bg-[var(--ui-bg)]",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3 w-3",children:l.jsx("path",{d:"M8 2c1.981 0 3.671.992 4.933 2.078 1.27 1.091 2.187 2.345 2.637 3.023a1.62 1.62 0 010 1.798c-.45.678-1.367 1.932-2.637 3.023C11.671 13.008 9.981 14 8 14s-3.671-.992-4.933-2.078C1.797 10.831.88 9.577.43 8.899a1.62 1.62 0 010-1.798c.45-.678 1.367-1.932 2.637-3.023C4.329 2.992 6.019 2 8 2zm0 10c3.3 0 5.9-3.048 6.505-3.904a.12.12 0 000-.192C13.9 7.048 11.3 4 8 4 4.7 4 2.1 7.048 1.495 7.904a.12.12 0 000 .192C2.1 8.952 4.7 12 8 12zm0-6.5a2.5 2.5 0 110 5 2.5 2.5 0 010-5zm0 1.5a1 1 0 100 2 1 1 0 000-2z"})})})}),l.jsx(De,{label:"Editar MCP",side:"top",children:l.jsx("button",{onClick:()=>m(_),className:"rounded p-1 text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] hover:bg-[var(--ui-bg)]",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3 w-3",children:l.jsx("path",{d:"M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L3.463 11.098a.25.25 0 00-.064.108l-.593 2.076 2.076-.593a.25.25 0 00.108-.064l8.61-8.61a.25.25 0 000-.354l-1.086-1.086-.087.087.087-.087z"})})})}),l.jsx(De,{label:"Duplicar MCP",side:"top",children:l.jsx("button",{onClick:()=>T(_.id),className:"rounded p-1 text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] hover:bg-[var(--ui-bg)]",children:l.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3 w-3",children:[l.jsx("path",{d:"M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"}),l.jsx("path",{d:"M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"})]})})}),l.jsx(De,{label:"Excluir MCP",side:"top",children:l.jsx("button",{onClick:()=>w(_.id),className:"rounded p-1 text-[var(--ui-text-muted)] hover:text-red-400 hover:bg-[var(--ui-bg)]",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3 w-3",children:l.jsx("path",{d:"M5.75 1a.75.75 0 00-.75.75V3H2a.75.75 0 000 1.5h.5l.627 8.77A1.75 1.75 0 004.872 15h6.256a1.75 1.75 0 001.745-1.73L13.5 4.5H14A.75.75 0 0014 3h-3V1.75A.75.75 0 0010.25 1h-4.5zM6.5 3V2.5h3V3h-3zm-2 1.5h7.022l-.618 8.638a.25.25 0 01-.249.362H5.345a.25.25 0 01-.249-.362L4.478 4.5H4.5z"})})})})]})]},_.id)),k.length===0&&l.jsx("div",{className:"px-3 py-6 text-center text-xs text-[var(--ui-text-muted)]",children:"Nenhum MCP encontrado para o filtro atual"})]}),h!==null&&l.jsx(BXe,{send:t,mcp:h==="new"?null:h,onClose:()=>m(null),onSaved:v}),g&&l.jsx(UXe,{mcp:g,onClose:()=>O(null),onEdit:_=>{O(null),m(_)}}),b&&l.jsx(ng,{title:"Excluir MCP",message:"Tem certeza que deseja excluir este MCP? Esta acao nao pode ser desfeita.",confirmLabel:"Excluir",variant:"danger",onConfirm:Q,onCancel:()=>w(null)})]})}const HXe=[{key:"skills",label:"Skills"},{key:"commands",label:"Commands"},{key:"hooks",label:"Hooks"},{key:"mcps",label:"MCPs"},{key:"agents",label:"Agents"}];function KXe({send:t}){const[e,n]=C.useState("skills");return l.jsxs("div",{className:"space-y-0",children:[l.jsx("div",{className:"flex items-center gap-1 border-b border-[var(--ui-border)] px-5 pt-4 pb-0",children:HXe.map(r=>l.jsx("button",{onClick:()=>n(r.key),className:`rounded-t px-3 py-1.5 text-xs font-medium transition-colors ${e===r.key?"bg-[var(--ui-surface)] border border-b-0 border-[var(--ui-border)] text-[var(--ui-text)]":"text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]"}`,children:r.label},r.key))}),e==="skills"&&l.jsx(QXe,{send:t}),e==="commands"&&l.jsx(EXe,{send:t}),e==="hooks"&&l.jsx(MXe,{send:t}),e==="mcps"&&l.jsx(GXe,{send:t}),e==="agents"&&l.jsx(qXe,{send:t})]})}const VV="mobile.shortcuts";function JXe(){return`shortcut-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}const zte=[{label:"Tab",sequence:"\\t",description:"Autocompletar"},{label:"Enter",sequence:"\\r",description:"Enviar comando"},{label:"Escape",sequence:"\\e",description:"Cancelar / sair"},{label:"Ctrl+C",sequence:"\\u0003",description:"Interromper processo"},{label:"Ctrl+D",sequence:"\\u0004",description:"EOF / sair do shell"},{label:"Ctrl+Z",sequence:"\\u001a",description:"Suspender processo"},{label:"Ctrl+L",sequence:"\\u000c",description:"Limpar tela"},{label:"Ctrl+A",sequence:"\\u0001",description:"Inicio da linha"},{label:"Ctrl+E",sequence:"\\u0005",description:"Fim da linha"},{label:"Ctrl+U",sequence:"\\u0015",description:"Apagar linha"},{label:"Ctrl+W",sequence:"\\u0017",description:"Apagar palavra"},{label:"Ctrl+R",sequence:"\\u0012",description:"Buscar historico"},{label:"Ctrl+V",sequence:"\\u0016",description:"Literal / quote"},{label:"Shift+Tab",sequence:"\\x1b[Z",description:"Autocompletar reverso"},{label:"Seta Cima",sequence:"\\x1b[A",description:"Historico anterior"},{label:"Seta Baixo",sequence:"\\x1b[B",description:"Historico proximo"}];function eqe({send:t}){const{shortcuts:e,setShortcuts:n,addShortcut:r,updateShortcut:i,removeShortcut:a,reorderShortcuts:s}=Zc(),[o,c]=C.useState(null),[u,d]=C.useState(!1),[h,m]=C.useState(!1),[g,O]=C.useState(""),[b,w]=C.useState(""),[v,S]=C.useState(""),[k,Q]=C.useState(!1),[T,_]=C.useState(2),[N,$]=C.useState(20);C.useEffect(()=>{(async()=>{try{const Y=(await t("settings.list",{category:"mobile"})).find(F=>F.key===VV);if(Y){const F=JSON.parse(Y.value);n(F)}}catch{}})()},[t,n]);const R=C.useCallback(async L=>{m(!0);try{await t("settings.set",{key:VV,value:JSON.stringify(L),category:"mobile",label:"Atalhos Mobile"})}finally{m(!1)}},[t]),A=async(L,Y)=>{i(L,{enabled:Y});const F=Zc.getState().shortcuts.map(Z=>Z.id===L?{...Z,enabled:Y}:Z);await R(F)},M=()=>{O(""),w(""),S(""),Q(!1),_(2),$(20)},I=L=>{const Y=zte[L];Y&&(O(Y.label),w(Y.description),S(Y.sequence))},V=L=>{var Y,F;c(L.id),d(!1),O(L.label),w(L.description),S(L.sequence),Q(!!L.repeat),_(((Y=L.repeat)==null?void 0:Y.count)??2),$(((F=L.repeat)==null?void 0:F.delayMs)??20)},D=async()=>{if(!o||!g.trim()||!v.trim())return;const L={label:g.trim(),description:b.trim(),sequence:v.trim(),repeat:k?{count:T,delayMs:N}:void 0};i(o,L);const Y=Zc.getState().shortcuts;await R(Y),c(null),M()},X=async()=>{if(!g.trim()||!v.trim())return;const L={id:JXe(),label:g.trim(),description:b.trim(),sequence:v.trim(),enabled:!0,repeat:k?{count:T,delayMs:N}:void 0};r(L);const Y=Zc.getState().shortcuts;await R(Y),d(!1),M()},q=async L=>{a(L);const Y=Zc.getState().shortcuts;await R(Y)},z=async(L,Y)=>{const F=Y==="up"?L-1:L+1;if(F<0||F>=e.length)return;s(L,F);const Z=Zc.getState().shortcuts;await R(Z)},j=async()=>{n(Pb),await R(Pb),c(null),d(!1),M()},W=g.trim()&&v.trim();return l.jsxs("div",{className:"space-y-5 p-5",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-semibold text-[var(--ui-text)]",children:"Atalhos do Teclado Mobile"}),l.jsx("p",{className:"mt-1 text-xs text-[var(--ui-text-muted)]",children:"Configure os atalhos que aparecem no botao de teclado ao usar o terminal no celular. Arraste para reordenar, desative ou crie novos atalhos."})]}),l.jsxs("div",{className:"space-y-2",children:[e.map((L,Y)=>l.jsx("div",{children:o===L.id?l.jsxs("div",{className:"rounded-xl border border-blue-500/50 bg-blue-500/5 p-4 space-y-3",children:[l.jsx(BV,{draftLabel:g,draftDescription:b,draftSequence:v,draftRepeat:k,draftRepeatCount:T,draftRepeatDelay:N,onLabelChange:O,onDescriptionChange:w,onSequenceChange:S,onRepeatChange:Q,onRepeatCountChange:_,onRepeatDelayChange:$,onPresetSelect:I}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{type:"button",onClick:D,disabled:!W,className:"rounded-lg bg-blue-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-blue-700 disabled:opacity-40",children:"Salvar"}),l.jsx("button",{type:"button",onClick:()=>{c(null),M()},className:"rounded-lg border border-[var(--ui-border)] px-3 py-1.5 text-xs font-medium text-[var(--ui-text-muted)] transition-colors hover:bg-[var(--ui-surface-hover)]",children:"Cancelar"})]})]}):l.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-[var(--ui-border)] bg-[var(--ui-bg)] px-4 py-3 transition-colors hover:border-[var(--ui-text-muted)]",children:[l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.jsx("button",{type:"button",onClick:()=>z(Y,"up"),disabled:Y===0,className:"text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] disabled:opacity-20","aria-label":"Mover para cima",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3 w-3",children:l.jsx("path",{d:"M8 4.5l4 5H4l4-5z"})})}),l.jsx("button",{type:"button",onClick:()=>z(Y,"down"),disabled:Y===e.length-1,className:"text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] disabled:opacity-20","aria-label":"Mover para baixo",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3 w-3",children:l.jsx("path",{d:"M8 11.5l4-5H4l4 5z"})})})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-semibold text-[var(--ui-text)]",children:L.label}),l.jsx("code",{className:"rounded bg-[var(--ui-surface-hover)] px-1.5 py-0.5 text-[10px] text-[var(--ui-text-muted)]",children:L.sequence}),L.repeat&&l.jsxs("span",{className:"text-[10px] text-[var(--ui-text-muted)]",children:["x",L.repeat.count]})]}),l.jsx("p",{className:"text-xs text-[var(--ui-text-muted)] truncate",children:L.description})]}),l.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[l.jsx(Id,{checked:L.enabled,onChange:F=>A(L.id,F)}),l.jsx("button",{type:"button",onClick:()=>V(L),className:"rounded p-1.5 text-[var(--ui-text-muted)] transition-colors hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-text)]","aria-label":"Editar atalho",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3.5 w-3.5",children:l.jsx("path",{d:"M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L3.463 11.098a.25.25 0 00-.064.108l-.558 1.953 1.953-.558a.25.25 0 00.108-.064l8.61-8.61a.25.25 0 000-.354l-1.086-1.086z"})})}),l.jsx("button",{type:"button",onClick:()=>q(L.id),className:"rounded p-1.5 text-[var(--ui-text-muted)] transition-colors hover:bg-red-500/10 hover:text-red-400","aria-label":"Remover atalho",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3.5 w-3.5",children:l.jsx("path",{d:"M6.5 1.75a.25.25 0 01.25-.25h2.5a.25.25 0 01.25.25V3h-3V1.75zM11 3V1.75A1.75 1.75 0 009.25 0h-2.5A1.75 1.75 0 005 1.75V3H2.75a.75.75 0 000 1.5h.928l.856 8.576A1.75 1.75 0 006.283 14.5h3.434a1.75 1.75 0 001.749-1.424l.856-8.576h.928a.75.75 0 000-1.5H11zm-5.22 1.5l.806 8.058a.25.25 0 00.249.192h3.434a.25.25 0 00.25-.192L11.32 4.5H4.78z"})})})]})]})},L.id)),e.length===0&&l.jsx("div",{className:"rounded-xl border border-dashed border-[var(--ui-border)] py-8 text-center",children:l.jsx("p",{className:"text-xs text-[var(--ui-text-muted)]",children:"Nenhum atalho configurado"})})]}),u&&l.jsxs("div",{className:"rounded-xl border border-emerald-500/50 bg-emerald-500/5 p-4 space-y-3",children:[l.jsx("p",{className:"text-xs font-semibold text-emerald-400 uppercase tracking-wider",children:"Novo Atalho"}),l.jsx(BV,{draftLabel:g,draftDescription:b,draftSequence:v,draftRepeat:k,draftRepeatCount:T,draftRepeatDelay:N,onLabelChange:O,onDescriptionChange:w,onSequenceChange:S,onRepeatChange:Q,onRepeatCountChange:_,onRepeatDelayChange:$,onPresetSelect:I}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{type:"button",onClick:X,disabled:!W,className:"rounded-lg bg-emerald-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-emerald-700 disabled:opacity-40",children:"Adicionar"}),l.jsx("button",{type:"button",onClick:()=>{d(!1),M()},className:"rounded-lg border border-[var(--ui-border)] px-3 py-1.5 text-xs font-medium text-[var(--ui-text-muted)] transition-colors hover:bg-[var(--ui-surface-hover)]",children:"Cancelar"})]})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[!u&&!o&&l.jsxs("button",{type:"button",onClick:()=>{d(!0),M()},className:"flex items-center gap-1.5 rounded-lg bg-blue-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-blue-700",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3.5 w-3.5",children:l.jsx("path",{d:"M8 2a.75.75 0 01.75.75v4.5h4.5a.75.75 0 010 1.5h-4.5v4.5a.75.75 0 01-1.5 0v-4.5h-4.5a.75.75 0 010-1.5h4.5v-4.5A.75.75 0 018 2z"})}),"Novo Atalho"]}),l.jsx("button",{type:"button",onClick:j,className:"rounded-lg border border-[var(--ui-border)] px-3 py-1.5 text-xs font-medium text-[var(--ui-text-muted)] transition-colors hover:bg-[var(--ui-surface-hover)]",children:"Restaurar Padrao"}),h&&l.jsx("span",{className:"text-[10px] text-[var(--ui-text-muted)]",children:"Salvando..."})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--ui-border)] bg-[var(--ui-surface)] p-4",children:[l.jsx("p",{className:"text-xs font-medium text-[var(--ui-text)] mb-2",children:"Sequencias de Escape"}),l.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-[11px] text-[var(--ui-text-muted)]",children:[l.jsxs("span",{children:[l.jsx("code",{className:"text-[var(--ui-text)]",children:"\\\\t"})," — Tab"]}),l.jsxs("span",{children:[l.jsx("code",{className:"text-[var(--ui-text)]",children:"\\\\n"})," — Nova linha"]}),l.jsxs("span",{children:[l.jsx("code",{className:"text-[var(--ui-text)]",children:"\\\\r"})," — Enter"]}),l.jsxs("span",{children:[l.jsx("code",{className:"text-[var(--ui-text)]",children:"\\\\e"})," — Escape"]}),l.jsxs("span",{children:[l.jsx("code",{className:"text-[var(--ui-text)]",children:"\\\\u0003"})," — Ctrl+C"]}),l.jsxs("span",{children:[l.jsx("code",{className:"text-[var(--ui-text)]",children:"\\\\x1b[A"})," — Seta Cima"]})]})]})]})}function BV({draftLabel:t,draftDescription:e,draftSequence:n,draftRepeat:r,draftRepeatCount:i,draftRepeatDelay:a,onLabelChange:s,onDescriptionChange:o,onSequenceChange:c,onRepeatChange:u,onRepeatCountChange:d,onRepeatDelayChange:h,onPresetSelect:m}){return l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[11px] font-medium text-[var(--ui-text-muted)]",children:"Preset (opcional)"}),l.jsxs("select",{className:"w-full rounded-lg border border-[var(--ui-border)] bg-[var(--ui-bg)] px-3 py-1.5 text-xs text-[var(--ui-text)]",value:"",onChange:g=>{const O=parseInt(g.target.value,10);isNaN(O)||m(O)},children:[l.jsx("option",{value:"",children:"Selecionar preset..."}),zte.map((g,O)=>l.jsxs("option",{value:O,children:[g.label," — ",g.description]},g.sequence))]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[11px] font-medium text-[var(--ui-text-muted)]",children:"Label *"}),l.jsx("input",{type:"text",value:t,onChange:g=>s(g.target.value),placeholder:"Ctrl+C",className:"w-full rounded-lg border border-[var(--ui-border)] bg-[var(--ui-bg)] px-3 py-1.5 text-xs text-[var(--ui-text)] placeholder:text-[var(--ui-text-muted)]"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[11px] font-medium text-[var(--ui-text-muted)]",children:"Sequencia *"}),l.jsx("input",{type:"text",value:n,onChange:g=>c(g.target.value),placeholder:"\\\\u0003",className:"w-full rounded-lg border border-[var(--ui-border)] bg-[var(--ui-bg)] px-3 py-1.5 text-xs font-mono text-[var(--ui-text)] placeholder:text-[var(--ui-text-muted)]"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[11px] font-medium text-[var(--ui-text-muted)]",children:"Descricao"}),l.jsx("input",{type:"text",value:e,onChange:g=>o(g.target.value),placeholder:"Interromper processo",className:"w-full rounded-lg border border-[var(--ui-border)] bg-[var(--ui-bg)] px-3 py-1.5 text-xs text-[var(--ui-text)] placeholder:text-[var(--ui-text-muted)]"})]}),l.jsx("div",{className:"flex items-center gap-3",children:l.jsx(Id,{checked:r,onChange:u,label:"Repetir",description:"Enviar a sequencia multiplas vezes"})}),r&&l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[11px] font-medium text-[var(--ui-text-muted)]",children:"Vezes"}),l.jsx("input",{type:"number",min:2,max:10,value:i,onChange:g=>d(parseInt(g.target.value,10)||2),className:"w-full rounded-lg border border-[var(--ui-border)] bg-[var(--ui-bg)] px-3 py-1.5 text-xs text-[var(--ui-text)]"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[11px] font-medium text-[var(--ui-text-muted)]",children:"Delay (ms)"}),l.jsx("input",{type:"number",min:0,max:1e3,value:a,onChange:g=>h(parseInt(g.target.value,10)||0),className:"w-full rounded-lg border border-[var(--ui-border)] bg-[var(--ui-bg)] px-3 py-1.5 text-xs text-[var(--ui-text)]"})]})]})]})}function tqe({onClose:t,send:e,onPushEvent:n,onRelayDisconnect:r}){const{t:i}=Mt(),[a,s]=C.useState("cli_tools"),{isCompact:o}=Xm(),{settings:c,installedClis:u,fetchSettings:d,setSetting:h,getSecret:m,detectClis:g}=HIe({send:e}),O=[{key:"cli_tools",label:i("settings.tabs.cliTools")},{key:"general",label:i("settings.tabs.general")},{key:"api_keys",label:i("settings.tabs.apiKeys")},{key:"providers",label:i("settings.tabs.providers")},{key:"tunnel",label:i("settings.tabs.tunnel")},{key:"templates",label:i("settings.tabs.templates","Templates")},{key:"skills_store",label:i("settings.tabs.skillsStore","Documentacao")},{key:"shortcuts",label:i("settings.tabs.shortcuts","Atalhos")},{key:"advanced",label:i("settings.tabs.advanced")}];return C.useEffect(()=>{d().catch(()=>{})},[d]),l.jsxs("div",{className:"flex h-full flex-col overflow-auto bg-[var(--ui-bg)]",children:[l.jsx("div",{className:"border-b border-[var(--ui-border)]",children:l.jsxs("div",{className:`mx-auto flex w-full max-w-5xl items-center gap-3 ${o?"px-3 py-2":"px-6 py-3"}`,children:[l.jsxs("button",{onClick:t,className:"flex items-center gap-1 text-xs text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] transition-colors",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3.5 w-3.5",children:l.jsx("path",{fillRule:"evenodd",d:"M7.78 12.53a.75.75 0 01-1.06 0L2.47 8.28a.75.75 0 010-1.06l4.25-4.25a.75.75 0 011.06 1.06L4.56 7.25H13a.75.75 0 010 1.5H4.56l3.22 3.22a.75.75 0 010 1.06z"})}),"Voltar"]}),l.jsx("h2",{className:"text-sm font-semibold text-[var(--ui-text)]",children:i("settings.title")})]})}),l.jsx("div",{className:"border-b border-[var(--ui-border)] bg-[var(--ui-bg)]",children:l.jsx("div",{className:`touch-scroll-x mx-auto flex w-full max-w-5xl overflow-x-auto ${o?"px-3":"px-6"}`,children:O.map(b=>l.jsx("button",{onClick:()=>s(b.key),className:`shrink-0 whitespace-nowrap border-b-2 px-3 py-2 text-xs font-medium transition-colors ${a===b.key?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]"}`,children:b.label},b.key))})}),l.jsx("div",{className:"flex-1 overflow-auto",children:l.jsxs("div",{className:"mx-auto w-full max-w-5xl",children:[a==="cli_tools"&&l.jsx(aXe,{send:e}),a==="general"&&l.jsx(U9e,{settings:c,setSetting:h,send:e,onPushEvent:n,onRelayDisconnect:r}),a==="api_keys"&&l.jsx(Y9e,{settings:c,setSetting:h,getSecret:m}),a==="providers"&&l.jsx(G9e,{installedClis:u,detectClis:g,send:e}),a==="tunnel"&&l.jsx(J9e,{send:e,onPushEvent:n}),a==="templates"&&l.jsx(bXe,{send:e}),a==="skills_store"&&l.jsx(KXe,{send:e}),a==="shortcuts"&&l.jsx(eqe,{send:e}),a==="advanced"&&l.jsx(H9e,{settings:c})]})})]})}let nqe=0;function rqe(){return`req-${++nqe}-${Date.now()}`}function iqe(t,e,n,r,i){const a=C.useRef(null),s=C.useRef(new Map),o=C.useRef(t);o.current=t;const c=C.useRef(e);c.current=e;const u=C.useRef(n);u.current=n;const d=C.useRef(i);d.current=i;const h=C.useRef(void 0),m=C.useRef(!1),g=C.useRef(0);return C.useEffect(()=>{let b=!1;function w(){if(b)return;const v=window.__IMPACTUS_CONFIG__,S=v!==void 0?v==null?void 0:v.relayUrl:"https://impactus-relay.replit.app";let k;if(S&&r){const T=S.startsWith("https")?"wss:":"ws:",_=S.replace(/^https?:\/\//,"");k=`${T}//${_}/ws/client/${r}`}else{if(S&&!r)return;{const T=window.electronBridge;if(T!=null&&T.serverPort)k=`ws://localhost:${T.serverPort}/ws`;else{k=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;const N=new URLSearchParams(window.location.search).get("token");N&&(k+=`?token=${encodeURIComponent(N)}`)}}}const Q=new WebSocket(k);a.current=Q,Q.onopen=()=>{var T,_;g.current=0,m.current?(T=c.current)==null||T.call(c):(_=u.current)==null||_.call(u),m.current=!0},Q.onmessage=T=>{if(T.data instanceof Blob){T.data.arrayBuffer().then(N=>{const $=new DataView(N);if($.getUint8(0)===1){const A=new TextDecoder,M=A.decode(new Uint8Array(N,1,36)),I=A.decode(new Uint8Array(N,37,36)),V=$.getUint32(73,!1),D=$.getUint16(77,!1),X=$.getUint16(79,!1),q=$.getInt16(81,!1),z=$.getInt16(83,!1),j=$.getUint16(85,!1)/100,W=new Uint8Array(N,87);o.current("browser.frame.binary",{sessionId:M,tabId:I,frameNumber:V,metadata:{deviceWidth:D,deviceHeight:X,scrollOffsetX:q,scrollOffsetY:z,pageScaleFactor:j},blob:new Blob([W],{type:"image/jpeg"})})}});return}let _;try{_=JSON.parse(T.data)}catch{return}if("type"in _&&_.type==="push"){const N=_;o.current(N.channel,N.data)}else{const N=_,$=s.current.get(N.id);$&&(s.current.delete(N.id),$(N))}},Q.onclose=()=>{var T;a.current=null;for(const[_,N]of s.current)N({id:_,error:{message:"Connection lost"}});if(s.current.clear(),!b){if(!!S&&!!r&&(g.current++,g.current>=3)){(T=d.current)==null||T.call(d);return}h.current=setTimeout(w,2e3)}},Q.onerror=()=>{}}return w(),()=>{var v;b=!0,clearTimeout(h.current),(v=a.current)==null||v.close(),a.current=null}},[r]),{send:C.useCallback((b,w,v)=>new Promise((S,k)=>{const Q=a.current;if(!Q||Q.readyState!==WebSocket.OPEN){k(new Error("WebSocket not connected"));return}const T=rqe(),_={id:T,method:b,params:w};s.current.set(T,$=>{$.error?k(new Error($.error.message)):S($.result)}),Q.send(JSON.stringify(_)),setTimeout(()=>{s.current.has(T)&&(s.current.delete(T),k(new Error(`Request ${b} timed out`)))},v??(b==="workspace.launch"?6e4:1e4))}),[])}}const aqe={undo:{keys:["Mod+Z"],context:"workspace",label:"Undo"},redo:{keys:["Mod+Shift+Z"],context:"workspace",label:"Redo"},toggleTopologyView:{keys:["Mod+G"],context:"swarm",label:"Toggle Topology View"},commandPalette:{keys:["Mod+K"],context:"global",label:"Command Palette"}},sqe=Ji(t=>({shortcuts:{...aqe},register:(e,n)=>t(r=>({shortcuts:{...r.shortcuts,[e]:n}})),unregister:e=>t(n=>{const r={...n.shortcuts};return delete r[e],{shortcuts:r}}),updateKeys:(e,n)=>t(r=>{const i=r.shortcuts[e];return i?{shortcuts:{...r.shortcuts,[e]:{...i,keys:n}}}:r}),setHandler:(e,n)=>t(r=>{const i=r.shortcuts[e];return i?{shortcuts:{...r.shortcuts,[e]:{...i,handler:n}}}:r})})),ZV=Ji((t,e)=>({undoStack:[],redoStack:[],pushSnapshot:(n,r)=>{const i={terminalPositions:n.terminalPositions,swarmTopologyEdits:n.swarmTopologyEdits,activeWorktreeId:n.activeWorktreeId,timestamp:n.timestamp??Date.now(),label:r??n.label??"change"};t(a=>({undoStack:[...a.undoStack.slice(-49),i],redoStack:[]}))},undo:()=>{const n=e();if(n.undoStack.length===0)return;const r=n.undoStack[n.undoStack.length-1];return t({undoStack:n.undoStack.slice(0,-1),redoStack:[...n.redoStack.slice(-49),r]}),r},redo:()=>{const n=e();if(n.redoStack.length===0)return;const r=n.redoStack[n.redoStack.length-1];return t({redoStack:n.redoStack.slice(0,-1),undoStack:[...n.undoStack.slice(-49),r]}),r},clear:()=>t({undoStack:[],redoStack:[]})})),oqe=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform);function lqe(t){const e=[];(oqe?t.metaKey:t.ctrlKey)&&e.push("Mod"),t.shiftKey&&e.push("Shift"),t.altKey&&e.push("Alt");const r=t.key.length===1?t.key.toUpperCase():t.key;return r!=="Shift"&&r!=="Control"&&r!=="Meta"&&r!=="Alt"&&e.push(r),e.join("+")}function cqe(t){return t.split("+").map(e=>e.length===1?e.toUpperCase():e).join("+")}function uqe(t={}){C.useEffect(()=>{const e=n=>{const r=n.target;if(!!r&&(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable))return;const a=lqe(n),{shortcuts:s}=sqe.getState();for(const[o,c]of Object.entries(s)){if(t.context&&c.context!==t.context&&c.context!=="global"||!c.keys.some(h=>cqe(h)===a))continue;const d=c.handler??dqe(o);if(d){n.preventDefault(),d();return}}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t.context])}function dqe(t){switch(t){case"undo":return()=>{ZV.getState().undo()};case"redo":return()=>{ZV.getState().redo()};case"toggleTopologyView":return()=>{var a;const{settings:e,updateSetting:n}=ga.getState(),i=(((a=e.find(s=>s.key==="swarm.view_mode"))==null?void 0:a.value)??"grid")==="topology"?"grid":"topology";n("swarm.view_mode",i)};case"commandPalette":return;default:return}}function fN(t){const e=lB(t);return Rp[e]??Rp.dark}const Dte=oB(),hN=fN(Dte);pp(hN);const fqe=Ji((t,e)=>(window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>{const{themeId:r}=e();if(r!=="system")return;const i=fN("system");pp(i),t({currentTheme:i,isDark:i.isDark})}),{themeId:Dte,currentTheme:hN,isDark:hN.isDark,setTheme:r=>{const i=fN(r);pp(i),localStorage.setItem("impactus-theme",r),t({themeId:r,currentTheme:i,isDark:i.isDark})},toggle:()=>{const r=e().isDark?"light":"dark",i=Rp[r];pp(i),localStorage.setItem("impactus-theme",r),t({themeId:r,currentTheme:i,isDark:i.isDark})}})),hqe=()=>fqe(),_O="swarm_relayCode";function pqe(){hqe(),uqe();const{t}=Mt(),[e,n]=C.useState(!1),[r,i]=C.useState(null),[a,s]=C.useState({}),[o,c]=C.useState(!1),u=window.__IMPACTUS_CONFIG__,d=u!==void 0?u==null?void 0:u.relayUrl:"https://impactus-relay.replit.app",h=!!d,[m,g]=C.useState(()=>{if(!d)return null;try{return localStorage.getItem(_O)}catch{return null}}),O=C.useCallback(J=>{try{localStorage.setItem(_O,J)}catch{}g(J)},[]),b=lc(J=>J.add),w=a1(J=>J.addNotification),v=C.useRef(new Set),{workspaces:S,activeWorkspaceId:k,view:Q,setView:T,goHome:_,setWorkspaces:N,addWorkspace:$,removeWorkspace:R,setActiveWorkspace:A,setRunning:M}=Vt(),I=C.useCallback((J,me)=>{for(const ve of v.current)ve(J,me);if(J==="workspace.status"){const ve=me;M(ve.id,ve.state==="running")}else if(J==="area.status"){const ve=me,{setAreaRunning:be}=Vt.getState();be(ve.id,ve.state==="running")}else if(J==="area.updated"){const ve=me;ve.workspaceId&&j.current("workspace.get",{id:ve.workspaceId}).then(be=>{const{updateWorkspace:ke}=Vt.getState();ke(be)}).catch(()=>{})}else if(J==="swarm.completed")b(t("app.swarmCompleted"),"success");else if(J==="swarm.escalation")b(me.message,"info");else if(J==="task.completed"){const ve=me;b(t("app.taskCompleted",{title:ve.title??ve.id}),"success")}else if(J==="swarm.agent.status"){const ve=me;ve.status==="error"&&b(t("app.agentError",{name:ve.name}),"error")}else J==="notification.new"&&w(me)},[M,b,w,t]),V=C.useCallback(async()=>{try{await new Promise(ke=>setTimeout(ke,500));const J=await j.current("workspace.list",{});N(J);for(const ke of J)M(ke.id,ke.isRunning===!0);const{activeWorkspaceId:me,view:ve}=Vt.getState(),be=J.filter(ke=>ke.isRunning);if(me&&ve==="workspace"&&J.some(ke=>ke.id===me))ne.current.add(me);else if(be.length>0){const ke=be[0];A(ke.id),ne.current.add(ke.id)}try{const ke=await j.current("terminal.list",{}),Je=new Set((ke.terminals||[]).map(ot=>ot.id));await new Promise(ot=>setTimeout(ot,200)),window.dispatchEvent(new CustomEvent("terminal-reconnect",{detail:{aliveIds:Je}}))}catch{}b(t("app.connectionRestored"),"success")}catch{}},[N,M,A,b,t]),D=C.useCallback(async()=>{try{const J=await j.current("workspace.list",{});N(J),c(!0);for(const ke of J)ke.isRunning&&M(ke.id,!0);const{activeWorkspaceId:me,view:ve}=Vt.getState(),be=J.filter(ke=>ke.isRunning);if(me&&ve==="workspace"&&J.some(ke=>ke.id===me))ne.current.add(me);else if(be.length>0){const ke=be[0];A(ke.id),ne.current.add(ke.id)}try{const ke=await j.current("terminal.list",{}),Je=new Set((ke.terminals||[]).map(ot=>ot.id));Je.size>0&&(await new Promise(ot=>setTimeout(ot,500)),window.dispatchEvent(new CustomEvent("terminal-reconnect",{detail:{aliveIds:Je}})))}catch{}}catch{}},[N,M,A]),X=C.useCallback(()=>{try{localStorage.removeItem(_O)}catch{}g(null),c(!1),b(t("app.relayDisconnected",{defaultValue:"Relay disconnected — enter new code"}),"error")},[b,t]),q=C.useCallback(()=>{try{localStorage.removeItem(_O)}catch{}g(null),c(!1)},[]),{send:z}=iqe(I,V,D,m,X),j=C.useRef(z);j.current=z;const W=C.useCallback(J=>(v.current.add(J),()=>{v.current.delete(J)}),[]),L=C.useCallback(async(J,me)=>{try{const ve=await z("workspace.create",{name:J.name,color:J.color,rootDirectory:J.rootDirectory,initGit:J.initGit??!0,defaultCommand:J.defaultCommand,terminalCount:J.terminalCount,terminals:J.terminals.map(be=>{var ke;return{label:be.label,directory:be.directory,command:be.command,commandSequence:((ke=be.commandSequence)==null?void 0:ke.filter(Je=>{var ot;return Je.command.trim()||((ot=Je.waitFor)==null?void 0:ot.trim())}))||[],env:{}}})});$(ve),n(!1),b(t("app.workspaceCreated",{name:ve.name}),"success"),me&&A(ve.id)}catch(ve){console.error("Failed to create workspace:",ve),b(t("app.workspaceCreateError"),"error")}},[z,$,A,b,t]),Y=C.useCallback(J=>{A(J)},[A]),F=C.useCallback(async J=>{try{await z("workspace.stop",{id:J}),M(J,!1),ne.current.delete(J),b(t("app.workspaceStopped"),"info")}catch(me){console.error("Failed to stop workspace:",me),b(t("app.workspaceStopError"),"error")}},[z,M,b,t]),Z=C.useCallback(async J=>{try{await z("workspace.stop",{id:J}).catch(()=>{}),await z("workspace.delete",{id:J}),R(J),M(J,!1),ne.current.delete(J),b(t("app.workspaceDeleted"),"info")}catch(me){console.error("Failed to delete workspace:",me),b(t("app.workspaceDeleteError"),"error")}},[z,R,M,b,t]),G=C.useCallback(async J=>{const me=S.find(ve=>ve.id===J);if(me)try{const ve=await z("workspace.create",{name:`${me.name} (copy)`,color:me.color,rootDirectory:me.rootDirectory,defaultCommand:me.defaultCommand,terminalCount:me.terminalCount,terminals:me.terminals.map(be=>({label:be.label,directory:be.directory,command:be.command,commandSequence:be.commandSequence||[],env:{}}))});$(ve),b(t("app.workspaceDuplicated",{name:ve.name}),"success")}catch(ve){console.error("Failed to duplicate workspace:",ve),b(t("app.workspaceDuplicateError"),"error")}},[S,z,$,b,t]),re=C.useCallback(async J=>{N(J);try{await z("workspace.reorder",{ids:J.map(me=>me.id)})}catch(me){console.error("Failed to persist workspace order:",me)}},[z,N]),ae=C.useCallback(async J=>{for(const me of J){const ve=await z("workspace.create",{name:me.name,color:me.color,rootDirectory:me.rootDirectory,defaultCommand:me.defaultCommand,terminalCount:me.terminalCount,terminals:me.terminals.map(be=>({label:be.label,directory:be.directory,command:be.command,commandSequence:be.commandSequence||[],env:{}}))});$(ve)}},[z,$]),se=C.useCallback(J=>{const me=S.find(ve=>ve.id===J);me&&(i(me),n(!0))},[S]);C.useCallback(async(J,me)=>{if(r)try{const ve=await z("workspace.update",{id:r.id,name:J.name,color:J.color,rootDirectory:J.rootDirectory,initGit:J.initGit??!0,defaultCommand:J.defaultCommand,terminalCount:J.terminalCount,layout:"auto",terminals:J.terminals.map(ke=>{var Je;return{label:ke.label,directory:ke.directory,command:ke.command,commandSequence:((Je=ke.commandSequence)==null?void 0:Je.filter(ot=>ot.command.trim()))||[],env:{}}})}),{updateWorkspace:be}=Vt.getState();be(ve),n(!1),i(null)}catch(ve){console.error("Failed to update workspace:",ve)}},[z,r]);const te=S.find(J=>J.id===k),ne=C.useRef(new Set);k&&Q==="workspace"&&ne.current.add(k);const oe=C.useMemo(()=>new Set(S.map(J=>J.id)),[S]);for(const J of ne.current)oe.has(J)||ne.current.delete(J);const K=C.useMemo(()=>S.filter(J=>ne.current.has(J.id)),[S,k]),pe=typeof window<"u"&&!!window.electronBridge;return h&&!o?m?l.jsx("div",{className:"flex h-screen w-screen flex-col items-center justify-center gap-4 bg-[var(--ui-bg)] text-[var(--ui-text)]",children:l.jsx(xt,{className:"text-2xl opacity-60",children:"Verifying connection..."})}):l.jsx(Nie,{onSubmit:O,relayUrl:d}):l.jsxs("div",{className:"flex h-screen w-screen bg-[var(--ui-bg)] text-[var(--ui-text)]",children:[l.jsx(rae,{isElectron:pe,onCreateWorkspace:()=>{i(null),n(!0)},onEditWorkspace:se,onDuplicateWorkspace:G,onDeleteWorkspace:Z,onStopWorkspace:F,onReorderWorkspaces:re,onOpenSettings:()=>T("settings")}),l.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[pe&&l.jsx("div",{className:"drag-region h-[38px] shrink-0 border-b border-[var(--ui-border)]"}),!e&&(Q==="home"||!te)&&l.jsx("div",{className:"flex shrink-0 items-center justify-end gap-3 px-4 py-2",children:l.jsx(rH,{})}),l.jsxs("div",{className:"min-h-0 flex-1",children:[e&&l.jsx("div",{className:"h-full",children:l.jsx(YIe,{send:z,mode:r?"edit":"create",initialWorkspace:r??void 0,onSubmit:L,onCreated:()=>{n(!1),i(null)},onRelaunch:J=>{s(me=>({...me,[J.id]:(me[J.id]??0)+1}))},onStackApplied:()=>{n(!1),i(null)},onCancel:()=>{n(!1),i(null)}})}),l.jsx("div",{className:"h-full",style:{display:!e&&(Q==="home"||!te)?void 0:"none"},children:l.jsx(aae,{onCreateWorkspace:()=>{i(null),n(!0)},onLaunchWorkspace:Y,onStopWorkspace:F,onDeleteWorkspace:Z,onImportWorkspaces:ae})}),K.map(J=>l.jsx("div",{className:"h-full",style:{display:!e&&Q==="workspace"&&J.id===k?void 0:"none"},children:l.jsx(RIe,{workspace:J,send:z,onPushEvent:W,onOpenWorkspaceSettings:()=>se(J.id)},`${J.id}:${a[J.id]??0}`)},J.id)),Q==="settings"&&l.jsx("div",{className:"h-full",children:l.jsx(tqe,{onClose:()=>_(),send:z,onPushEvent:W,onRelayDisconnect:h?q:void 0})})]})]}),l.jsx(GIe,{})]})}Zre.createRoot(document.getElementById("root")).render(l.jsx(pqe,{}));
2077
+ # Server key: `+t.name,language:"text"}]}function UXe({mcp:t,onClose:e,onEdit:n}){var d;const r=C.useMemo(()=>WXe(t),[t]),[i,a]=C.useState(((d=r[0])==null?void 0:d.cli)??"claude"),[s,o]=C.useState(!1),c=r.find(h=>h.cli===i)??r[0];function u(){c&&(navigator.clipboard.writeText(c.content).catch(()=>{}),o(!0),setTimeout(()=>o(!1),1500))}return l.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/50",onClick:e,children:l.jsxs("div",{className:"relative flex max-h-[90vh] w-full max-w-3xl flex-col rounded-lg border border-[var(--ui-border)] bg-[var(--ui-surface)] shadow-2xl",onClick:h=>h.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--ui-border)] px-5 py-3",children:[l.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4 text-[var(--ui-accent)]",children:l.jsx("path",{d:"M3 4a1 1 0 011-1h12a1 1 0 011 1v12a1 1 0 01-1 1H4a1 1 0 01-1-1V4zm2 1v10h10V5H5z"})}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--ui-text)]",children:t.displayName}),l.jsx("p",{className:"truncate text-[10px] font-mono text-[var(--ui-text-muted)]",children:t.name})]}),l.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[n&&l.jsx("button",{onClick:()=>n(t),className:"rounded border border-[var(--ui-border)] px-2 py-1 text-[10px] text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]",children:"Editar"}),l.jsx("button",{onClick:e,className:"rounded p-1 text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] hover:bg-[var(--ui-bg)]",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-4 w-4",children:l.jsx("path",{d:"M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"})})})]})]}),l.jsxs("div",{className:"space-y-4 overflow-y-auto px-5 py-4",children:[l.jsx("div",{className:"rounded border border-[var(--ui-border)] overflow-hidden",children:l.jsx("table",{className:"w-full text-xs",children:l.jsxs("tbody",{children:[l.jsxs("tr",{className:"border-b border-[var(--ui-border)]",children:[l.jsx("td",{className:"w-28 bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Transporte"}),l.jsx("td",{className:"px-3 py-2 font-mono text-[var(--ui-text)]",children:t.transport})]}),t.description&&l.jsxs("tr",{className:"border-b border-[var(--ui-border)]",children:[l.jsx("td",{className:"bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Descricao"}),l.jsx("td",{className:"px-3 py-2 text-[var(--ui-text)]",children:t.description})]}),t.transport==="stdio"?l.jsxs(l.Fragment,{children:[l.jsxs("tr",{className:"border-b border-[var(--ui-border)]",children:[l.jsx("td",{className:"bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Comando"}),l.jsx("td",{className:"px-3 py-2 font-mono text-[var(--ui-text)]",children:t.command||"--"})]}),l.jsxs("tr",{className:"border-b border-[var(--ui-border)]",children:[l.jsx("td",{className:"bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Args"}),l.jsx("td",{className:"px-3 py-2 font-mono text-[var(--ui-text)]",children:t.args&&t.args.length>0?t.args.join(" "):l.jsx("span",{className:"italic text-[var(--ui-text-muted)]",children:"(nenhum)"})})]})]}):l.jsxs("tr",{className:"border-b border-[var(--ui-border)]",children:[l.jsx("td",{className:"bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"URL"}),l.jsx("td",{className:"px-3 py-2 font-mono text-[var(--ui-text)] break-all",children:t.url||"--"})]}),t.timeoutMs&&l.jsxs("tr",{className:"border-b border-[var(--ui-border)]",children:[l.jsx("td",{className:"bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Timeout"}),l.jsxs("td",{className:"px-3 py-2 text-[var(--ui-text)]",children:[t.timeoutMs," ms"]})]}),t.tags&&t.tags.length>0&&l.jsxs("tr",{children:[l.jsx("td",{className:"bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Tags"}),l.jsx("td",{className:"px-3 py-2",children:l.jsx("div",{className:"flex flex-wrap gap-1",children:t.tags.map(h=>l.jsx("span",{className:"rounded-full border border-[var(--ui-border)] px-1.5 py-0.5 text-[10px] text-[var(--ui-text-muted)]",children:h},h))})})]})]})})}),l.jsxs("div",{children:[l.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[l.jsx("label",{className:"block text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:"Preview por CLI"}),l.jsx("button",{onClick:u,className:"rounded border border-[var(--ui-border)] px-2 py-0.5 text-[10px] text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]",children:s?"Copiado!":"Copiar"})]}),l.jsx("div",{className:"flex items-center gap-1 border-b border-[var(--ui-border)]",children:r.map(h=>l.jsx("button",{onClick:()=>a(h.cli),className:`rounded-t px-2.5 py-1 text-[10px] font-medium ${i===h.cli?"bg-[var(--ui-bg)] text-[var(--ui-text)] border border-b-0 border-[var(--ui-border)]":"text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]"}`,children:h.label},h.cli))}),c&&l.jsxs("div",{children:[l.jsx("p",{className:"mt-1 mb-1 text-[10px] font-mono text-[var(--ui-text-muted)]",children:c.filename}),l.jsx("pre",{className:"rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] p-3 font-mono text-[11px] text-[var(--ui-text)] overflow-auto max-h-[40vh]",children:c.content})]})]})]}),l.jsx("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--ui-border)] px-5 py-3",children:l.jsx("button",{onClick:e,className:"rounded border border-[var(--ui-border)] px-3 py-1.5 text-xs text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]",children:"Fechar"})})]})})}function YXe(t){try{return new Date(t).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"2-digit"})}catch{return"--"}}const FXe=[{value:"all",label:"Todos"},{value:"stdio",label:"stdio"},{value:"http",label:"http"},{value:"sse",label:"sse"}];function GXe({send:t}){const[e,n]=C.useState([]),[r,i]=C.useState(!0),[a,s]=C.useState(""),[o,c]=C.useState("all"),[u,d]=C.useState(""),[h,m]=C.useState(null),[g,O]=C.useState(null),[b,w]=C.useState(null),v=C.useCallback(async()=>{try{const _=await t("mcpStore.list",{}),N=Array.isArray(_)?_:_.mcps;n(N??[])}catch{n([])}finally{i(!1)}},[t]);C.useEffect(()=>{v()},[v]);const S=C.useMemo(()=>{const _=new Set;return e.forEach(N=>(N.tags||[]).forEach($=>_.add($))),Array.from(_).sort()},[e]),k=C.useMemo(()=>{const _=a.trim().toLowerCase();return e.filter(N=>o!=="all"&&N.transport!==o||u&&!(N.tags||[]).includes(u)?!1:_?N.displayName.toLowerCase().includes(_)||N.name.toLowerCase().includes(_)||(N.description||"").toLowerCase().includes(_)||(N.command||"").toLowerCase().includes(_)||(N.url||"").toLowerCase().includes(_):!0)},[e,a,o,u]);async function Q(){b&&(await t("mcpStore.delete",{id:b}),w(null),v())}async function T(_){await t("mcpStore.duplicate",{id:_}),v()}return l.jsxs("div",{className:"p-5 space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"text-sm font-semibold text-[var(--ui-text)]",children:"MCPs"}),l.jsx("div",{className:"flex items-center gap-2",children:l.jsx(De,{label:"Criar um novo servidor MCP",side:"bottom",children:l.jsx("button",{onClick:()=>m("new"),className:"rounded border border-[var(--ui-border)] px-3 py-1.5 text-xs text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]",children:"Adicionar MCP"})})})]}),!r&&e.length>0&&l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsxs("div",{className:"relative flex-1 min-w-[180px]",children:[l.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--ui-text-muted)]",children:l.jsx("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),l.jsx("input",{value:a,onChange:_=>s(_.target.value),placeholder:"Filtrar MCPs por nome, url ou descricao...",className:"w-full rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] py-1.5 pl-8 pr-3 text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]"})]}),l.jsx("select",{value:o,onChange:_=>c(_.target.value),className:"rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2 py-1.5 text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]",children:FXe.map(_=>l.jsxs("option",{value:_.value,children:["Transporte: ",_.label]},_.value))}),S.length>0&&l.jsxs("select",{value:u,onChange:_=>d(_.target.value),className:"rounded border border-[var(--ui-border)] bg-[var(--ui-bg)] px-2 py-1.5 text-xs text-[var(--ui-text)] outline-none focus:border-[var(--ui-accent)]",children:[l.jsx("option",{value:"",children:"Todas as tags"}),S.map(_=>l.jsx("option",{value:_,children:_},_))]}),l.jsxs("span",{className:"text-[10px] text-[var(--ui-text-muted)]",children:[k.length," de ",e.length]})]}),r&&l.jsx(xt,{className:"text-xs text-[var(--ui-text-muted)]",children:"Carregando..."}),!r&&e.length===0&&l.jsx("div",{className:"rounded-lg border border-dashed border-[var(--ui-border)] p-8 text-center",children:l.jsx("p",{className:"text-xs text-[var(--ui-text-muted)]",children:"Nenhum MCP salvo. Adicione um servidor MCP para conectar ferramentas externas aos agentes."})}),!r&&e.length>0&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-3 rounded bg-[var(--ui-bg)] px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[var(--ui-text-muted)]",children:[l.jsx("span",{className:"w-40",children:"Nome"}),l.jsx("span",{className:"w-20",children:"Transporte"}),l.jsx("span",{className:"flex-1 min-w-0",children:"Alvo"}),l.jsx("span",{className:"w-32",children:"Tags"}),l.jsx("span",{className:"w-20 text-center",children:"Adicionado"}),l.jsx("span",{className:"w-28 text-right",children:"Acoes"})]}),k.map(_=>l.jsxs("div",{className:"flex items-center gap-3 rounded border border-[var(--ui-border)] bg-[var(--ui-surface)] px-3 py-2 transition-colors hover:border-[var(--ui-accent)]/30",children:[l.jsxs("div",{className:"w-40 min-w-0",children:[l.jsx("div",{className:"truncate text-xs font-medium text-[var(--ui-text)]",children:_.displayName}),l.jsx("div",{className:"truncate text-[10px] text-[var(--ui-text-muted)] font-mono",children:_.name})]}),l.jsx("span",{className:"w-20",children:l.jsx("code",{className:"rounded bg-[var(--ui-bg)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--ui-text)]",children:_.transport})}),l.jsx("div",{className:"flex flex-1 min-w-0 items-center gap-1",children:l.jsx("code",{className:"flex-1 truncate rounded bg-[var(--ui-bg)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--ui-text)]",children:_.transport==="stdio"?`${_.command||""}${_.args&&_.args.length>0?" "+_.args.join(" "):""}`:_.url||"--"})}),l.jsxs("div",{className:"w-32 flex flex-wrap gap-0.5",children:[(_.tags||[]).slice(0,3).map(N=>l.jsx("span",{className:"rounded-full border border-[var(--ui-border)] px-1.5 py-0.5 text-[9px] text-[var(--ui-text-muted)]",children:N},N)),(_.tags||[]).length>3&&l.jsxs("span",{className:"text-[9px] text-[var(--ui-text-muted)]",children:["+",(_.tags||[]).length-3]})]}),l.jsx(De,{label:`Adicionado em ${new Date(_.createdAt).toLocaleString("pt-BR")}`,side:"top",children:l.jsx("span",{className:"w-20 text-center text-[10px] text-[var(--ui-text-muted)]",children:YXe(_.createdAt)})}),l.jsxs("div",{className:"flex w-28 items-center justify-end gap-0.5",children:[l.jsx(De,{label:"Ver detalhes",side:"top",children:l.jsx("button",{onClick:()=>O(_),className:"rounded p-1 text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] hover:bg-[var(--ui-bg)]",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3 w-3",children:l.jsx("path",{d:"M8 2c1.981 0 3.671.992 4.933 2.078 1.27 1.091 2.187 2.345 2.637 3.023a1.62 1.62 0 010 1.798c-.45.678-1.367 1.932-2.637 3.023C11.671 13.008 9.981 14 8 14s-3.671-.992-4.933-2.078C1.797 10.831.88 9.577.43 8.899a1.62 1.62 0 010-1.798c.45-.678 1.367-1.932 2.637-3.023C4.329 2.992 6.019 2 8 2zm0 10c3.3 0 5.9-3.048 6.505-3.904a.12.12 0 000-.192C13.9 7.048 11.3 4 8 4 4.7 4 2.1 7.048 1.495 7.904a.12.12 0 000 .192C2.1 8.952 4.7 12 8 12zm0-6.5a2.5 2.5 0 110 5 2.5 2.5 0 010-5zm0 1.5a1 1 0 100 2 1 1 0 000-2z"})})})}),l.jsx(De,{label:"Editar MCP",side:"top",children:l.jsx("button",{onClick:()=>m(_),className:"rounded p-1 text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] hover:bg-[var(--ui-bg)]",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3 w-3",children:l.jsx("path",{d:"M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L3.463 11.098a.25.25 0 00-.064.108l-.593 2.076 2.076-.593a.25.25 0 00.108-.064l8.61-8.61a.25.25 0 000-.354l-1.086-1.086-.087.087.087-.087z"})})})}),l.jsx(De,{label:"Duplicar MCP",side:"top",children:l.jsx("button",{onClick:()=>T(_.id),className:"rounded p-1 text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] hover:bg-[var(--ui-bg)]",children:l.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3 w-3",children:[l.jsx("path",{d:"M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"}),l.jsx("path",{d:"M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"})]})})}),l.jsx(De,{label:"Excluir MCP",side:"top",children:l.jsx("button",{onClick:()=>w(_.id),className:"rounded p-1 text-[var(--ui-text-muted)] hover:text-red-400 hover:bg-[var(--ui-bg)]",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3 w-3",children:l.jsx("path",{d:"M5.75 1a.75.75 0 00-.75.75V3H2a.75.75 0 000 1.5h.5l.627 8.77A1.75 1.75 0 004.872 15h6.256a1.75 1.75 0 001.745-1.73L13.5 4.5H14A.75.75 0 0014 3h-3V1.75A.75.75 0 0010.25 1h-4.5zM6.5 3V2.5h3V3h-3zm-2 1.5h7.022l-.618 8.638a.25.25 0 01-.249.362H5.345a.25.25 0 01-.249-.362L4.478 4.5H4.5z"})})})})]})]},_.id)),k.length===0&&l.jsx("div",{className:"px-3 py-6 text-center text-xs text-[var(--ui-text-muted)]",children:"Nenhum MCP encontrado para o filtro atual"})]}),h!==null&&l.jsx(BXe,{send:t,mcp:h==="new"?null:h,onClose:()=>m(null),onSaved:v}),g&&l.jsx(UXe,{mcp:g,onClose:()=>O(null),onEdit:_=>{O(null),m(_)}}),b&&l.jsx(ng,{title:"Excluir MCP",message:"Tem certeza que deseja excluir este MCP? Esta acao nao pode ser desfeita.",confirmLabel:"Excluir",variant:"danger",onConfirm:Q,onCancel:()=>w(null)})]})}const HXe=[{key:"skills",label:"Skills"},{key:"commands",label:"Commands"},{key:"hooks",label:"Hooks"},{key:"mcps",label:"MCPs"},{key:"agents",label:"Agents"}];function KXe({send:t}){const[e,n]=C.useState("skills");return l.jsxs("div",{className:"space-y-0",children:[l.jsx("div",{className:"flex items-center gap-1 border-b border-[var(--ui-border)] px-5 pt-4 pb-0",children:HXe.map(r=>l.jsx("button",{onClick:()=>n(r.key),className:`rounded-t px-3 py-1.5 text-xs font-medium transition-colors ${e===r.key?"bg-[var(--ui-surface)] border border-b-0 border-[var(--ui-border)] text-[var(--ui-text)]":"text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]"}`,children:r.label},r.key))}),e==="skills"&&l.jsx(QXe,{send:t}),e==="commands"&&l.jsx(EXe,{send:t}),e==="hooks"&&l.jsx(MXe,{send:t}),e==="mcps"&&l.jsx(GXe,{send:t}),e==="agents"&&l.jsx(qXe,{send:t})]})}const VV="mobile.shortcuts";function JXe(){return`shortcut-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}const zte=[{label:"Tab",sequence:"\\t",description:"Autocompletar"},{label:"Enter",sequence:"\\r",description:"Enviar comando"},{label:"Escape",sequence:"\\e",description:"Cancelar / sair"},{label:"Ctrl+C",sequence:"\\u0003",description:"Interromper processo"},{label:"Ctrl+D",sequence:"\\u0004",description:"EOF / sair do shell"},{label:"Ctrl+Z",sequence:"\\u001a",description:"Suspender processo"},{label:"Ctrl+L",sequence:"\\u000c",description:"Limpar tela"},{label:"Ctrl+A",sequence:"\\u0001",description:"Inicio da linha"},{label:"Ctrl+E",sequence:"\\u0005",description:"Fim da linha"},{label:"Ctrl+U",sequence:"\\u0015",description:"Apagar linha"},{label:"Ctrl+W",sequence:"\\u0017",description:"Apagar palavra"},{label:"Ctrl+R",sequence:"\\u0012",description:"Buscar historico"},{label:"Ctrl+V",sequence:"\\u0016",description:"Literal / quote"},{label:"Shift+Tab",sequence:"\\x1b[Z",description:"Autocompletar reverso"},{label:"Seta Cima",sequence:"\\x1b[A",description:"Historico anterior"},{label:"Seta Baixo",sequence:"\\x1b[B",description:"Historico proximo"}];function eqe({send:t}){const{shortcuts:e,setShortcuts:n,addShortcut:r,updateShortcut:i,removeShortcut:a,reorderShortcuts:s}=Zc(),[o,c]=C.useState(null),[u,d]=C.useState(!1),[h,m]=C.useState(!1),[g,O]=C.useState(""),[b,w]=C.useState(""),[v,S]=C.useState(""),[k,Q]=C.useState(!1),[T,_]=C.useState(2),[N,$]=C.useState(20);C.useEffect(()=>{(async()=>{try{const Y=(await t("settings.list",{category:"mobile"})).find(F=>F.key===VV);if(Y){const F=JSON.parse(Y.value);n(F)}}catch{}})()},[t,n]);const R=C.useCallback(async L=>{m(!0);try{await t("settings.set",{key:VV,value:JSON.stringify(L),category:"mobile",label:"Atalhos Mobile"})}finally{m(!1)}},[t]),A=async(L,Y)=>{i(L,{enabled:Y});const F=Zc.getState().shortcuts.map(Z=>Z.id===L?{...Z,enabled:Y}:Z);await R(F)},M=()=>{O(""),w(""),S(""),Q(!1),_(2),$(20)},I=L=>{const Y=zte[L];Y&&(O(Y.label),w(Y.description),S(Y.sequence))},V=L=>{var Y,F;c(L.id),d(!1),O(L.label),w(L.description),S(L.sequence),Q(!!L.repeat),_(((Y=L.repeat)==null?void 0:Y.count)??2),$(((F=L.repeat)==null?void 0:F.delayMs)??20)},D=async()=>{if(!o||!g.trim()||!v.trim())return;const L={label:g.trim(),description:b.trim(),sequence:v.trim(),repeat:k?{count:T,delayMs:N}:void 0};i(o,L);const Y=Zc.getState().shortcuts;await R(Y),c(null),M()},X=async()=>{if(!g.trim()||!v.trim())return;const L={id:JXe(),label:g.trim(),description:b.trim(),sequence:v.trim(),enabled:!0,repeat:k?{count:T,delayMs:N}:void 0};r(L);const Y=Zc.getState().shortcuts;await R(Y),d(!1),M()},q=async L=>{a(L);const Y=Zc.getState().shortcuts;await R(Y)},z=async(L,Y)=>{const F=Y==="up"?L-1:L+1;if(F<0||F>=e.length)return;s(L,F);const Z=Zc.getState().shortcuts;await R(Z)},j=async()=>{n(Pb),await R(Pb),c(null),d(!1),M()},W=g.trim()&&v.trim();return l.jsxs("div",{className:"space-y-5 p-5",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-semibold text-[var(--ui-text)]",children:"Atalhos do Teclado Mobile"}),l.jsx("p",{className:"mt-1 text-xs text-[var(--ui-text-muted)]",children:"Configure os atalhos que aparecem no botao de teclado ao usar o terminal no celular. Arraste para reordenar, desative ou crie novos atalhos."})]}),l.jsxs("div",{className:"space-y-2",children:[e.map((L,Y)=>l.jsx("div",{children:o===L.id?l.jsxs("div",{className:"rounded-xl border border-blue-500/50 bg-blue-500/5 p-4 space-y-3",children:[l.jsx(BV,{draftLabel:g,draftDescription:b,draftSequence:v,draftRepeat:k,draftRepeatCount:T,draftRepeatDelay:N,onLabelChange:O,onDescriptionChange:w,onSequenceChange:S,onRepeatChange:Q,onRepeatCountChange:_,onRepeatDelayChange:$,onPresetSelect:I}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{type:"button",onClick:D,disabled:!W,className:"rounded-lg bg-blue-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-blue-700 disabled:opacity-40",children:"Salvar"}),l.jsx("button",{type:"button",onClick:()=>{c(null),M()},className:"rounded-lg border border-[var(--ui-border)] px-3 py-1.5 text-xs font-medium text-[var(--ui-text-muted)] transition-colors hover:bg-[var(--ui-surface-hover)]",children:"Cancelar"})]})]}):l.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-[var(--ui-border)] bg-[var(--ui-bg)] px-4 py-3 transition-colors hover:border-[var(--ui-text-muted)]",children:[l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.jsx("button",{type:"button",onClick:()=>z(Y,"up"),disabled:Y===0,className:"text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] disabled:opacity-20","aria-label":"Mover para cima",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3 w-3",children:l.jsx("path",{d:"M8 4.5l4 5H4l4-5z"})})}),l.jsx("button",{type:"button",onClick:()=>z(Y,"down"),disabled:Y===e.length-1,className:"text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] disabled:opacity-20","aria-label":"Mover para baixo",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3 w-3",children:l.jsx("path",{d:"M8 11.5l4-5H4l4 5z"})})})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-semibold text-[var(--ui-text)]",children:L.label}),l.jsx("code",{className:"rounded bg-[var(--ui-surface-hover)] px-1.5 py-0.5 text-[10px] text-[var(--ui-text-muted)]",children:L.sequence}),L.repeat&&l.jsxs("span",{className:"text-[10px] text-[var(--ui-text-muted)]",children:["x",L.repeat.count]})]}),l.jsx("p",{className:"text-xs text-[var(--ui-text-muted)] truncate",children:L.description})]}),l.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[l.jsx(Id,{checked:L.enabled,onChange:F=>A(L.id,F)}),l.jsx("button",{type:"button",onClick:()=>V(L),className:"rounded p-1.5 text-[var(--ui-text-muted)] transition-colors hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-text)]","aria-label":"Editar atalho",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3.5 w-3.5",children:l.jsx("path",{d:"M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L3.463 11.098a.25.25 0 00-.064.108l-.558 1.953 1.953-.558a.25.25 0 00.108-.064l8.61-8.61a.25.25 0 000-.354l-1.086-1.086z"})})}),l.jsx("button",{type:"button",onClick:()=>q(L.id),className:"rounded p-1.5 text-[var(--ui-text-muted)] transition-colors hover:bg-red-500/10 hover:text-red-400","aria-label":"Remover atalho",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3.5 w-3.5",children:l.jsx("path",{d:"M6.5 1.75a.25.25 0 01.25-.25h2.5a.25.25 0 01.25.25V3h-3V1.75zM11 3V1.75A1.75 1.75 0 009.25 0h-2.5A1.75 1.75 0 005 1.75V3H2.75a.75.75 0 000 1.5h.928l.856 8.576A1.75 1.75 0 006.283 14.5h3.434a1.75 1.75 0 001.749-1.424l.856-8.576h.928a.75.75 0 000-1.5H11zm-5.22 1.5l.806 8.058a.25.25 0 00.249.192h3.434a.25.25 0 00.25-.192L11.32 4.5H4.78z"})})})]})]})},L.id)),e.length===0&&l.jsx("div",{className:"rounded-xl border border-dashed border-[var(--ui-border)] py-8 text-center",children:l.jsx("p",{className:"text-xs text-[var(--ui-text-muted)]",children:"Nenhum atalho configurado"})})]}),u&&l.jsxs("div",{className:"rounded-xl border border-emerald-500/50 bg-emerald-500/5 p-4 space-y-3",children:[l.jsx("p",{className:"text-xs font-semibold text-emerald-400 uppercase tracking-wider",children:"Novo Atalho"}),l.jsx(BV,{draftLabel:g,draftDescription:b,draftSequence:v,draftRepeat:k,draftRepeatCount:T,draftRepeatDelay:N,onLabelChange:O,onDescriptionChange:w,onSequenceChange:S,onRepeatChange:Q,onRepeatCountChange:_,onRepeatDelayChange:$,onPresetSelect:I}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{type:"button",onClick:X,disabled:!W,className:"rounded-lg bg-emerald-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-emerald-700 disabled:opacity-40",children:"Adicionar"}),l.jsx("button",{type:"button",onClick:()=>{d(!1),M()},className:"rounded-lg border border-[var(--ui-border)] px-3 py-1.5 text-xs font-medium text-[var(--ui-text-muted)] transition-colors hover:bg-[var(--ui-surface-hover)]",children:"Cancelar"})]})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[!u&&!o&&l.jsxs("button",{type:"button",onClick:()=>{d(!0),M()},className:"flex items-center gap-1.5 rounded-lg bg-blue-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-blue-700",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3.5 w-3.5",children:l.jsx("path",{d:"M8 2a.75.75 0 01.75.75v4.5h4.5a.75.75 0 010 1.5h-4.5v4.5a.75.75 0 01-1.5 0v-4.5h-4.5a.75.75 0 010-1.5h4.5v-4.5A.75.75 0 018 2z"})}),"Novo Atalho"]}),l.jsx("button",{type:"button",onClick:j,className:"rounded-lg border border-[var(--ui-border)] px-3 py-1.5 text-xs font-medium text-[var(--ui-text-muted)] transition-colors hover:bg-[var(--ui-surface-hover)]",children:"Restaurar Padrao"}),h&&l.jsx("span",{className:"text-[10px] text-[var(--ui-text-muted)]",children:"Salvando..."})]}),l.jsxs("div",{className:"rounded-lg border border-[var(--ui-border)] bg-[var(--ui-surface)] p-4",children:[l.jsx("p",{className:"text-xs font-medium text-[var(--ui-text)] mb-2",children:"Sequencias de Escape"}),l.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-[11px] text-[var(--ui-text-muted)]",children:[l.jsxs("span",{children:[l.jsx("code",{className:"text-[var(--ui-text)]",children:"\\\\t"})," — Tab"]}),l.jsxs("span",{children:[l.jsx("code",{className:"text-[var(--ui-text)]",children:"\\\\n"})," — Nova linha"]}),l.jsxs("span",{children:[l.jsx("code",{className:"text-[var(--ui-text)]",children:"\\\\r"})," — Enter"]}),l.jsxs("span",{children:[l.jsx("code",{className:"text-[var(--ui-text)]",children:"\\\\e"})," — Escape"]}),l.jsxs("span",{children:[l.jsx("code",{className:"text-[var(--ui-text)]",children:"\\\\u0003"})," — Ctrl+C"]}),l.jsxs("span",{children:[l.jsx("code",{className:"text-[var(--ui-text)]",children:"\\\\x1b[A"})," — Seta Cima"]})]})]})]})}function BV({draftLabel:t,draftDescription:e,draftSequence:n,draftRepeat:r,draftRepeatCount:i,draftRepeatDelay:a,onLabelChange:s,onDescriptionChange:o,onSequenceChange:c,onRepeatChange:u,onRepeatCountChange:d,onRepeatDelayChange:h,onPresetSelect:m}){return l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[11px] font-medium text-[var(--ui-text-muted)]",children:"Preset (opcional)"}),l.jsxs("select",{className:"w-full rounded-lg border border-[var(--ui-border)] bg-[var(--ui-bg)] px-3 py-1.5 text-xs text-[var(--ui-text)]",value:"",onChange:g=>{const O=parseInt(g.target.value,10);isNaN(O)||m(O)},children:[l.jsx("option",{value:"",children:"Selecionar preset..."}),zte.map((g,O)=>l.jsxs("option",{value:O,children:[g.label," — ",g.description]},g.sequence))]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[11px] font-medium text-[var(--ui-text-muted)]",children:"Label *"}),l.jsx("input",{type:"text",value:t,onChange:g=>s(g.target.value),placeholder:"Ctrl+C",className:"w-full rounded-lg border border-[var(--ui-border)] bg-[var(--ui-bg)] px-3 py-1.5 text-xs text-[var(--ui-text)] placeholder:text-[var(--ui-text-muted)]"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[11px] font-medium text-[var(--ui-text-muted)]",children:"Sequencia *"}),l.jsx("input",{type:"text",value:n,onChange:g=>c(g.target.value),placeholder:"\\\\u0003",className:"w-full rounded-lg border border-[var(--ui-border)] bg-[var(--ui-bg)] px-3 py-1.5 text-xs font-mono text-[var(--ui-text)] placeholder:text-[var(--ui-text-muted)]"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[11px] font-medium text-[var(--ui-text-muted)]",children:"Descricao"}),l.jsx("input",{type:"text",value:e,onChange:g=>o(g.target.value),placeholder:"Interromper processo",className:"w-full rounded-lg border border-[var(--ui-border)] bg-[var(--ui-bg)] px-3 py-1.5 text-xs text-[var(--ui-text)] placeholder:text-[var(--ui-text-muted)]"})]}),l.jsx("div",{className:"flex items-center gap-3",children:l.jsx(Id,{checked:r,onChange:u,label:"Repetir",description:"Enviar a sequencia multiplas vezes"})}),r&&l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[11px] font-medium text-[var(--ui-text-muted)]",children:"Vezes"}),l.jsx("input",{type:"number",min:2,max:10,value:i,onChange:g=>d(parseInt(g.target.value,10)||2),className:"w-full rounded-lg border border-[var(--ui-border)] bg-[var(--ui-bg)] px-3 py-1.5 text-xs text-[var(--ui-text)]"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"mb-1 block text-[11px] font-medium text-[var(--ui-text-muted)]",children:"Delay (ms)"}),l.jsx("input",{type:"number",min:0,max:1e3,value:a,onChange:g=>h(parseInt(g.target.value,10)||0),className:"w-full rounded-lg border border-[var(--ui-border)] bg-[var(--ui-bg)] px-3 py-1.5 text-xs text-[var(--ui-text)]"})]})]})]})}function tqe({onClose:t,send:e,onPushEvent:n,onRelayDisconnect:r}){const{t:i}=Mt(),[a,s]=C.useState("cli_tools"),{isCompact:o}=Xm(),{settings:c,installedClis:u,fetchSettings:d,setSetting:h,getSecret:m,detectClis:g}=HIe({send:e}),O=[{key:"cli_tools",label:i("settings.tabs.cliTools")},{key:"general",label:i("settings.tabs.general")},{key:"api_keys",label:i("settings.tabs.apiKeys")},{key:"providers",label:i("settings.tabs.providers")},{key:"tunnel",label:i("settings.tabs.tunnel")},{key:"templates",label:i("settings.tabs.templates","Templates")},{key:"skills_store",label:i("settings.tabs.skillsStore","Documentacao")},{key:"shortcuts",label:i("settings.tabs.shortcuts","Atalhos")},{key:"advanced",label:i("settings.tabs.advanced")}];return C.useEffect(()=>{d().catch(()=>{})},[d]),l.jsxs("div",{className:"flex h-full flex-col overflow-auto bg-[var(--ui-bg)]",children:[l.jsx("div",{className:"border-b border-[var(--ui-border)]",children:l.jsxs("div",{className:`mx-auto flex w-full max-w-5xl items-center gap-3 ${o?"px-3 py-2":"px-6 py-3"}`,children:[l.jsxs("button",{onClick:t,className:"flex items-center gap-1 text-xs text-[var(--ui-text-muted)] hover:text-[var(--ui-text)] transition-colors",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"h-3.5 w-3.5",children:l.jsx("path",{fillRule:"evenodd",d:"M7.78 12.53a.75.75 0 01-1.06 0L2.47 8.28a.75.75 0 010-1.06l4.25-4.25a.75.75 0 011.06 1.06L4.56 7.25H13a.75.75 0 010 1.5H4.56l3.22 3.22a.75.75 0 010 1.06z"})}),"Voltar"]}),l.jsx("h2",{className:"text-sm font-semibold text-[var(--ui-text)]",children:i("settings.title")})]})}),l.jsx("div",{className:"border-b border-[var(--ui-border)] bg-[var(--ui-bg)]",children:l.jsx("div",{className:`touch-scroll-x mx-auto flex w-full max-w-5xl overflow-x-auto ${o?"px-3":"px-6"}`,children:O.map(b=>l.jsx("button",{onClick:()=>s(b.key),className:`shrink-0 whitespace-nowrap border-b-2 px-3 py-2 text-xs font-medium transition-colors ${a===b.key?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]"}`,children:b.label},b.key))})}),l.jsx("div",{className:"flex-1 overflow-auto",children:l.jsxs("div",{className:"mx-auto w-full max-w-5xl",children:[a==="cli_tools"&&l.jsx(aXe,{send:e}),a==="general"&&l.jsx(U9e,{settings:c,setSetting:h,send:e,onPushEvent:n,onRelayDisconnect:r}),a==="api_keys"&&l.jsx(Y9e,{settings:c,setSetting:h,getSecret:m}),a==="providers"&&l.jsx(G9e,{installedClis:u,detectClis:g,send:e}),a==="tunnel"&&l.jsx(J9e,{send:e,onPushEvent:n}),a==="templates"&&l.jsx(bXe,{send:e}),a==="skills_store"&&l.jsx(KXe,{send:e}),a==="shortcuts"&&l.jsx(eqe,{send:e}),a==="advanced"&&l.jsx(H9e,{settings:c})]})})]})}let nqe=0;function rqe(){return`req-${++nqe}-${Date.now()}`}function iqe(t,e,n,r,i){const a=C.useRef(null),s=C.useRef(new Map),o=C.useRef(t);o.current=t;const c=C.useRef(e);c.current=e;const u=C.useRef(n);u.current=n;const d=C.useRef(i);d.current=i;const h=C.useRef(void 0),m=C.useRef(!1),g=C.useRef(0);return C.useEffect(()=>{let b=!1;function w(){if(b)return;const v=window.__IMPACTUS_CONFIG__,S=v!==void 0?v==null?void 0:v.relayUrl:"https://impactus-relay.replit.app";let k;if(S&&r){const T=S.startsWith("https")?"wss:":"ws:",_=S.replace(/^https?:\/\//,"");k=`${T}//${_}/ws/client/${r}`}else{if(S&&!r)return;{const T=window.electronBridge;if(T!=null&&T.serverPort)k=`ws://localhost:${T.serverPort}/ws`;else{k=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;const N=new URLSearchParams(window.location.search).get("token");N&&(k+=`?token=${encodeURIComponent(N)}`)}}}const Q=new WebSocket(k);a.current=Q,Q.onopen=()=>{var T,_;g.current=0,m.current?(T=c.current)==null||T.call(c):(_=u.current)==null||_.call(u),m.current=!0},Q.onmessage=T=>{if(T.data instanceof Blob){T.data.arrayBuffer().then(N=>{const $=new DataView(N);if($.getUint8(0)===1){const A=new TextDecoder,M=A.decode(new Uint8Array(N,1,36)),I=A.decode(new Uint8Array(N,37,36)),V=$.getUint32(73,!1),D=$.getUint16(77,!1),X=$.getUint16(79,!1),q=$.getInt16(81,!1),z=$.getInt16(83,!1),j=$.getUint16(85,!1)/100,W=new Uint8Array(N,87);o.current("browser.frame.binary",{sessionId:M,tabId:I,frameNumber:V,metadata:{deviceWidth:D,deviceHeight:X,scrollOffsetX:q,scrollOffsetY:z,pageScaleFactor:j},blob:new Blob([W],{type:"image/jpeg"})})}});return}let _;try{_=JSON.parse(T.data)}catch{return}if("type"in _&&_.type==="push"){const N=_;o.current(N.channel,N.data)}else{const N=_,$=s.current.get(N.id);$&&(s.current.delete(N.id),$(N))}},Q.onclose=()=>{var T;a.current=null;for(const[_,N]of s.current)N({id:_,error:{message:"Connection lost"}});if(s.current.clear(),!b){if(!!S&&!!r&&(g.current++,g.current>=3)){(T=d.current)==null||T.call(d);return}h.current=setTimeout(w,2e3)}},Q.onerror=()=>{}}return w(),()=>{var v;b=!0,clearTimeout(h.current),(v=a.current)==null||v.close(),a.current=null}},[r]),{send:C.useCallback((b,w,v)=>new Promise((S,k)=>{const Q=a.current;if(!Q||Q.readyState!==WebSocket.OPEN){k(new Error("WebSocket not connected"));return}const T=rqe(),_={id:T,method:b,params:w};s.current.set(T,$=>{$.error?k(new Error($.error.message)):S($.result)}),Q.send(JSON.stringify(_)),setTimeout(()=>{s.current.has(T)&&(s.current.delete(T),k(new Error(`Request ${b} timed out`)))},v??(b==="workspace.launch"?6e4:1e4))}),[])}}const aqe={undo:{keys:["Mod+Z"],context:"workspace",label:"Undo"},redo:{keys:["Mod+Shift+Z"],context:"workspace",label:"Redo"},toggleTopologyView:{keys:["Mod+G"],context:"swarm",label:"Toggle Topology View"},commandPalette:{keys:["Mod+K"],context:"global",label:"Command Palette"}},sqe=Ji(t=>({shortcuts:{...aqe},register:(e,n)=>t(r=>({shortcuts:{...r.shortcuts,[e]:n}})),unregister:e=>t(n=>{const r={...n.shortcuts};return delete r[e],{shortcuts:r}}),updateKeys:(e,n)=>t(r=>{const i=r.shortcuts[e];return i?{shortcuts:{...r.shortcuts,[e]:{...i,keys:n}}}:r}),setHandler:(e,n)=>t(r=>{const i=r.shortcuts[e];return i?{shortcuts:{...r.shortcuts,[e]:{...i,handler:n}}}:r})})),ZV=Ji((t,e)=>({undoStack:[],redoStack:[],pushSnapshot:(n,r)=>{const i={terminalPositions:n.terminalPositions,swarmTopologyEdits:n.swarmTopologyEdits,activeWorktreeId:n.activeWorktreeId,timestamp:n.timestamp??Date.now(),label:r??n.label??"change"};t(a=>({undoStack:[...a.undoStack.slice(-49),i],redoStack:[]}))},undo:()=>{const n=e();if(n.undoStack.length===0)return;const r=n.undoStack[n.undoStack.length-1];return t({undoStack:n.undoStack.slice(0,-1),redoStack:[...n.redoStack.slice(-49),r]}),r},redo:()=>{const n=e();if(n.redoStack.length===0)return;const r=n.redoStack[n.redoStack.length-1];return t({redoStack:n.redoStack.slice(0,-1),undoStack:[...n.undoStack.slice(-49),r]}),r},clear:()=>t({undoStack:[],redoStack:[]})})),oqe=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform);function lqe(t){const e=[];(oqe?t.metaKey:t.ctrlKey)&&e.push("Mod"),t.shiftKey&&e.push("Shift"),t.altKey&&e.push("Alt");const r=t.key.length===1?t.key.toUpperCase():t.key;return r!=="Shift"&&r!=="Control"&&r!=="Meta"&&r!=="Alt"&&e.push(r),e.join("+")}function cqe(t){return t.split("+").map(e=>e.length===1?e.toUpperCase():e).join("+")}function uqe(t={}){C.useEffect(()=>{const e=n=>{const r=n.target;if(!!r&&(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable))return;const a=lqe(n),{shortcuts:s}=sqe.getState();for(const[o,c]of Object.entries(s)){if(t.context&&c.context!==t.context&&c.context!=="global"||!c.keys.some(h=>cqe(h)===a))continue;const d=c.handler??dqe(o);if(d){n.preventDefault(),d();return}}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t.context])}function dqe(t){switch(t){case"undo":return()=>{ZV.getState().undo()};case"redo":return()=>{ZV.getState().redo()};case"toggleTopologyView":return()=>{var a;const{settings:e,updateSetting:n}=ga.getState(),i=(((a=e.find(s=>s.key==="swarm.view_mode"))==null?void 0:a.value)??"grid")==="topology"?"grid":"topology";n("swarm.view_mode",i)};case"commandPalette":return;default:return}}function fN(t){const e=lB(t);return Rp[e]??Rp.dark}const Dte=oB(),hN=fN(Dte);pp(hN);const fqe=Ji((t,e)=>(window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>{const{themeId:r}=e();if(r!=="system")return;const i=fN("system");pp(i),t({currentTheme:i,isDark:i.isDark})}),{themeId:Dte,currentTheme:hN,isDark:hN.isDark,setTheme:r=>{const i=fN(r);pp(i),localStorage.setItem("impactus-theme",r),t({themeId:r,currentTheme:i,isDark:i.isDark})},toggle:()=>{const r=e().isDark?"light":"dark",i=Rp[r];pp(i),localStorage.setItem("impactus-theme",r),t({themeId:r,currentTheme:i,isDark:i.isDark})}})),hqe=()=>fqe(),_O="swarm_relayCode";function pqe(){hqe(),uqe();const{t}=Mt(),[e,n]=C.useState(!1),[r,i]=C.useState(null),[a,s]=C.useState({}),[o,c]=C.useState(!1),u=window.__IMPACTUS_CONFIG__,d=u!==void 0?u==null?void 0:u.relayUrl:"https://impactus-relay.replit.app",h=!!d,[m,g]=C.useState(()=>{if(!d)return null;try{return localStorage.getItem(_O)}catch{return null}}),O=C.useCallback(J=>{try{localStorage.setItem(_O,J)}catch{}g(J)},[]),b=lc(J=>J.add),w=a1(J=>J.addNotification),v=C.useRef(new Set),{workspaces:S,activeWorkspaceId:k,view:Q,setView:T,goHome:_,setWorkspaces:N,addWorkspace:$,removeWorkspace:R,setActiveWorkspace:A,setRunning:M}=Vt(),I=C.useCallback((J,me)=>{for(const ve of v.current)ve(J,me);if(J==="workspace.status"){const ve=me;M(ve.id,ve.state==="running")}else if(J==="area.status"){const ve=me,{setAreaRunning:be}=Vt.getState();be(ve.id,ve.state==="running")}else if(J==="area.updated"){const ve=me;ve.workspaceId&&j.current("workspace.get",{id:ve.workspaceId}).then(be=>{const{updateWorkspace:ke}=Vt.getState();ke(be)}).catch(()=>{})}else if(J==="swarm.completed")b(t("app.swarmCompleted"),"success");else if(J==="swarm.escalation")b(me.message,"info");else if(J==="task.completed"){const ve=me;b(t("app.taskCompleted",{title:ve.title??ve.id}),"success")}else if(J==="swarm.agent.status"){const ve=me;ve.status==="error"&&b(t("app.agentError",{name:ve.name}),"error")}else J==="notification.new"&&w(me)},[M,b,w,t]),V=C.useCallback(async()=>{try{await new Promise(ke=>setTimeout(ke,500));const J=await j.current("workspace.list",{});N(J);for(const ke of J)M(ke.id,ke.isRunning===!0);const{activeWorkspaceId:me,view:ve}=Vt.getState(),be=J.filter(ke=>ke.isRunning);if(me&&ve==="workspace"&&J.some(ke=>ke.id===me))ne.current.add(me);else if(be.length>0){const ke=be[0];A(ke.id),ne.current.add(ke.id)}try{const ke=await j.current("terminal.list",{}),Je=new Set((ke.terminals||[]).map(ot=>ot.id));await new Promise(ot=>setTimeout(ot,200)),window.dispatchEvent(new CustomEvent("terminal-reconnect",{detail:{aliveIds:Je}}))}catch{}b(t("app.connectionRestored"),"success")}catch{}},[N,M,A,b,t]),D=C.useCallback(async()=>{try{const J=await j.current("workspace.list",{});N(J),c(!0);for(const ke of J)ke.isRunning&&M(ke.id,!0);const{activeWorkspaceId:me,view:ve}=Vt.getState(),be=J.filter(ke=>ke.isRunning);if(me&&ve==="workspace"&&J.some(ke=>ke.id===me))ne.current.add(me);else if(be.length>0){const ke=be[0];A(ke.id),ne.current.add(ke.id)}try{const ke=await j.current("terminal.list",{}),Je=new Set((ke.terminals||[]).map(ot=>ot.id));Je.size>0&&(await new Promise(ot=>setTimeout(ot,500)),window.dispatchEvent(new CustomEvent("terminal-reconnect",{detail:{aliveIds:Je}})))}catch{}}catch{}},[N,M,A]),X=C.useCallback(()=>{try{localStorage.removeItem(_O)}catch{}g(null),c(!1),b(t("app.relayDisconnected",{defaultValue:"Relay disconnected — enter new code"}),"error")},[b,t]),q=C.useCallback(()=>{try{localStorage.removeItem(_O)}catch{}g(null),c(!1)},[]),{send:z}=iqe(I,V,D,m,X),j=C.useRef(z);j.current=z;const W=C.useCallback(J=>(v.current.add(J),()=>{v.current.delete(J)}),[]),L=C.useCallback(async(J,me)=>{try{const ve=await z("workspace.create",{name:J.name,color:J.color,rootDirectory:J.rootDirectory,initGit:J.initGit??!0,defaultCommand:J.defaultCommand,terminalCount:J.terminalCount,terminals:J.terminals.map(be=>{var ke;return{label:be.label,directory:be.directory,command:be.command,commandSequence:((ke=be.commandSequence)==null?void 0:ke.filter(Je=>{var ot;return Je.command.trim()||((ot=Je.waitFor)==null?void 0:ot.trim())}))||[],env:{}}})});$(ve),n(!1),b(t("app.workspaceCreated",{name:ve.name}),"success"),me&&A(ve.id)}catch(ve){console.error("Failed to create workspace:",ve),b(t("app.workspaceCreateError"),"error")}},[z,$,A,b,t]),Y=C.useCallback(J=>{A(J)},[A]),F=C.useCallback(async J=>{try{await z("workspace.stop",{id:J}),M(J,!1),ne.current.delete(J),b(t("app.workspaceStopped"),"info")}catch(me){console.error("Failed to stop workspace:",me),b(t("app.workspaceStopError"),"error")}},[z,M,b,t]),Z=C.useCallback(async J=>{try{await z("workspace.stop",{id:J}).catch(()=>{}),await z("workspace.delete",{id:J}),R(J),M(J,!1),ne.current.delete(J),b(t("app.workspaceDeleted"),"info")}catch(me){console.error("Failed to delete workspace:",me),b(t("app.workspaceDeleteError"),"error")}},[z,R,M,b,t]),G=C.useCallback(async J=>{const me=S.find(ve=>ve.id===J);if(me)try{const ve=await z("workspace.create",{name:`${me.name} (copy)`,color:me.color,rootDirectory:me.rootDirectory,defaultCommand:me.defaultCommand,terminalCount:me.terminalCount,terminals:me.terminals.map(be=>({label:be.label,directory:be.directory,command:be.command,commandSequence:be.commandSequence||[],env:{}}))});$(ve),b(t("app.workspaceDuplicated",{name:ve.name}),"success")}catch(ve){console.error("Failed to duplicate workspace:",ve),b(t("app.workspaceDuplicateError"),"error")}},[S,z,$,b,t]),re=C.useCallback(async J=>{N(J);try{await z("workspace.reorder",{ids:J.map(me=>me.id)})}catch(me){console.error("Failed to persist workspace order:",me)}},[z,N]),ae=C.useCallback(async J=>{for(const me of J){const ve=await z("workspace.create",{name:me.name,color:me.color,rootDirectory:me.rootDirectory,defaultCommand:me.defaultCommand,terminalCount:me.terminalCount,terminals:me.terminals.map(be=>({label:be.label,directory:be.directory,command:be.command,commandSequence:be.commandSequence||[],env:{}}))});$(ve)}},[z,$]),se=C.useCallback(J=>{const me=S.find(ve=>ve.id===J);me&&(i(me),n(!0))},[S]);C.useCallback(async(J,me)=>{if(r)try{const ve=await z("workspace.update",{id:r.id,name:J.name,color:J.color,rootDirectory:J.rootDirectory,initGit:J.initGit??!0,defaultCommand:J.defaultCommand,terminalCount:J.terminalCount,layout:"auto",terminals:J.terminals.map(ke=>{var Je;return{label:ke.label,directory:ke.directory,command:ke.command,commandSequence:((Je=ke.commandSequence)==null?void 0:Je.filter(ot=>ot.command.trim()))||[],env:{}}})}),{updateWorkspace:be}=Vt.getState();be(ve),n(!1),i(null)}catch(ve){console.error("Failed to update workspace:",ve)}},[z,r]);const te=S.find(J=>J.id===k),ne=C.useRef(new Set);k&&Q==="workspace"&&ne.current.add(k);const oe=C.useMemo(()=>new Set(S.map(J=>J.id)),[S]);for(const J of ne.current)oe.has(J)||ne.current.delete(J);const K=C.useMemo(()=>S.filter(J=>ne.current.has(J.id)),[S,k]),pe=typeof window<"u"&&!!window.electronBridge;return o?l.jsxs("div",{className:"flex h-screen w-screen bg-[var(--ui-bg)] text-[var(--ui-text)]",children:[l.jsx(rae,{isElectron:pe,onCreateWorkspace:()=>{i(null),n(!0)},onEditWorkspace:se,onDuplicateWorkspace:G,onDeleteWorkspace:Z,onStopWorkspace:F,onReorderWorkspaces:re,onOpenSettings:()=>T("settings")}),l.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[pe&&l.jsx("div",{className:"drag-region h-[38px] shrink-0 border-b border-[var(--ui-border)]"}),!e&&(Q==="home"||!te)&&l.jsx("div",{className:"flex shrink-0 items-center justify-end gap-3 px-4 py-2",children:l.jsx(rH,{})}),l.jsxs("div",{className:"min-h-0 flex-1",children:[e&&l.jsx("div",{className:"h-full",children:l.jsx(YIe,{send:z,mode:r?"edit":"create",initialWorkspace:r??void 0,onSubmit:L,onCreated:()=>{n(!1),i(null)},onRelaunch:J=>{s(me=>({...me,[J.id]:(me[J.id]??0)+1}))},onStackApplied:()=>{n(!1),i(null)},onCancel:()=>{n(!1),i(null)}})}),l.jsx("div",{className:"h-full",style:{display:!e&&(Q==="home"||!te)?void 0:"none"},children:l.jsx(aae,{onCreateWorkspace:()=>{i(null),n(!0)},onLaunchWorkspace:Y,onStopWorkspace:F,onDeleteWorkspace:Z,onImportWorkspaces:ae})}),K.map(J=>l.jsx("div",{className:"h-full",style:{display:!e&&Q==="workspace"&&J.id===k?void 0:"none"},children:l.jsx(RIe,{workspace:J,send:z,onPushEvent:W,onOpenWorkspaceSettings:()=>se(J.id)},`${J.id}:${a[J.id]??0}`)},J.id)),Q==="settings"&&l.jsx("div",{className:"h-full",children:l.jsx(tqe,{onClose:()=>_(),send:z,onPushEvent:W,onRelayDisconnect:h?q:void 0})})]})]}),l.jsx(GIe,{})]}):h&&!m?l.jsx(Nie,{onSubmit:O,relayUrl:d}):l.jsx("div",{className:"flex h-screen w-screen flex-col items-center justify-center gap-4 bg-[var(--ui-bg)] text-[var(--ui-text)]",children:l.jsx(xt,{className:"text-2xl opacity-60",children:"Verifying connection..."})})}Zre.createRoot(document.getElementById("root")).render(l.jsx(pqe,{}));
package/web/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content" />
6
6
  <link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>😊</text></svg>">
7
7
  <title>Impactus Swarm</title>
8
- <script type="module" crossorigin src="./assets/index-DUQ3EDMr.js"></script>
8
+ <script type="module" crossorigin src="./assets/index-DRMcJORR.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="./assets/vendor-Cr01aj1d.js">
10
10
  <link rel="modulepreload" crossorigin href="./assets/xterm-C3JRPngT.js">
11
11
  <link rel="stylesheet" crossorigin href="./assets/index-BVj9bNIY.css">