limixbot 0.2.8 → 0.2.9

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 (122) hide show
  1. package/dist/assets/{ActivityPanel-peFEa8hc.js → ActivityPanel-DNJrm-It.js} +1 -1
  2. package/dist/assets/{App-DqXMyMLs.js → App-0-mtr0MN.js} +9 -9
  3. package/dist/assets/{AppEventEditor-7pfjIt50.js → AppEventEditor-cxtdNROG.js} +1 -1
  4. package/dist/assets/{BotSettingsDialog-D3hAY6mk.js → BotSettingsDialog-Bke-uC9C.js} +1 -1
  5. package/dist/assets/{BrowserPanel-h3psJrX9.js → BrowserPanel-DIWnLFx0.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-tU88r2vZ.js → BrowserProfilesManager-Byg78_T6.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-DWfi8tOM.js → CloudAddDialog-DbnC3LUp.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-BkDyk0uk.js → ComputerFilesPane-D8NwEQh2.js} +1 -1
  9. package/dist/assets/{ComputerPanel-C7jTOFiO.js → ComputerPanel-BVjkZ-QX.js} +2 -2
  10. package/dist/assets/{DataPanel-BCfRj7d6.js → DataPanel-jd0L0Ng-.js} +1 -1
  11. package/dist/assets/{DesktopViewer-jeI22vIi.js → DesktopViewer-Bj7DyfxJ.js} +1 -1
  12. package/dist/assets/{FilesView-B-gpIIvL.js → FilesView-D2dpovi2.js} +1 -1
  13. package/dist/assets/{GrokMoveDialog-BzDSBiBl.js → GrokMoveDialog-Cu9vgUWd.js} +1 -1
  14. package/dist/assets/{InspectorPanel-2I3CFtPj.js → InspectorPanel-B6Ix1Q90.js} +1 -1
  15. package/dist/assets/{KeyboardShortcutsModal-DdrvmhWG.js → KeyboardShortcutsModal-BxLj1UAT.js} +1 -1
  16. package/dist/assets/{LiveDesktop-D3KDasUO.js → LiveDesktop-IhmS_70N.js} +1 -1
  17. package/dist/assets/{LocalVmWorkspace-UWvcjjYE.js → LocalVmWorkspace-Cz_8PBvO.js} +1 -1
  18. package/dist/assets/{MacLocalControl-H2OhSRFA.js → MacLocalControl-BQx0dmBY.js} +1 -1
  19. package/dist/assets/{MarkdownFilePreview-CLaBnIvb.js → MarkdownFilePreview-BvcKRvLj.js} +1 -1
  20. package/dist/assets/{MenuMotion-nTkCdPNb.js → MenuMotion-Dg_hALEl.js} +1 -1
  21. package/dist/assets/{NewBotDialog-UUKIGmIQ.js → NewBotDialog-AG4lwjLs.js} +1 -1
  22. package/dist/assets/{PhoneAppDialog-CtUtHZIh.js → PhoneAppDialog-DnxYDUcZ.js} +1 -1
  23. package/dist/assets/PlacesRail-C-RypDbo.js +57 -0
  24. package/dist/assets/{PluginsPanel-DhRV2Z1H.js → PluginsPanel-DUMsui1-.js} +1 -1
  25. package/dist/assets/{ProIntroduction-kN19JQ-Y.js → ProIntroduction-DrVULNMR.js} +1 -1
  26. package/dist/assets/{RemoteAgentSettingsPanel-BjIqRepm.js → RemoteAgentSettingsPanel-C9bAP3v4.js} +1 -1
  27. package/dist/assets/{RoomPanel-CgoVFvjy.js → RoomPanel-DjGGiSTe.js} +1 -1
  28. package/dist/assets/{RoutinesPage-C2O4AgJB.js → RoutinesPage-DI6CbJ-R.js} +1 -1
  29. package/dist/assets/{SettingsModal-DOYrfxNQ.js → SettingsModal-2iNaR6ei.js} +1 -1
  30. package/dist/assets/{ShareTeamDialog-DNKIsuNU.js → ShareTeamDialog-D7jlR9HK.js} +1 -1
  31. package/dist/assets/{SignedInSites-DkQMWpRc.js → SignedInSites-zRGAI6no.js} +1 -1
  32. package/dist/assets/{TeamLibraryPanel-CnhMRwup.js → TeamLibraryPanel-ssb1UDr5.js} +1 -1
  33. package/dist/assets/{TeamMapPage-7eoMAyZs.js → TeamMapPage-BS05D1gH.js} +1 -1
  34. package/dist/assets/{TriggersPage-CvtwSgIq.js → TriggersPage-Bnny-m5i.js} +1 -1
  35. package/dist/assets/{VisibilitySection-CrMCXcM_.js → VisibilitySection-DYoJ1GdM.js} +1 -1
  36. package/dist/assets/{WebhookTrigger-DxnvfaPZ.js → WebhookTrigger-TRl3ZXbh.js} +1 -1
  37. package/dist/assets/{WorksOnGrid-CtcuFETm.js → WorksOnGrid-KH_NgeB8.js} +1 -1
  38. package/dist/assets/{abnfDiagram-YUKMZFIV-Bz6GT9ki.js → abnfDiagram-YUKMZFIV-BJa3HT_w.js} +1 -1
  39. package/dist/assets/{activity-BTE6SMHx.js → activity-DpguW9va.js} +1 -1
  40. package/dist/assets/{architectureDiagram-47P4ROYG-CVJfbFnd.js → architectureDiagram-47P4ROYG-C5gEKdsw.js} +1 -1
  41. package/dist/assets/{blockDiagram-E7TT5TSB-CMJZ058G.js → blockDiagram-E7TT5TSB-CT7xbCQZ.js} +1 -1
  42. package/dist/assets/{c4Diagram-CRA5TL53-Bcpf92Q7.js → c4Diagram-CRA5TL53-DSFZqTvf.js} +1 -1
  43. package/dist/assets/{calendar-days-DFNHSca_.js → calendar-days-ASlaivsQ.js} +1 -1
  44. package/dist/assets/channel-BqGEhKY0.js +1 -0
  45. package/dist/assets/{chunk-2Q5K7J3B-rROdH8y1.js → chunk-2Q5K7J3B-OtLqmkVp.js} +1 -1
  46. package/dist/assets/{chunk-5VM5RSS4-Gd9w73XJ.js → chunk-5VM5RSS4-Rq3LG0x-.js} +1 -1
  47. package/dist/assets/{chunk-7TKQ45FW-BRSSIX0r.js → chunk-7TKQ45FW-BvOFm5yO.js} +1 -1
  48. package/dist/assets/{chunk-AW2ZBBNX-fA_30rhU.js → chunk-AW2ZBBNX-Bp8ouRZs.js} +1 -1
  49. package/dist/assets/{chunk-FVRAUYC3-DPf3B5cF.js → chunk-FVRAUYC3-htnnltbK.js} +2 -2
  50. package/dist/assets/{chunk-HTAEGDNF-Kzp8IlCO.js → chunk-HTAEGDNF-dT7z7xQV.js} +1 -1
  51. package/dist/assets/{chunk-JWPE2WC7-BGJbQcUH.js → chunk-JWPE2WC7-BKhNCYBO.js} +1 -1
  52. package/dist/assets/{chunk-KQW6MTUR-D67e6u2B.js → chunk-KQW6MTUR-DeA1KhMw.js} +1 -1
  53. package/dist/assets/{chunk-XXDRQBXY-Ca87Y8ja.js → chunk-XXDRQBXY-DJCz3KwB.js} +1 -1
  54. package/dist/assets/{classDiagram-v2-K4WV4PDN-TEXCwmKE.js → classDiagram-v2-K4WV4PDN-BxZQcXjn.js} +1 -1
  55. package/dist/assets/{coins-D-qZ-kBF.js → coins-Kra8C23v.js} +1 -1
  56. package/dist/assets/{core-DVf7JTOd.js → core-D_ShnPPB.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-CNNKFtUt.js → cose-bilkent-JH36ORCC-DPvzbWJ-.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-DgCTQdJB.js → cynefin-EF2NZ3EQ-BU7oS4Kz.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-5JZrPpp0.js → cynefinDiagram-3GCD6N5R-BGBWfDSm.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-DfB1U7Ig.js → dagre-W4DXFKR2-IWCaUQIb.js} +1 -1
  61. package/dist/assets/{diagram-2UJZ2QOL-CUnhXNqi.js → diagram-2UJZ2QOL-Bhk3LC2M.js} +1 -1
  62. package/dist/assets/{diagram-OVF4WLC6-Cvq5rGDL.js → diagram-OVF4WLC6-CuabegT5.js} +1 -1
  63. package/dist/assets/{diagram-PFPMY2P6-B-7f57WA.js → diagram-PFPMY2P6-CoS7hKtb.js} +1 -1
  64. package/dist/assets/{diagram-UMYRVEAY-BxLx7qVG.js → diagram-UMYRVEAY-BQmo6hIx.js} +1 -1
  65. package/dist/assets/{diagram-YEKJPTXX-DP950rJu.js → diagram-YEKJPTXX-Dn-KHH-s.js} +1 -1
  66. package/dist/assets/{diagram-ZIFT7M5P-BhtOX3wi.js → diagram-ZIFT7M5P-BCWmVp3z.js} +1 -1
  67. package/dist/assets/{ebnfDiagram-VR2GEFS7-C6hk9Jmp.js → ebnfDiagram-VR2GEFS7-Bb086aqc.js} +1 -1
  68. package/dist/assets/{elk-IJKZMXRS-Bag6l1-J.js → elk-IJKZMXRS-C0AdhTr_.js} +1 -1
  69. package/dist/assets/{erDiagram-O2IAPWRE-BRX-fn6a.js → erDiagram-O2IAPWRE-CGa-MwBB.js} +1 -1
  70. package/dist/assets/{file-up-Bkktf2Wj.js → file-up-XN39lGyR.js} +1 -1
  71. package/dist/assets/{flowDiagram-OXPTDLAJ-CkjzLOJE.js → flowDiagram-OXPTDLAJ-BdLF4FEb.js} +1 -1
  72. package/dist/assets/{ganttDiagram-R7TSEDQI-4CAOJpRz.js → ganttDiagram-R7TSEDQI-iXPVrTqJ.js} +1 -1
  73. package/dist/assets/{gitGraphDiagram-XJZIOB7I-CskAy2ZD.js → gitGraphDiagram-XJZIOB7I-DA55YE0F.js} +1 -1
  74. package/dist/assets/{import-name-D4tI24_q.js → import-name-CNEv8Wx8.js} +1 -1
  75. package/dist/assets/{index-5OuBrk-s.js → index-BDVsw1Qr.js} +1 -1
  76. package/dist/assets/{index-BfvuKok1.js → index-CnQ2pCf7.js} +2 -2
  77. package/dist/assets/{index-DYquK9TF.js → index-CtBcDSNT.js} +1 -1
  78. package/dist/assets/{infoDiagram-5W2HQ5XZ-DwRSrZJz.js → infoDiagram-5W2HQ5XZ-DwwOOuPK.js} +1 -1
  79. package/dist/assets/{ishikawaDiagram-K3B6WC7H-D4AYxiIn.js → ishikawaDiagram-K3B6WC7H-uOns6fyB.js} +1 -1
  80. package/dist/assets/{journeyDiagram-COXZFDF6-Cy64QkAf.js → journeyDiagram-COXZFDF6-BNlo402b.js} +1 -1
  81. package/dist/assets/{kanban-definition-P3RFRI5V-BJPaLHmy.js → kanban-definition-P3RFRI5V-rApNRuxE.js} +1 -1
  82. package/dist/assets/{mcp-servers-1TpToatr.js → mcp-servers-DiCs_cE-.js} +1 -1
  83. package/dist/assets/{mermaid.core-BdIBhisy.js → mermaid.core-UoMXw4Pf.js} +4 -4
  84. package/dist/assets/{mindmap-definition-LZFPQGKD-di98H0Xi.js → mindmap-definition-LZFPQGKD-DMx0e0Ua.js} +1 -1
  85. package/dist/assets/{minimize-BZwJDZD1.js → minimize-C6tWjaQW.js} +1 -1
  86. package/dist/assets/{monitor-Chdrm5wS.js → monitor-CqHNmvSo.js} +1 -1
  87. package/dist/assets/{new-bot-K3vr9SqG.js → new-bot-CpjPfYn1.js} +1 -1
  88. package/dist/assets/{org-library-B5ne7DWA.js → org-library-DkWIJaGU.js} +1 -1
  89. package/dist/assets/{package-format-CibzDzgo.js → package-format-DQ8Q_tWB.js} +1 -1
  90. package/dist/assets/{pegDiagram-BGZESJAR-DHf_ETMP.js → pegDiagram-BGZESJAR-BGjO4xhf.js} +1 -1
  91. package/dist/assets/{pieDiagram-CAPJLFHJ-D26EUC2Q.js → pieDiagram-CAPJLFHJ-CKDnQaP9.js} +1 -1
  92. package/dist/assets/{quadrantDiagram-GDMTTRAM-CXd_WAYg.js → quadrantDiagram-GDMTTRAM-2Yd2aagw.js} +1 -1
  93. package/dist/assets/{rail-DnNaCE3b.js → rail-DzTUJt9y.js} +1 -1
  94. package/dist/assets/{railroadDiagram-SM67HX2B-CCLyjg6m.js → railroadDiagram-SM67HX2B-2p7uXTy-.js} +1 -1
  95. package/dist/assets/{remote-desktop-panel-zURkbtzE.js → remote-desktop-panel-CWP7wnfp.js} +1 -1
  96. package/dist/assets/{requirementDiagram-X7JNWC4A-DfIjRZlK.js → requirementDiagram-X7JNWC4A-B8Tb583R.js} +1 -1
  97. package/dist/assets/{sankeyDiagram-UM26HJRW-a192NXbb.js → sankeyDiagram-UM26HJRW-uH_0e9a7.js} +1 -1
  98. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-BN8CB3xi.js → sequenceDiagram-ZO4K6R2Y-BL2NmEjq.js} +1 -1
  99. package/dist/assets/{sizeCapture-INFHLROL-vA44CP_C.js → sizeCapture-INFHLROL-CF5rj-Tn.js} +1 -1
  100. package/dist/assets/{stateDiagram-v2-TBUQTH76-BNZvoQfc.js → stateDiagram-v2-TBUQTH76-Bi8FVJmD.js} +1 -1
  101. package/dist/assets/{styles-GmtHzqPG.js → styles-3gApXdcp.js} +2 -2
  102. package/dist/assets/{styles-m-GdEmxH.css → styles-D-yh7Z23.css} +1 -1
  103. package/dist/assets/{swimlanes-N4OXWK64-BoC9nCsP.js → swimlanes-N4OXWK64-cI7SKAY4.js} +1 -1
  104. package/dist/assets/swimlanesDiagram-K3J5GTZL-D8raS3ll.js +8 -0
  105. package/dist/assets/{team-share-n1TGl5ex.js → team-share-Dy8-U6dh.js} +1 -1
  106. package/dist/assets/{timeline-definition-YOQAKGHF-C8Qj9CXc.js → timeline-definition-YOQAKGHF-DgYVfZT2.js} +1 -1
  107. package/dist/assets/{usecaseDiagram-VIAY4XPW-vabAoQKz.js → usecaseDiagram-VIAY4XPW-DA-ohLD0.js} +1 -1
  108. package/dist/assets/{vennDiagram-BLWOH2XV-BMQyc0xY.js → vennDiagram-BLWOH2XV-DvsWwQlH.js} +1 -1
  109. package/dist/assets/vi-KgT8L8Qj.js +15 -0
  110. package/dist/assets/{wardleyDiagram-YMQ3BMBF-B5DEfy_2.js → wardleyDiagram-YMQ3BMBF--20oJB2z.js} +1 -1
  111. package/dist/assets/{xychartDiagram-TAQBALBS-J0E9Gsc_.js → xychartDiagram-TAQBALBS-C8j4OKSW.js} +1 -1
  112. package/dist/index.html +3 -3
  113. package/dist/rail.html +5 -5
  114. package/dist-server/index.js +87 -54
  115. package/dist-server/openmausbot.js +87 -54
  116. package/dist-server/package.json +1 -1
  117. package/dist-server/shared/mascot-bodies.js +23 -23
  118. package/package.json +1 -1
  119. package/dist/assets/PlacesRail-BJBF_akb.js +0 -57
  120. package/dist/assets/channel-SsqFZfUs.js +0 -1
  121. package/dist/assets/swimlanesDiagram-K3J5GTZL-pZjwzZmz.js +0 -8
  122. package/dist/assets/vi-VlbIiohE.js +0 -6
