limixbot 0.3.120 → 0.3.121

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 (52) hide show
  1. package/dist/assets/{ActivityPanel-BNI1ux2Y.js → ActivityPanel-oH7zEe1h.js} +1 -1
  2. package/dist/assets/{App-BtFoKXkb.js → App-C8J3XlgX.js} +8 -8
  3. package/dist/assets/{AppEventEditor-4O6prt9T.js → AppEventEditor-lsrjdXGL.js} +1 -1
  4. package/dist/assets/{BotSettingsDialog-DuiiKANg.js → BotSettingsDialog-BLVf7lNL.js} +1 -1
  5. package/dist/assets/{BrowserPanel-Cw0XeNKj.js → BrowserPanel-jSj0h--T.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-BXUJZPvf.js → BrowserProfilesManager-D8QTMXbY.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-CenW3juU.js → CloudAddDialog-CJtv0FXr.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-2CbBxe5x.js → ComputerFilesPane-BybRekwz.js} +1 -1
  9. package/dist/assets/{ComputerPanel-Dblzz3vs.js → ComputerPanel-DiOEMYnD.js} +2 -2
  10. package/dist/assets/{DataPanel-BE4kBVy_.js → DataPanel-D3DoJnrd.js} +1 -1
  11. package/dist/assets/{GrokMoveDialog-Bweic81i.js → GrokMoveDialog-CLpqy9bk.js} +1 -1
  12. package/dist/assets/{InspectorPanel-D8a2VKdd.js → InspectorPanel-BPvo8nZZ.js} +1 -1
  13. package/dist/assets/{KeyboardShortcutsModal-BEpU3l5V.js → KeyboardShortcutsModal-DrsY7KSu.js} +1 -1
  14. package/dist/assets/{LimixResizeHandles-US6Nri-U.js → LimixResizeHandles-BN2p7F7v.js} +1 -1
  15. package/dist/assets/{LiveDesktop-DJOZHCzT.js → LiveDesktop-DxEwcNB2.js} +1 -1
  16. package/dist/assets/{LocalVmWorkspace-NGZNs1wG.js → LocalVmWorkspace-DJqDfber.js} +1 -1
  17. package/dist/assets/{MacLocalControl-BAy3zv4a.js → MacLocalControl-d0NFbMGE.js} +1 -1
  18. package/dist/assets/{MarkdownFilePreview-BfNcCQnO.js → MarkdownFilePreview-BgsQgg1i.js} +1 -1
  19. package/dist/assets/{NewBotDialog-CKoKQIM9.js → NewBotDialog-C4UKPcXX.js} +1 -1
  20. package/dist/assets/{PhoneAppDialog-FY9PmkA6.js → PhoneAppDialog-xv4wn1mI.js} +1 -1
  21. package/dist/assets/{PluginsPanel-DvIsIELX.js → PluginsPanel-BwMqAsml.js} +1 -1
  22. package/dist/assets/{ProIntroduction-CZMEIOV3.js → ProIntroduction-r5lv0CF0.js} +1 -1
  23. package/dist/assets/{RemoteAgentSettingsPanel-BzNM-yd4.js → RemoteAgentSettingsPanel-D4mqcx4G.js} +1 -1
  24. package/dist/assets/{RoomPanel-BaXZH_OC.js → RoomPanel-Cc1ir5Pl.js} +1 -1
  25. package/dist/assets/{RoutinesPage-Bo4t8FOR.js → RoutinesPage-B2YvkjVI.js} +1 -1
  26. package/dist/assets/{SettingsModal-BnIPD1zO.js → SettingsModal-BrhwprP3.js} +1 -1
  27. package/dist/assets/{ShareTeamDialog-CKWIMaY6.js → ShareTeamDialog-DqP_VnFb.js} +1 -1
  28. package/dist/assets/{SignedInSites-B7wKzWCm.js → SignedInSites-CUea4XRc.js} +1 -1
  29. package/dist/assets/{TeamLibraryPanel-DOlj0Kyg.js → TeamLibraryPanel-BLrtwnPP.js} +1 -1
  30. package/dist/assets/{TeamMapPage-CdF8LQ0B.js → TeamMapPage-66LUkJrG.js} +1 -1
  31. package/dist/assets/{TriggersPage-CJUxvDcL.js → TriggersPage-BSq-2mGc.js} +1 -1
  32. package/dist/assets/{VisibilitySection-BGMvfVcC.js → VisibilitySection-c3v2Urid.js} +1 -1
  33. package/dist/assets/{WebhookTrigger-Jxr8mr7O.js → WebhookTrigger-CNOxLHYz.js} +1 -1
  34. package/dist/assets/{WorksOnGrid-BAc1xQ0J.js → WorksOnGrid-mltm5SpQ.js} +1 -1
  35. package/dist/assets/{core-CwWz_qwp.js → core-d8uKQbt4.js} +1 -1
  36. package/dist/assets/{import-name-DLjs1__7.js → import-name-BWQG-MzO.js} +1 -1
  37. package/dist/assets/{index-DLhL-159.js → index-C9y4_V8D.js} +2 -2
  38. package/dist/assets/{index-CjgWjXIR.js → index-DpOAIW5C.js} +1 -1
  39. package/dist/assets/{mcp-servers-DwlkPkVq.js → mcp-servers-BS2X7Buc.js} +1 -1
  40. package/dist/assets/{new-bot-pRpz-Z7k.js → new-bot-BM05ocFQ.js} +1 -1
  41. package/dist/assets/{org-library-BdRqFYyG.js → org-library-C1IF7HY_.js} +1 -1
  42. package/dist/assets/{package-format-D4N5QpsV.js → package-format-DwAaZAgV.js} +1 -1
  43. package/dist/assets/{remote-desktop-panel-CDov0Xv1.js → remote-desktop-panel-lMPAPeAh.js} +1 -1
  44. package/dist/index.html +1 -1
  45. package/dist-server/index.js +241 -239
  46. package/dist-server/package.json +1 -1
  47. package/dist-server/server/decider/index.js +32 -1
  48. package/dist-server/server/decider/relay.js +1 -1
  49. package/dist-server/server/extractor/contract.js +1 -1
  50. package/dist-server/server/index.js +1 -1
  51. package/dist-server/server/routes/helper-tools.js +1 -1
  52. package/package.json +1 -1
