limixbot 0.3.161 → 0.3.162

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 (49) hide show
  1. package/dist/assets/{ActivityPanel-D4K2fyw7.js → ActivityPanel-CMN_U4H6.js} +1 -1
  2. package/dist/assets/{App-B6W9JFXZ.js → App-DbfRrJPA.js} +94 -94
  3. package/dist/assets/{AppEventEditor-OWWzSxPd.js → AppEventEditor-BpXev-Xi.js} +1 -1
  4. package/dist/assets/{BotSettingsDialog-W_eO05D2.js → BotSettingsDialog-DzL9xn3E.js} +1 -1
  5. package/dist/assets/{BrowserPanel-C0NOYaOK.js → BrowserPanel-Dq80i975.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-48HNAHJm.js → BrowserProfilesManager-BiDKQm59.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-RDN92Hbu.js → CloudAddDialog-B-QSFP19.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-HhCIEUQ4.js → ComputerFilesPane-DU2CnBSk.js} +1 -1
  9. package/dist/assets/{ComputerPanel-C8ZuT_hf.js → ComputerPanel-3z4z9zuO.js} +2 -2
  10. package/dist/assets/{DataPanel-CEPYRb_t.js → DataPanel-D2rowgqx.js} +1 -1
  11. package/dist/assets/{GrokMoveDialog-BEkVuGJs.js → GrokMoveDialog-BM1fpvD9.js} +1 -1
  12. package/dist/assets/{InspectorPanel-CYwO5Hpk.js → InspectorPanel-CSXRdQWb.js} +1 -1
  13. package/dist/assets/{KeyboardShortcutsModal-CvoUyPNv.js → KeyboardShortcutsModal-Bl0rAIm5.js} +1 -1
  14. package/dist/assets/{KnowledgePanel-Crh_Mb2-.js → KnowledgePanel-BIucsmt4.js} +1 -1
  15. package/dist/assets/{LiveDesktop-DZV6iCg2.js → LiveDesktop-9xq-uOSe.js} +1 -1
  16. package/dist/assets/{LocalVmWorkspace-C82LcwJQ.js → LocalVmWorkspace-SpZ3uYGB.js} +1 -1
  17. package/dist/assets/{MacLocalControl-Bx_fyo-H.js → MacLocalControl-BSQ9KcLo.js} +1 -1
  18. package/dist/assets/{MarkdownFilePreview-BXNCSmvg.js → MarkdownFilePreview-Bdq8zdL7.js} +1 -1
  19. package/dist/assets/{NewBotDialog-D0agPdOC.js → NewBotDialog-Y3yhTrdv.js} +1 -1
  20. package/dist/assets/{PhoneAppDialog-DQpyRnEJ.js → PhoneAppDialog-xyMORAow.js} +1 -1
  21. package/dist/assets/{PluginsPanel-C4HY0lnL.js → PluginsPanel-BycWst3k.js} +1 -1
  22. package/dist/assets/{ProIntroduction-BO5ABFTi.js → ProIntroduction-CSoN3fqJ.js} +1 -1
  23. package/dist/assets/{RemoteAgentSettingsPanel-D0vIEaec.js → RemoteAgentSettingsPanel-BPaZTL6O.js} +1 -1
  24. package/dist/assets/{RoomPanel-KgR5RAVc.js → RoomPanel-D0qQD9cP.js} +1 -1
  25. package/dist/assets/{RoutinesPage-CFb9pR_B.js → RoutinesPage-BcixjsUv.js} +1 -1
  26. package/dist/assets/{SettingsModal-CBovr73q.js → SettingsModal-TeyS-NmE.js} +1 -1
  27. package/dist/assets/{ShareTeamDialog-E7_x3dOd.js → ShareTeamDialog-lgrszRmR.js} +1 -1
  28. package/dist/assets/{SignedInSites-tgZ-kFN4.js → SignedInSites-CZ0n7vLp.js} +1 -1
  29. package/dist/assets/{TeamLibraryPanel-DA7R6knC.js → TeamLibraryPanel-C4-iBK0f.js} +1 -1
  30. package/dist/assets/{TeamMapPage-CrEl0669.js → TeamMapPage-Bj61D2B3.js} +1 -1
  31. package/dist/assets/{TriggersPage-DoApzhWG.js → TriggersPage-ByPFvYfu.js} +1 -1
  32. package/dist/assets/{VisibilitySection-ChKxjJ5C.js → VisibilitySection-DoYze3-2.js} +1 -1
  33. package/dist/assets/{WebhookTrigger-B_VHQtPd.js → WebhookTrigger-B2um3gdH.js} +1 -1
  34. package/dist/assets/{WorksOnGrid-CBZxKyOV.js → WorksOnGrid-BHChAxnC.js} +1 -1
  35. package/dist/assets/{core-DXs_9m1L.js → core-9eGd8K9v.js} +1 -1
  36. package/dist/assets/{import-name-DviM_E6k.js → import-name-DoP5S_PW.js} +1 -1
  37. package/dist/assets/{index-kl2U4CdS.js → index-Cmy63UPX.js} +1 -1
  38. package/dist/assets/{index-Bh1qTRXw.js → index-DAHkvjY_.js} +2 -2
  39. package/dist/assets/{new-bot-78Wk4hfY.js → new-bot-C-8Y9Kzd.js} +1 -1
  40. package/dist/assets/{org-library-tkloWFxW.js → org-library-DBxhMG4q.js} +1 -1
  41. package/dist/assets/{package-format-nQAkOC1F.js → package-format-B8QbigkU.js} +1 -1
  42. package/dist/assets/{remote-desktop-panel-ByE5Ghzy.js → remote-desktop-panel-WDJu4EfU.js} +1 -1
  43. package/dist/index.html +1 -1
  44. package/dist-server/index.js +2495 -2482
  45. package/dist-server/package.json +1 -1
  46. package/dist-server/server/index.js +2 -1
  47. package/dist-server/server/working-drive-import.js +196 -0
  48. package/dist-server/server/working-folders.js +12 -3
  49. package/package.json +1 -1