@@ -1 +1 @@
1
- import{t,r as y,j as s}from"./styles-GmtHzqPG.js";import{W as Z,u as _,b8 as ee,D as R,G as se,T as te,n as B,A as z}from"./App-DqXMyMLs.js";import{r as ne,i as ie}from"./index-BfvuKok1.js";import{S as q}from"./SignedInSites-DkQMWpRc.js";import{P as re}from"./PlacesRail-BJBF_akb.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-${Z().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:W}=_(),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)}}},X=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)}}},Y=async e=>{if(!(a||!o||o.busy||e===(o.browserProfile??""))){f(!0),u("");try{await W(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=>{Y(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=>{X(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-3gApXdcp.js";import{W as Z,u as _,b8 as ee,D as R,G as se,T as te,n as B,A as z}from"./App-0-mtr0MN.js";import{r as ne,i as ie}from"./index-CnQ2pCf7.js";import{S as q}from"./SignedInSites-zRGAI6no.js";import{P as re}from"./PlacesRail-C-RypDbo.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-${Z().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:W}=_(),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)}}},X=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)}}},Y=async e=>{if(!(a||!o||o.busy||e===(o.browserProfile??""))){f(!0),u("");try{await W(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=>{Y(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=>{X(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,E as q,F as ve,H as M,t as n,G as se,Q,J as X,K as Pe,M as pe,N as Ce,O as Ee,T as fe,U as ze,V as Ae,W as Ue,Y as qe,Z as Me,$ as J,a as ue,a0 as $e,a1 as Ke,r as c,a2 as We,a3 as Ve,a4 as we,D as U,a5 as Ge,X as Je,a6 as Qe,a7 as Xe,a8 as Ye,a9 as Ze,aa as et,ab as Le,ac as tt}from"./styles-GmtHzqPG.js";import{L as nt,y as st,C as at,z as lt,F as ot,G as rt,S as ct,H as dt,I as it}from"./PlacesRail-BJBF_akb.js";import{u as ut}from"./App-DqXMyMLs.js";import"./monitor-Chdrm5wS.js";import"./index-BfvuKok1.js";import"./MenuMotion-nTkCdPNb.js";function pt({name:t,color:l,busy:o,interest:r,openFailed:s,onInterest:p,onOpen:f}){return e.jsxs("div",{"data-cloud-add":"has-cloud",className:q,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(ve,{color:l,size:32}),e.jsx(M,{title:n("cloudBuy.one.title"),sub:n("cloudBuy.one.sub",{name:t})})]}),e.jsxs("div",{className:se,children:[r!=="sent"&&e.jsx("button",{type:"button",className:Q,disabled:o,onClick:p,children:n("cloudBuy.one.email")}),e.jsx("button",{type:"button",className:X,disabled:o,onClick:f,children:n("cloudBuy.setup.open",{name:t})})]}),e.jsxs("div",{"aria-live":"polite",className:"text-[13px] leading-[18px] empty:-mt-5",children:[r==="sent"&&e.jsx("p",{className:"text-ink-secondary",children:n("cloudBuy.one.thanks")}),r==="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:r}){return e.jsxs("div",{"data-cloud-add":t,className:q,children:[e.jsx(M,{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(nt,{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:r,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:r,link:s,email:p,busy:f,copied:v,failed:N,onReopen:k,onCopy:T,onChangePlan:$}){const y=l?.plans.find(K=>K.tier===t)??null,E=y?Pe(y):pe(t),A=y?.trialDays===1?n("cloudBuy.pay.planTrial.one",{plan:E,due:Ce(0)}):y?.trialDays?n("cloudBuy.pay.planTrial.many",{plan:E,days:y.trialDays,due:Ce(0)}):y?n("cloudBuy.pay.planPaid",{plan:E,price:Ee(y.amount/100)}):E;return e.jsxs("div",{"data-cloud-add":r?"waiting-late":o==="signin"?"waiting-signin":"waiting",className:q,children:[e.jsx(M,{title:r?n("cloudBuy.pay.lateTitle"):n("cloudAdd.browserTitle"),sub:r?n("cloudBuy.pay.lateSub"):n(o==="signin"?"cloudBuy.pay.subSignIn":"cloudBuy.pay.sub")}),e.jsx(fe,{items:[{key:"signed-in",state:"done",title:n("cloudBuy.pay.signedIn"),detail:p},{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:r?X:Q,disabled:f,onClick:k,children:[e.jsx(st,{size:14,"aria-hidden":"true"}),n("cloudAdd.reopenCheckout")]}),s&&e.jsxs("button",{type:"button",className:Q,disabled:f,onClick:T,children:[e.jsx(at,{size:14,"aria-hidden":"true"}),n("cloudBuy.pay.copy")]}),e.jsx("button",{type:"button",className:`${ze} ms-1 px-1 py-1`,onClick:$,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 H=[["reserving","cloudHome.step.reserving"],["storage","cloudHome.step.storage"],["starting","cloudBuy.step.starting"],["checking","cloudHome.step.checking"]];function mt({tier:t,trial:l,credit:o},r){if(r)return n("cloudAdd.receivedTitle");const s=pe(t??l?.tier??void 0);return l?o?n("cloudBuy.setup.badgeCredit",{plan:s,credit:Ee(o.grantedUsd)}):n("cloudBuy.setup.badgeTrial",{plan:s}):n("cloudBuy.setup.badgePaid",{plan:s})}function xt({started:t,received:l,step:o,slow:r,ready:s,sleeps:p=!1,name:f,typed:v,color:N,counting:k,busy:T,openFailed:$,onName:y,onColor:E,onOpen:A,onNotNow:K}){const D=s?H.length:Math.max(0,H.findIndex(([d])=>d===o)),C=pe(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:q,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ue,{children:mt(t,l)}),e.jsx(M,{title:s?n("cloudBuy.ready.title",{name:f}):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(Ae,{value:D/H.length,label:n("cloudBuy.setup.progress")}),e.jsx(fe,{label:n("cloudBuy.setup.progress"),items:H.map(([d,w],j)=>({key:d,title:n(w,{name:f}),state:j<D?"done":j===D?"now":"next"}))}),r&&!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:Me,placeholder:n("cloudSetup.myCloud"),autoComplete:"off",spellCheck:!1,onChange:d=>y(d.target.value),className:qe})]}),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:J.map(d=>e.jsx("button",{type:"button",role:"radio","aria-checked":d===N,"aria-label":n(Ke[d]),tabIndex:d===N?0:-1,"data-color":d,onClick:()=>E(d),onKeyDown:w=>{const j=J.indexOf(d),W=w.key==="ArrowRight"||w.key==="ArrowDown"?1:w.key==="ArrowLeft"||w.key==="ArrowUp"?-1:0;if(!W)return;w.preventDefault();const Y=J[(j+W+J.length)%J.length];E(Y),w.currentTarget.parentElement?.querySelector(`[data-color="${Y}"]`)?.focus()},style:{background:$e(d)},className:ue("size-[26px] rounded-lg border-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",d===N?"border-ink shadow-[inset_0_0_0_2px_var(--color-app)]":"border-transparent")},d))})]}),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:f}),e.jsx("span",{className:"block truncate text-[12px] text-ink-tertiary",children:n(p?"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:f})}),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:K,children:n("notice.notNow")}),e.jsx("button",{type:"button",className:X,disabled:!s||T,onClick:A,children:n("cloudBuy.setup.open",{name:f})})]}),$&&e.jsx("p",{role:"alert",className:"-mt-2 text-end text-[13px] leading-[18px] text-danger",children:n("cloudBuy.openFailed",{name:f})})]})}function yt({team:t,step:l,slow:o}){const r=Math.max(0,H.findIndex(([p])=>p===l)),s=t??n("cloudBuy.team.unnamed");return e.jsxs("div",{"data-cloud-add":"team-starting","data-cloud-setup":l??"reserving",className:q,children:[e.jsx(M,{title:n("cloudBuy.team.setupTitle"),sub:n("cloudBuy.team.setupSub")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ae,{value:r/H.length,label:n("cloudBuy.setup.progress")}),e.jsx(fe,{label:n("cloudBuy.setup.progress"),items:H.map(([p,f],v)=>({key:p,title:n(f,{name:s}),state:v<r?"done":v===r?"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:r}){return e.jsxs("div",{"data-cloud-add":"team-ready",className:q,children:[e.jsx(M,{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:r,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(dt,{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(ct,{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(rt,{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:et(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]"},kt=new Set(["sign-in","signing-in","waiting","starting","team-starting"]);function Be({kind:t,staging:l,onClose:o,children:r}){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.target===s.currentTarget&&!kt.has(t)&&o(),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"cloud-add-title","data-cloud-add-dialog":!0,tabIndex:-1,className:ue(Ze,"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(Xe,Qe,"absolute end-4 top-4 z-10"),children:e.jsx(Je,{size:16})}),l&&e.jsx(Ye,{className:"absolute end-14 top-[22px] z-10 group-has-[[data-night-card]]/sheet:bg-app"}),r]})})}const jt=["offer","checking","unreachable","waiting","sign-in","signing-in"],St="button:not([disabled]):not([tabindex='-1']), input:not([disabled]):not([tabindex='-1']), [href], [tabindex='0']",Nt=t=>t.status==="connected"&&t.entitlement?.plan==="free"&&!t.purchase&&!t.machine,Ct=t=>t?.status==="connected"&&t.entitlement?.plan==="pro"&&t.entitlement.status==="active"?t.entitlement.tier??"pro":null;function Tt({now:t=Date.now}){const{state:l,dispatch:o}=ut(),r=l.cloudAdd,s=window.ogb?.remoteClient?.active?void 0:window.ogb?.cloudAccount,[p,f]=c.useState(null),[v,N]=c.useState(void 0),[k,T]=c.useState(null),[$,y]=c.useState(null),[E,A]=c.useState(!1),[K,D]=c.useState(!1),[C,d]=c.useState(!1),[w,j]=c.useState(!1),[W,Y]=c.useState(0),[Z,me]=c.useState([]),[h,g]=c.useState(null),[I,O]=c.useState({email:"",code:""}),[B,ee]=c.useState(null),[F,P]=c.useState(null),[z,S]=c.useState(null),[,Te]=c.useState(0),[xe,ae]=c.useState(!1),[Ie,le]=c.useState(!1),[Oe,Fe]=c.useState(!1),L=!!(r&&s),oe=l.config?.profile?.email?.trim()||null,re=ot();c.useEffect(()=>{if(!L||!s)return;let a=!0,i=!1;const b=s.onState(m=>{i=!0,a&&f(m)});return s.state().then(m=>{a&&!i&&f(m)}).catch(()=>{}),()=>{a=!1,b()}},[L,s]);const x=L?We(p,v,{now:t(),error:$,choosing:K,conflict:E,signIn:h,arrived:xe,terms:Ie}):null,ye=L&&x&&jt.includes(x.kind)&&p?`${p.status}:${JSON.stringify(p.offer??null)}:${W}`:null;c.useEffect(()=>{if(!ye||!s?.offer)return;let a=!0;return s.offer().then(i=>{a&&N(i)},()=>{a&&N(null)}),()=>{a=!1}},[ye,s]);const ce=n("cloudSetup.myCloud"),V={typed:B?.typed??ce,color:B?.color??we,name:Ve(B?.typed??ce,ce)},_=()=>{h&&s?.signInCancel?.().catch(()=>{}),o({type:"closeCloudAdd"}),y(null),A(!1),D(!1),j(!1),me([]),T(null),g(null),O({email:"",code:""}),ee(null),P(null),S(null),ae(!1),le(!1)};c.useEffect(()=>{if(!L)return;const a=document.activeElement,i=a&&a!==document.body&&typeof a.focus=="function"?a:null;r?.signIn&&(g({step:"email",intent:!1,problem:null}),O({email:oe??"",code:""}));const b=m=>{if(m.key==="Escape"){m.preventDefault(),_();return}if(m.key!=="Tab")return;const R=[...document.querySelector("[data-cloud-add-dialog]")?.querySelectorAll(St)??[]];if(!R.length)return;m.preventDefault();const Ne=R.indexOf(document.activeElement);R[Ne===-1?0:(Ne+(m.shiftKey?-1:1)+R.length)%R.length].focus()};return window.addEventListener("keydown",b,!0),(document.querySelector("#cloud-add-title")??document.querySelector("[data-cloud-add-dialog]"))?.focus(),()=>{window.removeEventListener("keydown",b,!0),i?.isConnected&&i.focus()}},[L]),c.useEffect(()=>{if(!(!L||!s?.sheet||re))return s.sheet(!0).catch(()=>{}),()=>{s.sheet?.(!1).catch(()=>{})}},[L,s,re]);const u=x?.kind??null,te=x?.kind==="sign-in"?`sign-in-${x.phase.step}`:u;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(()=>{(u==="waiting"||u==="starting"||u==="ready")&&!xe&&ae(!0),(u==="ready"||u==="team-ready")&&s?.readySeen?.().catch(()=>{})},[u]),c.useEffect(()=>{if(!u||!r)return;if(u==="settings"){_(),o({type:"toggleAppSettings",open:!0,section:"cloudAccount"});return}if(u==="checking")return;const a=Z.length===0;a&&U("cloud_dialog_shown",{source:r.source,view:u}),["starting","ready"].includes(u)&&!Z.includes(u)&&U("cloud_dialog_view",{view:u}),(a||!Z.includes(u))&&me([...Z,u])},[u]),c.useEffect(()=>{if(!u||!["starting","ready","has-cloud"].includes(u)||B||!s?.look)return;let a=!0;return s.look().then(i=>{a&&ee({typed:i.name,color:Ge(i.color)??we,dirty:u!=="has-cloud"})},()=>{}),()=>{a=!1}},[u]),c.useEffect(()=>{if(!B?.dirty||!s?.setLook)return;const a=setTimeout(()=>{s.setLook?.(V.name,B.color).catch(()=>{})},400);return()=>clearTimeout(a)},[B?.typed,B?.color]),c.useEffect(()=>{u!=="ready"||F!==null||P(!re&&typeof document.hasFocus=="function"&&document.hasFocus()?3:"off")},[u]);const ge=h?.step==="code"?h.resendAt:0;c.useEffect(()=>{if(!ge||ge<=t())return;const a=setTimeout(()=>Te(t()),1e3);return()=>clearTimeout(a)}),c.useEffect(()=>{if(z!=="copied")return;const a=setTimeout(()=>S(null),2500);return()=>clearTimeout(a)},[z]);const ne=a=>{C||(d(!0),j(!1),a().catch(()=>y("failed")).finally(()=>d(!1)))},he=()=>{C||!s||(d(!0),j(!1),P("done"),(async()=>{B?.dirty&&s.setLook&&await s.setLook(V.name,B.color).catch(()=>{}),await s.connectHome()})().then(()=>_(),()=>j(!0)).finally(()=>d(!1)))},_e=a=>{C||!s?.openTeam||(d(!0),j(!1),s.openTeam(a).then(()=>_(),()=>j(!0)).finally(()=>d(!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||!x||!r||!s||x.kind==="settings")return null;if(x.kind==="has-cloud"&&p?.status==="connected"&&p.clouds&&window.ogb?.cloudAdd&&(p.addCloud?.canAdd!==!1||p.adding&&!p.adding.done))return e.jsx(Be,{kind:Oe?"offer":"has-cloud",staging:p.staging===!0,onClose:_,children:e.jsx(lt,{onClose:_,onFirstCloud:()=>{},onWide:Fe,source:r.source})});const G=v??null,ke=()=>x.kind==="waiting"&&!k?x.plan:G?Le(G,k).tier:null,de=async a=>{if(!a||!s.checkout){y("failed");return}const i=!!G?.plans.find(R=>R.tier===a)?.trialDays,b=await s.checkout(a,r.source),m=b.outcome;f(b.state),m==="opened"||m==="signing-in"?(D(!1),y(null),A(!1),S(null),le(!1),U("cloud_checkout_opened",{plan:a,trial:i,source:r.source})):m==="rate-limited"?y("rate-limited"):m==="failed"?y("failed"):A(!0)},je=a=>{g({step:"email",intent:a,problem:null}),O({email:I.email||oe||"",code:""})},Se=()=>{if(C||!s.signInStart||!h||h.step==="done")return;const a=h;d(!0),s.signInStart(I.email).then(i=>{i.outcome==="sent"?(g({step:"code",intent:a.intent,email:i.email,resendAt:i.resendAt,problem:null,triesLeft:null,...i.signupOpen===!1?{signupOpen:!1}:{}}),O({email:i.email,code:""}),U("cloud_signin",{step:"code_sent",source:r.source})):g({...a,problem:i.outcome})},()=>g({...a,problem:"failed"})).finally(()=>d(!1))},De=a=>{if(!s.signInVerify||h?.step!=="code")return;const i=h,b=i.intent?ke():null;d(!0),(async()=>{try{const m=await s.signInVerify(a);if(m.outcome!=="signed-in"){O({email:I.email,code:""}),g({...i,problem:m.outcome,triesLeft:m.outcome==="wrong-code"?m.triesLeft:null});return}f(m.state),ae(!0),U("cloud_signin",{step:"signed_in",source:r.source}),b&&Nt(m.state)&&(tt(G,m.state.offer,b)?(g({step:"done",intent:!0}),await de(b)):(le(!0),T(b))),g(null),O({email:I.email,code:""})}catch{g({...i,problem:"failed",triesLeft:null})}finally{d(!1)}})()},Re={start:a=>{if(T(a),A(!1),x.kind==="offer"&&x.signedOut&&s.signInStart){je(!0);return}ne(()=>de(a))},signIn:()=>je(!1),back:()=>{g(null),s.signInCancel?.().catch(()=>{})},email:a=>O({email:a,code:I.code}),sendCode:Se,changeEmail:()=>{h&&(g({step:"email",intent:h.intent,problem:null}),s.signInCancel?.().catch(()=>{}))},code:a=>{const i=it(a);O({email:I.email,code:i}),i.length===8&&!C&&De(i)},resend:Se,browser:()=>ne(async()=>{const a=h?.intent?ke():null;g(null),await s.signInCancel?.().catch(()=>{}),U("cloud_signin",{step:"browser",source:r.source}),a?await de(a):f(await s.begin())}),reopenBrowser:()=>ne(async()=>f(await s.reopen())),cancelSignIn:()=>ne(async()=>f(await s.cancel())),reopenCheckout:()=>{if(x.kind!=="waiting"||C)return;d(!0),S(null),(s.reopenCheckout?s.reopenCheckout(x.plan,r.source):s.checkout(x.plan,r.source)).then(i=>{f(i.state),i.outcome!=="opened"&&S("pay-failed")},()=>S("pay-failed")).finally(()=>d(!1))},copyLink:()=>{s.copyCheckoutLink?.().then(a=>S(a?"copied":"pay-failed"),()=>S("pay-failed"))},changePlan:()=>{T(x.kind==="waiting"?x.plan:k),D(!0),S(null)},retry:()=>{y(null),A(!1),N(void 0),Y(W+1)},name:a=>ee({typed:a,color:V.color,dirty:!0}),color:a=>ee({typed:V.typed,color:a,dirty:!0}),openCloud:he,openTeam:_e,notNow:()=>P("off"),interest:()=>{C||!s.interest||(d(!0),s.interest().then(()=>S("interest-sent"),()=>S("interest-failed")).finally(()=>d(!1)))},close:_},He={chosen:k,current:Ct(p),offerShown:G,now:t(),busy:C,openFailed:w,email:I.email,code:I.code,profileEmail:oe,look:V,counting:typeof F=="number"?F:null,copied:z==="copied",payFailed:z==="pay-failed",interest:z==="interest-sent"?"sent":z==="interest-failed"?"failed":null};return e.jsx(Be,{kind:x.kind,staging:p?.staging===!0,onClose:_,children:e.jsx(ht,{view:x,ui:He,actions:Re})})}export{Tt as CloudAddDialog,ht as CloudAddPanel,Be as CloudAddSheet};
1
+ import{j as e,E as q,F as ve,H as M,t as n,G as se,Q,J as X,K as Pe,M as pe,N as Ce,O as Ee,T as fe,U as ze,V as Ae,W as Ue,Y as qe,Z as Me,$ as J,a as ue,a0 as $e,a1 as Ke,r as c,a2 as We,a3 as Ve,a4 as we,D as U,a5 as Ge,X as Je,a6 as Qe,a7 as Xe,a8 as Ye,a9 as Ze,aa as et,ab as Le,ac as tt}from"./styles-3gApXdcp.js";import{L as nt,y as st,C as at,z as lt,F as ot,G as rt,S as ct,H as dt,I as it}from"./PlacesRail-C-RypDbo.js";import{u as ut}from"./App-0-mtr0MN.js";import"./monitor-CqHNmvSo.js";import"./index-CnQ2pCf7.js";import"./MenuMotion-Dg_hALEl.js";function pt({name:t,color:l,busy:o,interest:r,openFailed:s,onInterest:p,onOpen:f}){return e.jsxs("div",{"data-cloud-add":"has-cloud",className:q,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(ve,{color:l,size:32}),e.jsx(M,{title:n("cloudBuy.one.title"),sub:n("cloudBuy.one.sub",{name:t})})]}),e.jsxs("div",{className:se,children:[r!=="sent"&&e.jsx("button",{type:"button",className:Q,disabled:o,onClick:p,children:n("cloudBuy.one.email")}),e.jsx("button",{type:"button",className:X,disabled:o,onClick:f,children:n("cloudBuy.setup.open",{name:t})})]}),e.jsxs("div",{"aria-live":"polite",className:"text-[13px] leading-[18px] empty:-mt-5",children:[r==="sent"&&e.jsx("p",{className:"text-ink-secondary",children:n("cloudBuy.one.thanks")}),r==="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:r}){return e.jsxs("div",{"data-cloud-add":t,className:q,children:[e.jsx(M,{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(nt,{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:r,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:r,link:s,email:p,busy:f,copied:v,failed:N,onReopen:k,onCopy:T,onChangePlan:$}){const y=l?.plans.find(K=>K.tier===t)??null,E=y?Pe(y):pe(t),A=y?.trialDays===1?n("cloudBuy.pay.planTrial.one",{plan:E,due:Ce(0)}):y?.trialDays?n("cloudBuy.pay.planTrial.many",{plan:E,days:y.trialDays,due:Ce(0)}):y?n("cloudBuy.pay.planPaid",{plan:E,price:Ee(y.amount/100)}):E;return e.jsxs("div",{"data-cloud-add":r?"waiting-late":o==="signin"?"waiting-signin":"waiting",className:q,children:[e.jsx(M,{title:r?n("cloudBuy.pay.lateTitle"):n("cloudAdd.browserTitle"),sub:r?n("cloudBuy.pay.lateSub"):n(o==="signin"?"cloudBuy.pay.subSignIn":"cloudBuy.pay.sub")}),e.jsx(fe,{items:[{key:"signed-in",state:"done",title:n("cloudBuy.pay.signedIn"),detail:p},{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:r?X:Q,disabled:f,onClick:k,children:[e.jsx(st,{size:14,"aria-hidden":"true"}),n("cloudAdd.reopenCheckout")]}),s&&e.jsxs("button",{type:"button",className:Q,disabled:f,onClick:T,children:[e.jsx(at,{size:14,"aria-hidden":"true"}),n("cloudBuy.pay.copy")]}),e.jsx("button",{type:"button",className:`${ze} ms-1 px-1 py-1`,onClick:$,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 H=[["reserving","cloudHome.step.reserving"],["storage","cloudHome.step.storage"],["starting","cloudBuy.step.starting"],["checking","cloudHome.step.checking"]];function mt({tier:t,trial:l,credit:o},r){if(r)return n("cloudAdd.receivedTitle");const s=pe(t??l?.tier??void 0);return l?o?n("cloudBuy.setup.badgeCredit",{plan:s,credit:Ee(o.grantedUsd)}):n("cloudBuy.setup.badgeTrial",{plan:s}):n("cloudBuy.setup.badgePaid",{plan:s})}function xt({started:t,received:l,step:o,slow:r,ready:s,sleeps:p=!1,name:f,typed:v,color:N,counting:k,busy:T,openFailed:$,onName:y,onColor:E,onOpen:A,onNotNow:K}){const D=s?H.length:Math.max(0,H.findIndex(([d])=>d===o)),C=pe(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:q,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ue,{children:mt(t,l)}),e.jsx(M,{title:s?n("cloudBuy.ready.title",{name:f}):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(Ae,{value:D/H.length,label:n("cloudBuy.setup.progress")}),e.jsx(fe,{label:n("cloudBuy.setup.progress"),items:H.map(([d,w],j)=>({key:d,title:n(w,{name:f}),state:j<D?"done":j===D?"now":"next"}))}),r&&!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:Me,placeholder:n("cloudSetup.myCloud"),autoComplete:"off",spellCheck:!1,onChange:d=>y(d.target.value),className:qe})]}),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:J.map(d=>e.jsx("button",{type:"button",role:"radio","aria-checked":d===N,"aria-label":n(Ke[d]),tabIndex:d===N?0:-1,"data-color":d,onClick:()=>E(d),onKeyDown:w=>{const j=J.indexOf(d),W=w.key==="ArrowRight"||w.key==="ArrowDown"?1:w.key==="ArrowLeft"||w.key==="ArrowUp"?-1:0;if(!W)return;w.preventDefault();const Y=J[(j+W+J.length)%J.length];E(Y),w.currentTarget.parentElement?.querySelector(`[data-color="${Y}"]`)?.focus()},style:{background:$e(d)},className:ue("size-[26px] rounded-lg border-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",d===N?"border-ink shadow-[inset_0_0_0_2px_var(--color-app)]":"border-transparent")},d))})]}),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:f}),e.jsx("span",{className:"block truncate text-[12px] text-ink-tertiary",children:n(p?"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:f})}),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:K,children:n("notice.notNow")}),e.jsx("button",{type:"button",className:X,disabled:!s||T,onClick:A,children:n("cloudBuy.setup.open",{name:f})})]}),$&&e.jsx("p",{role:"alert",className:"-mt-2 text-end text-[13px] leading-[18px] text-danger",children:n("cloudBuy.openFailed",{name:f})})]})}function yt({team:t,step:l,slow:o}){const r=Math.max(0,H.findIndex(([p])=>p===l)),s=t??n("cloudBuy.team.unnamed");return e.jsxs("div",{"data-cloud-add":"team-starting","data-cloud-setup":l??"reserving",className:q,children:[e.jsx(M,{title:n("cloudBuy.team.setupTitle"),sub:n("cloudBuy.team.setupSub")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ae,{value:r/H.length,label:n("cloudBuy.setup.progress")}),e.jsx(fe,{label:n("cloudBuy.setup.progress"),items:H.map(([p,f],v)=>({key:p,title:n(f,{name:s}),state:v<r?"done":v===r?"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:r}){return e.jsxs("div",{"data-cloud-add":"team-ready",className:q,children:[e.jsx(M,{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:r,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(dt,{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(ct,{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(rt,{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:et(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]"},kt=new Set(["sign-in","signing-in","waiting","starting","team-starting"]);function Be({kind:t,staging:l,onClose:o,children:r}){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.target===s.currentTarget&&!kt.has(t)&&o(),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"cloud-add-title","data-cloud-add-dialog":!0,tabIndex:-1,className:ue(Ze,"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(Xe,Qe,"absolute end-4 top-4 z-10"),children:e.jsx(Je,{size:16})}),l&&e.jsx(Ye,{className:"absolute end-14 top-[22px] z-10 group-has-[[data-night-card]]/sheet:bg-app"}),r]})})}const jt=["offer","checking","unreachable","waiting","sign-in","signing-in"],St="button:not([disabled]):not([tabindex='-1']), input:not([disabled]):not([tabindex='-1']), [href], [tabindex='0']",Nt=t=>t.status==="connected"&&t.entitlement?.plan==="free"&&!t.purchase&&!t.machine,Ct=t=>t?.status==="connected"&&t.entitlement?.plan==="pro"&&t.entitlement.status==="active"?t.entitlement.tier??"pro":null;function Tt({now:t=Date.now}){const{state:l,dispatch:o}=ut(),r=l.cloudAdd,s=window.ogb?.remoteClient?.active?void 0:window.ogb?.cloudAccount,[p,f]=c.useState(null),[v,N]=c.useState(void 0),[k,T]=c.useState(null),[$,y]=c.useState(null),[E,A]=c.useState(!1),[K,D]=c.useState(!1),[C,d]=c.useState(!1),[w,j]=c.useState(!1),[W,Y]=c.useState(0),[Z,me]=c.useState([]),[h,g]=c.useState(null),[I,O]=c.useState({email:"",code:""}),[B,ee]=c.useState(null),[F,P]=c.useState(null),[z,S]=c.useState(null),[,Te]=c.useState(0),[xe,ae]=c.useState(!1),[Ie,le]=c.useState(!1),[Oe,Fe]=c.useState(!1),L=!!(r&&s),oe=l.config?.profile?.email?.trim()||null,re=ot();c.useEffect(()=>{if(!L||!s)return;let a=!0,i=!1;const b=s.onState(m=>{i=!0,a&&f(m)});return s.state().then(m=>{a&&!i&&f(m)}).catch(()=>{}),()=>{a=!1,b()}},[L,s]);const x=L?We(p,v,{now:t(),error:$,choosing:K,conflict:E,signIn:h,arrived:xe,terms:Ie}):null,ye=L&&x&&jt.includes(x.kind)&&p?`${p.status}:${JSON.stringify(p.offer??null)}:${W}`:null;c.useEffect(()=>{if(!ye||!s?.offer)return;let a=!0;return s.offer().then(i=>{a&&N(i)},()=>{a&&N(null)}),()=>{a=!1}},[ye,s]);const ce=n("cloudSetup.myCloud"),V={typed:B?.typed??ce,color:B?.color??we,name:Ve(B?.typed??ce,ce)},_=()=>{h&&s?.signInCancel?.().catch(()=>{}),o({type:"closeCloudAdd"}),y(null),A(!1),D(!1),j(!1),me([]),T(null),g(null),O({email:"",code:""}),ee(null),P(null),S(null),ae(!1),le(!1)};c.useEffect(()=>{if(!L)return;const a=document.activeElement,i=a&&a!==document.body&&typeof a.focus=="function"?a:null;r?.signIn&&(g({step:"email",intent:!1,problem:null}),O({email:oe??"",code:""}));const b=m=>{if(m.key==="Escape"){m.preventDefault(),_();return}if(m.key!=="Tab")return;const R=[...document.querySelector("[data-cloud-add-dialog]")?.querySelectorAll(St)??[]];if(!R.length)return;m.preventDefault();const Ne=R.indexOf(document.activeElement);R[Ne===-1?0:(Ne+(m.shiftKey?-1:1)+R.length)%R.length].focus()};return window.addEventListener("keydown",b,!0),(document.querySelector("#cloud-add-title")??document.querySelector("[data-cloud-add-dialog]"))?.focus(),()=>{window.removeEventListener("keydown",b,!0),i?.isConnected&&i.focus()}},[L]),c.useEffect(()=>{if(!(!L||!s?.sheet||re))return s.sheet(!0).catch(()=>{}),()=>{s.sheet?.(!1).catch(()=>{})}},[L,s,re]);const u=x?.kind??null,te=x?.kind==="sign-in"?`sign-in-${x.phase.step}`:u;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(()=>{(u==="waiting"||u==="starting"||u==="ready")&&!xe&&ae(!0),(u==="ready"||u==="team-ready")&&s?.readySeen?.().catch(()=>{})},[u]),c.useEffect(()=>{if(!u||!r)return;if(u==="settings"){_(),o({type:"toggleAppSettings",open:!0,section:"cloudAccount"});return}if(u==="checking")return;const a=Z.length===0;a&&U("cloud_dialog_shown",{source:r.source,view:u}),["starting","ready"].includes(u)&&!Z.includes(u)&&U("cloud_dialog_view",{view:u}),(a||!Z.includes(u))&&me([...Z,u])},[u]),c.useEffect(()=>{if(!u||!["starting","ready","has-cloud"].includes(u)||B||!s?.look)return;let a=!0;return s.look().then(i=>{a&&ee({typed:i.name,color:Ge(i.color)??we,dirty:u!=="has-cloud"})},()=>{}),()=>{a=!1}},[u]),c.useEffect(()=>{if(!B?.dirty||!s?.setLook)return;const a=setTimeout(()=>{s.setLook?.(V.name,B.color).catch(()=>{})},400);return()=>clearTimeout(a)},[B?.typed,B?.color]),c.useEffect(()=>{u!=="ready"||F!==null||P(!re&&typeof document.hasFocus=="function"&&document.hasFocus()?3:"off")},[u]);const ge=h?.step==="code"?h.resendAt:0;c.useEffect(()=>{if(!ge||ge<=t())return;const a=setTimeout(()=>Te(t()),1e3);return()=>clearTimeout(a)}),c.useEffect(()=>{if(z!=="copied")return;const a=setTimeout(()=>S(null),2500);return()=>clearTimeout(a)},[z]);const ne=a=>{C||(d(!0),j(!1),a().catch(()=>y("failed")).finally(()=>d(!1)))},he=()=>{C||!s||(d(!0),j(!1),P("done"),(async()=>{B?.dirty&&s.setLook&&await s.setLook(V.name,B.color).catch(()=>{}),await s.connectHome()})().then(()=>_(),()=>j(!0)).finally(()=>d(!1)))},_e=a=>{C||!s?.openTeam||(d(!0),j(!1),s.openTeam(a).then(()=>_(),()=>j(!0)).finally(()=>d(!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||!x||!r||!s||x.kind==="settings")return null;if(x.kind==="has-cloud"&&p?.status==="connected"&&p.clouds&&window.ogb?.cloudAdd&&(p.addCloud?.canAdd!==!1||p.adding&&!p.adding.done))return e.jsx(Be,{kind:Oe?"offer":"has-cloud",staging:p.staging===!0,onClose:_,children:e.jsx(lt,{onClose:_,onFirstCloud:()=>{},onWide:Fe,source:r.source})});const G=v??null,ke=()=>x.kind==="waiting"&&!k?x.plan:G?Le(G,k).tier:null,de=async a=>{if(!a||!s.checkout){y("failed");return}const i=!!G?.plans.find(R=>R.tier===a)?.trialDays,b=await s.checkout(a,r.source),m=b.outcome;f(b.state),m==="opened"||m==="signing-in"?(D(!1),y(null),A(!1),S(null),le(!1),U("cloud_checkout_opened",{plan:a,trial:i,source:r.source})):m==="rate-limited"?y("rate-limited"):m==="failed"?y("failed"):A(!0)},je=a=>{g({step:"email",intent:a,problem:null}),O({email:I.email||oe||"",code:""})},Se=()=>{if(C||!s.signInStart||!h||h.step==="done")return;const a=h;d(!0),s.signInStart(I.email).then(i=>{i.outcome==="sent"?(g({step:"code",intent:a.intent,email:i.email,resendAt:i.resendAt,problem:null,triesLeft:null,...i.signupOpen===!1?{signupOpen:!1}:{}}),O({email:i.email,code:""}),U("cloud_signin",{step:"code_sent",source:r.source})):g({...a,problem:i.outcome})},()=>g({...a,problem:"failed"})).finally(()=>d(!1))},De=a=>{if(!s.signInVerify||h?.step!=="code")return;const i=h,b=i.intent?ke():null;d(!0),(async()=>{try{const m=await s.signInVerify(a);if(m.outcome!=="signed-in"){O({email:I.email,code:""}),g({...i,problem:m.outcome,triesLeft:m.outcome==="wrong-code"?m.triesLeft:null});return}f(m.state),ae(!0),U("cloud_signin",{step:"signed_in",source:r.source}),b&&Nt(m.state)&&(tt(G,m.state.offer,b)?(g({step:"done",intent:!0}),await de(b)):(le(!0),T(b))),g(null),O({email:I.email,code:""})}catch{g({...i,problem:"failed",triesLeft:null})}finally{d(!1)}})()},Re={start:a=>{if(T(a),A(!1),x.kind==="offer"&&x.signedOut&&s.signInStart){je(!0);return}ne(()=>de(a))},signIn:()=>je(!1),back:()=>{g(null),s.signInCancel?.().catch(()=>{})},email:a=>O({email:a,code:I.code}),sendCode:Se,changeEmail:()=>{h&&(g({step:"email",intent:h.intent,problem:null}),s.signInCancel?.().catch(()=>{}))},code:a=>{const i=it(a);O({email:I.email,code:i}),i.length===8&&!C&&De(i)},resend:Se,browser:()=>ne(async()=>{const a=h?.intent?ke():null;g(null),await s.signInCancel?.().catch(()=>{}),U("cloud_signin",{step:"browser",source:r.source}),a?await de(a):f(await s.begin())}),reopenBrowser:()=>ne(async()=>f(await s.reopen())),cancelSignIn:()=>ne(async()=>f(await s.cancel())),reopenCheckout:()=>{if(x.kind!=="waiting"||C)return;d(!0),S(null),(s.reopenCheckout?s.reopenCheckout(x.plan,r.source):s.checkout(x.plan,r.source)).then(i=>{f(i.state),i.outcome!=="opened"&&S("pay-failed")},()=>S("pay-failed")).finally(()=>d(!1))},copyLink:()=>{s.copyCheckoutLink?.().then(a=>S(a?"copied":"pay-failed"),()=>S("pay-failed"))},changePlan:()=>{T(x.kind==="waiting"?x.plan:k),D(!0),S(null)},retry:()=>{y(null),A(!1),N(void 0),Y(W+1)},name:a=>ee({typed:a,color:V.color,dirty:!0}),color:a=>ee({typed:V.typed,color:a,dirty:!0}),openCloud:he,openTeam:_e,notNow:()=>P("off"),interest:()=>{C||!s.interest||(d(!0),s.interest().then(()=>S("interest-sent"),()=>S("interest-failed")).finally(()=>d(!1)))},close:_},He={chosen:k,current:Ct(p),offerShown:G,now:t(),busy:C,openFailed:w,email:I.email,code:I.code,profileEmail:oe,look:V,counting:typeof F=="number"?F:null,copied:z==="copied",payFailed:z==="pay-failed",interest:z==="interest-sent"?"sent":z==="interest-failed"?"failed":null};return e.jsx(Be,{kind:x.kind,staging:p?.staging===!0,onClose:_,children:e.jsx(ht,{view:x,ui:He,actions:Re})})}export{Tt 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-GmtHzqPG.js";import{a2 as F,a3 as S,x as L,S as z,a4 as y,a5 as b,a6 as A,a7 as M,a8 as w,a9 as k,aa as P,ab as E,ac as $,u as I,w as B,F as O,ad as v,ae as T,af as D,ag as C,ah as H,ai as W,aj as X}from"./App-DqXMyMLs.js";import{a as _,R as q}from"./RoutinesPage-C2O4AgJB.js";import{L as G,P as J,d as K}from"./PlacesRail-BJBF_akb.js";import{C as Q}from"./MenuMotion-nTkCdPNb.js";function U({routines:t,runs:r,bots:p,pausedBots:c,loading:o,error:d,onOpen:l,onLogs:n,onToggle:x}){const u=[...t].sort((s,i)=>Number(i.enabled)-Number(s.enabled)||(s.nextRunAt??1/0)-(i.nextRunAt??1/0)||s.name.localeCompare(i.name));return e.jsxs("div",{className:"space-y-3","aria-label":a("routines.list"),children:[d&&e.jsx("div",{role:"alert",className:"rounded-lg bg-danger/10 p-3 text-[12px] text-danger",children:a("routines.loadError")}),o&&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")]}),!o&&!d&&u.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(_,{size:20,className:"mx-auto mb-2 opacity-60"}),a("routines.empty")]}),u.map(s=>{const i=F(s.id,r),m=i&&(i.attention?"attention":i.error?"error":i.output?"output":null),h=p?.find(g=>g.id===s.botId),f=x!==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:()=>l(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:[h&&`${h.name} · `,L(s.schedule)]})]}),f?e.jsx(z,{checked:s.enabled,"aria-label":a("routines.toggle",{name:s.name}),onClick:()=>x(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:y(s)})]}),(f||b(s)!==y(s))&&e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:b(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:i?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:M(i),children:a("routines.latestRun",{status:A(i)})}),e.jsx("span",{className:"block text-[11px] text-ink-secondary",children:w(i.finishedAt??i.startedAt??i.scheduledFor)})]}):e.jsx("span",{className:"text-ink-secondary",children:a("routines.neverRun")})}),e.jsxs("button",{type:"button",onClick:()=>n(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(k,{size:12}),a("routines.logs")]})]}),i&&m&&e.jsx("p",{className:N("mt-2 line-clamp-2 whitespace-pre-wrap text-[12px] leading-relaxed",i.error?"text-danger":"text-ink-secondary"),children:P(i,m)}),!!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:()=>E("paused"),children:a("routines.botPausedSwap")})]}),s.heldFor&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:$(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:p,defaultRunOn:c}){const{state:o,dispatch:d}=I(),[l,n]=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(B,{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:()=>n("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(k,{size:13}),a("routines.logs")]})]})]}),e.jsx(U,{routines:r,runs:p,pausedBots:o.config?.pausedBots,loading:o.routinesLoadState==="loading"&&r.length===0,error:o.routinesLoadState==="error",onOpen:n,onLogs:x=>d({type:"showRoutines",section:"logs",botId:t.id,routineId:x.id}),onToggle:x=>d({type:"updateRoutine",routineId:x.id,patch:{enabled:!x.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(q,{routine:l==="new"?void 0:l,bots:[t],lockedBotId:t.id,defaultRunOn:c,onClose:()=>n(null)},t.id)]})}const V=20;function Y(t,r=V){const p=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 n of l.deleted)p.add(n);for(const n of[...l.added,...l.changed])if(!p.has(n)&&(p.add(n),c.push(n),c.length>=r))break}}return c}function Z(t){const r=new Map,p=t.tasks?.find(n=>n.threadId===t.threadId),c=p?.cwd===void 0?t.cwd:p.cwd,o=c&&(/^[a-z]:[\\/]/i.test(c)||c.startsWith("\\\\")),d=n=>o?n.replace(/\\/g,"/"):n,l=typeof c=="string"?`${d(c).replace(/\/+$/,"")}/`:void 0;for(const n of[...C(t)].reverse()){if(n.role!=="bot"||n.kind!=="text")continue;const x=H(n.attachments),u=[...x.files,...W(n.text??"",[...x.images,...x.files.map(s=>s.path)])];for(const s of u){const i=s.private?s.path:X(s.path),m={file:s,message:{threadId:t.threadId,messageId:n.id}},h=d(i),f=l&&(o?h.slice(0,l.length).toLowerCase()===l.toLowerCase():h.startsWith(l)),g=[i,...f?[h.slice(l.length)]:[]];i.startsWith("./")&&g.push(i.replace(/^(\.\/)+/,""));for(const j of g)r.has(j)||r.set(j,m)}}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:p}=K(),c=p.host.homeDir,d=t.tasks?.find(u=>u.threadId===t.threadId)?.cwd,l=d===void 0?t.cwd:d,n=Y(t),x=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")}),n.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:n.map(u=>{const{name:s,folder:i}=ee(u),m=x.get(u);return e.jsxs("li",{className:"min-w-0 rounded-lg py-1",title:u,children:[m?e.jsx(D,{file:{...m.file,name:s},message:m.message,linked:m.file.linked,className:"w-full max-w-none"},`${m.message.threadId}:${m.message.messageId}:${m.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(k,{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:s}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:a("computer.files.notShared")})]}),i&&e.jsx("div",{className:"mt-1 truncate px-2.5 text-[11px] text-ink-tertiary",children:v(i,c)})]},u)})})]})]})}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-3gApXdcp.js";import{a2 as F,a3 as S,x as L,S as z,a4 as y,a5 as b,a6 as A,a7 as M,a8 as w,a9 as k,aa as P,ab as E,ac as $,u as I,w as B,F as O,ad as v,ae as T,af as D,ag as C,ah as H,ai as W,aj as X}from"./App-0-mtr0MN.js";import{a as _,R as q}from"./RoutinesPage-DI6CbJ-R.js";import{L as G,P as J,d as K}from"./PlacesRail-C-RypDbo.js";import{C as Q}from"./MenuMotion-Dg_hALEl.js";function U({routines:t,runs:r,bots:p,pausedBots:c,loading:o,error:d,onOpen:l,onLogs:n,onToggle:x}){const u=[...t].sort((s,i)=>Number(i.enabled)-Number(s.enabled)||(s.nextRunAt??1/0)-(i.nextRunAt??1/0)||s.name.localeCompare(i.name));return e.jsxs("div",{className:"space-y-3","aria-label":a("routines.list"),children:[d&&e.jsx("div",{role:"alert",className:"rounded-lg bg-danger/10 p-3 text-[12px] text-danger",children:a("routines.loadError")}),o&&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")]}),!o&&!d&&u.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(_,{size:20,className:"mx-auto mb-2 opacity-60"}),a("routines.empty")]}),u.map(s=>{const i=F(s.id,r),m=i&&(i.attention?"attention":i.error?"error":i.output?"output":null),h=p?.find(g=>g.id===s.botId),f=x!==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:()=>l(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:[h&&`${h.name} · `,L(s.schedule)]})]}),f?e.jsx(z,{checked:s.enabled,"aria-label":a("routines.toggle",{name:s.name}),onClick:()=>x(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:y(s)})]}),(f||b(s)!==y(s))&&e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:b(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:i?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:M(i),children:a("routines.latestRun",{status:A(i)})}),e.jsx("span",{className:"block text-[11px] text-ink-secondary",children:w(i.finishedAt??i.startedAt??i.scheduledFor)})]}):e.jsx("span",{className:"text-ink-secondary",children:a("routines.neverRun")})}),e.jsxs("button",{type:"button",onClick:()=>n(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(k,{size:12}),a("routines.logs")]})]}),i&&m&&e.jsx("p",{className:N("mt-2 line-clamp-2 whitespace-pre-wrap text-[12px] leading-relaxed",i.error?"text-danger":"text-ink-secondary"),children:P(i,m)}),!!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:()=>E("paused"),children:a("routines.botPausedSwap")})]}),s.heldFor&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:$(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:p,defaultRunOn:c}){const{state:o,dispatch:d}=I(),[l,n]=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(B,{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:()=>n("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(k,{size:13}),a("routines.logs")]})]})]}),e.jsx(U,{routines:r,runs:p,pausedBots:o.config?.pausedBots,loading:o.routinesLoadState==="loading"&&r.length===0,error:o.routinesLoadState==="error",onOpen:n,onLogs:x=>d({type:"showRoutines",section:"logs",botId:t.id,routineId:x.id}),onToggle:x=>d({type:"updateRoutine",routineId:x.id,patch:{enabled:!x.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(q,{routine:l==="new"?void 0:l,bots:[t],lockedBotId:t.id,defaultRunOn:c,onClose:()=>n(null)},t.id)]})}const V=20;function Y(t,r=V){const p=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 n of l.deleted)p.add(n);for(const n of[...l.added,...l.changed])if(!p.has(n)&&(p.add(n),c.push(n),c.length>=r))break}}return c}function Z(t){const r=new Map,p=t.tasks?.find(n=>n.threadId===t.threadId),c=p?.cwd===void 0?t.cwd:p.cwd,o=c&&(/^[a-z]:[\\/]/i.test(c)||c.startsWith("\\\\")),d=n=>o?n.replace(/\\/g,"/"):n,l=typeof c=="string"?`${d(c).replace(/\/+$/,"")}/`:void 0;for(const n of[...C(t)].reverse()){if(n.role!=="bot"||n.kind!=="text")continue;const x=H(n.attachments),u=[...x.files,...W(n.text??"",[...x.images,...x.files.map(s=>s.path)])];for(const s of u){const i=s.private?s.path:X(s.path),m={file:s,message:{threadId:t.threadId,messageId:n.id}},h=d(i),f=l&&(o?h.slice(0,l.length).toLowerCase()===l.toLowerCase():h.startsWith(l)),g=[i,...f?[h.slice(l.length)]:[]];i.startsWith("./")&&g.push(i.replace(/^(\.\/)+/,""));for(const j of g)r.has(j)||r.set(j,m)}}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:p}=K(),c=p.host.homeDir,d=t.tasks?.find(u=>u.threadId===t.threadId)?.cwd,l=d===void 0?t.cwd:d,n=Y(t),x=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")}),n.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:n.map(u=>{const{name:s,folder:i}=ee(u),m=x.get(u);return e.jsxs("li",{className:"min-w-0 rounded-lg py-1",title:u,children:[m?e.jsx(D,{file:{...m.file,name:s},message:m.message,linked:m.file.linked,className:"w-full max-w-none"},`${m.message.threadId}:${m.message.messageId}:${m.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(k,{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:s}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:a("computer.files.notShared")})]}),i&&e.jsx("div",{className:"mt-1 truncate px-2.5 text-[11px] text-ink-tertiary",children:v(i,c)})]},u)})})]})]})}export{re as C,le as R,U as a,Y as r,Z as s};