@@ -1 +1 @@
1
- import{r as c,j as e,t as s,X as h,S as m}from"./styles-ezcN4hc0.js";import{i as b,b as f,f as y,s as j,c as g,d as k,e as v}from"./App-BtFoKXkb.js";import{K as N}from"./MenuMotion-Dr44d4Sg.js";import"./index-DLhL-159.js";import"./PlacesRail-BesUMTCh.js";import"./monitor-DwKv3TJO.js";function w({item:r,isMac:n}){const a=k(r,n);return e.jsxs("div",{className:"flex items-center justify-between gap-4 py-1.5",children:[e.jsx("span",{className:"text-[13px] text-ink",children:v(r)}),e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:a.map((o,i)=>e.jsx("kbd",{className:"inline-flex min-w-[22px] items-center justify-center rounded-md border border-hairline/60 bg-control px-1.5 py-0.5 font-mono text-[12px] font-semibold text-ink shadow-xs",children:o},i))})]})}function D({open:r,onClose:n}){const[a,o]=c.useState(""),i=c.useRef(null),l=c.useRef(null),d=b(),p=f();if(c.useLayoutEffect(()=>{const t=i.current;if(!(!r||!t))return o(""),t.showModal(),l.current?.focus(),()=>t.close()},[r]),!r)return null;const x=y(j(p),a,d);return e.jsx("dialog",{ref:i,"aria-labelledby":"shortcuts-dialog-title",className:"m-auto w-[min(500px,calc(100%-32px))] max-h-[85vh] overflow-hidden rounded-2xl border border-hairline/50 bg-panel p-0 text-ink shadow-2xl backdrop:bg-black/60 backdrop:backdrop-blur-xs",onCancel:t=>{t.preventDefault(),n()},onKeyDown:t=>t.stopPropagation(),onMouseDown:t=>t.stopPropagation(),children:e.jsxs("div",{className:"flex max-h-[85vh] flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-hairline/40 px-5 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent/15 text-accent",children:e.jsx(N,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{id:"shortcuts-dialog-title",className:"text-[16px] font-semibold text-ink",children:s("shortcuts.title")}),e.jsx("p",{className:"text-[12px] text-ink-secondary",children:s("shortcuts.subtitle")})]})]}),e.jsx("button",{type:"button",onClick:n,"aria-label":s("shortcuts.close"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(h,{size:18})})]}),e.jsx("div",{className:"border-b border-hairline/30 px-5 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-hairline/40 bg-inset px-3 py-1.5 focus-within:border-focus",children:[e.jsx(m,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{ref:l,value:a,onChange:t=>o(t.target.value),placeholder:s("shortcuts.searchPlaceholder"),"aria-label":s("shortcuts.search"),className:"w-full bg-transparent text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-3 space-y-4",children:x.length===0?e.jsx("div",{className:"py-8 text-center text-[13px] text-ink-secondary",children:s("shortcuts.noMatch",{query:a})}):x.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-ink-tertiary",children:g(t)}),e.jsx("div",{className:"divide-y divide-hairline/20 rounded-xl bg-card/40 px-3 py-1 border border-hairline/30",children:t.items.map(u=>e.jsx(w,{item:u,isMac:d},u.id))})]},t.category))}),e.jsxs("div",{className:"flex items-center justify-between border-t border-hairline/40 bg-card/30 px-5 py-2.5 text-[12px] text-ink-secondary",children:[e.jsxs("span",{children:[s("shortcuts.openHintBefore")," ",e.jsx("kbd",{className:"rounded bg-control px-1 py-0.5 font-mono text-[11px]",children:"?"})," ",s("shortcuts.openHintAfter")]}),e.jsx("button",{type:"button",onClick:n,className:"ui-button ui-button-md",children:s("common.done")})]})]})})}export{D as KeyboardShortcutsModal};
1
+ import{r as c,j as e,t as s,X as h,S as m}from"./styles-ezcN4hc0.js";import{i as b,b as f,f as y,s as j,c as g,d as k,e as v}from"./App-C8J3XlgX.js";import{K as N}from"./MenuMotion-Dr44d4Sg.js";import"./index-C9y4_V8D.js";import"./PlacesRail-BesUMTCh.js";import"./monitor-DwKv3TJO.js";function w({item:r,isMac:n}){const a=k(r,n);return e.jsxs("div",{className:"flex items-center justify-between gap-4 py-1.5",children:[e.jsx("span",{className:"text-[13px] text-ink",children:v(r)}),e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:a.map((o,i)=>e.jsx("kbd",{className:"inline-flex min-w-[22px] items-center justify-center rounded-md border border-hairline/60 bg-control px-1.5 py-0.5 font-mono text-[12px] font-semibold text-ink shadow-xs",children:o},i))})]})}function D({open:r,onClose:n}){const[a,o]=c.useState(""),i=c.useRef(null),l=c.useRef(null),d=b(),p=f();if(c.useLayoutEffect(()=>{const t=i.current;if(!(!r||!t))return o(""),t.showModal(),l.current?.focus(),()=>t.close()},[r]),!r)return null;const x=y(j(p),a,d);return e.jsx("dialog",{ref:i,"aria-labelledby":"shortcuts-dialog-title",className:"m-auto w-[min(500px,calc(100%-32px))] max-h-[85vh] overflow-hidden rounded-2xl border border-hairline/50 bg-panel p-0 text-ink shadow-2xl backdrop:bg-black/60 backdrop:backdrop-blur-xs",onCancel:t=>{t.preventDefault(),n()},onKeyDown:t=>t.stopPropagation(),onMouseDown:t=>t.stopPropagation(),children:e.jsxs("div",{className:"flex max-h-[85vh] flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-hairline/40 px-5 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent/15 text-accent",children:e.jsx(N,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{id:"shortcuts-dialog-title",className:"text-[16px] font-semibold text-ink",children:s("shortcuts.title")}),e.jsx("p",{className:"text-[12px] text-ink-secondary",children:s("shortcuts.subtitle")})]})]}),e.jsx("button",{type:"button",onClick:n,"aria-label":s("shortcuts.close"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(h,{size:18})})]}),e.jsx("div",{className:"border-b border-hairline/30 px-5 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-hairline/40 bg-inset px-3 py-1.5 focus-within:border-focus",children:[e.jsx(m,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{ref:l,value:a,onChange:t=>o(t.target.value),placeholder:s("shortcuts.searchPlaceholder"),"aria-label":s("shortcuts.search"),className:"w-full bg-transparent text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-3 space-y-4",children:x.length===0?e.jsx("div",{className:"py-8 text-center text-[13px] text-ink-secondary",children:s("shortcuts.noMatch",{query:a})}):x.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-ink-tertiary",children:g(t)}),e.jsx("div",{className:"divide-y divide-hairline/20 rounded-xl bg-card/40 px-3 py-1 border border-hairline/30",children:t.items.map(u=>e.jsx(w,{item:u,isMac:d},u.id))})]},t.category))}),e.jsxs("div",{className:"flex items-center justify-between border-t border-hairline/40 bg-card/30 px-5 py-2.5 text-[12px] text-ink-secondary",children:[e.jsxs("span",{children:[s("shortcuts.openHintBefore")," ",e.jsx("kbd",{className:"rounded bg-control px-1 py-0.5 font-mono text-[11px]",children:"?"})," ",s("shortcuts.openHintAfter")]}),e.jsx("button",{type:"button",onClick:n,className:"ui-button ui-button-md",children:s("common.done")})]})]})})}export{D as KeyboardShortcutsModal};
@@ -1 +1 @@
1
- import{r as m,j as h}from"./styles-ezcN4hc0.js";import{x as M}from"./App-BtFoKXkb.js";const H="limix.settings.size",R=640,W=460,y=()=>typeof window<"u"&&window.innerWidth>=768;function b(n,o,l,p,c){const u=Math.max(1,window.innerWidth-p),s=Math.max(1,window.innerHeight-c);n.style.width=`${Math.round(Math.min(Math.max(o,R),u))}px`,n.style.height=`${Math.round(Math.min(Math.max(l,W),s))}px`}function v(n,o){n.style.width="",n.style.height="";try{window.localStorage.removeItem(o)}catch{}}const S=[{sx:1,sy:0,cls:"right-0 top-4 bottom-4 w-1.5",cursor:"cursor-ew-resize"},{sx:-1,sy:0,cls:"left-0 top-4 bottom-4 w-1.5",cursor:"cursor-ew-resize"},{sx:0,sy:1,cls:"bottom-0 left-4 right-4 h-1.5",cursor:"cursor-ns-resize"},{sx:0,sy:-1,cls:"top-0 left-4 right-4 h-1.5",cursor:"cursor-ns-resize"},{sx:1,sy:1,cls:"bottom-0 right-0 h-4 w-4",cursor:"cursor-nwse-resize"},{sx:-1,sy:1,cls:"bottom-0 left-0 h-4 w-4",cursor:"cursor-nesw-resize"}];function C({storageKey:n=H,widthInset:o=32,heightInset:l=96,showGrip:p=!1}={}){const c=m.useRef(null),u=m.useRef(null),s=m.useRef(null),z=M("Kéo để đổi kích thước (bấm đúp để đặt lại)","Drag to resize (double-click to reset)"),E=t=>{s.current={w:t.offsetWidth,h:t.offsetHeight};try{window.localStorage.setItem(n,JSON.stringify(s.current))}catch{}};m.useEffect(()=>{const t=c.current?.parentElement;if(!t)return;t.style.maxWidth="100%",t.style.maxHeight="100%",s.current=null;try{const e=JSON.parse(window.localStorage.getItem(n)??"null");e&&typeof e.w=="number"&&Number.isFinite(e.w)&&typeof e.h=="number"&&Number.isFinite(e.h)&&(s.current={w:e.w,h:e.h})}catch{}const r=()=>{const e=s.current;y()&&e?b(t,e.w,e.h,o,l):(t.style.width="",t.style.height="")};return r(),window.addEventListener("resize",r),()=>{u.current?.abort(),window.removeEventListener("resize",r)}},[n,o,l]);const k=t=>r=>{const e=c.current?.parentElement;if(!e||!y()||r.button!==0)return;r.preventDefault(),u.current?.abort();const i=new AbortController;u.current=i;const f=r.clientX,w=r.clientY,L=e.offsetWidth,N=e.offsetHeight,j=a=>{a.pointerId===r.pointerId&&b(e,L+t.sx*(a.clientX-f)*2,N+t.sy*(a.clientY-w)*2,o,l)},g=()=>{i.abort(),u.current=null,y()&&E(e)},D=a=>{a.pointerId===r.pointerId&&g()},d={signal:i.signal};window.addEventListener("pointermove",j,d),window.addEventListener("pointerup",D,d),window.addEventListener("pointercancel",D,d),window.addEventListener("blur",g,d)},x=()=>{const t=c.current?.parentElement;s.current=null,t&&v(t,n)};return h.jsx("span",{ref:c,className:"contents",children:S.map(t=>p&&t.sx===1&&t.sy===1?h.jsx("button",{type:"button",title:z,"aria-label":M("Đổi kích thước cửa sổ bằng phím mũi tên. Enter để đặt lại.","Resize with arrow keys. Press Enter to reset."),className:"absolute bottom-1 right-1 z-20 hidden size-5 cursor-nwse-resize touch-none items-center justify-center rounded text-ink-secondary hover:text-ink focus-visible:outline-2 focus-visible:outline-accent md:flex",onPointerDown:k(t),onDoubleClick:x,onKeyDown:r=>{const e=c.current?.parentElement;if(!e)return;if(r.key==="Enter"||r.key===" "){r.preventDefault(),x();return}const i=32,f=r.key==="ArrowRight"?i:r.key==="ArrowLeft"?-i:0,w=r.key==="ArrowDown"?i:r.key==="ArrowUp"?-i:0;!f&&!w||(r.preventDefault(),b(e,e.offsetWidth+f,e.offsetHeight+w,o,l),E(e))},children:h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",children:h.jsx("path",{d:"M3 10 10 3m-3 7 3-3",stroke:"currentColor",strokeLinecap:"round"})})},"grip"):h.jsx("span",{"aria-hidden":"true",title:z,className:`absolute z-20 hidden touch-none md:block ${t.cls} ${t.cursor}`,onPointerDown:k(t),onDoubleClick:x},`${t.sx}${t.sy}`))})}export{C as L};
1
+ import{r as m,j as h}from"./styles-ezcN4hc0.js";import{x as M}from"./App-C8J3XlgX.js";const H="limix.settings.size",R=640,W=460,y=()=>typeof window<"u"&&window.innerWidth>=768;function b(n,o,l,p,c){const u=Math.max(1,window.innerWidth-p),s=Math.max(1,window.innerHeight-c);n.style.width=`${Math.round(Math.min(Math.max(o,R),u))}px`,n.style.height=`${Math.round(Math.min(Math.max(l,W),s))}px`}function v(n,o){n.style.width="",n.style.height="";try{window.localStorage.removeItem(o)}catch{}}const S=[{sx:1,sy:0,cls:"right-0 top-4 bottom-4 w-1.5",cursor:"cursor-ew-resize"},{sx:-1,sy:0,cls:"left-0 top-4 bottom-4 w-1.5",cursor:"cursor-ew-resize"},{sx:0,sy:1,cls:"bottom-0 left-4 right-4 h-1.5",cursor:"cursor-ns-resize"},{sx:0,sy:-1,cls:"top-0 left-4 right-4 h-1.5",cursor:"cursor-ns-resize"},{sx:1,sy:1,cls:"bottom-0 right-0 h-4 w-4",cursor:"cursor-nwse-resize"},{sx:-1,sy:1,cls:"bottom-0 left-0 h-4 w-4",cursor:"cursor-nesw-resize"}];function C({storageKey:n=H,widthInset:o=32,heightInset:l=96,showGrip:p=!1}={}){const c=m.useRef(null),u=m.useRef(null),s=m.useRef(null),z=M("Kéo để đổi kích thước (bấm đúp để đặt lại)","Drag to resize (double-click to reset)"),E=t=>{s.current={w:t.offsetWidth,h:t.offsetHeight};try{window.localStorage.setItem(n,JSON.stringify(s.current))}catch{}};m.useEffect(()=>{const t=c.current?.parentElement;if(!t)return;t.style.maxWidth="100%",t.style.maxHeight="100%",s.current=null;try{const e=JSON.parse(window.localStorage.getItem(n)??"null");e&&typeof e.w=="number"&&Number.isFinite(e.w)&&typeof e.h=="number"&&Number.isFinite(e.h)&&(s.current={w:e.w,h:e.h})}catch{}const r=()=>{const e=s.current;y()&&e?b(t,e.w,e.h,o,l):(t.style.width="",t.style.height="")};return r(),window.addEventListener("resize",r),()=>{u.current?.abort(),window.removeEventListener("resize",r)}},[n,o,l]);const k=t=>r=>{const e=c.current?.parentElement;if(!e||!y()||r.button!==0)return;r.preventDefault(),u.current?.abort();const i=new AbortController;u.current=i;const f=r.clientX,w=r.clientY,L=e.offsetWidth,N=e.offsetHeight,j=a=>{a.pointerId===r.pointerId&&b(e,L+t.sx*(a.clientX-f)*2,N+t.sy*(a.clientY-w)*2,o,l)},g=()=>{i.abort(),u.current=null,y()&&E(e)},D=a=>{a.pointerId===r.pointerId&&g()},d={signal:i.signal};window.addEventListener("pointermove",j,d),window.addEventListener("pointerup",D,d),window.addEventListener("pointercancel",D,d),window.addEventListener("blur",g,d)},x=()=>{const t=c.current?.parentElement;s.current=null,t&&v(t,n)};return h.jsx("span",{ref:c,className:"contents",children:S.map(t=>p&&t.sx===1&&t.sy===1?h.jsx("button",{type:"button",title:z,"aria-label":M("Đổi kích thước cửa sổ bằng phím mũi tên. Enter để đặt lại.","Resize with arrow keys. Press Enter to reset."),className:"absolute bottom-1 right-1 z-20 hidden size-5 cursor-nwse-resize touch-none items-center justify-center rounded text-ink-secondary hover:text-ink focus-visible:outline-2 focus-visible:outline-accent md:flex",onPointerDown:k(t),onDoubleClick:x,onKeyDown:r=>{const e=c.current?.parentElement;if(!e)return;if(r.key==="Enter"||r.key===" "){r.preventDefault(),x();return}const i=32,f=r.key==="ArrowRight"?i:r.key==="ArrowLeft"?-i:0,w=r.key==="ArrowDown"?i:r.key==="ArrowUp"?-i:0;!f&&!w||(r.preventDefault(),b(e,e.offsetWidth+f,e.offsetHeight+w,o,l),E(e))},children:h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",children:h.jsx("path",{d:"M3 10 10 3m-3 7 3-3",stroke:"currentColor",strokeLinecap:"round"})})},"grip"):h.jsx("span",{"aria-hidden":"true",title:z,className:`absolute z-20 hidden touch-none md:block ${t.cls} ${t.cursor}`,onPointerDown:k(t),onDoubleClick:x},`${t.sx}${t.sy}`))})}export{C as L};
@@ -1 +1 @@
1
- import{r as n,t as s,j as e,a as o}from"./styles-ezcN4hc0.js";import{c as H,t as M}from"./desktop-connection-Dfaq6k5a.js";import{u as P,d as B,L as D}from"./PlacesRail-BesUMTCh.js";import{S as F,R as K}from"./MenuMotion-Dr44d4Sg.js";import{P as O,U as q}from"./App-BtFoKXkb.js";import"./desktop-viewer-CF-OpSo0.js";import"./monitor-DwKv3TJO.js";import"./index-DLhL-159.js";function Z({target:x,threadId:f,name:R,poster:b,expanded:r,onExpandedChange:h,onHandBack:E,handingBack:g,onUnreachable:v}){const j=n.useRef(null),a=n.useRef(null),[i,c]=n.useState("connecting"),[k,w]=n.useState(0),[l,y]=n.useState(""),N=n.useRef(!1),{dragProps:L,noDragStyle:u}=P(),T=B().capabilities.windowChrome==="mac-inset",C=n.useRef(v);C.current=v,n.useEffect(()=>{const t=new AbortController;let p,S;const V=()=>{c("disconnected"),N.current?k===0&&(S=setTimeout(()=>w(1),1e3)):C.current()};return c("connecting"),H(j.current,x,{threadId:f,signal:t.signal,events:{connected:()=>{N.current=!0,c("connected")},disconnected:V}}).then(m=>{if(t.signal.aborted)return m.disconnect();p=m,a.current=m},()=>{t.signal.aborted||V()}),()=>{t.abort(),clearTimeout(S),p?.disconnect(),a.current===p&&(a.current=null)}},[x,f,k]),n.useEffect(()=>{i==="connected"&&a.current?.focus({preventScroll:!0})},[r,i]);const z=s("computer.viewerTitle",{name:R}),A=e.jsxs("span",{className:"pointer-events-none flex items-center gap-1.5 rounded-full bg-black/70 px-2.5 py-1 text-[11px] font-medium text-white shadow-sm",children:[e.jsx("span",{className:"size-1.5 rounded-full bg-success","aria-hidden":"true"}),s("computer.inControl")]}),d="flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] focus-visible:outline-2 focus-visible:outline-focus disabled:opacity-50";return e.jsxs("div",{"data-live-desktop":!0,"data-state":i,"data-expanded":r?"true":void 0,className:o(r?"fixed inset-0 z-[65] flex flex-col bg-app":"relative h-full w-full"),onKeyDown:t=>{r&&t.key==="Escape"&&!(t.target instanceof HTMLCanvasElement)&&h(!1)},children:[r&&e.jsxs("header",{...L,className:o("flex shrink-0 flex-wrap items-center gap-2 border-b border-hairline/40 bg-panel px-3 py-2",T&&"pl-[86px]"),children:[e.jsx("span",{className:"min-w-0 truncate text-[13px] font-medium text-ink",children:z}),A,e.jsxs("form",{style:u,className:"ml-auto flex min-w-0 items-center gap-1",onSubmit:t=>{t.preventDefault(),!(!a.current||i!=="connected"||!l)&&(M(a.current,l),y(""))},children:[e.jsx("input",{value:l,onChange:t=>y(t.target.value),maxLength:4096,autoComplete:"off",autoCapitalize:"off",spellCheck:!1,placeholder:s("desktopViewer.text"),"aria-label":s("desktopViewer.text"),className:"w-44 min-w-0 rounded-lg border border-hairline bg-inset px-2.5 py-1.5 text-[12px] text-ink outline-none focus:border-focus max-sm:w-28"}),e.jsx("button",{type:"submit",disabled:i!=="connected"||!l,title:s("desktopViewer.send"),"aria-label":s("desktopViewer.send"),className:o(d,"bg-control text-ink hover:bg-raised-hover"),children:e.jsx(F,{size:14,"aria-hidden":"true"})})]}),e.jsxs("button",{type:"button",style:u,onClick:()=>h(!1),className:o(d,"bg-control text-ink hover:bg-raised-hover"),children:[e.jsx(O,{size:14,"aria-hidden":"true"}),e.jsx("span",{className:"max-sm:hidden",children:s("desktopViewer.exitFullscreen")})]}),e.jsxs("button",{type:"button",style:u,onClick:E,disabled:g,className:o(d,"bg-accent font-medium text-accent-ink hover:brightness-110"),children:[g?e.jsx(D,{size:14,className:"animate-spin","aria-hidden":"true"}):e.jsx(q,{size:14,"aria-hidden":"true"}),s("computer.handBack")]})]}),e.jsxs("div",{className:o("relative overflow-hidden bg-inset",r?"min-h-0 flex-1":"h-full w-full"),children:[b&&i!=="connected"&&e.jsx("img",{src:b,alt:"","aria-hidden":"true",className:"absolute inset-0 h-full w-full object-contain opacity-50"}),e.jsx("div",{ref:j,role:"application","aria-label":z,className:"absolute inset-0"}),i==="connecting"&&e.jsxs("div",{role:"status",className:"pointer-events-none absolute inset-0 flex items-center justify-center gap-2 text-[12px] text-ink-secondary",children:[e.jsx(D,{size:16,className:"animate-spin","aria-hidden":"true"}),s("desktopViewer.connecting")]}),i==="disconnected"&&e.jsxs("div",{role:"alert",className:"absolute inset-x-0 bottom-0 flex flex-col items-center gap-2 bg-card/95 p-3 text-center text-[12px] text-ink-secondary",children:[e.jsx("span",{children:s("desktopViewer.disconnected")}),e.jsxs("button",{type:"button",onClick:()=>w(t=>t+1),className:"flex items-center gap-1.5 rounded-md bg-control px-3 py-1.5 text-ink hover:bg-raised-hover",children:[e.jsx(K,{size:13,"aria-hidden":"true"}),s("desktopViewer.reconnect")]})]})]})]})}export{Z as LiveDesktop};
1
+ import{r as n,t as s,j as e,a as o}from"./styles-ezcN4hc0.js";import{c as H,t as M}from"./desktop-connection-Dfaq6k5a.js";import{u as P,d as B,L as D}from"./PlacesRail-BesUMTCh.js";import{S as F,R as K}from"./MenuMotion-Dr44d4Sg.js";import{P as O,U as q}from"./App-C8J3XlgX.js";import"./desktop-viewer-CF-OpSo0.js";import"./monitor-DwKv3TJO.js";import"./index-C9y4_V8D.js";function Z({target:x,threadId:f,name:R,poster:b,expanded:r,onExpandedChange:h,onHandBack:E,handingBack:g,onUnreachable:v}){const j=n.useRef(null),a=n.useRef(null),[i,c]=n.useState("connecting"),[k,w]=n.useState(0),[l,y]=n.useState(""),N=n.useRef(!1),{dragProps:L,noDragStyle:u}=P(),T=B().capabilities.windowChrome==="mac-inset",C=n.useRef(v);C.current=v,n.useEffect(()=>{const t=new AbortController;let p,S;const V=()=>{c("disconnected"),N.current?k===0&&(S=setTimeout(()=>w(1),1e3)):C.current()};return c("connecting"),H(j.current,x,{threadId:f,signal:t.signal,events:{connected:()=>{N.current=!0,c("connected")},disconnected:V}}).then(m=>{if(t.signal.aborted)return m.disconnect();p=m,a.current=m},()=>{t.signal.aborted||V()}),()=>{t.abort(),clearTimeout(S),p?.disconnect(),a.current===p&&(a.current=null)}},[x,f,k]),n.useEffect(()=>{i==="connected"&&a.current?.focus({preventScroll:!0})},[r,i]);const z=s("computer.viewerTitle",{name:R}),A=e.jsxs("span",{className:"pointer-events-none flex items-center gap-1.5 rounded-full bg-black/70 px-2.5 py-1 text-[11px] font-medium text-white shadow-sm",children:[e.jsx("span",{className:"size-1.5 rounded-full bg-success","aria-hidden":"true"}),s("computer.inControl")]}),d="flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] focus-visible:outline-2 focus-visible:outline-focus disabled:opacity-50";return e.jsxs("div",{"data-live-desktop":!0,"data-state":i,"data-expanded":r?"true":void 0,className:o(r?"fixed inset-0 z-[65] flex flex-col bg-app":"relative h-full w-full"),onKeyDown:t=>{r&&t.key==="Escape"&&!(t.target instanceof HTMLCanvasElement)&&h(!1)},children:[r&&e.jsxs("header",{...L,className:o("flex shrink-0 flex-wrap items-center gap-2 border-b border-hairline/40 bg-panel px-3 py-2",T&&"pl-[86px]"),children:[e.jsx("span",{className:"min-w-0 truncate text-[13px] font-medium text-ink",children:z}),A,e.jsxs("form",{style:u,className:"ml-auto flex min-w-0 items-center gap-1",onSubmit:t=>{t.preventDefault(),!(!a.current||i!=="connected"||!l)&&(M(a.current,l),y(""))},children:[e.jsx("input",{value:l,onChange:t=>y(t.target.value),maxLength:4096,autoComplete:"off",autoCapitalize:"off",spellCheck:!1,placeholder:s("desktopViewer.text"),"aria-label":s("desktopViewer.text"),className:"w-44 min-w-0 rounded-lg border border-hairline bg-inset px-2.5 py-1.5 text-[12px] text-ink outline-none focus:border-focus max-sm:w-28"}),e.jsx("button",{type:"submit",disabled:i!=="connected"||!l,title:s("desktopViewer.send"),"aria-label":s("desktopViewer.send"),className:o(d,"bg-control text-ink hover:bg-raised-hover"),children:e.jsx(F,{size:14,"aria-hidden":"true"})})]}),e.jsxs("button",{type:"button",style:u,onClick:()=>h(!1),className:o(d,"bg-control text-ink hover:bg-raised-hover"),children:[e.jsx(O,{size:14,"aria-hidden":"true"}),e.jsx("span",{className:"max-sm:hidden",children:s("desktopViewer.exitFullscreen")})]}),e.jsxs("button",{type:"button",style:u,onClick:E,disabled:g,className:o(d,"bg-accent font-medium text-accent-ink hover:brightness-110"),children:[g?e.jsx(D,{size:14,className:"animate-spin","aria-hidden":"true"}):e.jsx(q,{size:14,"aria-hidden":"true"}),s("computer.handBack")]})]}),e.jsxs("div",{className:o("relative overflow-hidden bg-inset",r?"min-h-0 flex-1":"h-full w-full"),children:[b&&i!=="connected"&&e.jsx("img",{src:b,alt:"","aria-hidden":"true",className:"absolute inset-0 h-full w-full object-contain opacity-50"}),e.jsx("div",{ref:j,role:"application","aria-label":z,className:"absolute inset-0"}),i==="connecting"&&e.jsxs("div",{role:"status",className:"pointer-events-none absolute inset-0 flex items-center justify-center gap-2 text-[12px] text-ink-secondary",children:[e.jsx(D,{size:16,className:"animate-spin","aria-hidden":"true"}),s("desktopViewer.connecting")]}),i==="disconnected"&&e.jsxs("div",{role:"alert",className:"absolute inset-x-0 bottom-0 flex flex-col items-center gap-2 bg-card/95 p-3 text-center text-[12px] text-ink-secondary",children:[e.jsx("span",{children:s("desktopViewer.disconnected")}),e.jsxs("button",{type:"button",onClick:()=>w(t=>t+1),className:"flex items-center gap-1.5 rounded-md bg-control px-3 py-1.5 text-ink hover:bg-raised-hover",children:[e.jsx(K,{size:13,"aria-hidden":"true"}),s("desktopViewer.reconnect")]})]})]})]})}export{Z as LiveDesktop};
@@ -1 +1 @@
1
- import{t as l,o as ae,s as ce,f as O,g as W,h as ve,r as i,p as he,j as c,X as we,a as Q,u as xe}from"./styles-ezcN4hc0.js";import{u as be,W as ke,X as ee,Y as ie,j as q,w as ye,U as te,Z as ge}from"./App-BtFoKXkb.js";import{u as Ne,L as T}from"./PlacesRail-BesUMTCh.js";import{M as le}from"./monitor-DwKv3TJO.js";import{R as je}from"./MenuMotion-Dr44d4Sg.js";import"./index-DLhL-159.js";function Ce(s,e){const u=(n,o)=>n.left<o.right&&n.right>o.left&&n.top<o.bottom&&n.bottom>o.top;return e.some(n=>n.visible&&n.rect.width>0&&n.rect.height>0&&(n.explicit||n.zIndex!==null&&n.zIndex>=10)&&s.some(o=>u(n.rect,o)))}async function Se(s,e,u,n){e&&e!==u&&(await s.setInteractive(null),await s.release(e));const o=await s.take(u);if(!o.held)throw new Error(l("vm.workspace.holdNotAcquired"));if(o.owned!==!0)return{status:"held-elsewhere",botId:u,snapshot:o};try{await s.setInteractive(n)}catch(d){throw await s.setInteractive(null).catch(()=>{}),await s.release(u).catch(()=>{}),d}return{status:"controlled",botId:u,snapshot:o}}async function $(s,e){return e?(await s.setInteractive(null).catch(()=>{}),s.release(e)):null}function ue(s){return s.filter(e=>e.computer==="vm"&&e.hidden!==!0).map(e=>e.id)}function Ee(s,e){const u=ue(s),n=u.includes(e)?e:u[0]??null;return[n,u.find(o=>o!==n)??null]}function Re(s,e,u){const n=[...s],o=e===0?1:0;return u&&n[o]===u&&(n[o]=n[e]),n[e]=u,n}function Le(s,e){const u=ue(e),n=new Set(u),o=[null,null];for(const d of[0,1]){const m=s[d];m&&n.delete(m)&&(o[d]=m)}for(const d of[0,1]){if(o[d])continue;const m=[...n][0];m&&(o[d]=m,n.delete(m))}return o}const ze=ae({mode:W(["shared","per-bot","pool"]).optional(),max_instances:ve().int().nonnegative().optional(),container:W(["running","stopped","missing"]).optional(),network:W(["loopback","unsafe","unknown"]).optional(),security:W(["hardened","unsafe","unknown"]).optional(),persistence:W(["durable","unsafe","unknown"]).optional(),desktopReady:O().optional(),ready:O().optional(),viewer_url:ce().min(1).optional()});function de(s){const e=ze.safeParse(s);return e.success?e.data:null}function X(s){const e=de(s),u=e?.mode??"unknown",n=e?.container??"unknown",o=e?.network??"unknown",d=e?.security??"unknown",m=e?.persistence??"unknown",w=e?.max_instances??0,h=e?.desktopReady===!0,x=!!(e?.ready===!0&&n==="running"&&o==="loopback"&&d==="hardened"&&m==="durable"&&h);return{mode:u,maxInstances:w,container:n,network:o,security:d,persistence:m,desktopReady:h,ready:x}}function Ve(s){const e=de(s);return!e||!X(s).ready?null:e.viewer_url??null}const D=["local-vm-workspace:left","local-vm-workspace:right"],pe=ae({held:O(),helpReason:ce().nullable(),help:xe().optional().transform(ge),owned:O().optional(),acquired:O().optional(),released:O().optional()});async function ne(s,e,u){const n=await q(`/api/bots/${s}/computer/control`,{method:"POST",body:JSON.stringify({action:e,controlLeaseId:u})}),o=pe.safeParse(n);if(!o.success)throw new Error("invalid-control-snapshot");return o.data}async function Oe(s){const e=pe.safeParse(await q(`/api/bots/${s}/computer/control`));if(!e.success)throw new Error("invalid-control-snapshot");return e.data}function re(s,e){fetch(`/api/bots/${s}/computer/control`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"release",controlLeaseId:e}),keepalive:!0}).then(async u=>{u.ok}).catch(()=>{})}async function se(s,e){return!0}function H(s,e,u){s({type:"computerControl",botId:e,held:u.held,helpReason:u.helpReason,help:u.help??null})}function oe(s){const e=s.current?.getBoundingClientRect();return!e||e.width<1||e.height<1?null:{x:Math.round(e.left),y:Math.round(e.top),width:Math.round(e.width),height:Math.round(e.height)}}const Be=['[aria-modal="true"]','[role="dialog"]','[role="menu"]',"[popover]","[data-native-view-overlay]",".fixed",".absolute"].join(",");function Ie(){const s=[...document.querySelectorAll("[data-native-view-host]")],e=s.map(n=>n.getBoundingClientRect()).filter(n=>n.width>0&&n.height>0);if(e.length===0)return!1;const u=[...document.querySelectorAll(Be)].filter(n=>!s.some(o=>n===o||n.contains(o)||o.contains(n))).map(n=>{const o=window.getComputedStyle(n),d=n.matches('[aria-modal="true"], [role="dialog"], [role="menu"], [popover], [data-native-view-overlay]'),m=Number.parseInt(o.zIndex,10);return{rect:n.getBoundingClientRect(),explicit:d,visible:o.display!=="none"&&o.visibility!=="hidden"&&Number(o.opacity)!==0,zIndex:Number.isFinite(m)?m:null}});return Ce(e,u)}function We(s){const[e,u]=i.useState(!1);return i.useEffect(()=>{let n=0;const o=()=>u(Ie()),d=()=>{n||(n=requestAnimationFrame(()=>{n=0,o()}))};o();const m=new MutationObserver(d);m.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class","style","aria-hidden","aria-modal","role","open","popover"]});const w=new ResizeObserver(d);w.observe(document.body);for(const x of document.querySelectorAll("[data-native-view-host]"))w.observe(x);const h=["toggle","animationstart","animationend","transitionstart","transitionend"];for(const x of h)document.addEventListener(x,d,!0);return window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),()=>{n&&cancelAnimationFrame(n),m.disconnect(),w.disconnect();for(const x of h)document.removeEventListener(x,d,!0);window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0)}},[]),s||e}function Ae(s,e){return s?s.container==="missing"?l("vm.workspace.status.missing"):s.container==="stopped"?l("vm.workspace.status.stopped"):s.ready?e==="error"?l("vm.workspace.status.viewerUnavailable"):e!=="ready"?l("vm.workspace.status.connecting"):l("vm.workspace.status.live"):l("vm.workspace.status.unavailable"):l("vm.workspace.status.checking")}function _e({index:s,bot:e,bots:u,otherBotId:n,obscured:o,active:d,heldElsewhere:m,controlPending:w,onSelect:h,onTake:x,onRelease:B,onOpenComputer:A}){const v=D[s],p=e?.id??null,I=e?.name??l("vm.workspace.localVm"),b=i.useRef(null),k=i.useRef(Promise.resolve()),z=i.useRef(o),[_,V]=i.useState(0),[C,N]=i.useState(null),[j,y]=i.useState({contextId:v,open:!1,status:"closed",interactive:!1}),[E,g]=i.useState(null),R=i.useCallback(async t=>{if(p)try{const a=await q(`/api/bots/${p}/local-computer`,{signal:t});t?.aborted||N(X(a))}catch{}},[p]),F=i.useRef(R);i.useEffect(()=>{F.current=R},[R]),i.useEffect(()=>{z.current=o},[o]),i.useEffect(()=>window.ogb?.desktopWorkspace?.onState(a=>{a.contextId===v&&(y(a),(a.status==="error"||a.status==="closed")&&F.current())}),[v]),i.useEffect(()=>{const t=window.ogb?.desktopWorkspace;let a=!0;const f=new AbortController;N(null),g(null),y({contextId:v,open:!1,status:"closed",interactive:!1});const M=async()=>{if(t&&await t.close(v).catch(()=>{}),!(!a||!p)){if(!t){g(l("vm.workspace.desktopRequired"));return}try{const S=await q(`/api/bots/${p}/local-computer`,{signal:f.signal});if(!a)return;const J=X(S);N(J);const Y=Ve(S);if(!J.ready||!Y||(await new Promise(me=>{let G=!1;const K=()=>{G||(G=!0,me())},fe=setTimeout(K,100);requestAnimationFrame(()=>{clearTimeout(fe),K()})}),!a))return;const U=oe(b);if(!U)throw new Error("layout-unavailable");const Z=await t.open({contextId:v,url:Y,title:l("vm.workspace.windowTitle",{name:I}),bounds:U});if(!a){await t.close(v).catch(()=>{});return}y(Z),await t.layout([{contextId:v,bounds:U,visible:!z.current&&Z.open}])}catch(S){if(!a||f.signal.aborted)return;g(S instanceof Error&&S.message==="layout-unavailable"?l("vm.workspace.layoutUnavailable"):l("vm.workspace.connectFailed"))}}};return k.current=k.current.catch(()=>{}).then(M),()=>{a=!1,f.abort(),t&&(k.current=k.current.catch(()=>{}).then(()=>t.close(v).then(()=>{}).catch(()=>{})))}},[p,I,v,_]),i.useEffect(()=>{if(!p)return;const t=new AbortController,a=window.setInterval(()=>{R(t.signal)},3e4);return()=>{t.abort(),window.clearInterval(a)}},[p,R]);const L=i.useCallback(()=>{const t=window.ogb?.desktopWorkspace,a=oe(b);!t||!a||!j.open||t.layout([{contextId:v,bounds:a,visible:!o}]).catch(()=>g(l("vm.workspace.positionFailed")))},[v,j.open,o]);i.useEffect(()=>{const t=b.current;if(!t)return;const a=new ResizeObserver(L);a.observe(t),window.addEventListener("resize",L);const f=requestAnimationFrame(L);return()=>{cancelAnimationFrame(f),a.disconnect(),window.removeEventListener("resize",L)}},[L]);const P=Ae(C,j.status),r=!!(e&&C?.ready&&j.status==="ready"&&j.open);return c.jsxs("section",{className:Q("flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border bg-panel",d?"border-accent/80 shadow-[0_0_0_1px_rgb(var(--accent)/0.35)]":"border-hairline/50"),children:[c.jsxs("div",{className:"flex min-h-[68px] items-center gap-3 border-b border-hairline/40 px-3 py-2.5",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("label",{className:"sr-only",htmlFor:`local-vm-slot-${s}`,children:l("vm.workspace.paneLabel",{number:s+1})}),c.jsxs(ye,{size:"sm",className:"w-full",id:`local-vm-slot-${s}`,value:e?.id??"",onChange:t=>h(t.target.value||null),disabled:w,children:[c.jsx("option",{value:"",children:l("vm.workspace.chooseBot")}),u.map(t=>c.jsx("option",{value:t.id,disabled:t.id===n,children:t.name},t.id))]}),c.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-ink-secondary",children:[c.jsx("span",{className:Q("h-1.5 w-1.5 rounded-full",d?"bg-accent":j.status==="ready"?"bg-success":j.status==="error"?"bg-danger":"bg-ink-secondary/50")}),d?l("vm.workspace.youHaveControl"):m?l("vm.workspace.controlElsewhere"):P]})]}),e&&d?c.jsxs("button",{type:"button",onClick:B,disabled:w,className:"flex shrink-0 items-center gap-1.5 rounded-lg bg-accent px-2.5 py-2 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[w?c.jsx(T,{size:13,className:"animate-spin"}):c.jsx(te,{size:13}),l("vm.workspace.handBack")]}):e?c.jsxs("button",{type:"button",onClick:()=>x(e.id),disabled:!r||w||m,className:"flex shrink-0 items-center gap-1.5 rounded-lg bg-raised px-2.5 py-2 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-45",title:l("vm.workspace.takeControlTitle"),children:[w?c.jsx(T,{size:13,className:"animate-spin"}):c.jsx(te,{size:13}),m?l("vm.workspace.heldElsewhere"):l("vm.workspace.takeControl")]}):null]}),c.jsx("div",{ref:b,"data-native-view-host":!0,className:"relative min-h-0 flex-1 bg-[#070707]",children:c.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center",children:e?!C&&!E?c.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[c.jsx(T,{size:15,className:"animate-spin"})," ",l("vm.workspace.checking",{name:e.name})]}):C?.ready&&j.status!=="error"&&!E?c.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[c.jsx(T,{size:15,className:"animate-spin"})," ",l("vm.workspace.connecting")]}):c.jsxs("div",{className:"flex max-w-[300px] flex-col items-center gap-3 text-ink-secondary",children:[c.jsx(ie,{size:21,className:"text-warning"}),c.jsx("div",{className:"text-[12px] leading-relaxed",children:E??(C?.container==="missing"?l("vm.workspace.notCreated",{name:e.name}):C?.container==="stopped"?l("vm.workspace.stopped",{name:e.name}):l("vm.workspace.notReady",{name:e.name}))}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("button",{type:"button",onClick:()=>V(t=>t+1),className:"flex items-center gap-1.5 rounded-lg bg-raised px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:[c.jsx(je,{size:13})," ",l("vm.workspace.retryStatus")]}),c.jsx("button",{type:"button",onClick:()=>A(e.id),className:"rounded-lg bg-raised px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:l("vm.workspace.openComputer")})]})]}):c.jsxs("div",{className:"flex max-w-[260px] flex-col items-center gap-2 text-ink-secondary",children:[c.jsx(le,{size:22}),c.jsx("span",{className:"text-[12px]",children:l("vm.workspace.chooseAnother")})]})})})]})}function $e({primaryBotId:s,overlayOpen:e,onClose:u,onOpenComputer:n}){const{state:o,dispatch:d}=be(),{dragProps:m}=Ne(),w=i.useMemo(()=>o.bots.filter(r=>r.computer==="vm"&&!r.hidden),[o.bots]),[h,x]=i.useState(()=>Ee(o.bots,s)),B=i.useRef(h),[A,v]=i.useState(null),p=i.useRef(null),I=i.useRef(null),b=I.current??ke();I.current=b;const k=i.useRef(!1),z=i.useRef(!0),[_,V]=i.useState(!1),[C,N]=i.useState(null),j=We(e);i.useEffect(()=>{B.current=h},[h]);const y=i.useMemo(()=>({async take(r){const t=await ee({action:"take",syncNativeBrowser:!0,requestControl:a=>ne(r,a,b),setNativeBrowserControl:a=>se()});return H(d,r,t),t.held&&t.owned===!0?p.current=r:p.current===r&&(p.current=null),t},async release(r){const t=await ee({action:"release",syncNativeBrowser:!0,requestControl:a=>ne(r,a,b),setNativeBrowserControl:a=>se()});return H(d,r,t),p.current===r&&(p.current=null),t},async setInteractive(r){const t=window.ogb?.desktopWorkspace;if(!t)throw new Error(l("vm.workspace.bridgeUnavailable"));return t.setInteractive(r)}}),[b,d]);i.useEffect(()=>{x(r=>{const t=Le(r,o.bots);return t[0]===r[0]&&t[1]===r[1]?r:t})},[o.bots]),i.useEffect(()=>{let r=!0;return(async()=>{for(const a of h)if(a)try{const f=await Oe(a);r&&H(d,a,f)}catch{}})(),()=>{r=!1}},[d,h]),i.useEffect(()=>{const r=p.current;!r||h.includes(r)||$(y,r).then(()=>{v(null)}).catch(()=>{N(l("vm.workspace.handoffFailed"))})},[y,h]),i.useEffect(()=>(z.current=!0,()=>{z.current=!1;const r=p.current,t=window.ogb?.desktopWorkspace;if(!t){r&&re(r,b);return}t.setInteractive(null).catch(()=>{}).then(()=>(r&&re(r,b),t.close())).catch(()=>{})}),[b]);const E=i.useCallback(r=>{const t=B.current.indexOf(r);return t<0?null:D[t]},[]),g=i.useCallback(async()=>{const r=p.current;if(!r)return!0;if(k.current)return!1;k.current=!0,V(!0),N(null);try{return await $(y,r),v(null),!0}catch{return N(l("vm.workspace.handBackFailed",{app:he()})),!1}finally{k.current=!1,V(!1)}},[y]),R=i.useCallback(async r=>{if(k.current||p.current===r)return;const t=window.ogb?.desktopWorkspace,a=E(r);if(!(!t||!a)){k.current=!0,V(!0),N(null);try{const f={...y,async setInteractive(S){if(S&&E(r)!==S)throw new Error(l("vm.workspace.paneChanged"));return y.setInteractive(S)}},M=await Se(f,p.current,r,a);if(v(null),M.status==="held-elsewhere"){N(l("vm.workspace.alreadyControlled"));return}if(!z.current){await $(y,r).catch(()=>{});return}v(r)}catch{v(p.current),N(l("vm.workspace.switchFailed"))}finally{k.current=!1,V(!1)}}},[E,y]),F=i.useCallback(async(r,t)=>{if(k.current)return;const a=B.current[r];a!==t&&(a&&p.current===a&&!await g()||x(f=>Re(f,r,t)))},[g]),L=i.useCallback(async()=>{p.current&&!await g()||u()},[g,u]),P=i.useCallback(async r=>{p.current&&!await g()||n(r)},[g,n]);return c.jsxs("main",{className:"flex h-full min-w-0 flex-1 flex-col bg-app",children:[c.jsxs("header",{...m,className:"flex min-h-[60px] items-center gap-3 border-b border-hairline/40 px-5 py-3",children:[c.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-accent/15 text-accent",children:c.jsx(le,{size:18})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("h1",{className:"truncate text-[14px] font-semibold text-ink",children:l("vm.workspace.viewTitle")}),c.jsx("p",{className:"truncate text-[12px] text-ink-secondary",children:l("vm.workspace.viewSubtitle")})]}),c.jsx("button",{type:"button",onClick:()=>{L()},disabled:_,className:"rounded-md p-1.5 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":l("vm.workspace.closeView"),children:c.jsx(we,{size:18})})]}),C&&c.jsxs("div",{className:"mx-3 mt-3 flex items-center gap-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:[c.jsx(ie,{size:14,className:"shrink-0"})," ",C]}),c.jsx("div",{className:"grid min-h-0 flex-1 grid-cols-2 gap-3 p-3",children:[0,1].map(r=>{const t=h[r],a=w.find(f=>f.id===t)??null;return c.jsx(_e,{index:r,bot:a,bots:w,otherBotId:h[r===0?1:0],obscured:j,active:!!(a&&A===a.id),heldElsewhere:!!(a&&o.computerControl[a.id]?.held&&A!==a.id),controlPending:_,onSelect:f=>{F(r,f)},onTake:f=>{R(f)},onRelease:()=>{g()},onOpenComputer:f=>{P(f)}},D[r])})})]})}export{$e as LocalVmWorkspace};
1
+ import{t as l,o as ae,s as ce,f as O,g as W,h as ve,r as i,p as he,j as c,X as we,a as Q,u as xe}from"./styles-ezcN4hc0.js";import{u as be,W as ke,X as ee,Y as ie,j as q,w as ye,U as te,Z as ge}from"./App-C8J3XlgX.js";import{u as Ne,L as T}from"./PlacesRail-BesUMTCh.js";import{M as le}from"./monitor-DwKv3TJO.js";import{R as je}from"./MenuMotion-Dr44d4Sg.js";import"./index-C9y4_V8D.js";function Ce(s,e){const u=(n,o)=>n.left<o.right&&n.right>o.left&&n.top<o.bottom&&n.bottom>o.top;return e.some(n=>n.visible&&n.rect.width>0&&n.rect.height>0&&(n.explicit||n.zIndex!==null&&n.zIndex>=10)&&s.some(o=>u(n.rect,o)))}async function Se(s,e,u,n){e&&e!==u&&(await s.setInteractive(null),await s.release(e));const o=await s.take(u);if(!o.held)throw new Error(l("vm.workspace.holdNotAcquired"));if(o.owned!==!0)return{status:"held-elsewhere",botId:u,snapshot:o};try{await s.setInteractive(n)}catch(d){throw await s.setInteractive(null).catch(()=>{}),await s.release(u).catch(()=>{}),d}return{status:"controlled",botId:u,snapshot:o}}async function $(s,e){return e?(await s.setInteractive(null).catch(()=>{}),s.release(e)):null}function ue(s){return s.filter(e=>e.computer==="vm"&&e.hidden!==!0).map(e=>e.id)}function Ee(s,e){const u=ue(s),n=u.includes(e)?e:u[0]??null;return[n,u.find(o=>o!==n)??null]}function Re(s,e,u){const n=[...s],o=e===0?1:0;return u&&n[o]===u&&(n[o]=n[e]),n[e]=u,n}function Le(s,e){const u=ue(e),n=new Set(u),o=[null,null];for(const d of[0,1]){const m=s[d];m&&n.delete(m)&&(o[d]=m)}for(const d of[0,1]){if(o[d])continue;const m=[...n][0];m&&(o[d]=m,n.delete(m))}return o}const ze=ae({mode:W(["shared","per-bot","pool"]).optional(),max_instances:ve().int().nonnegative().optional(),container:W(["running","stopped","missing"]).optional(),network:W(["loopback","unsafe","unknown"]).optional(),security:W(["hardened","unsafe","unknown"]).optional(),persistence:W(["durable","unsafe","unknown"]).optional(),desktopReady:O().optional(),ready:O().optional(),viewer_url:ce().min(1).optional()});function de(s){const e=ze.safeParse(s);return e.success?e.data:null}function X(s){const e=de(s),u=e?.mode??"unknown",n=e?.container??"unknown",o=e?.network??"unknown",d=e?.security??"unknown",m=e?.persistence??"unknown",w=e?.max_instances??0,h=e?.desktopReady===!0,x=!!(e?.ready===!0&&n==="running"&&o==="loopback"&&d==="hardened"&&m==="durable"&&h);return{mode:u,maxInstances:w,container:n,network:o,security:d,persistence:m,desktopReady:h,ready:x}}function Ve(s){const e=de(s);return!e||!X(s).ready?null:e.viewer_url??null}const D=["local-vm-workspace:left","local-vm-workspace:right"],pe=ae({held:O(),helpReason:ce().nullable(),help:xe().optional().transform(ge),owned:O().optional(),acquired:O().optional(),released:O().optional()});async function ne(s,e,u){const n=await q(`/api/bots/${s}/computer/control`,{method:"POST",body:JSON.stringify({action:e,controlLeaseId:u})}),o=pe.safeParse(n);if(!o.success)throw new Error("invalid-control-snapshot");return o.data}async function Oe(s){const e=pe.safeParse(await q(`/api/bots/${s}/computer/control`));if(!e.success)throw new Error("invalid-control-snapshot");return e.data}function re(s,e){fetch(`/api/bots/${s}/computer/control`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"release",controlLeaseId:e}),keepalive:!0}).then(async u=>{u.ok}).catch(()=>{})}async function se(s,e){return!0}function H(s,e,u){s({type:"computerControl",botId:e,held:u.held,helpReason:u.helpReason,help:u.help??null})}function oe(s){const e=s.current?.getBoundingClientRect();return!e||e.width<1||e.height<1?null:{x:Math.round(e.left),y:Math.round(e.top),width:Math.round(e.width),height:Math.round(e.height)}}const Be=['[aria-modal="true"]','[role="dialog"]','[role="menu"]',"[popover]","[data-native-view-overlay]",".fixed",".absolute"].join(",");function Ie(){const s=[...document.querySelectorAll("[data-native-view-host]")],e=s.map(n=>n.getBoundingClientRect()).filter(n=>n.width>0&&n.height>0);if(e.length===0)return!1;const u=[...document.querySelectorAll(Be)].filter(n=>!s.some(o=>n===o||n.contains(o)||o.contains(n))).map(n=>{const o=window.getComputedStyle(n),d=n.matches('[aria-modal="true"], [role="dialog"], [role="menu"], [popover], [data-native-view-overlay]'),m=Number.parseInt(o.zIndex,10);return{rect:n.getBoundingClientRect(),explicit:d,visible:o.display!=="none"&&o.visibility!=="hidden"&&Number(o.opacity)!==0,zIndex:Number.isFinite(m)?m:null}});return Ce(e,u)}function We(s){const[e,u]=i.useState(!1);return i.useEffect(()=>{let n=0;const o=()=>u(Ie()),d=()=>{n||(n=requestAnimationFrame(()=>{n=0,o()}))};o();const m=new MutationObserver(d);m.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class","style","aria-hidden","aria-modal","role","open","popover"]});const w=new ResizeObserver(d);w.observe(document.body);for(const x of document.querySelectorAll("[data-native-view-host]"))w.observe(x);const h=["toggle","animationstart","animationend","transitionstart","transitionend"];for(const x of h)document.addEventListener(x,d,!0);return window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),()=>{n&&cancelAnimationFrame(n),m.disconnect(),w.disconnect();for(const x of h)document.removeEventListener(x,d,!0);window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0)}},[]),s||e}function Ae(s,e){return s?s.container==="missing"?l("vm.workspace.status.missing"):s.container==="stopped"?l("vm.workspace.status.stopped"):s.ready?e==="error"?l("vm.workspace.status.viewerUnavailable"):e!=="ready"?l("vm.workspace.status.connecting"):l("vm.workspace.status.live"):l("vm.workspace.status.unavailable"):l("vm.workspace.status.checking")}function _e({index:s,bot:e,bots:u,otherBotId:n,obscured:o,active:d,heldElsewhere:m,controlPending:w,onSelect:h,onTake:x,onRelease:B,onOpenComputer:A}){const v=D[s],p=e?.id??null,I=e?.name??l("vm.workspace.localVm"),b=i.useRef(null),k=i.useRef(Promise.resolve()),z=i.useRef(o),[_,V]=i.useState(0),[C,N]=i.useState(null),[j,y]=i.useState({contextId:v,open:!1,status:"closed",interactive:!1}),[E,g]=i.useState(null),R=i.useCallback(async t=>{if(p)try{const a=await q(`/api/bots/${p}/local-computer`,{signal:t});t?.aborted||N(X(a))}catch{}},[p]),F=i.useRef(R);i.useEffect(()=>{F.current=R},[R]),i.useEffect(()=>{z.current=o},[o]),i.useEffect(()=>window.ogb?.desktopWorkspace?.onState(a=>{a.contextId===v&&(y(a),(a.status==="error"||a.status==="closed")&&F.current())}),[v]),i.useEffect(()=>{const t=window.ogb?.desktopWorkspace;let a=!0;const f=new AbortController;N(null),g(null),y({contextId:v,open:!1,status:"closed",interactive:!1});const M=async()=>{if(t&&await t.close(v).catch(()=>{}),!(!a||!p)){if(!t){g(l("vm.workspace.desktopRequired"));return}try{const S=await q(`/api/bots/${p}/local-computer`,{signal:f.signal});if(!a)return;const J=X(S);N(J);const Y=Ve(S);if(!J.ready||!Y||(await new Promise(me=>{let G=!1;const K=()=>{G||(G=!0,me())},fe=setTimeout(K,100);requestAnimationFrame(()=>{clearTimeout(fe),K()})}),!a))return;const U=oe(b);if(!U)throw new Error("layout-unavailable");const Z=await t.open({contextId:v,url:Y,title:l("vm.workspace.windowTitle",{name:I}),bounds:U});if(!a){await t.close(v).catch(()=>{});return}y(Z),await t.layout([{contextId:v,bounds:U,visible:!z.current&&Z.open}])}catch(S){if(!a||f.signal.aborted)return;g(S instanceof Error&&S.message==="layout-unavailable"?l("vm.workspace.layoutUnavailable"):l("vm.workspace.connectFailed"))}}};return k.current=k.current.catch(()=>{}).then(M),()=>{a=!1,f.abort(),t&&(k.current=k.current.catch(()=>{}).then(()=>t.close(v).then(()=>{}).catch(()=>{})))}},[p,I,v,_]),i.useEffect(()=>{if(!p)return;const t=new AbortController,a=window.setInterval(()=>{R(t.signal)},3e4);return()=>{t.abort(),window.clearInterval(a)}},[p,R]);const L=i.useCallback(()=>{const t=window.ogb?.desktopWorkspace,a=oe(b);!t||!a||!j.open||t.layout([{contextId:v,bounds:a,visible:!o}]).catch(()=>g(l("vm.workspace.positionFailed")))},[v,j.open,o]);i.useEffect(()=>{const t=b.current;if(!t)return;const a=new ResizeObserver(L);a.observe(t),window.addEventListener("resize",L);const f=requestAnimationFrame(L);return()=>{cancelAnimationFrame(f),a.disconnect(),window.removeEventListener("resize",L)}},[L]);const P=Ae(C,j.status),r=!!(e&&C?.ready&&j.status==="ready"&&j.open);return c.jsxs("section",{className:Q("flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border bg-panel",d?"border-accent/80 shadow-[0_0_0_1px_rgb(var(--accent)/0.35)]":"border-hairline/50"),children:[c.jsxs("div",{className:"flex min-h-[68px] items-center gap-3 border-b border-hairline/40 px-3 py-2.5",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("label",{className:"sr-only",htmlFor:`local-vm-slot-${s}`,children:l("vm.workspace.paneLabel",{number:s+1})}),c.jsxs(ye,{size:"sm",className:"w-full",id:`local-vm-slot-${s}`,value:e?.id??"",onChange:t=>h(t.target.value||null),disabled:w,children:[c.jsx("option",{value:"",children:l("vm.workspace.chooseBot")}),u.map(t=>c.jsx("option",{value:t.id,disabled:t.id===n,children:t.name},t.id))]}),c.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-ink-secondary",children:[c.jsx("span",{className:Q("h-1.5 w-1.5 rounded-full",d?"bg-accent":j.status==="ready"?"bg-success":j.status==="error"?"bg-danger":"bg-ink-secondary/50")}),d?l("vm.workspace.youHaveControl"):m?l("vm.workspace.controlElsewhere"):P]})]}),e&&d?c.jsxs("button",{type:"button",onClick:B,disabled:w,className:"flex shrink-0 items-center gap-1.5 rounded-lg bg-accent px-2.5 py-2 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[w?c.jsx(T,{size:13,className:"animate-spin"}):c.jsx(te,{size:13}),l("vm.workspace.handBack")]}):e?c.jsxs("button",{type:"button",onClick:()=>x(e.id),disabled:!r||w||m,className:"flex shrink-0 items-center gap-1.5 rounded-lg bg-raised px-2.5 py-2 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-45",title:l("vm.workspace.takeControlTitle"),children:[w?c.jsx(T,{size:13,className:"animate-spin"}):c.jsx(te,{size:13}),m?l("vm.workspace.heldElsewhere"):l("vm.workspace.takeControl")]}):null]}),c.jsx("div",{ref:b,"data-native-view-host":!0,className:"relative min-h-0 flex-1 bg-[#070707]",children:c.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center",children:e?!C&&!E?c.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[c.jsx(T,{size:15,className:"animate-spin"})," ",l("vm.workspace.checking",{name:e.name})]}):C?.ready&&j.status!=="error"&&!E?c.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[c.jsx(T,{size:15,className:"animate-spin"})," ",l("vm.workspace.connecting")]}):c.jsxs("div",{className:"flex max-w-[300px] flex-col items-center gap-3 text-ink-secondary",children:[c.jsx(ie,{size:21,className:"text-warning"}),c.jsx("div",{className:"text-[12px] leading-relaxed",children:E??(C?.container==="missing"?l("vm.workspace.notCreated",{name:e.name}):C?.container==="stopped"?l("vm.workspace.stopped",{name:e.name}):l("vm.workspace.notReady",{name:e.name}))}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("button",{type:"button",onClick:()=>V(t=>t+1),className:"flex items-center gap-1.5 rounded-lg bg-raised px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:[c.jsx(je,{size:13})," ",l("vm.workspace.retryStatus")]}),c.jsx("button",{type:"button",onClick:()=>A(e.id),className:"rounded-lg bg-raised px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:l("vm.workspace.openComputer")})]})]}):c.jsxs("div",{className:"flex max-w-[260px] flex-col items-center gap-2 text-ink-secondary",children:[c.jsx(le,{size:22}),c.jsx("span",{className:"text-[12px]",children:l("vm.workspace.chooseAnother")})]})})})]})}function $e({primaryBotId:s,overlayOpen:e,onClose:u,onOpenComputer:n}){const{state:o,dispatch:d}=be(),{dragProps:m}=Ne(),w=i.useMemo(()=>o.bots.filter(r=>r.computer==="vm"&&!r.hidden),[o.bots]),[h,x]=i.useState(()=>Ee(o.bots,s)),B=i.useRef(h),[A,v]=i.useState(null),p=i.useRef(null),I=i.useRef(null),b=I.current??ke();I.current=b;const k=i.useRef(!1),z=i.useRef(!0),[_,V]=i.useState(!1),[C,N]=i.useState(null),j=We(e);i.useEffect(()=>{B.current=h},[h]);const y=i.useMemo(()=>({async take(r){const t=await ee({action:"take",syncNativeBrowser:!0,requestControl:a=>ne(r,a,b),setNativeBrowserControl:a=>se()});return H(d,r,t),t.held&&t.owned===!0?p.current=r:p.current===r&&(p.current=null),t},async release(r){const t=await ee({action:"release",syncNativeBrowser:!0,requestControl:a=>ne(r,a,b),setNativeBrowserControl:a=>se()});return H(d,r,t),p.current===r&&(p.current=null),t},async setInteractive(r){const t=window.ogb?.desktopWorkspace;if(!t)throw new Error(l("vm.workspace.bridgeUnavailable"));return t.setInteractive(r)}}),[b,d]);i.useEffect(()=>{x(r=>{const t=Le(r,o.bots);return t[0]===r[0]&&t[1]===r[1]?r:t})},[o.bots]),i.useEffect(()=>{let r=!0;return(async()=>{for(const a of h)if(a)try{const f=await Oe(a);r&&H(d,a,f)}catch{}})(),()=>{r=!1}},[d,h]),i.useEffect(()=>{const r=p.current;!r||h.includes(r)||$(y,r).then(()=>{v(null)}).catch(()=>{N(l("vm.workspace.handoffFailed"))})},[y,h]),i.useEffect(()=>(z.current=!0,()=>{z.current=!1;const r=p.current,t=window.ogb?.desktopWorkspace;if(!t){r&&re(r,b);return}t.setInteractive(null).catch(()=>{}).then(()=>(r&&re(r,b),t.close())).catch(()=>{})}),[b]);const E=i.useCallback(r=>{const t=B.current.indexOf(r);return t<0?null:D[t]},[]),g=i.useCallback(async()=>{const r=p.current;if(!r)return!0;if(k.current)return!1;k.current=!0,V(!0),N(null);try{return await $(y,r),v(null),!0}catch{return N(l("vm.workspace.handBackFailed",{app:he()})),!1}finally{k.current=!1,V(!1)}},[y]),R=i.useCallback(async r=>{if(k.current||p.current===r)return;const t=window.ogb?.desktopWorkspace,a=E(r);if(!(!t||!a)){k.current=!0,V(!0),N(null);try{const f={...y,async setInteractive(S){if(S&&E(r)!==S)throw new Error(l("vm.workspace.paneChanged"));return y.setInteractive(S)}},M=await Se(f,p.current,r,a);if(v(null),M.status==="held-elsewhere"){N(l("vm.workspace.alreadyControlled"));return}if(!z.current){await $(y,r).catch(()=>{});return}v(r)}catch{v(p.current),N(l("vm.workspace.switchFailed"))}finally{k.current=!1,V(!1)}}},[E,y]),F=i.useCallback(async(r,t)=>{if(k.current)return;const a=B.current[r];a!==t&&(a&&p.current===a&&!await g()||x(f=>Re(f,r,t)))},[g]),L=i.useCallback(async()=>{p.current&&!await g()||u()},[g,u]),P=i.useCallback(async r=>{p.current&&!await g()||n(r)},[g,n]);return c.jsxs("main",{className:"flex h-full min-w-0 flex-1 flex-col bg-app",children:[c.jsxs("header",{...m,className:"flex min-h-[60px] items-center gap-3 border-b border-hairline/40 px-5 py-3",children:[c.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-accent/15 text-accent",children:c.jsx(le,{size:18})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("h1",{className:"truncate text-[14px] font-semibold text-ink",children:l("vm.workspace.viewTitle")}),c.jsx("p",{className:"truncate text-[12px] text-ink-secondary",children:l("vm.workspace.viewSubtitle")})]}),c.jsx("button",{type:"button",onClick:()=>{L()},disabled:_,className:"rounded-md p-1.5 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":l("vm.workspace.closeView"),children:c.jsx(we,{size:18})})]}),C&&c.jsxs("div",{className:"mx-3 mt-3 flex items-center gap-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:[c.jsx(ie,{size:14,className:"shrink-0"})," ",C]}),c.jsx("div",{className:"grid min-h-0 flex-1 grid-cols-2 gap-3 p-3",children:[0,1].map(r=>{const t=h[r],a=w.find(f=>f.id===t)??null;return c.jsx(_e,{index:r,bot:a,bots:w,otherBotId:h[r===0?1:0],obscured:j,active:!!(a&&A===a.id),heldElsewhere:!!(a&&o.computerControl[a.id]?.held&&A!==a.id),controlPending:_,onSelect:f=>{F(r,f)},onTake:f=>{R(f)},onRelease:()=>{g()},onOpenComputer:f=>{P(f)}},D[r])})})]})}export{$e as LocalVmWorkspace};
@@ -1 +1 @@
1
- import{c as v,t as a,r as u,j as t}from"./styles-ezcN4hc0.js";import{d as k,L}from"./PlacesRail-BesUMTCh.js";import{bl as C,bm as j,Y as N,bn as M,bo as S}from"./App-BtFoKXkb.js";const E=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],T=v("shield",E);async function I(e,r,s,i=6e4){const o=Date.now()+i;let c=e;for(;!c.ready&&c.container==="running"&&Date.now()<o;)s.throwIfAborted(),await new Promise((p,d)=>{const m=()=>{window.clearTimeout(l),d(s.reason)},l=window.setTimeout(()=>{s.removeEventListener("abort",m),p()},2e3);s.addEventListener("abort",m,{once:!0})}),c=await r();return s.throwIfAborted(),c}function g(e){if(!e)return e??null;const s={"Create the Local VM":"computer.problem.createVm","The Local VM is stopped; start it to continue":"computer.problem.vmStopped","The Local VM started, but Cua Driver is not ready yet":"computer.problem.cuaNotReady","The existing Local VM uses an older desktop or Cua Driver; recreate it":"computer.problem.oldImage","The existing container was not created by Limix Bot; recreate it":"computer.problem.unmanaged","The existing Local VM exposes its viewer publicly; recreate it":"computer.problem.publicViewer","The existing Local VM is missing safety limits; recreate it":"computer.problem.missingLimits","The existing Local VM is missing its durable folder; recreate it":"computer.problem.missingDurableFolder","Replace the private desktop to apply the working folder access change":"computer.problem.workingFolderChanged","Per-bot Local VMs require Docker or Podman because Apple container requires a fixed host port":"computer.problem.perBotRuntime","Install a supported container runtime first":"computer.problem.noRuntime"}[e];if(s)return a(s);const i=/^Start (\S+) first$/.exec(e);if(i)return a("computer.problem.startRuntime",{runtime:i[1]});const o=/^The Local VM desktop failed to start: (.+)$/.exec(e);return o?a("computer.problem.desktopFailed",{detail:o[1]}):e}class V extends Error{constructor(r,s,i){super(r),this.key=r,this.problem=s,this.fallbackKey=i}key;problem;fallbackKey}function K(e){if(e instanceof V)return a(e.key,e.fallbackKey?{problem:g(e.problem)??a(e.fallbackKey)}:void 0);const r=e instanceof Error?e.message:e;return typeof r=="string"&&/^\s*(?:HTTP\s*)?\d{3}\s*$/iu.test(r)?a("computer.err.screenUnavailable"):g(r)}let f=!1;const b=new Set,R=e=>(b.add(e),()=>{b.delete(e)}),w=()=>f;function P(){f=!0;for(const e of b)e()}async function D(e=r=>window.ogb?.permOpenSettings?.(r)){await e("accessibility"),!f&&await e("screen")}function B(){const{capabilities:e}=k(),r=u.useSyncExternalStore(R,w,w),s=e.localComputer.available?null:e.localComputer.message,i=C(j(s)),[o,c]=u.useState(!1),[p,d]=u.useState(!1),[m,l]=u.useState(null),h=async()=>{c(!0),l(null);try{await window.ogb?.localControl?.retry()}catch(n){l(n instanceof Error?n.message:String(n))}finally{c(!1)}},y=async()=>{l(null),d(!0);try{await D()}catch(n){d(!1),l(n instanceof Error?n.message:String(n))}};return u.useEffect(()=>{if(!p||r)return;let n=!1;const x=()=>{n||document.visibilityState==="visible"&&(n=!0,d(!1),h())};return window.addEventListener("focus",x),document.addEventListener("visibilitychange",x),()=>{window.removeEventListener("focus",x),document.removeEventListener("visibilitychange",x)}},[p,r]),e.host.platform!=="darwin"||e.localComputer.reasonCode==="remote-server"||e.localComputer.available||r?null:t.jsx("section",{className:"mt-4 rounded-xl border border-warning/25 bg-warning/10 p-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(T,{size:16,className:"mt-0.5 shrink-0 text-warning"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[14px] font-medium text-ink",children:a("computer.mac.allowTitle")}),t.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:i??a("computer.mac.permission.generic")}),s&&t.jsxs("details",{className:"mt-2 text-[12px] text-ink-secondary",children:[t.jsx("summary",{className:"cursor-pointer",children:a("computer.mac.permission.driverDetail")}),t.jsx("p",{className:"mt-1 break-words",children:s})]}),m&&t.jsxs("div",{className:"mt-2 flex gap-1.5 text-[12px] text-danger",children:[t.jsx(N,{size:13,className:"mt-0.5 shrink-0"}),t.jsx("span",{children:m})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[i&&s&&t.jsx(M,{reason:s}),!i&&t.jsx("button",{type:"button",onClick:()=>{y()},disabled:o,className:"inline-flex items-center gap-1.5 rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:a("computer.mac.openSystemSettings")}),t.jsxs("button",{type:"button",onClick:()=>{h()},disabled:o,className:"inline-flex items-center gap-1.5 rounded-lg border border-hairline/50 px-3 py-1.5 text-[13px] font-medium text-ink hover:bg-raised disabled:opacity-50",children:[o&&t.jsx(L,{size:13,className:"animate-spin"}),a("commandAllowlist.retry")]}),!o&&t.jsx(S,{onClick:P})]})]})]})})}export{V as L,B as M,g as l,K as p,I as w};
1
+ import{c as v,t as a,r as u,j as t}from"./styles-ezcN4hc0.js";import{d as k,L}from"./PlacesRail-BesUMTCh.js";import{bl as C,bm as j,Y as N,bn as M,bo as S}from"./App-C8J3XlgX.js";const E=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],T=v("shield",E);async function I(e,r,s,i=6e4){const o=Date.now()+i;let c=e;for(;!c.ready&&c.container==="running"&&Date.now()<o;)s.throwIfAborted(),await new Promise((p,d)=>{const m=()=>{window.clearTimeout(l),d(s.reason)},l=window.setTimeout(()=>{s.removeEventListener("abort",m),p()},2e3);s.addEventListener("abort",m,{once:!0})}),c=await r();return s.throwIfAborted(),c}function g(e){if(!e)return e??null;const s={"Create the Local VM":"computer.problem.createVm","The Local VM is stopped; start it to continue":"computer.problem.vmStopped","The Local VM started, but Cua Driver is not ready yet":"computer.problem.cuaNotReady","The existing Local VM uses an older desktop or Cua Driver; recreate it":"computer.problem.oldImage","The existing container was not created by Limix Bot; recreate it":"computer.problem.unmanaged","The existing Local VM exposes its viewer publicly; recreate it":"computer.problem.publicViewer","The existing Local VM is missing safety limits; recreate it":"computer.problem.missingLimits","The existing Local VM is missing its durable folder; recreate it":"computer.problem.missingDurableFolder","Replace the private desktop to apply the working folder access change":"computer.problem.workingFolderChanged","Per-bot Local VMs require Docker or Podman because Apple container requires a fixed host port":"computer.problem.perBotRuntime","Install a supported container runtime first":"computer.problem.noRuntime"}[e];if(s)return a(s);const i=/^Start (\S+) first$/.exec(e);if(i)return a("computer.problem.startRuntime",{runtime:i[1]});const o=/^The Local VM desktop failed to start: (.+)$/.exec(e);return o?a("computer.problem.desktopFailed",{detail:o[1]}):e}class V extends Error{constructor(r,s,i){super(r),this.key=r,this.problem=s,this.fallbackKey=i}key;problem;fallbackKey}function K(e){if(e instanceof V)return a(e.key,e.fallbackKey?{problem:g(e.problem)??a(e.fallbackKey)}:void 0);const r=e instanceof Error?e.message:e;return typeof r=="string"&&/^\s*(?:HTTP\s*)?\d{3}\s*$/iu.test(r)?a("computer.err.screenUnavailable"):g(r)}let f=!1;const b=new Set,R=e=>(b.add(e),()=>{b.delete(e)}),w=()=>f;function P(){f=!0;for(const e of b)e()}async function D(e=r=>window.ogb?.permOpenSettings?.(r)){await e("accessibility"),!f&&await e("screen")}function B(){const{capabilities:e}=k(),r=u.useSyncExternalStore(R,w,w),s=e.localComputer.available?null:e.localComputer.message,i=C(j(s)),[o,c]=u.useState(!1),[p,d]=u.useState(!1),[m,l]=u.useState(null),h=async()=>{c(!0),l(null);try{await window.ogb?.localControl?.retry()}catch(n){l(n instanceof Error?n.message:String(n))}finally{c(!1)}},y=async()=>{l(null),d(!0);try{await D()}catch(n){d(!1),l(n instanceof Error?n.message:String(n))}};return u.useEffect(()=>{if(!p||r)return;let n=!1;const x=()=>{n||document.visibilityState==="visible"&&(n=!0,d(!1),h())};return window.addEventListener("focus",x),document.addEventListener("visibilitychange",x),()=>{window.removeEventListener("focus",x),document.removeEventListener("visibilitychange",x)}},[p,r]),e.host.platform!=="darwin"||e.localComputer.reasonCode==="remote-server"||e.localComputer.available||r?null:t.jsx("section",{className:"mt-4 rounded-xl border border-warning/25 bg-warning/10 p-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(T,{size:16,className:"mt-0.5 shrink-0 text-warning"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[14px] font-medium text-ink",children:a("computer.mac.allowTitle")}),t.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:i??a("computer.mac.permission.generic")}),s&&t.jsxs("details",{className:"mt-2 text-[12px] text-ink-secondary",children:[t.jsx("summary",{className:"cursor-pointer",children:a("computer.mac.permission.driverDetail")}),t.jsx("p",{className:"mt-1 break-words",children:s})]}),m&&t.jsxs("div",{className:"mt-2 flex gap-1.5 text-[12px] text-danger",children:[t.jsx(N,{size:13,className:"mt-0.5 shrink-0"}),t.jsx("span",{children:m})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[i&&s&&t.jsx(M,{reason:s}),!i&&t.jsx("button",{type:"button",onClick:()=>{y()},disabled:o,className:"inline-flex items-center gap-1.5 rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:a("computer.mac.openSystemSettings")}),t.jsxs("button",{type:"button",onClick:()=>{h()},disabled:o,className:"inline-flex items-center gap-1.5 rounded-lg border border-hairline/50 px-3 py-1.5 text-[13px] font-medium text-ink hover:bg-raised disabled:opacity-50",children:[o&&t.jsx(L,{size:13,className:"animate-spin"}),a("commandAllowlist.retry")]}),!o&&t.jsx(S,{onClick:P})]})]})]})})}export{V as L,B as M,g as l,K as p,I as w};
@@ -1 +1 @@
1
- import{r as i,j as e,t}from"./styles-ezcN4hc0.js";import{F as v,H as k,J as N,K as j,M as y,N as C,R as E,O as S}from"./App-BtFoKXkb.js";import{L as z}from"./PlacesRail-BesUMTCh.js";import"./index-DLhL-159.js";import"./monitor-DwKv3TJO.js";import"./MenuMotion-Dr44d4Sg.js";const A=2*1024*1024;function D({path:r,name:n,message:d}){const[x,u]=i.useState(0),[p,h]=i.useState(null),[c,m]=i.useState(null),[l,w]=i.useState(!1),a=v(r,n,d);i.useEffect(()=>{const o=new AbortController;return m(null),h(null),(async()=>{let f=!1;try{const s=await k(r,d,o.signal);f=!0;const g=await N(s,o.signal,A,"windows-1252");o.signal.aborted||h(g)}catch(s){if(o.signal.aborted)return;!f&&s instanceof Error&&!(s instanceof TypeError)?m({reason:s.message}):m(s instanceof Error&&s.message==="size"?"size":"load")}})(),()=>o.abort()},[r,d.threadId,d.messageId,x]);const b=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-3 flex flex-wrap justify-center gap-2",children:[e.jsxs("button",{type:"button",className:"inline-flex max-w-full min-w-0 items-center gap-1.5 rounded-lg border border-hairline px-3 py-2 hover:bg-raised",disabled:a.state==="saving",onClick:()=>{a.save()},children:[e.jsx(j,{size:14,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 break-all",children:t("attach.saveAria",{name:n})})]}),e.jsx("button",{type:"button",className:"rounded-lg border border-hairline px-3 py-2 hover:bg-raised",onClick:()=>u(x+1),children:t("chat.retry")})]}),a.state==="failed"&&e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:a.reason})]});return c?e.jsxs("div",{className:"p-8 text-center text-sm",children:[e.jsx("p",{role:"alert",className:"text-ink-secondary",children:typeof c=="object"?t("markdown.refused",{reason:c.reason}):t(c==="size"?"markdown.tooLarge":"markdown.loadFailed")}),b]}):p===null?e.jsxs("div",{className:"p-12 text-center text-sm text-ink-secondary",children:[e.jsxs("span",{role:"status",className:"inline-flex items-center gap-2",children:[e.jsx(z,{size:16,className:"animate-spin"}),t("markdown.loading")]}),b]}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{type:"button",className:"table-action","aria-pressed":l,"aria-label":t(l?"markdown.rendered":"html.source"),title:t(l?"markdown.rendered":"html.source"),onClick:()=>w(!l),children:l?e.jsx(y,{size:14}):e.jsx(C,{size:14})}),e.jsx("button",{type:"button",className:"table-action","aria-label":t("html.reload"),title:t("html.reload"),onClick:()=>u(x+1),children:e.jsx(E,{size:14})}),e.jsx("button",{type:"button",className:"table-action","aria-label":t("attach.saveAria",{name:n}),title:t("attach.saveAria",{name:n}),disabled:a.state==="saving",onClick:()=>{a.save()},children:e.jsx(j,{size:14})})]}),a.state==="failed"&&e.jsx("p",{role:"alert",className:"text-end text-[12px] text-danger",children:a.reason}),e.jsx(F,{source:p,showSource:l})]})}function F({source:r,showSource:n}){return n?e.jsx("pre",{className:"h-[72dvh] overflow-auto rounded-lg border border-hairline/40 bg-inset p-3 text-[12px] leading-5 whitespace-pre-wrap break-words text-ink",children:r}):e.jsx("div",{"data-markdown-file":!0,className:"h-[72dvh] overflow-auto rounded-lg border border-hairline/40 bg-panel px-5 py-4 text-[14px] leading-6 text-ink",children:e.jsx(S,{text:r})})}export{A as MARKDOWN_PREVIEW_MAX_BYTES,F as MarkdownFileView,D as default};
1
+ import{r as i,j as e,t}from"./styles-ezcN4hc0.js";import{F as v,H as k,J as N,K as j,M as y,N as C,R as E,O as S}from"./App-C8J3XlgX.js";import{L as z}from"./PlacesRail-BesUMTCh.js";import"./index-C9y4_V8D.js";import"./monitor-DwKv3TJO.js";import"./MenuMotion-Dr44d4Sg.js";const A=2*1024*1024;function D({path:r,name:n,message:d}){const[x,u]=i.useState(0),[p,h]=i.useState(null),[c,m]=i.useState(null),[l,w]=i.useState(!1),a=v(r,n,d);i.useEffect(()=>{const o=new AbortController;return m(null),h(null),(async()=>{let f=!1;try{const s=await k(r,d,o.signal);f=!0;const g=await N(s,o.signal,A,"windows-1252");o.signal.aborted||h(g)}catch(s){if(o.signal.aborted)return;!f&&s instanceof Error&&!(s instanceof TypeError)?m({reason:s.message}):m(s instanceof Error&&s.message==="size"?"size":"load")}})(),()=>o.abort()},[r,d.threadId,d.messageId,x]);const b=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-3 flex flex-wrap justify-center gap-2",children:[e.jsxs("button",{type:"button",className:"inline-flex max-w-full min-w-0 items-center gap-1.5 rounded-lg border border-hairline px-3 py-2 hover:bg-raised",disabled:a.state==="saving",onClick:()=>{a.save()},children:[e.jsx(j,{size:14,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 break-all",children:t("attach.saveAria",{name:n})})]}),e.jsx("button",{type:"button",className:"rounded-lg border border-hairline px-3 py-2 hover:bg-raised",onClick:()=>u(x+1),children:t("chat.retry")})]}),a.state==="failed"&&e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:a.reason})]});return c?e.jsxs("div",{className:"p-8 text-center text-sm",children:[e.jsx("p",{role:"alert",className:"text-ink-secondary",children:typeof c=="object"?t("markdown.refused",{reason:c.reason}):t(c==="size"?"markdown.tooLarge":"markdown.loadFailed")}),b]}):p===null?e.jsxs("div",{className:"p-12 text-center text-sm text-ink-secondary",children:[e.jsxs("span",{role:"status",className:"inline-flex items-center gap-2",children:[e.jsx(z,{size:16,className:"animate-spin"}),t("markdown.loading")]}),b]}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{type:"button",className:"table-action","aria-pressed":l,"aria-label":t(l?"markdown.rendered":"html.source"),title:t(l?"markdown.rendered":"html.source"),onClick:()=>w(!l),children:l?e.jsx(y,{size:14}):e.jsx(C,{size:14})}),e.jsx("button",{type:"button",className:"table-action","aria-label":t("html.reload"),title:t("html.reload"),onClick:()=>u(x+1),children:e.jsx(E,{size:14})}),e.jsx("button",{type:"button",className:"table-action","aria-label":t("attach.saveAria",{name:n}),title:t("attach.saveAria",{name:n}),disabled:a.state==="saving",onClick:()=>{a.save()},children:e.jsx(j,{size:14})})]}),a.state==="failed"&&e.jsx("p",{role:"alert",className:"text-end text-[12px] text-danger",children:a.reason}),e.jsx(F,{source:p,showSource:l})]})}function F({source:r,showSource:n}){return n?e.jsx("pre",{className:"h-[72dvh] overflow-auto rounded-lg border border-hairline/40 bg-inset p-3 text-[12px] leading-5 whitespace-pre-wrap break-words text-ink",children:r}):e.jsx("div",{"data-markdown-file":!0,className:"h-[72dvh] overflow-auto rounded-lg border border-hairline/40 bg-panel px-5 py-4 text-[14px] leading-6 text-ink",children:e.jsx(S,{text:r})})}export{A as MARKDOWN_PREVIEW_MAX_BYTES,F as MarkdownFileView,D as default};
@@ -1 +1 @@
1
- import{t as s,r as l,b as Le,j as e,X as ye,d as De,a as ee,ah as we,ai as Oe,q as Me,v as Ue,aj as Fe,ak as ze,al as Ie,l as je,am as Ke,an as _e,ao as $e,ap as qe,aq as He,p as oe,G as Je}from"./styles-ezcN4hc0.js";import{j as C,E as Ve,u as S,bV as te,bW as We,a2 as y,S as R,bX as Ye,bY as ke,bZ as se,b_ as Xe,b$ as Ge,c0 as Ze,c1 as Qe,c2 as ce,c3 as de,c4 as et,c5 as tt,c6 as st,c7 as Se,w as U,c8 as nt,c9 as at,b as Ne,ca as ue,cb as it,cc as rt,cd as lt,ce as ot,cf as ct,cg as dt,ch as ut,ci as pt,cj as xt,ck as mt,cl as gt,cm as ht,cn as pe,co as ft,cp as bt,cq as vt,cr as yt,cs as Ce,bM as Q,ct as wt,cu as jt,cv as kt,cw as St,cx as Nt,cy as xe,T as Ee,cz as Ct}from"./App-BtFoKXkb.js";import{B as me,E as Et,s as Bt,r as ge,p as Rt,c as Pt,a as At}from"./new-bot-pRpz-Z7k.js";import{o as Tt}from"./index-DLhL-159.js";import{I as Lt,S as Dt,a as Ot,A as Mt,M as Ut,P as Ft,V as zt,v as It,i as he}from"./VisibilitySection-BGMvfVcC.js";import{R as Kt}from"./RoutinesPage-Bo4t8FOR.js";import{r as _t,L as W,Q as $t,R as qt,U as Ht,P as Jt}from"./PlacesRail-BesUMTCh.js";import{p as Vt,d as Wt,e as Yt,f as Xt}from"./team-share-C8QPbhlx.js";import{B as Gt}from"./BrowserProfilesManager-BXUJZPvf.js";function Zt(t){const n=[];for(const a of t){const i=a.source==="org"?s("newBot.presetsFromOrganization",{name:a.publisherName??a.packageName}):s("newBot.presetsImported"),r=n.find(d=>d.label===i);r?r.presets.push(a):n.push({label:i,presets:[a]})}return n}function Qt(t){const n={name:t.bot.name??t.name,title:t.bot.title??"",description:t.bot.description??"",soul:t.bot.soul??""},a=t.bot.appearance;return a&&(n.color=a.color,n.mascotExpression=a.mascotExpression??null,a.mascotBody&&(n.mascotBody=a.mascotBody)),n}function es(t){const n=t.bot.appearance?.avatar;if(!n)return null;let a;try{a=atob(n.data)}catch{return null}const i=new Uint8Array(a.length);for(let r=0;r<a.length;r+=1)i[r]=a.charCodeAt(r);return new File([i],`preset.${n.mime.slice(6)}`,{type:n.mime})}function ts(t){const n=[t.source==="org"&&t.publisherName?s("newBot.presetFromOrg",{package:t.packageName,release:t.release,publisher:t.publisherName}):s("newBot.presetFrom",{package:t.packageName,release:t.release})];t.description&&n.push(t.description);const a=t.skills.map(i=>i.name).join(", ");return a&&n.push(s(t.skillsEnabled?"newBot.presetSkillsOn":"newBot.presetSkillsOff",{names:a})),t.notes.length&&n.push(s("newBot.presetNotes",{names:t.notes.join(", ")})),t.playbooks.length&&n.push(s("newBot.presetPlaybooks",{names:t.playbooks.join(", ")})),n.push(s("newBot.presetKeeps")),n}function ss(t){return{id:t.id,skills:t.skills.map(n=>n.name),notes:[...t.notes]}}function fe(t){const n=a=>a?.trim()?a.trim():void 0;return{format:"package",version:2,kind:"library",name:n(t.name),presetName:n(t.name),presetDescription:n(t.description),release:n(t.release),notes:n(t.notes),includeMemory:t.includeNotes,...t.picture?{presetAvatar:t.picture}:{},...t.dryRun?{dryRun:!0}:{}}}function be({preview:t,localSkips:n}){const a=t.document.package.presets?.[0],i=Object.keys(a?.seed?.memory??{}).length,r=[[s("teamShare.part.skills"),a?.skills?.length?`${a.skills.length} · ${a.skills.join(", ")}`:"0"],[s("teamShare.part.notes"),i?String(i):s("teamShare.none")],[s("teamShare.part.pictures"),a?.bot.appearance?.avatar?s("teamShare.yes"):s("teamShare.none")]],d=[...n,...t.skipped.map(c=>Wt(c,t.document))];return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:s("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:r.map(([c,p])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-ink-secondary",children:c}),e.jsx("dd",{className:"max-w-[300px] truncate text-right text-ink",title:p,children:p})]},c))}),e.jsxs("p",{className:"mt-3 flex items-start gap-2 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx(Ve,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("span",{children:s("presetShare.never")})]}),t.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:s("teamShare.redacted")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:t.redacted.map(c=>e.jsx("li",{children:Yt(c,t.document)},c))})]}),d.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:s("teamShare.skipped")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:d.map((c,p)=>e.jsx("li",{children:c},`${c}-${p}`))})]})]})}function ns({onClose:t}){const n=l.useRef(null),[a,i]=l.useState(""),[r,d]=l.useState(""),[c,p]=l.useState(""),[o,h]=l.useState(""),[v,D]=l.useState(!0),[w,m]=l.useState(!0),[g,P]=l.useState(null),[b,A]=l.useState(null),[f,T]=l.useState(!1),[O,Y]=l.useState(null),[I,F]=l.useState(""),_=l.useRef(0);l.useEffect(()=>{let u=!1;return C("/api/bot-defaults").then(async({defaults:E})=>{!u&&E.profile.name?.trim()&&i(L=>L||E.profile.name.trim());const N=await Vt([{id:"defaults",avatarUrl:E.profile.avatarUrl,avatarCrop:E.profile.avatarCrop}]);u||P({dataUrl:N.avatars.defaults,skipped:N.skipped.map(L=>`${s("teamShare.field.picture")} — ${Le(`teamShare.skip.${L.reason}`,L.reason)}`)})}).catch(()=>{u||P({skipped:[]})}),()=>{u=!0}},[]);const $=u=>({name:a,description:r,release:c,notes:o,includeNotes:v,dryRun:u,...w&&g?.dataUrl?{picture:g.dataUrl}:{}});l.useEffect(()=>{if(!g)return;const u=++_.current,E=window.setTimeout(()=>{C("/api/teams/export",{method:"POST",body:JSON.stringify(fe({...$(!0),release:void 0}))}).then(N=>{u===_.current&&(A(N),F(""),p(L=>L||N.document.package.release))}).catch(N=>{u===_.current&&(A(null),F(N instanceof Error?N.message:String(N)))})},250);return()=>window.clearTimeout(E)},[g,v,w]);const X=async()=>{if(!f){T(!0),F("");try{const u=await C("/api/teams/export",{method:"POST",body:JSON.stringify(fe($(!1)))});Xt(u.filename,u.document),Y(u)}catch(u){F(u instanceof Error?u.message:String(u))}finally{T(!1)}}};l.useEffect(()=>{const u=document.activeElement instanceof HTMLElement?document.activeElement:null;return n.current?.focus(),()=>{u?.isConnected&&u.focus()}},[]);const z=w?g?.skipped??[]:[],K="mt-1 w-full rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[14px] text-ink disabled:opacity-60";return _t.createPortal(e.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/55 p-4",onMouseDown:u=>u.stopPropagation(),children:e.jsxs("div",{ref:n,role:"dialog","aria-modal":"true","aria-labelledby":"share-preset-title",tabIndex:-1,className:"flex max-h-[90vh] w-full max-w-[560px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel text-ink shadow-2xl outline-none",onKeyDown:u=>{if(u.key==="Escape"&&!f&&(u.stopPropagation(),t()),u.key==="Tab"){const E=n.current?.querySelectorAll("input:enabled, textarea:enabled, button:enabled");if(!E?.length)return;const N=E[0],L=E[E.length-1];u.shiftKey&&document.activeElement===N?(u.preventDefault(),L.focus()):!u.shiftKey&&document.activeElement===L&&(u.preventDefault(),N.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-preset-title",className:"text-[17px] font-semibold",children:s("presetShare.title")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("presetShare.intro")})]}),e.jsx("button",{"aria-label":s("presetShare.close"),disabled:f,onClick:t,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised",children:e.jsx(ye,{size:18})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:O?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"flex items-center gap-2 text-[14px] font-medium text-ink",children:[e.jsx(De,{size:16,className:"text-success"}),s("teamShare.saved",{filename:O.filename})]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("presetShare.savedHint")}),e.jsx("div",{className:"mt-4",children:e.jsx(be,{preview:O,localSkips:z})})]}):e.jsxs(e.Fragment,{children:[b?e.jsx(be,{preview:b,localSkips:z}):!I&&e.jsxs("div",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(W,{size:15,className:"animate-spin"}),s("presetShare.preparing")]}),e.jsxs("fieldset",{className:"mt-4 space-y-2 text-[13px]",disabled:f,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:w,onChange:u=>m(u.target.checked)}),s("presetShare.includePicture")]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:v,onChange:u=>D(u.target.checked)}),s("presetShare.includeNotes")]})]}),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:[s("presetShare.name"),e.jsx("input",{value:a,maxLength:100,disabled:f,onChange:u=>i(u.target.value),className:K})]}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("teamShare.release"),e.jsx("input",{value:c,maxLength:20,disabled:f,placeholder:"1.0.0",onChange:u=>p(u.target.value),className:K})]})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[s("presetShare.description"),e.jsx("input",{value:r,maxLength:300,disabled:f,onChange:u=>d(u.target.value),className:K})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[s("teamShare.notes"),e.jsx("textarea",{value:o,maxLength:4e3,rows:2,disabled:f,onChange:u=>h(u.target.value),className:K})]})]})}),I&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:I}),e.jsx("footer",{className:"flex justify-end gap-2 border-t border-hairline/35 px-6 py-3",children:O?e.jsx("button",{onClick:t,className:"rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white",children:s("teamShare.done")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:f,onClick:t,className:"rounded-lg px-3 py-2 text-[13px] text-ink-secondary hover:bg-raised",children:s("common.cancel")}),e.jsxs("button",{disabled:f||!b,onClick:()=>{X()},className:"flex items-center gap-2 rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white disabled:opacity-40",children:[f&&e.jsx(W,{size:14,className:"animate-spin"}),f?s("teamShare.saving"):s("teamShare.save")]})]})})]})}),document.body)}function ne(){const{dispatch:t}=S(),[n,a]=l.useState(!1),[i,r]=l.useState("");return{saving:n,error:i,save:async c=>{if(!n){a(!0),r("");try{const p=await C("/api/config",{method:"PATCH",body:JSON.stringify(c)});t({type:"configStatus",config:p})}catch(p){r(p instanceof Error?p.message:s("settings.experimental.error"))}finally{a(!1)}}}}}function Rs(){const{state:t}=S(),n=te(t.config),a=We(t.config),i=t.config?.browserEngine?.installable===!0,r=window.ogb?.platform==="win32"&&!a&&!i,{saving:d,error:c,save:p}=ne();return e.jsx(y,{title:s("settings.experimental.browserAria"),subtitle:a?n?s("settings.experimental.browserOn"):s("settings.experimental.browserOff"):r?s("settings.experimental.browserWindows"):Ye(t.config),message:c?e.jsx("p",{role:"alert",className:"text-danger",children:c}):null,children:e.jsx(R,{checked:n,"aria-label":s("settings.experimental.browserAria"),disabled:d||!n&&!a&&!i,onClick:()=>{p({features:{browser:!n}})},className:"disabled:cursor-wait disabled:opacity-50"})})}function Ps(){const{state:t}=S(),n=ke(),a=t.config?.browserEngine?.serverSites,{saving:i,error:r,save:d}=ne();return a===void 0||n!==!0||!te(t.config)?null:e.jsx(y,{title:s("settings.browser.serverSites"),subtitle:s("settings.browser.serverSitesDetail"),message:r?e.jsx("p",{role:"alert",className:"text-danger",children:r}):null,children:e.jsx(R,{checked:a,"aria-label":s("settings.browser.serverSites"),disabled:i,onClick:()=>{d({browserEngine:{egress:{localNetwork:!a}}})},className:"disabled:cursor-wait disabled:opacity-50"})})}function as(){const{state:t}=S(),n=t.config?.browserEngine?.engine==="chrome",{saving:a,error:i,save:r}=ne();return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"new-browser-settings",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.newBrowser")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s("settings.experimental.newBrowserDetail")})]}),e.jsx(R,{checked:n,"aria-label":s("settings.experimental.newBrowserAria"),disabled:a,onClick:()=>{r({browserEngine:{engine:n?"agent-browser":"chrome"}})},className:"disabled:cursor-wait disabled:opacity-50"})]}),i?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:i}):null]})}function is(){const{state:t,dispatch:n}=S(),a=se(t.config),i=Xe(t.config),r=Ge(t.config),d=Ze(t.config),c=Qe(t.bots,t.instances),[p,o]=l.useState(String(d)),[h,v]=l.useState(!1),[D,w]=l.useState(!1),[m,g]=l.useState(""),P=l.useRef(!1);l.useEffect(()=>{h||o(String(d))},[d,h]);const b=async f=>{if(P.current)return!1;P.current=!0,w(!0),g("");try{const T=await C("/api/config",{method:"PATCH",body:JSON.stringify({features:f})});return n({type:"configStatus",config:T}),!0}catch(T){return g(T instanceof Error?T.message:s("settings.experimental.error")),!1}finally{P.current=!1,w(!1)}},A=async()=>{if(!h)return;const f=et(p);if(f===null){g(s("settings.experimental.skillReviewStepsRange",{min:de,max:ce}));return}await b({skillReviewSteps:f})&&v(!1)};return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"skill-review-settings",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.skillReview")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s(a?"settings.experimental.skillReviewDetail":"settings.experimental.skillReviewNeedsAuthoring")})]}),e.jsx(R,{checked:i,"aria-label":s("settings.experimental.skillReviewAria"),disabled:D||!a,onClick:()=>{b({skillReview:!i})},className:"disabled:cursor-not-allowed disabled:opacity-50"})]}),e.jsx(rs,{engines:c}),i?e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13px] text-ink",children:s("settings.experimental.skillAutoApply")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s("settings.experimental.skillAutoApplyDetail")})]}),e.jsx(R,{checked:r,"aria-label":s("settings.experimental.skillAutoApplyAria"),disabled:D,onClick:()=>{b({skillAutoApply:!r})},className:"disabled:cursor-not-allowed disabled:opacity-50"})]}):null,i?e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsx("label",{htmlFor:"skill-review-steps",className:"text-[13px] text-ink",children:s("settings.experimental.skillReviewSteps")}),e.jsx("div",{className:`flex w-[96px] items-center rounded-lg border bg-inset ${m?"border-danger/60":"border-hairline/40 focus-within:border-focus"}`,children:e.jsx("input",{id:"skill-review-steps",type:"number",min:de,max:ce,step:1,inputMode:"numeric",value:p,disabled:D,"aria-invalid":!!m,onChange:f=>{o(f.target.value),v(!0),g("")},onBlur:()=>{A()},onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur()},className:"min-w-0 flex-1 bg-transparent px-3 py-1.5 text-[14px] tabular-nums text-ink focus:outline-none"})})]}):null,m?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:m}):null]})}function rs({engines:t}){return t.length?e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary","data-testid":"skill-review-engine-note",children:s("settings.experimental.skillReviewNoEngine",{engines:t.join(", ")})}):null}const ls=[{value:"off",label:"settings.experimental.shareSkillsOff"},{value:"ask",label:"settings.experimental.shareSkillsAsk"},{value:"auto",label:"settings.experimental.shareSkillsAuto"}];function os(){const{state:t,dispatch:n}=S(),[a,i]=l.useState(!1),[r,d]=l.useState("");if(!tt(t.config))return null;const c=se(t.config),p=st(t.config),o=async h=>{if(!(a||h===p)){i(!0),d("");try{const v=await C("/api/config",{method:"PATCH",body:JSON.stringify({features:{shareLearnedSkills:h}})});n({type:"configStatus",config:v})}catch(v){d(v instanceof Error?v.message:s("settings.experimental.error"))}finally{i(!1)}}};return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"share-learned-skills-settings",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.shareSkills")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s(c?"settings.experimental.shareSkillsDetail":"settings.experimental.shareSkillsNeedsAuthoring")})]}),e.jsx("div",{className:"inline-flex shrink-0 rounded-xl bg-inset p-1",role:"radiogroup","aria-label":s("settings.experimental.shareSkillsAria"),children:ls.map(h=>e.jsx("button",{type:"button",role:"radio","aria-checked":p===h.value,disabled:a||!c,onClick:()=>{o(h.value)},className:ee("rounded-lg px-3 py-1.5 text-[13px] transition-colors disabled:cursor-not-allowed disabled:opacity-50",p===h.value?"bg-raised text-ink shadow":"text-ink-secondary hover:text-ink"),children:s(h.label)},h.value))})]}),r?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:r}):null]})}function cs(){return e.jsxs(e.Fragment,{children:[e.jsx(is,{}),e.jsx(os,{})]})}function As({title:t=s("settings.updates.title")}){const n=ht(),a=window.ogb?.updater;if(!n||!a)return null;const i=n.status==="checking"?s("settings.updates.checking"):n.status==="downloading"?n.percent==null?s("settings.updates.startingDownload"):s("settings.updates.downloading",{percent:Math.round(n.percent)}):n.status==="preparing"?s("settings.updates.preparing"):n.status==="downloaded"?n.installMode==="handoff"?s("settings.updates.readyInstall",{app:oe(),version:n.version??""}):s("settings.updates.ready",{app:oe(),version:n.version??""}):n.status==="installing"?pe(n)||(n.installMode==="handoff"?s("settings.updates.openingTerminal"):s("settings.updates.restarting")):n.status==="handed-off"?s("settings.updates.handedOff"):n.status==="error"?s("settings.updates.failed",{message:pe(n)??s("settings.updates.unknownError")}):s("settings.updates.latest");return e.jsx(y,{title:t,subtitle:i,children:e.jsx("button",{onClick:()=>{if(n.status==="downloaded")return void a.install();a.check()},disabled:n.status==="checking"||n.status==="downloading"||n.status==="preparing"||n.status==="installing"||n.retryable===!1,className:"ui-button",children:n.retryable===!1?s("settings.updates.quitReopen"):n.status==="downloaded"?n.installMode==="handoff"?s("settings.updates.install"):s("settings.updates.restart"):n.status==="preparing"?s("settings.updates.preparingShort"):n.status==="installing"?n.installMode==="handoff"?s("settings.updates.opening"):s("settings.updates.restartingShort"):s("settings.updates.check")})})}function Be(){const{state:t,dispatch:n}=S(),a=t.config?.newBots?.effort??"",[i,r]=l.useState(!1),[d,c]=l.useState("");return{current:a,saving:i,error:d,save:async o=>{if(!i){r(!0),c("");try{const h=await C("/api/config",{method:"PATCH",body:JSON.stringify({newBots:{effort:yt(o)?o:null}})});n({type:"configStatus",config:h})}catch(h){c(h instanceof Error?h.message:s("settings.newBotEffort.error"))}finally{r(!1)}}}}}function Re({effort:t,className:n}){return e.jsxs(U,{size:"sm",className:n,value:t.current,disabled:t.saving,"aria-label":s("settings.newBotEffort.aria"),onChange:a=>{t.save(a.target.value)},children:[e.jsx("option",{value:"",children:s("settings.newBotEffort.default")}),ft.map(a=>e.jsx("option",{value:a,children:bt(a)},a))]})}function Ts(){const t=Be();return e.jsx(y,{title:s("settings.newBotEffort.title"),subtitle:s("settings.newBotEffort.subtitle"),message:t.error?e.jsx("p",{role:"alert",className:"text-danger",children:t.error}):null,children:e.jsx(Re,{effort:t,className:"w-full max-w-[240px]"})})}function ds({onEdit:t,onShare:n}){const a=Be();return e.jsx(y,{title:s("newBot.defaults"),subtitle:s("settings.newBotEffort.title"),message:a.error?e.jsx("p",{role:"alert",className:"text-danger",children:a.error}):null,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{effort:a,className:"w-auto"}),e.jsx("button",{type:"button",className:"ui-button","data-new-bot-share":!0,onClick:n,children:s("newBot.sharePreset")}),e.jsx("button",{type:"button",className:"ui-button","data-new-bot-defaults":!0,onClick:t,children:s("newBot.edit")})]})})}function us(){const{state:t,dispatch:n}=S(),[a,i]=l.useState(!1),[r,d]=l.useState(!1);return e.jsxs("div",{children:[e.jsx("button",{disabled:a,onClick:()=>{i(!0),d(!1),C("/api/config",{method:"PUT",body:JSON.stringify({onboarding:{...t.config?.onboarding?.completedAt?{}:$t().onboarding,hintsSeen:vt(t.config?.onboarding)}}),signal:AbortSignal.timeout(1e4)}).then(c=>{n({type:"configStatus",config:c}),n({type:"toggleTour",open:!0})}).catch(()=>d(!0)).finally(()=>i(!1))},className:"ui-button",children:s("settings.welcome.appTour")}),r&&e.jsx("p",{role:"alert",className:"mt-2 text-[13px] text-danger",children:s("onboarding.tour.error")})]})}function Ls(){const{dispatch:t}=S();return e.jsx(y,{title:s("settings.welcome.title"),subtitle:s("settings.welcome.subtitleShort"),children:e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(us,{}),e.jsx("button",{onClick:()=>t({type:"toggleWelcome",open:!0}),className:"ui-button",children:s("settings.welcome.replay")})]})})}function Ds({simple:t=!1}){const{state:n}=S(),a=Me(Ue(),n.config?.language);return e.jsx(y,{title:s("settings.language.title"),subtitle:Ie()?s("settings.language.subtitleComplete"):t?je()==="en"?void 0:s("settings.simple.language.partial"):s("settings.language.subtitle"),children:e.jsxs(U,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:a,"aria-label":s("settings.language.aria"),onChange:i=>ze(i.target.value),children:[e.jsx("option",{value:"",children:s(t?"settings.simple.language.system":"settings.language.system")}),Fe.map(({code:i,label:r})=>e.jsx("option",{value:i,children:r},i))]})})}function Os({simple:t=!1}){const n=Ne();return e.jsx(y,{title:s("settings.sendKey.title"),subtitle:s(t?"settings.simple.sendKey":"settings.sendKey.subtitle",{key:ue("mod-enter")}),children:e.jsx(U,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:n,"aria-label":s("settings.sendKey.title"),onChange:a=>it(rt(a.target.value)),children:Ke.map(a=>e.jsx("option",{value:a,children:ue(a)},a))})})}function Ms({simple:t=!1}){const n=lt(),a=ot(Ne());return e.jsx(y,{title:s("settings.followUp.title"),subtitle:s(t?"settings.simple.followUp":"settings.followUp.subtitle",{key:a}),children:e.jsxs(U,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:n,"aria-label":s("settings.followUp.title"),onChange:i=>ct(dt(i.target.value)),children:[e.jsx("option",{value:"steer",children:s("settings.followUp.steer")}),e.jsx("option",{value:"queue",children:s("settings.followUp.queue")})]})})}function Us({simple:t=!1}){const n=nt();return e.jsx(y,{title:s(t?"settings.userBubbles.simpleTitle":"settings.userBubbles.title"),subtitle:t?void 0:s("settings.userBubbles.subtitle"),children:e.jsx(R,{checked:n,"aria-label":s("settings.userBubbles.aria"),onClick:()=>at(!n)})})}function Fs({simple:t=!1}){const n=we();return e.jsx(y,{className:t?void 0:"rounded-2xl border border-accent-border/40 bg-raised-hover/40 py-4",title:s("settings.advancedMode.title"),subtitle:s(t?"settings.simple.advancedMode":"settings.advancedMode.subtitle"),children:e.jsx(R,{checked:n,"aria-label":s("settings.advancedMode.title"),onClick:()=>Oe(!n)})})}function zs(){const t=_e();return e.jsx(y,{title:s("settings.threadDisplay.title"),subtitle:s("settings.threadDisplay.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.threadDisplay.show"),onClick:()=>$e(!t)})})}function Is(){const t=ut();return e.jsx(y,{title:s("settings.pinnedCircles.title"),subtitle:s("settings.pinnedCircles.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.pinnedCircles.title"),onClick:()=>pt(!t)})})}function Ks(){const t=qe();return e.jsx(y,{title:s("settings.runCard.title"),subtitle:s("settings.runCard.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.runCard.show"),onClick:()=>He(!t)})})}function _s(){const t=xt();return e.jsx(y,{title:s("settings.universalPins.title"),subtitle:s("settings.universalPins.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.universalPins.title"),onClick:()=>mt(!t)})})}function $s(){const{state:t,dispatch:n}=S(),a=gt(t.config),[i,r]=l.useState(!1),[d,c]=l.useState(""),p=async()=>{if(!i){r(!0),c("");try{const o=await C("/api/config",{method:"PATCH",body:JSON.stringify({features:{showToolCalls:!a}})});n({type:"configStatus",config:o})}catch(o){c(o instanceof Error?o.message:s("settings.toolCalls.error"))}finally{r(!1)}}};return e.jsx(y,{title:s("settings.toolCalls.title"),subtitle:e.jsxs(e.Fragment,{children:[s("settings.toolCalls.subtitle")," ",s("settings.toolCalls.detail")]}),message:d?e.jsx("p",{role:"alert",className:"text-danger",children:d}):null,children:e.jsx(R,{checked:a,"aria-label":s("settings.toolCalls.aria"),disabled:i,onClick:()=>{p()},className:"disabled:cursor-wait disabled:opacity-50"})})}function qs(){const{state:t,dispatch:n}=S(),a=se(t.config),[i,r]=l.useState(!1),[d,c]=l.useState(""),p=async o=>{if(!i){r(!0),c("");try{const h=await C("/api/config",{method:"PATCH",body:JSON.stringify({features:{skillAuthoring:o}})});n({type:"configStatus",config:h})}catch(h){c(h instanceof Error?h.message:s("settings.experimental.error"))}finally{r(!1)}}};return e.jsxs(Se,{title:s("settings.experimental.title"),subtitle:s("settings.experimental.subtitle"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.skillAuthoring")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s("settings.experimental.skillAuthoringDetail")})]}),e.jsx(R,{checked:a,"aria-label":s("settings.experimental.skillAuthoringAria"),disabled:i,onClick:()=>{p(!a)},className:"disabled:cursor-wait disabled:opacity-50"})]}),d?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:d}):null,e.jsx(cs,{}),e.jsx(as,{})]})}function Hs(){const{state:t}=S(),n=t.config?.browserProfiles??[];return!te(t.config)&&n.length===0?null:e.jsx(Se,{title:s("settings.profiles.title"),subtitle:s("settings.profiles.sharedSubtitle"),children:e.jsx(Gt,{})})}const ve=["Identity","Soul","Skills","Memory","Routines","Access","Model","Permissions","Voice & alerts"],ps={Identity:"botSettings.sections.identity",Soul:"botSettings.sections.soul",Skills:"botSettings.sections.skills",Memory:"botSettings.sections.memory",Routines:"botSettings.sections.routines",Access:"botSettings.sections.access",Model:"botSettings.sections.model",Permissions:"botSettings.sections.permissions","Voice & alerts":"botSettings.sections.voice"};function Pe(t){return e.jsx(qt,{modal:!0,children:e.jsx(xs,{...t})})}function xs({defaultsMode:t=!1,onClose:n,onCreated:a,readyBotId:i,readyBotData:r}){const d=Ht(),c=S(),[,p]=l.useState(0),[o,h]=l.useState(()=>new me(Et,()=>p(x=>x+1))),[v,D]=l.useState("Identity"),[w,m]=l.useState(!1),[g,P]=l.useState(!1),b=g||c.state.botCreationPending,A=l.useRef(!1),f=l.useRef(!0),[T,O]=l.useState(""),[Y,I]=l.useState(null),[F,_]=l.useState("everyone"),[$,X]=l.useState(""),z=Ce(),K=c.state.config?.team?.name,[u,E]=l.useState(null),N=ke(),L=Je(),Ae=we()?ve:ve.filter(x=>x!=="Model"),ae=!t&&typeof window<"u"&&!window.ogb&&N===!0,H=l.useRef(null),q=l.useRef(n);q.current=n,l.useEffect(()=>{let x=!1;return C("/api/bot-defaults").then(B=>{if(x)return;const j=Bt(B,!t),k=t?void 0:r??(i?Q(i):void 0),M=new me(k?wt(j,k,je()):j,()=>p(V=>V+1));k&&Q(k.id)&&(M.role=k.id),h(M),m(!0)}).catch(B=>{x||O(String(B))}),()=>{x=!0}},[t,i,r]),l.useEffect(()=>(f.current=!0,()=>{f.current=!1}),[]),l.useEffect(()=>()=>o.dispose(),[o]),l.useEffect(()=>{b&&H.current?.focus()},[b]),l.useEffect(()=>{const x=document.activeElement instanceof HTMLElement?document.activeElement:null;H.current?.focus();const B=j=>{if(!d())return;const k=H.current;if(!k||j.target instanceof Node&&!k.contains(j.target))return;const M=k.querySelector('[role="dialog"], [role="alertdialog"]');if(M&&M.getClientRects().length||(j.key==="Escape"&&(j.preventDefault(),q.current()),j.key!=="Tab"))return;const V=[...k.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex="0"]')].filter(le=>le.getClientRects().length&&!le.closest("[hidden],fieldset:disabled")),G=V[0],Z=V.at(-1);if(!G||!Z){j.preventDefault(),k.focus();return}j.shiftKey&&(document.activeElement===G||document.activeElement===k)?(j.preventDefault(),Z.focus()):!j.shiftKey&&(document.activeElement===Z||document.activeElement===k)&&(j.preventDefault(),G.focus())};return window.addEventListener("keydown",B),()=>{window.removeEventListener("keydown",B),x?.isConnected&&x.focus()}},[d]);const ie=async()=>{if(!w||A.current||c.state.botCreationPending)return;if(!t&&o.bot.approvalMode==="auto"&&o.bot.computer==="local"&&!o.consent.acknowledgeLocalAuto){I("local");return}const x=ae?It(F,$):null;if(x&&!x.ok){O(s("botSettings.visibility.needPeople"));return}A.current=!0,P(!0),O(""),c.dispatch({type:"botCreationPending",on:!0});try{if(t)await C("/api/config",{method:"PATCH",body:JSON.stringify({newBotDefaults:await Rt(o)})});else{const{bot:B,warnings:j,paused:k}=await Pt(o,void 0,void 0,void 0,x?.ok?x.visibility:void 0,z?ge(u,o.bot.section,c.state.bots,z)??void 0:void 0);At(c.dispatch,B,j,{showThreads:L,source:o.preset?"preset":o.role?"template":"blank",role:o.role,paused:k});try{await a?.(B)}catch(M){c.dispatch({type:"error",message:M instanceof Error?M.message:String(M)})}}A.current=!1,f.current&&q.current()}catch(B){f.current&&O(B instanceof Error?B.message:String(B))}finally{A.current=!1,c.dispatch({type:"botCreationPending",on:!1}),f.current&&P(!1)}},J=o.bot,Te={...c,state:{...c.state,bots:[J,...c.state.bots],routines:o.routines,routineRuns:[],routinesLoadState:"ready"},flushBotPatches:async()=>J,dispatch:x=>{x.type==="updateBot"&&x.botId===o.id?o.patch(x.patch):x.type==="setModel"&&x.botId===o.id?(o.setModel(x.selection),x.resetApprovalToAsk&&o.patch({approvalMode:"ask"})):x.type==="routinePatched"||x.type==="toggleSettings"||c.dispatch(x)}},re=t?s("newBot.defaults"):s("sidebar.newBot");return e.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/60 p-3 sm:p-5",hidden:!t&&c.state.appSettingsOpen,children:e.jsxs("div",{ref:H,role:"dialog","aria-modal":"true","aria-label":re,"aria-busy":b,tabIndex:-1,className:"flex h-[min(760px,94dvh)] w-full max-w-[900px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel shadow-2xl outline-none",children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-hairline/40 px-5 py-4",children:[e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:re}),e.jsx("button",{type:"button",onClick:()=>q.current(),"aria-label":s("common.close"),className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-40",children:e.jsx(ye,{size:18,className:"pointer-events-none"})})]}),z&&!t&&K&&e.jsx(ms,{team:K}),ae&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 pt-3 text-[13px] text-ink-secondary","data-new-bot-visibility":!0,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[s("botSettings.visibility.title"),e.jsxs(U,{size:"sm",value:F,disabled:b,onChange:x=>_(x.target.value),children:[e.jsx("option",{value:"everyone",children:s("botSettings.visibility.everyone")}),e.jsx("option",{value:"admins",children:s("botSettings.visibility.admins")}),e.jsx("option",{value:"people",children:s("botSettings.visibility.people")})]})]}),F==="people"&&e.jsx("input",{value:$,disabled:b,onChange:x=>X(x.target.value),placeholder:s("botSettings.visibility.peoplePlaceholder"),"aria-label":s("botSettings.visibility.peopleLabel"),className:"min-w-[16rem] flex-1 rounded-lg border border-hairline/40 bg-inset px-3 py-1.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col sm:flex-row",children:[e.jsx("nav",{"aria-label":s("newBot.sections"),className:"flex shrink-0 gap-1 overflow-x-auto border-b border-hairline/40 p-2 sm:w-40 sm:flex-col sm:border-b-0 sm:border-r",children:Ae.map(x=>e.jsx("button",{type:"button",onClick:()=>D(x),"aria-current":v===x?"page":void 0,className:ee("shrink-0 rounded-lg px-3 py-2 text-left text-[13px]",v===x?"bg-control text-ink":"text-ink-secondary hover:bg-control/50"),children:s(ps[x])},x))}),e.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto p-4 sm:p-5",children:[!w&&!T&&e.jsxs("div",{role:"status",className:"flex items-center gap-2 text-[13px] text-ink-secondary",children:[e.jsx(W,{size:16,className:"animate-spin"}),s("newBot.loading")]}),w&&e.jsx("fieldset",{disabled:b,className:"min-w-0",children:e.jsx(jt,{value:Te,children:e.jsx(kt.Provider,{value:{request:o.request,draft:!0,uploadAvatar:o.uploadAvatar},children:e.jsx(gs,{active:v,draft:o,defaultsMode:t,owner:z&&!t?{value:ge(u,J.section,c.state.bots,z),choose:E}:void 0})})})})]})]}),T&&e.jsx("p",{role:"alert",className:"max-h-24 overflow-y-auto border-t border-hairline/40 px-5 py-3 text-[13px] text-danger",children:T}),e.jsxs("div",{className:"flex shrink-0 justify-end gap-2 border-t border-hairline/40 px-5 py-3",children:[e.jsx("button",{type:"button",onClick:()=>q.current(),className:"rounded-lg px-4 py-2 text-[13px] text-ink-secondary hover:bg-control",children:s("common.cancel")}),e.jsxs("button",{type:"button",disabled:!w||b||!t&&!J.name.trim(),onClick:()=>{ie()},className:"ui-button-primary flex items-center gap-2 rounded-lg bg-accent px-5 py-2 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-40",children:[b&&e.jsx(W,{size:15,className:"animate-spin"}),s(t?"newBot.saveDefaults":"newBot.create")]})]}),e.jsx(St,{open:Y==="local",onCancel:()=>I(null),onConfirm:()=>{o.consent.acknowledgeLocalAuto=!0,I(null),ie()}})]})})}function ms({team:t}){const n=typeof window>"u"?void 0:window.ogb?.workspaces;return e.jsxs("div",{"data-new-bot-shared":!0,className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-b border-hairline/40 bg-raised/30 px-5 py-2.5 text-[13px] text-ink-secondary",children:[e.jsx("span",{children:s("newBot.sharedWith",{team:t})}),n?e.jsx("button",{type:"button",onClick:()=>{Tt(n).catch(()=>{})},className:"font-medium text-accent hover:underline",children:s("newBot.justForYou")}):e.jsx("span",{children:s("newBot.justForYou").replace(/\s*→$/,"")})]})}function gs({active:t,draft:n,defaultsMode:a,owner:i}){const r=n.bot,{state:d}=S(),c=Ce(),p=Nt(r);return t==="Identity"?e.jsxs("div",{className:"space-y-4",children:[e.jsx(hs,{draft:n,defaultsMode:a}),e.jsx(Lt,{bot:r,patch:p.patch,activeState:p.activeState,mascotMotion:null,namePlaceholder:a?s("newBot.randomName"):void 0}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("newBot.team"),e.jsxs(U,{size:"lg",className:"mt-1.5 w-full",value:r.section??"",onChange:o=>n.patch({section:o.target.value}),children:[e.jsx("option",{value:"",children:s("teamSettings.general")}),[...new Set([...d.sections??[],...d.bots.map(o=>o.section??"")])].filter(Boolean).map(o=>e.jsx("option",{children:o},o))]})]}),i&&c&&e.jsxs("label",{className:"block text-[13px] text-ink-secondary","data-new-bot-reports-to":!0,children:[s("lookedAfter.newBot"),e.jsx(U,{size:"lg",className:"mt-1.5 w-full",value:i.value??"",onChange:o=>i.choose(o.target.value),children:c.people.map(o=>e.jsx("option",{value:o.email,children:o.you?s("owner.you",{name:o.name}):o.name},o.email))}),e.jsx("span",{className:"mt-1 block text-[12px]",children:s("lookedAfter.pickHint")})]})]}):t==="Soul"?e.jsx(Dt,{bot:r,patch:p.patch}):t==="Skills"?e.jsx(Ot,{bot:r}):t==="Memory"?e.jsx(fs,{draft:n}):t==="Routines"?e.jsx(bs,{draft:n}):t==="Access"?e.jsx(Mt,{bot:r,derived:p}):t==="Model"?e.jsx(Ut,{bot:r}):t==="Permissions"?e.jsx(Ft,{bot:r,derived:p}):e.jsx(zt,{bot:r,derived:p})}function hs({draft:t,defaultsMode:n}){const[a,i]=l.useState([]),[r,d]=l.useState(0),[c,p]=l.useState(""),o=l.useRef(!1);l.useEffect(()=>{if(n)return;let m=!1;return C("/api/bot-presets").then(g=>{m||i(g.presets)}).catch(()=>{m||i([])}),()=>{m=!0}},[n,r]);const h=t.preset?a.find(m=>m.id===t.preset.id):void 0,v=async m=>{p("");const g=m.startsWith("preset:")?a.find(b=>b.id===m.slice(7)):void 0;if(!g){t.choosePreset(void 0);const b=xe.find(f=>f.id===m);t.chooseRole(b?.id);const A=b&&Q(b.id)?.look;b&&t.patch({...Ct(b),...A});return}t.patch(Qt(g)),t.choosePreset(ss(g));const P=es(g);try{P?(t.patch({avatarUrl:await t.uploadAvatar(P),avatarCrop:g.bot.appearance.avatar.crop}),o.current=!0):o.current&&(t.patch({avatarUrl:""}),o.current=!1)}catch(b){p(b instanceof Error?b.message:String(b))}},D=async m=>{p("");try{await C(`/api/bot-presets/${encodeURIComponent(m.id)}`,{method:"DELETE"}),t.preset?.id===m.id&&t.choosePreset(void 0),d(g=>g+1)}catch(g){p(g instanceof Error?g.message:String(g))}},w=xe.map(m=>e.jsx("option",{value:m.id,children:m.title},m.id));return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("newBot.startingRole"),e.jsxs(U,{size:"lg",className:"mt-1.5 w-full",value:t.preset?`preset:${t.preset.id}`:"",onChange:m=>{v(m.target.value)},children:[e.jsx("option",{value:"",children:s("newBot.customSettings")}),Zt(a).map(m=>e.jsx("optgroup",{label:m.label,children:m.presets.map(g=>e.jsx("option",{value:`preset:${g.id}`,children:g.name},g.id))},m.label)),a.length?e.jsx("optgroup",{label:s("newBot.builtInRoles"),children:w}):w]})]}),h&&e.jsxs("div",{className:"mt-2 space-y-1 rounded-lg bg-card px-3 py-2.5 text-[13px] text-ink-secondary","data-new-bot-preset":!0,children:[ts(h).map((m,g)=>e.jsx("p",{className:"break-words",children:m},g)),h.source==="file"&&e.jsx("button",{type:"button",onClick:()=>{D(h)},className:"mt-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-ink",children:s("newBot.presetRemove")})]}),c&&e.jsx("p",{role:"alert",className:"mt-2 text-[13px] text-danger",children:c})]})}function fs({draft:t}){const[n,a]=l.useState("MEMORY.md"),[i,r]=l.useState("");return e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{size:"lg",className:"w-full","aria-label":s("memory.fileLabel",{path:n}),value:n,onChange:d=>a(d.target.value),children:[...new Set(["MEMORY.md",...Object.keys(t.template.memory)])].map(d=>e.jsx("option",{children:d},d))}),e.jsx("textarea",{className:ee(he,"min-h-72 font-mono"),"aria-label":s("memory.contents"),value:t.template.memory[n]??"",onChange:d=>t.setMemory(n,d.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:he,"aria-label":s("memory.newTopicLabel"),placeholder:s("memory.newTopicLabel"),value:i,onChange:d=>r(d.target.value)}),e.jsx("button",{type:"button","aria-label":s("memory.addTopic"),disabled:!/^[a-zA-Z0-9_-]+$/.test(i),className:"rounded-lg bg-control px-3 disabled:opacity-40",onClick:()=>{const d=`memory/${i}.md`;d in t.template.memory||t.setMemory(d,""),a(d),r("")},children:e.jsx(Jt,{size:16})}),n!=="MEMORY.md"&&e.jsx("button",{type:"button","aria-label":s("memory.removeTopic"),className:"rounded-lg bg-control px-3",onClick:()=>{t.setMemory(n,null),a("MEMORY.md")},children:e.jsx(Ee,{size:16})})]})]})}function bs({draft:t}){const[n,a]=l.useState(null);return e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{type:"button",className:"rounded-lg bg-accent px-3 py-2 text-[13px] text-white",onClick:()=>a("new"),children:s("computer.routines.create")}),t.routines.map(i=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-card p-3",children:[e.jsx("button",{type:"button",className:"min-w-0 flex-1 text-left text-[13px]",onClick:()=>a(i),children:i.name}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[12px] text-ink-secondary",children:[e.jsx("input",{type:"checkbox",checked:i.enabled,onChange:r=>t.setRoutineEnabled(i.id,r.target.checked)}),s("newBot.enabled")]}),e.jsx("button",{type:"button","aria-label":s("newBot.removeRoutine",{name:i.name}),onClick:()=>t.removeRoutine(i.id),className:"rounded p-1.5 hover:bg-control",children:e.jsx(Ee,{size:15})})]},i.id)),n&&e.jsx(Kt,{routine:n==="new"?void 0:n,bots:[t.bot],lockedBotId:t.id,onClose:()=>a(null)})]})}function vs({simple:t=!1}){const[n,a]=l.useState(!1),[i,r]=l.useState(!1),d=e.jsxs(e.Fragment,{children:[n&&e.jsx(Pe,{defaultsMode:!0,onClose:()=>a(!1)}),i&&e.jsx(ns,{onClose:()=>r(!1)})]});if(t)return e.jsxs(e.Fragment,{children:[e.jsx(ds,{onEdit:()=>a(!0),onShare:()=>r(!0)}),d]});const c=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!0),className:"cursor-pointer rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-control hover:text-ink",children:s("newBot.sharePreset")}),e.jsx("button",{type:"button",onClick:()=>a(!0),className:"cursor-pointer rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover",children:s("newBot.edit")})]}),d]});return e.jsx(y,{title:s("newBot.defaults"),children:c})}const Js=Object.freeze(Object.defineProperty({__proto__:null,DefaultBotSettings:vs,NewBotDialog:Pe},Symbol.toStringTag,{value:"Module"}));export{Fs as A,Rs as B,Us as C,vs as D,qs as E,Ms as F,Ds as L,Ts as N,Is as P,Ls as R,Ps as S,$s as T,As as U,Hs as a,Os as b,zs as c,_s as d,Ks as e,Js as f};
1
+ import{t as s,r as l,b as Le,j as e,X as ye,d as De,a as ee,ah as we,ai as Oe,q as Me,v as Ue,aj as Fe,ak as ze,al as Ie,l as je,am as Ke,an as _e,ao as $e,ap as qe,aq as He,p as oe,G as Je}from"./styles-ezcN4hc0.js";import{j as C,E as Ve,u as S,bV as te,bW as We,a2 as y,S as R,bX as Ye,bY as ke,bZ as se,b_ as Xe,b$ as Ge,c0 as Ze,c1 as Qe,c2 as ce,c3 as de,c4 as et,c5 as tt,c6 as st,c7 as Se,w as U,c8 as nt,c9 as at,b as Ne,ca as ue,cb as it,cc as rt,cd as lt,ce as ot,cf as ct,cg as dt,ch as ut,ci as pt,cj as xt,ck as mt,cl as gt,cm as ht,cn as pe,co as ft,cp as bt,cq as vt,cr as yt,cs as Ce,bM as Q,ct as wt,cu as jt,cv as kt,cw as St,cx as Nt,cy as xe,T as Ee,cz as Ct}from"./App-C8J3XlgX.js";import{B as me,E as Et,s as Bt,r as ge,p as Rt,c as Pt,a as At}from"./new-bot-BM05ocFQ.js";import{o as Tt}from"./index-C9y4_V8D.js";import{I as Lt,S as Dt,a as Ot,A as Mt,M as Ut,P as Ft,V as zt,v as It,i as he}from"./VisibilitySection-c3v2Urid.js";import{R as Kt}from"./RoutinesPage-B2YvkjVI.js";import{r as _t,L as W,Q as $t,R as qt,U as Ht,P as Jt}from"./PlacesRail-BesUMTCh.js";import{p as Vt,d as Wt,e as Yt,f as Xt}from"./team-share-C8QPbhlx.js";import{B as Gt}from"./BrowserProfilesManager-D8QTMXbY.js";function Zt(t){const n=[];for(const a of t){const i=a.source==="org"?s("newBot.presetsFromOrganization",{name:a.publisherName??a.packageName}):s("newBot.presetsImported"),r=n.find(d=>d.label===i);r?r.presets.push(a):n.push({label:i,presets:[a]})}return n}function Qt(t){const n={name:t.bot.name??t.name,title:t.bot.title??"",description:t.bot.description??"",soul:t.bot.soul??""},a=t.bot.appearance;return a&&(n.color=a.color,n.mascotExpression=a.mascotExpression??null,a.mascotBody&&(n.mascotBody=a.mascotBody)),n}function es(t){const n=t.bot.appearance?.avatar;if(!n)return null;let a;try{a=atob(n.data)}catch{return null}const i=new Uint8Array(a.length);for(let r=0;r<a.length;r+=1)i[r]=a.charCodeAt(r);return new File([i],`preset.${n.mime.slice(6)}`,{type:n.mime})}function ts(t){const n=[t.source==="org"&&t.publisherName?s("newBot.presetFromOrg",{package:t.packageName,release:t.release,publisher:t.publisherName}):s("newBot.presetFrom",{package:t.packageName,release:t.release})];t.description&&n.push(t.description);const a=t.skills.map(i=>i.name).join(", ");return a&&n.push(s(t.skillsEnabled?"newBot.presetSkillsOn":"newBot.presetSkillsOff",{names:a})),t.notes.length&&n.push(s("newBot.presetNotes",{names:t.notes.join(", ")})),t.playbooks.length&&n.push(s("newBot.presetPlaybooks",{names:t.playbooks.join(", ")})),n.push(s("newBot.presetKeeps")),n}function ss(t){return{id:t.id,skills:t.skills.map(n=>n.name),notes:[...t.notes]}}function fe(t){const n=a=>a?.trim()?a.trim():void 0;return{format:"package",version:2,kind:"library",name:n(t.name),presetName:n(t.name),presetDescription:n(t.description),release:n(t.release),notes:n(t.notes),includeMemory:t.includeNotes,...t.picture?{presetAvatar:t.picture}:{},...t.dryRun?{dryRun:!0}:{}}}function be({preview:t,localSkips:n}){const a=t.document.package.presets?.[0],i=Object.keys(a?.seed?.memory??{}).length,r=[[s("teamShare.part.skills"),a?.skills?.length?`${a.skills.length} · ${a.skills.join(", ")}`:"0"],[s("teamShare.part.notes"),i?String(i):s("teamShare.none")],[s("teamShare.part.pictures"),a?.bot.appearance?.avatar?s("teamShare.yes"):s("teamShare.none")]],d=[...n,...t.skipped.map(c=>Wt(c,t.document))];return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:s("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:r.map(([c,p])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-ink-secondary",children:c}),e.jsx("dd",{className:"max-w-[300px] truncate text-right text-ink",title:p,children:p})]},c))}),e.jsxs("p",{className:"mt-3 flex items-start gap-2 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx(Ve,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("span",{children:s("presetShare.never")})]}),t.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:s("teamShare.redacted")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:t.redacted.map(c=>e.jsx("li",{children:Yt(c,t.document)},c))})]}),d.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:s("teamShare.skipped")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:d.map((c,p)=>e.jsx("li",{children:c},`${c}-${p}`))})]})]})}function ns({onClose:t}){const n=l.useRef(null),[a,i]=l.useState(""),[r,d]=l.useState(""),[c,p]=l.useState(""),[o,h]=l.useState(""),[v,D]=l.useState(!0),[w,m]=l.useState(!0),[g,P]=l.useState(null),[b,A]=l.useState(null),[f,T]=l.useState(!1),[O,Y]=l.useState(null),[I,F]=l.useState(""),_=l.useRef(0);l.useEffect(()=>{let u=!1;return C("/api/bot-defaults").then(async({defaults:E})=>{!u&&E.profile.name?.trim()&&i(L=>L||E.profile.name.trim());const N=await Vt([{id:"defaults",avatarUrl:E.profile.avatarUrl,avatarCrop:E.profile.avatarCrop}]);u||P({dataUrl:N.avatars.defaults,skipped:N.skipped.map(L=>`${s("teamShare.field.picture")} — ${Le(`teamShare.skip.${L.reason}`,L.reason)}`)})}).catch(()=>{u||P({skipped:[]})}),()=>{u=!0}},[]);const $=u=>({name:a,description:r,release:c,notes:o,includeNotes:v,dryRun:u,...w&&g?.dataUrl?{picture:g.dataUrl}:{}});l.useEffect(()=>{if(!g)return;const u=++_.current,E=window.setTimeout(()=>{C("/api/teams/export",{method:"POST",body:JSON.stringify(fe({...$(!0),release:void 0}))}).then(N=>{u===_.current&&(A(N),F(""),p(L=>L||N.document.package.release))}).catch(N=>{u===_.current&&(A(null),F(N instanceof Error?N.message:String(N)))})},250);return()=>window.clearTimeout(E)},[g,v,w]);const X=async()=>{if(!f){T(!0),F("");try{const u=await C("/api/teams/export",{method:"POST",body:JSON.stringify(fe($(!1)))});Xt(u.filename,u.document),Y(u)}catch(u){F(u instanceof Error?u.message:String(u))}finally{T(!1)}}};l.useEffect(()=>{const u=document.activeElement instanceof HTMLElement?document.activeElement:null;return n.current?.focus(),()=>{u?.isConnected&&u.focus()}},[]);const z=w?g?.skipped??[]:[],K="mt-1 w-full rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[14px] text-ink disabled:opacity-60";return _t.createPortal(e.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/55 p-4",onMouseDown:u=>u.stopPropagation(),children:e.jsxs("div",{ref:n,role:"dialog","aria-modal":"true","aria-labelledby":"share-preset-title",tabIndex:-1,className:"flex max-h-[90vh] w-full max-w-[560px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel text-ink shadow-2xl outline-none",onKeyDown:u=>{if(u.key==="Escape"&&!f&&(u.stopPropagation(),t()),u.key==="Tab"){const E=n.current?.querySelectorAll("input:enabled, textarea:enabled, button:enabled");if(!E?.length)return;const N=E[0],L=E[E.length-1];u.shiftKey&&document.activeElement===N?(u.preventDefault(),L.focus()):!u.shiftKey&&document.activeElement===L&&(u.preventDefault(),N.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-preset-title",className:"text-[17px] font-semibold",children:s("presetShare.title")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("presetShare.intro")})]}),e.jsx("button",{"aria-label":s("presetShare.close"),disabled:f,onClick:t,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised",children:e.jsx(ye,{size:18})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:O?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"flex items-center gap-2 text-[14px] font-medium text-ink",children:[e.jsx(De,{size:16,className:"text-success"}),s("teamShare.saved",{filename:O.filename})]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("presetShare.savedHint")}),e.jsx("div",{className:"mt-4",children:e.jsx(be,{preview:O,localSkips:z})})]}):e.jsxs(e.Fragment,{children:[b?e.jsx(be,{preview:b,localSkips:z}):!I&&e.jsxs("div",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(W,{size:15,className:"animate-spin"}),s("presetShare.preparing")]}),e.jsxs("fieldset",{className:"mt-4 space-y-2 text-[13px]",disabled:f,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:w,onChange:u=>m(u.target.checked)}),s("presetShare.includePicture")]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:v,onChange:u=>D(u.target.checked)}),s("presetShare.includeNotes")]})]}),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:[s("presetShare.name"),e.jsx("input",{value:a,maxLength:100,disabled:f,onChange:u=>i(u.target.value),className:K})]}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("teamShare.release"),e.jsx("input",{value:c,maxLength:20,disabled:f,placeholder:"1.0.0",onChange:u=>p(u.target.value),className:K})]})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[s("presetShare.description"),e.jsx("input",{value:r,maxLength:300,disabled:f,onChange:u=>d(u.target.value),className:K})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[s("teamShare.notes"),e.jsx("textarea",{value:o,maxLength:4e3,rows:2,disabled:f,onChange:u=>h(u.target.value),className:K})]})]})}),I&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:I}),e.jsx("footer",{className:"flex justify-end gap-2 border-t border-hairline/35 px-6 py-3",children:O?e.jsx("button",{onClick:t,className:"rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white",children:s("teamShare.done")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:f,onClick:t,className:"rounded-lg px-3 py-2 text-[13px] text-ink-secondary hover:bg-raised",children:s("common.cancel")}),e.jsxs("button",{disabled:f||!b,onClick:()=>{X()},className:"flex items-center gap-2 rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white disabled:opacity-40",children:[f&&e.jsx(W,{size:14,className:"animate-spin"}),f?s("teamShare.saving"):s("teamShare.save")]})]})})]})}),document.body)}function ne(){const{dispatch:t}=S(),[n,a]=l.useState(!1),[i,r]=l.useState("");return{saving:n,error:i,save:async c=>{if(!n){a(!0),r("");try{const p=await C("/api/config",{method:"PATCH",body:JSON.stringify(c)});t({type:"configStatus",config:p})}catch(p){r(p instanceof Error?p.message:s("settings.experimental.error"))}finally{a(!1)}}}}}function Rs(){const{state:t}=S(),n=te(t.config),a=We(t.config),i=t.config?.browserEngine?.installable===!0,r=window.ogb?.platform==="win32"&&!a&&!i,{saving:d,error:c,save:p}=ne();return e.jsx(y,{title:s("settings.experimental.browserAria"),subtitle:a?n?s("settings.experimental.browserOn"):s("settings.experimental.browserOff"):r?s("settings.experimental.browserWindows"):Ye(t.config),message:c?e.jsx("p",{role:"alert",className:"text-danger",children:c}):null,children:e.jsx(R,{checked:n,"aria-label":s("settings.experimental.browserAria"),disabled:d||!n&&!a&&!i,onClick:()=>{p({features:{browser:!n}})},className:"disabled:cursor-wait disabled:opacity-50"})})}function Ps(){const{state:t}=S(),n=ke(),a=t.config?.browserEngine?.serverSites,{saving:i,error:r,save:d}=ne();return a===void 0||n!==!0||!te(t.config)?null:e.jsx(y,{title:s("settings.browser.serverSites"),subtitle:s("settings.browser.serverSitesDetail"),message:r?e.jsx("p",{role:"alert",className:"text-danger",children:r}):null,children:e.jsx(R,{checked:a,"aria-label":s("settings.browser.serverSites"),disabled:i,onClick:()=>{d({browserEngine:{egress:{localNetwork:!a}}})},className:"disabled:cursor-wait disabled:opacity-50"})})}function as(){const{state:t}=S(),n=t.config?.browserEngine?.engine==="chrome",{saving:a,error:i,save:r}=ne();return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"new-browser-settings",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.newBrowser")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s("settings.experimental.newBrowserDetail")})]}),e.jsx(R,{checked:n,"aria-label":s("settings.experimental.newBrowserAria"),disabled:a,onClick:()=>{r({browserEngine:{engine:n?"agent-browser":"chrome"}})},className:"disabled:cursor-wait disabled:opacity-50"})]}),i?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:i}):null]})}function is(){const{state:t,dispatch:n}=S(),a=se(t.config),i=Xe(t.config),r=Ge(t.config),d=Ze(t.config),c=Qe(t.bots,t.instances),[p,o]=l.useState(String(d)),[h,v]=l.useState(!1),[D,w]=l.useState(!1),[m,g]=l.useState(""),P=l.useRef(!1);l.useEffect(()=>{h||o(String(d))},[d,h]);const b=async f=>{if(P.current)return!1;P.current=!0,w(!0),g("");try{const T=await C("/api/config",{method:"PATCH",body:JSON.stringify({features:f})});return n({type:"configStatus",config:T}),!0}catch(T){return g(T instanceof Error?T.message:s("settings.experimental.error")),!1}finally{P.current=!1,w(!1)}},A=async()=>{if(!h)return;const f=et(p);if(f===null){g(s("settings.experimental.skillReviewStepsRange",{min:de,max:ce}));return}await b({skillReviewSteps:f})&&v(!1)};return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"skill-review-settings",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.skillReview")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s(a?"settings.experimental.skillReviewDetail":"settings.experimental.skillReviewNeedsAuthoring")})]}),e.jsx(R,{checked:i,"aria-label":s("settings.experimental.skillReviewAria"),disabled:D||!a,onClick:()=>{b({skillReview:!i})},className:"disabled:cursor-not-allowed disabled:opacity-50"})]}),e.jsx(rs,{engines:c}),i?e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13px] text-ink",children:s("settings.experimental.skillAutoApply")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s("settings.experimental.skillAutoApplyDetail")})]}),e.jsx(R,{checked:r,"aria-label":s("settings.experimental.skillAutoApplyAria"),disabled:D,onClick:()=>{b({skillAutoApply:!r})},className:"disabled:cursor-not-allowed disabled:opacity-50"})]}):null,i?e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsx("label",{htmlFor:"skill-review-steps",className:"text-[13px] text-ink",children:s("settings.experimental.skillReviewSteps")}),e.jsx("div",{className:`flex w-[96px] items-center rounded-lg border bg-inset ${m?"border-danger/60":"border-hairline/40 focus-within:border-focus"}`,children:e.jsx("input",{id:"skill-review-steps",type:"number",min:de,max:ce,step:1,inputMode:"numeric",value:p,disabled:D,"aria-invalid":!!m,onChange:f=>{o(f.target.value),v(!0),g("")},onBlur:()=>{A()},onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur()},className:"min-w-0 flex-1 bg-transparent px-3 py-1.5 text-[14px] tabular-nums text-ink focus:outline-none"})})]}):null,m?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:m}):null]})}function rs({engines:t}){return t.length?e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary","data-testid":"skill-review-engine-note",children:s("settings.experimental.skillReviewNoEngine",{engines:t.join(", ")})}):null}const ls=[{value:"off",label:"settings.experimental.shareSkillsOff"},{value:"ask",label:"settings.experimental.shareSkillsAsk"},{value:"auto",label:"settings.experimental.shareSkillsAuto"}];function os(){const{state:t,dispatch:n}=S(),[a,i]=l.useState(!1),[r,d]=l.useState("");if(!tt(t.config))return null;const c=se(t.config),p=st(t.config),o=async h=>{if(!(a||h===p)){i(!0),d("");try{const v=await C("/api/config",{method:"PATCH",body:JSON.stringify({features:{shareLearnedSkills:h}})});n({type:"configStatus",config:v})}catch(v){d(v instanceof Error?v.message:s("settings.experimental.error"))}finally{i(!1)}}};return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"share-learned-skills-settings",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.shareSkills")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s(c?"settings.experimental.shareSkillsDetail":"settings.experimental.shareSkillsNeedsAuthoring")})]}),e.jsx("div",{className:"inline-flex shrink-0 rounded-xl bg-inset p-1",role:"radiogroup","aria-label":s("settings.experimental.shareSkillsAria"),children:ls.map(h=>e.jsx("button",{type:"button",role:"radio","aria-checked":p===h.value,disabled:a||!c,onClick:()=>{o(h.value)},className:ee("rounded-lg px-3 py-1.5 text-[13px] transition-colors disabled:cursor-not-allowed disabled:opacity-50",p===h.value?"bg-raised text-ink shadow":"text-ink-secondary hover:text-ink"),children:s(h.label)},h.value))})]}),r?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:r}):null]})}function cs(){return e.jsxs(e.Fragment,{children:[e.jsx(is,{}),e.jsx(os,{})]})}function As({title:t=s("settings.updates.title")}){const n=ht(),a=window.ogb?.updater;if(!n||!a)return null;const i=n.status==="checking"?s("settings.updates.checking"):n.status==="downloading"?n.percent==null?s("settings.updates.startingDownload"):s("settings.updates.downloading",{percent:Math.round(n.percent)}):n.status==="preparing"?s("settings.updates.preparing"):n.status==="downloaded"?n.installMode==="handoff"?s("settings.updates.readyInstall",{app:oe(),version:n.version??""}):s("settings.updates.ready",{app:oe(),version:n.version??""}):n.status==="installing"?pe(n)||(n.installMode==="handoff"?s("settings.updates.openingTerminal"):s("settings.updates.restarting")):n.status==="handed-off"?s("settings.updates.handedOff"):n.status==="error"?s("settings.updates.failed",{message:pe(n)??s("settings.updates.unknownError")}):s("settings.updates.latest");return e.jsx(y,{title:t,subtitle:i,children:e.jsx("button",{onClick:()=>{if(n.status==="downloaded")return void a.install();a.check()},disabled:n.status==="checking"||n.status==="downloading"||n.status==="preparing"||n.status==="installing"||n.retryable===!1,className:"ui-button",children:n.retryable===!1?s("settings.updates.quitReopen"):n.status==="downloaded"?n.installMode==="handoff"?s("settings.updates.install"):s("settings.updates.restart"):n.status==="preparing"?s("settings.updates.preparingShort"):n.status==="installing"?n.installMode==="handoff"?s("settings.updates.opening"):s("settings.updates.restartingShort"):s("settings.updates.check")})})}function Be(){const{state:t,dispatch:n}=S(),a=t.config?.newBots?.effort??"",[i,r]=l.useState(!1),[d,c]=l.useState("");return{current:a,saving:i,error:d,save:async o=>{if(!i){r(!0),c("");try{const h=await C("/api/config",{method:"PATCH",body:JSON.stringify({newBots:{effort:yt(o)?o:null}})});n({type:"configStatus",config:h})}catch(h){c(h instanceof Error?h.message:s("settings.newBotEffort.error"))}finally{r(!1)}}}}}function Re({effort:t,className:n}){return e.jsxs(U,{size:"sm",className:n,value:t.current,disabled:t.saving,"aria-label":s("settings.newBotEffort.aria"),onChange:a=>{t.save(a.target.value)},children:[e.jsx("option",{value:"",children:s("settings.newBotEffort.default")}),ft.map(a=>e.jsx("option",{value:a,children:bt(a)},a))]})}function Ts(){const t=Be();return e.jsx(y,{title:s("settings.newBotEffort.title"),subtitle:s("settings.newBotEffort.subtitle"),message:t.error?e.jsx("p",{role:"alert",className:"text-danger",children:t.error}):null,children:e.jsx(Re,{effort:t,className:"w-full max-w-[240px]"})})}function ds({onEdit:t,onShare:n}){const a=Be();return e.jsx(y,{title:s("newBot.defaults"),subtitle:s("settings.newBotEffort.title"),message:a.error?e.jsx("p",{role:"alert",className:"text-danger",children:a.error}):null,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{effort:a,className:"w-auto"}),e.jsx("button",{type:"button",className:"ui-button","data-new-bot-share":!0,onClick:n,children:s("newBot.sharePreset")}),e.jsx("button",{type:"button",className:"ui-button","data-new-bot-defaults":!0,onClick:t,children:s("newBot.edit")})]})})}function us(){const{state:t,dispatch:n}=S(),[a,i]=l.useState(!1),[r,d]=l.useState(!1);return e.jsxs("div",{children:[e.jsx("button",{disabled:a,onClick:()=>{i(!0),d(!1),C("/api/config",{method:"PUT",body:JSON.stringify({onboarding:{...t.config?.onboarding?.completedAt?{}:$t().onboarding,hintsSeen:vt(t.config?.onboarding)}}),signal:AbortSignal.timeout(1e4)}).then(c=>{n({type:"configStatus",config:c}),n({type:"toggleTour",open:!0})}).catch(()=>d(!0)).finally(()=>i(!1))},className:"ui-button",children:s("settings.welcome.appTour")}),r&&e.jsx("p",{role:"alert",className:"mt-2 text-[13px] text-danger",children:s("onboarding.tour.error")})]})}function Ls(){const{dispatch:t}=S();return e.jsx(y,{title:s("settings.welcome.title"),subtitle:s("settings.welcome.subtitleShort"),children:e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(us,{}),e.jsx("button",{onClick:()=>t({type:"toggleWelcome",open:!0}),className:"ui-button",children:s("settings.welcome.replay")})]})})}function Ds({simple:t=!1}){const{state:n}=S(),a=Me(Ue(),n.config?.language);return e.jsx(y,{title:s("settings.language.title"),subtitle:Ie()?s("settings.language.subtitleComplete"):t?je()==="en"?void 0:s("settings.simple.language.partial"):s("settings.language.subtitle"),children:e.jsxs(U,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:a,"aria-label":s("settings.language.aria"),onChange:i=>ze(i.target.value),children:[e.jsx("option",{value:"",children:s(t?"settings.simple.language.system":"settings.language.system")}),Fe.map(({code:i,label:r})=>e.jsx("option",{value:i,children:r},i))]})})}function Os({simple:t=!1}){const n=Ne();return e.jsx(y,{title:s("settings.sendKey.title"),subtitle:s(t?"settings.simple.sendKey":"settings.sendKey.subtitle",{key:ue("mod-enter")}),children:e.jsx(U,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:n,"aria-label":s("settings.sendKey.title"),onChange:a=>it(rt(a.target.value)),children:Ke.map(a=>e.jsx("option",{value:a,children:ue(a)},a))})})}function Ms({simple:t=!1}){const n=lt(),a=ot(Ne());return e.jsx(y,{title:s("settings.followUp.title"),subtitle:s(t?"settings.simple.followUp":"settings.followUp.subtitle",{key:a}),children:e.jsxs(U,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:n,"aria-label":s("settings.followUp.title"),onChange:i=>ct(dt(i.target.value)),children:[e.jsx("option",{value:"steer",children:s("settings.followUp.steer")}),e.jsx("option",{value:"queue",children:s("settings.followUp.queue")})]})})}function Us({simple:t=!1}){const n=nt();return e.jsx(y,{title:s(t?"settings.userBubbles.simpleTitle":"settings.userBubbles.title"),subtitle:t?void 0:s("settings.userBubbles.subtitle"),children:e.jsx(R,{checked:n,"aria-label":s("settings.userBubbles.aria"),onClick:()=>at(!n)})})}function Fs({simple:t=!1}){const n=we();return e.jsx(y,{className:t?void 0:"rounded-2xl border border-accent-border/40 bg-raised-hover/40 py-4",title:s("settings.advancedMode.title"),subtitle:s(t?"settings.simple.advancedMode":"settings.advancedMode.subtitle"),children:e.jsx(R,{checked:n,"aria-label":s("settings.advancedMode.title"),onClick:()=>Oe(!n)})})}function zs(){const t=_e();return e.jsx(y,{title:s("settings.threadDisplay.title"),subtitle:s("settings.threadDisplay.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.threadDisplay.show"),onClick:()=>$e(!t)})})}function Is(){const t=ut();return e.jsx(y,{title:s("settings.pinnedCircles.title"),subtitle:s("settings.pinnedCircles.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.pinnedCircles.title"),onClick:()=>pt(!t)})})}function Ks(){const t=qe();return e.jsx(y,{title:s("settings.runCard.title"),subtitle:s("settings.runCard.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.runCard.show"),onClick:()=>He(!t)})})}function _s(){const t=xt();return e.jsx(y,{title:s("settings.universalPins.title"),subtitle:s("settings.universalPins.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.universalPins.title"),onClick:()=>mt(!t)})})}function $s(){const{state:t,dispatch:n}=S(),a=gt(t.config),[i,r]=l.useState(!1),[d,c]=l.useState(""),p=async()=>{if(!i){r(!0),c("");try{const o=await C("/api/config",{method:"PATCH",body:JSON.stringify({features:{showToolCalls:!a}})});n({type:"configStatus",config:o})}catch(o){c(o instanceof Error?o.message:s("settings.toolCalls.error"))}finally{r(!1)}}};return e.jsx(y,{title:s("settings.toolCalls.title"),subtitle:e.jsxs(e.Fragment,{children:[s("settings.toolCalls.subtitle")," ",s("settings.toolCalls.detail")]}),message:d?e.jsx("p",{role:"alert",className:"text-danger",children:d}):null,children:e.jsx(R,{checked:a,"aria-label":s("settings.toolCalls.aria"),disabled:i,onClick:()=>{p()},className:"disabled:cursor-wait disabled:opacity-50"})})}function qs(){const{state:t,dispatch:n}=S(),a=se(t.config),[i,r]=l.useState(!1),[d,c]=l.useState(""),p=async o=>{if(!i){r(!0),c("");try{const h=await C("/api/config",{method:"PATCH",body:JSON.stringify({features:{skillAuthoring:o}})});n({type:"configStatus",config:h})}catch(h){c(h instanceof Error?h.message:s("settings.experimental.error"))}finally{r(!1)}}};return e.jsxs(Se,{title:s("settings.experimental.title"),subtitle:s("settings.experimental.subtitle"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.skillAuthoring")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s("settings.experimental.skillAuthoringDetail")})]}),e.jsx(R,{checked:a,"aria-label":s("settings.experimental.skillAuthoringAria"),disabled:i,onClick:()=>{p(!a)},className:"disabled:cursor-wait disabled:opacity-50"})]}),d?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:d}):null,e.jsx(cs,{}),e.jsx(as,{})]})}function Hs(){const{state:t}=S(),n=t.config?.browserProfiles??[];return!te(t.config)&&n.length===0?null:e.jsx(Se,{title:s("settings.profiles.title"),subtitle:s("settings.profiles.sharedSubtitle"),children:e.jsx(Gt,{})})}const ve=["Identity","Soul","Skills","Memory","Routines","Access","Model","Permissions","Voice & alerts"],ps={Identity:"botSettings.sections.identity",Soul:"botSettings.sections.soul",Skills:"botSettings.sections.skills",Memory:"botSettings.sections.memory",Routines:"botSettings.sections.routines",Access:"botSettings.sections.access",Model:"botSettings.sections.model",Permissions:"botSettings.sections.permissions","Voice & alerts":"botSettings.sections.voice"};function Pe(t){return e.jsx(qt,{modal:!0,children:e.jsx(xs,{...t})})}function xs({defaultsMode:t=!1,onClose:n,onCreated:a,readyBotId:i,readyBotData:r}){const d=Ht(),c=S(),[,p]=l.useState(0),[o,h]=l.useState(()=>new me(Et,()=>p(x=>x+1))),[v,D]=l.useState("Identity"),[w,m]=l.useState(!1),[g,P]=l.useState(!1),b=g||c.state.botCreationPending,A=l.useRef(!1),f=l.useRef(!0),[T,O]=l.useState(""),[Y,I]=l.useState(null),[F,_]=l.useState("everyone"),[$,X]=l.useState(""),z=Ce(),K=c.state.config?.team?.name,[u,E]=l.useState(null),N=ke(),L=Je(),Ae=we()?ve:ve.filter(x=>x!=="Model"),ae=!t&&typeof window<"u"&&!window.ogb&&N===!0,H=l.useRef(null),q=l.useRef(n);q.current=n,l.useEffect(()=>{let x=!1;return C("/api/bot-defaults").then(B=>{if(x)return;const j=Bt(B,!t),k=t?void 0:r??(i?Q(i):void 0),M=new me(k?wt(j,k,je()):j,()=>p(V=>V+1));k&&Q(k.id)&&(M.role=k.id),h(M),m(!0)}).catch(B=>{x||O(String(B))}),()=>{x=!0}},[t,i,r]),l.useEffect(()=>(f.current=!0,()=>{f.current=!1}),[]),l.useEffect(()=>()=>o.dispose(),[o]),l.useEffect(()=>{b&&H.current?.focus()},[b]),l.useEffect(()=>{const x=document.activeElement instanceof HTMLElement?document.activeElement:null;H.current?.focus();const B=j=>{if(!d())return;const k=H.current;if(!k||j.target instanceof Node&&!k.contains(j.target))return;const M=k.querySelector('[role="dialog"], [role="alertdialog"]');if(M&&M.getClientRects().length||(j.key==="Escape"&&(j.preventDefault(),q.current()),j.key!=="Tab"))return;const V=[...k.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex="0"]')].filter(le=>le.getClientRects().length&&!le.closest("[hidden],fieldset:disabled")),G=V[0],Z=V.at(-1);if(!G||!Z){j.preventDefault(),k.focus();return}j.shiftKey&&(document.activeElement===G||document.activeElement===k)?(j.preventDefault(),Z.focus()):!j.shiftKey&&(document.activeElement===Z||document.activeElement===k)&&(j.preventDefault(),G.focus())};return window.addEventListener("keydown",B),()=>{window.removeEventListener("keydown",B),x?.isConnected&&x.focus()}},[d]);const ie=async()=>{if(!w||A.current||c.state.botCreationPending)return;if(!t&&o.bot.approvalMode==="auto"&&o.bot.computer==="local"&&!o.consent.acknowledgeLocalAuto){I("local");return}const x=ae?It(F,$):null;if(x&&!x.ok){O(s("botSettings.visibility.needPeople"));return}A.current=!0,P(!0),O(""),c.dispatch({type:"botCreationPending",on:!0});try{if(t)await C("/api/config",{method:"PATCH",body:JSON.stringify({newBotDefaults:await Rt(o)})});else{const{bot:B,warnings:j,paused:k}=await Pt(o,void 0,void 0,void 0,x?.ok?x.visibility:void 0,z?ge(u,o.bot.section,c.state.bots,z)??void 0:void 0);At(c.dispatch,B,j,{showThreads:L,source:o.preset?"preset":o.role?"template":"blank",role:o.role,paused:k});try{await a?.(B)}catch(M){c.dispatch({type:"error",message:M instanceof Error?M.message:String(M)})}}A.current=!1,f.current&&q.current()}catch(B){f.current&&O(B instanceof Error?B.message:String(B))}finally{A.current=!1,c.dispatch({type:"botCreationPending",on:!1}),f.current&&P(!1)}},J=o.bot,Te={...c,state:{...c.state,bots:[J,...c.state.bots],routines:o.routines,routineRuns:[],routinesLoadState:"ready"},flushBotPatches:async()=>J,dispatch:x=>{x.type==="updateBot"&&x.botId===o.id?o.patch(x.patch):x.type==="setModel"&&x.botId===o.id?(o.setModel(x.selection),x.resetApprovalToAsk&&o.patch({approvalMode:"ask"})):x.type==="routinePatched"||x.type==="toggleSettings"||c.dispatch(x)}},re=t?s("newBot.defaults"):s("sidebar.newBot");return e.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/60 p-3 sm:p-5",hidden:!t&&c.state.appSettingsOpen,children:e.jsxs("div",{ref:H,role:"dialog","aria-modal":"true","aria-label":re,"aria-busy":b,tabIndex:-1,className:"flex h-[min(760px,94dvh)] w-full max-w-[900px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel shadow-2xl outline-none",children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-hairline/40 px-5 py-4",children:[e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:re}),e.jsx("button",{type:"button",onClick:()=>q.current(),"aria-label":s("common.close"),className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-40",children:e.jsx(ye,{size:18,className:"pointer-events-none"})})]}),z&&!t&&K&&e.jsx(ms,{team:K}),ae&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 pt-3 text-[13px] text-ink-secondary","data-new-bot-visibility":!0,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[s("botSettings.visibility.title"),e.jsxs(U,{size:"sm",value:F,disabled:b,onChange:x=>_(x.target.value),children:[e.jsx("option",{value:"everyone",children:s("botSettings.visibility.everyone")}),e.jsx("option",{value:"admins",children:s("botSettings.visibility.admins")}),e.jsx("option",{value:"people",children:s("botSettings.visibility.people")})]})]}),F==="people"&&e.jsx("input",{value:$,disabled:b,onChange:x=>X(x.target.value),placeholder:s("botSettings.visibility.peoplePlaceholder"),"aria-label":s("botSettings.visibility.peopleLabel"),className:"min-w-[16rem] flex-1 rounded-lg border border-hairline/40 bg-inset px-3 py-1.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col sm:flex-row",children:[e.jsx("nav",{"aria-label":s("newBot.sections"),className:"flex shrink-0 gap-1 overflow-x-auto border-b border-hairline/40 p-2 sm:w-40 sm:flex-col sm:border-b-0 sm:border-r",children:Ae.map(x=>e.jsx("button",{type:"button",onClick:()=>D(x),"aria-current":v===x?"page":void 0,className:ee("shrink-0 rounded-lg px-3 py-2 text-left text-[13px]",v===x?"bg-control text-ink":"text-ink-secondary hover:bg-control/50"),children:s(ps[x])},x))}),e.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto p-4 sm:p-5",children:[!w&&!T&&e.jsxs("div",{role:"status",className:"flex items-center gap-2 text-[13px] text-ink-secondary",children:[e.jsx(W,{size:16,className:"animate-spin"}),s("newBot.loading")]}),w&&e.jsx("fieldset",{disabled:b,className:"min-w-0",children:e.jsx(jt,{value:Te,children:e.jsx(kt.Provider,{value:{request:o.request,draft:!0,uploadAvatar:o.uploadAvatar},children:e.jsx(gs,{active:v,draft:o,defaultsMode:t,owner:z&&!t?{value:ge(u,J.section,c.state.bots,z),choose:E}:void 0})})})})]})]}),T&&e.jsx("p",{role:"alert",className:"max-h-24 overflow-y-auto border-t border-hairline/40 px-5 py-3 text-[13px] text-danger",children:T}),e.jsxs("div",{className:"flex shrink-0 justify-end gap-2 border-t border-hairline/40 px-5 py-3",children:[e.jsx("button",{type:"button",onClick:()=>q.current(),className:"rounded-lg px-4 py-2 text-[13px] text-ink-secondary hover:bg-control",children:s("common.cancel")}),e.jsxs("button",{type:"button",disabled:!w||b||!t&&!J.name.trim(),onClick:()=>{ie()},className:"ui-button-primary flex items-center gap-2 rounded-lg bg-accent px-5 py-2 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-40",children:[b&&e.jsx(W,{size:15,className:"animate-spin"}),s(t?"newBot.saveDefaults":"newBot.create")]})]}),e.jsx(St,{open:Y==="local",onCancel:()=>I(null),onConfirm:()=>{o.consent.acknowledgeLocalAuto=!0,I(null),ie()}})]})})}function ms({team:t}){const n=typeof window>"u"?void 0:window.ogb?.workspaces;return e.jsxs("div",{"data-new-bot-shared":!0,className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-b border-hairline/40 bg-raised/30 px-5 py-2.5 text-[13px] text-ink-secondary",children:[e.jsx("span",{children:s("newBot.sharedWith",{team:t})}),n?e.jsx("button",{type:"button",onClick:()=>{Tt(n).catch(()=>{})},className:"font-medium text-accent hover:underline",children:s("newBot.justForYou")}):e.jsx("span",{children:s("newBot.justForYou").replace(/\s*→$/,"")})]})}function gs({active:t,draft:n,defaultsMode:a,owner:i}){const r=n.bot,{state:d}=S(),c=Ce(),p=Nt(r);return t==="Identity"?e.jsxs("div",{className:"space-y-4",children:[e.jsx(hs,{draft:n,defaultsMode:a}),e.jsx(Lt,{bot:r,patch:p.patch,activeState:p.activeState,mascotMotion:null,namePlaceholder:a?s("newBot.randomName"):void 0}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("newBot.team"),e.jsxs(U,{size:"lg",className:"mt-1.5 w-full",value:r.section??"",onChange:o=>n.patch({section:o.target.value}),children:[e.jsx("option",{value:"",children:s("teamSettings.general")}),[...new Set([...d.sections??[],...d.bots.map(o=>o.section??"")])].filter(Boolean).map(o=>e.jsx("option",{children:o},o))]})]}),i&&c&&e.jsxs("label",{className:"block text-[13px] text-ink-secondary","data-new-bot-reports-to":!0,children:[s("lookedAfter.newBot"),e.jsx(U,{size:"lg",className:"mt-1.5 w-full",value:i.value??"",onChange:o=>i.choose(o.target.value),children:c.people.map(o=>e.jsx("option",{value:o.email,children:o.you?s("owner.you",{name:o.name}):o.name},o.email))}),e.jsx("span",{className:"mt-1 block text-[12px]",children:s("lookedAfter.pickHint")})]})]}):t==="Soul"?e.jsx(Dt,{bot:r,patch:p.patch}):t==="Skills"?e.jsx(Ot,{bot:r}):t==="Memory"?e.jsx(fs,{draft:n}):t==="Routines"?e.jsx(bs,{draft:n}):t==="Access"?e.jsx(Mt,{bot:r,derived:p}):t==="Model"?e.jsx(Ut,{bot:r}):t==="Permissions"?e.jsx(Ft,{bot:r,derived:p}):e.jsx(zt,{bot:r,derived:p})}function hs({draft:t,defaultsMode:n}){const[a,i]=l.useState([]),[r,d]=l.useState(0),[c,p]=l.useState(""),o=l.useRef(!1);l.useEffect(()=>{if(n)return;let m=!1;return C("/api/bot-presets").then(g=>{m||i(g.presets)}).catch(()=>{m||i([])}),()=>{m=!0}},[n,r]);const h=t.preset?a.find(m=>m.id===t.preset.id):void 0,v=async m=>{p("");const g=m.startsWith("preset:")?a.find(b=>b.id===m.slice(7)):void 0;if(!g){t.choosePreset(void 0);const b=xe.find(f=>f.id===m);t.chooseRole(b?.id);const A=b&&Q(b.id)?.look;b&&t.patch({...Ct(b),...A});return}t.patch(Qt(g)),t.choosePreset(ss(g));const P=es(g);try{P?(t.patch({avatarUrl:await t.uploadAvatar(P),avatarCrop:g.bot.appearance.avatar.crop}),o.current=!0):o.current&&(t.patch({avatarUrl:""}),o.current=!1)}catch(b){p(b instanceof Error?b.message:String(b))}},D=async m=>{p("");try{await C(`/api/bot-presets/${encodeURIComponent(m.id)}`,{method:"DELETE"}),t.preset?.id===m.id&&t.choosePreset(void 0),d(g=>g+1)}catch(g){p(g instanceof Error?g.message:String(g))}},w=xe.map(m=>e.jsx("option",{value:m.id,children:m.title},m.id));return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("newBot.startingRole"),e.jsxs(U,{size:"lg",className:"mt-1.5 w-full",value:t.preset?`preset:${t.preset.id}`:"",onChange:m=>{v(m.target.value)},children:[e.jsx("option",{value:"",children:s("newBot.customSettings")}),Zt(a).map(m=>e.jsx("optgroup",{label:m.label,children:m.presets.map(g=>e.jsx("option",{value:`preset:${g.id}`,children:g.name},g.id))},m.label)),a.length?e.jsx("optgroup",{label:s("newBot.builtInRoles"),children:w}):w]})]}),h&&e.jsxs("div",{className:"mt-2 space-y-1 rounded-lg bg-card px-3 py-2.5 text-[13px] text-ink-secondary","data-new-bot-preset":!0,children:[ts(h).map((m,g)=>e.jsx("p",{className:"break-words",children:m},g)),h.source==="file"&&e.jsx("button",{type:"button",onClick:()=>{D(h)},className:"mt-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-ink",children:s("newBot.presetRemove")})]}),c&&e.jsx("p",{role:"alert",className:"mt-2 text-[13px] text-danger",children:c})]})}function fs({draft:t}){const[n,a]=l.useState("MEMORY.md"),[i,r]=l.useState("");return e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{size:"lg",className:"w-full","aria-label":s("memory.fileLabel",{path:n}),value:n,onChange:d=>a(d.target.value),children:[...new Set(["MEMORY.md",...Object.keys(t.template.memory)])].map(d=>e.jsx("option",{children:d},d))}),e.jsx("textarea",{className:ee(he,"min-h-72 font-mono"),"aria-label":s("memory.contents"),value:t.template.memory[n]??"",onChange:d=>t.setMemory(n,d.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:he,"aria-label":s("memory.newTopicLabel"),placeholder:s("memory.newTopicLabel"),value:i,onChange:d=>r(d.target.value)}),e.jsx("button",{type:"button","aria-label":s("memory.addTopic"),disabled:!/^[a-zA-Z0-9_-]+$/.test(i),className:"rounded-lg bg-control px-3 disabled:opacity-40",onClick:()=>{const d=`memory/${i}.md`;d in t.template.memory||t.setMemory(d,""),a(d),r("")},children:e.jsx(Jt,{size:16})}),n!=="MEMORY.md"&&e.jsx("button",{type:"button","aria-label":s("memory.removeTopic"),className:"rounded-lg bg-control px-3",onClick:()=>{t.setMemory(n,null),a("MEMORY.md")},children:e.jsx(Ee,{size:16})})]})]})}function bs({draft:t}){const[n,a]=l.useState(null);return e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{type:"button",className:"rounded-lg bg-accent px-3 py-2 text-[13px] text-white",onClick:()=>a("new"),children:s("computer.routines.create")}),t.routines.map(i=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-card p-3",children:[e.jsx("button",{type:"button",className:"min-w-0 flex-1 text-left text-[13px]",onClick:()=>a(i),children:i.name}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[12px] text-ink-secondary",children:[e.jsx("input",{type:"checkbox",checked:i.enabled,onChange:r=>t.setRoutineEnabled(i.id,r.target.checked)}),s("newBot.enabled")]}),e.jsx("button",{type:"button","aria-label":s("newBot.removeRoutine",{name:i.name}),onClick:()=>t.removeRoutine(i.id),className:"rounded p-1.5 hover:bg-control",children:e.jsx(Ee,{size:15})})]},i.id)),n&&e.jsx(Kt,{routine:n==="new"?void 0:n,bots:[t.bot],lockedBotId:t.id,onClose:()=>a(null)})]})}function vs({simple:t=!1}){const[n,a]=l.useState(!1),[i,r]=l.useState(!1),d=e.jsxs(e.Fragment,{children:[n&&e.jsx(Pe,{defaultsMode:!0,onClose:()=>a(!1)}),i&&e.jsx(ns,{onClose:()=>r(!1)})]});if(t)return e.jsxs(e.Fragment,{children:[e.jsx(ds,{onEdit:()=>a(!0),onShare:()=>r(!0)}),d]});const c=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!0),className:"cursor-pointer rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-control hover:text-ink",children:s("newBot.sharePreset")}),e.jsx("button",{type:"button",onClick:()=>a(!0),className:"cursor-pointer rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover",children:s("newBot.edit")})]}),d]});return e.jsx(y,{title:s("newBot.defaults"),children:c})}const Js=Object.freeze(Object.defineProperty({__proto__:null,DefaultBotSettings:vs,NewBotDialog:Pe},Symbol.toStringTag,{value:"Module"}));export{Fs as A,Rs as B,Us as C,vs as D,qs as E,Ms as F,Ds as L,Ts as N,Is as P,Ls as R,Ps as S,$s as T,As as U,Hs as a,Os as b,zs as c,_s as d,Ks as e,Js as f};
@@ -1 +1 @@
1
- import{r as d,j as t,t as n}from"./styles-ezcN4hc0.js";import{r as c}from"./PlacesRail-BesUMTCh.js";import{y as x,z as p,Q as m,D as u}from"./App-BtFoKXkb.js";import"./monitor-DwKv3TJO.js";import"./index-DLhL-159.js";import"./MenuMotion-Dr44d4Sg.js";const f=[{id:"ios",nameKey:"phoneApp.ios",actionKey:"phoneApp.iosAction",url:x},{id:"android",nameKey:"phoneApp.android",actionKey:"phoneApp.androidAction",url:p}];function v({open:r,onClose:o,connect:i=[]}){const a=d.useRef(null);if(d.useEffect(()=>{if(!r)return;a.current?.focus();const e=l=>{l.key==="Escape"&&(l.preventDefault(),o())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,o]),!r)return null;const s=t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onMouseDown:e=>e.stopPropagation(),children:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"phone-app-dialog-title",className:"max-h-full w-full max-w-[460px] overflow-y-auto rounded-2xl border border-hairline/50 bg-panel p-6 shadow-2xl",children:[t.jsx("h2",{id:"phone-app-dialog-title",className:"text-[17px] font-semibold text-ink",children:n("phoneApp.title")}),t.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:n("phoneApp.subtitle")}),t.jsx("ul",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2",children:f.map(e=>t.jsxs("li",{"data-phone-app":e.id,className:"flex flex-col items-center gap-3 rounded-xl bg-card p-4 text-center",children:[t.jsx("div",{className:"text-[14px] font-medium text-ink",children:n(e.nameKey)}),t.jsx("div",{className:"rounded-md bg-white p-2",children:t.jsx(m,{value:e.url,size:132,level:"M",bgColor:"#ffffff",fgColor:"#111111",title:n(e.actionKey)})}),t.jsx("button",{type:"button",onClick:()=>{u(e.url)},className:"text-[13px] text-accent hover:underline",children:n(e.actionKey)})]},e.id))}),i.length?t.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[t.jsx("p",{className:"text-[13px] leading-relaxed text-ink-secondary",children:n("phoneApp.next")}),i.map((e,l)=>t.jsxs("button",{type:"button","data-phone-app-connect":e.key,onClick:()=>{o(),e.onSelect()},className:l===0?"flex w-full flex-col items-center rounded-xl bg-accent px-4 py-2 text-[13px] font-medium text-accent-ink hover:opacity-90":"flex w-full flex-col items-center rounded-xl border border-hairline/50 px-4 py-2 text-[13px] font-medium text-ink hover:bg-raised",children:[t.jsx("span",{children:n("sidebar.menu.connectPhone")}),t.jsx("span",{className:"text-[12px] font-normal opacity-80",children:e.subtitle})]},e.key))]}):null,t.jsx("button",{ref:a,type:"button",onClick:o,className:"mt-3 w-full rounded-xl bg-raised px-4 py-2 text-[13px] font-medium text-ink hover:brightness-110",children:n("common.close")})]})});return typeof document>"u"?s:c.createPortal(s,document.body)}export{f as PHONE_APPS,v as PhoneAppDialog};
1
+ import{r as d,j as t,t as n}from"./styles-ezcN4hc0.js";import{r as c}from"./PlacesRail-BesUMTCh.js";import{y as x,z as p,Q as m,D as u}from"./App-C8J3XlgX.js";import"./monitor-DwKv3TJO.js";import"./index-C9y4_V8D.js";import"./MenuMotion-Dr44d4Sg.js";const f=[{id:"ios",nameKey:"phoneApp.ios",actionKey:"phoneApp.iosAction",url:x},{id:"android",nameKey:"phoneApp.android",actionKey:"phoneApp.androidAction",url:p}];function v({open:r,onClose:o,connect:i=[]}){const a=d.useRef(null);if(d.useEffect(()=>{if(!r)return;a.current?.focus();const e=l=>{l.key==="Escape"&&(l.preventDefault(),o())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,o]),!r)return null;const s=t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onMouseDown:e=>e.stopPropagation(),children:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"phone-app-dialog-title",className:"max-h-full w-full max-w-[460px] overflow-y-auto rounded-2xl border border-hairline/50 bg-panel p-6 shadow-2xl",children:[t.jsx("h2",{id:"phone-app-dialog-title",className:"text-[17px] font-semibold text-ink",children:n("phoneApp.title")}),t.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:n("phoneApp.subtitle")}),t.jsx("ul",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2",children:f.map(e=>t.jsxs("li",{"data-phone-app":e.id,className:"flex flex-col items-center gap-3 rounded-xl bg-card p-4 text-center",children:[t.jsx("div",{className:"text-[14px] font-medium text-ink",children:n(e.nameKey)}),t.jsx("div",{className:"rounded-md bg-white p-2",children:t.jsx(m,{value:e.url,size:132,level:"M",bgColor:"#ffffff",fgColor:"#111111",title:n(e.actionKey)})}),t.jsx("button",{type:"button",onClick:()=>{u(e.url)},className:"text-[13px] text-accent hover:underline",children:n(e.actionKey)})]},e.id))}),i.length?t.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[t.jsx("p",{className:"text-[13px] leading-relaxed text-ink-secondary",children:n("phoneApp.next")}),i.map((e,l)=>t.jsxs("button",{type:"button","data-phone-app-connect":e.key,onClick:()=>{o(),e.onSelect()},className:l===0?"flex w-full flex-col items-center rounded-xl bg-accent px-4 py-2 text-[13px] font-medium text-accent-ink hover:opacity-90":"flex w-full flex-col items-center rounded-xl border border-hairline/50 px-4 py-2 text-[13px] font-medium text-ink hover:bg-raised",children:[t.jsx("span",{children:n("sidebar.menu.connectPhone")}),t.jsx("span",{className:"text-[12px] font-normal opacity-80",children:e.subtitle})]},e.key))]}):null,t.jsx("button",{ref:a,type:"button",onClick:o,className:"mt-3 w-full rounded-xl bg-raised px-4 py-2 text-[13px] font-medium text-ink hover:brightness-110",children:n("common.close")})]})});return typeof document>"u"?s:c.createPortal(s,document.body)}export{f as PHONE_APPS,v as PhoneAppDialog};
@@ -1,4 +1,4 @@
1
- import{c as un,t as n,r as d,j as e,X as ns,ae as ss,a as q,d as Ze,l as xt,S as As,i as Vt}from"./styles-ezcN4hc0.js";import{S as pn,j as A,u as Xe,eG as Cs,eH as Ss,eI as Rs,eJ as ft,w as Es,eK as zs,eL as Is,l as Ts,G as Rn,eM as Os,eN as Bs,cT as Ps,T as Ms,ah as en,bt as Ls,D as tn,eO as zt,eP as as,eQ as It,eR as is,an as os,eS as Tt,eT as Us,eU as cs,eV as Ot,eW as rs,eX as $s,eY as En,eZ as Fs,Y as ls,e_ as Ct,e$ as Ks,f0 as Ds,f1 as Hs,f2 as Qs,f3 as _s,f4 as ct,f5 as zn,f6 as Js,f7 as In,eg as Tn,f8 as Vs,f9 as Gs,fa as qs,fb as Gt,fc as Ws,fd as Zs,fe as Ys,ff as Xs,fg as ea,fh as ta,fi as na,fj as sa,fk as aa,fl as ia,fm as oa}from"./App-BtFoKXkb.js";import{L as ie,P as ds,X as ca,a as ra,v as mn,E as la,_ as da,$ as ua,B as pa}from"./PlacesRail-BesUMTCh.js";import{u as qt}from"./mcp-servers-DwlkPkVq.js";import{C as us,R as nn}from"./MenuMotion-Dr44d4Sg.js";import{u as ma}from"./ProIntroduction-CZMEIOV3.js";import"./index-DLhL-159.js";import"./monitor-DwKv3TJO.js";const ha=[["path",{d:"M13 2a9 9 0 0 1 9 9",key:"1itnx2"}],["path",{d:"M13 6a5 5 0 0 1 5 5",key:"11nki7"}],["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],xa=un("phone-call",ha);const fa=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],ga=un("radio-tower",fa);const ba=[["path",{d:"m10.852 14.772-.383.923",key:"11vil6"}],["path",{d:"M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1v3clb"}],["path",{d:"m13.148 9.228.383-.923",key:"t2zzyc"}],["path",{d:"m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1bxfiv"}],["path",{d:"m14.772 10.852.923-.383",key:"k9m8cz"}],["path",{d:"m14.772 13.148.923.383",key:"1xvhww"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"m9.228 10.852-.923-.383",key:"1wtb30"}],["path",{d:"m9.228 13.148-.923.383",key:"1a830x"}]],Wt=un("server-cog",ba),ya=new Set(["twitter","x"]);function On(t,s){return t!=="managed"||!ya.has(s.trim().toLowerCase())?null:"Twitter/X needs your own X Developer app and Composio auth config. Use self-hosted connected apps for now."}const ka=5,ja=3,Bt=4;function va(t,s=ka,o=[]){const c=new Map;for(const f of t)for(const y of new Set(f.categories??[]))c.set(y,(c.get(y)??0)+1);const r=[...c].sort((f,y)=>y[1]-f[1]||f[0].localeCompare(y[0])).map(([f])=>f),l=o.filter(f=>r.indexOf(f)>=s),b=[...r.slice(0,Math.max(0,s-l.length)),...l];return{inline:b,more:r.filter(f=>!b.includes(f))}}function sn(t,s){return s===null||(t.categories??[]).includes(s)}function wa(t,s,o){const c=[],r=t.filter(l=>s(l.slug));r.length&&c.push({kind:"connected",cards:r});for(const l of o.slice(0,ja)){const b=t.filter(f=>!s(f.slug)&&sn(f,l));b.length&&c.push({kind:"category",category:l,cards:b.slice(0,Bt),more:b.length>Bt})}return c.push({kind:"all",cards:t.filter(l=>!s(l.slug))}),c}const Na={productivity:"productivity","developer tools":"developerTools",communication:"communication",files:"files","sales and crm":"salesCrm",design:"design",marketing:"marketing",analytics:"analytics",social:"social"},Aa={"google calendar":"googleCalendar","google sheets":"googleSheets","google docs":"googleDocs",notion:"notion",github:"github",linear:"linear",sentry:"sentry",jira:"jira",slack:"slack",gmail:"gmail",discord:"discord","google drive":"googleDrive",posthog:"posthog","x (twitter)":"xTwitter",reddit:"reddit",zapier:"zapier",hubspot:"hubspot",salesforce:"salesforce",asana:"asana",trello:"trello",dropbox:"dropbox",airtable:"airtable",figma:"figma",stripe:"stripe"};function rt(t){const s=Na[t.trim().toLowerCase()];return s?n(`apps.category.${s}`):t}function Bn(t){const s=Aa[t.label.trim().toLowerCase()];return s?n(`apps.catalog.${s}.blurb`):t.blurb}function Ca({server:t,disabled:s,onSaved:o}){const[c,r]=d.useState(!1),[l,b]=d.useState(null);if(typeof t.apps!="boolean"||t.apps&&t.hasApps!==!0)return null;const f=t.apps,y=async()=>{r(!0),b(null);try{const p=await A(`/api/mcp/servers/${encodeURIComponent(t.name)}`,{method:"PATCH",body:JSON.stringify({apps:!f})});o(p.servers??[])}catch(p){b(p instanceof Error?p.message:String(p))}finally{r(!1)}};return e.jsxs("div",{"data-mcp-apps":t.name,className:"mt-3 flex items-center gap-3 border-t border-hairline/40 pt-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:n("mcp.apps.title")}),e.jsx("div",{role:l?"alert":void 0,className:l?"mt-0.5 text-[12px] text-danger":"mt-0.5 text-[12px] text-ink-secondary",children:l??n("mcp.apps.desc")})]}),c&&e.jsx(ie,{"aria-hidden":"true",size:13,className:"animate-spin text-ink-secondary"}),e.jsx(pn,{checked:f,disabled:s||c,onClick:()=>{y()},"aria-label":n("mcp.apps.toggleAria",{name:t.name}),className:"disabled:opacity-40"})]})}function Pn({feature:t,enabled:s,prefix:o}){const{dispatch:c}=Xe(),[r,l]=d.useState(!1),[b,f]=d.useState(!1),y=async()=>{if(!r){l(!0),f(!1);try{const p=await A("/api/config",{method:"PATCH",body:JSON.stringify({features:{[t]:!s}})});c({type:"configStatus",config:p})}catch{f(!0)}finally{l(!1)}}};return e.jsxs("div",{className:"mt-4 flex items-start justify-between gap-4 rounded-2xl border border-hairline/50 bg-card px-4 py-4 sm:px-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:n(`${o}.title`)}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:n(`${o}.desc`)}),b&&e.jsx("p",{role:"alert",className:"mt-1 text-[12px] text-danger",children:n("mcp.claude.error")})]}),e.jsx(pn,{checked:s,"aria-label":n(`${o}.aria`),disabled:r,onClick:()=>{y()},className:"mt-0.5 shrink-0 disabled:cursor-wait disabled:opacity-50"})]})}function Sa(){const{state:t}=Xe();return e.jsxs(e.Fragment,{children:[e.jsx(Pn,{feature:"claudeUserMcp",enabled:Cs(t.config),prefix:"mcp.claude"}),e.jsx(Pn,{feature:"claudeUserSkills",enabled:Ss(t.config),prefix:"mcp.claudeSkills"})]})}function Mn({app:t}){if("image"in t.icon)return e.jsx("img",{src:t.icon.image,alt:"",className:"size-10 shrink-0 rounded-xl object-contain"});const s=t.icon.glyph;return e.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center rounded-xl bg-raised text-ink-secondary",children:e.jsx(s,{size:19,"aria-hidden":"true"})})}class me extends Error{key;constructor(s){super(s),this.key=s}}const an=/^https?:\/\//i,ps=/^[A-Za-z_][A-Za-z0-9_]*=/,Ra=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+:/,Ea=new Set(["npx","uvx","bunx"]),za=new Set(["pnpm","yarn"]);function Ia(t,s=[]){const o=Ta(t).trim();if(!o)return null;try{const c=/^[{[]/.test(o)?$a(o):an.test(o)&&!/\s/.test(o)?[hn(void 0,o,void 0,[])]:Oa(o);return{ok:!0,servers:Qa(c,s)}}catch(c){if(c instanceof me)return{ok:!1,error:c.key};throw c}}function Ta(t){return t.replace(/[“”„]/g,'"').replace(/[‘’]/g,"'").replace(/(^|\s)[–—](?=[a-z])/g,"$1--")}function ms(t){const s=[];let o=[],c="",r=!1;const l=()=>{r&&o.push(c),c="",r=!1},b=()=>{l(),o.length&&s.push(o),o=[]},f=y=>t[y]===`
1
+ import{c as un,t as n,r as d,j as e,X as ns,ae as ss,a as q,d as Ze,l as xt,S as As,i as Vt}from"./styles-ezcN4hc0.js";import{S as pn,j as A,u as Xe,eG as Cs,eH as Ss,eI as Rs,eJ as ft,w as Es,eK as zs,eL as Is,l as Ts,G as Rn,eM as Os,eN as Bs,cT as Ps,T as Ms,ah as en,bt as Ls,D as tn,eO as zt,eP as as,eQ as It,eR as is,an as os,eS as Tt,eT as Us,eU as cs,eV as Ot,eW as rs,eX as $s,eY as En,eZ as Fs,Y as ls,e_ as Ct,e$ as Ks,f0 as Ds,f1 as Hs,f2 as Qs,f3 as _s,f4 as ct,f5 as zn,f6 as Js,f7 as In,eg as Tn,f8 as Vs,f9 as Gs,fa as qs,fb as Gt,fc as Ws,fd as Zs,fe as Ys,ff as Xs,fg as ea,fh as ta,fi as na,fj as sa,fk as aa,fl as ia,fm as oa}from"./App-C8J3XlgX.js";import{L as ie,P as ds,X as ca,a as ra,v as mn,E as la,_ as da,$ as ua,B as pa}from"./PlacesRail-BesUMTCh.js";import{u as qt}from"./mcp-servers-BS2X7Buc.js";import{C as us,R as nn}from"./MenuMotion-Dr44d4Sg.js";import{u as ma}from"./ProIntroduction-r5lv0CF0.js";import"./index-C9y4_V8D.js";import"./monitor-DwKv3TJO.js";const ha=[["path",{d:"M13 2a9 9 0 0 1 9 9",key:"1itnx2"}],["path",{d:"M13 6a5 5 0 0 1 5 5",key:"11nki7"}],["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],xa=un("phone-call",ha);const fa=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],ga=un("radio-tower",fa);const ba=[["path",{d:"m10.852 14.772-.383.923",key:"11vil6"}],["path",{d:"M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1v3clb"}],["path",{d:"m13.148 9.228.383-.923",key:"t2zzyc"}],["path",{d:"m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1bxfiv"}],["path",{d:"m14.772 10.852.923-.383",key:"k9m8cz"}],["path",{d:"m14.772 13.148.923.383",key:"1xvhww"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"m9.228 10.852-.923-.383",key:"1wtb30"}],["path",{d:"m9.228 13.148-.923.383",key:"1a830x"}]],Wt=un("server-cog",ba),ya=new Set(["twitter","x"]);function On(t,s){return t!=="managed"||!ya.has(s.trim().toLowerCase())?null:"Twitter/X needs your own X Developer app and Composio auth config. Use self-hosted connected apps for now."}const ka=5,ja=3,Bt=4;function va(t,s=ka,o=[]){const c=new Map;for(const f of t)for(const y of new Set(f.categories??[]))c.set(y,(c.get(y)??0)+1);const r=[...c].sort((f,y)=>y[1]-f[1]||f[0].localeCompare(y[0])).map(([f])=>f),l=o.filter(f=>r.indexOf(f)>=s),b=[...r.slice(0,Math.max(0,s-l.length)),...l];return{inline:b,more:r.filter(f=>!b.includes(f))}}function sn(t,s){return s===null||(t.categories??[]).includes(s)}function wa(t,s,o){const c=[],r=t.filter(l=>s(l.slug));r.length&&c.push({kind:"connected",cards:r});for(const l of o.slice(0,ja)){const b=t.filter(f=>!s(f.slug)&&sn(f,l));b.length&&c.push({kind:"category",category:l,cards:b.slice(0,Bt),more:b.length>Bt})}return c.push({kind:"all",cards:t.filter(l=>!s(l.slug))}),c}const Na={productivity:"productivity","developer tools":"developerTools",communication:"communication",files:"files","sales and crm":"salesCrm",design:"design",marketing:"marketing",analytics:"analytics",social:"social"},Aa={"google calendar":"googleCalendar","google sheets":"googleSheets","google docs":"googleDocs",notion:"notion",github:"github",linear:"linear",sentry:"sentry",jira:"jira",slack:"slack",gmail:"gmail",discord:"discord","google drive":"googleDrive",posthog:"posthog","x (twitter)":"xTwitter",reddit:"reddit",zapier:"zapier",hubspot:"hubspot",salesforce:"salesforce",asana:"asana",trello:"trello",dropbox:"dropbox",airtable:"airtable",figma:"figma",stripe:"stripe"};function rt(t){const s=Na[t.trim().toLowerCase()];return s?n(`apps.category.${s}`):t}function Bn(t){const s=Aa[t.label.trim().toLowerCase()];return s?n(`apps.catalog.${s}.blurb`):t.blurb}function Ca({server:t,disabled:s,onSaved:o}){const[c,r]=d.useState(!1),[l,b]=d.useState(null);if(typeof t.apps!="boolean"||t.apps&&t.hasApps!==!0)return null;const f=t.apps,y=async()=>{r(!0),b(null);try{const p=await A(`/api/mcp/servers/${encodeURIComponent(t.name)}`,{method:"PATCH",body:JSON.stringify({apps:!f})});o(p.servers??[])}catch(p){b(p instanceof Error?p.message:String(p))}finally{r(!1)}};return e.jsxs("div",{"data-mcp-apps":t.name,className:"mt-3 flex items-center gap-3 border-t border-hairline/40 pt-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:n("mcp.apps.title")}),e.jsx("div",{role:l?"alert":void 0,className:l?"mt-0.5 text-[12px] text-danger":"mt-0.5 text-[12px] text-ink-secondary",children:l??n("mcp.apps.desc")})]}),c&&e.jsx(ie,{"aria-hidden":"true",size:13,className:"animate-spin text-ink-secondary"}),e.jsx(pn,{checked:f,disabled:s||c,onClick:()=>{y()},"aria-label":n("mcp.apps.toggleAria",{name:t.name}),className:"disabled:opacity-40"})]})}function Pn({feature:t,enabled:s,prefix:o}){const{dispatch:c}=Xe(),[r,l]=d.useState(!1),[b,f]=d.useState(!1),y=async()=>{if(!r){l(!0),f(!1);try{const p=await A("/api/config",{method:"PATCH",body:JSON.stringify({features:{[t]:!s}})});c({type:"configStatus",config:p})}catch{f(!0)}finally{l(!1)}}};return e.jsxs("div",{className:"mt-4 flex items-start justify-between gap-4 rounded-2xl border border-hairline/50 bg-card px-4 py-4 sm:px-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:n(`${o}.title`)}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:n(`${o}.desc`)}),b&&e.jsx("p",{role:"alert",className:"mt-1 text-[12px] text-danger",children:n("mcp.claude.error")})]}),e.jsx(pn,{checked:s,"aria-label":n(`${o}.aria`),disabled:r,onClick:()=>{y()},className:"mt-0.5 shrink-0 disabled:cursor-wait disabled:opacity-50"})]})}function Sa(){const{state:t}=Xe();return e.jsxs(e.Fragment,{children:[e.jsx(Pn,{feature:"claudeUserMcp",enabled:Cs(t.config),prefix:"mcp.claude"}),e.jsx(Pn,{feature:"claudeUserSkills",enabled:Ss(t.config),prefix:"mcp.claudeSkills"})]})}function Mn({app:t}){if("image"in t.icon)return e.jsx("img",{src:t.icon.image,alt:"",className:"size-10 shrink-0 rounded-xl object-contain"});const s=t.icon.glyph;return e.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center rounded-xl bg-raised text-ink-secondary",children:e.jsx(s,{size:19,"aria-hidden":"true"})})}class me extends Error{key;constructor(s){super(s),this.key=s}}const an=/^https?:\/\//i,ps=/^[A-Za-z_][A-Za-z0-9_]*=/,Ra=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+:/,Ea=new Set(["npx","uvx","bunx"]),za=new Set(["pnpm","yarn"]);function Ia(t,s=[]){const o=Ta(t).trim();if(!o)return null;try{const c=/^[{[]/.test(o)?$a(o):an.test(o)&&!/\s/.test(o)?[hn(void 0,o,void 0,[])]:Oa(o);return{ok:!0,servers:Qa(c,s)}}catch(c){if(c instanceof me)return{ok:!1,error:c.key};throw c}}function Ta(t){return t.replace(/[“”„]/g,'"').replace(/[‘’]/g,"'").replace(/(^|\s)[–—](?=[a-z])/g,"$1--")}function ms(t){const s=[];let o=[],c="",r=!1;const l=()=>{r&&o.push(c),c="",r=!1},b=()=>{l(),o.length&&s.push(o),o=[]},f=y=>t[y]===`
2
2
  `?1:t[y]==="\r"&&t[y+1]===`
