@hienlh/ppm 0.20.6 → 0.20.8
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.
- package/CHANGELOG.md +11 -0
- package/assets/skills/ppm/SKILL.md +1 -1
- package/assets/skills/ppm/references/http-api.md +1 -1
- package/dist/web/assets/{accounts-settings-section-B-F7U-gq.js → accounts-settings-section-CRXY4Bsc.js} +1 -1
- package/dist/web/assets/{ai-resource-editor-qRHwpktf.js → ai-resource-editor-CMQfhxXp.js} +1 -1
- package/dist/web/assets/ai-settings-section-446NZWhI.js +1 -0
- package/dist/web/assets/{ai-settings-section-DSlsTrpf.js → ai-settings-section-M07DCjAI.js} +1 -1
- package/dist/web/assets/api-client-CYZ79uUS.js +1 -0
- package/dist/web/assets/{api-client-CEYCBt_0.js → api-client-DwXlVfXP.js} +1 -1
- package/dist/web/assets/{api-settings-D18Q4Ocp.js → api-settings-BQIwZoLm.js} +1 -1
- package/dist/web/assets/{api-themes-sSv-6OLk.js → api-themes-CmJZLEY1.js} +1 -1
- package/dist/web/assets/{appearance-settings-section-BMlkj9U2.js → appearance-settings-section-BBlJtEm5.js} +1 -1
- package/dist/web/assets/arrow-left-DpXaakMC.js +1 -0
- package/dist/web/assets/{audio-preview-B4E5_7TW.js → audio-preview-DPMXOZ55.js} +1 -1
- package/dist/web/assets/{bot-D6sx11y0.js → bot-D3-n2i31.js} +1 -1
- package/dist/web/assets/{brain-KDa9jFRq.js → brain-CuAQMSBE.js} +1 -1
- package/dist/web/assets/{button-DX32ffge.js → button-zgoXa9r7.js} +1 -1
- package/dist/web/assets/{calendar-clock-C1asT-gk.js → calendar-clock-CDP7AVjA.js} +1 -1
- package/dist/web/assets/{chat-tab-DmqV3MlC.js → chat-tab-Dn45anqr.js} +4 -4
- package/dist/web/assets/check-BQKbhtoA.js +1 -0
- package/dist/web/assets/{chevron-down-Dp0rpHb8.js → chevron-down-B9puixxZ.js} +1 -1
- package/dist/web/assets/chevron-right-DK_HbYZC.js +1 -0
- package/dist/web/assets/{chevron-up-8PbsNiJp.js → chevron-up-BPAINgoK.js} +1 -1
- package/dist/web/assets/circle-OKk7s0DX.js +1 -0
- package/dist/web/assets/{circle-question-mark-CzR7YRc-.js → circle-question-mark-qcWYO1P_.js} +1 -1
- package/dist/web/assets/clock-BmPiGrSF.js +1 -0
- package/dist/web/assets/code-CRiIHSiv.js +1 -0
- package/dist/web/assets/{code-editor-C4CriX9c.js → code-editor-CKASeDbu.js} +2 -2
- package/dist/web/assets/{conflict-editor-LfQoRcK-.js → conflict-editor-C-Nv8YYj.js} +1 -1
- package/dist/web/assets/{context-menu-CJL8L98s.js → context-menu-DM9CgxGh.js} +1 -1
- package/dist/web/assets/{copy-BewHj66E.js → copy-CXuIH4VC.js} +1 -1
- package/dist/web/assets/{createLucideIcon-D8pyde1A.js → createLucideIcon-D6fVXe3s.js} +1 -1
- package/dist/web/assets/{csv-preview-BEYKn68B.js → csv-preview-ou3KFzIH.js} +1 -1
- package/dist/web/assets/{data-grid-overlay-editor-CbBkhhJa.js → data-grid-overlay-editor-dnWnblYo.js} +1 -1
- package/dist/web/assets/{data-grid-types-DeY60CLU.js → data-grid-types-BfGeMDy0.js} +1 -1
- package/dist/web/assets/{database-Y3ESDK4-.js → database-Dz0W7OH7.js} +1 -1
- package/dist/web/assets/{database-viewer-BL9R-ciJ.js → database-viewer-Ckqg_-SS.js} +1 -1
- package/dist/web/assets/{diff-viewer-D91SI_zb.js → diff-viewer-CMzFnBCD.js} +1 -1
- package/dist/web/assets/{dist-B0J2eYBz.js → dist-CWMPvPem.js} +1 -1
- package/dist/web/assets/{docx-preview-Xy7SZ7Vf.js → docx-preview-B7Aospmh.js} +1 -1
- package/dist/web/assets/{download-DG3_9xXy.js → download-D70Q4Ba6.js} +1 -1
- package/dist/web/assets/{edit-diff-preview-xdDQvPhs.js → edit-diff-preview-BvgPvuhH.js} +1 -1
- package/dist/web/assets/{esm-B-vXxHUd.js → esm-BHyWbWKE.js} +1 -1
- package/dist/web/assets/{explorer-body-ColVUjgk.js → explorer-body-CVx4qaIF.js} +1 -1
- package/dist/web/assets/explorer-window-content-CqKVMkgW.js +1 -0
- package/dist/web/assets/{extension-manager-section-B-BRHGu1.js → extension-manager-section-CtcpVMWs.js} +1 -1
- package/dist/web/assets/{extension-webview-DufzanN9.js → extension-webview-DZ_QRZSM.js} +1 -1
- package/dist/web/assets/{eye-gWwaF4Lg.js → eye-dfZn7evX.js} +1 -1
- package/dist/web/assets/{eye-off-GjXVuAOn.js → eye-off-CmtfyRUD.js} +1 -1
- package/dist/web/assets/{file-exclamation-point-JzhTU2TX.js → file-exclamation-point-D5K2aaLi.js} +1 -1
- package/dist/web/assets/{files-settings-section-Do5YbTUK.js → files-settings-section-D7v-6nTa.js} +1 -1
- package/dist/web/assets/{flask-conical-tp8gyZGh.js → flask-conical-Dix4qNDj.js} +1 -1
- package/dist/web/assets/{folder-symlink-fQRoG_rV.js → folder-symlink-BavsIzoj.js} +1 -1
- package/dist/web/assets/{general-settings-section-B-n_PYzs.js → general-settings-section-BW_h8pdA.js} +1 -1
- package/dist/web/assets/{git-log-panel-BQzOHgxG.js → git-log-panel-BQZkJDu0.js} +1 -1
- package/dist/web/assets/{glide-data-grid-BUS44oLM.js → glide-data-grid-JKEslqGe.js} +4 -4
- package/dist/web/assets/{group-chat-tab-CkHXqorZ.js → group-chat-tab-CTAhtVCr.js} +1 -1
- package/dist/web/assets/{hand-x0ejq3fS.js → hand-CIPALZsE.js} +1 -1
- package/dist/web/assets/{image-preview-fuU4h2nr.js → image-preview-V5SglTWk.js} +1 -1
- package/dist/web/assets/{index-Cx1meAwb.js → index-DVNJ2W5R.js} +7 -7
- package/dist/web/assets/{jira-watcher-section-BQ4hVqWo.js → jira-watcher-section-VyzVbAnw.js} +1 -1
- package/dist/web/assets/{key-round-CQpDrDxg.js → key-round-oIll4vo-.js} +1 -1
- package/dist/web/assets/keybindings-store-B5dEz0n1.js +1 -0
- package/dist/web/assets/{keyboard-DiOYrs6C.js → keyboard-BLwfiRkT.js} +1 -1
- package/dist/web/assets/{keyboard-shortcuts-section-BZUYdXGx.js → keyboard-shortcuts-section-DOJi75mV.js} +1 -1
- package/dist/web/assets/{lib-el9rA30D.js → lib-BAsciSLw.js} +1 -1
- package/dist/web/assets/loader-circle-DxI3O9_f.js +1 -0
- package/dist/web/assets/markdown-renderer-BGPo364Y.js +1 -0
- package/dist/web/assets/markdown-renderer-DtQIHtLs.js +3 -0
- package/dist/web/assets/{media-url-BMeBaB0q.js → media-url-TYMlO0M5.js} +1 -1
- package/dist/web/assets/{mobile-bottom-sheet-CmySDB6I.js → mobile-bottom-sheet-Ch1e_JBq.js} +1 -1
- package/dist/web/assets/mobile-explorer-sheet-C1q_DhrI.js +1 -0
- package/dist/web/assets/{monitor-C835ucWH.js → monitor-CG69bSMW.js} +1 -1
- package/dist/web/assets/notification-store-DvUtkAXs.js +1 -0
- package/dist/web/assets/{notifications-settings-section-JQ3l-Qp-.js → notifications-settings-section-CeRvkXOM.js} +1 -1
- package/dist/web/assets/{number-overlay-editor-DRjTIcPH.js → number-overlay-editor-DldrUNs4.js} +1 -1
- package/dist/web/assets/{overview-panel-DiiA3B_Z.js → overview-panel-DA0QB1-5.js} +1 -1
- package/dist/web/assets/{panel-store-BmdcSBNb.js → panel-store-D42k25jy.js} +1 -1
- package/dist/web/assets/{pdf-preview-B-JAU8JV.js → pdf-preview-Cq33D5ej.js} +1 -1
- package/dist/web/assets/portal-container-context-DeLx1cOI.js +1 -0
- package/dist/web/assets/{postgres-viewer-B--Y59n5.js → postgres-viewer-C__Z0C0s.js} +3 -3
- package/dist/web/assets/power-CvtnQHU4.js +1 -0
- package/dist/web/assets/{ppmbot-settings-section-D1SCOc0_.js → ppmbot-settings-section-Cma4VU7p.js} +1 -1
- package/dist/web/assets/{process-table-D9z7cEmb.js → process-table-DH_HXtGc.js} +1 -1
- package/dist/web/assets/{project-store-wWZ6bjwq.js → project-store-C83MMnlt.js} +1 -1
- package/dist/web/assets/{proxy-settings-section-y7VwH0Hf.js → proxy-settings-section-xrTsFlTF.js} +1 -1
- package/dist/web/assets/{query-audit-section-Ca_gRQ_s.js → query-audit-section-Drk97gb8.js} +1 -1
- package/dist/web/assets/{react-D1Yg256j.js → react-DqIU0LFM.js} +1 -1
- package/dist/web/assets/remote-desktop-mobile-sheet-6JdUr0Bj.js +2 -0
- package/dist/web/assets/{remote-desktop-mobile-view-CGQ8vSf1.js → remote-desktop-mobile-view-Gk8UCVIx.js} +1 -1
- package/dist/web/assets/{remote-desktop-readiness-gate-BmC3b05e.js → remote-desktop-readiness-gate-6reSZvad.js} +1 -1
- package/dist/web/assets/{remote-desktop-window-content-Cdaoltdz.js → remote-desktop-window-content-BW2KqONI.js} +1 -1
- package/dist/web/assets/{run-in-terminal-wHKwAnWP.js → run-in-terminal-DoTOtgQS.js} +1 -1
- package/dist/web/assets/{save-CipGrG1k.js → save-B1y4KIK9.js} +1 -1
- package/dist/web/assets/{schedules-settings-section--0s10CfA.js → schedules-settings-section-DcKEz-S7.js} +1 -1
- package/dist/web/assets/{send-Bb0jtcR6.js → send-B9VUQlEK.js} +1 -1
- package/dist/web/assets/{send-to-chat-BI7-fFpG.js → send-to-chat-Kl-0dNwN.js} +1 -1
- package/dist/web/assets/{separator-W_hJcXPk.js → separator-DvCsdlws.js} +1 -1
- package/dist/web/assets/{settings-body-DEMqFm5z.js → settings-body-CcKls51a.js} +2 -2
- package/dist/web/assets/{settings-store-CzLnTR8p.js → settings-store-_s4xFcFq.js} +2 -2
- package/dist/web/assets/settings-tab-ChAk8nh2.js +1 -0
- package/dist/web/assets/settings-window-content-sA1K0cPW.js +1 -0
- package/dist/web/assets/{shield-check-BsG3LV8i.js → shield-check-BJSX7cAS.js} +1 -1
- package/dist/web/assets/{shield-off-7jKWpJBD.js → shield-off-E1cQwXdc.js} +1 -1
- package/dist/web/assets/{sparkles-Dh-_J2Rd.js → sparkles-blTKn0vi.js} +1 -1
- package/dist/web/assets/{sql-query-editor-Clo90z8-.js → sql-query-editor-BoYxc5vd.js} +1 -1
- package/dist/web/assets/{sqlite-viewer-C08QQR_L.js → sqlite-viewer-O5lF3MMj.js} +1 -1
- package/dist/web/assets/{streaming-store-9XVmAMfV.js → streaming-store-QQvg1cS-.js} +1 -1
- package/dist/web/assets/{system-monitor-body-30-TFH3a.js → system-monitor-body-C2mVJ7PV.js} +2 -2
- package/dist/web/assets/system-monitor-tab-tXkg3jpV.js +1 -0
- package/dist/web/assets/system-monitor-window-content-BaKoFDEz.js +1 -0
- package/dist/web/assets/{tab-host-window-content-C6eG_Rf1.js → tab-host-window-content-C7F6D8hJ.js} +1 -1
- package/dist/web/assets/{tab-store-1xYJb0gM.js → tab-store-B2ip0-Mv.js} +1 -1
- package/dist/web/assets/{table-CRJsmfeg.js → table-8HT8BG30.js} +1 -1
- package/dist/web/assets/team-member-sheet-BA70_jmM.js +2 -0
- package/dist/web/assets/{team-member-window-content-BN3luct-.js → team-member-window-content-BwOTsc9r.js} +1 -1
- package/dist/web/assets/{terminal-tab-afylLiLY.js → terminal-tab-DlZW3MCn.js} +1 -1
- package/dist/web/assets/{text-wrap-oiekm5SB.js → text-wrap-DafY0-Pa.js} +1 -1
- package/dist/web/assets/{tool-cards-Ct1QdT8c.js → tool-cards-yiwO861p.js} +3 -3
- package/dist/web/assets/{use-accounts-data-C0bvcMhi.js → use-accounts-data-B9t4BQaI.js} +1 -1
- package/dist/web/assets/{use-blob-url-CrwoZJUJ.js → use-blob-url-D358Rpyp.js} +1 -1
- package/dist/web/assets/{use-coarse-long-press-BmI_GVW5.js → use-coarse-long-press-BsBpxWup.js} +1 -1
- package/dist/web/assets/{use-inline-blame-C1G-_NjC.js → use-inline-blame-D2pZjDoA.js} +1 -1
- package/dist/web/assets/{use-is-mobile-D1weanbj.js → use-is-mobile-Bi42QhIi.js} +1 -1
- package/dist/web/assets/{use-monaco-theme-cgPbRDUm.js → use-monaco-theme-DTPfPPvF.js} +1 -1
- package/dist/web/assets/use-open-team-member-DGEx9xB0.js +1 -0
- package/dist/web/assets/{use-remote-desktop-display-choice-DSqF1Rgx.js → use-remote-desktop-display-choice-BnVT4dhX.js} +1 -1
- package/dist/web/assets/{use-visual-viewport-Bfl3Bxxb.js → use-visual-viewport-CNdG4QHH.js} +1 -1
- package/dist/web/assets/use-websocket-DQg9BQcq.js +1 -0
- package/dist/web/assets/{vendor-markdown-Ls5AcU91.js → vendor-markdown-CuWCHIVb.js} +1 -1
- package/dist/web/assets/{vendor-ui-CaeeFO0B.js → vendor-ui-BBdkypKW.js} +1 -1
- package/dist/web/assets/{video-preview-BTzstVhM.js → video-preview-Dc4YbBqm.js} +1 -1
- package/dist/web/assets/{window-pip-registry-CrCYYTTf.js → window-pip-registry-BWxaVLj5.js} +1 -1
- package/dist/web/assets/{window-store-D0HbQ1pM.js → window-store-CfxP5yor.js} +1 -1
- package/dist/web/assets/ws-auth-FRzMmfQx.js +1 -0
- package/dist/web/assets/x-Bdaog6Az.js +1 -0
- package/dist/web/index.html +38 -38
- package/dist/web/sw.js +1 -1
- package/docs/architecture/ai-chat-and-providers.md +4 -0
- package/package.json +1 -1
- package/src/services/db.service.ts +18 -4
- package/src/web/components/shared/markdown-context.ts +6 -0
- package/src/web/components/shared/markdown-renderer.tsx +7 -3
- package/src/web/hooks/use-chat.ts +4 -0
- package/src/web/hooks/use-websocket.ts +7 -1
- package/dist/web/assets/ai-settings-section-BePrVceb.js +0 -1
- package/dist/web/assets/api-client-QfreGirP.js +0 -1
- package/dist/web/assets/arrow-left-CyFcsyzD.js +0 -1
- package/dist/web/assets/check-DN75Ucvz.js +0 -1
- package/dist/web/assets/chevron-right-De-Wz5Lz.js +0 -1
- package/dist/web/assets/circle-BCy0AUCo.js +0 -1
- package/dist/web/assets/clock-C1CQUQPZ.js +0 -1
- package/dist/web/assets/code-DJgYrFzm.js +0 -1
- package/dist/web/assets/explorer-window-content-VSMJfZC2.js +0 -1
- package/dist/web/assets/keybindings-store-yYx88hvw.js +0 -1
- package/dist/web/assets/loader-circle-DPMrnLQ2.js +0 -1
- package/dist/web/assets/markdown-renderer-BA3C2L-a.js +0 -3
- package/dist/web/assets/markdown-renderer-CMFkajd7.js +0 -1
- package/dist/web/assets/mobile-explorer-sheet-gvO7a80O.js +0 -1
- package/dist/web/assets/notification-store-CCh6a8RD.js +0 -1
- package/dist/web/assets/portal-container-context-DKymYOY-.js +0 -1
- package/dist/web/assets/power-CriQkeK5.js +0 -1
- package/dist/web/assets/remote-desktop-mobile-sheet-CdO2aMXl.js +0 -2
- package/dist/web/assets/settings-tab-Dh1FpBny.js +0 -1
- package/dist/web/assets/settings-window-content-3KrQ6imZ.js +0 -1
- package/dist/web/assets/system-monitor-tab-ChIXfOWg.js +0 -1
- package/dist/web/assets/system-monitor-window-content-C1Cd_pT7.js +0 -1
- package/dist/web/assets/team-member-sheet-BhatQbL1.js +0 -2
- package/dist/web/assets/use-open-team-member-CSUU7Z8N.js +0 -1
- package/dist/web/assets/use-websocket-BQssVSIR.js +0 -1
- package/dist/web/assets/ws-auth-D111jj32.js +0 -1
- package/dist/web/assets/x-CxoBA0po.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.20.8] - 2026-09-16
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **Windows file links in chat now open in PPM** — Markdown links such as `D:/Projects/app/report.md` retain their path instead of being cleared as an unsafe URL scheme.
|
|
9
|
+
|
|
10
|
+
## [0.20.7] - 2026-09-15
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- **Reconnecting overlay clears while chat streams** after the provider assigns a new session ID or reconnects before any events are buffered.
|
|
14
|
+
- **Selected model survives the first turn and reload** — model, effort and thinking settings follow the provider's new session ID.
|
|
15
|
+
|
|
5
16
|
## [0.20.6] - 2026-09-15
|
|
6
17
|
|
|
7
18
|
### Added
|
|
@@ -71,4 +71,4 @@ This skill covers the `ppm` CLI, its HTTP API, and its config DB. It does **not*
|
|
|
71
71
|
- Third-party extensions (inspect via `ppm ext list`).
|
|
72
72
|
- The Claude Agent SDK internals (separate skill).
|
|
73
73
|
|
|
74
|
-
<!-- Generated for PPM v0.20.
|
|
74
|
+
<!-- Generated for PPM v0.20.8 at build time. Re-run `ppm export skill --install` to refresh. -->
|
|
@@ -349,4 +349,4 @@ _Base URL: `http://localhost:8080` (default; override via `ppm config set port <
|
|
|
349
349
|
- `ws://<host>/ws/terminal` — PTY terminal multiplexer
|
|
350
350
|
- `ws://<host>/ws/extensions` — extension host channel
|
|
351
351
|
|
|
352
|
-
<!-- Generated from src/server/routes/ for PPM v0.20.
|
|
352
|
+
<!-- Generated from src/server/routes/ for PPM v0.20.8 -->
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{S as t,x as n}from"./vendor-markdown-Ls5AcU91.js";import"./vendor-ui-CaeeFO0B.js";import{t as r}from"./copy-BewHj66E.js";import{t as i}from"./download-DG3_9xXy.js";import{t as a}from"./flask-conical-tp8gyZGh.js";import{t as o}from"./key-round-CQpDrDxg.js";import{t as s}from"./loader-circle-DPMrnLQ2.js";import{t as c}from"./x-CxoBA0po.js";import{n as l,r as u}from"./api-client-CEYCBt_0.js";import{n as d}from"./utils-IrnQujwR.js";import"./portal-container-context-DKymYOY-.js";import{n as f}from"./use-is-mobile-D1weanbj.js";import{n as p,t as m}from"./button-DX32ffge.js";import{t as h}from"./mobile-bottom-sheet-CmySDB6I.js";import"./use-visual-viewport-Bfl3Bxxb.js";import{$t as g,B as _,Dn as v,Dr as y,G as b,Gn as x,H as S,Ln as C,M as w,On as T,Pn as E,Qn as D,Qt as O,U as k,V as A,W as j,X as M,Xt as N,Y as P,Yt as F,Zt as I,en as L,ir as R,kn as ee,lr as z,nn as B}from"./index-Cx1meAwb.js";import{addAccount as V,deleteAccount as H,exchangeOAuthCode as U,getAISettings as W,getAccountSettings as G,getOAuthUrl as K,getUsageHistory as q,importAccounts as te,patchAccount as J,testAccountToken as Y,testExport as ne,testRawToken as X,updateAccountSettings as re}from"./api-settings-D18Q4Ocp.js";import{a as ie,c as ae,i as oe,l as se,n as ce,o as le,r as ue,t as de,u as fe}from"./use-accounts-data-C0bvcMhi.js";var Z=e(t(),1),Q=n(),pe=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],$=Array.from({length:24},(e,t)=>t);function me(e,t){let n=Array.from({length:7},()=>Array.from({length:24},()=>({sum:0,count:0,avg:0})));for(let r of e){let e=t===`5h`?r.five_hour_util:r.weekly_util;if(e==null)continue;let i=new Date(r.recorded_at+(r.recorded_at.endsWith(`Z`)?``:`Z`)),a=(i.getDay()+6)%7,o=i.getHours();n[a][o].sum+=e,n[a][o].count+=1}for(let e of n)for(let t of e)t.avg=t.count>0?t.sum/t.count:0;return n}function he(e){return e.map(e=>{let t=e.reduce((e,t)=>e+t.sum,0),n=e.reduce((e,t)=>e+t.count,0);return n>0?t/n:0})}function ge(e){return $.map(t=>{let n=0,r=0;for(let i of e)n+=i[t].sum,r+=i[t].count;return r>0?n/r:0})}function _e(e){return e===0?`bg-surface-elevated`:e<.3?`bg-success/30`:e<.5?`bg-success/60`:e<.7?`bg-warning/50`:e<.9?`bg-warning/80`:`bg-error/80`}function ve(e){return e<.3?`bg-success`:e<.7?`bg-warning`:`bg-error`}function ye({accountId:e}){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(!0),[a,o]=(0,Z.useState)(`5h`);(0,Z.useEffect)(()=>{i(!0),q(e).then(n).catch(()=>n([])).finally(()=>i(!1))},[e]);let c=(0,Z.useMemo)(()=>t?me(t,a):null,[t,a]),l=(0,Z.useMemo)(()=>c?he(c):[],[c]),u=(0,Z.useMemo)(()=>c?ge(c):[],[c]),d=Math.max(...l,.01);if(Math.max(...u,.01),r)return(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,Q.jsx)(s,{className:`size-3 animate-spin text-text-subtle`})});if(!t||t.length===0)return(0,Q.jsx)(`div`,{className:`text-[10px] text-text-subtle py-2 text-center`,children:`No usage history yet`});let f=t.length,p=new Set(t.map(e=>new Date(e.recorded_at+(e.recorded_at.endsWith(`Z`)?``:`Z`)).toDateString())).size;return(0,Q.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle`,children:`Usage Pattern (7d)`}),(0,Q.jsxs)(`div`,{className:`flex gap-0.5 text-[9px]`,children:[(0,Q.jsx)(`button`,{onClick:()=>o(`5h`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`5h`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`5-hour rolling window limit — resets every 5 hours`,children:`5h`}),(0,Q.jsx)(`button`,{onClick:()=>o(`weekly`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`weekly`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`Weekly limit — resets every 7 days`,children:`Wk`})]})]}),(0,Q.jsxs)(`p`,{className:`text-[9px] text-text-subtle leading-tight`,children:[`Avg `,a===`5h`?`5-hour`:`weekly`,` limit usage over `,p,`d (`,f,` samples). Higher % = closer to rate limit. Hover cells for details.`]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by day of week`}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-[2px] mt-0.5`,children:pe.map((e,t)=>{let n=l[t]??0;return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-[8px] text-text-subtle w-5 shrink-0 text-right tabular-nums`,children:e}),(0,Q.jsx)(`div`,{className:`flex-1 h-2.5 bg-surface-elevated rounded-sm overflow-hidden`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-sm transition-all ${ve(n)}`,style:{width:`${Math.round(n/d*100)}%`}})}),(0,Q.jsxs)(`span`,{className:`text-[8px] text-text-subtle w-6 shrink-0 text-right tabular-nums`,children:[Math.round(n*100),`%`]})]},e)})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by hour (0h-23h)`}),(0,Q.jsx)(`div`,{className:`flex gap-[1px] mt-0.5`,children:$.map(e=>{let t=u[e]??0;return(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-[1px]`,children:[(0,Q.jsx)(`div`,{className:`w-full aspect-square rounded-[2px] ${_e(t)}`,title:`${e}:00 — avg ${Math.round(t*100)}% usage`}),e%6==0&&(0,Q.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})]},e)})})]}),c&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Day x Hour heatmap`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-[1px] mt-0.5`,children:[pe.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,Q.jsx)(`span`,{className:`text-[7px] text-text-subtle w-4 shrink-0 text-right`,children:e.charAt(0)}),$.map(n=>{let r=c[t][n];return(0,Q.jsx)(`div`,{className:`flex-1 aspect-square rounded-[1px] ${_e(r.avg)}`,title:`${e} ${n}:00 — ${r.count>0?`avg ${Math.round(r.avg*100)}% (${r.count} samples)`:`no data`}`},n)})]},e)),(0,Q.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,Q.jsx)(`span`,{className:`w-4 shrink-0`}),$.map(e=>(0,Q.jsx)(`div`,{className:`flex-1 text-center`,children:e%6==0&&(0,Q.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})},e))]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[8px] text-text-subtle`,children:[(0,Q.jsx)(`span`,{children:`Low`}),(0,Q.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/30`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/60`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/50`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/80`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-error/80`})]}),(0,Q.jsx)(`span`,{children:`High`}),(0,Q.jsx)(`span`,{className:`ml-1`,children:`|`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-surface-elevated border border-border/30`}),(0,Q.jsx)(`span`,{children:`No data`})]})]})}function be({profile:e,accountId:t,onClose:n}){let r=[[`Name`,e.account?.display_name],[`Email`,e.account?.email],[`Org`,e.organization?.name],[`Type`,e.organization?.organization_type],[`Tier`,e.organization?.rate_limit_tier],[`Status`,e.organization?.subscription_status]];return(0,Q.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3`,"data-testid":`account-profile-panel`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Profile`}),(0,Q.jsx)(`button`,{className:`p-2 text-muted-foreground hover:text-foreground cursor-pointer`,onClick:n,"aria-label":`Close profile`,children:(0,Q.jsx)(c,{className:`size-4`})})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[80px_1fr] gap-x-3 gap-y-1 text-xs`,children:r.map(([e,t])=>t?(0,Q.jsxs)(`span`,{className:`contents`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,Q.jsx)(`span`,{className:`break-all`,children:t})]},e):null)}),(0,Q.jsx)(ye,{accountId:t})]})}function xe({display:e,onConfirm:t,onCancel:n}){let r=f(),i=(0,Q.jsxs)(`div`,{className:`space-y-4`,"data-testid":`account-delete-confirm`,children:[(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Remove `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e}),`?`]}),(0,Q.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`The stored token is deleted from this machine. Any export you already made keeps working.`}),(0,Q.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-2`,children:[(0,Q.jsx)(m,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Cancel`}),(0,Q.jsx)(m,{variant:`destructive`,autoFocus:!1,onClick:t,className:`min-h-11`,children:`Remove account`})]})]});return r?(0,Q.jsx)(h,{open:!0,onClose:n,children:(0,Q.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Remove account`}),i]})}):(0,Q.jsx)(F,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(N,{className:`sm:max-w-sm`,children:[(0,Q.jsx)(g,{children:(0,Q.jsx)(L,{className:`text-sm`,children:`Remove account`})}),i]})})}function Se({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[h,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(`idle`);function S(){p(null),_(``),x(`idle`),d(null)}function C(){t(!1),S(),i(``),o(``),d(null)}async function w(){y(!0),d(null);try{let{url:e,state:t}=await K();p(t),x(`waiting`),window.open(e,`_blank`)}catch(e){d(e.message)}y(!1)}async function T(){if(!(!h.trim()||!f)){y(!0),d(null);try{let e=h.trim();e.includes(`#`)&&(e=e.split(`#`)[0]??e);let t=await U(e,f);C(),n(t?.status===`disabled`?`Signed in. This account is still disabled — enable it to use it.`:`Account connected via OAuth!`)}catch(e){d(e.message)}y(!1)}}async function E(){if(r.trim()){l(!0),d(null);try{let e=await V({apiKey:r.trim(),label:a.trim()||void 0});C(),n(e?.status===`disabled`?`Token updated. This account is still disabled — enable it to use it.`:`Account added!`)}catch(e){d(e.message)}l(!1)}}let D=r.trim()?r.trim().startsWith(`sk-ant-oat`)?`OAuth token (Claude Max/Pro)`:r.trim().startsWith(`sk-ant-api`)?`API key`:`Unknown format`:``;return(0,Q.jsx)(F,{open:e,onOpenChange:e=>{e||C()},children:(0,Q.jsxs)(N,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(g,{children:[(0,Q.jsx)(L,{className:`text-sm`,children:`Add Claude Account`}),(0,Q.jsx)(I,{className:`text-xs leading-relaxed`,children:`Connect via OAuth (recommended) or paste a token manually.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Recommended: Login with Claude`}),b===`idle`?(0,Q.jsx)(m,{size:`sm`,className:`w-full h-8 text-xs`,onClick:w,disabled:v,children:v?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{className:`size-3 animate-spin mr-1`}),` Opening...`]}):`Login with Claude`}):(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Authorize in the opened tab, then paste the code:`}),(0,Q.jsx)(M,{placeholder:`Paste code here...`,value:h,onChange:e=>_(e.target.value),className:`text-xs h-8 font-mono`,autoFocus:!0}),(0,Q.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,Q.jsx)(m,{size:`sm`,className:`flex-1 h-7 text-xs`,onClick:T,disabled:!h.trim()||v,children:v?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{className:`size-3 animate-spin mr-1`}),` Connecting...`]}):`Connect`}),(0,Q.jsx)(m,{size:`sm`,variant:`ghost`,className:`h-7 text-xs`,onClick:S,children:`Cancel`})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex-1 border-t`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`or paste token`}),(0,Q.jsx)(`div`,{className:`flex-1 border-t`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(P,{htmlFor:`add-token`,className:`text-xs`,children:`Token`}),(0,Q.jsx)(M,{id:`add-token`,type:`password`,placeholder:`sk-ant-...`,value:r,onChange:e=>i(e.target.value),className:`text-xs h-8 font-mono`}),D&&(0,Q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[`Detected: `,D]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(P,{htmlFor:`add-label`,className:`text-xs`,children:`Label (optional)`}),(0,Q.jsx)(M,{id:`add-label`,placeholder:`e.g. Personal, Work`,value:a,onChange:e=>o(e.target.value),className:`text-xs h-8`})]})]}),u&&(0,Q.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:u}),(0,Q.jsxs)(O,{children:[(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs h-7`,onClick:C,children:`Cancel`}),(0,Q.jsx)(m,{size:`sm`,className:`text-xs h-7`,onClick:E,disabled:!r.trim()||c,children:c?`Adding...`:`Add Token`})]})]})})}function Ce(e){let t=new Blob([e],{type:`application/json`}),n=document.createElement(`a`);n.href=URL.createObjectURL(t),n.download=`ppm-accounts-backup.json`,n.click(),URL.revokeObjectURL(n.href)}function we({open:e,onOpenChange:t,accounts:n,preselectId:a,onMessage:o}){let c=n.filter(e=>e.hasRefreshToken),[l,d]=(0,Z.useState)(new Set),[f,p]=(0,Z.useState)(``),[h,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(!1);e&&!S&&(d(a?new Set([a]):new Set(c.map(e=>e.id))),C(!0)),!e&&S&&C(!1);function w(){t(!1),p(``),_(!1),y(!1)}async function T(e){if(l.size===0)return;x(!0);let t=f.trim()||`ppm-hienlh`;try{let n={"Content-Type":`application/json`},r=u();r&&(n.Authorization=`Bearer ${r}`);let i=await fetch(`/api/accounts/export`,{method:`POST`,headers:n,body:JSON.stringify({password:t,accountIds:[...l],includeRefreshToken:h,refreshBeforeExport:v})});if(!i.ok){let e=await i.json();throw Error(e.error??`Export failed: ${i.status}`)}let a=await i.text();e&&await B(a)?o?.(`Backup copied to clipboard!`):(Ce(a),o?.(`Backup downloaded.`)),w()}catch{}x(!1)}let E=l.size>0&&!b;return(0,Q.jsx)(F,{open:e,onOpenChange:e=>{e||w()},children:(0,Q.jsxs)(N,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(g,{children:[(0,Q.jsxs)(L,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(z,{className:`size-3.5`}),` Export Accounts`]}),(0,Q.jsx)(I,{className:`text-xs`,children:`Select accounts and set a password to protect the backup.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Accounts to export`}),(0,Q.jsx)(`button`,{className:`text-[10px] text-primary hover:underline cursor-pointer`,onClick:()=>d(l.size===c.length?new Set:new Set(c.map(e=>e.id))),children:l.size===c.length?`Deselect all`:`Select all`})]}),c.length===0?(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground p-2 border rounded`,children:`No exportable accounts.`}):(0,Q.jsx)(`div`,{className:`max-h-36 overflow-y-auto space-y-1 border rounded p-2`,children:c.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`exp-${e.id}`,checked:l.has(e.id),onChange:t=>{let n=new Set(l);t.target.checked?n.add(e.id):n.delete(e.id),d(n)},className:`size-3.5 accent-primary cursor-pointer`}),(0,Q.jsx)(`label`,{htmlFor:`exp-${e.id}`,className:`text-xs cursor-pointer truncate`,children:e.label??e.email??e.id.slice(0,8)})]},e.id))})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(P,{className:`text-xs`,children:[`Password `,(0,Q.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,Q.jsx)(M,{type:`password`,placeholder:`Leave empty for default`,value:f,onChange:e=>p(e.target.value),className:`text-xs h-8`,autoComplete:`new-password`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`exp-full`,checked:h,onChange:e=>_(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,Q.jsx)(`label`,{htmlFor:`exp-full`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens (full transfer)`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`exp-refresh`,checked:v,onChange:e=>y(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,Q.jsx)(`label`,{htmlFor:`exp-refresh`,className:`text-[11px] cursor-pointer`,children:`Refresh tokens before export`})]}),h?(0,Q.jsxs)(`div`,{className:`rounded-md border border-error/30 bg-error/5 p-2.5`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] font-medium text-error`,children:`Full transfer — source accounts will expire`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Refresh tokens included. Source machine expires in ~1h after target refreshes.`})]}):v?(0,Q.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-2.5`,children:(0,Q.jsx)(`p`,{className:`text-[10px] font-medium text-warning`,children:`Refresh before export — invalidates previous shares`})}):(0,Q.jsx)(`div`,{className:`rounded-md border border-success/30 bg-success/5 p-2.5`,children:(0,Q.jsx)(`p`,{className:`text-[10px] font-medium text-success`,children:`Share current token (safe)`})}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Encrypted with AES-256-GCM + scrypt.`})]}),(0,Q.jsxs)(O,{className:`gap-1.5 flex-col sm:flex-row`,children:[(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:w,children:`Cancel`}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,disabled:!E,onClick:()=>T(!0),children:[(0,Q.jsx)(r,{className:`size-3 mr-1`}),` Copy`]}),(0,Q.jsx)(m,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!E,onClick:()=>T(!1),children:b?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(i,{className:`size-3 mr-1`}),` Download`]})})]})]})})}function Te({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null);function f(){t(!1),i(``),o(``),d(null)}async function p(){if(r.trim()){l(!0),d(null);try{let e=await te({data:r.trim(),password:a.trim()||`ppm-hienlh`});f(),n(`Imported ${e.imported} account(s)`)}catch(e){d(e.message||`Import failed`)}l(!1)}}return(0,Q.jsx)(F,{open:e,onOpenChange:e=>{e||f()},children:(0,Q.jsxs)(N,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(g,{children:[(0,Q.jsxs)(L,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(z,{className:`size-3.5`}),` Import Accounts`]}),(0,Q.jsx)(I,{className:`text-xs`,children:`Paste backup data and enter the export password. Imported accounts are temporary (~1h).`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(P,{className:`text-xs`,children:`Backup data`}),(0,Q.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),placeholder:`Paste backup JSON here...`,rows:4,className:`w-full text-xs p-2 rounded border border-border bg-background font-mono resize-none focus:outline-none focus:ring-1 focus:ring-primary`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(P,{className:`text-xs`,children:[`Password `,(0,Q.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,Q.jsx)(M,{type:`password`,placeholder:`Leave empty for default`,value:a,onChange:e=>o(e.target.value),className:`text-xs h-8`,autoComplete:`current-password`})]})]}),u&&(0,Q.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:u}),(0,Q.jsxs)(O,{children:[(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:f,children:`Cancel`}),(0,Q.jsx)(m,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!r.trim()||c,onClick:p,children:c?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{className:`size-3 animate-spin mr-1`}),` Importing...`]}):`Import`})]})]})})}var Ee=typeof window<`u`?window.matchMedia(`(min-width: 768px)`):null;function De(e){return Ee?.addEventListener(`change`,e),()=>Ee?.removeEventListener(`change`,e)}function Oe(){return Ee?.matches??!0}function ke(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(!0);return(0,Z.useEffect)(()=>{r(!0),G().then(t).finally(()=>r(!1))},[]),n?(0,Q.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Loading...`}):e?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Rotation Strategy`}),(0,Q.jsxs)(_,{value:e.strategy,onValueChange:async e=>{t(await re({strategy:e}))},children:[(0,Q.jsx)(k,{className:`w-full h-9 text-xs`,children:(0,Q.jsx)(j,{})}),(0,Q.jsxs)(A,{children:[(0,Q.jsx)(S,{value:`round-robin`,children:`Round-robin`}),(0,Q.jsx)(S,{value:`fill-first`,children:`Fill-first`}),(0,Q.jsx)(S,{value:`lowest-usage`,children:`Lowest usage`})]})]}),(0,Q.jsxs)(`p`,{className:`text-[10px] text-text-subtle`,children:[e.strategy===`round-robin`&&`Cycles through accounts evenly`,e.strategy===`fill-first`&&`Uses one account until its limit, then moves on`,e.strategy===`lowest-usage`&&`Picks the account with the lowest current usage`]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Max Retry`}),(0,Q.jsx)(`input`,{type:`number`,min:0,value:e.maxRetry,className:`w-full h-9 text-xs border rounded-md px-3 bg-background`,onChange:async e=>{let n=parseInt(e.target.value,10);!isNaN(n)&&n>=0&&t(await re({maxRetry:n}))}}),(0,Q.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`How many accounts to try on failure. 0 = try all available accounts.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Cooldown parking`}),(0,Q.jsx)(b,{checked:e.cooldownEnabled,onCheckedChange:async e=>{t(await re({cooldownEnabled:e}))}})]}),(0,Q.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`Park a failing account (rate limit / usage limit / auth error) until it recovers. Off: accounts stay selectable — rotation still skips accounts already ≥95% on the 5-hour limit.`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-xs border-t border-border pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-text-subtle`,children:`Active accounts`}),(0,Q.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.activeCount})]})]}):(0,Q.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Failed to load settings`})}function Ae({open:e,onOpenChange:t}){let n=(0,Z.useSyncExternalStore)(De,Oe);return e?n?(0,Q.jsx)(F,{open:e,onOpenChange:t,children:(0,Q.jsxs)(N,{className:`sm:max-w-sm`,children:[(0,Q.jsx)(g,{children:(0,Q.jsxs)(L,{className:`text-sm flex items-center gap-2`,children:[(0,Q.jsx)(x,{className:`size-4`}),` Rotation & Retry`]})}),(0,Q.jsx)(ke,{})]})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`fixed inset-0 z-50 transition-opacity duration-200 opacity-100`,onClick:()=>t(!1),style:{backgroundColor:`rgba(0,0,0,0.5)`}}),(0,Q.jsxs)(`div`,{className:d(`fixed bottom-0 left-0 right-0 z-50 bg-background rounded-t-2xl border-t border-border shadow-2xl`,`transition-transform duration-300 ease-out max-h-[85vh] overflow-y-auto`,`translate-y-0`),children:[(0,Q.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,Q.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-border`})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Q.jsx)(x,{className:`size-4`}),` Rotation & Retry`]}),(0,Q.jsx)(`button`,{onClick:()=>t(!1),className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,Q.jsx)(c,{className:`size-4`})})]}),(0,Q.jsx)(`div`,{className:`px-4 py-4 pb-8`,children:(0,Q.jsx)(ke,{})})]})]}):null}var je=p(`inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground shadow`,secondary:`border-transparent bg-secondary text-secondary-foreground`,destructive:`border-transparent bg-destructive text-destructive-foreground shadow`,outline:`text-foreground`}},defaultVariants:{variant:`default`}});function Me({className:e,variant:t,...n}){return(0,Q.jsx)(`div`,{className:d(je({variant:t}),e),...n})}function Ne(e){let t=Math.floor(Date.now()/1e3);return e>t?`${Math.floor((e-t)/60)}m`:`exp`}function Pe({accounts:e}){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(new Map),u=e.filter(e=>e.hasRefreshToken);async function d(){if(u.length!==0){i(!0);try{let e=await ne(u.map(e=>e.id),a);n(t=>[...t,{round:t.length+1,time:new Date().toLocaleTimeString(),includeRefresh:a,items:e}])}catch{}i(!1)}}async function f(e,t){l(t=>new Map(t).set(e,{loading:!0}));try{let n=await X(t);l(t=>new Map(t).set(e,{loading:!1,...n}))}catch(t){l(n=>new Map(n).set(e,{loading:!1,status:`error`,error:t.message}))}}function p(e,t){return[{key:`r${e.round}-pre-${t.id}`,label:`Pre-export`,token:t.preExportTokenFull,preview:t.preExportToken,expires:t.preExportExpires},{key:`r${e.round}-exp-${t.id}`,label:`Exported`,token:t.exportedTokenFull,preview:t.exportedToken,expires:t.exportedExpires},{key:`r${e.round}-post-${t.id}`,label:`Post-export`,token:t.postExportTokenFull,preview:t.postExportToken,expires:t.postExportExpires}]}function h(){for(let e of t)for(let t of e.items)for(let n of p(e,t))n.token&&f(n.key,n.token)}return(0,Q.jsxs)(`section`,{className:`border-t pt-4 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium`,children:`Simulate export`}),t.length>0&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[t.length,` round(s)`]})]}),(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Every run appends a round. Earlier rounds are kept so tokens can be compared across runs.`}),u.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No OAuth account with a refresh token to export.`}):(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(b,{id:`sim-include-refresh`,checked:a,onCheckedChange:o,className:`cursor-pointer`}),(0,Q.jsx)(P,{htmlFor:`sim-include-refresh`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens`})]}),(0,Q.jsx)(m,{size:`sm`,className:`h-7 text-xs cursor-pointer`,disabled:r,onClick:()=>void d(),children:r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):`Run export #${t.length+1}`})]}),t.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`w-full h-7 text-[11px] cursor-pointer`,onClick:h,children:[`Test all tokens (`,t.reduce((e,t)=>e+t.items.length*3,0),`)`]}),t.map(e=>(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`p`,{className:`text-xs font-medium text-primary`,children:[`Round #`,e.round]}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.time}),(0,Q.jsx)(Me,{variant:e.includeRefresh?`destructive`:`secondary`,className:`text-[9px] px-1 py-0`,children:e.includeRefresh?`with refresh`:`access only`})]}),e.items.map(t=>(0,Q.jsxs)(`div`,{className:`p-2 rounded-lg border bg-card space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] font-medium`,children:t.label??t.email??t.id.slice(0,8)}),t.tokenChanged&&(0,Q.jsx)(Me,{variant:`secondary`,className:`text-[9px] px-1 py-0`,children:`DB token changed`})]}),p(e,t).map(e=>{let t=c.get(e.key);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,Q.jsx)(`span`,{className:`w-20 shrink-0 text-muted-foreground text-[10px]`,children:e.label}),(0,Q.jsx)(`code`,{className:`flex-1 truncate font-mono text-[10px] bg-muted px-1 rounded`,children:e.preview??`N/A`}),e.expires&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:Ne(e.expires)}),e.token?(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-1.5 cursor-pointer shrink-0`,disabled:t?.loading,onClick:()=>void f(e.key,e.token),children:t?.loading?(0,Q.jsx)(s,{className:`size-3 animate-spin`}):`Test`}):(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`-`}),t&&!t.loading&&(0,Q.jsx)(`span`,{className:`text-[10px] font-medium shrink-0 ${t.status?.startsWith(`valid`)?`text-success`:`text-error`}`,children:t.status})]},e.key)})]},`r${e.round}-${t.id}`))]},e.round))]})]})}function Fe(e){let t=Math.floor(Date.now()/1e3),n=Math.floor(Math.abs(e-t)/60);return e>t?`${n}m left`:`expired ${n}m ago`}function Ie({open:e,onOpenChange:t,accounts:n}){let[r,i]=(0,Z.useState)(new Map),[o,c]=(0,Z.useState)(!1);async function l(e){i(t=>new Map(t).set(e,{loading:!0}));try{let t=await Y(e,o);i(n=>new Map(n).set(e,{loading:!1,result:t}))}catch(t){i(n=>new Map(n).set(e,{loading:!1,error:t.message}))}}function u(){for(let e of n.filter(e=>e.expiresAt!==null))l(e.id)}return(0,Q.jsx)(F,{open:e,onOpenChange:t,children:(0,Q.jsxs)(N,{className:`sm:max-w-xl max-h-[85vh] flex flex-col`,children:[(0,Q.jsxs)(g,{children:[(0,Q.jsxs)(L,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(a,{className:`size-4`}),` Token Test`]}),(0,Q.jsx)(I,{className:`text-xs`,children:`Probe stored tokens for validity. Nothing is modified.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-4 overflow-y-auto flex-1 pr-1`,children:[(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium`,children:`Current tokens`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(b,{id:`token-test-refresh`,checked:o,onCheckedChange:c,className:`cursor-pointer`}),(0,Q.jsx)(P,{htmlFor:`token-test-refresh`,className:`text-[11px] cursor-pointer`,children:`Also test refresh`})]}),(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer`,onClick:u,children:`Test all`})]})]}),n.length===0&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No accounts to test.`}),(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:n.map(e=>{let t=r.get(e.id),n=t?.result?.accessToken.status;return(0,Q.jsxs)(`div`,{className:`p-2 rounded border bg-card space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium truncate block`,children:e.label??e.email??e.id.slice(0,8)}),e.expiresAt&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Fe(e.expiresAt)})]}),(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer shrink-0`,disabled:t?.loading,onClick:()=>void l(e.id),children:t?.loading?(0,Q.jsx)(s,{className:`size-3 animate-spin`}):`Test`})]}),t&&!t.loading&&(0,Q.jsxs)(`div`,{className:`text-[11px] pl-2 border-l-2 border-muted`,children:[t.error&&(0,Q.jsx)(`p`,{className:`text-error`,children:t.error}),n&&(0,Q.jsxs)(`span`,{className:n.startsWith(`valid`)?`text-success`:`text-error`,children:[n,t.result?.accessToken.code?` (${t.result.accessToken.code})`:``]})]})]},e.id)})})]}),(0,Q.jsx)(Pe,{accounts:n})]}),(0,Q.jsx)(O,{children:(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Close`})})]})})}function Le(){let{usages:e,accounts:t,activeAccountId:n,initialLoading:r,refreshing:c,flashIds:l,reload:u}=de(),[d,f]=(0,Z.useState)(null),[p,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),[b,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null);function T(e){u(),e&&f(e)}async function O(e,t){h(e);try{await J(e,{status:t===`disabled`?`active`:`disabled`})}catch(e){f(e.message)}h(null),u()}async function k(){if(g){try{await H(g.id),f(`Account "${g.display}" removed.`),u()}catch(e){f(`Failed to remove: ${e.message}`)}_(null)}}let A=new Map(t.map(e=>[e.id,e])),j=e[0]?.usage.lastFetchedAt;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(ie,{description:`Connect multiple Claude accounts. PPM rotates between them automatically to avoid rate limits.`,onRefresh:()=>void u(),refreshing:c,disabled:r,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(m,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>w(`add`),children:[(0,Q.jsx)(D,{className:`size-4`}),` Add account`]}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>{S(null),w(`export`)},children:[(0,Q.jsx)(i,{className:`size-4`}),` Export`]}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>w(`import`),children:[(0,Q.jsx)(E,{className:`size-4`}),` Import`]}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>w(`rotation`),children:[(0,Q.jsx)(x,{className:`size-4`}),` Rotation`]}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>w(`token-test`),children:[(0,Q.jsx)(a,{className:`size-4`}),` Token test`]})]})}),(0,Q.jsx)(le,{message:d,onDismiss:()=>f(null)}),(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Accounts`}),j&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`usage `,se(new Date(j).getTime())]})]}),r?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(s,{className:`size-4 animate-spin`}),` Loading accounts...`]}):e.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,Q.jsx)(o,{className:`size-5 text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No accounts connected yet.`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add one to start using PPM.`})]}):(0,Q.jsx)(ue,{children:e.map(e=>(0,Q.jsx)(ce,{layout:`strip`,entry:e,isActive:e.accountId===n,accountInfo:A.get(e.accountId),onToggle:O,toggling:p===e.accountId,onDelete:(e,t)=>_({id:e,display:t}),onExport:e=>{S(e),w(`export`)},onViewProfile:(e,t)=>y({profile:e,accountId:t}),flash:l.has(e.accountId)},e.accountId))})]}),v&&(0,Q.jsx)(be,{profile:v.profile,accountId:v.accountId,onClose:()=>y(null)}),g&&(0,Q.jsx)(xe,{display:g.display,onConfirm:()=>void k(),onCancel:()=>_(null)}),(0,Q.jsx)(Se,{open:C===`add`,onOpenChange:e=>w(e?`add`:null),onSuccess:T}),(0,Q.jsx)(we,{open:C===`export`,onOpenChange:e=>{w(e?`export`:null),e||S(null)},accounts:t,preselectId:b,onMessage:f}),(0,Q.jsx)(Te,{open:C===`import`,onOpenChange:e=>w(e?`import`:null),onSuccess:T}),(0,Q.jsx)(Ae,{open:C===`rotation`,onOpenChange:e=>w(e?`rotation`:null)}),(0,Q.jsx)(Ie,{open:C===`token-test`,onOpenChange:e=>w(e?`token-test`:null),accounts:t})]})}function Re({open:e,onOpenChange:t,label:n,onLabelChange:r,apiKey:i,onApiKeyChange:a,adding:c,onAddApiKey:l,deviceWaiting:u,onStartDevice:d,device:f,error:p,browser:h,onStartBrowser:_,loginStarting:v,callbackUrl:b,onCallbackUrlChange:x,submittingCallback:S,onSubmitCallback:C}){let w=v||u||!!h||c;return(0,Q.jsx)(F,{open:e,onOpenChange:t,children:(0,Q.jsxs)(N,{className:`sm:max-w-md max-h-[90dvh] overflow-y-auto`,children:[(0,Q.jsxs)(g,{children:[(0,Q.jsx)(L,{className:`text-sm`,children:`Add Codex Account`}),(0,Q.jsx)(I,{className:`text-xs leading-relaxed`,children:`Choose browser login, a device code, or an OpenAI API key.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(P,{htmlFor:`codex-label`,className:`text-xs`,children:`Label (optional)`}),(0,Q.jsx)(M,{id:`codex-label`,placeholder:`e.g. Personal, Work`,value:n,onChange:e=>r(e.target.value),disabled:w,className:`text-xs`})]}),(0,Q.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Browser login`}),(0,Q.jsxs)(m,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:_,disabled:w,children:[(0,Q.jsx)(y,{className:`size-4`}),` Sign in with browser`]}),h&&(0,Q.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,Q.jsxs)(`a`,{href:h.authUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-primary hover:underline`,children:[(0,Q.jsx)(y,{className:`size-3`}),` Open ChatGPT sign-in`]}),(0,Q.jsx)(`p`,{children:`Sign in, then copy the full localhost callback URL from the address bar and paste it below. On a phone, copy it even if the page fails to load.`}),(0,Q.jsx)(P,{htmlFor:`codex-callback-url`,children:`Callback URL`}),(0,Q.jsx)(M,{id:`codex-callback-url`,type:`password`,autoComplete:`off`,spellCheck:!1,placeholder:`http://localhost:.../auth/callback?...`,value:b,onChange:e=>x(e.target.value),disabled:S}),(0,Q.jsxs)(m,{size:`sm`,onClick:C,disabled:!b.trim()||S,children:[S&&(0,Q.jsx)(s,{className:`size-3 animate-spin`}),` Submit callback URL`]}),(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(s,{className:`size-3 animate-spin`}),` Waiting for authorization. This may complete automatically on this computer.`]})]})]}),(0,Q.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Device code`}),(0,Q.jsx)(m,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:d,disabled:w,children:u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{className:`size-4 animate-spin`}),` Waiting for authorization...`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(R,{className:`size-4`}),` Sign in with device code`]})}),f&&(0,Q.jsxs)(`div`,{className:`rounded-md border border-primary/40 bg-primary/10 p-2.5 space-y-1.5`,children:[(0,Q.jsx)(`p`,{className:`text-[11px]`,children:`Enter this code to authorize:`}),(0,Q.jsx)(`div`,{className:`font-mono text-lg tracking-widest`,children:f.userCode}),(0,Q.jsxs)(`a`,{href:f.verificationUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-primary hover:underline text-[11px]`,children:[(0,Q.jsx)(y,{className:`size-3`}),` `,f.verificationUrl]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex-1 border-t`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`or paste an API key`}),(0,Q.jsx)(`div`,{className:`flex-1 border-t`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(P,{htmlFor:`codex-api-key`,className:`text-xs`,children:`OpenAI API key`}),(0,Q.jsx)(M,{id:`codex-api-key`,type:`password`,placeholder:`sk-...`,value:i,onChange:e=>a(e.target.value),className:`text-xs font-mono`})]})]}),v&&(0,Q.jsx)(`p`,{role:`status`,className:`text-xs`,children:`Starting login...`}),p&&(0,Q.jsx)(`div`,{role:`alert`,className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:p}),(0,Q.jsxs)(O,{children:[(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsxs)(m,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,onClick:l,disabled:!i.trim()||w,children:[c?(0,Q.jsx)(s,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(o,{className:`size-3.5`}),`Add key`]})]})]})})}function ze({mode:e,onOpenChange:t,password:n,onPasswordChange:r,busy:a,onExport:o,onImport:c,error:l}){let u=(0,Z.useRef)(null),d=e===`export`;return(0,Q.jsx)(F,{open:e!==null,onOpenChange:t,children:(0,Q.jsxs)(N,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(g,{children:[(0,Q.jsxs)(L,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(z,{className:`size-4`}),` `,d?`Export Codex Accounts`:`Import Codex Accounts`]}),(0,Q.jsx)(I,{className:`text-xs leading-relaxed`,children:d?`Writes a password-encrypted file containing each account's login.`:`Reads a backup file. The password must be the one it was exported with.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(P,{htmlFor:`codex-backup-password`,className:`text-xs`,children:`Password`}),(0,Q.jsx)(M,{id:`codex-backup-password`,type:`password`,placeholder:d?`Choose a password`:`Password used for the export`,value:n,onChange:e=>r(e.target.value),className:`text-xs`,autoComplete:d?`new-password`:`current-password`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`A backup holds full logins — keep the file and its password together.`})]}),l&&(0,Q.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:l}),(0,Q.jsx)(`input`,{ref:u,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&c(t)}}),(0,Q.jsxs)(O,{children:[(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsxs)(m,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,disabled:!n.trim()||a,onClick:()=>d?o():u.current?.click(),children:[a?(0,Q.jsx)(s,{className:`size-3.5 animate-spin`}):d?(0,Q.jsx)(i,{className:`size-3.5`}):(0,Q.jsx)(E,{className:`size-3.5`}),d?`Download backup`:`Choose file`]})]})]})})}var Be=[{value:`round-robin`,label:`Round-robin`,hint:`Take the next account each time.`},{value:`fill-first`,label:`Fill-first`,hint:`Stay on one account until it runs out.`},{value:`lowest-usage`,label:`Lowest usage`,hint:`Pick whichever has the most left.`}];function Ve({open:e,onOpenChange:t,strategy:n,onChange:r}){return(0,Q.jsx)(F,{open:e,onOpenChange:t,children:(0,Q.jsxs)(N,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(g,{children:[(0,Q.jsx)(L,{className:`text-sm`,children:`Codex Rotation`}),(0,Q.jsx)(I,{className:`text-xs leading-relaxed`,children:`How a new chat chooses among your Codex accounts.`})]}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:Be.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(e.value),"aria-current":n===e.value?`true`:void 0,className:d(`w-full text-left rounded-md border px-3 py-2.5 min-h-11 cursor-pointer transition-colors`,n===e.value?`border-primary bg-primary/10`:`border-border hover:bg-accent/50 active:bg-accent`),children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.hint})]},e.value))}),(0,Q.jsx)(O,{children:(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Done`})})]})})}function He(e){return e==null?null:Math.round(e*100)}function Ue({usage:e}){let t=e.session==null&&e.weekly==null;return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(t||e.session!=null)&&(0,Q.jsx)(ae,{label:`5-Hour Session`,pct:He(e.fiveHour),reset:fe(e.session),resetsAt:e.session?.resetsAt}),(t||e.weekly!=null)&&(0,Q.jsx)(ae,{label:`Weekly`,pct:He(e.sevenDay),reset:fe(e.weekly),resetsAt:e.weekly?.resetsAt})]})}var We=2e3,Ge=21e4;function Ke(e){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(`round-robin`),[a,o]=(0,Z.useState)({}),[s,c]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(new Set),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(``),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(``),[F,I]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(!1),[ee,z]=(0,Z.useState)(null),B=(0,Z.useRef)(null),V=(0,Z.useRef)(null),H=(0,Z.useRef)(0),U=(0,Z.useRef)(!1),W=(0,Z.useRef)(!1),G=(0,Z.useRef)(!1),K=(0,Z.useRef)(e);K.current=e;let q=(0,Z.useCallback)(async()=>{c(!0);try{let e=await l.get(`/api/codex-accounts`);n(e.accounts),i(e.strategy),l.get(`/api/codex-accounts/usage`).then(o).catch(()=>{})}finally{c(!1)}},[]);(0,Z.useEffect)(()=>{q()},[q]);let te=async()=>{if(!(!p.trim()||W.current||U.current||V.current)){W.current=!0,v(!0),b(null);try{await l.post(`/api/codex-accounts/api-key`,{apiKey:p.trim(),label:h.trim()||void 0}),m(``),g(``),e(),await q()}catch(e){b(e.message)}finally{W.current=!1,v(!1)}}},J=(0,Z.useCallback)(()=>{H.current+=1,U.current=!1,G.current=!1,B.current?.(),B.current=null;let e=V.current;V.current=null,e&&l.del(`/api/codex-accounts/${e.method}-login/${e.id}`).catch(()=>{})},[]),Y=(0,Z.useCallback)(()=>{J(),S(null),w(!1),E(null),O(!1),A(``),M(!1)},[J]),ne=(0,Z.useCallback)((e,t)=>{let n=Date.now()+(t===`browser`?61e4:Ge),r=!1,i;B.current=()=>{r=!0,clearTimeout(i)};let a=async()=>{if(r)return;let o=null;try{o=await l.get(`/api/codex-accounts/${t}-login/${e}/status`)}catch{}if(!r){if(o?.state===`done`){Y(),g(``),K.current(),await q();return}if(o?.state===`error`||Date.now()>n){Y(),b(o?.state===`error`?o.error:`${t===`browser`?`Browser`:`Device`} login timed out.`);return}i=setTimeout(a,We)}};a()},[Y,q]);(0,Z.useEffect)(()=>J,[J]);let X=async e=>{if(U.current||V.current||W.current)return;U.current=!0;let t=++H.current;O(!0),b(null);try{let n=await l.post(`/api/codex-accounts/${e}-login`,{label:h.trim()||void 0});if(t!==H.current){l.del(`/api/codex-accounts/${e}-login/${n.id}`).catch(()=>{});return}V.current={id:n.id,method:e},e===`device`?(S(n),w(!0)):E(n),ne(n.id,e)}catch(e){t===H.current&&b(e.message)}finally{t===H.current&&(U.current=!1,O(!1))}};return{accounts:t,strategy:r,usages:a,loading:s,apiKey:p,setApiKey:m,label:h,setLabel:g,adding:_,err:y,setErr:b,device:x,deviceWaiting:C,backupPassword:N,setBackupPassword:P,exporting:F,importing:L,msg:ee,setMsg:z,toggling:d,load:q,addApiKey:te,startDevice:()=>X(`device`),startBrowser:()=>X(`browser`),browser:T,loginStarting:D,callbackUrl:k,setCallbackUrl:A,submittingCallback:j,submitCallback:async()=>{let e=V.current;if(e?.method!==`browser`||!k.trim()||G.current)return;let t=H.current;G.current=!0,M(!0),b(null);let n=k.trim();A(``);try{await l.post(`/api/codex-accounts/browser-login/${e.id}/callback`,{callbackUrl:n})}catch(e){t===H.current&&b(e.message)}finally{t===H.current&&(G.current=!1,M(!1))}},cancelLogin:Y,remove:async e=>{await l.del(`/api/codex-accounts/${e}`),await q()},toggle:async(e,t)=>{let n=t===`disabled`?`active`:`disabled`;f(t=>new Set(t).add(e)),b(null);try{await l.patch(`/api/codex-accounts/${e}`,{status:n}),await q()}catch(e){b(e.message||`Could not change the account`)}finally{f(t=>{let n=new Set(t);return n.delete(e),n})}},changeStrategy:async e=>{i(e);try{await l.put(`/api/codex-accounts/strategy`,{strategy:e})}catch{}},doExport:async()=>{if(!N.trim()){b(`Set a backup password first.`);return}I(!0),b(null),z(null);try{let t={"Content-Type":`application/json`},n=u();n&&(t.Authorization=`Bearer ${n}`);let r=await fetch(`/api/codex-accounts/export`,{method:`POST`,headers:t,body:JSON.stringify({password:N})});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`Export failed: ${r.status}`)}let i=await r.text(),a=new Blob([i],{type:`application/json`}),o=document.createElement(`a`);o.href=URL.createObjectURL(a),o.download=`ppm-codex-accounts-backup.json`,o.click(),URL.revokeObjectURL(o.href),z(`Backup downloaded.`),e()}catch(e){b(e.message)}finally{I(!1)}},doImport:async t=>{if(!N.trim()){b(`Enter the backup password first.`);return}R(!0),b(null),z(null);try{let n=await t.text(),r=await l.post(`/api/codex-accounts/import`,{data:n,password:N});z(`Imported ${r.imported}${r.skipped?`, skipped ${r.skipped}`:``}.`),e(),await q()}catch(e){b(e.message)}finally{R(!1)}}}}function qe(){let[e,t]=(0,Z.useState)(null),n=Ke(()=>t(null));return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(ie,{description:(0,Q.jsxs)(Q.Fragment,{children:[`Each Codex account keeps its own login (`,(0,Q.jsx)(`code`,{children:`CODEX_HOME`}),`). One is picked per chat by the rotation setting.`]}),onRefresh:()=>void n.load(),refreshing:n.loading,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(m,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`add`),children:[(0,Q.jsx)(D,{className:`size-4`}),` Add account`]}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`export`),children:[(0,Q.jsx)(i,{className:`size-4`}),` Export`]}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`import`),children:[(0,Q.jsx)(E,{className:`size-4`}),` Import`]}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`rotation`),children:[(0,Q.jsx)(x,{className:`size-4`}),` Rotation`]})]})}),(0,Q.jsx)(le,{message:n.msg??n.err,onDismiss:()=>{n.setMsg(null),n.setErr(null)}}),(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Codex Accounts`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:n.strategy.replace(`-`,` `)})]}),n.loading&&n.accounts.length===0?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(s,{className:`size-4 animate-spin`}),` Loading accounts...`]}):n.accounts.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,Q.jsx)(o,{className:`size-5 text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Codex accounts yet.`}),(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Chats use your default `,(0,Q.jsx)(`code`,{children:`~/.codex`}),` login until you add one.`]})]}):(0,Q.jsx)(ue,{children:n.accounts.map(e=>{let t=n.usages[e.id]??{};return(0,Q.jsxs)(oe,{dense:!0,className:`min-w-[300px] shrink-0 snap-start`,"data-testid":`account-card`,"data-account-id":e.id,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium truncate flex-1 min-w-0`,children:e.label}),(0,Q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1 shrink-0`,children:e.type}),e.planType&&(0,Q.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:e.planType}),(0,Q.jsx)(b,{checked:e.status!==`disabled`,onCheckedChange:()=>void n.toggle(e.id,e.status??`active`),disabled:n.toggling.has(e.id),"aria-label":e.status===`disabled`?`Enable account`:`Disable account`,className:`cursor-pointer shrink-0`}),(0,Q.jsxs)(v,{children:[(0,Q.jsx)(ee,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void n.remove(e.id),"aria-label":`Remove account`,className:`p-2 rounded cursor-pointer text-text-subtle hover:text-error hover:bg-surface-elevated transition-colors shrink-0`,children:(0,Q.jsx)(C,{className:`size-4`})})}),(0,Q.jsx)(T,{side:`top`,children:`Remove account`})]})]}),(0,Q.jsx)(Ue,{usage:t})]},e.id)})})]}),(0,Q.jsx)(Re,{open:e===`add`,onOpenChange:e=>{e||n.cancelLogin(),t(e?`add`:null)},label:n.label,onLabelChange:n.setLabel,apiKey:n.apiKey,onApiKeyChange:n.setApiKey,adding:n.adding,onAddApiKey:()=>void n.addApiKey(),deviceWaiting:n.deviceWaiting,onStartDevice:()=>void n.startDevice(),device:n.device,browser:n.browser,onStartBrowser:()=>void n.startBrowser(),loginStarting:n.loginStarting,callbackUrl:n.callbackUrl,onCallbackUrlChange:n.setCallbackUrl,submittingCallback:n.submittingCallback,onSubmitCallback:()=>void n.submitCallback(),error:n.err}),(0,Q.jsx)(ze,{mode:e===`export`?`export`:e===`import`?`import`:null,onOpenChange:e=>{e||t(null)},password:n.backupPassword,onPasswordChange:n.setBackupPassword,busy:n.exporting||n.importing,onExport:()=>void n.doExport(),onImport:e=>void n.doImport(e),error:n.err}),(0,Q.jsx)(Ve,{open:e===`rotation`,onOpenChange:e=>t(e?`rotation`:null),strategy:n.strategy,onChange:e=>void n.changeStrategy(e)})]})}var Je=[{id:`claude`,label:`Claude`},{id:`codex`,label:`Codex`}];function Ye(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(`claude`);(0,Z.useEffect)(()=>{let e=!1;return W().then(n=>{e||t(new Set(Object.keys(n.providers??{})))}).catch(()=>{e||t(new Set([`claude`]))}),()=>{e=!0}},[]);let i=Je.filter(t=>t.id===`claude`||e?.has(t.id)),a=i.length>1;return(0,Q.jsxs)(`div`,{className:`space-y-4`,"data-testid":`accounts-pane`,"data-provider":n,children:[a&&(0,Q.jsx)(`div`,{className:`flex gap-1 border-b border-border/50`,children:i.map(e=>(0,Q.jsxs)(`button`,{onClick:()=>r(e.id),"data-testid":`accounts-tab-${e.id}`,"aria-current":n===e.id?`page`:void 0,className:`flex items-center gap-1.5 px-3 py-2 text-xs rounded-t transition-colors cursor-pointer ${n===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,Q.jsx)(w,{providerId:e.id}),e.label]},e.id))}),e===null&&!a&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(s,{className:`size-3 animate-spin`}),` Checking configured providers...`]}),n===`claude`?(0,Q.jsx)(Le,{}):(0,Q.jsx)(qe,{})]})}export{Ye as AccountsSettingsSection};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-BBdkypKW.js";import{t as r}from"./copy-CXuIH4VC.js";import{t as i}from"./download-D70Q4Ba6.js";import{t as a}from"./flask-conical-Dix4qNDj.js";import{t as o}from"./key-round-oIll4vo-.js";import{t as s}from"./loader-circle-DxI3O9_f.js";import{t as c}from"./x-Bdaog6Az.js";import{n as l,r as u}from"./api-client-DwXlVfXP.js";import{n as d}from"./utils-IrnQujwR.js";import"./portal-container-context-DeLx1cOI.js";import{n as f}from"./use-is-mobile-Bi42QhIi.js";import{n as p,t as m}from"./button-zgoXa9r7.js";import{t as h}from"./mobile-bottom-sheet-Ch1e_JBq.js";import"./use-visual-viewport-CNdG4QHH.js";import{$t as g,B as _,Dn as v,Dr as y,G as b,Gn as x,H as S,Ln as C,M as w,On as T,Pn as E,Qn as D,Qt as O,U as k,V as A,W as j,X as M,Xt as N,Y as P,Yt as F,Zt as I,en as L,ir as R,kn as ee,lr as z,nn as B}from"./index-DVNJ2W5R.js";import{addAccount as V,deleteAccount as H,exchangeOAuthCode as U,getAISettings as W,getAccountSettings as G,getOAuthUrl as K,getUsageHistory as q,importAccounts as te,patchAccount as J,testAccountToken as Y,testExport as ne,testRawToken as X,updateAccountSettings as re}from"./api-settings-BQIwZoLm.js";import{a as ie,c as ae,i as oe,l as se,n as ce,o as le,r as ue,t as de,u as fe}from"./use-accounts-data-B9t4BQaI.js";var Z=e(t(),1),Q=n(),pe=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],$=Array.from({length:24},(e,t)=>t);function me(e,t){let n=Array.from({length:7},()=>Array.from({length:24},()=>({sum:0,count:0,avg:0})));for(let r of e){let e=t===`5h`?r.five_hour_util:r.weekly_util;if(e==null)continue;let i=new Date(r.recorded_at+(r.recorded_at.endsWith(`Z`)?``:`Z`)),a=(i.getDay()+6)%7,o=i.getHours();n[a][o].sum+=e,n[a][o].count+=1}for(let e of n)for(let t of e)t.avg=t.count>0?t.sum/t.count:0;return n}function he(e){return e.map(e=>{let t=e.reduce((e,t)=>e+t.sum,0),n=e.reduce((e,t)=>e+t.count,0);return n>0?t/n:0})}function ge(e){return $.map(t=>{let n=0,r=0;for(let i of e)n+=i[t].sum,r+=i[t].count;return r>0?n/r:0})}function _e(e){return e===0?`bg-surface-elevated`:e<.3?`bg-success/30`:e<.5?`bg-success/60`:e<.7?`bg-warning/50`:e<.9?`bg-warning/80`:`bg-error/80`}function ve(e){return e<.3?`bg-success`:e<.7?`bg-warning`:`bg-error`}function ye({accountId:e}){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(!0),[a,o]=(0,Z.useState)(`5h`);(0,Z.useEffect)(()=>{i(!0),q(e).then(n).catch(()=>n([])).finally(()=>i(!1))},[e]);let c=(0,Z.useMemo)(()=>t?me(t,a):null,[t,a]),l=(0,Z.useMemo)(()=>c?he(c):[],[c]),u=(0,Z.useMemo)(()=>c?ge(c):[],[c]),d=Math.max(...l,.01);if(Math.max(...u,.01),r)return(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,Q.jsx)(s,{className:`size-3 animate-spin text-text-subtle`})});if(!t||t.length===0)return(0,Q.jsx)(`div`,{className:`text-[10px] text-text-subtle py-2 text-center`,children:`No usage history yet`});let f=t.length,p=new Set(t.map(e=>new Date(e.recorded_at+(e.recorded_at.endsWith(`Z`)?``:`Z`)).toDateString())).size;return(0,Q.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle`,children:`Usage Pattern (7d)`}),(0,Q.jsxs)(`div`,{className:`flex gap-0.5 text-[9px]`,children:[(0,Q.jsx)(`button`,{onClick:()=>o(`5h`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`5h`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`5-hour rolling window limit — resets every 5 hours`,children:`5h`}),(0,Q.jsx)(`button`,{onClick:()=>o(`weekly`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`weekly`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`Weekly limit — resets every 7 days`,children:`Wk`})]})]}),(0,Q.jsxs)(`p`,{className:`text-[9px] text-text-subtle leading-tight`,children:[`Avg `,a===`5h`?`5-hour`:`weekly`,` limit usage over `,p,`d (`,f,` samples). Higher % = closer to rate limit. Hover cells for details.`]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by day of week`}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-[2px] mt-0.5`,children:pe.map((e,t)=>{let n=l[t]??0;return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-[8px] text-text-subtle w-5 shrink-0 text-right tabular-nums`,children:e}),(0,Q.jsx)(`div`,{className:`flex-1 h-2.5 bg-surface-elevated rounded-sm overflow-hidden`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-sm transition-all ${ve(n)}`,style:{width:`${Math.round(n/d*100)}%`}})}),(0,Q.jsxs)(`span`,{className:`text-[8px] text-text-subtle w-6 shrink-0 text-right tabular-nums`,children:[Math.round(n*100),`%`]})]},e)})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by hour (0h-23h)`}),(0,Q.jsx)(`div`,{className:`flex gap-[1px] mt-0.5`,children:$.map(e=>{let t=u[e]??0;return(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-[1px]`,children:[(0,Q.jsx)(`div`,{className:`w-full aspect-square rounded-[2px] ${_e(t)}`,title:`${e}:00 — avg ${Math.round(t*100)}% usage`}),e%6==0&&(0,Q.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})]},e)})})]}),c&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Day x Hour heatmap`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-[1px] mt-0.5`,children:[pe.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,Q.jsx)(`span`,{className:`text-[7px] text-text-subtle w-4 shrink-0 text-right`,children:e.charAt(0)}),$.map(n=>{let r=c[t][n];return(0,Q.jsx)(`div`,{className:`flex-1 aspect-square rounded-[1px] ${_e(r.avg)}`,title:`${e} ${n}:00 — ${r.count>0?`avg ${Math.round(r.avg*100)}% (${r.count} samples)`:`no data`}`},n)})]},e)),(0,Q.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,Q.jsx)(`span`,{className:`w-4 shrink-0`}),$.map(e=>(0,Q.jsx)(`div`,{className:`flex-1 text-center`,children:e%6==0&&(0,Q.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})},e))]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[8px] text-text-subtle`,children:[(0,Q.jsx)(`span`,{children:`Low`}),(0,Q.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/30`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/60`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/50`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/80`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-error/80`})]}),(0,Q.jsx)(`span`,{children:`High`}),(0,Q.jsx)(`span`,{className:`ml-1`,children:`|`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-surface-elevated border border-border/30`}),(0,Q.jsx)(`span`,{children:`No data`})]})]})}function be({profile:e,accountId:t,onClose:n}){let r=[[`Name`,e.account?.display_name],[`Email`,e.account?.email],[`Org`,e.organization?.name],[`Type`,e.organization?.organization_type],[`Tier`,e.organization?.rate_limit_tier],[`Status`,e.organization?.subscription_status]];return(0,Q.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3`,"data-testid":`account-profile-panel`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Profile`}),(0,Q.jsx)(`button`,{className:`p-2 text-muted-foreground hover:text-foreground cursor-pointer`,onClick:n,"aria-label":`Close profile`,children:(0,Q.jsx)(c,{className:`size-4`})})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[80px_1fr] gap-x-3 gap-y-1 text-xs`,children:r.map(([e,t])=>t?(0,Q.jsxs)(`span`,{className:`contents`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,Q.jsx)(`span`,{className:`break-all`,children:t})]},e):null)}),(0,Q.jsx)(ye,{accountId:t})]})}function xe({display:e,onConfirm:t,onCancel:n}){let r=f(),i=(0,Q.jsxs)(`div`,{className:`space-y-4`,"data-testid":`account-delete-confirm`,children:[(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Remove `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e}),`?`]}),(0,Q.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`The stored token is deleted from this machine. Any export you already made keeps working.`}),(0,Q.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-2`,children:[(0,Q.jsx)(m,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Cancel`}),(0,Q.jsx)(m,{variant:`destructive`,autoFocus:!1,onClick:t,className:`min-h-11`,children:`Remove account`})]})]});return r?(0,Q.jsx)(h,{open:!0,onClose:n,children:(0,Q.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Remove account`}),i]})}):(0,Q.jsx)(F,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(N,{className:`sm:max-w-sm`,children:[(0,Q.jsx)(g,{children:(0,Q.jsx)(L,{className:`text-sm`,children:`Remove account`})}),i]})})}function Se({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[h,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(`idle`);function S(){p(null),_(``),x(`idle`),d(null)}function C(){t(!1),S(),i(``),o(``),d(null)}async function w(){y(!0),d(null);try{let{url:e,state:t}=await K();p(t),x(`waiting`),window.open(e,`_blank`)}catch(e){d(e.message)}y(!1)}async function T(){if(!(!h.trim()||!f)){y(!0),d(null);try{let e=h.trim();e.includes(`#`)&&(e=e.split(`#`)[0]??e);let t=await U(e,f);C(),n(t?.status===`disabled`?`Signed in. This account is still disabled — enable it to use it.`:`Account connected via OAuth!`)}catch(e){d(e.message)}y(!1)}}async function E(){if(r.trim()){l(!0),d(null);try{let e=await V({apiKey:r.trim(),label:a.trim()||void 0});C(),n(e?.status===`disabled`?`Token updated. This account is still disabled — enable it to use it.`:`Account added!`)}catch(e){d(e.message)}l(!1)}}let D=r.trim()?r.trim().startsWith(`sk-ant-oat`)?`OAuth token (Claude Max/Pro)`:r.trim().startsWith(`sk-ant-api`)?`API key`:`Unknown format`:``;return(0,Q.jsx)(F,{open:e,onOpenChange:e=>{e||C()},children:(0,Q.jsxs)(N,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(g,{children:[(0,Q.jsx)(L,{className:`text-sm`,children:`Add Claude Account`}),(0,Q.jsx)(I,{className:`text-xs leading-relaxed`,children:`Connect via OAuth (recommended) or paste a token manually.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Recommended: Login with Claude`}),b===`idle`?(0,Q.jsx)(m,{size:`sm`,className:`w-full h-8 text-xs`,onClick:w,disabled:v,children:v?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{className:`size-3 animate-spin mr-1`}),` Opening...`]}):`Login with Claude`}):(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Authorize in the opened tab, then paste the code:`}),(0,Q.jsx)(M,{placeholder:`Paste code here...`,value:h,onChange:e=>_(e.target.value),className:`text-xs h-8 font-mono`,autoFocus:!0}),(0,Q.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,Q.jsx)(m,{size:`sm`,className:`flex-1 h-7 text-xs`,onClick:T,disabled:!h.trim()||v,children:v?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{className:`size-3 animate-spin mr-1`}),` Connecting...`]}):`Connect`}),(0,Q.jsx)(m,{size:`sm`,variant:`ghost`,className:`h-7 text-xs`,onClick:S,children:`Cancel`})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex-1 border-t`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`or paste token`}),(0,Q.jsx)(`div`,{className:`flex-1 border-t`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(P,{htmlFor:`add-token`,className:`text-xs`,children:`Token`}),(0,Q.jsx)(M,{id:`add-token`,type:`password`,placeholder:`sk-ant-...`,value:r,onChange:e=>i(e.target.value),className:`text-xs h-8 font-mono`}),D&&(0,Q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[`Detected: `,D]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(P,{htmlFor:`add-label`,className:`text-xs`,children:`Label (optional)`}),(0,Q.jsx)(M,{id:`add-label`,placeholder:`e.g. Personal, Work`,value:a,onChange:e=>o(e.target.value),className:`text-xs h-8`})]})]}),u&&(0,Q.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:u}),(0,Q.jsxs)(O,{children:[(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs h-7`,onClick:C,children:`Cancel`}),(0,Q.jsx)(m,{size:`sm`,className:`text-xs h-7`,onClick:E,disabled:!r.trim()||c,children:c?`Adding...`:`Add Token`})]})]})})}function Ce(e){let t=new Blob([e],{type:`application/json`}),n=document.createElement(`a`);n.href=URL.createObjectURL(t),n.download=`ppm-accounts-backup.json`,n.click(),URL.revokeObjectURL(n.href)}function we({open:e,onOpenChange:t,accounts:n,preselectId:a,onMessage:o}){let c=n.filter(e=>e.hasRefreshToken),[l,d]=(0,Z.useState)(new Set),[f,p]=(0,Z.useState)(``),[h,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(!1);e&&!S&&(d(a?new Set([a]):new Set(c.map(e=>e.id))),C(!0)),!e&&S&&C(!1);function w(){t(!1),p(``),_(!1),y(!1)}async function T(e){if(l.size===0)return;x(!0);let t=f.trim()||`ppm-hienlh`;try{let n={"Content-Type":`application/json`},r=u();r&&(n.Authorization=`Bearer ${r}`);let i=await fetch(`/api/accounts/export`,{method:`POST`,headers:n,body:JSON.stringify({password:t,accountIds:[...l],includeRefreshToken:h,refreshBeforeExport:v})});if(!i.ok){let e=await i.json();throw Error(e.error??`Export failed: ${i.status}`)}let a=await i.text();e&&await B(a)?o?.(`Backup copied to clipboard!`):(Ce(a),o?.(`Backup downloaded.`)),w()}catch{}x(!1)}let E=l.size>0&&!b;return(0,Q.jsx)(F,{open:e,onOpenChange:e=>{e||w()},children:(0,Q.jsxs)(N,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(g,{children:[(0,Q.jsxs)(L,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(z,{className:`size-3.5`}),` Export Accounts`]}),(0,Q.jsx)(I,{className:`text-xs`,children:`Select accounts and set a password to protect the backup.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Accounts to export`}),(0,Q.jsx)(`button`,{className:`text-[10px] text-primary hover:underline cursor-pointer`,onClick:()=>d(l.size===c.length?new Set:new Set(c.map(e=>e.id))),children:l.size===c.length?`Deselect all`:`Select all`})]}),c.length===0?(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground p-2 border rounded`,children:`No exportable accounts.`}):(0,Q.jsx)(`div`,{className:`max-h-36 overflow-y-auto space-y-1 border rounded p-2`,children:c.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`exp-${e.id}`,checked:l.has(e.id),onChange:t=>{let n=new Set(l);t.target.checked?n.add(e.id):n.delete(e.id),d(n)},className:`size-3.5 accent-primary cursor-pointer`}),(0,Q.jsx)(`label`,{htmlFor:`exp-${e.id}`,className:`text-xs cursor-pointer truncate`,children:e.label??e.email??e.id.slice(0,8)})]},e.id))})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(P,{className:`text-xs`,children:[`Password `,(0,Q.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,Q.jsx)(M,{type:`password`,placeholder:`Leave empty for default`,value:f,onChange:e=>p(e.target.value),className:`text-xs h-8`,autoComplete:`new-password`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`exp-full`,checked:h,onChange:e=>_(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,Q.jsx)(`label`,{htmlFor:`exp-full`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens (full transfer)`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`exp-refresh`,checked:v,onChange:e=>y(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,Q.jsx)(`label`,{htmlFor:`exp-refresh`,className:`text-[11px] cursor-pointer`,children:`Refresh tokens before export`})]}),h?(0,Q.jsxs)(`div`,{className:`rounded-md border border-error/30 bg-error/5 p-2.5`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] font-medium text-error`,children:`Full transfer — source accounts will expire`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Refresh tokens included. Source machine expires in ~1h after target refreshes.`})]}):v?(0,Q.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-2.5`,children:(0,Q.jsx)(`p`,{className:`text-[10px] font-medium text-warning`,children:`Refresh before export — invalidates previous shares`})}):(0,Q.jsx)(`div`,{className:`rounded-md border border-success/30 bg-success/5 p-2.5`,children:(0,Q.jsx)(`p`,{className:`text-[10px] font-medium text-success`,children:`Share current token (safe)`})}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Encrypted with AES-256-GCM + scrypt.`})]}),(0,Q.jsxs)(O,{className:`gap-1.5 flex-col sm:flex-row`,children:[(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:w,children:`Cancel`}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,disabled:!E,onClick:()=>T(!0),children:[(0,Q.jsx)(r,{className:`size-3 mr-1`}),` Copy`]}),(0,Q.jsx)(m,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!E,onClick:()=>T(!1),children:b?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(i,{className:`size-3 mr-1`}),` Download`]})})]})]})})}function Te({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null);function f(){t(!1),i(``),o(``),d(null)}async function p(){if(r.trim()){l(!0),d(null);try{let e=await te({data:r.trim(),password:a.trim()||`ppm-hienlh`});f(),n(`Imported ${e.imported} account(s)`)}catch(e){d(e.message||`Import failed`)}l(!1)}}return(0,Q.jsx)(F,{open:e,onOpenChange:e=>{e||f()},children:(0,Q.jsxs)(N,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(g,{children:[(0,Q.jsxs)(L,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(z,{className:`size-3.5`}),` Import Accounts`]}),(0,Q.jsx)(I,{className:`text-xs`,children:`Paste backup data and enter the export password. Imported accounts are temporary (~1h).`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(P,{className:`text-xs`,children:`Backup data`}),(0,Q.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),placeholder:`Paste backup JSON here...`,rows:4,className:`w-full text-xs p-2 rounded border border-border bg-background font-mono resize-none focus:outline-none focus:ring-1 focus:ring-primary`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(P,{className:`text-xs`,children:[`Password `,(0,Q.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,Q.jsx)(M,{type:`password`,placeholder:`Leave empty for default`,value:a,onChange:e=>o(e.target.value),className:`text-xs h-8`,autoComplete:`current-password`})]})]}),u&&(0,Q.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:u}),(0,Q.jsxs)(O,{children:[(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:f,children:`Cancel`}),(0,Q.jsx)(m,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!r.trim()||c,onClick:p,children:c?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{className:`size-3 animate-spin mr-1`}),` Importing...`]}):`Import`})]})]})})}var Ee=typeof window<`u`?window.matchMedia(`(min-width: 768px)`):null;function De(e){return Ee?.addEventListener(`change`,e),()=>Ee?.removeEventListener(`change`,e)}function Oe(){return Ee?.matches??!0}function ke(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(!0);return(0,Z.useEffect)(()=>{r(!0),G().then(t).finally(()=>r(!1))},[]),n?(0,Q.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Loading...`}):e?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Rotation Strategy`}),(0,Q.jsxs)(_,{value:e.strategy,onValueChange:async e=>{t(await re({strategy:e}))},children:[(0,Q.jsx)(k,{className:`w-full h-9 text-xs`,children:(0,Q.jsx)(j,{})}),(0,Q.jsxs)(A,{children:[(0,Q.jsx)(S,{value:`round-robin`,children:`Round-robin`}),(0,Q.jsx)(S,{value:`fill-first`,children:`Fill-first`}),(0,Q.jsx)(S,{value:`lowest-usage`,children:`Lowest usage`})]})]}),(0,Q.jsxs)(`p`,{className:`text-[10px] text-text-subtle`,children:[e.strategy===`round-robin`&&`Cycles through accounts evenly`,e.strategy===`fill-first`&&`Uses one account until its limit, then moves on`,e.strategy===`lowest-usage`&&`Picks the account with the lowest current usage`]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Max Retry`}),(0,Q.jsx)(`input`,{type:`number`,min:0,value:e.maxRetry,className:`w-full h-9 text-xs border rounded-md px-3 bg-background`,onChange:async e=>{let n=parseInt(e.target.value,10);!isNaN(n)&&n>=0&&t(await re({maxRetry:n}))}}),(0,Q.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`How many accounts to try on failure. 0 = try all available accounts.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Cooldown parking`}),(0,Q.jsx)(b,{checked:e.cooldownEnabled,onCheckedChange:async e=>{t(await re({cooldownEnabled:e}))}})]}),(0,Q.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`Park a failing account (rate limit / usage limit / auth error) until it recovers. Off: accounts stay selectable — rotation still skips accounts already ≥95% on the 5-hour limit.`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-xs border-t border-border pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-text-subtle`,children:`Active accounts`}),(0,Q.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.activeCount})]})]}):(0,Q.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Failed to load settings`})}function Ae({open:e,onOpenChange:t}){let n=(0,Z.useSyncExternalStore)(De,Oe);return e?n?(0,Q.jsx)(F,{open:e,onOpenChange:t,children:(0,Q.jsxs)(N,{className:`sm:max-w-sm`,children:[(0,Q.jsx)(g,{children:(0,Q.jsxs)(L,{className:`text-sm flex items-center gap-2`,children:[(0,Q.jsx)(x,{className:`size-4`}),` Rotation & Retry`]})}),(0,Q.jsx)(ke,{})]})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`fixed inset-0 z-50 transition-opacity duration-200 opacity-100`,onClick:()=>t(!1),style:{backgroundColor:`rgba(0,0,0,0.5)`}}),(0,Q.jsxs)(`div`,{className:d(`fixed bottom-0 left-0 right-0 z-50 bg-background rounded-t-2xl border-t border-border shadow-2xl`,`transition-transform duration-300 ease-out max-h-[85vh] overflow-y-auto`,`translate-y-0`),children:[(0,Q.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,Q.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-border`})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Q.jsx)(x,{className:`size-4`}),` Rotation & Retry`]}),(0,Q.jsx)(`button`,{onClick:()=>t(!1),className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,Q.jsx)(c,{className:`size-4`})})]}),(0,Q.jsx)(`div`,{className:`px-4 py-4 pb-8`,children:(0,Q.jsx)(ke,{})})]})]}):null}var je=p(`inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground shadow`,secondary:`border-transparent bg-secondary text-secondary-foreground`,destructive:`border-transparent bg-destructive text-destructive-foreground shadow`,outline:`text-foreground`}},defaultVariants:{variant:`default`}});function Me({className:e,variant:t,...n}){return(0,Q.jsx)(`div`,{className:d(je({variant:t}),e),...n})}function Ne(e){let t=Math.floor(Date.now()/1e3);return e>t?`${Math.floor((e-t)/60)}m`:`exp`}function Pe({accounts:e}){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(new Map),u=e.filter(e=>e.hasRefreshToken);async function d(){if(u.length!==0){i(!0);try{let e=await ne(u.map(e=>e.id),a);n(t=>[...t,{round:t.length+1,time:new Date().toLocaleTimeString(),includeRefresh:a,items:e}])}catch{}i(!1)}}async function f(e,t){l(t=>new Map(t).set(e,{loading:!0}));try{let n=await X(t);l(t=>new Map(t).set(e,{loading:!1,...n}))}catch(t){l(n=>new Map(n).set(e,{loading:!1,status:`error`,error:t.message}))}}function p(e,t){return[{key:`r${e.round}-pre-${t.id}`,label:`Pre-export`,token:t.preExportTokenFull,preview:t.preExportToken,expires:t.preExportExpires},{key:`r${e.round}-exp-${t.id}`,label:`Exported`,token:t.exportedTokenFull,preview:t.exportedToken,expires:t.exportedExpires},{key:`r${e.round}-post-${t.id}`,label:`Post-export`,token:t.postExportTokenFull,preview:t.postExportToken,expires:t.postExportExpires}]}function h(){for(let e of t)for(let t of e.items)for(let n of p(e,t))n.token&&f(n.key,n.token)}return(0,Q.jsxs)(`section`,{className:`border-t pt-4 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium`,children:`Simulate export`}),t.length>0&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[t.length,` round(s)`]})]}),(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Every run appends a round. Earlier rounds are kept so tokens can be compared across runs.`}),u.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No OAuth account with a refresh token to export.`}):(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(b,{id:`sim-include-refresh`,checked:a,onCheckedChange:o,className:`cursor-pointer`}),(0,Q.jsx)(P,{htmlFor:`sim-include-refresh`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens`})]}),(0,Q.jsx)(m,{size:`sm`,className:`h-7 text-xs cursor-pointer`,disabled:r,onClick:()=>void d(),children:r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):`Run export #${t.length+1}`})]}),t.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`w-full h-7 text-[11px] cursor-pointer`,onClick:h,children:[`Test all tokens (`,t.reduce((e,t)=>e+t.items.length*3,0),`)`]}),t.map(e=>(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`p`,{className:`text-xs font-medium text-primary`,children:[`Round #`,e.round]}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.time}),(0,Q.jsx)(Me,{variant:e.includeRefresh?`destructive`:`secondary`,className:`text-[9px] px-1 py-0`,children:e.includeRefresh?`with refresh`:`access only`})]}),e.items.map(t=>(0,Q.jsxs)(`div`,{className:`p-2 rounded-lg border bg-card space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] font-medium`,children:t.label??t.email??t.id.slice(0,8)}),t.tokenChanged&&(0,Q.jsx)(Me,{variant:`secondary`,className:`text-[9px] px-1 py-0`,children:`DB token changed`})]}),p(e,t).map(e=>{let t=c.get(e.key);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,Q.jsx)(`span`,{className:`w-20 shrink-0 text-muted-foreground text-[10px]`,children:e.label}),(0,Q.jsx)(`code`,{className:`flex-1 truncate font-mono text-[10px] bg-muted px-1 rounded`,children:e.preview??`N/A`}),e.expires&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:Ne(e.expires)}),e.token?(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-1.5 cursor-pointer shrink-0`,disabled:t?.loading,onClick:()=>void f(e.key,e.token),children:t?.loading?(0,Q.jsx)(s,{className:`size-3 animate-spin`}):`Test`}):(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`-`}),t&&!t.loading&&(0,Q.jsx)(`span`,{className:`text-[10px] font-medium shrink-0 ${t.status?.startsWith(`valid`)?`text-success`:`text-error`}`,children:t.status})]},e.key)})]},`r${e.round}-${t.id}`))]},e.round))]})]})}function Fe(e){let t=Math.floor(Date.now()/1e3),n=Math.floor(Math.abs(e-t)/60);return e>t?`${n}m left`:`expired ${n}m ago`}function Ie({open:e,onOpenChange:t,accounts:n}){let[r,i]=(0,Z.useState)(new Map),[o,c]=(0,Z.useState)(!1);async function l(e){i(t=>new Map(t).set(e,{loading:!0}));try{let t=await Y(e,o);i(n=>new Map(n).set(e,{loading:!1,result:t}))}catch(t){i(n=>new Map(n).set(e,{loading:!1,error:t.message}))}}function u(){for(let e of n.filter(e=>e.expiresAt!==null))l(e.id)}return(0,Q.jsx)(F,{open:e,onOpenChange:t,children:(0,Q.jsxs)(N,{className:`sm:max-w-xl max-h-[85vh] flex flex-col`,children:[(0,Q.jsxs)(g,{children:[(0,Q.jsxs)(L,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(a,{className:`size-4`}),` Token Test`]}),(0,Q.jsx)(I,{className:`text-xs`,children:`Probe stored tokens for validity. Nothing is modified.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-4 overflow-y-auto flex-1 pr-1`,children:[(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium`,children:`Current tokens`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(b,{id:`token-test-refresh`,checked:o,onCheckedChange:c,className:`cursor-pointer`}),(0,Q.jsx)(P,{htmlFor:`token-test-refresh`,className:`text-[11px] cursor-pointer`,children:`Also test refresh`})]}),(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer`,onClick:u,children:`Test all`})]})]}),n.length===0&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No accounts to test.`}),(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:n.map(e=>{let t=r.get(e.id),n=t?.result?.accessToken.status;return(0,Q.jsxs)(`div`,{className:`p-2 rounded border bg-card space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium truncate block`,children:e.label??e.email??e.id.slice(0,8)}),e.expiresAt&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Fe(e.expiresAt)})]}),(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer shrink-0`,disabled:t?.loading,onClick:()=>void l(e.id),children:t?.loading?(0,Q.jsx)(s,{className:`size-3 animate-spin`}):`Test`})]}),t&&!t.loading&&(0,Q.jsxs)(`div`,{className:`text-[11px] pl-2 border-l-2 border-muted`,children:[t.error&&(0,Q.jsx)(`p`,{className:`text-error`,children:t.error}),n&&(0,Q.jsxs)(`span`,{className:n.startsWith(`valid`)?`text-success`:`text-error`,children:[n,t.result?.accessToken.code?` (${t.result.accessToken.code})`:``]})]})]},e.id)})})]}),(0,Q.jsx)(Pe,{accounts:n})]}),(0,Q.jsx)(O,{children:(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Close`})})]})})}function Le(){let{usages:e,accounts:t,activeAccountId:n,initialLoading:r,refreshing:c,flashIds:l,reload:u}=de(),[d,f]=(0,Z.useState)(null),[p,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),[b,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null);function T(e){u(),e&&f(e)}async function O(e,t){h(e);try{await J(e,{status:t===`disabled`?`active`:`disabled`})}catch(e){f(e.message)}h(null),u()}async function k(){if(g){try{await H(g.id),f(`Account "${g.display}" removed.`),u()}catch(e){f(`Failed to remove: ${e.message}`)}_(null)}}let A=new Map(t.map(e=>[e.id,e])),j=e[0]?.usage.lastFetchedAt;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(ie,{description:`Connect multiple Claude accounts. PPM rotates between them automatically to avoid rate limits.`,onRefresh:()=>void u(),refreshing:c,disabled:r,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(m,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>w(`add`),children:[(0,Q.jsx)(D,{className:`size-4`}),` Add account`]}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>{S(null),w(`export`)},children:[(0,Q.jsx)(i,{className:`size-4`}),` Export`]}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>w(`import`),children:[(0,Q.jsx)(E,{className:`size-4`}),` Import`]}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>w(`rotation`),children:[(0,Q.jsx)(x,{className:`size-4`}),` Rotation`]}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>w(`token-test`),children:[(0,Q.jsx)(a,{className:`size-4`}),` Token test`]})]})}),(0,Q.jsx)(le,{message:d,onDismiss:()=>f(null)}),(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Accounts`}),j&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`usage `,se(new Date(j).getTime())]})]}),r?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(s,{className:`size-4 animate-spin`}),` Loading accounts...`]}):e.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,Q.jsx)(o,{className:`size-5 text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No accounts connected yet.`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add one to start using PPM.`})]}):(0,Q.jsx)(ue,{children:e.map(e=>(0,Q.jsx)(ce,{layout:`strip`,entry:e,isActive:e.accountId===n,accountInfo:A.get(e.accountId),onToggle:O,toggling:p===e.accountId,onDelete:(e,t)=>_({id:e,display:t}),onExport:e=>{S(e),w(`export`)},onViewProfile:(e,t)=>y({profile:e,accountId:t}),flash:l.has(e.accountId)},e.accountId))})]}),v&&(0,Q.jsx)(be,{profile:v.profile,accountId:v.accountId,onClose:()=>y(null)}),g&&(0,Q.jsx)(xe,{display:g.display,onConfirm:()=>void k(),onCancel:()=>_(null)}),(0,Q.jsx)(Se,{open:C===`add`,onOpenChange:e=>w(e?`add`:null),onSuccess:T}),(0,Q.jsx)(we,{open:C===`export`,onOpenChange:e=>{w(e?`export`:null),e||S(null)},accounts:t,preselectId:b,onMessage:f}),(0,Q.jsx)(Te,{open:C===`import`,onOpenChange:e=>w(e?`import`:null),onSuccess:T}),(0,Q.jsx)(Ae,{open:C===`rotation`,onOpenChange:e=>w(e?`rotation`:null)}),(0,Q.jsx)(Ie,{open:C===`token-test`,onOpenChange:e=>w(e?`token-test`:null),accounts:t})]})}function Re({open:e,onOpenChange:t,label:n,onLabelChange:r,apiKey:i,onApiKeyChange:a,adding:c,onAddApiKey:l,deviceWaiting:u,onStartDevice:d,device:f,error:p,browser:h,onStartBrowser:_,loginStarting:v,callbackUrl:b,onCallbackUrlChange:x,submittingCallback:S,onSubmitCallback:C}){let w=v||u||!!h||c;return(0,Q.jsx)(F,{open:e,onOpenChange:t,children:(0,Q.jsxs)(N,{className:`sm:max-w-md max-h-[90dvh] overflow-y-auto`,children:[(0,Q.jsxs)(g,{children:[(0,Q.jsx)(L,{className:`text-sm`,children:`Add Codex Account`}),(0,Q.jsx)(I,{className:`text-xs leading-relaxed`,children:`Choose browser login, a device code, or an OpenAI API key.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(P,{htmlFor:`codex-label`,className:`text-xs`,children:`Label (optional)`}),(0,Q.jsx)(M,{id:`codex-label`,placeholder:`e.g. Personal, Work`,value:n,onChange:e=>r(e.target.value),disabled:w,className:`text-xs`})]}),(0,Q.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Browser login`}),(0,Q.jsxs)(m,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:_,disabled:w,children:[(0,Q.jsx)(y,{className:`size-4`}),` Sign in with browser`]}),h&&(0,Q.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,Q.jsxs)(`a`,{href:h.authUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-primary hover:underline`,children:[(0,Q.jsx)(y,{className:`size-3`}),` Open ChatGPT sign-in`]}),(0,Q.jsx)(`p`,{children:`Sign in, then copy the full localhost callback URL from the address bar and paste it below. On a phone, copy it even if the page fails to load.`}),(0,Q.jsx)(P,{htmlFor:`codex-callback-url`,children:`Callback URL`}),(0,Q.jsx)(M,{id:`codex-callback-url`,type:`password`,autoComplete:`off`,spellCheck:!1,placeholder:`http://localhost:.../auth/callback?...`,value:b,onChange:e=>x(e.target.value),disabled:S}),(0,Q.jsxs)(m,{size:`sm`,onClick:C,disabled:!b.trim()||S,children:[S&&(0,Q.jsx)(s,{className:`size-3 animate-spin`}),` Submit callback URL`]}),(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(s,{className:`size-3 animate-spin`}),` Waiting for authorization. This may complete automatically on this computer.`]})]})]}),(0,Q.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Device code`}),(0,Q.jsx)(m,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:d,disabled:w,children:u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{className:`size-4 animate-spin`}),` Waiting for authorization...`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(R,{className:`size-4`}),` Sign in with device code`]})}),f&&(0,Q.jsxs)(`div`,{className:`rounded-md border border-primary/40 bg-primary/10 p-2.5 space-y-1.5`,children:[(0,Q.jsx)(`p`,{className:`text-[11px]`,children:`Enter this code to authorize:`}),(0,Q.jsx)(`div`,{className:`font-mono text-lg tracking-widest`,children:f.userCode}),(0,Q.jsxs)(`a`,{href:f.verificationUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-primary hover:underline text-[11px]`,children:[(0,Q.jsx)(y,{className:`size-3`}),` `,f.verificationUrl]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex-1 border-t`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`or paste an API key`}),(0,Q.jsx)(`div`,{className:`flex-1 border-t`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(P,{htmlFor:`codex-api-key`,className:`text-xs`,children:`OpenAI API key`}),(0,Q.jsx)(M,{id:`codex-api-key`,type:`password`,placeholder:`sk-...`,value:i,onChange:e=>a(e.target.value),className:`text-xs font-mono`})]})]}),v&&(0,Q.jsx)(`p`,{role:`status`,className:`text-xs`,children:`Starting login...`}),p&&(0,Q.jsx)(`div`,{role:`alert`,className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:p}),(0,Q.jsxs)(O,{children:[(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsxs)(m,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,onClick:l,disabled:!i.trim()||w,children:[c?(0,Q.jsx)(s,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(o,{className:`size-3.5`}),`Add key`]})]})]})})}function ze({mode:e,onOpenChange:t,password:n,onPasswordChange:r,busy:a,onExport:o,onImport:c,error:l}){let u=(0,Z.useRef)(null),d=e===`export`;return(0,Q.jsx)(F,{open:e!==null,onOpenChange:t,children:(0,Q.jsxs)(N,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(g,{children:[(0,Q.jsxs)(L,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(z,{className:`size-4`}),` `,d?`Export Codex Accounts`:`Import Codex Accounts`]}),(0,Q.jsx)(I,{className:`text-xs leading-relaxed`,children:d?`Writes a password-encrypted file containing each account's login.`:`Reads a backup file. The password must be the one it was exported with.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(P,{htmlFor:`codex-backup-password`,className:`text-xs`,children:`Password`}),(0,Q.jsx)(M,{id:`codex-backup-password`,type:`password`,placeholder:d?`Choose a password`:`Password used for the export`,value:n,onChange:e=>r(e.target.value),className:`text-xs`,autoComplete:d?`new-password`:`current-password`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`A backup holds full logins — keep the file and its password together.`})]}),l&&(0,Q.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:l}),(0,Q.jsx)(`input`,{ref:u,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&c(t)}}),(0,Q.jsxs)(O,{children:[(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsxs)(m,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,disabled:!n.trim()||a,onClick:()=>d?o():u.current?.click(),children:[a?(0,Q.jsx)(s,{className:`size-3.5 animate-spin`}):d?(0,Q.jsx)(i,{className:`size-3.5`}):(0,Q.jsx)(E,{className:`size-3.5`}),d?`Download backup`:`Choose file`]})]})]})})}var Be=[{value:`round-robin`,label:`Round-robin`,hint:`Take the next account each time.`},{value:`fill-first`,label:`Fill-first`,hint:`Stay on one account until it runs out.`},{value:`lowest-usage`,label:`Lowest usage`,hint:`Pick whichever has the most left.`}];function Ve({open:e,onOpenChange:t,strategy:n,onChange:r}){return(0,Q.jsx)(F,{open:e,onOpenChange:t,children:(0,Q.jsxs)(N,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(g,{children:[(0,Q.jsx)(L,{className:`text-sm`,children:`Codex Rotation`}),(0,Q.jsx)(I,{className:`text-xs leading-relaxed`,children:`How a new chat chooses among your Codex accounts.`})]}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:Be.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(e.value),"aria-current":n===e.value?`true`:void 0,className:d(`w-full text-left rounded-md border px-3 py-2.5 min-h-11 cursor-pointer transition-colors`,n===e.value?`border-primary bg-primary/10`:`border-border hover:bg-accent/50 active:bg-accent`),children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.hint})]},e.value))}),(0,Q.jsx)(O,{children:(0,Q.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Done`})})]})})}function He(e){return e==null?null:Math.round(e*100)}function Ue({usage:e}){let t=e.session==null&&e.weekly==null;return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(t||e.session!=null)&&(0,Q.jsx)(ae,{label:`5-Hour Session`,pct:He(e.fiveHour),reset:fe(e.session),resetsAt:e.session?.resetsAt}),(t||e.weekly!=null)&&(0,Q.jsx)(ae,{label:`Weekly`,pct:He(e.sevenDay),reset:fe(e.weekly),resetsAt:e.weekly?.resetsAt})]})}var We=2e3,Ge=21e4;function Ke(e){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(`round-robin`),[a,o]=(0,Z.useState)({}),[s,c]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(new Set),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(``),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(``),[F,I]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(!1),[ee,z]=(0,Z.useState)(null),B=(0,Z.useRef)(null),V=(0,Z.useRef)(null),H=(0,Z.useRef)(0),U=(0,Z.useRef)(!1),W=(0,Z.useRef)(!1),G=(0,Z.useRef)(!1),K=(0,Z.useRef)(e);K.current=e;let q=(0,Z.useCallback)(async()=>{c(!0);try{let e=await l.get(`/api/codex-accounts`);n(e.accounts),i(e.strategy),l.get(`/api/codex-accounts/usage`).then(o).catch(()=>{})}finally{c(!1)}},[]);(0,Z.useEffect)(()=>{q()},[q]);let te=async()=>{if(!(!p.trim()||W.current||U.current||V.current)){W.current=!0,v(!0),b(null);try{await l.post(`/api/codex-accounts/api-key`,{apiKey:p.trim(),label:h.trim()||void 0}),m(``),g(``),e(),await q()}catch(e){b(e.message)}finally{W.current=!1,v(!1)}}},J=(0,Z.useCallback)(()=>{H.current+=1,U.current=!1,G.current=!1,B.current?.(),B.current=null;let e=V.current;V.current=null,e&&l.del(`/api/codex-accounts/${e.method}-login/${e.id}`).catch(()=>{})},[]),Y=(0,Z.useCallback)(()=>{J(),S(null),w(!1),E(null),O(!1),A(``),M(!1)},[J]),ne=(0,Z.useCallback)((e,t)=>{let n=Date.now()+(t===`browser`?61e4:Ge),r=!1,i;B.current=()=>{r=!0,clearTimeout(i)};let a=async()=>{if(r)return;let o=null;try{o=await l.get(`/api/codex-accounts/${t}-login/${e}/status`)}catch{}if(!r){if(o?.state===`done`){Y(),g(``),K.current(),await q();return}if(o?.state===`error`||Date.now()>n){Y(),b(o?.state===`error`?o.error:`${t===`browser`?`Browser`:`Device`} login timed out.`);return}i=setTimeout(a,We)}};a()},[Y,q]);(0,Z.useEffect)(()=>J,[J]);let X=async e=>{if(U.current||V.current||W.current)return;U.current=!0;let t=++H.current;O(!0),b(null);try{let n=await l.post(`/api/codex-accounts/${e}-login`,{label:h.trim()||void 0});if(t!==H.current){l.del(`/api/codex-accounts/${e}-login/${n.id}`).catch(()=>{});return}V.current={id:n.id,method:e},e===`device`?(S(n),w(!0)):E(n),ne(n.id,e)}catch(e){t===H.current&&b(e.message)}finally{t===H.current&&(U.current=!1,O(!1))}};return{accounts:t,strategy:r,usages:a,loading:s,apiKey:p,setApiKey:m,label:h,setLabel:g,adding:_,err:y,setErr:b,device:x,deviceWaiting:C,backupPassword:N,setBackupPassword:P,exporting:F,importing:L,msg:ee,setMsg:z,toggling:d,load:q,addApiKey:te,startDevice:()=>X(`device`),startBrowser:()=>X(`browser`),browser:T,loginStarting:D,callbackUrl:k,setCallbackUrl:A,submittingCallback:j,submitCallback:async()=>{let e=V.current;if(e?.method!==`browser`||!k.trim()||G.current)return;let t=H.current;G.current=!0,M(!0),b(null);let n=k.trim();A(``);try{await l.post(`/api/codex-accounts/browser-login/${e.id}/callback`,{callbackUrl:n})}catch(e){t===H.current&&b(e.message)}finally{t===H.current&&(G.current=!1,M(!1))}},cancelLogin:Y,remove:async e=>{await l.del(`/api/codex-accounts/${e}`),await q()},toggle:async(e,t)=>{let n=t===`disabled`?`active`:`disabled`;f(t=>new Set(t).add(e)),b(null);try{await l.patch(`/api/codex-accounts/${e}`,{status:n}),await q()}catch(e){b(e.message||`Could not change the account`)}finally{f(t=>{let n=new Set(t);return n.delete(e),n})}},changeStrategy:async e=>{i(e);try{await l.put(`/api/codex-accounts/strategy`,{strategy:e})}catch{}},doExport:async()=>{if(!N.trim()){b(`Set a backup password first.`);return}I(!0),b(null),z(null);try{let t={"Content-Type":`application/json`},n=u();n&&(t.Authorization=`Bearer ${n}`);let r=await fetch(`/api/codex-accounts/export`,{method:`POST`,headers:t,body:JSON.stringify({password:N})});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`Export failed: ${r.status}`)}let i=await r.text(),a=new Blob([i],{type:`application/json`}),o=document.createElement(`a`);o.href=URL.createObjectURL(a),o.download=`ppm-codex-accounts-backup.json`,o.click(),URL.revokeObjectURL(o.href),z(`Backup downloaded.`),e()}catch(e){b(e.message)}finally{I(!1)}},doImport:async t=>{if(!N.trim()){b(`Enter the backup password first.`);return}R(!0),b(null),z(null);try{let n=await t.text(),r=await l.post(`/api/codex-accounts/import`,{data:n,password:N});z(`Imported ${r.imported}${r.skipped?`, skipped ${r.skipped}`:``}.`),e(),await q()}catch(e){b(e.message)}finally{R(!1)}}}}function qe(){let[e,t]=(0,Z.useState)(null),n=Ke(()=>t(null));return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(ie,{description:(0,Q.jsxs)(Q.Fragment,{children:[`Each Codex account keeps its own login (`,(0,Q.jsx)(`code`,{children:`CODEX_HOME`}),`). One is picked per chat by the rotation setting.`]}),onRefresh:()=>void n.load(),refreshing:n.loading,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(m,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`add`),children:[(0,Q.jsx)(D,{className:`size-4`}),` Add account`]}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`export`),children:[(0,Q.jsx)(i,{className:`size-4`}),` Export`]}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`import`),children:[(0,Q.jsx)(E,{className:`size-4`}),` Import`]}),(0,Q.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`rotation`),children:[(0,Q.jsx)(x,{className:`size-4`}),` Rotation`]})]})}),(0,Q.jsx)(le,{message:n.msg??n.err,onDismiss:()=>{n.setMsg(null),n.setErr(null)}}),(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Codex Accounts`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:n.strategy.replace(`-`,` `)})]}),n.loading&&n.accounts.length===0?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(s,{className:`size-4 animate-spin`}),` Loading accounts...`]}):n.accounts.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,Q.jsx)(o,{className:`size-5 text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Codex accounts yet.`}),(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Chats use your default `,(0,Q.jsx)(`code`,{children:`~/.codex`}),` login until you add one.`]})]}):(0,Q.jsx)(ue,{children:n.accounts.map(e=>{let t=n.usages[e.id]??{};return(0,Q.jsxs)(oe,{dense:!0,className:`min-w-[300px] shrink-0 snap-start`,"data-testid":`account-card`,"data-account-id":e.id,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium truncate flex-1 min-w-0`,children:e.label}),(0,Q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1 shrink-0`,children:e.type}),e.planType&&(0,Q.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:e.planType}),(0,Q.jsx)(b,{checked:e.status!==`disabled`,onCheckedChange:()=>void n.toggle(e.id,e.status??`active`),disabled:n.toggling.has(e.id),"aria-label":e.status===`disabled`?`Enable account`:`Disable account`,className:`cursor-pointer shrink-0`}),(0,Q.jsxs)(v,{children:[(0,Q.jsx)(ee,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void n.remove(e.id),"aria-label":`Remove account`,className:`p-2 rounded cursor-pointer text-text-subtle hover:text-error hover:bg-surface-elevated transition-colors shrink-0`,children:(0,Q.jsx)(C,{className:`size-4`})})}),(0,Q.jsx)(T,{side:`top`,children:`Remove account`})]})]}),(0,Q.jsx)(Ue,{usage:t})]},e.id)})})]}),(0,Q.jsx)(Re,{open:e===`add`,onOpenChange:e=>{e||n.cancelLogin(),t(e?`add`:null)},label:n.label,onLabelChange:n.setLabel,apiKey:n.apiKey,onApiKeyChange:n.setApiKey,adding:n.adding,onAddApiKey:()=>void n.addApiKey(),deviceWaiting:n.deviceWaiting,onStartDevice:()=>void n.startDevice(),device:n.device,browser:n.browser,onStartBrowser:()=>void n.startBrowser(),loginStarting:n.loginStarting,callbackUrl:n.callbackUrl,onCallbackUrlChange:n.setCallbackUrl,submittingCallback:n.submittingCallback,onSubmitCallback:()=>void n.submitCallback(),error:n.err}),(0,Q.jsx)(ze,{mode:e===`export`?`export`:e===`import`?`import`:null,onOpenChange:e=>{e||t(null)},password:n.backupPassword,onPasswordChange:n.setBackupPassword,busy:n.exporting||n.importing,onExport:()=>void n.doExport(),onImport:e=>void n.doImport(e),error:n.err}),(0,Q.jsx)(Ve,{open:e===`rotation`,onOpenChange:e=>t(e?`rotation`:null),strategy:n.strategy,onChange:e=>void n.changeStrategy(e)})]})}var Je=[{id:`claude`,label:`Claude`},{id:`codex`,label:`Codex`}];function Ye(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(`claude`);(0,Z.useEffect)(()=>{let e=!1;return W().then(n=>{e||t(new Set(Object.keys(n.providers??{})))}).catch(()=>{e||t(new Set([`claude`]))}),()=>{e=!0}},[]);let i=Je.filter(t=>t.id===`claude`||e?.has(t.id)),a=i.length>1;return(0,Q.jsxs)(`div`,{className:`space-y-4`,"data-testid":`accounts-pane`,"data-provider":n,children:[a&&(0,Q.jsx)(`div`,{className:`flex gap-1 border-b border-border/50`,children:i.map(e=>(0,Q.jsxs)(`button`,{onClick:()=>r(e.id),"data-testid":`accounts-tab-${e.id}`,"aria-current":n===e.id?`page`:void 0,className:`flex items-center gap-1.5 px-3 py-2 text-xs rounded-t transition-colors cursor-pointer ${n===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,Q.jsx)(w,{providerId:e.id}),e.label]},e.id))}),e===null&&!a&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(s,{className:`size-3 animate-spin`}),` Checking configured providers...`]}),n===`claude`?(0,Q.jsx)(Le,{}):(0,Q.jsx)(qe,{})]})}export{Ye as AccountsSettingsSection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-BBdkypKW.js";import{t as r}from"./loader-circle-DxI3O9_f.js";import{t as i}from"./save-B1y4KIK9.js";import{s as a}from"./api-client-DwXlVfXP.js";import"./vendor-mermaid-CfY1-PkA.js";import"./settings-store-_s4xFcFq.js";import{n as o}from"./utils-IrnQujwR.js";import{F as s,Fn as c,I as l,In as u,L as d,R as f,lr as p,s as m,z as h}from"./index-DVNJ2W5R.js";import{t as g}from"./use-monaco-theme-DTPfPPvF.js";var _=e(t(),1),v=n();function y({metadata:e}){let t=e?.filePath,n=e?.name,o=e?.resourceType??`skill`,y=e?.scope??`user`,x=e?.readOnly===!0,S=e?.shadowed===!0,C=e?.shadowedBy,w=e?.project??``,[T,E]=(0,_.useState)(``),[D,O]=(0,_.useState)(``),[k,A]=(0,_.useState)(!0),[j,M]=(0,_.useState)(null),[N,P]=(0,_.useState)(!1),F=g(),I=(0,_.useRef)(``),L=T!==D;(0,_.useEffect)(()=>{let e=!1;return A(!0),M(null),f(t,w).then(t=>{e||(E(t.content),O(t.content),I.current=t.content)}).catch(t=>{e||M(t.message)}).finally(()=>{e||A(!1)}),()=>{e=!0}},[t,w]);let R=(0,_.useCallback)(async()=>{if(x||N)return;let e=I.current;if(e!==D){P(!0);try{await h(t,e,w),O(e),E(e),a.success(`Saved`),d.getState().reload()}catch(e){a.error(e.message)}finally{P(!1)}}},[t,w,D,x,N]);(0,_.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),R())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[R]);let z=l[o];return(0,v.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[(0,v.jsx)(z,{className:`size-4 text-text-subtle`}),(0,v.jsx)(`span`,{className:`text-sm font-semibold`,children:n}),(0,v.jsx)(s,{scope:y}),L&&!x&&(0,v.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary`,title:`Unsaved changes`}),(0,v.jsx)(`div`,{className:`flex-1`}),(0,v.jsxs)(`span`,{className:`hidden sm:block text-[11px] text-text-subtle`,children:[o,` · markdown`]}),!x&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`button`,{onClick:()=>E(D),disabled:!L||N,className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-text-secondary hover:bg-surface-elevated disabled:opacity-40`,children:[(0,v.jsx)(c,{className:`size-3.5`}),` Revert`]}),(0,v.jsxs)(`button`,{onClick:()=>void R(),disabled:!L||N,className:`flex items-center gap-1 rounded bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-40`,children:[N?(0,v.jsx)(r,{className:`size-3.5 animate-spin`}):(0,v.jsx)(i,{className:`size-3.5`}),` Save`]})]})]}),x&&(0,v.jsx)(b,{icon:p,tone:`muted`,children:`Bundled resource — read-only. Duplicate it (from the AI Resources panel) to make an editable copy.`}),S&&C&&(0,v.jsxs)(b,{icon:u,tone:`warn`,children:[`This `,o,` is overridden by another “`,C.name,`” from a higher-priority source (`,C.source,`). It is currently inactive.`]}),(0,v.jsx)(`div`,{className:`min-h-0 flex-1`,children:k?(0,v.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,v.jsx)(r,{className:`size-5 animate-spin text-primary`})}):j?(0,v.jsx)(`div`,{className:`p-6 text-center text-sm text-destructive`,children:j}):(0,v.jsx)(m,{height:`100%`,language:`markdown`,theme:F,value:T,onChange:e=>{let t=e??``;I.current=t,E(t)},options:{readOnly:x,minimap:{enabled:!1},fontSize:13,wordWrap:`on`,scrollBeyondLastLine:!1,lineNumbers:`on`}})})]})}function b({icon:e,tone:t,children:n}){return(0,v.jsxs)(`div`,{className:o(`flex items-start gap-2 px-3 py-2 text-[12px] shrink-0 border-b border-border`,t===`warn`?`bg-amber-500/10 text-amber-300`:`bg-surface-elevated text-text-secondary`),children:[(0,v.jsx)(e,{className:`mt-0.5 size-3.5 shrink-0`}),(0,v.jsx)(`span`,{children:n})]})}export{y as AiResourceEditor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-BBdkypKW.js";import"./api-client-DwXlVfXP.js";import"./portal-container-context-DeLx1cOI.js";import"./panel-store-D42k25jy.js";import"./window-store-CfxP5yor.js";import"./tab-store-B2ip0-Mv.js";import"./use-is-mobile-Bi42QhIi.js";import{t as e}from"./ai-settings-section-M07DCjAI.js";export{e as AISettingsSection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{S as t,x as n}from"./vendor-markdown-Ls5AcU91.js";import{n as r}from"./api-client-CEYCBt_0.js";import{B as i,Dr as a,G as o,H as s,Ln as c,M as l,U as u,V as d,W as f,X as p,Xn as m,Y as h,cn as g}from"./index-Cx1meAwb.js";import{getAISettings as _,updateAISettings as v}from"./api-settings-D18Q4Ocp.js";var y=e(t(),1),b=n(),x=[128e3,272e3,4e5,512e3,872e3,1e6],S=[1e5,2e5,23e4,35e4,45e4,75e4,9e5];function C({id:e,label:t,value:n,presets:r,disabled:i,compact:a,onChange:o}){let[s,c]=(0,y.useState)(!!n&&!r.includes(Number(n))),l=a?`text-[11px]`:`text-sm`;return(0,b.jsxs)(`div`,{className:`space-y-1`,children:[(0,b.jsx)(h,{htmlFor:e,className:l,children:t}),(0,b.jsxs)(`select`,{id:e,value:s?`custom`:n||`default`,disabled:i,"aria-describedby":`codex-context-help`,className:`w-full min-h-11 sm:min-h-0 rounded-md border border-input bg-background px-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 ${a?`h-7`:`h-9`} ${l}`,onChange:e=>{let t=e.target.value;c(t===`custom`),t!==`custom`&&o(t===`default`?``:t)},children:[(0,b.jsx)(`option`,{value:`default`,children:`Codex default`}),r.map(e=>(0,b.jsxs)(`option`,{value:String(e),children:[e===1e6?`1M`:`${e/1e3}K`,` tokens`]},e)),(0,b.jsx)(`option`,{value:`custom`,children:`Custom...`})]}),s&&(0,b.jsx)(p,{id:`${e}-custom`,"aria-label":`Custom ${t.toLowerCase()}`,type:`number`,min:1,step:1,required:!0,value:n,disabled:i,placeholder:`Enter tokens`,"aria-describedby":`codex-context-help`,className:`min-h-11 sm:min-h-0 ${a?`h-7 text-[11px]`:``}`,onChange:e=>o(e.target.value)})]})}function w({config:e,compact:t,saving:n,onSave:r}){let[i,a]=(0,y.useState)(String(e?.model_context_window??``)),[o,s]=(0,y.useState)(String(e?.model_auto_compact_token_limit??``)),[c,l]=(0,y.useState)(null),u=t?`text-[11px]`:`text-sm`,d=t?`text-[9px]`:`text-[11px]`;async function f(e){e.preventDefault();let t=i.trim()?Number(i):null,n=o.trim()?Number(o):null;if([t,n].some(e=>e!==null&&(!Number.isSafeInteger(e)||e<=0))){l(`Enter positive whole numbers of tokens, or leave blank for Codex defaults.`);return}if(t!==null&&n!==null&&n>t){l(`Auto-compact threshold must not exceed the context window.`);return}l(null),await r({model_context_window:t,model_auto_compact_token_limit:n})}return(0,b.jsxs)(`form`,{onSubmit:f,className:`space-y-2 rounded-md border border-border p-3`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,b.jsx)(C,{id:`codex-context-window`,label:`Context window (tokens)`,value:i,presets:x,disabled:n,compact:t,onChange:e=>{a(e),l(null)}}),(0,b.jsx)(C,{id:`codex-compact-threshold`,label:`Auto-compact threshold (tokens)`,value:o,presets:S,disabled:n,compact:t,onChange:e=>{s(e),l(null)}})]}),(0,b.jsx)(`p`,{id:`codex-context-help`,className:`${d} text-muted-foreground`,children:`Choose Codex default to use Codex configuration and model defaults, or Custom to enter a value. Presets are shortcuts, not a list of limits supported by your model; increasing these values does not unlock a larger context window. Applies to new sessions and sessions resumed after a PPM restart.`}),c&&(0,b.jsx)(`p`,{role:`alert`,className:`${u} text-error`,children:c}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`a`,{href:`https://learn.chatgpt.com/docs/config-file/config-reference`,target:`_blank`,rel:`noreferrer`,className:`${d} text-primary underline`,children:`Codex context documentation`}),(0,b.jsx)(`button`,{type:`submit`,disabled:n,className:`min-h-11 sm:min-h-0 rounded-md border border-border px-3 py-1.5 hover:bg-surface-elevated disabled:opacity-50 ${u}`,children:n?`Saving...`:`Save context settings`})]})]})}var T=[{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`},{value:`xhigh`,label:`Extra`},{value:`max`,label:`Max`}],E=[{value:`bypassPermissions`,label:`Bypass permissions (default)`},{value:`default`,label:`Ask before edits`},{value:`acceptEdits`,label:`Edit automatically`},{value:`plan`,label:`Plan mode`}],D={claude:`Claude`,cursor:`Cursor`,codex:`Codex`,gemini:`Gemini`};function O({compact:e}={}){let[t,n]=(0,y.useState)(null),[c,m]=(0,y.useState)(``),[x,S]=(0,y.useState)([]),[C,O]=(0,y.useState)(!1),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(null),[P,F]=(0,y.useState)(0);(0,y.useEffect)(()=>{_().then(e=>{n(e),m(e.default_provider??`claude`)}).catch(e=>N(e.message))},[]),(0,y.useEffect)(()=>{c&&(O(!0),r.get(`/api/settings/ai/providers/${c}/models`).then(S).catch(()=>S([])).finally(()=>O(!1)))},[c]);let I=t?Object.keys(t.providers).filter(e=>e!==`mock`).map(e=>({id:e,name:D[e]??e})):[],L=t?.providers[c],R=L?.type===`agent-sdk`||!L?.type&&c===`claude`,z=async e=>{if(!t)return!1;j(!0),N(null);try{return n(await v(e)),F(e=>e+1),!0}catch(e){return N(e.message),!1}finally{j(!1)}},B=(e,t)=>z({providers:{[c]:{[e]:t}}}),V=e?`text-[11px]`:`text-sm`,H=e?`text-xs`:`text-sm`,U=e?`space-y-2`:`space-y-4`,W=e?`space-y-1.5`:`space-y-3`,G=e?`space-y-1`:`space-y-1.5`;if(!t)return(0,b.jsxs)(`div`,{className:W,children:[(0,b.jsx)(`h3`,{className:`${H} font-medium text-text-secondary`,children:`AI Settings`}),(0,b.jsx)(`p`,{className:`${V} text-text-subtle`,children:M?`Error: ${M}`:`Loading...`})]});let K=R?x:[{value:`__default__`,label:`Auto (default)`},...x];return(0,b.jsxs)(`div`,{className:U,children:[(0,b.jsx)(`h3`,{className:`${H} font-medium text-text-secondary`,children:`AI Settings`}),(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border p-3`,children:[(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-share-provider-context`,className:e?V:void 0,children:`Share rules and memory between providers`}),(0,b.jsx)(`p`,{id:`ai-share-provider-context-description`,className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Share project rules and memory, plus global instruction files, across providers. Applies from the next project-chat message. Turning off keeps context already sent.`})]}),(0,b.jsx)(o,{id:`ai-share-provider-context`,"aria-describedby":`ai-share-provider-context-description`,checked:t.share_provider_context??!0,disabled:A,onCheckedChange:e=>z({share_provider_context:e})})]}),I.length>1&&(0,b.jsx)(`div`,{className:`flex gap-0.5 border-b border-border/50 -mx-1 px-1`,children:I.map(e=>(0,b.jsxs)(`button`,{onClick:()=>m(e.id),className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-t transition-colors ${c===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,b.jsx)(l,{providerId:e.id}),(0,b.jsx)(`span`,{className:`capitalize`,children:e.name})]},e.id))}),(0,b.jsxs)(`div`,{className:W,children:[c===`codex`&&(0,b.jsxs)(`button`,{type:`button`,onClick:()=>g(`accounts`),className:`w-full flex items-center justify-between gap-2 rounded-md border border-border px-2.5 py-2 text-left cursor-pointer hover:bg-surface-elevated transition-colors`,children:[(0,b.jsx)(`span`,{className:`${V} text-text-secondary`,children:`Codex accounts & login`}),(0,b.jsx)(a,{className:`size-3.5 text-text-subtle shrink-0`})]}),x.length>0&&(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-model`,className:e?V:void 0,children:`Model`}),(0,b.jsxs)(i,{value:R?L?.model??x[0]?.value:L?.model||`__default__`,onValueChange:e=>B(`model`,e===`__default__`?void 0:e),disabled:C,children:[(0,b.jsx)(u,{id:`ai-model`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,b.jsx)(f,{placeholder:C?`Loading models...`:`Select model`})}),(0,b.jsx)(d,{className:`max-h-[300px]`,children:K.map(e=>(0,b.jsx)(s,{value:e.value,children:e.label},e.value))})]})]}),c===`codex`&&(0,b.jsx)(w,{config:L,compact:e,saving:A,onSave:e=>z({providers:{codex:e}})},JSON.stringify([L?.model_context_window,L?.model_auto_compact_token_limit])),R&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-base-url`,className:e?V:void 0,children:`Base URL`}),(0,b.jsx)(p,{id:`ai-base-url`,type:`url`,defaultValue:L?.base_url??``,placeholder:`https://api.anthropic.com (default)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{B(`base_url`,e.target.value.trim()||void 0)}},`baseurl-${c}-${P}`)]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-api-key`,className:e?V:void 0,children:`API Key / Token`}),(0,b.jsx)(p,{id:`ai-api-key`,type:`password`,defaultValue:L?.api_key??``,placeholder:`sk-ant-... (optional, overrides accounts)`,className:e?`h-7 text-[11px] font-mono`:`font-mono`,onBlur:e=>{let t=e.target.value.trim();t.startsWith(`••••`)||B(`api_key`,t||void 0)}},`apikey-${c}-${P}`),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Direct API key or OAuth token. Leave empty to use connected accounts.`})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-effort`,className:e?V:void 0,children:`Effort`}),(0,b.jsxs)(i,{value:L?.effort??`high`,onValueChange:e=>B(`effort`,e),children:[(0,b.jsx)(u,{id:`ai-effort`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,b.jsx)(f,{})}),(0,b.jsx)(d,{children:T.map(e=>(0,b.jsx)(s,{value:e.value,children:e.label},e.value))})]})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-max-turns`,className:e?V:void 0,children:`Max Turns (1-500)`}),(0,b.jsx)(p,{id:`ai-max-turns`,type:`number`,min:1,max:500,defaultValue:L?.max_turns??100,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);isNaN(t)||B(`max_turns`,t)}},`turns-${c}-${P}`)]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-budget`,className:e?V:void 0,children:`Max Budget (USD)`}),(0,b.jsx)(p,{id:`ai-budget`,type:`number`,step:.1,min:.01,max:50,defaultValue:L?.max_budget_usd??``,placeholder:`No limit`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseFloat(e.target.value);B(`max_budget_usd`,isNaN(t)?void 0:t)}},`budget-${c}-${P}`)]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-thinking`,className:e?V:void 0,children:`Thinking Budget (tokens)`}),(0,b.jsx)(p,{id:`ai-thinking`,type:`number`,min:0,defaultValue:L?.thinking_budget_tokens??``,placeholder:`Adaptive (model decides)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);B(`thinking_budget_tokens`,isNaN(t)?void 0:t)}},`thinking-${c}-${P}`)]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{htmlFor:`ai-agent-teams`,className:e?V:void 0,children:`Agent Teams`}),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Experimental. Enables multi-agent collaboration with shared tasks and messaging. Uses ~7x more tokens.`})]}),(0,b.jsx)(o,{id:`ai-agent-teams`,checked:L?.agent_teams??!1,onCheckedChange:e=>B(`agent_teams`,e)})]}),L?.agent_teams&&(0,b.jsx)(k,{compact:e}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{htmlFor:`ai-context-1m`,className:e?V:void 0,children:`1M Context Window`}),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Requires an entitled account (Max/Team/Enterprise) and an Opus 4 / Sonnet 4 model. Other accounts will error.`})]}),(0,b.jsx)(o,{id:`ai-context-1m`,checked:L?.context_1m??!1,onCheckedChange:e=>B(`context_1m`,e)})]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{htmlFor:`ai-inherit-mcp`,className:e?V:void 0,children:`Inherit Claude Code MCP`}),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Auto-load MCP servers from Claude Code's ~/.claude.json (global + per-project). Your own MCP servers override inherited ones.`})]}),(0,b.jsx)(o,{id:`ai-inherit-mcp`,checked:L?.inherit_claude_mcp??!0,onCheckedChange:e=>B(`inherit_claude_mcp`,e)})]})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-permission-mode`,className:e?V:void 0,children:`Default Permission Mode`}),(0,b.jsxs)(i,{value:L?.permission_mode??`bypassPermissions`,onValueChange:e=>B(`permission_mode`,e),children:[(0,b.jsx)(u,{id:`ai-permission-mode`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,b.jsx)(f,{})}),(0,b.jsx)(d,{children:E.map(e=>(0,b.jsx)(s,{value:e.value,children:e.label},e.value))})]})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-system-prompt`,className:e?V:void 0,children:`Additional Instructions`}),(0,b.jsx)(`textarea`,{id:`ai-system-prompt`,rows:e?3:4,defaultValue:L?.system_prompt??``,placeholder:`Enter additional instructions for ${c}...`,className:`w-full rounded-md border border-input bg-background px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${e?`text-[11px]`:`text-sm`}`,onBlur:e=>{B(`system_prompt`,e.target.value.trim()||void 0)}},`sysprompt-${c}-${P}`)]})]}),A&&(0,b.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Saving...`}),M&&(0,b.jsx)(`p`,{className:`text-xs text-error`,children:M})]})}function k({compact:e}){let[t,n]=(0,y.useState)([]),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(null),l=(0,y.useCallback)(async()=>{a(!0);try{n(await r.get(`/api/teams`)??[])}catch{}a(!1)},[]);(0,y.useEffect)(()=>{l()},[l]);let u=async e=>{try{await r.del(`/api/teams/${encodeURIComponent(e)}`),n(t=>t.filter(t=>t.name!==e)),s(null)}catch{}};return t.length===0&&!i?null:(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsxs)(h,{className:e?`text-[11px]`:void 0,children:[`Teams (`,t.length,`)`]}),(0,b.jsx)(`button`,{onClick:l,className:`text-text-subtle hover:text-foreground p-1`,"aria-label":`Refresh teams`,children:(0,b.jsx)(m,{className:`size-3 ${i?`animate-spin`:``}`})})]}),t.map(e=>(0,b.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded bg-surface-elevated text-xs`,children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`font-medium truncate`,children:e.name}),e.description&&(0,b.jsx)(`div`,{className:`text-text-subtle truncate`,children:e.description}),(0,b.jsxs)(`div`,{className:`text-text-subtle`,children:[e.members?.length??e.memberCount??0,` members`,e.createdAt?` · ${new Date(e.createdAt).toLocaleDateString()}`:``]})]}),o===e.name?(0,b.jsxs)(`div`,{className:`flex gap-1 shrink-0 ml-2`,children:[(0,b.jsx)(`button`,{onClick:()=>u(e.name),className:`px-2 py-1 bg-error text-white rounded text-[10px]`,children:`Delete`}),(0,b.jsx)(`button`,{onClick:()=>s(null),className:`px-2 py-1 bg-panel-2 text-text rounded text-[10px]`,children:`Cancel`})]}):(0,b.jsx)(`button`,{onClick:()=>s(e.name),className:`shrink-0 text-text-subtle hover:text-error p-1 ml-2`,"aria-label":`Delete team ${e.name}`,children:(0,b.jsx)(c,{className:`size-3.5`})})]},e.name))]})}export{O as t};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import{n as r}from"./api-client-DwXlVfXP.js";import{B as i,Dr as a,G as o,H as s,Ln as c,M as l,U as u,V as d,W as f,X as p,Xn as m,Y as h,cn as g}from"./index-DVNJ2W5R.js";import{getAISettings as _,updateAISettings as v}from"./api-settings-BQIwZoLm.js";var y=e(t(),1),b=n(),x=[128e3,272e3,4e5,512e3,872e3,1e6],S=[1e5,2e5,23e4,35e4,45e4,75e4,9e5];function C({id:e,label:t,value:n,presets:r,disabled:i,compact:a,onChange:o}){let[s,c]=(0,y.useState)(!!n&&!r.includes(Number(n))),l=a?`text-[11px]`:`text-sm`;return(0,b.jsxs)(`div`,{className:`space-y-1`,children:[(0,b.jsx)(h,{htmlFor:e,className:l,children:t}),(0,b.jsxs)(`select`,{id:e,value:s?`custom`:n||`default`,disabled:i,"aria-describedby":`codex-context-help`,className:`w-full min-h-11 sm:min-h-0 rounded-md border border-input bg-background px-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 ${a?`h-7`:`h-9`} ${l}`,onChange:e=>{let t=e.target.value;c(t===`custom`),t!==`custom`&&o(t===`default`?``:t)},children:[(0,b.jsx)(`option`,{value:`default`,children:`Codex default`}),r.map(e=>(0,b.jsxs)(`option`,{value:String(e),children:[e===1e6?`1M`:`${e/1e3}K`,` tokens`]},e)),(0,b.jsx)(`option`,{value:`custom`,children:`Custom...`})]}),s&&(0,b.jsx)(p,{id:`${e}-custom`,"aria-label":`Custom ${t.toLowerCase()}`,type:`number`,min:1,step:1,required:!0,value:n,disabled:i,placeholder:`Enter tokens`,"aria-describedby":`codex-context-help`,className:`min-h-11 sm:min-h-0 ${a?`h-7 text-[11px]`:``}`,onChange:e=>o(e.target.value)})]})}function w({config:e,compact:t,saving:n,onSave:r}){let[i,a]=(0,y.useState)(String(e?.model_context_window??``)),[o,s]=(0,y.useState)(String(e?.model_auto_compact_token_limit??``)),[c,l]=(0,y.useState)(null),u=t?`text-[11px]`:`text-sm`,d=t?`text-[9px]`:`text-[11px]`;async function f(e){e.preventDefault();let t=i.trim()?Number(i):null,n=o.trim()?Number(o):null;if([t,n].some(e=>e!==null&&(!Number.isSafeInteger(e)||e<=0))){l(`Enter positive whole numbers of tokens, or leave blank for Codex defaults.`);return}if(t!==null&&n!==null&&n>t){l(`Auto-compact threshold must not exceed the context window.`);return}l(null),await r({model_context_window:t,model_auto_compact_token_limit:n})}return(0,b.jsxs)(`form`,{onSubmit:f,className:`space-y-2 rounded-md border border-border p-3`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,b.jsx)(C,{id:`codex-context-window`,label:`Context window (tokens)`,value:i,presets:x,disabled:n,compact:t,onChange:e=>{a(e),l(null)}}),(0,b.jsx)(C,{id:`codex-compact-threshold`,label:`Auto-compact threshold (tokens)`,value:o,presets:S,disabled:n,compact:t,onChange:e=>{s(e),l(null)}})]}),(0,b.jsx)(`p`,{id:`codex-context-help`,className:`${d} text-muted-foreground`,children:`Choose Codex default to use Codex configuration and model defaults, or Custom to enter a value. Presets are shortcuts, not a list of limits supported by your model; increasing these values does not unlock a larger context window. Applies to new sessions and sessions resumed after a PPM restart.`}),c&&(0,b.jsx)(`p`,{role:`alert`,className:`${u} text-error`,children:c}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`a`,{href:`https://learn.chatgpt.com/docs/config-file/config-reference`,target:`_blank`,rel:`noreferrer`,className:`${d} text-primary underline`,children:`Codex context documentation`}),(0,b.jsx)(`button`,{type:`submit`,disabled:n,className:`min-h-11 sm:min-h-0 rounded-md border border-border px-3 py-1.5 hover:bg-surface-elevated disabled:opacity-50 ${u}`,children:n?`Saving...`:`Save context settings`})]})]})}var T=[{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`},{value:`xhigh`,label:`Extra`},{value:`max`,label:`Max`}],E=[{value:`bypassPermissions`,label:`Bypass permissions (default)`},{value:`default`,label:`Ask before edits`},{value:`acceptEdits`,label:`Edit automatically`},{value:`plan`,label:`Plan mode`}],D={claude:`Claude`,cursor:`Cursor`,codex:`Codex`,gemini:`Gemini`};function O({compact:e}={}){let[t,n]=(0,y.useState)(null),[c,m]=(0,y.useState)(``),[x,S]=(0,y.useState)([]),[C,O]=(0,y.useState)(!1),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(null),[P,F]=(0,y.useState)(0);(0,y.useEffect)(()=>{_().then(e=>{n(e),m(e.default_provider??`claude`)}).catch(e=>N(e.message))},[]),(0,y.useEffect)(()=>{c&&(O(!0),r.get(`/api/settings/ai/providers/${c}/models`).then(S).catch(()=>S([])).finally(()=>O(!1)))},[c]);let I=t?Object.keys(t.providers).filter(e=>e!==`mock`).map(e=>({id:e,name:D[e]??e})):[],L=t?.providers[c],R=L?.type===`agent-sdk`||!L?.type&&c===`claude`,z=async e=>{if(!t)return!1;j(!0),N(null);try{return n(await v(e)),F(e=>e+1),!0}catch(e){return N(e.message),!1}finally{j(!1)}},B=(e,t)=>z({providers:{[c]:{[e]:t}}}),V=e?`text-[11px]`:`text-sm`,H=e?`text-xs`:`text-sm`,U=e?`space-y-2`:`space-y-4`,W=e?`space-y-1.5`:`space-y-3`,G=e?`space-y-1`:`space-y-1.5`;if(!t)return(0,b.jsxs)(`div`,{className:W,children:[(0,b.jsx)(`h3`,{className:`${H} font-medium text-text-secondary`,children:`AI Settings`}),(0,b.jsx)(`p`,{className:`${V} text-text-subtle`,children:M?`Error: ${M}`:`Loading...`})]});let K=R?x:[{value:`__default__`,label:`Auto (default)`},...x];return(0,b.jsxs)(`div`,{className:U,children:[(0,b.jsx)(`h3`,{className:`${H} font-medium text-text-secondary`,children:`AI Settings`}),(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border p-3`,children:[(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-share-provider-context`,className:e?V:void 0,children:`Share rules and memory between providers`}),(0,b.jsx)(`p`,{id:`ai-share-provider-context-description`,className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Share project rules and memory, plus global instruction files, across providers. Applies from the next project-chat message. Turning off keeps context already sent.`})]}),(0,b.jsx)(o,{id:`ai-share-provider-context`,"aria-describedby":`ai-share-provider-context-description`,checked:t.share_provider_context??!0,disabled:A,onCheckedChange:e=>z({share_provider_context:e})})]}),I.length>1&&(0,b.jsx)(`div`,{className:`flex gap-0.5 border-b border-border/50 -mx-1 px-1`,children:I.map(e=>(0,b.jsxs)(`button`,{onClick:()=>m(e.id),className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-t transition-colors ${c===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,b.jsx)(l,{providerId:e.id}),(0,b.jsx)(`span`,{className:`capitalize`,children:e.name})]},e.id))}),(0,b.jsxs)(`div`,{className:W,children:[c===`codex`&&(0,b.jsxs)(`button`,{type:`button`,onClick:()=>g(`accounts`),className:`w-full flex items-center justify-between gap-2 rounded-md border border-border px-2.5 py-2 text-left cursor-pointer hover:bg-surface-elevated transition-colors`,children:[(0,b.jsx)(`span`,{className:`${V} text-text-secondary`,children:`Codex accounts & login`}),(0,b.jsx)(a,{className:`size-3.5 text-text-subtle shrink-0`})]}),x.length>0&&(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-model`,className:e?V:void 0,children:`Model`}),(0,b.jsxs)(i,{value:R?L?.model??x[0]?.value:L?.model||`__default__`,onValueChange:e=>B(`model`,e===`__default__`?void 0:e),disabled:C,children:[(0,b.jsx)(u,{id:`ai-model`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,b.jsx)(f,{placeholder:C?`Loading models...`:`Select model`})}),(0,b.jsx)(d,{className:`max-h-[300px]`,children:K.map(e=>(0,b.jsx)(s,{value:e.value,children:e.label},e.value))})]})]}),c===`codex`&&(0,b.jsx)(w,{config:L,compact:e,saving:A,onSave:e=>z({providers:{codex:e}})},JSON.stringify([L?.model_context_window,L?.model_auto_compact_token_limit])),R&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-base-url`,className:e?V:void 0,children:`Base URL`}),(0,b.jsx)(p,{id:`ai-base-url`,type:`url`,defaultValue:L?.base_url??``,placeholder:`https://api.anthropic.com (default)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{B(`base_url`,e.target.value.trim()||void 0)}},`baseurl-${c}-${P}`)]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-api-key`,className:e?V:void 0,children:`API Key / Token`}),(0,b.jsx)(p,{id:`ai-api-key`,type:`password`,defaultValue:L?.api_key??``,placeholder:`sk-ant-... (optional, overrides accounts)`,className:e?`h-7 text-[11px] font-mono`:`font-mono`,onBlur:e=>{let t=e.target.value.trim();t.startsWith(`••••`)||B(`api_key`,t||void 0)}},`apikey-${c}-${P}`),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Direct API key or OAuth token. Leave empty to use connected accounts.`})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-effort`,className:e?V:void 0,children:`Effort`}),(0,b.jsxs)(i,{value:L?.effort??`high`,onValueChange:e=>B(`effort`,e),children:[(0,b.jsx)(u,{id:`ai-effort`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,b.jsx)(f,{})}),(0,b.jsx)(d,{children:T.map(e=>(0,b.jsx)(s,{value:e.value,children:e.label},e.value))})]})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-max-turns`,className:e?V:void 0,children:`Max Turns (1-500)`}),(0,b.jsx)(p,{id:`ai-max-turns`,type:`number`,min:1,max:500,defaultValue:L?.max_turns??100,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);isNaN(t)||B(`max_turns`,t)}},`turns-${c}-${P}`)]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-budget`,className:e?V:void 0,children:`Max Budget (USD)`}),(0,b.jsx)(p,{id:`ai-budget`,type:`number`,step:.1,min:.01,max:50,defaultValue:L?.max_budget_usd??``,placeholder:`No limit`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseFloat(e.target.value);B(`max_budget_usd`,isNaN(t)?void 0:t)}},`budget-${c}-${P}`)]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-thinking`,className:e?V:void 0,children:`Thinking Budget (tokens)`}),(0,b.jsx)(p,{id:`ai-thinking`,type:`number`,min:0,defaultValue:L?.thinking_budget_tokens??``,placeholder:`Adaptive (model decides)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);B(`thinking_budget_tokens`,isNaN(t)?void 0:t)}},`thinking-${c}-${P}`)]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{htmlFor:`ai-agent-teams`,className:e?V:void 0,children:`Agent Teams`}),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Experimental. Enables multi-agent collaboration with shared tasks and messaging. Uses ~7x more tokens.`})]}),(0,b.jsx)(o,{id:`ai-agent-teams`,checked:L?.agent_teams??!1,onCheckedChange:e=>B(`agent_teams`,e)})]}),L?.agent_teams&&(0,b.jsx)(k,{compact:e}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{htmlFor:`ai-context-1m`,className:e?V:void 0,children:`1M Context Window`}),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Requires an entitled account (Max/Team/Enterprise) and an Opus 4 / Sonnet 4 model. Other accounts will error.`})]}),(0,b.jsx)(o,{id:`ai-context-1m`,checked:L?.context_1m??!1,onCheckedChange:e=>B(`context_1m`,e)})]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{htmlFor:`ai-inherit-mcp`,className:e?V:void 0,children:`Inherit Claude Code MCP`}),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Auto-load MCP servers from Claude Code's ~/.claude.json (global + per-project). Your own MCP servers override inherited ones.`})]}),(0,b.jsx)(o,{id:`ai-inherit-mcp`,checked:L?.inherit_claude_mcp??!0,onCheckedChange:e=>B(`inherit_claude_mcp`,e)})]})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-permission-mode`,className:e?V:void 0,children:`Default Permission Mode`}),(0,b.jsxs)(i,{value:L?.permission_mode??`bypassPermissions`,onValueChange:e=>B(`permission_mode`,e),children:[(0,b.jsx)(u,{id:`ai-permission-mode`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,b.jsx)(f,{})}),(0,b.jsx)(d,{children:E.map(e=>(0,b.jsx)(s,{value:e.value,children:e.label},e.value))})]})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(h,{htmlFor:`ai-system-prompt`,className:e?V:void 0,children:`Additional Instructions`}),(0,b.jsx)(`textarea`,{id:`ai-system-prompt`,rows:e?3:4,defaultValue:L?.system_prompt??``,placeholder:`Enter additional instructions for ${c}...`,className:`w-full rounded-md border border-input bg-background px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${e?`text-[11px]`:`text-sm`}`,onBlur:e=>{B(`system_prompt`,e.target.value.trim()||void 0)}},`sysprompt-${c}-${P}`)]})]}),A&&(0,b.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Saving...`}),M&&(0,b.jsx)(`p`,{className:`text-xs text-error`,children:M})]})}function k({compact:e}){let[t,n]=(0,y.useState)([]),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(null),l=(0,y.useCallback)(async()=>{a(!0);try{n(await r.get(`/api/teams`)??[])}catch{}a(!1)},[]);(0,y.useEffect)(()=>{l()},[l]);let u=async e=>{try{await r.del(`/api/teams/${encodeURIComponent(e)}`),n(t=>t.filter(t=>t.name!==e)),s(null)}catch{}};return t.length===0&&!i?null:(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsxs)(h,{className:e?`text-[11px]`:void 0,children:[`Teams (`,t.length,`)`]}),(0,b.jsx)(`button`,{onClick:l,className:`text-text-subtle hover:text-foreground p-1`,"aria-label":`Refresh teams`,children:(0,b.jsx)(m,{className:`size-3 ${i?`animate-spin`:``}`})})]}),t.map(e=>(0,b.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded bg-surface-elevated text-xs`,children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`font-medium truncate`,children:e.name}),e.description&&(0,b.jsx)(`div`,{className:`text-text-subtle truncate`,children:e.description}),(0,b.jsxs)(`div`,{className:`text-text-subtle`,children:[e.members?.length??e.memberCount??0,` members`,e.createdAt?` · ${new Date(e.createdAt).toLocaleDateString()}`:``]})]}),o===e.name?(0,b.jsxs)(`div`,{className:`flex gap-1 shrink-0 ml-2`,children:[(0,b.jsx)(`button`,{onClick:()=>u(e.name),className:`px-2 py-1 bg-error text-white rounded text-[10px]`,children:`Delete`}),(0,b.jsx)(`button`,{onClick:()=>s(null),className:`px-2 py-1 bg-panel-2 text-text rounded text-[10px]`,children:`Cancel`})]}):(0,b.jsx)(`button`,{onClick:()=>s(e.name),className:`shrink-0 text-text-subtle hover:text-error p-1 ml-2`,"aria-label":`Delete team ${e.name}`,children:(0,b.jsx)(c,{className:`size-3.5`})})]},e.name))]})}export{O as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-BBdkypKW.js";import{i as e,n as t}from"./api-client-DwXlVfXP.js";export{t as api,e as projectUrl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{S as t}from"./vendor-markdown-Ls5AcU91.js";import{ft as n}from"./vendor-ui-CaeeFO0B.js";var r=e(t(),1),i=e(n(),1);function a(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var o=e=>{switch(e){case`success`:return ee;case`info`:return u;case`warning`:return l;case`error`:return d;default:return null}},s=Array(12).fill(0),c=({visible:e,className:t})=>r.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},r.createElement(`div`,{className:`sonner-spinner`},s.map((e,t)=>r.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),ee=r.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},r.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),l=r.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},r.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),u=r.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},r.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),d=r.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},r.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),f=r.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},r.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),r.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),te=()=>{let[e,t]=r.useState(document.hidden);return r.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},p=1,m=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:p++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let i=Promise.resolve(e instanceof Function?e():e),a=n!==void 0,o,s=i.then(async e=>{if(o=[`resolve`,e],r.isValidElement(e))a=!1,this.create({id:n,type:`default`,message:e});else if(g(e)&&!e.ok){a=!1;let i=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,o=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,s=typeof i==`object`&&!r.isValidElement(i)?i:{message:i};this.create({id:n,type:`error`,description:o,...s})}else if(e instanceof Error){a=!1;let i=typeof t.error==`function`?await t.error(e):t.error,o=typeof t.description==`function`?await t.description(e):t.description,s=typeof i==`object`&&!r.isValidElement(i)?i:{message:i};this.create({id:n,type:`error`,description:o,...s})}else if(t.success!==void 0){a=!1;let i=typeof t.success==`function`?await t.success(e):t.success,o=typeof t.description==`function`?await t.description(e):t.description,s=typeof i==`object`&&!r.isValidElement(i)?i:{message:i};this.create({id:n,type:`success`,description:o,...s})}}).catch(async e=>{if(o=[`reject`,e],t.error!==void 0){a=!1;let i=typeof t.error==`function`?await t.error(e):t.error,o=typeof t.description==`function`?await t.description(e):t.description,s=typeof i==`object`&&!r.isValidElement(i)?i:{message:i};this.create({id:n,type:`error`,description:o,...s})}}).finally(()=>{a&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),c=()=>new Promise((e,t)=>s.then(()=>o[0]===`reject`?t(o[1]):e(o[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:c}:Object.assign(n,{unwrap:c})},this.custom=(e,t)=>{let n=t?.id||p++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},h=(e,t)=>{let n=t?.id||p++;return m.addToast({title:e,...t,id:n}),n},g=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,_=h,v=Object.assign(_,{success:m.success,info:m.info,warning:m.warning,error:m.error,custom:m.custom,message:m.message,promise:m.promise,dismiss:m.dismiss,loading:m.loading},{getHistory:()=>m.toasts,getToasts:()=>m.getActiveToasts()});a(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function y(e){return e.label!==void 0}var ne=3,b=`24px`,x=`16px`,S=4e3,C=356,w=14,T=45,E=200;function D(...e){return e.filter(Boolean).join(` `)}function O(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var re=e=>{let{invert:t,toast:n,unstyled:i,interacting:a,setHeights:s,visibleToasts:ee,heights:l,index:u,toasts:d,expanded:p,removeToast:m,defaultRichColors:h,closeButton:g,style:_,cancelButtonStyle:v,actionButtonStyle:ne,className:b=``,descriptionClassName:x=``,duration:C,position:w,gap:re,expandByDefault:k,classNames:A,icons:j,closeButtonAriaLabel:M=`Close toast`}=e,[N,P]=r.useState(null),[F,I]=r.useState(null),[L,R]=r.useState(!1),[z,B]=r.useState(!1),[V,H]=r.useState(!1),[U,ie]=r.useState(!1),[ae,oe]=r.useState(!1),[se,W]=r.useState(0),[ce,le]=r.useState(0),G=r.useRef(n.duration||C||S),ue=r.useRef(null),K=r.useRef(null),de=u===0,fe=u+1<=ee,q=n.type,J=n.dismissible!==!1,pe=n.className||``,me=n.descriptionClassName||``,Y=r.useMemo(()=>l.findIndex(e=>e.toastId===n.id)||0,[l,n.id]),he=r.useMemo(()=>n.closeButton??g,[n.closeButton,g]),ge=r.useMemo(()=>n.duration||C||S,[n.duration,C]),X=r.useRef(0),Z=r.useRef(0),_e=r.useRef(0),Q=r.useRef(null),[ve,ye]=w.split(`-`),be=r.useMemo(()=>l.reduce((e,t,n)=>n>=Y?e:e+t.height,0),[l,Y]),xe=te(),Se=n.invert||t,Ce=q===`loading`;Z.current=r.useMemo(()=>Y*re+be,[Y,be]),r.useEffect(()=>{G.current=ge},[ge]),r.useEffect(()=>{R(!0)},[]),r.useEffect(()=>{let e=K.current;if(e){let t=e.getBoundingClientRect().height;return le(t),s(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>s(e=>e.filter(e=>e.toastId!==n.id))}},[s,n.id]),r.useLayoutEffect(()=>{if(!L)return;let e=K.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,le(r),s(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[L,n.title,n.description,s,n.id,n.jsx,n.action,n.cancel]);let $=r.useCallback(()=>{B(!0),W(Z.current),s(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{m(n)},E)},[n,m,s,Z]);r.useEffect(()=>{if(n.promise&&q===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return p||a||xe?(()=>{if(_e.current<X.current){let e=new Date().getTime()-X.current;G.current-=e}_e.current=new Date().getTime()})():G.current!==1/0&&(X.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),$()},G.current)),()=>clearTimeout(e)},[p,a,n,q,xe,$]),r.useEffect(()=>{n.delete&&($(),n.onDismiss==null||n.onDismiss.call(n,n))},[$,n.delete]);function we(){return j?.loading?r.createElement(`div`,{className:D(A?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":q===`loading`},j.loading):r.createElement(c,{className:D(A?.loader,n?.classNames?.loader),visible:q===`loading`})}let Te=n.icon||j?.[q]||o(q);return r.createElement(`li`,{tabIndex:0,ref:K,className:D(b,pe,A?.toast,n?.classNames?.toast,A?.default,A?.[q],n?.classNames?.[q]),"data-sonner-toast":``,"data-rich-colors":n.richColors??h,"data-styled":!(n.jsx||n.unstyled||i),"data-mounted":L,"data-promise":!!n.promise,"data-swiped":ae,"data-removed":z,"data-visible":fe,"data-y-position":ve,"data-x-position":ye,"data-index":u,"data-front":de,"data-swiping":V,"data-dismissible":J,"data-type":q,"data-invert":Se,"data-swipe-out":U,"data-swipe-direction":F,"data-expanded":!!(p||k&&L),"data-testid":n.testId,style:{"--index":u,"--toasts-before":u,"--z-index":d.length-u,"--offset":`${z?se:Z.current}px`,"--initial-height":k?`auto`:`${ce}px`,..._,...n.style},onDragEnd:()=>{H(!1),P(null),Q.current=null},onPointerDown:e=>{e.button!==2&&(Ce||!J||(ue.current=new Date,W(Z.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(H(!0),Q.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(U||!J)return;Q.current=null;let e=Number(K.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(K.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-ue.current?.getTime(),i=N===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=T||a>.11){W(Z.current),n.onDismiss==null||n.onDismiss.call(n,n),I(N===`x`?e>0?`right`:`left`:t>0?`down`:`up`),$(),ie(!0);return}else{var o,s;(o=K.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=K.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}oe(!1),H(!1),P(null)},onPointerMove:t=>{var n,r;if(!Q.current||!J||window.getSelection()?.toString().length>0)return;let i=t.clientY-Q.current.y,a=t.clientX-Q.current.x,o=e.swipeDirections??O(w);!N&&(Math.abs(a)>1||Math.abs(i)>1)&&P(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(N===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(N===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&oe(!0),(n=K.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=K.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},he&&!n.jsx&&q!==`loading`?r.createElement(`button`,{"aria-label":M,"data-disabled":Ce,"data-close-button":!0,onClick:Ce||!J?()=>{}:()=>{$(),n.onDismiss==null||n.onDismiss.call(n,n)},className:D(A?.closeButton,n?.classNames?.closeButton)},j?.close??f):null,(q||n.icon||n.promise)&&n.icon!==null&&(j?.[q]!==null||n.icon)?r.createElement(`div`,{"data-icon":``,className:D(A?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||we():null,n.type===`loading`?null:Te):null,r.createElement(`div`,{"data-content":``,className:D(A?.content,n?.classNames?.content)},r.createElement(`div`,{"data-title":``,className:D(A?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?r.createElement(`div`,{"data-description":``,className:D(x,me,A?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),r.isValidElement(n.cancel)?n.cancel:n.cancel&&y(n.cancel)?r.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||v,onClick:e=>{y(n.cancel)&&J&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),$())},className:D(A?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,r.isValidElement(n.action)?n.action:n.action&&y(n.action)?r.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||ne,onClick:e=>{y(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&$())},className:D(A?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function k(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function A(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?x:b;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var j=r.forwardRef(function(e,t){let{id:n,invert:a,position:o=`bottom-right`,hotkey:s=[`altKey`,`KeyT`],expand:c,closeButton:ee,className:l,offset:u,mobileOffset:d,theme:f=`light`,richColors:te,duration:p,style:h,visibleToasts:g=ne,toastOptions:_,dir:v=k(),gap:y=w,icons:b,containerAriaLabel:x=`Notifications`}=e,[S,T]=r.useState([]),E=r.useMemo(()=>n?S.filter(e=>e.toasterId===n):S.filter(e=>!e.toasterId),[S,n]),D=r.useMemo(()=>Array.from(new Set([o].concat(E.filter(e=>e.position).map(e=>e.position)))),[E,o]),[O,j]=r.useState([]),[M,N]=r.useState(!1),[P,F]=r.useState(!1),[I,L]=r.useState(f===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:f),R=r.useRef(null),z=s.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),B=r.useRef(null),V=r.useRef(!1),H=r.useCallback(e=>{T(t=>(t.find(t=>t.id===e.id)?.delete||m.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return r.useEffect(()=>m.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{T(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{i.flushSync(()=>{T(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[S]),r.useEffect(()=>{if(f!==`system`){L(f);return}if(f===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?L(`dark`):L(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{L(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{L(e?`dark`:`light`)}catch(e){console.error(e)}})}},[f]),r.useEffect(()=>{S.length<=1&&N(!1)},[S]),r.useEffect(()=>{let e=e=>{if(s.every(t=>e[t]||e.code===t)){var t;N(!0),(t=R.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===R.current||R.current?.contains(document.activeElement))&&N(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[s]),r.useEffect(()=>{if(R.current)return()=>{B.current&&(B.current.focus({preventScroll:!0}),B.current=null,V.current=!1)}},[R.current]),r.createElement(`section`,{ref:t,"aria-label":`${x} ${z}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},D.map((t,n)=>{let[i,o]=t.split(`-`);return E.length?r.createElement(`ol`,{key:t,dir:v===`auto`?k():v,tabIndex:-1,ref:R,className:l,"data-sonner-toaster":!0,"data-sonner-theme":I,"data-y-position":i,"data-x-position":o,style:{"--front-toast-height":`${O[0]?.height||0}px`,"--width":`${C}px`,"--gap":`${y}px`,...h,...A(u,d)},onBlur:e=>{V.current&&!e.currentTarget.contains(e.relatedTarget)&&(V.current=!1,B.current&&=(B.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||V.current||(V.current=!0,B.current=e.relatedTarget)},onMouseEnter:()=>N(!0),onMouseMove:()=>N(!0),onMouseLeave:()=>{P||N(!1)},onDragEnd:()=>N(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||F(!0)},onPointerUp:()=>F(!1)},E.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>r.createElement(re,{key:n.id,icons:b,index:i,toast:n,defaultRichColors:te,duration:_?.duration??p,className:_?.className,descriptionClassName:_?.descriptionClassName,invert:a,visibleToasts:g,closeButton:_?.closeButton??ee,interacting:P,position:t,style:_?.style,unstyled:_?.unstyled,classNames:_?.classNames,cancelButtonStyle:_?.cancelButtonStyle,actionButtonStyle:_?.actionButtonStyle,closeButtonAriaLabel:_?.closeButtonAriaLabel,removeToast:H,toasts:E.filter(e=>e.position==n.position),heights:O.filter(e=>e.position==n.position),setHeights:j,expandByDefault:c,gap:y,expanded:M,swipeDirections:e.swipeDirections}))):null}))}),M=`ppm-auth-token`,N=`ppm-auth-reload-ts`,P=!1;function F(e){let t=e.headers.get(`x-ppm-audit-error`);!t||P||(P=!0,v.error(`Query audit log is not recording`,{description:t}))}var I=new Map,L=3e4;function R(e){return e.reason??new DOMException(`Aborted`,`AbortError`)}var z=class{baseUrl;responseTimeoutMs;constructor(e=``,t=L){this.baseUrl=e,this.responseTimeoutMs=t}getToken(){return localStorage.getItem(M)}headers(){let e={"Content-Type":`application/json`},t=this.getToken();return t&&(e.Authorization=`Bearer ${t}`),e[`x-ppm-client`]=`web`,e}get(e,t){if(t?.signal)return this.rawGet(e,t.signal);let n=`${this.baseUrl}${e}`,r=I.get(n);if(r&&Date.now()-r.startedAt<this.responseTimeoutMs)return r.promise;let i=this.rawGet(e).finally(()=>{I.get(n)?.promise===i&&I.delete(n)});return I.set(n,{promise:i,startedAt:Date.now()}),i}async rawGet(e,t){if(t?.aborted)throw R(t);let n=new AbortController,r=setTimeout(()=>n.abort(new DOMException(`No response after ${this.responseTimeoutMs}ms: ${e}`,`TimeoutError`)),this.responseTimeoutMs),i=()=>n.abort(R(t));t?.addEventListener(`abort`,i,{once:!0});try{let t=await fetch(`${this.baseUrl}${e}`,{headers:this.headers(),signal:n.signal});return clearTimeout(r),await this.handleResponse(t)}finally{clearTimeout(r),t?.removeEventListener(`abort`,i)}}async post(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`POST`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});return this.handleResponse(n)}async put(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`PUT`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});return this.handleResponse(n)}async patch(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`PATCH`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});return this.handleResponse(n)}async del(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`DELETE`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});await this.handleResponse(n)}async handleResponse(e){if(F(e),e.status===401){localStorage.removeItem(M);let e=Number(sessionStorage.getItem(N)||`0`);throw Date.now()-e>3e3&&(sessionStorage.setItem(N,String(Date.now())),window.location.reload()),Error(`Unauthorized`)}let t;try{t=await e.json()}catch{throw Error(e.ok?`Empty response from server`:`Server error (HTTP ${e.status})`)}if(t.ok===!1)throw Error(t.error??`HTTP ${e.status}`);return t.data}},B=new z;function V(e){return`/api/project/${encodeURIComponent(e)}`}function H(e){localStorage.setItem(M,e)}function U(){return localStorage.getItem(M)}export{H as a,V as i,B as n,j as o,U as r,v as s,z as t};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t}from"./vendor-markdown-CuWCHIVb.js";import{ft as n}from"./vendor-ui-BBdkypKW.js";var r=e(t(),1),i=e(n(),1);function a(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var o=e=>{switch(e){case`success`:return ee;case`info`:return u;case`warning`:return l;case`error`:return d;default:return null}},s=Array(12).fill(0),c=({visible:e,className:t})=>r.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},r.createElement(`div`,{className:`sonner-spinner`},s.map((e,t)=>r.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),ee=r.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},r.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),l=r.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},r.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),u=r.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},r.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),d=r.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},r.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),f=r.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},r.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),r.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),te=()=>{let[e,t]=r.useState(document.hidden);return r.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},p=1,m=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:p++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let i=Promise.resolve(e instanceof Function?e():e),a=n!==void 0,o,s=i.then(async e=>{if(o=[`resolve`,e],r.isValidElement(e))a=!1,this.create({id:n,type:`default`,message:e});else if(g(e)&&!e.ok){a=!1;let i=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,o=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,s=typeof i==`object`&&!r.isValidElement(i)?i:{message:i};this.create({id:n,type:`error`,description:o,...s})}else if(e instanceof Error){a=!1;let i=typeof t.error==`function`?await t.error(e):t.error,o=typeof t.description==`function`?await t.description(e):t.description,s=typeof i==`object`&&!r.isValidElement(i)?i:{message:i};this.create({id:n,type:`error`,description:o,...s})}else if(t.success!==void 0){a=!1;let i=typeof t.success==`function`?await t.success(e):t.success,o=typeof t.description==`function`?await t.description(e):t.description,s=typeof i==`object`&&!r.isValidElement(i)?i:{message:i};this.create({id:n,type:`success`,description:o,...s})}}).catch(async e=>{if(o=[`reject`,e],t.error!==void 0){a=!1;let i=typeof t.error==`function`?await t.error(e):t.error,o=typeof t.description==`function`?await t.description(e):t.description,s=typeof i==`object`&&!r.isValidElement(i)?i:{message:i};this.create({id:n,type:`error`,description:o,...s})}}).finally(()=>{a&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),c=()=>new Promise((e,t)=>s.then(()=>o[0]===`reject`?t(o[1]):e(o[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:c}:Object.assign(n,{unwrap:c})},this.custom=(e,t)=>{let n=t?.id||p++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},h=(e,t)=>{let n=t?.id||p++;return m.addToast({title:e,...t,id:n}),n},g=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,_=h,v=Object.assign(_,{success:m.success,info:m.info,warning:m.warning,error:m.error,custom:m.custom,message:m.message,promise:m.promise,dismiss:m.dismiss,loading:m.loading},{getHistory:()=>m.toasts,getToasts:()=>m.getActiveToasts()});a(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function y(e){return e.label!==void 0}var ne=3,b=`24px`,x=`16px`,S=4e3,C=356,w=14,T=45,E=200;function D(...e){return e.filter(Boolean).join(` `)}function O(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var re=e=>{let{invert:t,toast:n,unstyled:i,interacting:a,setHeights:s,visibleToasts:ee,heights:l,index:u,toasts:d,expanded:p,removeToast:m,defaultRichColors:h,closeButton:g,style:_,cancelButtonStyle:v,actionButtonStyle:ne,className:b=``,descriptionClassName:x=``,duration:C,position:w,gap:re,expandByDefault:k,classNames:A,icons:j,closeButtonAriaLabel:M=`Close toast`}=e,[N,P]=r.useState(null),[F,I]=r.useState(null),[L,R]=r.useState(!1),[z,B]=r.useState(!1),[V,H]=r.useState(!1),[U,ie]=r.useState(!1),[ae,oe]=r.useState(!1),[se,W]=r.useState(0),[ce,le]=r.useState(0),G=r.useRef(n.duration||C||S),ue=r.useRef(null),K=r.useRef(null),de=u===0,fe=u+1<=ee,q=n.type,J=n.dismissible!==!1,pe=n.className||``,me=n.descriptionClassName||``,Y=r.useMemo(()=>l.findIndex(e=>e.toastId===n.id)||0,[l,n.id]),he=r.useMemo(()=>n.closeButton??g,[n.closeButton,g]),ge=r.useMemo(()=>n.duration||C||S,[n.duration,C]),X=r.useRef(0),Z=r.useRef(0),_e=r.useRef(0),Q=r.useRef(null),[ve,ye]=w.split(`-`),be=r.useMemo(()=>l.reduce((e,t,n)=>n>=Y?e:e+t.height,0),[l,Y]),xe=te(),Se=n.invert||t,Ce=q===`loading`;Z.current=r.useMemo(()=>Y*re+be,[Y,be]),r.useEffect(()=>{G.current=ge},[ge]),r.useEffect(()=>{R(!0)},[]),r.useEffect(()=>{let e=K.current;if(e){let t=e.getBoundingClientRect().height;return le(t),s(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>s(e=>e.filter(e=>e.toastId!==n.id))}},[s,n.id]),r.useLayoutEffect(()=>{if(!L)return;let e=K.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,le(r),s(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[L,n.title,n.description,s,n.id,n.jsx,n.action,n.cancel]);let $=r.useCallback(()=>{B(!0),W(Z.current),s(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{m(n)},E)},[n,m,s,Z]);r.useEffect(()=>{if(n.promise&&q===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return p||a||xe?(()=>{if(_e.current<X.current){let e=new Date().getTime()-X.current;G.current-=e}_e.current=new Date().getTime()})():G.current!==1/0&&(X.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),$()},G.current)),()=>clearTimeout(e)},[p,a,n,q,xe,$]),r.useEffect(()=>{n.delete&&($(),n.onDismiss==null||n.onDismiss.call(n,n))},[$,n.delete]);function we(){return j?.loading?r.createElement(`div`,{className:D(A?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":q===`loading`},j.loading):r.createElement(c,{className:D(A?.loader,n?.classNames?.loader),visible:q===`loading`})}let Te=n.icon||j?.[q]||o(q);return r.createElement(`li`,{tabIndex:0,ref:K,className:D(b,pe,A?.toast,n?.classNames?.toast,A?.default,A?.[q],n?.classNames?.[q]),"data-sonner-toast":``,"data-rich-colors":n.richColors??h,"data-styled":!(n.jsx||n.unstyled||i),"data-mounted":L,"data-promise":!!n.promise,"data-swiped":ae,"data-removed":z,"data-visible":fe,"data-y-position":ve,"data-x-position":ye,"data-index":u,"data-front":de,"data-swiping":V,"data-dismissible":J,"data-type":q,"data-invert":Se,"data-swipe-out":U,"data-swipe-direction":F,"data-expanded":!!(p||k&&L),"data-testid":n.testId,style:{"--index":u,"--toasts-before":u,"--z-index":d.length-u,"--offset":`${z?se:Z.current}px`,"--initial-height":k?`auto`:`${ce}px`,..._,...n.style},onDragEnd:()=>{H(!1),P(null),Q.current=null},onPointerDown:e=>{e.button!==2&&(Ce||!J||(ue.current=new Date,W(Z.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(H(!0),Q.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(U||!J)return;Q.current=null;let e=Number(K.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(K.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-ue.current?.getTime(),i=N===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=T||a>.11){W(Z.current),n.onDismiss==null||n.onDismiss.call(n,n),I(N===`x`?e>0?`right`:`left`:t>0?`down`:`up`),$(),ie(!0);return}else{var o,s;(o=K.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=K.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}oe(!1),H(!1),P(null)},onPointerMove:t=>{var n,r;if(!Q.current||!J||window.getSelection()?.toString().length>0)return;let i=t.clientY-Q.current.y,a=t.clientX-Q.current.x,o=e.swipeDirections??O(w);!N&&(Math.abs(a)>1||Math.abs(i)>1)&&P(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(N===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(N===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&oe(!0),(n=K.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=K.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},he&&!n.jsx&&q!==`loading`?r.createElement(`button`,{"aria-label":M,"data-disabled":Ce,"data-close-button":!0,onClick:Ce||!J?()=>{}:()=>{$(),n.onDismiss==null||n.onDismiss.call(n,n)},className:D(A?.closeButton,n?.classNames?.closeButton)},j?.close??f):null,(q||n.icon||n.promise)&&n.icon!==null&&(j?.[q]!==null||n.icon)?r.createElement(`div`,{"data-icon":``,className:D(A?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||we():null,n.type===`loading`?null:Te):null,r.createElement(`div`,{"data-content":``,className:D(A?.content,n?.classNames?.content)},r.createElement(`div`,{"data-title":``,className:D(A?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?r.createElement(`div`,{"data-description":``,className:D(x,me,A?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),r.isValidElement(n.cancel)?n.cancel:n.cancel&&y(n.cancel)?r.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||v,onClick:e=>{y(n.cancel)&&J&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),$())},className:D(A?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,r.isValidElement(n.action)?n.action:n.action&&y(n.action)?r.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||ne,onClick:e=>{y(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&$())},className:D(A?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function k(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function A(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?x:b;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var j=r.forwardRef(function(e,t){let{id:n,invert:a,position:o=`bottom-right`,hotkey:s=[`altKey`,`KeyT`],expand:c,closeButton:ee,className:l,offset:u,mobileOffset:d,theme:f=`light`,richColors:te,duration:p,style:h,visibleToasts:g=ne,toastOptions:_,dir:v=k(),gap:y=w,icons:b,containerAriaLabel:x=`Notifications`}=e,[S,T]=r.useState([]),E=r.useMemo(()=>n?S.filter(e=>e.toasterId===n):S.filter(e=>!e.toasterId),[S,n]),D=r.useMemo(()=>Array.from(new Set([o].concat(E.filter(e=>e.position).map(e=>e.position)))),[E,o]),[O,j]=r.useState([]),[M,N]=r.useState(!1),[P,F]=r.useState(!1),[I,L]=r.useState(f===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:f),R=r.useRef(null),z=s.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),B=r.useRef(null),V=r.useRef(!1),H=r.useCallback(e=>{T(t=>(t.find(t=>t.id===e.id)?.delete||m.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return r.useEffect(()=>m.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{T(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{i.flushSync(()=>{T(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[S]),r.useEffect(()=>{if(f!==`system`){L(f);return}if(f===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?L(`dark`):L(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{L(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{L(e?`dark`:`light`)}catch(e){console.error(e)}})}},[f]),r.useEffect(()=>{S.length<=1&&N(!1)},[S]),r.useEffect(()=>{let e=e=>{if(s.every(t=>e[t]||e.code===t)){var t;N(!0),(t=R.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===R.current||R.current?.contains(document.activeElement))&&N(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[s]),r.useEffect(()=>{if(R.current)return()=>{B.current&&(B.current.focus({preventScroll:!0}),B.current=null,V.current=!1)}},[R.current]),r.createElement(`section`,{ref:t,"aria-label":`${x} ${z}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},D.map((t,n)=>{let[i,o]=t.split(`-`);return E.length?r.createElement(`ol`,{key:t,dir:v===`auto`?k():v,tabIndex:-1,ref:R,className:l,"data-sonner-toaster":!0,"data-sonner-theme":I,"data-y-position":i,"data-x-position":o,style:{"--front-toast-height":`${O[0]?.height||0}px`,"--width":`${C}px`,"--gap":`${y}px`,...h,...A(u,d)},onBlur:e=>{V.current&&!e.currentTarget.contains(e.relatedTarget)&&(V.current=!1,B.current&&=(B.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||V.current||(V.current=!0,B.current=e.relatedTarget)},onMouseEnter:()=>N(!0),onMouseMove:()=>N(!0),onMouseLeave:()=>{P||N(!1)},onDragEnd:()=>N(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||F(!0)},onPointerUp:()=>F(!1)},E.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>r.createElement(re,{key:n.id,icons:b,index:i,toast:n,defaultRichColors:te,duration:_?.duration??p,className:_?.className,descriptionClassName:_?.descriptionClassName,invert:a,visibleToasts:g,closeButton:_?.closeButton??ee,interacting:P,position:t,style:_?.style,unstyled:_?.unstyled,classNames:_?.classNames,cancelButtonStyle:_?.cancelButtonStyle,actionButtonStyle:_?.actionButtonStyle,closeButtonAriaLabel:_?.closeButtonAriaLabel,removeToast:H,toasts:E.filter(e=>e.position==n.position),heights:O.filter(e=>e.position==n.position),setHeights:j,expandByDefault:c,gap:y,expanded:M,swipeDirections:e.swipeDirections}))):null}))}),M=`ppm-auth-token`,N=`ppm-auth-reload-ts`,P=!1;function F(e){let t=e.headers.get(`x-ppm-audit-error`);!t||P||(P=!0,v.error(`Query audit log is not recording`,{description:t}))}var I=new Map,L=3e4;function R(e){return e.reason??new DOMException(`Aborted`,`AbortError`)}var z=class{baseUrl;responseTimeoutMs;constructor(e=``,t=L){this.baseUrl=e,this.responseTimeoutMs=t}getToken(){return localStorage.getItem(M)}headers(){let e={"Content-Type":`application/json`},t=this.getToken();return t&&(e.Authorization=`Bearer ${t}`),e[`x-ppm-client`]=`web`,e}get(e,t){if(t?.signal)return this.rawGet(e,t.signal);let n=`${this.baseUrl}${e}`,r=I.get(n);if(r&&Date.now()-r.startedAt<this.responseTimeoutMs)return r.promise;let i=this.rawGet(e).finally(()=>{I.get(n)?.promise===i&&I.delete(n)});return I.set(n,{promise:i,startedAt:Date.now()}),i}async rawGet(e,t){if(t?.aborted)throw R(t);let n=new AbortController,r=setTimeout(()=>n.abort(new DOMException(`No response after ${this.responseTimeoutMs}ms: ${e}`,`TimeoutError`)),this.responseTimeoutMs),i=()=>n.abort(R(t));t?.addEventListener(`abort`,i,{once:!0});try{let t=await fetch(`${this.baseUrl}${e}`,{headers:this.headers(),signal:n.signal});return clearTimeout(r),await this.handleResponse(t)}finally{clearTimeout(r),t?.removeEventListener(`abort`,i)}}async post(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`POST`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});return this.handleResponse(n)}async put(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`PUT`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});return this.handleResponse(n)}async patch(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`PATCH`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});return this.handleResponse(n)}async del(e,t){let n=await fetch(`${this.baseUrl}${e}`,{method:`DELETE`,headers:this.headers(),body:t==null?void 0:JSON.stringify(t)});await this.handleResponse(n)}async handleResponse(e){if(F(e),e.status===401){localStorage.removeItem(M);let e=Number(sessionStorage.getItem(N)||`0`);throw Date.now()-e>3e3&&(sessionStorage.setItem(N,String(Date.now())),window.location.reload()),Error(`Unauthorized`)}let t;try{t=await e.json()}catch{throw Error(e.ok?`Empty response from server`:`Server error (HTTP ${e.status})`)}if(t.ok===!1)throw Error(t.error??`HTTP ${e.status}`);return t.data}},B=new z;function V(e){return`/api/project/${encodeURIComponent(e)}`}function H(e){localStorage.setItem(M,e)}function U(){return localStorage.getItem(M)}export{H as a,V as i,B as n,j as o,U as r,v as s,z as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./vendor-markdown-
|
|
1
|
+
import"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-BBdkypKW.js";import{n as e}from"./api-client-DwXlVfXP.js";function t(){return e.get(`/api/accounts`)}function n(){return e.get(`/api/accounts/active`)}function r(t){let n=t===`codex`?`/api/codex-accounts/pick`:`/api/accounts/pick`;return e.post(n)}function i(t){return e.post(`/api/accounts`,t)}function a(t){return e.del(`/api/accounts/${t}`)}function o(t,n){return e.patch(`/api/accounts/${t}`,n)}function s(){return e.get(`/api/accounts/settings`)}function c(t){return e.put(`/api/accounts/settings`,t)}function l(){return e.get(`/api/accounts/oauth/url`)}function u(t,n){return e.post(`/api/accounts/oauth/exchange`,{code:t,state:n})}function d(){return e.get(`/api/accounts/usage`)}function f(t){return e.get(`/api/accounts/${t}/usage-history`)}function p(t){return e.post(`/api/accounts/import`,t)}function m(t,n=!1){return e.post(`/api/accounts/${t}/test-token`,{testRefresh:n})}function h(t,n=!1){return e.post(`/api/accounts/test-export`,{accountIds:t,includeRefreshToken:n})}function g(t){return e.post(`/api/accounts/test-raw-token`,{token:t})}function _(t){return e.put(`/api/settings/device-name`,{device_name:t})}function v(){return e.get(`/api/settings/ai`)}function y(t){return e.put(`/api/settings/ai`,t)}function b(){return e.get(`/api/settings/proxy`)}function x(t){return e.put(`/api/settings/proxy`,t)}function S(){return e.get(`/api/settings/query-audit`)}function C(t){return e.put(`/api/settings/query-audit`,t)}function w(){return e.del(`/api/settings/query-audit/logs`)}export{i as addAccount,w as clearQueryAuditLogs,a as deleteAccount,u as exchangeOAuthCode,v as getAISettings,s as getAccountSettings,t as getAccounts,n as getActiveAccount,d as getAllAccountUsages,l as getOAuthUrl,b as getProxySettings,S as getQueryAuditSettings,f as getUsageHistory,p as importAccounts,o as patchAccount,r as pickAccountForTab,m as testAccountToken,h as testExport,g as testRawToken,y as updateAISettings,c as updateAccountSettings,_ as updateDeviceName,x as updateProxySettings,C as updateQueryAuditSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./vendor-markdown-
|
|
1
|
+
import"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-BBdkypKW.js";import{r as e}from"./api-client-DwXlVfXP.js";function t(t=!1){let n=e();return{...t?{"Content-Type":`application/json`}:{},...n?{Authorization:`Bearer ${n}`}:{}}}async function n(e){let t=await e.json();if(!t.ok)throw Error(t.error||`Request failed (${e.status})`);return t.data}async function r(){return n(await fetch(`/api/settings/themes`,{headers:t()}))}async function i(e){return(await n(await fetch(`/api/settings/themes`,{method:`POST`,headers:t(!0),body:JSON.stringify(e)}))).themes}async function a(e){await n(await fetch(`/api/settings/themes/${encodeURIComponent(e)}`,{method:`DELETE`,headers:t()}))}export{a as deleteImportedTheme,r as fetchImportedThemes,i as importTheme};
|