limixbot 0.3.36 → 0.3.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/assets/{ActivityPanel-CHOOXhF2.js → ActivityPanel-BD6l_BSa.js} +1 -1
  2. package/dist/assets/{App-DACLgBBp.js → App-CbT4-h7t.js} +8 -8
  3. package/dist/assets/{AppEventEditor-yd__W_U5.js → AppEventEditor-CTA5zGkt.js} +1 -1
  4. package/dist/assets/{BotSettingsDialog-D0TwRB9V.js → BotSettingsDialog-CnxgGek3.js} +1 -1
  5. package/dist/assets/{BrowserPanel-Drp3HiE6.js → BrowserPanel-CX4xPQmH.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-CBi69tlJ.js → BrowserProfilesManager-YWytzUvr.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-DuTdELlL.js → CloudAddDialog-BMVUFBLd.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-CQw24DeH.js → ComputerFilesPane-CrLU5eGw.js} +1 -1
  9. package/dist/assets/{ComputerPanel-DNgJVesd.js → ComputerPanel-kJfe7_yh.js} +2 -2
  10. package/dist/assets/{DataPanel-Cq0KvZP6.js → DataPanel-DKO3bOSP.js} +1 -1
  11. package/dist/assets/{FilesView-BEtP4Mzr.js → FilesView-DFm53zGa.js} +1 -1
  12. package/dist/assets/{GrokMoveDialog-CST2pJh9.js → GrokMoveDialog-U4Dn0qjV.js} +1 -1
  13. package/dist/assets/{InspectorPanel-BP95nKuG.js → InspectorPanel-BQVvubJx.js} +1 -1
  14. package/dist/assets/{KeyboardShortcutsModal-Bf8o1jmh.js → KeyboardShortcutsModal-j_XkjjbG.js} +1 -1
  15. package/dist/assets/{LiveDesktop-DDbR84fh.js → LiveDesktop-Dw246_jb.js} +1 -1
  16. package/dist/assets/{LocalVmWorkspace-Bwm8wLWQ.js → LocalVmWorkspace-DTumm8ar.js} +1 -1
  17. package/dist/assets/{MacLocalControl-D7qKApuf.js → MacLocalControl-DGQgQwOC.js} +1 -1
  18. package/dist/assets/{MarkdownFilePreview-go6WDoyj.js → MarkdownFilePreview-B1ENmVeN.js} +1 -1
  19. package/dist/assets/{NewBotDialog-B1gjhKhM.js → NewBotDialog-CUPHYfOA.js} +1 -1
  20. package/dist/assets/{PhoneAppDialog-BjuVpKiH.js → PhoneAppDialog-DBvCTPjD.js} +1 -1
  21. package/dist/assets/{PluginsPanel-VW25pt0Z.js → PluginsPanel-BHMywRlz.js} +1 -1
  22. package/dist/assets/{ProIntroduction-Cyu7L6m4.js → ProIntroduction-C-Ngfyha.js} +1 -1
  23. package/dist/assets/{RemoteAgentSettingsPanel-DFT8oaSE.js → RemoteAgentSettingsPanel-B-FM_qkX.js} +1 -1
  24. package/dist/assets/{RoomPanel-5JTYfABj.js → RoomPanel-CSloRoXd.js} +1 -1
  25. package/dist/assets/{RoutinesPage-poZPA-e1.js → RoutinesPage-BJnF_272.js} +1 -1
  26. package/dist/assets/{SettingsModal-CFir3mJE.js → SettingsModal-C2xabwue.js} +1 -1
  27. package/dist/assets/{ShareTeamDialog-DeHb5M55.js → ShareTeamDialog-iiKMHE9O.js} +1 -1
  28. package/dist/assets/{SignedInSites-KKFXLoTd.js → SignedInSites-BdgWdVUi.js} +1 -1
  29. package/dist/assets/{TeamLibraryPanel-Wrxotmve.js → TeamLibraryPanel-gNxRx6dJ.js} +1 -1
  30. package/dist/assets/{TeamMapPage-DjiTO9Dz.js → TeamMapPage-B04q4kNk.js} +1 -1
  31. package/dist/assets/{TriggersPage-BAd0XpRJ.js → TriggersPage-BWv-cF6T.js} +1 -1
  32. package/dist/assets/{VisibilitySection-XakosUpX.js → VisibilitySection-BgHgxqqh.js} +1 -1
  33. package/dist/assets/{WebhookTrigger-QjSNg9QS.js → WebhookTrigger-DgHEoYp-.js} +1 -1
  34. package/dist/assets/{WorksOnGrid-C0IlVrdO.js → WorksOnGrid-DpwLxZio.js} +1 -1
  35. package/dist/assets/{core-BNohLdWF.js → core-U5H80SxZ.js} +1 -1
  36. package/dist/assets/{import-name-BNYqlOCE.js → import-name-BujoBk4Y.js} +1 -1
  37. package/dist/assets/{index-DRc3H3Yn.js → index-BEyPuH85.js} +1 -1
  38. package/dist/assets/{index-By-CYMXf.js → index-BTJoFn8A.js} +2 -2
  39. package/dist/assets/{mcp-servers-BTdtwb7Q.js → mcp-servers-CIlBM4yB.js} +1 -1
  40. package/dist/assets/{new-bot-BI7r44Kf.js → new-bot-D2pBdFLY.js} +1 -1
  41. package/dist/assets/{org-library-C5EqhsGN.js → org-library-xIxGs5VY.js} +1 -1
  42. package/dist/assets/{package-format-M6l7zHYk.js → package-format-DFnnhVuV.js} +1 -1
  43. package/dist/assets/{remote-desktop-panel-CRh1d2zD.js → remote-desktop-panel-JUjpGN4N.js} +1 -1
  44. package/dist/index.html +1 -1
  45. package/dist-server/index.js +629 -619
  46. package/dist-server/package.json +1 -1
  47. package/dist-server/server/bot-api-host.js +17 -7
  48. package/dist-server/server/bot-api.js +1 -1
  49. package/dist-server/server/limix-channel-media.js +66 -0
  50. package/dist-server/server/webhook-ingress.js +2 -2
  51. package/package.json +1 -1
