@p4code/cli 0.8.28 → 0.8.30
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/dist/bin.mjs +1 -1
- package/dist/{binCli-CTh3xknE.mjs → binCli-Cooida2i.mjs} +314 -45
- package/dist/client/.vite/manifest.json +2218 -2218
- package/dist/client/assets/AlertDialogRoot-BSccQInP.js +2 -0
- package/dist/client/assets/{AnimatedHeight-xpLZZo3s.js → AnimatedHeight-N_bbjpO0.js} +2 -2
- package/dist/client/assets/{AuthSurfaceShell-D_hzy5by.js → AuthSurfaceShell-L4KCu0zC.js} +2 -2
- package/dist/client/assets/{CSPContext-BOMhNaNg.js → CSPContext-Bchqn4Z4.js} +2 -2
- package/dist/client/assets/{ChatGptUsageButton-B7IBN3Pq.js → ChatGptUsageButton-B21SbJHE.js} +2 -2
- package/dist/client/assets/{ChatMarkdown-6bkZ78vO.js → ChatMarkdown-COLD-67i.js} +4 -4
- package/dist/client/assets/{CheckboxIndicator-CtJqB7ns.js → CheckboxIndicator-C27GMhZi.js} +2 -2
- package/dist/client/assets/{ClippedText-DoAq5p0h.js → ClippedText-gxEyECp8.js} +2 -2
- package/dist/client/assets/{CodexSetupSection.logic-87IQTLRa.js → CodexSetupSection.logic-CJCh_zEq.js} +2 -2
- package/dist/client/assets/{ComboboxClear-gWUoU_9i.js → ComboboxClear-BU2zssbU.js} +2 -2
- package/dist/client/assets/{ComboboxGroupLabel-PqwekxYO.js → ComboboxGroupLabel-BOqTaS8V.js} +2 -2
- package/dist/client/assets/{CommandBlock-DXCZ6paN.js → CommandBlock-D1183EsF.js} +2 -2
- package/dist/client/assets/{ComposerPromptEditor-DZ-YKnMe.js → ComposerPromptEditor-C7KfkOgy.js} +4 -4
- package/dist/client/assets/{CompositeRoot-DXqEvNI3.js → CompositeRoot-DHfFZgBC.js} +2 -2
- package/dist/client/assets/{ConnectionStatusDot-DsDhJub7.js → ConnectionStatusDot-BzysNXvb.js} +2 -2
- package/dist/client/assets/{DesignPageTile-6OCPIqLU.js → DesignPageTile-BVOnXVkp.js} +2 -2
- package/dist/client/assets/{DevicePanel-CECEStbX.js → DevicePanel-DEh_qYd7.js} +2 -2
- package/dist/client/assets/{DeviceSetup-Ck1EofY9.js → DeviceSetup-BBZsR8Fr.js} +2 -2
- package/dist/client/assets/{DialogTitle-B_iSZXaO.js → DialogTitle-4VgvC45v.js} +2 -2
- package/dist/client/assets/{DiffCommentAnnotation-CvI2pBnS.js → DiffCommentAnnotation-CvbXZNlU.js} +2 -2
- package/dist/client/assets/{DiffFileTree-DbLr5IWH.js → DiffFileTree-gkpPNo7_.js} +2 -2
- package/dist/client/assets/{DiffPanel-Cq1eltuZ.js → DiffPanel-DA_D61VA.js} +2 -2
- package/dist/client/assets/{DiffWorkerPoolProvider-KQyWsi6k.js → DiffWorkerPoolProvider-CcVX0fG8.js} +2 -2
- package/dist/client/assets/EmbeddedDesign-BW14Z5y6.css +1 -0
- package/dist/client/assets/{EmbeddedDesign-DhM04pU7.js → EmbeddedDesign-sMURcLNz.js} +5 -5
- package/dist/client/assets/{EnvironmentMachineIcon-CmWYXtho.js → EnvironmentMachineIcon-Brb19vmz.js} +2 -2
- package/dist/client/assets/{ExpandableText-BgfA9yOq.js → ExpandableText-XtyFV-c_.js} +2 -2
- package/dist/client/assets/{FieldControl-D-HuGl-Y.js → FieldControl-wrjTWyrJ.js} +2 -2
- package/dist/client/assets/{FileDiff-CNttiWtf.js → FileDiff-sronKAp6.js} +2 -2
- package/dist/client/assets/{FilePreviewPanel-CGicpbOo.js → FilePreviewPanel-Cg0DUTIc.js} +2 -2
- package/dist/client/assets/{FoldedSettingsSection-BTPWwXUE.js → FoldedSettingsSection-DLuEPKAY.js} +2 -2
- package/dist/client/assets/{FormContext-D41axClw.js → FormContext-Coi3SJqc.js} +2 -2
- package/dist/client/assets/{Icons-bbJxtd49.js → Icons-Cq5M4QzB.js} +2 -2
- package/dist/client/assets/Input-Ffzotn9J.js +2 -0
- package/dist/client/assets/{KeybindingsSettings.logic-DbRWYCku.js → KeybindingsSettings.logic-6i6ZOa5z.js} +2 -2
- package/dist/client/assets/{NoProjectsHero-kyhQJSgF.js → NoProjectsHero--ql7uYBo.js} +2 -2
- package/dist/client/assets/{P4ConnectAccountPages-DRIMCs7k.js → P4ConnectAccountPages-TDsNzYfw.js} +2 -2
- package/dist/client/assets/{P4ConnectSidebarSignIn-C-ZetXUN.js → P4ConnectSidebarSignIn-Be8vdGVo.js} +2 -2
- package/dist/client/assets/{PanelLayoutControls-D9ZXss-X.js → PanelLayoutControls-Zu0oFRG7.js} +4 -4
- package/dist/client/assets/{PierreEntryIcon-B803YO8_.js → PierreEntryIcon-DqgAhwer.js} +2 -2
- package/dist/client/assets/{PopoverHandle-BUkWn6lX.js → PopoverHandle-CCHSPl9b.js} +2 -2
- package/dist/client/assets/{PreviewPanel-BziiiQxi.js → PreviewPanel-DD08ThG_.js} +2 -2
- package/dist/client/assets/{ProjectDefaultsSettings-xYQqDWRw.js → ProjectDefaultsSettings-D5t2KKCw.js} +2 -2
- package/dist/client/assets/{ProjectFavicon-BxL9C_zZ.js → ProjectFavicon-XFulTNXp.js} +3 -3
- package/dist/client/assets/{ProjectIconPickerDialog-gjdCKD85.js → ProjectIconPickerDialog-DM3GblS-.js} +2 -2
- package/dist/client/assets/{ProjectMonogram-C1SBXbLc.js → ProjectMonogram-B-2KfzJL.js} +2 -2
- package/dist/client/assets/{ProviderAuthTerminal-BdqGbrD-.js → ProviderAuthTerminal-mVsUo8Ok.js} +2 -2
- package/dist/client/assets/{ProviderModelPicker-BFOGSdmh.js → ProviderModelPicker-CjKl9oQ-.js} +2 -2
- package/dist/client/assets/{ProviderSettingsForm-BJzj9wl2.js → ProviderSettingsForm-CwEIvYik.js} +2 -2
- package/dist/client/assets/{PullRequestCodeTab-C8muv3ss.js → PullRequestCodeTab-jmI464nD.js} +2 -2
- package/dist/client/assets/{ReadOnlySourcePreview-CnJC2otA.js → ReadOnlySourcePreview-CUkA-v00.js} +2 -2
- package/dist/client/assets/{RenderErrorBoundary-CWP7Ykmu.js → RenderErrorBoundary-BJO0bU4D.js} +2 -2
- package/dist/client/assets/{ScheduledTasksSettings-B2-ZEorL.js → ScheduledTasksSettings-Bo3enXkz.js} +2 -2
- package/dist/client/assets/{ScopedSwitch-BX-fVWkE.js → ScopedSwitch-DDdBuLUs.js} +2 -2
- package/dist/client/assets/{ScrollAreaCorner-CpFtD7m1.js → ScrollAreaCorner-BIznaLk6.js} +2 -2
- package/dist/client/assets/{SecretInput-aXfqfjLk.js → SecretInput-C79TLohk.js} +2 -2
- package/dist/client/assets/{SelectScrollUpArrow-CMpd0Jm1.js → SelectScrollUpArrow-Cfi9Iziv.js} +2 -2
- package/dist/client/assets/{SettingsPanels-BDtXSbdD.js → SettingsPanels-C8MjaaUL.js} +2 -2
- package/dist/client/assets/{SettingsPanels.logic-OCadp8dD.js → SettingsPanels.logic-B09Pir8b.js} +2 -2
- package/dist/client/assets/{SettingsScopeNotice-Dajn79Bg.js → SettingsScopeNotice-DaeJ72Sg.js} +2 -2
- package/dist/client/assets/{ThemeEditorPanel-DXEV7Ie_.js → ThemeEditorPanel-DGjhhTBp.js} +2 -2
- package/dist/client/assets/{ThreadTerminalDrawer-aFQnCwrV.js → ThreadTerminalDrawer-BCmoxK35.js} +2 -2
- package/dist/client/assets/{TooltipViewport-BkvH9Kzg.js → TooltipViewport-DdG9rZd5.js} +2 -2
- package/dist/client/assets/{Virtualizer-DMRRdqR9.js → Virtualizer-CMZ8oKl8.js} +2 -2
- package/dist/client/assets/{WorkspaceBreadcrumb-DnyZiGsn.js → WorkspaceBreadcrumb-CALMpobe.js} +2 -2
- package/dist/client/assets/{WorkspacePageContainer-OhHg0688.js → WorkspacePageContainer-CiVT-7R2.js} +2 -2
- package/dist/client/assets/{WorkspacePageHeader-BUVfTGMv.js → WorkspacePageHeader-FKxEatch.js} +2 -2
- package/dist/client/assets/_chat-ocHzUdt4.js +46 -0
- package/dist/client/assets/{_chat.design-DWI-MLY7.js → _chat.design-DefqRI5s.js} +2 -2
- package/dist/client/assets/{_chat.index-CIbURiJU.js → _chat.index-D1VIhVyN.js} +2 -2
- package/dist/client/assets/{_chat.new-DkERK7Ju.js → _chat.new-s73MjdcS.js} +2 -2
- package/dist/client/assets/{_chat.pull-requests-BXkli2jv.js → _chat.pull-requests-Dql98L0y.js} +2 -2
- package/dist/client/assets/{abnfDiagram-VCTEODGH-ByXKIMIJ.js → abnfDiagram-VCTEODGH-DOxyvKcj.js} +2 -2
- package/dist/client/assets/{alert-D4hu_q2y.js → alert-61HmGaFS.js} +2 -2
- package/dist/client/assets/architecture-7GRP2DOG-ysaew9I_.js +1 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-CRs8AN1Y.js → architectureDiagram-5GKGNRK7-BctmlYSC.js} +2 -2
- package/dist/client/assets/{assets-BNBTdYNP.js → assets-iK4uYKwc.js} +2 -2
- package/dist/client/assets/{blockDiagram-I7D4REHJ-ilgACMM3.js → blockDiagram-I7D4REHJ-BKFiQmnb.js} +2 -2
- package/dist/client/assets/{browserHistoryStore-BX8E7ldD.js → browserHistoryStore-DlzJXSKq.js} +2 -2
- package/dist/client/assets/{browserLinkTarget-D3eCixJp.js → browserLinkTarget-oSUpd8wQ.js} +2 -2
- package/dist/client/assets/{c4Diagram-7LVT6UL2-Bwq3-L7P.js → c4Diagram-7LVT6UL2-B70VTQfy.js} +2 -2
- package/dist/client/assets/channel-Bf9bE7pb.js +2 -0
- package/dist/client/assets/{checkbox-PYOAN-IL.js → checkbox-CmtFeke_.js} +2 -2
- package/dist/client/assets/{chunk-4HAMMTFA-C4jNDShb.js → chunk-4HAMMTFA-imJi1uCM.js} +2 -2
- package/dist/client/assets/{chunk-75Z2AOVW-L1wmF_KI.js → chunk-75Z2AOVW-spGKNxlj.js} +2 -2
- package/dist/client/assets/{chunk-DU6HZSFF-BfZ5xWy3.js → chunk-DU6HZSFF-D9Oe_OOK.js} +2 -2
- package/dist/client/assets/{chunk-F27PBJKO-BkacPGLC.js → chunk-F27PBJKO-DDzU0TfB.js} +2 -2
- package/dist/client/assets/{chunk-GMAD6QVW-oeSYhMBo.js → chunk-GMAD6QVW-Bcz6gC85.js} +2 -2
- package/dist/client/assets/{chunk-GVQU2GXP-BuEWFnig.js → chunk-GVQU2GXP-CuIoweM2.js} +2 -2
- package/dist/client/assets/{chunk-IMKFNOWR-DD3QIg9Y.js → chunk-IMKFNOWR-02Cjgq5Q.js} +2 -2
- package/dist/client/assets/{chunk-L3NEJ4N5-z7EX83WR.js → chunk-L3NEJ4N5-sRngugRI.js} +2 -2
- package/dist/client/assets/{chunk-OSK3NFVY-DHZoeWxe.js → chunk-OSK3NFVY-D3jqOQjD.js} +2 -2
- package/dist/client/assets/{chunk-P2QGCYS3-CoY88v85.js → chunk-P2QGCYS3-Cd2kxI0m.js} +2 -2
- package/dist/client/assets/{chunk-POPQ4Y6H-C0LoWsGT.js → chunk-POPQ4Y6H-BeSVf2al.js} +2 -2
- package/dist/client/assets/{chunk-PWAF6VOD-D56FBahr.js → chunk-PWAF6VOD-efmX-v-S.js} +2 -2
- package/dist/client/assets/{chunk-SHT3W25Y-DV5FTtwQ.js → chunk-SHT3W25Y-BMiQYW29.js} +2 -2
- package/dist/client/assets/{chunk-SVP7TREG-8Re3q7oh.js → chunk-SVP7TREG-CfX4pY_6.js} +2 -2
- package/dist/client/assets/{chunk-TICWLB2K-Cf6JQRsk.js → chunk-TICWLB2K-xdVZ_elt.js} +2 -2
- package/dist/client/assets/classDiagram-ZZMXUADV-CA9aes1k.js +2 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-CA9aes1k.js +2 -0
- package/dist/client/assets/{color-picker-D4_JMCD4.js → color-picker-ChpGy00s.js} +2 -2
- package/dist/client/assets/{combobox-CJgXDxx7.js → combobox-Ch68LcDn.js} +2 -2
- package/dist/client/assets/{command-Bdd9mlwd.js → command-BrqzJdSJ.js} +2 -2
- package/dist/client/assets/{composer-logic-qo_WCoOG.js → composer-logic-CK986CSK.js} +2 -2
- package/dist/client/assets/{composerDraftUploads-V25cFF6x.js → composerDraftUploads-DV9ZXU0p.js} +2 -2
- package/dist/client/assets/{connect-xS5TNxN6.js → connect-DKpzmLkR.js} +2 -2
- package/dist/client/assets/{connect-agent-BxzfRNpE.js → connect-agent-DmJGMHuC.js} +2 -2
- package/dist/client/assets/{cynefin-OW5HDTMX-IIXmP-nN.js → cynefin-OW5HDTMX-C6wpDaSw.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-BcJM9-A6.js → cynefinDiagram-5FMLGOSQ-Cyhz3teD.js} +2 -2
- package/dist/client/assets/{dagre-GXQ25YYZ-DdHQMvS3.js → dagre-GXQ25YYZ-DFuahlPH.js} +2 -2
- package/dist/client/assets/{design-BJ2IVJXi.js → design-D45RcRXQ.js} +2 -2
- package/dist/client/assets/{device-B5UHgye_.js → device-54tUUHFz.js} +2 -2
- package/dist/client/assets/{diagram-S7CK7UJ4-CryZrud_.js → diagram-S7CK7UJ4-DkQ5Nu3q.js} +2 -2
- package/dist/client/assets/{diagram-UQ7AKVKN-BAERLSjk.js → diagram-UQ7AKVKN-NPAFPHeY.js} +2 -2
- package/dist/client/assets/{diagram-VSXAHHWV-BFezrcB9.js → diagram-VSXAHHWV-P9_NuIzp.js} +2 -2
- package/dist/client/assets/{diagram-VX7I27RA-C_DPu9hN.js → diagram-VX7I27RA-Bnnz-s76.js} +2 -2
- package/dist/client/assets/{diagram-Z3DM3KII-gf1HXqDh.js → diagram-Z3DM3KII-BS7qriIW.js} +2 -2
- package/dist/client/assets/{dialog-Bdi4gsq5.js → dialog-C-AXHdu2.js} +2 -2
- package/dist/client/assets/{diffRendering-BZVYVxSb.js → diffRendering-Mcle0sHL.js} +2 -2
- package/dist/client/assets/{discovery-list-CPLxz_C8.js → discovery-list-BLwegNxU.js} +2 -2
- package/dist/client/assets/{dist-C4dEfrtE.js → dist-DK5rhVDA.js} +3 -3
- package/dist/client/assets/{draft-input-CmGR2Zc1.js → draft-input-f9kP93zT.js} +2 -2
- package/dist/client/assets/{duoViewer-BSJbAeAM.js → duoViewer-7g-IzaNr.js} +2 -2
- package/dist/client/assets/{dynamic-BwDInrZk.js → dynamic-DLb-_cnk.js} +2 -2
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-DOa1Oxoi.js → ebnfDiagram-PWID7BFC-CuI7Wl4c.js} +2 -2
- package/dist/client/assets/{embeddedScripts-B6n6Rzsw.js → embeddedScripts-C_cF8pai.js} +2 -2
- package/dist/client/assets/{empty-DeLw5x6B.js → empty-BGBD5hOV.js} +2 -2
- package/dist/client/assets/{entities-f_LpWDGP.js → entities-mGmdXIiN.js} +2 -2
- package/dist/client/assets/{erDiagram-RLTQ6QDP-BOgY2RsW.js → erDiagram-RLTQ6QDP-CmaHuxo6.js} +2 -2
- package/dist/client/assets/eventmodeling-NTZA5JFV-CSjnlB84.js +1 -0
- package/dist/client/assets/{fileLinks-C5feST6o.js → fileLinks-Bc6Li7BF.js} +2 -2
- package/dist/client/assets/{fileTreeExpansion-4McmDYkr.js → fileTreeExpansion-BNb2UZXf.js} +2 -2
- package/dist/client/assets/flowDiagram-HODETNUW-CIiIEzKT.js +1 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-DHANnqYy.js → ganttDiagram-EL5Y4UJY-BJfJCbDD.js} +2 -2
- package/dist/client/assets/{getDiffFileInput-DjHqn-Tb.js → getDiffFileInput-CsHzJEX9.js} +2 -2
- package/dist/client/assets/{gitGraph-4MIJSDKK-B1wP1IDj.js → gitGraph-4MIJSDKK-DHTy7jS5.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-odn00pH9.js → gitGraphDiagram-WWUBYQGX-CN5_jsjk.js} +2 -2
- package/dist/client/assets/{guideRunStore-BuXFHADO.js → guideRunStore-DXewygsa.js} +2 -2
- package/dist/client/assets/{htmlRender-CSsSEPs1.js → htmlRender-BXRxD1K0.js} +2 -2
- package/dist/client/assets/{index-DW7vuxv_.js → index-Cc99BYlc.js} +3 -3
- package/dist/client/assets/{info-A6RAGUB7-Dvw63L11.js → info-A6RAGUB7-BKQWek1a.js} +1 -1
- package/dist/client/assets/{infoDiagram-27XIBGKW-CU82rrtH.js → infoDiagram-27XIBGKW-CEB092tl.js} +2 -2
- package/dist/client/assets/{input-CDBTiBJx.js → input-CyLVEbfy.js} +2 -2
- package/dist/client/assets/{input-group-CHJvPXpi.js → input-group-BpHzF9lc.js} +2 -2
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-CUWA9EZ6.js → ishikawaDiagram-5VMMS53U-B4g6aomR.js} +2 -2
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-DxDN61m2.js → journeyDiagram-3NMN7TZE-E0H5_S7k.js} +2 -2
- package/dist/client/assets/{kanban-definition-UXKFOSKX-DsVX8mLR.js → kanban-definition-UXKFOSKX-NAXUPg5S.js} +2 -2
- package/dist/client/assets/{kbd-BGpxKPhX.js → kbd-BCESLLdc.js} +2 -2
- package/dist/client/assets/{keybindings-4i_VvPsX.js → keybindings-D2lV30Mz.js} +2 -2
- package/dist/client/assets/{lazyRouteComponent-DehCr3JG.js → lazyRouteComponent-Cbf8_a0u.js} +2 -2
- package/dist/client/assets/{line-Bd1UwAnv.js → line-DO-RgJzw.js} +2 -2
- package/dist/client/assets/{link-DQSgeAPg.js → link-DATjtH5q.js} +2 -2
- package/dist/client/assets/{linkedPrompt-9p_0HiUR.js → linkedPrompt-BAG2ACRB.js} +2 -2
- package/dist/client/assets/{main-DYflPzD9.css → main-BjxTXt02.css} +1 -1
- package/dist/client/assets/{main-D6OSHTK1.js → main-Cy4Cptcv.js} +7 -7
- package/dist/client/assets/{mediaReference-BqCWwE_6.js → mediaReference-J7mxetxs.js} +2 -2
- package/dist/client/assets/{mediaSource-CKXEV-xH.js → mediaSource-BstjfZff.js} +2 -2
- package/dist/client/assets/{mermaid-parser.core-DNVawM8U.js → mermaid-parser.core-JHx2T1FT.js} +4 -4
- package/dist/client/assets/{mermaid.core-DiY2Mo1k.js → mermaid.core-B3tGOJeJ.js} +5 -5
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-D9niWwdo.js → mindmap-definition-YA3MSWOX-BcFho0Dn.js} +2 -2
- package/dist/client/assets/{number-field-j3MeOhOk.js → number-field-CkcbPdEw.js} +2 -2
- package/dist/client/assets/{observeResize-3DufCT68.js → observeResize-D4IgTUH5.js} +2 -2
- package/dist/client/assets/{onboarding-ChIfLFtJ.js → onboarding-DM020Fem.js} +2 -2
- package/dist/client/assets/{openFileInPreview-BEwUYee4.js → openFileInPreview-Dz9YJ_ac.js} +2 -2
- package/dist/client/assets/{p4ProjectFile-CuaSnYfs.js → p4ProjectFile-Brm-UVx_.js} +2 -2
- package/dist/client/assets/{packet-AYTQ26CC-DUQ3tZCm.js → packet-AYTQ26CC-VQgF_EWe.js} +1 -1
- package/dist/client/assets/{pair-CqJy0vEz.js → pair-hA7Cqxn5.js} +2 -2
- package/dist/client/assets/{pegDiagram-XKGWAZYB-CngbWshp.js → pegDiagram-XKGWAZYB-JBuFtmmY.js} +2 -2
- package/dist/client/assets/{pendingSendStore-DWZwD8Qe.js → pendingSendStore-GVfJAspD.js} +2 -2
- package/dist/client/assets/{phoneViewer-EiVMUfJk.js → phoneViewer-Cvh8p7or.js} +2 -2
- package/dist/client/assets/{pie-WAS4IAKB-BTlxIvlT.js → pie-WAS4IAKB-Cr8EobS3.js} +1 -1
- package/dist/client/assets/{pieDiagram-E7YTZNPT-DGB8Wyv9.js → pieDiagram-E7YTZNPT-CgmIxeTg.js} +2 -2
- package/dist/client/assets/{pierre-icons-h-5PO6Es.js → pierre-icons-DjEhTKcg.js} +2 -2
- package/dist/client/assets/{popover-N-pn4OqA.js → popover-DSpvkDFi.js} +2 -2
- package/dist/client/assets/{preview-DL8QWLgw.js → preview-B6BR8ksI.js} +2 -2
- package/dist/client/assets/{preview-D2IUAcO1.js → preview-pMqog2V9.js} +2 -2
- package/dist/client/assets/{previewMiniPlayerStore--CyDShCc.js → previewMiniPlayerStore-BkcmyfQf.js} +2 -2
- package/dist/client/assets/{primary-BiKaD1fF.js → primary-F1_Lkwvb.js} +2 -2
- package/dist/client/assets/{primaryCloudLinkState-Cj6NnNj4.js → primaryCloudLinkState-D615O7LR.js} +2 -2
- package/dist/client/assets/{projectFilesQueryState-C9qxBsmE.js → projectFilesQueryState-BO3GmMMv.js} +2 -2
- package/dist/client/assets/{projectScriptEditor-CIO5ye4D.js → projectScriptEditor-BdHFcjT3.js} +2 -2
- package/dist/client/assets/{providerSkills-Dez8rDqH.js → providerSkills-BddgobrH.js} +2 -2
- package/dist/client/assets/{pullRequestDetail.logic-UDSGN79l.js → pullRequestDetail.logic-BaEQKwjK.js} +2 -2
- package/dist/client/assets/{pullRequestIcons-B9gjoHK4.js → pullRequestIcons-Cf6S2cR8.js} +2 -2
- package/dist/client/assets/{pullRequestReviewStore-DuoLLEGp.js → pullRequestReviewStore-CQxQgiFQ.js} +2 -2
- package/dist/client/assets/{pullRequests-DK5muENv.js → pullRequests-BRmEsK2Q.js} +2 -2
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-Dyks054W.js → quadrantDiagram-AXDQQJYC-CbwI08-4.js} +2 -2
- package/dist/client/assets/{queries-CnKYA1jH.js → queries-BcESSYn_.js} +2 -2
- package/dist/client/assets/{query-DrtB5w10.js → query-BaUS26f1.js} +2 -2
- package/dist/client/assets/{radar-RG4KPBEZ-5t86Aak1.js → radar-RG4KPBEZ-CKw4z5ef.js} +1 -1
- package/dist/client/assets/{radio-group-D5b1YnNe.js → radio-group-znYoQ5jv.js} +2 -2
- package/dist/client/assets/{railroad-74A4TZTK-CjZW18sO.js → railroad-74A4TZTK-yF9I6BJK.js} +1 -1
- package/dist/client/assets/railroad-abnf-HS5TGJTU-BZNWh7r1.js +1 -0
- package/dist/client/assets/railroad-ebnf-LZEXJU2U-D1qiyawb.js +1 -0
- package/dist/client/assets/railroad-peg-WCYAUIDC-CPc5-DUZ.js +1 -0
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-DY2XrwTu.js → railroadDiagram-O6MQD6OU-C_mlrU3y.js} +2 -2
- package/dist/client/assets/{renderScheduler-CxIHtCj0.js → renderScheduler-hgnolN_Z.js} +2 -2
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-9MWiyLFr.js → requirementDiagram-BXWQKSXE-m0xFgOZT.js} +2 -2
- package/dist/client/assets/{rightPanelStore-BLSD3K6s.js → rightPanelStore-D_BFsdvo.js} +2 -2
- package/dist/client/assets/{runtime-BtL_3nGT.js → runtime-CQUKxsYj.js} +3 -3
- package/dist/client/assets/runtime-yiVU6Sqe.js +2 -0
- package/dist/client/assets/{runtimeModeConfig-CSStNUjU.js → runtimeModeConfig-NDts48yX.js} +2 -2
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-o3eBJ4t5.js → sankeyDiagram-P5KCCOFB-CrDEIJGO.js} +2 -2
- package/dist/client/assets/{scheduledTasksSettings.logic-CpaoLLyc.js → scheduledTasksSettings.logic-CjwotRHN.js} +2 -2
- package/dist/client/assets/{scroll-area-CT3H0nmo.js → scroll-area-1mTt9e_w.js} +2 -2
- package/dist/client/assets/{select-CqPGedM1.js → select-C3qtJHHz.js} +2 -2
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-E9SEYXIP.js → sequenceDiagram-WJ2MYXX4-C2mXOHs2.js} +2 -2
- package/dist/client/assets/{server-DK7wLDqS.js → server-BLcQ113X.js} +2 -2
- package/dist/client/assets/{session-CB_SwK9v.js → session-DW2fD94Y.js} +2 -2
- package/dist/client/assets/{session-logic-lPOzc1cs.js → session-logic-BoAbcuez.js} +2 -2
- package/dist/client/assets/{settings-vpymP2yR.js → settings-pvpS9x2U.js} +2 -2
- package/dist/client/assets/{settings.appearance-CRhnBCI2.js → settings.appearance-CIAPaPZX.js} +2 -2
- package/dist/client/assets/settings.archived-Bde4DYkW.js +2 -0
- package/dist/client/assets/{settings.computer-use-54EsP-qO.js → settings.computer-use-CAUqzxyv.js} +2 -2
- package/dist/client/assets/{settings.connections-Ck3AgyGG.js → settings.connections-13xLMAhr.js} +2 -2
- package/dist/client/assets/{settings.data-controls-D_RMMjIN.js → settings.data-controls-BOXRC8Vw.js} +2 -2
- package/dist/client/assets/{settings.decisions-Cbvkif9S.js → settings.decisions-TmJloyL9.js} +2 -2
- package/dist/client/assets/{settings.designs-BefGbBVB.js → settings.designs-CyNotUEk.js} +2 -2
- package/dist/client/assets/{settings.diagnostics-XFetpvca.js → settings.diagnostics-DkdiKc59.js} +2 -2
- package/dist/client/assets/{settings.general-Bk6wtWtE.js → settings.general-BLnrOoJD.js} +2 -2
- package/dist/client/assets/{settings.integrations-C6Lgx1NO.js → settings.integrations-Bj-NzGp5.js} +2 -2
- package/dist/client/assets/{settings.keybindings-BkE-gcjT.js → settings.keybindings-Hynypq_2.js} +2 -2
- package/dist/client/assets/{settings.open-source-licenses-C10v2gWN.js → settings.open-source-licenses-BVLrI8xe.js} +2 -2
- package/dist/client/assets/{settings.plugins-DCZ1gwld.js → settings.plugins-D21wkGTw.js} +2 -2
- package/dist/client/assets/{settings.projects-BInuPAfr.js → settings.projects-BlCVQVYS.js} +3 -3
- package/dist/client/assets/{settings.providers-ggyV-d7U.js → settings.providers-CmTl_hET.js} +3 -3
- package/dist/client/assets/{settings.scheduled-tasks-CkALFkch.js → settings.scheduled-tasks-CXWEivAp.js} +2 -2
- package/dist/client/assets/{settings.snap-shot-R8RC_FLN.js → settings.snap-shot-CXyKQzI-.js} +2 -2
- package/dist/client/assets/{settings.source-control-DteTH38s.js → settings.source-control-DqzAXgE6.js} +2 -2
- package/dist/client/assets/{settings.storage-CMsiwSuK.js → settings.storage-J9uu6HkG.js} +2 -2
- package/dist/client/assets/{settingsLayout-CFe_w3zi.js → settingsLayout-CSr5dVlb.js} +2 -2
- package/dist/client/assets/{sidebar-tK61bIR5.js → sidebar-tYIa3_8M.js} +2 -2
- package/dist/client/assets/{sidebarProjectGrouping-DR0wmmJk.js → sidebarProjectGrouping-6auzG_yr.js} +2 -2
- package/dist/client/assets/{skeleton-CzpSBxtu.js → skeleton-C5tu1gWo.js} +2 -2
- package/dist/client/assets/{sourceControl-DNVstovX.js → sourceControl-Dj6LDTGS.js} +2 -2
- package/dist/client/assets/{sourceControlClients-CW3X8Vqj.js → sourceControlClients-NBgA9Img.js} +2 -2
- package/dist/client/assets/{spinner-BkmZz-kc.js → spinner-DU7w6Tl0.js} +2 -2
- package/dist/client/assets/{standalone-page-CpVawPkl.js → standalone-page-C5ckzQAC.js} +2 -2
- package/dist/client/assets/{stateDiagram-D77RDMKH-DIphJncn.js → stateDiagram-D77RDMKH-D77VrSlu.js} +2 -2
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-B06SN6_K.js +2 -0
- package/dist/client/assets/{swimlanes-42K2YHIH-BY19pg1S.js → swimlanes-42K2YHIH-DDEKvgv1.js} +2 -2
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-0BKXg9Fk.js +9 -0
- package/dist/client/assets/{terminal-links-D1lZWzBL.js → terminal-links-DaRIZ_ri.js} +2 -2
- package/dist/client/assets/{terminalSessions-Br7AMEFR.js → terminalSessions-C09tT8Cz.js} +2 -2
- package/dist/client/assets/{textarea-UGuOTqiM.js → textarea-CAyj7_Hj.js} +2 -2
- package/dist/client/assets/{themePalette-DELPwUM7.js → themePalette-B0pJNxta.js} +2 -2
- package/dist/client/assets/{timeline-definition-24CTP7MA-ByzcuBaC.js → timeline-definition-24CTP7MA-BtdR_1Bv.js} +2 -2
- package/dist/client/assets/{toast-C2NI-Hlh.js → toast-1vb9aDAy.js} +2 -2
- package/dist/client/assets/{toggle-DTjg9Rvs.js → toggle-BdizphFv.js} +2 -2
- package/dist/client/assets/{toggle-group--s5MIuQv.js → toggle-group-DAQh9V2C.js} +2 -2
- package/dist/client/assets/{tooltip-CuJiZzK7.js → tooltip-DguVraEa.js} +2 -2
- package/dist/client/assets/{treeView-Q6P3EWNA-C6l--y6F.js → treeView-Q6P3EWNA-4M83xOE9.js} +1 -1
- package/dist/client/assets/{treemap-WGGIJYW6-2WmHmD0F.js → treemap-WGGIJYW6-Bw8xwOMU.js} +1 -1
- package/dist/client/assets/{uiStateStore-z548e4qC.js → uiStateStore-C4lPArJV.js} +2 -2
- package/dist/client/assets/{usage-Bb-jkura.js → usage-BIejz4Zw.js} +2 -2
- package/dist/client/assets/{usageAccess-CkJJNWUS.js → usageAccess-DeusmFu4.js} +2 -2
- package/dist/client/assets/{usageFormat-CUKLjyKC.js → usageFormat-bv0-SbBE.js} +2 -2
- package/dist/client/assets/{usageShortcuts-DMVEjVe8.js → usageShortcuts-Dx5czWNh.js} +2 -2
- package/dist/client/assets/{use-atom-command-BBLN3-cB.js → use-atom-command-BeLksgvP.js} +2 -2
- package/dist/client/assets/{useAriaLabelledBy-B4zsIPk4.js → useAriaLabelledBy-CvM07jd7.js} +2 -2
- package/dist/client/assets/{useHandleNewThread-CsUYJUoP.js → useHandleNewThread-uD-vMkEQ.js} +2 -2
- package/dist/client/assets/{useLocation-XbiRdmmb.js → useLocation-CsUjfT4f.js} +2 -2
- package/dist/client/assets/useNavigate-JwBJSn8e.js +2 -0
- package/dist/client/assets/{useNavigateBack-BDMTgSKu.js → useNavigateBack-CpakkPiu.js} +2 -2
- package/dist/client/assets/{useP4ConnectAuthPrompt-C_DWHou2.js → useP4ConnectAuthPrompt-BHYSUurl.js} +2 -2
- package/dist/client/assets/{useParams-DNmNCHjx.js → useParams-BmGuCYQD.js} +2 -2
- package/dist/client/assets/{usePermissionStatus-DBybaxyT.js → usePermissionStatus-DxuVlxCI.js} +2 -2
- package/dist/client/assets/{usePullRequestActions-2RLXa_AL.js → usePullRequestActions-Bvq7gnqT.js} +2 -2
- package/dist/client/assets/{useRegisterFieldControl-Cuo8UAhZ.js → useRegisterFieldControl-D9BX_Pej.js} +2 -2
- package/dist/client/assets/{useScopedModelAvailability-CLSjirRK.js → useScopedModelAvailability-BZnFH3BE.js} +2 -2
- package/dist/client/assets/{useSettings-BeOQNM41.js → useSettings-BxAEkFYM.js} +2 -2
- package/dist/client/assets/utils-CyMIjIQl.js +37 -0
- package/dist/client/assets/{vcsRefInvalidation-D5r-YO6n.js → vcsRefInvalidation-BExYB-sY.js} +2 -2
- package/dist/client/assets/{vennDiagram-4TSXK5OY-CsSeQEmm.js → vennDiagram-4TSXK5OY-DYrjPSgU.js} +2 -2
- package/dist/client/assets/{wardley-WFR3VGLG-DHUa30e5.js → wardley-WFR3VGLG-ttgtrPV7.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-NUfaDxHP.js → wardleyDiagram-VM6X3IG4-DjBKyYb1.js} +2 -2
- package/dist/client/assets/{welcome-DUwjP1q3.js → welcome-B4cmOOhJ.js} +2 -2
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-wdjDjsiQ.js → xychartDiagram-S5SC5T6Z-BRvsZPWi.js} +2 -2
- package/dist/client/index.html +1 -1
- package/dist/{renderer-U6GevbYv.mjs → renderer-A818pKS0.mjs} +2 -2
- package/dist/{runtime-Cui_uQWU.mjs → runtime-chxDiILq.mjs} +200 -112
- package/package.json +1 -1
- package/dist/client/assets/AlertDialogRoot-uMQTdBRo.js +0 -2
- package/dist/client/assets/EmbeddedDesign-DYfQOv0y.css +0 -1
- package/dist/client/assets/Input-BcEftKLM.js +0 -2
- package/dist/client/assets/_chat-EbDz56cx.js +0 -45
- package/dist/client/assets/architecture-7GRP2DOG-DI9suUNc.js +0 -1
- package/dist/client/assets/channel-BAWAGigO.js +0 -2
- package/dist/client/assets/classDiagram-ZZMXUADV-DIxrr9dl.js +0 -2
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-DIxrr9dl.js +0 -2
- package/dist/client/assets/eventmodeling-NTZA5JFV-DWccyGhB.js +0 -1
- package/dist/client/assets/flowDiagram-HODETNUW-2xlj_oad.js +0 -1
- package/dist/client/assets/railroad-abnf-HS5TGJTU-DOBW6UbH.js +0 -1
- package/dist/client/assets/railroad-ebnf-LZEXJU2U-Ck7zj7ML.js +0 -1
- package/dist/client/assets/railroad-peg-WCYAUIDC-BkEDvnoB.js +0 -1
- package/dist/client/assets/runtime-CxXKASQ8.js +0 -2
- package/dist/client/assets/settings.archived-qDhcwMq8.js +0 -2
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-l4hzw06_.js +0 -2
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-Dm5nKQAS.js +0 -9
- package/dist/client/assets/useNavigate-CSxB1zLo.js +0 -2
- package/dist/client/assets/utils-B0w8dSf5.js +0 -37
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{$n as n,$o as r,BE as i,Bp as a,Ds as o,Es as s,I_ as c,Jm as l,Jn as u,Ny as d,Od as f,RT as p,Rf as m,Ty as h,Uy as g,Yo as _,Yp as v,Zn as y,cm as b,cr as x,ds as S,el as C,gb as w,ks as T,lb as E,lr as D,mE as O,qn as k,rr as A,rs as j,s_ as M,t as N,ts as P,ur as F,xd as I}from"./utils-B0w8dSf5.js";import{B as L,L as R,W as z,q as B}from"./runtime-BtL_3nGT.js";import{a as V,c as H,o as ee,s as te,t as ne}from"./select-CqPGedM1.js";import{t as re}from"./useNavigateBack-BDMTgSKu.js";import{rt as ie}from"./useSettings-BeOQNM41.js";import{f as ae,s as oe}from"./server-DK7wLDqS.js";import{n as U,t as W}from"./session-CB_SwK9v.js";import{t as se}from"./use-atom-command-BBLN3-cB.js";import{a as ce,c as le,d as G,f as K,i as ue,l as q,n as de,o as fe,r as J,s as Y,t as pe,u as me}from"./usageFormat-CUKLjyKC.js";import{t as he}from"./env-wK1YYxA8.js";import{a as ge,n as _e,t as ve}from"./tooltip-CuJiZzK7.js";import{t as X}from"./skeleton-CzpSBxtu.js";import{n as ye,t as be}from"./toggle-group--s5MIuQv.js";import{t as xe}from"./input-CDBTiBJx.js";import{t as Se}from"./scroll-area-CT3H0nmo.js";import{a as Ce,c as we,i as Te,o as Ee,r as De,s as Oe,t as ke}from"./dialog-Bdi4gsq5.js";import{o as Ae}from"./sidebar-tK61bIR5.js";import{t as je}from"./observeResize-3DufCT68.js";import{y as Me}from"./keybindings-4i_VvPsX.js";import{i as Ne,o as Pe,t as Fe}from"./popover-N-pn4OqA.js";import{S as Ie,n as Le,t as Re}from"./ChatGptUsageButton-B7IBN3Pq.js";import{t as ze}from"./WorkspacePageContainer-OhHg0688.js";import{n as Be,r as Ve,t as He}from"./usageShortcuts-DMVEjVe8.js";import{Si as Ue,Ta as We,Wr as Ge,ar as Ke,cr as qe,hi as Je,or as Ye,sr as Xe}from"./main-D6OSHTK1.js";import{t as Ze}from"./WorkspacePageHeader-BUVfTGMv.js";import{i as Qe,n as $e,r as et,t as tt}from"./WorkspaceBreadcrumb-DnyZiGsn.js";import{t as nt}from"./usageAccess-CkJJNWUS.js";var Z=e(t(),1),Q=i(),rt=E(B);function it(e,t){return e?.sources.some(e=>e.action===`enableCursorKeychain`)===!0&&t?.some(e=>e.driver===`cursor`&&e.status===`ready`)===!0}function at(e){return e.some(e=>e.summary?.sources.some(e=>e.fingerprint.provider===`cursor`&&e.fingerprint.hostId===`cursor.com`))?[]:e.filter(e=>e.needsCursorKeychainAccess)}var ot=new Map,st=new Map;async function ct(e,t,n=!1,r=!1){let i=st.get(e);if(i!==void 0){if(r){try{await i}catch{}return ct(e,t,!1,!0)}return n?void 0:await i}let a=ot.get(e)??0;if(n&&Date.now()<a)return;let o=Promise.resolve().then(t).finally(()=>{st.delete(e),ot.set(e,Date.now()+3e5)});return st.set(e,o),await o}async function lt({registry:e,server:t,presentations:n,environmentIds:r,input:i}){await Promise.all(r.map(async r=>{let a=t.usageSummary({environmentId:r,input:i}),o=n.presentationAtom(r),s=new AbortController,c=()=>{e.get(o)?.connection.phase!==`connected`&&s.abort()},l=e.subscribe(o,c);c();try{let n=await L(e,t.refreshUsageRates,{environmentId:r,input:{}},{reportFailure:!1}),i=n._tag===`Failure`&&rt(z(n));if(e.refresh(a),i||s.signal.aborted)return;await R(e,a,{reportFailure:!1,signal:s.signal})}finally{l()}}))}function ut(e,t=!1){let{summary:n}=e;if(!e.isConnected||e.error!==null)return{phase:`inactive`};if(n===null)return{phase:`loading`};if(t)return{phase:`stale`};if(!e.isPending)return{phase:`ready`};let r=[...new Set(n.sources.flatMap(e=>e.refreshing?[e.fingerprint.provider]:[]))];return r.length>0?{phase:`partway`,providers:r}:{phase:`stale`}}function dt(e,t){return e.length===1?`Updating ${t(e[0])}…`:`Updating ${e.length} providers…`}function ft(e,t=!1){let n=new Set,r=!1;for(let i of e){let e=ut(i,t);if((e.phase===`loading`||e.phase===`stale`)&&(r=!0),e.phase===`partway`)for(let t of e.providers)n.add(t)}return{partial:r||n.size>0,everyProvider:r,providers:n}}function pt(e){return e.records>0&&e.unpricedRecords>=e.records}function mt(e){return[e.hostId,e.provider,e.resolvedHomePath,e.volumeId].join(` `)}function ht(e,t){let n=e.sources.filter(e=>e.fingerprint.provider===t.fingerprint.provider);return e.buckets.filter(e=>e.provider===t.fingerprint.provider&&(e.sourcePath===t.fingerprint.resolvedHomePath||e.sourcePath===void 0&&n.length===1))}function gt(e){return JSON.stringify([e.day,e.hourStart??null,e.provider,e.model])}function _t(e){let t=new Map,n=new Map,r=new Map,i=new Map,a=new Map,o=[],s=[...e].sort((e,t)=>(Date.parse(t.summary.readAt)||0)-(Date.parse(e.summary.readAt)||0)||e.environmentId.localeCompare(t.environmentId));for(let e of[`ok`,`partial`,`failed`])for(let r of s)for(let i of r.summary.sources){if(i.status!==e)continue;let s=mt(i.fingerprint);if(t.has(s)){o.push(`${r.label}: ${i.fingerprint.resolvedHomePath}`);continue}t.set(s,r.environmentId),n.set(s,{environment:r,source:i}),a.set(s,i.distinctSessions)}for(let e of s)for(let t of e.summary.sources){if(t.status!==`partial`)continue;let o=mt(t.fingerprint),s=n.get(o);if(s?.source.status!==`ok`||Date.parse(e.summary.readAt)<=Date.parse(s.environment.summary.readAt))continue;let c=r.get(o);c===void 0&&(c=new Set(ht(s.environment.summary,s.source).map(gt)),r.set(o,c));let l=i.get(e.environmentId)??new Set,u=!1;for(let n of ht(e.summary,t)){let e=gt(n);c.has(e)||(c.add(e),l.add(n),u=!0)}u&&(i.set(e.environmentId,l),a.set(o,Math.max(a.get(o)??0,t.distinctSessions)))}return{ownerByFingerprint:t,supplementalBucketsByEnvironment:i,sessionsByFingerprint:a,duplicates:o}}function vt(e,t,n,r){let i=new Set,a=new Set,o=new Map;for(let n of e.summary.sources){if(n.status===`missing`)continue;let s=mt(n.fingerprint);if(t.get(s)===e.environmentId){let e=n.fingerprint.provider;i.add(e),a.add(`${e}\u0000${n.fingerprint.resolvedHomePath}`),o.set(e,(o.get(e)??0)+(r.get(s)??n.distinctSessions))}}return{buckets:e.summary.buckets.filter(e=>n.has(e)||(e.sourcePath===void 0?i.has(e.provider):a.has(`${e.provider}\u0000${e.sourcePath}`))),sessionsByProvider:o}}function yt(e){return e.totals.uncachedInputTokens+e.totals.cachedInputTokens+e.totals.cacheCreationTokens+e.totals.outputTokens}function bt(e,t){return e>=4&&e<=t}var xt={costUsd:0,uncachedInputTokens:0,cachedInputTokens:0,cacheCreationTokens:0,outputTokens:0,reasoningTokens:0,totalTokens:0,records:0,sessions:0,providers:[],models:[],daily:[],hourly:[],costQuality:{providerReportedShare:0,modelPricedShare:0,unpricedShare:0,cacheSavingsUsd:0},categoryCost:{input:0,cacheRead:0,cacheWrite:0,output:0,unsplit:0},speedCost:{standard:0,fast:0,ultrafast:0,premium:0},duplicateSources:[],contributingEnvironments:[],contractMismatches:[]};function St(e,t){if(e.length===0)return xt;let n=[],r=[];for(let i of e)bt(i.summary.contractVersion,t)?n.push(i):r.push({environmentId:i.environmentId,direction:i.summary.contractVersion<t?`serverBehind`:`clientBehind`,contractVersion:i.summary.contractVersion});let{ownerByFingerprint:i,supplementalBucketsByEnvironment:a,sessionsByFingerprint:o,duplicates:s}=_t(n),c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y={input:0,cacheRead:0,cacheWrite:0,output:0},b={fast:0,ultrafast:0,premium:0},x=new Map,S=new Map,C=new Map,w=new Map,T=[];for(let e of n){let{buckets:t,sessionsByProvider:n}=vt(e,i,a.get(e.environmentId)??new Set,o);t.length>0&&T.push(e.environmentId);for(let[e,t]of n){if(h+=t,t===0)continue;let n=x.get(e)??{costUsd:0,totalTokens:0,records:0,sessions:0};n.sessions+=t,x.set(e,n)}for(let e of t){let t=yt(e);c+=e.costUsd,g+=e.cacheSavingsUsd,l+=e.totals.uncachedInputTokens,u+=e.totals.cachedInputTokens,d+=e.totals.cacheCreationTokens,f+=e.totals.outputTokens,p+=e.totals.reasoningTokens,m+=e.records,v+=e.unpricedRecords,e.costSource===`providerReported`&&(_+=e.records),e.categoryCostUsd!==void 0&&(y.input+=e.categoryCostUsd.input,y.cacheRead+=e.categoryCostUsd.cacheRead,y.cacheWrite+=e.categoryCostUsd.cacheWrite,y.output+=e.categoryCostUsd.output),b.fast+=e.fastCostUsd??0,b.ultrafast+=e.ultrafastCostUsd??0,b.premium+=e.speedPremiumUsd??0;let n=x.get(e.provider)??{costUsd:0,totalTokens:0,records:0,sessions:0};n.costUsd+=e.costUsd,n.totalTokens+=t,n.records+=e.records,x.set(e.provider,n);let r=`${e.provider} ${e.model}`,i=S.get(r)??{provider:e.provider,costUsd:0,totalTokens:0,tokens:{uncachedInputTokens:0,cachedInputTokens:0,cacheCreationTokens:0,outputTokens:0,reasoningTokens:0},records:0,unpricedRecords:0,unpricedTokens:0};i.costUsd+=e.costUsd,i.totalTokens+=t,i.tokens={uncachedInputTokens:i.tokens.uncachedInputTokens+e.totals.uncachedInputTokens,cachedInputTokens:i.tokens.cachedInputTokens+e.totals.cachedInputTokens,cacheCreationTokens:i.tokens.cacheCreationTokens+e.totals.cacheCreationTokens,outputTokens:i.tokens.outputTokens+e.totals.outputTokens,reasoningTokens:i.tokens.reasoningTokens+e.totals.reasoningTokens},i.records+=e.records,i.unpricedRecords+=e.unpricedRecords,e.records>0&&(i.unpricedTokens+=t*e.unpricedRecords/e.records),S.set(r,i);let a=C.get(e.day)??{costUsd:0,totalTokens:0,byProvider:new Map};a.costUsd+=e.costUsd,a.totalTokens+=t;let o=a.byProvider.get(e.provider)??{costUsd:0,totalTokens:0};if(o.costUsd+=e.costUsd,o.totalTokens+=t,a.byProvider.set(e.provider,o),C.set(e.day,a),e.hourStart!==void 0){let n=w.get(e.hourStart)??{day:e.day,hourStart:e.hourStart,costUsd:0,totalTokens:0,byProvider:new Map};n.costUsd+=e.costUsd,n.totalTokens+=t;let r=n.byProvider.get(e.provider)??{costUsd:0,totalTokens:0};r.costUsd+=e.costUsd,r.totalTokens+=t,n.byProvider.set(e.provider,r),w.set(e.hourStart,n)}}}let E=l+u+d+f,D=[...x.entries()].map(([e,t])=>({provider:e,costUsd:t.costUsd,totalTokens:t.totalTokens,records:t.records,sessions:t.sessions,costShare:c===0?0:t.costUsd/c,tokenShare:E===0?0:t.totalTokens/E})).sort((e,t)=>t.costUsd-e.costUsd),O=[...S.entries()].map(([e,t])=>({model:e.slice(e.indexOf(` `)+1),provider:t.provider,costUsd:t.costUsd,totalTokens:t.totalTokens,tokens:t.tokens,records:t.records,unpricedRecords:t.unpricedRecords,unpricedTokens:t.unpricedTokens,costShare:c===0?0:t.costUsd/c,tokenShare:E===0?0:t.totalTokens/E})).sort((e,t)=>t.costUsd-e.costUsd||t.totalTokens-e.totalTokens),k=[...C.entries()].map(([e,t])=>({day:e,costUsd:t.costUsd,totalTokens:t.totalTokens,byProvider:t.byProvider})).sort((e,t)=>e.day.localeCompare(t.day)),A=[...w.values()].sort((e,t)=>e.hourStart.localeCompare(t.hourStart));return{costUsd:c,uncachedInputTokens:l,cachedInputTokens:u,cacheCreationTokens:d,outputTokens:f,reasoningTokens:p,totalTokens:E,records:m,sessions:h,providers:D,models:O,daily:k,hourly:A,costQuality:{providerReportedShare:m===0?0:_/m,unpricedShare:m===0?0:v/m,modelPricedShare:m===0?0:(m-_-v)/m,cacheSavingsUsd:g},categoryCost:{...y,unsplit:Math.max(0,c-y.input-y.cacheRead-y.cacheWrite-y.output)},speedCost:{...b,standard:Math.max(0,c-b.fast-b.ultrafast)},duplicateSources:s,contributingEnvironments:T,contractMismatches:r}}var Ct=P(e=>j(t=>{let n=JSON.parse(e),r=t(ie.presentationsAtom),i=[];for(let[e,a]of r){let r=a.connection.phase===`connected`,o=t(W.sessionStateAtom(e)),c=nt({connectionPhase:a.connection.phase,session:p(s(o)),hasSessionError:o._tag===`Failure`});if(!c.canReadDiagnostics){i.push({environmentId:e,label:a.entry.target.label,isConnected:r,...c,summary:null,needsCursorKeychainAccess:!1});continue}let l=t(ae.usageSummary({environmentId:e,input:n})),u=p(s(l));i.push({environmentId:e,label:a.entry.target.label,isPending:l.waiting,canReadDiagnostics:!0,isConnected:r,error:l._tag===`Failure`?`This environment could not report usage.`:null,summary:u,needsCursorKeychainAccess:it(u,t(ae.providersValueAtom(e)))})}return i}).pipe(S(`web-usage:window:${e}`)));function wt(e,t){return St(e.flatMap(({environmentId:e,label:n,summary:r})=>r===null?[]:[{environmentId:e,label:n,summary:t===void 0?r:{...r,buckets:r.buckets.filter(t)}}]),6)}var Tt=new Set;function Et(e,t){return t.size===0?e:e.map(e=>e.summary===null?e:{...e,summary:{...e.summary,buckets:e.summary.buckets.filter(e=>!t.has(e.provider)),sources:e.summary.sources.filter(e=>!t.has(e.fingerprint.provider))}})}function Dt(e,t,n){let i=(0,Q.c)(36),a=t===void 0?null:t,o=n===void 0?Tt:n,s;i[0]!==e.resolution||i[1]!==e.sinceDay||i[2]!==e.sinceTime||i[3]!==e.timeZone||i[4]!==e.untilDay||i[5]!==e.untilTime?(s=JSON.stringify({sinceDay:e.sinceDay,untilDay:e.untilDay,timeZone:e.timeZone,resolution:e.resolution,sinceTime:e.sinceTime,untilTime:e.untilTime}),i[0]=e.resolution,i[1]=e.sinceDay,i[2]=e.sinceTime,i[3]=e.timeZone,i[4]=e.untilDay,i[5]=e.untilTime,i[6]=s):s=i[6];let c=s,l;i[7]===c?l=i[8]:(l=Ct(c),i[7]=c,i[8]=l);let u=r(l),d;i[9]!==u||i[10]!==a?(d=a===null?u:u.filter(e=>a.has(e.environmentId)),i[9]=u,i[10]=a,i[11]=d):d=i[11];let f=d,p;i[12]!==f||i[13]!==c?(p=e=>lt({registry:_,server:ae,presentations:ie,environmentIds:f.filter(jt).map(At),input:e??JSON.parse(c)}),i[12]=f,i[13]=c,i[14]=p):p=i[14];let m=p,h;i[15]!==o||i[16]!==f?(h=wt(Et(f,o)),i[15]=o,i[16]=f,i[17]=h):h=i[17];let g=h,v;i[18]===f?v=i[19]:(v=f.filter(kt),i[18]=f,i[19]=v);let y=v.length,b;i[20]===f?b=i[21]:(b=f.filter(Ot),i[20]=f,i[21]=b);let x=b.length,S=y===0&&x>0,[C,w]=(0,Z.useState)(null);y>0&&(C?.merged!==g||C.window!==e||C.selection!==a||C.hidden!==o)&&w({window:e,merged:g,selection:a,hidden:o});let T=C?.selection===a&&C.hidden===o?C:null,E;i[22]!==y||i[23]!==e||i[24]!==S||i[25]!==T||i[26]!==g?(E=y>0?{window:e,merged:g}:T??(S?null:{window:e,merged:g}),i[22]=y,i[23]=e,i[24]=S,i[25]=T,i[26]=g,i[27]=E):E=i[27];let D=E,O=y>0&&x>0,k;return i[28]!==u||i[29]!==S||i[30]!==g||i[31]!==m||i[32]!==f||i[33]!==D||i[34]!==O?(k={merged:g,environments:u,selectedEnvironments:f,isPending:S,shown:D,isPartial:O,refresh:m},i[28]=u,i[29]=S,i[30]=g,i[31]=m,i[32]=f,i[33]=D,i[34]=O,i[35]=k):k=i[35],k}function Ot(e){return e.summary===null&&e.error===null}function kt(e){return e.summary!==null}function At(e){let{environmentId:t}=e;return t}function jt(e){return e.canReadDiagnostics&&U(e.environmentId,`diagnostics:read`)}var $=e(O(),1);function Mt(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=N(`w-full caption-bottom text-xs`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,$.jsx)(`table`,{"data-slot":`table`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Nt(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=N(`[&_tr]:border-b`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`thead`,{"data-slot":`table-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Pt(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=N(`[&_tr:last-child]:border-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`tbody`,{"data-slot":`table-body`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ft(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=N(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`tr`,{"data-slot":`table-row`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function It(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=N(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`th`,{"data-slot":`table-head`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Lt(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=N(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`td`,{"data-slot":`table-cell`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Rt=[{key:`inputCostPerMillionTokens`,label:`Input`,optional:!1},{key:`outputCostPerMillionTokens`,label:`Output`,optional:!1},{key:`cacheReadCostPerMillionTokens`,label:`Cache read`,optional:!0},{key:`cacheWriteCostPerMillionTokens`,label:`Cache write`,optional:!0}];function zt(e=``,t){return{model:e,inputCostPerMillionTokens:t?.inputCostPerMillionTokens.toString()??``,outputCostPerMillionTokens:t?.outputCostPerMillionTokens.toString()??``,cacheReadCostPerMillionTokens:t?.cacheReadCostPerMillionTokens?.toString()??``,cacheWriteCostPerMillionTokens:t?.cacheWriteCostPerMillionTokens?.toString()??``}}function Bt(e){let t=e.model.trim();if(t.length===0)return null;let n={};for(let t of Rt){let r=e[t.key].trim();if(r===``){if(t.optional)continue;return null}if(!/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(r))return null;let i=Number(r);if(!Number.isFinite(i)||i<0)return null;n[t.key]=i}return n.inputCostPerMillionTokens===void 0||n.outputCostPerMillionTokens===void 0?null:{model:t,price:{inputCostPerMillionTokens:n.inputCostPerMillionTokens,outputCostPerMillionTokens:n.outputCostPerMillionTokens,...n.cacheReadCostPerMillionTokens===void 0?{}:{cacheReadCostPerMillionTokens:n.cacheReadCostPerMillionTokens},...n.cacheWriteCostPerMillionTokens===void 0?{}:{cacheWriteCostPerMillionTokens:n.cacheWriteCostPerMillionTokens}}}}function Vt(e){return e.isNew&&e.model.trim()===``&&(e.alias??``).trim()===``&&Object.values(e.values).every(e=>e.trim()===``)}function Ht(e,t){return e.prices&&Object.hasOwn(e.prices,t)?e.prices[t]:void 0}function Ut(e,t){return e.aliases&&Object.hasOwn(e.aliases,t)?e.aliases[t]:void 0}function Wt(e,t){if(e.some(e=>e.aliases===null))return{value:``,placeholder:`Unavailable`};let n=e.map(e=>Ut(e,t)??``);return n.some(e=>e!==n[0])?{value:``,placeholder:`Mixed`}:{value:n[0]??``,placeholder:`None`}}function Gt(e,t,n){let r=Rt.find(e=>e.key===n).optional,i=e.map(e=>Ht(e,t)?zt(t,Ht(e,t))[n]:null);return e.some(e=>e.prices===null)?{value:``,placeholder:`Unavailable`}:i.some(e=>e!==i[0])?{value:``,placeholder:`Mixed`}:{value:i[0]??``,placeholder:i[0]===null?`Automatic`:r?`Input rate`:`0.00`}}function Kt(e,t){let n=[],r=new Map;for(let i of t){if(Vt(i))continue;let t=i.model.trim(),a=Ut(e,t);if(i.removed){Ht(e,t)&&n.push({model:t,price:null}),a!==void 0&&n.push({model:t,alias:null});continue}let o=(i.alias??a??``).trim();if(o!==``){t===``?r.set(i.id,`Enter a model ID.`):o===t?r.set(i.id,`Map to a different model.`):(o!==a&&n.push({model:t,alias:o}),Ht(e,t)&&n.push({model:t,price:null}));continue}if(a!==void 0&&(n.push({model:t,alias:null}),!Ht(e,t)&&Object.values(i.values).every(e=>e.trim()===``)))continue;let s=zt(t,Ht(e,t)),c={...s,...i.values},l=Bt(c);if(l===null){let n=Rt.find(e=>!e.optional&&c[e.key].trim()===``);r.set(i.id,t===``?`Enter a model ID.`:n?`${n.label} is required on ${e.label}.`:`Use non-negative numbers for prices.`);continue}let u=zt(t,l.price);Rt.some(e=>s[e.key]!==u[e.key])&&n.push(l)}return{changes:n,errors:r}}function qt(e,t){return new Map(e.filter(e=>e.unavailable===null&&e.prices!==null).flatMap(e=>[...Kt(e,t).errors]))}async function Jt(e){await Promise.all(e.targets.map(async t=>{let n,r=e.changes.get(t.environmentId)??[],i=r.flatMap(e=>`price`in e?[[e.model,e.price]]:[]),a=r.flatMap(e=>`alias`in e?[[e.model,e.alias]]:[]);if(t.unavailable!==null)n={status:`failed`,error:t.unavailable};else if(a.length>0&&t.aliases===null)n={status:`failed`,error:`Update server to map models`};else try{n=(r.length===0?{_tag:`Success`}:await e.write({environmentId:t.environmentId,input:{patch:{...i.length>0?{usagePriceOverrides:Object.fromEntries(i)}:{},...a.length>0?{usageModelAliases:Object.fromEntries(a)}:{}}}}))._tag===`Success`?{status:`saved`}:{status:`failed`,error:`Could not save. Try again.`}}catch{n={status:`failed`,error:`Could not save. Try again.`}}e.onResult(t.environmentId,n)}))}var Yt=j(e=>[...e(ie.presentationsAtom)].map(([t,n])=>{let r=e(ae.settingsValueAtom(t)),i=e(W.sessionStateAtom(t)),a=p(s(i)),o=i._tag===`Failure`?`denied`:a===null?i.waiting?`pending`:`denied`:c(a,`settings:write`)?`granted`:`denied`;return{environmentId:t,label:n.entry.target.label,prices:r?.usagePriceOverrides??null,aliases:n.serverConfig?.environment.capabilities.usageModelAliases===!0?r?.usageModelAliases??null:null,unavailable:n.connection.phase===`connected`?r===null?`Prices not loaded`:n.serverConfig?.environment.capabilities.usagePriceOverrides===!0?o===`pending`?`Checking permissions…`:o===`denied`?`Read-only access`:null:`Update server to edit prices`:`Offline`}}));function Xt(e){let t=(0,Q.c)(119),{usage:i,initialSelectedEnvironmentIds:o,initialModel:s,onOpenChange:c}=e,d=r(Yt),[f,p]=(0,Z.useState)(o),m;if(t[0]!==d||t[1]!==f){let e;t[3]===f?e=t[4]:(e=e=>f===null||f.has(e.environmentId),t[3]=f,t[4]=e),m=d.filter(e),t[0]=d,t[1]=f,t[2]=m}else m=t[2];let h=m,g;t[5]!==s||t[6]!==h?(g=()=>s===void 0||h.some(e=>Object.hasOwn(e.prices??{},s)||Object.hasOwn(e.aliases??{},s))?[]:[{id:`new:initial`,model:s,isNew:!0,values:{}}],t[5]=s,t[6]=h,t[7]=g):g=t[7];let[_,y]=(0,Z.useState)(g),[b,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),T=(0,Z.useRef)(null),E=(0,Z.useRef)(0),O;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(O={reportFailure:!1},t[8]=O):O=t[8];let j=se(ae.updateSettings,O),M,P,F,L,R,z,B,V,H,ee,te,ne,re,ie,oe;if(t[9]!==C||t[10]!==_||t[11]!==d||t[12]!==c||t[13]!==b||t[14]!==h||t[15]!==f||t[16]!==j||t[17]!==i){let e=[...new Set(h.flatMap(mn))].sort(),r;t[33]===h?r=t[34]:(r=e=>h.some(t=>t.environmentId===e.environmentId),t[33]=h,t[34]=r);let o=[...new Set([...e,...i.filter(r).flatMap(fn)])].sort(),s;t[35]===_?s=t[36]:(s=new Set(_.filter(dn).map(un)),t[35]=_,t[36]=s);let m=s,g;t[37]!==C||t[38]!==m?(g=e=>C===null||!m.has(e),t[37]=C,t[38]=m,t[39]=g):g=t[39];let O=[...e.filter(g).map(e=>_.find(t=>t.id===`model:${e}`)??{id:`model:${e}`,model:e,isNew:!1,values:{}}),..._.filter(ln)],ae=_.filter(cn);z=qt(h,ae);for(let t of ae)t.isNew&&(t.model.trim()===``?z.set(t.id,`Enter a model ID.`):C===null&&(e.includes(t.model.trim())||_.some(e=>e.id!==t.id&&e.model.trim()===t.model.trim()))&&z.set(t.id,`This model already has a row. Edit its prices there.`));B=C?.destinations.filter(e=>C.results.get(e.environmentId)?.status===`failed`)??[];let W=b||B.length>0;V=ae.length>0,L=h.length===1?h[0].label:`${h.length} environments`;let se=f===null?`All environments`:L,ce;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>{y([]),w(null)},t[40]=ce):ce=t[40],R=ce;let le;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(le=e=>{p(e),w(null)},t[41]=le):le=t[41];let G=le,K;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(K=e=>{y(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e]),w(null)},t[42]=K):K=t[42];let ue=K,q=sn,de;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>{!e.isNew&&Object.keys(e.values).length===0&&e.alias===void 0?y(t=>t.filter(t=>t.id!==e.id)):ue(e)},t[43]=de):de=t[43];let fe=de,J;t[44]===h?J=t[45]:(J=(e,t,n)=>{let r={...e.values,[t]:n},i=Gt(h,e.model,t);q(e,i,n)&&delete r[t],fe({...e,values:r})},t[44]=h,t[45]=J);let Y=J,pe;t[46]===h?pe=t[47]:(pe=(e,t)=>{let{alias:n,...r}=e,i=Wt(h,e.model);fe(q(e,i,t)?r:{...r,alias:t})},t[46]=h,t[47]=pe);let me=pe;H=async e=>{let t=e!==void 0&&e;if(b)return;let n=t?B:h,r=t&&C?C.drafts:ae;if(n.length===0||r.length===0)return;let i=n.map(e=>d.find(t=>t.environmentId===e.environmentId)??{...e,prices:null,aliases:null,unavailable:`Environment removed`}),a=new Map(i.map(e=>[e.environmentId,Kt(e,r)]));S(!0),w(e=>({drafts:r,destinations:t&&e?e.destinations:i,results:new Map([...t&&e?e.results:[],...i.map(on)])}));let o=!1;await Jt({targets:i.map(e=>({...e,unavailable:e.unavailable??[...a.get(e.environmentId).errors.values()][0]??null})),changes:new Map([...a].map(an)),write:async e=>U(e.environmentId,`settings:write`)?j(e):{_tag:`Failure`},onResult:(e,t)=>{t.status===`failed`&&(o=!0),w(n=>n===null?null:{...n,results:new Map(n.results).set(e,t)})}}),S(!1),o||y([])},F=ke,ie=!0,t[48]!==c||t[49]!==b?(oe=e=>{b||c(e)},t[48]=c,t[49]=b,t[50]=oe):oe=t[50],P=Oe,ne=`max-w-4xl`,t[51]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsxs)(Ce,{children:[(0,$.jsx)(we,{children:`Custom model prices`}),(0,$.jsx)(De,{children:`Prices and mappings apply to all past and future usage on the environments you select.`})]}),t[51]=re):re=t[51],M=Ee;let he;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(Je,{id:`usage-prices-apply-label`,className:`shrink-0`,children:`Apply to`}),t[52]=he):he=t[52];let X;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,$.jsx)(D,{variant:`outline`,size:`sm`,className:`min-w-0`}),t[53]=X):X=t[53];let ye=b||V,be;t[54]===se?be=t[55]:(be=(0,$.jsx)(`span`,{id:`usage-prices-selection`,className:`truncate`,children:se}),t[54]=se,t[55]=be);let Se;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,$.jsx)(I,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[56]=Se):Se=t[56];let Te;t[57]!==ye||t[58]!==be?(Te=(0,$.jsxs)(x,{render:X,"aria-labelledby":`usage-prices-apply-label usage-prices-selection`,disabled:ye,children:[be,Se]}),t[57]=ye,t[58]=be,t[59]=Te):Te=t[59];let Ae=f===null,je;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(je=e=>G(e?null:new Set),t[60]=je):je=t[60];let Me;t[61]===Ae?Me=t[62]:(Me=(0,$.jsx)(u,{checked:Ae,closeOnClick:!1,onCheckedChange:je,children:`All environments`}),t[61]=Ae,t[62]=Me);let Ne;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,$.jsx)(A,{}),t[63]=Ne):Ne=t[63];let Pe;if(t[64]!==d||t[65]!==h||t[66]!==f){let e;t[68]!==d.length||t[69]!==h||t[70]!==f?(e=e=>(0,$.jsx)(u,{checked:f===null||f.has(e.environmentId),closeOnClick:!1,onCheckedChange:t=>{let n=new Set(h.map(rn));t?n.add(e.environmentId):n.delete(e.environmentId),G(n.size===d.length?null:n)},children:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.unavailable?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.unavailable}):null]})},e.environmentId),t[68]=d.length,t[69]=h,t[70]=f,t[71]=e):e=t[71],Pe=d.map(e),t[64]=d,t[65]=h,t[66]=f,t[67]=Pe}else Pe=t[67];let Fe;t[72]!==Me||t[73]!==Pe?(Fe=(0,$.jsxs)(n,{align:`start`,children:[Me,Ne,Pe]}),t[72]=Me,t[73]=Pe,t[74]=Fe):Fe=t[74];let Ie;t[75]!==Te||t[76]!==Fe?(Ie=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[he,(0,$.jsxs)(k,{children:[Te,Fe]})]}),t[75]=Te,t[76]=Fe,t[77]=Ie):Ie=t[77];let Le;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`USD / million tokens`}),t[78]=Le):Le=t[78],t[79]===Ie?ee=t[80]:(ee=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[Ie,Le]}),t[79]=Ie,t[80]=ee),te=h.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:d.length===0?`Connect an environment to set model prices.`:`Select an environment to see and change its model prices.`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`min-w-0 overflow-hidden rounded-lg border border-border`,children:(0,$.jsxs)(Mt,{className:`min-w-180 table-fixed`,"aria-label":`Custom model prices`,children:[(0,$.jsxs)(`colgroup`,{children:[(0,$.jsx)(`col`,{className:`w-[22%]`}),(0,$.jsx)(`col`,{className:`w-[18%]`}),Rt.map(nn),(0,$.jsx)(`col`,{className:`w-10`})]}),(0,$.jsx)(Nt,{children:(0,$.jsxs)(Ft,{children:[(0,$.jsx)(It,{children:`Model ID`}),(0,$.jsx)(It,{children:`Map to`}),Rt.map(tn),(0,$.jsx)(It,{children:(0,$.jsx)(D,{size:`icon-xs`,variant:`ghost`,"aria-label":`Add model price`,disabled:W,onClick:()=>{E.current+=1;let e=`new:${E.current}`;T.current=e,ue({id:e,model:``,isNew:!0,values:{}})},children:(0,$.jsx)(a,{"aria-hidden":!0})})})]})}),(0,$.jsx)(Pt,{children:O.length===0?(0,$.jsx)(Ft,{children:(0,$.jsx)(Lt,{colSpan:7,className:`text-center whitespace-normal`,children:(0,$.jsx)(`p`,{className:`py-6 text-muted-foreground`,children:h.some(en)?`Some environment prices are unavailable.`:`No custom prices or mappings. Add a row to set one.`})})}):O.map(e=>{let t=Wt(h,e.model),n=(e.alias??t.value).trim();return(0,$.jsxs)(Ft,{"data-row-id":e.id,children:[(0,$.jsxs)(Lt,{className:`whitespace-normal`,children:[e.isNew?(0,$.jsx)(xe,{size:`compact`,value:e.model,ref:t=>{t&&T.current===e.id&&(t.focus(),T.current=null)},"aria-label":`New model ID`,"aria-invalid":e.model.trim()!==``&&z.has(e.id)||void 0,list:`usage-price-models`,placeholder:`Model ID`,autoComplete:`off`,spellCheck:!1,disabled:W,onChange:t=>ue({...e,model:t.target.value})}):(0,$.jsx)(`span`,{className:N(`block break-all`,e.removed&&`text-muted-foreground line-through`),children:e.model}),z.has(e.id)&&(e.model.trim()!==``||Object.values(e.values).some($t))?(0,$.jsx)(`p`,{role:`alert`,className:`mt-1 text-xs text-destructive`,children:z.get(e.id)}):null]}),e.removed?(0,$.jsx)(Lt,{colSpan:5,children:(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Automatic pricing after saving`})}):(0,$.jsx)(Lt,{children:(0,$.jsx)(xe,{size:`compact`,value:e.alias??t.value,"aria-label":`Map ${e.model||`new model`} to model`,list:`usage-alias-models`,placeholder:e.isNew?`Optional`:t.placeholder,autoComplete:`off`,spellCheck:!1,disabled:W,onChange:t=>me(e,t.target.value)})}),e.removed?null:n===``?Rt.map(t=>{let n=Gt(h,e.model,t.key);return(0,$.jsx)(Lt,{children:(0,$.jsx)(xe,{size:`compact`,inputMode:`decimal`,"aria-label":`${t.label} price for ${e.model||`new model`}`,value:e.values[t.key]??(e.isNew?``:n.value),placeholder:e.isNew?t.optional?`Input rate`:`0.00`:n.placeholder,autoComplete:`off`,disabled:W,font:`mono`,onChange:n=>Y(e,t.key,n.target.value)})},t.key)}):(0,$.jsx)(Lt,{colSpan:4,className:`whitespace-normal`,children:(0,$.jsxs)(`span`,{className:`break-all text-muted-foreground`,children:[`Counted as `,n]})}),(0,$.jsx)(Lt,{children:(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{render:(0,$.jsx)(D,{size:`icon-xs`,variant:`ghost`}),disabled:W,"aria-label":e.removed?`Undo reset for ${e.model}`:e.isNew?`Remove new model`:`Reset price for ${e.model} to automatic`,onClick:()=>{e.isNew?y(t=>t.filter(t=>t.id!==e.id)):e.removed?fe({...e,removed:!1}):ue({...e,removed:!0})},children:e.isNew?(0,$.jsx)(l,{"aria-hidden":!0}):(0,$.jsx)(v,{"aria-hidden":!0})}),(0,$.jsx)(_e,{children:e.removed?`Undo reset`:e.isNew?`Remove row`:`Reset to automatic`})]})})]},e.id)})})]})}),(0,$.jsx)(`datalist`,{id:`usage-price-models`,children:o.filter(t=>!e.includes(t)).map(Qt)}),(0,$.jsx)(`datalist`,{id:`usage-alias-models`,children:o.filter(e=>h.every(t=>!Object.hasOwn(t.aliases??{},e))).map(Zt)}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Blank cache rates use the input price. Enter 0 for free tokens. A mapped model’s usage counts as the model it maps to.`,h.length>1?` Mixed cells keep each environment’s rate until you edit them.`:``]})]}),t[9]=C,t[10]=_,t[11]=d,t[12]=c,t[13]=b,t[14]=h,t[15]=f,t[16]=j,t[17]=i,t[18]=M,t[19]=P,t[20]=F,t[21]=L,t[22]=R,t[23]=z,t[24]=B,t[25]=V,t[26]=H,t[27]=ee,t[28]=te,t[29]=ne,t[30]=re,t[31]=ie,t[32]=oe}else M=t[18],P=t[19],F=t[20],L=t[21],R=t[22],z=t[23],B=t[24],V=t[25],H=t[26],ee=t[27],te=t[28],ne=t[29],re=t[30],ie=t[31],oe=t[32];let W;t[81]===C?W=t[82]:(W=C?(0,$.jsx)(`div`,{role:`status`,className:`grid gap-1 text-xs`,children:C.destinations.map(e=>{let t=C.results.get(e.environmentId);return(0,$.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate text-muted-foreground`,children:e.label}),(0,$.jsx)(`span`,{className:t?.status===`failed`?`text-right text-destructive`:`text-muted-foreground`,children:t?.status===`failed`?`Not saved · ${t.error}`:t?.status===`saved`?`Saved`:`Saving…`})]},e.environmentId)})}):null,t[81]=C,t[82]=W);let ce;t[83]!==M||t[84]!==W||t[85]!==ee||t[86]!==te?(ce=(0,$.jsxs)(M,{children:[ee,te,W]}),t[83]=M,t[84]=W,t[85]=ee,t[86]=te,t[87]=ce):ce=t[87];let le=V?`Changes apply to ${L}`:``,G;t[88]===le?G=t[89]:(G=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:le}),t[88]=le,t[89]=G);let K;t[90]!==R||t[91]!==B.length||t[92]!==V||t[93]!==b?(K=V?(0,$.jsx)(D,{variant:`ghost`,disabled:b,onClick:R,children:B.length>0?`Discard pending changes`:`Discard changes`}):null,t[90]=R,t[91]=B.length,t[92]=V,t[93]=b,t[94]=K):K=t[94];let ue=b||!V&&B.length===0||B.length===0&&(z.size>0||h.length===0),q;t[95]!==B.length||t[96]!==H?(q=()=>void H(B.length>0),t[95]=B.length,t[96]=H,t[97]=q):q=t[97];let de=b?`Saving…`:B.length>0?`Retry failed saves`:`Save changes`,fe;t[98]!==ue||t[99]!==q||t[100]!==de?(fe=(0,$.jsx)(D,{disabled:ue,onClick:q,children:de}),t[98]=ue,t[99]=q,t[100]=de,t[101]=fe):fe=t[101];let J;t[102]!==K||t[103]!==fe?(J=(0,$.jsxs)(`div`,{className:`flex w-full flex-wrap justify-end gap-2 sm:w-auto`,children:[K,fe]}),t[102]=K,t[103]=fe,t[104]=J):J=t[104];let Y;t[105]!==G||t[106]!==J?(Y=(0,$.jsxs)(Te,{variant:`bare`,className:`items-center sm:justify-between`,children:[G,J]}),t[105]=G,t[106]=J,t[107]=Y):Y=t[107];let pe;t[108]!==P||t[109]!==ce||t[110]!==Y||t[111]!==ne||t[112]!==re?(pe=(0,$.jsxs)(P,{className:ne,children:[re,ce,Y]}),t[108]=P,t[109]=ce,t[110]=Y,t[111]=ne,t[112]=re,t[113]=pe):pe=t[113];let me;return t[114]!==F||t[115]!==pe||t[116]!==ie||t[117]!==oe?(me=(0,$.jsx)(F,{open:ie,onOpenChange:oe,children:pe}),t[114]=F,t[115]=pe,t[116]=ie,t[117]=oe,t[118]=me):me=t[118],me}function Zt(e){return(0,$.jsx)(`option`,{value:e},e)}function Qt(e){return(0,$.jsx)(`option`,{value:e},e)}function $t(e){return e!==``}function en(e){return e.prices===null}function tn(e){return(0,$.jsx)(It,{children:e.label},e.key)}function nn(e){return(0,$.jsx)(`col`,{},e.key)}function rn(e){return e.environmentId}function an(e){let[t,n]=e;return[t,n.changes]}function on(e){return[e.environmentId,{status:`saving`}]}function sn(e,t,n){return!e.isNew&&t.placeholder!==`Mixed`&&t.placeholder!==`Unavailable`&&n===t.value}function cn(e){return!Vt(e)}function ln(e){return e.isNew}function un(e){return e.model.trim()}function dn(e){return e.isNew}function fn(e){return e.summary?.buckets.map(pn)??[]}function pn(e){return e.model}function mn(e){return[...Object.keys(e.prices??{}),...Object.keys(e.aliases??{})]}var hn=960,gn=260,_n=4,vn=8,yn=new Set;function bn(e,t,n){let r=e?.byProvider.get(t);return r===void 0?0:n===`tokens`?r.totalTokens:r.costUsd}function xn(e,t,n){return e.map(e=>{let r=t.get(e),i=Ye.map(e=>({provider:e,value:bn(r,e,n)}));return{bands:i,total:i.reduce((e,t)=>e+t.value,0)}})}function Sn(e){let t=e.length;if(t<2)return[0];let n=[];for(let r=0;r<t-1;r+=1){let t=(e[r+1]?.x??0)-(e[r]?.x??0),i=(e[r+1]?.y??0)-(e[r]?.y??0);n.push(t===0?0:i/t)}let r=Array.from({length:t},()=>0);r[0]=n[0]??0,r[t-1]=n[t-2]??0;for(let e=1;e<t-1;e+=1){let t=n[e-1]??0,i=n[e]??0;r[e]=t*i<=0?0:(t+i)/2}for(let e=0;e<t-1;e+=1){let t=n[e]??0;if(t===0){r[e]=0,r[e+1]=0;continue}let i=(r[e]??0)/t,a=(r[e+1]??0)/t,o=i*i+a*a;if(o>9){let n=3/Math.sqrt(o);r[e]=n*i*t,r[e+1]=n*a*t}}return r}function Cn(e){if(e.length<2)return[];let t=Sn(e),n=[];for(let r=0;r<e.length-1;r+=1){let i=e[r],a=e[r+1];if(i===void 0||a===void 0)continue;let o=a.x-i.x;n.push({from:i,c1:{x:i.x+o/3,y:i.y+(t[r]??0)*o/3},c2:{x:a.x-o/3,y:a.y-(t[r+1]??0)*o/3},to:a})}return n}function wn(e){let t=e[0];if(t===void 0)return``;let n=`M${t.from.x.toFixed(2)},${t.from.y.toFixed(2)}`;for(let t of e)n+=` C${t.c1.x.toFixed(2)},${t.c1.y.toFixed(2)} ${t.c2.x.toFixed(2)},${t.c2.y.toFixed(2)} ${t.to.x.toFixed(2)},${t.to.y.toFixed(2)}`;return n}function Tn(e){return e===``?``:`${e} L${hn},${gn} L0,${gn} Z`}function En(e,t){if(e<=0)return{max:0,ticks:[0]};let n=e/t,r=10**Math.floor(Math.log10(n)),i=n/r,a=(i>5?10:i>2?5:i>1?2:1)*r,o=Math.ceil(e/a)*a,s=[];for(let e=0;e<=o+a*1e-6;e+=a)s.push(e);return{max:o,ticks:s}}var Dn=Array.from({length:5},(e,t)=>t);function On(e,t){let n=e.reduce((e,t)=>t.bands.reduce((e,t)=>Math.max(e,t.value),e),0);return n===0&&t.size>0?{max:_n,ticks:Dn,labeled:!1}:{...En(n,_n),labeled:!0}}function kn(e,t){return t===0?gn:gn-e/t*252}function An(e,t,n,r,i){let a=xn(e,t,n),o=On(a,i),s=e.length<2?0:hn/(e.length-1);return{columns:a,scale:o,stepX:s,paths:r.map(e=>{let t=Ye.indexOf(e),n=wn(Cn(a.map((e,n)=>({x:n*s,y:kn(e.bands[t]?.value??0,o.max)}))));return{provider:e,loading:i.has(e),total:a.reduce((e,n)=>e+(n.bands[t]?.value??0),0),line:n,area:Tn(n)}}).toSorted((e,t)=>t.total-e.total)}}function jn(e){let t=(0,Q.c)(97),{providers:n,loadingProviders:r,days:i,daily:a,hours:o,hourly:s,metric:c,referenceTime:l,resolution:u,timeZone:d}=e,f=r===void 0?yn:r,p=u===`hour`?o:i,m;t[0]!==a||t[1]!==s||t[2]!==u?(m=u===`hour`?new Map(s.map(Pn)):new Map(a.map(Nn)),t[0]=a,t[1]=s,t[2]=u,t[3]=m):m=t[3];let h=m,[g,_]=(0,Z.useState)(null),v=(0,Z.useRef)(null),y=(0,Z.useRef)(null),b=(0,Z.useRef)(null),x;t[4]!==h||t[5]!==f||t[6]!==c||t[7]!==p||t[8]!==n?(x=An(p,h,c,n,f),t[4]=h,t[5]=f,t[6]=c,t[7]=p,t[8]=n,t[9]=x):x=t[9];let{columns:S,scale:C,paths:w,stepX:T}=x,E;t[10]===C.max?E=t[11]:(E=e=>kn(e,C.max),t[10]=C.max,t[11]=E);let D=E,O=Mn,k=c===`tokens`?q:G,A;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>{let e=v.current,t=y.current,n=b.current;if(e===null||t===null||n===null)return;let r=t.offsetWidth,i=t.offsetHeight,a=e.clientWidth,o=e.clientHeight,s=n.x+12+r<=a?n.x+12:n.x-12-r,c=n.y+12+i<=o?n.y+12:n.y-12-i,l=Math.min(Math.max(0,s),Math.max(0,a-r)),u=Math.min(Math.max(0,c),Math.max(0,o-i));e.style.setProperty(`--usage-tooltip-left`,`${l}px`),e.style.setProperty(`--usage-tooltip-top`,`${u}px`)},t[12]=A):A=t[12];let j=A,M,P;t[13]===g?(M=t[14],P=t[15]):(M=()=>{if(g===null)return;j();let e=v.current,t=y.current;if(e!==null&&t!==null)return je([e,t],j)},P=[g,j],t[13]=g,t[14]=M,t[15]=P),(0,Z.useLayoutEffect)(M,P);let F;t[16]===p.length?F=t[17]:(F=e=>{let t=v.current;if(t===null||p.length===0)return;let n=t.getBoundingClientRect();if(n.width===0)return;let r=Math.min(n.width,Math.max(0,e.clientX-n.left)),i=Math.min(n.height,Math.max(0,e.clientY-n.top)),a=r/n.width,o=Math.round(a*(p.length-1));b.current={x:r,y:i},j(),_(Math.min(p.length-1,Math.max(0,o)))},t[16]=p.length,t[17]=F);let I=F,L=g===null?void 0:p[g],R=g===null?void 0:S[g],z;if(t[18]!==f||t[19]!==n){let e;t[21]===f?e=t[22]:(e=e=>f.has(e),t[21]=f,t[22]=e),z=n.some(e),t[18]=f,t[19]=n,t[20]=z}else z=t[20];let B=z,V;t[23]!==u||t[24]!==d?(V=e=>u===`hour`?fe(e,d):ce(e),t[23]=u,t[24]=d,t[25]=V):V=t[25];let H=V,ee;t[26]!==H||t[27]!==l||t[28]!==u||t[29]!==d?(ee=e=>u===`hour`&&l!==void 0?le(e,l,d):H(e),t[26]=H,t[27]=l,t[28]=u,t[29]=d,t[30]=ee):ee=t[30];let te=ee,ne;t[31]!==k||t[32]!==C.labeled||t[33]!==C.ticks||t[34]!==D?(ne=C.labeled?C.ticks.map(e=>(0,$.jsx)(`span`,{className:`absolute right-0 -translate-y-1/2 text-3xs text-muted-foreground tabular-nums`,style:{top:`${D(e)/gn*100}%`},children:e===0?`0`:k(e)},e)):null,t[31]=k,t[32]=C.labeled,t[33]=C.ticks,t[34]=D,t[35]=ne):ne=t[35];let re;t[36]===ne?re=t[37]:(re=(0,$.jsx)(`div`,{className:`relative h-56 w-14 shrink-0`,children:ne}),t[36]=ne,t[37]=re);let ie;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>{b.current=null,_(null)},t[38]=ie):ie=t[38];let ae=`${u===`hour`?`Hourly`:`Daily`} ${c===`tokens`?`processed tokens`:`cost`} by provider`,oe;if(t[39]!==C.ticks||t[40]!==D){let e;t[42]===D?e=t[43]:(e=e=>{let t=D(e);return(0,$.jsx)(`line`,{x1:0,x2:hn,y1:t,y2:t,stroke:`currentColor`,strokeWidth:1,className:`text-border`,vectorEffect:`non-scaling-stroke`},e)},t[42]=D,t[43]=e),oe=C.ticks.map(e),t[39]=C.ticks,t[40]=D,t[41]=oe}else oe=t[41];let U;if(t[44]!==w){let e;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>{let{provider:t,loading:n,area:r}=e;return(0,$.jsx)(`path`,{d:r,className:O(n),fill:Xe[t].color,fillOpacity:.12},t)},t[46]=e):e=t[46],U=w.map(e),t[44]=w,t[45]=U}else U=t[45];let W;if(t[47]!==w){let e;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>{let{provider:t,loading:n,line:r}=e;return(0,$.jsx)(`path`,{d:r,className:O(n),fill:`none`,stroke:Xe[t].color,strokeWidth:2,vectorEffect:`non-scaling-stroke`},t)},t[49]=e):e=t[49],W=w.map(e),t[47]=w,t[48]=W}else W=t[48];let se;t[50]!==g||t[51]!==T?(se=g===null?null:(0,$.jsx)(`line`,{x1:g*T,x2:g*T,y1:vn,y2:gn,stroke:`currentColor`,strokeWidth:1,className:`text-muted-foreground`,vectorEffect:`non-scaling-stroke`}),t[50]=g,t[51]=T,t[52]=se):se=t[52];let K;t[53]!==ae||t[54]!==oe||t[55]!==U||t[56]!==W||t[57]!==se?(K=(0,$.jsxs)(`svg`,{className:`h-full w-full`,viewBox:`0 0 ${hn} ${gn}`,preserveAspectRatio:`none`,role:`img`,"aria-label":ae,children:[oe,U,W,se]}),t[53]=ae,t[54]=oe,t[55]=U,t[56]=W,t[57]=se,t[58]=K):K=t[58];let ue;t[59]!==k||t[60]!==te||t[61]!==R?.bands||t[62]!==R?.total||t[63]!==L||t[64]!==f||t[65]!==B||t[66]!==n?(ue=L===void 0?null:(0,$.jsxs)(`div`,{ref:y,className:`surface-glass pointer-events-none absolute z-10 min-w-36 max-w-full rounded-xl border border-border/50 px-2.5 py-2 text-xs shadow-lg`,style:{left:`var(--usage-tooltip-left, 0px)`,top:`var(--usage-tooltip-top, 0px)`},children:[(0,$.jsx)(`div`,{className:`mb-1 text-muted-foreground`,children:te(L)}),n.map(e=>{let{label:t,driverKind:n}=Xe[e];return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,$.jsx)(Le,{driverKind:n,displayName:t,iconClassName:`size-3`}),t]}),(0,$.jsx)(`span`,{className:N(`tabular-nums`,f.has(e)?`text-muted-foreground`:`text-foreground`),children:k(R?.bands.find(t=>t.provider===e)?.value??0)})]},e)}),(0,$.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-3 border-t border-border pt-1`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Total`}),(0,$.jsx)(`span`,{className:N(`tabular-nums`,B?`text-muted-foreground`:`text-foreground`),children:k(R?.total??0)})]})]}),t[59]=k,t[60]=te,t[61]=R?.bands,t[62]=R?.total,t[63]=L,t[64]=f,t[65]=B,t[66]=n,t[67]=ue):ue=t[67];let de;t[68]!==I||t[69]!==K||t[70]!==ue?(de=(0,$.jsxs)(`div`,{ref:v,className:`relative h-56 flex-1`,onMouseMove:I,onMouseLeave:ie,children:[K,ue]}),t[68]=I,t[69]=K,t[70]=ue,t[71]=de):de=t[71];let J;t[72]!==re||t[73]!==de?(J=(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[re,de]}),t[72]=re,t[73]=de,t[74]=J):J=t[74];let Y;t[75]!==H||t[76]!==p[0]?(Y=p[0]===void 0?``:H(p[0]),t[75]=H,t[76]=p[0],t[77]=Y):Y=t[77];let pe;t[78]===Y?pe=t[79]:(pe=(0,$.jsx)(`span`,{children:Y}),t[78]=Y,t[79]=pe);let me;t[80]!==H||t[81]!==p?(me=p[Math.floor(p.length/2)]===void 0?``:H(p[Math.floor(p.length/2)]??``),t[80]=H,t[81]=p,t[82]=me):me=t[82];let he;t[83]===me?he=t[84]:(he=(0,$.jsx)(`span`,{children:me}),t[83]=me,t[84]=he);let ge;t[85]!==H||t[86]!==p?(ge=p[p.length-1]===void 0?``:H(p[p.length-1]??``),t[85]=H,t[86]=p,t[87]=ge):ge=t[87];let _e;t[88]===ge?_e=t[89]:(_e=(0,$.jsx)(`span`,{children:ge}),t[88]=ge,t[89]=_e);let ve;t[90]!==pe||t[91]!==he||t[92]!==_e?(ve=(0,$.jsxs)(`div`,{className:`flex justify-between pl-16 text-3xs text-muted-foreground uppercase`,children:[pe,he,_e]}),t[90]=pe,t[91]=he,t[92]=_e,t[93]=ve):ve=t[93];let X;return t[94]!==J||t[95]!==ve?(X=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[J,ve]}),t[94]=J,t[95]=ve,t[96]=X):X=t[96],X}function Mn(e){return N(`transition-opacity`,e&&`opacity-40 delay-150`)}function Nn(e){return[e.day,e]}function Pn(e){return[e.hourStart,e]}function Fn(e){let t=(0,Q.c)(30),{label:n,segments:r,format:i,aside:a}=e,o,s,c,l,u,d;if(t[0]!==a||t[1]!==i||t[2]!==n||t[3]!==r){d=Symbol.for(`react.early_return_sentinel`);bb0:{let e=r.filter(Ln),f=e.reduce(In,0);if(f<=0){d=null;break bb0}c=`flex min-w-0 flex-col gap-2.5`;let p;t[10]===n?p=t[11]:(p=(0,$.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:n}),t[10]=n,t[11]=p),t[12]!==a||t[13]!==p?(l=(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[p,a]}),t[12]=a,t[13]=p,t[14]=l):l=t[14];let m;t[15]===i?m=t[16]:(m=e=>`${e.label} ${i(e.value)}`,t[15]=i,t[16]=m);let h;t[17]!==i||t[18]!==f?(h=e=>(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{render:(0,$.jsx)(`div`,{className:`h-full min-w-1 rounded-xs first:rounded-l-full last:rounded-r-full`,style:{flex:`${e.value} 1 0`,backgroundColor:e.color}})}),(0,$.jsxs)(_e,{children:[e.label,` · `,i(e.value),` · `,Y(e.value/f)]})]},e.label),t[17]=i,t[18]=f,t[19]=h):h=t[19],u=(0,$.jsx)(`div`,{role:`img`,"aria-label":`${n}: ${e.map(m).join(`, `)}`,className:`flex h-2 gap-0.5`,children:e.map(h)}),o=`flex flex-wrap gap-x-4 gap-y-1 text-xs`;let g;t[20]===i?g=t[21]:(g=e=>(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-2 rounded-xs`,style:{backgroundColor:e.color}}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,$.jsx)(`span`,{className:`text-foreground tabular-nums`,children:i(e.value)})]},e.label),t[20]=i,t[21]=g),s=e.map(g)}t[0]=a,t[1]=i,t[2]=n,t[3]=r,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;t[22]!==o||t[23]!==s?(f=(0,$.jsx)(`div`,{className:o,children:s}),t[22]=o,t[23]=s,t[24]=f):f=t[24];let p;return t[25]!==c||t[26]!==l||t[27]!==u||t[28]!==f?(p=(0,$.jsxs)(`div`,{className:c,children:[l,u,f]}),t[25]=c,t[26]=l,t[27]=u,t[28]=f,t[29]=p):p=t[29],p}function In(e,t){return e+t.value}function Ln(e){return e.value>0}function Rn(e){return e.toSorted((e,t)=>t.totalTokens-e.totalTokens||t.costUsd-e.costUsd)}function zn(e,t){return t===`tokens`?e.tokenShare:pt(e)?null:e.costShare}function Bn({tokens:e}){let t=e.uncachedInputTokens+e.cachedInputTokens+e.cacheCreationTokens;return t===0?null:e.cachedInputTokens/t}function Vn(e){let t=e.totalTokens-e.unpricedTokens;return t<=0||pt(e)?null:e.costUsd/t*1e6}var Hn=e=>`color-mix(in oklab, var(--foreground) ${e}%, var(--background))`,Un={input:Hn(60),cacheRead:Hn(30),cacheWrite:Hn(72),output:Hn(100),other:Hn(44)};function Wn(e){return[{label:`Input`,value:e.input,color:Un.input},{label:`Cache read`,value:e.cacheRead,color:Un.cacheRead},{label:`Cache write`,value:e.cacheWrite,color:Un.cacheWrite},{label:`Output`,value:e.output,color:Un.output},{label:`Other`,value:e.unsplit>=.005?e.unsplit:0,color:Un.other}]}function Gn(e){return[{label:`Input`,value:e.uncachedInputTokens,color:Un.input},{label:`Cache read`,value:e.cachedInputTokens,color:Un.cacheRead},{label:`Cache write`,value:e.cacheCreationTokens,color:Un.cacheWrite},{label:`Output`,value:e.outputTokens,color:Un.output}]}function Kn(e){return[{label:`Standard`,value:e.standard,color:Hn(34)},{label:`Fast`,value:e.fast,color:Hn(66)},{label:`Ultrafast`,value:e.ultrafast,color:Hn(100)}]}function qn(e){let t=(0,Q.c)(80),{model:n,environments:r,metric:i,chartWindow:a,onSetPrice:o,onClose:s}=e,c;t[0]!==n.model||t[1]!==n.provider?(c=e=>e.provider===n.provider&&e.model===n.model,t[0]=n.model,t[1]=n.provider,t[2]=c):c=t[2];let l;t[3]!==r||t[4]!==c?(l=wt(r,c),t[3]=r,t[4]=c,t[5]=l):l=t[5];let u=l,d;t[6]===n.provider?d=t[7]:(d=[n.provider],t[6]=n.provider,t[7]=d);let f=d,p=Xe[n.provider],m;t[8]===n?m=t[9]:(m=pt(n),t[8]=n,t[9]=m);let h=m,g;if(t[10]!==h||t[11]!==n){let e=Bn(n),r=Vn(n),i;t[13]!==h||t[14]!==n.costUsd?(i=h?`Unpriced`:G(n.costUsd),t[13]=h,t[14]=n.costUsd,t[15]=i):i=t[15];let a;t[16]===i?a=t[17]:(a={label:`Cost`,value:i},t[16]=i,t[17]=a);let o;t[18]===n.totalTokens?o=t[19]:(o=q(n.totalTokens),t[18]=n.totalTokens,t[19]=o);let s;t[20]===o?s=t[21]:(s={label:`Tokens`,value:o},t[20]=o,t[21]=s),g=[a,s,r===null?null:{label:`Per 1M tokens`,value:G(r)},e===null?null:{label:`Cache hit`,value:Y(e)}].filter(Yn),t[10]=h,t[11]=n,t[12]=g}else g=t[12];let _=g,v;t[22]===s?v=t[23]:(v=e=>{e||s()},t[22]=s,t[23]=v);let y;t[24]!==p.driverKind||t[25]!==p.label?(y=(0,$.jsx)(Le,{driverKind:p.driverKind,displayName:p.label,iconClassName:`size-5`}),t[24]=p.driverKind,t[25]=p.label,t[26]=y):y=t[26];let b;t[27]===n.model?b=t[28]:(b=(0,$.jsx)(we,{children:n.model}),t[27]=n.model,t[28]=b);let x;t[29]!==y||t[30]!==b?(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y,b]}),t[29]=y,t[30]=b,t[31]=x):x=t[31];let S;t[32]!==h||t[33]!==n.costShare?(S=h?``:` · ${Y(n.costShare)} of cost`,t[32]=h,t[33]=n.costShare,t[34]=S):S=t[34];let C;t[35]!==p.label||t[36]!==S?(C=(0,$.jsxs)(De,{children:[p.label,S]}),t[35]=p.label,t[36]=S,t[37]=C):C=t[37];let w;t[38]!==C||t[39]!==x?(w=(0,$.jsxs)(Ce,{children:[x,C]}),t[38]=C,t[39]=x,t[40]=w):w=t[40];let T;t[41]===_?T=t[42]:(T=(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-4 sm:grid-cols-4`,children:_.map(Jn)}),t[41]=_,t[42]=T);let E=h?`tokens`:i,O;t[43]!==a.days||t[44]!==a.hours||t[45]!==a.referenceTime||t[46]!==a.resolution||t[47]!==a.timeZone||t[48]!==f||t[49]!==E||t[50]!==u.daily||t[51]!==u.hourly?(O=(0,$.jsx)(jn,{providers:f,days:a.days,daily:u.daily,hours:a.hours,hourly:u.hourly,metric:E,referenceTime:a.referenceTime,resolution:a.resolution,timeZone:a.timeZone}),t[43]=a.days,t[44]=a.hours,t[45]=a.referenceTime,t[46]=a.resolution,t[47]=a.timeZone,t[48]=f,t[49]=E,t[50]=u.daily,t[51]=u.hourly,t[52]=O):O=t[52];let k;t[53]!==h||t[54]!==u.categoryCost?(k=h?null:(0,$.jsx)(Fn,{label:`Cost by type`,segments:Wn(u.categoryCost),format:G}),t[53]=h,t[54]=u.categoryCost,t[55]=k):k=t[55];let A;t[56]===n.tokens?A=t[57]:(A=Gn(n.tokens),t[56]=n.tokens,t[57]=A);let j;t[58]===A?j=t[59]:(j=(0,$.jsx)(Fn,{label:`Tokens by type`,segments:A,format:q}),t[58]=A,t[59]=j);let M;t[60]===u.speedCost?M=t[61]:(M=u.speedCost.fast+u.speedCost.ultrafast>0?(0,$.jsx)(Fn,{label:`Cost by speed`,segments:Kn(u.speedCost),format:G,aside:(0,$.jsx)(Xn,{premiumUsd:u.speedCost.premium})}):null,t[60]=u.speedCost,t[61]=M);let N;t[62]!==k||t[63]!==j||t[64]!==M?(N=(0,$.jsxs)(`div`,{className:`grid gap-x-10 gap-y-8 sm:grid-cols-2`,children:[k,j,M]}),t[62]=k,t[63]=j,t[64]=M,t[65]=N):N=t[65];let P;t[66]!==T||t[67]!==O||t[68]!==N?(P=(0,$.jsx)(Ee,{children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[T,O,N]})}),t[66]=T,t[67]=O,t[68]=N,t[69]=P):P=t[69];let F;t[70]!==n.unpricedTokens||t[71]!==o?(F=n.unpricedTokens>0?(0,$.jsxs)(Te,{variant:`bare`,className:`items-center sm:justify-between`,children:[(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[q(n.unpricedTokens),` tokens have no known price`]}),(0,$.jsx)(D,{onClick:o,children:`Set price`})]}):null,t[70]=n.unpricedTokens,t[71]=o,t[72]=F):F=t[72];let I;t[73]!==w||t[74]!==P||t[75]!==F?(I=(0,$.jsxs)(Oe,{className:`max-w-3xl`,children:[w,P,F]}),t[73]=w,t[74]=P,t[75]=F,t[76]=I):I=t[76];let L;return t[77]!==I||t[78]!==v?(L=(0,$.jsx)(ke,{open:!0,onOpenChange:v,children:I}),t[77]=I,t[78]=v,t[79]=L):L=t[79],L}function Jn(e){return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,$.jsx)(`span`,{className:`text-2xl font-semibold text-foreground`,children:e.value})]},e.label)}function Yn(e){return e!==null}function Xn(e){let t=(0,Q.c)(4),{premiumUsd:n}=e,r;t[0]===n?r=t[1]:(r=G(n),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Premium `,(0,$.jsx)(`span`,{className:`text-foreground tabular-nums`,children:r})]}),t[2]=r,t[3]=i),i}var Zn=`p4code:usage-page-preferences:v1`,Qn=g({metric:d([`cost`,`tokens`,`limits`]),windowDays:d([1,7,30,90]),hiddenProviders:w(h(C))}),$n={metric:`limits`,windowDays:30};function er(){try{return o(Zn,Qn)??$n}catch(e){return console.error(`Could not read Usage page preferences.`,e),$n}}function tr(e){try{T(Zn,e,Qn)}catch(e){console.error(`Could not save Usage page preferences.`,e)}}function nr(e){return He.some(t=>t.value===e)}function rr(e){return Be.some(t=>t.days===e)}var ir=e=>Xe[e].label;function ar(){let[e,t]=(0,Z.useState)(er);re();let n=r(oe),i=e=>{let t=Me(n,e.command,{context:{usagePageOpen:!0}});return t?`${e.label} (${t})`:e.label},[a,o]=(0,Z.useState)(()=>({days:e.windowDays,window:K(e.windowDays,void 0,e.windowDays===1?`hour`:`day`)})),s=e.metric,c=s===`limits`,[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(()=>Date.now()),p=(0,Z.useRef)(!1),[h,g]=(0,Z.useState)(`model`),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(null),C=(0,Z.useMemo)(()=>new Set(e.hiddenProviders),[e.hiddenProviders]),{days:w,window:T}=a,E=w===1,{merged:O,environments:k,selectedEnvironments:A,shown:j,isPartial:M,refresh:P}=Dt(T,x,C),I=j?.merged??O,L=j?.window??T,R=L.resolution===`hour`,z=l&&!c,B=j!==null&&j.window!==T,U=(0,Z.useMemo)(()=>{if(B)return{partial:!0,everyProvider:!0,providers:new Set};let e=ft(A,z),t=new Set([...e.providers].filter(e=>!C.has(e)));return{partial:e.everyProvider||t.size>0,everyProvider:e.everyProvider,providers:t}},[B,z,A,C]),W=e=>U.everyProvider||U.providers.has(e),le=r(ie.presentationsAtom),me=C.has(`cursor`)?[]:at(A),ge=[...new Set(A.flatMap(e=>e.summary?.sources.flatMap(e=>e.message&&!e.action&&!C.has(e.fingerprint.provider)&&(e.status===`partial`||e.status===`failed`||e.fingerprint.provider===`cursor`)?[e.message]:[])??[]))],_e=se(ae.refreshProviders,{reportFailure:!1}),ve=A.some(e=>e.canReadDiagnostics),X=(0,Z.useMemo)(()=>pe(L.sinceDay,L.untilDay),[L.sinceDay,L.untilDay]),xe=(0,Z.useMemo)(()=>L.sinceTime===void 0||L.untilTime===void 0?[]:de(L.sinceTime,L.untilTime),[L.sinceTime,L.untilTime]),Ce=(0,Z.useMemo)(()=>(R?I.hourly:I.daily).toReversed(),[R,I.daily,I.hourly]),we=(0,Z.useMemo)(()=>h===`model`&&s===`tokens`?Rn(I.models):I.models,[h,I.models,s]),Te=(0,Z.useMemo)(()=>qe(I.providers),[I.providers]),Ee=(0,Z.useMemo)(()=>Ye.filter(e=>Te.includes(e)||U.providers.has(e)),[U.providers,Te]),De=(0,Z.useMemo)(()=>new Set(Ee.filter(e=>U.everyProvider||U.providers.has(e))),[Ee,U.everyProvider,U.providers]),Oe=y===null?void 0:I.models.find(e=>`${e.provider}:${e.model}`===y),ke=we.reduce((e,t)=>Math.max(e,s===`tokens`?t.totalTokens:t.costUsd),0),je=Ee.map(e=>({kind:`usage`,provider:e})),Le=Math.max(Ee.indexOf(`codex`),Ee.indexOf(`claude`))+1;je.splice(Le,0,...me.map(e=>({kind:`enable`,environment:e})));let Je=`${60/(Ee.length+2)}%`,Qe=n=>{let r={...e,...n};t(r),tr(r)},nt=e=>{rr(e)&&(Qe({windowDays:e}),o({days:e,window:K(e,void 0,e===1?`hour`:`day`)}))},Q=e=>{e===`limits`&&f(Date.now()),Qe({metric:e})},rt=async(e=!1,t=!1)=>{try{await Promise.all(Array.from(le,([n,r])=>{if((x===null||x.has(n))&&r.connection.phase===`connected`&&r.serverConfig!==null)return ct(n,()=>_e({environmentId:n,input:{}}),e,t)}))}finally{f(Date.now())}},it=(0,Z.useEffectEvent)(e=>{if(e.defaultPrevented||e.repeat||e.isComposing||Ge()||Ue())return;let t=Ve(e,n),r=He.find(e=>e.command===t),i=Be.find(e=>e.command===t);(r||i)&&(e.preventDefault(),e.stopPropagation(),r&&Q(r.value),i&&!c&&nt(i.days))});(0,Z.useEffect)(()=>(globalThis.window.addEventListener(`keydown`,it,!0),()=>globalThis.window.removeEventListener(`keydown`,it,!0)),[]);let ot=()=>{if(p.current)return;if(c){p.current=!0,u(!0),rt().finally(()=>{p.current=!1,u(!1)});return}let e=K(w,void 0,E?`hour`:`day`);(e.sinceDay!==T.sinceDay||e.untilDay!==T.untilDay||e.sinceTime!==T.sinceTime||e.untilTime!==T.untilTime)&&o({days:w,window:e}),p.current=!0,u(!0),P(e).finally(()=>{p.current=!1,u(!1)})},st=[...le].filter(([e,t])=>t.connection.phase===`connected`&&t.serverConfig!==null&&(x===null||x.has(e))).map(([e])=>e).sort().join(`,`),lt=(0,Z.useEffectEvent)(()=>{rt(!0)});(0,Z.useEffect)(()=>{c&&st&<()},[c,st]);let ut=R&&L.sinceTime!==void 0&&L.untilTime!==void 0?`${ue(L.sinceTime,L.timeZone)} to ${ue(L.untilTime,L.timeZone)}`:`${ce(L.sinceDay)} to ${ce(L.untilDay)}`,dt=(0,$.jsxs)(`div`,{className:`grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 py-2 xl:flex`,children:[(0,$.jsxs)(tt,{ariaLabel:`Usage breadcrumb`,className:`min-w-0`,children:[(0,$.jsx)($e,{children:(0,$.jsx)(`h1`,{children:`Usage`})}),(0,$.jsx)(et,{}),(0,$.jsx)($e,{className:`min-w-10 shrink`,children:(0,$.jsx)(vr,{environments:k,selectedEnvironments:A,selectedEnvironmentIds:x,onSelectionChange:S,showUsageStatus:!c,refreshing:z,isPartial:M,duplicateSources:I.duplicateSources,contractMismatches:I.contractMismatches,onOpenModelPrices:()=>v({})})}),(0,$.jsx)(et,{}),(0,$.jsx)($e,{current:!0,className:`min-w-10`,children:(0,$.jsx)(xr,{hiddenProviders:C,onChange:e=>Qe({hiddenProviders:e})})})]}),c?null:(0,$.jsx)(`span`,{className:`hidden min-w-0 truncate text-xs text-muted-foreground 2xl:block`,children:ut}),(0,$.jsxs)(`div`,{className:`ms-auto hidden min-w-0 items-center justify-end gap-2 xl:flex`,children:[(0,$.jsx)(ye,{"aria-label":`Usage metric`,variant:`segmented`,value:[s],onValueChange:e=>{let t=e[0];nr(t)&&Q(t)},children:He.map(e=>(0,$.jsx)(be,{value:e.value,title:i(e),children:e.label},e.value))}),(0,$.jsx)(ye,{"aria-label":`Usage period`,variant:`segmented`,value:[String(w)],disabled:c,onValueChange:e=>{let t=e[0];t&&nt(Number(t))},children:Be.map(e=>(0,$.jsx)(be,{value:String(e.days),title:i(e),children:e.label},e.days))}),(0,$.jsx)(D,{onClick:ot,"aria-label":c?`Refresh limits`:`Refresh usage`,"aria-busy":l,disabled:l||!c&&!ve,size:`icon-sm`,variant:`ghost`,children:(0,$.jsx)(We,{size:`sm`,refreshing:l})})]}),(0,$.jsxs)(`div`,{className:`ms-auto flex min-w-0 items-center justify-end gap-1 xl:hidden`,children:[(0,$.jsxs)(ne,{value:s,onValueChange:e=>{nr(e)&&Q(e)},children:[(0,$.jsx)(te,{"aria-label":`Usage metric`,size:`compact`,variant:`ghost`,className:`w-auto min-w-0`,children:(0,$.jsx)(H,{children:He.find(e=>e.value===s)?.label})}),(0,$.jsx)(ee,{align:`end`,alignItemWithTrigger:!1,children:He.map(e=>(0,$.jsx)(V,{value:e.value,title:i(e),children:e.label},e.value))})]}),(0,$.jsxs)(ne,{value:String(w),disabled:c,onValueChange:e=>nt(Number(e)),children:[(0,$.jsx)(te,{"aria-label":`Usage period`,size:`compact`,variant:`ghost`,className:`w-auto min-w-0`,children:(0,$.jsx)(H,{children:Be.find(e=>e.days===w)?.label})}),(0,$.jsx)(ee,{align:`end`,alignItemWithTrigger:!1,children:Be.map(e=>(0,$.jsx)(V,{value:String(e.days),title:i(e),children:e.label},e.days))})]}),(0,$.jsx)(D,{onClick:ot,"aria-label":c?`Refresh limits`:`Refresh usage`,"aria-busy":l,disabled:l||!c&&!ve,size:`icon-sm`,variant:`ghost`,children:(0,$.jsx)(We,{size:`sm`,refreshing:l})})]})]});return(0,$.jsxs)(Ae,{className:`h-dvh min-h-0 overflow-hidden overscroll-y-none isolate`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-background text-foreground`,children:[(0,$.jsx)(Ze,{electron:he,children:dt}),(0,$.jsx)(Se,{className:`min-h-0 flex-1`,children:(0,$.jsx)(ze,{width:`wide`,children:A.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:k.length===0?`Connect an environment to see ${c?`limits`:`usage`}.`:`Select an environment to see ${c?`limits`:`usage`}.`}):c?(0,$.jsx)(Ke,{selectedEnvironmentIds:x,hiddenProviders:C,now:d,cursorPrompt:me.length>0?(0,$.jsx)(lr,{environments:me,onEnabled:()=>{P(),rt(!1,!0)}}):null}):j===null?(0,$.jsx)(Sr,{}):ve?(0,$.jsxs)(`div`,{"aria-busy":U.partial,className:`flex flex-col gap-6`,children:[ge.map(e=>(0,$.jsx)(`p`,{className:`mb-4 text-sm text-muted-foreground`,children:e},e)),(0,$.jsxs)(`section`,{className:`grid gap-6 lg:grid-cols-[minmax(0,18rem)_minmax(0,1fr)]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:N(`text-4xl font-semibold text-foreground tabular-nums`,dr(U.partial)),children:s===`cost`?G(I.costUsd):q(I.totalTokens)}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsxs)(`span`,{className:dr(U.partial),children:[J(I.sessions),` sessions`]}),s===`cost`&&` · API estimate`]}),s===`cost`&&I.costQuality.unpricedShare>0&&(0,$.jsxs)(Fe,{children:[(0,$.jsx)(Pe,{openOnHover:!0,render:(0,$.jsx)(F,{tone:`muted`}),"aria-label":`Unpriced usage details`,children:(0,$.jsx)(m,{className:`size-3`,"aria-hidden":!0})}),(0,$.jsxs)(Ne,{side:`top`,tooltipStyle:!0,children:[`API estimate excludes`,` `,Y(I.costQuality.unpricedShare),` unpriced records.`]})]})]})]}),!C.has(`codex`)&&[...le].some(([e,t])=>(x===null||x.has(e))&&t.serverConfig?.providers.some(Ie))?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:`ChatGPT shared usage`}),(0,$.jsx)(Re,{size:`xs`})]}):null,je.map(e=>{if(e.kind===`enable`)return(0,$.jsx)(cr,{environmentId:e.environment.environmentId,label:e.environment.label,showEnvironment:A.length>1,onEnabled:()=>{P(),rt(!1,!0)}},`enable:${e.environment.environmentId}`);let t=e.provider,n=I.providers.find(e=>e.provider===t),r=s===`cost`?n?.costShare??0:n?.tokenShare??0,i=n?.sessions??0,a=`${J(i)} ${i===1?`session`:`sessions`}`,o=W(t),c=o&&!Te.includes(t);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm text-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-2 shrink-0 rounded-full`,style:{backgroundColor:Xe[t].color}}),(0,$.jsx)(ur,{provider:t,className:`size-4`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:Xe[t].label}),(0,$.jsx)(`span`,{className:N(`shrink-0 whitespace-nowrap text-2xs text-muted-foreground tabular-nums`,dr(o),c&&`invisible`),children:a})]})]}),(0,$.jsx)(`span`,{className:N(`shrink-0 text-sm font-medium text-foreground tabular-nums`,dr(o)),children:c?`—`:s===`cost`?G(n?.costUsd??0):q(n?.totalTokens??0)})]}),(0,$.jsx)(`span`,{className:N(`text-xs text-muted-foreground`,dr(o),c&&`invisible`),children:s===`cost`?`${Y(r)} of cost · ${q(n?.totalTokens??0)} tokens`:`${Y(r)} of tokens · ${G(n?.costUsd??0)}`})]},t)})]}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,$.jsxs)(`h2`,{className:`text-sm font-medium text-foreground`,children:[R?`Hourly`:`Daily`,` `,s===`tokens`?`processed tokens`:`cost`]}),(0,$.jsx)(jn,{providers:Ee,loadingProviders:De,days:X,daily:I.daily,hours:xe,hourly:I.hourly,metric:s,referenceTime:L.untilTime,resolution:R?`hour`:`day`,timeZone:L.timeZone})]})]}),(0,$.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Totals`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-4 py-1 md:grid-cols-5`,children:[(0,$.jsx)(fr,{loading:U.partial,label:`Processed tokens`,value:q(I.totalTokens)}),(0,$.jsx)(fr,{loading:U.partial,label:`Cached input`,value:q(I.cachedInputTokens)}),(0,$.jsx)(fr,{loading:U.partial,label:`Uncached input`,value:q(I.uncachedInputTokens)}),(0,$.jsx)(fr,{loading:U.partial,label:`Output`,value:q(I.outputTokens)}),(0,$.jsx)(fr,{loading:U.partial,label:`Cache savings`,value:G(I.costQuality.cacheSavingsUsd)})]})]}),I.totalTokens>0?(0,$.jsx)(`section`,{className:N(`grid gap-x-12 gap-y-8 lg:grid-cols-2`,dr(U.partial)),children:s===`tokens`?(0,$.jsx)(Fn,{label:`Tokens by type`,segments:Gn(I),format:q}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Fn,{label:`Cost by type`,segments:Wn(I.categoryCost),format:G}),I.speedCost.fast+I.speedCost.ultrafast>0?(0,$.jsx)(Fn,{label:`Cost by speed`,segments:Kn(I.speedCost),format:G,aside:(0,$.jsx)(Xn,{premiumUsd:I.speedCost.premium})}):null]})}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Breakdown`}),(0,$.jsx)(ye,{"aria-label":`Usage breakdown`,variant:`segmented`,value:[h],onValueChange:e=>{let t=e[0];(t===`model`||t===`time`)&&g(t)},children:[{value:`model`,label:`Model`},{value:`time`,label:R?`Hour`:`Day`}].map(e=>(0,$.jsx)(be,{value:e.value,children:e.label},e.value))})]}),h===`model`?(0,$.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b border-border text-right text-xs text-muted-foreground`,children:[(0,$.jsx)(`th`,{className:`py-2 pr-3 text-left font-normal`,children:`#`}),(0,$.jsx)(`th`,{className:`w-full py-2 text-left font-normal`,children:`Model`}),(0,$.jsx)(`th`,{className:`py-2 pl-6 font-normal`,children:`Cost`}),(0,$.jsx)(`th`,{className:`hidden py-2 pl-6 font-normal sm:table-cell`,children:`Share`}),(0,$.jsx)(`th`,{className:`py-2 pl-6 font-normal`,children:`Tokens`})]})}),(0,$.jsx)(`tbody`,{children:we.length===0?(0,$.jsx)(`tr`,{children:(0,$.jsx)(`td`,{colSpan:5,className:`py-6 text-center text-muted-foreground`,children:`No activity in this window.`})}):we.map((e,t)=>{let n=`${e.provider}:${e.model}`,r=s===`tokens`?e.totalTokens:e.costUsd,i=zn(e,s===`tokens`?`tokens`:`cost`),a=dr(W(e.provider));return(0,$.jsxs)(`tr`,{className:`relative border-b border-border/50 text-right whitespace-nowrap text-muted-foreground tabular-nums transition-colors hover:bg-muted/50 has-focus-visible:bg-muted/50`,children:[(0,$.jsx)(`td`,{className:`py-2.5 pr-3 text-left text-xs`,children:t+1}),(0,$.jsxs)(`td`,{className:`py-2.5 text-left whitespace-normal`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b(n),className:`flex items-center gap-2 text-left text-foreground outline-none after:absolute after:inset-0`,children:[(0,$.jsx)(ur,{provider:e.provider,className:`size-3.5`}),e.model]}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:N(`mt-1.5 h-0.5 max-w-48`,a),children:(0,$.jsx)(`div`,{className:`h-full rounded-full`,style:{width:r>0&&ke>0?`max(0.5rem, ${r/ke*100}%)`:0,backgroundColor:Xe[e.provider].color}})})]}),(0,$.jsx)(`td`,{className:N(`py-2.5 pl-6 text-foreground`,a),children:pt(e)?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Unpriced`}):G(e.costUsd)}),(0,$.jsx)(`td`,{className:N(`hidden py-2.5 pl-6 sm:table-cell`,a),children:i===null?``:Y(i)}),(0,$.jsx)(`td`,{className:N(`py-2.5 pl-6`,a),children:q(e.totalTokens)})]},n)})})]}):(0,$.jsxs)(`table`,{className:`w-full table-fixed text-sm`,children:[(0,$.jsxs)(`colgroup`,{children:[(0,$.jsx)(`col`,{className:`w-2/5`}),Ee.map(e=>(0,$.jsx)(`col`,{style:{width:Je}},e)),(0,$.jsx)(`col`,{style:{width:Je}}),(0,$.jsx)(`col`,{style:{width:Je}})]}),(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b border-border text-left text-xs text-muted-foreground`,children:[(0,$.jsx)(`th`,{className:`py-2 font-normal`,children:R?`Hour`:`Day`}),Ee.map(e=>(0,$.jsx)(`th`,{className:`py-2 text-right font-normal`,children:Xe[e].label},e)),(0,$.jsx)(`th`,{className:`py-2 text-right font-normal`,children:`Total`}),(0,$.jsx)(`th`,{className:`py-2 text-right font-normal`,children:`Tokens`})]})}),(0,$.jsx)(`tbody`,{children:Ce.length===0?(0,$.jsx)(`tr`,{children:(0,$.jsx)(`td`,{colSpan:Ee.length+3,className:`py-6 text-center text-muted-foreground`,children:`No activity in this window.`})}):Ce.map(e=>(0,$.jsxs)(`tr`,{className:`border-b border-border/50 transition-colors hover:bg-muted/50`,children:[(0,$.jsx)(`td`,{className:`py-2 text-foreground`,children:`hourStart`in e?fe(e.hourStart,L.timeZone):ce(e.day)}),Ee.map(t=>(0,$.jsx)(`td`,{className:N(`py-2 text-right text-muted-foreground tabular-nums`,dr(W(t))),children:G(e.byProvider.get(t)?.costUsd??0)},t)),(0,$.jsx)(`td`,{className:N(`py-2 text-right text-foreground tabular-nums`,dr(U.partial)),children:G(e.costUsd)}),(0,$.jsx)(`td`,{className:N(`py-2 text-right text-muted-foreground tabular-nums`,dr(U.partial)),children:q(e.totalTokens)})]},`hourStart`in e?e.hourStart:e.day))})]})]})]}):(0,$.jsx)(`div`,{className:`space-y-2 py-12 text-center text-sm text-muted-foreground`,children:A.map(e=>(0,$.jsxs)(`p`,{children:[A.length>1?`${e.label}: `:null,e.error]},e.environmentId))})})})]}),Oe!==void 0&&!c?(0,$.jsx)(qn,{model:Oe,environments:A,metric:s===`tokens`?`tokens`:`cost`,chartWindow:{days:X,hours:xe,resolution:R?`hour`:`day`,timeZone:L.timeZone,referenceTime:L.untilTime},onSetPrice:()=>{b(null),v({model:Oe.model})},onClose:()=>b(null)}):null,_?(0,$.jsx)(Xt,{usage:k,initialSelectedEnvironmentIds:x,initialModel:_.model,onOpenChange:e=>{e||v(null)}}):null]})}var or=`Requires access to your Cursor login in macOS Keychain.`;function sr({environmentId:e,label:t,onEnabled:n,tooltip:r,buttonText:i=`Enable`}){let a=se(ae.updateSettings,{label:`enable Cursor account usage`}),[o,s]=(0,Z.useState)(!1),c=async()=>{s(!0);try{(await a({environmentId:e,input:{patch:{cursorKeychainUsageEnabled:!0}}}))._tag===`Success`&&n()}finally{s(!1)}},l=r?(0,$.jsx)(F,{disabled:o,"aria-busy":o,"aria-label":`Enable Cursor usage from ${t}`,onClick:()=>void c(),children:i}):(0,$.jsx)(D,{size:`sm`,variant:`outline`,disabled:o,"aria-busy":o,"aria-label":`Enable Cursor usage from ${t}`,onClick:()=>void c(),children:i});return r?(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{render:l}),(0,$.jsx)(_e,{children:or})]}):l}function cr(e){let t=(0,Q.c)(11),{environmentId:n,label:r,showEnvironment:i,onEnabled:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-2 shrink-0 rounded-full`,style:{backgroundColor:Xe.cursor.color}}),s=(0,$.jsx)(ur,{provider:`cursor`,className:`size-4`}),t[0]=o,t[1]=s):(o=t[0],s=t[1]);let c=i?` · ${r}`:``,l;t[2]===c?l=t[3]:(l=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm text-foreground`,children:[o,s,(0,$.jsxs)(`span`,{className:`truncate`,children:[`Cursor`,c]})]}),t[2]=c,t[3]=l);let u;t[4]!==n||t[5]!==r||t[6]!==a?(u=(0,$.jsx)(sr,{environmentId:n,label:r,onEnabled:a,tooltip:!0}),t[4]=n,t[5]=r,t[6]=a,t[7]=u):u=t[7];let d;return t[8]!==l||t[9]!==u?(d=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-4 text-sm`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10],d}function lr(e){let t=(0,Q.c)(10),{environments:n,onEnabled:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-medium text-foreground`,children:[(0,$.jsx)(Le,{driverKind:M.make(`cursor`),displayName:`Cursor`,indicatorBackground:`var(--background)`,className:`size-5`,iconClassName:`size-4 text-foreground/80`}),`Cursor`]}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:or}),t[1]=a):a=t[1];let o;if(t[2]!==n||t[3]!==r){let e;t[5]!==n.length||t[6]!==r?(e=e=>(0,$.jsx)(sr,{environmentId:e.environmentId,label:e.label,buttonText:n.length>1?`Enable on ${e.label}`:`Enable`,onEnabled:r,tooltip:!1},e.environmentId),t[5]=n.length,t[6]=r,t[7]=e):e=t[7],o=n.map(e),t[2]=n,t[3]=r,t[4]=o}else o=t[4];let s;return t[8]===o?s=t[9]:(s=(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[i,(0,$.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-lg border border-border/60 p-4`,children:[a,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o})]})]}),t[8]=o,t[9]=s),s}function ur(e){let t=(0,Q.c)(4),{provider:n,className:r}=e,i=Xe[n],a;return t[0]!==r||t[1]!==i.driverKind||t[2]!==i.label?(a=(0,$.jsx)(Le,{driverKind:i.driverKind,displayName:i.label,iconClassName:r}),t[0]=r,t[1]=i.driverKind,t[2]=i.label,t[3]=a):a=t[3],a}function dr(e){return N(`transition-opacity`,e&&`opacity-40 delay-150`)}function fr(e){let t=(0,Q.c)(10),{label:n,value:r,loading:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n}),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=N(`text-base font-medium text-foreground tabular-nums`,dr(i)),t[2]=i,t[3]=o);let s;t[4]!==o||t[5]!==r?(s=(0,$.jsx)(`span`,{className:o,children:r}),t[4]=o,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==s?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function pr(e){let t=(0,Q.c)(14),{environments:n,duplicateSources:r,contractMismatches:i}=e,a,o,s,c;if(t[0]!==i||t[1]!==r||t[2]!==n){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=n.filter(_r),t=new Map(i.map(gr)),l=n.flatMap(e=>{let n=t.get(e.environmentId);return n===void 0?[]:[{environment:e,mismatch:n}]});if(e.length===0&&l.length===0&&r.length===0){c=null;break bb0}a=`flex flex-col gap-1 border-t border-border px-2 py-2 text-xs text-muted-foreground`,o=e.map(hr),s=l.map(mr)}t[0]=i,t[1]=r,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else a=t[3],o=t[4],s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;t[7]===r?l=t[8]:(l=r.length>0?(0,$.jsxs)(`span`,{children:[`Counted once across environments sharing a transcript directory:`,` `,r.join(`, `)]}):null,t[7]=r,t[8]=l);let u;return t[9]!==a||t[10]!==o||t[11]!==s||t[12]!==l?(u=(0,$.jsxs)(`div`,{className:a,children:[o,s,l]}),t[9]=a,t[10]=o,t[11]=s,t[12]=l,t[13]=u):u=t[13],u}function mr(e){let{environment:t,mismatch:n}=e;return(0,$.jsx)(`span`,{children:me(t.label,n)},t.environmentId)}function hr(e){return(0,$.jsxs)(`span`,{children:[e.label,`: `,e.error]},e.label)}function gr(e){return[e.environmentId,e]}function _r(e){return e.error!==null}function vr(e){let t=(0,Q.c)(56),{environments:r,selectedEnvironments:i,selectedEnvironmentIds:a,onSelectionChange:o,showUsageStatus:s,refreshing:c,isPartial:l,duplicateSources:d,contractMismatches:p,onOpenModelPrices:m}=e,h=a===null,g=h?`All environments`:i.length===1?i[0].label:`${i.length} environments`,_;t[0]!==p||t[1]!==i?(_=i.some(br)||p.length>0,t[0]=p,t[1]=i,t[2]=_):_=t[2];let v=_,S;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(F,{}),t[3]=S):S=t[3];let C;t[4]===g?C=t[5]:(C=(0,$.jsx)(Qe,{children:g}),t[4]=g,t[5]=C);let w;t[6]!==v||t[7]!==s?(w=(0,$.jsx)(`span`,{className:`flex size-3.5 shrink-0 items-center justify-center text-muted-foreground`,children:s&&v?(0,$.jsx)(f,{className:`size-3.5 text-warning-foreground`,"aria-label":`Some environments could not report usage`}):(0,$.jsx)(I,{className:`size-3.5 opacity-0 transition-opacity group-hover/usage-environment:opacity-100 group-focus-visible/usage-environment:opacity-100 group-data-popup-open/usage-environment:opacity-100`,"aria-hidden":!0})}),t[6]=v,t[7]=s,t[8]=w):w=t[8];let T;t[9]!==C||t[10]!==w?(T=(0,$.jsxs)(x,{render:S,className:`group/usage-environment min-w-0 max-w-full`,children:[C,w]}),t[9]=C,t[10]=w,t[11]=T):T=t[11];let E;t[12]===o?E=t[13]:(E=e=>o(e?null:new Set),t[12]=o,t[13]=E);let D;t[14]!==h||t[15]!==E?(D=(0,$.jsx)(u,{checked:h,closeOnClick:!1,onCheckedChange:E,children:`All environments`}),t[14]=h,t[15]=E,t[16]=D):D=t[16];let O;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(A,{}),t[17]=O):O=t[17];let j;if(t[18]!==r||t[19]!==o||t[20]!==c||t[21]!==a||t[22]!==i||t[23]!==s){let e;t[25]!==r.length||t[26]!==o||t[27]!==c||t[28]!==a||t[29]!==i||t[30]!==s?(e=e=>{let t=a===null||a.has(e.environmentId),n=ut(e,c),l=e.error===null?e.summary!==null&&!bt(e.summary.contractVersion,6)?`Update required`:e.isConnected?n.phase===`loading`?`Scanning…`:n.phase===`stale`?`Refreshing…`:n.phase===`partway`?dt(n.providers,ir):`Ready`:`Connecting…`:`Unavailable`;return(0,$.jsx)(u,{checked:t,closeOnClick:!1,onCheckedChange:t=>{let n=new Set(i.map(yr));t?n.add(e.environmentId):n.delete(e.environmentId),o(n.size===r.length?null:n)},children:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),s?(0,$.jsx)(`span`,{className:N(`shrink-0 text-xs text-muted-foreground`,e.error!==null&&`text-destructive`),children:l}):null]})},e.environmentId)},t[25]=r.length,t[26]=o,t[27]=c,t[28]=a,t[29]=i,t[30]=s,t[31]=e):e=t[31],j=r.map(e),t[18]=r,t[19]=o,t[20]=c,t[21]=a,t[22]=i,t[23]=s,t[24]=j}else j=t[24];let M;t[32]===r.length?M=t[33]:(M=r.length===0?(0,$.jsx)(`p`,{className:`px-2 py-2 text-xs text-muted-foreground`,children:`No environments connected.`}):null,t[32]=r.length,t[33]=M);let P;t[34]!==l||t[35]!==s?(P=s&&l?(0,$.jsx)(`p`,{className:`px-2 py-2 text-xs text-muted-foreground`,children:`Totals are partial while selected environments scan.`}):null,t[34]=l,t[35]=s,t[36]=P):P=t[36];let L;t[37]!==p||t[38]!==d||t[39]!==i||t[40]!==s?(L=s?(0,$.jsx)(pr,{environments:i,duplicateSources:d,contractMismatches:p}):null,t[37]=p,t[38]=d,t[39]=i,t[40]=s,t[41]=L):L=t[41];let R;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(A,{}),t[42]=R):R=t[42];let z;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(b,{"aria-hidden":!0}),t[43]=z):z=t[43];let B;t[44]===m?B=t[45]:(B=(0,$.jsxs)(y,{onClick:m,children:[z,`Model prices`]}),t[44]=m,t[45]=B);let V;t[46]!==M||t[47]!==P||t[48]!==L||t[49]!==B||t[50]!==D||t[51]!==j?(V=(0,$.jsxs)(n,{align:`start`,children:[D,O,j,M,P,L,R,B]}),t[46]=M,t[47]=P,t[48]=L,t[49]=B,t[50]=D,t[51]=j,t[52]=V):V=t[52];let H;return t[53]!==V||t[54]!==T?(H=(0,$.jsxs)(k,{children:[T,V]}),t[53]=V,t[54]=T,t[55]=H):H=t[55],H}function yr(e){return e.environmentId}function br(e){return e.error!==null}function xr(e){let t=(0,Q.c)(23),{hiddenProviders:r,onChange:i}=e,a;t[0]===r?a=t[1]:(a=Ye.filter(e=>!r.has(e)),t[0]=r,t[1]=a);let o=a,s=o.length===Ye.length?`All providers`:o.length===0?`No providers`:o.length===1?Xe[o[0]].label:`${o.length} providers`,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(F,{}),t[2]=c):c=t[2];let l;t[3]===s?l=t[4]:(l=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:s}),t[3]=s,t[4]=l);let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(I,{className:`size-3.5 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/usage-provider:opacity-100 group-focus-visible/usage-provider:opacity-100 group-data-popup-open/usage-provider:opacity-100`,"aria-hidden":!0}),t[5]=d):d=t[5];let f;t[6]===l?f=t[7]:(f=(0,$.jsxs)(x,{render:c,className:`group/usage-provider min-w-0 max-w-full`,children:[l,d]}),t[6]=l,t[7]=f);let p=r.size===0,m;t[8]===i?m=t[9]:(m=e=>i(e?[]:Ye),t[8]=i,t[9]=m);let h;t[10]!==p||t[11]!==m?(h=(0,$.jsx)(u,{checked:p,closeOnClick:!1,onCheckedChange:m,children:`All providers`}),t[10]=p,t[11]=m,t[12]=h):h=t[12];let g;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(A,{}),t[13]=g):g=t[13];let _;t[14]!==r||t[15]!==i?(_=Ye.map(e=>(0,$.jsx)(u,{checked:!r.has(e),closeOnClick:!1,onCheckedChange:t=>i(Ye.filter(n=>n===e?!t:r.has(n))),children:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(ur,{provider:e,className:`size-3.5`}),(0,$.jsx)(`span`,{className:`truncate`,children:Xe[e].label})]})},e)),t[14]=r,t[15]=i,t[16]=_):_=t[16];let v;t[17]!==_||t[18]!==h?(v=(0,$.jsxs)(n,{align:`start`,children:[h,g,_]}),t[17]=_,t[18]=h,t[19]=v):v=t[19];let y;return t[20]!==v||t[21]!==f?(y=(0,$.jsxs)(k,{children:[f,v]}),t[20]=v,t[21]=f,t[22]=y):y=t[22],y}function Sr(){let e=(0,Q.c)(7),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(X,{className:`h-10 w-36`}),(0,$.jsx)(X,{className:`h-4 w-32`})]}),Ye.map(Cr)]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(X,{className:`h-5 w-24`}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`section`,{className:`grid gap-6 lg:grid-cols-[minmax(0,18rem)_minmax(0,1fr)]`,children:[t,(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(X,{className:`ml-16 h-56`}),(0,$.jsx)(X,{className:`ml-16 h-4`})]})]})]}),e[2]=r):r=e[2];let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Totals`}),e[3]=i):i=e[3];let a;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[i,(0,$.jsx)(wr,{labels:[`Processed tokens`,`Cached input`,`Uncached input`,`Output`,`Cache savings`]})]}),e[4]=a):a=e[4];let o;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`section`,{className:`grid gap-x-12 gap-y-8 lg:grid-cols-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,$.jsx)(X,{className:`h-5 w-28`}),(0,$.jsx)(X,{className:`h-2`}),(0,$.jsx)(X,{className:`h-4 w-72`})]})}),e[5]=o):o=e[5];let s;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsxs)($.Fragment,{children:[r,a,o,(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Breakdown`}),(0,$.jsx)(X,{shape:`card`,className:`h-7 w-28`})]}),(0,$.jsx)(X,{className:`h-44`})]})]}),e[6]=s):s=e[6],s}function Cr(e){return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-5 items-center justify-between gap-4`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{shape:`pill`,className:`size-2 shrink-0`}),(0,$.jsx)(X,{shape:`pill`,className:`size-4 shrink-0`}),(0,$.jsx)(X,{className:`h-3.5 w-20`})]}),(0,$.jsx)(X,{className:`h-3.5 w-14`})]}),(0,$.jsx)(X,{className:`h-4 w-36`})]},e)}function wr(e){let t=(0,Q.c)(4),{labels:n}=e,r;t[0]===n?r=t[1]:(r=n.map(Tr),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-4 py-1 md:grid-cols-5`,children:r}),t[2]=r,t[3]=i),i}function Tr(e){return(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,$.jsx)(X,{className:`h-6 w-16`})]},e)}var Er=ar;export{Er as component};
|
|
2
|
-
//# sourceMappingURL=usage-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{$n as n,$o as r,BE as i,Bp as a,Ds as o,Es as s,I_ as c,Jm as l,Jn as u,Ny as d,Od as f,RT as p,Rf as m,Ty as h,Uy as g,Yo as _,Yp as v,Zn as y,cm as b,cr as x,ds as S,el as C,gb as w,ks as T,lb as E,lr as D,mE as O,qn as k,rr as A,rs as j,s_ as M,t as N,ts as P,ur as F,xd as I}from"./utils-CyMIjIQl.js";import{B as L,L as R,W as z,q as B}from"./runtime-CQUKxsYj.js";import{a as V,c as H,o as ee,s as te,t as ne}from"./select-C3qtJHHz.js";import{t as re}from"./useNavigateBack-CpakkPiu.js";import{rt as ie}from"./useSettings-BxAEkFYM.js";import{f as ae,s as oe}from"./server-BLcQ113X.js";import{n as U,t as W}from"./session-DW2fD94Y.js";import{t as se}from"./use-atom-command-BeLksgvP.js";import{a as ce,c as le,d as G,f as K,i as ue,l as q,n as de,o as fe,r as J,s as Y,t as pe,u as me}from"./usageFormat-bv0-SbBE.js";import{t as he}from"./env-wK1YYxA8.js";import{a as ge,n as _e,t as ve}from"./tooltip-DguVraEa.js";import{t as X}from"./skeleton-C5tu1gWo.js";import{n as ye,t as be}from"./toggle-group-DAQh9V2C.js";import{t as xe}from"./input-CyLVEbfy.js";import{t as Se}from"./scroll-area-1mTt9e_w.js";import{a as Ce,c as we,i as Te,o as Ee,r as De,s as Oe,t as ke}from"./dialog-C-AXHdu2.js";import{o as Ae}from"./sidebar-tYIa3_8M.js";import{t as je}from"./observeResize-D4IgTUH5.js";import{y as Me}from"./keybindings-D2lV30Mz.js";import{i as Ne,o as Pe,t as Fe}from"./popover-DSpvkDFi.js";import{S as Ie,n as Le,t as Re}from"./ChatGptUsageButton-B21SbJHE.js";import{t as ze}from"./WorkspacePageContainer-CiVT-7R2.js";import{n as Be,r as Ve,t as He}from"./usageShortcuts-Dx5czWNh.js";import{Si as Ue,Ta as We,Wr as Ge,ar as Ke,cr as qe,hi as Je,or as Ye,sr as Xe}from"./main-Cy4Cptcv.js";import{t as Ze}from"./WorkspacePageHeader-FKxEatch.js";import{i as Qe,n as $e,r as et,t as tt}from"./WorkspaceBreadcrumb-CALMpobe.js";import{t as nt}from"./usageAccess-DeusmFu4.js";var Z=e(t(),1),Q=i(),rt=E(B);function it(e,t){return e?.sources.some(e=>e.action===`enableCursorKeychain`)===!0&&t?.some(e=>e.driver===`cursor`&&e.status===`ready`)===!0}function at(e){return e.some(e=>e.summary?.sources.some(e=>e.fingerprint.provider===`cursor`&&e.fingerprint.hostId===`cursor.com`))?[]:e.filter(e=>e.needsCursorKeychainAccess)}var ot=new Map,st=new Map;async function ct(e,t,n=!1,r=!1){let i=st.get(e);if(i!==void 0){if(r){try{await i}catch{}return ct(e,t,!1,!0)}return n?void 0:await i}let a=ot.get(e)??0;if(n&&Date.now()<a)return;let o=Promise.resolve().then(t).finally(()=>{st.delete(e),ot.set(e,Date.now()+3e5)});return st.set(e,o),await o}async function lt({registry:e,server:t,presentations:n,environmentIds:r,input:i}){await Promise.all(r.map(async r=>{let a=t.usageSummary({environmentId:r,input:i}),o=n.presentationAtom(r),s=new AbortController,c=()=>{e.get(o)?.connection.phase!==`connected`&&s.abort()},l=e.subscribe(o,c);c();try{let n=await L(e,t.refreshUsageRates,{environmentId:r,input:{}},{reportFailure:!1}),i=n._tag===`Failure`&&rt(z(n));if(e.refresh(a),i||s.signal.aborted)return;await R(e,a,{reportFailure:!1,signal:s.signal})}finally{l()}}))}function ut(e,t=!1){let{summary:n}=e;if(!e.isConnected||e.error!==null)return{phase:`inactive`};if(n===null)return{phase:`loading`};if(t)return{phase:`stale`};if(!e.isPending)return{phase:`ready`};let r=[...new Set(n.sources.flatMap(e=>e.refreshing?[e.fingerprint.provider]:[]))];return r.length>0?{phase:`partway`,providers:r}:{phase:`stale`}}function dt(e,t){return e.length===1?`Updating ${t(e[0])}…`:`Updating ${e.length} providers…`}function ft(e,t=!1){let n=new Set,r=!1;for(let i of e){let e=ut(i,t);if((e.phase===`loading`||e.phase===`stale`)&&(r=!0),e.phase===`partway`)for(let t of e.providers)n.add(t)}return{partial:r||n.size>0,everyProvider:r,providers:n}}function pt(e){return e.records>0&&e.unpricedRecords>=e.records}function mt(e){return[e.hostId,e.provider,e.resolvedHomePath,e.volumeId].join(` `)}function ht(e,t){let n=e.sources.filter(e=>e.fingerprint.provider===t.fingerprint.provider);return e.buckets.filter(e=>e.provider===t.fingerprint.provider&&(e.sourcePath===t.fingerprint.resolvedHomePath||e.sourcePath===void 0&&n.length===1))}function gt(e){return JSON.stringify([e.day,e.hourStart??null,e.provider,e.model])}function _t(e){let t=new Map,n=new Map,r=new Map,i=new Map,a=new Map,o=[],s=[...e].sort((e,t)=>(Date.parse(t.summary.readAt)||0)-(Date.parse(e.summary.readAt)||0)||e.environmentId.localeCompare(t.environmentId));for(let e of[`ok`,`partial`,`failed`])for(let r of s)for(let i of r.summary.sources){if(i.status!==e)continue;let s=mt(i.fingerprint);if(t.has(s)){o.push(`${r.label}: ${i.fingerprint.resolvedHomePath}`);continue}t.set(s,r.environmentId),n.set(s,{environment:r,source:i}),a.set(s,i.distinctSessions)}for(let e of s)for(let t of e.summary.sources){if(t.status!==`partial`)continue;let o=mt(t.fingerprint),s=n.get(o);if(s?.source.status!==`ok`||Date.parse(e.summary.readAt)<=Date.parse(s.environment.summary.readAt))continue;let c=r.get(o);c===void 0&&(c=new Set(ht(s.environment.summary,s.source).map(gt)),r.set(o,c));let l=i.get(e.environmentId)??new Set,u=!1;for(let n of ht(e.summary,t)){let e=gt(n);c.has(e)||(c.add(e),l.add(n),u=!0)}u&&(i.set(e.environmentId,l),a.set(o,Math.max(a.get(o)??0,t.distinctSessions)))}return{ownerByFingerprint:t,supplementalBucketsByEnvironment:i,sessionsByFingerprint:a,duplicates:o}}function vt(e,t,n,r){let i=new Set,a=new Set,o=new Map;for(let n of e.summary.sources){if(n.status===`missing`)continue;let s=mt(n.fingerprint);if(t.get(s)===e.environmentId){let e=n.fingerprint.provider;i.add(e),a.add(`${e}\u0000${n.fingerprint.resolvedHomePath}`),o.set(e,(o.get(e)??0)+(r.get(s)??n.distinctSessions))}}return{buckets:e.summary.buckets.filter(e=>n.has(e)||(e.sourcePath===void 0?i.has(e.provider):a.has(`${e.provider}\u0000${e.sourcePath}`))),sessionsByProvider:o}}function yt(e){return e.totals.uncachedInputTokens+e.totals.cachedInputTokens+e.totals.cacheCreationTokens+e.totals.outputTokens}function bt(e,t){return e>=4&&e<=t}var xt={costUsd:0,uncachedInputTokens:0,cachedInputTokens:0,cacheCreationTokens:0,outputTokens:0,reasoningTokens:0,totalTokens:0,records:0,sessions:0,providers:[],models:[],daily:[],hourly:[],costQuality:{providerReportedShare:0,modelPricedShare:0,unpricedShare:0,cacheSavingsUsd:0},categoryCost:{input:0,cacheRead:0,cacheWrite:0,output:0,unsplit:0},speedCost:{standard:0,fast:0,ultrafast:0,premium:0},duplicateSources:[],contributingEnvironments:[],contractMismatches:[]};function St(e,t){if(e.length===0)return xt;let n=[],r=[];for(let i of e)bt(i.summary.contractVersion,t)?n.push(i):r.push({environmentId:i.environmentId,direction:i.summary.contractVersion<t?`serverBehind`:`clientBehind`,contractVersion:i.summary.contractVersion});let{ownerByFingerprint:i,supplementalBucketsByEnvironment:a,sessionsByFingerprint:o,duplicates:s}=_t(n),c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y={input:0,cacheRead:0,cacheWrite:0,output:0},b={fast:0,ultrafast:0,premium:0},x=new Map,S=new Map,C=new Map,w=new Map,T=[];for(let e of n){let{buckets:t,sessionsByProvider:n}=vt(e,i,a.get(e.environmentId)??new Set,o);t.length>0&&T.push(e.environmentId);for(let[e,t]of n){if(h+=t,t===0)continue;let n=x.get(e)??{costUsd:0,totalTokens:0,records:0,sessions:0};n.sessions+=t,x.set(e,n)}for(let e of t){let t=yt(e);c+=e.costUsd,g+=e.cacheSavingsUsd,l+=e.totals.uncachedInputTokens,u+=e.totals.cachedInputTokens,d+=e.totals.cacheCreationTokens,f+=e.totals.outputTokens,p+=e.totals.reasoningTokens,m+=e.records,v+=e.unpricedRecords,e.costSource===`providerReported`&&(_+=e.records),e.categoryCostUsd!==void 0&&(y.input+=e.categoryCostUsd.input,y.cacheRead+=e.categoryCostUsd.cacheRead,y.cacheWrite+=e.categoryCostUsd.cacheWrite,y.output+=e.categoryCostUsd.output),b.fast+=e.fastCostUsd??0,b.ultrafast+=e.ultrafastCostUsd??0,b.premium+=e.speedPremiumUsd??0;let n=x.get(e.provider)??{costUsd:0,totalTokens:0,records:0,sessions:0};n.costUsd+=e.costUsd,n.totalTokens+=t,n.records+=e.records,x.set(e.provider,n);let r=`${e.provider} ${e.model}`,i=S.get(r)??{provider:e.provider,costUsd:0,totalTokens:0,tokens:{uncachedInputTokens:0,cachedInputTokens:0,cacheCreationTokens:0,outputTokens:0,reasoningTokens:0},records:0,unpricedRecords:0,unpricedTokens:0};i.costUsd+=e.costUsd,i.totalTokens+=t,i.tokens={uncachedInputTokens:i.tokens.uncachedInputTokens+e.totals.uncachedInputTokens,cachedInputTokens:i.tokens.cachedInputTokens+e.totals.cachedInputTokens,cacheCreationTokens:i.tokens.cacheCreationTokens+e.totals.cacheCreationTokens,outputTokens:i.tokens.outputTokens+e.totals.outputTokens,reasoningTokens:i.tokens.reasoningTokens+e.totals.reasoningTokens},i.records+=e.records,i.unpricedRecords+=e.unpricedRecords,e.records>0&&(i.unpricedTokens+=t*e.unpricedRecords/e.records),S.set(r,i);let a=C.get(e.day)??{costUsd:0,totalTokens:0,byProvider:new Map};a.costUsd+=e.costUsd,a.totalTokens+=t;let o=a.byProvider.get(e.provider)??{costUsd:0,totalTokens:0};if(o.costUsd+=e.costUsd,o.totalTokens+=t,a.byProvider.set(e.provider,o),C.set(e.day,a),e.hourStart!==void 0){let n=w.get(e.hourStart)??{day:e.day,hourStart:e.hourStart,costUsd:0,totalTokens:0,byProvider:new Map};n.costUsd+=e.costUsd,n.totalTokens+=t;let r=n.byProvider.get(e.provider)??{costUsd:0,totalTokens:0};r.costUsd+=e.costUsd,r.totalTokens+=t,n.byProvider.set(e.provider,r),w.set(e.hourStart,n)}}}let E=l+u+d+f,D=[...x.entries()].map(([e,t])=>({provider:e,costUsd:t.costUsd,totalTokens:t.totalTokens,records:t.records,sessions:t.sessions,costShare:c===0?0:t.costUsd/c,tokenShare:E===0?0:t.totalTokens/E})).sort((e,t)=>t.costUsd-e.costUsd),O=[...S.entries()].map(([e,t])=>({model:e.slice(e.indexOf(` `)+1),provider:t.provider,costUsd:t.costUsd,totalTokens:t.totalTokens,tokens:t.tokens,records:t.records,unpricedRecords:t.unpricedRecords,unpricedTokens:t.unpricedTokens,costShare:c===0?0:t.costUsd/c,tokenShare:E===0?0:t.totalTokens/E})).sort((e,t)=>t.costUsd-e.costUsd||t.totalTokens-e.totalTokens),k=[...C.entries()].map(([e,t])=>({day:e,costUsd:t.costUsd,totalTokens:t.totalTokens,byProvider:t.byProvider})).sort((e,t)=>e.day.localeCompare(t.day)),A=[...w.values()].sort((e,t)=>e.hourStart.localeCompare(t.hourStart));return{costUsd:c,uncachedInputTokens:l,cachedInputTokens:u,cacheCreationTokens:d,outputTokens:f,reasoningTokens:p,totalTokens:E,records:m,sessions:h,providers:D,models:O,daily:k,hourly:A,costQuality:{providerReportedShare:m===0?0:_/m,unpricedShare:m===0?0:v/m,modelPricedShare:m===0?0:(m-_-v)/m,cacheSavingsUsd:g},categoryCost:{...y,unsplit:Math.max(0,c-y.input-y.cacheRead-y.cacheWrite-y.output)},speedCost:{...b,standard:Math.max(0,c-b.fast-b.ultrafast)},duplicateSources:s,contributingEnvironments:T,contractMismatches:r}}var Ct=P(e=>j(t=>{let n=JSON.parse(e),r=t(ie.presentationsAtom),i=[];for(let[e,a]of r){let r=a.connection.phase===`connected`,o=t(W.sessionStateAtom(e)),c=nt({connectionPhase:a.connection.phase,session:p(s(o)),hasSessionError:o._tag===`Failure`});if(!c.canReadDiagnostics){i.push({environmentId:e,label:a.entry.target.label,isConnected:r,...c,summary:null,needsCursorKeychainAccess:!1});continue}let l=t(ae.usageSummary({environmentId:e,input:n})),u=p(s(l));i.push({environmentId:e,label:a.entry.target.label,isPending:l.waiting,canReadDiagnostics:!0,isConnected:r,error:l._tag===`Failure`?`This environment could not report usage.`:null,summary:u,needsCursorKeychainAccess:it(u,t(ae.providersValueAtom(e)))})}return i}).pipe(S(`web-usage:window:${e}`)));function wt(e,t){return St(e.flatMap(({environmentId:e,label:n,summary:r})=>r===null?[]:[{environmentId:e,label:n,summary:t===void 0?r:{...r,buckets:r.buckets.filter(t)}}]),6)}var Tt=new Set;function Et(e,t){return t.size===0?e:e.map(e=>e.summary===null?e:{...e,summary:{...e.summary,buckets:e.summary.buckets.filter(e=>!t.has(e.provider)),sources:e.summary.sources.filter(e=>!t.has(e.fingerprint.provider))}})}function Dt(e,t,n){let i=(0,Q.c)(36),a=t===void 0?null:t,o=n===void 0?Tt:n,s;i[0]!==e.resolution||i[1]!==e.sinceDay||i[2]!==e.sinceTime||i[3]!==e.timeZone||i[4]!==e.untilDay||i[5]!==e.untilTime?(s=JSON.stringify({sinceDay:e.sinceDay,untilDay:e.untilDay,timeZone:e.timeZone,resolution:e.resolution,sinceTime:e.sinceTime,untilTime:e.untilTime}),i[0]=e.resolution,i[1]=e.sinceDay,i[2]=e.sinceTime,i[3]=e.timeZone,i[4]=e.untilDay,i[5]=e.untilTime,i[6]=s):s=i[6];let c=s,l;i[7]===c?l=i[8]:(l=Ct(c),i[7]=c,i[8]=l);let u=r(l),d;i[9]!==u||i[10]!==a?(d=a===null?u:u.filter(e=>a.has(e.environmentId)),i[9]=u,i[10]=a,i[11]=d):d=i[11];let f=d,p;i[12]!==f||i[13]!==c?(p=e=>lt({registry:_,server:ae,presentations:ie,environmentIds:f.filter(jt).map(At),input:e??JSON.parse(c)}),i[12]=f,i[13]=c,i[14]=p):p=i[14];let m=p,h;i[15]!==o||i[16]!==f?(h=wt(Et(f,o)),i[15]=o,i[16]=f,i[17]=h):h=i[17];let g=h,v;i[18]===f?v=i[19]:(v=f.filter(kt),i[18]=f,i[19]=v);let y=v.length,b;i[20]===f?b=i[21]:(b=f.filter(Ot),i[20]=f,i[21]=b);let x=b.length,S=y===0&&x>0,[C,w]=(0,Z.useState)(null);y>0&&(C?.merged!==g||C.window!==e||C.selection!==a||C.hidden!==o)&&w({window:e,merged:g,selection:a,hidden:o});let T=C?.selection===a&&C.hidden===o?C:null,E;i[22]!==y||i[23]!==e||i[24]!==S||i[25]!==T||i[26]!==g?(E=y>0?{window:e,merged:g}:T??(S?null:{window:e,merged:g}),i[22]=y,i[23]=e,i[24]=S,i[25]=T,i[26]=g,i[27]=E):E=i[27];let D=E,O=y>0&&x>0,k;return i[28]!==u||i[29]!==S||i[30]!==g||i[31]!==m||i[32]!==f||i[33]!==D||i[34]!==O?(k={merged:g,environments:u,selectedEnvironments:f,isPending:S,shown:D,isPartial:O,refresh:m},i[28]=u,i[29]=S,i[30]=g,i[31]=m,i[32]=f,i[33]=D,i[34]=O,i[35]=k):k=i[35],k}function Ot(e){return e.summary===null&&e.error===null}function kt(e){return e.summary!==null}function At(e){let{environmentId:t}=e;return t}function jt(e){return e.canReadDiagnostics&&U(e.environmentId,`diagnostics:read`)}var $=e(O(),1);function Mt(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=N(`w-full caption-bottom text-xs`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,$.jsx)(`table`,{"data-slot":`table`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Nt(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=N(`[&_tr]:border-b`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`thead`,{"data-slot":`table-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Pt(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=N(`[&_tr:last-child]:border-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`tbody`,{"data-slot":`table-body`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ft(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=N(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`tr`,{"data-slot":`table-row`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function It(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=N(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`th`,{"data-slot":`table-head`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Lt(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=N(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`td`,{"data-slot":`table-cell`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Rt=[{key:`inputCostPerMillionTokens`,label:`Input`,optional:!1},{key:`outputCostPerMillionTokens`,label:`Output`,optional:!1},{key:`cacheReadCostPerMillionTokens`,label:`Cache read`,optional:!0},{key:`cacheWriteCostPerMillionTokens`,label:`Cache write`,optional:!0}];function zt(e=``,t){return{model:e,inputCostPerMillionTokens:t?.inputCostPerMillionTokens.toString()??``,outputCostPerMillionTokens:t?.outputCostPerMillionTokens.toString()??``,cacheReadCostPerMillionTokens:t?.cacheReadCostPerMillionTokens?.toString()??``,cacheWriteCostPerMillionTokens:t?.cacheWriteCostPerMillionTokens?.toString()??``}}function Bt(e){let t=e.model.trim();if(t.length===0)return null;let n={};for(let t of Rt){let r=e[t.key].trim();if(r===``){if(t.optional)continue;return null}if(!/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(r))return null;let i=Number(r);if(!Number.isFinite(i)||i<0)return null;n[t.key]=i}return n.inputCostPerMillionTokens===void 0||n.outputCostPerMillionTokens===void 0?null:{model:t,price:{inputCostPerMillionTokens:n.inputCostPerMillionTokens,outputCostPerMillionTokens:n.outputCostPerMillionTokens,...n.cacheReadCostPerMillionTokens===void 0?{}:{cacheReadCostPerMillionTokens:n.cacheReadCostPerMillionTokens},...n.cacheWriteCostPerMillionTokens===void 0?{}:{cacheWriteCostPerMillionTokens:n.cacheWriteCostPerMillionTokens}}}}function Vt(e){return e.isNew&&e.model.trim()===``&&(e.alias??``).trim()===``&&Object.values(e.values).every(e=>e.trim()===``)}function Ht(e,t){return e.prices&&Object.hasOwn(e.prices,t)?e.prices[t]:void 0}function Ut(e,t){return e.aliases&&Object.hasOwn(e.aliases,t)?e.aliases[t]:void 0}function Wt(e,t){if(e.some(e=>e.aliases===null))return{value:``,placeholder:`Unavailable`};let n=e.map(e=>Ut(e,t)??``);return n.some(e=>e!==n[0])?{value:``,placeholder:`Mixed`}:{value:n[0]??``,placeholder:`None`}}function Gt(e,t,n){let r=Rt.find(e=>e.key===n).optional,i=e.map(e=>Ht(e,t)?zt(t,Ht(e,t))[n]:null);return e.some(e=>e.prices===null)?{value:``,placeholder:`Unavailable`}:i.some(e=>e!==i[0])?{value:``,placeholder:`Mixed`}:{value:i[0]??``,placeholder:i[0]===null?`Automatic`:r?`Input rate`:`0.00`}}function Kt(e,t){let n=[],r=new Map;for(let i of t){if(Vt(i))continue;let t=i.model.trim(),a=Ut(e,t);if(i.removed){Ht(e,t)&&n.push({model:t,price:null}),a!==void 0&&n.push({model:t,alias:null});continue}let o=(i.alias??a??``).trim();if(o!==``){t===``?r.set(i.id,`Enter a model ID.`):o===t?r.set(i.id,`Map to a different model.`):(o!==a&&n.push({model:t,alias:o}),Ht(e,t)&&n.push({model:t,price:null}));continue}if(a!==void 0&&(n.push({model:t,alias:null}),!Ht(e,t)&&Object.values(i.values).every(e=>e.trim()===``)))continue;let s=zt(t,Ht(e,t)),c={...s,...i.values},l=Bt(c);if(l===null){let n=Rt.find(e=>!e.optional&&c[e.key].trim()===``);r.set(i.id,t===``?`Enter a model ID.`:n?`${n.label} is required on ${e.label}.`:`Use non-negative numbers for prices.`);continue}let u=zt(t,l.price);Rt.some(e=>s[e.key]!==u[e.key])&&n.push(l)}return{changes:n,errors:r}}function qt(e,t){return new Map(e.filter(e=>e.unavailable===null&&e.prices!==null).flatMap(e=>[...Kt(e,t).errors]))}async function Jt(e){await Promise.all(e.targets.map(async t=>{let n,r=e.changes.get(t.environmentId)??[],i=r.flatMap(e=>`price`in e?[[e.model,e.price]]:[]),a=r.flatMap(e=>`alias`in e?[[e.model,e.alias]]:[]);if(t.unavailable!==null)n={status:`failed`,error:t.unavailable};else if(a.length>0&&t.aliases===null)n={status:`failed`,error:`Update server to map models`};else try{n=(r.length===0?{_tag:`Success`}:await e.write({environmentId:t.environmentId,input:{patch:{...i.length>0?{usagePriceOverrides:Object.fromEntries(i)}:{},...a.length>0?{usageModelAliases:Object.fromEntries(a)}:{}}}}))._tag===`Success`?{status:`saved`}:{status:`failed`,error:`Could not save. Try again.`}}catch{n={status:`failed`,error:`Could not save. Try again.`}}e.onResult(t.environmentId,n)}))}var Yt=j(e=>[...e(ie.presentationsAtom)].map(([t,n])=>{let r=e(ae.settingsValueAtom(t)),i=e(W.sessionStateAtom(t)),a=p(s(i)),o=i._tag===`Failure`?`denied`:a===null?i.waiting?`pending`:`denied`:c(a,`settings:write`)?`granted`:`denied`;return{environmentId:t,label:n.entry.target.label,prices:r?.usagePriceOverrides??null,aliases:n.serverConfig?.environment.capabilities.usageModelAliases===!0?r?.usageModelAliases??null:null,unavailable:n.connection.phase===`connected`?r===null?`Prices not loaded`:n.serverConfig?.environment.capabilities.usagePriceOverrides===!0?o===`pending`?`Checking permissions…`:o===`denied`?`Read-only access`:null:`Update server to edit prices`:`Offline`}}));function Xt(e){let t=(0,Q.c)(119),{usage:i,initialSelectedEnvironmentIds:o,initialModel:s,onOpenChange:c}=e,d=r(Yt),[f,p]=(0,Z.useState)(o),m;if(t[0]!==d||t[1]!==f){let e;t[3]===f?e=t[4]:(e=e=>f===null||f.has(e.environmentId),t[3]=f,t[4]=e),m=d.filter(e),t[0]=d,t[1]=f,t[2]=m}else m=t[2];let h=m,g;t[5]!==s||t[6]!==h?(g=()=>s===void 0||h.some(e=>Object.hasOwn(e.prices??{},s)||Object.hasOwn(e.aliases??{},s))?[]:[{id:`new:initial`,model:s,isNew:!0,values:{}}],t[5]=s,t[6]=h,t[7]=g):g=t[7];let[_,y]=(0,Z.useState)(g),[b,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),T=(0,Z.useRef)(null),E=(0,Z.useRef)(0),O;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(O={reportFailure:!1},t[8]=O):O=t[8];let j=se(ae.updateSettings,O),M,P,F,L,R,z,B,V,H,ee,te,ne,re,ie,oe;if(t[9]!==C||t[10]!==_||t[11]!==d||t[12]!==c||t[13]!==b||t[14]!==h||t[15]!==f||t[16]!==j||t[17]!==i){let e=[...new Set(h.flatMap(mn))].sort(),r;t[33]===h?r=t[34]:(r=e=>h.some(t=>t.environmentId===e.environmentId),t[33]=h,t[34]=r);let o=[...new Set([...e,...i.filter(r).flatMap(fn)])].sort(),s;t[35]===_?s=t[36]:(s=new Set(_.filter(dn).map(un)),t[35]=_,t[36]=s);let m=s,g;t[37]!==C||t[38]!==m?(g=e=>C===null||!m.has(e),t[37]=C,t[38]=m,t[39]=g):g=t[39];let O=[...e.filter(g).map(e=>_.find(t=>t.id===`model:${e}`)??{id:`model:${e}`,model:e,isNew:!1,values:{}}),..._.filter(ln)],ae=_.filter(cn);z=qt(h,ae);for(let t of ae)t.isNew&&(t.model.trim()===``?z.set(t.id,`Enter a model ID.`):C===null&&(e.includes(t.model.trim())||_.some(e=>e.id!==t.id&&e.model.trim()===t.model.trim()))&&z.set(t.id,`This model already has a row. Edit its prices there.`));B=C?.destinations.filter(e=>C.results.get(e.environmentId)?.status===`failed`)??[];let W=b||B.length>0;V=ae.length>0,L=h.length===1?h[0].label:`${h.length} environments`;let se=f===null?`All environments`:L,ce;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>{y([]),w(null)},t[40]=ce):ce=t[40],R=ce;let le;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(le=e=>{p(e),w(null)},t[41]=le):le=t[41];let G=le,K;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(K=e=>{y(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e]),w(null)},t[42]=K):K=t[42];let ue=K,q=sn,de;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>{!e.isNew&&Object.keys(e.values).length===0&&e.alias===void 0?y(t=>t.filter(t=>t.id!==e.id)):ue(e)},t[43]=de):de=t[43];let fe=de,J;t[44]===h?J=t[45]:(J=(e,t,n)=>{let r={...e.values,[t]:n},i=Gt(h,e.model,t);q(e,i,n)&&delete r[t],fe({...e,values:r})},t[44]=h,t[45]=J);let Y=J,pe;t[46]===h?pe=t[47]:(pe=(e,t)=>{let{alias:n,...r}=e,i=Wt(h,e.model);fe(q(e,i,t)?r:{...r,alias:t})},t[46]=h,t[47]=pe);let me=pe;H=async e=>{let t=e!==void 0&&e;if(b)return;let n=t?B:h,r=t&&C?C.drafts:ae;if(n.length===0||r.length===0)return;let i=n.map(e=>d.find(t=>t.environmentId===e.environmentId)??{...e,prices:null,aliases:null,unavailable:`Environment removed`}),a=new Map(i.map(e=>[e.environmentId,Kt(e,r)]));S(!0),w(e=>({drafts:r,destinations:t&&e?e.destinations:i,results:new Map([...t&&e?e.results:[],...i.map(on)])}));let o=!1;await Jt({targets:i.map(e=>({...e,unavailable:e.unavailable??[...a.get(e.environmentId).errors.values()][0]??null})),changes:new Map([...a].map(an)),write:async e=>U(e.environmentId,`settings:write`)?j(e):{_tag:`Failure`},onResult:(e,t)=>{t.status===`failed`&&(o=!0),w(n=>n===null?null:{...n,results:new Map(n.results).set(e,t)})}}),S(!1),o||y([])},F=ke,ie=!0,t[48]!==c||t[49]!==b?(oe=e=>{b||c(e)},t[48]=c,t[49]=b,t[50]=oe):oe=t[50],P=Oe,ne=`max-w-4xl`,t[51]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsxs)(Ce,{children:[(0,$.jsx)(we,{children:`Custom model prices`}),(0,$.jsx)(De,{children:`Prices and mappings apply to all past and future usage on the environments you select.`})]}),t[51]=re):re=t[51],M=Ee;let he;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(Je,{id:`usage-prices-apply-label`,className:`shrink-0`,children:`Apply to`}),t[52]=he):he=t[52];let X;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,$.jsx)(D,{variant:`outline`,size:`sm`,className:`min-w-0`}),t[53]=X):X=t[53];let ye=b||V,be;t[54]===se?be=t[55]:(be=(0,$.jsx)(`span`,{id:`usage-prices-selection`,className:`truncate`,children:se}),t[54]=se,t[55]=be);let Se;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,$.jsx)(I,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[56]=Se):Se=t[56];let Te;t[57]!==ye||t[58]!==be?(Te=(0,$.jsxs)(x,{render:X,"aria-labelledby":`usage-prices-apply-label usage-prices-selection`,disabled:ye,children:[be,Se]}),t[57]=ye,t[58]=be,t[59]=Te):Te=t[59];let Ae=f===null,je;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(je=e=>G(e?null:new Set),t[60]=je):je=t[60];let Me;t[61]===Ae?Me=t[62]:(Me=(0,$.jsx)(u,{checked:Ae,closeOnClick:!1,onCheckedChange:je,children:`All environments`}),t[61]=Ae,t[62]=Me);let Ne;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,$.jsx)(A,{}),t[63]=Ne):Ne=t[63];let Pe;if(t[64]!==d||t[65]!==h||t[66]!==f){let e;t[68]!==d.length||t[69]!==h||t[70]!==f?(e=e=>(0,$.jsx)(u,{checked:f===null||f.has(e.environmentId),closeOnClick:!1,onCheckedChange:t=>{let n=new Set(h.map(rn));t?n.add(e.environmentId):n.delete(e.environmentId),G(n.size===d.length?null:n)},children:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.unavailable?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.unavailable}):null]})},e.environmentId),t[68]=d.length,t[69]=h,t[70]=f,t[71]=e):e=t[71],Pe=d.map(e),t[64]=d,t[65]=h,t[66]=f,t[67]=Pe}else Pe=t[67];let Fe;t[72]!==Me||t[73]!==Pe?(Fe=(0,$.jsxs)(n,{align:`start`,children:[Me,Ne,Pe]}),t[72]=Me,t[73]=Pe,t[74]=Fe):Fe=t[74];let Ie;t[75]!==Te||t[76]!==Fe?(Ie=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[he,(0,$.jsxs)(k,{children:[Te,Fe]})]}),t[75]=Te,t[76]=Fe,t[77]=Ie):Ie=t[77];let Le;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`USD / million tokens`}),t[78]=Le):Le=t[78],t[79]===Ie?ee=t[80]:(ee=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[Ie,Le]}),t[79]=Ie,t[80]=ee),te=h.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:d.length===0?`Connect an environment to set model prices.`:`Select an environment to see and change its model prices.`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`min-w-0 overflow-hidden rounded-lg border border-border`,children:(0,$.jsxs)(Mt,{className:`min-w-180 table-fixed`,"aria-label":`Custom model prices`,children:[(0,$.jsxs)(`colgroup`,{children:[(0,$.jsx)(`col`,{className:`w-[22%]`}),(0,$.jsx)(`col`,{className:`w-[18%]`}),Rt.map(nn),(0,$.jsx)(`col`,{className:`w-10`})]}),(0,$.jsx)(Nt,{children:(0,$.jsxs)(Ft,{children:[(0,$.jsx)(It,{children:`Model ID`}),(0,$.jsx)(It,{children:`Map to`}),Rt.map(tn),(0,$.jsx)(It,{children:(0,$.jsx)(D,{size:`icon-xs`,variant:`ghost`,"aria-label":`Add model price`,disabled:W,onClick:()=>{E.current+=1;let e=`new:${E.current}`;T.current=e,ue({id:e,model:``,isNew:!0,values:{}})},children:(0,$.jsx)(a,{"aria-hidden":!0})})})]})}),(0,$.jsx)(Pt,{children:O.length===0?(0,$.jsx)(Ft,{children:(0,$.jsx)(Lt,{colSpan:7,className:`text-center whitespace-normal`,children:(0,$.jsx)(`p`,{className:`py-6 text-muted-foreground`,children:h.some(en)?`Some environment prices are unavailable.`:`No custom prices or mappings. Add a row to set one.`})})}):O.map(e=>{let t=Wt(h,e.model),n=(e.alias??t.value).trim();return(0,$.jsxs)(Ft,{"data-row-id":e.id,children:[(0,$.jsxs)(Lt,{className:`whitespace-normal`,children:[e.isNew?(0,$.jsx)(xe,{size:`compact`,value:e.model,ref:t=>{t&&T.current===e.id&&(t.focus(),T.current=null)},"aria-label":`New model ID`,"aria-invalid":e.model.trim()!==``&&z.has(e.id)||void 0,list:`usage-price-models`,placeholder:`Model ID`,autoComplete:`off`,spellCheck:!1,disabled:W,onChange:t=>ue({...e,model:t.target.value})}):(0,$.jsx)(`span`,{className:N(`block break-all`,e.removed&&`text-muted-foreground line-through`),children:e.model}),z.has(e.id)&&(e.model.trim()!==``||Object.values(e.values).some($t))?(0,$.jsx)(`p`,{role:`alert`,className:`mt-1 text-xs text-destructive`,children:z.get(e.id)}):null]}),e.removed?(0,$.jsx)(Lt,{colSpan:5,children:(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Automatic pricing after saving`})}):(0,$.jsx)(Lt,{children:(0,$.jsx)(xe,{size:`compact`,value:e.alias??t.value,"aria-label":`Map ${e.model||`new model`} to model`,list:`usage-alias-models`,placeholder:e.isNew?`Optional`:t.placeholder,autoComplete:`off`,spellCheck:!1,disabled:W,onChange:t=>me(e,t.target.value)})}),e.removed?null:n===``?Rt.map(t=>{let n=Gt(h,e.model,t.key);return(0,$.jsx)(Lt,{children:(0,$.jsx)(xe,{size:`compact`,inputMode:`decimal`,"aria-label":`${t.label} price for ${e.model||`new model`}`,value:e.values[t.key]??(e.isNew?``:n.value),placeholder:e.isNew?t.optional?`Input rate`:`0.00`:n.placeholder,autoComplete:`off`,disabled:W,font:`mono`,onChange:n=>Y(e,t.key,n.target.value)})},t.key)}):(0,$.jsx)(Lt,{colSpan:4,className:`whitespace-normal`,children:(0,$.jsxs)(`span`,{className:`break-all text-muted-foreground`,children:[`Counted as `,n]})}),(0,$.jsx)(Lt,{children:(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{render:(0,$.jsx)(D,{size:`icon-xs`,variant:`ghost`}),disabled:W,"aria-label":e.removed?`Undo reset for ${e.model}`:e.isNew?`Remove new model`:`Reset price for ${e.model} to automatic`,onClick:()=>{e.isNew?y(t=>t.filter(t=>t.id!==e.id)):e.removed?fe({...e,removed:!1}):ue({...e,removed:!0})},children:e.isNew?(0,$.jsx)(l,{"aria-hidden":!0}):(0,$.jsx)(v,{"aria-hidden":!0})}),(0,$.jsx)(_e,{children:e.removed?`Undo reset`:e.isNew?`Remove row`:`Reset to automatic`})]})})]},e.id)})})]})}),(0,$.jsx)(`datalist`,{id:`usage-price-models`,children:o.filter(t=>!e.includes(t)).map(Qt)}),(0,$.jsx)(`datalist`,{id:`usage-alias-models`,children:o.filter(e=>h.every(t=>!Object.hasOwn(t.aliases??{},e))).map(Zt)}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Blank cache rates use the input price. Enter 0 for free tokens. A mapped model’s usage counts as the model it maps to.`,h.length>1?` Mixed cells keep each environment’s rate until you edit them.`:``]})]}),t[9]=C,t[10]=_,t[11]=d,t[12]=c,t[13]=b,t[14]=h,t[15]=f,t[16]=j,t[17]=i,t[18]=M,t[19]=P,t[20]=F,t[21]=L,t[22]=R,t[23]=z,t[24]=B,t[25]=V,t[26]=H,t[27]=ee,t[28]=te,t[29]=ne,t[30]=re,t[31]=ie,t[32]=oe}else M=t[18],P=t[19],F=t[20],L=t[21],R=t[22],z=t[23],B=t[24],V=t[25],H=t[26],ee=t[27],te=t[28],ne=t[29],re=t[30],ie=t[31],oe=t[32];let W;t[81]===C?W=t[82]:(W=C?(0,$.jsx)(`div`,{role:`status`,className:`grid gap-1 text-xs`,children:C.destinations.map(e=>{let t=C.results.get(e.environmentId);return(0,$.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate text-muted-foreground`,children:e.label}),(0,$.jsx)(`span`,{className:t?.status===`failed`?`text-right text-destructive`:`text-muted-foreground`,children:t?.status===`failed`?`Not saved · ${t.error}`:t?.status===`saved`?`Saved`:`Saving…`})]},e.environmentId)})}):null,t[81]=C,t[82]=W);let ce;t[83]!==M||t[84]!==W||t[85]!==ee||t[86]!==te?(ce=(0,$.jsxs)(M,{children:[ee,te,W]}),t[83]=M,t[84]=W,t[85]=ee,t[86]=te,t[87]=ce):ce=t[87];let le=V?`Changes apply to ${L}`:``,G;t[88]===le?G=t[89]:(G=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:le}),t[88]=le,t[89]=G);let K;t[90]!==R||t[91]!==B.length||t[92]!==V||t[93]!==b?(K=V?(0,$.jsx)(D,{variant:`ghost`,disabled:b,onClick:R,children:B.length>0?`Discard pending changes`:`Discard changes`}):null,t[90]=R,t[91]=B.length,t[92]=V,t[93]=b,t[94]=K):K=t[94];let ue=b||!V&&B.length===0||B.length===0&&(z.size>0||h.length===0),q;t[95]!==B.length||t[96]!==H?(q=()=>void H(B.length>0),t[95]=B.length,t[96]=H,t[97]=q):q=t[97];let de=b?`Saving…`:B.length>0?`Retry failed saves`:`Save changes`,fe;t[98]!==ue||t[99]!==q||t[100]!==de?(fe=(0,$.jsx)(D,{disabled:ue,onClick:q,children:de}),t[98]=ue,t[99]=q,t[100]=de,t[101]=fe):fe=t[101];let J;t[102]!==K||t[103]!==fe?(J=(0,$.jsxs)(`div`,{className:`flex w-full flex-wrap justify-end gap-2 sm:w-auto`,children:[K,fe]}),t[102]=K,t[103]=fe,t[104]=J):J=t[104];let Y;t[105]!==G||t[106]!==J?(Y=(0,$.jsxs)(Te,{variant:`bare`,className:`items-center sm:justify-between`,children:[G,J]}),t[105]=G,t[106]=J,t[107]=Y):Y=t[107];let pe;t[108]!==P||t[109]!==ce||t[110]!==Y||t[111]!==ne||t[112]!==re?(pe=(0,$.jsxs)(P,{className:ne,children:[re,ce,Y]}),t[108]=P,t[109]=ce,t[110]=Y,t[111]=ne,t[112]=re,t[113]=pe):pe=t[113];let me;return t[114]!==F||t[115]!==pe||t[116]!==ie||t[117]!==oe?(me=(0,$.jsx)(F,{open:ie,onOpenChange:oe,children:pe}),t[114]=F,t[115]=pe,t[116]=ie,t[117]=oe,t[118]=me):me=t[118],me}function Zt(e){return(0,$.jsx)(`option`,{value:e},e)}function Qt(e){return(0,$.jsx)(`option`,{value:e},e)}function $t(e){return e!==``}function en(e){return e.prices===null}function tn(e){return(0,$.jsx)(It,{children:e.label},e.key)}function nn(e){return(0,$.jsx)(`col`,{},e.key)}function rn(e){return e.environmentId}function an(e){let[t,n]=e;return[t,n.changes]}function on(e){return[e.environmentId,{status:`saving`}]}function sn(e,t,n){return!e.isNew&&t.placeholder!==`Mixed`&&t.placeholder!==`Unavailable`&&n===t.value}function cn(e){return!Vt(e)}function ln(e){return e.isNew}function un(e){return e.model.trim()}function dn(e){return e.isNew}function fn(e){return e.summary?.buckets.map(pn)??[]}function pn(e){return e.model}function mn(e){return[...Object.keys(e.prices??{}),...Object.keys(e.aliases??{})]}var hn=960,gn=260,_n=4,vn=8,yn=new Set;function bn(e,t,n){let r=e?.byProvider.get(t);return r===void 0?0:n===`tokens`?r.totalTokens:r.costUsd}function xn(e,t,n){return e.map(e=>{let r=t.get(e),i=Ye.map(e=>({provider:e,value:bn(r,e,n)}));return{bands:i,total:i.reduce((e,t)=>e+t.value,0)}})}function Sn(e){let t=e.length;if(t<2)return[0];let n=[];for(let r=0;r<t-1;r+=1){let t=(e[r+1]?.x??0)-(e[r]?.x??0),i=(e[r+1]?.y??0)-(e[r]?.y??0);n.push(t===0?0:i/t)}let r=Array.from({length:t},()=>0);r[0]=n[0]??0,r[t-1]=n[t-2]??0;for(let e=1;e<t-1;e+=1){let t=n[e-1]??0,i=n[e]??0;r[e]=t*i<=0?0:(t+i)/2}for(let e=0;e<t-1;e+=1){let t=n[e]??0;if(t===0){r[e]=0,r[e+1]=0;continue}let i=(r[e]??0)/t,a=(r[e+1]??0)/t,o=i*i+a*a;if(o>9){let n=3/Math.sqrt(o);r[e]=n*i*t,r[e+1]=n*a*t}}return r}function Cn(e){if(e.length<2)return[];let t=Sn(e),n=[];for(let r=0;r<e.length-1;r+=1){let i=e[r],a=e[r+1];if(i===void 0||a===void 0)continue;let o=a.x-i.x;n.push({from:i,c1:{x:i.x+o/3,y:i.y+(t[r]??0)*o/3},c2:{x:a.x-o/3,y:a.y-(t[r+1]??0)*o/3},to:a})}return n}function wn(e){let t=e[0];if(t===void 0)return``;let n=`M${t.from.x.toFixed(2)},${t.from.y.toFixed(2)}`;for(let t of e)n+=` C${t.c1.x.toFixed(2)},${t.c1.y.toFixed(2)} ${t.c2.x.toFixed(2)},${t.c2.y.toFixed(2)} ${t.to.x.toFixed(2)},${t.to.y.toFixed(2)}`;return n}function Tn(e){return e===``?``:`${e} L${hn},${gn} L0,${gn} Z`}function En(e,t){if(e<=0)return{max:0,ticks:[0]};let n=e/t,r=10**Math.floor(Math.log10(n)),i=n/r,a=(i>5?10:i>2?5:i>1?2:1)*r,o=Math.ceil(e/a)*a,s=[];for(let e=0;e<=o+a*1e-6;e+=a)s.push(e);return{max:o,ticks:s}}var Dn=Array.from({length:5},(e,t)=>t);function On(e,t){let n=e.reduce((e,t)=>t.bands.reduce((e,t)=>Math.max(e,t.value),e),0);return n===0&&t.size>0?{max:_n,ticks:Dn,labeled:!1}:{...En(n,_n),labeled:!0}}function kn(e,t){return t===0?gn:gn-e/t*252}function An(e,t,n,r,i){let a=xn(e,t,n),o=On(a,i),s=e.length<2?0:hn/(e.length-1);return{columns:a,scale:o,stepX:s,paths:r.map(e=>{let t=Ye.indexOf(e),n=wn(Cn(a.map((e,n)=>({x:n*s,y:kn(e.bands[t]?.value??0,o.max)}))));return{provider:e,loading:i.has(e),total:a.reduce((e,n)=>e+(n.bands[t]?.value??0),0),line:n,area:Tn(n)}}).toSorted((e,t)=>t.total-e.total)}}function jn(e){let t=(0,Q.c)(97),{providers:n,loadingProviders:r,days:i,daily:a,hours:o,hourly:s,metric:c,referenceTime:l,resolution:u,timeZone:d}=e,f=r===void 0?yn:r,p=u===`hour`?o:i,m;t[0]!==a||t[1]!==s||t[2]!==u?(m=u===`hour`?new Map(s.map(Pn)):new Map(a.map(Nn)),t[0]=a,t[1]=s,t[2]=u,t[3]=m):m=t[3];let h=m,[g,_]=(0,Z.useState)(null),v=(0,Z.useRef)(null),y=(0,Z.useRef)(null),b=(0,Z.useRef)(null),x;t[4]!==h||t[5]!==f||t[6]!==c||t[7]!==p||t[8]!==n?(x=An(p,h,c,n,f),t[4]=h,t[5]=f,t[6]=c,t[7]=p,t[8]=n,t[9]=x):x=t[9];let{columns:S,scale:C,paths:w,stepX:T}=x,E;t[10]===C.max?E=t[11]:(E=e=>kn(e,C.max),t[10]=C.max,t[11]=E);let D=E,O=Mn,k=c===`tokens`?q:G,A;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>{let e=v.current,t=y.current,n=b.current;if(e===null||t===null||n===null)return;let r=t.offsetWidth,i=t.offsetHeight,a=e.clientWidth,o=e.clientHeight,s=n.x+12+r<=a?n.x+12:n.x-12-r,c=n.y+12+i<=o?n.y+12:n.y-12-i,l=Math.min(Math.max(0,s),Math.max(0,a-r)),u=Math.min(Math.max(0,c),Math.max(0,o-i));e.style.setProperty(`--usage-tooltip-left`,`${l}px`),e.style.setProperty(`--usage-tooltip-top`,`${u}px`)},t[12]=A):A=t[12];let j=A,M,P;t[13]===g?(M=t[14],P=t[15]):(M=()=>{if(g===null)return;j();let e=v.current,t=y.current;if(e!==null&&t!==null)return je([e,t],j)},P=[g,j],t[13]=g,t[14]=M,t[15]=P),(0,Z.useLayoutEffect)(M,P);let F;t[16]===p.length?F=t[17]:(F=e=>{let t=v.current;if(t===null||p.length===0)return;let n=t.getBoundingClientRect();if(n.width===0)return;let r=Math.min(n.width,Math.max(0,e.clientX-n.left)),i=Math.min(n.height,Math.max(0,e.clientY-n.top)),a=r/n.width,o=Math.round(a*(p.length-1));b.current={x:r,y:i},j(),_(Math.min(p.length-1,Math.max(0,o)))},t[16]=p.length,t[17]=F);let I=F,L=g===null?void 0:p[g],R=g===null?void 0:S[g],z;if(t[18]!==f||t[19]!==n){let e;t[21]===f?e=t[22]:(e=e=>f.has(e),t[21]=f,t[22]=e),z=n.some(e),t[18]=f,t[19]=n,t[20]=z}else z=t[20];let B=z,V;t[23]!==u||t[24]!==d?(V=e=>u===`hour`?fe(e,d):ce(e),t[23]=u,t[24]=d,t[25]=V):V=t[25];let H=V,ee;t[26]!==H||t[27]!==l||t[28]!==u||t[29]!==d?(ee=e=>u===`hour`&&l!==void 0?le(e,l,d):H(e),t[26]=H,t[27]=l,t[28]=u,t[29]=d,t[30]=ee):ee=t[30];let te=ee,ne;t[31]!==k||t[32]!==C.labeled||t[33]!==C.ticks||t[34]!==D?(ne=C.labeled?C.ticks.map(e=>(0,$.jsx)(`span`,{className:`absolute right-0 -translate-y-1/2 text-3xs text-muted-foreground tabular-nums`,style:{top:`${D(e)/gn*100}%`},children:e===0?`0`:k(e)},e)):null,t[31]=k,t[32]=C.labeled,t[33]=C.ticks,t[34]=D,t[35]=ne):ne=t[35];let re;t[36]===ne?re=t[37]:(re=(0,$.jsx)(`div`,{className:`relative h-56 w-14 shrink-0`,children:ne}),t[36]=ne,t[37]=re);let ie;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>{b.current=null,_(null)},t[38]=ie):ie=t[38];let ae=`${u===`hour`?`Hourly`:`Daily`} ${c===`tokens`?`processed tokens`:`cost`} by provider`,oe;if(t[39]!==C.ticks||t[40]!==D){let e;t[42]===D?e=t[43]:(e=e=>{let t=D(e);return(0,$.jsx)(`line`,{x1:0,x2:hn,y1:t,y2:t,stroke:`currentColor`,strokeWidth:1,className:`text-border`,vectorEffect:`non-scaling-stroke`},e)},t[42]=D,t[43]=e),oe=C.ticks.map(e),t[39]=C.ticks,t[40]=D,t[41]=oe}else oe=t[41];let U;if(t[44]!==w){let e;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>{let{provider:t,loading:n,area:r}=e;return(0,$.jsx)(`path`,{d:r,className:O(n),fill:Xe[t].color,fillOpacity:.12},t)},t[46]=e):e=t[46],U=w.map(e),t[44]=w,t[45]=U}else U=t[45];let W;if(t[47]!==w){let e;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>{let{provider:t,loading:n,line:r}=e;return(0,$.jsx)(`path`,{d:r,className:O(n),fill:`none`,stroke:Xe[t].color,strokeWidth:2,vectorEffect:`non-scaling-stroke`},t)},t[49]=e):e=t[49],W=w.map(e),t[47]=w,t[48]=W}else W=t[48];let se;t[50]!==g||t[51]!==T?(se=g===null?null:(0,$.jsx)(`line`,{x1:g*T,x2:g*T,y1:vn,y2:gn,stroke:`currentColor`,strokeWidth:1,className:`text-muted-foreground`,vectorEffect:`non-scaling-stroke`}),t[50]=g,t[51]=T,t[52]=se):se=t[52];let K;t[53]!==ae||t[54]!==oe||t[55]!==U||t[56]!==W||t[57]!==se?(K=(0,$.jsxs)(`svg`,{className:`h-full w-full`,viewBox:`0 0 ${hn} ${gn}`,preserveAspectRatio:`none`,role:`img`,"aria-label":ae,children:[oe,U,W,se]}),t[53]=ae,t[54]=oe,t[55]=U,t[56]=W,t[57]=se,t[58]=K):K=t[58];let ue;t[59]!==k||t[60]!==te||t[61]!==R?.bands||t[62]!==R?.total||t[63]!==L||t[64]!==f||t[65]!==B||t[66]!==n?(ue=L===void 0?null:(0,$.jsxs)(`div`,{ref:y,className:`surface-glass pointer-events-none absolute z-10 min-w-36 max-w-full rounded-xl border border-border/50 px-2.5 py-2 text-xs shadow-lg`,style:{left:`var(--usage-tooltip-left, 0px)`,top:`var(--usage-tooltip-top, 0px)`},children:[(0,$.jsx)(`div`,{className:`mb-1 text-muted-foreground`,children:te(L)}),n.map(e=>{let{label:t,driverKind:n}=Xe[e];return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,$.jsx)(Le,{driverKind:n,displayName:t,iconClassName:`size-3`}),t]}),(0,$.jsx)(`span`,{className:N(`tabular-nums`,f.has(e)?`text-muted-foreground`:`text-foreground`),children:k(R?.bands.find(t=>t.provider===e)?.value??0)})]},e)}),(0,$.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-3 border-t border-border pt-1`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Total`}),(0,$.jsx)(`span`,{className:N(`tabular-nums`,B?`text-muted-foreground`:`text-foreground`),children:k(R?.total??0)})]})]}),t[59]=k,t[60]=te,t[61]=R?.bands,t[62]=R?.total,t[63]=L,t[64]=f,t[65]=B,t[66]=n,t[67]=ue):ue=t[67];let de;t[68]!==I||t[69]!==K||t[70]!==ue?(de=(0,$.jsxs)(`div`,{ref:v,className:`relative h-56 flex-1`,onMouseMove:I,onMouseLeave:ie,children:[K,ue]}),t[68]=I,t[69]=K,t[70]=ue,t[71]=de):de=t[71];let J;t[72]!==re||t[73]!==de?(J=(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[re,de]}),t[72]=re,t[73]=de,t[74]=J):J=t[74];let Y;t[75]!==H||t[76]!==p[0]?(Y=p[0]===void 0?``:H(p[0]),t[75]=H,t[76]=p[0],t[77]=Y):Y=t[77];let pe;t[78]===Y?pe=t[79]:(pe=(0,$.jsx)(`span`,{children:Y}),t[78]=Y,t[79]=pe);let me;t[80]!==H||t[81]!==p?(me=p[Math.floor(p.length/2)]===void 0?``:H(p[Math.floor(p.length/2)]??``),t[80]=H,t[81]=p,t[82]=me):me=t[82];let he;t[83]===me?he=t[84]:(he=(0,$.jsx)(`span`,{children:me}),t[83]=me,t[84]=he);let ge;t[85]!==H||t[86]!==p?(ge=p[p.length-1]===void 0?``:H(p[p.length-1]??``),t[85]=H,t[86]=p,t[87]=ge):ge=t[87];let _e;t[88]===ge?_e=t[89]:(_e=(0,$.jsx)(`span`,{children:ge}),t[88]=ge,t[89]=_e);let ve;t[90]!==pe||t[91]!==he||t[92]!==_e?(ve=(0,$.jsxs)(`div`,{className:`flex justify-between pl-16 text-3xs text-muted-foreground uppercase`,children:[pe,he,_e]}),t[90]=pe,t[91]=he,t[92]=_e,t[93]=ve):ve=t[93];let X;return t[94]!==J||t[95]!==ve?(X=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[J,ve]}),t[94]=J,t[95]=ve,t[96]=X):X=t[96],X}function Mn(e){return N(`transition-opacity`,e&&`opacity-40 delay-150`)}function Nn(e){return[e.day,e]}function Pn(e){return[e.hourStart,e]}function Fn(e){let t=(0,Q.c)(30),{label:n,segments:r,format:i,aside:a}=e,o,s,c,l,u,d;if(t[0]!==a||t[1]!==i||t[2]!==n||t[3]!==r){d=Symbol.for(`react.early_return_sentinel`);bb0:{let e=r.filter(Ln),f=e.reduce(In,0);if(f<=0){d=null;break bb0}c=`flex min-w-0 flex-col gap-2.5`;let p;t[10]===n?p=t[11]:(p=(0,$.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:n}),t[10]=n,t[11]=p),t[12]!==a||t[13]!==p?(l=(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[p,a]}),t[12]=a,t[13]=p,t[14]=l):l=t[14];let m;t[15]===i?m=t[16]:(m=e=>`${e.label} ${i(e.value)}`,t[15]=i,t[16]=m);let h;t[17]!==i||t[18]!==f?(h=e=>(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{render:(0,$.jsx)(`div`,{className:`h-full min-w-1 rounded-xs first:rounded-l-full last:rounded-r-full`,style:{flex:`${e.value} 1 0`,backgroundColor:e.color}})}),(0,$.jsxs)(_e,{children:[e.label,` · `,i(e.value),` · `,Y(e.value/f)]})]},e.label),t[17]=i,t[18]=f,t[19]=h):h=t[19],u=(0,$.jsx)(`div`,{role:`img`,"aria-label":`${n}: ${e.map(m).join(`, `)}`,className:`flex h-2 gap-0.5`,children:e.map(h)}),o=`flex flex-wrap gap-x-4 gap-y-1 text-xs`;let g;t[20]===i?g=t[21]:(g=e=>(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-2 rounded-xs`,style:{backgroundColor:e.color}}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,$.jsx)(`span`,{className:`text-foreground tabular-nums`,children:i(e.value)})]},e.label),t[20]=i,t[21]=g),s=e.map(g)}t[0]=a,t[1]=i,t[2]=n,t[3]=r,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;t[22]!==o||t[23]!==s?(f=(0,$.jsx)(`div`,{className:o,children:s}),t[22]=o,t[23]=s,t[24]=f):f=t[24];let p;return t[25]!==c||t[26]!==l||t[27]!==u||t[28]!==f?(p=(0,$.jsxs)(`div`,{className:c,children:[l,u,f]}),t[25]=c,t[26]=l,t[27]=u,t[28]=f,t[29]=p):p=t[29],p}function In(e,t){return e+t.value}function Ln(e){return e.value>0}function Rn(e){return e.toSorted((e,t)=>t.totalTokens-e.totalTokens||t.costUsd-e.costUsd)}function zn(e,t){return t===`tokens`?e.tokenShare:pt(e)?null:e.costShare}function Bn({tokens:e}){let t=e.uncachedInputTokens+e.cachedInputTokens+e.cacheCreationTokens;return t===0?null:e.cachedInputTokens/t}function Vn(e){let t=e.totalTokens-e.unpricedTokens;return t<=0||pt(e)?null:e.costUsd/t*1e6}var Hn=e=>`color-mix(in oklab, var(--foreground) ${e}%, var(--background))`,Un={input:Hn(60),cacheRead:Hn(30),cacheWrite:Hn(72),output:Hn(100),other:Hn(44)};function Wn(e){return[{label:`Input`,value:e.input,color:Un.input},{label:`Cache read`,value:e.cacheRead,color:Un.cacheRead},{label:`Cache write`,value:e.cacheWrite,color:Un.cacheWrite},{label:`Output`,value:e.output,color:Un.output},{label:`Other`,value:e.unsplit>=.005?e.unsplit:0,color:Un.other}]}function Gn(e){return[{label:`Input`,value:e.uncachedInputTokens,color:Un.input},{label:`Cache read`,value:e.cachedInputTokens,color:Un.cacheRead},{label:`Cache write`,value:e.cacheCreationTokens,color:Un.cacheWrite},{label:`Output`,value:e.outputTokens,color:Un.output}]}function Kn(e){return[{label:`Standard`,value:e.standard,color:Hn(34)},{label:`Fast`,value:e.fast,color:Hn(66)},{label:`Ultrafast`,value:e.ultrafast,color:Hn(100)}]}function qn(e){let t=(0,Q.c)(80),{model:n,environments:r,metric:i,chartWindow:a,onSetPrice:o,onClose:s}=e,c;t[0]!==n.model||t[1]!==n.provider?(c=e=>e.provider===n.provider&&e.model===n.model,t[0]=n.model,t[1]=n.provider,t[2]=c):c=t[2];let l;t[3]!==r||t[4]!==c?(l=wt(r,c),t[3]=r,t[4]=c,t[5]=l):l=t[5];let u=l,d;t[6]===n.provider?d=t[7]:(d=[n.provider],t[6]=n.provider,t[7]=d);let f=d,p=Xe[n.provider],m;t[8]===n?m=t[9]:(m=pt(n),t[8]=n,t[9]=m);let h=m,g;if(t[10]!==h||t[11]!==n){let e=Bn(n),r=Vn(n),i;t[13]!==h||t[14]!==n.costUsd?(i=h?`Unpriced`:G(n.costUsd),t[13]=h,t[14]=n.costUsd,t[15]=i):i=t[15];let a;t[16]===i?a=t[17]:(a={label:`Cost`,value:i},t[16]=i,t[17]=a);let o;t[18]===n.totalTokens?o=t[19]:(o=q(n.totalTokens),t[18]=n.totalTokens,t[19]=o);let s;t[20]===o?s=t[21]:(s={label:`Tokens`,value:o},t[20]=o,t[21]=s),g=[a,s,r===null?null:{label:`Per 1M tokens`,value:G(r)},e===null?null:{label:`Cache hit`,value:Y(e)}].filter(Yn),t[10]=h,t[11]=n,t[12]=g}else g=t[12];let _=g,v;t[22]===s?v=t[23]:(v=e=>{e||s()},t[22]=s,t[23]=v);let y;t[24]!==p.driverKind||t[25]!==p.label?(y=(0,$.jsx)(Le,{driverKind:p.driverKind,displayName:p.label,iconClassName:`size-5`}),t[24]=p.driverKind,t[25]=p.label,t[26]=y):y=t[26];let b;t[27]===n.model?b=t[28]:(b=(0,$.jsx)(we,{children:n.model}),t[27]=n.model,t[28]=b);let x;t[29]!==y||t[30]!==b?(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y,b]}),t[29]=y,t[30]=b,t[31]=x):x=t[31];let S;t[32]!==h||t[33]!==n.costShare?(S=h?``:` · ${Y(n.costShare)} of cost`,t[32]=h,t[33]=n.costShare,t[34]=S):S=t[34];let C;t[35]!==p.label||t[36]!==S?(C=(0,$.jsxs)(De,{children:[p.label,S]}),t[35]=p.label,t[36]=S,t[37]=C):C=t[37];let w;t[38]!==C||t[39]!==x?(w=(0,$.jsxs)(Ce,{children:[x,C]}),t[38]=C,t[39]=x,t[40]=w):w=t[40];let T;t[41]===_?T=t[42]:(T=(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-4 sm:grid-cols-4`,children:_.map(Jn)}),t[41]=_,t[42]=T);let E=h?`tokens`:i,O;t[43]!==a.days||t[44]!==a.hours||t[45]!==a.referenceTime||t[46]!==a.resolution||t[47]!==a.timeZone||t[48]!==f||t[49]!==E||t[50]!==u.daily||t[51]!==u.hourly?(O=(0,$.jsx)(jn,{providers:f,days:a.days,daily:u.daily,hours:a.hours,hourly:u.hourly,metric:E,referenceTime:a.referenceTime,resolution:a.resolution,timeZone:a.timeZone}),t[43]=a.days,t[44]=a.hours,t[45]=a.referenceTime,t[46]=a.resolution,t[47]=a.timeZone,t[48]=f,t[49]=E,t[50]=u.daily,t[51]=u.hourly,t[52]=O):O=t[52];let k;t[53]!==h||t[54]!==u.categoryCost?(k=h?null:(0,$.jsx)(Fn,{label:`Cost by type`,segments:Wn(u.categoryCost),format:G}),t[53]=h,t[54]=u.categoryCost,t[55]=k):k=t[55];let A;t[56]===n.tokens?A=t[57]:(A=Gn(n.tokens),t[56]=n.tokens,t[57]=A);let j;t[58]===A?j=t[59]:(j=(0,$.jsx)(Fn,{label:`Tokens by type`,segments:A,format:q}),t[58]=A,t[59]=j);let M;t[60]===u.speedCost?M=t[61]:(M=u.speedCost.fast+u.speedCost.ultrafast>0?(0,$.jsx)(Fn,{label:`Cost by speed`,segments:Kn(u.speedCost),format:G,aside:(0,$.jsx)(Xn,{premiumUsd:u.speedCost.premium})}):null,t[60]=u.speedCost,t[61]=M);let N;t[62]!==k||t[63]!==j||t[64]!==M?(N=(0,$.jsxs)(`div`,{className:`grid gap-x-10 gap-y-8 sm:grid-cols-2`,children:[k,j,M]}),t[62]=k,t[63]=j,t[64]=M,t[65]=N):N=t[65];let P;t[66]!==T||t[67]!==O||t[68]!==N?(P=(0,$.jsx)(Ee,{children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[T,O,N]})}),t[66]=T,t[67]=O,t[68]=N,t[69]=P):P=t[69];let F;t[70]!==n.unpricedTokens||t[71]!==o?(F=n.unpricedTokens>0?(0,$.jsxs)(Te,{variant:`bare`,className:`items-center sm:justify-between`,children:[(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[q(n.unpricedTokens),` tokens have no known price`]}),(0,$.jsx)(D,{onClick:o,children:`Set price`})]}):null,t[70]=n.unpricedTokens,t[71]=o,t[72]=F):F=t[72];let I;t[73]!==w||t[74]!==P||t[75]!==F?(I=(0,$.jsxs)(Oe,{className:`max-w-3xl`,children:[w,P,F]}),t[73]=w,t[74]=P,t[75]=F,t[76]=I):I=t[76];let L;return t[77]!==I||t[78]!==v?(L=(0,$.jsx)(ke,{open:!0,onOpenChange:v,children:I}),t[77]=I,t[78]=v,t[79]=L):L=t[79],L}function Jn(e){return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,$.jsx)(`span`,{className:`text-2xl font-semibold text-foreground`,children:e.value})]},e.label)}function Yn(e){return e!==null}function Xn(e){let t=(0,Q.c)(4),{premiumUsd:n}=e,r;t[0]===n?r=t[1]:(r=G(n),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Premium `,(0,$.jsx)(`span`,{className:`text-foreground tabular-nums`,children:r})]}),t[2]=r,t[3]=i),i}var Zn=`p4code:usage-page-preferences:v1`,Qn=g({metric:d([`cost`,`tokens`,`limits`]),windowDays:d([1,7,30,90]),hiddenProviders:w(h(C))}),$n={metric:`limits`,windowDays:30};function er(){try{return o(Zn,Qn)??$n}catch(e){return console.error(`Could not read Usage page preferences.`,e),$n}}function tr(e){try{T(Zn,e,Qn)}catch(e){console.error(`Could not save Usage page preferences.`,e)}}function nr(e){return He.some(t=>t.value===e)}function rr(e){return Be.some(t=>t.days===e)}var ir=e=>Xe[e].label;function ar(){let[e,t]=(0,Z.useState)(er);re();let n=r(oe),i=e=>{let t=Me(n,e.command,{context:{usagePageOpen:!0}});return t?`${e.label} (${t})`:e.label},[a,o]=(0,Z.useState)(()=>({days:e.windowDays,window:K(e.windowDays,void 0,e.windowDays===1?`hour`:`day`)})),s=e.metric,c=s===`limits`,[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(()=>Date.now()),p=(0,Z.useRef)(!1),[h,g]=(0,Z.useState)(`model`),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(null),C=(0,Z.useMemo)(()=>new Set(e.hiddenProviders),[e.hiddenProviders]),{days:w,window:T}=a,E=w===1,{merged:O,environments:k,selectedEnvironments:A,shown:j,isPartial:M,refresh:P}=Dt(T,x,C),I=j?.merged??O,L=j?.window??T,R=L.resolution===`hour`,z=l&&!c,B=j!==null&&j.window!==T,U=(0,Z.useMemo)(()=>{if(B)return{partial:!0,everyProvider:!0,providers:new Set};let e=ft(A,z),t=new Set([...e.providers].filter(e=>!C.has(e)));return{partial:e.everyProvider||t.size>0,everyProvider:e.everyProvider,providers:t}},[B,z,A,C]),W=e=>U.everyProvider||U.providers.has(e),le=r(ie.presentationsAtom),me=C.has(`cursor`)?[]:at(A),ge=[...new Set(A.flatMap(e=>e.summary?.sources.flatMap(e=>e.message&&!e.action&&!C.has(e.fingerprint.provider)&&(e.status===`partial`||e.status===`failed`||e.fingerprint.provider===`cursor`)?[e.message]:[])??[]))],_e=se(ae.refreshProviders,{reportFailure:!1}),ve=A.some(e=>e.canReadDiagnostics),X=(0,Z.useMemo)(()=>pe(L.sinceDay,L.untilDay),[L.sinceDay,L.untilDay]),xe=(0,Z.useMemo)(()=>L.sinceTime===void 0||L.untilTime===void 0?[]:de(L.sinceTime,L.untilTime),[L.sinceTime,L.untilTime]),Ce=(0,Z.useMemo)(()=>(R?I.hourly:I.daily).toReversed(),[R,I.daily,I.hourly]),we=(0,Z.useMemo)(()=>h===`model`&&s===`tokens`?Rn(I.models):I.models,[h,I.models,s]),Te=(0,Z.useMemo)(()=>qe(I.providers),[I.providers]),Ee=(0,Z.useMemo)(()=>Ye.filter(e=>Te.includes(e)||U.providers.has(e)),[U.providers,Te]),De=(0,Z.useMemo)(()=>new Set(Ee.filter(e=>U.everyProvider||U.providers.has(e))),[Ee,U.everyProvider,U.providers]),Oe=y===null?void 0:I.models.find(e=>`${e.provider}:${e.model}`===y),ke=we.reduce((e,t)=>Math.max(e,s===`tokens`?t.totalTokens:t.costUsd),0),je=Ee.map(e=>({kind:`usage`,provider:e})),Le=Math.max(Ee.indexOf(`codex`),Ee.indexOf(`claude`))+1;je.splice(Le,0,...me.map(e=>({kind:`enable`,environment:e})));let Je=`${60/(Ee.length+2)}%`,Qe=n=>{let r={...e,...n};t(r),tr(r)},nt=e=>{rr(e)&&(Qe({windowDays:e}),o({days:e,window:K(e,void 0,e===1?`hour`:`day`)}))},Q=e=>{e===`limits`&&f(Date.now()),Qe({metric:e})},rt=async(e=!1,t=!1)=>{try{await Promise.all(Array.from(le,([n,r])=>{if((x===null||x.has(n))&&r.connection.phase===`connected`&&r.serverConfig!==null)return ct(n,()=>_e({environmentId:n,input:{}}),e,t)}))}finally{f(Date.now())}},it=(0,Z.useEffectEvent)(e=>{if(e.defaultPrevented||e.repeat||e.isComposing||Ge()||Ue())return;let t=Ve(e,n),r=He.find(e=>e.command===t),i=Be.find(e=>e.command===t);(r||i)&&(e.preventDefault(),e.stopPropagation(),r&&Q(r.value),i&&!c&&nt(i.days))});(0,Z.useEffect)(()=>(globalThis.window.addEventListener(`keydown`,it,!0),()=>globalThis.window.removeEventListener(`keydown`,it,!0)),[]);let ot=()=>{if(p.current)return;if(c){p.current=!0,u(!0),rt().finally(()=>{p.current=!1,u(!1)});return}let e=K(w,void 0,E?`hour`:`day`);(e.sinceDay!==T.sinceDay||e.untilDay!==T.untilDay||e.sinceTime!==T.sinceTime||e.untilTime!==T.untilTime)&&o({days:w,window:e}),p.current=!0,u(!0),P(e).finally(()=>{p.current=!1,u(!1)})},st=[...le].filter(([e,t])=>t.connection.phase===`connected`&&t.serverConfig!==null&&(x===null||x.has(e))).map(([e])=>e).sort().join(`,`),lt=(0,Z.useEffectEvent)(()=>{rt(!0)});(0,Z.useEffect)(()=>{c&&st&<()},[c,st]);let ut=R&&L.sinceTime!==void 0&&L.untilTime!==void 0?`${ue(L.sinceTime,L.timeZone)} to ${ue(L.untilTime,L.timeZone)}`:`${ce(L.sinceDay)} to ${ce(L.untilDay)}`,dt=(0,$.jsxs)(`div`,{className:`grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 py-2 xl:flex`,children:[(0,$.jsxs)(tt,{ariaLabel:`Usage breadcrumb`,className:`min-w-0`,children:[(0,$.jsx)($e,{children:(0,$.jsx)(`h1`,{children:`Usage`})}),(0,$.jsx)(et,{}),(0,$.jsx)($e,{className:`min-w-10 shrink`,children:(0,$.jsx)(vr,{environments:k,selectedEnvironments:A,selectedEnvironmentIds:x,onSelectionChange:S,showUsageStatus:!c,refreshing:z,isPartial:M,duplicateSources:I.duplicateSources,contractMismatches:I.contractMismatches,onOpenModelPrices:()=>v({})})}),(0,$.jsx)(et,{}),(0,$.jsx)($e,{current:!0,className:`min-w-10`,children:(0,$.jsx)(xr,{hiddenProviders:C,onChange:e=>Qe({hiddenProviders:e})})})]}),c?null:(0,$.jsx)(`span`,{className:`hidden min-w-0 truncate text-xs text-muted-foreground 2xl:block`,children:ut}),(0,$.jsxs)(`div`,{className:`ms-auto hidden min-w-0 items-center justify-end gap-2 xl:flex`,children:[(0,$.jsx)(ye,{"aria-label":`Usage metric`,variant:`segmented`,value:[s],onValueChange:e=>{let t=e[0];nr(t)&&Q(t)},children:He.map(e=>(0,$.jsx)(be,{value:e.value,title:i(e),children:e.label},e.value))}),(0,$.jsx)(ye,{"aria-label":`Usage period`,variant:`segmented`,value:[String(w)],disabled:c,onValueChange:e=>{let t=e[0];t&&nt(Number(t))},children:Be.map(e=>(0,$.jsx)(be,{value:String(e.days),title:i(e),children:e.label},e.days))}),(0,$.jsx)(D,{onClick:ot,"aria-label":c?`Refresh limits`:`Refresh usage`,"aria-busy":l,disabled:l||!c&&!ve,size:`icon-sm`,variant:`ghost`,children:(0,$.jsx)(We,{size:`sm`,refreshing:l})})]}),(0,$.jsxs)(`div`,{className:`ms-auto flex min-w-0 items-center justify-end gap-1 xl:hidden`,children:[(0,$.jsxs)(ne,{value:s,onValueChange:e=>{nr(e)&&Q(e)},children:[(0,$.jsx)(te,{"aria-label":`Usage metric`,size:`compact`,variant:`ghost`,className:`w-auto min-w-0`,children:(0,$.jsx)(H,{children:He.find(e=>e.value===s)?.label})}),(0,$.jsx)(ee,{align:`end`,alignItemWithTrigger:!1,children:He.map(e=>(0,$.jsx)(V,{value:e.value,title:i(e),children:e.label},e.value))})]}),(0,$.jsxs)(ne,{value:String(w),disabled:c,onValueChange:e=>nt(Number(e)),children:[(0,$.jsx)(te,{"aria-label":`Usage period`,size:`compact`,variant:`ghost`,className:`w-auto min-w-0`,children:(0,$.jsx)(H,{children:Be.find(e=>e.days===w)?.label})}),(0,$.jsx)(ee,{align:`end`,alignItemWithTrigger:!1,children:Be.map(e=>(0,$.jsx)(V,{value:String(e.days),title:i(e),children:e.label},e.days))})]}),(0,$.jsx)(D,{onClick:ot,"aria-label":c?`Refresh limits`:`Refresh usage`,"aria-busy":l,disabled:l||!c&&!ve,size:`icon-sm`,variant:`ghost`,children:(0,$.jsx)(We,{size:`sm`,refreshing:l})})]})]});return(0,$.jsxs)(Ae,{className:`h-dvh min-h-0 overflow-hidden overscroll-y-none isolate`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-background text-foreground`,children:[(0,$.jsx)(Ze,{electron:he,children:dt}),(0,$.jsx)(Se,{className:`min-h-0 flex-1`,children:(0,$.jsx)(ze,{width:`wide`,children:A.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:k.length===0?`Connect an environment to see ${c?`limits`:`usage`}.`:`Select an environment to see ${c?`limits`:`usage`}.`}):c?(0,$.jsx)(Ke,{selectedEnvironmentIds:x,hiddenProviders:C,now:d,cursorPrompt:me.length>0?(0,$.jsx)(lr,{environments:me,onEnabled:()=>{P(),rt(!1,!0)}}):null}):j===null?(0,$.jsx)(Sr,{}):ve?(0,$.jsxs)(`div`,{"aria-busy":U.partial,className:`flex flex-col gap-6`,children:[ge.map(e=>(0,$.jsx)(`p`,{className:`mb-4 text-sm text-muted-foreground`,children:e},e)),(0,$.jsxs)(`section`,{className:`grid gap-6 lg:grid-cols-[minmax(0,18rem)_minmax(0,1fr)]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:N(`text-4xl font-semibold text-foreground tabular-nums`,dr(U.partial)),children:s===`cost`?G(I.costUsd):q(I.totalTokens)}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsxs)(`span`,{className:dr(U.partial),children:[J(I.sessions),` sessions`]}),s===`cost`&&` · API estimate`]}),s===`cost`&&I.costQuality.unpricedShare>0&&(0,$.jsxs)(Fe,{children:[(0,$.jsx)(Pe,{openOnHover:!0,render:(0,$.jsx)(F,{tone:`muted`}),"aria-label":`Unpriced usage details`,children:(0,$.jsx)(m,{className:`size-3`,"aria-hidden":!0})}),(0,$.jsxs)(Ne,{side:`top`,tooltipStyle:!0,children:[`API estimate excludes`,` `,Y(I.costQuality.unpricedShare),` unpriced records.`]})]})]})]}),!C.has(`codex`)&&[...le].some(([e,t])=>(x===null||x.has(e))&&t.serverConfig?.providers.some(Ie))?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:`ChatGPT shared usage`}),(0,$.jsx)(Re,{size:`xs`})]}):null,je.map(e=>{if(e.kind===`enable`)return(0,$.jsx)(cr,{environmentId:e.environment.environmentId,label:e.environment.label,showEnvironment:A.length>1,onEnabled:()=>{P(),rt(!1,!0)}},`enable:${e.environment.environmentId}`);let t=e.provider,n=I.providers.find(e=>e.provider===t),r=s===`cost`?n?.costShare??0:n?.tokenShare??0,i=n?.sessions??0,a=`${J(i)} ${i===1?`session`:`sessions`}`,o=W(t),c=o&&!Te.includes(t);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm text-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-2 shrink-0 rounded-full`,style:{backgroundColor:Xe[t].color}}),(0,$.jsx)(ur,{provider:t,className:`size-4`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:Xe[t].label}),(0,$.jsx)(`span`,{className:N(`shrink-0 whitespace-nowrap text-2xs text-muted-foreground tabular-nums`,dr(o),c&&`invisible`),children:a})]})]}),(0,$.jsx)(`span`,{className:N(`shrink-0 text-sm font-medium text-foreground tabular-nums`,dr(o)),children:c?`—`:s===`cost`?G(n?.costUsd??0):q(n?.totalTokens??0)})]}),(0,$.jsx)(`span`,{className:N(`text-xs text-muted-foreground`,dr(o),c&&`invisible`),children:s===`cost`?`${Y(r)} of cost · ${q(n?.totalTokens??0)} tokens`:`${Y(r)} of tokens · ${G(n?.costUsd??0)}`})]},t)})]}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,$.jsxs)(`h2`,{className:`text-sm font-medium text-foreground`,children:[R?`Hourly`:`Daily`,` `,s===`tokens`?`processed tokens`:`cost`]}),(0,$.jsx)(jn,{providers:Ee,loadingProviders:De,days:X,daily:I.daily,hours:xe,hourly:I.hourly,metric:s,referenceTime:L.untilTime,resolution:R?`hour`:`day`,timeZone:L.timeZone})]})]}),(0,$.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Totals`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-4 py-1 md:grid-cols-5`,children:[(0,$.jsx)(fr,{loading:U.partial,label:`Processed tokens`,value:q(I.totalTokens)}),(0,$.jsx)(fr,{loading:U.partial,label:`Cached input`,value:q(I.cachedInputTokens)}),(0,$.jsx)(fr,{loading:U.partial,label:`Uncached input`,value:q(I.uncachedInputTokens)}),(0,$.jsx)(fr,{loading:U.partial,label:`Output`,value:q(I.outputTokens)}),(0,$.jsx)(fr,{loading:U.partial,label:`Cache savings`,value:G(I.costQuality.cacheSavingsUsd)})]})]}),I.totalTokens>0?(0,$.jsx)(`section`,{className:N(`grid gap-x-12 gap-y-8 lg:grid-cols-2`,dr(U.partial)),children:s===`tokens`?(0,$.jsx)(Fn,{label:`Tokens by type`,segments:Gn(I),format:q}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Fn,{label:`Cost by type`,segments:Wn(I.categoryCost),format:G}),I.speedCost.fast+I.speedCost.ultrafast>0?(0,$.jsx)(Fn,{label:`Cost by speed`,segments:Kn(I.speedCost),format:G,aside:(0,$.jsx)(Xn,{premiumUsd:I.speedCost.premium})}):null]})}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Breakdown`}),(0,$.jsx)(ye,{"aria-label":`Usage breakdown`,variant:`segmented`,value:[h],onValueChange:e=>{let t=e[0];(t===`model`||t===`time`)&&g(t)},children:[{value:`model`,label:`Model`},{value:`time`,label:R?`Hour`:`Day`}].map(e=>(0,$.jsx)(be,{value:e.value,children:e.label},e.value))})]}),h===`model`?(0,$.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b border-border text-right text-xs text-muted-foreground`,children:[(0,$.jsx)(`th`,{className:`py-2 pr-3 text-left font-normal`,children:`#`}),(0,$.jsx)(`th`,{className:`w-full py-2 text-left font-normal`,children:`Model`}),(0,$.jsx)(`th`,{className:`py-2 pl-6 font-normal`,children:`Cost`}),(0,$.jsx)(`th`,{className:`hidden py-2 pl-6 font-normal sm:table-cell`,children:`Share`}),(0,$.jsx)(`th`,{className:`py-2 pl-6 font-normal`,children:`Tokens`})]})}),(0,$.jsx)(`tbody`,{children:we.length===0?(0,$.jsx)(`tr`,{children:(0,$.jsx)(`td`,{colSpan:5,className:`py-6 text-center text-muted-foreground`,children:`No activity in this window.`})}):we.map((e,t)=>{let n=`${e.provider}:${e.model}`,r=s===`tokens`?e.totalTokens:e.costUsd,i=zn(e,s===`tokens`?`tokens`:`cost`),a=dr(W(e.provider));return(0,$.jsxs)(`tr`,{className:`relative border-b border-border/50 text-right whitespace-nowrap text-muted-foreground tabular-nums transition-colors hover:bg-muted/50 has-focus-visible:bg-muted/50`,children:[(0,$.jsx)(`td`,{className:`py-2.5 pr-3 text-left text-xs`,children:t+1}),(0,$.jsxs)(`td`,{className:`py-2.5 text-left whitespace-normal`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b(n),className:`flex items-center gap-2 text-left text-foreground outline-none after:absolute after:inset-0`,children:[(0,$.jsx)(ur,{provider:e.provider,className:`size-3.5`}),e.model]}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:N(`mt-1.5 h-0.5 max-w-48`,a),children:(0,$.jsx)(`div`,{className:`h-full rounded-full`,style:{width:r>0&&ke>0?`max(0.5rem, ${r/ke*100}%)`:0,backgroundColor:Xe[e.provider].color}})})]}),(0,$.jsx)(`td`,{className:N(`py-2.5 pl-6 text-foreground`,a),children:pt(e)?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Unpriced`}):G(e.costUsd)}),(0,$.jsx)(`td`,{className:N(`hidden py-2.5 pl-6 sm:table-cell`,a),children:i===null?``:Y(i)}),(0,$.jsx)(`td`,{className:N(`py-2.5 pl-6`,a),children:q(e.totalTokens)})]},n)})})]}):(0,$.jsxs)(`table`,{className:`w-full table-fixed text-sm`,children:[(0,$.jsxs)(`colgroup`,{children:[(0,$.jsx)(`col`,{className:`w-2/5`}),Ee.map(e=>(0,$.jsx)(`col`,{style:{width:Je}},e)),(0,$.jsx)(`col`,{style:{width:Je}}),(0,$.jsx)(`col`,{style:{width:Je}})]}),(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b border-border text-left text-xs text-muted-foreground`,children:[(0,$.jsx)(`th`,{className:`py-2 font-normal`,children:R?`Hour`:`Day`}),Ee.map(e=>(0,$.jsx)(`th`,{className:`py-2 text-right font-normal`,children:Xe[e].label},e)),(0,$.jsx)(`th`,{className:`py-2 text-right font-normal`,children:`Total`}),(0,$.jsx)(`th`,{className:`py-2 text-right font-normal`,children:`Tokens`})]})}),(0,$.jsx)(`tbody`,{children:Ce.length===0?(0,$.jsx)(`tr`,{children:(0,$.jsx)(`td`,{colSpan:Ee.length+3,className:`py-6 text-center text-muted-foreground`,children:`No activity in this window.`})}):Ce.map(e=>(0,$.jsxs)(`tr`,{className:`border-b border-border/50 transition-colors hover:bg-muted/50`,children:[(0,$.jsx)(`td`,{className:`py-2 text-foreground`,children:`hourStart`in e?fe(e.hourStart,L.timeZone):ce(e.day)}),Ee.map(t=>(0,$.jsx)(`td`,{className:N(`py-2 text-right text-muted-foreground tabular-nums`,dr(W(t))),children:G(e.byProvider.get(t)?.costUsd??0)},t)),(0,$.jsx)(`td`,{className:N(`py-2 text-right text-foreground tabular-nums`,dr(U.partial)),children:G(e.costUsd)}),(0,$.jsx)(`td`,{className:N(`py-2 text-right text-muted-foreground tabular-nums`,dr(U.partial)),children:q(e.totalTokens)})]},`hourStart`in e?e.hourStart:e.day))})]})]})]}):(0,$.jsx)(`div`,{className:`space-y-2 py-12 text-center text-sm text-muted-foreground`,children:A.map(e=>(0,$.jsxs)(`p`,{children:[A.length>1?`${e.label}: `:null,e.error]},e.environmentId))})})})]}),Oe!==void 0&&!c?(0,$.jsx)(qn,{model:Oe,environments:A,metric:s===`tokens`?`tokens`:`cost`,chartWindow:{days:X,hours:xe,resolution:R?`hour`:`day`,timeZone:L.timeZone,referenceTime:L.untilTime},onSetPrice:()=>{b(null),v({model:Oe.model})},onClose:()=>b(null)}):null,_?(0,$.jsx)(Xt,{usage:k,initialSelectedEnvironmentIds:x,initialModel:_.model,onOpenChange:e=>{e||v(null)}}):null]})}var or=`Requires access to your Cursor login in macOS Keychain.`;function sr({environmentId:e,label:t,onEnabled:n,tooltip:r,buttonText:i=`Enable`}){let a=se(ae.updateSettings,{label:`enable Cursor account usage`}),[o,s]=(0,Z.useState)(!1),c=async()=>{s(!0);try{(await a({environmentId:e,input:{patch:{cursorKeychainUsageEnabled:!0}}}))._tag===`Success`&&n()}finally{s(!1)}},l=r?(0,$.jsx)(F,{disabled:o,"aria-busy":o,"aria-label":`Enable Cursor usage from ${t}`,onClick:()=>void c(),children:i}):(0,$.jsx)(D,{size:`sm`,variant:`outline`,disabled:o,"aria-busy":o,"aria-label":`Enable Cursor usage from ${t}`,onClick:()=>void c(),children:i});return r?(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{render:l}),(0,$.jsx)(_e,{children:or})]}):l}function cr(e){let t=(0,Q.c)(11),{environmentId:n,label:r,showEnvironment:i,onEnabled:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-2 shrink-0 rounded-full`,style:{backgroundColor:Xe.cursor.color}}),s=(0,$.jsx)(ur,{provider:`cursor`,className:`size-4`}),t[0]=o,t[1]=s):(o=t[0],s=t[1]);let c=i?` · ${r}`:``,l;t[2]===c?l=t[3]:(l=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm text-foreground`,children:[o,s,(0,$.jsxs)(`span`,{className:`truncate`,children:[`Cursor`,c]})]}),t[2]=c,t[3]=l);let u;t[4]!==n||t[5]!==r||t[6]!==a?(u=(0,$.jsx)(sr,{environmentId:n,label:r,onEnabled:a,tooltip:!0}),t[4]=n,t[5]=r,t[6]=a,t[7]=u):u=t[7];let d;return t[8]!==l||t[9]!==u?(d=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-4 text-sm`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10],d}function lr(e){let t=(0,Q.c)(10),{environments:n,onEnabled:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-medium text-foreground`,children:[(0,$.jsx)(Le,{driverKind:M.make(`cursor`),displayName:`Cursor`,indicatorBackground:`var(--background)`,className:`size-5`,iconClassName:`size-4 text-foreground/80`}),`Cursor`]}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:or}),t[1]=a):a=t[1];let o;if(t[2]!==n||t[3]!==r){let e;t[5]!==n.length||t[6]!==r?(e=e=>(0,$.jsx)(sr,{environmentId:e.environmentId,label:e.label,buttonText:n.length>1?`Enable on ${e.label}`:`Enable`,onEnabled:r,tooltip:!1},e.environmentId),t[5]=n.length,t[6]=r,t[7]=e):e=t[7],o=n.map(e),t[2]=n,t[3]=r,t[4]=o}else o=t[4];let s;return t[8]===o?s=t[9]:(s=(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[i,(0,$.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-lg border border-border/60 p-4`,children:[a,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o})]})]}),t[8]=o,t[9]=s),s}function ur(e){let t=(0,Q.c)(4),{provider:n,className:r}=e,i=Xe[n],a;return t[0]!==r||t[1]!==i.driverKind||t[2]!==i.label?(a=(0,$.jsx)(Le,{driverKind:i.driverKind,displayName:i.label,iconClassName:r}),t[0]=r,t[1]=i.driverKind,t[2]=i.label,t[3]=a):a=t[3],a}function dr(e){return N(`transition-opacity`,e&&`opacity-40 delay-150`)}function fr(e){let t=(0,Q.c)(10),{label:n,value:r,loading:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n}),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=N(`text-base font-medium text-foreground tabular-nums`,dr(i)),t[2]=i,t[3]=o);let s;t[4]!==o||t[5]!==r?(s=(0,$.jsx)(`span`,{className:o,children:r}),t[4]=o,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==s?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function pr(e){let t=(0,Q.c)(14),{environments:n,duplicateSources:r,contractMismatches:i}=e,a,o,s,c;if(t[0]!==i||t[1]!==r||t[2]!==n){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=n.filter(_r),t=new Map(i.map(gr)),l=n.flatMap(e=>{let n=t.get(e.environmentId);return n===void 0?[]:[{environment:e,mismatch:n}]});if(e.length===0&&l.length===0&&r.length===0){c=null;break bb0}a=`flex flex-col gap-1 border-t border-border px-2 py-2 text-xs text-muted-foreground`,o=e.map(hr),s=l.map(mr)}t[0]=i,t[1]=r,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else a=t[3],o=t[4],s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;t[7]===r?l=t[8]:(l=r.length>0?(0,$.jsxs)(`span`,{children:[`Counted once across environments sharing a transcript directory:`,` `,r.join(`, `)]}):null,t[7]=r,t[8]=l);let u;return t[9]!==a||t[10]!==o||t[11]!==s||t[12]!==l?(u=(0,$.jsxs)(`div`,{className:a,children:[o,s,l]}),t[9]=a,t[10]=o,t[11]=s,t[12]=l,t[13]=u):u=t[13],u}function mr(e){let{environment:t,mismatch:n}=e;return(0,$.jsx)(`span`,{children:me(t.label,n)},t.environmentId)}function hr(e){return(0,$.jsxs)(`span`,{children:[e.label,`: `,e.error]},e.label)}function gr(e){return[e.environmentId,e]}function _r(e){return e.error!==null}function vr(e){let t=(0,Q.c)(56),{environments:r,selectedEnvironments:i,selectedEnvironmentIds:a,onSelectionChange:o,showUsageStatus:s,refreshing:c,isPartial:l,duplicateSources:d,contractMismatches:p,onOpenModelPrices:m}=e,h=a===null,g=h?`All environments`:i.length===1?i[0].label:`${i.length} environments`,_;t[0]!==p||t[1]!==i?(_=i.some(br)||p.length>0,t[0]=p,t[1]=i,t[2]=_):_=t[2];let v=_,S;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(F,{}),t[3]=S):S=t[3];let C;t[4]===g?C=t[5]:(C=(0,$.jsx)(Qe,{children:g}),t[4]=g,t[5]=C);let w;t[6]!==v||t[7]!==s?(w=(0,$.jsx)(`span`,{className:`flex size-3.5 shrink-0 items-center justify-center text-muted-foreground`,children:s&&v?(0,$.jsx)(f,{className:`size-3.5 text-warning-foreground`,"aria-label":`Some environments could not report usage`}):(0,$.jsx)(I,{className:`size-3.5 opacity-0 transition-opacity group-hover/usage-environment:opacity-100 group-focus-visible/usage-environment:opacity-100 group-data-popup-open/usage-environment:opacity-100`,"aria-hidden":!0})}),t[6]=v,t[7]=s,t[8]=w):w=t[8];let T;t[9]!==C||t[10]!==w?(T=(0,$.jsxs)(x,{render:S,className:`group/usage-environment min-w-0 max-w-full`,children:[C,w]}),t[9]=C,t[10]=w,t[11]=T):T=t[11];let E;t[12]===o?E=t[13]:(E=e=>o(e?null:new Set),t[12]=o,t[13]=E);let D;t[14]!==h||t[15]!==E?(D=(0,$.jsx)(u,{checked:h,closeOnClick:!1,onCheckedChange:E,children:`All environments`}),t[14]=h,t[15]=E,t[16]=D):D=t[16];let O;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(A,{}),t[17]=O):O=t[17];let j;if(t[18]!==r||t[19]!==o||t[20]!==c||t[21]!==a||t[22]!==i||t[23]!==s){let e;t[25]!==r.length||t[26]!==o||t[27]!==c||t[28]!==a||t[29]!==i||t[30]!==s?(e=e=>{let t=a===null||a.has(e.environmentId),n=ut(e,c),l=e.error===null?e.summary!==null&&!bt(e.summary.contractVersion,6)?`Update required`:e.isConnected?n.phase===`loading`?`Scanning…`:n.phase===`stale`?`Refreshing…`:n.phase===`partway`?dt(n.providers,ir):`Ready`:`Connecting…`:`Unavailable`;return(0,$.jsx)(u,{checked:t,closeOnClick:!1,onCheckedChange:t=>{let n=new Set(i.map(yr));t?n.add(e.environmentId):n.delete(e.environmentId),o(n.size===r.length?null:n)},children:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),s?(0,$.jsx)(`span`,{className:N(`shrink-0 text-xs text-muted-foreground`,e.error!==null&&`text-destructive`),children:l}):null]})},e.environmentId)},t[25]=r.length,t[26]=o,t[27]=c,t[28]=a,t[29]=i,t[30]=s,t[31]=e):e=t[31],j=r.map(e),t[18]=r,t[19]=o,t[20]=c,t[21]=a,t[22]=i,t[23]=s,t[24]=j}else j=t[24];let M;t[32]===r.length?M=t[33]:(M=r.length===0?(0,$.jsx)(`p`,{className:`px-2 py-2 text-xs text-muted-foreground`,children:`No environments connected.`}):null,t[32]=r.length,t[33]=M);let P;t[34]!==l||t[35]!==s?(P=s&&l?(0,$.jsx)(`p`,{className:`px-2 py-2 text-xs text-muted-foreground`,children:`Totals are partial while selected environments scan.`}):null,t[34]=l,t[35]=s,t[36]=P):P=t[36];let L;t[37]!==p||t[38]!==d||t[39]!==i||t[40]!==s?(L=s?(0,$.jsx)(pr,{environments:i,duplicateSources:d,contractMismatches:p}):null,t[37]=p,t[38]=d,t[39]=i,t[40]=s,t[41]=L):L=t[41];let R;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(A,{}),t[42]=R):R=t[42];let z;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(b,{"aria-hidden":!0}),t[43]=z):z=t[43];let B;t[44]===m?B=t[45]:(B=(0,$.jsxs)(y,{onClick:m,children:[z,`Model prices`]}),t[44]=m,t[45]=B);let V;t[46]!==M||t[47]!==P||t[48]!==L||t[49]!==B||t[50]!==D||t[51]!==j?(V=(0,$.jsxs)(n,{align:`start`,children:[D,O,j,M,P,L,R,B]}),t[46]=M,t[47]=P,t[48]=L,t[49]=B,t[50]=D,t[51]=j,t[52]=V):V=t[52];let H;return t[53]!==V||t[54]!==T?(H=(0,$.jsxs)(k,{children:[T,V]}),t[53]=V,t[54]=T,t[55]=H):H=t[55],H}function yr(e){return e.environmentId}function br(e){return e.error!==null}function xr(e){let t=(0,Q.c)(23),{hiddenProviders:r,onChange:i}=e,a;t[0]===r?a=t[1]:(a=Ye.filter(e=>!r.has(e)),t[0]=r,t[1]=a);let o=a,s=o.length===Ye.length?`All providers`:o.length===0?`No providers`:o.length===1?Xe[o[0]].label:`${o.length} providers`,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(F,{}),t[2]=c):c=t[2];let l;t[3]===s?l=t[4]:(l=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:s}),t[3]=s,t[4]=l);let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(I,{className:`size-3.5 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/usage-provider:opacity-100 group-focus-visible/usage-provider:opacity-100 group-data-popup-open/usage-provider:opacity-100`,"aria-hidden":!0}),t[5]=d):d=t[5];let f;t[6]===l?f=t[7]:(f=(0,$.jsxs)(x,{render:c,className:`group/usage-provider min-w-0 max-w-full`,children:[l,d]}),t[6]=l,t[7]=f);let p=r.size===0,m;t[8]===i?m=t[9]:(m=e=>i(e?[]:Ye),t[8]=i,t[9]=m);let h;t[10]!==p||t[11]!==m?(h=(0,$.jsx)(u,{checked:p,closeOnClick:!1,onCheckedChange:m,children:`All providers`}),t[10]=p,t[11]=m,t[12]=h):h=t[12];let g;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(A,{}),t[13]=g):g=t[13];let _;t[14]!==r||t[15]!==i?(_=Ye.map(e=>(0,$.jsx)(u,{checked:!r.has(e),closeOnClick:!1,onCheckedChange:t=>i(Ye.filter(n=>n===e?!t:r.has(n))),children:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(ur,{provider:e,className:`size-3.5`}),(0,$.jsx)(`span`,{className:`truncate`,children:Xe[e].label})]})},e)),t[14]=r,t[15]=i,t[16]=_):_=t[16];let v;t[17]!==_||t[18]!==h?(v=(0,$.jsxs)(n,{align:`start`,children:[h,g,_]}),t[17]=_,t[18]=h,t[19]=v):v=t[19];let y;return t[20]!==v||t[21]!==f?(y=(0,$.jsxs)(k,{children:[f,v]}),t[20]=v,t[21]=f,t[22]=y):y=t[22],y}function Sr(){let e=(0,Q.c)(7),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(X,{className:`h-10 w-36`}),(0,$.jsx)(X,{className:`h-4 w-32`})]}),Ye.map(Cr)]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(X,{className:`h-5 w-24`}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`section`,{className:`grid gap-6 lg:grid-cols-[minmax(0,18rem)_minmax(0,1fr)]`,children:[t,(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(X,{className:`ml-16 h-56`}),(0,$.jsx)(X,{className:`ml-16 h-4`})]})]})]}),e[2]=r):r=e[2];let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Totals`}),e[3]=i):i=e[3];let a;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[i,(0,$.jsx)(wr,{labels:[`Processed tokens`,`Cached input`,`Uncached input`,`Output`,`Cache savings`]})]}),e[4]=a):a=e[4];let o;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`section`,{className:`grid gap-x-12 gap-y-8 lg:grid-cols-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,$.jsx)(X,{className:`h-5 w-28`}),(0,$.jsx)(X,{className:`h-2`}),(0,$.jsx)(X,{className:`h-4 w-72`})]})}),e[5]=o):o=e[5];let s;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsxs)($.Fragment,{children:[r,a,o,(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Breakdown`}),(0,$.jsx)(X,{shape:`card`,className:`h-7 w-28`})]}),(0,$.jsx)(X,{className:`h-44`})]})]}),e[6]=s):s=e[6],s}function Cr(e){return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-5 items-center justify-between gap-4`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{shape:`pill`,className:`size-2 shrink-0`}),(0,$.jsx)(X,{shape:`pill`,className:`size-4 shrink-0`}),(0,$.jsx)(X,{className:`h-3.5 w-20`})]}),(0,$.jsx)(X,{className:`h-3.5 w-14`})]}),(0,$.jsx)(X,{className:`h-4 w-36`})]},e)}function wr(e){let t=(0,Q.c)(4),{labels:n}=e,r;t[0]===n?r=t[1]:(r=n.map(Tr),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-4 py-1 md:grid-cols-5`,children:r}),t[2]=r,t[3]=i),i}function Tr(e){return(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,$.jsx)(X,{className:`h-6 w-16`})]},e)}var Er=ar;export{Er as component};
|
|
2
|
+
//# sourceMappingURL=usage-BIejz4Zw.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{I_ as e,h_ as t}from"./utils-
|
|
2
|
-
//# sourceMappingURL=usageAccess-
|
|
1
|
+
import{I_ as e,h_ as t}from"./utils-CyMIjIQl.js";function n(n){if(n.hasSessionError)return{canReadDiagnostics:!1,isPending:!1,error:`Could not check this connection's access to diagnostics and usage.`};if(n.session===null){let e=n.connectionPhase===`connected`||n.connectionPhase===`connecting`||n.connectionPhase===`reconnecting`;return{canReadDiagnostics:!1,isPending:e,error:e?null:`This environment is not connected.`}}let r=e(n.session,t);return{canReadDiagnostics:r,isPending:!1,error:r?null:`This connection does not have access to diagnostics and usage.`}}export{n as t};
|
|
2
|
+
//# sourceMappingURL=usageAccess-DeusmFu4.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$c as e}from"./utils-
|
|
2
|
-
//# sourceMappingURL=usageFormat-
|
|
1
|
+
import{$c as e}from"./utils-CyMIjIQl.js";var t=new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:2}),n=new Intl.NumberFormat(`en-US`);function r(e){return t.format(e)}function i(e){return n.format(Math.round(e))}function a(e){let t=Math.abs(e);return t>=0xe8d4a51000?`${o(e/0xe8d4a51000)}T`:t>=1e9?`${o(e/1e9)}B`:t>=1e6?`${o(e/1e6)}M`:t>=1e3?`${o(e/1e3)}K`:n.format(Math.round(e))}function o(e){let t=Math.abs(e),n=t>=100?0:t>=10?1:2;return e.toFixed(n).replace(/\.0+$/,``)}function s(e,t=1){let n=e*100,r=10**-t;return n>0&&n<r?`<${r.toFixed(t)}%`:`${n.toFixed(t)}%`}function c(e,t){return t.direction===`serverBehind`?`${e} runs an older server version and is excluded from totals.`:`This client is older than the server on ${e}; its usage is excluded from totals.`}function l(e){let[t,n,r]=e.split(`-`).map(e=>Number(e));return t===void 0||n===void 0||r===void 0?e:`${[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][n-1]??``} ${r}`}function u(e,t){let n=[],r=Date.parse(`${e}T00:00:00Z`),i=Date.parse(`${t}T00:00:00Z`);if(Number.isNaN(r)||Number.isNaN(i)||i<r)return n;for(let e=r;e<=i;e+=864e5)n.push(new Date(e).toISOString().slice(0,10));return n}var d=36e5,f=new Map;function p(e,t){if(t.timeZone===void 0)return new Intl.DateTimeFormat(e,t);let n=JSON.stringify([e,t]),r=f.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),f.size>=16&&f.clear(),f.set(n,r)),r}function m(e,t){let n=[],r=Date.parse(e),i=Date.parse(t);if(Number.isNaN(r)||Number.isNaN(i)||i<=r)return n;for(let e=r;e<i;e+=d)n.push(new Date(e).toISOString());return n}function h(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;let r=t===void 0?{}:{timeZone:t},i=p(`en-US`,{...r,hour:`numeric`}),a=p(`en-CA`,{...r,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,hourCycle:`h23`}),o=a.format(n);return[-36e5,d].some(e=>a.format(new Date(n.getTime()+e))===o)?p(`en-US`,{...t===void 0?{}:{timeZone:t},hour:`numeric`,timeZoneName:`short`}).format(n):i.format(n)}function g(e,t){let n=new Date(e);return Number.isNaN(n.getTime())?e:p(`en-US`,{...t===void 0?{}:{timeZone:t},month:`short`,day:`numeric`,hour:`numeric`}).format(n)}function _(e,t,n){let r=new Date(e),i=new Date(t);if(Number.isNaN(r.getTime())||Number.isNaN(i.getTime()))return g(e,n);let a=p(`en-CA`,{...n===void 0?{}:{timeZone:n},year:`numeric`,month:`2-digit`,day:`2-digit`}),o=Date.parse(`${a.format(r)}T00:00:00Z`),s=Date.parse(`${a.format(i)}T00:00:00Z`),c=Math.round((s-o)/(24*d)),l=h(e,n);return c===0?`${l} today`:c===1?`${l} yesterday`:g(e,n)}function v(t,n=new Date,r=`day`){let i=Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`,a;try{a=new Intl.DateTimeFormat(`en-CA`,{timeZone:i,year:`numeric`,month:`2-digit`,day:`2-digit`})}catch{i=`UTC`,a=new Intl.DateTimeFormat(`en-CA`,{timeZone:`UTC`,year:`numeric`,month:`2-digit`,day:`2-digit`})}let o=a.format(n);if(r===`hour`){let t=Math.floor(n.getTime()/6e4)*6e4,o=t-24*d,s=new Date(o),c=new Date(t);return{sinceDay:e.make(a.format(s)),untilDay:e.make(a.format(c)),timeZone:i,resolution:r,sinceTime:s.toISOString(),untilTime:c.toISOString()}}let[s=0,c=1,l=1]=o.split(`-`).map(e=>Number.parseInt(e,10)),u=new Date(Date.UTC(s,c-1,l-(t-1)));return{sinceDay:e.make(u.toISOString().slice(0,10)),untilDay:e.make(o),timeZone:i,resolution:r}}export{l as a,_ as c,r as d,v as f,g as i,a as l,m as n,h as o,i as r,s,u as t,c as u};
|
|
2
|
+
//# sourceMappingURL=usageFormat-bv0-SbBE.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e}from"./keybindings-
|
|
2
|
-
//# sourceMappingURL=usageShortcuts-
|
|
1
|
+
import{_ as e}from"./keybindings-D2lV30Mz.js";var t=[{value:`cost`,label:`Cost`,command:`usage.cost`},{value:`tokens`,label:`Tokens`,command:`usage.tokens`},{value:`limits`,label:`Limits`,command:`usage.limits`}],n=[{days:1,label:`Past 24h`,command:`usage.period.day`},{days:7,label:`7 days`,command:`usage.period.week`},{days:30,label:`30 days`,command:`usage.period.month`},{days:90,label:`90 days`,command:`usage.period.quarter`}];function r(t,n){let r=t.target;return r instanceof HTMLElement&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.tagName===`SELECT`||r.isContentEditable||r.closest(`[role="dialog"], [aria-modal="true"], [data-slot$="popup"]`))?null:e(t,n,{context:{usagePageOpen:!0}})}export{n,r,t};
|
|
2
|
+
//# sourceMappingURL=usageShortcuts-Dx5czWNh.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{BE as n,es as r}from"./utils-
|
|
2
|
-
//# sourceMappingURL=use-atom-command-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{BE as n,es as r}from"./utils-CyMIjIQl.js";import{B as i}from"./runtime-CQUKxsYj.js";var a=n(),o=e(t(),1);function s(e,t){let n=(0,a.c)(6),s=(0,o.useContext)(r),c=typeof t==`string`?t:t?.label??e.label,l=typeof t==`string`?!0:t?.reportFailure??!0,u=typeof t==`string`?!0:t?.reportDefect??!0,d;return n[0]!==e||n[1]!==c||n[2]!==s||n[3]!==u||n[4]!==l?(d=t=>i(s,e,t,{label:c,reportFailure:l,reportDefect:u}),n[0]=e,n[1]=c,n[2]=s,n[3]=u,n[4]=l,n[5]=d):d=n[5],d}export{s as t};
|
|
2
|
+
//# sourceMappingURL=use-atom-command-BeLksgvP.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{ka as n,za as r}from"./utils-
|
|
2
|
-
//# sourceMappingURL=useAriaLabelledBy-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{ka as n,za as r}from"./utils-CyMIjIQl.js";var i=e(t());function a(e,t,a,s=!0,c){let[l,u]=i.useState(),d=n(c?`${c}-label`:void 0),f=e??t??l;return r(()=>{let n=e||t||!s?void 0:o(a.current,d);l!==n&&u(n)}),f}function o(e,t){let n=s(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function s(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}export{a as t};
|
|
2
|
+
//# sourceMappingURL=useAriaLabelledBy-CvM07jd7.js.map
|
package/dist/client/assets/{useHandleNewThread-CsUYJUoP.js → useHandleNewThread-uD-vMkEQ.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{$o as n,BE as r,C as i,D as a,Xs as o,Yo as s,Ys as c,Zs as l,al as u,c as d,g as f,gh as p,i as m,s as h}from"./utils-B0w8dSf5.js";import{L as g,R as _}from"./runtime-BtL_3nGT.js";import{d as ee,f as te,k as v,m as ne,p as y,w as re}from"./entities-f_LpWDGP.js";import{$t as b,cn as x,tt as S}from"./runtime-CxXKASQ8.js";import{a as C,t as ie}from"./useParams-DNmNCHjx.js";import{d as w}from"./toast-C2NI-Hlh.js";import{s as T}from"./useSettings-BeOQNM41.js";import{n as E}from"./server-DK7wLDqS.js";import"./queries-CnKYA1jH.js";import{p as D}from"./session-logic-lPOzc1cs.js";import{a as O,i as k,n as ae,o as A}from"./threadSort-Bd2rijEy.js";import{c as j,r as M}from"./projectFilesQueryState-C9qxBsmE.js";import{r as N,t as oe}from"./uiStateStore-z548e4qC.js";import{d as P,f as F,i as se,r as ce,s as le,t as I}from"./p4ProjectFile-CuaSnYfs.js";var L=e(t(),1),R=r(),z=`[data-thread-item], [data-thread-selection-safe]`,B=3,V=160;function H(e){let t=(0,R.c)(6),[n,r]=L.useState(null),[i,a]=L.useState(e),o,s;t[0]!==e||t[1]!==n?(o=()=>{if(e){a(!0);return}if(n===null)return;if(typeof IntersectionObserver>`u`){a(!0);return}let t=n.closest(`[data-slot="scroll-area-viewport"]`),r=new IntersectionObserver(e=>{let[t]=e;return a(t?.isIntersecting===!0)},{root:t,rootMargin:`${V}px 0px`});return r.observe(n),()=>r.disconnect()},s=[e,n],t[0]=e,t[1]=n,t[2]=o,t[3]=s):(o=t[2],s=t[3]),L.useEffect(o,s);let c=e||i,l;return t[4]===c?l=t[5]:(l={leaseLiveStatus:c,rowRef:r},t[4]=c,t[5]=l),l}function U(e,t){let n=L.useRef(null);return e!==null&&t!==null&&(n.current={key:e,value:t}),t===null?e!==null&&n.current?.key===e?n.current.value:null:t}function W(e,t,n,r){let i=e.indexOf(t),a=e.indexOf(n);return i===-1||a===-1?[]:e.slice(Math.min(i,a),Math.max(i,a)+1).filter(r)}async function G(e){let t=new Set,n=null;for(let r of e.entries){let i=await e.delete(r,t);if(i!==null){if(i._tag===`Failure`){if(_(i))break;n??=i;continue}t.add(r.threadKey)}}return{deletedThreadKeys:t,firstFailure:n}}async function K(e){let t=[],n=[];for(let r of e.entries){let i=!1,a=await e.archive(r,()=>{i=!0});if((i||a._tag===`Success`)&&t.push(r.threadKey),a._tag===`Success`)continue;let o=a;if(i){n.push(o);continue}return{archivedThreadKeys:t,mutationFailure:o,followupFailures:n}}return{archivedThreadKeys:t,mutationFailure:null,followupFailures:n}}function q(e){return[{id:`mark-unread`,label:`Mark unread (${e.count})`},{id:`archive`,label:`Archive (${e.count})`,disabled:e.hasRunningThread},{id:`delete`,label:`Delete (${e.count})`,destructive:!0}]}function J(e){return e.lineage.relationshipToParent===`subagent`}function ue(e,t){let n=S(e);return e.filter(e=>e.archivedAt===null&&!J(e)&&n(e)&&(t===null||t.has(`${e.environmentId}:${e.projectId}`)))}var de={"Pending Approval":5,"Awaiting Input":4,Working:3,Connecting:3,Waiting:2.5,"Plan Ready":2,Completed:1};function fe(e){let t=e.setTimeoutFn??globalThis.setTimeout,n=e.clearTimeoutFn??globalThis.clearTimeout,r=!1,i=null,a=()=>{i!==null&&(n(i),i=null)};return{sync:n=>{if(!n){a(),r&&(r=!1,e.onVisibilityChange(!1));return}r||i!==null||(i=t(()=>{i=null,r=!0,e.onVisibilityChange(!0)},e.delayMs))},dispose:()=>{a()}}}function pe(){let e=(0,R.c)(5),[t,n]=L.useState(!1),r=L.useRef(null),i,a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{let e=fe({delayMs:200,onVisibilityChange:e=>{n(e)},setTimeoutFn:window.setTimeout.bind(window),clearTimeoutFn:window.clearTimeout.bind(window)});return r.current=e,()=>{e.dispose(),r.current=null}},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),L.useEffect(i,a);let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{r.current?.sync(e)},e[2]=o):o=e[2];let s=o,c;return e[3]===t?c=e[4]:(c={showThreadJumpHints:t,updateThreadJumpHintsVisibility:s},e[3]=t,e[4]=c),c}function me(e,t){return e===void 0?t:e??void 0}function he(e){if(!e.latestRun?.completedAt)return!1;let t=Date.parse(e.latestRun.completedAt);if(Number.isNaN(t)||!e.lastVisitedAt)return!1;let n=Date.parse(e.lastVisitedAt);return Number.isNaN(n)?!0:t>n}function ge(e){return e===null||!e.closest(z)}function _e(e){return e>1}function ve(e,t){return e===null||!(`closest`in e)||typeof e.closest!=`function`?null:e.closest(t)}function ye(e){return typeof e!=`object`||!e?!1:ve(e,`a[href]`)!==null||ve(`parentElement`in e&&e.parentElement!==null&&typeof e.parentElement==`object`?e.parentElement:null,`a[href]`)!==null}function be(e){let{getId:t,getPreferenceIds:n,items:r,preferredIds:i}=e;if(i.length===0)return[...r];let a=new Map;for(let[e,i]of r.entries()){let r=n?.(i)??[t(i)];for(let t of new Set(r)){let n=a.get(t);n?n.push(e):a.set(t,[e])}}let o=new Set,s=i.flatMap(e=>{let t=a.get(e)?.find(e=>!o.has(e));return t===void 0?[]:(o.add(t),[r[t]])}),c=r.filter((e,t)=>!o.has(t));return[...s,...c]}function xe(e,t=B){return e.slice(0,Math.max(0,t))}function Se(e){let{currentThreadId:t,direction:n,threadIds:r}=e;if(r.length===0)return null;if(t===null)return n===`previous`?r.at(-1)??null:r[0]??null;let i=r.indexOf(t);return i===-1?null:n===`previous`?i>0?r[i-1]??null:null:i<r.length-1?r[i+1]??null:null}function Ce(e){return e.button===2||e.isMac&&e.button===0&&e.ctrlKey}function we(e){return e.hasPendingApprovals||e.pendingSubagentRequest===`approval`?`approval`:e.hasPendingUserInput||e.pendingSubagentRequest===`user_input`?`input`:e.runtime!==null&&[`preparing`,`queued`,`starting`,`running`,`waiting`].includes(e.runtime.status)?`working`:e.runtime?.status===`idle`?`waiting`:e.runtime?.status===`failed`?e.runtime.lastErrorClass===`usage_limit`?`limited`:`failed`:`ready`}function Te(e,t){let n=O(e,t),r=n.filter(e=>e.pinnedAt!=null);return r.length===0?n:[...k(r),...n.filter(e=>e.pinnedAt==null)]}function Ee(e,t){let n=d(t);if(n.length===0)return!1;let r=d(x(e).join(` `));return n.split(` `).every(e=>r.includes(e))}function De(e){let{thread:t}=e;return t.hasPendingApprovals||t.pendingSubagentRequest===`approval`?{label:`Pending Approval`,colorClass:`text-amber-600 dark:text-amber-300/90`,dotClass:`bg-amber-500 dark:bg-amber-300/90`,pulse:!1}:t.hasPendingUserInput||t.pendingSubagentRequest===`user_input`?{label:`Awaiting Input`,colorClass:`text-indigo-600 dark:text-indigo-300/90`,dotClass:`bg-indigo-500 dark:bg-indigo-300/90`,pulse:!1}:t.runtime?.status===`running`||t.runtime?.status===`waiting`?{label:`Working`,colorClass:`text-sky-600 dark:text-sky-300/80`,dotClass:`bg-sky-500 dark:bg-sky-300/80`,pulse:!0}:t.runtime?.status===`preparing`||t.runtime?.status===`starting`||t.runtime?.status===`queued`?{label:`Connecting`,colorClass:`text-sky-600 dark:text-sky-300/80`,dotClass:`bg-sky-500 dark:bg-sky-300/80`,pulse:!0}:b(t.pendingBackgroundTasks??[])?{label:`Waiting`,colorClass:`text-sidebar-muted-foreground`,dotClass:`bg-sidebar-muted-foreground`,pulse:!1}:!t.hasPendingUserInput&&t.interactionMode===`plan`&&D(t.latestRun,t.runtime)&&t.hasActionableProposedPlan?{label:`Plan Ready`,colorClass:`text-violet-600 dark:text-violet-300/90`,dotClass:`bg-violet-500 dark:bg-violet-300/90`,pulse:!1}:he(t)?{label:`Completed`,colorClass:`text-emerald-600 dark:text-emerald-300/90`,dotClass:`bg-emerald-500 dark:bg-emerald-300/90`,pulse:!1}:null}function Oe(e){let t=null;for(let n of e)n!==null&&(t===null||de[n.label]>de[t.label])&&(t=n);return t}function ke(e,t){return t.projectExpanded?t.isThreadListExpanded||e.length<=t.previewCount?e:e.slice(0,t.previewCount):[]}function Ae(e){let{deletedThreadId:t,deletedThreadIds:n,sortOrder:r,threads:i}=e,a=i.find(e=>e.id===t);return a?O(i.filter(e=>e.projectId===a.projectId&&e.id!==t&&!n?.has(e.id)),r)[0]?.id??null:null}function je(e,t,n){return t.length>0?t.reduce((e,t)=>Math.max(e,ae(t,n)),-1/0):n===`created_at`?A(e.createdAt)??-1/0:A(e.updatedAt??e.createdAt)??-1/0}function Y(e,t,n,r){return t===`manual`?[...e]:e.map(e=>({project:e,timestamp:je(e,n(e),t)})).sort((e,t)=>(t.timestamp===e.timestamp?0:t.timestamp>e.timestamp?1:-1)||r(e.project,t.project)).map(({project:e})=>e)}function Me(e,t,n){let r=new Map;for(let e of t){let t=r.get(e.projectId)??[];t.push(e),r.set(e.projectId,t)}return Y(e,n,e=>r.get(e.id)??[],(e,t)=>e.title.localeCompare(t.title)||e.id.localeCompare(t.id))}function Ne(e,t,n){let r=new Map(e.flatMap(e=>e.memberProjectRefs.map(t=>[`${t.environmentId}\0${t.projectId}`,e.projectKey]))),i=new Map;for(let e of t){if(e.archivedAt!==null)continue;let t=r.get(`${e.environmentId}\0${e.projectId}`);if(!t)continue;let n=i.get(t);n?n.push(e):i.set(t,[e])}return Y(e,n,e=>i.get(e.projectKey)??[],(e,t)=>e.title.localeCompare(t.title)||e.projectKey.localeCompare(t.projectKey))}function Pe(e,t,n){return Ne(e,ue(t,null),n)}function Fe(e,t,n){let r=(e,t)=>`${e}\u0000${t}`,i=new Map;for(let e of t){if(e.archivedAt!==null)continue;let t=r(e.environmentId,e.projectId),n=i.get(t)??[];n.push(e),i.set(t,n)}return Y(e,n,e=>i.get(r(e.environmentId,e.id))??[],(e,t)=>e.title.localeCompare(t.title)||e.environmentId.localeCompare(t.environmentId)||e.id.localeCompare(t.id))}function X(e){return e.envMode!==`local`&&e.newWorktreesStartFromOrigin}function Ie(e){return e.projectDefaultSelection??(e.carrySourceDraftId===e.destinationDraftId?null:e.carrySelection)}function Z(e){let t=e?.activeProvider;return e?.modelSelectionExplicit===!0&&t!=null&&e.modelSelectionByProvider[t]!==void 0}function Le(e){return e.activeThread?c(e.activeThread.environmentId,e.activeThread.projectId):e.activeDraftThread?c(e.activeDraftThread.environmentId,e.activeDraftThread.projectId):e.defaultProjectRef}async function Re(e){let t=Le(e);return t?(await e.handleNewThread(t),!0):!1}async function ze(e,t){let n=await g(s,M(e,t,u),{reportDefect:!1,reportFailure:!1}),r=j(e,t,u,j(e,t,n._tag===`Success`?n.value.relativePath:u,n._tag===`Success`?n.value:null));return r===null||r.truncated?null:I(r.contents)}function Q(e){return{...e?.branch===void 0?{}:{branch:e.branch},...e?.worktreePath===void 0?{}:{worktreePath:e.worktreePath},...e?.envMode===void 0?{}:{envMode:e.envMode},...e?.startFromOrigin===void 0?{}:{startFromOrigin:e.startFromOrigin}}}function $(){let e=(0,R.c)(7),t=n(E),r=T(F),s=C(),c;e[0]===s.state.matches?c=e[1]:(c=()=>{let e=s.state.matches[s.state.matches.length-1]?.params??{};return w(e)},e[0]=s.state.matches,e[1]=c);let u=c,d;return e[2]!==t||e[3]!==u||e[4]!==r||e[5]!==s?(d=(e,n)=>{let c=te(),d=t.get(e.environmentId)?.settings??p,{getComposerDraft:g,getDraftSessionByLogicalProjectKey:_,getDraftSession:v,getDraftThread:re,applyStickyState:b,setDraftThreadContext:x,setLogicalProjectDraftThreadId:S,setModelSelection:C}=a.getState(),ie=s.state.location.href,w=()=>s.state.location.href!==ie,T=u(),E=T?.kind===`server`?y(T.threadRef):null,D=T?.kind===`draft`?v(T.draftId):null,O=T?g(T.kind===`server`?T.threadRef:T.draftId):null,k=O?.activeProvider??null,ae=(k?O?.modelSelectionByProvider[k]??null:null)??E?.modelSelection??null,A=O?.interactionMode??E?.interactionMode??D?.interactionMode??null,j=c.find(t=>t.id===e.projectId&&t.environmentId===e.environmentId),M=()=>w()||j!==void 0&&ee(e)===null,N=se(d,j?.id??null,j),oe=N.settings.defaultModelSelection,P=N.settings.defaultRuntimeMode,F=e=>Ie({projectDefaultSelection:oe??null,carrySelection:ae,carrySourceDraftId:T?.kind===`draft`?T.draftId:null,destinationDraftId:e}),I=async()=>{let n=j!==void 0&&N.settings.defaultThreadEnvMode===null?await ze(j.environmentId,j.workspaceRoot):null;return ce({projectSettings:se(d,j?.id??null,j,n),workspaceRoot:j?.workspaceRoot??null,newProjectsRoot:t.get(e.environmentId)?.newProjectsRoot,projectHasThreads:ne().some(t=>t.environmentId===e.environmentId&&t.projectId===e.projectId)})},L=j?le(j,r):l(e),R=n?.branch!==void 0,z=n?.worktreePath!==void 0,B=n?.envMode!==void 0,V=n?.startFromOrigin!==void 0,H=_(L),U=H?o(H.environmentId,H.threadId):null,W=H!==null&&H.promotedTo==null&&U!==null&&y(U)===null?H:null;U&&W===null&&i(U);let G=W&&!f(g(W.draftId))?W:null,K=T?T.kind===`server`?re(T.threadRef):v(T.draftId):null;if(G)return(async()=>{let t=T?.kind===`draft`&&T.draftId===G.draftId,r=R||z||B||V,i=null;if(r)i=Q(n);else if(!t){let e=await I();if(M())return null;let t=u(),n=t?.kind===`draft`&&t.draftId===G.draftId,r=U!==null&&y(U)!==null,a=_(L)?.draftId!==G.draftId,o=f(g(G.draftId));if(n||r||a||o)return null;i={branch:null,worktreePath:null,envMode:e,startFromOrigin:X({envMode:e,newWorktreesStartFromOrigin:N.settings.newWorktreesStartFromOrigin})}}if(i&&x(G.draftId,{...i,...t?{}:{runtimeMode:P},...A?{interactionMode:A}:{}}),!Z(g(G.draftId))){b(G.draftId);let e=F(G.draftId);e&&C(G.draftId,e,{replaceOptions:!0})}S(L,e,G.draftId,{threadId:G.threadId,...i,...t?{}:{runtimeMode:P},...A?{interactionMode:A}:{}});let a={draftId:G.draftId,threadId:G.threadId},o=u();return o?.kind===`draft`&&o.draftId===G.draftId||await s.navigate({to:`/draft/$draftId`,params:{draftId:G.draftId},replace:n?.replace??!1}),a})();if(K&&T?.kind===`draft`&&K.logicalProjectKey===L&&K.promotedTo==null&&!f(g(T.draftId)))return(R||z||B||V)&&x(T.draftId,Q(n)),S(L,e,T.draftId,{threadId:K.threadId,createdAt:K.createdAt,runtimeMode:K.runtimeMode,interactionMode:K.interactionMode,...Q(n)}),Promise.resolve({draftId:T.draftId,threadId:K.threadId});let q=m(),J=h(),ue=new Date().toISOString();return(async()=>{let t=n?.envMode??await I();if(M())return null;let r=_(L);if(r&&r.draftId!==H?.draftId&&y(o(r.environmentId,r.threadId))===null)return S(L,e,r.draftId,{threadId:r.threadId,createdAt:r.createdAt,runtimeMode:r.runtimeMode,interactionMode:r.interactionMode,...Q(n)}),await s.navigate({to:`/draft/$draftId`,params:{draftId:r.draftId},replace:n?.replace??!1}),{draftId:r.draftId,threadId:r.threadId};S(L,e,q,{threadId:J,createdAt:ue,branch:n?.branch??null,worktreePath:n?.worktreePath??null,envMode:t,startFromOrigin:n?.startFromOrigin??X({envMode:t,newWorktreesStartFromOrigin:N.settings.newWorktreesStartFromOrigin}),runtimeMode:P,...A?{interactionMode:A}:{}}),b(q);let i=F(q);return i&&C(q,i,{replaceOptions:!0}),await s.navigate({to:`/draft/$draftId`,params:{draftId:q},replace:n?.replace??!1}),{draftId:q,threadId:J}})()},e[2]=t,e[3]=u,e[4]=r,e[5]=s,e[6]=d):d=e[6],d}function Be(){let e=(0,R.c)(16),t=N(We),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={strict:!1,select:Ue},e[0]=n):n=e[0];let r=ie(n),i=r?.kind===`server`?r.threadRef:null,o=r?.kind===`draft`?r.draftId:null,s=v(i),l=a(He),u;e[1]!==l||e[2]!==r?(u=()=>r?r.kind===`server`?l(r.threadRef):a.getState().getDraftSession(r.draftId):null,e[1]=l,e[2]=r,e[3]=u):u=e[3];let d=a(u),f=re(),p;e[4]!==t||e[5]!==f?(p=be({items:f,preferredIds:t,getId:P,getPreferenceIds:Ve}),e[4]=t,e[5]=f,e[6]=p):p=e[6];let m=p,h=$(),g;e[7]===m[0]?g=e[8]:(g=m[0]?c(m[0].environmentId,m[0].id):null,e[7]=m[0],e[8]=g);let _;return e[9]!==d||e[10]!==s||e[11]!==h||e[12]!==o||e[13]!==i||e[14]!==g?(_={activeDraftThread:d,activeThread:s,defaultProjectRef:g,handleNewThread:h,routeDraftId:o,routeThreadRef:i},e[9]=d,e[10]=s,e[11]=h,e[12]=o,e[13]=i,e[14]=g,e[15]=_):_=e[15],_}function Ve(e){return[P(e),oe(e.workspaceRoot)]}function He(e){return e.getDraftThread}function Ue(e){return w(e)}function We(e){return e.projectOrder}export{U as A,De as C,Fe as D,Me as E,pe as M,Pe as O,me as S,Ne as T,Se as _,Le as a,W as b,q as c,xe as d,Ce as f,Ee as g,be as h,X as i,H as j,Te as k,G as l,_e as m,$ as n,Re as o,ye as p,Z as r,K as s,Be as t,Ae as u,Oe as v,ge as w,we as x,ke as y};
|
|
2
|
-
//# sourceMappingURL=useHandleNewThread-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{$o as n,BE as r,C as i,D as a,Xs as o,Yo as s,Ys as c,Zs as l,al as u,c as d,g as f,gh as p,i as m,s as h}from"./utils-CyMIjIQl.js";import{L as g,R as _}from"./runtime-CQUKxsYj.js";import{d as ee,f as te,k as v,m as ne,p as y,w as re}from"./entities-mGmdXIiN.js";import{$t as b,cn as x,tt as S}from"./runtime-yiVU6Sqe.js";import{a as C,t as ie}from"./useParams-BmGuCYQD.js";import{d as w}from"./toast-1vb9aDAy.js";import{s as T}from"./useSettings-BxAEkFYM.js";import{n as E}from"./server-BLcQ113X.js";import"./queries-BcESSYn_.js";import{p as D}from"./session-logic-BoAbcuez.js";import{a as O,i as k,n as ae,o as A}from"./threadSort-Bd2rijEy.js";import{c as j,r as M}from"./projectFilesQueryState-BO3GmMMv.js";import{r as N,t as oe}from"./uiStateStore-C4lPArJV.js";import{d as P,f as F,i as se,r as ce,s as le,t as I}from"./p4ProjectFile-Brm-UVx_.js";var L=e(t(),1),R=r(),z=`[data-thread-item], [data-thread-selection-safe]`,B=3,V=160;function H(e){let t=(0,R.c)(6),[n,r]=L.useState(null),[i,a]=L.useState(e),o,s;t[0]!==e||t[1]!==n?(o=()=>{if(e){a(!0);return}if(n===null)return;if(typeof IntersectionObserver>`u`){a(!0);return}let t=n.closest(`[data-slot="scroll-area-viewport"]`),r=new IntersectionObserver(e=>{let[t]=e;return a(t?.isIntersecting===!0)},{root:t,rootMargin:`${V}px 0px`});return r.observe(n),()=>r.disconnect()},s=[e,n],t[0]=e,t[1]=n,t[2]=o,t[3]=s):(o=t[2],s=t[3]),L.useEffect(o,s);let c=e||i,l;return t[4]===c?l=t[5]:(l={leaseLiveStatus:c,rowRef:r},t[4]=c,t[5]=l),l}function U(e,t){let n=L.useRef(null);return e!==null&&t!==null&&(n.current={key:e,value:t}),t===null?e!==null&&n.current?.key===e?n.current.value:null:t}function W(e,t,n,r){let i=e.indexOf(t),a=e.indexOf(n);return i===-1||a===-1?[]:e.slice(Math.min(i,a),Math.max(i,a)+1).filter(r)}async function G(e){let t=new Set,n=null;for(let r of e.entries){let i=await e.delete(r,t);if(i!==null){if(i._tag===`Failure`){if(_(i))break;n??=i;continue}t.add(r.threadKey)}}return{deletedThreadKeys:t,firstFailure:n}}async function K(e){let t=[],n=[];for(let r of e.entries){let i=!1,a=await e.archive(r,()=>{i=!0});if((i||a._tag===`Success`)&&t.push(r.threadKey),a._tag===`Success`)continue;let o=a;if(i){n.push(o);continue}return{archivedThreadKeys:t,mutationFailure:o,followupFailures:n}}return{archivedThreadKeys:t,mutationFailure:null,followupFailures:n}}function q(e){return[{id:`mark-unread`,label:`Mark unread (${e.count})`},{id:`archive`,label:`Archive (${e.count})`,disabled:e.hasRunningThread},{id:`delete`,label:`Delete (${e.count})`,destructive:!0}]}function J(e){return e.lineage.relationshipToParent===`subagent`}function ue(e,t){let n=S(e);return e.filter(e=>e.archivedAt===null&&!J(e)&&n(e)&&(t===null||t.has(`${e.environmentId}:${e.projectId}`)))}var de={"Pending Approval":5,"Awaiting Input":4,Working:3,Connecting:3,Waiting:2.5,"Plan Ready":2,Completed:1};function fe(e){let t=e.setTimeoutFn??globalThis.setTimeout,n=e.clearTimeoutFn??globalThis.clearTimeout,r=!1,i=null,a=()=>{i!==null&&(n(i),i=null)};return{sync:n=>{if(!n){a(),r&&(r=!1,e.onVisibilityChange(!1));return}r||i!==null||(i=t(()=>{i=null,r=!0,e.onVisibilityChange(!0)},e.delayMs))},dispose:()=>{a()}}}function pe(){let e=(0,R.c)(5),[t,n]=L.useState(!1),r=L.useRef(null),i,a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{let e=fe({delayMs:200,onVisibilityChange:e=>{n(e)},setTimeoutFn:window.setTimeout.bind(window),clearTimeoutFn:window.clearTimeout.bind(window)});return r.current=e,()=>{e.dispose(),r.current=null}},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),L.useEffect(i,a);let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{r.current?.sync(e)},e[2]=o):o=e[2];let s=o,c;return e[3]===t?c=e[4]:(c={showThreadJumpHints:t,updateThreadJumpHintsVisibility:s},e[3]=t,e[4]=c),c}function me(e,t){return e===void 0?t:e??void 0}function he(e){if(!e.latestRun?.completedAt)return!1;let t=Date.parse(e.latestRun.completedAt);if(Number.isNaN(t)||!e.lastVisitedAt)return!1;let n=Date.parse(e.lastVisitedAt);return Number.isNaN(n)?!0:t>n}function ge(e){return e===null||!e.closest(z)}function _e(e){return e>1}function ve(e,t){return e===null||!(`closest`in e)||typeof e.closest!=`function`?null:e.closest(t)}function ye(e){return typeof e!=`object`||!e?!1:ve(e,`a[href]`)!==null||ve(`parentElement`in e&&e.parentElement!==null&&typeof e.parentElement==`object`?e.parentElement:null,`a[href]`)!==null}function be(e){let{getId:t,getPreferenceIds:n,items:r,preferredIds:i}=e;if(i.length===0)return[...r];let a=new Map;for(let[e,i]of r.entries()){let r=n?.(i)??[t(i)];for(let t of new Set(r)){let n=a.get(t);n?n.push(e):a.set(t,[e])}}let o=new Set,s=i.flatMap(e=>{let t=a.get(e)?.find(e=>!o.has(e));return t===void 0?[]:(o.add(t),[r[t]])}),c=r.filter((e,t)=>!o.has(t));return[...s,...c]}function xe(e,t=B){return e.slice(0,Math.max(0,t))}function Se(e){let{currentThreadId:t,direction:n,threadIds:r}=e;if(r.length===0)return null;if(t===null)return n===`previous`?r.at(-1)??null:r[0]??null;let i=r.indexOf(t);return i===-1?null:n===`previous`?i>0?r[i-1]??null:null:i<r.length-1?r[i+1]??null:null}function Ce(e){return e.button===2||e.isMac&&e.button===0&&e.ctrlKey}function we(e){return e.hasPendingApprovals||e.pendingSubagentRequest===`approval`?`approval`:e.hasPendingUserInput||e.pendingSubagentRequest===`user_input`?`input`:e.runtime!==null&&[`preparing`,`queued`,`starting`,`running`,`waiting`].includes(e.runtime.status)?`working`:e.runtime?.status===`idle`?`waiting`:e.runtime?.status===`failed`?e.runtime.lastErrorClass===`usage_limit`?`limited`:`failed`:`ready`}function Te(e,t){let n=O(e,t),r=n.filter(e=>e.pinnedAt!=null);return r.length===0?n:[...k(r),...n.filter(e=>e.pinnedAt==null)]}function Ee(e,t){let n=d(t);if(n.length===0)return!1;let r=d(x(e).join(` `));return n.split(` `).every(e=>r.includes(e))}function De(e){let{thread:t}=e;return t.hasPendingApprovals||t.pendingSubagentRequest===`approval`?{label:`Pending Approval`,colorClass:`text-amber-600 dark:text-amber-300/90`,dotClass:`bg-amber-500 dark:bg-amber-300/90`,pulse:!1}:t.hasPendingUserInput||t.pendingSubagentRequest===`user_input`?{label:`Awaiting Input`,colorClass:`text-indigo-600 dark:text-indigo-300/90`,dotClass:`bg-indigo-500 dark:bg-indigo-300/90`,pulse:!1}:t.runtime?.status===`running`||t.runtime?.status===`waiting`?{label:`Working`,colorClass:`text-sky-600 dark:text-sky-300/80`,dotClass:`bg-sky-500 dark:bg-sky-300/80`,pulse:!0}:t.runtime?.status===`preparing`||t.runtime?.status===`starting`||t.runtime?.status===`queued`?{label:`Connecting`,colorClass:`text-sky-600 dark:text-sky-300/80`,dotClass:`bg-sky-500 dark:bg-sky-300/80`,pulse:!0}:b(t.pendingBackgroundTasks??[])?{label:`Waiting`,colorClass:`text-sidebar-muted-foreground`,dotClass:`bg-sidebar-muted-foreground`,pulse:!1}:!t.hasPendingUserInput&&t.interactionMode===`plan`&&D(t.latestRun,t.runtime)&&t.hasActionableProposedPlan?{label:`Plan Ready`,colorClass:`text-violet-600 dark:text-violet-300/90`,dotClass:`bg-violet-500 dark:bg-violet-300/90`,pulse:!1}:he(t)?{label:`Completed`,colorClass:`text-emerald-600 dark:text-emerald-300/90`,dotClass:`bg-emerald-500 dark:bg-emerald-300/90`,pulse:!1}:null}function Oe(e){let t=null;for(let n of e)n!==null&&(t===null||de[n.label]>de[t.label])&&(t=n);return t}function ke(e,t){return t.projectExpanded?t.isThreadListExpanded||e.length<=t.previewCount?e:e.slice(0,t.previewCount):[]}function Ae(e){let{deletedThreadId:t,deletedThreadIds:n,sortOrder:r,threads:i}=e,a=i.find(e=>e.id===t);return a?O(i.filter(e=>e.projectId===a.projectId&&e.id!==t&&!n?.has(e.id)),r)[0]?.id??null:null}function je(e,t,n){return t.length>0?t.reduce((e,t)=>Math.max(e,ae(t,n)),-1/0):n===`created_at`?A(e.createdAt)??-1/0:A(e.updatedAt??e.createdAt)??-1/0}function Y(e,t,n,r){return t===`manual`?[...e]:e.map(e=>({project:e,timestamp:je(e,n(e),t)})).sort((e,t)=>(t.timestamp===e.timestamp?0:t.timestamp>e.timestamp?1:-1)||r(e.project,t.project)).map(({project:e})=>e)}function Me(e,t,n){let r=new Map;for(let e of t){let t=r.get(e.projectId)??[];t.push(e),r.set(e.projectId,t)}return Y(e,n,e=>r.get(e.id)??[],(e,t)=>e.title.localeCompare(t.title)||e.id.localeCompare(t.id))}function Ne(e,t,n){let r=new Map(e.flatMap(e=>e.memberProjectRefs.map(t=>[`${t.environmentId}\0${t.projectId}`,e.projectKey]))),i=new Map;for(let e of t){if(e.archivedAt!==null)continue;let t=r.get(`${e.environmentId}\0${e.projectId}`);if(!t)continue;let n=i.get(t);n?n.push(e):i.set(t,[e])}return Y(e,n,e=>i.get(e.projectKey)??[],(e,t)=>e.title.localeCompare(t.title)||e.projectKey.localeCompare(t.projectKey))}function Pe(e,t,n){return Ne(e,ue(t,null),n)}function Fe(e,t,n){let r=(e,t)=>`${e}\u0000${t}`,i=new Map;for(let e of t){if(e.archivedAt!==null)continue;let t=r(e.environmentId,e.projectId),n=i.get(t)??[];n.push(e),i.set(t,n)}return Y(e,n,e=>i.get(r(e.environmentId,e.id))??[],(e,t)=>e.title.localeCompare(t.title)||e.environmentId.localeCompare(t.environmentId)||e.id.localeCompare(t.id))}function X(e){return e.envMode!==`local`&&e.newWorktreesStartFromOrigin}function Ie(e){return e.projectDefaultSelection??(e.carrySourceDraftId===e.destinationDraftId?null:e.carrySelection)}function Z(e){let t=e?.activeProvider;return e?.modelSelectionExplicit===!0&&t!=null&&e.modelSelectionByProvider[t]!==void 0}function Le(e){return e.activeThread?c(e.activeThread.environmentId,e.activeThread.projectId):e.activeDraftThread?c(e.activeDraftThread.environmentId,e.activeDraftThread.projectId):e.defaultProjectRef}async function Re(e){let t=Le(e);return t?(await e.handleNewThread(t),!0):!1}async function ze(e,t){let n=await g(s,M(e,t,u),{reportDefect:!1,reportFailure:!1}),r=j(e,t,u,j(e,t,n._tag===`Success`?n.value.relativePath:u,n._tag===`Success`?n.value:null));return r===null||r.truncated?null:I(r.contents)}function Q(e){return{...e?.branch===void 0?{}:{branch:e.branch},...e?.worktreePath===void 0?{}:{worktreePath:e.worktreePath},...e?.envMode===void 0?{}:{envMode:e.envMode},...e?.startFromOrigin===void 0?{}:{startFromOrigin:e.startFromOrigin}}}function $(){let e=(0,R.c)(7),t=n(E),r=T(F),s=C(),c;e[0]===s.state.matches?c=e[1]:(c=()=>{let e=s.state.matches[s.state.matches.length-1]?.params??{};return w(e)},e[0]=s.state.matches,e[1]=c);let u=c,d;return e[2]!==t||e[3]!==u||e[4]!==r||e[5]!==s?(d=(e,n)=>{let c=te(),d=t.get(e.environmentId)?.settings??p,{getComposerDraft:g,getDraftSessionByLogicalProjectKey:_,getDraftSession:v,getDraftThread:re,applyStickyState:b,setDraftThreadContext:x,setLogicalProjectDraftThreadId:S,setModelSelection:C}=a.getState(),ie=s.state.location.href,w=()=>s.state.location.href!==ie,T=u(),E=T?.kind===`server`?y(T.threadRef):null,D=T?.kind===`draft`?v(T.draftId):null,O=T?g(T.kind===`server`?T.threadRef:T.draftId):null,k=O?.activeProvider??null,ae=(k?O?.modelSelectionByProvider[k]??null:null)??E?.modelSelection??null,A=O?.interactionMode??E?.interactionMode??D?.interactionMode??null,j=c.find(t=>t.id===e.projectId&&t.environmentId===e.environmentId),M=()=>w()||j!==void 0&&ee(e)===null,N=se(d,j?.id??null,j),oe=N.settings.defaultModelSelection,P=N.settings.defaultRuntimeMode,F=e=>Ie({projectDefaultSelection:oe??null,carrySelection:ae,carrySourceDraftId:T?.kind===`draft`?T.draftId:null,destinationDraftId:e}),I=async()=>{let n=j!==void 0&&N.settings.defaultThreadEnvMode===null?await ze(j.environmentId,j.workspaceRoot):null;return ce({projectSettings:se(d,j?.id??null,j,n),workspaceRoot:j?.workspaceRoot??null,newProjectsRoot:t.get(e.environmentId)?.newProjectsRoot,projectHasThreads:ne().some(t=>t.environmentId===e.environmentId&&t.projectId===e.projectId)})},L=j?le(j,r):l(e),R=n?.branch!==void 0,z=n?.worktreePath!==void 0,B=n?.envMode!==void 0,V=n?.startFromOrigin!==void 0,H=_(L),U=H?o(H.environmentId,H.threadId):null,W=H!==null&&H.promotedTo==null&&U!==null&&y(U)===null?H:null;U&&W===null&&i(U);let G=W&&!f(g(W.draftId))?W:null,K=T?T.kind===`server`?re(T.threadRef):v(T.draftId):null;if(G)return(async()=>{let t=T?.kind===`draft`&&T.draftId===G.draftId,r=R||z||B||V,i=null;if(r)i=Q(n);else if(!t){let e=await I();if(M())return null;let t=u(),n=t?.kind===`draft`&&t.draftId===G.draftId,r=U!==null&&y(U)!==null,a=_(L)?.draftId!==G.draftId,o=f(g(G.draftId));if(n||r||a||o)return null;i={branch:null,worktreePath:null,envMode:e,startFromOrigin:X({envMode:e,newWorktreesStartFromOrigin:N.settings.newWorktreesStartFromOrigin})}}if(i&&x(G.draftId,{...i,...t?{}:{runtimeMode:P},...A?{interactionMode:A}:{}}),!Z(g(G.draftId))){b(G.draftId);let e=F(G.draftId);e&&C(G.draftId,e,{replaceOptions:!0})}S(L,e,G.draftId,{threadId:G.threadId,...i,...t?{}:{runtimeMode:P},...A?{interactionMode:A}:{}});let a={draftId:G.draftId,threadId:G.threadId},o=u();return o?.kind===`draft`&&o.draftId===G.draftId||await s.navigate({to:`/draft/$draftId`,params:{draftId:G.draftId},replace:n?.replace??!1}),a})();if(K&&T?.kind===`draft`&&K.logicalProjectKey===L&&K.promotedTo==null&&!f(g(T.draftId)))return(R||z||B||V)&&x(T.draftId,Q(n)),S(L,e,T.draftId,{threadId:K.threadId,createdAt:K.createdAt,runtimeMode:K.runtimeMode,interactionMode:K.interactionMode,...Q(n)}),Promise.resolve({draftId:T.draftId,threadId:K.threadId});let q=m(),J=h(),ue=new Date().toISOString();return(async()=>{let t=n?.envMode??await I();if(M())return null;let r=_(L);if(r&&r.draftId!==H?.draftId&&y(o(r.environmentId,r.threadId))===null)return S(L,e,r.draftId,{threadId:r.threadId,createdAt:r.createdAt,runtimeMode:r.runtimeMode,interactionMode:r.interactionMode,...Q(n)}),await s.navigate({to:`/draft/$draftId`,params:{draftId:r.draftId},replace:n?.replace??!1}),{draftId:r.draftId,threadId:r.threadId};S(L,e,q,{threadId:J,createdAt:ue,branch:n?.branch??null,worktreePath:n?.worktreePath??null,envMode:t,startFromOrigin:n?.startFromOrigin??X({envMode:t,newWorktreesStartFromOrigin:N.settings.newWorktreesStartFromOrigin}),runtimeMode:P,...A?{interactionMode:A}:{}}),b(q);let i=F(q);return i&&C(q,i,{replaceOptions:!0}),await s.navigate({to:`/draft/$draftId`,params:{draftId:q},replace:n?.replace??!1}),{draftId:q,threadId:J}})()},e[2]=t,e[3]=u,e[4]=r,e[5]=s,e[6]=d):d=e[6],d}function Be(){let e=(0,R.c)(16),t=N(We),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={strict:!1,select:Ue},e[0]=n):n=e[0];let r=ie(n),i=r?.kind===`server`?r.threadRef:null,o=r?.kind===`draft`?r.draftId:null,s=v(i),l=a(He),u;e[1]!==l||e[2]!==r?(u=()=>r?r.kind===`server`?l(r.threadRef):a.getState().getDraftSession(r.draftId):null,e[1]=l,e[2]=r,e[3]=u):u=e[3];let d=a(u),f=re(),p;e[4]!==t||e[5]!==f?(p=be({items:f,preferredIds:t,getId:P,getPreferenceIds:Ve}),e[4]=t,e[5]=f,e[6]=p):p=e[6];let m=p,h=$(),g;e[7]===m[0]?g=e[8]:(g=m[0]?c(m[0].environmentId,m[0].id):null,e[7]=m[0],e[8]=g);let _;return e[9]!==d||e[10]!==s||e[11]!==h||e[12]!==o||e[13]!==i||e[14]!==g?(_={activeDraftThread:d,activeThread:s,defaultProjectRef:g,handleNewThread:h,routeDraftId:o,routeThreadRef:i},e[9]=d,e[10]=s,e[11]=h,e[12]=o,e[13]=i,e[14]=g,e[15]=_):_=e[15],_}function Ve(e){return[P(e),oe(e.workspaceRoot)]}function He(e){return e.getDraftThread}function Ue(e){return w(e)}function We(e){return e.projectOrder}export{U as A,De as C,Fe as D,Me as E,pe as M,Pe as O,me as S,Ne as T,Se as _,Le as a,W as b,q as c,xe as d,Ce as f,Ee as g,be as h,X as i,H as j,Te as k,G as l,_e as m,$ as n,Re as o,ye as p,Z as r,K as s,Be as t,Ae as u,Oe as v,ge as w,we as x,ke as y};
|
|
2
|
+
//# sourceMappingURL=useHandleNewThread-uD-vMkEQ.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{a as n,r,x as i}from"./useParams-
|
|
2
|
-
//# sourceMappingURL=useLocation-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{a as n,r,x as i}from"./useParams-BmGuCYQD.js";var a=e(t(),1);function o(e){let t=n(),o=(0,a.useRef)(void 0);return r(t.stores.location,n=>{let r=e?.select?e.select(n):n;if(e?.structuralSharing??t.options.defaultStructuralSharing){let e=i(o.current,r);return o.current=e,e}return r})}export{o as t};
|
|
2
|
+
//# sourceMappingURL=useLocation-CsUjfT4f.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{a as n}from"./useParams-BmGuCYQD.js";var r=e(t(),1);function i(e){let t=n();return r.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}export{i as t};
|
|
2
|
+
//# sourceMappingURL=useNavigate-JwBJSn8e.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{BE as n}from"./utils-
|
|
2
|
-
//# sourceMappingURL=useNavigateBack-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{BE as n}from"./utils-CyMIjIQl.js";import{a as r,r as i}from"./useParams-BmGuCYQD.js";import{t as a}from"./useNavigate-JwBJSn8e.js";function o(){let e=r();return i(e.stores.location,e=>e.state.__TSR_index!==0)}var s=n(),c=e(t(),1);function l(){let e=(0,s.c)(3),t=a(),n=o(),r;return e[0]!==n||e[1]!==t?(r=()=>{if(n){window.history.back();return}t({to:`/`})},e[0]=n,e[1]=t,e[2]=r):r=e[2],r}function u(e){let t=(0,s.c)(3),n=l(),r=e??n,i,a;t[0]===r?(i=t[1],a=t[2]):(i=()=>{let e=e=>{if(e.defaultPrevented||e.repeat||e.isComposing||e.key!==`Escape`)return;e.preventDefault();let t=document.activeElement;t instanceof HTMLElement&&t.blur(),r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},a=[r],t[0]=r,t[1]=i,t[2]=a),(0,c.useEffect)(i,a)}export{u as t};
|
|
2
|
+
//# sourceMappingURL=useNavigateBack-CpakkPiu.js.map
|
package/dist/client/assets/{useP4ConnectAuthPrompt-C_DWHou2.js → useP4ConnectAuthPrompt-BHYSUurl.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{BE as e}from"./utils-
|
|
2
|
-
//# sourceMappingURL=useP4ConnectAuthPrompt-
|
|
1
|
+
import{BE as e}from"./utils-CyMIjIQl.js";import{t}from"./env-wK1YYxA8.js";import{i as n}from"./dist-DK5rhVDA.js";import{t as r}from"./authRedirect-DWE5a_T9.js";var i=e();function a(){let e=(0,i.c)(2),a=n(),o;return e[0]===a?o=e[1]:(o={authPrompt:null,openAuthPrompt:()=>{a.openSignIn(r(window.location.href,t))}},e[0]=a,e[1]=o),o}export{a as t};
|
|
2
|
+
//# sourceMappingURL=useP4ConnectAuthPrompt-BHYSUurl.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{Di as n}from"./utils-
|
|
2
|
-
//# sourceMappingURL=useParams-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{Di as n}from"./utils-CyMIjIQl.js";function r(e){return e[e.length-1]}function i(e){return typeof e==`function`}function a(e,t){return i(e)?e(t):e}var o=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;function c(e){for(let t in e)if(o.call(e,t))return!0;return!1}var l=()=>Object.create(null),u=(e,t)=>d(e,t,l);function d(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=h(e)&&h(i);if(!a&&!(p(e)&&p(i)))return i;let s=a?e:f(e);if(!s)return i;let c=a?i:f(i);if(!c)return i;let l=s.length,u=c.length,m=a?Array(u):n(),g=0;for(let t=0;t<u;t++){let s=a?t:c[t],u=e[s],f=i[s];if(u===f){m[s]=u,(a?t<l:o.call(e,s))&&g++;continue}if(u===null||f===null||typeof u!=`object`||typeof f!=`object`){m[s]=f;continue}let p=d(u,f,n,r+1);m[s]=p,p===u&&g++}return l===u&&g===l?e:m}function f(e){let t=Object.getOwnPropertyNames(e);for(let n of t)if(!s.call(e,n))return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;let r=t;for(let t of n){if(!s.call(e,t))return!1;r.push(t)}return r}function p(e){if(!m(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!m(n)||!n.hasOwnProperty(`isPrototypeOf`))}function m(e){return Object.prototype.toString.call(e)===`[object Object]`}function h(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function g(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!g(e[r],t[r],n))return!1;return!0}if(p(e)&&p(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!g(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!g(e[o],t[o],n)))return!1;return i===a}return!1}function _(e){let t,n,r=new Promise((e,r)=>{t=e,n=r});return r.status=`pending`,r.resolve=n=>{r.status=`resolved`,r.value=n,t(n),e?.(n)},r.reject=e=>{r.status=`rejected`,n(e)},r}function v(e){return typeof e?.message==`string`?e.message.startsWith(`Failed to fetch dynamically imported module`)||e.message.startsWith(`error loading dynamically imported module`)||e.message.startsWith(`Importing a module script failed`):!1}function y(e){return!!(e&&typeof e==`object`&&typeof e.then==`function`)}function b(e){return e.replace(/[\x00-\x1f\x7f]/g,``)}function x(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return b(t)}var S=[`http:`,`https:`,`mailto:`,`tel:`];function C(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function w(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=x(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=x(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function T(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function E(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function D(){throw Error(`Invariant failed`)}var O=n(),k=e(t(),1),A=k.createContext(null);function j(e){return k.useContext(A)}var M=k.createContext(void 0),N=k.createContext(void 0);function P(e,t){return e===t}function F(e,t,n=P){let r=(0,k.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,k.useCallback)(()=>e?.get(),[e]);return(0,O.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var I={get:()=>void 0,subscribe:()=>({unsubscribe:()=>{}})};function L(e){let t=j(),n=k.useContext(e.from?N:M),r=e.from??n,i=r?e.from?t.stores.getRouteMatchStore(r):t.stores.matchStores.get(r):void 0,a=k.useRef(void 0);return F(i??I,n=>{if((e.shouldThrow??!0)&&!n&&D(),n===void 0)return;let r=e.select?e.select(n):n;if(e.structuralSharing??t.options.defaultStructuralSharing){let e=d(a.current,r);return a.current=e,e}return r})}function R(e){return L({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}export{v as _,j as a,u as b,S as c,w as d,g as f,C as g,c as h,M as i,E as l,a as m,L as n,A as o,T as p,F as r,D as s,R as t,_ as u,y as v,d as x,r as y};
|
|
2
|
+
//# sourceMappingURL=useParams-BmGuCYQD.js.map
|