limixbot 0.3.93 → 0.3.94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/assets/{ActivityPanel-Bv00iZaa.js → ActivityPanel-2Uv233L-.js} +1 -1
  2. package/dist/assets/{App-Ba5tz_33.js → App-x36HXaXk.js} +8 -8
  3. package/dist/assets/{AppEventEditor-E54k4VDs.js → AppEventEditor-DBKUbaYn.js} +1 -1
  4. package/dist/assets/{BotSettingsDialog-ClJ78W_2.js → BotSettingsDialog-DqPzlGjL.js} +1 -1
  5. package/dist/assets/{BrowserPanel-wjxuynsR.js → BrowserPanel-DgidHsOC.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-1CZVRudF.js → BrowserProfilesManager-_AtQVsJG.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-CQJmPc_f.js → CloudAddDialog-C41Gk9oF.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-B2Qt6-zL.js → ComputerFilesPane-3IWnCxt_.js} +1 -1
  9. package/dist/assets/{ComputerPanel-OD4YmaoL.js → ComputerPanel-B3Cmq78b.js} +2 -2
  10. package/dist/assets/{DataPanel-DfqwjJ0z.js → DataPanel-BKinQVdn.js} +1 -1
  11. package/dist/assets/{FilesView-BnM7FRZo.js → FilesView-LN7pBhGU.js} +1 -1
  12. package/dist/assets/{GrokMoveDialog-BdNxENHY.js → GrokMoveDialog-C-77lJ3M.js} +1 -1
  13. package/dist/assets/{InspectorPanel-6sazgX3D.js → InspectorPanel-BQ236Bpi.js} +1 -1
  14. package/dist/assets/{KeyboardShortcutsModal-CfL3MPUp.js → KeyboardShortcutsModal-CqtGifvC.js} +1 -1
  15. package/dist/assets/{LiveDesktop-Cb1i69Qh.js → LiveDesktop-1diZmS5Q.js} +1 -1
  16. package/dist/assets/{LocalVmWorkspace-DJ2SSwSw.js → LocalVmWorkspace-Byk31r_m.js} +1 -1
  17. package/dist/assets/{MacLocalControl-BkMnqkNv.js → MacLocalControl-O_QtCEuT.js} +1 -1
  18. package/dist/assets/{MarkdownFilePreview-BnyzC4z8.js → MarkdownFilePreview-B8opDuC0.js} +1 -1
  19. package/dist/assets/{NewBotDialog-1R1xXhfX.js → NewBotDialog-_5JxRNIE.js} +1 -1
  20. package/dist/assets/{PhoneAppDialog-nM_f_AI3.js → PhoneAppDialog-D5oUvyea.js} +1 -1
  21. package/dist/assets/{PluginsPanel-BuvefhNg.js → PluginsPanel-C7SC_Z-v.js} +1 -1
  22. package/dist/assets/{ProIntroduction-sLFU_j7z.js → ProIntroduction-Cz7Ugz8r.js} +1 -1
  23. package/dist/assets/{RemoteAgentSettingsPanel-D_ItcQn_.js → RemoteAgentSettingsPanel-DutPlaXm.js} +1 -1
  24. package/dist/assets/{RoomPanel-Axx6CCNC.js → RoomPanel-DTaZi2sS.js} +1 -1
  25. package/dist/assets/{RoutinesPage-DHlvO9sv.js → RoutinesPage-ChuBJMsA.js} +1 -1
  26. package/dist/assets/{SettingsModal-CVMjo224.js → SettingsModal-DI-8ogJ0.js} +1 -1
  27. package/dist/assets/{ShareTeamDialog-CKzEgzCG.js → ShareTeamDialog-4AxslXRQ.js} +1 -1
  28. package/dist/assets/{SignedInSites-Dk5VcFKc.js → SignedInSites-BVCXgsGL.js} +1 -1
  29. package/dist/assets/{TeamLibraryPanel-CcD5X82G.js → TeamLibraryPanel-32Q163aI.js} +1 -1
  30. package/dist/assets/{TeamMapPage-bB5fL0Xf.js → TeamMapPage-DdSr_Mh7.js} +1 -1
  31. package/dist/assets/{TriggersPage-DifKwoHU.js → TriggersPage-DE7sqwZ3.js} +1 -1
  32. package/dist/assets/{VisibilitySection-BMwqbzL6.js → VisibilitySection-zsv4bW4L.js} +1 -1
  33. package/dist/assets/{WebhookTrigger-1kv2WU1m.js → WebhookTrigger-BTpUm74C.js} +1 -1
  34. package/dist/assets/{WorksOnGrid-Xxc_Nwu2.js → WorksOnGrid-BR1AkGgh.js} +1 -1
  35. package/dist/assets/{core-CGxXO6Mh.js → core-DwyEAsKw.js} +1 -1
  36. package/dist/assets/{import-name-BvkwZj7c.js → import-name-B-tlhBrM.js} +1 -1
  37. package/dist/assets/{index-CBQesSyk.js → index-DVxCxmdg.js} +2 -2
  38. package/dist/assets/{index-Hd2b4wyp.js → index-DcZpHpIH.js} +1 -1
  39. package/dist/assets/{mcp-servers-BgT071FJ.js → mcp-servers-UkbCCVYK.js} +1 -1
  40. package/dist/assets/{new-bot-h4C-I91i.js → new-bot-BF9YhKLu.js} +1 -1
  41. package/dist/assets/{org-library-hS6E2YFD.js → org-library-DGdb4nka.js} +1 -1
  42. package/dist/assets/{package-format-D_hMgGVE.js → package-format-BQDuoJ7s.js} +1 -1
  43. package/dist/assets/{remote-desktop-panel-DcMAAC8T.js → remote-desktop-panel-B1XXcgff.js} +1 -1
  44. package/dist/index.html +1 -1
  45. package/dist-server/index.js +9 -8
  46. package/dist-server/package.json +1 -1
  47. package/dist-server/server/limix-skill-store.js +2 -1
  48. package/package.json +1 -1
  49. package/skills/reverse-engineer-anything/LICENSE +21 -0
  50. package/skills/reverse-engineer-anything/SKILL.md +24 -0
  51. package/skills/reverse-engineer-anything/manifest.json +25 -0
  52. package/skills/reverse-engineer-anything/references/evidence-workflows.md +176 -0