@@ -1 +1 @@
1
- import{t as s,r as l,b as De,j as e,X as we,d as Oe,a as te,ai as je,aj as Me,v as Ue,w as Fe,ak as ze,al as Ie,am as Ke,m as ke,l as H,an as _e,ao as $e,ap as qe,aq as He,ar as Je,p as ce,H as Ye}from"./styles-DnkNzLDs.js";import{j as C,D as Ve,u as S,bX as se,bY as We,a1 as v,S as R,bZ as Xe,b_ as Se,b$ as ne,c0 as Ge,c1 as Ze,c2 as Qe,c3 as et,c4 as de,c5 as ue,c6 as tt,c7 as st,c8 as nt,c9 as Ne,w as D,ca as at,cb as it,cc as rt,cd as lt,b as Ce,ce as pe,cf as ot,cg as ct,ch as dt,ci as ut,cj as pt,ck as mt,cl as xt,cm as gt,cn as ht,co as ft,cp as bt,cq as vt,cr as me,cs as yt,ct as wt,cu as jt,cv as kt,cw as Ee,bL as ee,cx as St,cy as Nt,cz as Ct,cA as Et,cB as Bt,cC as xe,T as Be,cD as Rt}from"./App-B6W9JFXZ.js";import{B as ge,E as Pt,s as At,r as he,p as Tt,c as Lt,a as Dt}from"./new-bot-78Wk4hfY.js";import{o as Ot}from"./index-Bh1qTRXw.js";import{I as Mt,S as Ut,a as Ft,A as zt,M as It,P as Kt,V as _t,v as $t,i as fe}from"./VisibilitySection-ChKxjJ5C.js";import{R as qt}from"./RoutinesPage-CFb9pR_B.js";import{r as Ht,L as W,Q as Jt,R as Yt,U as Vt,P as Wt}from"./PlacesRail-fw4FbMbq.js";import{p as Xt,d as Gt,e as Zt,f as Qt}from"./team-share-DwBBsedz.js";import{B as es}from"./BrowserProfilesManager-48HNAHJm.js";function ts(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 ss(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 ns(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 as(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 is(t){return{id:t.id,skills:t.skills.map(n=>n.name),notes:[...t.notes]}}function be(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 ve({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=>Gt(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:Zt(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 rs({onClose:t}){const n=l.useRef(null),[a,i]=l.useState(""),[r,d]=l.useState(""),[c,p]=l.useState(""),[o,h]=l.useState(""),[y,O]=l.useState(!0),[w,x]=l.useState(!0),[g,P]=l.useState(null),[b,A]=l.useState(null),[f,T]=l.useState(!1),[M,X]=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 Xt([{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")} — ${De(`teamShare.skip.${L.reason}`,L.reason)}`)})}).catch(()=>{u||P({skipped:[]})}),()=>{u=!0}},[]);const $=u=>({name:a,description:r,release:c,notes:o,includeNotes:y,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(be({...$(!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,y,w]);const G=async()=>{if(!f){T(!0),F("");try{const u=await C("/api/teams/export",{method:"POST",body:JSON.stringify(be($(!1)))});Qt(u.filename,u.document),X(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 Ht.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(we,{size:18})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:M?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"flex items-center gap-2 text-[14px] font-medium text-ink",children:[e.jsx(Oe,{size:16,className:"text-success"}),s("teamShare.saved",{filename:M.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(ve,{preview:M,localSkips:z})})]}):e.jsxs(e.Fragment,{children:[b?e.jsx(ve,{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=>x(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:y,onChange:u=>O(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:M?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:()=>{G()},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 ae(){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 Ts(){const{state:t}=S(),n=se(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}=ae();return e.jsx(v,{title:s("settings.experimental.browserAria"),subtitle:a?n?s("settings.experimental.browserOn"):s("settings.experimental.browserOff"):r?s("settings.experimental.browserWindows"):Xe(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 Ls(){const{state:t}=S(),n=Se(),a=t.config?.browserEngine?.serverSites,{saving:i,error:r,save:d}=ae();return a===void 0||n!==!0||!se(t.config)?null:e.jsx(v,{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 ls(){const{state:t}=S(),n=t.config?.browserEngine?.engine==="chrome",{saving:a,error:i,save:r}=ae();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 os(){const{state:t,dispatch:n}=S(),a=ne(t.config),i=Ge(t.config),r=Ze(t.config),d=Qe(t.config),c=et(t.bots,t.instances),[p,o]=l.useState(String(d)),[h,y]=l.useState(!1),[O,w]=l.useState(!1),[x,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=tt(p);if(f===null){g(s("settings.experimental.skillReviewStepsRange",{min:ue,max:de}));return}await b({skillReviewSteps:f})&&y(!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:O||!a,onClick:()=>{b({skillReview:!i})},className:"disabled:cursor-not-allowed disabled:opacity-50"})]}),e.jsx(cs,{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:O,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 ${x?"border-danger/60":"border-hairline/40 focus-within:border-focus"}`,children:e.jsx("input",{id:"skill-review-steps",type:"number",min:ue,max:de,step:1,inputMode:"numeric",value:p,disabled:O,"aria-invalid":!!x,onChange:f=>{o(f.target.value),y(!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,x?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:x}):null]})}function cs({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 ds=[{value:"off",label:"settings.experimental.shareSkillsOff"},{value:"ask",label:"settings.experimental.shareSkillsAsk"},{value:"auto",label:"settings.experimental.shareSkillsAuto"}];function us(){const{state:t,dispatch:n}=S(),[a,i]=l.useState(!1),[r,d]=l.useState("");if(!st(t.config))return null;const c=ne(t.config),p=nt(t.config),o=async h=>{if(!(a||h===p)){i(!0),d("");try{const y=await C("/api/config",{method:"PATCH",body:JSON.stringify({features:{shareLearnedSkills:h}})});n({type:"configStatus",config:y})}catch(y){d(y instanceof Error?y.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:ds.map(h=>e.jsx("button",{type:"button",role:"radio","aria-checked":p===h.value,disabled:a||!c,onClick:()=>{o(h.value)},className:te("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 ps(){return e.jsxs(e.Fragment,{children:[e.jsx(os,{}),e.jsx(us,{})]})}function Ds({title:t=s("settings.updates.title")}){const n=vt(),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:ce(),version:n.version??""}):s("settings.updates.ready",{app:ce(),version:n.version??""}):n.status==="installing"?me(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:me(n)??s("settings.updates.unknownError")}):s("settings.updates.latest");return e.jsx(v,{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 Re(){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:kt(o)?o:null}})});n({type:"configStatus",config:h})}catch(h){c(h instanceof Error?h.message:s("settings.newBotEffort.error"))}finally{r(!1)}}}}}function Pe({effort:t,className:n}){return e.jsxs(D,{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")}),yt.map(a=>e.jsx("option",{value:a,children:wt(a)},a))]})}function Os(){const t=Re();return e.jsx(v,{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(Pe,{effort:t,className:"w-full max-w-[240px]"})})}function ms({onEdit:t,onShare:n}){const a=Re();return e.jsx(v,{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(Pe,{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 xs(){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?{}:Jt().onboarding,hintsSeen:jt(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 Ms(){const{dispatch:t}=S();return e.jsx(v,{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(xs,{}),e.jsx("button",{onClick:()=>t({type:"toggleWelcome",open:!0}),className:"ui-button",children:s("settings.welcome.replay")})]})})}function Us({simple:t=!1}){const{state:n}=S(),a=Ue(Fe(),n.config?.language);return e.jsx(v,{title:s("settings.language.title"),subtitle:Ke()?s("settings.language.subtitleComplete"):t?ke()==="en"?void 0:s("settings.simple.language.partial"):s("settings.language.subtitle"),children:e.jsxs(D,{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=>Ie(i.target.value),children:[e.jsx("option",{value:"",children:s(t?"settings.simple.language.system":"settings.language.system")}),ze.map(({code:i,label:r})=>e.jsx("option",{value:i,children:r},i))]})})}function Fs(){const t=rt(),n=H("Gợi ý tin nhắn tiếp theo","Next-message suggestions");return e.jsx(v,{title:n,subtitle:H("Chế độ tự động có thể dùng lượt gọi mô hình của bot trên cuộc trò chuyện hiện tại.","Automatic mode can use an extra model call for the current conversation."),children:e.jsxs(D,{size:"sm",value:t,"aria-label":n,onChange:a=>lt(a.target.value),children:[e.jsx("option",{value:"auto",children:H("Tự động","Automatic")}),e.jsx("option",{value:"local",children:H("Chỉ dùng quy tắc cục bộ","Local rules only")}),e.jsx("option",{value:"off",children:H("Tắt","Off")})]})})}function zs({simple:t=!1}){const n=Ce();return e.jsx(v,{title:s("settings.sendKey.title"),subtitle:s(t?"settings.simple.sendKey":"settings.sendKey.subtitle",{key:pe("mod-enter")}),children:e.jsx(D,{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=>ot(ct(a.target.value)),children:_e.map(a=>e.jsx("option",{value:a,children:pe(a)},a))})})}function Is({simple:t=!1}){const n=dt(),a=ut(Ce());return e.jsx(v,{title:s("settings.followUp.title"),subtitle:s(t?"settings.simple.followUp":"settings.followUp.subtitle",{key:a}),children:e.jsxs(D,{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=>pt(mt(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 Ks({simple:t=!1}){const n=at();return e.jsx(v,{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:()=>it(!n)})})}function _s({simple:t=!1}){const n=je();return e.jsx(v,{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:()=>Me(!n)})})}function $s(){const t=$e();return e.jsx(v,{title:s("settings.threadDisplay.title"),subtitle:s("settings.threadDisplay.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.threadDisplay.show"),onClick:()=>qe(!t)})})}function qs(){const t=xt();return e.jsx(v,{title:s("settings.pinnedCircles.title"),subtitle:s("settings.pinnedCircles.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.pinnedCircles.title"),onClick:()=>gt(!t)})})}function Hs(){const t=He();return e.jsx(v,{title:s("settings.runCard.title"),subtitle:s("settings.runCard.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.runCard.show"),onClick:()=>Je(!t)})})}function Js(){const t=ht();return e.jsx(v,{title:s("settings.universalPins.title"),subtitle:s("settings.universalPins.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.universalPins.title"),onClick:()=>ft(!t)})})}function Ys(){const{state:t,dispatch:n}=S(),a=bt(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(v,{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 Vs(){const{state:t,dispatch:n}=S(),a=ne(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(Ne,{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(ps,{}),e.jsx(ls,{})]})}function Ws(){const{state:t}=S(),n=t.config?.browserProfiles??[];return!se(t.config)&&n.length===0?null:e.jsx(Ne,{title:s("settings.profiles.title"),subtitle:s("settings.profiles.sharedSubtitle"),children:e.jsx(es,{})})}const ye=["Identity","Soul","Skills","Memory","Routines","Access","Model","Permissions","Voice & alerts"],gs={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 Ae(t){return e.jsx(Yt,{modal:!0,children:e.jsx(hs,{...t})})}function hs({defaultsMode:t=!1,onClose:n,onCreated:a,readyBotId:i,readyBotData:r}){const d=Vt(),c=S(),[,p]=l.useState(0),[o,h]=l.useState(()=>new ge(Pt,()=>p(m=>m+1))),[y,O]=l.useState("Identity"),[w,x]=l.useState(!1),[g,P]=l.useState(!1),b=g||c.state.botCreationPending,A=l.useRef(!1),f=l.useRef(!0),[T,M]=l.useState(""),[X,I]=l.useState(null),[F,_]=l.useState("everyone"),[$,G]=l.useState(""),z=Ee(),K=c.state.config?.team?.name,[u,E]=l.useState(null),N=Se(),L=Ye(),Te=je()?ye:ye.filter(m=>m!=="Model"),ie=!t&&typeof window<"u"&&!window.ogb&&N===!0,J=l.useRef(null),q=l.useRef(n);q.current=n,l.useEffect(()=>{let m=!1;return C("/api/bot-defaults").then(B=>{if(m)return;const j=At(B,!t),k=t?void 0:r??(i?ee(i):void 0),U=new ge(k?St(j,k,ke()):j,()=>p(V=>V+1));k&&ee(k.id)&&(U.role=k.id),h(U),x(!0)}).catch(B=>{m||M(String(B))}),()=>{m=!0}},[t,i,r]),l.useEffect(()=>(f.current=!0,()=>{f.current=!1}),[]),l.useEffect(()=>()=>o.dispose(),[o]),l.useEffect(()=>{b&&J.current?.focus()},[b]),l.useEffect(()=>{const m=document.activeElement instanceof HTMLElement?document.activeElement:null;J.current?.focus();const B=j=>{if(!d())return;const k=J.current;if(!k||j.target instanceof Node&&!k.contains(j.target))return;const U=k.querySelector('[role="dialog"], [role="alertdialog"]');if(U&&U.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(oe=>oe.getClientRects().length&&!oe.closest("[hidden],fieldset:disabled")),Z=V[0],Q=V.at(-1);if(!Z||!Q){j.preventDefault(),k.focus();return}j.shiftKey&&(document.activeElement===Z||document.activeElement===k)?(j.preventDefault(),Q.focus()):!j.shiftKey&&(document.activeElement===Q||document.activeElement===k)&&(j.preventDefault(),Z.focus())};return window.addEventListener("keydown",B),()=>{window.removeEventListener("keydown",B),m?.isConnected&&m.focus()}},[d]);const re=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 m=ie?$t(F,$):null;if(m&&!m.ok){M(s("botSettings.visibility.needPeople"));return}A.current=!0,P(!0),M(""),c.dispatch({type:"botCreationPending",on:!0});try{if(t)await C("/api/config",{method:"PATCH",body:JSON.stringify({newBotDefaults:await Tt(o)})});else{const{bot:B,warnings:j,paused:k}=await Lt(o,void 0,void 0,void 0,m?.ok?m.visibility:void 0,z?he(u,o.bot.section,c.state.bots,z)??void 0:void 0);Dt(c.dispatch,B,j,{showThreads:L,source:o.preset?"preset":o.role?"template":"blank",role:o.role,paused:k});try{await a?.(B)}catch(U){c.dispatch({type:"error",message:U instanceof Error?U.message:String(U)})}}A.current=!1,f.current&&q.current()}catch(B){f.current&&M(B instanceof Error?B.message:String(B))}finally{A.current=!1,c.dispatch({type:"botCreationPending",on:!1}),f.current&&P(!1)}},Y=o.bot,Le={...c,state:{...c.state,bots:[Y,...c.state.bots],routines:o.routines,routineRuns:[],routinesLoadState:"ready"},flushBotPatches:async()=>Y,dispatch:m=>{m.type==="updateBot"&&m.botId===o.id?o.patch(m.patch):m.type==="setModel"&&m.botId===o.id?(o.setModel(m.selection),m.resetApprovalToAsk&&o.patch({approvalMode:"ask"})):m.type==="routinePatched"||m.type==="toggleSettings"||c.dispatch(m)}},le=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:J,role:"dialog","aria-modal":"true","aria-label":le,"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:le}),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(we,{size:18,className:"pointer-events-none"})})]}),z&&!t&&K&&e.jsx(fs,{team:K}),ie&&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(D,{size:"sm",value:F,disabled:b,onChange:m=>_(m.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:m=>G(m.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:Te.map(m=>e.jsx("button",{type:"button",onClick:()=>O(m),"aria-current":y===m?"page":void 0,className:te("shrink-0 rounded-lg px-3 py-2 text-left text-[13px]",y===m?"bg-control text-ink":"text-ink-secondary hover:bg-control/50"),children:s(gs[m])},m))}),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(Nt,{value:Le,children:e.jsx(Ct.Provider,{value:{request:o.request,draft:!0,uploadAvatar:o.uploadAvatar},children:e.jsx(bs,{active:y,draft:o,defaultsMode:t,owner:z&&!t?{value:he(u,Y.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&&!Y.name.trim(),onClick:()=>{re()},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(Et,{open:X==="local",onCancel:()=>I(null),onConfirm:()=>{o.consent.acknowledgeLocalAuto=!0,I(null),re()}})]})})}function fs({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:()=>{Ot(n).catch(()=>{})},className:"font-medium text-accent hover:underline",children:s("newBot.justForYou")}):e.jsx("span",{children:s("newBot.justForYou").replace(/\s*→$/,"")})]})}function bs({active:t,draft:n,defaultsMode:a,owner:i}){const r=n.bot,{state:d}=S(),c=Ee(),p=Bt(r);return t==="Identity"?e.jsxs("div",{className:"space-y-4",children:[e.jsx(vs,{draft:n,defaultsMode:a}),e.jsx(Mt,{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(D,{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(D,{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(Ut,{bot:r,patch:p.patch}):t==="Skills"?e.jsx(Ft,{bot:r}):t==="Memory"?e.jsx(ys,{draft:n}):t==="Routines"?e.jsx(ws,{draft:n}):t==="Access"?e.jsx(zt,{bot:r,derived:p}):t==="Model"?e.jsx(It,{bot:r}):t==="Permissions"?e.jsx(Kt,{bot:r,derived:p}):e.jsx(_t,{bot:r,derived:p})}function vs({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 x=!1;return C("/api/bot-presets").then(g=>{x||i(g.presets)}).catch(()=>{x||i([])}),()=>{x=!0}},[n,r]);const h=t.preset?a.find(x=>x.id===t.preset.id):void 0,y=async x=>{p("");const g=x.startsWith("preset:")?a.find(b=>b.id===x.slice(7)):void 0;if(!g){t.choosePreset(void 0);const b=xe.find(f=>f.id===x);t.chooseRole(b?.id);const A=b&&ee(b.id)?.look;b&&t.patch({...Rt(b),...A});return}t.patch(ss(g)),t.choosePreset(is(g));const P=ns(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))}},O=async x=>{p("");try{await C(`/api/bot-presets/${encodeURIComponent(x.id)}`,{method:"DELETE"}),t.preset?.id===x.id&&t.choosePreset(void 0),d(g=>g+1)}catch(g){p(g instanceof Error?g.message:String(g))}},w=xe.map(x=>e.jsx("option",{value:x.id,children:x.title},x.id));return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("newBot.startingRole"),e.jsxs(D,{size:"lg",className:"mt-1.5 w-full",value:t.preset?`preset:${t.preset.id}`:"",onChange:x=>{y(x.target.value)},children:[e.jsx("option",{value:"",children:s("newBot.customSettings")}),ts(a).map(x=>e.jsx("optgroup",{label:x.label,children:x.presets.map(g=>e.jsx("option",{value:`preset:${g.id}`,children:g.name},g.id))},x.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:[as(h).map((x,g)=>e.jsx("p",{className:"break-words",children:x},g)),h.source==="file"&&e.jsx("button",{type:"button",onClick:()=>{O(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 ys({draft:t}){const[n,a]=l.useState("MEMORY.md"),[i,r]=l.useState("");return e.jsxs("div",{className:"space-y-3",children:[e.jsx(D,{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:te(fe,"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:fe,"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(Wt,{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(Be,{size:16})})]})]})}function ws({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(Be,{size:15})})]},i.id)),n&&e.jsx(qt,{routine:n==="new"?void 0:n,bots:[t.bot],lockedBotId:t.id,onClose:()=>a(null)})]})}function js({simple:t=!1}){const[n,a]=l.useState(!1),[i,r]=l.useState(!1),d=e.jsxs(e.Fragment,{children:[n&&e.jsx(Ae,{defaultsMode:!0,onClose:()=>a(!1)}),i&&e.jsx(rs,{onClose:()=>r(!1)})]});if(t)return e.jsxs(e.Fragment,{children:[e.jsx(ms,{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(v,{title:s("newBot.defaults"),children:c})}const Xs=Object.freeze(Object.defineProperty({__proto__:null,DefaultBotSettings:js,NewBotDialog:Ae},Symbol.toStringTag,{value:"Module"}));export{_s as A,Ts as B,Ks as C,js as D,Vs as E,Is as F,Us as L,Os as N,qs as P,Ms as R,Ls as S,Ys as T,Ds as U,Ws as a,Fs as b,zs as c,$s as d,Js as e,Hs as f,Xs as g};
1
+ import{t as s,r as l,b as De,j as e,X as we,d as Oe,a as te,ai as je,aj as Me,v as Ue,w as Fe,ak as ze,al as Ie,am as Ke,m as ke,l as H,an as _e,ao as $e,ap as qe,aq as He,ar as Je,p as ce,H as Ye}from"./styles-DnkNzLDs.js";import{j as C,D as Ve,u as S,bX as se,bY as We,a1 as v,S as R,bZ as Xe,b_ as Se,b$ as ne,c0 as Ge,c1 as Ze,c2 as Qe,c3 as et,c4 as de,c5 as ue,c6 as tt,c7 as st,c8 as nt,c9 as Ne,w as D,ca as at,cb as it,cc as rt,cd as lt,b as Ce,ce as pe,cf as ot,cg as ct,ch as dt,ci as ut,cj as pt,ck as mt,cl as xt,cm as gt,cn as ht,co as ft,cp as bt,cq as vt,cr as me,cs as yt,ct as wt,cu as jt,cv as kt,cw as Ee,bL as ee,cx as St,cy as Nt,cz as Ct,cA as Et,cB as Bt,cC as xe,T as Be,cD as Rt}from"./App-DbfRrJPA.js";import{B as ge,E as Pt,s as At,r as he,p as Tt,c as Lt,a as Dt}from"./new-bot-C-8Y9Kzd.js";import{o as Ot}from"./index-DAHkvjY_.js";import{I as Mt,S as Ut,a as Ft,A as zt,M as It,P as Kt,V as _t,v as $t,i as fe}from"./VisibilitySection-DoYze3-2.js";import{R as qt}from"./RoutinesPage-BcixjsUv.js";import{r as Ht,L as W,Q as Jt,R as Yt,U as Vt,P as Wt}from"./PlacesRail-fw4FbMbq.js";import{p as Xt,d as Gt,e as Zt,f as Qt}from"./team-share-DwBBsedz.js";import{B as es}from"./BrowserProfilesManager-BiDKQm59.js";function ts(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 ss(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 ns(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 as(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 is(t){return{id:t.id,skills:t.skills.map(n=>n.name),notes:[...t.notes]}}function be(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 ve({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=>Gt(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:Zt(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 rs({onClose:t}){const n=l.useRef(null),[a,i]=l.useState(""),[r,d]=l.useState(""),[c,p]=l.useState(""),[o,h]=l.useState(""),[y,O]=l.useState(!0),[w,x]=l.useState(!0),[g,P]=l.useState(null),[b,A]=l.useState(null),[f,T]=l.useState(!1),[M,X]=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 Xt([{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")} — ${De(`teamShare.skip.${L.reason}`,L.reason)}`)})}).catch(()=>{u||P({skipped:[]})}),()=>{u=!0}},[]);const $=u=>({name:a,description:r,release:c,notes:o,includeNotes:y,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(be({...$(!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,y,w]);const G=async()=>{if(!f){T(!0),F("");try{const u=await C("/api/teams/export",{method:"POST",body:JSON.stringify(be($(!1)))});Qt(u.filename,u.document),X(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 Ht.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(we,{size:18})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:M?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"flex items-center gap-2 text-[14px] font-medium text-ink",children:[e.jsx(Oe,{size:16,className:"text-success"}),s("teamShare.saved",{filename:M.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(ve,{preview:M,localSkips:z})})]}):e.jsxs(e.Fragment,{children:[b?e.jsx(ve,{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=>x(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:y,onChange:u=>O(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:M?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:()=>{G()},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 ae(){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 Ts(){const{state:t}=S(),n=se(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}=ae();return e.jsx(v,{title:s("settings.experimental.browserAria"),subtitle:a?n?s("settings.experimental.browserOn"):s("settings.experimental.browserOff"):r?s("settings.experimental.browserWindows"):Xe(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 Ls(){const{state:t}=S(),n=Se(),a=t.config?.browserEngine?.serverSites,{saving:i,error:r,save:d}=ae();return a===void 0||n!==!0||!se(t.config)?null:e.jsx(v,{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 ls(){const{state:t}=S(),n=t.config?.browserEngine?.engine==="chrome",{saving:a,error:i,save:r}=ae();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 os(){const{state:t,dispatch:n}=S(),a=ne(t.config),i=Ge(t.config),r=Ze(t.config),d=Qe(t.config),c=et(t.bots,t.instances),[p,o]=l.useState(String(d)),[h,y]=l.useState(!1),[O,w]=l.useState(!1),[x,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=tt(p);if(f===null){g(s("settings.experimental.skillReviewStepsRange",{min:ue,max:de}));return}await b({skillReviewSteps:f})&&y(!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:O||!a,onClick:()=>{b({skillReview:!i})},className:"disabled:cursor-not-allowed disabled:opacity-50"})]}),e.jsx(cs,{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:O,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 ${x?"border-danger/60":"border-hairline/40 focus-within:border-focus"}`,children:e.jsx("input",{id:"skill-review-steps",type:"number",min:ue,max:de,step:1,inputMode:"numeric",value:p,disabled:O,"aria-invalid":!!x,onChange:f=>{o(f.target.value),y(!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,x?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:x}):null]})}function cs({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 ds=[{value:"off",label:"settings.experimental.shareSkillsOff"},{value:"ask",label:"settings.experimental.shareSkillsAsk"},{value:"auto",label:"settings.experimental.shareSkillsAuto"}];function us(){const{state:t,dispatch:n}=S(),[a,i]=l.useState(!1),[r,d]=l.useState("");if(!st(t.config))return null;const c=ne(t.config),p=nt(t.config),o=async h=>{if(!(a||h===p)){i(!0),d("");try{const y=await C("/api/config",{method:"PATCH",body:JSON.stringify({features:{shareLearnedSkills:h}})});n({type:"configStatus",config:y})}catch(y){d(y instanceof Error?y.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:ds.map(h=>e.jsx("button",{type:"button",role:"radio","aria-checked":p===h.value,disabled:a||!c,onClick:()=>{o(h.value)},className:te("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 ps(){return e.jsxs(e.Fragment,{children:[e.jsx(os,{}),e.jsx(us,{})]})}function Ds({title:t=s("settings.updates.title")}){const n=vt(),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:ce(),version:n.version??""}):s("settings.updates.ready",{app:ce(),version:n.version??""}):n.status==="installing"?me(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:me(n)??s("settings.updates.unknownError")}):s("settings.updates.latest");return e.jsx(v,{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 Re(){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:kt(o)?o:null}})});n({type:"configStatus",config:h})}catch(h){c(h instanceof Error?h.message:s("settings.newBotEffort.error"))}finally{r(!1)}}}}}function Pe({effort:t,className:n}){return e.jsxs(D,{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")}),yt.map(a=>e.jsx("option",{value:a,children:wt(a)},a))]})}function Os(){const t=Re();return e.jsx(v,{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(Pe,{effort:t,className:"w-full max-w-[240px]"})})}function ms({onEdit:t,onShare:n}){const a=Re();return e.jsx(v,{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(Pe,{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 xs(){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?{}:Jt().onboarding,hintsSeen:jt(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 Ms(){const{dispatch:t}=S();return e.jsx(v,{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(xs,{}),e.jsx("button",{onClick:()=>t({type:"toggleWelcome",open:!0}),className:"ui-button",children:s("settings.welcome.replay")})]})})}function Us({simple:t=!1}){const{state:n}=S(),a=Ue(Fe(),n.config?.language);return e.jsx(v,{title:s("settings.language.title"),subtitle:Ke()?s("settings.language.subtitleComplete"):t?ke()==="en"?void 0:s("settings.simple.language.partial"):s("settings.language.subtitle"),children:e.jsxs(D,{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=>Ie(i.target.value),children:[e.jsx("option",{value:"",children:s(t?"settings.simple.language.system":"settings.language.system")}),ze.map(({code:i,label:r})=>e.jsx("option",{value:i,children:r},i))]})})}function Fs(){const t=rt(),n=H("Gợi ý tin nhắn tiếp theo","Next-message suggestions");return e.jsx(v,{title:n,subtitle:H("Chế độ tự động có thể dùng lượt gọi mô hình của bot trên cuộc trò chuyện hiện tại.","Automatic mode can use an extra model call for the current conversation."),children:e.jsxs(D,{size:"sm",value:t,"aria-label":n,onChange:a=>lt(a.target.value),children:[e.jsx("option",{value:"auto",children:H("Tự động","Automatic")}),e.jsx("option",{value:"local",children:H("Chỉ dùng quy tắc cục bộ","Local rules only")}),e.jsx("option",{value:"off",children:H("Tắt","Off")})]})})}function zs({simple:t=!1}){const n=Ce();return e.jsx(v,{title:s("settings.sendKey.title"),subtitle:s(t?"settings.simple.sendKey":"settings.sendKey.subtitle",{key:pe("mod-enter")}),children:e.jsx(D,{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=>ot(ct(a.target.value)),children:_e.map(a=>e.jsx("option",{value:a,children:pe(a)},a))})})}function Is({simple:t=!1}){const n=dt(),a=ut(Ce());return e.jsx(v,{title:s("settings.followUp.title"),subtitle:s(t?"settings.simple.followUp":"settings.followUp.subtitle",{key:a}),children:e.jsxs(D,{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=>pt(mt(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 Ks({simple:t=!1}){const n=at();return e.jsx(v,{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:()=>it(!n)})})}function _s({simple:t=!1}){const n=je();return e.jsx(v,{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:()=>Me(!n)})})}function $s(){const t=$e();return e.jsx(v,{title:s("settings.threadDisplay.title"),subtitle:s("settings.threadDisplay.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.threadDisplay.show"),onClick:()=>qe(!t)})})}function qs(){const t=xt();return e.jsx(v,{title:s("settings.pinnedCircles.title"),subtitle:s("settings.pinnedCircles.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.pinnedCircles.title"),onClick:()=>gt(!t)})})}function Hs(){const t=He();return e.jsx(v,{title:s("settings.runCard.title"),subtitle:s("settings.runCard.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.runCard.show"),onClick:()=>Je(!t)})})}function Js(){const t=ht();return e.jsx(v,{title:s("settings.universalPins.title"),subtitle:s("settings.universalPins.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.universalPins.title"),onClick:()=>ft(!t)})})}function Ys(){const{state:t,dispatch:n}=S(),a=bt(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(v,{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 Vs(){const{state:t,dispatch:n}=S(),a=ne(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(Ne,{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(ps,{}),e.jsx(ls,{})]})}function Ws(){const{state:t}=S(),n=t.config?.browserProfiles??[];return!se(t.config)&&n.length===0?null:e.jsx(Ne,{title:s("settings.profiles.title"),subtitle:s("settings.profiles.sharedSubtitle"),children:e.jsx(es,{})})}const ye=["Identity","Soul","Skills","Memory","Routines","Access","Model","Permissions","Voice & alerts"],gs={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 Ae(t){return e.jsx(Yt,{modal:!0,children:e.jsx(hs,{...t})})}function hs({defaultsMode:t=!1,onClose:n,onCreated:a,readyBotId:i,readyBotData:r}){const d=Vt(),c=S(),[,p]=l.useState(0),[o,h]=l.useState(()=>new ge(Pt,()=>p(m=>m+1))),[y,O]=l.useState("Identity"),[w,x]=l.useState(!1),[g,P]=l.useState(!1),b=g||c.state.botCreationPending,A=l.useRef(!1),f=l.useRef(!0),[T,M]=l.useState(""),[X,I]=l.useState(null),[F,_]=l.useState("everyone"),[$,G]=l.useState(""),z=Ee(),K=c.state.config?.team?.name,[u,E]=l.useState(null),N=Se(),L=Ye(),Te=je()?ye:ye.filter(m=>m!=="Model"),ie=!t&&typeof window<"u"&&!window.ogb&&N===!0,J=l.useRef(null),q=l.useRef(n);q.current=n,l.useEffect(()=>{let m=!1;return C("/api/bot-defaults").then(B=>{if(m)return;const j=At(B,!t),k=t?void 0:r??(i?ee(i):void 0),U=new ge(k?St(j,k,ke()):j,()=>p(V=>V+1));k&&ee(k.id)&&(U.role=k.id),h(U),x(!0)}).catch(B=>{m||M(String(B))}),()=>{m=!0}},[t,i,r]),l.useEffect(()=>(f.current=!0,()=>{f.current=!1}),[]),l.useEffect(()=>()=>o.dispose(),[o]),l.useEffect(()=>{b&&J.current?.focus()},[b]),l.useEffect(()=>{const m=document.activeElement instanceof HTMLElement?document.activeElement:null;J.current?.focus();const B=j=>{if(!d())return;const k=J.current;if(!k||j.target instanceof Node&&!k.contains(j.target))return;const U=k.querySelector('[role="dialog"], [role="alertdialog"]');if(U&&U.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(oe=>oe.getClientRects().length&&!oe.closest("[hidden],fieldset:disabled")),Z=V[0],Q=V.at(-1);if(!Z||!Q){j.preventDefault(),k.focus();return}j.shiftKey&&(document.activeElement===Z||document.activeElement===k)?(j.preventDefault(),Q.focus()):!j.shiftKey&&(document.activeElement===Q||document.activeElement===k)&&(j.preventDefault(),Z.focus())};return window.addEventListener("keydown",B),()=>{window.removeEventListener("keydown",B),m?.isConnected&&m.focus()}},[d]);const re=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 m=ie?$t(F,$):null;if(m&&!m.ok){M(s("botSettings.visibility.needPeople"));return}A.current=!0,P(!0),M(""),c.dispatch({type:"botCreationPending",on:!0});try{if(t)await C("/api/config",{method:"PATCH",body:JSON.stringify({newBotDefaults:await Tt(o)})});else{const{bot:B,warnings:j,paused:k}=await Lt(o,void 0,void 0,void 0,m?.ok?m.visibility:void 0,z?he(u,o.bot.section,c.state.bots,z)??void 0:void 0);Dt(c.dispatch,B,j,{showThreads:L,source:o.preset?"preset":o.role?"template":"blank",role:o.role,paused:k});try{await a?.(B)}catch(U){c.dispatch({type:"error",message:U instanceof Error?U.message:String(U)})}}A.current=!1,f.current&&q.current()}catch(B){f.current&&M(B instanceof Error?B.message:String(B))}finally{A.current=!1,c.dispatch({type:"botCreationPending",on:!1}),f.current&&P(!1)}},Y=o.bot,Le={...c,state:{...c.state,bots:[Y,...c.state.bots],routines:o.routines,routineRuns:[],routinesLoadState:"ready"},flushBotPatches:async()=>Y,dispatch:m=>{m.type==="updateBot"&&m.botId===o.id?o.patch(m.patch):m.type==="setModel"&&m.botId===o.id?(o.setModel(m.selection),m.resetApprovalToAsk&&o.patch({approvalMode:"ask"})):m.type==="routinePatched"||m.type==="toggleSettings"||c.dispatch(m)}},le=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:J,role:"dialog","aria-modal":"true","aria-label":le,"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:le}),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(we,{size:18,className:"pointer-events-none"})})]}),z&&!t&&K&&e.jsx(fs,{team:K}),ie&&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(D,{size:"sm",value:F,disabled:b,onChange:m=>_(m.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:m=>G(m.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:Te.map(m=>e.jsx("button",{type:"button",onClick:()=>O(m),"aria-current":y===m?"page":void 0,className:te("shrink-0 rounded-lg px-3 py-2 text-left text-[13px]",y===m?"bg-control text-ink":"text-ink-secondary hover:bg-control/50"),children:s(gs[m])},m))}),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(Nt,{value:Le,children:e.jsx(Ct.Provider,{value:{request:o.request,draft:!0,uploadAvatar:o.uploadAvatar},children:e.jsx(bs,{active:y,draft:o,defaultsMode:t,owner:z&&!t?{value:he(u,Y.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&&!Y.name.trim(),onClick:()=>{re()},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(Et,{open:X==="local",onCancel:()=>I(null),onConfirm:()=>{o.consent.acknowledgeLocalAuto=!0,I(null),re()}})]})})}function fs({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:()=>{Ot(n).catch(()=>{})},className:"font-medium text-accent hover:underline",children:s("newBot.justForYou")}):e.jsx("span",{children:s("newBot.justForYou").replace(/\s*→$/,"")})]})}function bs({active:t,draft:n,defaultsMode:a,owner:i}){const r=n.bot,{state:d}=S(),c=Ee(),p=Bt(r);return t==="Identity"?e.jsxs("div",{className:"space-y-4",children:[e.jsx(vs,{draft:n,defaultsMode:a}),e.jsx(Mt,{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(D,{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(D,{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(Ut,{bot:r,patch:p.patch}):t==="Skills"?e.jsx(Ft,{bot:r}):t==="Memory"?e.jsx(ys,{draft:n}):t==="Routines"?e.jsx(ws,{draft:n}):t==="Access"?e.jsx(zt,{bot:r,derived:p}):t==="Model"?e.jsx(It,{bot:r}):t==="Permissions"?e.jsx(Kt,{bot:r,derived:p}):e.jsx(_t,{bot:r,derived:p})}function vs({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 x=!1;return C("/api/bot-presets").then(g=>{x||i(g.presets)}).catch(()=>{x||i([])}),()=>{x=!0}},[n,r]);const h=t.preset?a.find(x=>x.id===t.preset.id):void 0,y=async x=>{p("");const g=x.startsWith("preset:")?a.find(b=>b.id===x.slice(7)):void 0;if(!g){t.choosePreset(void 0);const b=xe.find(f=>f.id===x);t.chooseRole(b?.id);const A=b&&ee(b.id)?.look;b&&t.patch({...Rt(b),...A});return}t.patch(ss(g)),t.choosePreset(is(g));const P=ns(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))}},O=async x=>{p("");try{await C(`/api/bot-presets/${encodeURIComponent(x.id)}`,{method:"DELETE"}),t.preset?.id===x.id&&t.choosePreset(void 0),d(g=>g+1)}catch(g){p(g instanceof Error?g.message:String(g))}},w=xe.map(x=>e.jsx("option",{value:x.id,children:x.title},x.id));return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("newBot.startingRole"),e.jsxs(D,{size:"lg",className:"mt-1.5 w-full",value:t.preset?`preset:${t.preset.id}`:"",onChange:x=>{y(x.target.value)},children:[e.jsx("option",{value:"",children:s("newBot.customSettings")}),ts(a).map(x=>e.jsx("optgroup",{label:x.label,children:x.presets.map(g=>e.jsx("option",{value:`preset:${g.id}`,children:g.name},g.id))},x.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:[as(h).map((x,g)=>e.jsx("p",{className:"break-words",children:x},g)),h.source==="file"&&e.jsx("button",{type:"button",onClick:()=>{O(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 ys({draft:t}){const[n,a]=l.useState("MEMORY.md"),[i,r]=l.useState("");return e.jsxs("div",{className:"space-y-3",children:[e.jsx(D,{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:te(fe,"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:fe,"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(Wt,{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(Be,{size:16})})]})]})}function ws({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(Be,{size:15})})]},i.id)),n&&e.jsx(qt,{routine:n==="new"?void 0:n,bots:[t.bot],lockedBotId:t.id,onClose:()=>a(null)})]})}function js({simple:t=!1}){const[n,a]=l.useState(!1),[i,r]=l.useState(!1),d=e.jsxs(e.Fragment,{children:[n&&e.jsx(Ae,{defaultsMode:!0,onClose:()=>a(!1)}),i&&e.jsx(rs,{onClose:()=>r(!1)})]});if(t)return e.jsxs(e.Fragment,{children:[e.jsx(ms,{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(v,{title:s("newBot.defaults"),children:c})}const Xs=Object.freeze(Object.defineProperty({__proto__:null,DefaultBotSettings:js,NewBotDialog:Ae},Symbol.toStringTag,{value:"Module"}));export{_s as A,Ts as B,Ks as C,js as D,Vs as E,Is as F,Us as L,Os as N,qs as P,Ms as R,Ls as S,Ys as T,Ds as U,Ws as a,Fs as b,zs as c,$s as d,Js as e,Hs as f,Xs as g};
@@ -1 +1 @@
1
- import{r as d,j as t,t as n}from"./styles-DnkNzLDs.js";import{r as c}from"./PlacesRail-fw4FbMbq.js";import{x,y as p,Q as m,z as u}from"./App-B6W9JFXZ.js";import"./monitor-D-rHzZVy.js";import"./index-Bh1qTRXw.js";import"./MenuMotion-xBTC4eOZ.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-DnkNzLDs.js";import{r as c}from"./PlacesRail-fw4FbMbq.js";import{x,y as p,Q as m,z as u}from"./App-DbfRrJPA.js";import"./monitor-D-rHzZVy.js";import"./index-DAHkvjY_.js";import"./MenuMotion-xBTC4eOZ.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 ts,af as ns,a as _,d as Xe,m as Pt,S as Ns,i as Vt}from"./styles-DnkNzLDs.js";import{S as pn,j as w,u as et,eE as As,eF as Cs,eG as Ss,eH as ht,w as Rs,eI as Es,eJ as zs,eK as Gt,l as Is,G as Rn,eL as Ts,eM as Os,cX as Bs,T as Ps,ag as en,bs as Ms,z as tn,eN as Et,eO as ss,eP as zt,eQ as as,am as is,eR as It,eS as Ls,eT as os,eU as Tt,eV as cs,eW as Us,eX as En,eY as $s,X as rs,eZ as Nt,e_ as Fs,e$ as Ks,f0 as Ds,f1 as Qs,f2 as Hs,f3 as ct,f4 as zn,f5 as _s,f6 as Js,f7 as At,f8 as Vs,f9 as Gs,fa as In,ej as Tn,fb as qs,fc as Zs,fd as Ws,fe as qt,ff as Xs,fg as Ys,fh as ea,fi as ta,fj as na,fk as sa,fl as aa,fm as ia,fn as oa,fo as ca,fp as ra}from"./App-B6W9JFXZ.js";import{L as ae,P as ls,X as la,a as da,v as mn,E as ua,_ as pa,$ as ma,B as ha}from"./PlacesRail-fw4FbMbq.js";import{C as ds,R as nn}from"./MenuMotion-xBTC4eOZ.js";import{u as xa}from"./ProIntroduction-BO5ABFTi.js";import"./index-Bh1qTRXw.js";import"./monitor-D-rHzZVy.js";const fa=[["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"}]],ga=un("phone-call",fa);const ba=[["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"}]],ya=un("radio-tower",ba);const ka=[["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"}]],Zt=un("server-cog",ka),ja=new Set(["twitter","x"]);function On(t,s){return t!=="managed"||!ja.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 va=5,wa=3,Ot=4;function Na(t,s=va,r=[]){const o=new Map;for(const g of t)for(const k of new Set(g.categories??[]))o.set(k,(o.get(k)??0)+1);const c=[...o].sort((g,k)=>k[1]-g[1]||g[0].localeCompare(k[0])).map(([g])=>g),l=r.filter(g=>c.indexOf(g)>=s),y=[...c.slice(0,Math.max(0,s-l.length)),...l];return{inline:y,more:c.filter(g=>!y.includes(g))}}function sn(t,s){return s===null||(t.categories??[]).includes(s)}function Aa(t,s,r){const o=[],c=t.filter(l=>s(l.slug));c.length&&o.push({kind:"connected",cards:c});for(const l of r.slice(0,wa)){const y=t.filter(g=>!s(g.slug)&&sn(g,l));y.length&&o.push({kind:"category",category:l,cards:y.slice(0,Ot),more:y.length>Ot})}return o.push({kind:"all",cards:t.filter(l=>!s(l.slug))}),o}const Ca={productivity:"productivity","developer tools":"developerTools",communication:"communication",files:"files","sales and crm":"salesCrm",design:"design",marketing:"marketing",analytics:"analytics",social:"social"},Sa={"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=Ca[t.trim().toLowerCase()];return s?n(`apps.category.${s}`):t}function Bn(t){const s=Sa[t.label.trim().toLowerCase()];return s?n(`apps.catalog.${s}.blurb`):t.blurb}function Ra({server:t,disabled:s,onSaved:r}){const[o,c]=d.useState(!1),[l,y]=d.useState(null);if(typeof t.apps!="boolean"||t.apps&&t.hasApps!==!0)return null;const g=t.apps,k=async()=>{c(!0),y(null);try{const p=await w(`/api/mcp/servers/${encodeURIComponent(t.name)}`,{method:"PATCH",body:JSON.stringify({apps:!g})});r(p.servers??[])}catch(p){y(p instanceof Error?p.message:String(p))}finally{c(!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")})]}),o&&e.jsx(ae,{"aria-hidden":"true",size:13,className:"animate-spin text-ink-secondary"}),e.jsx(pn,{checked:g,disabled:s||o,onClick:()=>{k()},"aria-label":n("mcp.apps.toggleAria",{name:t.name}),className:"disabled:opacity-40"})]})}function Pn({feature:t,enabled:s,prefix:r}){const{dispatch:o}=et(),[c,l]=d.useState(!1),[y,g]=d.useState(!1),k=async()=>{if(!c){l(!0),g(!1);try{const p=await w("/api/config",{method:"PATCH",body:JSON.stringify({features:{[t]:!s}})});o({type:"configStatus",config:p})}catch{g(!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(`${r}.title`)}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:n(`${r}.desc`)}),y&&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(`${r}.aria`),disabled:c,onClick:()=>{k()},className:"mt-0.5 shrink-0 disabled:cursor-wait disabled:opacity-50"})]})}function Ea(){const{state:t}=et();return e.jsxs(e.Fragment,{children:[e.jsx(Pn,{feature:"claudeUserMcp",enabled:As(t.config),prefix:"mcp.claude"}),e.jsx(Pn,{feature:"claudeUserSkills",enabled:Cs(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,us=/^[A-Za-z_][A-Za-z0-9_]*=/,za=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+:/,Ia=new Set(["npx","uvx","bunx"]),Ta=new Set(["pnpm","yarn"]);function Oa(t,s=[]){const r=Ba(t).trim();if(!r)return null;try{const o=/^[{[]/.test(r)?Ka(r):an.test(r)&&!/\s/.test(r)?[hn(void 0,r,void 0,[])]:Pa(r);return{ok:!0,servers:Ja(o,s)}}catch(o){if(o instanceof me)return{ok:!1,error:o.key};throw o}}function Ba(t){return t.replace(/[“”„]/g,'"').replace(/[‘’]/g,"'").replace(/(^|\s)[–—](?=[a-z])/g,"$1--")}function ps(t){const s=[];let r=[],o="",c=!1;const l=()=>{c&&r.push(o),o="",c=!1},y=()=>{l(),r.length&&s.push(r),r=[]},g=k=>t[k]===`
1
+ import{c as un,t as n,r as d,j as e,X as ts,af as ns,a as _,d as Xe,m as Pt,S as Ns,i as Vt}from"./styles-DnkNzLDs.js";import{S as pn,j as w,u as et,eE as As,eF as Cs,eG as Ss,eH as ht,w as Rs,eI as Es,eJ as zs,eK as Gt,l as Is,G as Rn,eL as Ts,eM as Os,cX as Bs,T as Ps,ag as en,bs as Ms,z as tn,eN as Et,eO as ss,eP as zt,eQ as as,am as is,eR as It,eS as Ls,eT as os,eU as Tt,eV as cs,eW as Us,eX as En,eY as $s,X as rs,eZ as Nt,e_ as Fs,e$ as Ks,f0 as Ds,f1 as Qs,f2 as Hs,f3 as ct,f4 as zn,f5 as _s,f6 as Js,f7 as At,f8 as Vs,f9 as Gs,fa as In,ej as Tn,fb as qs,fc as Zs,fd as Ws,fe as qt,ff as Xs,fg as Ys,fh as ea,fi as ta,fj as na,fk as sa,fl as aa,fm as ia,fn as oa,fo as ca,fp as ra}from"./App-DbfRrJPA.js";import{L as ae,P as ls,X as la,a as da,v as mn,E as ua,_ as pa,$ as ma,B as ha}from"./PlacesRail-fw4FbMbq.js";import{C as ds,R as nn}from"./MenuMotion-xBTC4eOZ.js";import{u as xa}from"./ProIntroduction-CSoN3fqJ.js";import"./index-DAHkvjY_.js";import"./monitor-D-rHzZVy.js";const fa=[["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"}]],ga=un("phone-call",fa);const ba=[["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"}]],ya=un("radio-tower",ba);const ka=[["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"}]],Zt=un("server-cog",ka),ja=new Set(["twitter","x"]);function On(t,s){return t!=="managed"||!ja.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 va=5,wa=3,Ot=4;function Na(t,s=va,r=[]){const o=new Map;for(const g of t)for(const k of new Set(g.categories??[]))o.set(k,(o.get(k)??0)+1);const c=[...o].sort((g,k)=>k[1]-g[1]||g[0].localeCompare(k[0])).map(([g])=>g),l=r.filter(g=>c.indexOf(g)>=s),y=[...c.slice(0,Math.max(0,s-l.length)),...l];return{inline:y,more:c.filter(g=>!y.includes(g))}}function sn(t,s){return s===null||(t.categories??[]).includes(s)}function Aa(t,s,r){const o=[],c=t.filter(l=>s(l.slug));c.length&&o.push({kind:"connected",cards:c});for(const l of r.slice(0,wa)){const y=t.filter(g=>!s(g.slug)&&sn(g,l));y.length&&o.push({kind:"category",category:l,cards:y.slice(0,Ot),more:y.length>Ot})}return o.push({kind:"all",cards:t.filter(l=>!s(l.slug))}),o}const Ca={productivity:"productivity","developer tools":"developerTools",communication:"communication",files:"files","sales and crm":"salesCrm",design:"design",marketing:"marketing",analytics:"analytics",social:"social"},Sa={"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=Ca[t.trim().toLowerCase()];return s?n(`apps.category.${s}`):t}function Bn(t){const s=Sa[t.label.trim().toLowerCase()];return s?n(`apps.catalog.${s}.blurb`):t.blurb}function Ra({server:t,disabled:s,onSaved:r}){const[o,c]=d.useState(!1),[l,y]=d.useState(null);if(typeof t.apps!="boolean"||t.apps&&t.hasApps!==!0)return null;const g=t.apps,k=async()=>{c(!0),y(null);try{const p=await w(`/api/mcp/servers/${encodeURIComponent(t.name)}`,{method:"PATCH",body:JSON.stringify({apps:!g})});r(p.servers??[])}catch(p){y(p instanceof Error?p.message:String(p))}finally{c(!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")})]}),o&&e.jsx(ae,{"aria-hidden":"true",size:13,className:"animate-spin text-ink-secondary"}),e.jsx(pn,{checked:g,disabled:s||o,onClick:()=>{k()},"aria-label":n("mcp.apps.toggleAria",{name:t.name}),className:"disabled:opacity-40"})]})}function Pn({feature:t,enabled:s,prefix:r}){const{dispatch:o}=et(),[c,l]=d.useState(!1),[y,g]=d.useState(!1),k=async()=>{if(!c){l(!0),g(!1);try{const p=await w("/api/config",{method:"PATCH",body:JSON.stringify({features:{[t]:!s}})});o({type:"configStatus",config:p})}catch{g(!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(`${r}.title`)}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:n(`${r}.desc`)}),y&&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(`${r}.aria`),disabled:c,onClick:()=>{k()},className:"mt-0.5 shrink-0 disabled:cursor-wait disabled:opacity-50"})]})}function Ea(){const{state:t}=et();return e.jsxs(e.Fragment,{children:[e.jsx(Pn,{feature:"claudeUserMcp",enabled:As(t.config),prefix:"mcp.claude"}),e.jsx(Pn,{feature:"claudeUserSkills",enabled:Cs(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,us=/^[A-Za-z_][A-Za-z0-9_]*=/,za=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+:/,Ia=new Set(["npx","uvx","bunx"]),Ta=new Set(["pnpm","yarn"]);function Oa(t,s=[]){const r=Ba(t).trim();if(!r)return null;try{const o=/^[{[]/.test(r)?Ka(r):an.test(r)&&!/\s/.test(r)?[hn(void 0,r,void 0,[])]:Pa(r);return{ok:!0,servers:Ja(o,s)}}catch(o){if(o instanceof me)return{ok:!1,error:o.key};throw o}}function Ba(t){return t.replace(/[“”„]/g,'"').replace(/[‘’]/g,"'").replace(/(^|\s)[–—](?=[a-z])/g,"$1--")}function ps(t){const s=[];let r=[],o="",c=!1;const l=()=>{c&&r.push(o),o="",c=!1},y=()=>{l(),r.length&&s.push(r),r=[]},g=k=>t[k]===`
2
2
  `?1:t[k]==="\r"&&t[k+1]===`
3
3
  `?2:0;for(let k=0;k<t.length;k+=1){const p=t[k];if(p==="\\"||(p==="`"||p==="^")&&g(k+1)){const h=g(k+1);if(h){k+=h;continue}k+1<t.length&&(o+=t[k+1],c=!0,k+=1);continue}if(p==="'"){const h=t.indexOf("'",k+1);if(h<0)throw new me("mcp.paste.notRecognized");o+=t.slice(k+1,h),c=!0,k=h;continue}if(p==='"'){let h=k+1;for(;h<t.length&&t[h]!=='"';h+=1){if(t[h]==="\\"&&h+1<t.length){const A=g(h+1);if(A){h+=A;continue}if('"\\$`'.includes(t[h+1])){o+=t[h+1],h+=1;continue}}o+=t[h]}if(h>=t.length)throw new me("mcp.paste.notRecognized");c=!0,k=h;continue}if(p==="$"&&t[k+1]==="("){const h=t.indexOf(")",k+2);if(h<0)throw new me("mcp.paste.notRecognized");o+=t.slice(k,h+1),c=!0,k=h;continue}if(p==="#"&&!c){for(;k+1<t.length&&t[k+1]!==`
4
4
  `;)k+=1;continue}if(p===`
@@ -1 +1 @@
1
- import{r as c,j as s,k as h,t as u}from"./styles-DnkNzLDs.js";import{f as m,g as b,h as a,i as p}from"./PlacesRail-fw4FbMbq.js";import{u as g,a1 as w,a2 as v}from"./App-B6W9JFXZ.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-DnkNzLDs.js";import{f as m,g as b,h as a,i as p}from"./PlacesRail-fw4FbMbq.js";import{u as g,a1 as w,a2 as v}from"./App-DbfRrJPA.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 +1 @@
1
- import{r,j as e,C as w,t as n,X as C,a as S}from"./styles-DnkNzLDs.js";import{u as A,I as z,T,B as p,V as L,g as P,S as B,h as E,j as I}from"./App-B6W9JFXZ.js";import{u as R,B as F,L as U,b as V}from"./PlacesRail-fw4FbMbq.js";import"./index-Bh1qTRXw.js";import"./monitor-D-rHzZVy.js";import"./MenuMotion-xBTC4eOZ.js";function M({bot:t,overlay:b=!1}){const{dispatch:f}=A(),{dragProps:k}=R(),[x,g]=r.useState(!1),[h,l]=r.useState(""),[v,j]=r.useState(!1),d=r.useRef(null),o=r.useRef(null),c=r.useRef(null),y=()=>f({type:"toggleSettings",open:!1}),i=a=>{if(o.current={...o.current,...a},c.current)return c.current;g(!0),l("");const s=async()=>{for(;o.current;){const u=o.current;o.current=null,l("");try{const m=await I(`/api/bots/${t.id}/profile`,{method:"PATCH",body:JSON.stringify(u)});f({type:"botPatched",bot:m.bot})}catch(m){l(m instanceof Error?m.message:n("remoteAgent.updateFailed"))}}};return c.current=s().finally(()=>{c.current=null,g(!1)}),c.current},N=async a=>{if(a){j(!0),l("");try{const s=await E(a),u=s?V(s.path):null;if(!u)throw new Error(n("settings.profile.avatar.invalidType"));await i({avatarUrl:u,avatarCrop:t.avatarCrop==="square"?"square":"circle"})}catch(s){l(s instanceof Error?s.message:String(s))}finally{j(!1),d.current&&(d.current.value="")}}};return e.jsxs("aside",{className:S("animate-panel-in absolute inset-0 z-40 flex h-full min-w-0 flex-col border-l border-hairline/40 bg-panel",b?"md:left-auto md:w-[400px] md:shadow-2xl":"md:relative md:z-20 md:w-[400px] md:shrink-0"),children:[e.jsxs("div",{...k,className:"flex items-center justify-between px-4 py-3",children:[e.jsx("button",{onClick:y,"aria-label":n("remoteAgent.collapse"),className:"flex size-10 items-center justify-center rounded-md text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(w,{size:18})}),e.jsx("span",{className:"text-[15px] font-semibold text-ink",children:n("remoteAgent.title")}),e.jsx("button",{onClick:y,"aria-label":n("remoteAgent.close"),className:"flex size-10 items-center justify-center rounded-md text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(C,{size:18})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 pb-5",children:e.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx(F,{bot:t,state:"idle",size:64,motion:"none",motionKey:0,animated:!1}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:d,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"sr-only",onChange:a=>{N(a.target.files?.[0])}}),e.jsxs("button",{type:"button",disabled:v||x,onClick:()=>d.current?.click(),className:"flex items-center gap-1.5 rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[v?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(z,{size:14})," ",n("botIdentity.avatar")]}),t.avatarUrl&&e.jsx("button",{type:"button",disabled:x,onClick:()=>{i({avatarUrl:null,avatarCrop:"mascot"})},"aria-label":n("remoteAgent.removeAvatar"),className:"flex size-9 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-danger",children:e.jsx(T,{size:14})})]})]}),e.jsxs("label",{className:"block text-[12px] font-medium text-ink-secondary",children:[n("botSettings.identity.name"),e.jsx("input",{defaultValue:t.name,maxLength:p.name,onBlur:a=>{const s=a.currentTarget.value.trim();s&&s!==t.name&&i({name:s})},className:"mt-1 w-full rounded-lg bg-inset px-3 py-2 text-[14px] text-ink focus:outline-none focus:ring-1 focus:ring-accent"},t.id)]}),e.jsxs("label",{className:"mt-3 block text-[12px] font-medium text-ink-secondary",children:[n("botSettings.identity.title"),e.jsx("input",{defaultValue:t.title??"",maxLength:p.title,onBlur:a=>{a.currentTarget.value!==(t.title??"")&&i({title:a.currentTarget.value})},className:"mt-1 w-full rounded-lg bg-inset px-3 py-2 text-[14px] text-ink focus:outline-none focus:ring-1 focus:ring-accent"},t.id)]}),e.jsxs("label",{className:"mt-3 block text-[12px] font-medium text-ink-secondary",children:[n("remoteAgent.description"),e.jsx("textarea",{defaultValue:t.description??"",maxLength:p.description,rows:4,onBlur:a=>{a.currentTarget.value!==(t.description??"")&&i({description:a.currentTarget.value})},className:"mt-1 w-full resize-y rounded-lg bg-inset px-3 py-2 text-[13px] leading-relaxed text-ink focus:outline-none focus:ring-1 focus:ring-accent"},t.id)]})]}),e.jsx(L,{bot:t,workspaceConfigurationLocked:!0,onPatch:a=>{i(a)}}),e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx(P,{size:16,className:"mt-0.5 shrink-0 text-ink-secondary"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:n("notifications.title")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:n("remoteAgent.notificationsHint")})]})]}),e.jsx(B,{checked:t.notifications,disabled:x,"aria-label":n("remoteAgent.notifications"),onClick:()=>{i({notifications:!t.notifications})}})]}),h?e.jsx("div",{role:"alert",className:"text-[12px] text-danger",children:h}):null]})})]})}export{M as RemoteAgentSettingsPanel};
1
+ import{r,j as e,C as w,t as n,X as C,a as S}from"./styles-DnkNzLDs.js";import{u as A,I as z,T,B as p,V as L,g as P,S as B,h as E,j as I}from"./App-DbfRrJPA.js";import{u as R,B as F,L as U,b as V}from"./PlacesRail-fw4FbMbq.js";import"./index-DAHkvjY_.js";import"./monitor-D-rHzZVy.js";import"./MenuMotion-xBTC4eOZ.js";function M({bot:t,overlay:b=!1}){const{dispatch:f}=A(),{dragProps:k}=R(),[x,g]=r.useState(!1),[h,l]=r.useState(""),[v,j]=r.useState(!1),d=r.useRef(null),o=r.useRef(null),c=r.useRef(null),y=()=>f({type:"toggleSettings",open:!1}),i=a=>{if(o.current={...o.current,...a},c.current)return c.current;g(!0),l("");const s=async()=>{for(;o.current;){const u=o.current;o.current=null,l("");try{const m=await I(`/api/bots/${t.id}/profile`,{method:"PATCH",body:JSON.stringify(u)});f({type:"botPatched",bot:m.bot})}catch(m){l(m instanceof Error?m.message:n("remoteAgent.updateFailed"))}}};return c.current=s().finally(()=>{c.current=null,g(!1)}),c.current},N=async a=>{if(a){j(!0),l("");try{const s=await E(a),u=s?V(s.path):null;if(!u)throw new Error(n("settings.profile.avatar.invalidType"));await i({avatarUrl:u,avatarCrop:t.avatarCrop==="square"?"square":"circle"})}catch(s){l(s instanceof Error?s.message:String(s))}finally{j(!1),d.current&&(d.current.value="")}}};return e.jsxs("aside",{className:S("animate-panel-in absolute inset-0 z-40 flex h-full min-w-0 flex-col border-l border-hairline/40 bg-panel",b?"md:left-auto md:w-[400px] md:shadow-2xl":"md:relative md:z-20 md:w-[400px] md:shrink-0"),children:[e.jsxs("div",{...k,className:"flex items-center justify-between px-4 py-3",children:[e.jsx("button",{onClick:y,"aria-label":n("remoteAgent.collapse"),className:"flex size-10 items-center justify-center rounded-md text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(w,{size:18})}),e.jsx("span",{className:"text-[15px] font-semibold text-ink",children:n("remoteAgent.title")}),e.jsx("button",{onClick:y,"aria-label":n("remoteAgent.close"),className:"flex size-10 items-center justify-center rounded-md text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(C,{size:18})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 pb-5",children:e.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx(F,{bot:t,state:"idle",size:64,motion:"none",motionKey:0,animated:!1}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:d,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"sr-only",onChange:a=>{N(a.target.files?.[0])}}),e.jsxs("button",{type:"button",disabled:v||x,onClick:()=>d.current?.click(),className:"flex items-center gap-1.5 rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[v?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(z,{size:14})," ",n("botIdentity.avatar")]}),t.avatarUrl&&e.jsx("button",{type:"button",disabled:x,onClick:()=>{i({avatarUrl:null,avatarCrop:"mascot"})},"aria-label":n("remoteAgent.removeAvatar"),className:"flex size-9 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-danger",children:e.jsx(T,{size:14})})]})]}),e.jsxs("label",{className:"block text-[12px] font-medium text-ink-secondary",children:[n("botSettings.identity.name"),e.jsx("input",{defaultValue:t.name,maxLength:p.name,onBlur:a=>{const s=a.currentTarget.value.trim();s&&s!==t.name&&i({name:s})},className:"mt-1 w-full rounded-lg bg-inset px-3 py-2 text-[14px] text-ink focus:outline-none focus:ring-1 focus:ring-accent"},t.id)]}),e.jsxs("label",{className:"mt-3 block text-[12px] font-medium text-ink-secondary",children:[n("botSettings.identity.title"),e.jsx("input",{defaultValue:t.title??"",maxLength:p.title,onBlur:a=>{a.currentTarget.value!==(t.title??"")&&i({title:a.currentTarget.value})},className:"mt-1 w-full rounded-lg bg-inset px-3 py-2 text-[14px] text-ink focus:outline-none focus:ring-1 focus:ring-accent"},t.id)]}),e.jsxs("label",{className:"mt-3 block text-[12px] font-medium text-ink-secondary",children:[n("remoteAgent.description"),e.jsx("textarea",{defaultValue:t.description??"",maxLength:p.description,rows:4,onBlur:a=>{a.currentTarget.value!==(t.description??"")&&i({description:a.currentTarget.value})},className:"mt-1 w-full resize-y rounded-lg bg-inset px-3 py-2 text-[13px] leading-relaxed text-ink focus:outline-none focus:ring-1 focus:ring-accent"},t.id)]})]}),e.jsx(L,{bot:t,workspaceConfigurationLocked:!0,onPatch:a=>{i(a)}}),e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx(P,{size:16,className:"mt-0.5 shrink-0 text-ink-secondary"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:n("notifications.title")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:n("remoteAgent.notificationsHint")})]})]}),e.jsx(B,{checked:t.notifications,disabled:x,"aria-label":n("remoteAgent.notifications"),onClick:()=>{i({notifications:!t.notifications})}})]}),h?e.jsx("div",{role:"alert",className:"text-[12px] text-danger",children:h}):null]})})]})}export{M as RemoteAgentSettingsPanel};
@@ -1,2 +1,2 @@
1
- import{j as e,a as z,t as a,H as F,r as d,S as L,X as B}from"./styles-DnkNzLDs.js";import{E as O,C as $,T as G,B as I,n as K,u as q,r as H}from"./PlacesRail-fw4FbMbq.js";import{am as U,u as w,an as A,ao as W,ap as J,aq as X,ar as _,as as Q,at as V,au as Y,av as M,aw as Z,J as ee,ax as te,ay as ae,az as se,aA as ne,aB as oe,aC as re,aD as le,aE as ie,aF as ce,aG as P,aH as S,aI as de,aJ as ue,aK as pe,aL as C,aM as v,aN as me,aO as fe,aP as xe,aQ as he,aR as be,aS as je,aT as ye,aU as ge,aV as ke,aW as N,aX as ve,aa as we,aY as Re}from"./App-B6W9JFXZ.js";import{C as Se}from"./MenuMotion-xBTC4eOZ.js";import"./monitor-D-rHzZVy.js";import"./index-Bh1qTRXw.js";function T(t){return t===60?a("room.panel.hour"):t%60===0?a("room.panel.hours",{hours:t/60}):a("room.panel.minutes",{minutes:t})}function Ce(t){const{dispatch:s}=w(),i=F(),u=A(t.threadId),o=W(t),[p,r]=d.useState(null),f=t.messages,b=f.length>0,n=()=>se({threadId:t.threadId,hasMore:t.hasMore,title:t.name,messages:f,isGroup:!0}),x=i?[]:J(t.tasks??[]),m=X(t.usage);return{items:[{key:"find",label:a("chat.find"),icon:e.jsx(L,{size:16}),active:u,trailing:e.jsx(Q,{id:"find-conversation"}),onSelect:()=>_(t.threadId)},...i?[]:[{key:"new-thread",heading:a("task.list"),separatorBefore:!0,label:a("task.newShort"),icon:e.jsx(V,{size:16}),onSelect:()=>s({type:"newGroupTask",groupId:t.id})}],...x.length<2?[]:[{key:"threads",label:a("task.switch"),icon:e.jsx(M,{size:16}),value:String(x.length),submenu:x.map(l=>({key:`thread:${l.threadId}`,label:Y(l.title||a("task.newShort")),active:l.threadId===t.threadId,onSelect:()=>s({type:"switchGroupTask",groupId:t.id,threadId:l.threadId})})),onSelect:()=>{}}],{key:"copy",heading:a("chat.export.heading"),separatorBefore:!0,label:a("chat.export.copy"),icon:e.jsx($,{size:16}),disabled:!b,keepOpen:!0,trailing:p&&e.jsx("span",{role:"status",className:"text-[11px] text-ink-secondary",children:a(p==="copied"?"chat.export.copied":"chat.export.copyFailed")}),onSelect:()=>{Z(n()).then(l=>r(l?"copied":"failed"))}},{key:"download",label:a("chat.export.download"),icon:e.jsx(ee,{size:16}),disabled:!b,onSelect:()=>{const l=n(),g=h=>ne(oe(t.name),h);typeof l=="string"?g(l):l.then(g).catch(h=>s({type:"error",message:h instanceof Error?h.message:String(h)}))}},{key:"turn-limit",label:a("room.panel.turnLimit"),icon:e.jsx(G,{size:16}),separatorBefore:!0,value:T(o.saved??o.globalMinutes),submenu:[{key:"turn-limit:default",label:a("room.turnLimit.default",{minutes:o.globalMinutes}),active:o.saved===null,onSelect:()=>o.save(null)},...te.map(l=>({key:`turn-limit:${l}`,label:T(l),active:o.saved===l,onSelect:()=>o.save(l)}))],onSelect:()=>{}},...m?[{key:"usage",label:a("chat.usage.menu"),icon:e.jsx(ae,{size:16}),keepOpen:!0,trailing:e.jsx("span",{title:m.title,"data-testid":"group-usage-chip",className:"tabular-nums text-[12px] text-ink-secondary",children:m.short}),onSelect:()=>{}}]:[]],on:u}}function Ne({group:t}){const{items:s,on:i}=Ce(t);return e.jsx(U,{items:s,ariaLabel:a("chat.more"),triggerClassName:"rounded-full",triggerTitle:a("chat.more"),renderTrigger:({open:u})=>e.jsx("span",{"data-testid":"room-more",className:z("flex size-8 items-center justify-center rounded-full bg-raised/50 transition-colors hover:bg-raised","max-md:size-9 max-md:border max-md:border-hairline max-md:bg-card",u||i?"text-accent":"text-ink"),children:e.jsx(O,{size:16})})})}function Te({group:t}){return e.jsx(Ne,{group:t},t.threadId)}function Ee({group:t,members:s}){const{state:i,dispatch:u}=w(),o=re(i.config),p=le(t,s),r=ie(p),f=n=>{n!==r&&u({type:"patchGroup",groupId:t.id,patch:{defaultResponder:de(n,p)}})},b=[{choice:"auto",title:a("room.panel.responder.autoOption"),hint:o?void 0:a("room.responder.autoOff",{name:ce(t,s)??a("room.responder.leadFallback")})},{choice:"everyone",title:a("room.panel.responder.everyone")},{choice:"mentions",title:a("room.panel.responder.mentions")}];return e.jsx("div",{role:"radiogroup","aria-label":a("room.panel.whoResponds"),children:e.jsxs(P,{children:[s.map(n=>e.jsx(S,{"data-panel-choice":`member:${n.id}`,title:e.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx(I,{bot:n,state:K(n.mascotExpression)??"happy",size:22,animated:!1}),e.jsx("span",{className:"truncate",children:n.name})]}),checked:r===`member:${n.id}`,onClick:()=>f(`member:${n.id}`)},n.id)),b.map(({choice:n,title:x,hint:m})=>e.jsx(S,{"data-panel-choice":n,title:x,hint:m,checked:r===n,onClick:()=>f(n)},n))]})})}const E={responder:{title:"room.panel.whoResponds",intro:"room.panel.responder.intro"},folder:{title:"room.folder.title",intro:"room.folder.detail"}};function ze({group:t,members:s}){return e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{"data-room-panel-faces":!0,className:"mt-0.5 flex -space-x-3",children:s.slice(0,3).map(i=>e.jsx(I,{bot:i,state:"happy",size:52,animated:!1},i.id))}),e.jsx("h2",{id:"room-panel-title",className:"mt-2.5 max-w-full truncate px-1.5 text-[18px] font-semibold text-ink",children:t.name}),t.description&&e.jsx("p",{className:"mt-px line-clamp-2 max-w-full text-[13px] text-ink-secondary",children:t.description})]})}function Ie({group:t}){const s=ge(t),i=d.useRef(null),u=d.useRef(!1);d.useEffect(()=>{s.open||!u.current||(u.current=!1,i.current?.focus())},[s.open]);const o=r=>{r.key==="Escape"&&(r.preventDefault(),r.stopPropagation()),(r.key==="Escape"||r.key==="Enter"&&(r.metaKey||r.ctrlKey))&&(u.current=!0),s.onKeyDown(r)};if(s.open)return e.jsxs(ke,{"data-panel-row":"instructions",children:[e.jsx(N,{title:a("room.panel.instructions")}),e.jsx("textarea",{autoFocus:!0,dir:"auto","aria-label":a("room.panel.instructions"),value:s.draft,onChange:r=>s.setDraft(r.target.value),onBlur:s.save,onKeyDown:o,placeholder:a("room.bulletin.placeholder"),rows:6,className:"w-full resize-y rounded-lg border border-hairline bg-inset px-2.5 py-2 text-[13px] leading-relaxed text-ink outline-none placeholder:text-ink-tertiary focus:border-accent-border"}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-panel-done":"instructions",onMouseDown:r=>r.preventDefault(),onClick:()=>{u.current=!0,s.save()},className:ve,children:a("botSettings.simple.done")})})]});const p=t.bulletin.split(`
1
+ import{j as e,a as z,t as a,H as F,r as d,S as L,X as B}from"./styles-DnkNzLDs.js";import{E as O,C as $,T as G,B as I,n as K,u as q,r as H}from"./PlacesRail-fw4FbMbq.js";import{am as U,u as w,an as A,ao as W,ap as J,aq as X,ar as _,as as Q,at as V,au as Y,av as M,aw as Z,J as ee,ax as te,ay as ae,az as se,aA as ne,aB as oe,aC as re,aD as le,aE as ie,aF as ce,aG as P,aH as S,aI as de,aJ as ue,aK as pe,aL as C,aM as v,aN as me,aO as fe,aP as xe,aQ as he,aR as be,aS as je,aT as ye,aU as ge,aV as ke,aW as N,aX as ve,aa as we,aY as Re}from"./App-DbfRrJPA.js";import{C as Se}from"./MenuMotion-xBTC4eOZ.js";import"./monitor-D-rHzZVy.js";import"./index-DAHkvjY_.js";function T(t){return t===60?a("room.panel.hour"):t%60===0?a("room.panel.hours",{hours:t/60}):a("room.panel.minutes",{minutes:t})}function Ce(t){const{dispatch:s}=w(),i=F(),u=A(t.threadId),o=W(t),[p,r]=d.useState(null),f=t.messages,b=f.length>0,n=()=>se({threadId:t.threadId,hasMore:t.hasMore,title:t.name,messages:f,isGroup:!0}),x=i?[]:J(t.tasks??[]),m=X(t.usage);return{items:[{key:"find",label:a("chat.find"),icon:e.jsx(L,{size:16}),active:u,trailing:e.jsx(Q,{id:"find-conversation"}),onSelect:()=>_(t.threadId)},...i?[]:[{key:"new-thread",heading:a("task.list"),separatorBefore:!0,label:a("task.newShort"),icon:e.jsx(V,{size:16}),onSelect:()=>s({type:"newGroupTask",groupId:t.id})}],...x.length<2?[]:[{key:"threads",label:a("task.switch"),icon:e.jsx(M,{size:16}),value:String(x.length),submenu:x.map(l=>({key:`thread:${l.threadId}`,label:Y(l.title||a("task.newShort")),active:l.threadId===t.threadId,onSelect:()=>s({type:"switchGroupTask",groupId:t.id,threadId:l.threadId})})),onSelect:()=>{}}],{key:"copy",heading:a("chat.export.heading"),separatorBefore:!0,label:a("chat.export.copy"),icon:e.jsx($,{size:16}),disabled:!b,keepOpen:!0,trailing:p&&e.jsx("span",{role:"status",className:"text-[11px] text-ink-secondary",children:a(p==="copied"?"chat.export.copied":"chat.export.copyFailed")}),onSelect:()=>{Z(n()).then(l=>r(l?"copied":"failed"))}},{key:"download",label:a("chat.export.download"),icon:e.jsx(ee,{size:16}),disabled:!b,onSelect:()=>{const l=n(),g=h=>ne(oe(t.name),h);typeof l=="string"?g(l):l.then(g).catch(h=>s({type:"error",message:h instanceof Error?h.message:String(h)}))}},{key:"turn-limit",label:a("room.panel.turnLimit"),icon:e.jsx(G,{size:16}),separatorBefore:!0,value:T(o.saved??o.globalMinutes),submenu:[{key:"turn-limit:default",label:a("room.turnLimit.default",{minutes:o.globalMinutes}),active:o.saved===null,onSelect:()=>o.save(null)},...te.map(l=>({key:`turn-limit:${l}`,label:T(l),active:o.saved===l,onSelect:()=>o.save(l)}))],onSelect:()=>{}},...m?[{key:"usage",label:a("chat.usage.menu"),icon:e.jsx(ae,{size:16}),keepOpen:!0,trailing:e.jsx("span",{title:m.title,"data-testid":"group-usage-chip",className:"tabular-nums text-[12px] text-ink-secondary",children:m.short}),onSelect:()=>{}}]:[]],on:u}}function Ne({group:t}){const{items:s,on:i}=Ce(t);return e.jsx(U,{items:s,ariaLabel:a("chat.more"),triggerClassName:"rounded-full",triggerTitle:a("chat.more"),renderTrigger:({open:u})=>e.jsx("span",{"data-testid":"room-more",className:z("flex size-8 items-center justify-center rounded-full bg-raised/50 transition-colors hover:bg-raised","max-md:size-9 max-md:border max-md:border-hairline max-md:bg-card",u||i?"text-accent":"text-ink"),children:e.jsx(O,{size:16})})})}function Te({group:t}){return e.jsx(Ne,{group:t},t.threadId)}function Ee({group:t,members:s}){const{state:i,dispatch:u}=w(),o=re(i.config),p=le(t,s),r=ie(p),f=n=>{n!==r&&u({type:"patchGroup",groupId:t.id,patch:{defaultResponder:de(n,p)}})},b=[{choice:"auto",title:a("room.panel.responder.autoOption"),hint:o?void 0:a("room.responder.autoOff",{name:ce(t,s)??a("room.responder.leadFallback")})},{choice:"everyone",title:a("room.panel.responder.everyone")},{choice:"mentions",title:a("room.panel.responder.mentions")}];return e.jsx("div",{role:"radiogroup","aria-label":a("room.panel.whoResponds"),children:e.jsxs(P,{children:[s.map(n=>e.jsx(S,{"data-panel-choice":`member:${n.id}`,title:e.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx(I,{bot:n,state:K(n.mascotExpression)??"happy",size:22,animated:!1}),e.jsx("span",{className:"truncate",children:n.name})]}),checked:r===`member:${n.id}`,onClick:()=>f(`member:${n.id}`)},n.id)),b.map(({choice:n,title:x,hint:m})=>e.jsx(S,{"data-panel-choice":n,title:x,hint:m,checked:r===n,onClick:()=>f(n)},n))]})})}const E={responder:{title:"room.panel.whoResponds",intro:"room.panel.responder.intro"},folder:{title:"room.folder.title",intro:"room.folder.detail"}};function ze({group:t,members:s}){return e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{"data-room-panel-faces":!0,className:"mt-0.5 flex -space-x-3",children:s.slice(0,3).map(i=>e.jsx(I,{bot:i,state:"happy",size:52,animated:!1},i.id))}),e.jsx("h2",{id:"room-panel-title",className:"mt-2.5 max-w-full truncate px-1.5 text-[18px] font-semibold text-ink",children:t.name}),t.description&&e.jsx("p",{className:"mt-px line-clamp-2 max-w-full text-[13px] text-ink-secondary",children:t.description})]})}function Ie({group:t}){const s=ge(t),i=d.useRef(null),u=d.useRef(!1);d.useEffect(()=>{s.open||!u.current||(u.current=!1,i.current?.focus())},[s.open]);const o=r=>{r.key==="Escape"&&(r.preventDefault(),r.stopPropagation()),(r.key==="Escape"||r.key==="Enter"&&(r.metaKey||r.ctrlKey))&&(u.current=!0),s.onKeyDown(r)};if(s.open)return e.jsxs(ke,{"data-panel-row":"instructions",children:[e.jsx(N,{title:a("room.panel.instructions")}),e.jsx("textarea",{autoFocus:!0,dir:"auto","aria-label":a("room.panel.instructions"),value:s.draft,onChange:r=>s.setDraft(r.target.value),onBlur:s.save,onKeyDown:o,placeholder:a("room.bulletin.placeholder"),rows:6,className:"w-full resize-y rounded-lg border border-hairline bg-inset px-2.5 py-2 text-[13px] leading-relaxed text-ink outline-none placeholder:text-ink-tertiary focus:border-accent-border"}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-panel-done":"instructions",onMouseDown:r=>r.preventDefault(),onClick:()=>{u.current=!0,s.save()},className:ve,children:a("botSettings.simple.done")})})]});const p=t.bulletin.split(`
2
2
  `)[0]?.trim();return e.jsxs("button",{ref:i,type:"button","data-panel-edit":"instructions","aria-label":`${a("botSettings.simple.edit")}: ${a("room.panel.instructions")}`,onClick:s.start,className:z(Re,"w-full text-left hover:bg-ink/[0.03]"),children:[e.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-lg bg-ink/[0.05] text-ink-secondary max-md:size-8 max-md:rounded-full","aria-hidden":"true",children:e.jsx(we,{size:15})}),e.jsx(N,{title:a("room.panel.instructions"),hint:e.jsx("span",{dir:"auto",className:"line-clamp-1",children:p||a("room.panel.instructionsHint")})}),e.jsx(Se,{size:15,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]})}function Oe({group:t,overlay:s=!1}){const{state:i}=w(),{dragProps:u}=q(),[o,p]=d.useState(null),[r,f]=d.useState(!1),b=d.useRef(null),n=d.useRef(null),x=d.useRef(null),m=d.useRef(null),j=d.useMemo(()=>t.memberIds.map(c=>i.bots.find(k=>k.id===c)).filter(c=>!!c),[t.memberIds,i.bots]),l=ue(t),g=d.useCallback(()=>f(!1),[]),h=c=>{p(c),n.current?.scrollTo({top:0})},R=()=>{m.current=o,p(null)};d.useEffect(()=>{o!==null?n.current?.querySelector("[data-panel-back]")?.focus():m.current&&(n.current?.querySelector(`[data-panel-page="${m.current}"]`)?.focus(),m.current=null)},[o]),d.useEffect(()=>{const c=b.current;c?.focus();const k=y=>{y.key!=="Escape"||y.defaultPrevented||c&&y.target instanceof Node&&!c.contains(y.target)||(y.preventDefault(),C({refocus:!0}))};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[]);const D=c=>{c.key!=="Escape"||c.defaultPrevented||o===null||(c.preventDefault(),c.stopPropagation(),R())};return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{ref:b,role:"dialog","aria-labelledby":"room-panel-title",tabIndex:-1,"data-room-panel":!0,onKeyDown:D,className:je(s,!0),children:[e.jsxs("div",{...u,className:"flex h-[52px] shrink-0 items-center justify-end gap-2 px-3.5",children:[e.jsx(Te,{group:t}),e.jsx("button",{type:"button",onClick:()=>C({refocus:!0}),"aria-label":a("botSettings.simple.close"),className:pe,children:e.jsx(B,{size:16,className:"pointer-events-none"})})]}),e.jsx("div",{ref:n,className:"@container relative min-h-0 flex-1 overflow-y-auto px-5 pb-7",children:o===null?e.jsxs(e.Fragment,{children:[e.jsx(ze,{group:t,members:j}),e.jsxs(P,{children:[e.jsx(v,{"data-panel-page":"responder",icon:M,title:a("room.panel.whoResponds"),value:me(t,j),onClick:()=>h("responder")}),e.jsx(v,{"data-panel-page":"folder",icon:fe,title:a("room.folder.title"),value:l?.name??a("room.panel.folder.own"),tooltip:l?.path,onClick:()=>h("folder")}),e.jsx(Ie,{group:t}),e.jsx(v,{ref:x,"data-panel-row":"members",icon:xe,title:a("room.panel.members"),value:String(j.length),onClick:()=>f(!0)})]})]}):e.jsxs("div",{"data-panel-page-view":o,children:[e.jsx("span",{id:"room-panel-title",className:"sr-only",children:t.name}),e.jsx(he,{back:t.name,title:a(E[o].title),intro:a(E[o].intro),onBack:R}),e.jsx("div",{className:"mt-4 flex flex-col gap-3",children:o==="responder"?e.jsx(Ee,{group:t,members:j}):e.jsx(be,{group:t,heading:!1})})]})})]}),r&&H.createPortal(e.jsx(ye,{group:t,onClose:g,triggerRef:x}),document.body)]})}export{Oe as RoomPanel};