3
3
  `?2:0;for(let y=0;y<t.length;y+=1){const p=t[y];if(p==="\\"||(p==="`"||p==="^")&&f(y+1)){const m=f(y+1);if(m){y+=m;continue}y+1<t.length&&(c+=t[y+1],r=!0,y+=1);continue}if(p==="'"){const m=t.indexOf("'",y+1);if(m<0)throw new me("mcp.paste.notRecognized");c+=t.slice(y+1,m),r=!0,y=m;continue}if(p==='"'){let m=y+1;for(;m<t.length&&t[m]!=='"';m+=1){if(t[m]==="\\"&&m+1<t.length){const j=f(m+1);if(j){m+=j;continue}if('"\\$`'.includes(t[m+1])){c+=t[m+1],m+=1;continue}}c+=t[m]}if(m>=t.length)throw new me("mcp.paste.notRecognized");r=!0,y=m;continue}if(p==="$"&&t[y+1]==="("){const m=t.indexOf(")",y+2);if(m<0)throw new me("mcp.paste.notRecognized");c+=t.slice(y,m+1),r=!0,y=m;continue}if(p==="#"&&!r){for(;y+1<t.length&&t[y+1]!==`
4
4
  `;)y+=1;continue}if(p===`
@@ -1 +1 @@
1
- import{r as c,j as s,k as h,t as u}from"./styles-ezcN4hc0.js";import{f as m,g as b,h as a,i as p}from"./PlacesRail-BesUMTCh.js";import{u as g,a2 as w,a3 as v}from"./App-BtFoKXkb.js";function f(t,e){const o=t&&!window.ogb?.remoteClient?.active?window.ogb?.cloudAccount:void 0,[i,n]=c.useState(null),r=o?.offer?JSON.stringify(e??null):null;return c.useEffect(()=>{if(r===null||!o?.offer)return;let l=!0;return o.offer().then(x=>{l&&n(x)},()=>{}),()=>{l=!1}},[o,r]),o?.offer?i:null}function d(){const t=window.ogb?.remoteClient?.active?void 0:window.ogb?.cloudAccount,[e,o]=c.useState(null);return c.useEffect(()=>{if(!t)return;let i=!0,n=!1;const r=t.onState(l=>{n=!0,i&&o(l)});return t.state().then(l=>{i&&!n&&o(l)}).catch(()=>{}),()=>{i=!1,r()}},[t]),t&&m?{view:b(e),account:e}:null}function S(){const{dispatch:t}=g(),e=d(),o=e!==null&&a(e.view);if(f(o,e?.account?.offer),!e)return null;const{view:i}=e,n=p(i);return!n&&i.kind!=="reauth"?null:s.jsxs("section",{"aria-label":u("settings.section.cloudAccount"),"data-cloud-plan":i.kind,className:"flex flex-wrap items-center justify-between gap-3 rounded-xl border border-hairline/50 p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(h,{className:"text-ink-secondary",size:18,"aria-hidden":"true"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-[14px] font-semibold text-ink",children:u("settings.section.cloudAccount")}),s.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:i.kind==="reauth"?u("pro.reauthShort"):n})]})]}),s.jsx("button",{type:"button",className:"ui-button",onClick:()=>t({type:"toggleAppSettings",open:!0,section:"cloudAccount"}),children:u("pro.openCloudSettings")})]})}function A({place:t,usage:e=null,upgrade:o}){const{dispatch:i}=g(),n=d(),r=n!==null&&a(n.view);if(f(r,n?.account?.offer),!n)return null;const l=n.view.kind==="reauth"?u("pro.reauthShort"):p(n.view);return l?s.jsx(w,{title:u("pro.name"),subtitle:l,children:t==="account"?s.jsx("button",{type:"button","data-cloud-plan":n.view.kind,className:"ui-button",onClick:()=>i({type:"toggleAppSettings",open:!0,section:"cloudAccount"}),children:u("settings.simple.account.manage")}):e&&o?s.jsx(v,{usage:e,upgrade:o}):null}):null}function y(){const t=d(),e=t!==null&&a(t.view);return f(e,t?.account?.offer),null}export{A as C,S as P,f as a,y as b,d as u};
1
+ import{r as c,j as s,k as h,t as u}from"./styles-ezcN4hc0.js";import{f as m,g as b,h as a,i as p}from"./PlacesRail-BesUMTCh.js";import{u as g,a2 as w,a3 as v}from"./App-C8J3XlgX.js";function f(t,e){const o=t&&!window.ogb?.remoteClient?.active?window.ogb?.cloudAccount:void 0,[i,n]=c.useState(null),r=o?.offer?JSON.stringify(e??null):null;return c.useEffect(()=>{if(r===null||!o?.offer)return;let l=!0;return o.offer().then(x=>{l&&n(x)},()=>{}),()=>{l=!1}},[o,r]),o?.offer?i:null}function d(){const t=window.ogb?.remoteClient?.active?void 0:window.ogb?.cloudAccount,[e,o]=c.useState(null);return c.useEffect(()=>{if(!t)return;let i=!0,n=!1;const r=t.onState(l=>{n=!0,i&&o(l)});return t.state().then(l=>{i&&!n&&o(l)}).catch(()=>{}),()=>{i=!1,r()}},[t]),t&&m?{view:b(e),account:e}:null}function S(){const{dispatch:t}=g(),e=d(),o=e!==null&&a(e.view);if(f(o,e?.account?.offer),!e)return null;const{view:i}=e,n=p(i);return!n&&i.kind!=="reauth"?null:s.jsxs("section",{"aria-label":u("settings.section.cloudAccount"),"data-cloud-plan":i.kind,className:"flex flex-wrap items-center justify-between gap-3 rounded-xl border border-hairline/50 p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(h,{className:"text-ink-secondary",size:18,"aria-hidden":"true"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-[14px] font-semibold text-ink",children:u("settings.section.cloudAccount")}),s.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:i.kind==="reauth"?u("pro.reauthShort"):n})]})]}),s.jsx("button",{type:"button",className:"ui-button",onClick:()=>t({type:"toggleAppSettings",open:!0,section:"cloudAccount"}),children:u("pro.openCloudSettings")})]})}function A({place:t,usage:e=null,upgrade:o}){const{dispatch:i}=g(),n=d(),r=n!==null&&a(n.view);if(f(r,n?.account?.offer),!n)return null;const l=n.view.kind==="reauth"?u("pro.reauthShort"):p(n.view);return l?s.jsx(w,{title:u("pro.name"),subtitle:l,children:t==="account"?s.jsx("button",{type:"button","data-cloud-plan":n.view.kind,className:"ui-button",onClick:()=>i({type:"toggleAppSettings",open:!0,section:"cloudAccount"}),children:u("settings.simple.account.manage")}):e&&o?s.jsx(v,{usage:e,upgrade:o}):null}):null}function y(){const t=d(),e=t!==null&&a(t.view);return f(e,t?.account?.offer),null}export{A as C,S as P,f as a,y as b,d as u};