@@ -1 +1 @@
1
- import{r,t as a,d as ne,j as e,X as le,f as ce}from"./styles-h5tFt3-N.js";import{r as ie,L as K}from"./PlacesRail-Cq-ZB7CK.js";import{S as B,a as de,p as J,r as oe,s as V,b as me,c as xe,t as pe,n as ue,d as he,e as fe,f as ge}from"./team-share-4fayckbz.js";import{u as Se,n as I,K as be}from"./App-DACLgBBp.js";import"./monitor-D4StKPgF.js";import"./index-By-CYMXf.js";import"./MenuMotion-DQh3Is8R.js";function G({preview:l,includeMemory:x,localSkips:b}){const i=l.document.package,c=l.summary.counts,L=i.team?.leader?i.agents.find(s=>s.key===i.team?.leader)?.name:void 0,j=i.agents.filter(s=>s.appearance.avatar).length,T=i.agents.reduce((s,p)=>s+Object.keys(p.seed?.memory??{}).length,0),k=[[a("teamShare.part.bots"),`${c.bots} · ${l.summary.botNames.join(", ")}`],[a("teamShare.part.skills"),String(c.skills)],[a("teamShare.part.playbooks"),String(c.playbooks)],[a("teamShare.part.rooms"),String(c.rooms)],[a("teamShare.part.routines"),String(c.routines)],[a("teamShare.part.brief"),i.team?.brief?a("teamShare.yes"):a("teamShare.none")],[a("teamShare.part.leader"),L??a("teamShare.none")],[a("teamShare.part.connections"),String(c.connections)],[a("teamShare.part.pictures"),String(j)],[a("teamShare.part.notes"),x?String(T):a("teamShare.none")],...c.presets?[[a("teamShare.part.presets"),`${c.presets} · ${l.summary.presetNames.join(", ")}`]]:[]],C=[...b,...l.skipped.map(s=>he(s,l.document))];return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:a("teamShare.included")}),e.jsx("dl",{className:"mt-2 grid grid-cols-[minmax(0,1fr)_auto] gap-x-4 gap-y-1.5 rounded-xl bg-raised/45 px-4 py-3 text-[13px]",children:k.map(([s,p])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-ink-secondary",children:s}),e.jsx("dd",{className:"max-w-[260px] truncate text-right text-ink",title:p,children:p})]},s))}),i.connections?.length?e.jsxs("div",{className:"mt-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:a("teamShare.addresses")}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:i.connections.map(s=>e.jsxs("li",{className:"break-all",children:[e.jsx("span",{className:"text-ink",children:s.label})," · ",s.mcp.url]},s.key))})]}):null,e.jsxs("p",{className:"mt-3 flex items-start gap-2 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx(be,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("span",{children:a("teamShare.never")})]}),l.redacted.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:a("teamShare.redacted")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:l.redacted.map(s=>e.jsx("li",{children:fe(s,l.document)},s))})]}),C.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:a("teamShare.skipped")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:C.map((s,p)=>e.jsx("li",{children:s},`${s}-${p}`))})]})]})}function je({available:l,ticked:x,counted:b,onToggle:i}){return e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:a("teamShare.includeSkills")}),b&&l.length===0&&e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:a("teamShare.noSkills")}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-x-4 gap-y-1",children:l.map(c=>e.jsxs("label",{className:"flex items-center gap-1.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"size-3.5 accent-accent",checked:x.has(c),onChange:()=>i(c)}),c]},c))})]})}function Pe({team:l,onClose:x}){const{state:b}=Se(),i=r.useRef(null),c=r.useMemo(()=>b.bots.filter(t=>!t.hidden&&(t.section?.trim()??"")===l),[b.bots,l]),L=r.useMemo(()=>new Map(c.map(t=>[t.id,t.name])),[c]),[j,T]=r.useState(l||a("teamLibrary.general")),[k,C]=r.useState(""),[s,p]=r.useState(""),[z,M]=r.useState(""),[R,W]=r.useState(""),[h,X]=r.useState(B.includePictures),[f,Q]=r.useState(B.includeMemory),[u,Y]=r.useState(!1),[g,H]=r.useState(null),[y,Z]=r.useState(null),[S,O]=r.useState(null),[ee,E]=r.useState(de),{preview:$,available:N,included:te,error:D}=ee,U=t=>E(n=>({...n,error:t})),[d,_]=r.useState(!1),[P,ae]=r.useState(null),A=r.useRef(0);r.useEffect(()=>{let t=!1;return J(c).then(n=>{t||O({avatars:n.avatars,skipped:n.skipped.map(o=>`${L.get(o.botId)??o.botId} · ${a("teamShare.field.picture")} — ${ne(`teamShare.skip.${o.reason}`,o.reason)}`)})}).catch(()=>{t||O({avatars:{},skipped:[]})}),()=>{t=!0}},[]),r.useEffect(()=>{if(!u||g)return;let t=!1;return I("/api/bot-defaults").then(({defaults:n})=>J([{id:"defaults",avatarUrl:n.profile.avatarUrl,avatarCrop:n.profile.avatarCrop}])).then(n=>{t||H({dataUrl:n.avatars.defaults})}).catch(()=>{t||H({})}),()=>{t=!0}},[u,g]);const q=r.useCallback(t=>({team:l,name:j,tagline:k,summary:s,release:z,notes:R,skills:oe(y,N),includeMemory:f,...h&&S?{avatars:S.avatars}:{},...u?{includeDefaultsPreset:!0,...h&&g?.dataUrl?{presetAvatar:g.dataUrl}:{}}:{},dryRun:t}),[l,j,k,s,z,R,y,N,f,h,S,u,g]);r.useEffect(()=>{if(!S)return;if(u&&!g){E(m=>({...m,preview:null}));return}const t=++A.current,n=y===null,o=window.setTimeout(()=>{I("/api/teams/export",{method:"POST",body:JSON.stringify(V({...q(!0),release:void 0}))}).then(m=>{t===A.current&&(E(w=>me(w,m,n)),M(w=>w||m.document.package.release))}).catch(m=>{t===A.current&&E(w=>xe(w,m))})},250);return()=>window.clearTimeout(o)},[S,y,f,h,u,g]);const se=async()=>{if(!d){_(!0),U("");try{const t=await I("/api/teams/export",{method:"POST",body:JSON.stringify(V(q(!1)))});ge(t.filename,t.document),ae(t)}catch(t){U(t instanceof Error?t.message:String(t))}finally{_(!1)}}};r.useEffect(()=>{const t=document.activeElement instanceof HTMLElement?document.activeElement:null;return i.current?.focus(),()=>{t?.isConnected&&t.focus()}},[]);const F=pe(y,te,N),re=t=>{const n=new Set(F);n.has(t)?n.delete(t):n.add(t),Z(n)},v="mt-1 w-full rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[14px] text-ink disabled:opacity-60";return ie.createPortal(e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4",onMouseDown:t=>t.stopPropagation(),children:e.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-labelledby":"share-team-title",tabIndex:-1,className:"flex max-h-[90vh] w-full max-w-[620px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel text-ink shadow-2xl outline-none",onKeyDown:t=>{if(t.key==="Escape"&&!d&&(t.stopPropagation(),x()),t.key==="Tab"){const n=i.current?.querySelectorAll("input:enabled, textarea:enabled, button:enabled");if(!n?.length)return;const o=n[0],m=n[n.length-1];t.shiftKey&&document.activeElement===o?(t.preventDefault(),m.focus()):!t.shiftKey&&document.activeElement===m&&(t.preventDefault(),o.focus())}},children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-6 pb-2 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"share-team-title",className:"text-[17px] font-semibold",children:a("teamShare.title",{name:l||a("teamLibrary.general")})}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:a("teamShare.intro")})]}),e.jsx("button",{"aria-label":a("teamShare.close"),disabled:d,onClick:x,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised",children:e.jsx(le,{size:18})})]}),P?e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:[e.jsxs("p",{className:"flex items-center gap-2 text-[14px] font-medium text-ink",children:[e.jsx(ce,{size:16,className:"text-success"}),a("teamShare.saved",{filename:P.filename})]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:a("teamShare.savedHint")}),e.jsx("div",{className:"mt-4",children:e.jsx(G,{preview:P,includeMemory:f,localSkips:h?S?.skipped??[]:[]})})]}):e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:[$?e.jsx(G,{preview:$,includeMemory:f,localSkips:h?S?.skipped??[]:[]}):!D&&e.jsxs("div",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(K,{size:15,className:"animate-spin"}),a("teamShare.preparing")]}),e.jsxs("fieldset",{className:"mt-4 space-y-2 text-[13px]",disabled:d,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:h,onChange:t=>X(t.target.checked)}),a("teamShare.includePictures")]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:f,onChange:t=>Q(t.target.checked)}),a("teamShare.includeNotes")]}),e.jsx("p",{className:"pl-6 text-[12px] leading-relaxed text-ink-secondary",children:ue(f)}),e.jsx(je,{available:N??[],ticked:F,counted:N!==null,onToggle:re}),e.jsxs("label",{className:"flex items-center gap-2 pt-1",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:u,onChange:t=>Y(t.target.checked)}),a("teamShare.includePreset")]}),u&&e.jsx("p",{className:"pl-6 text-[12px] leading-relaxed text-ink-secondary",children:a("teamShare.presetHint")})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[a("teamShare.name"),e.jsx("input",{value:j,maxLength:100,disabled:d,onChange:t=>T(t.target.value),className:v})]}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[a("teamShare.release"),e.jsx("input",{value:z,maxLength:20,disabled:d,placeholder:"1.0.0",onChange:t=>M(t.target.value),className:v})]})]}),e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:a("teamShare.releaseHint")}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[a("teamShare.notes"),e.jsx("textarea",{value:R,maxLength:4e3,rows:2,disabled:d,onChange:t=>W(t.target.value),className:v})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[a("teamShare.tagline"),e.jsx("input",{value:k,maxLength:160,disabled:d,onChange:t=>C(t.target.value),className:v})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[a("teamShare.summary"),e.jsx("textarea",{value:s,maxLength:2e3,rows:2,disabled:d,onChange:t=>p(t.target.value),className:v})]})]}),D&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:D}),e.jsx("footer",{className:"flex justify-end gap-2 border-t border-hairline/35 px-6 py-3",children:P?e.jsx("button",{onClick:x,className:"rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white",children:a("teamShare.done")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:d,onClick:x,className:"rounded-lg px-3 py-2 text-[13px] text-ink-secondary hover:bg-raised",children:a("common.cancel")}),e.jsxs("button",{disabled:d||!$||!j.trim(),onClick:()=>{se()},className:"flex items-center gap-2 rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white disabled:opacity-40",children:[d&&e.jsx(K,{size:14,className:"animate-spin"}),d?a("teamShare.saving"):a("teamShare.save")]})]})})]})}),document.body)}export{je as ShareSkillChoices,G as ShareTeamContents,Pe as ShareTeamDialog};
1
+ import{r,t as a,d as ne,j as e,X as le,f as ce}from"./styles-h5tFt3-N.js";import{r as ie,L as K}from"./PlacesRail-Cq-ZB7CK.js";import{S as B,a as de,p as J,r as oe,s as V,b as me,c as xe,t as pe,n as ue,d as he,e as fe,f as ge}from"./team-share-4fayckbz.js";import{u as Se,n as I,K as be}from"./App-CbT4-h7t.js";import"./monitor-D4StKPgF.js";import"./index-BTJoFn8A.js";import"./MenuMotion-DQh3Is8R.js";function G({preview:l,includeMemory:x,localSkips:b}){const i=l.document.package,c=l.summary.counts,L=i.team?.leader?i.agents.find(s=>s.key===i.team?.leader)?.name:void 0,j=i.agents.filter(s=>s.appearance.avatar).length,T=i.agents.reduce((s,p)=>s+Object.keys(p.seed?.memory??{}).length,0),k=[[a("teamShare.part.bots"),`${c.bots} · ${l.summary.botNames.join(", ")}`],[a("teamShare.part.skills"),String(c.skills)],[a("teamShare.part.playbooks"),String(c.playbooks)],[a("teamShare.part.rooms"),String(c.rooms)],[a("teamShare.part.routines"),String(c.routines)],[a("teamShare.part.brief"),i.team?.brief?a("teamShare.yes"):a("teamShare.none")],[a("teamShare.part.leader"),L??a("teamShare.none")],[a("teamShare.part.connections"),String(c.connections)],[a("teamShare.part.pictures"),String(j)],[a("teamShare.part.notes"),x?String(T):a("teamShare.none")],...c.presets?[[a("teamShare.part.presets"),`${c.presets} · ${l.summary.presetNames.join(", ")}`]]:[]],C=[...b,...l.skipped.map(s=>he(s,l.document))];return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:a("teamShare.included")}),e.jsx("dl",{className:"mt-2 grid grid-cols-[minmax(0,1fr)_auto] gap-x-4 gap-y-1.5 rounded-xl bg-raised/45 px-4 py-3 text-[13px]",children:k.map(([s,p])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-ink-secondary",children:s}),e.jsx("dd",{className:"max-w-[260px] truncate text-right text-ink",title:p,children:p})]},s))}),i.connections?.length?e.jsxs("div",{className:"mt-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:a("teamShare.addresses")}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:i.connections.map(s=>e.jsxs("li",{className:"break-all",children:[e.jsx("span",{className:"text-ink",children:s.label})," · ",s.mcp.url]},s.key))})]}):null,e.jsxs("p",{className:"mt-3 flex items-start gap-2 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx(be,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("span",{children:a("teamShare.never")})]}),l.redacted.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:a("teamShare.redacted")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:l.redacted.map(s=>e.jsx("li",{children:fe(s,l.document)},s))})]}),C.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:a("teamShare.skipped")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:C.map((s,p)=>e.jsx("li",{children:s},`${s}-${p}`))})]})]})}function je({available:l,ticked:x,counted:b,onToggle:i}){return e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:a("teamShare.includeSkills")}),b&&l.length===0&&e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:a("teamShare.noSkills")}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-x-4 gap-y-1",children:l.map(c=>e.jsxs("label",{className:"flex items-center gap-1.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"size-3.5 accent-accent",checked:x.has(c),onChange:()=>i(c)}),c]},c))})]})}function Pe({team:l,onClose:x}){const{state:b}=Se(),i=r.useRef(null),c=r.useMemo(()=>b.bots.filter(t=>!t.hidden&&(t.section?.trim()??"")===l),[b.bots,l]),L=r.useMemo(()=>new Map(c.map(t=>[t.id,t.name])),[c]),[j,T]=r.useState(l||a("teamLibrary.general")),[k,C]=r.useState(""),[s,p]=r.useState(""),[z,M]=r.useState(""),[R,W]=r.useState(""),[h,X]=r.useState(B.includePictures),[f,Q]=r.useState(B.includeMemory),[u,Y]=r.useState(!1),[g,H]=r.useState(null),[y,Z]=r.useState(null),[S,O]=r.useState(null),[ee,E]=r.useState(de),{preview:$,available:N,included:te,error:D}=ee,U=t=>E(n=>({...n,error:t})),[d,_]=r.useState(!1),[P,ae]=r.useState(null),A=r.useRef(0);r.useEffect(()=>{let t=!1;return J(c).then(n=>{t||O({avatars:n.avatars,skipped:n.skipped.map(o=>`${L.get(o.botId)??o.botId} · ${a("teamShare.field.picture")} — ${ne(`teamShare.skip.${o.reason}`,o.reason)}`)})}).catch(()=>{t||O({avatars:{},skipped:[]})}),()=>{t=!0}},[]),r.useEffect(()=>{if(!u||g)return;let t=!1;return I("/api/bot-defaults").then(({defaults:n})=>J([{id:"defaults",avatarUrl:n.profile.avatarUrl,avatarCrop:n.profile.avatarCrop}])).then(n=>{t||H({dataUrl:n.avatars.defaults})}).catch(()=>{t||H({})}),()=>{t=!0}},[u,g]);const q=r.useCallback(t=>({team:l,name:j,tagline:k,summary:s,release:z,notes:R,skills:oe(y,N),includeMemory:f,...h&&S?{avatars:S.avatars}:{},...u?{includeDefaultsPreset:!0,...h&&g?.dataUrl?{presetAvatar:g.dataUrl}:{}}:{},dryRun:t}),[l,j,k,s,z,R,y,N,f,h,S,u,g]);r.useEffect(()=>{if(!S)return;if(u&&!g){E(m=>({...m,preview:null}));return}const t=++A.current,n=y===null,o=window.setTimeout(()=>{I("/api/teams/export",{method:"POST",body:JSON.stringify(V({...q(!0),release:void 0}))}).then(m=>{t===A.current&&(E(w=>me(w,m,n)),M(w=>w||m.document.package.release))}).catch(m=>{t===A.current&&E(w=>xe(w,m))})},250);return()=>window.clearTimeout(o)},[S,y,f,h,u,g]);const se=async()=>{if(!d){_(!0),U("");try{const t=await I("/api/teams/export",{method:"POST",body:JSON.stringify(V(q(!1)))});ge(t.filename,t.document),ae(t)}catch(t){U(t instanceof Error?t.message:String(t))}finally{_(!1)}}};r.useEffect(()=>{const t=document.activeElement instanceof HTMLElement?document.activeElement:null;return i.current?.focus(),()=>{t?.isConnected&&t.focus()}},[]);const F=pe(y,te,N),re=t=>{const n=new Set(F);n.has(t)?n.delete(t):n.add(t),Z(n)},v="mt-1 w-full rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[14px] text-ink disabled:opacity-60";return ie.createPortal(e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4",onMouseDown:t=>t.stopPropagation(),children:e.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-labelledby":"share-team-title",tabIndex:-1,className:"flex max-h-[90vh] w-full max-w-[620px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel text-ink shadow-2xl outline-none",onKeyDown:t=>{if(t.key==="Escape"&&!d&&(t.stopPropagation(),x()),t.key==="Tab"){const n=i.current?.querySelectorAll("input:enabled, textarea:enabled, button:enabled");if(!n?.length)return;const o=n[0],m=n[n.length-1];t.shiftKey&&document.activeElement===o?(t.preventDefault(),m.focus()):!t.shiftKey&&document.activeElement===m&&(t.preventDefault(),o.focus())}},children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-6 pb-2 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"share-team-title",className:"text-[17px] font-semibold",children:a("teamShare.title",{name:l||a("teamLibrary.general")})}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:a("teamShare.intro")})]}),e.jsx("button",{"aria-label":a("teamShare.close"),disabled:d,onClick:x,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised",children:e.jsx(le,{size:18})})]}),P?e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:[e.jsxs("p",{className:"flex items-center gap-2 text-[14px] font-medium text-ink",children:[e.jsx(ce,{size:16,className:"text-success"}),a("teamShare.saved",{filename:P.filename})]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:a("teamShare.savedHint")}),e.jsx("div",{className:"mt-4",children:e.jsx(G,{preview:P,includeMemory:f,localSkips:h?S?.skipped??[]:[]})})]}):e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:[$?e.jsx(G,{preview:$,includeMemory:f,localSkips:h?S?.skipped??[]:[]}):!D&&e.jsxs("div",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(K,{size:15,className:"animate-spin"}),a("teamShare.preparing")]}),e.jsxs("fieldset",{className:"mt-4 space-y-2 text-[13px]",disabled:d,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:h,onChange:t=>X(t.target.checked)}),a("teamShare.includePictures")]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:f,onChange:t=>Q(t.target.checked)}),a("teamShare.includeNotes")]}),e.jsx("p",{className:"pl-6 text-[12px] leading-relaxed text-ink-secondary",children:ue(f)}),e.jsx(je,{available:N??[],ticked:F,counted:N!==null,onToggle:re}),e.jsxs("label",{className:"flex items-center gap-2 pt-1",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:u,onChange:t=>Y(t.target.checked)}),a("teamShare.includePreset")]}),u&&e.jsx("p",{className:"pl-6 text-[12px] leading-relaxed text-ink-secondary",children:a("teamShare.presetHint")})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[a("teamShare.name"),e.jsx("input",{value:j,maxLength:100,disabled:d,onChange:t=>T(t.target.value),className:v})]}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[a("teamShare.release"),e.jsx("input",{value:z,maxLength:20,disabled:d,placeholder:"1.0.0",onChange:t=>M(t.target.value),className:v})]})]}),e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:a("teamShare.releaseHint")}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[a("teamShare.notes"),e.jsx("textarea",{value:R,maxLength:4e3,rows:2,disabled:d,onChange:t=>W(t.target.value),className:v})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[a("teamShare.tagline"),e.jsx("input",{value:k,maxLength:160,disabled:d,onChange:t=>C(t.target.value),className:v})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[a("teamShare.summary"),e.jsx("textarea",{value:s,maxLength:2e3,rows:2,disabled:d,onChange:t=>p(t.target.value),className:v})]})]}),D&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:D}),e.jsx("footer",{className:"flex justify-end gap-2 border-t border-hairline/35 px-6 py-3",children:P?e.jsx("button",{onClick:x,className:"rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white",children:a("teamShare.done")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:d,onClick:x,className:"rounded-lg px-3 py-2 text-[13px] text-ink-secondary hover:bg-raised",children:a("common.cancel")}),e.jsxs("button",{disabled:d||!$||!j.trim(),onClick:()=>{se()},className:"flex items-center gap-2 rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white disabled:opacity-40",children:[d&&e.jsx(K,{size:14,className:"animate-spin"}),d?a("teamShare.saving"):a("teamShare.save")]})]})})]})}),document.body)}export{je as ShareSkillChoices,G as ShareTeamContents,Pe as ShareTeamDialog};
@@ -1 +1 @@
1
- import{r,j as s,t}from"./styles-h5tFt3-N.js";import{n as b}from"./App-DACLgBBp.js";import{a as k}from"./PlacesRail-Cq-ZB7CK.js";function E({target:i,scope:a={},sharedBy:x,disabled:N=!1,bare:l=!1}){const[n,S]=r.useState(null),[o,m]=r.useState(!1),[c,u]=r.useState(""),p=async e=>{m(!0),u("");try{S((await e()).sites)}catch(d){u(d instanceof Error&&d.message?d.message:t("settings.sites.error"))}finally{m(!1)}},g=()=>p(()=>b(`/api/browser-sites?${new URLSearchParams({...i,...a}).toString()}`)),f=e=>p(()=>b("/api/browser-sites/sign-out",{method:"POST",body:JSON.stringify({...i,...a,...e?{site:e}:{}})})),v=`${"bot"in i?`bot:${i.bot}`:`profile:${i.profile}`}${a.threadId?`:${a.threadId}`:""}`;r.useEffect(()=>{l&&g()},[l,v]);const h=N||o,j="flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-50",y=s.jsxs("div",{className:l?"flex min-w-0 flex-col gap-2":"mt-2 flex flex-col gap-2","aria-busy":o,children:[x.length>1&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.sites.shared",{names:x.join(", ")})}),n===null&&!c&&s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.sites.loading")}),n?.length===0&&s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.sites.none")}),!!n?.length&&s.jsx("ul",{className:"divide-y divide-hairline/30",children:n.map(e=>s.jsxs("li",{className:"flex min-w-0 items-center gap-2 py-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-ink",title:e.site,children:e.site}),s.jsxs("button",{type:"button",disabled:h,onClick:()=>{f(e.site)},"aria-label":t("settings.sites.signOutOf",{site:e.site}),className:j,children:[s.jsx(k,{size:13}),t("settings.sites.signOut")]})]},e.site))}),!!n?.length&&s.jsxs("button",{type:"button",disabled:h,onClick:()=>{f()},className:`${j} self-start`,children:[s.jsx(k,{size:13}),t("settings.sites.signOutAll")]}),c&&s.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:c})]});return l?y:s.jsxs("details",{className:"min-w-0",onToggle:e=>{e.currentTarget.open&&!o&&g()},children:[s.jsx("summary",{className:"cursor-pointer text-[12px] font-medium text-ink-secondary hover:text-ink",children:t("settings.sites.title")}),y]})}export{E as S};
1
+ import{r,j as s,t}from"./styles-h5tFt3-N.js";import{n as b}from"./App-CbT4-h7t.js";import{a as k}from"./PlacesRail-Cq-ZB7CK.js";function E({target:i,scope:a={},sharedBy:x,disabled:N=!1,bare:l=!1}){const[n,S]=r.useState(null),[o,m]=r.useState(!1),[c,u]=r.useState(""),p=async e=>{m(!0),u("");try{S((await e()).sites)}catch(d){u(d instanceof Error&&d.message?d.message:t("settings.sites.error"))}finally{m(!1)}},g=()=>p(()=>b(`/api/browser-sites?${new URLSearchParams({...i,...a}).toString()}`)),f=e=>p(()=>b("/api/browser-sites/sign-out",{method:"POST",body:JSON.stringify({...i,...a,...e?{site:e}:{}})})),v=`${"bot"in i?`bot:${i.bot}`:`profile:${i.profile}`}${a.threadId?`:${a.threadId}`:""}`;r.useEffect(()=>{l&&g()},[l,v]);const h=N||o,j="flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-50",y=s.jsxs("div",{className:l?"flex min-w-0 flex-col gap-2":"mt-2 flex flex-col gap-2","aria-busy":o,children:[x.length>1&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.sites.shared",{names:x.join(", ")})}),n===null&&!c&&s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.sites.loading")}),n?.length===0&&s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.sites.none")}),!!n?.length&&s.jsx("ul",{className:"divide-y divide-hairline/30",children:n.map(e=>s.jsxs("li",{className:"flex min-w-0 items-center gap-2 py-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-ink",title:e.site,children:e.site}),s.jsxs("button",{type:"button",disabled:h,onClick:()=>{f(e.site)},"aria-label":t("settings.sites.signOutOf",{site:e.site}),className:j,children:[s.jsx(k,{size:13}),t("settings.sites.signOut")]})]},e.site))}),!!n?.length&&s.jsxs("button",{type:"button",disabled:h,onClick:()=>{f()},className:`${j} self-start`,children:[s.jsx(k,{size:13}),t("settings.sites.signOutAll")]}),c&&s.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:c})]});return l?y:s.jsxs("details",{className:"min-w-0",onToggle:e=>{e.currentTarget.open&&!o&&g()},children:[s.jsx("summary",{className:"cursor-pointer text-[12px] font-medium text-ink-secondary hover:text-ink",children:t("settings.sites.title")}),y]})}export{E as S};
@@ -1 +1 @@
1
- import{t as s,j as e,a as j,f as be,r as i,X as jt,S as kt}from"./styles-h5tFt3-N.js";import{L as C,N as Nt,P as vt,r as Xe,O as wt,z as Ue,Q as St,y as le}from"./PlacesRail-Cq-ZB7CK.js";import{bw as Ct,bx as Lt,by as Bt,w as Et,bz as Ye,bA as zt,aQ as Ve,u as Ze,n as N,bB as w,bC as Tt,bD as It,bE as Ot,bF as Rt,bG as Pt,bH as At,bI as He,bJ as Dt,F as $t,bK as Ft}from"./App-DACLgBBp.js";import{o as et,a as Gt,b as Mt,c as _t,d as Ut,t as he,e as Yt,M as Ht}from"./org-library-C5EqhsGN.js";import{t as qt,a as Kt}from"./import-name-BNYqlOCE.js";import{ShareTeamDialog as Jt}from"./ShareTeamDialog-DeHb5M55.js";import{R as Wt}from"./MenuMotion-DQh3Is8R.js";import"./monitor-D4StKPgF.js";import"./index-By-CYMXf.js";import"./package-format-M6l7zHYk.js";import"./team-share-4fayckbz.js";const Qt={"seo growth team":"seoGrowth","engineering team":"engineering","100x marketing team":"marketing100x","reddit lead miner":"redditLeadMiner","competitor watch":"competitorWatch","inbox follow-up":"inboxFollowup"};function tt(a){const o=Qt[a.name.trim().toLowerCase()];return o?{...a,name:s(`templates.catalog.${o}.name`),summary:s(`templates.catalog.${o}.summary`),outcome:a.outcome?s(`templates.catalog.${o}.outcome`):void 0}:a}function Xt(a,o){const m=tt(a);return`${m.name} ${m.summary} ${a.name} ${a.summary} ${a.category} ${a.skills.join(" ")} ${a.requires.apps.join(" ")}`.toLowerCase().includes(o)}const F=["bg-purple-500/15 text-purple-300","bg-cyan-500/15 text-cyan-300","bg-orange-500/15 text-orange-300","bg-emerald-500/15 text-emerald-300"];function Vt({pending:a,importedNames:o,org:m=!1}){return e.jsxs(e.Fragment,{children:[a.description&&e.jsx("p",{className:"max-w-2xl text-[14px] leading-relaxed text-ink-secondary",children:a.description}),a.brief&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.brief")}),e.jsx("p",{className:"mt-1 line-clamp-4 whitespace-pre-wrap break-words",children:a.brief})]}),!!a.warnings?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"mb-2 font-medium text-ink",children:s("templates.backupNotes")}),a.warnings?.map((p,c)=>e.jsx("p",{children:p},c))]}),(a.kind==="package"||a.kind==="backup")&&e.jsxs("div",{className:"mt-5 flex flex-wrap gap-2 text-[12px] text-ink-secondary",children:[a.chiefOfStaff&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ct,{size:13}),s("templates.leads",{name:a.chiefOfStaff})]}),!a.library&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Lt,{size:13}),s("templates.groupChats",{count:a.rooms})]}),!(a.library&&!a.playbooks)&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Bt,{size:13}),s("templates.playbooks",{count:a.playbooks})]}),!a.library&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Et,{size:13}),a.version===2?s("teamImport.routinesPaused",{count:a.routines}):s("templates.pausedRoutines",{count:a.routines})]}),a.kind==="package"&&a.version!==2&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ye,{size:13}),s("templates.connections",{count:a.apps.length})]}),!!a.connections?.length&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ye,{size:13}),s("teamImport.connections",{count:a.connections?.length??0})]}),!!a.notes&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(zt,{size:13}),s("teamImport.notes",{count:a.notes??0})]}),!!a.presets?.length&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ve,{size:13}),s("teamImport.presets",{count:a.presets?.length??0})]})]}),!!a.skills?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:m?s("orgLibrary.skillsOn"):a.version===2?s("teamImport.skillsOff"):s("templates.skillsDisabled")}),e.jsx("p",{className:"mt-1 break-words",children:a.skills?.join(", ")}),!m&&e.jsx("p",{className:"mt-1",children:a.version===2?s("teamImport.skillsReview"):s("templates.skillsReview")})]}),a.library&&!!a.presets?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.presetList")}),e.jsx("p",{className:"mt-1 break-words",children:a.presets?.join(", ")})]}),!!a.offeredSkills?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.offeredSkills")}),e.jsx("p",{className:"mt-1 break-words",children:a.offeredSkills?.join(", ")})]}),!!a.connections?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.connections",{count:a.connections?.length??0})}),e.jsx("ul",{className:"mt-1",children:a.connections?.map((p,c)=>e.jsxs("li",{className:"truncate",children:[p.label," · ",p.url]},`${p.label}-${c}`))})]}),a.members.length>0&&e.jsx("div",{className:"mt-6 text-[12px] font-medium text-ink-secondary",children:s("templates.teamMembers")}),e.jsx("div",{className:"mt-2 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:a.members.map((p,c)=>e.jsxs("div",{className:"flex min-h-[72px] items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[a.pictures?.[c]?e.jsx("img",{src:a.pictures[c],alt:"",className:"size-9 shrink-0 rounded-lg object-cover"}):e.jsx("div",{className:j("flex size-9 shrink-0 items-center justify-center rounded-lg text-[13px] font-semibold",F[c%F.length]),children:p.name.slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-[14px] font-medium text-ink",children:o[c]}),o[c]!==p.name&&e.jsx("div",{className:"text-[12px] text-ink-secondary",children:s("templates.newCopyOf",{name:p.name})}),e.jsx("div",{className:"mt-0.5 truncate text-[13px] text-ink-secondary",children:p.title||s("templates.generalAssistant")})]})]},`${p.name}-${c}`))}),e.jsxs("div",{className:"mt-6 flex items-start gap-2.5 rounded-xl bg-raised/45 px-4 py-3 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx(be,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("p",{children:a.kind==="backup"?s("templates.backupSafety",{archived:a.archivedBots?s("templates.archivedBots",{count:a.archivedBots}):""}):m?a.members.length?s("orgLibrary.teamSafety"):s("orgLibrary.librarySafety"):a.library?s("teamImport.librarySafety"):a.version===2?s("teamImport.sharedTeamSafety"):a.kind==="package"?s("templates.packageSafety"):s("templates.legacySafety")})]})]})}async function Zt(a,o){for(const m of o??[])await fetch(`/api/limix/skill-store/${encodeURIComponent(a)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:m,add:!0})}).catch(()=>{})}const es={gmail:"Gmail",github:"GitHub",discord:"Discord",slack:"Slack",googlecalendar:"Google Calendar",notion:"Notion",linear:"Linear",figma:"Figma",gong:"Gong",hubspot:"HubSpot",postiz:"Postiz"},qe={everyday:"readyBots.category.everyday",work:"readyBots.category.work",writing:"readyBots.category.writing",design:"readyBots.category.design",sales:"readyBots.category.sales",personal:"readyBots.category.personal"},fe=()=>Ot.map(a=>{const o=Rt(a);return{id:a.id,name:a.name,title:o.title,category:a.category,description:o.description,try:o.tryAsking,look:a.look,apps:a.apps,routines:a.routines?.length??0,builtIn:!0}});let $=null;async function ts(){const{bots:a}=await N("/api/limix/bots/refresh",{method:"POST"});return $=a.length?a.map(o=>({...o,builtIn:!1})):null,a.length}const ss=(a,o)=>{const m=o.trim().toLowerCase();return!m||[a.name,a.title,a.description,a.category].some(p=>p.toLowerCase().includes(m))};function as({search:a,onDialog:o,onAdded:m,revision:p=0}){const{state:c,dispatch:h}=Ze(),[y,L]=i.useState(null),[x,f]=i.useState($),[I,G]=i.useState(!1),[E,M]=i.useState(null),[_,U]=i.useState(""),[B,O]=i.useState(null);i.useEffect(()=>{if(p>0){f($??fe()),G(!1);return}let l=!0;return N("/api/limix/bots").then(({bots:b})=>{if(!l)return;const J=b.length?b.map(R=>({...R,builtIn:!1})):fe();$=b.length?J:null,f(J),G(!1)}).catch(()=>{l&&(f($??fe()),G(!$))}),()=>{l=!1}},[p]);const q=()=>{O(null),o(!1)},K=async l=>{if(!(E||Pt(c))){if(U(""),window.ogb?.remoteClient?.active){h({type:"newBot",onCreated:m});return}if(l.builtIn){O({id:l.id}),o(!0);return}M(l.id);try{const{bot:b}=await N(`/api/limix/bots/${l.id}`);O({id:l.id,data:b,skills:b.skills}),o(!0)}catch(b){U(b instanceof Error?b.message:String(b))}finally{M(null)}}};if(!x)return e.jsxs("div",{className:"mb-8 flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(C,{size:15,className:"animate-spin"}),s("templates.loading")]});const T=x.filter(l=>(!y||l.category===y)&&ss(l,a));return a.trim()&&T.length===0?null:e.jsxs("section",{className:"mb-8","aria-labelledby":"ready-bots-title",children:[e.jsxs("div",{className:"mb-1 flex flex-wrap items-baseline justify-between gap-2",children:[e.jsx("h3",{id:"ready-bots-title",className:"text-[12px] font-medium text-ink-secondary",children:s("readyBots.title")}),e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:e.jsx("p",{className:"text-[12px] text-ink-tertiary",role:"status","aria-live":"polite",children:I?w("Đang dùng bản có sẵn trong ứng dụng (chưa tải được kho mẫu).","Showing the bots built into the app (the template library could not be loaded)."):s("readyBots.subtitle")})})]}),e.jsx("div",{className:"mb-3 mt-2 flex flex-wrap gap-1.5",role:"group","aria-label":s("readyBots.categories"),children:[null,...Tt].map(l=>e.jsx("button",{type:"button","aria-pressed":y===l,onClick:()=>L(l),className:j("rounded-full px-3 py-1 text-[13px] transition-colors",y===l?"bg-ink text-panel":"bg-raised/70 text-ink-secondary hover:text-ink"),children:l?s(qe[l]):s("readyBots.all")},l??"all"))}),_&&e.jsx("p",{role:"alert",className:"mb-3 rounded-xl bg-danger/10 px-3 py-2 text-[13px] text-danger",children:_}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-3",children:T.map(l=>e.jsxs("article",{"data-ready-bot":l.id,className:"flex flex-col rounded-2xl border border-hairline/40 bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Nt,{color:l.look.color,bodyId:l.look.mascotBody,size:40,animated:!1,label:l.name}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"truncate text-[14px] font-medium text-ink",children:l.name}),e.jsxs("p",{className:"truncate text-[12px] text-ink-secondary",children:[l.title," · ",s(qe[l.category])]})]}),e.jsxs("button",{type:"button",onClick:()=>{K(l)},disabled:E!==null,"aria-label":w(`Dùng mẫu ${l.name}, ${l.title}`,`Use template ${l.name}, ${l.title}`),className:"flex h-8 shrink-0 items-center gap-1 rounded-full bg-raised px-3 text-[13px] font-medium text-ink hover:bg-raised-hover disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-accent",children:[E===l.id?e.jsx(C,{size:14,className:"animate-spin","aria-hidden":"true"}):e.jsx(vt,{size:14,"aria-hidden":"true"}),w("Dùng mẫu","Use template")]})]}),e.jsx("p",{className:"mt-3 text-[13px] leading-[1.45] text-ink-secondary",children:l.description}),e.jsx("p",{className:"mt-2 text-[12px] italic text-ink-tertiary",children:s("readyBots.try",{prompt:l.try})}),(l.apps.length>0||l.routines>0)&&e.jsx("p",{className:"mt-auto pt-2 text-[12px] text-ink-tertiary",children:[l.apps.length>0&&s("readyBots.worksWith",{apps:l.apps.map(b=>es[b]??b).join(", ")}),l.routines>0&&s("readyBots.pausedRoutine")].filter(Boolean).join(" · ")})]},l.id))}),B&&Xe.createPortal(e.jsx(It,{readyBotId:B.id,readyBotData:B.data,onClose:q,onCreated:l=>{o(!1),Zt(l.id,B.skills),m(l)}}),document.body)]})}const Ke=["bg-cyan-500/15 text-cyan-300","bg-purple-500/15 text-purple-300","bg-emerald-500/15 text-emerald-300","bg-orange-500/15 text-orange-300"];function rs({listing:a,busy:o,notice:m,error:p,onAdd:c,onDetails:h}){const y=a.organization.name;return e.jsxs("div",{children:[e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:s("orgLibrary.intro",{name:y})}),a.packages.length===0?e.jsx("p",{className:"mt-6 text-[13px] text-ink-secondary",children:s("orgLibrary.empty",{name:y})}):e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:a.packages.map((L,x)=>e.jsx(ns,{entry:L,index:x,busy:o,onAdd:c,onDetails:h},L.packageId))}),m&&e.jsx("div",{role:"status",className:"mt-4 rounded-lg bg-raised/60 px-3 py-2 text-[13px] text-ink-secondary",children:m}),p&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:p})]})}function ns({entry:a,index:o,busy:m,onAdd:p,onDetails:c}){const h=et(a),y=Gt(a),L=Mt(a),x=m===a.packageId;return e.jsxs("article",{className:"flex min-h-[104px] items-center gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx("div",{className:j("flex size-11 shrink-0 items-center justify-center rounded-xl",Ke[o%Ke.length]),children:e.jsx(wt,{size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-medium text-ink",children:a.name}),e.jsx("p",{className:"mt-0.5 truncate text-[13px] text-ink-secondary",children:a.tagline}),e.jsxs("p",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-[12px] text-ink-tertiary",children:[e.jsx("span",{children:_t(a)}),y&&e.jsx("span",{className:"rounded-full bg-accent/10 px-2 py-0.5 text-accent-text",children:y}),a.release&&e.jsx("span",{children:a.release.version})]}),e.jsx("p",{className:"mt-0.5 truncate text-[12px] text-ink-tertiary",children:Ut(a.contents)}),L.map(f=>e.jsx("p",{className:"mt-0.5 text-[12px] text-warning",children:f},f))]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[h==="add"&&e.jsxs("button",{onClick:()=>p(a),disabled:m!==null,"aria-label":s("orgLibrary.addAria",{name:a.name}),className:"flex min-w-[72px] items-center justify-center gap-1.5 rounded-full bg-accent px-3.5 py-2 text-[13px] font-medium text-white hover:bg-accent/90 disabled:opacity-40",children:[x&&e.jsx(C,{size:13,className:"animate-spin"}),x?s("orgLibrary.adding"):s("orgLibrary.add")]}),h==="added"&&e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-raised px-3 py-1.5 text-[12px] text-ink-secondary",children:[e.jsx(be,{size:13,className:"text-success"}),s("orgLibrary.added")]}),h==="updateApp"&&e.jsx("span",{className:"max-w-[140px] text-right text-[12px] text-ink-secondary",children:s("orgLibrary.updateApp")}),h==="notReady"&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("orgLibrary.notReady")}),h==="noRelease"&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("orgLibrary.noRelease")}),a.blob==="ready"&&e.jsx("button",{onClick:()=>c(a),disabled:m!==null,"aria-label":s("orgLibrary.detailsAria",{name:a.name}),className:"rounded-full px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-40",children:s("orgLibrary.details")})]})]})}const is="https://github.com/leomieo/limix-bot-teams",Je=["cyan","red","purple","green","orange"];async function We(a){if(window.ogb?.openExternal){await window.ogb.openExternal(a);return}const o=window.open(a,"_blank","noopener,noreferrer");o&&(o.opener=null)}function ls(a,o){const m=new Map;for(const c of o){if(c.hidden)continue;const h=c.section?.trim()??"";m.set(h,(m.get(h)??0)+1)}return[...[...new Set([...a.map(c=>c.trim()).filter(Boolean),...m.keys()])].filter(c=>c!==""),""].flatMap(c=>m.get(c)?[{name:c,bots:m.get(c)}]:[])}function Qe({index:a}){return e.jsx("div",{className:j("flex size-11 shrink-0 items-center justify-center rounded-xl",F[a%F.length]),children:e.jsx(Ve,{size:20})})}function ys({onClose:a,onImported:o,returnFocusRef:m,initialUrl:p}){const{state:c,dispatch:h}=Ze(),y=i.useRef(null),L=i.useRef(null),[x,f]=i.useState("explore"),[I,G]=i.useState(null),[E,M]=i.useState(!0),[_,U]=i.useState(""),[B,O]=i.useState(!1),[q,K]=i.useState(""),[T,l]=i.useState(""),[b,J]=i.useState(0),R=i.useRef(0),[oe,ye]=i.useState(null),[d,Y]=i.useState(null),[st,at]=i.useState("file"),[ce,je]=i.useState(""),[ke,Ne]=i.useState(!1),[S,W]=i.useState(!1),[rt,de]=i.useState(!1),[me,nt]=i.useState(""),[P,u]=i.useState(""),[ve,we]=i.useState(""),[Q,Se]=i.useState(!1),[k,Ce]=i.useState(null),[it,lt]=i.useState(""),[X,xe]=i.useState(null),[Le,Be]=i.useState(new Set),[Ee,ze]=i.useState(""),[V,Te]=i.useState(!1),[Z,Ie]=i.useState(null),[Oe,ot]=i.useState(!1),[ee,Re]=i.useState(null),[ct,te]=i.useState(null),[dt,Pe]=i.useState(""),[mt,se]=i.useState(""),[A,ae]=i.useState(null),z=i.useRef(!1),D=i.useRef(0),pe=c.bots.filter(t=>!t.hidden).length,Ae=ls(c.sections??[],c.bots),xt=new Set(c.bots.map(t=>t.name.trim().toLowerCase())),pt=d?.members.map(t=>qt(t.name,xt))??[],re=i.useCallback(async(t=!1)=>{const r=++R.current;M(!0),U("");try{const n=await N(`/api/team-library/catalog${t?"?fresh=1":""}`);return r===R.current&&G(n),!0}catch(n){return r===R.current&&U(n instanceof Error?n.message:String(n)),!1}finally{r===R.current&&M(!1)}},[]),ut=async()=>{if(!B){O(!0),K(""),l("");try{const[t,r]=await Promise.allSettled([ts(),re(!0)]);if(t.status==="fulfilled"&&J(n=>n+1),t.status==="fulfilled"&&r.status==="fulfilled"&&r.value)K(w("Đã cập nhật mẫu Bot và mẫu nhóm Bot.","Bot and team templates updated."));else{const n=[...t.status==="rejected"?[w("mẫu Bot","bot templates")]:[],...r.status==="rejected"||!r.value?[w("mẫu nhóm Bot","team templates")]:[]];l(w(`Chưa cập nhật được ${n.join(", ")}. Hãy thử lại.`,`Could not update ${n.join(", ")}. Please retry.`))}}finally{O(!1)}}};i.useEffect(()=>{re()},[re]);const ne=i.useCallback(async()=>{try{const t=await N("/api/org-library");Re(t),t.organization&&!z.current&&f("org")}catch{Re({organization:null,packages:[]})}},[]);i.useEffect(()=>{ne()},[ne]),i.useEffect(()=>(y.current?.focus(),()=>m.current?.focus()),[m]),i.useEffect(()=>{const t=r=>{if(Z!==null||Oe)return;if(r.key==="Escape"&&!S){r.preventDefault(),r.stopPropagation(),d?(Y(null),ae(null)):a();return}if(r.key!=="Tab")return;const n=y.current,g=Array.from(n?.querySelectorAll('button:not([disabled]), a[href], input:not([disabled]), [tabindex]:not([tabindex="-1"])')??[]);if(!n||g.length===0)return;const v=g[0],ie=g.at(-1);r.shiftKey&&(document.activeElement===v||!n.contains(document.activeElement))?(r.preventDefault(),ie.focus()):!r.shiftKey&&document.activeElement===ie&&(r.preventDefault(),v.focus())};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[S,a,d,Z,Oe]);const ue=(t,r)=>{Y(t),at(r),u("")},De=async t=>{if(t.size>Ht)throw new Error(s("templates.fileTooLarge"));const r=await t.text();let n=r;if(!t.name.toLowerCase().endsWith(".md"))try{n=JSON.parse(r)}catch(g){throw g instanceof SyntaxError?new Error(s("teamLibrary.invalidJson")):g}ue(he(n),"file")},gt=async t=>{ye(t.slug),u("");try{ue(he(await N(`/api/team-library/teams/${t.slug}`)),"library")}catch(r){u(r instanceof Error?r.message:String(r))}finally{ye(null)}},$e=async()=>{await Fe(ce)},Fe=async t=>{if(t.trim()){Ne(!0),u("");try{const r=await N("/api/team-library/github",{method:"POST",body:JSON.stringify({url:t.trim()})});ue(he(r),"github")}catch(r){u(r instanceof Error?r.message:String(r))}finally{Ne(!1)}}};i.useEffect(()=>{p&&(z.current=!0,f("import"),je(p),Fe(p))},[p]);const ht=async()=>{if(d){W(!0),u("");try{const t=await Kt(d.manifest,h);le("team_imported",{members:t.bots.length,source:st,mode:"add",format:d.kind}),o({name:d.name,members:t.bots.length,...t.connections?.length?{connections:t.connections.length}:{},...t.presets?.length?{presets:t.presets.length}:{}})}catch(t){u(t instanceof Error?t.message:String(t))}finally{W(!1)}}},ft=async t=>{te(t.packageId),se("");try{const r=await N(`/api/org-library/packages/${t.packageId}`);Y(Yt(r.document)),ae(t),u("")}catch(r){se(r instanceof Error?r.message:String(r))}finally{te(null)}},Ge=async t=>{te(t.packageId),W(!0),se(""),Pe(""),u("");try{const r=await N("/api/org-library/add",{method:"POST",body:JSON.stringify({packageId:t.packageId})});for(const g of r.bots??[])h({type:"botAdded",bot:g});for(const g of r.groups??[])h({type:"groupPatched",group:g});for(const g of r.routines??[])h({type:"routinePatched",routine:g});const n=r.bots?.find(g=>!g.hidden);if(le("team_imported",{members:r.bots?.length??0,source:"organization",mode:"add",format:"package"}),n){h({type:"select",id:n.id}),o({name:t.name,members:r.bots.length,...r.connections?.length?{connections:r.connections.length}:{}});return}Y(null),ae(null),r.alreadyAdded||Pe(s("orgLibrary.addedSkills",{name:t.name})),await ne()}catch(r){const n=r instanceof Error?r.message:String(r);A?u(n):se(n),await ne()}finally{te(null),W(!1)}},H=ve.trim(),ge=async t=>{const r=++D.current;Se(!0),u(""),Ce(null),xe(null),Be(new Set);try{const n=await N(`/api/teams/scout?cwd=${encodeURIComponent(t)}`);if(r!==D.current)return;Ce(n),lt(t),ze(n.suggestion.roomName),le("team_scouted",{signals:n.suggestion.manifest.team.members.length-1}),N(`/api/teams/scout/directory?cwd=${encodeURIComponent(t)}`).then(g=>{r===D.current&&xe(g.directory)}).catch(()=>{r===D.current&&xe([])})}catch(n){if(r!==D.current)return;u(n instanceof Error?n.message:String(n))}finally{r===D.current&&Se(!1)}},bt=async()=>{const t=await window.ogb?.pickFolder?.(H||void 0);t&&(we(t),await ge(t))},yt=async()=>{if(!(!k||V)){Te(!0),u("");try{const t=(X??[]).filter(v=>Le.has(v.slug)).map((v,ie)=>({key:`dir-${v.slug}`,name:v.name,title:v.category||s("templates.communityBot"),description:v.prompt,appearance:{color:Je[ie%Je.length]}})),r={...k.suggestion.manifest,team:{...k.suggestion.manifest.team,members:[...k.suggestion.manifest.team.members,...t]}},n=Ee.trim()||k.suggestion.roomName,g=await N(`/api/teams/import?mode=project&cwd=${encodeURIComponent(it)}&room=${encodeURIComponent(n)}`,{method:"POST",body:JSON.stringify(r)});for(const v of g.bots)h({type:"botAdded",bot:v});g.group&&(h({type:"groupPatched",group:{...g.group,messages:[]}}),h({type:"select",id:g.group.id})),le("team_imported",{members:g.bots.length,source:"scout",mode:"project"}),o({name:n,members:g.bots.length})}catch(t){u(t instanceof Error?t.message:String(t))}finally{Te(!1)}}},Me=me.trim().toLowerCase(),_e=(I?.teams??[]).filter(t=>!Me||Xt(t,Me));return Xe.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/55 p-4 sm:p-6",onMouseDown:t=>t.stopPropagation(),children:[e.jsxs("div",{ref:y,role:"dialog","aria-modal":"true","aria-labelledby":"team-library-title",tabIndex:-1,className:"animate-pop-in flex h-[min(780px,calc(100dvh-2rem))] w-full max-w-[1040px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel shadow-2xl shadow-black/50 outline-none",children:[e.jsxs("header",{className:"flex items-start justify-between gap-4 px-6 pb-3 pt-6 sm:px-8 sm:pt-7",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d&&e.jsx("button",{onClick:()=>{Y(null),ae(null),u("")},disabled:S,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":s("templates.back"),children:e.jsx(At,{size:18})}),e.jsx("h2",{id:"team-library-title",className:"truncate text-[22px] font-semibold tracking-[-0.01em] text-ink",children:d?d.name:s("templates.title")})]}),e.jsx("p",{className:j("mt-1 text-[13px] text-ink-secondary",d&&"ml-9"),children:d?d.kind==="backup"?s("templates.backupSummary",{bots:d.members.length,conversations:d.conversations??0}):d.kind==="package"?d.library?s("teamImport.library"):d.version===2?s("teamImport.sharedTeam",{count:d.members.length}):s("templates.playbookSummary",{count:d.members.length}):s("templates.readyBots",{count:d.members.length}):s("templates.subtitle")})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[!d&&e.jsxs("button",{onClick:()=>{We(I?.repositoryUrl??is)},className:"flex items-center gap-1.5 rounded-lg px-2.5 py-2 text-[13px] text-ink-secondary hover:bg-raised hover:text-ink",title:s("templates.openRepository"),children:[e.jsx(He,{size:16}),e.jsx("span",{className:"max-sm:hidden",children:s("templates.communityRepo")}),e.jsx(Ue,{size:12})]}),e.jsx("button",{onClick:a,disabled:S,className:"rounded-lg p-2 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":s("templates.close"),children:e.jsx(jt,{size:21})})]})]}),d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-6 pt-6 sm:px-8",children:[e.jsx(Vt,{pending:d,importedNames:pt,org:A!==null}),P&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:P})]}),e.jsxs("footer",{className:"flex flex-col gap-3 border-t border-hairline/35 px-6 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-8",children:[e.jsxs("div",{className:"text-[13px] text-ink-secondary",children:[s(pe===0?"templates.existingNone":pe===1?"templates.existingOne":"templates.existingMany",{count:pe})," ",d.kind==="backup"?s("teamImport.backupCopies"):d.library?s("teamImport.libraryAdds"):d.members.length===0?"":s("teamImport.newSection",{name:d.teamName??d.name})]}),A?et(A)==="add"?e.jsxs("button",{onClick:()=>{Ge(A)},disabled:S,"aria-label":s("orgLibrary.addAria",{name:A.name}),className:"flex shrink-0 items-center justify-center gap-2 rounded-full bg-accent px-5 py-2.5 text-[14px] font-medium text-white hover:bg-accent/90 disabled:opacity-60",children:[S&&e.jsx(C,{size:15,className:"animate-spin"}),S?s("orgLibrary.adding"):s("orgLibrary.add")]}):e.jsxs("span",{className:"flex shrink-0 items-center gap-1 rounded-full bg-raised px-4 py-2 text-[13px] text-ink-secondary",children:[e.jsx(be,{size:14,className:"text-success"}),s("orgLibrary.added")]}):e.jsxs("button",{onClick:()=>{ht()},disabled:S,className:"flex shrink-0 items-center justify-center gap-2 rounded-full bg-accent px-5 py-2.5 text-[14px] font-medium text-white hover:bg-accent/90 disabled:opacity-60",children:[S&&e.jsx(C,{size:15,className:"animate-spin"}),S?s("templates.importing"):d.kind==="backup"?s("templates.importBackup"):d.library?s("teamImport.addPresets"):s("templates.addTeam")]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-6 pb-4 pt-5 sm:px-8",children:[e.jsxs("div",{className:"flex max-w-full flex-wrap rounded-xl bg-raised/70 p-1",role:"tablist","aria-label":s("templates.source"),children:[ee?.organization&&e.jsx("button",{role:"tab","aria-selected":x==="org",onClick:()=>{z.current=!0,f("org"),u("")},className:j("max-w-[220px] truncate rounded-lg px-4 py-2 text-[14px] transition-colors",x==="org"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("orgLibrary.tab",{name:ee.organization.name})}),e.jsx("button",{role:"tab","aria-selected":x==="explore",onClick:()=>{z.current=!0,f("explore"),u("")},className:j("rounded-lg px-4 py-2 text-[14px] transition-colors",x==="explore"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("templates.explore")}),e.jsx("button",{role:"tab","aria-selected":x==="import",onClick:()=>{z.current=!0,f("import"),u("")},className:j("rounded-lg px-4 py-2 text-[14px] transition-colors",x==="import"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("templates.import")}),e.jsx("button",{role:"tab","aria-selected":x==="scout",onClick:()=>{z.current=!0,f("scout"),u("")},className:j("rounded-lg px-4 py-2 text-[14px] transition-colors",x==="scout"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("templates.fromFolder")}),e.jsx("button",{role:"tab","aria-selected":x==="share",onClick:()=>{z.current=!0,f("share"),u("")},className:j("rounded-lg px-4 py-2 text-[14px] transition-colors",x==="share"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("teamLibrary.shareTab")}),e.jsx("button",{role:"tab","aria-selected":x==="teams",onClick:()=>{z.current=!0,f("teams"),u("")},className:j("rounded-lg px-4 py-2 text-[14px] transition-colors",x==="teams"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:w("Bản mẫu Nhóm","Team templates")})]}),e.jsxs("button",{type:"button",onClick:()=>{ut()},disabled:B,title:w("Tải lại mẫu Bot và mẫu nhóm Bot mới nhất từ kho","Reload the latest bot and team templates"),className:"flex h-10 shrink-0 items-center gap-1.5 rounded-xl bg-raised/70 px-3 text-[13px] font-medium text-ink hover:bg-raised-hover disabled:opacity-60",children:[e.jsx(Wt,{size:14,"aria-hidden":"true",className:B?"animate-spin":void 0}),B?w("Đang cập nhật","Updating"):w("Cập nhật","Update")]}),(x==="explore"||x==="teams")&&e.jsxs("label",{className:"flex h-11 w-full items-center gap-2.5 rounded-xl bg-raised/70 px-3.5 sm:ml-auto sm:w-[240px]",children:[e.jsx(kt,{size:17,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:me,onChange:t=>nt(t.target.value),placeholder:s("templates.search"),"aria-label":s("templates.search"),className:"min-w-0 flex-1 bg-transparent text-[14px] text-ink placeholder:text-ink-secondary focus:outline-none"})]})]}),(q||T)&&e.jsx("p",{role:T?"alert":"status",className:j("px-6 pb-2 text-[13px] sm:px-8",T?"text-danger":"text-ink-secondary"),children:T||q}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-7 pt-5 sm:px-8",children:[x==="org"&&ee?.organization&&e.jsx(rs,{listing:ee,busy:ct,notice:dt,error:mt,onAdd:t=>{Ge(t)},onDetails:t=>{ft(t)}}),x==="explore"&&e.jsx(as,{revision:b,search:me,onDialog:ot,onAdded:a}),x==="teams"&&e.jsxs("div",{children:[E&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-24 text-[13px] text-ink-secondary",children:[e.jsx(C,{size:16,className:"animate-spin"})," ",s("templates.loading")]}),!E&&_&&e.jsxs("div",{className:"rounded-xl bg-danger/10 p-4 text-[13px] text-danger",children:[e.jsx("p",{children:_}),e.jsx("button",{onClick:()=>{re()},className:"mt-3 rounded-full bg-raised px-3.5 py-2 text-ink hover:bg-raised-hover",children:s("common.tryAgain")})]}),!E&&I&&e.jsx("div",{className:"grid grid-cols-1 gap-x-10 md:grid-cols-2",children:_e.map((t,r)=>{const n=tt(t);return e.jsxs("article",{className:"flex min-h-[104px] items-center gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx(Qe,{index:r}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-medium text-ink",children:n.name}),e.jsx("p",{className:"mt-0.5 truncate text-[13px] text-ink-secondary",children:n.outcome??n.summary}),e.jsxs("p",{className:"mt-1 truncate text-[12px] text-ink-tertiary",children:[s("templates.botCount",{count:t.members})," · ",s("templates.playbookCount",{count:t.skills.length}),t.requires.apps.length>0&&` · ${t.requires.apps.join(", ")}`,t.setupMinutes&&` · ${s("templates.minutes",{count:t.setupMinutes})}`]})]}),e.jsxs("button",{onClick:()=>{gt(t)},disabled:oe!==null,className:"flex min-w-[72px] items-center justify-center gap-1.5 rounded-full bg-raised px-3.5 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-40",children:[oe===t.slug&&e.jsx(C,{size:13,className:"animate-spin"}),oe===t.slug?s("templates.loadingShort"):s("templates.load")]})]},t.slug)})}),!E&&I&&_e.length===0&&e.jsxs("div",{className:"flex min-h-56 flex-col items-center justify-center text-center",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("templates.noneFound")}),e.jsx("div",{className:"mt-1 text-[13px] text-ink-secondary",children:s("templates.tryDifferentSearch")})]})]}),x==="import"&&e.jsxs("div",{children:[e.jsx("input",{ref:L,type:"file",accept:".md,.json,.mausbackup.json,.mausteam.json,text/markdown,application/json",className:"hidden",onChange:t=>{const r=t.currentTarget.files?.[0];t.currentTarget.value="",r&&De(r).catch(n=>u(n instanceof Error?n.message:String(n)))}}),e.jsx("div",{className:"mb-3 text-[12px] font-medium text-ink-secondary",children:s("templates.bringYourOwn")}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("button",{onClick:()=>L.current?.click(),onDragEnter:t=>{t.preventDefault(),de(!0)},onDragOver:t=>t.preventDefault(),onDragLeave:()=>de(!1),onDrop:t=>{t.preventDefault(),de(!1);const r=t.dataTransfer.files[0];r&&De(r).catch(n=>u(n instanceof Error?n.message:String(n)))},className:j("flex min-h-56 flex-col items-center justify-center rounded-2xl border border-dashed px-6 text-center transition-colors",rt?"border-accent bg-accent/5":"border-hairline/60 bg-raised/20 hover:bg-raised/35"),children:[e.jsx(St,{size:27,className:"text-accent"}),e.jsx("span",{className:"mt-3 text-[14px] font-medium text-ink",children:s("templates.chooseFile")}),e.jsx("span",{className:"mt-1 text-[13px] text-ink-secondary",children:s("templates.dropFile")})]}),e.jsxs("div",{className:"flex min-h-56 flex-col justify-center rounded-2xl bg-raised/25 px-6",children:[e.jsx(He,{size:25,className:"text-ink-secondary"}),e.jsx("h3",{className:"mt-3 text-[14px] font-medium text-ink",children:s("templates.loadGithub")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("templates.githubHint")}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("input",{value:ce,onChange:t=>je(t.target.value),onKeyDown:t=>t.key==="Enter"&&void $e(),placeholder:s("templates.githubPlaceholder"),"aria-label":s("templates.githubUrl"),className:"min-w-0 flex-1 rounded-xl bg-raised/80 px-3 py-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),e.jsxs("button",{onClick:()=>{$e()},disabled:!ce.trim()||ke,className:"flex items-center gap-1.5 rounded-full bg-accent px-4 py-2.5 text-[13px] font-medium text-white hover:bg-accent/90 disabled:opacity-40",children:[ke&&e.jsx(C,{size:13,className:"animate-spin"}),s("templates.load")]})]})]})]}),P&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:P})]}),x==="share"&&e.jsxs("div",{children:[e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:s("teamLibrary.shareIntro")}),Ae.length===0?e.jsx("p",{className:"mt-6 text-[13px] text-ink-secondary",children:s("teamLibrary.shareEmpty")}):e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:Ae.map((t,r)=>e.jsxs("article",{className:"flex min-h-[84px] items-center gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx(Qe,{index:r}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-medium text-ink",children:t.name||s("teamLibrary.general")}),e.jsx("p",{className:"mt-0.5 text-[13px] text-ink-secondary",children:s("teamLibrary.shareBots",{count:t.bots})})]}),e.jsxs("button",{onClick:()=>Ie(t.name),"aria-label":s("teamLibrary.shareTeamAria",{name:t.name||s("teamLibrary.general")}),className:"flex items-center gap-1.5 rounded-full bg-raised px-3.5 py-2 text-[13px] text-ink hover:bg-raised-hover",children:[e.jsx(Dt,{size:13}),s("teamLibrary.shareTeam")]})]},t.name||"general"))})]}),x==="scout"&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-3 text-[12px] font-medium text-ink-secondary",children:s("templates.startFolder")}),e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:s("templates.scoutHint")}),e.jsxs("div",{className:"mt-4 flex flex-col gap-2 sm:flex-row",children:[e.jsx("input",{value:ve,onChange:t=>we(t.target.value),onKeyDown:t=>t.key==="Enter"&&H&&void ge(H),placeholder:"/path/to/your/project","aria-label":s("templates.projectFolder"),className:"min-w-0 flex-1 rounded-xl bg-raised/80 px-3 py-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),!!window.ogb?.pickFolder&&e.jsxs("button",{onClick:()=>{bt()},disabled:Q,className:"flex items-center justify-center gap-1.5 rounded-full bg-raised px-4 py-2.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-40",children:[e.jsx($t,{size:14}),s("templates.browse")]}),e.jsxs("button",{onClick:()=>{ge(H)},disabled:!H||Q,className:"flex items-center justify-center gap-1.5 rounded-full bg-accent px-4 py-2.5 text-[13px] font-medium text-white hover:bg-accent/90 disabled:opacity-40",children:[Q?e.jsx(C,{size:14,className:"animate-spin"}):e.jsx(Ft,{size:14}),Q?s("templates.scouting"):s("templates.scout")]})]}),k&&e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"rounded-2xl bg-raised/25 px-5 py-4",children:[e.jsx("div",{className:"text-[15px] font-semibold text-ink",children:k.profile.name}),k.profile.summary&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:k.profile.summary}),k.profile.stacks.length>0&&e.jsx("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:k.profile.stacks.map(t=>e.jsx("span",{className:"rounded-full bg-raised px-2.5 py-1 text-[12px] text-ink-secondary",children:t},t))})]}),e.jsx("div",{className:"mt-5 text-[12px] font-medium text-ink-secondary",children:s("templates.suggestedTeam")}),e.jsx("div",{className:"mt-1 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:k.suggestion.manifest.team.members.map((t,r)=>e.jsxs("div",{className:"flex min-h-[64px] items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[e.jsx("div",{className:j("flex size-9 shrink-0 items-center justify-center rounded-lg text-[13px] font-semibold",F[r%F.length]),children:t.name.slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"truncate text-[14px] font-medium text-ink",children:[t.name," ",e.jsxs("span",{className:"font-normal text-ink-secondary",children:["· ",t.title]})]}),e.jsx("div",{className:"mt-0.5 truncate text-[12px] text-ink-secondary",children:k.suggestion.reasons[t.key]??""})]})]},t.key))}),X&&X.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-5 text-[12px] font-medium text-ink-secondary",children:s("templates.communityDirectory")}),e.jsx("div",{className:"mt-1 flex flex-col",children:X.map(t=>e.jsxs("div",{className:"flex items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:Le.has(t.slug),onChange:()=>Be(r=>{const n=new Set(r);return n.has(t.slug)?n.delete(t.slug):n.add(t.slug),n}),className:"size-4 accent-accent"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"truncate text-[14px] font-medium text-ink",children:[t.name,t.category&&e.jsxs("span",{className:"font-normal text-ink-secondary",children:[" · ",t.category]})]}),e.jsx("div",{className:"mt-0.5 truncate text-[12px] text-ink-secondary",children:s("templates.matches",{values:t.matched.join(", ")})})]})]}),e.jsx("button",{onClick:()=>{We(t.detailUrl)},"aria-label":s("templates.openDirectory",{name:t.name}),title:s("templates.readBeforeAdding"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(Ue,{size:14})})]},t.slug))})]}),e.jsxs("div",{className:"mt-6 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx("input",{value:Ee,onChange:t=>ze(t.target.value),"aria-label":s("templates.groupChatName"),className:"min-w-0 flex-1 rounded-xl bg-raised/80 px-3 py-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),e.jsxs("button",{onClick:()=>{yt()},disabled:V,className:"flex shrink-0 items-center justify-center gap-2 rounded-full bg-accent px-5 py-2.5 text-[14px] font-medium text-white hover:bg-accent/90 disabled:opacity-60",children:[V&&e.jsx(C,{size:15,className:"animate-spin"}),V?s("templates.creating"):s("templates.createGroupChat")]})]}),e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("templates.createGroupHint")})]}),P&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:P})]})]})]})]}),Z!==null&&e.jsx(Jt,{team:Z,onClose:()=>Ie(null)})]}),document.body)}export{Vt as TeamImportDetails,ys as TeamLibraryPanel,ls as shareableTeamList};
1
+ import{t as s,j as e,a as j,f as be,r as i,X as jt,S as kt}from"./styles-h5tFt3-N.js";import{L as C,N as Nt,P as vt,r as Xe,O as wt,z as Ue,Q as St,y as le}from"./PlacesRail-Cq-ZB7CK.js";import{bw as Ct,bx as Lt,by as Bt,w as Et,bz as Ye,bA as zt,aQ as Ve,u as Ze,n as N,bB as w,bC as Tt,bD as It,bE as Ot,bF as Rt,bG as Pt,bH as At,bI as He,bJ as Dt,F as $t,bK as Ft}from"./App-CbT4-h7t.js";import{o as et,a as Gt,b as Mt,c as _t,d as Ut,t as he,e as Yt,M as Ht}from"./org-library-xIxGs5VY.js";import{t as qt,a as Kt}from"./import-name-BujoBk4Y.js";import{ShareTeamDialog as Jt}from"./ShareTeamDialog-iiKMHE9O.js";import{R as Wt}from"./MenuMotion-DQh3Is8R.js";import"./monitor-D4StKPgF.js";import"./index-BTJoFn8A.js";import"./package-format-DFnnhVuV.js";import"./team-share-4fayckbz.js";const Qt={"seo growth team":"seoGrowth","engineering team":"engineering","100x marketing team":"marketing100x","reddit lead miner":"redditLeadMiner","competitor watch":"competitorWatch","inbox follow-up":"inboxFollowup"};function tt(a){const o=Qt[a.name.trim().toLowerCase()];return o?{...a,name:s(`templates.catalog.${o}.name`),summary:s(`templates.catalog.${o}.summary`),outcome:a.outcome?s(`templates.catalog.${o}.outcome`):void 0}:a}function Xt(a,o){const m=tt(a);return`${m.name} ${m.summary} ${a.name} ${a.summary} ${a.category} ${a.skills.join(" ")} ${a.requires.apps.join(" ")}`.toLowerCase().includes(o)}const F=["bg-purple-500/15 text-purple-300","bg-cyan-500/15 text-cyan-300","bg-orange-500/15 text-orange-300","bg-emerald-500/15 text-emerald-300"];function Vt({pending:a,importedNames:o,org:m=!1}){return e.jsxs(e.Fragment,{children:[a.description&&e.jsx("p",{className:"max-w-2xl text-[14px] leading-relaxed text-ink-secondary",children:a.description}),a.brief&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.brief")}),e.jsx("p",{className:"mt-1 line-clamp-4 whitespace-pre-wrap break-words",children:a.brief})]}),!!a.warnings?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"mb-2 font-medium text-ink",children:s("templates.backupNotes")}),a.warnings?.map((p,c)=>e.jsx("p",{children:p},c))]}),(a.kind==="package"||a.kind==="backup")&&e.jsxs("div",{className:"mt-5 flex flex-wrap gap-2 text-[12px] text-ink-secondary",children:[a.chiefOfStaff&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ct,{size:13}),s("templates.leads",{name:a.chiefOfStaff})]}),!a.library&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Lt,{size:13}),s("templates.groupChats",{count:a.rooms})]}),!(a.library&&!a.playbooks)&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Bt,{size:13}),s("templates.playbooks",{count:a.playbooks})]}),!a.library&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Et,{size:13}),a.version===2?s("teamImport.routinesPaused",{count:a.routines}):s("templates.pausedRoutines",{count:a.routines})]}),a.kind==="package"&&a.version!==2&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ye,{size:13}),s("templates.connections",{count:a.apps.length})]}),!!a.connections?.length&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ye,{size:13}),s("teamImport.connections",{count:a.connections?.length??0})]}),!!a.notes&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(zt,{size:13}),s("teamImport.notes",{count:a.notes??0})]}),!!a.presets?.length&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ve,{size:13}),s("teamImport.presets",{count:a.presets?.length??0})]})]}),!!a.skills?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:m?s("orgLibrary.skillsOn"):a.version===2?s("teamImport.skillsOff"):s("templates.skillsDisabled")}),e.jsx("p",{className:"mt-1 break-words",children:a.skills?.join(", ")}),!m&&e.jsx("p",{className:"mt-1",children:a.version===2?s("teamImport.skillsReview"):s("templates.skillsReview")})]}),a.library&&!!a.presets?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.presetList")}),e.jsx("p",{className:"mt-1 break-words",children:a.presets?.join(", ")})]}),!!a.offeredSkills?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.offeredSkills")}),e.jsx("p",{className:"mt-1 break-words",children:a.offeredSkills?.join(", ")})]}),!!a.connections?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.connections",{count:a.connections?.length??0})}),e.jsx("ul",{className:"mt-1",children:a.connections?.map((p,c)=>e.jsxs("li",{className:"truncate",children:[p.label," · ",p.url]},`${p.label}-${c}`))})]}),a.members.length>0&&e.jsx("div",{className:"mt-6 text-[12px] font-medium text-ink-secondary",children:s("templates.teamMembers")}),e.jsx("div",{className:"mt-2 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:a.members.map((p,c)=>e.jsxs("div",{className:"flex min-h-[72px] items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[a.pictures?.[c]?e.jsx("img",{src:a.pictures[c],alt:"",className:"size-9 shrink-0 rounded-lg object-cover"}):e.jsx("div",{className:j("flex size-9 shrink-0 items-center justify-center rounded-lg text-[13px] font-semibold",F[c%F.length]),children:p.name.slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-[14px] font-medium text-ink",children:o[c]}),o[c]!==p.name&&e.jsx("div",{className:"text-[12px] text-ink-secondary",children:s("templates.newCopyOf",{name:p.name})}),e.jsx("div",{className:"mt-0.5 truncate text-[13px] text-ink-secondary",children:p.title||s("templates.generalAssistant")})]})]},`${p.name}-${c}`))}),e.jsxs("div",{className:"mt-6 flex items-start gap-2.5 rounded-xl bg-raised/45 px-4 py-3 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx(be,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("p",{children:a.kind==="backup"?s("templates.backupSafety",{archived:a.archivedBots?s("templates.archivedBots",{count:a.archivedBots}):""}):m?a.members.length?s("orgLibrary.teamSafety"):s("orgLibrary.librarySafety"):a.library?s("teamImport.librarySafety"):a.version===2?s("teamImport.sharedTeamSafety"):a.kind==="package"?s("templates.packageSafety"):s("templates.legacySafety")})]})]})}async function Zt(a,o){for(const m of o??[])await fetch(`/api/limix/skill-store/${encodeURIComponent(a)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:m,add:!0})}).catch(()=>{})}const es={gmail:"Gmail",github:"GitHub",discord:"Discord",slack:"Slack",googlecalendar:"Google Calendar",notion:"Notion",linear:"Linear",figma:"Figma",gong:"Gong",hubspot:"HubSpot",postiz:"Postiz"},qe={everyday:"readyBots.category.everyday",work:"readyBots.category.work",writing:"readyBots.category.writing",design:"readyBots.category.design",sales:"readyBots.category.sales",personal:"readyBots.category.personal"},fe=()=>Ot.map(a=>{const o=Rt(a);return{id:a.id,name:a.name,title:o.title,category:a.category,description:o.description,try:o.tryAsking,look:a.look,apps:a.apps,routines:a.routines?.length??0,builtIn:!0}});let $=null;async function ts(){const{bots:a}=await N("/api/limix/bots/refresh",{method:"POST"});return $=a.length?a.map(o=>({...o,builtIn:!1})):null,a.length}const ss=(a,o)=>{const m=o.trim().toLowerCase();return!m||[a.name,a.title,a.description,a.category].some(p=>p.toLowerCase().includes(m))};function as({search:a,onDialog:o,onAdded:m,revision:p=0}){const{state:c,dispatch:h}=Ze(),[y,L]=i.useState(null),[x,f]=i.useState($),[I,G]=i.useState(!1),[E,M]=i.useState(null),[_,U]=i.useState(""),[B,O]=i.useState(null);i.useEffect(()=>{if(p>0){f($??fe()),G(!1);return}let l=!0;return N("/api/limix/bots").then(({bots:b})=>{if(!l)return;const J=b.length?b.map(R=>({...R,builtIn:!1})):fe();$=b.length?J:null,f(J),G(!1)}).catch(()=>{l&&(f($??fe()),G(!$))}),()=>{l=!1}},[p]);const q=()=>{O(null),o(!1)},K=async l=>{if(!(E||Pt(c))){if(U(""),window.ogb?.remoteClient?.active){h({type:"newBot",onCreated:m});return}if(l.builtIn){O({id:l.id}),o(!0);return}M(l.id);try{const{bot:b}=await N(`/api/limix/bots/${l.id}`);O({id:l.id,data:b,skills:b.skills}),o(!0)}catch(b){U(b instanceof Error?b.message:String(b))}finally{M(null)}}};if(!x)return e.jsxs("div",{className:"mb-8 flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(C,{size:15,className:"animate-spin"}),s("templates.loading")]});const T=x.filter(l=>(!y||l.category===y)&&ss(l,a));return a.trim()&&T.length===0?null:e.jsxs("section",{className:"mb-8","aria-labelledby":"ready-bots-title",children:[e.jsxs("div",{className:"mb-1 flex flex-wrap items-baseline justify-between gap-2",children:[e.jsx("h3",{id:"ready-bots-title",className:"text-[12px] font-medium text-ink-secondary",children:s("readyBots.title")}),e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:e.jsx("p",{className:"text-[12px] text-ink-tertiary",role:"status","aria-live":"polite",children:I?w("Đang dùng bản có sẵn trong ứng dụng (chưa tải được kho mẫu).","Showing the bots built into the app (the template library could not be loaded)."):s("readyBots.subtitle")})})]}),e.jsx("div",{className:"mb-3 mt-2 flex flex-wrap gap-1.5",role:"group","aria-label":s("readyBots.categories"),children:[null,...Tt].map(l=>e.jsx("button",{type:"button","aria-pressed":y===l,onClick:()=>L(l),className:j("rounded-full px-3 py-1 text-[13px] transition-colors",y===l?"bg-ink text-panel":"bg-raised/70 text-ink-secondary hover:text-ink"),children:l?s(qe[l]):s("readyBots.all")},l??"all"))}),_&&e.jsx("p",{role:"alert",className:"mb-3 rounded-xl bg-danger/10 px-3 py-2 text-[13px] text-danger",children:_}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-3",children:T.map(l=>e.jsxs("article",{"data-ready-bot":l.id,className:"flex flex-col rounded-2xl border border-hairline/40 bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Nt,{color:l.look.color,bodyId:l.look.mascotBody,size:40,animated:!1,label:l.name}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"truncate text-[14px] font-medium text-ink",children:l.name}),e.jsxs("p",{className:"truncate text-[12px] text-ink-secondary",children:[l.title," · ",s(qe[l.category])]})]}),e.jsxs("button",{type:"button",onClick:()=>{K(l)},disabled:E!==null,"aria-label":w(`Dùng mẫu ${l.name}, ${l.title}`,`Use template ${l.name}, ${l.title}`),className:"flex h-8 shrink-0 items-center gap-1 rounded-full bg-raised px-3 text-[13px] font-medium text-ink hover:bg-raised-hover disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-accent",children:[E===l.id?e.jsx(C,{size:14,className:"animate-spin","aria-hidden":"true"}):e.jsx(vt,{size:14,"aria-hidden":"true"}),w("Dùng mẫu","Use template")]})]}),e.jsx("p",{className:"mt-3 text-[13px] leading-[1.45] text-ink-secondary",children:l.description}),e.jsx("p",{className:"mt-2 text-[12px] italic text-ink-tertiary",children:s("readyBots.try",{prompt:l.try})}),(l.apps.length>0||l.routines>0)&&e.jsx("p",{className:"mt-auto pt-2 text-[12px] text-ink-tertiary",children:[l.apps.length>0&&s("readyBots.worksWith",{apps:l.apps.map(b=>es[b]??b).join(", ")}),l.routines>0&&s("readyBots.pausedRoutine")].filter(Boolean).join(" · ")})]},l.id))}),B&&Xe.createPortal(e.jsx(It,{readyBotId:B.id,readyBotData:B.data,onClose:q,onCreated:l=>{o(!1),Zt(l.id,B.skills),m(l)}}),document.body)]})}const Ke=["bg-cyan-500/15 text-cyan-300","bg-purple-500/15 text-purple-300","bg-emerald-500/15 text-emerald-300","bg-orange-500/15 text-orange-300"];function rs({listing:a,busy:o,notice:m,error:p,onAdd:c,onDetails:h}){const y=a.organization.name;return e.jsxs("div",{children:[e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:s("orgLibrary.intro",{name:y})}),a.packages.length===0?e.jsx("p",{className:"mt-6 text-[13px] text-ink-secondary",children:s("orgLibrary.empty",{name:y})}):e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:a.packages.map((L,x)=>e.jsx(ns,{entry:L,index:x,busy:o,onAdd:c,onDetails:h},L.packageId))}),m&&e.jsx("div",{role:"status",className:"mt-4 rounded-lg bg-raised/60 px-3 py-2 text-[13px] text-ink-secondary",children:m}),p&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:p})]})}function ns({entry:a,index:o,busy:m,onAdd:p,onDetails:c}){const h=et(a),y=Gt(a),L=Mt(a),x=m===a.packageId;return e.jsxs("article",{className:"flex min-h-[104px] items-center gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx("div",{className:j("flex size-11 shrink-0 items-center justify-center rounded-xl",Ke[o%Ke.length]),children:e.jsx(wt,{size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-medium text-ink",children:a.name}),e.jsx("p",{className:"mt-0.5 truncate text-[13px] text-ink-secondary",children:a.tagline}),e.jsxs("p",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-[12px] text-ink-tertiary",children:[e.jsx("span",{children:_t(a)}),y&&e.jsx("span",{className:"rounded-full bg-accent/10 px-2 py-0.5 text-accent-text",children:y}),a.release&&e.jsx("span",{children:a.release.version})]}),e.jsx("p",{className:"mt-0.5 truncate text-[12px] text-ink-tertiary",children:Ut(a.contents)}),L.map(f=>e.jsx("p",{className:"mt-0.5 text-[12px] text-warning",children:f},f))]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[h==="add"&&e.jsxs("button",{onClick:()=>p(a),disabled:m!==null,"aria-label":s("orgLibrary.addAria",{name:a.name}),className:"flex min-w-[72px] items-center justify-center gap-1.5 rounded-full bg-accent px-3.5 py-2 text-[13px] font-medium text-white hover:bg-accent/90 disabled:opacity-40",children:[x&&e.jsx(C,{size:13,className:"animate-spin"}),x?s("orgLibrary.adding"):s("orgLibrary.add")]}),h==="added"&&e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-raised px-3 py-1.5 text-[12px] text-ink-secondary",children:[e.jsx(be,{size:13,className:"text-success"}),s("orgLibrary.added")]}),h==="updateApp"&&e.jsx("span",{className:"max-w-[140px] text-right text-[12px] text-ink-secondary",children:s("orgLibrary.updateApp")}),h==="notReady"&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("orgLibrary.notReady")}),h==="noRelease"&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("orgLibrary.noRelease")}),a.blob==="ready"&&e.jsx("button",{onClick:()=>c(a),disabled:m!==null,"aria-label":s("orgLibrary.detailsAria",{name:a.name}),className:"rounded-full px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-40",children:s("orgLibrary.details")})]})]})}const is="https://github.com/leomieo/limix-bot-teams",Je=["cyan","red","purple","green","orange"];async function We(a){if(window.ogb?.openExternal){await window.ogb.openExternal(a);return}const o=window.open(a,"_blank","noopener,noreferrer");o&&(o.opener=null)}function ls(a,o){const m=new Map;for(const c of o){if(c.hidden)continue;const h=c.section?.trim()??"";m.set(h,(m.get(h)??0)+1)}return[...[...new Set([...a.map(c=>c.trim()).filter(Boolean),...m.keys()])].filter(c=>c!==""),""].flatMap(c=>m.get(c)?[{name:c,bots:m.get(c)}]:[])}function Qe({index:a}){return e.jsx("div",{className:j("flex size-11 shrink-0 items-center justify-center rounded-xl",F[a%F.length]),children:e.jsx(Ve,{size:20})})}function ys({onClose:a,onImported:o,returnFocusRef:m,initialUrl:p}){const{state:c,dispatch:h}=Ze(),y=i.useRef(null),L=i.useRef(null),[x,f]=i.useState("explore"),[I,G]=i.useState(null),[E,M]=i.useState(!0),[_,U]=i.useState(""),[B,O]=i.useState(!1),[q,K]=i.useState(""),[T,l]=i.useState(""),[b,J]=i.useState(0),R=i.useRef(0),[oe,ye]=i.useState(null),[d,Y]=i.useState(null),[st,at]=i.useState("file"),[ce,je]=i.useState(""),[ke,Ne]=i.useState(!1),[S,W]=i.useState(!1),[rt,de]=i.useState(!1),[me,nt]=i.useState(""),[P,u]=i.useState(""),[ve,we]=i.useState(""),[Q,Se]=i.useState(!1),[k,Ce]=i.useState(null),[it,lt]=i.useState(""),[X,xe]=i.useState(null),[Le,Be]=i.useState(new Set),[Ee,ze]=i.useState(""),[V,Te]=i.useState(!1),[Z,Ie]=i.useState(null),[Oe,ot]=i.useState(!1),[ee,Re]=i.useState(null),[ct,te]=i.useState(null),[dt,Pe]=i.useState(""),[mt,se]=i.useState(""),[A,ae]=i.useState(null),z=i.useRef(!1),D=i.useRef(0),pe=c.bots.filter(t=>!t.hidden).length,Ae=ls(c.sections??[],c.bots),xt=new Set(c.bots.map(t=>t.name.trim().toLowerCase())),pt=d?.members.map(t=>qt(t.name,xt))??[],re=i.useCallback(async(t=!1)=>{const r=++R.current;M(!0),U("");try{const n=await N(`/api/team-library/catalog${t?"?fresh=1":""}`);return r===R.current&&G(n),!0}catch(n){return r===R.current&&U(n instanceof Error?n.message:String(n)),!1}finally{r===R.current&&M(!1)}},[]),ut=async()=>{if(!B){O(!0),K(""),l("");try{const[t,r]=await Promise.allSettled([ts(),re(!0)]);if(t.status==="fulfilled"&&J(n=>n+1),t.status==="fulfilled"&&r.status==="fulfilled"&&r.value)K(w("Đã cập nhật mẫu Bot và mẫu nhóm Bot.","Bot and team templates updated."));else{const n=[...t.status==="rejected"?[w("mẫu Bot","bot templates")]:[],...r.status==="rejected"||!r.value?[w("mẫu nhóm Bot","team templates")]:[]];l(w(`Chưa cập nhật được ${n.join(", ")}. Hãy thử lại.`,`Could not update ${n.join(", ")}. Please retry.`))}}finally{O(!1)}}};i.useEffect(()=>{re()},[re]);const ne=i.useCallback(async()=>{try{const t=await N("/api/org-library");Re(t),t.organization&&!z.current&&f("org")}catch{Re({organization:null,packages:[]})}},[]);i.useEffect(()=>{ne()},[ne]),i.useEffect(()=>(y.current?.focus(),()=>m.current?.focus()),[m]),i.useEffect(()=>{const t=r=>{if(Z!==null||Oe)return;if(r.key==="Escape"&&!S){r.preventDefault(),r.stopPropagation(),d?(Y(null),ae(null)):a();return}if(r.key!=="Tab")return;const n=y.current,g=Array.from(n?.querySelectorAll('button:not([disabled]), a[href], input:not([disabled]), [tabindex]:not([tabindex="-1"])')??[]);if(!n||g.length===0)return;const v=g[0],ie=g.at(-1);r.shiftKey&&(document.activeElement===v||!n.contains(document.activeElement))?(r.preventDefault(),ie.focus()):!r.shiftKey&&document.activeElement===ie&&(r.preventDefault(),v.focus())};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[S,a,d,Z,Oe]);const ue=(t,r)=>{Y(t),at(r),u("")},De=async t=>{if(t.size>Ht)throw new Error(s("templates.fileTooLarge"));const r=await t.text();let n=r;if(!t.name.toLowerCase().endsWith(".md"))try{n=JSON.parse(r)}catch(g){throw g instanceof SyntaxError?new Error(s("teamLibrary.invalidJson")):g}ue(he(n),"file")},gt=async t=>{ye(t.slug),u("");try{ue(he(await N(`/api/team-library/teams/${t.slug}`)),"library")}catch(r){u(r instanceof Error?r.message:String(r))}finally{ye(null)}},$e=async()=>{await Fe(ce)},Fe=async t=>{if(t.trim()){Ne(!0),u("");try{const r=await N("/api/team-library/github",{method:"POST",body:JSON.stringify({url:t.trim()})});ue(he(r),"github")}catch(r){u(r instanceof Error?r.message:String(r))}finally{Ne(!1)}}};i.useEffect(()=>{p&&(z.current=!0,f("import"),je(p),Fe(p))},[p]);const ht=async()=>{if(d){W(!0),u("");try{const t=await Kt(d.manifest,h);le("team_imported",{members:t.bots.length,source:st,mode:"add",format:d.kind}),o({name:d.name,members:t.bots.length,...t.connections?.length?{connections:t.connections.length}:{},...t.presets?.length?{presets:t.presets.length}:{}})}catch(t){u(t instanceof Error?t.message:String(t))}finally{W(!1)}}},ft=async t=>{te(t.packageId),se("");try{const r=await N(`/api/org-library/packages/${t.packageId}`);Y(Yt(r.document)),ae(t),u("")}catch(r){se(r instanceof Error?r.message:String(r))}finally{te(null)}},Ge=async t=>{te(t.packageId),W(!0),se(""),Pe(""),u("");try{const r=await N("/api/org-library/add",{method:"POST",body:JSON.stringify({packageId:t.packageId})});for(const g of r.bots??[])h({type:"botAdded",bot:g});for(const g of r.groups??[])h({type:"groupPatched",group:g});for(const g of r.routines??[])h({type:"routinePatched",routine:g});const n=r.bots?.find(g=>!g.hidden);if(le("team_imported",{members:r.bots?.length??0,source:"organization",mode:"add",format:"package"}),n){h({type:"select",id:n.id}),o({name:t.name,members:r.bots.length,...r.connections?.length?{connections:r.connections.length}:{}});return}Y(null),ae(null),r.alreadyAdded||Pe(s("orgLibrary.addedSkills",{name:t.name})),await ne()}catch(r){const n=r instanceof Error?r.message:String(r);A?u(n):se(n),await ne()}finally{te(null),W(!1)}},H=ve.trim(),ge=async t=>{const r=++D.current;Se(!0),u(""),Ce(null),xe(null),Be(new Set);try{const n=await N(`/api/teams/scout?cwd=${encodeURIComponent(t)}`);if(r!==D.current)return;Ce(n),lt(t),ze(n.suggestion.roomName),le("team_scouted",{signals:n.suggestion.manifest.team.members.length-1}),N(`/api/teams/scout/directory?cwd=${encodeURIComponent(t)}`).then(g=>{r===D.current&&xe(g.directory)}).catch(()=>{r===D.current&&xe([])})}catch(n){if(r!==D.current)return;u(n instanceof Error?n.message:String(n))}finally{r===D.current&&Se(!1)}},bt=async()=>{const t=await window.ogb?.pickFolder?.(H||void 0);t&&(we(t),await ge(t))},yt=async()=>{if(!(!k||V)){Te(!0),u("");try{const t=(X??[]).filter(v=>Le.has(v.slug)).map((v,ie)=>({key:`dir-${v.slug}`,name:v.name,title:v.category||s("templates.communityBot"),description:v.prompt,appearance:{color:Je[ie%Je.length]}})),r={...k.suggestion.manifest,team:{...k.suggestion.manifest.team,members:[...k.suggestion.manifest.team.members,...t]}},n=Ee.trim()||k.suggestion.roomName,g=await N(`/api/teams/import?mode=project&cwd=${encodeURIComponent(it)}&room=${encodeURIComponent(n)}`,{method:"POST",body:JSON.stringify(r)});for(const v of g.bots)h({type:"botAdded",bot:v});g.group&&(h({type:"groupPatched",group:{...g.group,messages:[]}}),h({type:"select",id:g.group.id})),le("team_imported",{members:g.bots.length,source:"scout",mode:"project"}),o({name:n,members:g.bots.length})}catch(t){u(t instanceof Error?t.message:String(t))}finally{Te(!1)}}},Me=me.trim().toLowerCase(),_e=(I?.teams??[]).filter(t=>!Me||Xt(t,Me));return Xe.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/55 p-4 sm:p-6",onMouseDown:t=>t.stopPropagation(),children:[e.jsxs("div",{ref:y,role:"dialog","aria-modal":"true","aria-labelledby":"team-library-title",tabIndex:-1,className:"animate-pop-in flex h-[min(780px,calc(100dvh-2rem))] w-full max-w-[1040px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel shadow-2xl shadow-black/50 outline-none",children:[e.jsxs("header",{className:"flex items-start justify-between gap-4 px-6 pb-3 pt-6 sm:px-8 sm:pt-7",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d&&e.jsx("button",{onClick:()=>{Y(null),ae(null),u("")},disabled:S,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":s("templates.back"),children:e.jsx(At,{size:18})}),e.jsx("h2",{id:"team-library-title",className:"truncate text-[22px] font-semibold tracking-[-0.01em] text-ink",children:d?d.name:s("templates.title")})]}),e.jsx("p",{className:j("mt-1 text-[13px] text-ink-secondary",d&&"ml-9"),children:d?d.kind==="backup"?s("templates.backupSummary",{bots:d.members.length,conversations:d.conversations??0}):d.kind==="package"?d.library?s("teamImport.library"):d.version===2?s("teamImport.sharedTeam",{count:d.members.length}):s("templates.playbookSummary",{count:d.members.length}):s("templates.readyBots",{count:d.members.length}):s("templates.subtitle")})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[!d&&e.jsxs("button",{onClick:()=>{We(I?.repositoryUrl??is)},className:"flex items-center gap-1.5 rounded-lg px-2.5 py-2 text-[13px] text-ink-secondary hover:bg-raised hover:text-ink",title:s("templates.openRepository"),children:[e.jsx(He,{size:16}),e.jsx("span",{className:"max-sm:hidden",children:s("templates.communityRepo")}),e.jsx(Ue,{size:12})]}),e.jsx("button",{onClick:a,disabled:S,className:"rounded-lg p-2 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":s("templates.close"),children:e.jsx(jt,{size:21})})]})]}),d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-6 pt-6 sm:px-8",children:[e.jsx(Vt,{pending:d,importedNames:pt,org:A!==null}),P&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:P})]}),e.jsxs("footer",{className:"flex flex-col gap-3 border-t border-hairline/35 px-6 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-8",children:[e.jsxs("div",{className:"text-[13px] text-ink-secondary",children:[s(pe===0?"templates.existingNone":pe===1?"templates.existingOne":"templates.existingMany",{count:pe})," ",d.kind==="backup"?s("teamImport.backupCopies"):d.library?s("teamImport.libraryAdds"):d.members.length===0?"":s("teamImport.newSection",{name:d.teamName??d.name})]}),A?et(A)==="add"?e.jsxs("button",{onClick:()=>{Ge(A)},disabled:S,"aria-label":s("orgLibrary.addAria",{name:A.name}),className:"flex shrink-0 items-center justify-center gap-2 rounded-full bg-accent px-5 py-2.5 text-[14px] font-medium text-white hover:bg-accent/90 disabled:opacity-60",children:[S&&e.jsx(C,{size:15,className:"animate-spin"}),S?s("orgLibrary.adding"):s("orgLibrary.add")]}):e.jsxs("span",{className:"flex shrink-0 items-center gap-1 rounded-full bg-raised px-4 py-2 text-[13px] text-ink-secondary",children:[e.jsx(be,{size:14,className:"text-success"}),s("orgLibrary.added")]}):e.jsxs("button",{onClick:()=>{ht()},disabled:S,className:"flex shrink-0 items-center justify-center gap-2 rounded-full bg-accent px-5 py-2.5 text-[14px] font-medium text-white hover:bg-accent/90 disabled:opacity-60",children:[S&&e.jsx(C,{size:15,className:"animate-spin"}),S?s("templates.importing"):d.kind==="backup"?s("templates.importBackup"):d.library?s("teamImport.addPresets"):s("templates.addTeam")]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-6 pb-4 pt-5 sm:px-8",children:[e.jsxs("div",{className:"flex max-w-full flex-wrap rounded-xl bg-raised/70 p-1",role:"tablist","aria-label":s("templates.source"),children:[ee?.organization&&e.jsx("button",{role:"tab","aria-selected":x==="org",onClick:()=>{z.current=!0,f("org"),u("")},className:j("max-w-[220px] truncate rounded-lg px-4 py-2 text-[14px] transition-colors",x==="org"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("orgLibrary.tab",{name:ee.organization.name})}),e.jsx("button",{role:"tab","aria-selected":x==="explore",onClick:()=>{z.current=!0,f("explore"),u("")},className:j("rounded-lg px-4 py-2 text-[14px] transition-colors",x==="explore"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("templates.explore")}),e.jsx("button",{role:"tab","aria-selected":x==="import",onClick:()=>{z.current=!0,f("import"),u("")},className:j("rounded-lg px-4 py-2 text-[14px] transition-colors",x==="import"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("templates.import")}),e.jsx("button",{role:"tab","aria-selected":x==="scout",onClick:()=>{z.current=!0,f("scout"),u("")},className:j("rounded-lg px-4 py-2 text-[14px] transition-colors",x==="scout"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("templates.fromFolder")}),e.jsx("button",{role:"tab","aria-selected":x==="share",onClick:()=>{z.current=!0,f("share"),u("")},className:j("rounded-lg px-4 py-2 text-[14px] transition-colors",x==="share"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("teamLibrary.shareTab")}),e.jsx("button",{role:"tab","aria-selected":x==="teams",onClick:()=>{z.current=!0,f("teams"),u("")},className:j("rounded-lg px-4 py-2 text-[14px] transition-colors",x==="teams"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:w("Bản mẫu Nhóm","Team templates")})]}),e.jsxs("button",{type:"button",onClick:()=>{ut()},disabled:B,title:w("Tải lại mẫu Bot và mẫu nhóm Bot mới nhất từ kho","Reload the latest bot and team templates"),className:"flex h-10 shrink-0 items-center gap-1.5 rounded-xl bg-raised/70 px-3 text-[13px] font-medium text-ink hover:bg-raised-hover disabled:opacity-60",children:[e.jsx(Wt,{size:14,"aria-hidden":"true",className:B?"animate-spin":void 0}),B?w("Đang cập nhật","Updating"):w("Cập nhật","Update")]}),(x==="explore"||x==="teams")&&e.jsxs("label",{className:"flex h-11 w-full items-center gap-2.5 rounded-xl bg-raised/70 px-3.5 sm:ml-auto sm:w-[240px]",children:[e.jsx(kt,{size:17,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:me,onChange:t=>nt(t.target.value),placeholder:s("templates.search"),"aria-label":s("templates.search"),className:"min-w-0 flex-1 bg-transparent text-[14px] text-ink placeholder:text-ink-secondary focus:outline-none"})]})]}),(q||T)&&e.jsx("p",{role:T?"alert":"status",className:j("px-6 pb-2 text-[13px] sm:px-8",T?"text-danger":"text-ink-secondary"),children:T||q}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-7 pt-5 sm:px-8",children:[x==="org"&&ee?.organization&&e.jsx(rs,{listing:ee,busy:ct,notice:dt,error:mt,onAdd:t=>{Ge(t)},onDetails:t=>{ft(t)}}),x==="explore"&&e.jsx(as,{revision:b,search:me,onDialog:ot,onAdded:a}),x==="teams"&&e.jsxs("div",{children:[E&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-24 text-[13px] text-ink-secondary",children:[e.jsx(C,{size:16,className:"animate-spin"})," ",s("templates.loading")]}),!E&&_&&e.jsxs("div",{className:"rounded-xl bg-danger/10 p-4 text-[13px] text-danger",children:[e.jsx("p",{children:_}),e.jsx("button",{onClick:()=>{re()},className:"mt-3 rounded-full bg-raised px-3.5 py-2 text-ink hover:bg-raised-hover",children:s("common.tryAgain")})]}),!E&&I&&e.jsx("div",{className:"grid grid-cols-1 gap-x-10 md:grid-cols-2",children:_e.map((t,r)=>{const n=tt(t);return e.jsxs("article",{className:"flex min-h-[104px] items-center gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx(Qe,{index:r}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-medium text-ink",children:n.name}),e.jsx("p",{className:"mt-0.5 truncate text-[13px] text-ink-secondary",children:n.outcome??n.summary}),e.jsxs("p",{className:"mt-1 truncate text-[12px] text-ink-tertiary",children:[s("templates.botCount",{count:t.members})," · ",s("templates.playbookCount",{count:t.skills.length}),t.requires.apps.length>0&&` · ${t.requires.apps.join(", ")}`,t.setupMinutes&&` · ${s("templates.minutes",{count:t.setupMinutes})}`]})]}),e.jsxs("button",{onClick:()=>{gt(t)},disabled:oe!==null,className:"flex min-w-[72px] items-center justify-center gap-1.5 rounded-full bg-raised px-3.5 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-40",children:[oe===t.slug&&e.jsx(C,{size:13,className:"animate-spin"}),oe===t.slug?s("templates.loadingShort"):s("templates.load")]})]},t.slug)})}),!E&&I&&_e.length===0&&e.jsxs("div",{className:"flex min-h-56 flex-col items-center justify-center text-center",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("templates.noneFound")}),e.jsx("div",{className:"mt-1 text-[13px] text-ink-secondary",children:s("templates.tryDifferentSearch")})]})]}),x==="import"&&e.jsxs("div",{children:[e.jsx("input",{ref:L,type:"file",accept:".md,.json,.mausbackup.json,.mausteam.json,text/markdown,application/json",className:"hidden",onChange:t=>{const r=t.currentTarget.files?.[0];t.currentTarget.value="",r&&De(r).catch(n=>u(n instanceof Error?n.message:String(n)))}}),e.jsx("div",{className:"mb-3 text-[12px] font-medium text-ink-secondary",children:s("templates.bringYourOwn")}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("button",{onClick:()=>L.current?.click(),onDragEnter:t=>{t.preventDefault(),de(!0)},onDragOver:t=>t.preventDefault(),onDragLeave:()=>de(!1),onDrop:t=>{t.preventDefault(),de(!1);const r=t.dataTransfer.files[0];r&&De(r).catch(n=>u(n instanceof Error?n.message:String(n)))},className:j("flex min-h-56 flex-col items-center justify-center rounded-2xl border border-dashed px-6 text-center transition-colors",rt?"border-accent bg-accent/5":"border-hairline/60 bg-raised/20 hover:bg-raised/35"),children:[e.jsx(St,{size:27,className:"text-accent"}),e.jsx("span",{className:"mt-3 text-[14px] font-medium text-ink",children:s("templates.chooseFile")}),e.jsx("span",{className:"mt-1 text-[13px] text-ink-secondary",children:s("templates.dropFile")})]}),e.jsxs("div",{className:"flex min-h-56 flex-col justify-center rounded-2xl bg-raised/25 px-6",children:[e.jsx(He,{size:25,className:"text-ink-secondary"}),e.jsx("h3",{className:"mt-3 text-[14px] font-medium text-ink",children:s("templates.loadGithub")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("templates.githubHint")}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("input",{value:ce,onChange:t=>je(t.target.value),onKeyDown:t=>t.key==="Enter"&&void $e(),placeholder:s("templates.githubPlaceholder"),"aria-label":s("templates.githubUrl"),className:"min-w-0 flex-1 rounded-xl bg-raised/80 px-3 py-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),e.jsxs("button",{onClick:()=>{$e()},disabled:!ce.trim()||ke,className:"flex items-center gap-1.5 rounded-full bg-accent px-4 py-2.5 text-[13px] font-medium text-white hover:bg-accent/90 disabled:opacity-40",children:[ke&&e.jsx(C,{size:13,className:"animate-spin"}),s("templates.load")]})]})]})]}),P&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:P})]}),x==="share"&&e.jsxs("div",{children:[e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:s("teamLibrary.shareIntro")}),Ae.length===0?e.jsx("p",{className:"mt-6 text-[13px] text-ink-secondary",children:s("teamLibrary.shareEmpty")}):e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:Ae.map((t,r)=>e.jsxs("article",{className:"flex min-h-[84px] items-center gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx(Qe,{index:r}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-medium text-ink",children:t.name||s("teamLibrary.general")}),e.jsx("p",{className:"mt-0.5 text-[13px] text-ink-secondary",children:s("teamLibrary.shareBots",{count:t.bots})})]}),e.jsxs("button",{onClick:()=>Ie(t.name),"aria-label":s("teamLibrary.shareTeamAria",{name:t.name||s("teamLibrary.general")}),className:"flex items-center gap-1.5 rounded-full bg-raised px-3.5 py-2 text-[13px] text-ink hover:bg-raised-hover",children:[e.jsx(Dt,{size:13}),s("teamLibrary.shareTeam")]})]},t.name||"general"))})]}),x==="scout"&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-3 text-[12px] font-medium text-ink-secondary",children:s("templates.startFolder")}),e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:s("templates.scoutHint")}),e.jsxs("div",{className:"mt-4 flex flex-col gap-2 sm:flex-row",children:[e.jsx("input",{value:ve,onChange:t=>we(t.target.value),onKeyDown:t=>t.key==="Enter"&&H&&void ge(H),placeholder:"/path/to/your/project","aria-label":s("templates.projectFolder"),className:"min-w-0 flex-1 rounded-xl bg-raised/80 px-3 py-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),!!window.ogb?.pickFolder&&e.jsxs("button",{onClick:()=>{bt()},disabled:Q,className:"flex items-center justify-center gap-1.5 rounded-full bg-raised px-4 py-2.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-40",children:[e.jsx($t,{size:14}),s("templates.browse")]}),e.jsxs("button",{onClick:()=>{ge(H)},disabled:!H||Q,className:"flex items-center justify-center gap-1.5 rounded-full bg-accent px-4 py-2.5 text-[13px] font-medium text-white hover:bg-accent/90 disabled:opacity-40",children:[Q?e.jsx(C,{size:14,className:"animate-spin"}):e.jsx(Ft,{size:14}),Q?s("templates.scouting"):s("templates.scout")]})]}),k&&e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"rounded-2xl bg-raised/25 px-5 py-4",children:[e.jsx("div",{className:"text-[15px] font-semibold text-ink",children:k.profile.name}),k.profile.summary&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:k.profile.summary}),k.profile.stacks.length>0&&e.jsx("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:k.profile.stacks.map(t=>e.jsx("span",{className:"rounded-full bg-raised px-2.5 py-1 text-[12px] text-ink-secondary",children:t},t))})]}),e.jsx("div",{className:"mt-5 text-[12px] font-medium text-ink-secondary",children:s("templates.suggestedTeam")}),e.jsx("div",{className:"mt-1 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:k.suggestion.manifest.team.members.map((t,r)=>e.jsxs("div",{className:"flex min-h-[64px] items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[e.jsx("div",{className:j("flex size-9 shrink-0 items-center justify-center rounded-lg text-[13px] font-semibold",F[r%F.length]),children:t.name.slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"truncate text-[14px] font-medium text-ink",children:[t.name," ",e.jsxs("span",{className:"font-normal text-ink-secondary",children:["· ",t.title]})]}),e.jsx("div",{className:"mt-0.5 truncate text-[12px] text-ink-secondary",children:k.suggestion.reasons[t.key]??""})]})]},t.key))}),X&&X.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-5 text-[12px] font-medium text-ink-secondary",children:s("templates.communityDirectory")}),e.jsx("div",{className:"mt-1 flex flex-col",children:X.map(t=>e.jsxs("div",{className:"flex items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:Le.has(t.slug),onChange:()=>Be(r=>{const n=new Set(r);return n.has(t.slug)?n.delete(t.slug):n.add(t.slug),n}),className:"size-4 accent-accent"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"truncate text-[14px] font-medium text-ink",children:[t.name,t.category&&e.jsxs("span",{className:"font-normal text-ink-secondary",children:[" · ",t.category]})]}),e.jsx("div",{className:"mt-0.5 truncate text-[12px] text-ink-secondary",children:s("templates.matches",{values:t.matched.join(", ")})})]})]}),e.jsx("button",{onClick:()=>{We(t.detailUrl)},"aria-label":s("templates.openDirectory",{name:t.name}),title:s("templates.readBeforeAdding"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(Ue,{size:14})})]},t.slug))})]}),e.jsxs("div",{className:"mt-6 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx("input",{value:Ee,onChange:t=>ze(t.target.value),"aria-label":s("templates.groupChatName"),className:"min-w-0 flex-1 rounded-xl bg-raised/80 px-3 py-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),e.jsxs("button",{onClick:()=>{yt()},disabled:V,className:"flex shrink-0 items-center justify-center gap-2 rounded-full bg-accent px-5 py-2.5 text-[14px] font-medium text-white hover:bg-accent/90 disabled:opacity-60",children:[V&&e.jsx(C,{size:15,className:"animate-spin"}),V?s("templates.creating"):s("templates.createGroupChat")]})]}),e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("templates.createGroupHint")})]}),P&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:P})]})]})]})]}),Z!==null&&e.jsx(Jt,{team:Z,onClose:()=>Ie(null)})]}),document.body)}export{Vt as TeamImportDetails,ys as TeamLibraryPanel,ls as shareableTeamList};