@@ -1 +1 @@
1
- import{t,r as y,j as s}from"./styles-f5xRqRwH.js";import{_ as Y,u as Z,bf as ee,D as R,G as se,T as te,n as B,A as z}from"./App-Ba5tz_33.js";import{r as ne,i as ie}from"./index-CBQesSyk.js";import{S as q}from"./SignedInSites-Dk5VcFKc.js";import{P as re}from"./PlacesRail-CiZjMESo.js";function G(i){return i.map(({id:l,name:x,browser:c})=>({id:l,name:x,...c?{browser:c}:{}}))}function ae(i,l){return{browserProfiles:G(l),expectedBrowserProfiles:G(i)}}function oe(){return`profile-${Y().replaceAll("-","")}`}function J(i,l){const x=i.filter(g=>g.browserProfile===l&&g.busy);if(!x.length)return null;const c=x.map(g=>g.name).join(", ");return x.length===1?t("settings.profiles.busyOne",{names:c}):t("settings.profiles.busyMany",{names:c})}function le(i,l){return i&&l?{threadId:l}:{}}function ue(i,l){const x=new URLSearchParams(l).toString();return x?`${i}${i.includes("?")?"&":"?"}${x}`:i}function pe({bot:i,onProfileChanged:l,disabled:x=!1}){const{state:c,dispatch:g,flushBotPatches:_}=Z(),r=c.config?.browserProfiles??[],v=c.config?.browserEngine?.myChrome===!0,b=c.config?.browserEngine?.myChromeOn,E=c.config?.browserEngine?.myChromeLendable===!0,w=c.bots??[],o=i?w.find(e=>e.id===i.id)??i:void 0,[O,L]=y.useState(null),[S,f]=y.useState(!1),[N,A]=y.useState(""),[h,j]=y.useState(null),[F,u]=y.useState(""),k=y.useId(),a=S||x||O!==!0;y.useEffect(()=>{let e=!0;return ne().then(n=>{e&&L(ie(n))}),()=>{e=!1}},[]);const T=async e=>{if(u(e instanceof Error?e.message:t("settings.profiles.saveError")),e instanceof z&&e.status===409)try{const n=await B("/api/config");g({type:"configStatus",config:n})}catch{u(t("settings.profiles.refreshError"))}e instanceof z&&(e.status===401||e.status===403)&&L(!1)},C=async e=>{try{const n=await B("/api/config",{method:"PATCH",body:JSON.stringify(ae(r,e))});return g({type:"configStatus",config:n}),!0}catch(n){return await T(n),!1}},K=async()=>{if(!(a||!N.trim()||r.length>=20)){f(!0),u("");try{await C([...r,{id:oe(),name:N.trim()}])&&A("")}finally{f(!1)}}},Q=async()=>{if(!(a||!h?.name.trim())){if(!r.some(e=>e.id===h.id)){u(t("settings.profiles.removed"));return}f(!0),u("");try{await C(r.map(e=>e.id===h.id?{...e,name:h.name.trim()}:e))&&j(null)}finally{f(!1)}}},V=async e=>{if(a)return;const n=J(w,e.id);if(n)return u(n);const p=w.filter(m=>m.browserProfile===e.id),$=p.length?` ${t("settings.profiles.deleteUsers",{names:p.map(m=>m.name).join(", ")})}`:"";if(window.confirm(t("settings.profiles.confirm",{name:e.name,bots:$}))){f(!0),u("");try{await C(r.filter(m=>m.id!==e.id))&&(h?.id===e.id&&j(null),o?.browserProfile===e.id&&l?.())}finally{f(!1)}}},W=async(e,n)=>{if(!(a||(e.browser??"")===n)){f(!0),u("");try{await C(r.map(p=>p.id===e.id?{...p,browser:n==="chrome"?"chrome":void 0}:p))}finally{f(!1)}}},X=async e=>{if(!(a||!o||o.busy||e===(o.browserProfile??""))){f(!0),u("");try{await _(o.id);const n=await B(`/api/bots/${encodeURIComponent(o.id)}`,{method:"PATCH",body:JSON.stringify({browserProfile:e||null})});g({type:"botPatched",bot:n.bot}),l?.()}catch(n){await T(n)}finally{f(!1)}}};if(O===!1)return s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.profiles.ownerOnly")});const I="min-w-0 flex-1 rounded-md border border-hairline/40 bg-inset px-2.5 py-2 text-[13px] text-ink outline-none focus:border-accent disabled:opacity-50",P="shrink-0 rounded-md bg-control px-2.5 py-2 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-50",d=o?.browserProfile??"",M=r.find(e=>e.id===d),U=e=>w.filter(n=>n.browserProfile===e).map(n=>n.name),D=e=>e?.browser==="chrome"&&(v||E),H=s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeHint")}),b&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeLent",{name:b.name,device:ee(b.device)})}),b?.online===!1&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeLentOffline",{name:b.name})})]});return s.jsxs("div",{className:"flex min-w-0 flex-col gap-3","aria-busy":S,children:[o&&s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:`${k}-profile`,className:"text-[12px] font-medium text-ink",children:t("settings.profiles.browserSession")}),s.jsxs(R,{className:"w-full",id:`${k}-profile`,value:d,disabled:a||o.busy,onChange:e=>{X(e.target.value)},children:[s.jsx("option",{value:"",children:t("settings.profiles.own")}),r.map(e=>s.jsx("option",{value:e.id,children:e.name},e.id)),s.jsx("option",{value:"guest",children:t("settings.profiles.temporary")}),d&&d!=="guest"&&!r.some(e=>e.id===d)?s.jsx("option",{value:d,disabled:!0,children:t("settings.profiles.removed")}):null]}),s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:o.busy?t("settings.profiles.stopToSwitch"):d==="guest"?t("settings.profiles.temporaryHint"):t("settings.profiles.sharedHint")}),D(M)?s.jsxs(s.Fragment,{children:[H,!v&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeShare")})]}):(d===""||M)&&s.jsx(q,{target:{bot:o.id},scope:le(c.config?.team,i?.threadId),sharedBy:d?U(d):[o.name],disabled:a},`${o.id}:${d}`)]}),s.jsxs("details",{open:!o,className:"min-w-0",children:[s.jsx("summary",{className:"cursor-pointer text-[12px] font-medium text-ink-secondary hover:text-ink",children:t("settings.profiles.manage")}),s.jsxs("div",{className:"mt-3 flex flex-col gap-3",children:[s.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:e=>{e.preventDefault(),K()},children:[s.jsx("label",{htmlFor:`${k}-new`,className:"sr-only",children:t("settings.profiles.newName")}),s.jsx("input",{id:`${k}-new`,value:N,onChange:e=>A(e.target.value),maxLength:40,required:!0,disabled:a||r.length>=20,placeholder:t("settings.profiles.newName"),className:I}),s.jsxs("button",{type:"submit",disabled:a||!N.trim()||r.length>=20,className:`${P} flex items-center gap-1`,children:[s.jsx(re,{size:13}),t("settings.profiles.create")]})]}),r.length>=20&&s.jsx("p",{className:"text-[11px] text-ink-secondary",children:t("settings.profiles.limit")}),!v&&r.length>0&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t(E?"settings.profiles.myChromeShare":"settings.profiles.myChromeUnavailable")}),!r.length&&s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.profiles.sharedEmpty")}),s.jsx("div",{className:"divide-y divide-hairline/30",children:r.map(e=>{const n=U(e.id),p=J(w,e.id),$=D(e);return s.jsxs("div",{className:"flex flex-col gap-1 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(se,{size:14,className:"shrink-0 text-ink-secondary"}),h?.id===e.id?s.jsxs("form",{className:"flex min-w-0 flex-1 flex-wrap gap-2",onSubmit:m=>{m.preventDefault(),Q()},children:[s.jsx("input",{autoFocus:!0,value:h.name,onChange:m=>j({id:e.id,name:m.target.value}),maxLength:40,required:!0,disabled:a,className:I,"aria-label":t("settings.profiles.nameAria")}),s.jsx("button",{type:"submit",disabled:a||!h.name.trim(),className:P,children:t("common.save")}),s.jsx("button",{type:"button",disabled:S,onClick:()=>j(null),className:P,children:t("common.cancel")})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",disabled:a,onClick:()=>{j({id:e.id,name:e.name}),u("")},className:"min-w-0 flex-1 truncate text-left text-[13px] font-medium text-ink hover:underline disabled:opacity-50",title:t("settings.profiles.rename"),children:e.name}),s.jsxs("button",{type:"button",onClick:()=>{V(e)},disabled:a||!!p,title:p??t("settings.profiles.deleteTitle"),"aria-label":`${t("common.delete")} ${e.name}`,className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-danger disabled:opacity-50",children:[s.jsx(te,{size:13}),t("common.delete")]})]})]}),s.jsx("p",{className:"break-words pl-6 text-[11px] text-ink-secondary",children:n.length?t("settings.profiles.usedBy",{names:n.join(", ")}):t("settings.profiles.notInUse")}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-2 pl-6 pt-1",children:[s.jsxs("label",{className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[t("settings.profiles.browserLabel"),s.jsxs(R,{size:"sm",value:e.browser??"",disabled:a,onChange:m=>{W(e,m.target.value)},children:[s.jsx("option",{value:"",children:t("settings.profiles.builtIn")}),s.jsx("option",{value:"chrome",disabled:!v,children:t("settings.profiles.myChrome")})]})]}),$?H:s.jsx(q,{target:{profile:e.id},sharedBy:n,disabled:a})]})]},e.id)})})]})]}),F&&s.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:F})]})}export{pe as B,le as b,ue as w};
1
+ import{t,r as y,j as s}from"./styles-f5xRqRwH.js";import{_ as Y,u as Z,bf as ee,D as R,G as se,T as te,n as B,A as z}from"./App-x36HXaXk.js";import{r as ne,i as ie}from"./index-DVxCxmdg.js";import{S as q}from"./SignedInSites-BVCXgsGL.js";import{P as re}from"./PlacesRail-CiZjMESo.js";function G(i){return i.map(({id:l,name:x,browser:c})=>({id:l,name:x,...c?{browser:c}:{}}))}function ae(i,l){return{browserProfiles:G(l),expectedBrowserProfiles:G(i)}}function oe(){return`profile-${Y().replaceAll("-","")}`}function J(i,l){const x=i.filter(g=>g.browserProfile===l&&g.busy);if(!x.length)return null;const c=x.map(g=>g.name).join(", ");return x.length===1?t("settings.profiles.busyOne",{names:c}):t("settings.profiles.busyMany",{names:c})}function le(i,l){return i&&l?{threadId:l}:{}}function ue(i,l){const x=new URLSearchParams(l).toString();return x?`${i}${i.includes("?")?"&":"?"}${x}`:i}function pe({bot:i,onProfileChanged:l,disabled:x=!1}){const{state:c,dispatch:g,flushBotPatches:_}=Z(),r=c.config?.browserProfiles??[],v=c.config?.browserEngine?.myChrome===!0,b=c.config?.browserEngine?.myChromeOn,E=c.config?.browserEngine?.myChromeLendable===!0,w=c.bots??[],o=i?w.find(e=>e.id===i.id)??i:void 0,[O,L]=y.useState(null),[S,f]=y.useState(!1),[N,A]=y.useState(""),[h,j]=y.useState(null),[F,u]=y.useState(""),k=y.useId(),a=S||x||O!==!0;y.useEffect(()=>{let e=!0;return ne().then(n=>{e&&L(ie(n))}),()=>{e=!1}},[]);const T=async e=>{if(u(e instanceof Error?e.message:t("settings.profiles.saveError")),e instanceof z&&e.status===409)try{const n=await B("/api/config");g({type:"configStatus",config:n})}catch{u(t("settings.profiles.refreshError"))}e instanceof z&&(e.status===401||e.status===403)&&L(!1)},C=async e=>{try{const n=await B("/api/config",{method:"PATCH",body:JSON.stringify(ae(r,e))});return g({type:"configStatus",config:n}),!0}catch(n){return await T(n),!1}},K=async()=>{if(!(a||!N.trim()||r.length>=20)){f(!0),u("");try{await C([...r,{id:oe(),name:N.trim()}])&&A("")}finally{f(!1)}}},Q=async()=>{if(!(a||!h?.name.trim())){if(!r.some(e=>e.id===h.id)){u(t("settings.profiles.removed"));return}f(!0),u("");try{await C(r.map(e=>e.id===h.id?{...e,name:h.name.trim()}:e))&&j(null)}finally{f(!1)}}},V=async e=>{if(a)return;const n=J(w,e.id);if(n)return u(n);const p=w.filter(m=>m.browserProfile===e.id),$=p.length?` ${t("settings.profiles.deleteUsers",{names:p.map(m=>m.name).join(", ")})}`:"";if(window.confirm(t("settings.profiles.confirm",{name:e.name,bots:$}))){f(!0),u("");try{await C(r.filter(m=>m.id!==e.id))&&(h?.id===e.id&&j(null),o?.browserProfile===e.id&&l?.())}finally{f(!1)}}},W=async(e,n)=>{if(!(a||(e.browser??"")===n)){f(!0),u("");try{await C(r.map(p=>p.id===e.id?{...p,browser:n==="chrome"?"chrome":void 0}:p))}finally{f(!1)}}},X=async e=>{if(!(a||!o||o.busy||e===(o.browserProfile??""))){f(!0),u("");try{await _(o.id);const n=await B(`/api/bots/${encodeURIComponent(o.id)}`,{method:"PATCH",body:JSON.stringify({browserProfile:e||null})});g({type:"botPatched",bot:n.bot}),l?.()}catch(n){await T(n)}finally{f(!1)}}};if(O===!1)return s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.profiles.ownerOnly")});const I="min-w-0 flex-1 rounded-md border border-hairline/40 bg-inset px-2.5 py-2 text-[13px] text-ink outline-none focus:border-accent disabled:opacity-50",P="shrink-0 rounded-md bg-control px-2.5 py-2 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-50",d=o?.browserProfile??"",M=r.find(e=>e.id===d),U=e=>w.filter(n=>n.browserProfile===e).map(n=>n.name),D=e=>e?.browser==="chrome"&&(v||E),H=s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeHint")}),b&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeLent",{name:b.name,device:ee(b.device)})}),b?.online===!1&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeLentOffline",{name:b.name})})]});return s.jsxs("div",{className:"flex min-w-0 flex-col gap-3","aria-busy":S,children:[o&&s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:`${k}-profile`,className:"text-[12px] font-medium text-ink",children:t("settings.profiles.browserSession")}),s.jsxs(R,{className:"w-full",id:`${k}-profile`,value:d,disabled:a||o.busy,onChange:e=>{X(e.target.value)},children:[s.jsx("option",{value:"",children:t("settings.profiles.own")}),r.map(e=>s.jsx("option",{value:e.id,children:e.name},e.id)),s.jsx("option",{value:"guest",children:t("settings.profiles.temporary")}),d&&d!=="guest"&&!r.some(e=>e.id===d)?s.jsx("option",{value:d,disabled:!0,children:t("settings.profiles.removed")}):null]}),s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:o.busy?t("settings.profiles.stopToSwitch"):d==="guest"?t("settings.profiles.temporaryHint"):t("settings.profiles.sharedHint")}),D(M)?s.jsxs(s.Fragment,{children:[H,!v&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeShare")})]}):(d===""||M)&&s.jsx(q,{target:{bot:o.id},scope:le(c.config?.team,i?.threadId),sharedBy:d?U(d):[o.name],disabled:a},`${o.id}:${d}`)]}),s.jsxs("details",{open:!o,className:"min-w-0",children:[s.jsx("summary",{className:"cursor-pointer text-[12px] font-medium text-ink-secondary hover:text-ink",children:t("settings.profiles.manage")}),s.jsxs("div",{className:"mt-3 flex flex-col gap-3",children:[s.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:e=>{e.preventDefault(),K()},children:[s.jsx("label",{htmlFor:`${k}-new`,className:"sr-only",children:t("settings.profiles.newName")}),s.jsx("input",{id:`${k}-new`,value:N,onChange:e=>A(e.target.value),maxLength:40,required:!0,disabled:a||r.length>=20,placeholder:t("settings.profiles.newName"),className:I}),s.jsxs("button",{type:"submit",disabled:a||!N.trim()||r.length>=20,className:`${P} flex items-center gap-1`,children:[s.jsx(re,{size:13}),t("settings.profiles.create")]})]}),r.length>=20&&s.jsx("p",{className:"text-[11px] text-ink-secondary",children:t("settings.profiles.limit")}),!v&&r.length>0&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t(E?"settings.profiles.myChromeShare":"settings.profiles.myChromeUnavailable")}),!r.length&&s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.profiles.sharedEmpty")}),s.jsx("div",{className:"divide-y divide-hairline/30",children:r.map(e=>{const n=U(e.id),p=J(w,e.id),$=D(e);return s.jsxs("div",{className:"flex flex-col gap-1 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(se,{size:14,className:"shrink-0 text-ink-secondary"}),h?.id===e.id?s.jsxs("form",{className:"flex min-w-0 flex-1 flex-wrap gap-2",onSubmit:m=>{m.preventDefault(),Q()},children:[s.jsx("input",{autoFocus:!0,value:h.name,onChange:m=>j({id:e.id,name:m.target.value}),maxLength:40,required:!0,disabled:a,className:I,"aria-label":t("settings.profiles.nameAria")}),s.jsx("button",{type:"submit",disabled:a||!h.name.trim(),className:P,children:t("common.save")}),s.jsx("button",{type:"button",disabled:S,onClick:()=>j(null),className:P,children:t("common.cancel")})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",disabled:a,onClick:()=>{j({id:e.id,name:e.name}),u("")},className:"min-w-0 flex-1 truncate text-left text-[13px] font-medium text-ink hover:underline disabled:opacity-50",title:t("settings.profiles.rename"),children:e.name}),s.jsxs("button",{type:"button",onClick:()=>{V(e)},disabled:a||!!p,title:p??t("settings.profiles.deleteTitle"),"aria-label":`${t("common.delete")} ${e.name}`,className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-danger disabled:opacity-50",children:[s.jsx(te,{size:13}),t("common.delete")]})]})]}),s.jsx("p",{className:"break-words pl-6 text-[11px] text-ink-secondary",children:n.length?t("settings.profiles.usedBy",{names:n.join(", ")}):t("settings.profiles.notInUse")}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-2 pl-6 pt-1",children:[s.jsxs("label",{className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[t("settings.profiles.browserLabel"),s.jsxs(R,{size:"sm",value:e.browser??"",disabled:a,onChange:m=>{W(e,m.target.value)},children:[s.jsx("option",{value:"",children:t("settings.profiles.builtIn")}),s.jsx("option",{value:"chrome",disabled:!v,children:t("settings.profiles.myChrome")})]})]}),$?H:s.jsx(q,{target:{profile:e.id},sharedBy:n,disabled:a})]})]},e.id)})})]})]}),F&&s.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:F})]})}export{pe as B,le as b,ue as w};
@@ -1 +1 @@
1
- import{j as e,Q as z,R as ve,T as U,t as n,U as se,V as Q,W as X,Y as pe,Z as He,$ as Ee,a0 as ze,a1 as Ue,a2 as qe,a3 as G,a as ue,a4 as $e,a5 as Me,r as c,a6 as We,a7 as Ce,a8 as Ke,X as Ve,a9 as Ge,aa as Je,ab as Qe,ac as Xe}from"./styles-f5xRqRwH.js";import{L as Ye,o as Ze,p as fe,q as we,s as Ae,v as et,C as tt,w as nt,t as J,x as st,y as at,z as lt,F as ot,G as Le,S as dt,H as ct,I as rt,J as it}from"./PlacesRail-CiZjMESo.js";import{u as ut}from"./App-Ba5tz_33.js";import"./monitor-BRnjhHD0.js";import"./index-CBQesSyk.js";import"./MenuMotion-B8impuLz.js";function pt({name:t,color:l,busy:o,interest:d,openFailed:s,onInterest:u,onOpen:p}){return e.jsxs("div",{"data-cloud-add":"has-cloud",className:z,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(ve,{color:l,size:32}),e.jsx(U,{title:n("cloudBuy.one.title"),sub:n("cloudBuy.one.sub",{name:t})})]}),e.jsxs("div",{className:se,children:[d!=="sent"&&e.jsx("button",{type:"button",className:Q,disabled:o,onClick:u,children:n("cloudBuy.one.email")}),e.jsx("button",{type:"button",className:X,disabled:o,onClick:p,children:n("cloudBuy.setup.open",{name:t})})]}),e.jsxs("div",{"aria-live":"polite",className:"text-[13px] leading-[18px] empty:-mt-5",children:[d==="sent"&&e.jsx("p",{className:"text-ink-secondary",children:n("cloudBuy.one.thanks")}),d==="failed"&&e.jsx("p",{role:"alert",className:"text-danger",children:n("cloudBuy.one.failed")}),s&&e.jsx("p",{role:"alert",className:"text-danger",children:n("cloudBuy.openFailed",{name:t})})]})]})}function ie({kind:t,line:l,onRetry:o,onClose:d}){return e.jsxs("div",{"data-cloud-add":t,className:z,children:[e.jsx(U,{title:n("cloudAdd.title")}),l?e.jsx("p",{role:"alert",className:"text-[14px] leading-5 text-ink",children:l}):e.jsxs("p",{role:"status",className:"flex items-center gap-2 text-[13px] leading-[18px] text-ink-secondary",children:[e.jsx(Ye,{size:14,className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}),n("cloudAdd.checking")]}),e.jsxs("div",{className:se,children:[e.jsx("button",{type:"button",className:Q,onClick:d,children:n("cloudAdd.close")}),o&&e.jsx("button",{type:"button",className:X,onClick:o,children:n("cloudAdd.tryAgain")})]})]})}function ft({plan:t,offer:l,browser:o,late:d,link:s,email:u,busy:p,copied:v,failed:N,onReopen:k,onCopy:I,onChangePlan:q}){const y=l?.plans.find($=>$.tier===t)??null,E=y?Ze(y):fe(t),A=y?.trialDays===1?n("cloudBuy.pay.planTrial.one",{plan:E,due:we(0)}):y?.trialDays?n("cloudBuy.pay.planTrial.many",{plan:E,days:y.trialDays,due:we(0)}):y?n("cloudBuy.pay.planPaid",{plan:E,price:Ae(y.amount/100)}):E;return e.jsxs("div",{"data-cloud-add":d?"waiting-late":o==="signin"?"waiting-signin":"waiting",className:z,children:[e.jsx(U,{title:d?n("cloudBuy.pay.lateTitle"):n("cloudAdd.browserTitle"),sub:d?n("cloudBuy.pay.lateSub"):n(o==="signin"?"cloudBuy.pay.subSignIn":"cloudBuy.pay.sub")}),e.jsx(pe,{items:[{key:"signed-in",state:"done",title:n("cloudBuy.pay.signedIn"),detail:u},{key:"payment",state:"now",title:n("cloudBuy.pay.waiting"),detail:A},{key:"setup",state:"next",title:n("cloudBuy.pay.setup"),detail:n("cloudBuy.pay.setupHint")}]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",className:d?X:Q,disabled:p,onClick:k,children:[e.jsx(et,{size:14,"aria-hidden":"true"}),n("cloudAdd.reopenCheckout")]}),s&&e.jsxs("button",{type:"button",className:Q,disabled:p,onClick:I,children:[e.jsx(tt,{size:14,"aria-hidden":"true"}),n("cloudBuy.pay.copy")]}),e.jsx("button",{type:"button",className:`${He} ms-1 px-1 py-1`,onClick:q,children:n("cloudAdd.changePlan")})]}),e.jsxs("div",{"aria-live":"polite",className:"text-[13px] leading-[18px] empty:-mt-5",children:[v&&e.jsx("p",{className:"text-ink-secondary",children:n("cloudBuy.pay.copied")}),N&&e.jsx("p",{role:"alert",className:"text-danger",children:n("cloudBuy.pay.failed")})]})]})}const R=[["reserving","cloudHome.step.reserving"],["storage","cloudHome.step.storage"],["starting","cloudBuy.step.starting"],["checking","cloudHome.step.checking"]];function mt({tier:t,trial:l,credit:o},d){if(d)return n("cloudAdd.receivedTitle");const s=fe(t??l?.tier??void 0);return l?o?n("cloudBuy.setup.badgeCredit",{plan:s,credit:Ae(o.grantedUsd)}):n("cloudBuy.setup.badgeTrial",{plan:s}):n("cloudBuy.setup.badgePaid",{plan:s})}function xt({started:t,received:l,step:o,slow:d,ready:s,sleeps:u=!1,name:p,typed:v,color:N,counting:k,busy:I,openFailed:q,onName:y,onColor:E,onOpen:A,onNotNow:$}){const _=s?R.length:Math.max(0,R.findIndex(([i])=>i===o)),C=fe(t.tier??t.trial?.tier??void 0);return e.jsxs("div",{"data-cloud-add":s?"ready":l?"received":"starting","data-cloud-setup":s?"ready":o??"reserving",className:z,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(ze,{children:mt(t,l)}),e.jsx(U,{title:s?n("cloudBuy.ready.title",{name:p}):n("cloudBuy.setup.title"),sub:s?n("cloudBuy.ready.sub"):l?n("cloudAccount.purchaseNoteNoDate"):n("cloudBuy.setup.sub")})]}),e.jsxs("div",{className:"grid gap-6 sm:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ee,{value:_/R.length,label:n("cloudBuy.setup.progress")}),e.jsx(pe,{label:n("cloudBuy.setup.progress"),items:R.map(([i,w],j)=>({key:i,title:n(w,{name:p}),state:j<_?"done":j===_?"now":"next"}))}),d&&!s&&e.jsx("p",{role:"status",className:"px-3 text-[13px] leading-[18px] text-ink-secondary",children:n("cloudHome.slow")})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"cloud-add-name",className:"text-[13px] leading-[18px] text-ink-secondary",children:n("cloudBuy.setup.name")}),e.jsx("input",{id:"cloud-add-name",value:v,maxLength:qe,placeholder:n("cloudSetup.myCloud"),autoComplete:"off",spellCheck:!1,onChange:i=>y(i.target.value),className:Ue})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{id:"cloud-add-color",className:"text-[13px] leading-[18px] text-ink-secondary",children:n("cloudBuy.setup.color")}),e.jsx("div",{role:"radiogroup","aria-labelledby":"cloud-add-color",className:"flex flex-wrap gap-2",children:G.map(i=>e.jsx("button",{type:"button",role:"radio","aria-checked":i===N,"aria-label":n(Me[i]),tabIndex:i===N?0:-1,"data-color":i,onClick:()=>E(i),onKeyDown:w=>{const j=G.indexOf(i),M=w.key==="ArrowRight"||w.key==="ArrowDown"?1:w.key==="ArrowLeft"||w.key==="ArrowUp"?-1:0;if(!M)return;w.preventDefault();const Y=G[(j+M+G.length)%G.length];E(Y),w.currentTarget.parentElement?.querySelector(`[data-color="${Y}"]`)?.focus()},style:{background:$e(i)},className:ue("size-[26px] rounded-lg border-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",i===N?"border-ink shadow-[inset_0_0_0_2px_var(--color-app)]":"border-transparent")},i))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-[13px] leading-[18px] text-ink-secondary",children:n("cloudBuy.setup.preview")}),e.jsxs("span",{"data-cloud-preview":!0,className:"inline-flex max-w-full items-center gap-2 self-start rounded-[12px] border-[0.5px] border-ink/10 bg-menu py-1.5 pe-3 ps-1.5",children:[e.jsx(ve,{color:N}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-[13px] font-medium leading-4 text-ink",children:p}),e.jsx("span",{className:"block truncate text-[12px] text-ink-tertiary",children:n(u?"cloudBuy.setup.previewLineSleeps":"cloudBuy.setup.previewLine",{plan:C})})]})]})]})]})]}),s&&k===null&&e.jsx("p",{className:"text-[13px] leading-[18px] text-ink-tertiary",children:n("cloudBuy.ready.hint",{name:p})}),e.jsxs("div",{className:se,children:[k!==null&&e.jsx("span",{role:"status",className:"me-1 text-[13px] text-ink-secondary",children:n("cloudBuy.setup.openingIn",{seconds:k})}),k!==null&&e.jsx("button",{type:"button",className:Q,onClick:$,children:n("notice.notNow")}),e.jsx("button",{type:"button",className:X,disabled:!s||I,onClick:A,children:n("cloudBuy.setup.open",{name:p})})]}),q&&e.jsx("p",{role:"alert",className:"-mt-2 text-end text-[13px] leading-[18px] text-danger",children:n("cloudBuy.openFailed",{name:p})})]})}function yt({team:t,step:l,slow:o}){const d=Math.max(0,R.findIndex(([u])=>u===l)),s=t??n("cloudBuy.team.unnamed");return e.jsxs("div",{"data-cloud-add":"team-starting","data-cloud-setup":l??"reserving",className:z,children:[e.jsx(U,{title:n("cloudBuy.team.setupTitle"),sub:n("cloudBuy.team.setupSub")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ee,{value:d/R.length,label:n("cloudBuy.setup.progress")}),e.jsx(pe,{label:n("cloudBuy.setup.progress"),items:R.map(([u,p],v)=>({key:u,title:n(p,{name:s}),state:v<d?"done":v===d?"now":"next"}))}),o&&e.jsx("p",{role:"status",className:"px-3 text-[13px] leading-[18px] text-ink-secondary",children:n("cloudHome.slow")})]})]})}function gt({name:t,busy:l,openFailed:o,onOpen:d}){return e.jsxs("div",{"data-cloud-add":"team-ready",className:z,children:[e.jsx(U,{title:n("cloudBuy.team.readyTitle"),sub:n("cloudBuy.team.readySub",{name:t})}),e.jsx("p",{className:"text-[13px] leading-[18px] text-ink-tertiary",children:n("cloudBuy.ready.hint",{name:t})}),e.jsx("div",{className:se,children:e.jsx("button",{type:"button","data-autofocus":!0,className:X,disabled:l,onClick:d,children:n("cloudBuy.setup.open",{name:t})})}),o&&e.jsx("p",{role:"alert",className:"-mt-2 text-end text-[13px] leading-[18px] text-danger",children:n("cloudBuy.openFailed",{name:t})})]})}function ht({view:t,ui:l,actions:o}){switch(t.kind){case"checking":return e.jsx(ie,{kind:"checking",line:null,onClose:o.close});case"unreachable":return e.jsx(ie,{kind:"unreachable",line:n("cloudAdd.unreachable"),onRetry:o.retry,onClose:o.close});case"error":return e.jsx(ie,{kind:`error-${t.reason}`,line:n(t.reason==="rate-limited"?"cloudAdd.rateLimited":"cloudAdd.failed"),onRetry:o.retry,onClose:o.close});case"offer":return e.jsx(ct,{offer:t.offer,current:l.current,now:l.now,busy:l.busy,signedOut:t.signedOut,notice:t.notice?n(t.notice==="code-expired"?"cloudAdd.codeExpired":t.notice==="signin-ended"?"cloudAdd.signInEnded":t.notice==="terms"?"cloudBuy.termsChanged":"cloudAdd.preparing"):null,onStart:o.start,onSignIn:o.signIn});case"sign-in":return e.jsx(dt,{phase:t.phase,email:l.email,code:l.code,profileEmail:l.profileEmail,busy:l.busy,now:l.now,onBack:o.back,onEmail:o.email,onSend:o.sendCode,onChangeEmail:o.changeEmail,onCode:o.code,onResend:o.resend,onBrowser:o.browser});case"signing-in":return e.jsx(ot,{code:t.code,checkout:t.checkout,busy:l.busy,trial:l.offerShown?!!Le(l.offerShown,l.chosen).trialDays:!1,onReopen:o.reopenBrowser,onCancel:o.cancelSignIn});case"waiting":return e.jsx(ft,{plan:t.plan,offer:l.offerShown,browser:t.browser,late:t.late,link:t.link,email:t.email,busy:l.busy,copied:l.copied,failed:l.payFailed,onReopen:o.reopenCheckout,onCopy:o.copyLink,onChangePlan:o.changePlan});case"starting":case"ready":return e.jsx(xt,{started:t,received:t.kind==="starting"&&t.received,step:t.kind==="starting"?t.step:null,slow:t.kind==="starting"&&t.slow,ready:t.kind==="ready",sleeps:lt(t,l.offerShown),name:l.look.name,typed:l.look.typed,color:l.look.color,counting:l.counting,busy:l.busy,openFailed:l.openFailed,onName:o.name,onColor:o.color,onOpen:o.openCloud,onNotNow:o.notNow});case"has-cloud":return e.jsx(pt,{name:l.look.name,color:l.look.color,busy:l.busy,interest:l.interest,openFailed:l.openFailed,onInterest:o.interest,onOpen:o.openCloud});case"team-starting":return e.jsx(yt,{team:t.team,step:t.step,slow:t.slow});case"team-ready":return e.jsx(gt,{name:t.team.name,busy:l.busy,openFailed:l.openFailed,onOpen:()=>o.openTeam(t.team.id)});case"settings":return null}}const bt={offer:"max-w-[920px]",starting:"max-w-[720px]",ready:"max-w-[720px]"};function Be({kind:t,staging:l,onClose:o,children:d}){return e.jsx("div",{className:"ui-scrim fixed inset-0 z-[60] flex items-center justify-center p-4 sm:p-6",onMouseDown:s=>s.stopPropagation(),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"cloud-add-title","data-cloud-add-dialog":!0,tabIndex:-1,className:ue(Xe,"group/sheet animate-pop-in relative max-h-full w-full overflow-y-auto overscroll-contain outline-none",bt[t]??"max-w-[540px]"),children:[e.jsx("button",{type:"button",onClick:o,"aria-label":n("cloudAdd.close"),className:ue(Je,Ge,"absolute end-4 top-4 z-10"),children:e.jsx(Ve,{size:16})}),l&&e.jsx(Qe,{className:"absolute end-14 top-[22px] z-10 group-has-[[data-night-card]]/sheet:bg-app"}),d]})})}const kt=["offer","checking","unreachable","waiting","sign-in","signing-in"],jt="button:not([disabled]):not([tabindex='-1']), input:not([disabled]):not([tabindex='-1']), [href], [tabindex='0']",St=t=>t.status==="connected"&&t.entitlement?.plan==="free"&&!t.purchase&&!t.machine,Nt=t=>t?.status==="connected"&&t.entitlement?.plan==="pro"&&t.entitlement.status==="active"?t.entitlement.tier??"pro":null;function Lt({now:t=Date.now}){const{state:l,dispatch:o}=ut(),d=l.cloudAdd,s=window.ogb?.remoteClient?.active?void 0:window.ogb?.cloudAccount,[u,p]=c.useState(null),[v,N]=c.useState(void 0),[k,I]=c.useState(null),[q,y]=c.useState(null),[E,A]=c.useState(!1),[$,_]=c.useState(!1),[C,i]=c.useState(!1),[w,j]=c.useState(!1),[M,Y]=c.useState(0),[Z,me]=c.useState([]),[b,h]=c.useState(null),[T,O]=c.useState({email:"",code:""}),[B,ee]=c.useState(null),[F,P]=c.useState(null),[H,S]=c.useState(null),[,Ie]=c.useState(0),[xe,ae]=c.useState(!1),[Te,le]=c.useState(!1),[Oe,Fe]=c.useState(!1),L=!!(d&&s),oe=l.config?.profile?.email?.trim()||null,de=at();c.useEffect(()=>{if(!L||!s)return;let a=!0,r=!1;const g=s.onState(x=>{r=!0,a&&p(x)});return s.state().then(x=>{a&&!r&&p(x)}).catch(()=>{}),()=>{a=!1,g()}},[L,s]);const m=L?nt(u,v,{now:t(),error:q,choosing:$,conflict:E,signIn:b,arrived:xe,terms:Te}):null,ye=L&&m&&kt.includes(m.kind)&&u?`${u.status}:${JSON.stringify(u.offer??null)}:${M}`:null;c.useEffect(()=>{if(!ye||!s?.offer)return;let a=!0;return s.offer().then(r=>{a&&N(r)},()=>{a&&N(null)}),()=>{a=!1}},[ye,s]);const ce=n("cloudSetup.myCloud"),W={typed:B?.typed??ce,color:B?.color??Ce,name:We(B?.typed??ce,ce)},D=()=>{b&&s?.signInCancel?.().catch(()=>{}),o({type:"closeCloudAdd"}),y(null),A(!1),_(!1),j(!1),me([]),I(null),h(null),O({email:"",code:""}),ee(null),P(null),S(null),ae(!1),le(!1)};c.useEffect(()=>{if(!L)return;const a=document.activeElement,r=a&&a!==document.body&&typeof a.focus=="function"?a:null;d?.signIn&&(h({step:"email",intent:!1,problem:null}),O({email:oe??"",code:""}));const g=x=>{if(x.key==="Escape"){x.preventDefault(),D();return}if(x.key!=="Tab")return;const V=[...document.querySelector("[data-cloud-add-dialog]")?.querySelectorAll(jt)??[]];if(!V.length)return;x.preventDefault();const Ne=V.indexOf(document.activeElement);V[Ne===-1?0:(Ne+(x.shiftKey?-1:1)+V.length)%V.length].focus()};return window.addEventListener("keydown",g,!0),(document.querySelector("#cloud-add-title")??document.querySelector("[data-cloud-add-dialog]"))?.focus(),()=>{window.removeEventListener("keydown",g,!0),r?.isConnected&&r.focus()}},[L]),c.useEffect(()=>{if(!(!L||!s?.sheet||de))return s.sheet(!0).catch(()=>{}),()=>{s.sheet?.(!1).catch(()=>{})}},[L,s,de]);const f=m?.kind??null,te=m?.kind==="sign-in"?`sign-in-${m.phase.step}`:f;c.useEffect(()=>{!te||te==="checking"||te==="settings"||document.activeElement?.closest?.("[data-cloud-add-dialog]")||(document.querySelector("[data-cloud-add-dialog] [data-autofocus]")??document.querySelector("#cloud-add-title"))?.focus()},[te]),c.useEffect(()=>{(f==="waiting"||f==="starting"||f==="ready")&&!xe&&ae(!0),(f==="ready"||f==="team-ready")&&s?.readySeen?.().catch(()=>{})},[f]),c.useEffect(()=>{if(!f||!d)return;if(f==="settings"){D(),o({type:"toggleAppSettings",open:!0,section:"cloudAccount"});return}if(f==="checking")return;const a=Z.length===0;a&&J("cloud_dialog_shown",{source:d.source}),["starting","ready"].includes(f)&&Z.includes(f),(a||!Z.includes(f))&&me([...Z,f])},[f]),c.useEffect(()=>{if(!f||!["starting","ready","has-cloud"].includes(f)||B||!s?.look)return;let a=!0;return s.look().then(r=>{a&&ee({typed:r.name,color:Ke(r.color)??Ce,dirty:f!=="has-cloud"})},()=>{}),()=>{a=!1}},[f]),c.useEffect(()=>{if(!B?.dirty||!s?.setLook)return;const a=setTimeout(()=>{s.setLook?.(W.name,B.color).catch(()=>{})},400);return()=>clearTimeout(a)},[B?.typed,B?.color]),c.useEffect(()=>{f!=="ready"||F!==null||P(!de&&typeof document.hasFocus=="function"&&document.hasFocus()?3:"off")},[f]);const ge=b?.step==="code"?b.resendAt:0;c.useEffect(()=>{if(!ge||ge<=t())return;const a=setTimeout(()=>Ie(t()),1e3);return()=>clearTimeout(a)}),c.useEffect(()=>{if(H!=="copied")return;const a=setTimeout(()=>S(null),2500);return()=>clearTimeout(a)},[H]);const ne=a=>{C||(i(!0),j(!1),a().catch(()=>y("failed")).finally(()=>i(!1)))},he=()=>{C||!s||(i(!0),j(!1),P("done"),(async()=>{B?.dirty&&s.setLook&&await s.setLook(W.name,B.color).catch(()=>{}),await s.connectHome()})().then(()=>D(),()=>j(!0)).finally(()=>i(!1)))},De=a=>{C||!s?.openTeam||(i(!0),j(!1),s.openTeam(a).then(()=>D(),()=>j(!0)).finally(()=>i(!1)))};c.useEffect(()=>{if(typeof F!="number")return;const a=setTimeout(()=>{F>1?P(F-1):he()},1e3);return()=>clearTimeout(a)},[F]);const be=typeof F=="number";if(c.useEffect(()=>{if(!be)return;const a=()=>P("off");return window.addEventListener("blur",a),()=>window.removeEventListener("blur",a)},[be]),!L||!m||!d||!s||m.kind==="settings")return null;if(m.kind==="has-cloud"&&u?.status==="connected"&&u.clouds&&window.ogb?.cloudAdd&&(u.addCloud?.canAdd!==!1||u.adding&&!u.adding.done))return e.jsx(Be,{kind:Oe?"offer":"has-cloud",staging:u.staging===!0,onClose:D,children:e.jsx(st,{onClose:D,onFirstCloud:()=>{},onWide:Fe,source:d.source})});const K=v??null,ke=()=>m.kind==="waiting"&&!k?m.plan:K?Le(K,k).tier:null,re=async a=>{if(!a||!s.checkout){y("failed");return}K?.plans.find(x=>x.tier===a)?.trialDays;const r=await s.checkout(a,d.source),g=r.outcome;p(r.state),g==="opened"||g==="signing-in"?(_(!1),y(null),A(!1),S(null),le(!1),J("cloud_checkout_opened",{source:d.source})):g==="rate-limited"?y("rate-limited"):g==="failed"?y("failed"):A(!0)},je=a=>{h({step:"email",intent:a,problem:null}),O({email:T.email||oe||"",code:""})},Se=()=>{if(C||!s.signInStart||!b||b.step==="done")return;const a=b;i(!0),s.signInStart(T.email).then(r=>{r.outcome==="sent"?(h({step:"code",intent:a.intent,email:r.email,resendAt:r.resendAt,problem:null,triesLeft:null,...r.signupOpen===!1?{signupOpen:!1}:{}}),O({email:r.email,code:""}),J("cloud_signin",{source:d.source})):h({...a,problem:r.outcome})},()=>h({...a,problem:"failed"})).finally(()=>i(!1))},_e=a=>{if(!s.signInVerify||b?.step!=="code")return;const r=b,g=r.intent?ke():null;i(!0),(async()=>{try{const x=await s.signInVerify(a);if(x.outcome!=="signed-in"){O({email:T.email,code:""}),h({...r,problem:x.outcome,triesLeft:x.outcome==="wrong-code"?x.triesLeft:null});return}p(x.state),ae(!0),J("cloud_signin",{step:"signed_in",source:d.source}),g&&St(x.state)&&(it(K,x.state.offer,g)?(h({step:"done",intent:!0}),await re(g)):(le(!0),I(g))),h(null),O({email:T.email,code:""})}catch{h({...r,problem:"failed",triesLeft:null})}finally{i(!1)}})()},Re={start:a=>{if(I(a),A(!1),m.kind==="offer"&&m.signedOut&&s.signInStart){je(!0);return}ne(()=>re(a))},signIn:()=>je(!1),back:()=>{h(null),s.signInCancel?.().catch(()=>{})},email:a=>O({email:a,code:T.code}),sendCode:Se,changeEmail:()=>{b&&(h({step:"email",intent:b.intent,problem:null}),s.signInCancel?.().catch(()=>{}))},code:a=>{const r=rt(a);O({email:T.email,code:r}),r.length===8&&!C&&_e(r)},resend:Se,browser:()=>ne(async()=>{const a=b?.intent?ke():null;h(null),await s.signInCancel?.().catch(()=>{}),J("cloud_signin",{source:d.source}),a?await re(a):p(await s.begin())}),reopenBrowser:()=>ne(async()=>p(await s.reopen())),cancelSignIn:()=>ne(async()=>p(await s.cancel())),reopenCheckout:()=>{if(m.kind!=="waiting"||C)return;i(!0),S(null),(s.reopenCheckout?s.reopenCheckout(m.plan,d.source):s.checkout(m.plan,d.source)).then(r=>{p(r.state),r.outcome!=="opened"&&S("pay-failed")},()=>S("pay-failed")).finally(()=>i(!1))},copyLink:()=>{s.copyCheckoutLink?.().then(a=>S(a?"copied":"pay-failed"),()=>S("pay-failed"))},changePlan:()=>{I(m.kind==="waiting"?m.plan:k),_(!0),S(null)},retry:()=>{y(null),A(!1),N(void 0),Y(M+1)},name:a=>ee({typed:a,color:W.color,dirty:!0}),color:a=>ee({typed:W.typed,color:a,dirty:!0}),openCloud:he,openTeam:De,notNow:()=>P("off"),interest:()=>{C||!s.interest||(i(!0),s.interest().then(()=>S("interest-sent"),()=>S("interest-failed")).finally(()=>i(!1)))},close:D},Pe={chosen:k,current:Nt(u),offerShown:K,now:t(),busy:C,openFailed:w,email:T.email,code:T.code,profileEmail:oe,look:W,counting:typeof F=="number"?F:null,copied:H==="copied",payFailed:H==="pay-failed",interest:H==="interest-sent"?"sent":H==="interest-failed"?"failed":null};return e.jsx(Be,{kind:m.kind,staging:u?.staging===!0,onClose:D,children:e.jsx(ht,{view:m,ui:Pe,actions:Re})})}export{Lt as CloudAddDialog,ht as CloudAddPanel,Be as CloudAddSheet};
1
+ import{j as e,Q as z,R as ve,T as U,t as n,U as se,V as Q,W as X,Y as pe,Z as He,$ as Ee,a0 as ze,a1 as Ue,a2 as qe,a3 as G,a as ue,a4 as $e,a5 as Me,r as c,a6 as We,a7 as Ce,a8 as Ke,X as Ve,a9 as Ge,aa as Je,ab as Qe,ac as Xe}from"./styles-f5xRqRwH.js";import{L as Ye,o as Ze,p as fe,q as we,s as Ae,v as et,C as tt,w as nt,t as J,x as st,y as at,z as lt,F as ot,G as Le,S as dt,H as ct,I as rt,J as it}from"./PlacesRail-CiZjMESo.js";import{u as ut}from"./App-x36HXaXk.js";import"./monitor-BRnjhHD0.js";import"./index-DVxCxmdg.js";import"./MenuMotion-B8impuLz.js";function pt({name:t,color:l,busy:o,interest:d,openFailed:s,onInterest:u,onOpen:p}){return e.jsxs("div",{"data-cloud-add":"has-cloud",className:z,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(ve,{color:l,size:32}),e.jsx(U,{title:n("cloudBuy.one.title"),sub:n("cloudBuy.one.sub",{name:t})})]}),e.jsxs("div",{className:se,children:[d!=="sent"&&e.jsx("button",{type:"button",className:Q,disabled:o,onClick:u,children:n("cloudBuy.one.email")}),e.jsx("button",{type:"button",className:X,disabled:o,onClick:p,children:n("cloudBuy.setup.open",{name:t})})]}),e.jsxs("div",{"aria-live":"polite",className:"text-[13px] leading-[18px] empty:-mt-5",children:[d==="sent"&&e.jsx("p",{className:"text-ink-secondary",children:n("cloudBuy.one.thanks")}),d==="failed"&&e.jsx("p",{role:"alert",className:"text-danger",children:n("cloudBuy.one.failed")}),s&&e.jsx("p",{role:"alert",className:"text-danger",children:n("cloudBuy.openFailed",{name:t})})]})]})}function ie({kind:t,line:l,onRetry:o,onClose:d}){return e.jsxs("div",{"data-cloud-add":t,className:z,children:[e.jsx(U,{title:n("cloudAdd.title")}),l?e.jsx("p",{role:"alert",className:"text-[14px] leading-5 text-ink",children:l}):e.jsxs("p",{role:"status",className:"flex items-center gap-2 text-[13px] leading-[18px] text-ink-secondary",children:[e.jsx(Ye,{size:14,className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}),n("cloudAdd.checking")]}),e.jsxs("div",{className:se,children:[e.jsx("button",{type:"button",className:Q,onClick:d,children:n("cloudAdd.close")}),o&&e.jsx("button",{type:"button",className:X,onClick:o,children:n("cloudAdd.tryAgain")})]})]})}function ft({plan:t,offer:l,browser:o,late:d,link:s,email:u,busy:p,copied:v,failed:N,onReopen:k,onCopy:I,onChangePlan:q}){const y=l?.plans.find($=>$.tier===t)??null,E=y?Ze(y):fe(t),A=y?.trialDays===1?n("cloudBuy.pay.planTrial.one",{plan:E,due:we(0)}):y?.trialDays?n("cloudBuy.pay.planTrial.many",{plan:E,days:y.trialDays,due:we(0)}):y?n("cloudBuy.pay.planPaid",{plan:E,price:Ae(y.amount/100)}):E;return e.jsxs("div",{"data-cloud-add":d?"waiting-late":o==="signin"?"waiting-signin":"waiting",className:z,children:[e.jsx(U,{title:d?n("cloudBuy.pay.lateTitle"):n("cloudAdd.browserTitle"),sub:d?n("cloudBuy.pay.lateSub"):n(o==="signin"?"cloudBuy.pay.subSignIn":"cloudBuy.pay.sub")}),e.jsx(pe,{items:[{key:"signed-in",state:"done",title:n("cloudBuy.pay.signedIn"),detail:u},{key:"payment",state:"now",title:n("cloudBuy.pay.waiting"),detail:A},{key:"setup",state:"next",title:n("cloudBuy.pay.setup"),detail:n("cloudBuy.pay.setupHint")}]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",className:d?X:Q,disabled:p,onClick:k,children:[e.jsx(et,{size:14,"aria-hidden":"true"}),n("cloudAdd.reopenCheckout")]}),s&&e.jsxs("button",{type:"button",className:Q,disabled:p,onClick:I,children:[e.jsx(tt,{size:14,"aria-hidden":"true"}),n("cloudBuy.pay.copy")]}),e.jsx("button",{type:"button",className:`${He} ms-1 px-1 py-1`,onClick:q,children:n("cloudAdd.changePlan")})]}),e.jsxs("div",{"aria-live":"polite",className:"text-[13px] leading-[18px] empty:-mt-5",children:[v&&e.jsx("p",{className:"text-ink-secondary",children:n("cloudBuy.pay.copied")}),N&&e.jsx("p",{role:"alert",className:"text-danger",children:n("cloudBuy.pay.failed")})]})]})}const R=[["reserving","cloudHome.step.reserving"],["storage","cloudHome.step.storage"],["starting","cloudBuy.step.starting"],["checking","cloudHome.step.checking"]];function mt({tier:t,trial:l,credit:o},d){if(d)return n("cloudAdd.receivedTitle");const s=fe(t??l?.tier??void 0);return l?o?n("cloudBuy.setup.badgeCredit",{plan:s,credit:Ae(o.grantedUsd)}):n("cloudBuy.setup.badgeTrial",{plan:s}):n("cloudBuy.setup.badgePaid",{plan:s})}function xt({started:t,received:l,step:o,slow:d,ready:s,sleeps:u=!1,name:p,typed:v,color:N,counting:k,busy:I,openFailed:q,onName:y,onColor:E,onOpen:A,onNotNow:$}){const _=s?R.length:Math.max(0,R.findIndex(([i])=>i===o)),C=fe(t.tier??t.trial?.tier??void 0);return e.jsxs("div",{"data-cloud-add":s?"ready":l?"received":"starting","data-cloud-setup":s?"ready":o??"reserving",className:z,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(ze,{children:mt(t,l)}),e.jsx(U,{title:s?n("cloudBuy.ready.title",{name:p}):n("cloudBuy.setup.title"),sub:s?n("cloudBuy.ready.sub"):l?n("cloudAccount.purchaseNoteNoDate"):n("cloudBuy.setup.sub")})]}),e.jsxs("div",{className:"grid gap-6 sm:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ee,{value:_/R.length,label:n("cloudBuy.setup.progress")}),e.jsx(pe,{label:n("cloudBuy.setup.progress"),items:R.map(([i,w],j)=>({key:i,title:n(w,{name:p}),state:j<_?"done":j===_?"now":"next"}))}),d&&!s&&e.jsx("p",{role:"status",className:"px-3 text-[13px] leading-[18px] text-ink-secondary",children:n("cloudHome.slow")})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"cloud-add-name",className:"text-[13px] leading-[18px] text-ink-secondary",children:n("cloudBuy.setup.name")}),e.jsx("input",{id:"cloud-add-name",value:v,maxLength:qe,placeholder:n("cloudSetup.myCloud"),autoComplete:"off",spellCheck:!1,onChange:i=>y(i.target.value),className:Ue})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{id:"cloud-add-color",className:"text-[13px] leading-[18px] text-ink-secondary",children:n("cloudBuy.setup.color")}),e.jsx("div",{role:"radiogroup","aria-labelledby":"cloud-add-color",className:"flex flex-wrap gap-2",children:G.map(i=>e.jsx("button",{type:"button",role:"radio","aria-checked":i===N,"aria-label":n(Me[i]),tabIndex:i===N?0:-1,"data-color":i,onClick:()=>E(i),onKeyDown:w=>{const j=G.indexOf(i),M=w.key==="ArrowRight"||w.key==="ArrowDown"?1:w.key==="ArrowLeft"||w.key==="ArrowUp"?-1:0;if(!M)return;w.preventDefault();const Y=G[(j+M+G.length)%G.length];E(Y),w.currentTarget.parentElement?.querySelector(`[data-color="${Y}"]`)?.focus()},style:{background:$e(i)},className:ue("size-[26px] rounded-lg border-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",i===N?"border-ink shadow-[inset_0_0_0_2px_var(--color-app)]":"border-transparent")},i))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-[13px] leading-[18px] text-ink-secondary",children:n("cloudBuy.setup.preview")}),e.jsxs("span",{"data-cloud-preview":!0,className:"inline-flex max-w-full items-center gap-2 self-start rounded-[12px] border-[0.5px] border-ink/10 bg-menu py-1.5 pe-3 ps-1.5",children:[e.jsx(ve,{color:N}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-[13px] font-medium leading-4 text-ink",children:p}),e.jsx("span",{className:"block truncate text-[12px] text-ink-tertiary",children:n(u?"cloudBuy.setup.previewLineSleeps":"cloudBuy.setup.previewLine",{plan:C})})]})]})]})]})]}),s&&k===null&&e.jsx("p",{className:"text-[13px] leading-[18px] text-ink-tertiary",children:n("cloudBuy.ready.hint",{name:p})}),e.jsxs("div",{className:se,children:[k!==null&&e.jsx("span",{role:"status",className:"me-1 text-[13px] text-ink-secondary",children:n("cloudBuy.setup.openingIn",{seconds:k})}),k!==null&&e.jsx("button",{type:"button",className:Q,onClick:$,children:n("notice.notNow")}),e.jsx("button",{type:"button",className:X,disabled:!s||I,onClick:A,children:n("cloudBuy.setup.open",{name:p})})]}),q&&e.jsx("p",{role:"alert",className:"-mt-2 text-end text-[13px] leading-[18px] text-danger",children:n("cloudBuy.openFailed",{name:p})})]})}function yt({team:t,step:l,slow:o}){const d=Math.max(0,R.findIndex(([u])=>u===l)),s=t??n("cloudBuy.team.unnamed");return e.jsxs("div",{"data-cloud-add":"team-starting","data-cloud-setup":l??"reserving",className:z,children:[e.jsx(U,{title:n("cloudBuy.team.setupTitle"),sub:n("cloudBuy.team.setupSub")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ee,{value:d/R.length,label:n("cloudBuy.setup.progress")}),e.jsx(pe,{label:n("cloudBuy.setup.progress"),items:R.map(([u,p],v)=>({key:u,title:n(p,{name:s}),state:v<d?"done":v===d?"now":"next"}))}),o&&e.jsx("p",{role:"status",className:"px-3 text-[13px] leading-[18px] text-ink-secondary",children:n("cloudHome.slow")})]})]})}function gt({name:t,busy:l,openFailed:o,onOpen:d}){return e.jsxs("div",{"data-cloud-add":"team-ready",className:z,children:[e.jsx(U,{title:n("cloudBuy.team.readyTitle"),sub:n("cloudBuy.team.readySub",{name:t})}),e.jsx("p",{className:"text-[13px] leading-[18px] text-ink-tertiary",children:n("cloudBuy.ready.hint",{name:t})}),e.jsx("div",{className:se,children:e.jsx("button",{type:"button","data-autofocus":!0,className:X,disabled:l,onClick:d,children:n("cloudBuy.setup.open",{name:t})})}),o&&e.jsx("p",{role:"alert",className:"-mt-2 text-end text-[13px] leading-[18px] text-danger",children:n("cloudBuy.openFailed",{name:t})})]})}function ht({view:t,ui:l,actions:o}){switch(t.kind){case"checking":return e.jsx(ie,{kind:"checking",line:null,onClose:o.close});case"unreachable":return e.jsx(ie,{kind:"unreachable",line:n("cloudAdd.unreachable"),onRetry:o.retry,onClose:o.close});case"error":return e.jsx(ie,{kind:`error-${t.reason}`,line:n(t.reason==="rate-limited"?"cloudAdd.rateLimited":"cloudAdd.failed"),onRetry:o.retry,onClose:o.close});case"offer":return e.jsx(ct,{offer:t.offer,current:l.current,now:l.now,busy:l.busy,signedOut:t.signedOut,notice:t.notice?n(t.notice==="code-expired"?"cloudAdd.codeExpired":t.notice==="signin-ended"?"cloudAdd.signInEnded":t.notice==="terms"?"cloudBuy.termsChanged":"cloudAdd.preparing"):null,onStart:o.start,onSignIn:o.signIn});case"sign-in":return e.jsx(dt,{phase:t.phase,email:l.email,code:l.code,profileEmail:l.profileEmail,busy:l.busy,now:l.now,onBack:o.back,onEmail:o.email,onSend:o.sendCode,onChangeEmail:o.changeEmail,onCode:o.code,onResend:o.resend,onBrowser:o.browser});case"signing-in":return e.jsx(ot,{code:t.code,checkout:t.checkout,busy:l.busy,trial:l.offerShown?!!Le(l.offerShown,l.chosen).trialDays:!1,onReopen:o.reopenBrowser,onCancel:o.cancelSignIn});case"waiting":return e.jsx(ft,{plan:t.plan,offer:l.offerShown,browser:t.browser,late:t.late,link:t.link,email:t.email,busy:l.busy,copied:l.copied,failed:l.payFailed,onReopen:o.reopenCheckout,onCopy:o.copyLink,onChangePlan:o.changePlan});case"starting":case"ready":return e.jsx(xt,{started:t,received:t.kind==="starting"&&t.received,step:t.kind==="starting"?t.step:null,slow:t.kind==="starting"&&t.slow,ready:t.kind==="ready",sleeps:lt(t,l.offerShown),name:l.look.name,typed:l.look.typed,color:l.look.color,counting:l.counting,busy:l.busy,openFailed:l.openFailed,onName:o.name,onColor:o.color,onOpen:o.openCloud,onNotNow:o.notNow});case"has-cloud":return e.jsx(pt,{name:l.look.name,color:l.look.color,busy:l.busy,interest:l.interest,openFailed:l.openFailed,onInterest:o.interest,onOpen:o.openCloud});case"team-starting":return e.jsx(yt,{team:t.team,step:t.step,slow:t.slow});case"team-ready":return e.jsx(gt,{name:t.team.name,busy:l.busy,openFailed:l.openFailed,onOpen:()=>o.openTeam(t.team.id)});case"settings":return null}}const bt={offer:"max-w-[920px]",starting:"max-w-[720px]",ready:"max-w-[720px]"};function Be({kind:t,staging:l,onClose:o,children:d}){return e.jsx("div",{className:"ui-scrim fixed inset-0 z-[60] flex items-center justify-center p-4 sm:p-6",onMouseDown:s=>s.stopPropagation(),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"cloud-add-title","data-cloud-add-dialog":!0,tabIndex:-1,className:ue(Xe,"group/sheet animate-pop-in relative max-h-full w-full overflow-y-auto overscroll-contain outline-none",bt[t]??"max-w-[540px]"),children:[e.jsx("button",{type:"button",onClick:o,"aria-label":n("cloudAdd.close"),className:ue(Je,Ge,"absolute end-4 top-4 z-10"),children:e.jsx(Ve,{size:16})}),l&&e.jsx(Qe,{className:"absolute end-14 top-[22px] z-10 group-has-[[data-night-card]]/sheet:bg-app"}),d]})})}const kt=["offer","checking","unreachable","waiting","sign-in","signing-in"],jt="button:not([disabled]):not([tabindex='-1']), input:not([disabled]):not([tabindex='-1']), [href], [tabindex='0']",St=t=>t.status==="connected"&&t.entitlement?.plan==="free"&&!t.purchase&&!t.machine,Nt=t=>t?.status==="connected"&&t.entitlement?.plan==="pro"&&t.entitlement.status==="active"?t.entitlement.tier??"pro":null;function Lt({now:t=Date.now}){const{state:l,dispatch:o}=ut(),d=l.cloudAdd,s=window.ogb?.remoteClient?.active?void 0:window.ogb?.cloudAccount,[u,p]=c.useState(null),[v,N]=c.useState(void 0),[k,I]=c.useState(null),[q,y]=c.useState(null),[E,A]=c.useState(!1),[$,_]=c.useState(!1),[C,i]=c.useState(!1),[w,j]=c.useState(!1),[M,Y]=c.useState(0),[Z,me]=c.useState([]),[b,h]=c.useState(null),[T,O]=c.useState({email:"",code:""}),[B,ee]=c.useState(null),[F,P]=c.useState(null),[H,S]=c.useState(null),[,Ie]=c.useState(0),[xe,ae]=c.useState(!1),[Te,le]=c.useState(!1),[Oe,Fe]=c.useState(!1),L=!!(d&&s),oe=l.config?.profile?.email?.trim()||null,de=at();c.useEffect(()=>{if(!L||!s)return;let a=!0,r=!1;const g=s.onState(x=>{r=!0,a&&p(x)});return s.state().then(x=>{a&&!r&&p(x)}).catch(()=>{}),()=>{a=!1,g()}},[L,s]);const m=L?nt(u,v,{now:t(),error:q,choosing:$,conflict:E,signIn:b,arrived:xe,terms:Te}):null,ye=L&&m&&kt.includes(m.kind)&&u?`${u.status}:${JSON.stringify(u.offer??null)}:${M}`:null;c.useEffect(()=>{if(!ye||!s?.offer)return;let a=!0;return s.offer().then(r=>{a&&N(r)},()=>{a&&N(null)}),()=>{a=!1}},[ye,s]);const ce=n("cloudSetup.myCloud"),W={typed:B?.typed??ce,color:B?.color??Ce,name:We(B?.typed??ce,ce)},D=()=>{b&&s?.signInCancel?.().catch(()=>{}),o({type:"closeCloudAdd"}),y(null),A(!1),_(!1),j(!1),me([]),I(null),h(null),O({email:"",code:""}),ee(null),P(null),S(null),ae(!1),le(!1)};c.useEffect(()=>{if(!L)return;const a=document.activeElement,r=a&&a!==document.body&&typeof a.focus=="function"?a:null;d?.signIn&&(h({step:"email",intent:!1,problem:null}),O({email:oe??"",code:""}));const g=x=>{if(x.key==="Escape"){x.preventDefault(),D();return}if(x.key!=="Tab")return;const V=[...document.querySelector("[data-cloud-add-dialog]")?.querySelectorAll(jt)??[]];if(!V.length)return;x.preventDefault();const Ne=V.indexOf(document.activeElement);V[Ne===-1?0:(Ne+(x.shiftKey?-1:1)+V.length)%V.length].focus()};return window.addEventListener("keydown",g,!0),(document.querySelector("#cloud-add-title")??document.querySelector("[data-cloud-add-dialog]"))?.focus(),()=>{window.removeEventListener("keydown",g,!0),r?.isConnected&&r.focus()}},[L]),c.useEffect(()=>{if(!(!L||!s?.sheet||de))return s.sheet(!0).catch(()=>{}),()=>{s.sheet?.(!1).catch(()=>{})}},[L,s,de]);const f=m?.kind??null,te=m?.kind==="sign-in"?`sign-in-${m.phase.step}`:f;c.useEffect(()=>{!te||te==="checking"||te==="settings"||document.activeElement?.closest?.("[data-cloud-add-dialog]")||(document.querySelector("[data-cloud-add-dialog] [data-autofocus]")??document.querySelector("#cloud-add-title"))?.focus()},[te]),c.useEffect(()=>{(f==="waiting"||f==="starting"||f==="ready")&&!xe&&ae(!0),(f==="ready"||f==="team-ready")&&s?.readySeen?.().catch(()=>{})},[f]),c.useEffect(()=>{if(!f||!d)return;if(f==="settings"){D(),o({type:"toggleAppSettings",open:!0,section:"cloudAccount"});return}if(f==="checking")return;const a=Z.length===0;a&&J("cloud_dialog_shown",{source:d.source}),["starting","ready"].includes(f)&&Z.includes(f),(a||!Z.includes(f))&&me([...Z,f])},[f]),c.useEffect(()=>{if(!f||!["starting","ready","has-cloud"].includes(f)||B||!s?.look)return;let a=!0;return s.look().then(r=>{a&&ee({typed:r.name,color:Ke(r.color)??Ce,dirty:f!=="has-cloud"})},()=>{}),()=>{a=!1}},[f]),c.useEffect(()=>{if(!B?.dirty||!s?.setLook)return;const a=setTimeout(()=>{s.setLook?.(W.name,B.color).catch(()=>{})},400);return()=>clearTimeout(a)},[B?.typed,B?.color]),c.useEffect(()=>{f!=="ready"||F!==null||P(!de&&typeof document.hasFocus=="function"&&document.hasFocus()?3:"off")},[f]);const ge=b?.step==="code"?b.resendAt:0;c.useEffect(()=>{if(!ge||ge<=t())return;const a=setTimeout(()=>Ie(t()),1e3);return()=>clearTimeout(a)}),c.useEffect(()=>{if(H!=="copied")return;const a=setTimeout(()=>S(null),2500);return()=>clearTimeout(a)},[H]);const ne=a=>{C||(i(!0),j(!1),a().catch(()=>y("failed")).finally(()=>i(!1)))},he=()=>{C||!s||(i(!0),j(!1),P("done"),(async()=>{B?.dirty&&s.setLook&&await s.setLook(W.name,B.color).catch(()=>{}),await s.connectHome()})().then(()=>D(),()=>j(!0)).finally(()=>i(!1)))},De=a=>{C||!s?.openTeam||(i(!0),j(!1),s.openTeam(a).then(()=>D(),()=>j(!0)).finally(()=>i(!1)))};c.useEffect(()=>{if(typeof F!="number")return;const a=setTimeout(()=>{F>1?P(F-1):he()},1e3);return()=>clearTimeout(a)},[F]);const be=typeof F=="number";if(c.useEffect(()=>{if(!be)return;const a=()=>P("off");return window.addEventListener("blur",a),()=>window.removeEventListener("blur",a)},[be]),!L||!m||!d||!s||m.kind==="settings")return null;if(m.kind==="has-cloud"&&u?.status==="connected"&&u.clouds&&window.ogb?.cloudAdd&&(u.addCloud?.canAdd!==!1||u.adding&&!u.adding.done))return e.jsx(Be,{kind:Oe?"offer":"has-cloud",staging:u.staging===!0,onClose:D,children:e.jsx(st,{onClose:D,onFirstCloud:()=>{},onWide:Fe,source:d.source})});const K=v??null,ke=()=>m.kind==="waiting"&&!k?m.plan:K?Le(K,k).tier:null,re=async a=>{if(!a||!s.checkout){y("failed");return}K?.plans.find(x=>x.tier===a)?.trialDays;const r=await s.checkout(a,d.source),g=r.outcome;p(r.state),g==="opened"||g==="signing-in"?(_(!1),y(null),A(!1),S(null),le(!1),J("cloud_checkout_opened",{source:d.source})):g==="rate-limited"?y("rate-limited"):g==="failed"?y("failed"):A(!0)},je=a=>{h({step:"email",intent:a,problem:null}),O({email:T.email||oe||"",code:""})},Se=()=>{if(C||!s.signInStart||!b||b.step==="done")return;const a=b;i(!0),s.signInStart(T.email).then(r=>{r.outcome==="sent"?(h({step:"code",intent:a.intent,email:r.email,resendAt:r.resendAt,problem:null,triesLeft:null,...r.signupOpen===!1?{signupOpen:!1}:{}}),O({email:r.email,code:""}),J("cloud_signin",{source:d.source})):h({...a,problem:r.outcome})},()=>h({...a,problem:"failed"})).finally(()=>i(!1))},_e=a=>{if(!s.signInVerify||b?.step!=="code")return;const r=b,g=r.intent?ke():null;i(!0),(async()=>{try{const x=await s.signInVerify(a);if(x.outcome!=="signed-in"){O({email:T.email,code:""}),h({...r,problem:x.outcome,triesLeft:x.outcome==="wrong-code"?x.triesLeft:null});return}p(x.state),ae(!0),J("cloud_signin",{step:"signed_in",source:d.source}),g&&St(x.state)&&(it(K,x.state.offer,g)?(h({step:"done",intent:!0}),await re(g)):(le(!0),I(g))),h(null),O({email:T.email,code:""})}catch{h({...r,problem:"failed",triesLeft:null})}finally{i(!1)}})()},Re={start:a=>{if(I(a),A(!1),m.kind==="offer"&&m.signedOut&&s.signInStart){je(!0);return}ne(()=>re(a))},signIn:()=>je(!1),back:()=>{h(null),s.signInCancel?.().catch(()=>{})},email:a=>O({email:a,code:T.code}),sendCode:Se,changeEmail:()=>{b&&(h({step:"email",intent:b.intent,problem:null}),s.signInCancel?.().catch(()=>{}))},code:a=>{const r=rt(a);O({email:T.email,code:r}),r.length===8&&!C&&_e(r)},resend:Se,browser:()=>ne(async()=>{const a=b?.intent?ke():null;h(null),await s.signInCancel?.().catch(()=>{}),J("cloud_signin",{source:d.source}),a?await re(a):p(await s.begin())}),reopenBrowser:()=>ne(async()=>p(await s.reopen())),cancelSignIn:()=>ne(async()=>p(await s.cancel())),reopenCheckout:()=>{if(m.kind!=="waiting"||C)return;i(!0),S(null),(s.reopenCheckout?s.reopenCheckout(m.plan,d.source):s.checkout(m.plan,d.source)).then(r=>{p(r.state),r.outcome!=="opened"&&S("pay-failed")},()=>S("pay-failed")).finally(()=>i(!1))},copyLink:()=>{s.copyCheckoutLink?.().then(a=>S(a?"copied":"pay-failed"),()=>S("pay-failed"))},changePlan:()=>{I(m.kind==="waiting"?m.plan:k),_(!0),S(null)},retry:()=>{y(null),A(!1),N(void 0),Y(M+1)},name:a=>ee({typed:a,color:W.color,dirty:!0}),color:a=>ee({typed:W.typed,color:a,dirty:!0}),openCloud:he,openTeam:De,notNow:()=>P("off"),interest:()=>{C||!s.interest||(i(!0),s.interest().then(()=>S("interest-sent"),()=>S("interest-failed")).finally(()=>i(!1)))},close:D},Pe={chosen:k,current:Nt(u),offerShown:K,now:t(),busy:C,openFailed:w,email:T.email,code:T.code,profileEmail:oe,look:W,counting:typeof F=="number"?F:null,copied:H==="copied",payFailed:H==="pay-failed",interest:H==="interest-sent"?"sent":H==="interest-failed"?"failed":null};return e.jsx(Be,{kind:m.kind,staging:u?.staging===!0,onClose:D,children:e.jsx(ht,{view:m,ui:Pe,actions:Re})})}export{Lt as CloudAddDialog,ht as CloudAddPanel,Be as CloudAddSheet};
@@ -1 +1 @@
1
- import{j as e,t as a,a as N,r as R}from"./styles-f5xRqRwH.js";import{a9 as F,aa as S,x as L,S as z,ab as b,ac as y,ad as A,ae as B,af as w,ag as j,ah as M,ai as P,aj as E,u as I,w as $,F as O,ak as v,al as T,am as D,an as C,ao as H,ap as W,aq as q}from"./App-Ba5tz_33.js";import{a as X,R as _}from"./RoutinesPage-DHlvO9sv.js";import{L as G,P as J,d as K}from"./PlacesRail-CiZjMESo.js";import{C as Q}from"./MenuMotion-B8impuLz.js";function U({routines:t,runs:r,bots:x,pausedBots:c,heldBots:o,loading:d,error:l,onOpen:i,onLogs:p,onToggle:h}){const m=[...t].sort((s,n)=>Number(n.enabled)-Number(s.enabled)||(s.nextRunAt??1/0)-(n.nextRunAt??1/0)||s.name.localeCompare(n.name));return e.jsxs("div",{className:"space-y-3","aria-label":a("routines.list"),children:[l&&e.jsx("div",{role:"alert",className:"rounded-lg bg-danger/10 p-3 text-[12px] text-danger",children:a("routines.loadError")}),d&&e.jsxs("p",{role:"status",className:"flex items-center gap-2 p-3 text-[12px] text-ink-secondary",children:[e.jsx(G,{size:14,className:"animate-spin"}),a("routines.loading")]}),!d&&!l&&m.length===0&&e.jsxs("div",{className:"rounded-xl border border-dashed border-hairline/50 p-5 text-center text-[13px] text-ink-secondary",children:[e.jsx(X,{size:20,className:"mx-auto mb-2 opacity-60"}),a("routines.empty")]}),m.map(s=>{const n=F(s.id,r),u=n&&(n.attention?"attention":n.error?"error":n.output?"output":null),g=x?.find(k=>k.id===s.botId),f=h!==void 0&&!S(s);return e.jsxs("article",{className:"rounded-xl border border-hairline/40 bg-card p-3.5","aria-label":s.name,children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>i(s),className:"min-w-0 flex-1 text-left hover:text-accent",children:[e.jsx("span",{className:"block truncate text-[13px] font-semibold text-ink",children:s.name}),e.jsxs("span",{className:"mt-1 block text-[12px] leading-relaxed text-ink-secondary",children:[g&&`${g.name} · `,L(s.schedule)]})]}),f?e.jsx(z,{checked:s.enabled,"aria-label":a("routines.toggle",{name:s.name}),onClick:()=>h(s)}):e.jsx("span",{className:N("shrink-0 rounded-full bg-inset px-2 py-0.5 text-[10px]",s.enabled&&s.nextRunAt!=null?"text-accent":"text-ink-secondary"),children:b(s)})]}),(f||y(s)!==b(s))&&e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:y(s)}),e.jsxs("div",{className:"mt-1 flex items-start justify-between gap-2",children:[e.jsx("div",{className:"min-w-0 text-[12px]",children:n?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:B(n),children:a("routines.latestRun",{status:A(n)})}),e.jsx("span",{className:"block text-[11px] text-ink-secondary",children:w(n.finishedAt??n.startedAt??n.scheduledFor)})]}):e.jsx("span",{className:"text-ink-secondary",children:a("routines.neverRun")})}),e.jsxs("button",{type:"button",onClick:()=>p(s),"aria-label":a("routines.logsFor",{name:s.name}),className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[11px] text-ink-secondary hover:bg-raised hover:text-ink",children:[e.jsx(j,{size:12}),a("routines.logs")]})]}),n&&u&&e.jsx("p",{className:N("mt-2 line-clamp-2 whitespace-pre-wrap text-[12px] leading-relaxed",n.error?"text-danger":"text-ink-secondary"),children:M(n,u)}),!!s.failureStreak&&e.jsx("p",{className:"mt-2 text-[12px] text-danger",children:a("routines.failureStreak",{count:s.failureStreak})}),s.weekRuns&&e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:a(s.weekRuns.total===1?"routines.weekRunsOne":"routines.weekRuns",s.weekRuns)}),s.warning&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-warning",children:s.warning}),s.enabled&&c?.includes(s.botId)&&e.jsxs("p",{className:"mt-2 text-[12px] leading-relaxed text-warning","data-routine-bot-paused":"",children:[a("routines.botPaused")," ",e.jsx("button",{type:"button",className:"cursor-pointer text-accent hover:underline",onClick:()=>P("paused"),children:a("routines.botPausedSwap")})]}),s.enabled&&o?.includes(s.botId)&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-warning","data-routine-bot-held":"",children:a("routines.botHeld")}),s.heldFor&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:E(s)}),!!s.skippedRuns&&e.jsxs("p",{className:"mt-2 text-[12px] text-ink-secondary",children:[a("routines.skippedRuns",{count:s.skippedRuns}),s.lastSkippedAt!=null&&e.jsxs(e.Fragment,{children:[" · ",a("routines.lastSkipped",{date:w(s.lastSkippedAt)})]})]})]},s.id)})]})}function le({bot:t,routines:r,runs:x,defaultRunOn:c}){const{state:o,dispatch:d}=I(),[l,i]=R.useState(null);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{size:16,className:"text-accent"}),e.jsx("h2",{className:"min-w-0 flex-1 text-[15px] font-medium text-ink",children:a("computer.tab.routines")}),e.jsx("span",{className:"text-[12px] text-ink-secondary",children:r.length})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>i("new"),className:"flex flex-1 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[12px] font-medium text-white hover:brightness-110",children:[e.jsx(J,{size:14}),a("computer.routines.create")]}),e.jsxs("button",{type:"button",onClick:()=>d({type:"showRoutines",section:"logs",botId:t.id}),className:"flex items-center gap-1.5 rounded-lg bg-control px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(j,{size:13}),a("routines.logs")]})]})]}),e.jsx(U,{routines:r,runs:x,pausedBots:o.config?.pausedBots,heldBots:o.config?.heldBots,loading:o.routinesLoadState==="loading"&&r.length===0,error:o.routinesLoadState==="error",onOpen:i,onLogs:p=>d({type:"showRoutines",section:"logs",botId:t.id,routineId:p.id}),onToggle:p=>d({type:"updateRoutine",routineId:p.id,patch:{enabled:!p.enabled}})}),e.jsxs("button",{type:"button",onClick:()=>d({type:"showRoutines",section:"schedule",view:"list",botId:t.id}),className:"self-start text-[12px] text-accent hover:underline",children:[a("computer.routines.openTitle")," ",e.jsx(Q,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]}),l&&e.jsx(_,{routine:l==="new"?void 0:l,bots:[t],lockedBotId:t.id,defaultRunOn:c,onClose:()=>i(null)},t.id)]})}const V=20;function Y(t,r=V){const x=new Set,c=[],o=C(t);for(let d=o.length-1;d>=0&&c.length<r;d-=1){const l=o[d].digest?.files;if(l){for(const i of l.deleted)x.add(i);for(const i of[...l.added,...l.changed])if(!x.has(i)&&(x.add(i),c.push(i),c.length>=r))break}}return c}function Z(t){const r=new Map,x=t.tasks?.find(i=>i.threadId===t.threadId),c=x?.cwd===void 0?t.cwd:x.cwd,o=c&&(/^[a-z]:[\\/]/i.test(c)||c.startsWith("\\\\")),d=i=>o?i.replace(/\\/g,"/"):i,l=typeof c=="string"?`${d(c).replace(/\/+$/,"")}/`:void 0;for(const i of[...C(t)].reverse()){if(i.role!=="bot"||i.kind!=="text")continue;const p=H(i.attachments),h=[...p.files,...W(i.text??"",[...p.images,...p.files.map(m=>m.path)])];for(const m of h){const s=m.private?m.path:q(m.path),n={file:m,message:{threadId:t.threadId,messageId:i.id}},u=d(s),g=l&&(o?u.slice(0,l.length).toLowerCase()===l.toLowerCase():u.startsWith(l)),f=[s,...g?[u.slice(l.length)]:[]];s.startsWith("./")&&f.push(s.replace(/^(\.\/)+/,""));for(const k of f)r.has(k)||r.set(k,n)}}return r}function ee(t){const r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return r<0?{name:t,folder:""}:{name:t.slice(r+1),folder:t.slice(0,r)}}function re({bot:t}){const{dispatch:r}=I(),{capabilities:x}=K(),c=x.host.homeDir,d=t.tasks?.find(h=>h.threadId===t.threadId)?.cwd,l=d===void 0?t.cwd:d,i=Y(t),p=R.useMemo(()=>Z(t),[t.messages,t.activeLeafId,t.threadId,t.tasks,t.cwd]);return e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pb-5","data-testid":"computer-files",children:[e.jsxs("div",{className:"mt-2 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:a("computer.files.folder")}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(O,{size:15,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",title:l??void 0,children:l?v(l,c):l===null?a("computer.files.homeFolder"):a("computer.files.privateFolder",{name:t.name})}),e.jsx("button",{type:"button",onClick:()=>{r({type:"toggleComputer",open:!1}),T(r,"access",{page:"folder"})},className:"shrink-0 rounded-lg bg-control px-2.5 py-1 text-[12px] text-ink hover:bg-raised-hover",children:a(d===void 0?"computer.files.changeFolder":"computer.files.changeDefaultFolder")})]}),d!==void 0&&e.jsx("p",{className:"mt-2 text-[12px] leading-5 text-ink-secondary",children:a("computer.files.pinnedFolderHint")})]}),e.jsxs("div",{className:"mt-3 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:a("computer.files.recent")}),i.length===0?e.jsx("p",{className:"mt-2 text-[12px] leading-5 text-ink-secondary",children:a("computer.files.empty",{name:t.name})}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:i.map(h=>{const{name:m,folder:s}=ee(h),n=p.get(h);return e.jsxs("li",{className:"min-w-0 rounded-lg py-1",title:h,children:[n?e.jsx(D,{file:{...n.file,name:m},message:n.message,linked:n.file.linked,className:"w-full max-w-none"},`${n.message.threadId}:${n.message.messageId}:${n.file.path}`):e.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",title:a("computer.files.notSharedHint"),children:[e.jsx(j,{size:14,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-ink",children:m}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:a("computer.files.notShared")})]}),s&&e.jsx("div",{className:"mt-1 truncate px-2.5 text-[11px] text-ink-tertiary",children:v(s,c)})]},h)})})]})]})}export{re as C,le as R,U as a,Y as r,Z as s};
1
+ import{j as e,t as a,a as N,r as R}from"./styles-f5xRqRwH.js";import{a9 as F,aa as S,x as L,S as z,ab as b,ac as y,ad as A,ae as B,af as w,ag as j,ah as M,ai as P,aj as E,u as I,w as $,F as O,ak as v,al as T,am as D,an as C,ao as H,ap as W,aq as q}from"./App-x36HXaXk.js";import{a as X,R as _}from"./RoutinesPage-ChuBJMsA.js";import{L as G,P as J,d as K}from"./PlacesRail-CiZjMESo.js";import{C as Q}from"./MenuMotion-B8impuLz.js";function U({routines:t,runs:r,bots:x,pausedBots:c,heldBots:o,loading:d,error:l,onOpen:i,onLogs:p,onToggle:h}){const m=[...t].sort((s,n)=>Number(n.enabled)-Number(s.enabled)||(s.nextRunAt??1/0)-(n.nextRunAt??1/0)||s.name.localeCompare(n.name));return e.jsxs("div",{className:"space-y-3","aria-label":a("routines.list"),children:[l&&e.jsx("div",{role:"alert",className:"rounded-lg bg-danger/10 p-3 text-[12px] text-danger",children:a("routines.loadError")}),d&&e.jsxs("p",{role:"status",className:"flex items-center gap-2 p-3 text-[12px] text-ink-secondary",children:[e.jsx(G,{size:14,className:"animate-spin"}),a("routines.loading")]}),!d&&!l&&m.length===0&&e.jsxs("div",{className:"rounded-xl border border-dashed border-hairline/50 p-5 text-center text-[13px] text-ink-secondary",children:[e.jsx(X,{size:20,className:"mx-auto mb-2 opacity-60"}),a("routines.empty")]}),m.map(s=>{const n=F(s.id,r),u=n&&(n.attention?"attention":n.error?"error":n.output?"output":null),g=x?.find(k=>k.id===s.botId),f=h!==void 0&&!S(s);return e.jsxs("article",{className:"rounded-xl border border-hairline/40 bg-card p-3.5","aria-label":s.name,children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>i(s),className:"min-w-0 flex-1 text-left hover:text-accent",children:[e.jsx("span",{className:"block truncate text-[13px] font-semibold text-ink",children:s.name}),e.jsxs("span",{className:"mt-1 block text-[12px] leading-relaxed text-ink-secondary",children:[g&&`${g.name} · `,L(s.schedule)]})]}),f?e.jsx(z,{checked:s.enabled,"aria-label":a("routines.toggle",{name:s.name}),onClick:()=>h(s)}):e.jsx("span",{className:N("shrink-0 rounded-full bg-inset px-2 py-0.5 text-[10px]",s.enabled&&s.nextRunAt!=null?"text-accent":"text-ink-secondary"),children:b(s)})]}),(f||y(s)!==b(s))&&e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:y(s)}),e.jsxs("div",{className:"mt-1 flex items-start justify-between gap-2",children:[e.jsx("div",{className:"min-w-0 text-[12px]",children:n?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:B(n),children:a("routines.latestRun",{status:A(n)})}),e.jsx("span",{className:"block text-[11px] text-ink-secondary",children:w(n.finishedAt??n.startedAt??n.scheduledFor)})]}):e.jsx("span",{className:"text-ink-secondary",children:a("routines.neverRun")})}),e.jsxs("button",{type:"button",onClick:()=>p(s),"aria-label":a("routines.logsFor",{name:s.name}),className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[11px] text-ink-secondary hover:bg-raised hover:text-ink",children:[e.jsx(j,{size:12}),a("routines.logs")]})]}),n&&u&&e.jsx("p",{className:N("mt-2 line-clamp-2 whitespace-pre-wrap text-[12px] leading-relaxed",n.error?"text-danger":"text-ink-secondary"),children:M(n,u)}),!!s.failureStreak&&e.jsx("p",{className:"mt-2 text-[12px] text-danger",children:a("routines.failureStreak",{count:s.failureStreak})}),s.weekRuns&&e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:a(s.weekRuns.total===1?"routines.weekRunsOne":"routines.weekRuns",s.weekRuns)}),s.warning&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-warning",children:s.warning}),s.enabled&&c?.includes(s.botId)&&e.jsxs("p",{className:"mt-2 text-[12px] leading-relaxed text-warning","data-routine-bot-paused":"",children:[a("routines.botPaused")," ",e.jsx("button",{type:"button",className:"cursor-pointer text-accent hover:underline",onClick:()=>P("paused"),children:a("routines.botPausedSwap")})]}),s.enabled&&o?.includes(s.botId)&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-warning","data-routine-bot-held":"",children:a("routines.botHeld")}),s.heldFor&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:E(s)}),!!s.skippedRuns&&e.jsxs("p",{className:"mt-2 text-[12px] text-ink-secondary",children:[a("routines.skippedRuns",{count:s.skippedRuns}),s.lastSkippedAt!=null&&e.jsxs(e.Fragment,{children:[" · ",a("routines.lastSkipped",{date:w(s.lastSkippedAt)})]})]})]},s.id)})]})}function le({bot:t,routines:r,runs:x,defaultRunOn:c}){const{state:o,dispatch:d}=I(),[l,i]=R.useState(null);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{size:16,className:"text-accent"}),e.jsx("h2",{className:"min-w-0 flex-1 text-[15px] font-medium text-ink",children:a("computer.tab.routines")}),e.jsx("span",{className:"text-[12px] text-ink-secondary",children:r.length})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>i("new"),className:"flex flex-1 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[12px] font-medium text-white hover:brightness-110",children:[e.jsx(J,{size:14}),a("computer.routines.create")]}),e.jsxs("button",{type:"button",onClick:()=>d({type:"showRoutines",section:"logs",botId:t.id}),className:"flex items-center gap-1.5 rounded-lg bg-control px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(j,{size:13}),a("routines.logs")]})]})]}),e.jsx(U,{routines:r,runs:x,pausedBots:o.config?.pausedBots,heldBots:o.config?.heldBots,loading:o.routinesLoadState==="loading"&&r.length===0,error:o.routinesLoadState==="error",onOpen:i,onLogs:p=>d({type:"showRoutines",section:"logs",botId:t.id,routineId:p.id}),onToggle:p=>d({type:"updateRoutine",routineId:p.id,patch:{enabled:!p.enabled}})}),e.jsxs("button",{type:"button",onClick:()=>d({type:"showRoutines",section:"schedule",view:"list",botId:t.id}),className:"self-start text-[12px] text-accent hover:underline",children:[a("computer.routines.openTitle")," ",e.jsx(Q,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]}),l&&e.jsx(_,{routine:l==="new"?void 0:l,bots:[t],lockedBotId:t.id,defaultRunOn:c,onClose:()=>i(null)},t.id)]})}const V=20;function Y(t,r=V){const x=new Set,c=[],o=C(t);for(let d=o.length-1;d>=0&&c.length<r;d-=1){const l=o[d].digest?.files;if(l){for(const i of l.deleted)x.add(i);for(const i of[...l.added,...l.changed])if(!x.has(i)&&(x.add(i),c.push(i),c.length>=r))break}}return c}function Z(t){const r=new Map,x=t.tasks?.find(i=>i.threadId===t.threadId),c=x?.cwd===void 0?t.cwd:x.cwd,o=c&&(/^[a-z]:[\\/]/i.test(c)||c.startsWith("\\\\")),d=i=>o?i.replace(/\\/g,"/"):i,l=typeof c=="string"?`${d(c).replace(/\/+$/,"")}/`:void 0;for(const i of[...C(t)].reverse()){if(i.role!=="bot"||i.kind!=="text")continue;const p=H(i.attachments),h=[...p.files,...W(i.text??"",[...p.images,...p.files.map(m=>m.path)])];for(const m of h){const s=m.private?m.path:q(m.path),n={file:m,message:{threadId:t.threadId,messageId:i.id}},u=d(s),g=l&&(o?u.slice(0,l.length).toLowerCase()===l.toLowerCase():u.startsWith(l)),f=[s,...g?[u.slice(l.length)]:[]];s.startsWith("./")&&f.push(s.replace(/^(\.\/)+/,""));for(const k of f)r.has(k)||r.set(k,n)}}return r}function ee(t){const r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return r<0?{name:t,folder:""}:{name:t.slice(r+1),folder:t.slice(0,r)}}function re({bot:t}){const{dispatch:r}=I(),{capabilities:x}=K(),c=x.host.homeDir,d=t.tasks?.find(h=>h.threadId===t.threadId)?.cwd,l=d===void 0?t.cwd:d,i=Y(t),p=R.useMemo(()=>Z(t),[t.messages,t.activeLeafId,t.threadId,t.tasks,t.cwd]);return e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pb-5","data-testid":"computer-files",children:[e.jsxs("div",{className:"mt-2 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:a("computer.files.folder")}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(O,{size:15,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",title:l??void 0,children:l?v(l,c):l===null?a("computer.files.homeFolder"):a("computer.files.privateFolder",{name:t.name})}),e.jsx("button",{type:"button",onClick:()=>{r({type:"toggleComputer",open:!1}),T(r,"access",{page:"folder"})},className:"shrink-0 rounded-lg bg-control px-2.5 py-1 text-[12px] text-ink hover:bg-raised-hover",children:a(d===void 0?"computer.files.changeFolder":"computer.files.changeDefaultFolder")})]}),d!==void 0&&e.jsx("p",{className:"mt-2 text-[12px] leading-5 text-ink-secondary",children:a("computer.files.pinnedFolderHint")})]}),e.jsxs("div",{className:"mt-3 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:a("computer.files.recent")}),i.length===0?e.jsx("p",{className:"mt-2 text-[12px] leading-5 text-ink-secondary",children:a("computer.files.empty",{name:t.name})}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:i.map(h=>{const{name:m,folder:s}=ee(h),n=p.get(h);return e.jsxs("li",{className:"min-w-0 rounded-lg py-1",title:h,children:[n?e.jsx(D,{file:{...n.file,name:m},message:n.message,linked:n.file.linked,className:"w-full max-w-none"},`${n.message.threadId}:${n.message.messageId}:${n.file.path}`):e.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",title:a("computer.files.notSharedHint"),children:[e.jsx(j,{size:14,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-ink",children:m}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:a("computer.files.notShared")})]}),s&&e.jsx("div",{className:"mt-1 truncate px-2.5 text-[11px] text-ink-tertiary",children:v(s,c)})]},h)})})]})]})}export{re as C,le as R,U as a,Y as r,Z as s};