diff --git a/README.md b/README.md index f52779ff..9ee106e0 100644 --- a/README.md +++ b/README.md @@ -373,7 +373,7 @@ telemetry on macOS, Linux, and WSL: the cautious `CHECK SESSION` inactivity fallback. - **Command approval details and controls** — supported live requests show the command, directory and reason in the Sessions tab's full detail page, with - buttons matching Codex's offered decisions, with confirmation for grants. Incomplete or + buttons matching Codex's offered decisions, with confirmation for broader grants. Incomplete or unsupported requests still need answering in Codex. - **Resolved-model API equivalents** — live model-reroute and response-usage events let Codexometer price a positively matched call using the model that @@ -569,7 +569,7 @@ context from assistant messages and input/approval requests. Resolved requests and new turns clear stale pending context. Observation alone never starts a turn or answers a question. Explicit actions in Sessions can submit follow-up turns to idle sessions, answer supported blocking questions, and send selected command -decisions (with confirmation for permission grants). Drafts stay in memory; +decisions (with confirmation for broader permission grants). Drafts stay in memory; submitted text enters Codex's normal session history and follow-ups consume model usage. Nothing is sent automatically; see the Sessions controls below. Without a shared daemon, previews use @@ -593,12 +593,12 @@ codexometer --codex /path/to/codex | `v` | Cycle views within Quota or Usage | | `z` | Zero the Sessions baseline | | `s` | Open Benchmark Scope (Benchmark view only) | -| `o` | Arm Close All in the Sessions overview; press again to confirm, or `Esc` to cancel | +| `o` | Close All session rows; strict confirmation mode adds a second press, with `Esc` to cancel | | `g` | Cycle available trend periods in Quota → Pace | | `h` | Toggle the trace in Quota → Pace; in Sessions, reset all rows to graph-only / split detail-and-graph, closing full detail and clearing individual row choices | | `Left` / `Right` | In Sessions, highlight attention pills or cycle status filters when that header area has focus; otherwise less / more detail for the selected session: graph ↔ split ↔ wide ↔ full screen; stops at either end | | `b` | Run the selected benchmark scope (Benchmark view only) | -| `a` | Arm, then confirm, Run All (Benchmark view only) | +| `a` | Run All benchmarks; confirmation follows the selected policy (Benchmark view only) | | `x` | Dismiss the selected Sessions row; close Benchmark detail/Scope, or stop an active suite and retain its incomplete trial | | `d` | Select Daily in Usage, or close the Benchmark Scope screen | | `6` / `1` | Select 6/12 months of Usage history | @@ -608,7 +608,7 @@ codexometer --codex /path/to/codex | `w` | Select Weekly in Usage, or cycle Cost, Balanced, and Speed benchmark ranking weights | | `Up` / `Down` | Select a session row or scroll full detail. Up beyond the first row/top of detail moves through visible attention pills to summary filters; Down retraces that path. Select a Benchmark row or scroll its open detail. Focused editors retain their own arrows | | `Enter` / `Space` | Open a selected Benchmark result, or toggle a Scope checkbox; in Sessions, Enter opens a keyboard-highlighted attention pill. Otherwise in full detail, Enter focuses an available reply editor or submits its text | -| `c` | Copy an eligible Sessions reply while its detail is shown, confirm an armed session approval, select Cumulative in Usage, or copy the Benchmark matrix/open run detail; types normally in a focused editor | +| `c` | Copy an eligible Sessions reply while its detail is shown, confirm an armed approval or strict action review, select Cumulative in Usage, or copy the Benchmark matrix/open run detail; types normally in a focused editor | | `l` | Clear accumulated Benchmark results while no suite is running | | `Page Up` / `Page Down` | Page Usage history, session rows, or Benchmark results; scroll Sessions full detail / Benchmark detail (outside a focused editor) | | `q` | Quit | @@ -1291,10 +1291,10 @@ The other top-level views are: closes the selected row. Close All applies the same dismissal and automatic return behavior to all rows. On narrow terminals its label becomes `[××]` with `(O)` below it; Zero shows `0` with `(Z)`. - Close All requires confirmation: click or press `o` once to arm it, then click - or press `o` again within five seconds to confirm. `Esc` cancels. A change - to the visible rows requires a fresh confirmation; switching views or Zero - cancels an armed action. + Close All is immediate by default. With `--confirmation require`, click or + press `o` once to arm it, then again within five seconds to confirm. `Esc` + cancels. Changed visible rows require fresh confirmation; switching views + or Zero cancels an armed action. Close All is disabled when no rows are visible. When the terminal cannot fit every root, use Page Up, Page Down, or the mouse wheel to page through the rows. @@ -1684,9 +1684,9 @@ the other categories; the counts are not separate parts to add together. The summary counts and token totals remain global, excluding dismissed sessions from state counts but retaining their measured tokens. Attention pills stay available across filters; opening an excluded session clears the filter to keep -its row accessible. **Close All** only dismisses matching, non-dismissed sessions -after confirmation; filtering never stops telemetry collection or changes the -Zero baseline. Dismissed sessions are skipped, and Down is disabled at the last +its row accessible. **Close All** only dismisses matching, non-dismissed sessions; +`--confirmation require` adds confirmation. Filtering never stops telemetry +collection or changes the Zero baseline. Dismissed sessions are skipped, and Down is disabled at the last matching session. These up/down session-selection buttons disappear in full detail, where Up/Down scroll the text. On narrow boxes, arrow buttons are omitted if they cannot fit; keyboard and @@ -1844,18 +1844,20 @@ read-only browser mode, except for the terminal-only `/commands` shortcut. **Connected-session commands — shared app-server required.** Availability depends on the installed server and session state; unsupported or empty catalogues are omitted. Changes require explicit selection and, in the browser, opt-in writable -mode. Reversible session-local changes do not need a second confirmation; -permission/directory changes and unknown actions remain guarded by default. +mode. By default, reversible session-local changes do not need a second +confirmation; permission/directory changes and unknown actions remain guarded. +The [confirmation policy](#confirmation-policy) can require review for every +substantive change or skip extra review except quota-reset redemption. Browse-only entries do not execute tools or change configuration. | Command family | Live options and behaviour | | --- | --- | | `/cd` | Change the selected session’s directory after review and confirmation while idle and with no queued messages. Absolute, session-relative and `~/` paths are supported; success is verified from running configuration. Retains thread ID/history; does not reproduce native project-config reload/fork. | | `/cwd`, `/pwd` | Read-only aliases showing the running session’s current directory, including during active turns. | -| `/rename` | Edit the selected session’s saved name and apply it without a second confirmation. Uses Codex’s name API; works during an active turn and does not send a prompt or change model settings. | +| `/rename` | Edit the selected session’s saved name and apply it without a second confirmation by default. Uses Codex’s name API; works during an active turn and does not send a prompt or change model settings. | | `/goal` | Inspect this session’s objective, official goal state and token budget/usage. Set an objective, edit it, pause, resume or clear it. Native forms `/goal `, `/goal edit`, `/goal pause`, `/goal resume` and `/goal clear` are supported. The Budget option (also `/goal budget `) changes the total goal-token budget. Mutations require confirmation by default. | | `/model` | Advertised models, their descriptions and supported reasoning levels. Choosing a model resets its explicit speed override to the server default. | -| Advertised speed commands, such as `/fast` | Show the default speed and every advertised tier in one list, initially highlighting the current speed. Up/Down highlights; **Enter APPLY** or clicking a choice applies it without a second confirmation. IDs and descriptions come from the current model's catalogue; no tier IDs are guessed. The changed speed is verified before success is reported. | +| Advertised speed commands, such as `/fast` | Show the default speed and every advertised tier in one list, initially highlighting the current speed. Up/Down highlights; **Enter APPLY** or clicking a choice applies it without a second confirmation by default. IDs and descriptions come from the current model's catalogue; no tier IDs are guessed. The changed speed is verified before success is reported. | | `/plan` | Advertised collaboration modes, using Codex's built-in mode instructions. | | `/permissions` | Named profiles allowed for the session's directory, with supplied descriptions. Review carefully: this changes future permission behaviour. | | `/skills`, `/apps`, `/mcp`, `/hooks`, `/experimental` | **Browse-only** live inventories and supplied help, including MCP tool descriptions. Invoke/configure these through Codex. | @@ -1885,7 +1887,7 @@ goal-token budget**, not an account spending limit; omitted budgets are retained and `unlimited` explicitly removes the goal budget. Codexometer accepts objectives up to 4,096 characters and positive budgets up to 9,007,199,254,740,991; Codex can impose further limits. Every mutation is session-scoped, freshly revalidated and -verified after acknowledgment, with no automatic retry. `--no-confirm` also opts +verified after acknowledgment, with no automatic retry. `--confirmation none` also opts out of goal confirmations; read-only web mode never enables goal writes. Older/unsupported servers omit the live `/goal` family rather than simulating it. @@ -1924,8 +1926,10 @@ The terminal `/statusline` checkbox list uses the same composer expansion, but deliberately does not filter: **Up/Down** selects, **Space** toggles, **Left/Right** reorders and **Enter** applies the local display preferences. Escape discards unapplied changes. Other menu levels keep help subdued on one line, shortened -with an ellipsis when needed. Reversible settings use **Enter APPLY**; guarded -changes keep separate review and **C CONFIRM** by default. Shrinking the terminal +with an ellipsis when needed. By default, reversible settings use **Enter APPLY**, +while guarded changes use separate review and **C CONFIRM**. With +`--confirmation require`, reversible settings also use **Enter REVIEW**, then +**C CONFIRM**; `--confirmation none` applies either kind on explicit selection. Shrinking the terminal cannot activate a hidden control. The composer and conversation remain in place through all levels, including in a wide session row. `/commands` also opens the root list, including local commands without a shared daemon. @@ -1951,8 +1955,8 @@ for the upstream catalogues. Renames require a loaded session and revalidated options; a concurrent rename or reconnect invalidates the old choice. The updated name appears on the next telemetry refresh. -Codex session-setting changes require a loaded session. Guarded changes retain -their separate confirmation with a 30-second expiry. Speed-only changes can be sent while working or waiting for an approval; +Codex session-setting changes require a loaded session. When the selected policy +requires review, confirmations expire after 30 seconds. Speed-only changes can be sent while working or waiting for an approval; other settings still require idle and no pending approval. The command and options are revalidated before sending; stale connections and changed options fail closed. A normal turn start/completion does not invalidate a speed confirmation, but changed @@ -1964,40 +1968,47 @@ confirmations retain the draft and error context. These changes do not modify gl quota thresholds may later supersede model settings. Uncertain requests are not retried automatically. Read-only web mode offers no command-control endpoint. -### Fewer confirmation steps +### Confirmation policy -By default, `/rename`, model/reasoning selection, advertised speed changes such as -`/fast`, and `/plan` apply on explicit selection. They do not launch a prompt; -settings affect subsequent turns and can be changed again. Model and speed choices -can still affect quota consumption or API cost. `/cd`, `/permissions`, unknown -commands and other guarded actions retain their existing confirmation steps. -Local display commands and read-only inventories remain immediate or browse-only. +Codexometer uses a balanced confirmation policy by default. Explicit one-time +approvals, replies, ordinary queue edits, Close All, `/rename`, model/reasoning +selection, advertised speed changes such as `/fast`, and `/plan` apply immediately. +They still require an explicit action and a fresh, valid session capability. -To opt out of Codexometer's extra confirmation clicks for this launch: +Broader permission grants, `/permissions`, `/cd`, quota-profile changes, native +queue deletion, scheduled follow-ups and Send now, and broad/external benchmark +launches keep their review steps. Terminal schedule forms retain their explicit +Confirm Schedule / Save Changes action. Settings affect subsequent work; model +and speed choices can affect quota consumption or API cost. + +| Setting | Behaviour | +|---|---| +| Omitted | Balanced default: confirm higher-impact actions. | +| `--confirmation none` | Skip extra confirmations, except quota-reset redemption. | +| `--confirmation require` | Confirm every substantive action; navigation and viewing stay immediate. | ```sh -codexometer --no-confirm -codexometer --web --web-control --no-confirm +codexometer --confirmation none +codexometer --web --web-control --confirmation require ``` -**Quota resets are the one exception: redeeming a reset always requires confirmation.** -Elsewhere, this flag makes explicit actions single-step, including approvals and -persistent grants, quota-profile decisions, sending browser prompts or schedules, -scheduled Send now, native queue deletion, Close All dismissal and guarded benchmark -launches. An accidental click can therefore authorise work, spend quota or change -permissions: use it only when you want that trade-off. It never chooses an action -for you or automatically approves an incoming request. - -The flag is not saved in preferences, does not enable web writes without -`--web-control`, and is not forwarded to Codex. Codex's sandbox/approval rules, -fresh-state checks, capability/revision validation and one-use/replay guards remain. -The browser still uses server-side prepare/commit validation, but completes both -phases after the one explicit action. Failed or uncertain writes are never retried -automatically. Unless stated otherwise, confirmation instructions elsewhere in this -README describe the default guarded behaviour. -Recognised key-repeat events are ignored for command submission and approval -shortcuts. Older terminals may not distinguish held-key repeats, so avoid holding -action keys when using `--no-confirm`. +**Quota-reset redemption always requires confirmation, in every mode.** Strict +mode also reviews ordinary terminal replies, active-turn steer/queue/interrupt +actions, queued-message edits and trigger deletion. Reviews bind the exact target, +payload and live capability, expire, and can be cancelled without discarding the +draft. Secret answers remain masked during review. Approve Once is listed first +when Codex advertises it; reusable grants are never invented or substituted. + +The policy is launch-scoped, is not saved in preferences, does not enable browser +writes without `--web-control`, and is not forwarded to Codex. It never selects an +action or automatically approves an incoming request. Codex permissions, fresh +state checks, one-use capabilities and replay guards remain active. The browser +retains server-side prepare/commit validation even when one explicit click completes +both phases. Failed or uncertain writes are never automatically retried. +Recognised key-repeat events cannot submit or confirm actions. On terminals that +cannot identify held-key repeats, tap action keys rather than holding them. The +old `--no-confirm` flag has been removed; replace it with `--confirmation none`. +Use `--confirmation balanced` to select the default explicitly. **Slash-command audit:** the [complete version-matched inventory](docs/slash-command-support.md) compares Codexometer with Codex CLI **0.162.1**, including aliases, partial support @@ -2120,10 +2131,10 @@ or incomplete requests retain their original bounded text. fresh approval each time, even when ordinary approvals have been saved or reviewed automatically. The terminal and writable web mode offer **APPROVE ONCE**, **DECLINE**, and **REJECT & STOP TURN**, with a **HUMAN APPROVAL REQUIRED** label. -Session-wide and persistent grants cannot satisfy these checkpoints. `--no-confirm` -can remove the extra confirmation step, but every request still needs an explicit -human action. Passive observation and read-only web mode do not advertise support -for answering these checkpoints; use a capable native Codex client there. +Session-wide and persistent grants cannot satisfy these checkpoints. One-time +decisions are immediate by default; `--confirmation require` adds a review step. +Every request still needs an explicit human action. Passive observation and +read-only web mode do not advertise support for answering these checkpoints; use a capable native Codex client there. **File-change approvals (shared app-server only):** proposed additions, deletions and updates are shown as scrollable patches, with file paths, rename destinations, @@ -2131,7 +2142,8 @@ old/new line numbers and green additions/red removals. An overall `+N / −N` summary counts added and removed source lines across all proposed files (not wrapped display rows or patch headers). Full detail retains the preceding commentary and justification. The terminal and writable web interface -offer **APPROVE ONCE** (with confirmation), **DECLINE**, and **REJECT & STOP TURN**. +offer **APPROVE ONCE**, **DECLINE**, and **REJECT & STOP TURN**. These decisions +are immediate by default and reviewed with `--confirmation require`. Read-only web mode can display the patch but cannot answer it. Inline terminal buttons appear only when the entire proposed patch fits; otherwise open full detail. @@ -2146,9 +2158,11 @@ or persistent permission grants. When the approval event omits the command or directory, Codexometer associates it with the preceding command item from the same thread, turn and item. A complete ordinary command request offers clickable -buttons matching the supported decisions Codex actually offers, in its order: +buttons matching the supported decisions Codex actually offers, with Approve Once +first when available and the remaining choices in their offered order: -- **APPROVE ONCE** grants this command after **CONFIRM APPROVAL**. +- **APPROVE ONCE** grants this command immediately by default. Strict mode adds + **CONFIRM APPROVAL**. - **ALLOW FOR SESSION** grants session-scoped approval after **CONFIRM SESSION GRANT**; future prompts covered by Codex's session approval cache may run without asking again. @@ -2168,24 +2182,27 @@ decision absent from the request can be submitted. For older servers omitting the decision list, only the legacy Accept/Cancel pair is offered. Closing the detail page cancels an unsubmitted confirmation. Each visible -approval button has a numbered shortcut (`1`–`8`, following the offered order). -A grant shortcut selects the choice. For **APPROVE ONCE**, terminals supporting +approval button has a numbered shortcut (`1`–`8`, following the displayed order). +One-time approvals, decline and reject/stop act immediately by default. Broader +grants first select their confirmation. In strict mode, terminals supporting key-release events through the [Kitty keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/) -allow the same number again after releasing it (`1`, release, +let **APPROVE ONCE** use the same number again after releasing it (`1`, release, `1` for the first option). The confirmation button displays that number; held-key repeats cannot confirm. `C` remains an alternative, whether selected by keyboard or mouse. Terminals without key-release support retain the displayed `C` -confirmation. Session-wide and persistent grants always require `C` or clicking -the confirmation button, not repeating their number. Armed confirmations expire +confirmation. When a confirmation is required, session-wide and persistent grants +require `C` or clicking the confirmation button, not repeating their number. Armed confirmations expire after five seconds and are cancelled by changing the target or leaving its view; -a new request requires a new confirmation. Decline -and reject/stop shortcuts act immediately, just like their buttons. Only one -session—the expanded row or full-detail target—can display approval controls +a new request requires a new confirmation. Strict mode also confirms decline +and reject/stop decisions. Only one session—the expanded row or full-detail +target—can display approval controls at a time. Hidden, clipped and compact controls have no active shortcuts, and typing in the reply editor never triggers approval shortcuts. -This enhanced shortcut depends on the **terminal application and detected -keyboard protocol**, not just the operating system: +The following Approve Once examples describe `--confirmation require`; the +balanced default sends that choice on the first explicit action. The enhanced +confirmation shortcut depends on the **terminal application and detected keyboard +protocol**: - **Windows Terminal 1.24 with Ubuntu/WSL:** uses `1` then `C`. Microsoft introduced Kitty keyboard-protocol support in @@ -2204,15 +2221,16 @@ Kitty protocol support is **not required to run Codexometer or approve commands* If the confirmation button shows `C`, use `C` or click it; this is the safe fallback in both inline and full-screen detail, not a missing approval feature. -Buttons wrap into rows when needed, reserve their -confirmation widths so other targets do not move, and sit in a pinned footer +Buttons wrap into rows when needed and sit in a pinned footer. Guarded buttons +reserve confirmation widths so other targets do not move; immediate decisions +reserve only their displayed width. The footer sits below the scrolling request text, separated by one blank line when space allows. Very short terminals omit that spacer first. Controls are hidden if the terminal -cannot fit them with room to read the request. All permission grants require -their own explicit second confirmation; confirming one choice cannot confirm another. +cannot fit them with room to read the request. When confirmation is required, it +binds exactly one choice; confirming it cannot confirm another. Actions are bound to a single pending request on the current connection. They -become unavailable when resolved elsewhere, the turn ends, or the connection +become unavailable when the request is resolved or invalidated, or the connection closes. The server arbitrates simultaneous responses from multiple clients. Sending a decision is not proof that the command ran: check Codex for the outcome. Failed or ambiguous sends are not automatically retried. @@ -2365,8 +2383,8 @@ authenticated `GET /games` and uses every game name returned by DigBench; no clear all, or choose any subset. **Run Scope** executes every selected game against every selected compatible model/reasoning-effort pair. **Run All** executes every discovered game against every compatible pair. Both controls -display the exact remote-session count and require a second confirmation before -creating those sessions, because every game/pair invocation creates a persisted +display the exact remote-session count and require a second confirmation by +default before creating those sessions, because every game/pair invocation creates a persisted remote session with a random seed. Create a token from the [DigBench token page](https://digbench.ai/account/tokens) @@ -2505,8 +2523,9 @@ every selected compatible model/effort pair. The button is enabled whenever that scope contains at least one benchmark and one compatible pair, and its label shows the resulting turn count. **Run All** deliberately ignores the scope and executes every benchmark in the active suite against every compatible -model/effort pair. Codexometer displays that exact total and requires a second -confirmation within five seconds. A fresh, ephemeral, read-only app-server +model/effort pair. Codexometer displays that exact total and, by default, requires +a second confirmation within five seconds. `--confirmation none` skips that +extra step; strict mode also confirms individual built-in scope launches. A fresh, ephemeral, read-only app-server thread is used for each built-in trial, so benchmark history does not clutter normal Codex sessions. The turns still consume the same account quota shown by Codexometer unless a benchmark API key is supplied; with a key, they use @@ -2851,7 +2870,7 @@ open directly. --check-auth verify the current Codex login and exit --error-log PATH opt into bounded JSON operational diagnostics (off by default) --verbose add diagnostic context to --error-log; never raw payloads ---no-confirm skip extra confirmation clicks, except quota-reset redemption +--confirmation MODE balanced (default), none, or require; quota resets always confirmed --demo preview simulated quota, Sessions, Usage, and benchmark data --inline render inline instead of using the alternate screen --web experimental read-only browser interface (loopback only) @@ -2941,6 +2960,8 @@ enlarge the terminal. The Quota page retains only its existing reset controls. Click **APPLY PROFILE** (or press `1` for the selected session), then click **CONFIRM PROFILE** or press `C` within ten seconds. Click **SKIP** or press `2` to skip that session at the current threshold; `Esc` cancels confirmation. +Applying a profile is immediate with `--confirmation none`. Strict mode also +reviews Skip, using `C` or a confirmation click to commit and `Esc` to cancel. Navigation, resizing and inventory refresh disarm confirmations. Each approval is for exactly one session—there is no bulk approval and newly discovered sessions need their own review. Each pill represents a distinct review: one @@ -2956,7 +2977,9 @@ that session's profile change, just like the terminal. Native Codex requests remain accessible through their own pills or normal session detail. Follow-up composers stay hidden while a quota review is pending, preserving existing drafts; switching reviews cancels pending confirmation. Select **APPLY PROFILE** -or **SKIP**, then review and confirm. Cross-session quota navigation is blocked +or **SKIP**. Apply requires review by default; Skip is immediate. Strict mode +reviews either choice, while `--confirmation none` applies either directly. +Cross-session quota navigation is blocked while the current session has an unsent draft or a send in progress. Confirmations bind to the exact session, current settings, threshold and quota window and expire after 30 seconds. @@ -3183,7 +3206,8 @@ the dashboard. The composer stays anchored below it; on shorter terminals the form scrolls with the mouse wheel and follows keyboard focus. Esc or Ctrl+S returns to the conversation, preserving a new follow-up draft. Cancelling an edit to a saved trigger leaves that trigger and any separate reply draft intact. -Normal Enter-to-send remains immediate. The structured form offers **after quota +Normal Enter-to-send is immediate by default; `--confirmation require` adds +a review of the exact draft before sending. The structured form offers **after quota refresh**, a delay in hours/minutes, or a calendar date and local time. Use Tab to move between visible fields (Shift+Tab goes back), arrows to adjust, digits to enter hours/minutes, and Page Up/Down to change calendar month. Calendar arrows @@ -3197,11 +3221,14 @@ Hover highlights the individual control without changing the selected trigger. The dashboard tabs, attention pills and footer remain usable while editing; navigating away retains the unsaved form in memory for that session. Explicit Back/Esc still cancels an edit. Editing or deleting a native queued message also -stays inside the detail pane; Tab/Shift+Tab selects its controls, Enter confirms -the selected action and Esc cancels. +stays inside the detail pane; Tab/Shift+Tab selects its controls, Enter submits +the selected action and Esc cancels. Strict mode adds review before committing +an ordinary edit; deletion keeps its existing review unless confirmation is +disabled. Writable web mode offers the same triggers in the full-detail composer, with the -browser's date/time picker and a separate review/confirmation step. Read-only web +browser's date/time picker and a separate review/confirmation step by default. +`--confirmation none` skips that extra step. Read-only web mode cannot create or access scheduled prompts. Both composers have a subtle theme-coloured background. @@ -3228,15 +3255,18 @@ theme-coloured background. show an explanation before saving. Existing triggers use **SAVE CHANGES**. Terminal keyboard hints follow the focused field; the selected trigger stays underlined when unfocused and filled when focused. - **Ctrl+S** edits; **Ctrl+D** deletes the trigger. **Ctrl+N** requests - **Send now**, followed by **Ctrl+Y** or a confirmation click; Escape cancels that - confirmation. These actions also have clickable buttons. Send now remains + **Ctrl+S** edits; **Ctrl+D** deletes the trigger. Strict mode reviews deletion + before cancelling the saved job. **Ctrl+N** requests + **Send now**, followed by **Ctrl+Y** or a confirmation click by default; + `--confirmation none` skips the extra step. Escape cancels an armed confirmation. These actions also have clickable buttons. Send now remains disabled without fresh available quota and an eligible idle session. It shares the automatic dispatch guard so the same trigger cannot send twice. Editing invalidates older Send now confirmations. Approval/question controls retain priority over the pending-trigger controls. - Writable web detail provides **Edit · Ctrl+S**, **Delete trigger** and separately - confirmed **Send now**. Standard Tab/Shift+Tab and native form keyboard controls + confirmed **Send now** by default. Strict mode also reviews **Delete trigger**; + `--confirmation none` skips extra review. Standard Tab/Shift+Tab and native form + keyboard controls cover the entire web form. Back leaves the existing trigger unchanged. Browser editing does not pause the saved trigger. If it is changed, deleted or sent while you edit, the old edit cannot overwrite or recreate it: go back and @@ -3302,9 +3332,11 @@ there is no separate read-only pairing link on a control-enabled server. directory and exact command. Select one of the actual supported decisions, answer the input questions, or write a follow-up. Session-wide and persistent prefix grants are explicitly marked and show the supplied prefix details. -5. Click **REVIEW BEFORE SENDING**, then the separate **CONFIRM** button within - 30 seconds. Cancel returns to editing; Enter in a text area inserts a newline, - never submits. All decisions, including declines, use this two-step browser flow. +5. Use the displayed send/decision button. Actions requiring review show + **REVIEW BEFORE SENDING**, then a separate **CONFIRM** button with a 30-second + expiry. Cancel returns to editing; Enter in a text area inserts a newline, + never submits. `--confirmation require` adds this review to every substantive + decision, including one-time approvals, ordinary replies and declines. The server binds preparation to the exact session, source request, chosen option and answers. Confirmation rechecks the offer against current reader/provider diff --git a/assets/screenshots/approval.png b/assets/screenshots/approval.png index e0d84407..007789b4 100644 Binary files a/assets/screenshots/approval.png and b/assets/screenshots/approval.png differ diff --git a/assets/screenshots/manifest.json b/assets/screenshots/manifest.json index 49db73ee..e6a1a225 100644 --- a/assets/screenshots/manifest.json +++ b/assets/screenshots/manifest.json @@ -14,8 +14,8 @@ "caption": "Session detail: synthetic commentary, the exact command to review, and explicit approval controls.", "columns": 136, "rows": 35, - "frameSHA256": "6693d343f49fbd08c540c9c3219ab9e39c5b6a8006343c7391a998d641fc5608", - "pngSHA256": "d4e21219b531c58adf0d1e931363b77b9a4f9dcf2fe8882d9791652e64f49f2a" + "frameSHA256": "9139ff68e8bf1aac70d4ee00aee2ee3c8d12a4c0c489da024a113b0d2d0b3811", + "pngSHA256": "bee25bf391a19c75971128f8dfade7413bda4d7e78ba1d2d0d5a74528bdde430" }, { "file": "benchmark.png", diff --git a/internal/codex/approval_options.go b/internal/codex/approval_options.go index 5efacc54..200ea91d 100644 --- a/internal/codex/approval_options.go +++ b/internal/codex/approval_options.go @@ -84,5 +84,13 @@ func commandApprovalOptions(raw []json.RawMessage) ([8]ApprovalOption, string) { if len(raw) > 16 { names = append(names, "…") } + // Present the one-command grant first when it was actually advertised. + for i, option := range out { + if option.Kind == "accept" { + copy(out[1:i+1], out[:i]) + out[0] = option + break + } + } return out, strings.Join(names, ", ") } diff --git a/internal/codex/approval_options_test.go b/internal/codex/approval_options_test.go index 781dae02..e79a387a 100644 --- a/internal/codex/approval_options_test.go +++ b/internal/codex/approval_options_test.go @@ -12,6 +12,7 @@ func TestAdvertisedApprovalChoices(t *testing.T) { kinds []string }{ {`["accept","cancel"]`, []string{"accept", "cancel"}}, + {`["acceptForSession","decline","accept","cancel"]`, []string{"accept", "acceptForSession", "decline", "cancel"}}, {`["cancel"]`, []string{"cancel"}}, {`["acceptForSession","decline"]`, []string{"acceptForSession", "decline"}}, {`null`, []string{"accept", "cancel"}}, diff --git a/internal/confirmation/policy.go b/internal/confirmation/policy.go index a2be86b8..e339a525 100644 --- a/internal/confirmation/policy.go +++ b/internal/confirmation/policy.go @@ -2,25 +2,61 @@ // second click never authorises an action or bypasses backend validation. package confirmation +import "fmt" + +type Mode string + +const ( + Balanced Mode = "balanced" + None Mode = "none" + Require Mode = "require" +) + +func Parse(value string) (Mode, error) { + switch Mode(value) { + case Balanced, None, Require: + return Mode(value), nil + default: + return "", fmt.Errorf("--confirmation must be balanced, none or require") + } +} + type Action uint8 const ( - Guarded Action = iota // Unknown actions fail closed by default. - Reversible + Guarded Action = iota // Unknown actions remain guarded by default. + Narrow QuotaReset ) -type Policy struct { - NoConfirm bool -} +type Policy struct{ Mode Mode } func (p Policy) Required(action Action) bool { - return action == QuotaReset || !p.NoConfirm && action != Reversible + if action == QuotaReset { + return true + } + switch p.Mode { + case None: + return false + case Require: + return true + default: + return action != Narrow + } } func Command(reversible bool) Action { if reversible { - return Reversible + return Narrow } return Guarded } + +func Approval(kind string) Action { + switch kind { + case "accept", "decline", "cancel": + return Narrow + default: + return Guarded + } +} diff --git a/internal/confirmation/policy_test.go b/internal/confirmation/policy_test.go index 87c754e3..da0e132e 100644 --- a/internal/confirmation/policy_test.go +++ b/internal/confirmation/policy_test.go @@ -3,21 +3,31 @@ package confirmation import "testing" func TestPolicy(t *testing.T) { - for _, tc := range []struct { - noConfirm bool - action Action - want bool - }{ - {false, Guarded, true}, {false, Reversible, false}, - {false, QuotaReset, true}, {false, Action(99), true}, - {true, Guarded, false}, {true, Reversible, false}, - {true, QuotaReset, true}, {true, Action(99), false}, - } { - if (Policy{NoConfirm: tc.noConfirm}).Required(tc.action) != tc.want { - t.Fatal("wrong confirmation policy", tc) + for _, mode := range []Mode{"", Balanced, None, Require} { + for _, action := range []Action{Guarded, Narrow, QuotaReset, Action(99)} { + want := action == QuotaReset || mode != None && (mode == Require || action != Narrow) + if (Policy{Mode: mode}).Required(action) != want { + t.Fatal("wrong confirmation policy", mode, action) + } } } - if Command(false) != Guarded || Command(true) != Reversible { - t.Fatal("unknown command must remain guarded") + if Command(false) != Guarded || Command(true) != Narrow { + t.Fatal("unknown commands must remain guarded") + } + for _, kind := range []string{"accept", "decline", "cancel", "acceptForSession", "acceptWithExecpolicyAmendment", "unknown"} { + narrow := kind == "accept" || kind == "decline" || kind == "cancel" + if (Approval(kind) == Narrow) != narrow { + t.Fatal("incorrect approval scope", kind) + } + } +} + +func TestParseMode(t *testing.T) { + for _, value := range []string{"balanced", "none", "require", "", "no", "true", "never"} { + mode, err := Parse(value) + valid := value == "balanced" || value == "none" || value == "require" + if (err == nil) != valid || valid && string(mode) != value { + t.Fatal(value, mode, err) + } } } diff --git a/internal/ui/action_review.go b/internal/ui/action_review.go new file mode 100644 index 00000000..077a95b9 --- /dev/null +++ b/internal/ui/action_review.go @@ -0,0 +1,188 @@ +package ui + +import ( + "crypto/sha256" + "encoding/json" + "strings" + "time" + + tea "charm.land/bubbletea/v2" + "charm.land/lipgloss/v2" + "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" + "github.com/merefield/codexometer/internal/i18n" +) + +// A strict review holds no runnable closure. Confirmation re-enters the normal +// action path, which rechecks the target, exact payload and live capability. +type monitorActionReview struct { + action, target, destination, title, text string + signature [32]byte + until time.Time + scroll int + approved bool +} + +func (m *Model) reviewMonitorAction(action, destination, title, text string, payload any) bool { + if !m.confirmations.Required(confirmation.Narrow) { + return false + } + encoded, err := json.Marshal(payload) + if err != nil { + return true + } + signature := sha256.Sum256(encoded) + target := m.monitorContextTarget() + if r := m.actionReview; r != nil && r.approved && r.action == action && r.target == target && r.destination == destination && r.signature == signature && time.Now().Before(r.until) { + m.actionReview = nil + return false + } + m.actionReview = &monitorActionReview{action: action, target: target, destination: destination, title: title, text: text, signature: signature, until: time.Now().Add(30 * time.Second)} + return true +} + +// Controls and the document share one layout, including translated wrapping. +func layoutActionReview(width, height int) (buttons []monitorNavigationButton, rows, gap int) { + labels := []string{i18n.Text("[ C CONFIRM ]"), i18n.Text("[ ESC CANCEL ]")} + x, y := 2, 0 + for i, label := range labels { + buttonWidth := lipgloss.Width(label) + if buttonWidth > width-4 { + return nil, max(height-2, 1), 0 + } + if x+buttonWidth > width-2 { + x, y = 2, y+1 + } + buttons = append(buttons, monitorNavigationButton{label: label, action: []string{"confirm", "cancel"}[i], enabled: true, rect: monitorRect{x: x, y: y, width: buttonWidth, height: 1}}) + x += buttonWidth + 2 + } + rows, gap, top := monitorContextBodyLayout(height, y+1) + if rows < 1 { + return nil, max(height-2, 1), 0 + } + for i := range buttons { + buttons[i].rect.y += top + } + return buttons, rows, gap +} + +func (m Model) actionReviewButtons() []monitorNavigationButton { + g := m.monitorDashboardLayout() + buttons, _, _ := layoutActionReview(g.contentWidth, g.meterHeight) + return buttons +} + +func (m Model) renderActionReview(width, height int, colors palette) string { + r := m.actionReview + buttons, rows, gap := layoutActionReview(width, height) + lines := sessionWebLiteralTextLines(codex.SanitizeApprovalText(r.destination+"\n\n"+r.text), max(width-4, 1)) + start := min(r.scroll, max(len(lines)-rows, 0)) + body := append([]string(nil), lines[start:min(start+rows, len(lines))]...) + for len(body) < rows+gap { + body = append(body, "") + } + if len(buttons) > 0 { + top := buttons[0].rect.y + controls := make([]string, buttons[len(buttons)-1].rect.y-top+1) + for _, button := range buttons { + row := button.rect.y - top + controls[row] += strings.Repeat(" ", max(button.rect.x-2-lipgloss.Width(controls[row]), 0)) + colors.label().Render(button.label) + } + body = append(body, controls...) + } + return frameSizedWithActions(width, max(height-2, 1), r.title, "", "", strings.Join(body, "\n"), colors.primary, colors) +} + +func (m Model) updateActionReview(msg tea.Msg) (Model, tea.Cmd, bool) { + if m.actionReview == nil { + return m, nil, false + } + if m.meterView != viewMonitor || m.actionReview.target != m.monitorContextTarget() || !time.Now().Before(m.actionReview.until) { + m.actionReview = nil + switch msg.(type) { + case tea.KeyPressMsg, tea.MouseClickMsg, tea.MouseWheelMsg, tea.PasteMsg: + return m, nil, true + } + return m, nil, false + } + // Copy before changing an immutable Model snapshot's review state. + review := *m.actionReview + m.actionReview = &review + action := "" + switch event := msg.(type) { + case tea.KeyPressMsg: + if event.IsRepeat { + return m, nil, true + } + switch event.String() { + case "c": + action = "confirm" + case "esc": + action = "cancel" + case "up", "pgup": + review.scroll = max(review.scroll-3, 0) + case "down", "pgdown": + review.scroll++ + } + case tea.MouseClickMsg: + if event.Button != tea.MouseLeft { + return m, nil, true + } + g := m.monitorDashboardLayout() + action = monitorNavigationButtonsHit(m.actionReviewButtons(), event.X-2, event.Y-g.meterY) + case tea.MouseWheelMsg: + if event.Button == tea.MouseWheelUp { + review.scroll = max(review.scroll-3, 0) + } else { + review.scroll += 3 + } + case tea.MouseMotionMsg, tea.PasteMsg: + return m, nil, true + default: + return m, nil, false // Telemetry and action responses keep flowing. + } + if action == "cancel" { + m.actionReview = nil + return m, nil, true + } + if action != "confirm" || len(m.actionReviewButtons()) == 0 { + return m, nil, true + } + if m.err != nil || m.monitorError != "" { + m.actionReview = nil + return m, nil, true + } + review.approved = true + var next Model + var cmd tea.Cmd + switch review.action { + case "reply": + next, cmd, _ = m.submitMonitorPrompt() + case "steer", "queue", "interrupt": + next, cmd, _ = m.submitMonitorTurn(review.action) + case "queue-edit": + next, cmd, _ = m.changeQueueItem() + case "profile-skip": + next, cmd, _ = m.profileAction("profile-skip:"+review.destination, false) + case "trigger-delete": + cmd = m.triggerAction("ctrl+d") + next = m + default: + m.actionReview = nil + return m, nil, true + } + if next.actionReview != nil && next.actionReview.approved { + next.actionReview = nil + } + return next, cmd, true +} + +// Ordinary sends and edits are narrow actions. Permission grants, scheduling, +// queue deletion and other guarded workflows retain their own review screens. +func (m *Model) reviewPromptAction(action, destination string, payload any, text string) bool { + title := i18n.Text("REPLY") + if action != "reply" { + title += " // " + strings.ToUpper(action) + } + return m.reviewMonitorAction(action, destination, title, text, payload) +} diff --git a/internal/ui/benchmark.go b/internal/ui/benchmark.go index d5a04c97..c07c29d0 100644 --- a/internal/ui/benchmark.go +++ b/internal/ui/benchmark.go @@ -1,6 +1,7 @@ package ui import ( + tea "charm.land/bubbletea/v2" "fmt" "math" "slices" @@ -924,17 +925,15 @@ func (m Model) benchmarkControlLines(width int) [][]benchmarkControlSegment { if m.benchmarkPlanning { allLabel = i18n.Text("[ DISCOVERING TURNS… ]") } + unit := i18n.Text("TURNS") if selected.external { selectedLabel = i18n.Format("[ (B) RUN SCOPE // %d REMOTE ]", scopeTurns) - if m.benchmarkSelectedArmed { - selectedLabel = i18n.Format("[ CONFIRM // %d REMOTE SESSIONS ]", scopeTurns) - } + unit = i18n.Text("REMOTE SESSIONS") + } + if m.benchmarkSelectedArmed { + selectedLabel = i18n.Format("[ CONFIRM // %d %s ]", scopeTurns, unit) } if m.benchmarkAllArmed { - unit := i18n.Text("TURNS") - if selected.external { - unit = i18n.Text("REMOTE SESSIONS") - } allLabel = i18n.Format("[ CONFIRM // %d %s ]", allTurns, unit) } primaryLabelsWidth := lipgloss.Width(selectedLabel) + lipgloss.Width(allLabel) + 1 @@ -943,7 +942,7 @@ func (m Model) benchmarkControlLines(width int) [][]benchmarkControlSegment { } if primaryLabelsWidth > width { selectedLabel = i18n.Format("[B:SCOPE %d]", scopeTurns) - if selected.external && m.benchmarkSelectedArmed { + if m.benchmarkSelectedArmed { selectedLabel = i18n.Format("[B:CONFIRM %d]", scopeTurns) } allLabel = fmt.Sprintf("[A:SUITE %d]", allTurns) @@ -961,7 +960,7 @@ func (m Model) benchmarkControlLines(width int) [][]benchmarkControlSegment { if primaryLabelsWidth > width { stopLabel = i18n.Text("[STOP]") selectedLabel = fmt.Sprintf("[S:%d]", scopeTurns) - if selected.external && m.benchmarkSelectedArmed { + if m.benchmarkSelectedArmed { selectedLabel = fmt.Sprintf("[S:%d?]", scopeTurns) } allLabel = i18n.Format("[ALL:%d]", allTurns) @@ -2071,3 +2070,15 @@ func (m Model) benchmarkRunAt(x, y int) (benchmarkTableRow, bool) { } return rows[index], true } + +// Both launch controls bind their review to the current confirmation sequence. +func (m *Model) armBenchmarkLaunch(all bool) tea.Cmd { + if all { + m.benchmarkAllArmed = true + } else { + m.benchmarkSelectedArmed = true + } + m.benchmarkConfirmSequence++ + sequence := m.benchmarkConfirmSequence + return tea.Tick(5*time.Second, func(time.Time) tea.Msg { return benchmarkConfirmExpiredMsg{sequence: sequence} }) +} diff --git a/internal/ui/confirmation_modes_test.go b/internal/ui/confirmation_modes_test.go new file mode 100644 index 00000000..25080ed9 --- /dev/null +++ b/internal/ui/confirmation_modes_test.go @@ -0,0 +1,365 @@ +package ui + +import ( + "strings" + "testing" + "time" + + tea "charm.land/bubbletea/v2" + "github.com/charmbracelet/x/ansi" + "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" +) + +func TestConfirmationModesBindApprovalScope(t *testing.T) { + for _, mode := range []confirmation.Mode{confirmation.Balanced, confirmation.None, confirmation.Require} { + for index, kind := range []string{"accept", "decline", "cancel", "acceptForSession", "acceptWithExecpolicyAmendment"} { + m := approvalTestModel() + m.SetConfirmationMode(mode) + action := m.monitorApprovalButtons(180, 40)[index].action + m, cmd, _ := m.monitorApprovalAction(action) + guarded := (confirmation.Policy{Mode: mode}).Required(confirmation.Approval(kind)) + if guarded { + if cmd != nil || m.monitorApprovalConfirm == "" { + t.Fatal("missing confirmation", mode, kind) + } + m, cmd, _ = m.updateMonitorApprovalKey("c") + } + if cmd == nil || !m.monitorApprovalBusy { + t.Fatal("explicit decision was not queued", mode, kind) + } + cmd() + if m.fetcher.(*approvalTestClient).decision != m.monitorSessionData[0].preview.ApprovalOptions[index].Value { + t.Fatal("wrong decision sent") + } + } + } +} + +func TestBalancedCloseAllIsImmediate(t *testing.T) { + m := contextTestModel() + m.requestMonitorCloseAll() + if m.visibleMonitorSessionCount() != 0 || m.monitorCloseAllArmed() { + t.Fatal("balanced Close All still needs confirmation") + } +} + +func TestStrictReversibleCommandRequiresReview(t *testing.T) { + m, client := commandTestModel(t) + m.SetConfirmationMode(confirmation.Require) + m.monitorCommands.menu.Choices[0].Reversible = true + m, cmd, _ := m.chooseMonitorCommand() + if cmd != nil || client.calls != 0 || !m.monitorCommands.detail { + t.Fatal("strict setting change bypassed review") + } + _, cmd, _ = m.confirmMonitorCommand() + if cmd == nil { + t.Fatal("reviewed setting could not be confirmed") + } + cmd() + if client.calls != 1 { + t.Fatal("setting not applied exactly once") + } +} + +func TestStrictReplyReviewBindsPayloadAndCapability(t *testing.T) { + for _, change := range []string{"none", "payload", "capability", "target", "expiry", "cancel", "repeat"} { + t.Run(change, func(t *testing.T) { + m, client := promptTestModel() + m.SetConfirmationMode(confirmation.Require) + m.focusMonitorPrompt() + m.monitorPrompt.input.SetValue("Review this exact draft") + m, cmd, _ := m.submitMonitorPrompt() + if cmd != nil || m.actionReview == nil || client.answers != nil { + t.Fatal("reply bypassed strict review") + } + if rendered := ansi.Strip(m.render()); !strings.Contains(rendered, "Review this exact draft") || !strings.Contains(rendered, "CONFIRM") { + t.Fatal("review omitted payload or confirmation") + } + k := key('c') + switch change { + case "payload": + m.monitorPrompt.input.SetValue("Different draft") + case "capability": + client.offer.Token = "replacement" + case "target": + m.setRowContext("root-two", contextFull) + case "expiry": + m.actionReview.until = time.Now().Add(-time.Second) + case "cancel": + k = specialKey(tea.KeyEscape) + case "repeat": + k.IsRepeat = true + } + next, cmd := m.Update(k) + m = next.(Model) + if change != "none" { + if cmd != nil || client.answers != nil { + t.Fatal("unreviewed or cancelled payload submitted") + } + return + } + if cmd == nil || m.actionReview != nil { + t.Fatal("fresh explicit confirmation did not submit") + } + cmd() + if len(client.answers) != 1 || client.answers[0] != "Review this exact draft" { + t.Fatal("wrong reply submitted") + } + }) + } +} + +func TestStrictTurnActionsRequireExplicitReview(t *testing.T) { + for _, action := range []string{"steer", "queue", "interrupt"} { + m, client := turnTestModel() + m.SetConfirmationMode(confirmation.Require) + m, cmd, _ := m.submitMonitorTurn(action) + if cmd != nil || m.actionReview == nil { + t.Fatal("turn action bypassed review", action) + } + next, cmd := m.Update(key('c')) + if cmd == nil || next.(Model).actionReview != nil { + t.Fatal("turn action could not be confirmed", action) + } + cmd() + if client.action != action { + t.Fatal("wrong active-turn action", client.action) + } + } +} + +func TestStrictReviewMasksAllSecretAnswers(t *testing.T) { + for _, secretLast := range []bool{false, true} { + m, client := promptTestModel() + m.monitorSessionData[0].preview.Kind = codex.SessionContextQuestion + m.monitorSessionData[0].preview.InputToken = client.offer.Token + questions := []codex.PromptQuestion{{Text: "Secret", Secret: true, FreeText: true}, {Text: "Public", FreeText: true}} + answers := []string{"Never reveal this secret", "Public answer"} + if secretLast { + questions[0], questions[1] = questions[1], questions[0] + answers[0], answers[1] = answers[1], answers[0] + } + client.offer.Questions = questions + m.SetConfirmationMode(confirmation.Require) + m.focusMonitorPrompt() + var cmd tea.Cmd + for _, answer := range answers { + m.monitorPrompt.input.SetValue(answer) + m, cmd, _ = m.submitMonitorPrompt() + } + if cmd != nil || m.actionReview == nil { + t.Fatal("missing question review", secretLast) + } + shown := ansi.Strip(m.render()) + if strings.Contains(shown, "Never reveal this secret") || !strings.Contains(shown, "Public answer") { + t.Fatal("review revealed a secret or hid a public answer", secretLast) + } + next, cmd := m.Update(key('c')) + if cmd == nil || next.(Model).actionReview != nil { + t.Fatal("question answers could not be confirmed", secretLast) + } + cmd() + if len(client.answers) != len(answers) || client.answers[0] != answers[0] || client.answers[1] != answers[1] { + t.Fatal("display masking altered submitted answers", secretLast) + } + } +} + +func TestStrictQueueEditUsesReviewedItem(t *testing.T) { + m, client := queueTestModel(false) + m.SetConfirmationMode(confirmation.Require) + m.openQueueItem(0, false) + m.monitorQueue.input.SetValue("Reviewed edit") + m, cmd, _ := m.changeQueueItem() + if cmd != nil || m.actionReview == nil { + t.Fatal("queue edit bypassed review") + } + next, cmd := m.Update(key('c')) + if cmd == nil || next.(Model).actionReview != nil { + t.Fatal("queue edit could not be confirmed") + } + cmd() + if client.changed != "one" || client.text != "Reviewed edit" { + t.Fatal("wrong queue edit") + } +} + +func TestStrictReviewKeepsMouseControlsVisibleWithLongDrafts(t *testing.T) { + for _, width := range []int{40, 80, 120} { + for _, height := range []int{18, 24, 40} { + m, client := promptTestModel() + m.width, m.height = width, height + m.SetConfirmationMode(confirmation.Require) + m.focusMonitorPrompt() + m.monitorPrompt.input.SetValue(strings.Repeat("Long reviewed draft\n", 100)) + m, _, _ = m.submitMonitorPrompt() + buttons := m.actionReviewButtons() + if len(buttons) != 2 { + t.Fatal("review controls hidden at supported size", width, height) + } + g := m.monitorDashboardLayout() + lines := strings.Split(ansi.Strip(m.render()), "\n") + for _, button := range buttons { + y := g.meterY + button.rect.y + x := 2 + button.rect.x + if y >= len(lines) || ansi.Cut(lines[y], x, x+button.rect.width) != button.label { + t.Fatal("review control rendering/hit geometry mismatch", width, height, button.label) + } + } + next, cmd := m.Update(tea.MouseClickMsg{X: 2 + buttons[0].rect.x, Y: g.meterY + buttons[0].rect.y, Button: tea.MouseLeft}) + if cmd == nil || next.(Model).actionReview != nil { + t.Fatal("visible review confirmation was not clickable") + } + cmd() + if len(client.answers) != 1 { + t.Fatal("reviewed draft was not submitted") + } + } + } +} + +func TestStrictTriggerDeletionCanBeCancelled(t *testing.T) { + m, _ := scheduledTestModel(t) + m.SetConfirmationMode(confirmation.Require) + m.triggerAction("ctrl+d") + if m.actionReview == nil || len(m.scheduleUI.queue.List("root-one")) != 1 { + t.Fatal("trigger deletion bypassed review") + } + next, _ := m.Update(specialKey(tea.KeyEscape)) + m = next.(Model) + if m.actionReview != nil || len(m.scheduleUI.queue.List("root-one")) != 1 { + t.Fatal("cancel deleted trigger") + } + m.triggerAction("ctrl+d") + next, _ = m.Update(key('c')) + m = next.(Model) + if m.actionReview != nil || len(m.scheduleUI.queue.List("root-one")) != 0 { + t.Fatal("confirmed trigger deletion failed") + } +} + +func TestBalancedOneTimeApprovalDoesNotReserveStrictButtonWidths(t *testing.T) { + m := approvalTestModel() + m.SetConfirmationMode(confirmation.Balanced) + options := m.monitorSessionData[0].preview.ApprovalOptions + m.monitorSessionData[0].preview.ApprovalOptions = [8]codex.ApprovalOption{options[0], options[2]} + if len(m.monitorApprovalButtons(36, 14)) != 2 { + t.Fatal("immediate approval buttons were hidden by unused confirmation widths") + } +} + +func TestStrictBenchmarkScopeShowsConfirmationAtEveryLabelSize(t *testing.T) { + plan := codex.BenchmarkPlan{Models: []codex.BenchmarkModelOption{{Model: "model", DisplayName: "Model", Efforts: []string{"high"}}}, Efforts: []string{"high"}, Games: []string{"P-1"}} + client := codex.Client{DigBenchToken: "synthetic", DigBenchGames: plan.Games} + for _, suite := range []int{0, 1, 2} { + m := Model{width: 160, height: 40, meterView: viewBenchmark, benchmarkRunner: client, benchmarkScopedRunner: client, benchmarkPlan: plan, benchmarkScope: plan.AllScope(), benchmarkCombinations: 1, benchmarkSelectedSuite: suite} + m.SetConfirmationMode(confirmation.Require) + next, cmd := m.Update(key('b')) + m = next.(Model) + if cmd == nil || !m.benchmarkSelectedArmed || m.benchmarkState == benchmarkRunning { + t.Fatal("first press did not exclusively arm review", suite) + } + for _, width := range []int{200, 36, 18} { + found := false + for _, row := range m.benchmarkControlLines(width) { + for _, segment := range row { + if segment.button != footerButtonBenchmarkSelected { + continue + } + found = true + if !strings.Contains(segment.text, "CONFIRM") && !strings.Contains(segment.text, "?") { + t.Fatal("armed scope still looks like immediate launch", suite, width, segment.text) + } + if width == 200 { + unit := "TURNS" + if suite == 2 { + unit = "REMOTE SESSIONS" + } + if !strings.Contains(segment.text, unit) { + t.Fatal("wrong launch unit", segment.text) + } + } + } + } + if !found { + t.Fatal("confirmation control disappeared", suite, width) + } + } + next, cmd = m.Update(key('b')) + if cmd == nil || next.(Model).benchmarkSelectedArmed || next.(Model).benchmarkState != benchmarkRunning { + t.Fatal("explicit second press did not launch", suite) + } + } +} + +func TestStrictChildQuestionDisplaysItsActualDestination(t *testing.T) { + m, client := promptTestModel() + client.offer.ThreadID = "child-worker" + client.offer.Questions = []codex.PromptQuestion{{Text: "Question", FreeText: true}} + row := &m.monitorSessionData[0] + row.preview.Kind = codex.SessionContextQuestion + row.preview.ThreadID = client.offer.ThreadID + row.preview.InputToken = client.offer.Token + m.SetConfirmationMode(confirmation.Require) + m.focusMonitorPrompt() + m.monitorPrompt.input.SetValue("Answer for the child") + m, cmd, _ := m.submitMonitorPrompt() + if cmd != nil || m.actionReview == nil || m.actionReview.target != "root-one" || m.actionReview.destination != "child-worker" { + t.Fatal("review confused the visible row and action destination") + } + g := m.monitorDashboardLayout() + shown := ansi.Strip(m.renderActionReview(g.contentWidth, g.meterHeight, paletteFor(m.theme))) + if !strings.Contains(shown, "child-worker") || strings.Contains(shown, "root-one") { + t.Fatal("review displays the wrong answer destination", shown) + } + next, cmd := m.Update(key('c')) + if cmd == nil || next.(Model).actionReview != nil { + t.Fatal("child answer could not be confirmed") + } + cmd() + if len(client.answers) != 1 || client.answers[0] != "Answer for the child" { + t.Fatal("review altered the answer") + } +} + +func TestStrictProfileSkipConfirmsTheClickedPartialRow(t *testing.T) { + for _, mode := range []int{contextSplit, contextWide} { + for _, target := range []string{"one", "two"} { + m, client := profileTestModel(t) + m.width, m.height = 240, 80 + m.SetConfirmationMode(confirmation.Require) + m.setRowContext("one", mode) + presentation := m.monitorContextTarget() + clicked := false + for _, pane := range m.monitorPartialContextPanes() { + if pane.session.id != target { + continue + } + buttons := m.profileButtons(pane.frame.width, pane.frame.height, pane.session) + if len(buttons) != 2 { + t.Fatal("profile review does not fit fixture") + } + b := buttons[1] + _, _, cy := monitorContextBodyLayout(pane.frame.height, buttons[len(buttons)-1].y+1) + g := m.monitorDashboardLayout() + next, _ := m.Update(tea.MouseClickMsg{X: 4 + pane.frame.x + b.x, Y: g.meterY + pane.frame.y + cy + b.y, Button: tea.MouseLeft}) + m = next.(Model) + clicked = true + break + } + if !clicked || m.actionReview == nil || m.actionReview.target != presentation || m.actionReview.destination != target || len(m.quotaCandidates()) != 2 { + t.Fatal("click did not review the intended profile", mode, target) + } + next, cmd := m.Update(key('c')) + m = next.(Model) + if cmd != nil || m.actionReview != nil || client.updates != 0 { + t.Fatal("Skip wrote settings or failed to finish review", mode, target) + } + candidates := m.quotaCandidates() + if len(candidates) != 1 || candidates[0].ID == target { + t.Fatal("Skip did not preserve the clicked session ID", mode, target, candidates) + } + } + } +} diff --git a/internal/ui/confirmations.go b/internal/ui/confirmations.go index b2e5d4a6..eae45f98 100644 --- a/internal/ui/confirmations.go +++ b/internal/ui/confirmations.go @@ -2,8 +2,8 @@ package ui import "github.com/merefield/codexometer/internal/confirmation" -// SetNoConfirm applies only to this launch, never to saved display preferences. -// Quota-reset redemption remains guarded regardless of this setting. -func (m *Model) SetNoConfirm(value bool) { - m.confirmations = confirmation.Policy{NoConfirm: value} +// SetConfirmationMode applies only to this launch, never to saved preferences. +// Quota-reset redemption remains guarded in every mode. +func (m *Model) SetConfirmationMode(mode confirmation.Mode) { + m.confirmations = confirmation.Policy{Mode: mode} } diff --git a/internal/ui/confirmations_test.go b/internal/ui/confirmations_test.go index c5e6a26a..d35a4c88 100644 --- a/internal/ui/confirmations_test.go +++ b/internal/ui/confirmations_test.go @@ -6,11 +6,12 @@ import ( tea "charm.land/bubbletea/v2" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" ) -func TestNoConfirmQueueDeletionStillTargetsTheSelectedItem(t *testing.T) { +func TestConfirmationNoneQueueDeletionStillTargetsTheSelectedItem(t *testing.T) { m, client := queueTestModel(false) - m.SetNoConfirm(true) + m.SetConfirmationMode(confirmation.None) cmd := m.openQueueItem(0, true) if cmd == nil || client.changed != "" { t.Fatal("deletion was not an explicit one-shot command") @@ -21,9 +22,9 @@ func TestNoConfirmQueueDeletionStillTargetsTheSelectedItem(t *testing.T) { } } -func TestNoConfirmProfileSelectionDoesNotApplyOtherSessions(t *testing.T) { +func TestConfirmationNoneProfileSelectionDoesNotApplyOtherSessions(t *testing.T) { m, client := profileTestModel(t) - m.SetNoConfirm(true) + m.SetConfirmationMode(confirmation.None) m, cmd, _ := m.updateProfileKey("1") if cmd == nil || client.updates != 0 { t.Fatal("explicit profile action was not queued exactly once") @@ -35,9 +36,9 @@ func TestNoConfirmProfileSelectionDoesNotApplyOtherSessions(t *testing.T) { } } -func TestNoConfirmSendNowRetainsDispatchGuards(t *testing.T) { +func TestConfirmationNoneSendNowRetainsDispatchGuards(t *testing.T) { m, client := scheduledTestModel(t) - m.SetNoConfirm(true) + m.SetConfirmationMode(confirmation.None) cmd := m.triggerAction("ctrl+n") if cmd == nil { t.Fatal("Send now still required a second confirmation") @@ -48,10 +49,10 @@ func TestNoConfirmSendNowRetainsDispatchGuards(t *testing.T) { } } -func TestNoConfirmRunAllRequiresAnExplicitLaunch(t *testing.T) { +func TestConfirmationNoneRunAllRequiresAnExplicitLaunch(t *testing.T) { tasks := make(chan []codex.BenchmarkTaskID, 1) m := New(benchmarkCaptureFetcher{stubFetcher: stubFetcher{snapshot: codex.DemoSnapshot()}, tasks: tasks}, time.Minute) - m.SetNoConfirm(true) + m.SetConfirmationMode(confirmation.None) m.snapshot, m.loading, m.meterView, m.benchmarkCombinations = codex.DemoSnapshot(), false, viewBenchmark, 1 m, cmd := m.activateFooterButton(footerButtonBenchmarkAll) if cmd == nil || m.benchmarkState != benchmarkRunning || m.benchmarkAllArmed { @@ -64,9 +65,9 @@ func TestNoConfirmRunAllRequiresAnExplicitLaunch(t *testing.T) { } } -func TestNoConfirmDoesNotTurnComposerTypingIntoAnApproval(t *testing.T) { +func TestConfirmationNoneDoesNotTurnComposerTypingIntoAnApproval(t *testing.T) { m := approvalTestModel() - m.SetNoConfirm(true) + m.SetConfirmationMode(confirmation.None) m.monitorPrompt = monitorPromptState{session: "root-one", offer: codex.SessionPromptOffer{Token: "previous", TurnID: "turn"}, input: newMonitorEditor()} m.monitorPrompt.input.SetValue("Keep my draft") m.monitorPrompt.input.Focus() @@ -75,3 +76,10 @@ func TestNoConfirmDoesNotTurnComposerTypingIntoAnApproval(t *testing.T) { t.Fatal("typing during a composer/approval transition granted permission") } } + +func testConfirmationMode(none bool) confirmation.Mode { + if none { + return confirmation.None + } + return confirmation.Balanced +} diff --git a/internal/ui/localisation_test.go b/internal/ui/localisation_test.go index 6dd4d8c0..efe57a73 100644 --- a/internal/ui/localisation_test.go +++ b/internal/ui/localisation_test.go @@ -91,6 +91,7 @@ func TestLocalisedScreensHelper(t *testing.T) { t.Run("monitor_pill_selection", TestMonitorSelectedPillMarkersPreserveLayout) t.Run("monitor_context_surfaces", TestMonitorContextResponsiveHitTargets) t.Run("monitor_history_surfaces", TestMonitorHistoryRenderedControlsAndLiveApproval) + t.Run("strict_action_review_surfaces", TestStrictReviewKeepsMouseControlsVisibleWithLongDrafts) t.Run("monitor_privacy_surfaces", TestMonitorContextPrivacyAndDismissRenderedTargets) t.Run("monitor_approval_surfaces", TestMonitorApprovalRenderedTargets) t.Run("monitor_expanded_surfaces", TestExpandedContextResponsiveHitTargets) diff --git a/internal/ui/model.go b/internal/ui/model.go index b5265bb2..c1f0b8f1 100644 --- a/internal/ui/model.go +++ b/internal/ui/model.go @@ -178,6 +178,7 @@ type Model struct { benchmarkQuotaAccounting benchmarkQuotaAccounting confirmations confirmation.Policy + actionReview *monitorActionReview monitorState monitorState monitorAutoStart bool monitorStartedAt time.Time @@ -480,25 +481,17 @@ func (m Model) Init() tea.Cmd { } func (m Model) update(message tea.Msg) (tea.Model, tea.Cmd) { - if next, cmd, handled := m.updateStartup(message); handled { - return next, cmd - } else { - m = next - } - if next, cmd, handled := m.updateMonitorHistory(message); handled { - return next, cmd - } else { - m = next - } - if next, cmd, handled := m.updateMonitorSuggestions(message); handled { - return next, cmd - } else { - m = next - } - if next, cmd, handled := m.updateMonitorCommands(message); handled { - return next, cmd - } else { + // Priority handlers run before editor updates; each carries the resulting + // immutable model forward even when it does not consume the message. + for _, update := range []func(Model, tea.Msg) (Model, tea.Cmd, bool){ + Model.updateStartup, Model.updateActionReview, Model.updateMonitorHistory, + Model.updateMonitorSuggestions, Model.updateMonitorCommands, + } { + next, cmd, handled := update(m, message) m = next + if handled { + return m, cmd + } } colors := paletteFor(m.theme) m.monitorPrompt.input.style(colors) @@ -1479,11 +1472,9 @@ func (m Model) activateFooterButton(button footerButtonID) (Model, tea.Cmd) { case footerButtonBenchmarkSelected: if m.meterView == viewBenchmark && m.benchmarkCanRunSelected() { tasks := m.benchmarkScopedTasks() - if m.benchmarkSelectedSuiteExternal() && !m.benchmarkSelectedArmed && !m.confirmations.NoConfirm { - m.benchmarkSelectedArmed = true - m.benchmarkConfirmSequence++ - sequence := m.benchmarkConfirmSequence - return m, tea.Tick(5*time.Second, func(time.Time) tea.Msg { return benchmarkConfirmExpiredMsg{sequence: sequence} }) + if !m.benchmarkSelectedArmed && m.confirmations.Required(confirmation.Command(!m.benchmarkSelectedSuiteExternal())) { + cmd := m.armBenchmarkLaunch(false) + return m, cmd } m.benchmarkSelectedArmed = false m.benchmarkAllArmed = false @@ -1497,11 +1488,9 @@ func (m Model) activateFooterButton(button footerButtonID) (Model, tea.Cmd) { allCombinations = m.benchmarkCombinations } if m.meterView == viewBenchmark && benchmarkRunAllAvailable(m.benchmarkRunActive(), allCombinations, len(tasks)) { - if !m.benchmarkAllArmed && !m.confirmations.NoConfirm { - m.benchmarkAllArmed = true - m.benchmarkConfirmSequence++ - sequence := m.benchmarkConfirmSequence - return m, tea.Tick(5*time.Second, func(time.Time) tea.Msg { return benchmarkConfirmExpiredMsg{sequence: sequence} }) + if !m.benchmarkAllArmed && m.confirmations.Required(confirmation.Guarded) { + cmd := m.armBenchmarkLaunch(true) + return m, cmd } m.benchmarkAllArmed = false return m.startBenchmark(tasks, allScope, true) diff --git a/internal/ui/monitor.go b/internal/ui/monitor.go index f56d18e2..b568b12a 100644 --- a/internal/ui/monitor.go +++ b/internal/ui/monitor.go @@ -80,6 +80,9 @@ func layoutMonitorArea(width, height int) monitorGeometry { } func (m Model) renderMonitorArea(width, height int, colors palette) monitorView { + if m.actionReview != nil { + return monitorView{view: m.renderActionReview(width, height, colors)} + } if m.monitorContextDetail != "" && !m.contextTargetHidden() { summary, rows, buttons := m.monitorDetailHeader(width, height) var parts []string diff --git a/internal/ui/monitor_approval.go b/internal/ui/monitor_approval.go index 1a5b533c..6bb8008b 100644 --- a/internal/ui/monitor_approval.go +++ b/internal/ui/monitor_approval.go @@ -9,6 +9,7 @@ import ( tea "charm.land/bubbletea/v2" "charm.land/lipgloss/v2" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" "github.com/merefield/codexometer/internal/i18n" ) @@ -119,6 +120,9 @@ func approvalShortcutLabel(kind string, confirm bool, index int) string { if label == "" { return "" } + if confirm && (kind == "decline" || kind == "cancel") { + return i18n.Text("[ C CONFIRM ]") + " " + label + } shortcut := strconv.Itoa(index + 1) if confirm { shortcut = "C" @@ -152,7 +156,10 @@ func (m Model) monitorApprovalButtons(width, height int) []monitorApprovalButton continue } label := m.approvalButtonLabel(option.Kind, false, i) - slot := max(lipgloss.Width(label), lipgloss.Width(m.approvalButtonLabel(option.Kind, true, i))) + slot := lipgloss.Width(label) + if m.confirmations.Required(confirmation.Approval(option.Kind)) { + slot = max(slot, lipgloss.Width(m.approvalButtonLabel(option.Kind, true, i))) + } if slot > width-4 || label == "" { return nil } @@ -291,7 +298,7 @@ func (m Model) monitorApprovalAction(action string) (Model, tea.Cmd, bool) { if option.Kind == "" { return m, nil, true } - if option.GrantsPermission() && !m.confirmations.NoConfirm && !m.approvalConfirmationActive(token, action) { + if m.confirmations.Required(confirmation.Approval(option.Kind)) && !m.approvalConfirmationActive(token, action) { m.monitorApprovalConfirm = token + "/" + action m.monitorApprovalConfirmUntil = time.Now().Add(monitorApprovalConfirmDuration) m.monitorApprovalNumberReleased = false diff --git a/internal/ui/monitor_approval_test.go b/internal/ui/monitor_approval_test.go index dd5f5fca..1db919ab 100644 --- a/internal/ui/monitor_approval_test.go +++ b/internal/ui/monitor_approval_test.go @@ -12,6 +12,7 @@ import ( "charm.land/lipgloss/v2" "github.com/charmbracelet/x/ansi" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" "github.com/merefield/codexometer/internal/i18n" ) @@ -66,6 +67,7 @@ func (c *approvalTestClient) RespondSessionApproval(_ context.Context, token, de func approvalTestModel() Model { m := contextTestModel() + m.SetConfirmationMode(confirmation.Require) m.fetcher = &approvalTestClient{token: "live"} m.monitorSessionData[0].preview = codex.SessionContext{Kind: codex.SessionContextApproval, Text: "Command: git push\nDirectory: /work", Source: "LIVE", ApprovalToken: "live"} m.monitorSessionData[0].preview.ApprovalOptions = [8]codex.ApprovalOption{ @@ -75,10 +77,10 @@ func approvalTestModel() Model { return m } -func TestNoConfirmStillRequiresAnExplicitApprovalAndLiveCapability(t *testing.T) { +func TestConfirmationNoneStillRequiresAnExplicitApprovalAndLiveCapability(t *testing.T) { for _, stale := range []bool{false, true} { m := approvalTestModel() - m.SetNoConfirm(true) + m.SetConfirmationMode(confirmation.None) client := m.fetcher.(*approvalTestClient) if stale { client.token = "replacement" @@ -139,7 +141,7 @@ func TestMonitorApprovalRenderedTargets(t *testing.T) { } updated, cmd := m.Update(tea.MouseClickMsg(tea.Mouse{X: x, Y: y, Button: tea.MouseLeft})) u := updated.(Model) - if option.GrantsPermission() && !(confirmed && i == 0) { + if m.confirmations.Required(confirmation.Approval(option.Kind)) && !(confirmed && i == 0) { if cmd != nil || u.monitorApprovalConfirm != "live/"+action { t.Fatal("first click must only confirm") } @@ -214,6 +216,7 @@ func TestMonitorApprovalNumberSelectsCConfirms(t *testing.T) { } for _, index := range []int{1, 2} { m := approvalTestModel() + m.SetConfirmationMode(confirmation.Balanced) m, cmd, _ := m.updateMonitorContextKey(strconv.Itoa(index + 1)) if cmd == nil || !m.monitorApprovalBusy { t.Fatal("negative decision shortcut did not match its button") diff --git a/internal/ui/monitor_close_all.go b/internal/ui/monitor_close_all.go index 668b7cbe..9f68fedf 100644 --- a/internal/ui/monitor_close_all.go +++ b/internal/ui/monitor_close_all.go @@ -1,6 +1,7 @@ package ui import ( + "github.com/merefield/codexometer/internal/confirmation" "slices" "time" ) @@ -26,7 +27,7 @@ func (m *Model) clearMonitorCloseAllConfirmation() { } func (m *Model) requestMonitorCloseAll() { - if m.confirmations.NoConfirm || m.monitorCloseAllArmed() { + if !m.confirmations.Required(confirmation.Narrow) || m.monitorCloseAllArmed() { m.dismissAllMonitorSessions() return } diff --git a/internal/ui/monitor_close_all_test.go b/internal/ui/monitor_close_all_test.go index 94ee312b..76696d76 100644 --- a/internal/ui/monitor_close_all_test.go +++ b/internal/ui/monitor_close_all_test.go @@ -11,6 +11,7 @@ import ( "charm.land/lipgloss/v2" "github.com/charmbracelet/x/ansi" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" "github.com/merefield/codexometer/internal/i18n" ) @@ -27,6 +28,7 @@ func TestMonitorCloseAllDismissesOffScreenRowsAndPreservesMeasurement(t *testing monitorBaseline: 1200, monitorLatest: 1320, monitorSamples: []monitorSample{{Tokens: 120}}, } + m.SetConfirmationMode(confirmation.Require) m.startMonitorSessions(usage, now) for i := range usage.Sessions { usage.Sessions[i].TotalTokens = 110 @@ -113,6 +115,7 @@ func TestMonitorCloseAllRenderedControlAndEmptyList(t *testing.T) { func TestMonitorControlsHaveDistinctScopedShortcuts(t *testing.T) { for _, k := range []tea.KeyPressMsg{key('z'), key('Z')} { m := contextTestModel() + m.SetConfirmationMode(confirmation.Require) next, cmd := m.Update(k) m = next.(Model) if cmd == nil || m.monitorState != monitorResetting || m.flashedButton != footerButtonMonitorReset || m.visibleMonitorSessionCount() != 3 { @@ -121,6 +124,7 @@ func TestMonitorControlsHaveDistinctScopedShortcuts(t *testing.T) { } for _, k := range []tea.KeyPressMsg{key('s'), key('S')} { m := contextTestModel() + m.SetConfirmationMode(confirmation.Require) next, cmd := m.Update(k) m = next.(Model) if cmd != nil || m.monitorState != monitorRunning || m.flashedButton != footerButtonNone { @@ -129,6 +133,7 @@ func TestMonitorControlsHaveDistinctScopedShortcuts(t *testing.T) { } for _, k := range []tea.KeyPressMsg{key('o'), key('O')} { m := contextTestModel() + m.SetConfirmationMode(confirmation.Require) next, cmd := m.Update(k) m = next.(Model) if cmd == nil || !m.monitorCloseAllArmed() || m.visibleMonitorSessionCount() != 3 { @@ -141,6 +146,7 @@ func TestMonitorControlsHaveDistinctScopedShortcuts(t *testing.T) { } } m := contextTestModel() + m.SetConfirmationMode(confirmation.Require) m.monitorSelectedID = "root-one" next, _ := m.Update(key('x')) m = next.(Model) @@ -148,6 +154,7 @@ func TestMonitorControlsHaveDistinctScopedShortcuts(t *testing.T) { t.Fatal("plain x no longer closes only the selected row") } m = contextTestModel() + m.SetConfirmationMode(confirmation.Require) m.requestMonitorCloseAll() repeated := key('o') repeated.IsRepeat = true @@ -157,6 +164,7 @@ func TestMonitorControlsHaveDistinctScopedShortcuts(t *testing.T) { t.Fatal("repeated O confirmed Close All") } m = contextTestModel() + m.SetConfirmationMode(confirmation.Require) m.meterView = viewBars for _, k := range []tea.KeyPressMsg{key('z'), key('o')} { next, cmd = m.Update(k) @@ -169,6 +177,7 @@ func TestMonitorControlsHaveDistinctScopedShortcuts(t *testing.T) { func TestMonitorControlShortcutsTypeNormallyInComposer(t *testing.T) { m, _ := inlinePromptTestModel() + m.SetConfirmationMode(confirmation.Require) m, _ = promptKey(m, tea.KeyEnter, "") if !m.monitorPrompt.input.Focused() { t.Fatal("inline composer did not focus") @@ -185,6 +194,7 @@ func TestMonitorControlShortcutsTypeNormallyInComposer(t *testing.T) { func TestMonitorCompactControlsKeepShortcutHints(t *testing.T) { for _, size := range []struct{ w, h int }{{40, 16}, {80, 24}, {120, 40}} { m := contextTestModel() + m.SetConfirmationMode(confirmation.Require) m.width, m.height = size.w, size.h g := m.monitorDashboardLayout() a := m.monitorArea(g.contentWidth, g.meterHeight) @@ -211,6 +221,7 @@ func TestMonitorCompactControlsKeepShortcutHints(t *testing.T) { func TestMonitorCloseAllConfirmationCancelExpiryAndChangedRows(t *testing.T) { m := contextTestModel() + m.SetConfirmationMode(confirmation.Require) m.requestMonitorCloseAll() next, cmd := m.Update(specialKey(tea.KeyEscape)) m = next.(Model) @@ -236,6 +247,7 @@ func TestMonitorCloseAllConfirmationCancelExpiryAndChangedRows(t *testing.T) { t.Fatal("Zero retained the armed Close All") } m = contextTestModel() + m.SetConfirmationMode(confirmation.Require) m.requestMonitorCloseAll() next, _ = m.pressViewTab(viewBars) m = next.(Model) @@ -246,6 +258,7 @@ func TestMonitorCloseAllConfirmationCancelExpiryAndChangedRows(t *testing.T) { func TestMonitorCloseAllArmingShowsConfirmationAndReleasesTypingFocus(t *testing.T) { m, _ := inlinePromptTestModel() + m.SetConfirmationMode(confirmation.Require) m, _ = promptKey(m, tea.KeyEnter, "") m.monitorPrompt.input.SetValue("draft") m.requestMonitorCloseAll() diff --git a/internal/ui/monitor_commands.go b/internal/ui/monitor_commands.go index 8572ddb6..cd7ee350 100644 --- a/internal/ui/monitor_commands.go +++ b/internal/ui/monitor_commands.go @@ -523,7 +523,7 @@ func (m Model) commandFooter(width int) []commandDisplayRow { var buttons []commandDisplayRow if p.menu.Input && !p.busy && p.notice == "" && strings.TrimSpace(p.input.Value()) != "" { label := "[ ENTER REVIEW ]" - if p.menu.ReversibleInput || m.confirmations.NoConfirm { + if !m.confirmations.Required(confirmation.Command(p.menu.ReversibleInput)) { label = "[ ENTER APPLY ]" } buttons = append(buttons, commandDisplayRow{text: i18n.Text(label), action: "review"}) diff --git a/internal/ui/monitor_commands_interaction_test.go b/internal/ui/monitor_commands_interaction_test.go index bd1fe178..b469cc98 100644 --- a/internal/ui/monitor_commands_interaction_test.go +++ b/internal/ui/monitor_commands_interaction_test.go @@ -7,6 +7,7 @@ import ( "charm.land/bubbles/v2/textinput" tea "charm.land/bubbletea/v2" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" ) func TestMonitorPickerClicksRespectConfirmationPolicy(t *testing.T) { @@ -17,7 +18,7 @@ func TestMonitorPickerClicksRespectConfirmationPolicy(t *testing.T) { t.Run(fmt.Sprintf("inline=%t/width=%d/reversible=%t/noConfirm=%t", inline, width, reversible, noConfirm), func(t *testing.T) { m, f := speedCommandTestModel(t) m.width = width - m.SetNoConfirm(noConfirm) + m.SetConfirmationMode(testConfirmationMode(noConfirm)) m.monitorCommands.menu.Choices[0].Reversible = reversible if inline { m.monitorCommands.inline = true @@ -109,7 +110,7 @@ func TestMonitorCommandRightRepeatKeepsTextCursorMovement(t *testing.T) { func TestMonitorCommandRepeatGuardsOnlySubmissionKeys(t *testing.T) { m, f := commandTestModel(t) - m.SetNoConfirm(true) + m.SetConfirmationMode(confirmation.None) for _, code := range []rune{tea.KeyEnter, tea.KeyRight} { next, cmd := m.Update(tea.KeyPressMsg{Code: code, IsRepeat: true}) m = next.(Model) diff --git a/internal/ui/monitor_commands_test.go b/internal/ui/monitor_commands_test.go index 9fadb747..2de18933 100644 --- a/internal/ui/monitor_commands_test.go +++ b/internal/ui/monitor_commands_test.go @@ -17,6 +17,7 @@ import ( uv "github.com/charmbracelet/ultraviolet" "github.com/charmbracelet/x/ansi" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" "github.com/merefield/codexometer/internal/i18n" ) @@ -51,7 +52,7 @@ func TestMonitorCommandsApplyReversibleChoicesWithoutExtraConfirmation(t *testin for _, noConfirm := range []bool{false, true} { for _, reversible := range []bool{false, true} { m, f := commandTestModel(t) - m.SetNoConfirm(noConfirm) + m.SetConfirmationMode(testConfirmationMode(noConfirm)) m.monitorCommands.menu.Choices[0].Reversible = reversible m.monitorPrompt.input.SetValue("keep draft") next, cmd, _ := m.chooseMonitorCommand() @@ -72,10 +73,10 @@ func TestMonitorCommandsApplyReversibleChoicesWithoutExtraConfirmation(t *testin } } -func TestNoConfirmDoesNotApplyUnavailableOrHiddenCommands(t *testing.T) { +func TestConfirmationNoneDoesNotApplyUnavailableOrHiddenCommands(t *testing.T) { for _, blocked := range []string{"unavailable", "tiny", "busy", "notice", "closed"} { m, f := commandTestModel(t) - m.SetNoConfirm(true) + m.SetConfirmationMode(confirmation.None) switch blocked { case "unavailable": m.monitorCommands.menu.Choices[0].Unavailable = "Waiting for idle." diff --git a/internal/ui/monitor_filter_test.go b/internal/ui/monitor_filter_test.go index cebf4099..8b47862e 100644 --- a/internal/ui/monitor_filter_test.go +++ b/internal/ui/monitor_filter_test.go @@ -11,6 +11,7 @@ import ( "charm.land/lipgloss/v2" "github.com/charmbracelet/x/ansi" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" "github.com/merefield/codexometer/internal/i18n" ) @@ -287,6 +288,7 @@ func TestMonitorStatusFilterPreservesDraftAndApprovalAccess(t *testing.T) { func TestMonitorStatusFilterCloseAllAndPagingAreScoped(t *testing.T) { m := statusFilterTestModel() + m.SetConfirmationMode(confirmation.Require) for i := range 12 { m.monitorSessionData = append(m.monitorSessionData, monitorSession{id: fmt.Sprint("work-", i), displayed: true, working: true}) } diff --git a/internal/ui/monitor_history_test.go b/internal/ui/monitor_history_test.go index cbfb29ea..c807815b 100644 --- a/internal/ui/monitor_history_test.go +++ b/internal/ui/monitor_history_test.go @@ -13,6 +13,7 @@ import ( uv "github.com/charmbracelet/ultraviolet" "github.com/charmbracelet/x/ansi" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" "github.com/merefield/codexometer/internal/i18n" ) @@ -142,6 +143,7 @@ func TestMonitorHistoryRenderedControlsAndLiveApproval(t *testing.T) { m := historyTestModel() m.moveMonitorHistory(-1) live := approvalTestModel() + m.SetConfirmationMode(confirmation.Require) approval := live.monitorSessionData[0].preview m.fetcher = live.fetcher m.monitorSessionData[0].preview = approval diff --git a/internal/ui/monitor_profile.go b/internal/ui/monitor_profile.go index aec6b733..a2093878 100644 --- a/internal/ui/monitor_profile.go +++ b/internal/ui/monitor_profile.go @@ -246,6 +246,9 @@ func (m Model) profileAction(action string, confirm bool) (Model, tea.Cmd, bool) return m, nil, true } if skip { + if m.reviewMonitorAction("profile-skip", id, i18n.Text("QUOTA THRESHOLD"), i18n.Text("[ (2) SKIP ]"), []any{id, m.quotaStepPending, m.quotaStepWindow}) { + return m, nil, true + } m.declineQuotaSession(id) return m, nil, true } diff --git a/internal/ui/monitor_prompt.go b/internal/ui/monitor_prompt.go index af8e50bd..da453e23 100644 --- a/internal/ui/monitor_prompt.go +++ b/internal/ui/monitor_prompt.go @@ -10,6 +10,7 @@ import ( tea "charm.land/bubbletea/v2" "github.com/charmbracelet/x/ansi" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" "github.com/merefield/codexometer/internal/i18n" ) @@ -362,7 +363,7 @@ func (m Model) updateMonitorPrompt(msg tea.Msg) (Model, tea.Cmd, bool) { *p = monitorPromptState{session: p.session} m.monitorApprovalConfirm = "" m.monitorApprovalNumberReleased = false - if m.confirmations.NoConfirm { + if !m.confirmations.Required(confirmation.Approval(s.preview.ApprovalOptions[index].Kind)) { // Losing composer focus must never reinterpret typing // as an immediate grant, even with fewer UI prompts. return m, nil, true @@ -482,6 +483,9 @@ func (m Model) submitMonitorTurn(action string) (Model, tea.Cmd, bool) { if !ok || p.busy || o.Token == "" || o.Token != p.offer.Token || o.TurnID == "" || action != "interrupt" && text == "" { return m, nil, true } + if m.reviewPromptAction(action, o.ThreadID, []any{o.Token, o.TurnID, action, text}, text) { + return m, nil, true + } p.busy, p.notice = true, "" session := p.session steer := monitorSteerReceipt{session: session, thread: o.ThreadID, turn: o.TurnID, text: codex.SanitizeSessionContext(text), sentAt: time.Now()} @@ -534,6 +538,15 @@ func (m Model) submitMonitorPrompt() (Model, tea.Cmd, bool) { return m, nil, true } answers := append([]string(nil), p.answers[:p.question+1]...) + display := append([]string(nil), answers...) + for i, question := range p.offer.Questions { + if i < len(display) && question.Secret { + display[i] = "••••" + } + } + if m.reviewPromptAction("reply", p.offer.ThreadID, []any{p.offer.Token, p.answers}, strings.Join(display, "\n")) { + return m, nil, true + } token, session := p.offer.Token, p.session p.busy = true m.monitorDetailSent = detailSentState{} diff --git a/internal/ui/monitor_queue.go b/internal/ui/monitor_queue.go index 637f9285..0077c7a5 100644 --- a/internal/ui/monitor_queue.go +++ b/internal/ui/monitor_queue.go @@ -10,6 +10,7 @@ import ( tea "charm.land/bubbletea/v2" "github.com/charmbracelet/x/ansi" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" "github.com/merefield/codexometer/internal/i18n" "github.com/merefield/codexometer/internal/schedule" ) @@ -380,7 +381,7 @@ func (m *Model) openQueueItem(index int, remove bool) tea.Cmd { q.input, _ = m.queueEditorLayout(g.contentWidth, g.meterHeight) m.monitorPrompt.input.Blur() if remove { - if m.confirmations.NoConfirm { + if !m.confirmations.Required(confirmation.Guarded) { next, cmd, _ := m.changeQueueItem() *m = next return cmd @@ -674,6 +675,9 @@ func (m Model) changeQueueItem() (Model, tea.Cmd, bool) { q.notice = i18n.Text("Enlarge the terminal before confirming.") return m, nil, true } + if !q.deleting && m.reviewMonitorAction("queue-edit", q.session, i18n.Text("EDIT QUEUED MESSAGE"), text, []any{q.session, q.item, text}) { + return m, nil, true + } q.busy = true id, item, remove := q.session, q.item, q.deleting return m, func() tea.Msg { diff --git a/internal/ui/monitor_read.go b/internal/ui/monitor_read.go index b63c538d..15a95a48 100644 --- a/internal/ui/monitor_read.go +++ b/internal/ui/monitor_read.go @@ -63,7 +63,7 @@ func (m *Model) acknowledgeMonitorResult() tea.Cmd { id := m.monitorReadIntent m.monitorReadIntent = "" client, ok := m.fetcher.(codex.SessionReadStateClient) - if !ok || id == "" || m.monitorReadBusy || m.meterView != viewMonitor || m.monitorState != monitorRunning || m.monitorError != "" || m.monitorCommands.open || m.monitorQueue.open || m.scheduleUI.open || m.rowContextMode(id) == contextGraph { + if !ok || id == "" || m.actionReview != nil || m.monitorReadBusy || m.meterView != viewMonitor || m.monitorState != monitorRunning || m.monitorError != "" || m.monitorCommands.open || m.monitorQueue.open || m.scheduleUI.open || m.rowContextMode(id) == contextGraph { return nil } for _, row := range m.monitorSessionData { diff --git a/internal/ui/monitor_schedule_panel.go b/internal/ui/monitor_schedule_panel.go index 7e547d55..e2c6fd46 100644 --- a/internal/ui/monitor_schedule_panel.go +++ b/internal/ui/monitor_schedule_panel.go @@ -8,6 +8,7 @@ import ( tea "charm.land/bubbletea/v2" "github.com/charmbracelet/x/ansi" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" "github.com/merefield/codexometer/internal/i18n" "github.com/merefield/codexometer/internal/schedule" ) @@ -159,6 +160,9 @@ func (m *Model) triggerAction(key string) tea.Cmd { case "esc": p.confirmID = "" case "ctrl+d": + if m.reviewMonitorAction("trigger-delete", j.Session, i18n.Text("TRIGGER SET"), j.Text, j) { + return nil + } if err := p.queue.Cancel(j.Session, j.ID); err != nil { p.notice = err.Error() } else { @@ -171,7 +175,7 @@ func (m *Model) triggerAction(key string) tea.Cmd { p.confirmToken = m.monitorPromptOffer().Token p.confirmUntil = time.Now().Add(20 * time.Second) p.notice = "" - if m.confirmations.NoConfirm { + if !m.confirmations.Required(confirmation.Guarded) { return m.triggerAction("ctrl+y") } } diff --git a/internal/ui/quota_reset_test.go b/internal/ui/quota_reset_test.go index 08e73c94..3eed7dbd 100644 --- a/internal/ui/quota_reset_test.go +++ b/internal/ui/quota_reset_test.go @@ -11,6 +11,7 @@ import ( "charm.land/lipgloss/v2" "github.com/charmbracelet/x/ansi" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" ) type resetFake struct { @@ -32,13 +33,13 @@ func resetModel() (Model, *resetFake) { return m, f } -func TestNoConfirmNeverBypassesQuotaResetConfirmation(t *testing.T) { +func TestConfirmationNoneNeverBypassesQuotaResetConfirmation(t *testing.T) { m, f := resetModel() - m.SetNoConfirm(true) + m.SetConfirmationMode(confirmation.None) n, cmd := m.pressQuotaReset() m = n.(Model) if cmd != nil || len(f.keys) != 0 || m.resetConfirmUntil.IsZero() { - t.Fatal("--no-confirm bypassed the irreversible quota-reset confirmation") + t.Fatal("--confirmation none bypassed the irreversible quota-reset confirmation") } _, cmd = m.pressQuotaReset() if cmd == nil { diff --git a/internal/ui/quota_step_down.go b/internal/ui/quota_step_down.go index aef9df79..6b9ce606 100644 --- a/internal/ui/quota_step_down.go +++ b/internal/ui/quota_step_down.go @@ -9,6 +9,7 @@ import ( tea "charm.land/bubbletea/v2" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" "github.com/merefield/codexometer/internal/i18n" ) @@ -183,7 +184,7 @@ func (m Model) pressQuotaSession(id string, confirm bool) (Model, tea.Cmd) { return m, nil } m.resetConfirmUntil = time.Time{} - if m.confirmations.NoConfirm { + if !m.confirmations.Required(confirmation.Guarded) { return m.startQuotaUpdate(targets) } if !confirm { diff --git a/internal/web/control_commands_test.go b/internal/web/control_commands_test.go index 6a198d9c..e4afaf39 100644 --- a/internal/web/control_commands_test.go +++ b/internal/web/control_commands_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" ) type commandsFake struct { @@ -100,9 +101,9 @@ func TestCommandConfirmationIsBoundAndSingleUse(t *testing.T) { } } -func TestNoConfirmDoesNotBypassServerCommandTickets(t *testing.T) { +func TestConfirmationNoneDoesNotBypassServerCommandTickets(t *testing.T) { s, _, token := controlServer(t) - s.store.state.NoConfirm = true + s.store.state.ConfirmationMode = confirmation.None f := &commandsFake{revision: "current"} s.control.commands = f b := actionRequest{Session: "parent", Command: &commandRequest{Mode: "commit", Path: "model", Revision: "current", Choice: "choice"}} diff --git a/internal/web/dist/assets/index-DDOErweg.js b/internal/web/dist/assets/index-DDOErweg.js new file mode 100644 index 00000000..5a8b4aba --- /dev/null +++ b/internal/web/dist/assets/index-DDOErweg.js @@ -0,0 +1,50 @@ +(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=Array.isArray,t=Array.prototype.indexOf,n=Array.prototype.includes,r=Array.from,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyDescriptors,s=Object.prototype,c=Array.prototype,l=Object.getPrototypeOf,u=Object.isExtensible;function d(e){return typeof e==`function`}var f=()=>{};function p(e){return e()}function m(e){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}function g(e,t,n=!1){return e===void 0?n?t():t:e}function _(e,t){if(Array.isArray(e))return e;if(t===void 0||!(Symbol.iterator in e))return Array.from(e);let n=[];for(let r of e)if(n.push(r),n.length===t)break;return n}var v=1024,y=2048,b=4096,x=8192,S=16384,C=32768,w=1<<25,T=65536,E=1<<19,D=1<<20,ee=1<<25,te=1<<21,O=1<<22,ne=1<<23,re=Symbol(`$state`),ie=Symbol(`component`),ae=Symbol(`legacy props`),oe=Symbol(``),se=Symbol(`attributes`),ce=Symbol(`class`),le=Symbol(`style`),ue=Symbol(`text`),de=Symbol(`form reset`),fe=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},pe=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`),me={},k=Symbol(`uninitialized`),he=`http://www.w3.org/1999/xhtml`;function ge(){console.warn(`https://svelte.dev/e/derived_inert`)}function _e(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function ve(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function ye(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var A=!1;function be(e){A=e}var j;function M(e){if(e===null)throw _e(),me;return j=e}function xe(){return M(sn(j))}function N(e){if(A){if(sn(j)!==null)throw _e(),me;j=e}}function Se(e=1){if(A){for(var t=e,n=j;t--;)n=sn(n);j=n}}function Ce(e=!0){for(var t=0,n=j;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else(r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=sn(n);e&&n.remove(),n=i}}function we(e){if(!e||e.nodeType!==8)throw _e(),me;return e.data}function Te(e){return e===this.v}function Ee(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function De(e){return!Ee(e,this.v)}function Oe(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function ke(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function Ae(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function je(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Me(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Ne(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Pe(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Fe(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Ie(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Le(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Re(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function ze(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var Be=!1;function Ve(){Be=!0}var He=null;function Ue(e){He=e}function We(e,t=!1,n){He={p:He,i:!1,c:null,e:null,s:e,x:null,r:W,l:Be&&!t?{s:null,u:null,$:[]}:null}}function Ge(e){var t=He,n=t.e;if(n!==null){t.e=null;for(var r of n)bn(r)}return e!==void 0&&(t.x=e),t.i=!0,He=t.p,Ke(e)}function Ke(e={}){return i(e,ie,{value:!0}),e}function qe(){return!Be||He!==null&&He.l===null}var Je=[];function Ye(){var e=Je;Je=[],m(e)}function Xe(e){if(Je.length===0&&!wt){var t=Je;queueMicrotask(()=>{t===Je&&Ye()})}Je.push(e)}function Ze(){for(;Je.length>0;)Ye()}var Qe=~(y|b|v);function $e(e,t){e.f=e.f&Qe|t}function et(e){e.f&512||e.deps===null?$e(e,v):$e(e,b)}function tt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),$e(e,v)}function nt(e){A&&on(e)!==null&&cn(e)}var rt=!1;function it(){rt||(rt=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[de]?.()})},{capture:!0}))}function at(e){var t=U,n=W;Wn(null),Gn(null);try{return e()}finally{Wn(t),Gn(n)}}function ot(e,t,n,r=n){e.addEventListener(t,()=>at(n));let i=e[de];e[de]=i?()=>{i(),r(!0)}:()=>r(!0),it()}function st(e,t,n,r){let i=qe()?dt:mt;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=W,c=ct(),l=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function u(e){if(!(s.f&16384)){c();try{r([...o,...e])}catch(e){pn(e,s)}lt()}}var d=ut();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>pt(e))).then(u).catch(e=>pn(e,s)).finally(d)}l?l.then(()=>{c(),f(),lt()}):f()}function ct(){var e=W,t=U,n=He,r=F;return function(i=!0){Gn(e),Wn(t),Ue(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function lt(e=!0){Gn(null),Wn(null),Ue(null),e&&F?.deactivate()}function ut(){var e=W,t=e.b,n=F,r=!!t?.is_rendered();return t?.update_pending_count(1,n),n.increment(r,e),()=>{t?.update_pending_count(-1,n),n.decrement(r,e)}}function dt(e){var t=2|y;return W!==null&&(W.f|=E),{ctx:He,deps:null,effects:null,equals:Te,f:t,fn:e,reactions:null,rv:0,v:k,wv:0,parent:W,ac:null}}var ft=Symbol(`obsolete`);function pt(e,t,n){let r=W;r===null&&ke();var i=void 0,a=Vt(k),o=!U,s=new Set;return wn(()=>{var t=W,n=h();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==fe&&n.reject(e)}).finally(lt)}catch(e){n.reject(e),lt()}var c=F;if(o){if(t.f&32768)var l=ut();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(ft);else for(let e of s.values())e.reject(ft);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==ft&&(c.activate(),t?(a.f|=ne,Gt(a,t)):(a.f&8388608&&(a.f^=ne),Gt(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),vn(()=>{for(let e of s)e.reject(ft)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function P(e){let t=dt(e);return qn(t),t}function mt(e){let t=dt(e);return t.equals=De,t}function ht(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(fe),t.ac=null}),t.fn!==null&&(t.teardown=f),cr(t,0),kn(t))}function yt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&lr(t)}var bt=null,F=null,xt=null,St=null,Ct=null,wt=!1,Tt=!1,Et=null,Dt=null,Ot=0,kt=1,At=class e{id=kt++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){bt===null?bt=this:(bt.#n=this,this.#t=bt),bt=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)$e(r,y),t(r);for(r of n.m)$e(r,b),t(r)}this.#p.add(e)}#g(){var e=[];for(let i of this.#c)if(!(i.f&16384||!(i.f&6144))){for(var t=i,n=!1;t.parent!==null;){t=t.parent;var r=t.f;if(r&96){if(!(r&1024)){n=!0;break}t.f^=v}}n||e.push(t)}return this.#c=[],e}#_(){this.#e=!0;for(let e of this.#u)this.#d.delete(e),$e(e,y),this.schedule(e);for(let e of this.#d)$e(e,b),this.schedule(e);this.apply();for(var t=Et=[],n=[],r=Dt=[];this.#c.length>0;){Ot++>1e3&&(this.#S(),Mt());for(let e of this.#g())try{this.#v(e,t,n)}catch(t){throw Lt(e),this.#h()||this.discard(),t}}if(F=null,r.length>0){var i=e.ensure();for(let e of r)i.schedule(e)}if(Et=null,Dt=null,this.#h()){this.#x(n),this.#x(t);for(let[e,t]of this.#f)It(e,t);r.length>0&&F.#_();return}let a=this.#y();if(a)this.#x(n),this.#x(t),a.#b(this);else{this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),xt=this,Pt(n),Pt(t),xt=null,this.#s?.resolve();var o=F;if(this.#a===0&&(this.#c.length===0||o!==null)&&this.#S(),this.#c.length>0){if(o!==null){for(let e of this.#c)o.#c.push(e);this.#c=[]}else o=this}o!==null&&(zt.clear(),o.#_())}}#v(e,t,n){e.f^=v;for(var r=e.first;r!==null;){var i=r.f,a=!!(i&96);if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=v:i&4?t.push(r):rr(r)&&(i&16&&this.#d.add(r),lr(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#y(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#b(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}e.async_deriveds.clear(),this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null&&!(e.f&2&&!(e.f&6144)))for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),$e(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),F=this,this.#_()}#x(e){for(var t=0;t{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=h()).promise}static ensure(){if(F===null){let t=F=new e;!Tt&&!wt&&Xe(()=>{t.#e||t.flush()})}return F}apply(){St=null}schedule(e){Ct=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)?e.b.defer_effect(e):this.#c.push(e)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?bt=e:t.#t=e,this.linked=!1}}};function jt(e){var t=wt;wt=!0;try{var n;for(e&&(F!==null&&!F.is_fork&&F.flush(),n=e());;){if(Ze(),F===null)return n;F.flush()}}finally{wt=t}}function Mt(){try{Pe()}catch(e){pn(e,Ct)}}var Nt=null;function Pt(e){var t=e.length;if(t!==0){for(var n=0;n0)){zt.clear();for(let e of Nt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Nt.has(n)&&(Nt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||lr(n)}}Nt.clear()}}Nt=null}}function Ft(e){F.schedule(e)}function It(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),$e(e,v);for(var n=e.first;n!==null;)It(n,t),n=n.next}}function Lt(e){$e(e,v);for(var t=e.first;t!==null;)Lt(t),t=t.next}var Rt=new Set,zt=new Map,Bt=!1;function Vt(e,t){return{f:0,v:e,reactions:null,equals:Te,rv:0,wv:0}}function I(e,t){let n=Vt(e,t);return qn(n),n}function Ht(e,t=!1,n=!0){let r=Vt(e);return t||(r.equals=De),Be&&n&&He!==null&&He.l!==null&&(He.l.s??=[]).push(r),r}function L(e,t,n=!1){return U!==null&&(!Un||U.f&131072)&&qe()&&U.f&4325394&&(Kn===null||!Kn.has(e))&&Re(),Gt(e,n?Xt(t):t,Dt)}var Ut=null,Wt=0;function Gt(e,t,n=null){if(!e.equals(t)){Vn?zt.set(e,t):zt.has(e)||zt.set(e,e.v);var r=At.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&>(t),St===null&&et(t)}e.wv=nr(),Ut=null,Wt=0,Yt(e,y,n),Ut=null,qe()&&W!==null&&W.f&1024&&!(W.f&96)&&(Xn===null?Zn([e]):Xn.push(e)),!r.is_fork&&Rt.size>0&&!Bt&&Kt()}return t}function Kt(){Bt=!1;for(let e of Rt){e.f&1024&&$e(e,b);let t;try{t=rr(e)}catch{t=!0}t&&lr(e)}Rt.clear()}function qt(e,t=1){var n=G(e),r=t===1?n++:n--;return L(e,n),r}function Jt(e){L(e,e.v+1)}function Yt(e,t,n){var r=e.reactions;if(r!==null){var i=qe(),a=r.length;if(Wt+=a,Wt>1e5&&Ut===null&&(Ut=new Set),Ut!==null){if(Ut.has(e))return;Ut.add(e)}for(var o=0;o{if(er===d)return e();var t=U,n=er;Wn(null),tr(d);var r=e();return Wn(t),tr(n),r};return i&&r.set(`length`,I(t.length,u)),new Proxy(t,{defineProperty(e,t,n){`value`in n&&n.configurable!==!1&&n.enumerable!==!1&&n.writable!==!1||Ie();var i=r.get(t);return i===void 0?f(()=>{var e=I(n.value,u);return r.set(t,e),e}):L(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>I(k,u));r.set(t,e),Jt(o)}}else L(n,k),Jt(o);return!0},get(e,n,i){if(n===re)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>I(Xt(s?e[n]:k),u)),r.set(n,o)),o!==void 0){var c=G(o);return c===k?void 0:c}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){this.has?.(e,t);var n=Reflect.getOwnPropertyDescriptor(e,t),i=r.get(t);if(i!==void 0){var a=G(i);if(a===k)return;if(n&&`value`in n)n.value=a;else return{enumerable:!0,configurable:!0,value:a,writable:!0}}return n},has(e,t){if(t===re)return!0;var n=r.get(t),i=n!==void 0&&n.v!==k||Reflect.has(e,t);return(n!==void 0||W!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>I(i?Xt(e[t]):k,u)),r.set(t,n)),G(n)===k)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dI(k,u)),r.set(d+``,p)):L(p,k)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>I(void 0,u)),L(c,Xt(n)),r.set(t,c));else{l=c.v!==k;var m=f(()=>Xt(n));L(c,m)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(s,n),!l){if(i&&typeof t==`string`){var g=r.get(`length`),_=Number(t);Number.isInteger(_)&&_>=g.v&&L(g,_+1)}Jt(o)}return!0},ownKeys(e){G(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==k});for(var[n,i]of r)i.v!==k&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Le()}})}function Zt(e){try{if(typeof e==`object`&&e&&re in e)return e[re]}catch{}return e}function Qt(e,t){return Object.is(Zt(e),Zt(t))}var $t,en,tn,nn;function rn(){if($t===void 0){$t=window,en=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;tn=a(t,`firstChild`).get,nn=a(t,`nextSibling`).get,u(e)&&(e[ce]=void 0,e[se]=null,e[le]=void 0,e.__e=void 0),u(n)&&(n[ue]=void 0)}}function an(e=``){return document.createTextNode(e)}function on(e){return tn.call(e)}function sn(e){return nn.call(e)}function R(e,t){if(!A)return on(e);var n=on(j);if(n===null)n=j.appendChild(an());else if(t&&n.nodeType!==3){var r=an();return n?.before(r),M(r),r}return t&&dn(n),M(n),n}function z(e,t=!1){if(!A){var n=on(e);return n instanceof Comment&&n.data===``?sn(n):n}if(t){if(j?.nodeType!==3){var r=an();return j?.before(r),M(r),r}dn(j)}return j}function B(e,t=!1){if(!A)return on(e);var n=R(e,t);return N(e),n}function V(e,t=1,n=!1){let r=A?j:e;for(var i;t--;)i=r,r=sn(r);if(!A)return r;if(n){if(r?.nodeType!==3){var a=an();return r===null?i?.after(a):r.before(a),M(a),a}dn(r)}return M(r),r}function cn(e){e.textContent=``}function ln(){return!1}function un(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function dn(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function fn(e){var t=W;if(t===null)return U.f|=ne,e;if(!(t.f&32768)&&!(t.f&4))throw e;pn(e,t)}function pn(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128&&!(t.f&33570816)){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}function mn(e){W===null&&(U===null&&Ne(e),Me()),Vn&&je(e)}function hn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function gn(e,t){var n=W;n!==null&&n.f&8192&&(e|=x);var r={ctx:He,deps:null,nodes:null,f:e|y|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};F?.register_created_effect(r);var i=r;if(e&4)Et===null?At.ensure().schedule(r):Et.push(r);else if(t!==null){try{lr(r)}catch(e){throw jn(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=T))}if(i!==null&&(i.parent=n,n!==null&&hn(i,n),U!==null&&U.f&2&&!(e&64))){var a=U;(a.effects??=[]).push(i)}return r}function _n(){return U!==null&&!Un}function vn(e){let t=gn(8,null);return $e(t,v),t.teardown=e,t}function yn(e){mn(`$effect`);var t=W.f;if(!U&&t&32&&He!==null&&!He.i){var n=He;(n.e??=[]).push(e)}else return bn(e)}function bn(e){return gn(4|D,e)}function xn(e){return mn(`$effect.pre`),gn(8|D,e)}function Sn(e){At.ensure();let t=gn(64|E,e);return(e={})=>new Promise(n=>{e.outro?Pn(t,()=>{jn(t),n(void 0)}):(jn(t),n(void 0))})}function Cn(e){return gn(4,e)}function wn(e){return gn(O|E,e)}function Tn(e,t=0){return gn(8|t,e)}function H(e,t=[],n=[],r=[]){st(r,t,n,t=>{gn(8,()=>{e(...t.map(G))})})}function En(e,t=0){return gn(16|t,e)}function Dn(e){return gn(32|E,e)}function On(e){var t=e.teardown;if(t!==null){let n=Vn,r=U;Hn(!0),Wn(null);try{t.call(null)}catch(t){pn(t,e.parent)}finally{Hn(n),Wn(r)}}}function kn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&at(()=>{e.abort(fe)});var r=n.next;n.f&64?n.parent=null:jn(n,t),n=r}}function An(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||jn(t),t=n}}function jn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Mn(e.nodes.start,e.nodes.end),n=!0),e.f|=w,kn(e,t&&!n),cr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();On(e),e.f^=w,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Nn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Mn(e,t){for(;e!==null;){var n=e===t?null:sn(e);e.remove(),e=n}}function Nn(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Pn(e,t,n=!0){var r=[];e.f|=256,Fn(e,r,!0);var i=()=>{n&&jn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Fn(e,t,n){if(!(e.f&8192)){e.f^=x;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=!!(i.f&65536)||!!(i.f&32)&&!!(e.f&16);Fn(i,t,o?n:!1)}i=a}}}function In(e){e.f&=-257,Ln(e,!0)}function Ln(e,t){if(!(e.f&256)&&e.f&8192){e.f^=x,e.f&1024||($e(e,y),At.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=!!(n.f&65536)||!!(n.f&32);Ln(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function Rn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:sn(n);t.append(n),n=i}}var zn=null,Bn=!1,Vn=!1;function Hn(e){Vn=e}var U=null,Un=!1;function Wn(e){U=e}var W=null;function Gn(e){W=e}var Kn=null;function qn(e){U!==null&&(U.f&2097152||U.f&2)&&(Kn??=new Set).add(e)}var Jn=null,Yn=0,Xn=null;function Zn(e){Xn=e}var Qn=1,$n=0,er=$n;function tr(e){er=e}function nr(){return++Qn}function rr(e){var t=e.f;if(t&2048)return!0;if(t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&St===null&&$e(e,v)}return!1}function ir(e,t,n=!0){var r=e.reactions;if(r!==null&&!(Kn!==null&&Kn.has(e)))for(var i=0;i{e.ac.abort(fe)}),e.ac=null);try{e.f|=te;var u=e.fn,d=u();e.f|=C;var f=or(e);if(qe()&&Xn!==null&&!Un&&f!==null&&!(e.f&6146))for(var p=0;p0)for(t.length=Yn+Jn.length,r=0;r{s.ac.abort(fe),s.ac=null,$e(s,y)}),vt(s),cr(s,0)}}function cr(e,t){var n=e.deps;if(n!==null)for(var r=t;rn?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?(i.__removed=!1,Xe(()=>{i.__removed||t.addEventListener(e,i,r)})):t.addEventListener(e,i,r),i}function Sr(e,t,n,r,i){var a={capture:r,passive:i},o=xr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&vn(()=>{o.__removed=!0,t.removeEventListener(e,o,a)})}function K(e,t,n){(t[vr]??={})[e]=n}function Cr(e){for(var t=0;t{Tr=!1,wr=null}));var s=0,c=wr===e&&e[vr];if(c){var l=a.indexOf(c);if(l!==-1&&(t===document||t===window)){e[vr]=t;return}var u=a.indexOf(t);if(u===-1)return;l<=u&&(s=l)}if(o=a[s]||e.target,o!==t){i(e,`currentTarget`,{configurable:!0,get(){return o||n}});var d=U,f=W;Wn(null),Gn(null);try{for(var p,m=[];o!==null&&o!==t;){try{var h=o[vr]?.[r];h==null||o.disabled&&e.target!==o||h.call(o,e)}catch(e){p?m.push(e):p=e}if(e.cancelBubble)break;s++,o=s{throw e});throw p}}finally{e[vr]=t,delete e.currentTarget,Wn(d),Gn(f)}}}var Dr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Or(e){return Dr?.createHTML(e)??e}function kr(e){var t=un(`template`);return t.innerHTML=Or(e.replaceAll(``,``)),t.content}function Ar(e,t){var n=W;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function q(e,t){var n=!!(t&1),r=!!(t&2),i,a=!e.startsWith(``);return()=>{if(A)return Ar(j,null),j;i===void 0&&(i=kr(a?e:``+e),n||(i=on(i)));var t=r||en?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=on(t),s=t.lastChild;Ar(o,s)}else Ar(t,t);return t}}function jr(e,t,n=`svg`){var r=!e.startsWith(``),i=!!(t&1),a=`<${n}>${r?e:``+e}`,o;return()=>{if(A)return Ar(j,null),j;if(!o){var e=on(kr(a));if(i)for(o=document.createDocumentFragment();on(e);)o.appendChild(on(e));else o=on(e)}var t=o.cloneNode(!0);if(i){var n=on(t),r=t.lastChild;Ar(n,r)}else Ar(t,t);return t}}function Mr(e,t){return jr(e,t,`svg`)}function Nr(e=``){if(!A){var t=an(e+``);return Ar(t,t),t}var n=j;return n.nodeType===3?dn(n):(n.before(n=an()),M(n)),Ar(n,n),n}function Pr(){if(A)return Ar(j,null),j;var e=document.createDocumentFragment(),t=document.createComment(``),n=an();return e.append(t,n),Ar(t,n),e}function J(e,t){if(A){var n=W;n.f&32768&&n.nodes.end!==null||(n.nodes.end=j),xe()}else e!==null&&e.before(t)}function Fr(){if(A&&j&&j.nodeType===8&&j.textContent?.startsWith(`$`)){let e=j.textContent.substring(1);return xe(),e}return(window.__svelte??={}).uid??=1,`c${window.__svelte.uid++}`}function Ir(e){let t=0,n=Vt(0),r;return()=>{_n()&&(G(n),Tn(()=>(t===0&&(r=pr(()=>e(()=>Jt(n)))),t+=1,()=>{Xe(()=>{--t,t===0&&(r?.(),r=void 0,Jt(n))})})))}}var Lr=T|E;function Rr(e,t,n,r){new zr(e,t,n,r)}var zr=class{parent;is_pending=!1;transform_error;#e;#t=A?j:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=Ir(()=>(this.#m=Vt(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=W;t.b=this,t.f|=128,n(e)},this.parent=W.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=En(()=>{if(A){let e=this.#t;xe();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#y():this.#g()}else this.#b()},Lr),A&&(this.#e=j)}#g(){try{this.#a=Dn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed,{reset:n,invoke_onerror:r}=this.#v(e);Xe(r),t&&(this.#s=Dn(()=>{t(this.#e,()=>e,()=>n)}))}#v(e){var t=!1,n=!1;let r=()=>{t?ye():(t=!0,n&&ze(),this.#s!==null&&Pn(this.#s,()=>{this.#s=null}),this.#S(()=>{this.#b()}))};return{reset:r,invoke_onerror:()=>{try{n=!0,this.#n.onerror?.(e,r),n=!1}catch(e){pn(e,this.#i&&this.#i.parent)}}}}#y(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=Dn(()=>e(this.#e)),Xe(()=>{var e=this.#c=document.createDocumentFragment(),t=an(),n=!1;e.append(t),this.#a=this.#S(()=>{try{return Dn(()=>this.#r(t))}catch(e){try{this.error(e),n=!0}catch(e){pn(e,this.#i.parent)}return null}}),this.#a===null?(this.#c=null,n&&this.#x(F)):this.#u===0&&(this.#e.before(e),this.#c=null,Pn(this.#o,()=>{this.#o=null}),this.#x(F))}))}#b(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=Dn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();Rn(this.#a,e);let t=this.#n.pending;this.#o=Dn(()=>t(this.#e))}else this.#x(F)}catch(e){this.error(e)}}#x(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){tt(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#S(e){var t=W,n=U,r=He;Gn(this.#i),Wn(this.#i),Ue(this.#i.ctx);try{return At.ensure(),e()}finally{Gn(t),Wn(n),Ue(r)}}#C(e,t){this.has_pending_snippet()?(this.#u+=e,this.#u===0&&(this.#x(t),this.#o&&Pn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))):this.parent&&this.parent.#C(e,t)}update_pending_count(e,t){this.#C(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,Xe(()=>{this.#d=!1,this.#m&&Gt(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),G(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;F?.is_fork?(this.#a&&F.skip_effect(this.#a),this.#o&&F.skip_effect(this.#o),this.#s&&F.skip_effect(this.#s),F.oncommit(()=>{this.#w(e)})):this.#w(e)}#w(e){this.#a&&=(jn(this.#a),null),this.#o&&=(jn(this.#o),null),this.#s&&=(jn(this.#s),null),A&&(M(this.#t),Se(),M(Ce()));let t=this.#n.failed,n=e=>{let{reset:n,invoke_onerror:r}=this.#v(e);r(),t&&(this.#s=this.#S(()=>{try{return Dn(()=>{var r=W;r.b=this,r.f|=128,t(this.#e,()=>e,()=>n)})}catch(e){return pn(e,this.#i.parent),null}}))};Xe(()=>{var t;try{t=this.transform_error(e)}catch(e){pn(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(n,e=>pn(e,this.#i&&this.#i.parent)):n(t)})}};function Y(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[ue]??=e.nodeValue)&&(e[ue]=n,e.nodeValue=`${n}`)}function Br(e,t){return Hr(e,t)}var Vr=new Map;function Hr(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){rn();var l=void 0,u=Sn(()=>{var s=n??t.appendChild(an());Rr(s,{pending:()=>{}},t=>{We({});var n=He;if(o&&(n.c=o),a&&(i.$$events=a),A&&Ar(t,null),l=e(t,i)||Ke(),A&&(W.nodes.end=j,j===null||j.nodeType!==8||j.data!==`]`))throw _e(),me;Ge()},c);var u=new Set,d=e=>{for(var n=0;n{for(var e of u)for(let n of[t,document]){var r=Vr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Er),r.delete(e),r.size===0&&Vr.delete(n)):r.set(e,i)}br.delete(d),s!==n&&s.parentNode?.removeChild(s)}});return Ur.set(l,u),l}var Ur=new WeakMap,Wr=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)In(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(In(r.effect),this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(jn(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();Rn(r,t),t.append(an()),this.#n.set(e,{effect:r,fragment:t})}else jn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Pn(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(jn(n.effect),this.#n.delete(e))};ensure(e,t){var n=F,r=ln();if(t&&!this.#t.has(e)&&!this.#n.has(e)){if(r){var i=document.createDocumentFragment(),a=an();i.append(a),this.#n.set(e,{effect:Dn(()=>t(a)),fragment:i})}else this.#t.set(e,Dn(()=>t(this.anchor)))}if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else A&&(this.anchor=j),this.#a(n)}};function X(e,t,n=!1){var r;A&&(r=j,xe());var i=new Wr(e),a=n?T:0;function o(e,t){if(A){var n=we(r);if(e!==parseInt(n.substring(1))){var a=Ce();M(a),i.anchor=a,be(!1),i.ensure(e,t),be(!0);return}}i.ensure(e,t)}En(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var Gr=Symbol(`NaN`);function Kr(e,t,n){A&&xe();var r=new Wr(e),i=!qe();En(()=>{var e=t();e!==e&&(e=Gr),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function qr(e,t){return t}function Jr(e,t,n){for(var i=[],a=t.length,o,s=t.length,c=0;c{if(o){if(o.pending.delete(n),o.done.add(n),o.pending.size===0){var t=e.outrogroups;Yr(e,r(o.done)),t.delete(o),t.size===0&&(e.outrogroups=null)}}else--s},!1)}if(s===0){var l=i.length===0&&n!==null&&e.pending.size===0;if(l){var u=n,d=u.parentNode;cn(d),d.append(u),e.items.clear()}Yr(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function Yr(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i{var t=i();return e(t)?t:t==null?[]:r(t)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=d,Qr(v,p,c,n,a),d!==null&&(p.length===0?d.f&33554432?(d.f^=ee,ei(d,null,c)):In(d):Pn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:En(()=>{p=G(f);var e=p.length;let t=!1;A&&we(c)===`[!`!=(e===0)&&(c=Ce(),M(c),be(!1),t=!0);for(var r=new Set,u=F,v=ln(),y=0;ys(c)):(d=Dn(()=>s(Xr??=an())),d.f|=ee)),e>r.size&&Ae(``,``,``),A&&e>0&&M(Ce()),!h){if(m.set(u,r),v){for(let[e,t]of l)r.has(e)||u.skip_effect(t.e);u.oncommit(g),u.ondiscard(_)}else g(u)}t&&be(!0),G(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,A&&(c=j)}function Zr(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function Qr(e,t,n,i,a){var o=!!(i&8),s=t.length,c=e.items,l=Zr(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v0){var E=i&4&&s===0?n:null;if(o){for(v=0;v{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function $r(e,t,n,r,i,a,o,s){var c=o&1?o&16?Vt(n):Ht(n,!1,!1):null,l=o&2?Vt(i):null;return{v:c,i:l,e:Dn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function ei(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=sn(r);if(a.before(r),r===i)return;r=o}}function ti(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function ni(e,t,...n){var r=new Wr(e);En(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},T)}function ri(e,t,n){var r;A&&(r=j,xe());var i=new Wr(e);En(()=>{var e=t()??null;if(A&&we(r)===`[`!=(e!==null)){var a=Ce();M(a),i.anchor=a,be(!1),i.ensure(e,e&&(t=>n(t,e))),be(!0)}else i.ensure(e,e&&(t=>n(t,e)))},T)}var ii=[...` +\r\f\xA0\v`];function ai(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i of Object.keys(n))if(n[i])r=r?r+` `+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var s=o+a;(o===0||ii.includes(r[o-1]))&&(s===r.length||ii.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function oi(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function si(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function ci(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\/\*.*?\*\//g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(si)),i&&c.push(...Object.keys(i).map(si));var l=0,u=-1;let t=e.length;for(var d=0;d{t.every(vi)||(`__defaultValue`in e&&pi(e,!1),`__value`in e&&mi(e,e.__value))});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),vn(()=>{t.disconnect()})}function gi(e,t,n=t){var r=new WeakSet,i=!0;ot(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),_i);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&_i(o)}n(a),e.__value=a,F!==null&&r.add(F)}),Cn(()=>{var a=t();if(e===document.activeElement){var o=F;if(r.has(o))return}if(mi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=_i(s),n(a))}e.__value=a,i=!1})}function _i(e){return`__value`in e?e.__value:e.value}function vi(e){if(e.target.closest(`selectedcontent`)!==null)return!0;if(e.type===`childList`){var t=[...e.addedNodes,...e.removedNodes];return t.length>0&&t.every(e=>e.nodeName===`SELECTEDCONTENT`)}return!1}var yi=Symbol(`is custom element`),bi=Symbol(`is html`),xi=pe?`link`:`LINK`;function Si(e){if(A){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;Q(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;Q(e,`checked`,null),e.checked=r}}};e[de]=n,Xe(n),it()}}function Ci(e,t){var n=wi(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function Q(e,t,n,r){var i=wi(e);A&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===xi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[oe]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&Ei(e).has(t)?e[t]=n:e.setAttribute(t,n))}function wi(e){return e[se]??={[yi]:e.nodeName.includes(`-`),[bi]:e.namespaceURI===he}}var Ti=new Map;function Ei(e){var t=e.getAttribute(`is`)||e.nodeName,n=Ti.get(t);if(n)return n;Ti.set(t,n=new Set);for(var r,i=e,a=Element.prototype;a!==i;){for(var s in r=o(i),r)r[s].set&&s!==`innerHTML`&&s!==`textContent`&&s!==`innerText`&&n.add(s);i=l(i)}return n}function Di(e,t,n=t){var r=new WeakSet;ot(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=Mi(e)?Ni(a):a,n(a),F!==null&&r.add(F),await ur(),a!==(a=t())){var o=e.selectionStart,s=e.selectionEnd,c=e.value.length;if(e.value=a??``,s!==null){var l=e.value.length;o===s&&s===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(s,l))}}}),(A&&e.defaultValue!==e.value||pr(t)==null&&e.value)&&(n(Mi(e)?Ni(e.value):e.value),F!==null&&r.add(F)),Tn(()=>{var n=t();if(e===document.activeElement){var i=F;if(r.has(i))return}Mi(e)&&n===Ni(e.value)||(e.type!==`date`||n||e.value)&&n!==e.value&&(e.value=n??``)})}var Oi=new Set;function ki(e,t,n,r,i=r){var a=n.getAttribute(`type`)===`checkbox`,o=e;let s=!1;if(t!==null)for(var c of t)o=o[c]??=[];o.push(n),ot(n,`change`,()=>{var e=n.__value;a&&(e=ji(o,e,n.checked)),i(e)},()=>i(a?[]:null)),Tn(()=>{var e=r();A&&n.defaultChecked!==n.checked?s=!0:a?(e||=[],n.checked=e.includes(n.__value)):n.checked=Qt(n.__value,e)}),vn(()=>{var e=o.indexOf(n);e!==-1&&o.splice(e,1)}),Oi.has(o)||(Oi.add(o),Xe(()=>{o.sort((e,t)=>e.compareDocumentPosition(t)===4?-1:1),Oi.delete(o)})),Xe(()=>{if(s){var e=a?ji(o,e,n.checked):o.find(e=>e.checked)?.__value;i(e)}})}function Ai(e,t,n=t){ot(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(A&&e.defaultChecked!==e.checked||pr(t)==null)&&n(e.checked),Tn(()=>{e.checked=!!t()})}function ji(e,t,n){for(var r=new Set,i=0;i{var n=this.#e.get(e);n.delete(t),n.size===0&&(this.#e.delete(e),this.#t.unobserve(e))}}#r(){return this.#t??=new ResizeObserver(t=>{for(var n of t){e.entries.set(n.target,n);for(var r of this.#e.get(n.target)||[])r(n)}})}}({box:`border-box`});function Fi(e,t,n){var r=Pi.observe(e,()=>n(e[t]));Cn(()=>(pr(()=>n(e[t])),r))}function Ii(e,t){return e===t||e?.[re]===t}function Li(e=Ke(),t,n,r){var i=He.r,a=W;return Cn(()=>{var o,s;return Tn(()=>{o=s,s=r?.()||[],pr(()=>{Ii(n(...s),e)||(t(e,...s),o&&Ii(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&Ii(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function Ri(e,t,n,r,i){var a=()=>{r(n[e])};n.addEventListener(t,a),i?Tn(()=>{n[e]=i()}):a(),(n===document.body||n===window||n===document)&&vn(()=>{n.removeEventListener(t,a)})}function zi(e=!1){let t=He,n=t.l.u;if(!n)return;let r=()=>mr(t.s);if(e){let e=0,n={},i=dt(()=>{let r=!1,i=t.s;for(let e in i)i[e]!==n[e]&&(n[e]=i[e],r=!0);return r&&e++,e});r=()=>G(i)}n.b.length&&xn(()=>{Bi(t,r),m(n.b)}),yn(()=>{let e=pr(()=>n.m.map(p));return()=>{for(let t of e)typeof t==`function`&&t()}}),n.a.length&&yn(()=>{Bi(t,r),m(n.a)})}function Bi(e,t){if(e.l.s)for(let t of e.l.s)G(t);t()}var Vi=!1;function Hi(e){var t=Vi;try{return Vi=!1,[e(),Vi]}finally{Vi=t}}var Ui={get(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(d(r)&&(r=r()),typeof r==`object`&&r&&t in r)return r[t]}},set(e,t,n){let r=e.props.length;for(;r--;){let i=e.props[r];d(i)&&(i=i());let o=a(i,t);if(o&&o.set)return o.set(n),!0}return!1},getOwnPropertyDescriptor(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(d(r)&&(r=r()),typeof r==`object`&&r&&t in r){let e=a(r,t);return e&&!e.configurable&&(e.configurable=!0),e}}},has(e,t){if(t===re||t===ae)return!1;for(let n of e.props)if(d(n)&&(n=n()),n!=null&&t in n)return!0;return!1},ownKeys(e){let t=[];for(let n of e.props)if(d(n)&&(n=n()),n){for(let e in n)t.includes(e)||t.push(e);for(let e of Object.getOwnPropertySymbols(n))t.includes(e)||t.push(e)}return t}};function Wi(...e){return new Proxy({props:e},Ui)}function Gi(e,t,n,r){var i=!Be||!!(n&2),o=!!(n&8),s=!!(n&16),c=r,l=!0,u=void 0,d=()=>s&&i?(u??=dt(r),G(u)):(l&&(l=!1,c=s?pr(r):r),c);let f;if(o){var p=re in e||ae in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=Hi(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&Fe(t),f(m)));var g=i?()=>{var n=e[t];return n===void 0?d():(l=!0,n)}:()=>{var n=e[t];return n!==void 0&&(c=void 0),n===void 0?c:n};if(i&&!(n&4))return g;if(f){var _=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||_||h)&&f(t?g():e),e):g()})}var v=!1,y=(n&1?dt:mt)(()=>(v=!1,g()));o&&G(y);var b=W;return(function(e,t){if(arguments.length>0){let n=t?G(y):i&&o?Xt(e):e;return L(y,n),v=!0,c!==void 0&&(c=n),e}return Vn&&v||b.f&16384?y.v:G(y)})}function Ki(e){He===null&&Oe(`onMount`),Be&&He.l!==null?Ji(He).m.push(e):yn(()=>{let t=pr(e);if(typeof t==`function`)return t})}function qi(e){He===null&&Oe(`onDestroy`),Ki(()=>()=>pr(e))}function Ji(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);function Yi(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,i,a,o=[],s=``,c=e.split(`/`);for(c[0]||c.shift();i=c.shift();)n=i[0],n===`*`?(o.push(`wild`),s+=`/(.*)`):n===`:`?(r=i.indexOf(`?`,1),a=i.indexOf(`.`,1),o.push(i.substring(1,~r?r:~a?a:i.length)),s+=~r&&!~a?`(?:/([^/]+?))?`:`/([^/]+?)`,~a&&(s+=(~r?`?`:``)+`\\`+i.substring(a))):s+=`/`+i;return{keys:o,pattern:RegExp(`^`+s+(t?`(?=$|/)`:`/?$`),`i`)}}var Xi=new class{#e=I(Zi());get _loc(){return G(this.#e)}set _loc(e){L(this.#e,e)}#t=P(()=>this._loc.location);get _location(){return G(this.#t)}set _location(e){L(this.#t,e)}#n=P(()=>this._loc.querystring);get _querystring(){return G(this.#n)}set _querystring(e){L(this.#n,e)}#r=I(void 0);get _params(){return G(this.#r)}set _params(e){L(this.#r,e)}get loc(){return this._loc}get location(){return this._location}get querystring(){return this._querystring}get params(){return this._params}constructor(){typeof window<`u`?window.addEventListener(`hashchange`,()=>{this._loc=Zi()}):console.warn(`[svelte-spa-router] window 'window' is not defined, skipping initiation`)}};function Zi(){let e=typeof window<`u`?window.location.href:``,t=e.indexOf(`#/`),n=t>-1?e.substr(t+1):`/`,r=n.indexOf(`?`),i=``;return r>-1&&(i=n.substr(r+1),n=n.substr(0,r)),{location:n,querystring:i}}async function Qi(e){if(!e||e.length<1||e.charAt(0)!=`/`&&e.indexOf(`#/`)!==0)throw Error(`Invalid parameter location`);await ur();let t=(e.charAt(0)==`#`?``:`#`)+e;try{let e={...history.state};delete e.__svelte_spa_router_scrollX,delete e.__svelte_spa_router_scrollY,window.history.replaceState(e,``,t)}catch{console.warn("Caught exception while replacing the current page. If you're running this in the Svelte REPL, please note that the `replace` method might not work in this environment.")}window.dispatchEvent(new Event(`hashchange`))}function $i(e){e?window.scrollTo(e.__svelte_spa_router_scrollX||0,e.__svelte_spa_router_scrollY||0):window.scrollTo(0,0)}function ea(e,t){We(t,!0);let n=Gi(t,`routes`,19,()=>({})),r=Gi(t,`prefix`,3,``),i=Gi(t,`restoreScrollState`,3,!1),a=Gi(t,`onConditionsFailed`,3,()=>{}),o=Gi(t,`onRouteLoaded`,3,()=>{}),s=Gi(t,`onRouteLoading`,3,()=>{}),c=Gi(t,`onRouteEvent`,3,()=>{});class l{path;component;conditions;userData;props;_pattern;_keys;constructor(e,t){let n=e=>typeof e==`object`&&!!e&&e._sveltesparouter===!0;if(!t||typeof t!=`function`&&!n(t))throw Error(`Invalid component object`);if(!e||typeof e==`string`&&(e.length<1||e.charAt(0)!=`/`&&e.charAt(0)!=`*`)||typeof e==`object`&&!(e instanceof RegExp))throw Error(`Invalid value for "path" argument - strings must start with / or *`);let r=Yi(e);if(this.path=e,n(t)){let e=t;this.component=e.component,this.conditions=e.conditions||[],this.userData=e.userData,this.props=e.props||{}}else{let e=t;this.component=()=>Promise.resolve(e),this.conditions=[],this.props={}}this._pattern=r.pattern,this._keys=r.keys}match(e){if(r()){if(typeof r()==`string`){if(e.startsWith(r()))e=e.substr(r().length)||`/`;else return null}else if(r()instanceof RegExp){let t=e.match(r());if(t&&t[0])e=e.substr(t[0].length)||`/`;else return null}}let t=this._pattern.exec(e);if(t===null)return null;if(this._keys===!1)return t;let n={},i=0;for(;i{u.push(new l(t,e))}):Object.keys(n()).forEach(e=>{let t=n();u.push(new l(e,t[e]))});let d=I(null),f=I(null),p=I({}),m=null,h=null;yn(()=>{history.scrollRestoration=i()?`manual`:`auto`}),yn(()=>{if(!i())return;let e=e=>{m=e.state&&(e.state.__svelte_spa_router_scrollY||e.state.__svelte_spa_router_scrollX)?e.state:null};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)});async function g(e,t){await ur(),e(t)}yn(()=>{let e=Xi.loc,t=!1;return pr(async()=>{let n=0;for(;n{t=!0}});function _(e){return e&&typeof e==`object`&&Object.keys(e).length?e:null}var v=Pr(),y=z(v),b=e=>{let t=P(()=>G(d));var n=Pr(),r=z(n),i=e=>{var n=Pr();ri(z(n),()=>G(t),(e,t)=>{t(e,Wi({get params(){return G(f)},get onRouteEvent(){return c()}},()=>G(p)))}),J(e,n)},a=e=>{var n=Pr();ri(z(n),()=>G(t),(e,t)=>{t(e,Wi({get onRouteEvent(){return c()}},()=>G(p)))}),J(e,n)};X(r,e=>{G(f)?e(i):e(a,-1)}),J(e,n)};X(y,e=>{G(d)&&e(b)}),J(e,v),Ge()}var ta=[`bars`,`pace`,`pie`,`fuel`,`resets`,`thresholds`];function na(e){return e===`zone`||e===`consumption-pace`?`pace`:typeof e==`string`&&ta.includes(e)?e:`bars`}var ra=`codexometer.web.preferences.v1`,ia={statusLine:null,tab:`quota`,view:`bars`,selected:``,defaultDetail:0,layouts:[]};function aa(){try{let e=JSON.parse(localStorage.getItem(ra)||`null`);return!e||typeof e!=`object`?ia:{statusLine:Array.isArray(e.statusLine)?[...new Set(e.statusLine.filter(e=>typeof e==`string`&&e.length<64))].slice(0,32):null,tab:[`quota`,`sessions`,`usage`].includes(e.tab)?e.tab:`quota`,view:na(e.view),selected:typeof e.selected==`string`?e.selected.slice(0,256):``,defaultDetail:+(e.defaultDetail===1),layouts:Array.isArray(e.layouts)?e.layouts.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length<=256&&[0,1,2].includes(t.level)}).slice(-100):[]}}catch{return ia}}var oa=Xt(aa()),sa=Xt({open:!1}),ca=Xt({requests:0});function la(){let e=JSON.stringify(oa);try{localStorage.setItem(ra,e)}catch{}}function ua(){return oa.tab===`quota`?`/quota/`+oa.view:`/`+oa.tab}function da(e){return oa.layouts.find(t=>t.id===e)?.level??oa.defaultDetail}function fa(e){oa.defaultDetail=e,oa.layouts=[]}function pa(e,t){oa.layouts=[...oa.layouts.filter(t=>t.id!==e),{id:e,level:Math.max(0,Math.min(2,t))}].slice(-100)}var $=Xt({data:null,connected:!1,error:``}),ma=e=>e==null?`Unavailable`:e.toLocaleString(`en-GB`),ha=e=>!e||String(e).startsWith(`0001-`)?`Not yet available`:new Date(typeof e==`number`?e*1e3:e).toLocaleString(`en-GB`),ga=`codexometer.web.session`,_a=class extends Error{},va;async function ya(e,t,n){if(!va||!$.connected||!$.data?.control||$.data.sessionsError)throw Error(`Session controls unavailable. Check the live connection.`);return await va(e,t,n)}function ba(){let e=new AbortController,t,n=``;va=async(t,r,i)=>{let a=await fetch(`/api/control/`+t,{method:`POST`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`},body:JSON.stringify(r),signal:AbortSignal.any([e.signal,AbortSignal.timeout(8e3),...i?[i]:[]]),cache:`no-store`});if(!a.ok)throw a.status===502?Error(`Outcome uncertain. Check Codex before taking another action; nothing was retried.`):new _a(`Action rejected, expired or changed. Refresh and check Codex; nothing was retried.`);return a.json()};try{n=sessionStorage.getItem(ga)||``}catch{}let r=location.hash,i=r.startsWith(`#pair=`)?r.slice(6):``;(i||!r||r===`#`)&&(history.replaceState(null,``,`/#`+ua()),window.dispatchEvent(new HashChangeEvent(`hashchange`)));async function a(){if(i)try{let t=await fetch(`/api/pair`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({secret:i}),signal:e.signal});if(!t.ok)throw Error(`Pairing link expired or already used. Restart --web for a fresh link.`);n=(await t.json()).token;try{sessionStorage.setItem(ga,n)}catch{}}catch(t){e.signal.aborted||($.error=t instanceof Error?t.message:`Pairing failed`);return}n?await o():$.error=`Open the private pairing link printed by codexometer --web in your terminal.`}async function o(){try{let t=await fetch(`/api/events`,{headers:{Authorization:`Bearer ${n}`},signal:e.signal,cache:`no-store`});if(t.status===401){try{sessionStorage.removeItem(ga)}catch{}$.error=`Browser session expired. Restart --web and open its new pairing link.`;return}if(!t.ok||!t.body)throw Error(`Live connection unavailable`);let r=t.body.getReader(),i=new TextDecoder,a=``;for(;!e.signal.aborted;){let{done:e,value:t}=await r.read();if(e)break;a+=i.decode(t,{stream:!0});let n;for(;(n=a.indexOf(` + +`))>=0;){let e=a.slice(0,n);a=a.slice(n+2),e.startsWith(`data: `)&&($.data=JSON.parse(e.slice(6)),$.connected=!0,$.error=``)}}}catch{}finally{$.connected=!1}e.signal.aborted||($.error=`Connection lost — showing last observation. Reconnecting…`,t=setTimeout(o,2500))}return a(),()=>{va=void 0,e.abort(),clearTimeout(t),$.connected=!1}}Ve();var xa=q(`

Quota refresh failed. Policy state is based on the last successful + observation.

`),Sa=q(`

`),Ca=q(`

The longest Codex quota window selects one active model profile. ASK + creates a per-session review; AUTO applies the profile on the next + eligible check.

`,1),wa=q(`

No threshold-based model steps were configured at launch.

`);function Ta(e,t){We(t,!1),zi();var n=Pr(),r=z(n),i=e=>{var t=Ca(),n=z(t),r=B(n),i=V(n,2),a=e=>{J(e,xa())};X(i,e=>{$.data.quotaError&&e(a)});var o=V(i,2),s=R(o),c=B(s),l=V(s,4);Z(l,5,()=>$.data.thresholds,qr,(e,t)=>{var n=Sa();let r;var i=R(n),a=B(i),o=V(i,2),s=R(o),c=B(s,!0),l=B(V(s,2));N(o);var u=V(o,2),d=B(u,!0),f=B(V(u,2));N(n),H((e,i)=>{r=li(n,1,``,null,r,{active:G(t).state===`ACTIVE`,next:G(t).state===`NEXT`}),Y(a,`${G(t).threshold??``}%`),Y(c,G(t).model),Y(l,`${e??``} REASONING // ${i??``} + SPEED`),Y(d,G(t).mode),Y(f,`${G(t).state??``}${G(t).state===`NEXT`?` // ${G(t).remaining||0} PP TO GO`:``}`)},[()=>G(t).effort.toUpperCase(),()=>G(t).speed.toUpperCase()]),J(e,n)}),N(l),N(o),H(e=>{Y(r,`MODEL STEP POLICY // OBSERVED ${e??``}`),Y(c,`THRESHOLDS // ${$.data.thresholds.length??``} CONFIGURED`)},[()=>ha($.data.quotaAt)]),J(e,t)},a=e=>{J(e,wa())};X(r,e=>{$.data?.thresholds?.length?e(i):e(a,-1)}),J(e,n),Ge()}var Ea=Mr(` `,1),Da=Mr(` `,1),Oa=Mr(` `,1),ka=Mr(` `,1),Aa=q(`
`,1),ja=q(` `),Ma=q(`
Quota observations
Observed atPeriod elapsedConsumedTrail segment
`),Na=q(`
OBSERVATION DATA
`),Pa=q(`
CONSUMPTIONQUOTA PERIOD ELAPSED
`,1);function Fa(e,t){let n=Fr();We(t,!0);let r=Gi(t,`trail`,19,()=>[]),i=I(!1),a=I(!0),o=I(`window`),s=[0,25,50,75,100],c=P(()=>t.plot?.known?t.plot.elapsed:t.elapsed),l=I(400),u=I(240),d=P(()=>G(l)-24),f=P(()=>G(u)-48),p=P(()=>Math.max(1,G(d)-48)),m=P(()=>Math.max(1,G(f)-20)),h=P(()=>48+Math.max(0,Math.min(100,G(c)))/100*G(p));function g(e){return G(f)-(e-0)/100*G(m)}let _=P(()=>g(t.used)),v=P(()=>t.used-G(c)),y=P(()=>r().map((e,t)=>`${t===0||e.break?`M`:`L`}${48+e.elapsed/100*G(p)} ${g(e.used)}`).join(` `)),b=P(()=>{let e=0;for(let t=r().length-1;t>0;t--)if(r()[t].break){e=t;break}return r().slice(e)}),x=P(()=>G(b).length<2?0:Math.max(0,Date.parse(G(b).at(-1).at)-Date.parse(G(b)[0].at))),S=P(()=>Object.fromEntries((t.plot?.modes||[]).map(e=>[e.id,e.available])));yn(()=>{G(o)!==`window`&&!G(S)[G(o)]&&L(o,`window`)});let C=P(()=>{let e=t.plot?.modes.find(e=>e.id===G(o));if(!e?.segment)return null;let{x1:n,y1:r,x2:i,y2:a}=e.segment,s=Math.hypot((i-n)/100*G(p),(a-r)/100*G(m)),c=Math.max(3,Math.min(9,Math.floor(s/65)+2));return{path:`M${Array.from({length:c},(e,t)=>{let o=n+(i-n)*t/(c-1),s=r+(a-r)*t/(c-1);return`${48+o/100*G(p)} ${g(s)}`}).join(` L`)}`,projected:e.projected,safe:e.safe}}),w=P(()=>{if(G(b).length===0)return`NO OBSERVATIONS`;if(G(b).length===1)return`ONE OBSERVATION`;let e=Math.floor(G(x)/6e4);if(e<60)return`${e} MIN CONTINUOUS`;let t=Math.floor(e/60);return t<24?`${t}H CONTINUOUS`:`${Math.floor(t/24)}D ${t%24}H CONTINUOUS`});var T=Pa(),E=z(T),D=R(E);let ee;var te=R(D),O=R(te),ne=V(O);N(te);var re=V(te),ie=V(re);Z(ie,17,()=>s,qr,(e,t)=>{var n=Ea(),r=z(n),i=V(r),a=B(i);H(()=>{Q(r,`x1`,48+G(t)/100*G(p)),Q(r,`x2`,48+G(t)/100*G(p)),Q(r,`y2`,G(f)),Q(i,`x`,48+G(t)/100*G(p)),Q(i,`y`,G(f)+20),Y(a,`${G(t)??``}%`)}),J(e,n)});var ae=V(ie);Z(ae,17,()=>s,qr,(e,t)=>{var n=Da(),r=z(n),i=V(r),a=B(i);H((e,n,o)=>{Q(r,`y1`,e),Q(r,`x2`,G(d)),Q(r,`y2`,n),Q(i,`y`,o),Y(a,`${G(t)??``}%`)},[()=>g(G(t)),()=>g(G(t)),()=>g(G(t))+4]),J(e,n)});var oe=V(ae),se=V(oe),ce=V(se),le=e=>{var t=Oa(),n=z(t),i=V(n),a=V(i),o=B(R(a));N(a),H((e,t)=>{Q(n,`d`,G(y)),Q(i,`d`,G(y)),Q(a,`cx`,48+r()[0].elapsed/100*G(p)),Q(a,`cy`,e),Y(o,`First observation: ${t??``}`)},[()=>g(r()[0].used),()=>ha(r()[0].at)]),J(e,t)};X(ce,e=>{G(a)&&r().length&&e(le)});var ue=V(ce),de=e=>{var t=ka(),r=z(t),i=V(r),a=B(R(i));N(i),H(e=>{Q(r,`d`,G(C).path),Q(i,`d`,G(C).path),Q(i,`marker-mid`,`url(#${n}-trend-arrow)`),Y(a,`${G(o)===`window`?`Window-average pace`:`Recent consumption trajectory`} projects ${e??``}% at reset if continued`)},[()=>G(C).projected.toFixed(1)]),J(e,t)};X(ue,e=>{G(C)&&e(de)});var fe=V(ue,2),pe=V(fe),me=V(pe),k=B(R(me));N(me),N(D),N(E);var he=V(E,2),ge=R(he),_e=R(ge),ve=V(_e,3),ye=B(ve,!0),A=V(ve,2),be=e=>{var t=Aa(),n=B(V(z(t)));H(e=>Y(n,`TREND // ${e??``}`),[()=>G(C).projected>=100?`QUOTA EXHAUSTION PROJECTED`:`${G(C).projected.toFixed(1)}% PROJECTED AT RESET`]),J(e,t)};X(A,e=>{G(C)&&e(be)}),N(ge);var j=V(ge,2),M=R(j),xe=R(M);Si(xe),Se(),N(M);var Ce=V(M,2),we=V(R(Ce),2),Te=R(we);Te.value=Te.__value=`off`;var Ee=V(Te),De=B(Ee);Ee.value=Ee.__value=`halfHour`;var Oe=V(Ee),ke=B(Oe);Oe.value=Oe.__value=`hour`;var Ae=V(Oe),je=B(Ae);Ae.value=Ae.__value=`day`;var Me=V(Ae),Ne=B(Me);Me.value=Me.__value=`window`,N(we),hi(we),N(Ce);var Pe=B(V(Ce,2));N(j),N(he);var Fe=V(he,2),Ie=e=>{var t=Na(),n=V(R(t),2),a=e=>{var t=Ma(),n=R(t),i=V(R(n),2);Z(i,21,r,qr,(e,t,n)=>{var r=ja(),i=R(r),a=R(i),o=B(a,!0);N(i);var s=V(i),c=B(s),l=V(s),u=B(l),d=B(V(l),!0);N(r),H((e,r)=>{Q(a,`datetime`,G(t).at),Y(o,e),Y(c,`${r??``}%`),Y(u,`${G(t).used??``}%`),Y(d,n===0?`First observation`:G(t).break?`Gap before this observation`:`Connected to previous observation`)},[()=>ha(G(t).at),()=>G(t).elapsed.toFixed(1)]),J(e,r)}),N(i),N(n),N(t),J(e,t)};X(n,e=>{G(i)&&e(a)}),N(t),Ri(`open`,`toggle`,t,e=>L(i,e),()=>G(i)),J(e,t)};X(Fe,e=>{r().length&&e(Ie)}),H((e,r,i,a,o,s)=>{Q(D,`viewBox`,`0 0 ${G(l)} ${G(u)}`),Q(D,`aria-label`,e),ee=di(D,``,ee,{"--trend-color":G(C)?.safe?`#115b35`:`#7f1825`}),Q(O,`id`,n),Q(ne,`id`,n+`-trend-arrow`),Q(re,`width`,G(p)),Q(re,`height`,G(m)),Q(re,`fill`,`url(#${n})`),Q(oe,`d`,`M48 20 V${G(f)} H${G(d)}`),Q(se,`y1`,r),Q(se,`x2`,G(d)),Q(se,`y2`,i),Q(fe,`x`,48+G(p)/2),Q(fe,`y`,G(u)-5),Q(pe,`cx`,G(h)),Q(pe,`cy`,G(_)),Q(me,`cx`,G(h)),Q(me,`cy`,G(_)),Y(k,`${t.used??``}% consumed // ${a??``}% of period elapsed`),Y(_e,`${t.used??``}% USED // ${o??``}% TIME ELAPSED`),Y(ye,s),Ee.disabled=!G(S).halfHour,Y(De,`LAST 30 MINUTES${G(S).halfHour?``:` — UNAVAILABLE`}`),Oe.disabled=!G(S).hour,Y(ke,`LAST HOUR${G(S).hour?``:` — UNAVAILABLE`}`),Ae.disabled=!G(S).day,Y(je,`LAST 24 HOURS${G(S).day?``:` — UNAVAILABLE`}`),Me.disabled=!G(S).window,Y(Ne,`FROM WINDOW START${G(S).window?``:` — NO TIME ELAPSED`}`),Y(Pe,`HISTORY // ${G(w)??``}`)},[()=>`Pace: ${t.used}% consumed, ${G(c).toFixed(1)}% of quota period elapsed. ${G(v)>0?`Above`:G(v)<0?`Below`:`On`} the steady-consumption line.${G(a)&&r().length?` Trace path contains ${r().length} ${r().length===1?`observation`:`observations`}; gaps are not interpolated.`:``}`,()=>g(0),()=>g(100),()=>G(c).toFixed(1),()=>G(c).toFixed(1),()=>Math.abs(G(v))<.05?`ON PACE`:G(v)>0?`ABOVE THE LINE — CONSUMING FASTER THAN TIME`:`BELOW THE LINE — WITHIN PACE`]),Fi(E,`clientWidth`,e=>L(l,e)),Fi(E,`clientHeight`,e=>L(u,e)),Ai(xe,()=>G(a),e=>L(a,e)),gi(we,()=>G(o),e=>L(o,e)),J(e,T),Ge()}var Ia=q(` `),La=q(`

Quota refresh failed. Values below are the last successful observation.

`),Ra=q(`

`),za=q(`

Expiry details unavailable. No listed expiry does not mean no expiry.

`),Ba=q(`

`),Va=q(`

Read-only preview. Use the terminal to redeem a reset.

The backend may return only some credits. This list does not establish + redemption order.

`),Ha=q(` `,1),Ua=Mr(``),Wa=Mr(``),Ga=q(`
`),Ka=q(`

Cycle duration or reset date unavailable — position cannot be + plotted.

`),qa=q(`
EMPTYFULL
`),Ja=q(`

`,1),Ya=q(`
`,1),Xa=q(`

`),Za=q(`

`),Qa=q(`

No quota windows reported yet.

`),$a=q(`
`,1),eo=q(`

All reported windows are shown. API-equivalent learning and quota status + scoring remain in the terminal for this first preview.

`,1),to=q(` `,1);function no(e,t){We(t,!0);let n=Gi(t,`params`,19,()=>({})),r=P(()=>ta.filter(e=>e!==`thresholds`||!!$.data?.thresholds?.length)),i=I(Xt(Date.now())),a=P(()=>G(r).includes(na(n().view))?na(n().view):`bars`);Ki(()=>{let e=setInterval(()=>L(i,Date.now(),!0),1e3);return()=>clearInterval(e)});function o(e){return!e.duration||e.duration<=0||!e.reset?null:Math.max(0,Math.min(100,100*(1-(e.reset*1e3-G(i))/(e.duration*6e4))))}yn(()=>{oa.view=G(a),(n().view===`zone`||n().view===`consumption-pace`)&&Qi(`/quota/pace`)});function s(e){let t=e/100*Math.PI*2;return`M60 60 L60 14 A46 46 0 ${+(e>50)} 1 ${60+46*Math.sin(t)} ${60-46*Math.cos(t)} Z`}var c=to(),l=z(c);Z(l,21,()=>G(r),qr,(e,t)=>{var n=Ia();let r;var i=B(n,!0);H(e=>{Q(n,`href`,`#/quota/`+G(t)),Q(n,`aria-current`,G(a)===G(t)?`page`:void 0),r=li(n,1,``,null,r,{active:G(a)===G(t)}),Y(i,e)},[()=>G(t)===`fuel`?`FUEL TANK`:G(t).toUpperCase()]),J(e,n)}),N(l);var u=V(l,2),d=e=>{var t=eo(),n=z(t),r=e=>{J(e,La())};X(n,e=>{$.data.quotaError&&e(r)});var i=V(n,2),c=e=>{var t=Ra(),n=B(t);H(()=>Y(n,`Last usage accounting issue: + ${$.data.usageDiagnostic??``}`)),J(e,t)};X(i,e=>{$.data.usageDiagnostic&&e(c)});var l=V(i,2),u=B(l),d=V(l,2),f=e=>{Ta(e,{})},p=e=>{var t=Va(),n=R(t),r=B(n),i=V(n,4),a=e=>{J(e,za())};X(i,e=>{$.data.credits.length||e(a)}),Z(V(i,2),17,()=>$.data.credits,qr,(e,t)=>{var n=Ba(),r=R(n),i=B(r),a=B(V(r,2),!0);N(n),H(e=>{Y(i,`${(G(t).title||`Quota reset`)??``} // ${G(t).status??``}`),Y(a,e)},[()=>G(t).expiryKnown?G(t).expires?`EXPIRES `+ha(G(t).expires):`Does not expire`:`Expiry information unavailable`]),J(e,n)}),Se(2),N(t),H(()=>Y(r,`RESET INVENTORY // ${$.data.creditCount??``} AVAILABLE`)),J(e,t)},m=e=>{var t=$a(),n=z(t);let r;Z(n,21,()=>$.data.meters,qr,(e,t)=>{let n=P(()=>o(G(t)));var r=Za(),i=R(r),c=B(i,!0),l=V(i,2),u=R(l),d=e=>{var n=Ha(),r=z(n),i=B(r),a=B(V(r));H(()=>{Y(i,`FREE ${100-G(t).used}%`),Y(a,`USED ${G(t).used??``}%`)}),J(e,n)},f=e=>{var n=Ha(),r=z(n),i=B(r),a=B(V(r));H(()=>{Y(i,`USED ${G(t).used??``}%`),Y(a,`FREE ${100-G(t).used}%`)}),J(e,n)};X(u,e=>{G(a)===`fuel`?e(d):e(f,-1)}),N(l);var p=V(l,2);let m;var h=R(p),g=e=>{var n=Ga(),r=R(n),i=V(R(r)),a=e=>{J(e,Ua())},o=e=>{var n=Wa();H(e=>Q(n,`d`,e),[()=>s(G(t).used)]),J(e,n)};X(i,e=>{G(t).used>=100?e(a):G(t).used>0&&e(o,1)}),N(r),N(n),H(()=>Q(r,`aria-label`,`${G(t).used}% quota used`)),J(e,n)},_=e=>{var r=Pr(),i=z(r),a=e=>{{let r=P(()=>G(t).trail||[]);Fa(e,{get used(){return G(t).used},get elapsed(){return G(n)},get trail(){return G(r)},get plot(){return G(t).plot}})}},o=e=>{J(e,Ka())};X(i,e=>{G(n)===null?e(o,-1):e(a)}),J(e,r)},v=e=>{var r=Ya(),i=z(r),o=R(i);let s;N(i);var c=V(i,2),l=e=>{J(e,qa())};X(c,e=>{G(a)===`fuel`&&e(l)});var u=V(c,2),d=e=>{var t=Ja(),r=z(t),i=B(r),o=V(r,2),s=R(o);let c;N(o),H(e=>{Y(i,`RESET CYCLE // ${e??``}% ELAPSED`),c=di(s,``,c,{width:`${G(a)===`fuel`?100-G(n):G(n)}%`})},[()=>Math.floor(G(n))]),J(e,t)};X(u,e=>{G(n)!==null&&e(d)}),H(()=>{Q(i,`aria-label`,G(a)===`fuel`?`Fuel remaining`:`Quota used`),Q(i,`aria-valuenow`,G(a)===`fuel`?100-G(t).used:G(t).used),s=di(o,``,s,{width:`${G(a)===`fuel`?100-G(t).used:G(t).used}%`})}),J(e,r)};X(h,e=>{G(a)===`pie`?e(g):G(a)===`pace`?e(_,1):e(v,-1)}),N(p);var y=V(p,2),b=B(y),x=V(y,2),S=e=>{var n=Xa(),r=B(n,!0);H(()=>Y(r,G(t).details)),J(e,n)};X(x,e=>{G(t).details&&e(S)}),N(r),H(e=>{Y(c,G(t).name),m=li(p,1,`meter-graphic`,null,m,{"bar-graphic":G(a)===`bars`||G(a)===`fuel`}),Y(b,`RESETS // ${e??``}`)},[()=>ha(G(t).reset)]),J(e,r)}),N(n);var i=V(n,2),c=e=>{J(e,Qa())};X(i,e=>{$.data.meters.length||e(c)}),H(()=>r=li(n,1,`quota-grid`,null,r,{radial:G(a)===`pie`,zone:G(a)===`pace`})),J(e,t)};X(d,e=>{G(a)===`thresholds`?e(f):G(a)===`resets`?e(p,1):e(m,-1)}),Se(2),H(e=>Y(u,`QUOTA // OBSERVED ${e??``}`),[()=>ha($.data.quotaAt)]),J(e,t)};X(u,e=>{$.data&&e(d)}),J(e,c),Ge()}var ro=q(`
`),io=q(`

`,1);function ao(e,t){We(t,!0);let n=Gi(t,`values`,19,()=>[]),r=Gi(t,`label`,3,`Token activity`),i=Gi(t,`capacity`,3,0),a=P(()=>Math.max(0,...n())),o=P(()=>i()>n().length?[...Array(i()-n().length).fill(0),...n()]:n());var s=io(),c=z(s),l=B(c),u=V(c,2);Z(u,21,()=>G(o),qr,(e,t)=>{var n=ro();let r;H((e,t)=>{Q(n,`title`,e),r=di(n,``,r,{height:t})},[()=>G(t).toLocaleString(`en-GB`)+` tokens`,()=>`${100*G(t)/Math.max(1,G(a))}%`]),J(e,n)}),N(u),H((e,t)=>{Y(l,`SCALE // 0 — ${e??``} TOKENS`),Q(u,`aria-label`,t)},[()=>G(a).toLocaleString(`en-GB`),()=>`${r()}. Peak ${G(a).toLocaleString(`en-GB`)} tokens.`]),J(e,s),Ge()}function oo(e,t=!1){return e===`require`||e!==`none`&&!t}function so(e){if(!e||![`LAST REPLY`,`LAST ACTIVITY`].includes(e.contextKind))return``;let t=e.text||e.contextKind===`LAST ACTIVITY`&&e.workingCommand||``;return t.trim()?t:``}var co=[{id:`local-statusline`,label:`/statusline`,help:`Choose fields for Codexometer’s detail footer. Saved display preferences only.`,next:`statusline`},{id:`local-usage`,label:`/usage`,help:`Open Codexometer’s usage history. Existing quota and reset views remain available.`,next:`usage`},{id:`local-copy`,label:`/copy`,help:`Copy the selected session’s observed reply or activity using Codexometer’s copy control.`,next:`copy`},{id:`local-theme`,label:`/theme`,help:`Choose a Codexometer display theme. Saved local display preferences only.`,next:`theme`},{id:`local-exit`,label:`/exit`,help:`Leave this Codexometer interface. Codex sessions continue running.`,next:`exit`},{id:`local-quit`,label:`/quit`,help:`Alias for /exit. Codex sessions continue running.`,next:`quit`}],lo=[`surface`,`model`,`feature`,`task start`],uo=q(` `),fo=q(``),po=q(`

`),mo=q(`

`),ho=q(`
`),go=q(`

`),_o=q(`

`,1),vo=q(`

`),yo=q(`

Loading / sending…

`),bo=q(`
`),xo=q(`

`),So=q(`

 
`),Co=q(`
`),wo=q(`
`),To=q(`

Review expired. Press Enter to review again.

`),Eo=q(`

`,1),Do=q(`

`,1),Oo=q(`

No available matching commands.

`),ko=q(` `,1),Ao=q(`

`),jo=q(`

Review expired. Review the option again.

`),Mo=q(``),No=q(``),Po=q(``),Fo=q(``),Io=q(``),Lo=q(``),Ro=q(`
`),zo=q(`
`);function Bo(e,t){let n=Fr();We(t,!0);let r=e=>{var t=Pr();Z(z(t),19,()=>G(me),e=>e.id,(e,t,r)=>{var i=fo();let o;var s=R(i),c=B(s,!0),l=V(s),u=B(l),d=V(l),f=e=>{var n=uo(),r=B(n,!0);H(()=>Y(r,G(t).help)),J(e,n)};X(d,e=>{(G(v)?.path===``||G(le))&&e(f)}),N(i),H((e,s)=>{Q(i,`id`,`${n}-${G(r)}`),Q(i,`role`,G(le)?`option`:void 0),Q(i,`aria-selected`,G(le)?G(T)===G(r):void 0),Q(i,`tabindex`,G(le)?-1:void 0),i.disabled=G(g)||G(_e)&&!a(),Q(i,`title`,G(t).help),Q(i,`aria-label`,e),o=li(i,1,`svelte-7bfwr9`,null,o,{suggested:G(T)===G(r)}),Y(c,G(t).label),Y(u,`${G(le)&&G(t).selected?` // CURRENT`:``}${s??``}`)},[()=>G(t).label+(G(le)&&G(t).selected?` // CURRENT`:``)+ae(G(t)),()=>ae(G(t))]),Sr(`focus`,i,()=>{G(le)||ye(G(r))}),K(`click`,i,()=>{ye(G(r)),M(G(t))}),J(e,i)}),J(e,t)},i=Gi(t,`query`,3,``),a=Gi(t,`localOnly`,3,!1),o=Gi(t,`oncopy`,3,()=>{}),s=Gi(t,`onchange`,3,()=>{}),c=Gi(t,`oncomplete`,3,e=>{}),l=co.map(e=>e.next);function u(){return co.map(e=>[`exit`,`quit`].includes(e.next||``)?{...e,help:`Return to Sessions. The local server and Codex sessions remain running.`}:{...e})}function d(){return{title:`/ COMMANDS`,help:`Local Codexometer commands remain available without session control.`,path:``,revision:``,choices:u()}}function f(){L(b,``),L(O,``),L(x,0),L(ne,[],!0)}function p(){w++,L(g,!1),L(h,!1),L(E,i()),f(),L(_,``),G(fe)?s()():c()(i())}async function m(e){if(!l.includes(e))return!1;if(e===`copy`&&!so($.data?.sessions.find(e=>e.id===t.session)))return L(_,`No reply or activity text is available to copy for this session.`),!0;if(e===`copy`){let e=o()();p(),await e}else p(),e===`usage`?location.hash=`/usage`:e===`theme`?ca.requests++:e===`statusline`?sa.open=!0:location.hash=`/sessions`;return!0}let h=I(!1),g=I(!1),_=I(``),v=I(null),y=I(null),b=I(``),x=I(0),S=I(Xt(Date.now())),C=I(``),w=0,T=I(0),E=I(null),D=I(void 0),ee=I(void 0),te=I(void 0),O=I(``),ne=I(Xt([])),re=P(()=>!!G(v)?.inputReview),ie=P(()=>!!G(y)&&!G(re)||!!G(O)||G(ne).length>0);function ae(e){return e.unavailable?e.unavailable.startsWith(`Waiting for idle.`)?` // WAITING FOR IDLE`:` // UNAVAILABLE`:e.next?` →`:e.action?``:` // HELP`}async function oe(e){G(v)&&!(G(ve)&&G(pe))&&L(ne,[...G(ne),{path:G(v).path,index:G(T),input:G(C)}],!0),await j(e)}async function se(){if(!G(ie))return;if(w++,L(g,!1),L(b,``),L(x,0),L(_,``),G(O)){L(O,``),G(D)?.focus();return}if(G(y)&&!G(re)){L(y,null),await ur(),G(D)?.focus();return}let e=G(ne).at(-1);e&&(L(ne,G(ne).slice(0,-1),!0),await j(e.path,e))}function ce(){G(v)&&G(C).trim()&&!G(g)&&!G(_e)&&oe(G(v).path+`/`+encodeURIComponent(G(C).trim()))}let le=P(()=>G(h)&&!!G(v)?.picker&&!G(y)),ue=P(()=>G(h)&&!G(v)?.input&&!G(y)),de=setInterval(()=>{L(S,Date.now(),!0)},1e3);qi(()=>{clearInterval(de),w++});let fe=P(()=>i().trim().startsWith(`/`)&&!i().trim().startsWith(`//`)),pe=P(()=>G(v)?.path===``&&G(fe)?i().trim().slice(1).toLowerCase():``),me=P(()=>(G(v)?.choices||[]).filter(e=>!G(pe)||e.label.toLowerCase().startsWith(`/`+G(pe)))),k=P(()=>G(y)||G(me)[G(T)]),he=P(()=>!!G(b)&&G(S)G(me).find(e=>e.id===G(O))),_e=P(()=>!$.connected||!!$.data?.sessionsError),ve=P(()=>G(h)&&G(fe)&&(!G(v)||G(v).path===``)&&!G(y));yn(()=>{i(),L(T,0)}),yn(()=>{let e=G(T);G(me),G(ue)&&ur().then(()=>{let t=G(D)?.children[e];if(!t||!G(D))return;let n=G(D).getBoundingClientRect(),r=t.getBoundingClientRect();r.topn.bottom&&(G(D).scrollTop+=r.bottom-n.bottom)})});function ye(e){G(T)!==e&&G(v)?.picker&&(L(O,``),L(b,``),L(x,0),L(_,``),w++),L(T,e,!0)}function A(){w++,L(g,!1),L(h,!1),L(E,i()),f(),c()(i())}function be(e){let t=!!G(ee)?.contains(e.target);if(!G(h)||!G(ue)&&!G(y)&&!G(v)?.input||!G(fe)&&!t||G(_e)&&!a()||e.isComposing||e.ctrlKey||e.metaKey||e.altKey)return;if(G(v)?.input){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),A());return}let n=e.key===`ArrowLeft`,r=e.key.toLowerCase()===`f`,o=e.key.toLowerCase()===`c`;if((o||r||n)&&!t||![`ArrowUp`,`ArrowDown`,`Tab`,`Enter`,`Escape`].includes(e.key)&&!o&&!r&&!n||e.key===`Tab`&&(G(y)||G(v)?.path!==``||e.shiftKey)||e.key===`Enter`&&e.target instanceof Element&&e.target.closest(`button`)&&!G(D)?.contains(e.target)&&!e.target.closest(`[data-command-confirm]`)||G(y)&&!t||G(y)&&[`ArrowUp`,`ArrowDown`].includes(e.key))return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){A();return}if(G(g)||e.repeat&&(o||e.key===`Enter`))return;if(n){G(ie)&&se();return}if(r){j(G(v)?.path||``,void 0,!0);return}if(o){(G(y)?.action||G(le)&&G(O))&&Se();return}if(G(y)){e.key===`Enter`&&G(y).action&&!G(he)&&!G(_)&&xe(G(y));return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){ye(Math.min(Math.max(G(T)+(e.key===`ArrowUp`?-1:1),0),Math.max(G(me).length-1,0))),!G(le)&&G(D)?.contains(e.target)&&ur().then(()=>(G(D)?.children[G(T)])?.focus());return}if(e.key===`Enter`&&(G(v)?.path===``||G(v)?.path===`goal`)&&/^\/goal\s+\S/.test(i().trim())){let e=G(v)?.path===`goal`?G(me).find(e=>i().trim().slice(6).trim().toLowerCase()===e.label.toLowerCase()):void 0;if(e){M(e);return}oe(i().trim().slice(1));return}let s=G(me)[G(T)];s&&(e.key===`Tab`?c()(s.label):G(le)?xe(s):M(s))}yn(()=>{G(_e)&&!a()&&(w++,L(g,!1),f(),G(h)&&(L(h,!1),L(E,i())),L(v,null),L(y,null))}),yn(()=>{G(fe)&&!G(h)&&i()!==G(E)&&(!G(_e)||a())&&(f(),L(h,!0),j(``))});async function j(e,n,r=!1){let i=++w;if(G(v)&&L(v,{...G(v),path:e},!0),n&&L(C,n.input,!0),L(g,!0),L(y,null),L(O,``),L(b,``),L(x,0),L(_,``),a())L(v,d(),!0),L(T,n?.index??0,!0),L(g,!1);else try{let a=await ya(`commands`,{session:t.session,command:{mode:`list`,path:e,...r?{refresh:!0}:{}}});i===w&&(a.choices||=[],(e===``||e===`help`)&&(a.choices=[...a.choices.filter(e=>!l.includes(e.label.replace(/^\//,``))),...u()]),L(v,a,!0),L(T,n?Math.min(n.index,Math.max(a.choices.length-1,0)):a.picker?Math.max(a.choices.findIndex(e=>e.selected),0):0,!0),a.picker&&ur().then(()=>G(D)?.focus()),L(C,n?.input??a.value??``,!0),n&&ur().then(()=>{a.input?G(ee)?.querySelector(`input`)?.focus():G(D)?.focus()}),a.inputReview&&a.choices.length===1&&(L(g,!1),M(a.choices[0])))}catch{i===w&&(L(_,`Command catalogue unavailable. Use Codex.`),e===``||e===`help`?(L(v,d(),!0),L(_,``)):L(v,{title:`/`+e,help:``,path:e,revision:``,choices:[]},!0))}finally{i===w&&L(g,!1)}}async function M(e){e.unavailable||G(g)||e.next&&await m(e.next)||G(_)||(G(v)?.picker?(ye(G(me).findIndex(t=>t.id===e.id)),e.action&&!oo($.data?.confirmationMode,!!e.reversible)?await xe(e):G(D)?.focus()):e.next?await oe(e.next):await xe(e))}async function xe(e){if(G(g)||G(_e)||!G(v)||e.unavailable||G(_))return;let n=e.action&&!oo($.data?.confirmationMode,!!e.reversible);if(G(v).picker){if(G(he)&&G(O)===e.id)return;L(O,e.id,!0)}else n||(L(y,e,!0),ur().then(()=>G(te)?.focus()));if(L(b,``),L(x,0),L(_,``),!e.action)return;let r=++w;L(g,!0);try{let n=await ya(`commands`,{session:t.session,command:{mode:`prepare`,path:G(v).path,revision:G(v).revision,choice:e.id}});if(r===w){let e=Date.parse(n.expires);if(!n.confirmation||!Number.isFinite(e)||Date.now()>=e)throw Error(`Review confirmation unavailable`);L(b,n.confirmation,!0),L(x,e,!0)}}catch{r===w&&L(_,`Option changed or unavailable. Refresh before retrying.`)}finally{r===w&&L(g,!1)}n&&r===w&&G(b)&&await Se()}async function Se(){if(!G(b)||G(_e)||G(g)||Date.now()>=G(x)||!G(v)||G(v).picker&&G(O)!==G(me)[G(T)]?.id)return;let e=G(b);L(b,``),L(g,!0);let n=++w;try{let r=await ya(`commands`,{session:t.session,confirmation:e,command:{mode:`commit`,path:G(v).path}});n===w&&(L(_,r.message,!0),L(h,!1),L(v,null),L(y,null),f(),L(E,null),s()())}catch{n===w&&L(_,`Change unconfirmed. Check Codex before retrying.`)}finally{n===w&&L(g,!1)}}var Ce={handleKey:be},we=zo(),Te=R(we),Ee=V(Te,2),De=e=>{var t=po(),n=B(t,!0);H(()=>Y(n,G(_))),J(e,t)};X(Ee,e=>{G(_)&&!G(h)&&e(De)});var Oe=V(Ee,2),ke=e=>{var i=Ro();let o;var s=R(i),c=e=>{var t=_o(),n=z(t),r=B(n,!0),i=V(n,2),a=e=>{var t=ho();Z(t,21,()=>G(v).help.split(` +`),qr,(e,t)=>{var n=mo(),r=B(n,!0);H(()=>{Q(n,`title`,G(t)),Y(r,G(t))}),J(e,n)}),N(t),J(e,t)},o=e=>{var t=go(),n=B(t,!0);H(()=>Y(n,G(v)?.help||`Loading live options…`)),J(e,t)};X(i,e=>{G(v)?.path===`goal`?e(a):e(o,-1)}),H(()=>Y(r,G(v)?.title||`/ COMMANDS`)),J(e,t)};X(s,e=>{G(ve)||e(c)});var l=V(s,2),u=e=>{var t=vo(),n=B(t,!0);H(()=>Y(n,G(_))),J(e,t)};X(l,e=>{G(_)&&e(u)});var d=V(l,2),f=e=>{J(e,yo())};X(d,e=>{G(g)&&e(f)});var p=V(d,2),m=e=>{var t=bo(),r=R(t),i=R(r),o=V(i);Si(o),N(r),N(t),H(e=>{Q(t,`id`,`${n}-input`),Y(i,`${e??``} `),Q(o,`aria-label`,G(v).inputLabel||`Session name`),Q(o,`maxlength`,G(v).inputLimit||512),o.disabled=G(g)||G(_e)&&!a()},[()=>(G(v).inputLabel||`Session name`).toUpperCase()]),Sr(`submit`,t,e=>{e.preventDefault(),ce()}),Di(o,()=>G(C),e=>L(C,e)),J(e,t)},h=e=>{var n=So(),r=R(n),i=B(r,!0),a=V(r,2),o=B(a,!0),s=V(a,2),c=e=>{var n=xo(),r=R(n),i=V(r),a=e=>{J(e,Nr(`Only this session's saved + name changes.`))},o=P(()=>G(v)?.path.startsWith(`rename/`)),s=e=>{J(e,Nr(`Only this session’s + directory changes; project configuration is not reloaded.`))},c=P(()=>G(v)?.path.startsWith(`cd/`)),l=e=>{J(e,Nr(`Only this session's goal + changes.`))},u=P(()=>G(v)?.path.startsWith(`goal/`)),d=e=>{J(e,Nr(`No change sent yet. Model, reasoning and speed settings can + change token usage and cost. Changes affect subsequent turns of + this session, not global defaults. Automatic quota thresholds + may later supersede model settings.`))};X(i,e=>{G(o)?e(a):G(c)?e(s,1):G(u)?e(l,2):e(d,-1)}),N(n),H(()=>Y(r,`TARGET // ${t.session??``}. `)),J(e,n)};X(s,e=>{G(y).action&&e(c)}),N(n),Li(n,e=>L(te,e),()=>G(te)),H(()=>{Y(i,G(y).label),Y(o,G(y).help||`No additional help supplied by Codex.`)}),J(e,n)},w=e=>{var t=ko(),i=z(t),a=e=>{var t=Co(),i=R(t);r(i),N(t),Li(t,e=>L(D,e),()=>G(D)),H(()=>Q(t,`aria-activedescendant`,`${n}-${G(T)}`)),J(e,t)},o=e=>{var t=wo();let n;var i=R(t);r(i),N(t),Li(t,e=>L(D,e),()=>G(D)),H(()=>n=li(t,1,`command-options svelte-7bfwr9`,null,n,{vertical:G(ve)})),J(e,t)};X(i,e=>{G(le)?e(a):e(o,-1)});var s=V(i,2),c=e=>{var t=Do(),n=z(t),r=B(n,!0),i=V(n,2),a=e=>{var t=Eo(),n=z(t),r=B(n),i=V(n,2),a=e=>{J(e,To())};X(i,e=>{G(b)&&G(S)>=G(x)&&e(a)}),H(()=>Y(r,`REVIEW // ${G(ge).label??``}. No change sent yet.`)),J(e,t)};X(i,e=>{G(ge)&&e(a)}),H(()=>Y(r,G(me)[G(T)]?.help)),J(e,t)};X(s,e=>{G(le)&&e(c)});var l=V(s,2),u=e=>{J(e,Oo())};X(l,e=>{!G(g)&&!G(me).length&&e(u)}),J(e,t)};X(p,e=>{G(v)?.input?e(m):G(y)?e(h,1):e(w,-1)});var E=V(p,2),O=e=>{var t=Ao(),n=B(t,!0);H(()=>Y(n,G(k).unavailable)),J(e,t)};X(E,e=>{G(k)?.unavailable&&e(O)});var ne=V(E,2),re=e=>{J(e,jo())};X(ne,e=>{G(b)&&G(S)>=G(x)&&!G(le)&&e(re)});var ae=V(ne,2),oe=R(ae),ue=e=>{var t=Pr(),r=z(t),i=e=>{var t=Mo(),r=B(t,!0);H((e,i)=>{Q(t,`form`,`${n}-input`),t.disabled=e,Y(r,i)},[()=>G(g)||G(_e)||!G(C).trim(),()=>oo($.data?.confirmationMode,!!G(v).reversibleInput)?`ENTER REVIEW`:`ENTER APPLY`]),J(e,t)},o=e=>{var t=Pr(),n=z(t),r=e=>{var t=No();H(()=>t.disabled=G(g)||G(_e)&&!a()),K(`click`,t,Se),J(e,t)},i=P(()=>G(he)&&oo($.data?.confirmationMode,!!G(k).reversible)),o=e=>{var t=Po(),n=B(t,!0);H(e=>{t.disabled=G(g)||G(_e)&&!a(),Y(n,e)},[()=>oo($.data?.confirmationMode,!!G(k).reversible)?`ENTER REVIEW`:`ENTER APPLY`]),K(`click`,t,()=>{G(k)&&xe(G(k))}),J(e,t)};X(n,e=>{G(i)?e(r):e(o,-1)}),J(e,t)},s=e=>{var t=Po(),n=B(t);H(()=>{t.disabled=G(g)||G(_e)&&!a(),Y(n,`ENTER ${G(k).next?`OPEN`:`HELP`}`)}),K(`click`,t,()=>{G(k)&&M(G(k))}),J(e,t)};X(r,e=>{G(v)?.input?e(i):G(k)?.action&&!G(k).unavailable?e(o,1):!G(y)&&G(k)&&!G(k).unavailable&&e(s,2)}),J(e,t)};X(oe,e=>{G(_)||e(ue)});var de=V(oe,2),fe=e=>{var t=Fo();H(()=>t.disabled=G(g)),K(`click`,t,se),J(e,t)};X(de,e=>{G(ie)&&e(fe)});var pe=V(de,2),ye=e=>{var t=Io();H(()=>t.disabled=G(g)),K(`click`,t,()=>j(G(v)?.path||``,void 0,!0)),J(e,t)};X(pe,e=>{G(ve)||e(ye)});var Ce=V(pe,2);N(ae);var we=V(ae,2),Te=e=>{var t=Lo(),n=B(t);H(()=>Y(n,`↑/↓ select${G(ve)?` · Tab complete`:``}`)),J(e,t)};X(we,e=>{!G(v)?.input&&!G(y)&&e(Te)}),N(i),Li(i,e=>L(ee,e),()=>G(ee)),H(()=>{Q(i,`aria-label`,G(ve)?`Slash command suggestions`:`Session command options`),o=li(i,1,`svelte-7bfwr9`,null,o,{"command-popup":G(ve)})}),K(`keydown`,i,be),K(`click`,Ce,A),J(e,i)};return X(Oe,e=>{G(h)&&e(ke)}),N(we),H(()=>Te.disabled=G(_e)&&!a()||G(g)),K(`click`,Te,()=>{L(h,!G(h)),L(E,G(h)?null:i(),!0),L(b,``),G(h)?(L(ne,[],!0),j(``)):A()}),J(e,we),Ge(Ce)}Cr([`click`,`keydown`]);var Vo=q(` `,1),Ho=q(`
`),Uo=q(`
/
`);function Wo(e,t){We(t,!0);let n=P(()=>t.lines.filter(e=>e.kind===`addition`).length),r=P(()=>t.lines.filter(e=>e.kind===`removal`).length);var i=Uo(),a=R(i),o=R(a),s=B(o),c=B(V(o,2));N(a),Z(V(a,2),17,()=>t.lines,qr,(e,t)=>{var n=Ho();let r;var i=R(n),a=e=>{var n=Vo(),r=z(n),i=B(r,!0),a=B(V(r),!0);H(()=>{Y(i,G(t).old||``),Y(a,G(t).new||``)}),J(e,n)};X(i,e=>{G(t).kind!==`heading`&&G(t).kind!==`metadata`&&e(a)});var o=B(V(i),!0);N(n),H(()=>{r=li(n,1,`diff-line svelte-x4gtb6`,null,r,{added:G(t).kind===`addition`,removed:G(t).kind===`removal`,heading:G(t).kind===`heading`}),Y(o,G(t).text)}),J(e,n)}),N(i),H(()=>{Q(a,`aria-label`,`${G(n)} lines added, ${G(r)} lines removed`),Y(s,`+${G(n)??``}`),Y(c,`−${G(r)??``}`)}),J(e,i),Ge()}var Go=q(`

`),Ko=q(``),qo=q(`

Send this saved prompt now? This starts Codex work and consumes quota.

`,1),Jo=q(``),Yo=q(`

 

In memory only. Follows session model, reasoning and speed. Closing + Codexometer cancels pending work.

`),Xo=q(`

HUMAN APPROVAL REQUIRED

Managed policy requires approval each time.

`,1),Zo=q(`

CURRENT PROFILE

MODEL / REASONING LEVEL / SPEED

 

PROPOSED PROFILE

MODEL / REASONING LEVEL / SPEED

 

Applied settings remain after Codexometer closes.

`,1),Qo=q(`

`),$o=q(`

 
`,1),es=q(`

Command unavailable from this observation. Open Codex to inspect the + request.

`),ts=q(`

Session controls temporarily unavailable. Check Codex for current state.

`),ns=q(`

Checking session controls…

`),rs=q(`

`),is=q(`
About browser controls

Controls require a supported live request from a connected shared + app-server session. Local observations alone cannot provide them.

`),as=q(` `,1),os=q(` `),ss=q(`Grants permission beyond this one action. Check the scope + carefully.`),cs=q(``),ls=q(``),us=q(``),ds=q(``),fs=q(`

Not before this time; when quota and idle allow.

`),ps=q(`

`,1),ms=q(`

The existing trigger remains active until saved or deleted. If + it changes or sends while you edit, saving is blocked.

`),hs=q(` `,1),gs=q(``),_s=q(``),vs=q(``),ys=q(` `,1),bs=q(`
  • `),xs=q(`
    View fixed choices

    Type one of these choices exactly. Your answer stays masked.

      `),Ss=q(` `,1),Cs=q(`

      `),ws=q(`

      `,1),Ts=q(` `,1),Es=q(``),Ds=q(`

      `,1),Os=q(`

      `);function ks(e,t){We(t,!0);let n=[],r=Gi(t,`observedCommand`,3,``),i=Gi(t,`observedFileChanges`,19,()=>[]),a=Gi(t,`review`,3,``),o=Gi(t,`suspended`,3,!1),s=Gi(t,`openScheduler`,3,!1),c=Gi(t,`onProtectedChange`,3,e=>{}),l=Gi(t,`oncopy`,3,()=>{}),u=I(null),d=I(Xt([])),f=I(null),p=I(``),m=I(0),h=I(Xt(Date.now())),g=I(!1),_=I(``),v=I(!1),y=I(!1),b=I(``),x=I(!1),S=I(``),C=I(!1),w=I(``),T=I(``),E=I(0),D=I(`now`),ee=I(60),te=I(``),O=I(!1),ne=I(``),re=I(Xt([])),ie=P(()=>G(re).find(e=>e.status!==`sent`)),ae=I(void 0),oe=I(void 0);function se(e){if(G(x)){ur().then(()=>G(ae)?.focus());return}if(e.status!==`pending`||G(g)||!G(u)?.id||G(u).kind!==`prompt`||G(u).questions?.length)return;L(x,!0),L(S,e.id,!0),ur().then(()=>G(ae)?.focus()),L(d,[e.text],!0),L(D,e.trigger===`quota`?`quota`:`at`,!0),L(p,``),L(w,``);let t=new Date(e.at||0);e.trigger!==`quota`&&L(te,new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,16),!0)}yn(()=>{s()&&G(ie)&&!G(C)&&G(u)?.id&&G(u).kind===`prompt`&&!G(u).questions?.length&&(L(C,!0),se(G(ie)))});async function ce(){if(!a())try{L(re,await ya(`schedules`,{session:t.session},M.signal),!0),G(x)&&!G(re).some(e=>e.id===G(S)&&e.status===`pending`)&&L(p,``),G(w)&&!G(re).some(e=>e.id===G(w)&&e.status===`pending`)&&(L(p,``),L(w,``))}catch{}}async function le(e){if(oo($.data?.confirmationMode,!0)&&(G(T)!==e||G(h)>=G(E)))L(T,e,!0),L(E,G(h)+3e4);else{L(T,``);try{L(re,await ya(`schedules`,{session:t.session,cancelId:e},M.signal),!0),L(x,!1),L(p,``),L(w,``),L(d,[],!0)}catch(e){L(_,e instanceof Error?e.message:`Unable to cancel trigger.`,!0)}}}yn(()=>(c()(G(g)||G(d).some(e=>e.length>0)),()=>c()(!1)));let ue=P(()=>$.data?.sessions.find(e=>e.id===t.session)?.status),de=P(()=>!$.connected||!!$.data?.sessionsError),fe=P(()=>a()!==`profile`&&G(u)?.kind===`prompt`&&!G(u).questions?.length&&!!$.data?.profiles?.some(e=>e.session===t.session&&e.pending)),pe=P(()=>!G(de)&&!G(y)&&!!G(u)?.id&&G(u).kind===`approval`&&G(b)!==G(u).id),me=P(()=>G(pe)?G(u).command:r()),k=P(()=>!!G(p)&&G(h)oo($.data?.confirmationMode,G(u)?.kind===`approval`?G(f)!==null&&!G(u).choices?.[G(f)]?.persistent:G(u)?.kind===`profile`?G(f)===1:!(G(u)?.kind!==`prompt`||G(w)||G(x)||!G(u).questions?.length&&G(D)!==`now`))),ge=P(()=>G(u)?.questions?.length?G(u).questions:[{text:`Follow-up message`,secret:!1,freeText:!0,options:[]}]),_e=P(()=>G(u)?.kind===`approval`||G(u)?.kind===`profile`?G(f)!==null:G(d).length===G(ge).length&&G(d).every((e,t)=>e.trim().length>0&&(G(ge)[t].freeText||G(ge)[t].options?.includes(e)))),ve=P(()=>G(u)?.kind===`prompt`&&!G(u).questions?.length&&G(D)!==`now`),ye=P(()=>G(D)===`delay`?G(h)+G(ee)*6e4:Date.parse(G(te))),A=P(()=>{if(!G(ve))return``;if(G(x)&&!G(re).some(e=>e.id===G(S)&&e.status===`pending`))return`Trigger changed, removed or already sent. Go back and reopen it; your draft has not been saved.`;if(!G(d)[0]?.trim())return`Enter a message to schedule.`;if(G(D)===`quota`)return``;if(!Number.isFinite(G(ye))||G(ye)<=G(h))return`Choose a future date/time or a delay greater than zero.`;let e=new Date(G(h));return e.setFullYear(e.getFullYear()+1),G(ye)>=e.getTime()?`Choose a time within one year.`:``});function be(e){return e===void 0?`Not yet available`:new Date(e).toLocaleString([],{timeZoneName:`short`})}function j(e){if(e.status!==`pending`)return e.status;if(e.trigger===`at`&&e.at&&Date.parse(e.at)>G(h))return`Due in `+Math.ceil((Date.parse(e.at)-G(h))/6e4)+` min`;let t=G(de)?`waiting for a fresh connection`:e.waitingReason||(e.canSend?`ready; awaiting dispatch`:`waiting for quota and an eligible idle session`);return(e.trigger===`at`?`Time reached — `:``)+t}yn(()=>{(G(de)||o()||G(fe)||G(h)>=G(m))&&L(p,``)});let M=new AbortController;Ki(()=>{let e=e=>{e.ctrlKey&&e.key.toLowerCase()===`s`&&!a()&&G(ie)&&(e.preventDefault(),se(G(ie)))};window.addEventListener(`keydown`,e);let n,r=setInterval(()=>{L(h,Date.now(),!0)},1e3);async function i(){await ce();try{let e=await ya(`offer`,{session:t.session,...a()?{review:a()}:{}},M.signal);if(M.signal.aborted)return;L(y,!1),G(u)?.id!==e.id&&(L(p,``),L(f,null),L(d,Array(Math.max(1,e.questions?.length||0)).fill(``),!0)),L(u,e,!0),G(v)&&e.id&&e.id!==G(b)&&(L(_,``),L(v,!1))}catch{M.signal.aborted||(L(u,null),L(y,!0),L(p,``))}finally{M.signal.aborted||(n=setTimeout(i,2e3))}}return i(),()=>{window.removeEventListener(`keydown`,e),M.abort(),clearTimeout(n),clearInterval(r)}});async function xe(e){if(!e&&G(u)?.kind===`prompt`&&!G(u).questions?.length&&G(d)[0]?.trim().startsWith(`/`)&&!G(d)[0]?.trim().startsWith(`//`)){L(_,`Choose a slash command from COMMANDS; use // for literal slash text.`);return}if(!G(u)?.id||G(g)||G(de)||o()||G(fe)||(e?!e.canSend:!G(_e)||G(A)))return;let n=G(u).id;L(g,!0),L(_,``),L(v,!1),L(p,``),L(w,e?.id||``,!0);try{let r=!e&&G(u).kind===`prompt`&&!G(u).questions?.length&&G(D)!==`now`?{trigger:G(D)===`quota`?`quota`:`at`,zone:Intl.DateTimeFormat().resolvedOptions().timeZone,...G(D)===`quota`?{}:{at:(G(D)===`delay`?new Date(Date.now()+G(ee)*6e4):new Date(G(te))).toISOString()}}:void 0;L(O,!!r),L(ne,r?r.trigger===`quota`?`After fresh quota becomes available, when the session is idle`:be(r.at)+` — not before this time; when quota and idle allow`:``,!0);let i=await ya(`prepare`,{session:t.session,...a()?{review:a()}:{},offer:n,...e?{sendId:e.id}:{},...r?{schedule:r}:{},...r&&G(x)?{editId:G(S)}:{},...G(u).kind===`approval`||G(u).kind===`profile`?{choice:G(f)}:{answers:e?[e.text]:[...G(d)]}},M.signal);G(u)?.id!==n||M.signal.aborted||G(de)||o()||G(fe)||(L(p,i.confirmation,!0),L(m,Date.parse(i.expires),!0))}catch(e){M.signal.aborted||L(_,e instanceof Error?e.message:`Unable to prepare action.`,!0)}finally{L(g,!1)}!G(he)&&G(p)&&!M.signal.aborted&&await Ce()}async function Ce(){if(!G(u)?.id||G(g)||o()||G(fe)||!G(k))return;let e=G(u).id,n=G(u).kind,r=G(p);L(p,``),L(g,!0),L(b,e,!0);try{await ya(`commit`,{session:t.session,...a()?{review:a()}:{},offer:e,confirmation:r},M.signal),L(v,!0),L(x,!1),G(O)&&(L(b,``),await ce()),L(_,G(O)?`Trigger set. Closing Codexometer cancels it.`:n===`profile`?`Profile decision completed.`:n===`approval`?`Decision sent.`:`Text sent.`,!0)}catch(e){L(_,e instanceof _a?e.message:`Outcome uncertain. Check Codex before taking another action; nothing was retried.`,!0)}finally{L(g,!1),L(w,``),await ce(),L(d,[],!0),L(f,null)}}var we=as(),Te=z(we),Ee=e=>{var t=Pr();Z(z(t),17,()=>G(re).filter(e=>e.status!==`sent`),e=>e.id,(e,t)=>{var n=Yo(),r=R(n),i=B(r,!0),a=V(r,2),s=B(a),c=V(a,2),l=B(c,!0),d=V(c,2),f=B(d,!0),m=V(d,2),v=B(m,!0),y=V(m,2),b=e=>{var t=Go(),n=B(t,!0);H(()=>Y(n,G(_))),J(e,t)};X(y,e=>{G(_)&&e(b)});var x=V(y,4),S=V(x,2),C=B(S,!0),D=V(S,2),ee=e=>{var t=Ko();K(`click`,t,()=>{L(T,``)}),J(e,t)};X(D,e=>{G(T)===G(t).id&&G(h){var n=qo(),r=V(z(n),2),i=V(r,2);H(()=>r.disabled=G(g)||G(de)||!G(t).canSend),K(`click`,r,Ce),K(`click`,i,()=>{L(p,``),L(w,``)}),J(e,n)},ne=e=>{var n=Jo();H(()=>n.disabled=G(g)||G(de)||!G(t).canSend||o()),K(`click`,n,()=>xe(G(t))),J(e,n)};X(te,e=>{G(k)&&G(w)===G(t).id?e(O):e(ne,-1)}),N(n),H((e,n)=>{Y(i,G(t).status===`uncertain`?`CHECK TRIGGER — outcome uncertain; not retried`:`SCHEDULED FOLLOW-UP`),Y(s,`TARGET // ${G(t).session??``}`),Y(l,e),Y(f,n),Y(v,G(t).text),x.disabled=G(g)||!G(u)?.id||G(u).kind!==`prompt`||!!G(u).questions?.length||G(t).status!==`pending`,S.disabled=G(g)||G(t).status===`sending`,Y(C,G(T)===G(t).id&&G(h)G(t).trigger===`quota`?`After confirmed quota recovery, when idle`:`Not before ${be(G(t).at)}`,()=>j(G(t))]),K(`click`,x,()=>se(G(t))),K(`click`,S,()=>le(G(t).id)),J(e,n)}),J(e,t)},De=P(()=>!a()&&G(u)?.kind!==`approval`&&!G(u)?.questions?.length&&![`APPROVAL NEEDED`,`INPUT NEEDED`].includes(G(ue)||``));X(Te,e=>{G(De)&&e(Ee)});var Oe=V(Te,2),ke=e=>{var r=Os(),o=R(r),s=B(o,!0),c=V(o,2),S=e=>{var t=Xo();Se(2),J(e,t)};X(c,e=>{G(u)?.requiredHumanApproval&&!G(de)&&!G(y)&&e(S)});var C=V(c,2),w=e=>{var t=Zo(),n=z(t),r=B(n),i=V(n,6),a=B(i,!0),o=B(V(i,6),!0);Se(2),H(()=>{Y(r,`Your ${G(u).profile.threshold??``}% quota threshold has been reached. Review + the profile for subsequent turns.`),Y(a,G(u).profile.current),Y(o,G(u).profile.proposed)}),J(e,t)};X(C,e=>{G(u)?.profile&&!G(de)&&!G(y)&&e(w)});var T=V(C,2),E=e=>{var t=Qo();let n;var r=B(t,!0);H(()=>{n=li(t,1,`svelte-1oupzfc`,null,n,{notice:!G(v),sent:G(v)}),Y(r,G(_))}),J(e,t)};X(T,e=>{G(_)&&e(E)});var re=V(T,2),ie=e=>{Wo(e,{get lines(){return G(u).fileChanges}})},se=e=>{Wo(e,{get lines(){return i()}})},ce=e=>{var t=$o(),n=z(t),r=B(n,!0),i=B(V(n,2),!0);H(()=>{Y(r,G(pe)?`EXACT COMMAND`:`LAST OBSERVED COMMAND`),Y(i,G(me))}),J(e,t)},le=e=>{J(e,es())};X(re,e=>{G(u)?.fileChanges?.length&&!G(de)&&!G(y)?e(ie):i().length?e(se,1):G(me)?e(ce,2):a()!==`profile`&&G(ue)===`APPROVAL NEEDED`&&!G(v)&&e(le,3)});var fe=V(re,2),ve=e=>{J(e,ts())},j=e=>{J(e,ns())},M=e=>{var t=as(),n=z(t),r=e=>{var t=rs(),n=B(t,!0);H(e=>Y(n,e),[()=>G(ue)===`WORKING`?`Codex is working — nothing to respond to.`:[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(G(ue)||``)?`Respond in Codex for this request.`:`Nothing needs a response right now.`]),J(e,t)};X(n,e=>{(G(ue)===`WORKING`||!G(v)&&!G(g))&&e(r)});var i=V(n,2),a=e=>{J(e,is())},o=P(()=>[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(G(ue)||``)&&!G(v));X(i,e=>{G(o)&&e(a)}),J(e,t)},we=e=>{var r=Ds(),i=z(r),o=B(i),s=V(i,2),c=R(s),_=B(c,!0),v=V(c,2),y=e=>{var r=Pr();Z(z(r),17,()=>G(u).choices||[],qr,(e,r,i)=>{var o=cs(),s=R(o);Si(s),s.value=s.__value=i;var c=V(s),l=V(c),u=e=>{var t=os(),n=B(t,!0);H(()=>Y(n,G(r).detail)),J(e,t)};X(l,e=>{G(r).detail&&e(u)});var d=V(l,2),p=e=>{J(e,ss())};X(d,e=>{G(r).persistent&&e(p)}),N(o),H(()=>{Q(s,`name`,`decision-`+t.session+`-`+a()),Y(c,` ${G(r).label??``} `)}),ki(n,[],s,()=>G(f),e=>L(f,e)),J(e,o)}),J(e,r)},b=e=>{var n=as(),r=z(n),i=e=>{var t=hs(),n=z(t),r=V(R(n)),i=R(r),a=e=>{var t=ls();t.value=t.__value=`now`,J(e,t)};X(i,e=>{G(x)||e(a)});var o=V(i);o.value=o.__value=`quota`;var s=V(o);s.value=s.__value=`delay`;var c=V(s);c.value=c.__value=`at`,N(r),hi(r),N(n);var l=V(n,2),u=e=>{var t=us(),n=V(R(t));Si(n),N(t),Di(n,()=>G(ee),e=>L(ee,e)),J(e,t)};X(l,e=>{G(D)===`delay`&&e(u)});var d=V(l,2),f=e=>{var t=ds(),n=V(R(t));Si(n),N(t),Di(n,()=>G(te),e=>L(te,e)),J(e,t)};X(d,e=>{G(D)===`at`&&e(f)});var p=V(d,2),m=e=>{var t=ps(),n=z(t),r=B(n),i=V(n,2),a=e=>{J(e,fs())};X(i,e=>{G(D)!==`quota`&&e(a)});var o=V(i,2);o.textContent=`Timezone: ${Intl.DateTimeFormat().resolvedOptions().timeZone??``}. + One pending request per session; saving replaces it. Memory + only; Codexometer must stay running. Uses session model, + reasoning and speed.`,H(e=>Y(r,`Will send: ${e??``}`),[()=>G(D)===`quota`?`when quota is available and this session is idle`:Number.isFinite(G(ye))?be(G(ye)):`choose a date and time`]),J(e,t)};X(p,e=>{G(D)!==`now`&&e(m)});var h=V(p,2),g=e=>{J(e,ms())};X(h,e=>{G(x)&&e(g)}),gi(r,()=>G(D),e=>L(D,e)),J(e,t)};X(r,e=>{G(u).questions?.length||e(i)}),Z(V(r,2),17,()=>G(ge),qr,(e,n,r)=>{var i=Ss(),o=z(i),s=e=>{{let n=P(()=>G(d)[0]||``);Li(Bo(e,{get session(){return t.session},get oncopy(){return l()},get query(){return G(n)},oncomplete:e=>{L(d,[e],!0),ur().then(()=>G(ae)?.focus())},onchange:()=>{L(d,[``],!0),ur().then(()=>G(ae)?.focus())}}),e=>L(oe,e,!0),()=>G(oe))}};X(o,e=>{r===0&&a()!==`profile`&&G(u).kind===`prompt`&&!G(u).questions?.length&&e(s)});var c=V(o,2),f=R(c),p=V(f),m=e=>{var t=gs();Si(t),Di(t,()=>G(d)[r],e=>G(d)[r]=e),J(e,t)},h=e=>{var t=vs(),i=R(t);i.value=i.__value=``,Z(V(i),17,()=>G(n).options||[],qr,(e,t)=>{var n=_s(),r=B(n,!0),i={};H(()=>{Y(r,G(t)),i!==(i=G(t))&&(n.value=(n.__value=i)??``)}),J(e,n)}),N(t),hi(t),gi(t,()=>G(d)[r],e=>G(d)[r]=e),J(e,t)},g=e=>{var t=ys(),i=z(t);nt(i),Li(i,e=>L(ae,e),()=>G(ae));var a=V(i,2),o=e=>{var t=rs(),r=B(t);H(e=>Y(r,`Suggested answers: ${e??``}`),[()=>G(n).options.join(` · `)]),J(e,t)};X(a,e=>{G(n).options?.length&&e(o)}),K(`keydown`,i,e=>{G(u)?.kind===`prompt`&&!G(u).questions?.length&&G(oe)?.handleKey(e)}),Di(i,()=>G(d)[r],e=>G(d)[r]=e),J(e,t)};X(p,e=>{G(n).secret?e(m):G(n).freeText?e(g,-1):e(h,1)}),N(c);var _=V(c,2),v=e=>{var t=xs(),r=V(R(t),4);Z(r,21,()=>G(n).options||[],qr,(e,t)=>{var n=bs(),r=B(n,!0);H(()=>Y(r,G(t))),J(e,n)}),N(r),N(t),J(e,t)};X(_,e=>{G(n).secret&&!G(n).freeText&&e(v)}),H(()=>Y(f,`${G(n).text??``} `)),J(e,i)}),J(e,n)};X(v,e=>{G(u).kind===`approval`||G(u).kind===`profile`?e(y):e(b,-1)}),N(s);var S=V(s,2),C=e=>{var t=ws(),n=z(t),r=e=>{var t=Cs(),n=B(t);H(()=>Y(n,`TRIGGER // ${G(ne)??``}`)),J(e,t)};X(n,e=>{G(O)&&e(r)});var i=V(n,2),a=B(i),o=V(i,2),s=B(o),c=V(o,2);H(e=>{Y(a,`Check the target and ${G(u).kind===`profile`?`profile above`:G(u).kind===`approval`?G(u).fileChanges?.length?`proposed file changes above`:`exact command and permission scope`:`message above`}. ${G(O)?`This schedules a follow-up that will send automatically when eligible`:`This will send to Codex`}; it may start work using your quota. + Confirmation expires in ${e??``}s.`),o.disabled=G(g)||G(de),Y(s,`CONFIRM ${(G(u).kind===`approval`||G(u).kind===`profile`?G(u).choices?.[G(f)]?.label:G(O)?G(x)?`SAVE CHANGES`:`SCHEDULE`:`SEND`)??``}`)},[()=>Math.max(0,Math.ceil((G(m)-G(h))/1e3))]),K(`click`,o,Ce),K(`click`,c,()=>{L(p,``)}),J(e,t)},w=e=>{var t=Ts(),n=z(t),r=e=>{var t=Go(),n=B(t,!0);H(()=>Y(n,G(A))),J(e,t)};X(n,e=>{G(A)&&e(r)});var i=V(n,2),a=B(i,!0);H(()=>{i.disabled=G(g)||G(de)||!G(_e)||!!G(A),Y(a,G(g)?`SENDING…`:G(he)?G(x)?`REVIEW CHANGES`:`REVIEW BEFORE SENDING`:G(x)?`SAVE CHANGES`:G(u).kind===`approval`||G(u).kind===`profile`?`SEND DECISION`:G(u).kind===`prompt`&&!G(u).questions?.length&&G(D)!==`now`?`SET TRIGGER`:`SEND`)}),K(`click`,i,()=>xe()),J(e,t)};X(S,e=>{G(k)&&G(he)?e(C):e(w,-1)});var T=V(S,2),E=e=>{var t=Es();K(`click`,t,()=>{L(x,!1),L(p,``),L(d,[],!0)}),J(e,t)};X(T,e=>{G(x)&&e(E)}),H(()=>{Y(o,`TARGET // ${G(u).thread??``} // ${(G(u).directory||`Directory unavailable`)??``}`),s.disabled=G(g)||G(k)||G(de),Y(_,G(u).kind===`approval`||G(u).kind===`profile`?`Choose a decision`:G(x)?`EDIT SCHEDULED FOLLOW-UP`:`Reply to this session`)}),J(e,r)};X(fe,e=>{G(de)||G(y)?e(ve):G(u)?G(u).id?G(b)!==G(u).id&&e(we,3):e(M,2):e(j,1)}),N(r),H(()=>Y(s,a()===`profile`?`QUOTA THRESHOLD`:`SESSION CONTROL // EXPERIMENTAL`)),J(e,r)};X(Oe,e=>{!G(fe)&&(!G(ie)||G(x)||a()||G(u)?.kind!==`prompt`||G(u).questions?.length)&&e(ke)}),J(e,we),Ge()}Cr([`click`,`keydown`]);var As=q(` `);function js(e,t){We(t,!0);let n=Gi(t,`stale`,3,!1),r=P(()=>n()||!!t.goal?.stale);var i=Pr(),a=z(i),o=e=>{var n=As();let i;var a=B(n,!0);H((e,o)=>{i=li(n,1,`goal-status svelte-1yfu3xi`,null,i,{stale:G(r),pursuing:!G(r)&&t.goal.status===`active`,blocked:e}),Q(n,`title`,o),Y(a,G(r)?`GOAL STALE`:t.goal.label)},[()=>!G(r)&&[`blocked`,`usageLimited`,`budgetLimited`].includes(t.goal.status),()=>t.goal.objective+` +`+t.goal.tokensUsed.toLocaleString()+(t.goal.tokenBudget===null?` tokens`:` / `+t.goal.tokenBudget.toLocaleString()+` tokens`)]),J(e,n)};X(a,e=>{t.goal&&e(o)}),J(e,i),Ge()}var Ms=q(` `,1),Ns=q(`
      `),Ps=q(`

      STATUS LINE // CODEXOMETER

      Choose multiple fields and their order. These display preferences do not + change Codex CLI configuration. Missing values are omitted.

      `),Fs=q(`

      `,1);function Is(e,t){We(t,!0);let n=Gi(t,`stale`,3,!1),r=I(Xt([])),i=I(!1),a=P(()=>$.data?.statusLineFields||[]),o=e=>[...new Set(e??G(a).filter(e=>e.default).map(e=>e.id))].filter(e=>G(a).some(t=>t.id===e)),s=e=>o(e).map(e=>e===`run-state`&&(n()||!$.connected||$.data?.sessionsError)?`STALE`:t.session.statusLine?.[e]).filter(Boolean).join(` · `),c=P(()=>[...G(r).map(e=>G(a).find(t=>t.id===e)).filter(Boolean),...G(a).filter(e=>!G(r).includes(e.id))]);yn(()=>{sa.open&&!G(i)?(L(r,o(oa.statusLine),!0),L(i,!0)):sa.open||L(i,!1)});function l(e,t){L(r,t?[...G(r),e]:G(r).filter(t=>t!==e),!0)}function u(e,t){let n=G(r).indexOf(e),i=n+t;if(n<0||i<0||i>=G(r).length)return;let a=[...G(r)];[a[n],a[i]]=[a[i],a[n]],L(r,a,!0)}var d=Fs(),p=z(d),m=e=>{var t=Ps(),n=V(R(t),4);Z(n,21,()=>G(c),e=>e.id,(e,t)=>{var n=Ns(),i=R(n),a=R(i);Si(a);var o=V(a,1,!0),s=B(V(o),!0);N(i);var c=V(i,2),d=e=>{var n=Ms(),i=z(n),a=V(i,2);H((e,n)=>{Q(i,`aria-label`,`Move `+G(t).label+` earlier`),i.disabled=e,Q(a,`aria-label`,`Move `+G(t).label+` later`),a.disabled=n},[()=>G(r).indexOf(G(t).id)===0,()=>G(r).indexOf(G(t).id)===G(r).length-1]),K(`click`,i,()=>u(G(t).id,-1)),K(`click`,a,()=>u(G(t).id,1)),J(e,n)},f=P(()=>G(r).includes(G(t).id));X(c,e=>{G(f)&&e(d)}),N(n),H(e=>{Q(i,`title`,G(t).help),Ci(a,e),Y(o,G(t).label),Y(s,G(t).help)},[()=>G(r).includes(G(t).id)]),K(`change`,a,e=>l(G(t).id,e.currentTarget.checked)),J(e,n)}),N(n);var i=V(n,2),a=B(i),o=V(i,2),d=V(o,2);N(t),H(e=>Y(a,`Preview // ${e??``}`),[()=>s(G(r))||`—`]),K(`click`,o,()=>{oa.statusLine=[...G(r)],la(),sa.open=!1}),K(`click`,d,()=>{sa.open=!1}),J(e,t)};X(p,e=>{sa.open&&e(m)});var h=V(p,2),g=R(h),_=B(g,!0),v=V(g,2);{let e=P(()=>n()||!$.connected||!!$.data?.sessionsError);js(v,{get goal(){return t.session.goal},get stale(){return G(e)}})}var y=V(v,2);ni(V(y,2),()=>t.children??f),N(h),H((e,t)=>{Q(g,`title`,e),Y(_,t)},[()=>s(oa.statusLine),()=>s(oa.statusLine)]),K(`click`,y,()=>{sa.open=!sa.open}),J(e,d),Ge()}Cr([`change`,`click`]);var Ls=q(`
      `);function Rs(e,t){We(t,!0);let n=Gi(t,`active`,3,!1),r=Gi(t,`compact`,3,!1),i=P(()=>so(t.session)),a=P(()=>!!G(i)),o=I(!1),s=I(``),c=I(!1);yn(()=>{if(!G(c))return;let e=setTimeout(()=>{L(c,!1)},150);return()=>clearTimeout(e)}),yn(()=>{G(i),t.session.status,L(s,``)});async function l(){if(!G(a)||G(o))return;let e=G(i);L(o,!0),L(c,!0),L(s,``);try{await navigator.clipboard.writeText(e),G(i)===e&&L(s,`Copied.`)}catch{G(i)===e&&L(s,`Clipboard unavailable. Select the visible text and copy it manually.`)}finally{L(o,!1)}}function u(e){!n()||!G(a)||e.defaultPrevented||e.repeat||e.ctrlKey||e.metaKey||e.altKey||e.key.toLowerCase()!==`c`||e.target instanceof Element&&e.target.closest(`input, textarea, select, [contenteditable]`)||(e.preventDefault(),l())}var d={copy:l},f=Pr();Sr(`keydown`,$t,u);var p=z(f),m=e=>{var t=Ls();let n;var i=R(t),a=B(i,!0),u=V(i,2);let d;N(t),H(()=>{n=li(t,1,`session-copy svelte-543j00`,null,n,{compact:r()}),Y(a,G(s)),u.disabled=G(o),d=li(u,1,`svelte-543j00`,null,d,{flashed:G(c)})}),K(`click`,u,l),J(e,t)};return X(p,e=>{G(a)&&e(m)}),J(e,f),Ge(d)}Cr([`click`]);var zs=q(`

       
      `,1),Bs=q(`

      LATEST GUIDANCE

       
      `,1),Vs=q(`

      CONTEXT

       

      `,1),Hs=q(`

      `),Us=q(`

      `),Ws=q(`
       
      `),Gs=q(`

       
      `,1),Ks=q(`
       
      `),qs=q(`

      Command unavailable from this observation. Open Codex to inspect the + request.

      `),Js=q(`

      `,1),Ys=q(`

      `),Xs=q(` `,1),Zs=q(`

      `),Qs=q(`
      `),$s=q(`

      Session connection or refresh unavailable. Context and telemetry may be + stale.

      `),ec=q(`

      Some quota profile checks are unavailable. Only sessions with freshly + verified quota and settings can be updated; previous outcome notices remain + visible.

      `),tc=q(` `),nc=q(` `),rc=q(` `),ic=q(``),ac=q(`

      Read only — reply or approve in Codex.

      `),oc=q(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),sc=q(`
      `),cc=q(` `,1),lc=q(`
      `),uc=q(`

      This session is no longer in the current observation. Return to sessions.

      `),dc=q(`

      `),fc=q(``),pc=q(`

      `),mc=q(` `),hc=q(`

      `),gc=q(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),_c=q(`

      `),vc=q(`

      TOKEN ACTIVITY // 30 SECOND SAMPLES

      `),yc=q(`

      TOKENS

      FULL DETAIL →
      `),bc=q(`

      No locally observed sessions yet. Keep Codex running alongside + Codexometer.

      `),xc=q(`

      ↑ ↓ SELECT SESSION // ← LESS DETAIL // → MORE DETAIL // ESC BACK

      `,1),Sc=q(`

      SESSION TOTALS

      `,1);function Cc(e,t){We(t,!0);let n=(e,t=f,n,r)=>{let i=mt(()=>g(n?.(),!0)),a=mt(()=>g(r?.(),!1));var o=Xs(),s=z(o),c=e=>{var n=zs(),r=z(n),i=B(r,!0),a=B(V(r,2),!0);H(()=>{Y(i,t().contextKind===`LAST REPLY`&&!t().streaming?`TASK`:`CURRENT TASK`),Y(a,t().currentTask)}),J(e,n)};X(s,e=>{t().currentTask&&e(c)});var l=V(s,2),u=e=>{var n=Bs(),r=B(V(z(n),2),!0);H(()=>Y(r,t().latestGuidance)),J(e,n)};X(l,e=>{t().latestGuidance&&e(u)});var d=V(l,2),p=e=>{var n=Vs(),r=B(V(z(n),2),!0);Se(2),H(()=>Y(r,t().approvalContext)),J(e,n)};X(d,e=>{G(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(p)});var m=V(d,2),h=e=>{var n=Hs();let r;var i=B(n,!0);H(e=>{r=li(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),Y(i,e)},[()=>ie(t())]),J(e,n)},_=P(()=>ie(t())&&(!G(a)||G(v)||t().status===`CHECK SESSION`||y(t())));X(m,e=>{G(_)&&e(h)});var b=V(m,2),x=e=>{var n=Us(),r=B(n,!0);H(e=>Y(r,e),[()=>ae(t())]),J(e,n)};X(b,e=>{G(i)&&e(x)});var S=V(b,2),C=e=>{var n=Ws(),r=B(n,!0);H(()=>Y(r,t().text||`No session context available.`)),J(e,n)};X(S,e=>{(t().text||!t().workingCommand)&&e(C)});var w=V(S,2),T=e=>{var n=Gs(),r=V(z(n),2),i=R(r),a=V(i),o=e=>{var n=Nr();H(()=>Y(n,`// ${t().commandTiming??``}`)),J(e,n)};X(a,e=>{t().commandTiming&&e(o)});var s=V(a,2),c=e=>{var n=Nr();H(()=>Y(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),J(e,n)};X(s,e=>{!G(v)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(c)});var l=V(s,2),u=e=>{J(e,Nr(`+`))};X(l,e=>{t().runningLimited&&e(u)}),N(r);var d=B(V(r,2),!0);H(e=>{Y(i,`COMMAND // ${e??``} `),Y(d,t().workingCommand)},[()=>G(v)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),J(e,n)};X(w,e=>{t().workingCommand&&e(T)});var E=V(w,2),D=e=>{Wo(e,{get lines(){return t().fileChanges}})},ee=e=>{var n=Js(),r=V(z(n),2),i=B(r,!0),a=V(r,2),o=e=>{var n=Ks(),r=B(n,!0);H(()=>Y(r,t().command)),J(e,n)},s=e=>{J(e,qs())};X(a,e=>{t().command?e(o):e(s,-1)}),H(()=>Y(i,G(v)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),J(e,n)};X(E,e=>{(!G(a)||!$.data?.control)&&t().fileChanges?.length?e(D):G(a)&&$.data?.control||!t().command&&t().status!==`APPROVAL NEEDED`||e(ee,1)});var te=V(E,2),O=e=>{var n=Ys(),r=B(n);H(()=>Y(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),J(e,n)};X(te,e=>{G(a)||e(O)}),J(e,o)},r=I(void 0),i=Gi(t,`params`,19,()=>({})),a=P(()=>$.data?.sessions||[]),o=P(()=>$.data?.control&&$.data.profiles||[]),s=P(()=>($.data?.triggers||[]).filter(e=>G(a).some(t=>t.id===e.session)));function c(e,t){i().id&&i().id!==t&&G(u)?e.preventDefault():O(t)}function l(e){return[`TURN COMPLETE`,`IDLE`,`ACTIVE`].includes(e.status)&&G(s).some(t=>t.session===e.id)?`TRIGGER SET`:e.status}let u=I(!1);function d(e,t){i().id&&i().id!==t&&G(u)?e.preventDefault():O(t)}yn(()=>{let e=i().id;e&&pr(()=>{oa.selected=e,pa(e,2)})});let p=P(()=>G(a).find(e=>e.id===i().id)),m=P(()=>new URLSearchParams(Xi.querystring).get(`review`)===`profile`&&G(o).some(e=>e.session===i().id&&e.pending)),h=P(()=>G(a).some(e=>e.id===oa.selected)?oa.selected:G(a)[0]?.id),v=P(()=>!$.connected||!!$.data?.sessionsError);function y(e){return e.status!==`STALE`&&e.failed===!0}let b=P(()=>[[`OBSERVED TOKENS`,ma(G(a).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,ma(G(a).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`ERRORS`,`ERRORS`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,G(v)?`—`:ma(G(a).filter(e=>t===`ERRORS`?y(e):e.status===t).length)])]),x=P(()=>G(a).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`].includes(e.status)||y(e)).sort((e,t)=>S(e)-S(t)));function S(e){return e.status===`APPROVAL NEEDED`?0:e.status===`INPUT NEEDED`?1:2}let C=P(()=>G(a).filter(e=>e.status===`TURN COMPLETE`&&(!e.readStateKnown||e.unread)&&!G(s).some(t=>t.session===e.id)&&!G(o).some(t=>t.session===e.id&&t.pending))),w=I(``),T=new Set;async function E(e){if(!$.data?.control||G(v)||!e.unread||!e.readRevision||!e.replyTurn||e.streaming||G(m))return;let t=e.id,n=e.readRevision,r=e.replyTurn,i=JSON.stringify([t,n,r]);if(!T.has(i)){T.add(i);try{await ur();let e=G(a).find(e=>e.id===t),i=document.getElementById(`content`),o=i?.getBoundingClientRect(),s=o?o.left+i.clientLeft:0,c=o?o.top+i.clientTop:0,l=s+(i?.clientWidth||0),u=c+(i?.clientHeight||0);if(!Array.from(document.querySelectorAll(`[data-result-session]`)).some(e=>{let n=e.getBoundingClientRect();return i?.contains(e)&&e.dataset.resultSession===t&&e.dataset.resultTurn===r&&!e.closest(`[inert], [hidden]`)&&document.visibilityState===`visible`&&n.leftMath.max(0,s)&&n.topMath.max(0,c)&&n.width>0&&n.height>0})||e?.readRevision!==n||e?.replyTurn!==r||G(v))return;await ya(`read`,{session:t,read:{turn:r,revision:n}}),L(w,``)}catch{L(w,`Result changed or could not be marked read. Open it again to retry.`)}finally{T.delete(i)}}}function D(e){O(e);let t=G(a).find(t=>t.id===e);t&&E(t)}let ee=I(Xt(pr(()=>i().id||``))),te=I(``);yn(()=>{let e=i().id||``;e!==G(ee)&&(L(ee,e,!0),L(te,e,!0))}),yn(()=>{if(G(te)&&G(p)?.id===G(te)){let e=G(p);L(te,``),pr(()=>{E(e)})}});function O(e){oa.selected=e,ur().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function ne(e,t){if(O(e),i().id){t<0&&(pa(e,2),location.hash=`/sessions`);return}let n=da(e)+t;if(n>2)location.hash=`/sessions/`+encodeURIComponent(e);else if(pa(e,n),t>0){let t=G(a).find(t=>t.id===e);t&&E(t)}}function re(e){let t=e.target;if(!(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||t.closest(`input, textarea, select, [contenteditable="true"]`))){if(e.key===`Escape`&&i().id)e.preventDefault(),ne(i().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(i().id||G(h)))e.preventDefault(),ne(i().id||G(h),e.key===`ArrowLeft`?-1:1);else if(!i().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&G(a).length){e.preventDefault();let t=G(a).findIndex(e=>e.id===G(h));O(G(a)[Math.max(0,Math.min(G(a).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function ie(e){return G(v)?`Last observation only — refresh unavailable. Check Codex for current state.`:e.status===`CHECK SESSION`?`INFERRED INACTIVITY — a quiet session, not a confirmed input or approval request. Local tools may still be running.`:y(e)?e.status===`MODEL BUSY`?`CONFIRMED TURN FAILURE — the selected model was at capacity. Choose another model with /model or retry when ready. This is not a quota-exhaustion signal.`:e.status===`MODEL UNAVAILABLE`?`CONFIRMED TURN FAILURE — the provider could not find the selected model. Choose an available model with /model. No automatic retry or model change.`:e.status===`CAPACITY RESTRICTED`?`CONFIRMED TURN FAILURE — capacity is unavailable on a policy-restricted route. Inspect the error before changing settings or retrying. This is not a quota-exhaustion signal; no automatic retry or policy change.`:`CONFIRMED TURN FAILURE — inspect the error below before sending another prompt. No automatic retry or model change.`:$.data?.control&&[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(e.status)?`Open full detail for supported live controls; otherwise reply in Codex.`:e.status===`APPROVAL NEEDED`?`OBSERVED APPROVAL SIGNAL — approve or decline in Codex.`:e.status===`INPUT NEEDED`?`OBSERVED INPUT SIGNAL — reply in Codex.`:e.status===`TURN COMPLETE`?`OBSERVED TURN COMPLETION — informational, not an approval request.`:``}function ae(e){return e.streaming&&e.contextKind===`LAST REPLY`?`REPLY // STREAMING`:e.contextKind||`LAST ACTIVITY`}var oe=Sc();Sr(`keydown`,$t,re);var se=z(oe),ce=e=>{var t=Zs(),n=B(t,!0);H(()=>Y(n,G(w))),J(e,t)};X(se,e=>{G(w)&&e(ce)});var le=V(se,2),ue=B(V(R(le),2));N(le);var de=V(le,2);let fe;Z(de,21,()=>G(b),qr,(e,t)=>{var n=P(()=>_(G(t),2));let r=()=>G(n)[0],i=()=>G(n)[1];var a=Qs();let o;var s=R(a),c=B(s,!0),l=B(V(s,2),!0);N(a),H(()=>{o=li(a,1,`svelte-mm4wfe`,null,o,{failed:r()===`ERRORS`&&i()!==`0`&&i()!==`—`}),Y(c,r()),Y(l,i())}),J(e,a)}),N(de);var pe=V(de,2),me=B(pe),k=V(pe,2),he=e=>{J(e,$s())};X(k,e=>{G(v)&&e(he)});var ge=V(k,2),_e=e=>{J(e,ec())};X(ge,e=>{$.data?.profileError&&e(_e)});var ve=V(ge,2),ye=e=>{var t=ic(),n=R(t);Z(n,17,()=>G(x),qr,(e,t)=>{var n=tc();let r;var i=B(n);H((e,a,o)=>{r=li(n,1,`button`,null,r,{approval:e}),Q(n,`href`,a),Y(i,`${G(t).status??``} + ${o??``} // ${(G(t).name||G(t).directory||G(t).id)??``}`)},[()=>G(t).status===`APPROVAL NEEDED`||G(t).status===`INPUT NEEDED`||y(G(t)),()=>`#/sessions/`+encodeURIComponent(G(t).id),()=>Array.from(G(t).id).slice(-5).join(``).toUpperCase()]),K(`click`,n,()=>O(G(t).id)),J(e,n)});var r=V(n,2);Z(r,17,()=>G(o).filter(e=>e.pending&&G(a).some(t=>t.id===e.session)),qr,(e,t)=>{var n=nc(),r=B(n);H((e,a,o)=>{Q(n,`title`,i().id&&i().id!==G(t).session&&G(u)?`Finish sending or clear your current draft before switching sessions.`:`Review this session’s quota threshold`),Q(n,`href`,e),Y(r,`QUOTA THRESHOLD ${a??``} // ${o??``}`)},[()=>`#/sessions/`+encodeURIComponent(G(t).session)+`?review=profile`,()=>Array.from(G(t).session).slice(-5).join(``).toUpperCase(),()=>G(a).find(e=>e.id===G(t).session)?.name||G(a).find(e=>e.id===G(t).session)?.directory||G(t).session]),K(`click`,n,e=>d(e,G(t).session)),J(e,n)});var l=V(r,2);Z(l,17,()=>G(C),qr,(e,t)=>{var n=rc(),r=B(n);H((e,i)=>{Q(n,`href`,e),Y(r,`TURN COMPLETE ${i??``} // + ${(G(t).name||G(t).directory||G(t).id)??``}`)},[()=>`#/sessions/`+encodeURIComponent(G(t).id),()=>Array.from(G(t).id).slice(-5).join(``).toUpperCase()]),K(`click`,n,()=>O(G(t).id)),J(e,n)}),Z(V(l,2),17,()=>G(s),qr,(e,t)=>{var n=rc(),r=B(n);H((e,t,i)=>{Q(n,`href`,e),Y(r,`TRIGGER SET ${t??``} // ${i??``}`)},[()=>`#/sessions/`+encodeURIComponent(G(t).session),()=>Array.from(G(t).session).slice(-5).join(``).toUpperCase(),()=>G(a).find(e=>e.id===G(t).session)?.name||G(a).find(e=>e.id===G(t).session)?.directory]),K(`click`,n,e=>c(e,G(t).session)),J(e,n)}),N(t),J(e,t)},A=P(()=>(G(x).length||G(C).length||G(o).some(e=>e.pending)||G(s).length)&&!G(v));X(ve,e=>{G(A)&&e(ye)});var be=V(ve,2),j=e=>{var t=Pr(),a=z(t),s=e=>{var t=lc(),a=R(t),s=R(a);let c;var d=R(s);let f;var h=V(d);N(s);var g=V(s,2);N(a);var _=V(a,2),b=e=>{var t=Ys(),n=B(t,!0);H(()=>Y(n,G(p).directory)),J(e,t)};X(_,e=>{G(p).name&&G(p).directory&&e(b)});var x=V(_,2),S=B(x),C=V(x,2);let w;var T=R(C),D=R(T);n(D,()=>G(p),()=>!0,()=>!0),N(T);var ee=V(T,2),te=e=>{var t=Pr();Kr(z(t),()=>G(p).id,e=>{{let t=P(()=>new URLSearchParams(Xi.querystring).get(`schedule`)===`edit`),n=P(()=>G(p).fileChanges||[]);ks(e,{get session(){return G(p).id},oncopy:()=>G(r)?.copy(),get openScheduler(){return G(t)},get observedCommand(){return G(p).command},get observedFileChanges(){return G(n)},get suspended(){return G(m)},onProtectedChange:e=>{L(u,e,!0)}})}}),J(e,t)},ne=e=>{var t=ac();Kr(V(R(t),2),()=>G(p).id,e=>{Bo(e,{get session(){return G(p).id},localOnly:!0,oncopy:()=>G(r)?.copy()})}),N(t),J(e,t)};X(ee,e=>{$.data?.control?e(te):e(ne,-1)}),N(C);var re=V(C,2);Z(re,17,()=>G(o).filter(e=>e.session===G(p).id),e=>e.session,(e,t)=>{var n=sc(),r=R(n),i=e=>{var n=Zs(),r=B(n,!0);H(()=>Y(r,G(t).notice)),J(e,n)};X(r,e=>{G(t).notice&&e(i)});var a=V(r,2),o=e=>{ks(e,{get session(){return G(p).id},review:`profile`})},s=e=>{var t=oc();H(e=>Q(t,`href`,e),[()=>`#/sessions/`+encodeURIComponent(G(p).id)+`?review=profile`]),J(e,t)};X(a,e=>{G(t).pending&&G(m)?e(o):G(t).pending&&e(s,1)}),N(n),H(()=>Q(n,`id`,`quota-profile-`+G(p).id)),J(e,n)});var ie=V(re,2),ae=e=>{var t=Pr();Kr(z(t),()=>G(p).id,e=>{Is(e,{get session(){return G(p)},get stale(){return G(v)},children:e=>{var t=Pr(),n=z(t),i=e=>{Li(Rs(e,{get session(){return G(p)},active:!0,compact:!0}),e=>L(r,e,!0),()=>G(r))};X(n,e=>{G(m)||e(i)}),J(e,t)},$$slots:{default:!0}})}),J(e,t)},oe=e=>{var t=cc(),n=z(t),i=e=>{var t=Pr();Kr(z(t),()=>G(p).id,e=>{Li(Rs(e,{get session(){return G(p)},active:!0}),e=>L(r,e,!0),()=>G(r))}),J(e,t)};X(n,e=>{G(m)||e(i)}),Kr(V(n,2),()=>G(p).id,e=>{Is(e,{get session(){return G(p)},get stale(){return G(v)}})}),J(e,t)};X(ie,e=>{G(p).goal?e(ae):e(oe,-1)}),N(t),H((e,t,n,r)=>{c=li(s,1,`svelte-mm4wfe`,null,c,{failed:e,reviewed:G(p).status===`TURN COMPLETE`&&G(p).readStateKnown&&!G(p).unread}),f=li(d,1,`lamp lit svelte-mm4wfe`,null,f,{failed:t,working:G(p).status===`WORKING`&&!G(v)}),Y(h,`${n??``} // ${(G(p).name||G(p).directory)??``}`),Y(S,`${r??``} TOKENS // ${G(p).id??``} // CONTEXT SOURCE // ${(G(p).source||`LOCAL`)??``}`),w=di(C,``,w,{display:G(m)?`none`:void 0}),Q(T,`data-result-session`,G(p).id),Q(T,`data-result-turn`,G(p).replyTurn)},[()=>y(G(p))&&!G(v)&&!G(m),()=>y(G(p))&&!G(v),()=>G(v)?`STALE`:G(m)?`QUOTA THRESHOLD`:l(G(p)),()=>ma(G(p).tokens)]),K(`click`,g,()=>{O(i().id),pa(i().id,2)}),Sr(`wheel`,T,()=>{E(G(p))}),J(e,t)},c=e=>{J(e,uc())};X(a,e=>{G(p)?e(s):e(c,-1)}),J(e,t)},M=e=>{var t=xc(),r=z(t),i=V(R(r),2),s=R(i),c=V(s,2);N(i),N(r);var u=V(r,2);Z(u,17,()=>G(a),e=>e.id,(e,t)=>{let r=P(()=>da(G(t).id));var i=yc();let a;var s=R(i),c=R(s),u=e=>{var n=dc(),r=R(n),i=B(r);N(n),H(e=>{Q(r,`aria-pressed`,G(h)===G(t).id),Y(i,`${e??``} // ${G(t).name??``}`)},[()=>Array.from(G(t).id).slice(-5).join(``).toUpperCase()]),K(`click`,r,()=>O(G(t).id)),J(e,n)};X(c,e=>{G(t).name&&e(u)});var f=V(c,2),p=R(f);let m;var g=R(p);let _;var b=V(g,1,!0);N(p),N(f);var x=V(f,2),S=e=>{var n=fc(),r=B(n,!0);H(()=>{Q(n,`aria-pressed`,G(h)===G(t).id),Y(r,G(t).directory||G(t).id)}),K(`click`,n,()=>O(G(t).id)),J(e,n)};X(x,e=>{G(t).name||e(S)});var C=V(x,2),w=R(C);Se(),N(C);var T=V(C,2),ee=e=>{var n=Ys(),r=B(n,!0);H(()=>Y(r,G(t).directory)),J(e,n)};X(T,e=>{G(t).name&&G(t).directory&&e(ee)});var te=V(T,2),re=B(te),ie=V(te,2),oe=B(ie),se=V(ie,2);js(se,{get goal(){return G(t).goal},get stale(){return G(v)}});var ce=V(se,2),le=R(ce),ue=V(le,2),de=B(ue,!0),fe=V(ue,2);N(ce);var pe=V(ce,2),me=V(pe,2),k=e=>{var n=pc(),r=B(n,!0);H(e=>Y(r,e),[()=>G(t).status===`CHECK SESSION`?`INFERRED INACTIVITY`:y(G(t))?`OPEN DETAIL FOR THE TURN ERROR`:$.data?.control?`OPEN FULL DETAIL OR REPLY IN CODEX`:G(t).status===`APPROVAL NEEDED`?`APPROVE OR DECLINE IN CODEX`:`REPLY IN CODEX`]),J(e,n)},he=P(()=>!G(v)&&([`APPROVAL NEEDED`,`INPUT NEEDED`,`CHECK SESSION`].includes(G(t).status)||y(G(t))));X(me,e=>{G(he)&&e(k)}),N(s);var ge=V(s,2),_e=e=>{var r=_c(),i=R(r),a=R(i),s=B(a,!0),c=V(a,2),l=e=>{var n=mc(),r=B(n,!0);H(e=>{Q(n,`href`,e),Y(r,$.data?.control?`REVIEW IN FULL DETAIL ↗`:`APPROVAL IN CODEX ↗`)},[()=>`#/sessions/`+encodeURIComponent(G(t).id)]),J(e,n)};X(c,e=>{!G(v)&&G(t).status===`APPROVAL NEEDED`&&e(l)}),N(i);var u=V(i,2),f=R(u);n(f,()=>G(t),()=>!1),N(u);var p=V(u,2);Z(p,17,()=>G(o).filter(e=>e.session===G(t).id),qr,(e,n)=>{var r=cc(),i=z(r),a=e=>{var t=hc(),r=B(t,!0);H(()=>Y(r,G(n).notice)),J(e,t)};X(i,e=>{G(n).notice&&e(a)});var o=V(i,2),s=e=>{var n=gc();H(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(G(t).id)+`?review=profile`]),K(`click`,n,e=>d(e,G(t).id)),J(e,n)};X(o,e=>{G(n).pending&&e(s)}),J(e,r)});var m=V(p,2);{let e=P(()=>G(h)===G(t).id);Rs(m,{get session(){return G(t)},get active(){return G(e)}})}N(r),H(e=>{Y(s,e),Q(u,`data-result-session`,G(t).id),Q(u,`data-result-turn`,G(t).replyTurn)},[()=>ae(G(t))]),Sr(`wheel`,u,()=>{E(G(t))}),J(e,r)};X(ge,e=>{G(r)>0&&e(_e)});var ve=V(ge,2),ye=e=>{var n=vc(),r=V(R(n),2);{let e=P(()=>(G(t).samples||[]).map(e=>e.tokens));ao(r,{get values(){return G(e)},capacity:120})}var i=B(V(r,2));N(n),H(()=>Y(i,`LAST ${(G(t).samples?.length||0)??``} SAMPLES // AUTO SCALE`)),J(e,n)};X(ve,e=>{G(r)<2&&e(ye)}),N(i),H((e,n,o,s,c,l,u)=>{a=li(i,1,`session-row`,null,a,{selected:G(h)===G(t).id,wide:G(r)===2,split:G(r)===1}),Q(i,`aria-label`,`Session `+(G(t).name||G(t).directory||G(t).id)),m=li(p,1,`status-detail svelte-mm4wfe`,null,m,{reviewed:G(t).status===`TURN COMPLETE`&&G(t).readStateKnown&&!G(t).unread,failed:e}),Q(p,`href`,n),_=li(g,1,`lamp lit svelte-mm4wfe`,null,_,{failed:o,working:G(t).status===`WORKING`&&!G(v)}),Y(b,s),Y(w,`${c??``} `),Y(re,`${G(t).agents??``} LINKED AGENTS`),Y(oe,`ACTIVE // ${l??``}`),le.disabled=G(r)===0,Q(ue,`aria-expanded`,G(r)>0),Y(de,G(r)?`HIDE DETAIL`:`SHOW DETAIL`),Q(pe,`href`,u)},[()=>y(G(t))&&!G(v),()=>`#/sessions/`+encodeURIComponent(G(t).id),()=>y(G(t))&&!G(v),()=>G(v)?`STALE`:l(G(t)),()=>ma(G(t).tokens),()=>ha(G(t).activity),()=>`#/sessions/`+encodeURIComponent(G(t).id)]),K(`click`,p,()=>D(G(t).id)),K(`click`,le,()=>ne(G(t).id,-1)),K(`click`,ue,()=>{let e=G(r)===0;O(G(t).id),pa(G(t).id,+!!e),e&&E(G(t))}),K(`click`,fe,()=>ne(G(t).id,1)),K(`click`,pe,()=>D(G(t).id)),J(e,i)});var f=V(u,2),p=e=>{J(e,bc())};X(f,e=>{G(a).length||e(p)}),K(`click`,s,()=>fa(1)),K(`click`,c,()=>fa(0)),J(e,t)};X(be,e=>{i().id?e(j):e(M,-1)}),H(e=>{Y(ue,`OBSERVED ${e??``}`),fe=li(de,1,`session-totals`,null,fe,{stale:G(v)}),Y(me,`${G(v)?`LAST KNOWN TOTALS — live state counts unavailable. `:``}Tokens + observed since this server started for currently listed sessions; linked + agents are already included. Totals can decrease when a session leaves the + list. History samples every 30 seconds. Not account-wide totals.`)},[()=>ha($.data?.sessionsAt)]),J(e,oe),Ge()}Cr([`click`]);var wc=q(``),Tc=q(`

      `),Ec=q(`

      Relative usage/credits are not tokens or quota percentages. Groupings + describe the same usage, not additional consumption.

      `,1),Dc=q(`// APPROXIMATE`),Oc=q(`

      Partial accounting: totals may still change.

      `),kc=q(`

      Percentage of this period's historical allowance, not today's limit. May + exceed 100%. This is not a manual/automatic reset log.

      `,1),Ac=q(`

      `,1),jc=q(`

      This optional account report is unavailable. Token history remains + available; missing data does not mean zero usage.

      `),Mc=q(`
      `),Nc=q(`
      `),Pc=q(`

      No usage reported for this day.

      `),Fc=q(`

      Selected breakdown unavailable; missing does not mean zero.

      `),Ic=q(`

      `,1);function Lc(e,t){We(t,!0);let n=I(Xt(lo[0])),r=I(0),i=P(()=>t.reports?.daily),a=P(()=>t.reports?.plan),o=P(()=>t.mode===`breakdown`?G(i)?.days?.length||0:G(a)?.periods?.length||0),s=P(()=>Math.min(G(r),Math.max(0,G(o)-1))),c=P(()=>G(i)?.days?.[(G(i)?.days?.length||0)-1-G(s)]),l=P(()=>G(a)?.periods?.[G(s)]),u=P(()=>t.mode===`breakdown`?G(i)?.units||``:`%`),d=P(()=>(t.mode===`breakdown`?G(c):G(l))?.views?.[G(n)]),f=P(()=>G(d)?.rows||[]),p=P(()=>G(d)?.total),m=P(()=>G(d)?.level||`unknown`),h=P(()=>G(d)?.peak||1),g=e=>e==null?`UNKNOWN`:e.toLocaleString(`en-GB`,{maximumFractionDigits:2});var _=Ic(),v=z(_),y=R(v),b=V(R(y));Z(b,21,()=>lo,qr,(e,t)=>{var n=wc(),r=B(n,!0),i={};H(e=>{Y(r,e),i!==(i=G(t))&&(n.value=(n.__value=i)??``)},[()=>G(t).charAt(0).toUpperCase()+G(t).slice(1)]),J(e,n)}),N(b),hi(b),N(y);var x=V(y,2),S=V(x,2),C=B(V(S,2),!0);N(v);var w=V(v,2),T=R(w),E=B(T,!0),D=V(T,2),ee=B(D),te=V(D,2),O=e=>{var t=Ec(),n=z(t),r=B(n),a=V(n,2),o=e=>{var t=Tc(),n=B(t);H(()=>Y(n,`Data as of ${G(i).dataAsOf??``}`)),J(e,t)};X(a,e=>{G(i).dataAsOf&&e(o)});var s=B(V(a,2));Se(2),H((e,t)=>{Y(r,`Latest fetch ${e??``} // queried ${G(i).from??``} → ${G(i).through??``}. + Reports are fetched from OpenAI and are not saved between runs.`),Y(s,`${(G(c)?.date||`No daily buckets reported`)??``} // ${t??``} + ${G(u)??``}`)},[()=>ha(G(i).fetchedAt),()=>g(G(p))]),J(e,t)},ne=e=>{var t=Ac(),n=z(t),r=R(n);let i;var o=B(r,!0),s=V(r),c=e=>{J(e,Dc())};X(s,e=>{G(a).approximate&&e(c)});var u=V(s);N(n);var d=V(n,2),f=R(d),h=V(f),_=e=>{var t=Nr();H(()=>Y(t,`// Boundary tolerance ${G(a).boundary_tolerance_seconds??``}s`)),J(e,t)};X(h,e=>{G(a).boundary_tolerance_seconds!=null&&e(_)}),N(d);var v=V(d,2),y=e=>{var t=kc(),n=z(t),r=R(n),i=V(r);let a;var o=B(i);N(n);var s=V(n,2),c=B(s),u=V(s,2),d=e=>{J(e,Oc())};X(u,e=>{G(l).accounting_complete||e(d)}),Se(2),H(e=>{Y(r,`${G(l).window_minutes??``} MIN // ${G(l).plan_type??``} // `),a=li(i,1,`svelte-1fbui7h`,null,a,{muted:G(m)===`unknown`,"quota-near":G(m)===`near`,"quota-full":G(m)===`full`}),Y(o,`USED ${e??``}${G(p)==null?``:`%`}`),Y(c,`${G(l).starts_at??``} → ${G(l).ends_at??``}`)},[()=>g(G(p))]),J(e,t)};X(v,e=>{G(l)&&e(y)}),H(e=>{i=li(r,1,`svelte-1fbui7h`,null,i,{"quality-warning":!G(a).coverage_complete}),Y(o,G(a).coverage_complete?`Reported range complete`:`Partial coverage`),Y(u,` // Latest fetch ${e??``}`),Y(f,`Coverage starts ${(G(a).coverage_start||`unknown`)??``} // Data as of ${(G(a).data_as_of||`unknown`)??``}`)},[()=>ha(G(a).fetchedAt)]),J(e,t)},re=e=>{J(e,jc())};X(te,e=>{t.mode===`breakdown`&&G(i)?e(O):t.mode===`periods`&&G(a)?e(ne,1):e(re,-1)});var ie=V(te,2),ae=e=>{var n=Nc(),r=R(n),i=B(V(R(r),2),!0);N(r),Z(V(r,2),17,()=>G(f),qr,(e,n,r)=>{let i=()=>G(n).name,a=()=>G(n).value;var o=Mc();let s;var c=R(o),l=B(c,!0),u=V(c,2),d=R(u);let f;N(u);var p=B(V(u,2));N(o),H((e,n,a)=>{s=li(o,1,`report-row svelte-1fbui7h`,null,s,{unknown:e,alternate:r%2==1}),Q(c,`title`,i()),Y(l,i()),f=di(d,``,f,{width:n}),Y(p,`${a??``}${t.mode===`periods`?`%`:``}`)},[()=>i().trim().toLowerCase()===`unknown`,()=>`${Math.max(0,100*a()/G(h))}%`,()=>g(a())]),J(e,o)}),N(n),H(()=>Y(i,t.mode===`breakdown`?G(u):`QUOTA USED`)),J(e,n)},oe=e=>{J(e,Pc())},se=e=>{J(e,Fc())};X(ie,e=>{G(f).length?e(ae):t.mode===`breakdown`&&G(d)?.knownEmpty?e(oe,1):(G(i)&&t.mode===`breakdown`||G(a)&&t.mode===`periods`)&&e(se,2)}),N(w),H(()=>{x.disabled=G(s)>=G(o)-1,S.disabled=G(s)===0,Y(C,G(o)?`${G(s)+1} / ${G(o)}`:`NO DATA`),Y(E,t.mode===`breakdown`?`DAILY BREAKDOWN`:`QUOTA WINDOWS`),Y(ee,`${(t.mode===`breakdown`?t.reports?.dailyStatus||`UNAVAILABLE`:t.reports?.planStatus||`UNAVAILABLE`)??``} // UTC`)}),gi(b,()=>G(n),e=>L(n,e)),K(`click`,x,()=>L(r,G(s)+1)),K(`click`,S,()=>L(r,G(s)-1)),J(e,_),Ge()}Cr([`click`]);var Rc=864e5;function zc(e,t){let n=new Date(e);n.setUTCDate(1),n.setUTCMonth(n.getUTCMonth()+t);let r=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)).getUTCDate();return n.setUTCDate(Math.min(e.getUTCDate(),r)),n}function Bc(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));for(let e=0;;e++){let i=zc(r,-t),a=new Date(i.getTime()+Rc);if(e===n)return{start:a,end:r};r=i}}var Vc=q(``),Hc=q(``,1),Uc=q(`

      History refresh failed. Any displayed history is the last successful + observation.

      `),Wc=q(`

      Token history unavailable; other reports may still be available.

      `),Gc=q(``),Kc=q(`
      `),qc=q(`

      LESS ░ ▒ ▓ █ MORE // HOVER FOR DATE AND TOKENS

      `,1),Jc=q(`
      `,1),Yc=q(` `),Xc=q(`

      LIFETIME TOKENS

      PEAK DAY

      CURRENT STREAK

      DAYS

      LONGEST TURN

      SECONDS

      LONGEST STREAK

      DAYS

      OPENAI // UTC

      Accessible data table
      Date (UTC)Tokens

      `,1),Zc=q(`

      History unavailable or awaiting a matching account observation. Missing + history is not treated as zero usage.

      `),Qc=q(`

      USAGE // ACCOUNT HISTORY

      Account-wide history reported by Codex, not the local Sessions counter. Dates + use UTC. Allowance history is approximate where indicated; reset causes are + not provided.

      `,1);function $c(e,t){We(t,!0);let n=I(`daily`),r=I(12),i=I(0),a=P(()=>{let e=$.data?.usage?.dailyUsageBuckets;if(!e)return[];let{start:t,end:n}=Bc(new Date,G(r),G(i)),a=new Map;for(let t of e)!Number.isFinite(t.tokens)||t.tokens<0||a.set(t.startDate,(a.get(t.startDate)||0)+t.tokens);let o=[];for(let e=t;e<=n;e=new Date(e.getTime()+864e5)){let t=e.toISOString().slice(0,10);o.push({date:t,tokens:a.get(t)||0})}return o}),o=P(()=>Math.max(1,...G(a).map(e=>e.tokens))),s=P(()=>G(a).length?new Date(G(a)[0].date+`T00:00:00Z`).getUTCDay():0),c=P(()=>{if(G(n)===`monthly`){let e=new Map;for(let t of G(a))e.set(t.date.slice(0,7),(e.get(t.date.slice(0,7))||0)+t.tokens);return[...e].map(([e,t])=>({date:e,tokens:t}))}let e=0;return G(a).map(t=>({date:t.date,tokens:e+=t.tokens}))});var l=Qc(),u=V(z(l),4);Z(u,20,()=>[[`daily`,`Daily`],[`monthly`,`Monthly`],[`cumulative`,`Cumulative`],[`breakdown`,`Breakdown`],[`periods`,`Windows`]],qr,(e,t)=>{var r=P(()=>_(t,2));let a=()=>G(r)[0],o=()=>G(r)[1];var s=Vc();let c;var l=B(s,!0);H(()=>{Q(s,`aria-pressed`,G(n)===a()),c=li(s,1,``,null,c,{active:G(n)===a()}),Y(l,o())}),K(`click`,s,()=>{L(n,a(),!0),L(i,0)}),J(e,s)}),N(u);var d=V(u,2),f=R(d),p=e=>{var t=Hc(),n=z(t),a=V(R(n)),o=R(a);o.value=o.__value=6;var s=V(o);s.value=s.__value=12,N(a),hi(a),N(n);var c=V(n),l=V(c);H(()=>l.disabled=G(i)===0),K(`change`,a,()=>L(i,0)),gi(a,()=>G(r),e=>L(r,e)),K(`click`,c,()=>qt(i)),K(`click`,l,()=>qt(i,-1)),J(e,t)};X(f,e=>{G(n)!==`breakdown`&&G(n)!==`periods`&&e(p)}),N(d);var m=V(d,2),h=e=>{J(e,Uc())};X(m,e=>{$.data?.usageError&&e(h)});var g=V(m,2),v=e=>{J(e,Wc())};X(g,e=>{$.data?.usage?.tokenStatus===`UNAVAILABLE`&&G(n)!==`breakdown`&&G(n)!==`periods`&&e(v)});var y=V(g,2),b=e=>{var t=Pr();Kr(z(t),()=>G(n),e=>{{let t=P(()=>$.data?.usage?.reports);Lc(e,{get reports(){return G(t)},get mode(){return G(n)}})}}),J(e,t)},x=e=>{var t=Xc(),r=z(t),i=R(r),l=B(V(R(i),2),!0);N(i);var u=V(i,2),d=B(V(R(u),2),!0);N(u);var f=V(u,2),p=V(R(f),2),m=R(p);Se(),N(p),N(f);var h=V(f,2),g=V(R(h),2),_=R(g);Se(),N(g),N(h);var v=V(h,2),y=V(R(v),2),b=R(y);Se(),N(y),N(v),N(r);var x=V(r,4),S=R(x),C=B(S),w=V(S,2),T=e=>{var t=qc(),n=z(t),r=R(n),i=R(r);Z(i,17,()=>Array(G(s)),qr,(e,t)=>{J(e,Gc())}),Z(V(i,2),17,()=>G(a),qr,(e,t)=>{var n=Kc();let r,i;H(e=>{r=li(n,1,`heat-cell`,null,r,{zero:G(t).tokens===0}),Q(n,`title`,e),i=di(n,``,i,{opacity:G(t).tokens?.25+.75*G(t).tokens/G(o):1})},[()=>`${G(t).date}: ${ma(G(t).tokens)} tokens`]),J(e,n)}),N(r),N(n),Se(2),J(e,t)},E=e=>{var t=Jc(),r=z(t);{let e=P(()=>G(c).map(e=>e.tokens)),t=P(()=>G(n)+` usage`);ao(r,{get values(){return G(e)},get label(){return G(t)}})}var i=V(r,2),a=R(i),o=B(a,!0),s=B(V(a),!0);N(i),H(e=>{Y(o,G(c)[0]?.date),Y(s,e)},[()=>G(c).at(-1)?.date]),J(e,t)};X(w,e=>{G(n)===`daily`?e(T):e(E,-1)});var D=V(w,2),ee=V(R(D),2),te=R(ee),O=V(R(te));Z(O,21,()=>G(n)===`daily`?G(a):G(c),qr,(e,t)=>{var n=Yc(),r=R(n),i=B(r,!0),a=B(V(r),!0);N(n),H(e=>{Y(i,G(t).date),Y(a,e)},[()=>ma(G(t).tokens)]),J(e,n)}),N(O),N(te),N(ee),N(D),N(x);var ne=B(V(x,2));H((e,t,n,r,i,o,s)=>{Y(l,e),Y(d,t),Y(m,`${n??``} `),Y(_,`${r??``} `),Y(b,`${i??``} `),Y(C,`${G(a)[0]?.date??``} — ${o??``}`),Y(ne,`OBSERVED ${s??``} // CUMULATIVE IS FOR THE SELECTED PERIOD`)},[()=>ma($.data.usage.summary.lifetimeTokens),()=>ma($.data.usage.summary.peakDailyTokens),()=>ma($.data.usage.summary.currentStreakDays),()=>ma($.data.usage.summary.longestRunningTurnSec),()=>ma($.data.usage.summary.longestStreakDays),()=>G(a).at(-1)?.date,()=>ha($.data.usageAt)]),J(e,t)},S=e=>{J(e,Zc())};X(y,e=>{G(n)===`breakdown`||G(n)===`periods`?e(b):$.data?.usage&&$.data.usage.dailyUsageBuckets!==null?e(x,1):e(S,-1)}),J(e,l),Ge()}Cr([`click`,`change`]);var el=q(`

      Page not found

      Return to Quota

      `,1);function tl(e){var t=el();Se(2),J(e,t)}var nl=`CODEXOMETER`,rl=[`█▀▀ █▀█ █▀▄ █▀▀ ▀▄▀ █▀█ █▀▄▀█ █▀▀ ▀█▀ █▀▀ █▀█`,`█▄▄ █▄█ █▄▀ ██▄ █ █ █▄█ █ ▀ █ ██▄ █ ██▄ █▀▄`].flatMap(e=>[[...e].map(e=>e===`█`||e===`▀`),[...e].map(e=>e===`█`||e===`▄`)]),il=rl[0].length,al=rl.length,ol=0,sl=[...nl].map(e=>{let t=e===`M`?5:3,n={start:ol,width:t};return ol+=t+1,n}),cl=`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`,ll=`010 101 111 101.110 111 101 110.111 100 100 111.110 101 101 110.111 100 110 111.111 100 110 100.111 100 101 111.101 101 111 101.111 010 010 111.001 001 101 111.101 110 110 101.100 100 100 111.101 111 101 101.101 111 111 101.111 101 101 111.111 101 111 100.111 101 111 001.111 101 110 101.111 100 001 111.111 010 010 010.101 101 101 111.101 101 101 010.101 101 111 101.101 010 010 101.101 101 010 010.111 001 100 111.111 101 101 111.110 010 010 111.111 001 110 111.111 011 001 111.101 101 111 001.111 110 001 111.100 111 101 111.111 001 010 010.111 111 101 111.111 101 111 001`.split(`.`).map(e=>e.split(` `));function ul(e=nl,t=-1,n=!1){let r=``;for(let i=0;i{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}function ml(){let e=dl[Math.floor(Math.random()*dl.length)],t=Math.floor(Math.random()*4294967296),n=pl(t),r=[...nl].map((e,t)=>t);for(let e=r.length-1;e>0;e--){let t=Math.floor(n()*(e+1));[r[e],r[t]]=[r[t],r[e]]}return{variant:e,seed:t,order:r}}function hl(e,t){if(e.variant===`typing`){let e=t<1080,n=e?0:Math.min(Math.floor((t-1080)/90)+1,11);return{text:nl.slice(0,n).padEnd(11),cursor:n,dot:e?Math.floor(t/180)%2==0:n<11}}if(e.variant===`shuffle`){let n=pl(e.seed^Math.floor(t/70)),r=[...nl].map(e=>{let t;do t=cl[Math.floor(n()*36)];while(t===e);return t}),i=Math.min(Math.floor(t/110),11);for(let t of e.order.slice(0,i))r[t]=nl[t];return{text:r.join(``),cursor:-1,dot:!1}}return{text:nl,cursor:-1,dot:!1}}var gl=Mr(``);function _l(e,t){We(t,!0);let n=Gi(t,`text`,3,nl),r=Gi(t,`cursor`,19,()=>-1),i=Gi(t,`dot`,3,!1),a=P(()=>ul(n(),r(),i()));var o=gl(),s=B(o);H(()=>{Q(o,`viewBox`,`0 0 ${il} ${al}`),Q(o,`width`,il),Q(o,`height`,al),Q(s,`d`,G(a))}),J(e,o),Ge()}var vl=q(`
      `),yl=q(`
      `);function bl(e,t){We(t,!0);let n=I(void 0),r=I(0),i=I(Xt({width:0,height:0,pixelRatio:1})),a=I(Xt({x:0,y:0,width:0})),o=P(()=>G(n)?hl(G(n),G(r)):void 0),s=P(()=>{if(!G(n))return{x:0,y:0,width:0};let e=fl[G(n).variant],t=Math.min(Math.max((G(r)-e-180)/800,0),1),o=t*t*(3-2*t),s=G(i).width+(G(a).width-G(i).width)*o,c=Math.max((G(i).height-G(i).width*al/il)/2,0),l=(G(n).variant===`slide`&&G(r)Math.round(e*G(i).pixelRatio)/G(i).pixelRatio;return{x:d(l),y:d(u),width:d(s)}});Ki(()=>{let e=matchMedia(`(prefers-reduced-motion: reduce)`);if(e.matches){t.onfinish();return}L(n,ml(),!0);let o=fl[G(n).variant]+180+800,s=0,c=!1,l=performance.now(),u=()=>{let e=t.target?.getBoundingClientRect();L(i,{width:window.innerWidth,height:window.innerHeight,pixelRatio:window.devicePixelRatio||1},!0),e&&L(a,{x:e.x,y:e.y,width:e.width},!0)},d=()=>{c||(c=!0,cancelAnimationFrame(s),t.onfinish())},f=e=>{e instanceof PointerEvent&&e.button!==0||e instanceof KeyboardEvent&&(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)||e instanceof KeyboardEvent&&[`Shift`,`Control`,`Alt`,`Meta`].includes(e.key)||(e.preventDefault(),e.stopImmediatePropagation(),d())},p=()=>{e.matches&&d()},m=e=>{L(r,Math.max(e-l,0),!0),G(r)>=o?d():s=requestAnimationFrame(m)},h=new ResizeObserver(u);if(t.target){h.observe(t.target),t.target.parentElement&&h.observe(t.target.parentElement);let e=t.target.closest(`header`);e&&h.observe(e)}return u(),window.addEventListener(`resize`,u),document.addEventListener(`keydown`,f,!0),document.addEventListener(`pointerdown`,f,!0),e.addEventListener(`change`,p),s=requestAnimationFrame(m),()=>{c=!0,cancelAnimationFrame(s),h.disconnect(),window.removeEventListener(`resize`,u),document.removeEventListener(`keydown`,f,!0),document.removeEventListener(`pointerdown`,f,!0),e.removeEventListener(`change`,p)}});var c=yl(),l=R(c),u=e=>{var t=vl();let n;_l(R(t),{get text(){return G(o).text},get cursor(){return G(o).cursor},get dot(){return G(o).dot}}),N(t),H(()=>{Q(t,`data-text`,G(o).text),Q(t,`data-cursor`,G(o).dot?G(o).cursor:void 0),n=di(t,``,n,{left:`${G(s).x}px`,top:`${G(s).y}px`,width:`${G(s).width}px`})}),J(e,t)};X(l,e=>{G(o)&&e(u)});var d=V(l,2);N(c),H(()=>Q(c,`data-entrance`,G(n)?.variant)),K(`click`,d,function(...e){t.onfinish?.apply(this,e)}),J(e,c),Ge()}Cr([`click`]);var xl=q(` `),Sl=q(`

      `),Cl=q(`

      Connecting to your local Codexometer…

      `),wl=q(``),Tl=q(`

      Your quota. Your sessions. Your command centre.

      `);function El(e,t){We(t,!0);let n={"/":no,"/quota/:view?":no,"/sessions/:id?":Cc,"/usage":$c,"*":tl},r={quota:/^(?:\/|\/quota(?:\/[^/]+)?\/?)$/,sessions:/^\/sessions(?:\/[^/]+)?\/?$/,usage:/^\/usage\/?$/},i=I(`hacker`),a=I(!0),o=I(void 0);yn(()=>{ca.requests&&ur().then(()=>{G(o)?.focus(),G(o)?.scrollIntoView({block:`nearest`})})});let s=I(void 0),c=[`hacker`,`rust`,`blue-steel`,`ultraviolet`,`nightshade`];yn(()=>{la()}),yn(()=>{if($.data)for(let[e,t]of Object.entries(r))t.test(Xi.location)&&(oa.tab=e)}),Ki(()=>{try{let e=localStorage.getItem(`codexometer.web.theme`);e&&c.includes(e)&&L(i,e,!0)}catch{}return ba()});function l(){try{localStorage.setItem(`codexometer.web.theme`,G(i))}catch{}}var u=Tl(),d=R(u),f=R(d),p=R(f);_l(R(p),{}),N(p),Li(p,e=>L(s,e),()=>G(s)),Se(2),N(f);var m=V(f,2),h=R(m);let g;var v=V(h,1,!0),y=B(V(v));N(m),N(d);var b=V(d,2);Z(b,21,()=>Object.entries(r),qr,(e,t)=>{var n=P(()=>_(G(t),2));let r=()=>G(n)[0],i=()=>G(n)[1],a=P(()=>i().test(Xi.location));var o=xl();let s;var c=B(o,!0);H(e=>{Q(o,`href`,r()===`quota`?`#/quota/`+oa.view:`#/`+r()),Q(o,`aria-current`,G(a)?`page`:void 0),s=li(o,1,``,null,s,{active:G(a)}),Y(c,e)},[()=>r().toUpperCase()]),J(e,o)}),N(b);var x=V(b,2),S=R(x),C=e=>{var t=Sl(),n=B(t,!0);H(()=>Y(n,$.error)),J(e,t)};X(S,e=>{$.error&&e(C)});var w=V(S,2),T=e=>{ea(e,{get routes(){return n}})},E=e=>{J(e,Cl())};X(w,e=>{$.data?e(T):$.error||e(E,1)}),N(x);var D=V(x,2),ee=R(D),te=B(ee),O=V(ee,2),ne=B(O,!0),re=V(O,2),ie=V(R(re));Z(ie,21,()=>c,qr,(e,t)=>{var n=wl(),r=B(n,!0),i={};H(e=>{Y(r,e),i!==(i=G(t))&&(n.value=(n.__value=i)??``)},[()=>G(t).replace(`-`,` `).toUpperCase()]),J(e,n)}),N(ie),Li(ie,e=>L(o,e),()=>G(o)),hi(ie),N(re),N(D);var ae=V(D,2),oe=e=>{bl(e,{get target(){return G(s)},onfinish:()=>L(a,!1)})};X(ae,e=>{G(a)&&e(oe)}),N(u),H(()=>{Q(u,`data-theme`,G(i)),Q(u,`data-starting`,G(a)),d.inert=G(a),g=li(h,1,`lamp`,null,g,{lit:$.connected}),Y(v,$.connected?`CONNECTED`:`OFFLINE`),Y(y,`EXPERIMENTAL // ${$.data?.control?`SESSION CONTROL`:`READ ONLY`}`),b.inert=G(a),x.inert=G(a),D.inert=G(a),Y(te,`v${($.data?.version||`…`)??``} // LOCAL ONLY`),Y(ne,$.data?.control?`Session control enabled. Stop the server to revoke access.`:`No actions can be sent from this preview.`)}),K(`change`,ie,l),gi(ie,()=>G(i),e=>L(i,e)),J(e,u),Ge()}Cr([`change`]),Br(El,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/web/dist/assets/index-DmCO8RLB.js b/internal/web/dist/assets/index-DmCO8RLB.js deleted file mode 100644 index 8fe89a38..00000000 --- a/internal/web/dist/assets/index-DmCO8RLB.js +++ /dev/null @@ -1,50 +0,0 @@ -(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=Array.isArray,t=Array.prototype.indexOf,n=Array.prototype.includes,r=Array.from,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyDescriptors,s=Object.prototype,c=Array.prototype,l=Object.getPrototypeOf,u=Object.isExtensible;function d(e){return typeof e==`function`}var f=()=>{};function p(e){return e()}function m(e){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}function g(e,t,n=!1){return e===void 0?n?t():t:e}function _(e,t){if(Array.isArray(e))return e;if(t===void 0||!(Symbol.iterator in e))return Array.from(e);let n=[];for(let r of e)if(n.push(r),n.length===t)break;return n}var v=1024,y=2048,b=4096,x=8192,S=16384,C=32768,w=1<<25,T=65536,E=1<<19,D=1<<20,ee=1<<25,te=1<<21,O=1<<22,ne=1<<23,re=Symbol(`$state`),ie=Symbol(`component`),ae=Symbol(`legacy props`),oe=Symbol(``),se=Symbol(`attributes`),ce=Symbol(`class`),k=Symbol(`style`),le=Symbol(`text`),ue=Symbol(`form reset`),de=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},fe=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`),pe={},A=Symbol(`uninitialized`),me=`http://www.w3.org/1999/xhtml`;function he(){console.warn(`https://svelte.dev/e/derived_inert`)}function ge(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function _e(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function ve(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var j=!1;function ye(e){j=e}var M;function be(e){if(e===null)throw ge(),pe;return M=e}function xe(){return be(sn(M))}function N(e){if(j){if(sn(M)!==null)throw ge(),pe;M=e}}function Se(e=1){if(j){for(var t=e,n=M;t--;)n=sn(n);M=n}}function Ce(e=!0){for(var t=0,n=M;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else(r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=sn(n);e&&n.remove(),n=i}}function we(e){if(!e||e.nodeType!==8)throw ge(),pe;return e.data}function Te(e){return e===this.v}function Ee(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function De(e){return!Ee(e,this.v)}function Oe(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function ke(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function Ae(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function je(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Me(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Ne(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Pe(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Fe(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Ie(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Le(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Re(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function ze(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var Be=!1;function Ve(){Be=!0}var He=null;function Ue(e){He=e}function We(e,t=!1,n){He={p:He,i:!1,c:null,e:null,s:e,x:null,r:W,l:Be&&!t?{s:null,u:null,$:[]}:null}}function Ge(e){var t=He,n=t.e;if(n!==null){t.e=null;for(var r of n)bn(r)}return e!==void 0&&(t.x=e),t.i=!0,He=t.p,Ke(e)}function Ke(e={}){return i(e,ie,{value:!0}),e}function qe(){return!Be||He!==null&&He.l===null}var Je=[];function Ye(){var e=Je;Je=[],m(e)}function Xe(e){if(Je.length===0&&!wt){var t=Je;queueMicrotask(()=>{t===Je&&Ye()})}Je.push(e)}function Ze(){for(;Je.length>0;)Ye()}var Qe=~(y|b|v);function $e(e,t){e.f=e.f&Qe|t}function et(e){e.f&512||e.deps===null?$e(e,v):$e(e,b)}function tt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),$e(e,v)}function nt(e){j&&on(e)!==null&&cn(e)}var rt=!1;function it(){rt||(rt=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[ue]?.()})},{capture:!0}))}function at(e){var t=U,n=W;Wn(null),Gn(null);try{return e()}finally{Wn(t),Gn(n)}}function ot(e,t,n,r=n){e.addEventListener(t,()=>at(n));let i=e[ue];e[ue]=i?()=>{i(),r(!0)}:()=>r(!0),it()}function st(e,t,n,r){let i=qe()?dt:mt;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=W,c=ct(),l=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function u(e){if(!(s.f&16384)){c();try{r([...o,...e])}catch(e){pn(e,s)}lt()}}var d=ut();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>pt(e))).then(u).catch(e=>pn(e,s)).finally(d)}l?l.then(()=>{c(),f(),lt()}):f()}function ct(){var e=W,t=U,n=He,r=F;return function(i=!0){Gn(e),Wn(t),Ue(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function lt(e=!0){Gn(null),Wn(null),Ue(null),e&&F?.deactivate()}function ut(){var e=W,t=e.b,n=F,r=!!t?.is_rendered();return t?.update_pending_count(1,n),n.increment(r,e),()=>{t?.update_pending_count(-1,n),n.decrement(r,e)}}function dt(e){var t=2|y;return W!==null&&(W.f|=E),{ctx:He,deps:null,effects:null,equals:Te,f:t,fn:e,reactions:null,rv:0,v:A,wv:0,parent:W,ac:null}}var ft=Symbol(`obsolete`);function pt(e,t,n){let r=W;r===null&&ke();var i=void 0,a=Vt(A),o=!U,s=new Set;return wn(()=>{var t=W,n=h();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==de&&n.reject(e)}).finally(lt)}catch(e){n.reject(e),lt()}var c=F;if(o){if(t.f&32768)var l=ut();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(ft);else for(let e of s.values())e.reject(ft);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==ft&&(c.activate(),t?(a.f|=ne,Gt(a,t)):(a.f&8388608&&(a.f^=ne),Gt(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),vn(()=>{for(let e of s)e.reject(ft)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function P(e){let t=dt(e);return qn(t),t}function mt(e){let t=dt(e);return t.equals=De,t}function ht(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(de),t.ac=null}),t.fn!==null&&(t.teardown=f),cr(t,0),kn(t))}function yt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&lr(t)}var bt=null,F=null,xt=null,St=null,Ct=null,wt=!1,Tt=!1,Et=null,Dt=null,Ot=0,kt=1,At=class e{id=kt++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){bt===null?bt=this:(bt.#n=this,this.#t=bt),bt=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)$e(r,y),t(r);for(r of n.m)$e(r,b),t(r)}this.#p.add(e)}#g(){var e=[];for(let i of this.#c)if(!(i.f&16384||!(i.f&6144))){for(var t=i,n=!1;t.parent!==null;){t=t.parent;var r=t.f;if(r&96){if(!(r&1024)){n=!0;break}t.f^=v}}n||e.push(t)}return this.#c=[],e}#_(){this.#e=!0;for(let e of this.#u)this.#d.delete(e),$e(e,y),this.schedule(e);for(let e of this.#d)$e(e,b),this.schedule(e);this.apply();for(var t=Et=[],n=[],r=Dt=[];this.#c.length>0;){Ot++>1e3&&(this.#S(),Mt());for(let e of this.#g())try{this.#v(e,t,n)}catch(t){throw Lt(e),this.#h()||this.discard(),t}}if(F=null,r.length>0){var i=e.ensure();for(let e of r)i.schedule(e)}if(Et=null,Dt=null,this.#h()){this.#x(n),this.#x(t);for(let[e,t]of this.#f)It(e,t);r.length>0&&F.#_();return}let a=this.#y();if(a)this.#x(n),this.#x(t),a.#b(this);else{this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),xt=this,Pt(n),Pt(t),xt=null,this.#s?.resolve();var o=F;if(this.#a===0&&(this.#c.length===0||o!==null)&&this.#S(),this.#c.length>0){if(o!==null){for(let e of this.#c)o.#c.push(e);this.#c=[]}else o=this}o!==null&&(zt.clear(),o.#_())}}#v(e,t,n){e.f^=v;for(var r=e.first;r!==null;){var i=r.f,a=!!(i&96);if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=v:i&4?t.push(r):rr(r)&&(i&16&&this.#d.add(r),lr(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#y(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#b(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}e.async_deriveds.clear(),this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null&&!(e.f&2&&!(e.f&6144)))for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),$e(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),F=this,this.#_()}#x(e){for(var t=0;t{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=h()).promise}static ensure(){if(F===null){let t=F=new e;!Tt&&!wt&&Xe(()=>{t.#e||t.flush()})}return F}apply(){St=null}schedule(e){Ct=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)?e.b.defer_effect(e):this.#c.push(e)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?bt=e:t.#t=e,this.linked=!1}}};function jt(e){var t=wt;wt=!0;try{var n;for(e&&(F!==null&&!F.is_fork&&F.flush(),n=e());;){if(Ze(),F===null)return n;F.flush()}}finally{wt=t}}function Mt(){try{Pe()}catch(e){pn(e,Ct)}}var Nt=null;function Pt(e){var t=e.length;if(t!==0){for(var n=0;n0)){zt.clear();for(let e of Nt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Nt.has(n)&&(Nt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||lr(n)}}Nt.clear()}}Nt=null}}function Ft(e){F.schedule(e)}function It(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),$e(e,v);for(var n=e.first;n!==null;)It(n,t),n=n.next}}function Lt(e){$e(e,v);for(var t=e.first;t!==null;)Lt(t),t=t.next}var Rt=new Set,zt=new Map,Bt=!1;function Vt(e,t){return{f:0,v:e,reactions:null,equals:Te,rv:0,wv:0}}function I(e,t){let n=Vt(e,t);return qn(n),n}function Ht(e,t=!1,n=!0){let r=Vt(e);return t||(r.equals=De),Be&&n&&He!==null&&He.l!==null&&(He.l.s??=[]).push(r),r}function L(e,t,n=!1){return U!==null&&(!Un||U.f&131072)&&qe()&&U.f&4325394&&(Kn===null||!Kn.has(e))&&Re(),Gt(e,n?Xt(t):t,Dt)}var Ut=null,Wt=0;function Gt(e,t,n=null){if(!e.equals(t)){Vn?zt.set(e,t):zt.has(e)||zt.set(e,e.v);var r=At.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&>(t),St===null&&et(t)}e.wv=nr(),Ut=null,Wt=0,Yt(e,y,n),Ut=null,qe()&&W!==null&&W.f&1024&&!(W.f&96)&&(Xn===null?Zn([e]):Xn.push(e)),!r.is_fork&&Rt.size>0&&!Bt&&Kt()}return t}function Kt(){Bt=!1;for(let e of Rt){e.f&1024&&$e(e,b);let t;try{t=rr(e)}catch{t=!0}t&&lr(e)}Rt.clear()}function qt(e,t=1){var n=G(e),r=t===1?n++:n--;return L(e,n),r}function Jt(e){L(e,e.v+1)}function Yt(e,t,n){var r=e.reactions;if(r!==null){var i=qe(),a=r.length;if(Wt+=a,Wt>1e5&&Ut===null&&(Ut=new Set),Ut!==null){if(Ut.has(e))return;Ut.add(e)}for(var o=0;o{if(er===d)return e();var t=U,n=er;Wn(null),tr(d);var r=e();return Wn(t),tr(n),r};return i&&r.set(`length`,I(t.length,u)),new Proxy(t,{defineProperty(e,t,n){`value`in n&&n.configurable!==!1&&n.enumerable!==!1&&n.writable!==!1||Ie();var i=r.get(t);return i===void 0?f(()=>{var e=I(n.value,u);return r.set(t,e),e}):L(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>I(A,u));r.set(t,e),Jt(o)}}else L(n,A),Jt(o);return!0},get(e,n,i){if(n===re)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>I(Xt(s?e[n]:A),u)),r.set(n,o)),o!==void 0){var c=G(o);return c===A?void 0:c}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){this.has?.(e,t);var n=Reflect.getOwnPropertyDescriptor(e,t),i=r.get(t);if(i!==void 0){var a=G(i);if(a===A)return;if(n&&`value`in n)n.value=a;else return{enumerable:!0,configurable:!0,value:a,writable:!0}}return n},has(e,t){if(t===re)return!0;var n=r.get(t),i=n!==void 0&&n.v!==A||Reflect.has(e,t);return(n!==void 0||W!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>I(i?Xt(e[t]):A,u)),r.set(t,n)),G(n)===A)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dI(A,u)),r.set(d+``,p)):L(p,A)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>I(void 0,u)),L(c,Xt(n)),r.set(t,c));else{l=c.v!==A;var m=f(()=>Xt(n));L(c,m)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(s,n),!l){if(i&&typeof t==`string`){var g=r.get(`length`),_=Number(t);Number.isInteger(_)&&_>=g.v&&L(g,_+1)}Jt(o)}return!0},ownKeys(e){G(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==A});for(var[n,i]of r)i.v!==A&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Le()}})}function Zt(e){try{if(typeof e==`object`&&e&&re in e)return e[re]}catch{}return e}function Qt(e,t){return Object.is(Zt(e),Zt(t))}var $t,en,tn,nn;function rn(){if($t===void 0){$t=window,en=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;tn=a(t,`firstChild`).get,nn=a(t,`nextSibling`).get,u(e)&&(e[ce]=void 0,e[se]=null,e[k]=void 0,e.__e=void 0),u(n)&&(n[le]=void 0)}}function an(e=``){return document.createTextNode(e)}function on(e){return tn.call(e)}function sn(e){return nn.call(e)}function R(e,t){if(!j)return on(e);var n=on(M);if(n===null)n=M.appendChild(an());else if(t&&n.nodeType!==3){var r=an();return n?.before(r),be(r),r}return t&&dn(n),be(n),n}function z(e,t=!1){if(!j){var n=on(e);return n instanceof Comment&&n.data===``?sn(n):n}if(t){if(M?.nodeType!==3){var r=an();return M?.before(r),be(r),r}dn(M)}return M}function B(e,t=!1){if(!j)return on(e);var n=R(e,t);return N(e),n}function V(e,t=1,n=!1){let r=j?M:e;for(var i;t--;)i=r,r=sn(r);if(!j)return r;if(n){if(r?.nodeType!==3){var a=an();return r===null?i?.after(a):r.before(a),be(a),a}dn(r)}return be(r),r}function cn(e){e.textContent=``}function ln(){return!1}function un(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function dn(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function fn(e){var t=W;if(t===null)return U.f|=ne,e;if(!(t.f&32768)&&!(t.f&4))throw e;pn(e,t)}function pn(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128&&!(t.f&33570816)){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}function mn(e){W===null&&(U===null&&Ne(e),Me()),Vn&&je(e)}function hn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function gn(e,t){var n=W;n!==null&&n.f&8192&&(e|=x);var r={ctx:He,deps:null,nodes:null,f:e|y|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};F?.register_created_effect(r);var i=r;if(e&4)Et===null?At.ensure().schedule(r):Et.push(r);else if(t!==null){try{lr(r)}catch(e){throw jn(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=T))}if(i!==null&&(i.parent=n,n!==null&&hn(i,n),U!==null&&U.f&2&&!(e&64))){var a=U;(a.effects??=[]).push(i)}return r}function _n(){return U!==null&&!Un}function vn(e){let t=gn(8,null);return $e(t,v),t.teardown=e,t}function yn(e){mn(`$effect`);var t=W.f;if(!U&&t&32&&He!==null&&!He.i){var n=He;(n.e??=[]).push(e)}else return bn(e)}function bn(e){return gn(4|D,e)}function xn(e){return mn(`$effect.pre`),gn(8|D,e)}function Sn(e){At.ensure();let t=gn(64|E,e);return(e={})=>new Promise(n=>{e.outro?Pn(t,()=>{jn(t),n(void 0)}):(jn(t),n(void 0))})}function Cn(e){return gn(4,e)}function wn(e){return gn(O|E,e)}function Tn(e,t=0){return gn(8|t,e)}function H(e,t=[],n=[],r=[]){st(r,t,n,t=>{gn(8,()=>{e(...t.map(G))})})}function En(e,t=0){return gn(16|t,e)}function Dn(e){return gn(32|E,e)}function On(e){var t=e.teardown;if(t!==null){let n=Vn,r=U;Hn(!0),Wn(null);try{t.call(null)}catch(t){pn(t,e.parent)}finally{Hn(n),Wn(r)}}}function kn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&at(()=>{e.abort(de)});var r=n.next;n.f&64?n.parent=null:jn(n,t),n=r}}function An(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||jn(t),t=n}}function jn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Mn(e.nodes.start,e.nodes.end),n=!0),e.f|=w,kn(e,t&&!n),cr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();On(e),e.f^=w,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Nn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Mn(e,t){for(;e!==null;){var n=e===t?null:sn(e);e.remove(),e=n}}function Nn(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Pn(e,t,n=!0){var r=[];e.f|=256,Fn(e,r,!0);var i=()=>{n&&jn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Fn(e,t,n){if(!(e.f&8192)){e.f^=x;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=!!(i.f&65536)||!!(i.f&32)&&!!(e.f&16);Fn(i,t,o?n:!1)}i=a}}}function In(e){e.f&=-257,Ln(e,!0)}function Ln(e,t){if(!(e.f&256)&&e.f&8192){e.f^=x,e.f&1024||($e(e,y),At.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=!!(n.f&65536)||!!(n.f&32);Ln(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function Rn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:sn(n);t.append(n),n=i}}var zn=null,Bn=!1,Vn=!1;function Hn(e){Vn=e}var U=null,Un=!1;function Wn(e){U=e}var W=null;function Gn(e){W=e}var Kn=null;function qn(e){U!==null&&(U.f&2097152||U.f&2)&&(Kn??=new Set).add(e)}var Jn=null,Yn=0,Xn=null;function Zn(e){Xn=e}var Qn=1,$n=0,er=$n;function tr(e){er=e}function nr(){return++Qn}function rr(e){var t=e.f;if(t&2048)return!0;if(t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&St===null&&$e(e,v)}return!1}function ir(e,t,n=!0){var r=e.reactions;if(r!==null&&!(Kn!==null&&Kn.has(e)))for(var i=0;i{e.ac.abort(de)}),e.ac=null);try{e.f|=te;var u=e.fn,d=u();e.f|=C;var f=or(e);if(qe()&&Xn!==null&&!Un&&f!==null&&!(e.f&6146))for(var p=0;p0)for(t.length=Yn+Jn.length,r=0;r{s.ac.abort(de),s.ac=null,$e(s,y)}),vt(s),cr(s,0)}}function cr(e,t){var n=e.deps;if(n!==null)for(var r=t;rn?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?(i.__removed=!1,Xe(()=>{i.__removed||t.addEventListener(e,i,r)})):t.addEventListener(e,i,r),i}function Sr(e,t,n,r,i){var a={capture:r,passive:i},o=xr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&vn(()=>{o.__removed=!0,t.removeEventListener(e,o,a)})}function K(e,t,n){(t[vr]??={})[e]=n}function Cr(e){for(var t=0;t{Tr=!1,wr=null}));var s=0,c=wr===e&&e[vr];if(c){var l=a.indexOf(c);if(l!==-1&&(t===document||t===window)){e[vr]=t;return}var u=a.indexOf(t);if(u===-1)return;l<=u&&(s=l)}if(o=a[s]||e.target,o!==t){i(e,`currentTarget`,{configurable:!0,get(){return o||n}});var d=U,f=W;Wn(null),Gn(null);try{for(var p,m=[];o!==null&&o!==t;){try{var h=o[vr]?.[r];h==null||o.disabled&&e.target!==o||h.call(o,e)}catch(e){p?m.push(e):p=e}if(e.cancelBubble)break;s++,o=s{throw e});throw p}}finally{e[vr]=t,delete e.currentTarget,Wn(d),Gn(f)}}}var Dr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Or(e){return Dr?.createHTML(e)??e}function kr(e){var t=un(`template`);return t.innerHTML=Or(e.replaceAll(``,``)),t.content}function Ar(e,t){var n=W;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function q(e,t){var n=!!(t&1),r=!!(t&2),i,a=!e.startsWith(``);return()=>{if(j)return Ar(M,null),M;i===void 0&&(i=kr(a?e:``+e),n||(i=on(i)));var t=r||en?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=on(t),s=t.lastChild;Ar(o,s)}else Ar(t,t);return t}}function jr(e,t,n=`svg`){var r=!e.startsWith(``),i=!!(t&1),a=`<${n}>${r?e:``+e}`,o;return()=>{if(j)return Ar(M,null),M;if(!o){var e=on(kr(a));if(i)for(o=document.createDocumentFragment();on(e);)o.appendChild(on(e));else o=on(e)}var t=o.cloneNode(!0);if(i){var n=on(t),r=t.lastChild;Ar(n,r)}else Ar(t,t);return t}}function Mr(e,t){return jr(e,t,`svg`)}function Nr(e=``){if(!j){var t=an(e+``);return Ar(t,t),t}var n=M;return n.nodeType===3?dn(n):(n.before(n=an()),be(n)),Ar(n,n),n}function Pr(){if(j)return Ar(M,null),M;var e=document.createDocumentFragment(),t=document.createComment(``),n=an();return e.append(t,n),Ar(t,n),e}function J(e,t){if(j){var n=W;n.f&32768&&n.nodes.end!==null||(n.nodes.end=M),xe()}else e!==null&&e.before(t)}function Fr(){if(j&&M&&M.nodeType===8&&M.textContent?.startsWith(`$`)){let e=M.textContent.substring(1);return xe(),e}return(window.__svelte??={}).uid??=1,`c${window.__svelte.uid++}`}function Ir(e){let t=0,n=Vt(0),r;return()=>{_n()&&(G(n),Tn(()=>(t===0&&(r=pr(()=>e(()=>Jt(n)))),t+=1,()=>{Xe(()=>{--t,t===0&&(r?.(),r=void 0,Jt(n))})})))}}var Lr=T|E;function Rr(e,t,n,r){new zr(e,t,n,r)}var zr=class{parent;is_pending=!1;transform_error;#e;#t=j?M:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=Ir(()=>(this.#m=Vt(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=W;t.b=this,t.f|=128,n(e)},this.parent=W.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=En(()=>{if(j){let e=this.#t;xe();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#y():this.#g()}else this.#b()},Lr),j&&(this.#e=M)}#g(){try{this.#a=Dn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed,{reset:n,invoke_onerror:r}=this.#v(e);Xe(r),t&&(this.#s=Dn(()=>{t(this.#e,()=>e,()=>n)}))}#v(e){var t=!1,n=!1;let r=()=>{t?ve():(t=!0,n&&ze(),this.#s!==null&&Pn(this.#s,()=>{this.#s=null}),this.#S(()=>{this.#b()}))};return{reset:r,invoke_onerror:()=>{try{n=!0,this.#n.onerror?.(e,r),n=!1}catch(e){pn(e,this.#i&&this.#i.parent)}}}}#y(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=Dn(()=>e(this.#e)),Xe(()=>{var e=this.#c=document.createDocumentFragment(),t=an(),n=!1;e.append(t),this.#a=this.#S(()=>{try{return Dn(()=>this.#r(t))}catch(e){try{this.error(e),n=!0}catch(e){pn(e,this.#i.parent)}return null}}),this.#a===null?(this.#c=null,n&&this.#x(F)):this.#u===0&&(this.#e.before(e),this.#c=null,Pn(this.#o,()=>{this.#o=null}),this.#x(F))}))}#b(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=Dn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();Rn(this.#a,e);let t=this.#n.pending;this.#o=Dn(()=>t(this.#e))}else this.#x(F)}catch(e){this.error(e)}}#x(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){tt(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#S(e){var t=W,n=U,r=He;Gn(this.#i),Wn(this.#i),Ue(this.#i.ctx);try{return At.ensure(),e()}finally{Gn(t),Wn(n),Ue(r)}}#C(e,t){this.has_pending_snippet()?(this.#u+=e,this.#u===0&&(this.#x(t),this.#o&&Pn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))):this.parent&&this.parent.#C(e,t)}update_pending_count(e,t){this.#C(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,Xe(()=>{this.#d=!1,this.#m&&Gt(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),G(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;F?.is_fork?(this.#a&&F.skip_effect(this.#a),this.#o&&F.skip_effect(this.#o),this.#s&&F.skip_effect(this.#s),F.oncommit(()=>{this.#w(e)})):this.#w(e)}#w(e){this.#a&&=(jn(this.#a),null),this.#o&&=(jn(this.#o),null),this.#s&&=(jn(this.#s),null),j&&(be(this.#t),Se(),be(Ce()));let t=this.#n.failed,n=e=>{let{reset:n,invoke_onerror:r}=this.#v(e);r(),t&&(this.#s=this.#S(()=>{try{return Dn(()=>{var r=W;r.b=this,r.f|=128,t(this.#e,()=>e,()=>n)})}catch(e){return pn(e,this.#i.parent),null}}))};Xe(()=>{var t;try{t=this.transform_error(e)}catch(e){pn(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(n,e=>pn(e,this.#i&&this.#i.parent)):n(t)})}};function Y(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[le]??=e.nodeValue)&&(e[le]=n,e.nodeValue=`${n}`)}function Br(e,t){return Hr(e,t)}var Vr=new Map;function Hr(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){rn();var l=void 0,u=Sn(()=>{var s=n??t.appendChild(an());Rr(s,{pending:()=>{}},t=>{We({});var n=He;if(o&&(n.c=o),a&&(i.$$events=a),j&&Ar(t,null),l=e(t,i)||Ke(),j&&(W.nodes.end=M,M===null||M.nodeType!==8||M.data!==`]`))throw ge(),pe;Ge()},c);var u=new Set,d=e=>{for(var n=0;n{for(var e of u)for(let n of[t,document]){var r=Vr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Er),r.delete(e),r.size===0&&Vr.delete(n)):r.set(e,i)}br.delete(d),s!==n&&s.parentNode?.removeChild(s)}});return Ur.set(l,u),l}var Ur=new WeakMap,Wr=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)In(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(In(r.effect),this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(jn(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();Rn(r,t),t.append(an()),this.#n.set(e,{effect:r,fragment:t})}else jn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Pn(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(jn(n.effect),this.#n.delete(e))};ensure(e,t){var n=F,r=ln();if(t&&!this.#t.has(e)&&!this.#n.has(e)){if(r){var i=document.createDocumentFragment(),a=an();i.append(a),this.#n.set(e,{effect:Dn(()=>t(a)),fragment:i})}else this.#t.set(e,Dn(()=>t(this.anchor)))}if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else j&&(this.anchor=M),this.#a(n)}};function X(e,t,n=!1){var r;j&&(r=M,xe());var i=new Wr(e),a=n?T:0;function o(e,t){if(j){var n=we(r);if(e!==parseInt(n.substring(1))){var a=Ce();be(a),i.anchor=a,ye(!1),i.ensure(e,t),ye(!0);return}}i.ensure(e,t)}En(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var Gr=Symbol(`NaN`);function Kr(e,t,n){j&&xe();var r=new Wr(e),i=!qe();En(()=>{var e=t();e!==e&&(e=Gr),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function qr(e,t){return t}function Jr(e,t,n){for(var i=[],a=t.length,o,s=t.length,c=0;c{if(o){if(o.pending.delete(n),o.done.add(n),o.pending.size===0){var t=e.outrogroups;Yr(e,r(o.done)),t.delete(o),t.size===0&&(e.outrogroups=null)}}else--s},!1)}if(s===0){var l=i.length===0&&n!==null&&e.pending.size===0;if(l){var u=n,d=u.parentNode;cn(d),d.append(u),e.items.clear()}Yr(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function Yr(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i{var t=i();return e(t)?t:t==null?[]:r(t)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=d,Qr(v,p,c,n,a),d!==null&&(p.length===0?d.f&33554432?(d.f^=ee,ei(d,null,c)):In(d):Pn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:En(()=>{p=G(f);var e=p.length;let t=!1;j&&we(c)===`[!`!=(e===0)&&(c=Ce(),be(c),ye(!1),t=!0);for(var r=new Set,u=F,v=ln(),y=0;ys(c)):(d=Dn(()=>s(Xr??=an())),d.f|=ee)),e>r.size&&Ae(``,``,``),j&&e>0&&be(Ce()),!h){if(m.set(u,r),v){for(let[e,t]of l)r.has(e)||u.skip_effect(t.e);u.oncommit(g),u.ondiscard(_)}else g(u)}t&&ye(!0),G(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,j&&(c=M)}function Zr(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function Qr(e,t,n,i,a){var o=!!(i&8),s=t.length,c=e.items,l=Zr(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v0){var E=i&4&&s===0?n:null;if(o){for(v=0;v{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function $r(e,t,n,r,i,a,o,s){var c=o&1?o&16?Vt(n):Ht(n,!1,!1):null,l=o&2?Vt(i):null;return{v:c,i:l,e:Dn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function ei(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=sn(r);if(a.before(r),r===i)return;r=o}}function ti(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function ni(e,t,...n){var r=new Wr(e);En(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},T)}function ri(e,t,n){var r;j&&(r=M,xe());var i=new Wr(e);En(()=>{var e=t()??null;if(j&&we(r)===`[`!=(e!==null)){var a=Ce();be(a),i.anchor=a,ye(!1),i.ensure(e,e&&(t=>n(t,e))),ye(!0)}else i.ensure(e,e&&(t=>n(t,e)))},T)}var ii=[...` -\r\f\xA0\v`];function ai(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i of Object.keys(n))if(n[i])r=r?r+` `+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var s=o+a;(o===0||ii.includes(r[o-1]))&&(s===r.length||ii.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function oi(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function si(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function ci(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\/\*.*?\*\//g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(si)),i&&c.push(...Object.keys(i).map(si));var l=0,u=-1;let t=e.length;for(var d=0;d{t.every(vi)||(`__defaultValue`in e&&pi(e,!1),`__value`in e&&mi(e,e.__value))});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),vn(()=>{t.disconnect()})}function gi(e,t,n=t){var r=new WeakSet,i=!0;ot(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),_i);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&_i(o)}n(a),e.__value=a,F!==null&&r.add(F)}),Cn(()=>{var a=t();if(e===document.activeElement){var o=F;if(r.has(o))return}if(mi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=_i(s),n(a))}e.__value=a,i=!1})}function _i(e){return`__value`in e?e.__value:e.value}function vi(e){if(e.target.closest(`selectedcontent`)!==null)return!0;if(e.type===`childList`){var t=[...e.addedNodes,...e.removedNodes];return t.length>0&&t.every(e=>e.nodeName===`SELECTEDCONTENT`)}return!1}var yi=Symbol(`is custom element`),bi=Symbol(`is html`),xi=fe?`link`:`LINK`;function Si(e){if(j){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;Q(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;Q(e,`checked`,null),e.checked=r}}};e[ue]=n,Xe(n),it()}}function Ci(e,t){var n=wi(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function Q(e,t,n,r){var i=wi(e);j&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===xi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[oe]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&Ei(e).has(t)?e[t]=n:e.setAttribute(t,n))}function wi(e){return e[se]??={[yi]:e.nodeName.includes(`-`),[bi]:e.namespaceURI===me}}var Ti=new Map;function Ei(e){var t=e.getAttribute(`is`)||e.nodeName,n=Ti.get(t);if(n)return n;Ti.set(t,n=new Set);for(var r,i=e,a=Element.prototype;a!==i;){for(var s in r=o(i),r)r[s].set&&s!==`innerHTML`&&s!==`textContent`&&s!==`innerText`&&n.add(s);i=l(i)}return n}function Di(e,t,n=t){var r=new WeakSet;ot(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=Mi(e)?Ni(a):a,n(a),F!==null&&r.add(F),await ur(),a!==(a=t())){var o=e.selectionStart,s=e.selectionEnd,c=e.value.length;if(e.value=a??``,s!==null){var l=e.value.length;o===s&&s===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(s,l))}}}),(j&&e.defaultValue!==e.value||pr(t)==null&&e.value)&&(n(Mi(e)?Ni(e.value):e.value),F!==null&&r.add(F)),Tn(()=>{var n=t();if(e===document.activeElement){var i=F;if(r.has(i))return}Mi(e)&&n===Ni(e.value)||(e.type!==`date`||n||e.value)&&n!==e.value&&(e.value=n??``)})}var Oi=new Set;function ki(e,t,n,r,i=r){var a=n.getAttribute(`type`)===`checkbox`,o=e;let s=!1;if(t!==null)for(var c of t)o=o[c]??=[];o.push(n),ot(n,`change`,()=>{var e=n.__value;a&&(e=ji(o,e,n.checked)),i(e)},()=>i(a?[]:null)),Tn(()=>{var e=r();j&&n.defaultChecked!==n.checked?s=!0:a?(e||=[],n.checked=e.includes(n.__value)):n.checked=Qt(n.__value,e)}),vn(()=>{var e=o.indexOf(n);e!==-1&&o.splice(e,1)}),Oi.has(o)||(Oi.add(o),Xe(()=>{o.sort((e,t)=>e.compareDocumentPosition(t)===4?-1:1),Oi.delete(o)})),Xe(()=>{if(s){var e=a?ji(o,e,n.checked):o.find(e=>e.checked)?.__value;i(e)}})}function Ai(e,t,n=t){ot(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(j&&e.defaultChecked!==e.checked||pr(t)==null)&&n(e.checked),Tn(()=>{e.checked=!!t()})}function ji(e,t,n){for(var r=new Set,i=0;i{var n=this.#e.get(e);n.delete(t),n.size===0&&(this.#e.delete(e),this.#t.unobserve(e))}}#r(){return this.#t??=new ResizeObserver(t=>{for(var n of t){e.entries.set(n.target,n);for(var r of this.#e.get(n.target)||[])r(n)}})}}({box:`border-box`});function Fi(e,t,n){var r=Pi.observe(e,()=>n(e[t]));Cn(()=>(pr(()=>n(e[t])),r))}function Ii(e,t){return e===t||e?.[re]===t}function Li(e=Ke(),t,n,r){var i=He.r,a=W;return Cn(()=>{var o,s;return Tn(()=>{o=s,s=r?.()||[],pr(()=>{Ii(n(...s),e)||(t(e,...s),o&&Ii(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&Ii(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function Ri(e,t,n,r,i){var a=()=>{r(n[e])};n.addEventListener(t,a),i?Tn(()=>{n[e]=i()}):a(),(n===document.body||n===window||n===document)&&vn(()=>{n.removeEventListener(t,a)})}function zi(e=!1){let t=He,n=t.l.u;if(!n)return;let r=()=>mr(t.s);if(e){let e=0,n={},i=dt(()=>{let r=!1,i=t.s;for(let e in i)i[e]!==n[e]&&(n[e]=i[e],r=!0);return r&&e++,e});r=()=>G(i)}n.b.length&&xn(()=>{Bi(t,r),m(n.b)}),yn(()=>{let e=pr(()=>n.m.map(p));return()=>{for(let t of e)typeof t==`function`&&t()}}),n.a.length&&yn(()=>{Bi(t,r),m(n.a)})}function Bi(e,t){if(e.l.s)for(let t of e.l.s)G(t);t()}var Vi=!1;function Hi(e){var t=Vi;try{return Vi=!1,[e(),Vi]}finally{Vi=t}}var Ui={get(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(d(r)&&(r=r()),typeof r==`object`&&r&&t in r)return r[t]}},set(e,t,n){let r=e.props.length;for(;r--;){let i=e.props[r];d(i)&&(i=i());let o=a(i,t);if(o&&o.set)return o.set(n),!0}return!1},getOwnPropertyDescriptor(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(d(r)&&(r=r()),typeof r==`object`&&r&&t in r){let e=a(r,t);return e&&!e.configurable&&(e.configurable=!0),e}}},has(e,t){if(t===re||t===ae)return!1;for(let n of e.props)if(d(n)&&(n=n()),n!=null&&t in n)return!0;return!1},ownKeys(e){let t=[];for(let n of e.props)if(d(n)&&(n=n()),n){for(let e in n)t.includes(e)||t.push(e);for(let e of Object.getOwnPropertySymbols(n))t.includes(e)||t.push(e)}return t}};function Wi(...e){return new Proxy({props:e},Ui)}function Gi(e,t,n,r){var i=!Be||!!(n&2),o=!!(n&8),s=!!(n&16),c=r,l=!0,u=void 0,d=()=>s&&i?(u??=dt(r),G(u)):(l&&(l=!1,c=s?pr(r):r),c);let f;if(o){var p=re in e||ae in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=Hi(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&Fe(t),f(m)));var g=i?()=>{var n=e[t];return n===void 0?d():(l=!0,n)}:()=>{var n=e[t];return n!==void 0&&(c=void 0),n===void 0?c:n};if(i&&!(n&4))return g;if(f){var _=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||_||h)&&f(t?g():e),e):g()})}var v=!1,y=(n&1?dt:mt)(()=>(v=!1,g()));o&&G(y);var b=W;return(function(e,t){if(arguments.length>0){let n=t?G(y):i&&o?Xt(e):e;return L(y,n),v=!0,c!==void 0&&(c=n),e}return Vn&&v||b.f&16384?y.v:G(y)})}function Ki(e){He===null&&Oe(`onMount`),Be&&He.l!==null?Ji(He).m.push(e):yn(()=>{let t=pr(e);if(typeof t==`function`)return t})}function qi(e){He===null&&Oe(`onDestroy`),Ki(()=>()=>pr(e))}function Ji(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);function Yi(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,i,a,o=[],s=``,c=e.split(`/`);for(c[0]||c.shift();i=c.shift();)n=i[0],n===`*`?(o.push(`wild`),s+=`/(.*)`):n===`:`?(r=i.indexOf(`?`,1),a=i.indexOf(`.`,1),o.push(i.substring(1,~r?r:~a?a:i.length)),s+=~r&&!~a?`(?:/([^/]+?))?`:`/([^/]+?)`,~a&&(s+=(~r?`?`:``)+`\\`+i.substring(a))):s+=`/`+i;return{keys:o,pattern:RegExp(`^`+s+(t?`(?=$|/)`:`/?$`),`i`)}}var Xi=new class{#e=I(Zi());get _loc(){return G(this.#e)}set _loc(e){L(this.#e,e)}#t=P(()=>this._loc.location);get _location(){return G(this.#t)}set _location(e){L(this.#t,e)}#n=P(()=>this._loc.querystring);get _querystring(){return G(this.#n)}set _querystring(e){L(this.#n,e)}#r=I(void 0);get _params(){return G(this.#r)}set _params(e){L(this.#r,e)}get loc(){return this._loc}get location(){return this._location}get querystring(){return this._querystring}get params(){return this._params}constructor(){typeof window<`u`?window.addEventListener(`hashchange`,()=>{this._loc=Zi()}):console.warn(`[svelte-spa-router] window 'window' is not defined, skipping initiation`)}};function Zi(){let e=typeof window<`u`?window.location.href:``,t=e.indexOf(`#/`),n=t>-1?e.substr(t+1):`/`,r=n.indexOf(`?`),i=``;return r>-1&&(i=n.substr(r+1),n=n.substr(0,r)),{location:n,querystring:i}}async function Qi(e){if(!e||e.length<1||e.charAt(0)!=`/`&&e.indexOf(`#/`)!==0)throw Error(`Invalid parameter location`);await ur();let t=(e.charAt(0)==`#`?``:`#`)+e;try{let e={...history.state};delete e.__svelte_spa_router_scrollX,delete e.__svelte_spa_router_scrollY,window.history.replaceState(e,``,t)}catch{console.warn("Caught exception while replacing the current page. If you're running this in the Svelte REPL, please note that the `replace` method might not work in this environment.")}window.dispatchEvent(new Event(`hashchange`))}function $i(e){e?window.scrollTo(e.__svelte_spa_router_scrollX||0,e.__svelte_spa_router_scrollY||0):window.scrollTo(0,0)}function ea(e,t){We(t,!0);let n=Gi(t,`routes`,19,()=>({})),r=Gi(t,`prefix`,3,``),i=Gi(t,`restoreScrollState`,3,!1),a=Gi(t,`onConditionsFailed`,3,()=>{}),o=Gi(t,`onRouteLoaded`,3,()=>{}),s=Gi(t,`onRouteLoading`,3,()=>{}),c=Gi(t,`onRouteEvent`,3,()=>{});class l{path;component;conditions;userData;props;_pattern;_keys;constructor(e,t){let n=e=>typeof e==`object`&&!!e&&e._sveltesparouter===!0;if(!t||typeof t!=`function`&&!n(t))throw Error(`Invalid component object`);if(!e||typeof e==`string`&&(e.length<1||e.charAt(0)!=`/`&&e.charAt(0)!=`*`)||typeof e==`object`&&!(e instanceof RegExp))throw Error(`Invalid value for "path" argument - strings must start with / or *`);let r=Yi(e);if(this.path=e,n(t)){let e=t;this.component=e.component,this.conditions=e.conditions||[],this.userData=e.userData,this.props=e.props||{}}else{let e=t;this.component=()=>Promise.resolve(e),this.conditions=[],this.props={}}this._pattern=r.pattern,this._keys=r.keys}match(e){if(r()){if(typeof r()==`string`){if(e.startsWith(r()))e=e.substr(r().length)||`/`;else return null}else if(r()instanceof RegExp){let t=e.match(r());if(t&&t[0])e=e.substr(t[0].length)||`/`;else return null}}let t=this._pattern.exec(e);if(t===null)return null;if(this._keys===!1)return t;let n={},i=0;for(;i{u.push(new l(t,e))}):Object.keys(n()).forEach(e=>{let t=n();u.push(new l(e,t[e]))});let d=I(null),f=I(null),p=I({}),m=null,h=null;yn(()=>{history.scrollRestoration=i()?`manual`:`auto`}),yn(()=>{if(!i())return;let e=e=>{m=e.state&&(e.state.__svelte_spa_router_scrollY||e.state.__svelte_spa_router_scrollX)?e.state:null};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)});async function g(e,t){await ur(),e(t)}yn(()=>{let e=Xi.loc,t=!1;return pr(async()=>{let n=0;for(;n{t=!0}});function _(e){return e&&typeof e==`object`&&Object.keys(e).length?e:null}var v=Pr(),y=z(v),b=e=>{let t=P(()=>G(d));var n=Pr(),r=z(n),i=e=>{var n=Pr();ri(z(n),()=>G(t),(e,t)=>{t(e,Wi({get params(){return G(f)},get onRouteEvent(){return c()}},()=>G(p)))}),J(e,n)},a=e=>{var n=Pr();ri(z(n),()=>G(t),(e,t)=>{t(e,Wi({get onRouteEvent(){return c()}},()=>G(p)))}),J(e,n)};X(r,e=>{G(f)?e(i):e(a,-1)}),J(e,n)};X(y,e=>{G(d)&&e(b)}),J(e,v),Ge()}var ta=[`bars`,`pace`,`pie`,`fuel`,`resets`,`thresholds`];function na(e){return e===`zone`||e===`consumption-pace`?`pace`:typeof e==`string`&&ta.includes(e)?e:`bars`}var ra=`codexometer.web.preferences.v1`,ia={statusLine:null,tab:`quota`,view:`bars`,selected:``,defaultDetail:0,layouts:[]};function aa(){try{let e=JSON.parse(localStorage.getItem(ra)||`null`);return!e||typeof e!=`object`?ia:{statusLine:Array.isArray(e.statusLine)?[...new Set(e.statusLine.filter(e=>typeof e==`string`&&e.length<64))].slice(0,32):null,tab:[`quota`,`sessions`,`usage`].includes(e.tab)?e.tab:`quota`,view:na(e.view),selected:typeof e.selected==`string`?e.selected.slice(0,256):``,defaultDetail:+(e.defaultDetail===1),layouts:Array.isArray(e.layouts)?e.layouts.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length<=256&&[0,1,2].includes(t.level)}).slice(-100):[]}}catch{return ia}}var oa=Xt(aa()),sa=Xt({open:!1}),ca=Xt({requests:0});function la(){let e=JSON.stringify(oa);try{localStorage.setItem(ra,e)}catch{}}function ua(){return oa.tab===`quota`?`/quota/`+oa.view:`/`+oa.tab}function da(e){return oa.layouts.find(t=>t.id===e)?.level??oa.defaultDetail}function fa(e){oa.defaultDetail=e,oa.layouts=[]}function pa(e,t){oa.layouts=[...oa.layouts.filter(t=>t.id!==e),{id:e,level:Math.max(0,Math.min(2,t))}].slice(-100)}var $=Xt({data:null,connected:!1,error:``}),ma=e=>e==null?`Unavailable`:e.toLocaleString(`en-GB`),ha=e=>!e||String(e).startsWith(`0001-`)?`Not yet available`:new Date(typeof e==`number`?e*1e3:e).toLocaleString(`en-GB`),ga=`codexometer.web.session`,_a=class extends Error{},va;async function ya(e,t,n){if(!va||!$.connected||!$.data?.control||$.data.sessionsError)throw Error(`Session controls unavailable. Check the live connection.`);return await va(e,t,n)}function ba(){let e=new AbortController,t,n=``;va=async(t,r,i)=>{let a=await fetch(`/api/control/`+t,{method:`POST`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`},body:JSON.stringify(r),signal:AbortSignal.any([e.signal,AbortSignal.timeout(8e3),...i?[i]:[]]),cache:`no-store`});if(!a.ok)throw a.status===502?Error(`Outcome uncertain. Check Codex before taking another action; nothing was retried.`):new _a(`Action rejected, expired or changed. Refresh and check Codex; nothing was retried.`);return a.json()};try{n=sessionStorage.getItem(ga)||``}catch{}let r=location.hash,i=r.startsWith(`#pair=`)?r.slice(6):``;(i||!r||r===`#`)&&(history.replaceState(null,``,`/#`+ua()),window.dispatchEvent(new HashChangeEvent(`hashchange`)));async function a(){if(i)try{let t=await fetch(`/api/pair`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({secret:i}),signal:e.signal});if(!t.ok)throw Error(`Pairing link expired or already used. Restart --web for a fresh link.`);n=(await t.json()).token;try{sessionStorage.setItem(ga,n)}catch{}}catch(t){e.signal.aborted||($.error=t instanceof Error?t.message:`Pairing failed`);return}n?await o():$.error=`Open the private pairing link printed by codexometer --web in your terminal.`}async function o(){try{let t=await fetch(`/api/events`,{headers:{Authorization:`Bearer ${n}`},signal:e.signal,cache:`no-store`});if(t.status===401){try{sessionStorage.removeItem(ga)}catch{}$.error=`Browser session expired. Restart --web and open its new pairing link.`;return}if(!t.ok||!t.body)throw Error(`Live connection unavailable`);let r=t.body.getReader(),i=new TextDecoder,a=``;for(;!e.signal.aborted;){let{done:e,value:t}=await r.read();if(e)break;a+=i.decode(t,{stream:!0});let n;for(;(n=a.indexOf(` - -`))>=0;){let e=a.slice(0,n);a=a.slice(n+2),e.startsWith(`data: `)&&($.data=JSON.parse(e.slice(6)),$.connected=!0,$.error=``)}}}catch{}finally{$.connected=!1}e.signal.aborted||($.error=`Connection lost — showing last observation. Reconnecting…`,t=setTimeout(o,2500))}return a(),()=>{va=void 0,e.abort(),clearTimeout(t),$.connected=!1}}Ve();var xa=q(`

      Quota refresh failed. Policy state is based on the last successful - observation.

      `),Sa=q(`

      `),Ca=q(`

      The longest Codex quota window selects one active model profile. ASK - creates a per-session review; AUTO applies the profile on the next - eligible check.

      `,1),wa=q(`

      No threshold-based model steps were configured at launch.

      `);function Ta(e,t){We(t,!1),zi();var n=Pr(),r=z(n),i=e=>{var t=Ca(),n=z(t),r=B(n),i=V(n,2),a=e=>{J(e,xa())};X(i,e=>{$.data.quotaError&&e(a)});var o=V(i,2),s=R(o),c=B(s),l=V(s,4);Z(l,5,()=>$.data.thresholds,qr,(e,t)=>{var n=Sa();let r;var i=R(n),a=B(i),o=V(i,2),s=R(o),c=B(s,!0),l=B(V(s,2));N(o);var u=V(o,2),d=B(u,!0),f=B(V(u,2));N(n),H((e,i)=>{r=li(n,1,``,null,r,{active:G(t).state===`ACTIVE`,next:G(t).state===`NEXT`}),Y(a,`${G(t).threshold??``}%`),Y(c,G(t).model),Y(l,`${e??``} REASONING // ${i??``} - SPEED`),Y(d,G(t).mode),Y(f,`${G(t).state??``}${G(t).state===`NEXT`?` // ${G(t).remaining||0} PP TO GO`:``}`)},[()=>G(t).effort.toUpperCase(),()=>G(t).speed.toUpperCase()]),J(e,n)}),N(l),N(o),H(e=>{Y(r,`MODEL STEP POLICY // OBSERVED ${e??``}`),Y(c,`THRESHOLDS // ${$.data.thresholds.length??``} CONFIGURED`)},[()=>ha($.data.quotaAt)]),J(e,t)},a=e=>{J(e,wa())};X(r,e=>{$.data?.thresholds?.length?e(i):e(a,-1)}),J(e,n),Ge()}var Ea=Mr(` `,1),Da=Mr(` `,1),Oa=Mr(` `,1),ka=Mr(` `,1),Aa=q(`
      `,1),ja=q(` `),Ma=q(`
      Quota observations
      Observed atPeriod elapsedConsumedTrail segment
      `),Na=q(`
      OBSERVATION DATA
      `),Pa=q(`
      CONSUMPTIONQUOTA PERIOD ELAPSED
      `,1);function Fa(e,t){let n=Fr();We(t,!0);let r=Gi(t,`trail`,19,()=>[]),i=I(!1),a=I(!0),o=I(`window`),s=[0,25,50,75,100],c=P(()=>t.plot?.known?t.plot.elapsed:t.elapsed),l=I(400),u=I(240),d=P(()=>G(l)-24),f=P(()=>G(u)-48),p=P(()=>Math.max(1,G(d)-48)),m=P(()=>Math.max(1,G(f)-20)),h=P(()=>48+Math.max(0,Math.min(100,G(c)))/100*G(p));function g(e){return G(f)-(e-0)/100*G(m)}let _=P(()=>g(t.used)),v=P(()=>t.used-G(c)),y=P(()=>r().map((e,t)=>`${t===0||e.break?`M`:`L`}${48+e.elapsed/100*G(p)} ${g(e.used)}`).join(` `)),b=P(()=>{let e=0;for(let t=r().length-1;t>0;t--)if(r()[t].break){e=t;break}return r().slice(e)}),x=P(()=>G(b).length<2?0:Math.max(0,Date.parse(G(b).at(-1).at)-Date.parse(G(b)[0].at))),S=P(()=>Object.fromEntries((t.plot?.modes||[]).map(e=>[e.id,e.available])));yn(()=>{G(o)!==`window`&&!G(S)[G(o)]&&L(o,`window`)});let C=P(()=>{let e=t.plot?.modes.find(e=>e.id===G(o));if(!e?.segment)return null;let{x1:n,y1:r,x2:i,y2:a}=e.segment,s=Math.hypot((i-n)/100*G(p),(a-r)/100*G(m)),c=Math.max(3,Math.min(9,Math.floor(s/65)+2));return{path:`M${Array.from({length:c},(e,t)=>{let o=n+(i-n)*t/(c-1),s=r+(a-r)*t/(c-1);return`${48+o/100*G(p)} ${g(s)}`}).join(` L`)}`,projected:e.projected,safe:e.safe}}),w=P(()=>{if(G(b).length===0)return`NO OBSERVATIONS`;if(G(b).length===1)return`ONE OBSERVATION`;let e=Math.floor(G(x)/6e4);if(e<60)return`${e} MIN CONTINUOUS`;let t=Math.floor(e/60);return t<24?`${t}H CONTINUOUS`:`${Math.floor(t/24)}D ${t%24}H CONTINUOUS`});var T=Pa(),E=z(T),D=R(E);let ee;var te=R(D),O=R(te),ne=V(O);N(te);var re=V(te),ie=V(re);Z(ie,17,()=>s,qr,(e,t)=>{var n=Ea(),r=z(n),i=V(r),a=B(i);H(()=>{Q(r,`x1`,48+G(t)/100*G(p)),Q(r,`x2`,48+G(t)/100*G(p)),Q(r,`y2`,G(f)),Q(i,`x`,48+G(t)/100*G(p)),Q(i,`y`,G(f)+20),Y(a,`${G(t)??``}%`)}),J(e,n)});var ae=V(ie);Z(ae,17,()=>s,qr,(e,t)=>{var n=Da(),r=z(n),i=V(r),a=B(i);H((e,n,o)=>{Q(r,`y1`,e),Q(r,`x2`,G(d)),Q(r,`y2`,n),Q(i,`y`,o),Y(a,`${G(t)??``}%`)},[()=>g(G(t)),()=>g(G(t)),()=>g(G(t))+4]),J(e,n)});var oe=V(ae),se=V(oe),ce=V(se),k=e=>{var t=Oa(),n=z(t),i=V(n),a=V(i),o=B(R(a));N(a),H((e,t)=>{Q(n,`d`,G(y)),Q(i,`d`,G(y)),Q(a,`cx`,48+r()[0].elapsed/100*G(p)),Q(a,`cy`,e),Y(o,`First observation: ${t??``}`)},[()=>g(r()[0].used),()=>ha(r()[0].at)]),J(e,t)};X(ce,e=>{G(a)&&r().length&&e(k)});var le=V(ce),ue=e=>{var t=ka(),r=z(t),i=V(r),a=B(R(i));N(i),H(e=>{Q(r,`d`,G(C).path),Q(i,`d`,G(C).path),Q(i,`marker-mid`,`url(#${n}-trend-arrow)`),Y(a,`${G(o)===`window`?`Window-average pace`:`Recent consumption trajectory`} projects ${e??``}% at reset if continued`)},[()=>G(C).projected.toFixed(1)]),J(e,t)};X(le,e=>{G(C)&&e(ue)});var de=V(le,2),fe=V(de),pe=V(fe),A=B(R(pe));N(pe),N(D),N(E);var me=V(E,2),he=R(me),ge=R(he),_e=V(ge,3),ve=B(_e,!0),j=V(_e,2),ye=e=>{var t=Aa(),n=B(V(z(t)));H(e=>Y(n,`TREND // ${e??``}`),[()=>G(C).projected>=100?`QUOTA EXHAUSTION PROJECTED`:`${G(C).projected.toFixed(1)}% PROJECTED AT RESET`]),J(e,t)};X(j,e=>{G(C)&&e(ye)}),N(he);var M=V(he,2),be=R(M),xe=R(be);Si(xe),Se(),N(be);var Ce=V(be,2),we=V(R(Ce),2),Te=R(we);Te.value=Te.__value=`off`;var Ee=V(Te),De=B(Ee);Ee.value=Ee.__value=`halfHour`;var Oe=V(Ee),ke=B(Oe);Oe.value=Oe.__value=`hour`;var Ae=V(Oe),je=B(Ae);Ae.value=Ae.__value=`day`;var Me=V(Ae),Ne=B(Me);Me.value=Me.__value=`window`,N(we),hi(we),N(Ce);var Pe=B(V(Ce,2));N(M),N(me);var Fe=V(me,2),Ie=e=>{var t=Na(),n=V(R(t),2),a=e=>{var t=Ma(),n=R(t),i=V(R(n),2);Z(i,21,r,qr,(e,t,n)=>{var r=ja(),i=R(r),a=R(i),o=B(a,!0);N(i);var s=V(i),c=B(s),l=V(s),u=B(l),d=B(V(l),!0);N(r),H((e,r)=>{Q(a,`datetime`,G(t).at),Y(o,e),Y(c,`${r??``}%`),Y(u,`${G(t).used??``}%`),Y(d,n===0?`First observation`:G(t).break?`Gap before this observation`:`Connected to previous observation`)},[()=>ha(G(t).at),()=>G(t).elapsed.toFixed(1)]),J(e,r)}),N(i),N(n),N(t),J(e,t)};X(n,e=>{G(i)&&e(a)}),N(t),Ri(`open`,`toggle`,t,e=>L(i,e),()=>G(i)),J(e,t)};X(Fe,e=>{r().length&&e(Ie)}),H((e,r,i,a,o,s)=>{Q(D,`viewBox`,`0 0 ${G(l)} ${G(u)}`),Q(D,`aria-label`,e),ee=di(D,``,ee,{"--trend-color":G(C)?.safe?`#115b35`:`#7f1825`}),Q(O,`id`,n),Q(ne,`id`,n+`-trend-arrow`),Q(re,`width`,G(p)),Q(re,`height`,G(m)),Q(re,`fill`,`url(#${n})`),Q(oe,`d`,`M48 20 V${G(f)} H${G(d)}`),Q(se,`y1`,r),Q(se,`x2`,G(d)),Q(se,`y2`,i),Q(de,`x`,48+G(p)/2),Q(de,`y`,G(u)-5),Q(fe,`cx`,G(h)),Q(fe,`cy`,G(_)),Q(pe,`cx`,G(h)),Q(pe,`cy`,G(_)),Y(A,`${t.used??``}% consumed // ${a??``}% of period elapsed`),Y(ge,`${t.used??``}% USED // ${o??``}% TIME ELAPSED`),Y(ve,s),Ee.disabled=!G(S).halfHour,Y(De,`LAST 30 MINUTES${G(S).halfHour?``:` — UNAVAILABLE`}`),Oe.disabled=!G(S).hour,Y(ke,`LAST HOUR${G(S).hour?``:` — UNAVAILABLE`}`),Ae.disabled=!G(S).day,Y(je,`LAST 24 HOURS${G(S).day?``:` — UNAVAILABLE`}`),Me.disabled=!G(S).window,Y(Ne,`FROM WINDOW START${G(S).window?``:` — NO TIME ELAPSED`}`),Y(Pe,`HISTORY // ${G(w)??``}`)},[()=>`Pace: ${t.used}% consumed, ${G(c).toFixed(1)}% of quota period elapsed. ${G(v)>0?`Above`:G(v)<0?`Below`:`On`} the steady-consumption line.${G(a)&&r().length?` Trace path contains ${r().length} ${r().length===1?`observation`:`observations`}; gaps are not interpolated.`:``}`,()=>g(0),()=>g(100),()=>G(c).toFixed(1),()=>G(c).toFixed(1),()=>Math.abs(G(v))<.05?`ON PACE`:G(v)>0?`ABOVE THE LINE — CONSUMING FASTER THAN TIME`:`BELOW THE LINE — WITHIN PACE`]),Fi(E,`clientWidth`,e=>L(l,e)),Fi(E,`clientHeight`,e=>L(u,e)),Ai(xe,()=>G(a),e=>L(a,e)),gi(we,()=>G(o),e=>L(o,e)),J(e,T),Ge()}var Ia=q(` `),La=q(`

      Quota refresh failed. Values below are the last successful observation.

      `),Ra=q(`

      `),za=q(`

      Expiry details unavailable. No listed expiry does not mean no expiry.

      `),Ba=q(`

      `),Va=q(`

      Read-only preview. Use the terminal to redeem a reset.

      The backend may return only some credits. This list does not establish - redemption order.

      `),Ha=q(` `,1),Ua=Mr(``),Wa=Mr(``),Ga=q(`
      `),Ka=q(`

      Cycle duration or reset date unavailable — position cannot be - plotted.

      `),qa=q(`
      EMPTYFULL
      `),Ja=q(`

      `,1),Ya=q(`
      `,1),Xa=q(`

      `),Za=q(`

      `),Qa=q(`

      No quota windows reported yet.

      `),$a=q(`
      `,1),eo=q(`

      All reported windows are shown. API-equivalent learning and quota status - scoring remain in the terminal for this first preview.

      `,1),to=q(` `,1);function no(e,t){We(t,!0);let n=Gi(t,`params`,19,()=>({})),r=P(()=>ta.filter(e=>e!==`thresholds`||!!$.data?.thresholds?.length)),i=I(Xt(Date.now())),a=P(()=>G(r).includes(na(n().view))?na(n().view):`bars`);Ki(()=>{let e=setInterval(()=>L(i,Date.now(),!0),1e3);return()=>clearInterval(e)});function o(e){return!e.duration||e.duration<=0||!e.reset?null:Math.max(0,Math.min(100,100*(1-(e.reset*1e3-G(i))/(e.duration*6e4))))}yn(()=>{oa.view=G(a),(n().view===`zone`||n().view===`consumption-pace`)&&Qi(`/quota/pace`)});function s(e){let t=e/100*Math.PI*2;return`M60 60 L60 14 A46 46 0 ${+(e>50)} 1 ${60+46*Math.sin(t)} ${60-46*Math.cos(t)} Z`}var c=to(),l=z(c);Z(l,21,()=>G(r),qr,(e,t)=>{var n=Ia();let r;var i=B(n,!0);H(e=>{Q(n,`href`,`#/quota/`+G(t)),Q(n,`aria-current`,G(a)===G(t)?`page`:void 0),r=li(n,1,``,null,r,{active:G(a)===G(t)}),Y(i,e)},[()=>G(t)===`fuel`?`FUEL TANK`:G(t).toUpperCase()]),J(e,n)}),N(l);var u=V(l,2),d=e=>{var t=eo(),n=z(t),r=e=>{J(e,La())};X(n,e=>{$.data.quotaError&&e(r)});var i=V(n,2),c=e=>{var t=Ra(),n=B(t);H(()=>Y(n,`Last usage accounting issue: - ${$.data.usageDiagnostic??``}`)),J(e,t)};X(i,e=>{$.data.usageDiagnostic&&e(c)});var l=V(i,2),u=B(l),d=V(l,2),f=e=>{Ta(e,{})},p=e=>{var t=Va(),n=R(t),r=B(n),i=V(n,4),a=e=>{J(e,za())};X(i,e=>{$.data.credits.length||e(a)}),Z(V(i,2),17,()=>$.data.credits,qr,(e,t)=>{var n=Ba(),r=R(n),i=B(r),a=B(V(r,2),!0);N(n),H(e=>{Y(i,`${(G(t).title||`Quota reset`)??``} // ${G(t).status??``}`),Y(a,e)},[()=>G(t).expiryKnown?G(t).expires?`EXPIRES `+ha(G(t).expires):`Does not expire`:`Expiry information unavailable`]),J(e,n)}),Se(2),N(t),H(()=>Y(r,`RESET INVENTORY // ${$.data.creditCount??``} AVAILABLE`)),J(e,t)},m=e=>{var t=$a(),n=z(t);let r;Z(n,21,()=>$.data.meters,qr,(e,t)=>{let n=P(()=>o(G(t)));var r=Za(),i=R(r),c=B(i,!0),l=V(i,2),u=R(l),d=e=>{var n=Ha(),r=z(n),i=B(r),a=B(V(r));H(()=>{Y(i,`FREE ${100-G(t).used}%`),Y(a,`USED ${G(t).used??``}%`)}),J(e,n)},f=e=>{var n=Ha(),r=z(n),i=B(r),a=B(V(r));H(()=>{Y(i,`USED ${G(t).used??``}%`),Y(a,`FREE ${100-G(t).used}%`)}),J(e,n)};X(u,e=>{G(a)===`fuel`?e(d):e(f,-1)}),N(l);var p=V(l,2);let m;var h=R(p),g=e=>{var n=Ga(),r=R(n),i=V(R(r)),a=e=>{J(e,Ua())},o=e=>{var n=Wa();H(e=>Q(n,`d`,e),[()=>s(G(t).used)]),J(e,n)};X(i,e=>{G(t).used>=100?e(a):G(t).used>0&&e(o,1)}),N(r),N(n),H(()=>Q(r,`aria-label`,`${G(t).used}% quota used`)),J(e,n)},_=e=>{var r=Pr(),i=z(r),a=e=>{{let r=P(()=>G(t).trail||[]);Fa(e,{get used(){return G(t).used},get elapsed(){return G(n)},get trail(){return G(r)},get plot(){return G(t).plot}})}},o=e=>{J(e,Ka())};X(i,e=>{G(n)===null?e(o,-1):e(a)}),J(e,r)},v=e=>{var r=Ya(),i=z(r),o=R(i);let s;N(i);var c=V(i,2),l=e=>{J(e,qa())};X(c,e=>{G(a)===`fuel`&&e(l)});var u=V(c,2),d=e=>{var t=Ja(),r=z(t),i=B(r),o=V(r,2),s=R(o);let c;N(o),H(e=>{Y(i,`RESET CYCLE // ${e??``}% ELAPSED`),c=di(s,``,c,{width:`${G(a)===`fuel`?100-G(n):G(n)}%`})},[()=>Math.floor(G(n))]),J(e,t)};X(u,e=>{G(n)!==null&&e(d)}),H(()=>{Q(i,`aria-label`,G(a)===`fuel`?`Fuel remaining`:`Quota used`),Q(i,`aria-valuenow`,G(a)===`fuel`?100-G(t).used:G(t).used),s=di(o,``,s,{width:`${G(a)===`fuel`?100-G(t).used:G(t).used}%`})}),J(e,r)};X(h,e=>{G(a)===`pie`?e(g):G(a)===`pace`?e(_,1):e(v,-1)}),N(p);var y=V(p,2),b=B(y),x=V(y,2),S=e=>{var n=Xa(),r=B(n,!0);H(()=>Y(r,G(t).details)),J(e,n)};X(x,e=>{G(t).details&&e(S)}),N(r),H(e=>{Y(c,G(t).name),m=li(p,1,`meter-graphic`,null,m,{"bar-graphic":G(a)===`bars`||G(a)===`fuel`}),Y(b,`RESETS // ${e??``}`)},[()=>ha(G(t).reset)]),J(e,r)}),N(n);var i=V(n,2),c=e=>{J(e,Qa())};X(i,e=>{$.data.meters.length||e(c)}),H(()=>r=li(n,1,`quota-grid`,null,r,{radial:G(a)===`pie`,zone:G(a)===`pace`})),J(e,t)};X(d,e=>{G(a)===`thresholds`?e(f):G(a)===`resets`?e(p,1):e(m,-1)}),Se(2),H(e=>Y(u,`QUOTA // OBSERVED ${e??``}`),[()=>ha($.data.quotaAt)]),J(e,t)};X(u,e=>{$.data&&e(d)}),J(e,c),Ge()}var ro=q(`
      `),io=q(`

      `,1);function ao(e,t){We(t,!0);let n=Gi(t,`values`,19,()=>[]),r=Gi(t,`label`,3,`Token activity`),i=Gi(t,`capacity`,3,0),a=P(()=>Math.max(0,...n())),o=P(()=>i()>n().length?[...Array(i()-n().length).fill(0),...n()]:n());var s=io(),c=z(s),l=B(c),u=V(c,2);Z(u,21,()=>G(o),qr,(e,t)=>{var n=ro();let r;H((e,t)=>{Q(n,`title`,e),r=di(n,``,r,{height:t})},[()=>G(t).toLocaleString(`en-GB`)+` tokens`,()=>`${100*G(t)/Math.max(1,G(a))}%`]),J(e,n)}),N(u),H((e,t)=>{Y(l,`SCALE // 0 — ${e??``} TOKENS`),Q(u,`aria-label`,t)},[()=>G(a).toLocaleString(`en-GB`),()=>`${r()}. Peak ${G(a).toLocaleString(`en-GB`)} tokens.`]),J(e,s),Ge()}function oo(e){if(!e||![`LAST REPLY`,`LAST ACTIVITY`].includes(e.contextKind))return``;let t=e.text||e.contextKind===`LAST ACTIVITY`&&e.workingCommand||``;return t.trim()?t:``}var so=[{id:`local-statusline`,label:`/statusline`,help:`Choose fields for Codexometer’s detail footer. Saved display preferences only.`,next:`statusline`},{id:`local-usage`,label:`/usage`,help:`Open Codexometer’s usage history. Existing quota and reset views remain available.`,next:`usage`},{id:`local-copy`,label:`/copy`,help:`Copy the selected session’s observed reply or activity using Codexometer’s copy control.`,next:`copy`},{id:`local-theme`,label:`/theme`,help:`Choose a Codexometer display theme. Saved local display preferences only.`,next:`theme`},{id:`local-exit`,label:`/exit`,help:`Leave this Codexometer interface. Codex sessions continue running.`,next:`exit`},{id:`local-quit`,label:`/quit`,help:`Alias for /exit. Codex sessions continue running.`,next:`quit`}],co=[`surface`,`model`,`feature`,`task start`],lo=q(` `),uo=q(``),fo=q(`

      `),po=q(`

      `),mo=q(`
      `),ho=q(`

      `),go=q(`

      `,1),_o=q(`

      `),vo=q(`

      Loading / sending…

      `),yo=q(`
      `),bo=q(`

      `),xo=q(`

       
      `),So=q(`
      `),Co=q(`
      `),wo=q(`

      Review expired. Press Enter to review again.

      `),To=q(`

      `,1),Eo=q(`

      `,1),Do=q(`

      No available matching commands.

      `),Oo=q(` `,1),ko=q(`

      `),Ao=q(`

      Review expired. Review the option again.

      `),jo=q(``),Mo=q(``),No=q(``),Po=q(``),Fo=q(``),Io=q(``),Lo=q(`
      `),Ro=q(`
      `);function zo(e,t){let n=Fr();We(t,!0);let r=e=>{var t=Pr();Z(z(t),19,()=>G(pe),e=>e.id,(e,t,r)=>{var i=uo();let o;var s=R(i),c=B(s,!0),l=V(s),u=B(l),d=V(l),f=e=>{var n=lo(),r=B(n,!0);H(()=>Y(r,G(t).help)),J(e,n)};X(d,e=>{(G(v)?.path===``||G(k))&&e(f)}),N(i),H((e,s)=>{Q(i,`id`,`${n}-${G(r)}`),Q(i,`role`,G(k)?`option`:void 0),Q(i,`aria-selected`,G(k)?G(T)===G(r):void 0),Q(i,`tabindex`,G(k)?-1:void 0),i.disabled=G(g)||G(ge)&&!a(),Q(i,`title`,G(t).help),Q(i,`aria-label`,e),o=li(i,1,`svelte-7bfwr9`,null,o,{suggested:G(T)===G(r)}),Y(c,G(t).label),Y(u,`${G(k)&&G(t).selected?` // CURRENT`:``}${s??``}`)},[()=>G(t).label+(G(k)&&G(t).selected?` // CURRENT`:``)+ae(G(t)),()=>ae(G(t))]),Sr(`focus`,i,()=>{G(k)||ve(G(r))}),K(`click`,i,()=>{ve(G(r)),be(G(t))}),J(e,i)}),J(e,t)},i=Gi(t,`query`,3,``),a=Gi(t,`localOnly`,3,!1),o=Gi(t,`oncopy`,3,()=>{}),s=Gi(t,`onchange`,3,()=>{}),c=Gi(t,`oncomplete`,3,e=>{}),l=so.map(e=>e.next);function u(){return so.map(e=>[`exit`,`quit`].includes(e.next||``)?{...e,help:`Return to Sessions. The local server and Codex sessions remain running.`}:{...e})}function d(){return{title:`/ COMMANDS`,help:`Local Codexometer commands remain available without session control.`,path:``,revision:``,choices:u()}}function f(){L(b,``),L(O,``),L(x,0),L(ne,[],!0)}function p(){w++,L(g,!1),L(h,!1),L(E,i()),f(),L(_,``),G(de)?s()():c()(i())}async function m(e){if(!l.includes(e))return!1;if(e===`copy`&&!oo($.data?.sessions.find(e=>e.id===t.session)))return L(_,`No reply or activity text is available to copy for this session.`),!0;if(e===`copy`){let e=o()();p(),await e}else p(),e===`usage`?location.hash=`/usage`:e===`theme`?ca.requests++:e===`statusline`?sa.open=!0:location.hash=`/sessions`;return!0}let h=I(!1),g=I(!1),_=I(``),v=I(null),y=I(null),b=I(``),x=I(0),S=I(Xt(Date.now())),C=I(``),w=0,T=I(0),E=I(null),D=I(void 0),ee=I(void 0),te=I(void 0),O=I(``),ne=I(Xt([])),re=P(()=>!!G(v)?.inputReview),ie=P(()=>!!G(y)&&!G(re)||!!G(O)||G(ne).length>0);function ae(e){return e.unavailable?e.unavailable.startsWith(`Waiting for idle.`)?` // WAITING FOR IDLE`:` // UNAVAILABLE`:e.next?` →`:e.action?``:` // HELP`}async function oe(e){G(v)&&!(G(_e)&&G(fe))&&L(ne,[...G(ne),{path:G(v).path,index:G(T),input:G(C)}],!0),await M(e)}async function se(){if(!G(ie))return;if(w++,L(g,!1),L(b,``),L(x,0),L(_,``),G(O)){L(O,``),G(D)?.focus();return}if(G(y)&&!G(re)){L(y,null),await ur(),G(D)?.focus();return}let e=G(ne).at(-1);e&&(L(ne,G(ne).slice(0,-1),!0),await M(e.path,e))}function ce(){G(v)&&G(C).trim()&&!G(g)&&!G(ge)&&oe(G(v).path+`/`+encodeURIComponent(G(C).trim()))}let k=P(()=>G(h)&&!!G(v)?.picker&&!G(y)),le=P(()=>G(h)&&!G(v)?.input&&!G(y)),ue=setInterval(()=>{L(S,Date.now(),!0)},1e3);qi(()=>{clearInterval(ue),w++});let de=P(()=>i().trim().startsWith(`/`)&&!i().trim().startsWith(`//`)),fe=P(()=>G(v)?.path===``&&G(de)?i().trim().slice(1).toLowerCase():``),pe=P(()=>(G(v)?.choices||[]).filter(e=>!G(fe)||e.label.toLowerCase().startsWith(`/`+G(fe)))),A=P(()=>G(y)||G(pe)[G(T)]),me=P(()=>!!G(b)&&G(S)G(pe).find(e=>e.id===G(O))),ge=P(()=>!$.connected||!!$.data?.sessionsError),_e=P(()=>G(h)&&G(de)&&(!G(v)||G(v).path===``)&&!G(y));yn(()=>{i(),L(T,0)}),yn(()=>{let e=G(T);G(pe),G(le)&&ur().then(()=>{let t=G(D)?.children[e];if(!t||!G(D))return;let n=G(D).getBoundingClientRect(),r=t.getBoundingClientRect();r.topn.bottom&&(G(D).scrollTop+=r.bottom-n.bottom)})});function ve(e){G(T)!==e&&G(v)?.picker&&(L(O,``),L(b,``),L(x,0),L(_,``),w++),L(T,e,!0)}function j(){w++,L(g,!1),L(h,!1),L(E,i()),f(),c()(i())}function ye(e){let t=!!G(ee)?.contains(e.target);if(!G(h)||!G(le)&&!G(y)&&!G(v)?.input||!G(de)&&!t||G(ge)&&!a()||e.isComposing||e.ctrlKey||e.metaKey||e.altKey)return;if(G(v)?.input){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),j());return}let n=e.key===`ArrowLeft`,r=e.key.toLowerCase()===`f`,o=e.key.toLowerCase()===`c`;if((o||r||n)&&!t||![`ArrowUp`,`ArrowDown`,`Tab`,`Enter`,`Escape`].includes(e.key)&&!o&&!r&&!n||e.key===`Tab`&&(G(y)||G(v)?.path!==``||e.shiftKey)||e.key===`Enter`&&e.target instanceof Element&&e.target.closest(`button`)&&!G(D)?.contains(e.target)&&!e.target.closest(`[data-command-confirm]`)||G(y)&&!t||G(y)&&[`ArrowUp`,`ArrowDown`].includes(e.key))return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){j();return}if(G(g)||e.repeat&&(o||e.key===`Enter`))return;if(n){G(ie)&&se();return}if(r){M(G(v)?.path||``,void 0,!0);return}if(o){(G(y)?.action||G(k)&&G(O))&&Se();return}if(G(y)){e.key===`Enter`&&G(y).action&&!G(me)&&!G(_)&&xe(G(y));return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){ve(Math.min(Math.max(G(T)+(e.key===`ArrowUp`?-1:1),0),Math.max(G(pe).length-1,0))),!G(k)&&G(D)?.contains(e.target)&&ur().then(()=>(G(D)?.children[G(T)])?.focus());return}if(e.key===`Enter`&&(G(v)?.path===``||G(v)?.path===`goal`)&&/^\/goal\s+\S/.test(i().trim())){let e=G(v)?.path===`goal`?G(pe).find(e=>i().trim().slice(6).trim().toLowerCase()===e.label.toLowerCase()):void 0;if(e){be(e);return}oe(i().trim().slice(1));return}let s=G(pe)[G(T)];s&&(e.key===`Tab`?c()(s.label):G(k)?xe(s):be(s))}yn(()=>{G(ge)&&!a()&&(w++,L(g,!1),f(),G(h)&&(L(h,!1),L(E,i())),L(v,null),L(y,null))}),yn(()=>{G(de)&&!G(h)&&i()!==G(E)&&(!G(ge)||a())&&(f(),L(h,!0),M(``))});async function M(e,n,r=!1){let i=++w;if(G(v)&&L(v,{...G(v),path:e},!0),n&&L(C,n.input,!0),L(g,!0),L(y,null),L(O,``),L(b,``),L(x,0),L(_,``),a())L(v,d(),!0),L(T,n?.index??0,!0),L(g,!1);else try{let a=await ya(`commands`,{session:t.session,command:{mode:`list`,path:e,...r?{refresh:!0}:{}}});i===w&&(a.choices||=[],(e===``||e===`help`)&&(a.choices=[...a.choices.filter(e=>!l.includes(e.label.replace(/^\//,``))),...u()]),L(v,a,!0),L(T,n?Math.min(n.index,Math.max(a.choices.length-1,0)):a.picker?Math.max(a.choices.findIndex(e=>e.selected),0):0,!0),a.picker&&ur().then(()=>G(D)?.focus()),L(C,n?.input??a.value??``,!0),n&&ur().then(()=>{a.input?G(ee)?.querySelector(`input`)?.focus():G(D)?.focus()}),a.inputReview&&a.choices.length===1&&(L(g,!1),be(a.choices[0])))}catch{i===w&&(L(_,`Command catalogue unavailable. Use Codex.`),e===``||e===`help`?(L(v,d(),!0),L(_,``)):L(v,{title:`/`+e,help:``,path:e,revision:``,choices:[]},!0))}finally{i===w&&L(g,!1)}}async function be(e){e.unavailable||G(g)||e.next&&await m(e.next)||G(_)||(G(v)?.picker?(ve(G(pe).findIndex(t=>t.id===e.id)),e.action&&(e.reversible||$.data?.noConfirm)?await xe(e):G(D)?.focus()):e.next?await oe(e.next):await xe(e))}async function xe(e){if(G(g)||G(ge)||!G(v)||e.unavailable||G(_))return;let n=e.action&&(e.reversible||$.data?.noConfirm);if(G(v).picker){if(G(me)&&G(O)===e.id)return;L(O,e.id,!0)}else n||(L(y,e,!0),ur().then(()=>G(te)?.focus()));if(L(b,``),L(x,0),L(_,``),!e.action)return;let r=++w;L(g,!0);try{let n=await ya(`commands`,{session:t.session,command:{mode:`prepare`,path:G(v).path,revision:G(v).revision,choice:e.id}});if(r===w){let e=Date.parse(n.expires);if(!n.confirmation||!Number.isFinite(e)||Date.now()>=e)throw Error(`Review confirmation unavailable`);L(b,n.confirmation,!0),L(x,e,!0)}}catch{r===w&&L(_,`Option changed or unavailable. Refresh before retrying.`)}finally{r===w&&L(g,!1)}n&&r===w&&G(b)&&await Se()}async function Se(){if(!G(b)||G(ge)||G(g)||Date.now()>=G(x)||!G(v)||G(v).picker&&G(O)!==G(pe)[G(T)]?.id)return;let e=G(b);L(b,``),L(g,!0);let n=++w;try{let r=await ya(`commands`,{session:t.session,confirmation:e,command:{mode:`commit`,path:G(v).path}});n===w&&(L(_,r.message,!0),L(h,!1),L(v,null),L(y,null),f(),L(E,null),s()())}catch{n===w&&L(_,`Change unconfirmed. Check Codex before retrying.`)}finally{n===w&&L(g,!1)}}var Ce={handleKey:ye},we=Ro(),Te=R(we),Ee=V(Te,2),De=e=>{var t=fo(),n=B(t,!0);H(()=>Y(n,G(_))),J(e,t)};X(Ee,e=>{G(_)&&!G(h)&&e(De)});var Oe=V(Ee,2),ke=e=>{var i=Lo();let o;var s=R(i),c=e=>{var t=go(),n=z(t),r=B(n,!0),i=V(n,2),a=e=>{var t=mo();Z(t,21,()=>G(v).help.split(` -`),qr,(e,t)=>{var n=po(),r=B(n,!0);H(()=>{Q(n,`title`,G(t)),Y(r,G(t))}),J(e,n)}),N(t),J(e,t)},o=e=>{var t=ho(),n=B(t,!0);H(()=>Y(n,G(v)?.help||`Loading live options…`)),J(e,t)};X(i,e=>{G(v)?.path===`goal`?e(a):e(o,-1)}),H(()=>Y(r,G(v)?.title||`/ COMMANDS`)),J(e,t)};X(s,e=>{G(_e)||e(c)});var l=V(s,2),u=e=>{var t=_o(),n=B(t,!0);H(()=>Y(n,G(_))),J(e,t)};X(l,e=>{G(_)&&e(u)});var d=V(l,2),f=e=>{J(e,vo())};X(d,e=>{G(g)&&e(f)});var p=V(d,2),m=e=>{var t=yo(),r=R(t),i=R(r),o=V(i);Si(o),N(r),N(t),H(e=>{Q(t,`id`,`${n}-input`),Y(i,`${e??``} `),Q(o,`aria-label`,G(v).inputLabel||`Session name`),Q(o,`maxlength`,G(v).inputLimit||512),o.disabled=G(g)||G(ge)&&!a()},[()=>(G(v).inputLabel||`Session name`).toUpperCase()]),Sr(`submit`,t,e=>{e.preventDefault(),ce()}),Di(o,()=>G(C),e=>L(C,e)),J(e,t)},h=e=>{var n=xo(),r=R(n),i=B(r,!0),a=V(r,2),o=B(a,!0),s=V(a,2),c=e=>{var n=bo(),r=R(n),i=V(r),a=e=>{J(e,Nr(`Only this session's saved - name changes.`))},o=P(()=>G(v)?.path.startsWith(`rename/`)),s=e=>{J(e,Nr(`Only this session’s - directory changes; project configuration is not reloaded.`))},c=P(()=>G(v)?.path.startsWith(`cd/`)),l=e=>{J(e,Nr(`Only this session's goal - changes.`))},u=P(()=>G(v)?.path.startsWith(`goal/`)),d=e=>{J(e,Nr(`No change sent yet. Model, reasoning and speed settings can - change token usage and cost. Changes affect subsequent turns of - this session, not global defaults. Automatic quota thresholds - may later supersede model settings.`))};X(i,e=>{G(o)?e(a):G(c)?e(s,1):G(u)?e(l,2):e(d,-1)}),N(n),H(()=>Y(r,`TARGET // ${t.session??``}. `)),J(e,n)};X(s,e=>{G(y).action&&e(c)}),N(n),Li(n,e=>L(te,e),()=>G(te)),H(()=>{Y(i,G(y).label),Y(o,G(y).help||`No additional help supplied by Codex.`)}),J(e,n)},w=e=>{var t=Oo(),i=z(t),a=e=>{var t=So(),i=R(t);r(i),N(t),Li(t,e=>L(D,e),()=>G(D)),H(()=>Q(t,`aria-activedescendant`,`${n}-${G(T)}`)),J(e,t)},o=e=>{var t=Co();let n;var i=R(t);r(i),N(t),Li(t,e=>L(D,e),()=>G(D)),H(()=>n=li(t,1,`command-options svelte-7bfwr9`,null,n,{vertical:G(_e)})),J(e,t)};X(i,e=>{G(k)?e(a):e(o,-1)});var s=V(i,2),c=e=>{var t=Eo(),n=z(t),r=B(n,!0),i=V(n,2),a=e=>{var t=To(),n=z(t),r=B(n),i=V(n,2),a=e=>{J(e,wo())};X(i,e=>{G(b)&&G(S)>=G(x)&&e(a)}),H(()=>Y(r,`REVIEW // ${G(he).label??``}. No change sent yet.`)),J(e,t)};X(i,e=>{G(he)&&e(a)}),H(()=>Y(r,G(pe)[G(T)]?.help)),J(e,t)};X(s,e=>{G(k)&&e(c)});var l=V(s,2),u=e=>{J(e,Do())};X(l,e=>{!G(g)&&!G(pe).length&&e(u)}),J(e,t)};X(p,e=>{G(v)?.input?e(m):G(y)?e(h,1):e(w,-1)});var E=V(p,2),O=e=>{var t=ko(),n=B(t,!0);H(()=>Y(n,G(A).unavailable)),J(e,t)};X(E,e=>{G(A)?.unavailable&&e(O)});var ne=V(E,2),re=e=>{J(e,Ao())};X(ne,e=>{G(b)&&G(S)>=G(x)&&!G(k)&&e(re)});var ae=V(ne,2),oe=R(ae),le=e=>{var t=Pr(),r=z(t),i=e=>{var t=jo(),r=B(t,!0);H(e=>{Q(t,`form`,`${n}-input`),t.disabled=e,Y(r,G(v).reversibleInput||$.data?.noConfirm?`ENTER APPLY`:`ENTER REVIEW`)},[()=>G(g)||G(ge)||!G(C).trim()]),J(e,t)},o=e=>{var t=Pr(),n=z(t),r=e=>{var t=Mo();H(()=>t.disabled=G(g)||G(ge)&&!a()),K(`click`,t,Se),J(e,t)},i=e=>{var t=No(),n=B(t,!0);H(()=>{t.disabled=G(g)||G(ge)&&!a(),Y(n,G(A).reversible||$.data?.noConfirm?`ENTER APPLY`:`ENTER REVIEW`)}),K(`click`,t,()=>{G(A)&&xe(G(A))}),J(e,t)};X(n,e=>{G(me)&&!G(A).reversible&&!$.data?.noConfirm?e(r):e(i,-1)}),J(e,t)},s=e=>{var t=No(),n=B(t);H(()=>{t.disabled=G(g)||G(ge)&&!a(),Y(n,`ENTER ${G(A).next?`OPEN`:`HELP`}`)}),K(`click`,t,()=>{G(A)&&be(G(A))}),J(e,t)};X(r,e=>{G(v)?.input?e(i):G(A)?.action&&!G(A).unavailable?e(o,1):!G(y)&&G(A)&&!G(A).unavailable&&e(s,2)}),J(e,t)};X(oe,e=>{G(_)||e(le)});var ue=V(oe,2),de=e=>{var t=Po();H(()=>t.disabled=G(g)),K(`click`,t,se),J(e,t)};X(ue,e=>{G(ie)&&e(de)});var fe=V(ue,2),ve=e=>{var t=Fo();H(()=>t.disabled=G(g)),K(`click`,t,()=>M(G(v)?.path||``,void 0,!0)),J(e,t)};X(fe,e=>{G(_e)||e(ve)});var Ce=V(fe,2);N(ae);var we=V(ae,2),Te=e=>{var t=Io(),n=B(t);H(()=>Y(n,`↑/↓ select${G(_e)?` · Tab complete`:``}`)),J(e,t)};X(we,e=>{!G(v)?.input&&!G(y)&&e(Te)}),N(i),Li(i,e=>L(ee,e),()=>G(ee)),H(()=>{Q(i,`aria-label`,G(_e)?`Slash command suggestions`:`Session command options`),o=li(i,1,`svelte-7bfwr9`,null,o,{"command-popup":G(_e)})}),K(`keydown`,i,ye),K(`click`,Ce,j),J(e,i)};return X(Oe,e=>{G(h)&&e(ke)}),N(we),H(()=>Te.disabled=G(ge)&&!a()||G(g)),K(`click`,Te,()=>{L(h,!G(h)),L(E,G(h)?null:i(),!0),L(b,``),G(h)?(L(ne,[],!0),M(``)):j()}),J(e,we),Ge(Ce)}Cr([`click`,`keydown`]);var Bo=q(` `,1),Vo=q(`
      `),Ho=q(`
      /
      `);function Uo(e,t){We(t,!0);let n=P(()=>t.lines.filter(e=>e.kind===`addition`).length),r=P(()=>t.lines.filter(e=>e.kind===`removal`).length);var i=Ho(),a=R(i),o=R(a),s=B(o),c=B(V(o,2));N(a),Z(V(a,2),17,()=>t.lines,qr,(e,t)=>{var n=Vo();let r;var i=R(n),a=e=>{var n=Bo(),r=z(n),i=B(r,!0),a=B(V(r),!0);H(()=>{Y(i,G(t).old||``),Y(a,G(t).new||``)}),J(e,n)};X(i,e=>{G(t).kind!==`heading`&&G(t).kind!==`metadata`&&e(a)});var o=B(V(i),!0);N(n),H(()=>{r=li(n,1,`diff-line svelte-x4gtb6`,null,r,{added:G(t).kind===`addition`,removed:G(t).kind===`removal`,heading:G(t).kind===`heading`}),Y(o,G(t).text)}),J(e,n)}),N(i),H(()=>{Q(a,`aria-label`,`${G(n)} lines added, ${G(r)} lines removed`),Y(s,`+${G(n)??``}`),Y(c,`−${G(r)??``}`)}),J(e,i),Ge()}var Wo=q(`

      `),Go=q(`

      Send this saved prompt now? This starts Codex work and consumes quota.

      `,1),Ko=q(``),qo=q(`

       

      In memory only. Follows session model, reasoning and speed. Closing - Codexometer cancels pending work.

      `),Jo=q(`

      HUMAN APPROVAL REQUIRED

      Managed policy requires approval each time.

      `,1),Yo=q(`

      CURRENT PROFILE

      MODEL / REASONING LEVEL / SPEED

       

      PROPOSED PROFILE

      MODEL / REASONING LEVEL / SPEED

       

      Applied settings remain after Codexometer closes.

      `,1),Xo=q(`

      `),Zo=q(`

       
      `,1),Qo=q(`

      Command unavailable from this observation. Open Codex to inspect the - request.

      `),$o=q(`

      Session controls temporarily unavailable. Check Codex for current state.

      `),es=q(`

      Checking session controls…

      `),ts=q(`

      `),ns=q(`
      About browser controls

      Controls require a supported live request from a connected shared - app-server session. Local observations alone cannot provide them.

      `),rs=q(` `,1),is=q(` `),as=q(`Grants permission beyond this one action. Check the scope - carefully.`),os=q(``),ss=q(``),cs=q(``),ls=q(``),us=q(`

      Not before this time; when quota and idle allow.

      `),ds=q(`

      `,1),fs=q(`

      The existing trigger remains active until saved or deleted. If - it changes or sends while you edit, saving is blocked.

      `),ps=q(` `,1),ms=q(``),hs=q(``),gs=q(``),_s=q(` `,1),vs=q(`
    • `),ys=q(`
      View fixed choices

      Type one of these choices exactly. Your answer stays masked.

        `),bs=q(` `,1),xs=q(`

        `),Ss=q(`

        `,1),Cs=q(` `,1),ws=q(``),Ts=q(`

        `,1),Es=q(`

        `);function Ds(e,t){We(t,!0);let n=[],r=Gi(t,`observedCommand`,3,``),i=Gi(t,`observedFileChanges`,19,()=>[]),a=Gi(t,`review`,3,``),o=Gi(t,`suspended`,3,!1),s=Gi(t,`openScheduler`,3,!1),c=Gi(t,`onProtectedChange`,3,e=>{}),l=Gi(t,`oncopy`,3,()=>{}),u=I(null),d=I(Xt([])),f=I(null),p=I(``),m=I(0),h=I(Xt(Date.now())),g=I(!1),_=I(``),v=I(!1),y=I(!1),b=I(``),x=I(!1),S=I(``),C=I(!1),w=I(``),T=I(`now`),E=I(60),D=I(``),ee=I(!1),te=I(``),O=I(Xt([])),ne=P(()=>G(O).find(e=>e.status!==`sent`)),re=I(void 0),ie=I(void 0);function ae(e){if(G(x)){ur().then(()=>G(re)?.focus());return}if(e.status!==`pending`||G(g)||!G(u)?.id||G(u).kind!==`prompt`||G(u).questions?.length)return;L(x,!0),L(S,e.id,!0),ur().then(()=>G(re)?.focus()),L(d,[e.text],!0),L(T,e.trigger===`quota`?`quota`:`at`,!0),L(p,``),L(w,``);let t=new Date(e.at||0);e.trigger!==`quota`&&L(D,new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,16),!0)}yn(()=>{s()&&G(ne)&&!G(C)&&G(u)?.id&&G(u).kind===`prompt`&&!G(u).questions?.length&&(L(C,!0),ae(G(ne)))});async function oe(){if(!a())try{L(O,await ya(`schedules`,{session:t.session},j.signal),!0),G(x)&&!G(O).some(e=>e.id===G(S)&&e.status===`pending`)&&L(p,``),G(w)&&!G(O).some(e=>e.id===G(w)&&e.status===`pending`)&&(L(p,``),L(w,``))}catch{}}async function se(e){try{L(O,await ya(`schedules`,{session:t.session,cancelId:e},j.signal),!0),L(x,!1),L(p,``),L(w,``),L(d,[],!0)}catch(e){L(_,e instanceof Error?e.message:`Unable to cancel trigger.`,!0)}}yn(()=>(c()(G(g)||G(d).some(e=>e.length>0)),()=>c()(!1)));let ce=P(()=>$.data?.sessions.find(e=>e.id===t.session)?.status),k=P(()=>!$.connected||!!$.data?.sessionsError),le=P(()=>a()!==`profile`&&G(u)?.kind===`prompt`&&!G(u).questions?.length&&!!$.data?.profiles?.some(e=>e.session===t.session&&e.pending)),ue=P(()=>!G(k)&&!G(y)&&!!G(u)?.id&&G(u).kind===`approval`&&G(b)!==G(u).id),de=P(()=>G(ue)?G(u).command:r()),fe=P(()=>!!G(p)&&G(h)G(u)?.questions?.length?G(u).questions:[{text:`Follow-up message`,secret:!1,freeText:!0,options:[]}]),A=P(()=>G(u)?.kind===`approval`||G(u)?.kind===`profile`?G(f)!==null:G(d).length===G(pe).length&&G(d).every((e,t)=>e.trim().length>0&&(G(pe)[t].freeText||G(pe)[t].options?.includes(e)))),me=P(()=>G(u)?.kind===`prompt`&&!G(u).questions?.length&&G(T)!==`now`),he=P(()=>G(T)===`delay`?G(h)+G(E)*6e4:Date.parse(G(D))),ge=P(()=>{if(!G(me))return``;if(G(x)&&!G(O).some(e=>e.id===G(S)&&e.status===`pending`))return`Trigger changed, removed or already sent. Go back and reopen it; your draft has not been saved.`;if(!G(d)[0]?.trim())return`Enter a message to schedule.`;if(G(T)===`quota`)return``;if(!Number.isFinite(G(he))||G(he)<=G(h))return`Choose a future date/time or a delay greater than zero.`;let e=new Date(G(h));return e.setFullYear(e.getFullYear()+1),G(he)>=e.getTime()?`Choose a time within one year.`:``});function _e(e){return e===void 0?`Not yet available`:new Date(e).toLocaleString([],{timeZoneName:`short`})}function ve(e){if(e.status!==`pending`)return e.status;if(e.trigger===`at`&&e.at&&Date.parse(e.at)>G(h))return`Due in `+Math.ceil((Date.parse(e.at)-G(h))/6e4)+` min`;let t=G(k)?`waiting for a fresh connection`:e.waitingReason||(e.canSend?`ready; awaiting dispatch`:`waiting for quota and an eligible idle session`);return(e.trigger===`at`?`Time reached — `:``)+t}yn(()=>{(G(k)||o()||G(le)||G(h)>=G(m))&&L(p,``)});let j=new AbortController;Ki(()=>{let e=e=>{e.ctrlKey&&e.key.toLowerCase()===`s`&&!a()&&G(ne)&&(e.preventDefault(),ae(G(ne)))};window.addEventListener(`keydown`,e);let n,r=setInterval(()=>{L(h,Date.now(),!0)},1e3);async function i(){await oe();try{let e=await ya(`offer`,{session:t.session,...a()?{review:a()}:{}},j.signal);if(j.signal.aborted)return;L(y,!1),G(u)?.id!==e.id&&(L(p,``),L(f,null),L(d,Array(Math.max(1,e.questions?.length||0)).fill(``),!0)),L(u,e,!0),G(v)&&e.id&&e.id!==G(b)&&(L(_,``),L(v,!1))}catch{j.signal.aborted||(L(u,null),L(y,!0),L(p,``))}finally{j.signal.aborted||(n=setTimeout(i,2e3))}}return i(),()=>{window.removeEventListener(`keydown`,e),j.abort(),clearTimeout(n),clearInterval(r)}});async function ye(e){if(!e&&G(u)?.kind===`prompt`&&!G(u).questions?.length&&G(d)[0]?.trim().startsWith(`/`)&&!G(d)[0]?.trim().startsWith(`//`)){L(_,`Choose a slash command from COMMANDS; use // for literal slash text.`);return}if(!G(u)?.id||G(g)||G(k)||o()||G(le)||(e?!e.canSend:!G(A)||G(ge)))return;let n=G(u).id;L(g,!0),L(_,``),L(v,!1),L(p,``),L(w,e?.id||``,!0);try{let r=!e&&G(u).kind===`prompt`&&!G(u).questions?.length&&G(T)!==`now`?{trigger:G(T)===`quota`?`quota`:`at`,zone:Intl.DateTimeFormat().resolvedOptions().timeZone,...G(T)===`quota`?{}:{at:(G(T)===`delay`?new Date(Date.now()+G(E)*6e4):new Date(G(D))).toISOString()}}:void 0;L(ee,!!r),L(te,r?r.trigger===`quota`?`After fresh quota becomes available, when the session is idle`:_e(r.at)+` — not before this time; when quota and idle allow`:``,!0);let i=await ya(`prepare`,{session:t.session,...a()?{review:a()}:{},offer:n,...e?{sendId:e.id}:{},...r?{schedule:r}:{},...r&&G(x)?{editId:G(S)}:{},...G(u).kind===`approval`||G(u).kind===`profile`?{choice:G(f)}:{answers:e?[e.text]:[...G(d)]}},j.signal);G(u)?.id!==n||j.signal.aborted||G(k)||o()||G(le)||(L(p,i.confirmation,!0),L(m,Date.parse(i.expires),!0))}catch(e){j.signal.aborted||L(_,e instanceof Error?e.message:`Unable to prepare action.`,!0)}finally{L(g,!1)}$.data?.noConfirm&&G(p)&&!j.signal.aborted&&await M()}async function M(){if(!G(u)?.id||G(g)||o()||G(le)||!G(fe))return;let e=G(u).id,n=G(u).kind,r=G(p);L(p,``),L(g,!0),L(b,e,!0);try{await ya(`commit`,{session:t.session,...a()?{review:a()}:{},offer:e,confirmation:r},j.signal),L(v,!0),L(x,!1),G(ee)&&(L(b,``),await oe()),L(_,G(ee)?`Trigger set. Closing Codexometer cancels it.`:n===`profile`?`Profile decision completed.`:n===`approval`?`Decision sent.`:`Text sent.`,!0)}catch(e){L(_,e instanceof _a?e.message:`Outcome uncertain. Check Codex before taking another action; nothing was retried.`,!0)}finally{L(g,!1),L(w,``),await oe(),L(d,[],!0),L(f,null)}}var be=rs(),xe=z(be),Ce=e=>{var t=Pr();Z(z(t),17,()=>G(O).filter(e=>e.status!==`sent`),e=>e.id,(e,t)=>{var n=qo(),r=R(n),i=B(r,!0),a=V(r,2),s=B(a),c=V(a,2),l=B(c,!0),d=V(c,2),f=B(d,!0),m=V(d,2),h=B(m,!0),v=V(m,2),y=e=>{var t=Wo(),n=B(t,!0);H(()=>Y(n,G(_))),J(e,t)};X(v,e=>{G(_)&&e(y)});var b=V(v,4),x=V(b,2),S=V(x,2),C=e=>{var n=Go(),r=V(z(n),2),i=V(r,2);H(()=>r.disabled=G(g)||G(k)||!G(t).canSend),K(`click`,r,M),K(`click`,i,()=>{L(p,``),L(w,``)}),J(e,n)},T=e=>{var n=Ko();H(()=>n.disabled=G(g)||G(k)||!G(t).canSend||o()),K(`click`,n,()=>ye(G(t))),J(e,n)};X(S,e=>{G(fe)&&G(w)===G(t).id?e(C):e(T,-1)}),N(n),H((e,n)=>{Y(i,G(t).status===`uncertain`?`CHECK TRIGGER — outcome uncertain; not retried`:`SCHEDULED FOLLOW-UP`),Y(s,`TARGET // ${G(t).session??``}`),Y(l,e),Y(f,n),Y(h,G(t).text),b.disabled=G(g)||!G(u)?.id||G(u).kind!==`prompt`||!!G(u).questions?.length||G(t).status!==`pending`,x.disabled=G(g)||G(t).status===`sending`},[()=>G(t).trigger===`quota`?`After confirmed quota recovery, when idle`:`Not before ${_e(G(t).at)}`,()=>ve(G(t))]),K(`click`,b,()=>ae(G(t))),K(`click`,x,()=>se(G(t).id)),J(e,n)}),J(e,t)},we=P(()=>!a()&&G(u)?.kind!==`approval`&&!G(u)?.questions?.length&&![`APPROVAL NEEDED`,`INPUT NEEDED`].includes(G(ce)||``));X(xe,e=>{G(we)&&e(Ce)});var Te=V(xe,2),Ee=e=>{var r=Es(),o=R(r),s=B(o,!0),c=V(o,2),S=e=>{var t=Jo();Se(2),J(e,t)};X(c,e=>{G(u)?.requiredHumanApproval&&!G(k)&&!G(y)&&e(S)});var C=V(c,2),w=e=>{var t=Yo(),n=z(t),r=B(n),i=V(n,6),a=B(i,!0),o=B(V(i,6),!0);Se(2),H(()=>{Y(r,`Your ${G(u).profile.threshold??``}% quota threshold has been reached. Review - the profile for subsequent turns.`),Y(a,G(u).profile.current),Y(o,G(u).profile.proposed)}),J(e,t)};X(C,e=>{G(u)?.profile&&!G(k)&&!G(y)&&e(w)});var O=V(C,2),ne=e=>{var t=Xo();let n;var r=B(t,!0);H(()=>{n=li(t,1,`svelte-1oupzfc`,null,n,{notice:!G(v),sent:G(v)}),Y(r,G(_))}),J(e,t)};X(O,e=>{G(_)&&e(ne)});var ae=V(O,2),oe=e=>{Uo(e,{get lines(){return G(u).fileChanges}})},se=e=>{Uo(e,{get lines(){return i()}})},le=e=>{var t=Zo(),n=z(t),r=B(n,!0),i=B(V(n,2),!0);H(()=>{Y(r,G(ue)?`EXACT COMMAND`:`LAST OBSERVED COMMAND`),Y(i,G(de))}),J(e,t)},me=e=>{J(e,Qo())};X(ae,e=>{G(u)?.fileChanges?.length&&!G(k)&&!G(y)?e(oe):i().length?e(se,1):G(de)?e(le,2):a()!==`profile`&&G(ce)===`APPROVAL NEEDED`&&!G(v)&&e(me,3)});var ve=V(ae,2),j=e=>{J(e,$o())},be=e=>{J(e,es())},xe=e=>{var t=rs(),n=z(t),r=e=>{var t=ts(),n=B(t,!0);H(e=>Y(n,e),[()=>G(ce)===`WORKING`?`Codex is working — nothing to respond to.`:[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(G(ce)||``)?`Respond in Codex for this request.`:`Nothing needs a response right now.`]),J(e,t)};X(n,e=>{(G(ce)===`WORKING`||!G(v)&&!G(g))&&e(r)});var i=V(n,2),a=e=>{J(e,ns())},o=P(()=>[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(G(ce)||``)&&!G(v));X(i,e=>{G(o)&&e(a)}),J(e,t)},Ce=e=>{var r=Ts(),i=z(r),o=B(i),s=V(i,2),c=R(s),_=B(c,!0),v=V(c,2),y=e=>{var r=Pr();Z(z(r),17,()=>G(u).choices||[],qr,(e,r,i)=>{var o=os(),s=R(o);Si(s),s.value=s.__value=i;var c=V(s),l=V(c),u=e=>{var t=is(),n=B(t,!0);H(()=>Y(n,G(r).detail)),J(e,t)};X(l,e=>{G(r).detail&&e(u)});var d=V(l,2),p=e=>{J(e,as())};X(d,e=>{G(r).persistent&&e(p)}),N(o),H(()=>{Q(s,`name`,`decision-`+t.session+`-`+a()),Y(c,` ${G(r).label??``} `)}),ki(n,[],s,()=>G(f),e=>L(f,e)),J(e,o)}),J(e,r)},b=e=>{var n=rs(),r=z(n),i=e=>{var t=ps(),n=z(t),r=V(R(n)),i=R(r),a=e=>{var t=ss();t.value=t.__value=`now`,J(e,t)};X(i,e=>{G(x)||e(a)});var o=V(i);o.value=o.__value=`quota`;var s=V(o);s.value=s.__value=`delay`;var c=V(s);c.value=c.__value=`at`,N(r),hi(r),N(n);var l=V(n,2),u=e=>{var t=cs(),n=V(R(t));Si(n),N(t),Di(n,()=>G(E),e=>L(E,e)),J(e,t)};X(l,e=>{G(T)===`delay`&&e(u)});var d=V(l,2),f=e=>{var t=ls(),n=V(R(t));Si(n),N(t),Di(n,()=>G(D),e=>L(D,e)),J(e,t)};X(d,e=>{G(T)===`at`&&e(f)});var p=V(d,2),m=e=>{var t=ds(),n=z(t),r=B(n),i=V(n,2),a=e=>{J(e,us())};X(i,e=>{G(T)!==`quota`&&e(a)});var o=V(i,2);o.textContent=`Timezone: ${Intl.DateTimeFormat().resolvedOptions().timeZone??``}. - One pending request per session; saving replaces it. Memory - only; Codexometer must stay running. Uses session model, - reasoning and speed.`,H(e=>Y(r,`Will send: ${e??``}`),[()=>G(T)===`quota`?`when quota is available and this session is idle`:Number.isFinite(G(he))?_e(G(he)):`choose a date and time`]),J(e,t)};X(p,e=>{G(T)!==`now`&&e(m)});var h=V(p,2),g=e=>{J(e,fs())};X(h,e=>{G(x)&&e(g)}),gi(r,()=>G(T),e=>L(T,e)),J(e,t)};X(r,e=>{G(u).questions?.length||e(i)}),Z(V(r,2),17,()=>G(pe),qr,(e,n,r)=>{var i=bs(),o=z(i),s=e=>{{let n=P(()=>G(d)[0]||``);Li(zo(e,{get session(){return t.session},get oncopy(){return l()},get query(){return G(n)},oncomplete:e=>{L(d,[e],!0),ur().then(()=>G(re)?.focus())},onchange:()=>{L(d,[``],!0),ur().then(()=>G(re)?.focus())}}),e=>L(ie,e,!0),()=>G(ie))}};X(o,e=>{r===0&&a()!==`profile`&&G(u).kind===`prompt`&&!G(u).questions?.length&&e(s)});var c=V(o,2),f=R(c),p=V(f),m=e=>{var t=ms();Si(t),Di(t,()=>G(d)[r],e=>G(d)[r]=e),J(e,t)},h=e=>{var t=gs(),i=R(t);i.value=i.__value=``,Z(V(i),17,()=>G(n).options||[],qr,(e,t)=>{var n=hs(),r=B(n,!0),i={};H(()=>{Y(r,G(t)),i!==(i=G(t))&&(n.value=(n.__value=i)??``)}),J(e,n)}),N(t),hi(t),gi(t,()=>G(d)[r],e=>G(d)[r]=e),J(e,t)},g=e=>{var t=_s(),i=z(t);nt(i),Li(i,e=>L(re,e),()=>G(re));var a=V(i,2),o=e=>{var t=ts(),r=B(t);H(e=>Y(r,`Suggested answers: ${e??``}`),[()=>G(n).options.join(` · `)]),J(e,t)};X(a,e=>{G(n).options?.length&&e(o)}),K(`keydown`,i,e=>{G(u)?.kind===`prompt`&&!G(u).questions?.length&&G(ie)?.handleKey(e)}),Di(i,()=>G(d)[r],e=>G(d)[r]=e),J(e,t)};X(p,e=>{G(n).secret?e(m):G(n).freeText?e(g,-1):e(h,1)}),N(c);var _=V(c,2),v=e=>{var t=ys(),r=V(R(t),4);Z(r,21,()=>G(n).options||[],qr,(e,t)=>{var n=vs(),r=B(n,!0);H(()=>Y(r,G(t))),J(e,n)}),N(r),N(t),J(e,t)};X(_,e=>{G(n).secret&&!G(n).freeText&&e(v)}),H(()=>Y(f,`${G(n).text??``} `)),J(e,i)}),J(e,n)};X(v,e=>{G(u).kind===`approval`||G(u).kind===`profile`?e(y):e(b,-1)}),N(s);var S=V(s,2),C=e=>{var t=Ss(),n=z(t),r=e=>{var t=xs(),n=B(t);H(()=>Y(n,`TRIGGER // ${G(te)??``}`)),J(e,t)};X(n,e=>{G(ee)&&e(r)});var i=V(n,2),a=B(i),o=V(i,2),s=B(o),c=V(o,2);H(e=>{Y(a,`Check the target and ${G(u).kind===`profile`?`profile above`:G(u).kind===`approval`?G(u).fileChanges?.length?`proposed file changes above`:`exact command and permission scope`:`message above`}. ${G(ee)?`This schedules a follow-up that will send automatically when eligible`:`This will send to Codex`}; it may start work using your quota. - Confirmation expires in ${e??``}s.`),o.disabled=G(g)||G(k),Y(s,`CONFIRM ${(G(u).kind===`approval`||G(u).kind===`profile`?G(u).choices?.[G(f)]?.label:G(ee)?G(x)?`SAVE CHANGES`:`SCHEDULE`:`SEND`)??``}`)},[()=>Math.max(0,Math.ceil((G(m)-G(h))/1e3))]),K(`click`,o,M),K(`click`,c,()=>{L(p,``)}),J(e,t)},w=e=>{var t=Cs(),n=z(t),r=e=>{var t=Wo(),n=B(t,!0);H(()=>Y(n,G(ge))),J(e,t)};X(n,e=>{G(ge)&&e(r)});var i=V(n,2),a=B(i,!0);H(()=>{i.disabled=G(g)||G(k)||!G(A)||!!G(ge),Y(a,G(g)?`SENDING…`:$.data?.noConfirm?G(x)?`SAVE CHANGES`:G(u).kind===`approval`||G(u).kind===`profile`?`SEND DECISION`:G(u).kind===`prompt`&&!G(u).questions?.length&&G(T)!==`now`?`SET TRIGGER`:`SEND`:G(x)?`REVIEW CHANGES`:`REVIEW BEFORE SENDING`)}),K(`click`,i,()=>ye()),J(e,t)};X(S,e=>{G(fe)&&!$.data?.noConfirm?e(C):e(w,-1)});var O=V(S,2),ne=e=>{var t=ws();K(`click`,t,()=>{L(x,!1),L(p,``),L(d,[],!0)}),J(e,t)};X(O,e=>{G(x)&&e(ne)}),H(()=>{Y(o,`TARGET // ${G(u).thread??``} // ${(G(u).directory||`Directory unavailable`)??``}`),s.disabled=G(g)||G(fe)||G(k),Y(_,G(u).kind===`approval`||G(u).kind===`profile`?`Choose a decision`:G(x)?`EDIT SCHEDULED FOLLOW-UP`:`Reply to this session`)}),J(e,r)};X(ve,e=>{G(k)||G(y)?e(j):G(u)?G(u).id?G(b)!==G(u).id&&e(Ce,3):e(xe,2):e(be,1)}),N(r),H(()=>Y(s,a()===`profile`?`QUOTA THRESHOLD`:`SESSION CONTROL // EXPERIMENTAL`)),J(e,r)};X(Te,e=>{!G(le)&&(!G(ne)||G(x)||a()||G(u)?.kind!==`prompt`||G(u).questions?.length)&&e(Ee)}),J(e,be),Ge()}Cr([`click`,`keydown`]);var Os=q(` `);function ks(e,t){We(t,!0);let n=Gi(t,`stale`,3,!1),r=P(()=>n()||!!t.goal?.stale);var i=Pr(),a=z(i),o=e=>{var n=Os();let i;var a=B(n,!0);H((e,o)=>{i=li(n,1,`goal-status svelte-1yfu3xi`,null,i,{stale:G(r),pursuing:!G(r)&&t.goal.status===`active`,blocked:e}),Q(n,`title`,o),Y(a,G(r)?`GOAL STALE`:t.goal.label)},[()=>!G(r)&&[`blocked`,`usageLimited`,`budgetLimited`].includes(t.goal.status),()=>t.goal.objective+` -`+t.goal.tokensUsed.toLocaleString()+(t.goal.tokenBudget===null?` tokens`:` / `+t.goal.tokenBudget.toLocaleString()+` tokens`)]),J(e,n)};X(a,e=>{t.goal&&e(o)}),J(e,i),Ge()}var As=q(` `,1),js=q(`
        `),Ms=q(`

        STATUS LINE // CODEXOMETER

        Choose multiple fields and their order. These display preferences do not - change Codex CLI configuration. Missing values are omitted.

        `),Ns=q(`

        `,1);function Ps(e,t){We(t,!0);let n=Gi(t,`stale`,3,!1),r=I(Xt([])),i=I(!1),a=P(()=>$.data?.statusLineFields||[]),o=e=>[...new Set(e??G(a).filter(e=>e.default).map(e=>e.id))].filter(e=>G(a).some(t=>t.id===e)),s=e=>o(e).map(e=>e===`run-state`&&(n()||!$.connected||$.data?.sessionsError)?`STALE`:t.session.statusLine?.[e]).filter(Boolean).join(` · `),c=P(()=>[...G(r).map(e=>G(a).find(t=>t.id===e)).filter(Boolean),...G(a).filter(e=>!G(r).includes(e.id))]);yn(()=>{sa.open&&!G(i)?(L(r,o(oa.statusLine),!0),L(i,!0)):sa.open||L(i,!1)});function l(e,t){L(r,t?[...G(r),e]:G(r).filter(t=>t!==e),!0)}function u(e,t){let n=G(r).indexOf(e),i=n+t;if(n<0||i<0||i>=G(r).length)return;let a=[...G(r)];[a[n],a[i]]=[a[i],a[n]],L(r,a,!0)}var d=Ns(),p=z(d),m=e=>{var t=Ms(),n=V(R(t),4);Z(n,21,()=>G(c),e=>e.id,(e,t)=>{var n=js(),i=R(n),a=R(i);Si(a);var o=V(a,1,!0),s=B(V(o),!0);N(i);var c=V(i,2),d=e=>{var n=As(),i=z(n),a=V(i,2);H((e,n)=>{Q(i,`aria-label`,`Move `+G(t).label+` earlier`),i.disabled=e,Q(a,`aria-label`,`Move `+G(t).label+` later`),a.disabled=n},[()=>G(r).indexOf(G(t).id)===0,()=>G(r).indexOf(G(t).id)===G(r).length-1]),K(`click`,i,()=>u(G(t).id,-1)),K(`click`,a,()=>u(G(t).id,1)),J(e,n)},f=P(()=>G(r).includes(G(t).id));X(c,e=>{G(f)&&e(d)}),N(n),H(e=>{Q(i,`title`,G(t).help),Ci(a,e),Y(o,G(t).label),Y(s,G(t).help)},[()=>G(r).includes(G(t).id)]),K(`change`,a,e=>l(G(t).id,e.currentTarget.checked)),J(e,n)}),N(n);var i=V(n,2),a=B(i),o=V(i,2),d=V(o,2);N(t),H(e=>Y(a,`Preview // ${e??``}`),[()=>s(G(r))||`—`]),K(`click`,o,()=>{oa.statusLine=[...G(r)],la(),sa.open=!1}),K(`click`,d,()=>{sa.open=!1}),J(e,t)};X(p,e=>{sa.open&&e(m)});var h=V(p,2),g=R(h),_=B(g,!0),v=V(g,2);{let e=P(()=>n()||!$.connected||!!$.data?.sessionsError);ks(v,{get goal(){return t.session.goal},get stale(){return G(e)}})}var y=V(v,2);ni(V(y,2),()=>t.children??f),N(h),H((e,t)=>{Q(g,`title`,e),Y(_,t)},[()=>s(oa.statusLine),()=>s(oa.statusLine)]),K(`click`,y,()=>{sa.open=!sa.open}),J(e,d),Ge()}Cr([`change`,`click`]);var Fs=q(`
        `);function Is(e,t){We(t,!0);let n=Gi(t,`active`,3,!1),r=Gi(t,`compact`,3,!1),i=P(()=>oo(t.session)),a=P(()=>!!G(i)),o=I(!1),s=I(``),c=I(!1);yn(()=>{if(!G(c))return;let e=setTimeout(()=>{L(c,!1)},150);return()=>clearTimeout(e)}),yn(()=>{G(i),t.session.status,L(s,``)});async function l(){if(!G(a)||G(o))return;let e=G(i);L(o,!0),L(c,!0),L(s,``);try{await navigator.clipboard.writeText(e),G(i)===e&&L(s,`Copied.`)}catch{G(i)===e&&L(s,`Clipboard unavailable. Select the visible text and copy it manually.`)}finally{L(o,!1)}}function u(e){!n()||!G(a)||e.defaultPrevented||e.repeat||e.ctrlKey||e.metaKey||e.altKey||e.key.toLowerCase()!==`c`||e.target instanceof Element&&e.target.closest(`input, textarea, select, [contenteditable]`)||(e.preventDefault(),l())}var d={copy:l},f=Pr();Sr(`keydown`,$t,u);var p=z(f),m=e=>{var t=Fs();let n;var i=R(t),a=B(i,!0),u=V(i,2);let d;N(t),H(()=>{n=li(t,1,`session-copy svelte-543j00`,null,n,{compact:r()}),Y(a,G(s)),u.disabled=G(o),d=li(u,1,`svelte-543j00`,null,d,{flashed:G(c)})}),K(`click`,u,l),J(e,t)};return X(p,e=>{G(a)&&e(m)}),J(e,f),Ge(d)}Cr([`click`]);var Ls=q(`

         
        `,1),Rs=q(`

        LATEST GUIDANCE

         
        `,1),zs=q(`

        CONTEXT

         

        `,1),Bs=q(`

        `),Vs=q(`

        `),Hs=q(`
         
        `),Us=q(`

         
        `,1),Ws=q(`
         
        `),Gs=q(`

        Command unavailable from this observation. Open Codex to inspect the - request.

        `),Ks=q(`

        `,1),qs=q(`

        `),Js=q(` `,1),Ys=q(`

        `),Xs=q(`
        `),Zs=q(`

        Session connection or refresh unavailable. Context and telemetry may be - stale.

        `),Qs=q(`

        Some quota profile checks are unavailable. Only sessions with freshly - verified quota and settings can be updated; previous outcome notices remain - visible.

        `),$s=q(` `),ec=q(` `),tc=q(` `),nc=q(``),rc=q(`

        Read only — reply or approve in Codex.

        `),ic=q(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),ac=q(`
        `),oc=q(` `,1),sc=q(`
        `),cc=q(`

        This session is no longer in the current observation. Return to sessions.

        `),lc=q(`

        `),uc=q(``),dc=q(`

        `),fc=q(` `),pc=q(`

        `),mc=q(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),hc=q(`

        `),gc=q(`

        TOKEN ACTIVITY // 30 SECOND SAMPLES

        `),_c=q(`

        TOKENS

        FULL DETAIL →
        `),vc=q(`

        No locally observed sessions yet. Keep Codex running alongside - Codexometer.

        `),yc=q(`

        ↑ ↓ SELECT SESSION // ← LESS DETAIL // → MORE DETAIL // ESC BACK

        `,1),bc=q(`

        SESSION TOTALS

        `,1);function xc(e,t){We(t,!0);let n=(e,t=f,n,r)=>{let i=mt(()=>g(n?.(),!0)),a=mt(()=>g(r?.(),!1));var o=Js(),s=z(o),c=e=>{var n=Ls(),r=z(n),i=B(r,!0),a=B(V(r,2),!0);H(()=>{Y(i,t().contextKind===`LAST REPLY`&&!t().streaming?`TASK`:`CURRENT TASK`),Y(a,t().currentTask)}),J(e,n)};X(s,e=>{t().currentTask&&e(c)});var l=V(s,2),u=e=>{var n=Rs(),r=B(V(z(n),2),!0);H(()=>Y(r,t().latestGuidance)),J(e,n)};X(l,e=>{t().latestGuidance&&e(u)});var d=V(l,2),p=e=>{var n=zs(),r=B(V(z(n),2),!0);Se(2),H(()=>Y(r,t().approvalContext)),J(e,n)};X(d,e=>{G(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(p)});var m=V(d,2),h=e=>{var n=Bs();let r;var i=B(n,!0);H(e=>{r=li(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),Y(i,e)},[()=>ie(t())]),J(e,n)},_=P(()=>ie(t())&&(!G(a)||G(v)||t().status===`CHECK SESSION`||y(t())));X(m,e=>{G(_)&&e(h)});var b=V(m,2),x=e=>{var n=Vs(),r=B(n,!0);H(e=>Y(r,e),[()=>ae(t())]),J(e,n)};X(b,e=>{G(i)&&e(x)});var S=V(b,2),C=e=>{var n=Hs(),r=B(n,!0);H(()=>Y(r,t().text||`No session context available.`)),J(e,n)};X(S,e=>{(t().text||!t().workingCommand)&&e(C)});var w=V(S,2),T=e=>{var n=Us(),r=V(z(n),2),i=R(r),a=V(i),o=e=>{var n=Nr();H(()=>Y(n,`// ${t().commandTiming??``}`)),J(e,n)};X(a,e=>{t().commandTiming&&e(o)});var s=V(a,2),c=e=>{var n=Nr();H(()=>Y(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),J(e,n)};X(s,e=>{!G(v)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(c)});var l=V(s,2),u=e=>{J(e,Nr(`+`))};X(l,e=>{t().runningLimited&&e(u)}),N(r);var d=B(V(r,2),!0);H(e=>{Y(i,`COMMAND // ${e??``} `),Y(d,t().workingCommand)},[()=>G(v)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),J(e,n)};X(w,e=>{t().workingCommand&&e(T)});var E=V(w,2),D=e=>{Uo(e,{get lines(){return t().fileChanges}})},ee=e=>{var n=Ks(),r=V(z(n),2),i=B(r,!0),a=V(r,2),o=e=>{var n=Ws(),r=B(n,!0);H(()=>Y(r,t().command)),J(e,n)},s=e=>{J(e,Gs())};X(a,e=>{t().command?e(o):e(s,-1)}),H(()=>Y(i,G(v)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),J(e,n)};X(E,e=>{(!G(a)||!$.data?.control)&&t().fileChanges?.length?e(D):G(a)&&$.data?.control||!t().command&&t().status!==`APPROVAL NEEDED`||e(ee,1)});var te=V(E,2),O=e=>{var n=qs(),r=B(n);H(()=>Y(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),J(e,n)};X(te,e=>{G(a)||e(O)}),J(e,o)},r=I(void 0),i=Gi(t,`params`,19,()=>({})),a=P(()=>$.data?.sessions||[]),o=P(()=>$.data?.control&&$.data.profiles||[]),s=P(()=>($.data?.triggers||[]).filter(e=>G(a).some(t=>t.id===e.session)));function c(e,t){i().id&&i().id!==t&&G(u)?e.preventDefault():O(t)}function l(e){return[`TURN COMPLETE`,`IDLE`,`ACTIVE`].includes(e.status)&&G(s).some(t=>t.session===e.id)?`TRIGGER SET`:e.status}let u=I(!1);function d(e,t){i().id&&i().id!==t&&G(u)?e.preventDefault():O(t)}yn(()=>{let e=i().id;e&&pr(()=>{oa.selected=e,pa(e,2)})});let p=P(()=>G(a).find(e=>e.id===i().id)),m=P(()=>new URLSearchParams(Xi.querystring).get(`review`)===`profile`&&G(o).some(e=>e.session===i().id&&e.pending)),h=P(()=>G(a).some(e=>e.id===oa.selected)?oa.selected:G(a)[0]?.id),v=P(()=>!$.connected||!!$.data?.sessionsError);function y(e){return e.status!==`STALE`&&e.failed===!0}let b=P(()=>[[`OBSERVED TOKENS`,ma(G(a).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,ma(G(a).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`ERRORS`,`ERRORS`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,G(v)?`—`:ma(G(a).filter(e=>t===`ERRORS`?y(e):e.status===t).length)])]),x=P(()=>G(a).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`].includes(e.status)||y(e)).sort((e,t)=>S(e)-S(t)));function S(e){return e.status===`APPROVAL NEEDED`?0:e.status===`INPUT NEEDED`?1:2}let C=P(()=>G(a).filter(e=>e.status===`TURN COMPLETE`&&(!e.readStateKnown||e.unread)&&!G(s).some(t=>t.session===e.id)&&!G(o).some(t=>t.session===e.id&&t.pending))),w=I(``),T=new Set;async function E(e){if(!$.data?.control||G(v)||!e.unread||!e.readRevision||!e.replyTurn||e.streaming||G(m))return;let t=e.id,n=e.readRevision,r=e.replyTurn,i=JSON.stringify([t,n,r]);if(!T.has(i)){T.add(i);try{await ur();let e=G(a).find(e=>e.id===t),i=document.getElementById(`content`),o=i?.getBoundingClientRect(),s=o?o.left+i.clientLeft:0,c=o?o.top+i.clientTop:0,l=s+(i?.clientWidth||0),u=c+(i?.clientHeight||0);if(!Array.from(document.querySelectorAll(`[data-result-session]`)).some(e=>{let n=e.getBoundingClientRect();return i?.contains(e)&&e.dataset.resultSession===t&&e.dataset.resultTurn===r&&!e.closest(`[inert], [hidden]`)&&document.visibilityState===`visible`&&n.leftMath.max(0,s)&&n.topMath.max(0,c)&&n.width>0&&n.height>0})||e?.readRevision!==n||e?.replyTurn!==r||G(v))return;await ya(`read`,{session:t,read:{turn:r,revision:n}}),L(w,``)}catch{L(w,`Result changed or could not be marked read. Open it again to retry.`)}finally{T.delete(i)}}}function D(e){O(e);let t=G(a).find(t=>t.id===e);t&&E(t)}let ee=I(Xt(pr(()=>i().id||``))),te=I(``);yn(()=>{let e=i().id||``;e!==G(ee)&&(L(ee,e,!0),L(te,e,!0))}),yn(()=>{if(G(te)&&G(p)?.id===G(te)){let e=G(p);L(te,``),pr(()=>{E(e)})}});function O(e){oa.selected=e,ur().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function ne(e,t){if(O(e),i().id){t<0&&(pa(e,2),location.hash=`/sessions`);return}let n=da(e)+t;if(n>2)location.hash=`/sessions/`+encodeURIComponent(e);else if(pa(e,n),t>0){let t=G(a).find(t=>t.id===e);t&&E(t)}}function re(e){let t=e.target;if(!(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||t.closest(`input, textarea, select, [contenteditable="true"]`))){if(e.key===`Escape`&&i().id)e.preventDefault(),ne(i().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(i().id||G(h)))e.preventDefault(),ne(i().id||G(h),e.key===`ArrowLeft`?-1:1);else if(!i().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&G(a).length){e.preventDefault();let t=G(a).findIndex(e=>e.id===G(h));O(G(a)[Math.max(0,Math.min(G(a).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function ie(e){return G(v)?`Last observation only — refresh unavailable. Check Codex for current state.`:e.status===`CHECK SESSION`?`INFERRED INACTIVITY — a quiet session, not a confirmed input or approval request. Local tools may still be running.`:y(e)?e.status===`MODEL BUSY`?`CONFIRMED TURN FAILURE — the selected model was at capacity. Choose another model with /model or retry when ready. This is not a quota-exhaustion signal.`:e.status===`MODEL UNAVAILABLE`?`CONFIRMED TURN FAILURE — the provider could not find the selected model. Choose an available model with /model. No automatic retry or model change.`:e.status===`CAPACITY RESTRICTED`?`CONFIRMED TURN FAILURE — capacity is unavailable on a policy-restricted route. Inspect the error before changing settings or retrying. This is not a quota-exhaustion signal; no automatic retry or policy change.`:`CONFIRMED TURN FAILURE — inspect the error below before sending another prompt. No automatic retry or model change.`:$.data?.control&&[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(e.status)?`Open full detail for supported live controls; otherwise reply in Codex.`:e.status===`APPROVAL NEEDED`?`OBSERVED APPROVAL SIGNAL — approve or decline in Codex.`:e.status===`INPUT NEEDED`?`OBSERVED INPUT SIGNAL — reply in Codex.`:e.status===`TURN COMPLETE`?`OBSERVED TURN COMPLETION — informational, not an approval request.`:``}function ae(e){return e.streaming&&e.contextKind===`LAST REPLY`?`REPLY // STREAMING`:e.contextKind||`LAST ACTIVITY`}var oe=bc();Sr(`keydown`,$t,re);var se=z(oe),ce=e=>{var t=Ys(),n=B(t,!0);H(()=>Y(n,G(w))),J(e,t)};X(se,e=>{G(w)&&e(ce)});var k=V(se,2),le=B(V(R(k),2));N(k);var ue=V(k,2);let de;Z(ue,21,()=>G(b),qr,(e,t)=>{var n=P(()=>_(G(t),2));let r=()=>G(n)[0],i=()=>G(n)[1];var a=Xs();let o;var s=R(a),c=B(s,!0),l=B(V(s,2),!0);N(a),H(()=>{o=li(a,1,`svelte-mm4wfe`,null,o,{failed:r()===`ERRORS`&&i()!==`0`&&i()!==`—`}),Y(c,r()),Y(l,i())}),J(e,a)}),N(ue);var fe=V(ue,2),pe=B(fe),A=V(fe,2),me=e=>{J(e,Zs())};X(A,e=>{G(v)&&e(me)});var he=V(A,2),ge=e=>{J(e,Qs())};X(he,e=>{$.data?.profileError&&e(ge)});var _e=V(he,2),ve=e=>{var t=nc(),n=R(t);Z(n,17,()=>G(x),qr,(e,t)=>{var n=$s();let r;var i=B(n);H((e,a,o)=>{r=li(n,1,`button`,null,r,{approval:e}),Q(n,`href`,a),Y(i,`${G(t).status??``} - ${o??``} // ${(G(t).name||G(t).directory||G(t).id)??``}`)},[()=>G(t).status===`APPROVAL NEEDED`||G(t).status===`INPUT NEEDED`||y(G(t)),()=>`#/sessions/`+encodeURIComponent(G(t).id),()=>Array.from(G(t).id).slice(-5).join(``).toUpperCase()]),K(`click`,n,()=>O(G(t).id)),J(e,n)});var r=V(n,2);Z(r,17,()=>G(o).filter(e=>e.pending&&G(a).some(t=>t.id===e.session)),qr,(e,t)=>{var n=ec(),r=B(n);H((e,a,o)=>{Q(n,`title`,i().id&&i().id!==G(t).session&&G(u)?`Finish sending or clear your current draft before switching sessions.`:`Review this session’s quota threshold`),Q(n,`href`,e),Y(r,`QUOTA THRESHOLD ${a??``} // ${o??``}`)},[()=>`#/sessions/`+encodeURIComponent(G(t).session)+`?review=profile`,()=>Array.from(G(t).session).slice(-5).join(``).toUpperCase(),()=>G(a).find(e=>e.id===G(t).session)?.name||G(a).find(e=>e.id===G(t).session)?.directory||G(t).session]),K(`click`,n,e=>d(e,G(t).session)),J(e,n)});var l=V(r,2);Z(l,17,()=>G(C),qr,(e,t)=>{var n=tc(),r=B(n);H((e,i)=>{Q(n,`href`,e),Y(r,`TURN COMPLETE ${i??``} // - ${(G(t).name||G(t).directory||G(t).id)??``}`)},[()=>`#/sessions/`+encodeURIComponent(G(t).id),()=>Array.from(G(t).id).slice(-5).join(``).toUpperCase()]),K(`click`,n,()=>O(G(t).id)),J(e,n)}),Z(V(l,2),17,()=>G(s),qr,(e,t)=>{var n=tc(),r=B(n);H((e,t,i)=>{Q(n,`href`,e),Y(r,`TRIGGER SET ${t??``} // ${i??``}`)},[()=>`#/sessions/`+encodeURIComponent(G(t).session),()=>Array.from(G(t).session).slice(-5).join(``).toUpperCase(),()=>G(a).find(e=>e.id===G(t).session)?.name||G(a).find(e=>e.id===G(t).session)?.directory]),K(`click`,n,e=>c(e,G(t).session)),J(e,n)}),N(t),J(e,t)},j=P(()=>(G(x).length||G(C).length||G(o).some(e=>e.pending)||G(s).length)&&!G(v));X(_e,e=>{G(j)&&e(ve)});var ye=V(_e,2),M=e=>{var t=Pr(),a=z(t),s=e=>{var t=sc(),a=R(t),s=R(a);let c;var d=R(s);let f;var h=V(d);N(s);var g=V(s,2);N(a);var _=V(a,2),b=e=>{var t=qs(),n=B(t,!0);H(()=>Y(n,G(p).directory)),J(e,t)};X(_,e=>{G(p).name&&G(p).directory&&e(b)});var x=V(_,2),S=B(x),C=V(x,2);let w;var T=R(C),D=R(T);n(D,()=>G(p),()=>!0,()=>!0),N(T);var ee=V(T,2),te=e=>{var t=Pr();Kr(z(t),()=>G(p).id,e=>{{let t=P(()=>new URLSearchParams(Xi.querystring).get(`schedule`)===`edit`),n=P(()=>G(p).fileChanges||[]);Ds(e,{get session(){return G(p).id},oncopy:()=>G(r)?.copy(),get openScheduler(){return G(t)},get observedCommand(){return G(p).command},get observedFileChanges(){return G(n)},get suspended(){return G(m)},onProtectedChange:e=>{L(u,e,!0)}})}}),J(e,t)},ne=e=>{var t=rc();Kr(V(R(t),2),()=>G(p).id,e=>{zo(e,{get session(){return G(p).id},localOnly:!0,oncopy:()=>G(r)?.copy()})}),N(t),J(e,t)};X(ee,e=>{$.data?.control?e(te):e(ne,-1)}),N(C);var re=V(C,2);Z(re,17,()=>G(o).filter(e=>e.session===G(p).id),e=>e.session,(e,t)=>{var n=ac(),r=R(n),i=e=>{var n=Ys(),r=B(n,!0);H(()=>Y(r,G(t).notice)),J(e,n)};X(r,e=>{G(t).notice&&e(i)});var a=V(r,2),o=e=>{Ds(e,{get session(){return G(p).id},review:`profile`})},s=e=>{var t=ic();H(e=>Q(t,`href`,e),[()=>`#/sessions/`+encodeURIComponent(G(p).id)+`?review=profile`]),J(e,t)};X(a,e=>{G(t).pending&&G(m)?e(o):G(t).pending&&e(s,1)}),N(n),H(()=>Q(n,`id`,`quota-profile-`+G(p).id)),J(e,n)});var ie=V(re,2),ae=e=>{var t=Pr();Kr(z(t),()=>G(p).id,e=>{Ps(e,{get session(){return G(p)},get stale(){return G(v)},children:e=>{var t=Pr(),n=z(t),i=e=>{Li(Is(e,{get session(){return G(p)},active:!0,compact:!0}),e=>L(r,e,!0),()=>G(r))};X(n,e=>{G(m)||e(i)}),J(e,t)},$$slots:{default:!0}})}),J(e,t)},oe=e=>{var t=oc(),n=z(t),i=e=>{var t=Pr();Kr(z(t),()=>G(p).id,e=>{Li(Is(e,{get session(){return G(p)},active:!0}),e=>L(r,e,!0),()=>G(r))}),J(e,t)};X(n,e=>{G(m)||e(i)}),Kr(V(n,2),()=>G(p).id,e=>{Ps(e,{get session(){return G(p)},get stale(){return G(v)}})}),J(e,t)};X(ie,e=>{G(p).goal?e(ae):e(oe,-1)}),N(t),H((e,t,n,r)=>{c=li(s,1,`svelte-mm4wfe`,null,c,{failed:e,reviewed:G(p).status===`TURN COMPLETE`&&G(p).readStateKnown&&!G(p).unread}),f=li(d,1,`lamp lit svelte-mm4wfe`,null,f,{failed:t,working:G(p).status===`WORKING`&&!G(v)}),Y(h,`${n??``} // ${(G(p).name||G(p).directory)??``}`),Y(S,`${r??``} TOKENS // ${G(p).id??``} // CONTEXT SOURCE // ${(G(p).source||`LOCAL`)??``}`),w=di(C,``,w,{display:G(m)?`none`:void 0}),Q(T,`data-result-session`,G(p).id),Q(T,`data-result-turn`,G(p).replyTurn)},[()=>y(G(p))&&!G(v)&&!G(m),()=>y(G(p))&&!G(v),()=>G(v)?`STALE`:G(m)?`QUOTA THRESHOLD`:l(G(p)),()=>ma(G(p).tokens)]),K(`click`,g,()=>{O(i().id),pa(i().id,2)}),Sr(`wheel`,T,()=>{E(G(p))}),J(e,t)},c=e=>{J(e,cc())};X(a,e=>{G(p)?e(s):e(c,-1)}),J(e,t)},be=e=>{var t=yc(),r=z(t),i=V(R(r),2),s=R(i),c=V(s,2);N(i),N(r);var u=V(r,2);Z(u,17,()=>G(a),e=>e.id,(e,t)=>{let r=P(()=>da(G(t).id));var i=_c();let a;var s=R(i),c=R(s),u=e=>{var n=lc(),r=R(n),i=B(r);N(n),H(e=>{Q(r,`aria-pressed`,G(h)===G(t).id),Y(i,`${e??``} // ${G(t).name??``}`)},[()=>Array.from(G(t).id).slice(-5).join(``).toUpperCase()]),K(`click`,r,()=>O(G(t).id)),J(e,n)};X(c,e=>{G(t).name&&e(u)});var f=V(c,2),p=R(f);let m;var g=R(p);let _;var b=V(g,1,!0);N(p),N(f);var x=V(f,2),S=e=>{var n=uc(),r=B(n,!0);H(()=>{Q(n,`aria-pressed`,G(h)===G(t).id),Y(r,G(t).directory||G(t).id)}),K(`click`,n,()=>O(G(t).id)),J(e,n)};X(x,e=>{G(t).name||e(S)});var C=V(x,2),w=R(C);Se(),N(C);var T=V(C,2),ee=e=>{var n=qs(),r=B(n,!0);H(()=>Y(r,G(t).directory)),J(e,n)};X(T,e=>{G(t).name&&G(t).directory&&e(ee)});var te=V(T,2),re=B(te),ie=V(te,2),oe=B(ie),se=V(ie,2);ks(se,{get goal(){return G(t).goal},get stale(){return G(v)}});var ce=V(se,2),k=R(ce),le=V(k,2),ue=B(le,!0),de=V(le,2);N(ce);var fe=V(ce,2),pe=V(fe,2),A=e=>{var n=dc(),r=B(n,!0);H(e=>Y(r,e),[()=>G(t).status===`CHECK SESSION`?`INFERRED INACTIVITY`:y(G(t))?`OPEN DETAIL FOR THE TURN ERROR`:$.data?.control?`OPEN FULL DETAIL OR REPLY IN CODEX`:G(t).status===`APPROVAL NEEDED`?`APPROVE OR DECLINE IN CODEX`:`REPLY IN CODEX`]),J(e,n)},me=P(()=>!G(v)&&([`APPROVAL NEEDED`,`INPUT NEEDED`,`CHECK SESSION`].includes(G(t).status)||y(G(t))));X(pe,e=>{G(me)&&e(A)}),N(s);var he=V(s,2),ge=e=>{var r=hc(),i=R(r),a=R(i),s=B(a,!0),c=V(a,2),l=e=>{var n=fc(),r=B(n,!0);H(e=>{Q(n,`href`,e),Y(r,$.data?.control?`REVIEW IN FULL DETAIL ↗`:`APPROVAL IN CODEX ↗`)},[()=>`#/sessions/`+encodeURIComponent(G(t).id)]),J(e,n)};X(c,e=>{!G(v)&&G(t).status===`APPROVAL NEEDED`&&e(l)}),N(i);var u=V(i,2),f=R(u);n(f,()=>G(t),()=>!1),N(u);var p=V(u,2);Z(p,17,()=>G(o).filter(e=>e.session===G(t).id),qr,(e,n)=>{var r=oc(),i=z(r),a=e=>{var t=pc(),r=B(t,!0);H(()=>Y(r,G(n).notice)),J(e,t)};X(i,e=>{G(n).notice&&e(a)});var o=V(i,2),s=e=>{var n=mc();H(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(G(t).id)+`?review=profile`]),K(`click`,n,e=>d(e,G(t).id)),J(e,n)};X(o,e=>{G(n).pending&&e(s)}),J(e,r)});var m=V(p,2);{let e=P(()=>G(h)===G(t).id);Is(m,{get session(){return G(t)},get active(){return G(e)}})}N(r),H(e=>{Y(s,e),Q(u,`data-result-session`,G(t).id),Q(u,`data-result-turn`,G(t).replyTurn)},[()=>ae(G(t))]),Sr(`wheel`,u,()=>{E(G(t))}),J(e,r)};X(he,e=>{G(r)>0&&e(ge)});var _e=V(he,2),ve=e=>{var n=gc(),r=V(R(n),2);{let e=P(()=>(G(t).samples||[]).map(e=>e.tokens));ao(r,{get values(){return G(e)},capacity:120})}var i=B(V(r,2));N(n),H(()=>Y(i,`LAST ${(G(t).samples?.length||0)??``} SAMPLES // AUTO SCALE`)),J(e,n)};X(_e,e=>{G(r)<2&&e(ve)}),N(i),H((e,n,o,s,c,l,u)=>{a=li(i,1,`session-row`,null,a,{selected:G(h)===G(t).id,wide:G(r)===2,split:G(r)===1}),Q(i,`aria-label`,`Session `+(G(t).name||G(t).directory||G(t).id)),m=li(p,1,`status-detail svelte-mm4wfe`,null,m,{reviewed:G(t).status===`TURN COMPLETE`&&G(t).readStateKnown&&!G(t).unread,failed:e}),Q(p,`href`,n),_=li(g,1,`lamp lit svelte-mm4wfe`,null,_,{failed:o,working:G(t).status===`WORKING`&&!G(v)}),Y(b,s),Y(w,`${c??``} `),Y(re,`${G(t).agents??``} LINKED AGENTS`),Y(oe,`ACTIVE // ${l??``}`),k.disabled=G(r)===0,Q(le,`aria-expanded`,G(r)>0),Y(ue,G(r)?`HIDE DETAIL`:`SHOW DETAIL`),Q(fe,`href`,u)},[()=>y(G(t))&&!G(v),()=>`#/sessions/`+encodeURIComponent(G(t).id),()=>y(G(t))&&!G(v),()=>G(v)?`STALE`:l(G(t)),()=>ma(G(t).tokens),()=>ha(G(t).activity),()=>`#/sessions/`+encodeURIComponent(G(t).id)]),K(`click`,p,()=>D(G(t).id)),K(`click`,k,()=>ne(G(t).id,-1)),K(`click`,le,()=>{let e=G(r)===0;O(G(t).id),pa(G(t).id,+!!e),e&&E(G(t))}),K(`click`,de,()=>ne(G(t).id,1)),K(`click`,fe,()=>D(G(t).id)),J(e,i)});var f=V(u,2),p=e=>{J(e,vc())};X(f,e=>{G(a).length||e(p)}),K(`click`,s,()=>fa(1)),K(`click`,c,()=>fa(0)),J(e,t)};X(ye,e=>{i().id?e(M):e(be,-1)}),H(e=>{Y(le,`OBSERVED ${e??``}`),de=li(ue,1,`session-totals`,null,de,{stale:G(v)}),Y(pe,`${G(v)?`LAST KNOWN TOTALS — live state counts unavailable. `:``}Tokens - observed since this server started for currently listed sessions; linked - agents are already included. Totals can decrease when a session leaves the - list. History samples every 30 seconds. Not account-wide totals.`)},[()=>ha($.data?.sessionsAt)]),J(e,oe),Ge()}Cr([`click`]);var Sc=q(``),Cc=q(`

        `),wc=q(`

        Relative usage/credits are not tokens or quota percentages. Groupings - describe the same usage, not additional consumption.

        `,1),Tc=q(`// APPROXIMATE`),Ec=q(`

        Partial accounting: totals may still change.

        `),Dc=q(`

        Percentage of this period's historical allowance, not today's limit. May - exceed 100%. This is not a manual/automatic reset log.

        `,1),Oc=q(`

        `,1),kc=q(`

        This optional account report is unavailable. Token history remains - available; missing data does not mean zero usage.

        `),Ac=q(`
        `),jc=q(`
        `),Mc=q(`

        No usage reported for this day.

        `),Nc=q(`

        Selected breakdown unavailable; missing does not mean zero.

        `),Pc=q(`

        `,1);function Fc(e,t){We(t,!0);let n=I(Xt(co[0])),r=I(0),i=P(()=>t.reports?.daily),a=P(()=>t.reports?.plan),o=P(()=>t.mode===`breakdown`?G(i)?.days?.length||0:G(a)?.periods?.length||0),s=P(()=>Math.min(G(r),Math.max(0,G(o)-1))),c=P(()=>G(i)?.days?.[(G(i)?.days?.length||0)-1-G(s)]),l=P(()=>G(a)?.periods?.[G(s)]),u=P(()=>t.mode===`breakdown`?G(i)?.units||``:`%`),d=P(()=>(t.mode===`breakdown`?G(c):G(l))?.views?.[G(n)]),f=P(()=>G(d)?.rows||[]),p=P(()=>G(d)?.total),m=P(()=>G(d)?.level||`unknown`),h=P(()=>G(d)?.peak||1),g=e=>e==null?`UNKNOWN`:e.toLocaleString(`en-GB`,{maximumFractionDigits:2});var _=Pc(),v=z(_),y=R(v),b=V(R(y));Z(b,21,()=>co,qr,(e,t)=>{var n=Sc(),r=B(n,!0),i={};H(e=>{Y(r,e),i!==(i=G(t))&&(n.value=(n.__value=i)??``)},[()=>G(t).charAt(0).toUpperCase()+G(t).slice(1)]),J(e,n)}),N(b),hi(b),N(y);var x=V(y,2),S=V(x,2),C=B(V(S,2),!0);N(v);var w=V(v,2),T=R(w),E=B(T,!0),D=V(T,2),ee=B(D),te=V(D,2),O=e=>{var t=wc(),n=z(t),r=B(n),a=V(n,2),o=e=>{var t=Cc(),n=B(t);H(()=>Y(n,`Data as of ${G(i).dataAsOf??``}`)),J(e,t)};X(a,e=>{G(i).dataAsOf&&e(o)});var s=B(V(a,2));Se(2),H((e,t)=>{Y(r,`Latest fetch ${e??``} // queried ${G(i).from??``} → ${G(i).through??``}. - Reports are fetched from OpenAI and are not saved between runs.`),Y(s,`${(G(c)?.date||`No daily buckets reported`)??``} // ${t??``} - ${G(u)??``}`)},[()=>ha(G(i).fetchedAt),()=>g(G(p))]),J(e,t)},ne=e=>{var t=Oc(),n=z(t),r=R(n);let i;var o=B(r,!0),s=V(r),c=e=>{J(e,Tc())};X(s,e=>{G(a).approximate&&e(c)});var u=V(s);N(n);var d=V(n,2),f=R(d),h=V(f),_=e=>{var t=Nr();H(()=>Y(t,`// Boundary tolerance ${G(a).boundary_tolerance_seconds??``}s`)),J(e,t)};X(h,e=>{G(a).boundary_tolerance_seconds!=null&&e(_)}),N(d);var v=V(d,2),y=e=>{var t=Dc(),n=z(t),r=R(n),i=V(r);let a;var o=B(i);N(n);var s=V(n,2),c=B(s),u=V(s,2),d=e=>{J(e,Ec())};X(u,e=>{G(l).accounting_complete||e(d)}),Se(2),H(e=>{Y(r,`${G(l).window_minutes??``} MIN // ${G(l).plan_type??``} // `),a=li(i,1,`svelte-1fbui7h`,null,a,{muted:G(m)===`unknown`,"quota-near":G(m)===`near`,"quota-full":G(m)===`full`}),Y(o,`USED ${e??``}${G(p)==null?``:`%`}`),Y(c,`${G(l).starts_at??``} → ${G(l).ends_at??``}`)},[()=>g(G(p))]),J(e,t)};X(v,e=>{G(l)&&e(y)}),H(e=>{i=li(r,1,`svelte-1fbui7h`,null,i,{"quality-warning":!G(a).coverage_complete}),Y(o,G(a).coverage_complete?`Reported range complete`:`Partial coverage`),Y(u,` // Latest fetch ${e??``}`),Y(f,`Coverage starts ${(G(a).coverage_start||`unknown`)??``} // Data as of ${(G(a).data_as_of||`unknown`)??``}`)},[()=>ha(G(a).fetchedAt)]),J(e,t)},re=e=>{J(e,kc())};X(te,e=>{t.mode===`breakdown`&&G(i)?e(O):t.mode===`periods`&&G(a)?e(ne,1):e(re,-1)});var ie=V(te,2),ae=e=>{var n=jc(),r=R(n),i=B(V(R(r),2),!0);N(r),Z(V(r,2),17,()=>G(f),qr,(e,n,r)=>{let i=()=>G(n).name,a=()=>G(n).value;var o=Ac();let s;var c=R(o),l=B(c,!0),u=V(c,2),d=R(u);let f;N(u);var p=B(V(u,2));N(o),H((e,n,a)=>{s=li(o,1,`report-row svelte-1fbui7h`,null,s,{unknown:e,alternate:r%2==1}),Q(c,`title`,i()),Y(l,i()),f=di(d,``,f,{width:n}),Y(p,`${a??``}${t.mode===`periods`?`%`:``}`)},[()=>i().trim().toLowerCase()===`unknown`,()=>`${Math.max(0,100*a()/G(h))}%`,()=>g(a())]),J(e,o)}),N(n),H(()=>Y(i,t.mode===`breakdown`?G(u):`QUOTA USED`)),J(e,n)},oe=e=>{J(e,Mc())},se=e=>{J(e,Nc())};X(ie,e=>{G(f).length?e(ae):t.mode===`breakdown`&&G(d)?.knownEmpty?e(oe,1):(G(i)&&t.mode===`breakdown`||G(a)&&t.mode===`periods`)&&e(se,2)}),N(w),H(()=>{x.disabled=G(s)>=G(o)-1,S.disabled=G(s)===0,Y(C,G(o)?`${G(s)+1} / ${G(o)}`:`NO DATA`),Y(E,t.mode===`breakdown`?`DAILY BREAKDOWN`:`QUOTA WINDOWS`),Y(ee,`${(t.mode===`breakdown`?t.reports?.dailyStatus||`UNAVAILABLE`:t.reports?.planStatus||`UNAVAILABLE`)??``} // UTC`)}),gi(b,()=>G(n),e=>L(n,e)),K(`click`,x,()=>L(r,G(s)+1)),K(`click`,S,()=>L(r,G(s)-1)),J(e,_),Ge()}Cr([`click`]);var Ic=864e5;function Lc(e,t){let n=new Date(e);n.setUTCDate(1),n.setUTCMonth(n.getUTCMonth()+t);let r=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)).getUTCDate();return n.setUTCDate(Math.min(e.getUTCDate(),r)),n}function Rc(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));for(let e=0;;e++){let i=Lc(r,-t),a=new Date(i.getTime()+Ic);if(e===n)return{start:a,end:r};r=i}}var zc=q(``),Bc=q(``,1),Vc=q(`

        History refresh failed. Any displayed history is the last successful - observation.

        `),Hc=q(`

        Token history unavailable; other reports may still be available.

        `),Uc=q(``),Wc=q(`
        `),Gc=q(`

        LESS ░ ▒ ▓ █ MORE // HOVER FOR DATE AND TOKENS

        `,1),Kc=q(`
        `,1),qc=q(` `),Jc=q(`

        LIFETIME TOKENS

        PEAK DAY

        CURRENT STREAK

        DAYS

        LONGEST TURN

        SECONDS

        LONGEST STREAK

        DAYS

        OPENAI // UTC

        Accessible data table
        Date (UTC)Tokens

        `,1),Yc=q(`

        History unavailable or awaiting a matching account observation. Missing - history is not treated as zero usage.

        `),Xc=q(`

        USAGE // ACCOUNT HISTORY

        Account-wide history reported by Codex, not the local Sessions counter. Dates - use UTC. Allowance history is approximate where indicated; reset causes are - not provided.

        `,1);function Zc(e,t){We(t,!0);let n=I(`daily`),r=I(12),i=I(0),a=P(()=>{let e=$.data?.usage?.dailyUsageBuckets;if(!e)return[];let{start:t,end:n}=Rc(new Date,G(r),G(i)),a=new Map;for(let t of e)!Number.isFinite(t.tokens)||t.tokens<0||a.set(t.startDate,(a.get(t.startDate)||0)+t.tokens);let o=[];for(let e=t;e<=n;e=new Date(e.getTime()+864e5)){let t=e.toISOString().slice(0,10);o.push({date:t,tokens:a.get(t)||0})}return o}),o=P(()=>Math.max(1,...G(a).map(e=>e.tokens))),s=P(()=>G(a).length?new Date(G(a)[0].date+`T00:00:00Z`).getUTCDay():0),c=P(()=>{if(G(n)===`monthly`){let e=new Map;for(let t of G(a))e.set(t.date.slice(0,7),(e.get(t.date.slice(0,7))||0)+t.tokens);return[...e].map(([e,t])=>({date:e,tokens:t}))}let e=0;return G(a).map(t=>({date:t.date,tokens:e+=t.tokens}))});var l=Xc(),u=V(z(l),4);Z(u,20,()=>[[`daily`,`Daily`],[`monthly`,`Monthly`],[`cumulative`,`Cumulative`],[`breakdown`,`Breakdown`],[`periods`,`Windows`]],qr,(e,t)=>{var r=P(()=>_(t,2));let a=()=>G(r)[0],o=()=>G(r)[1];var s=zc();let c;var l=B(s,!0);H(()=>{Q(s,`aria-pressed`,G(n)===a()),c=li(s,1,``,null,c,{active:G(n)===a()}),Y(l,o())}),K(`click`,s,()=>{L(n,a(),!0),L(i,0)}),J(e,s)}),N(u);var d=V(u,2),f=R(d),p=e=>{var t=Bc(),n=z(t),a=V(R(n)),o=R(a);o.value=o.__value=6;var s=V(o);s.value=s.__value=12,N(a),hi(a),N(n);var c=V(n),l=V(c);H(()=>l.disabled=G(i)===0),K(`change`,a,()=>L(i,0)),gi(a,()=>G(r),e=>L(r,e)),K(`click`,c,()=>qt(i)),K(`click`,l,()=>qt(i,-1)),J(e,t)};X(f,e=>{G(n)!==`breakdown`&&G(n)!==`periods`&&e(p)}),N(d);var m=V(d,2),h=e=>{J(e,Vc())};X(m,e=>{$.data?.usageError&&e(h)});var g=V(m,2),v=e=>{J(e,Hc())};X(g,e=>{$.data?.usage?.tokenStatus===`UNAVAILABLE`&&G(n)!==`breakdown`&&G(n)!==`periods`&&e(v)});var y=V(g,2),b=e=>{var t=Pr();Kr(z(t),()=>G(n),e=>{{let t=P(()=>$.data?.usage?.reports);Fc(e,{get reports(){return G(t)},get mode(){return G(n)}})}}),J(e,t)},x=e=>{var t=Jc(),r=z(t),i=R(r),l=B(V(R(i),2),!0);N(i);var u=V(i,2),d=B(V(R(u),2),!0);N(u);var f=V(u,2),p=V(R(f),2),m=R(p);Se(),N(p),N(f);var h=V(f,2),g=V(R(h),2),_=R(g);Se(),N(g),N(h);var v=V(h,2),y=V(R(v),2),b=R(y);Se(),N(y),N(v),N(r);var x=V(r,4),S=R(x),C=B(S),w=V(S,2),T=e=>{var t=Gc(),n=z(t),r=R(n),i=R(r);Z(i,17,()=>Array(G(s)),qr,(e,t)=>{J(e,Uc())}),Z(V(i,2),17,()=>G(a),qr,(e,t)=>{var n=Wc();let r,i;H(e=>{r=li(n,1,`heat-cell`,null,r,{zero:G(t).tokens===0}),Q(n,`title`,e),i=di(n,``,i,{opacity:G(t).tokens?.25+.75*G(t).tokens/G(o):1})},[()=>`${G(t).date}: ${ma(G(t).tokens)} tokens`]),J(e,n)}),N(r),N(n),Se(2),J(e,t)},E=e=>{var t=Kc(),r=z(t);{let e=P(()=>G(c).map(e=>e.tokens)),t=P(()=>G(n)+` usage`);ao(r,{get values(){return G(e)},get label(){return G(t)}})}var i=V(r,2),a=R(i),o=B(a,!0),s=B(V(a),!0);N(i),H(e=>{Y(o,G(c)[0]?.date),Y(s,e)},[()=>G(c).at(-1)?.date]),J(e,t)};X(w,e=>{G(n)===`daily`?e(T):e(E,-1)});var D=V(w,2),ee=V(R(D),2),te=R(ee),O=V(R(te));Z(O,21,()=>G(n)===`daily`?G(a):G(c),qr,(e,t)=>{var n=qc(),r=R(n),i=B(r,!0),a=B(V(r),!0);N(n),H(e=>{Y(i,G(t).date),Y(a,e)},[()=>ma(G(t).tokens)]),J(e,n)}),N(O),N(te),N(ee),N(D),N(x);var ne=B(V(x,2));H((e,t,n,r,i,o,s)=>{Y(l,e),Y(d,t),Y(m,`${n??``} `),Y(_,`${r??``} `),Y(b,`${i??``} `),Y(C,`${G(a)[0]?.date??``} — ${o??``}`),Y(ne,`OBSERVED ${s??``} // CUMULATIVE IS FOR THE SELECTED PERIOD`)},[()=>ma($.data.usage.summary.lifetimeTokens),()=>ma($.data.usage.summary.peakDailyTokens),()=>ma($.data.usage.summary.currentStreakDays),()=>ma($.data.usage.summary.longestRunningTurnSec),()=>ma($.data.usage.summary.longestStreakDays),()=>G(a).at(-1)?.date,()=>ha($.data.usageAt)]),J(e,t)},S=e=>{J(e,Yc())};X(y,e=>{G(n)===`breakdown`||G(n)===`periods`?e(b):$.data?.usage&&$.data.usage.dailyUsageBuckets!==null?e(x,1):e(S,-1)}),J(e,l),Ge()}Cr([`click`,`change`]);var Qc=q(`

        Page not found

        Return to Quota

        `,1);function $c(e){var t=Qc();Se(2),J(e,t)}var el=`CODEXOMETER`,tl=[`█▀▀ █▀█ █▀▄ █▀▀ ▀▄▀ █▀█ █▀▄▀█ █▀▀ ▀█▀ █▀▀ █▀█`,`█▄▄ █▄█ █▄▀ ██▄ █ █ █▄█ █ ▀ █ ██▄ █ ██▄ █▀▄`].flatMap(e=>[[...e].map(e=>e===`█`||e===`▀`),[...e].map(e=>e===`█`||e===`▄`)]),nl=tl[0].length,rl=tl.length,il=0,al=[...el].map(e=>{let t=e===`M`?5:3,n={start:il,width:t};return il+=t+1,n}),ol=`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`,sl=`010 101 111 101.110 111 101 110.111 100 100 111.110 101 101 110.111 100 110 111.111 100 110 100.111 100 101 111.101 101 111 101.111 010 010 111.001 001 101 111.101 110 110 101.100 100 100 111.101 111 101 101.101 111 111 101.111 101 101 111.111 101 111 100.111 101 111 001.111 101 110 101.111 100 001 111.111 010 010 010.101 101 101 111.101 101 101 010.101 101 111 101.101 010 010 101.101 101 010 010.111 001 100 111.111 101 101 111.110 010 010 111.111 001 110 111.111 011 001 111.101 101 111 001.111 110 001 111.100 111 101 111.111 001 010 010.111 111 101 111.111 101 111 001`.split(`.`).map(e=>e.split(` `));function cl(e=el,t=-1,n=!1){let r=``;for(let i=0;i{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}function fl(){let e=ll[Math.floor(Math.random()*ll.length)],t=Math.floor(Math.random()*4294967296),n=dl(t),r=[...el].map((e,t)=>t);for(let e=r.length-1;e>0;e--){let t=Math.floor(n()*(e+1));[r[e],r[t]]=[r[t],r[e]]}return{variant:e,seed:t,order:r}}function pl(e,t){if(e.variant===`typing`){let e=t<1080,n=e?0:Math.min(Math.floor((t-1080)/90)+1,11);return{text:el.slice(0,n).padEnd(11),cursor:n,dot:e?Math.floor(t/180)%2==0:n<11}}if(e.variant===`shuffle`){let n=dl(e.seed^Math.floor(t/70)),r=[...el].map(e=>{let t;do t=ol[Math.floor(n()*36)];while(t===e);return t}),i=Math.min(Math.floor(t/110),11);for(let t of e.order.slice(0,i))r[t]=el[t];return{text:r.join(``),cursor:-1,dot:!1}}return{text:el,cursor:-1,dot:!1}}var ml=Mr(``);function hl(e,t){We(t,!0);let n=Gi(t,`text`,3,el),r=Gi(t,`cursor`,19,()=>-1),i=Gi(t,`dot`,3,!1),a=P(()=>cl(n(),r(),i()));var o=ml(),s=B(o);H(()=>{Q(o,`viewBox`,`0 0 ${nl} ${rl}`),Q(o,`width`,nl),Q(o,`height`,rl),Q(s,`d`,G(a))}),J(e,o),Ge()}var gl=q(`
        `),_l=q(`
        `);function vl(e,t){We(t,!0);let n=I(void 0),r=I(0),i=I(Xt({width:0,height:0,pixelRatio:1})),a=I(Xt({x:0,y:0,width:0})),o=P(()=>G(n)?pl(G(n),G(r)):void 0),s=P(()=>{if(!G(n))return{x:0,y:0,width:0};let e=ul[G(n).variant],t=Math.min(Math.max((G(r)-e-180)/800,0),1),o=t*t*(3-2*t),s=G(i).width+(G(a).width-G(i).width)*o,c=Math.max((G(i).height-G(i).width*rl/nl)/2,0),l=(G(n).variant===`slide`&&G(r)Math.round(e*G(i).pixelRatio)/G(i).pixelRatio;return{x:d(l),y:d(u),width:d(s)}});Ki(()=>{let e=matchMedia(`(prefers-reduced-motion: reduce)`);if(e.matches){t.onfinish();return}L(n,fl(),!0);let o=ul[G(n).variant]+180+800,s=0,c=!1,l=performance.now(),u=()=>{let e=t.target?.getBoundingClientRect();L(i,{width:window.innerWidth,height:window.innerHeight,pixelRatio:window.devicePixelRatio||1},!0),e&&L(a,{x:e.x,y:e.y,width:e.width},!0)},d=()=>{c||(c=!0,cancelAnimationFrame(s),t.onfinish())},f=e=>{e instanceof PointerEvent&&e.button!==0||e instanceof KeyboardEvent&&(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)||e instanceof KeyboardEvent&&[`Shift`,`Control`,`Alt`,`Meta`].includes(e.key)||(e.preventDefault(),e.stopImmediatePropagation(),d())},p=()=>{e.matches&&d()},m=e=>{L(r,Math.max(e-l,0),!0),G(r)>=o?d():s=requestAnimationFrame(m)},h=new ResizeObserver(u);if(t.target){h.observe(t.target),t.target.parentElement&&h.observe(t.target.parentElement);let e=t.target.closest(`header`);e&&h.observe(e)}return u(),window.addEventListener(`resize`,u),document.addEventListener(`keydown`,f,!0),document.addEventListener(`pointerdown`,f,!0),e.addEventListener(`change`,p),s=requestAnimationFrame(m),()=>{c=!0,cancelAnimationFrame(s),h.disconnect(),window.removeEventListener(`resize`,u),document.removeEventListener(`keydown`,f,!0),document.removeEventListener(`pointerdown`,f,!0),e.removeEventListener(`change`,p)}});var c=_l(),l=R(c),u=e=>{var t=gl();let n;hl(R(t),{get text(){return G(o).text},get cursor(){return G(o).cursor},get dot(){return G(o).dot}}),N(t),H(()=>{Q(t,`data-text`,G(o).text),Q(t,`data-cursor`,G(o).dot?G(o).cursor:void 0),n=di(t,``,n,{left:`${G(s).x}px`,top:`${G(s).y}px`,width:`${G(s).width}px`})}),J(e,t)};X(l,e=>{G(o)&&e(u)});var d=V(l,2);N(c),H(()=>Q(c,`data-entrance`,G(n)?.variant)),K(`click`,d,function(...e){t.onfinish?.apply(this,e)}),J(e,c),Ge()}Cr([`click`]);var yl=q(` `),bl=q(`

        `),xl=q(`

        Connecting to your local Codexometer…

        `),Sl=q(``),Cl=q(`

        Your quota. Your sessions. Your command centre.

        `);function wl(e,t){We(t,!0);let n={"/":no,"/quota/:view?":no,"/sessions/:id?":xc,"/usage":Zc,"*":$c},r={quota:/^(?:\/|\/quota(?:\/[^/]+)?\/?)$/,sessions:/^\/sessions(?:\/[^/]+)?\/?$/,usage:/^\/usage\/?$/},i=I(`hacker`),a=I(!0),o=I(void 0);yn(()=>{ca.requests&&ur().then(()=>{G(o)?.focus(),G(o)?.scrollIntoView({block:`nearest`})})});let s=I(void 0),c=[`hacker`,`rust`,`blue-steel`,`ultraviolet`,`nightshade`];yn(()=>{la()}),yn(()=>{if($.data)for(let[e,t]of Object.entries(r))t.test(Xi.location)&&(oa.tab=e)}),Ki(()=>{try{let e=localStorage.getItem(`codexometer.web.theme`);e&&c.includes(e)&&L(i,e,!0)}catch{}return ba()});function l(){try{localStorage.setItem(`codexometer.web.theme`,G(i))}catch{}}var u=Cl(),d=R(u),f=R(d),p=R(f);hl(R(p),{}),N(p),Li(p,e=>L(s,e),()=>G(s)),Se(2),N(f);var m=V(f,2),h=R(m);let g;var v=V(h,1,!0),y=B(V(v));N(m),N(d);var b=V(d,2);Z(b,21,()=>Object.entries(r),qr,(e,t)=>{var n=P(()=>_(G(t),2));let r=()=>G(n)[0],i=()=>G(n)[1],a=P(()=>i().test(Xi.location));var o=yl();let s;var c=B(o,!0);H(e=>{Q(o,`href`,r()===`quota`?`#/quota/`+oa.view:`#/`+r()),Q(o,`aria-current`,G(a)?`page`:void 0),s=li(o,1,``,null,s,{active:G(a)}),Y(c,e)},[()=>r().toUpperCase()]),J(e,o)}),N(b);var x=V(b,2),S=R(x),C=e=>{var t=bl(),n=B(t,!0);H(()=>Y(n,$.error)),J(e,t)};X(S,e=>{$.error&&e(C)});var w=V(S,2),T=e=>{ea(e,{get routes(){return n}})},E=e=>{J(e,xl())};X(w,e=>{$.data?e(T):$.error||e(E,1)}),N(x);var D=V(x,2),ee=R(D),te=B(ee),O=V(ee,2),ne=B(O,!0),re=V(O,2),ie=V(R(re));Z(ie,21,()=>c,qr,(e,t)=>{var n=Sl(),r=B(n,!0),i={};H(e=>{Y(r,e),i!==(i=G(t))&&(n.value=(n.__value=i)??``)},[()=>G(t).replace(`-`,` `).toUpperCase()]),J(e,n)}),N(ie),Li(ie,e=>L(o,e),()=>G(o)),hi(ie),N(re),N(D);var ae=V(D,2),oe=e=>{vl(e,{get target(){return G(s)},onfinish:()=>L(a,!1)})};X(ae,e=>{G(a)&&e(oe)}),N(u),H(()=>{Q(u,`data-theme`,G(i)),Q(u,`data-starting`,G(a)),d.inert=G(a),g=li(h,1,`lamp`,null,g,{lit:$.connected}),Y(v,$.connected?`CONNECTED`:`OFFLINE`),Y(y,`EXPERIMENTAL // ${$.data?.control?`SESSION CONTROL`:`READ ONLY`}`),b.inert=G(a),x.inert=G(a),D.inert=G(a),Y(te,`v${($.data?.version||`…`)??``} // LOCAL ONLY`),Y(ne,$.data?.control?`Session control enabled. Stop the server to revoke access.`:`No actions can be sent from this preview.`)}),K(`change`,ie,l),gi(ie,()=>G(i),e=>L(i,e)),J(e,u),Ge()}Cr([`change`]),Br(wl,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/web/dist/index.html b/internal/web/dist/index.html index ed5c79f7..cd6d11ec 100644 --- a/internal/web/dist/index.html +++ b/internal/web/dist/index.html @@ -5,7 +5,7 @@ Codexometer // Experimental web - + diff --git a/internal/web/server.go b/internal/web/server.go index 368bc980..e687fc1b 100644 --- a/internal/web/server.go +++ b/internal/web/server.go @@ -23,6 +23,7 @@ import ( "github.com/charmbracelet/x/term" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" ) // Assets are checked in so go install and terminal-only builds need no Node. @@ -43,7 +44,7 @@ type server struct { } type Options struct { - NoConfirm bool + ConfirmationMode confirmation.Mode } // Run binds IPv4 loopback only. Control must be explicitly enabled at launch. @@ -68,12 +69,14 @@ func Run(ctx context.Context, source Source, refresh time.Duration, port int, ou s.control = newControl(source, s.store) s.store.state.Control = true if len(options) > 0 { - s.store.state.NoConfirm = options[0].NoConfirm + s.store.state.ConfirmationMode = options[0].ConfirmationMode } s.store.publish() mode = "SESSION CONTROL ENABLED — prompts, decisions and configured quota profiles enabled" - if s.store.state.NoConfirm { + if s.store.state.ConfirmationMode == confirmation.None { mode += " // EXTRA CONFIRMATIONS OFF" + } else if s.store.state.ConfirmationMode == confirmation.Require { + mode += " // CONFIRM EVERY ACTION" } } ctx, cancel := context.WithCancel(ctx) diff --git a/internal/web/state.go b/internal/web/state.go index 24dbfe99..9f34f3a9 100644 --- a/internal/web/state.go +++ b/internal/web/state.go @@ -9,6 +9,7 @@ import ( "time" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" "github.com/merefield/codexometer/internal/quotagraph" "github.com/merefield/codexometer/internal/statusline" "github.com/merefield/codexometer/internal/version" @@ -134,7 +135,7 @@ type state struct { Thresholds []quotaThreshold `json:"thresholds,omitempty"` ProfileError bool `json:"profileError,omitempty"` Control bool `json:"control"` - NoConfirm bool `json:"noConfirm,omitempty"` + ConfirmationMode confirmation.Mode `json:"confirmationMode"` Version string `json:"version"` Meters []meter `json:"meters" ts:"nonnull"` Credits []credit `json:"credits" ts:"nonnull"` @@ -169,7 +170,7 @@ type store struct { } func newStore() *store { - s := &store{state: state{StatusLineFields: statusline.Fields(), Version: version.Current(), Meters: []meter{}, Credits: []credit{}, Sessions: []session{}}, previous: map[string]int64{}, samples: map[string][]sample{}, changed: make(chan struct{})} + s := &store{state: state{ConfirmationMode: confirmation.Balanced, StatusLineFields: statusline.Fields(), Version: version.Current(), Meters: []meter{}, Credits: []credit{}, Sessions: []session{}}, previous: map[string]int64{}, samples: map[string][]sample{}, changed: make(chan struct{})} s.publish() return s } diff --git a/main.go b/main.go index b818b8f2..1a2e3b0c 100644 --- a/main.go +++ b/main.go @@ -16,6 +16,7 @@ import ( tea "charm.land/bubbletea/v2" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" "github.com/merefield/codexometer/internal/diagnostics" "github.com/merefield/codexometer/internal/digbench" "github.com/merefield/codexometer/internal/ui" @@ -356,8 +357,8 @@ type dependencies struct { checkAuth func(context.Context, string) (codex.Snapshot, error) listDigBenchGames func(context.Context, string) ([]string, error) runDigBench func(context.Context, string, string, string, codex.DigBenchOptions) (codex.DigBenchResult, error) - startUI func(ui.Fetcher, time.Duration, bool, int, int, bool) error - startWeb func(web.Source, time.Duration, int, io.Writer, bool, bool) error + startUI func(ui.Fetcher, time.Duration, bool, int, int, confirmation.Mode) error + startWeb func(web.Source, time.Duration, int, io.Writer, bool, confirmation.Mode) error } func defaultDependencies() dependencies { @@ -373,10 +374,10 @@ func defaultDependencies() dependencies { return (codex.Client{Binary: binary, BenchmarkAPIKey: apiKey}).RunDigBench(ctx, digbench.Client{Token: token}, options) }, startUI: startUI, - startWeb: func(source web.Source, refresh time.Duration, port int, output io.Writer, control, noConfirm bool) error { + startWeb: func(source web.Source, refresh time.Duration, port int, output io.Writer, control bool, mode confirmation.Mode) error { ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() - return web.Run(ctx, source, refresh, port, output, control, web.Options{NoConfirm: noConfirm}) + return web.Run(ctx, source, refresh, port, output, control, web.Options{ConfirmationMode: mode}) }, } } @@ -386,24 +387,24 @@ func run(args []string, stdout, stderr io.Writer, deps dependencies) int { flags.SetOutput(stderr) var quotaSteps quotaStepFlags var ( - codexPath = flags.String("codex", "codex", "path to the Codex CLI") - errorLog = flags.String("error-log", "", "write bounded operational diagnostics to this file (off by default)") - verbose = flags.Bool("verbose", false, "include diagnostic context in --error-log (never raw payloads)") - noConfirm = flags.Bool("no-confirm", false, "skip Codexometer confirmation steps except quota resets (does not bypass Codex permissions)") - refresh = flags.Duration("refresh", time.Minute, "quota refresh interval") - demo = flags.Bool("demo", false, "show the UI with simulated quota data") - inline = flags.Bool("inline", false, "render inline instead of using the alternate screen") - webMode = flags.Bool("web", false, "serve the experimental read-only browser interface on loopback") - webControl = flags.Bool("web-control", false, "enable experimental browser session approvals, prompts and configured quota profiles (requires --web)") - webPort = flags.Int("web-port", 0, "local web port (0 chooses an available port; requires --web)") - resetThreshold = flags.Int("reset-threshold", 80, "show reset at this quota consumption (0-100; also shown for expiring credits)") - resetWarningHours = flags.Int("reset-warning-hours", 72, "warn this many hours before a reset credit expires (0 disables expiry warnings)") - checkAuth = flags.Bool("check-auth", false, "verify access to the current Codex login and exit") - digBenchGame = flags.String("digbench-game", "", "run one experimental DigBench game and exit") - digBenchModel = flags.String("digbench-model", "gpt-5.6-sol", "Codex model for --digbench-game") - digBenchEffort = flags.String("digbench-effort", "high", "reasoning effort for --digbench-game") - digBenchTimeout = flags.Duration("digbench-timeout", codex.DefaultDigBenchTimeout, "hard limit for --digbench-game") - printVersion bool + codexPath = flags.String("codex", "codex", "path to the Codex CLI") + errorLog = flags.String("error-log", "", "write bounded operational diagnostics to this file (off by default)") + verbose = flags.Bool("verbose", false, "include diagnostic context in --error-log (never raw payloads)") + confirmationOption = flags.String("confirmation", "balanced", "confirmation policy: balanced, none or require (quota resets always require confirmation)") + refresh = flags.Duration("refresh", time.Minute, "quota refresh interval") + demo = flags.Bool("demo", false, "show the UI with simulated quota data") + inline = flags.Bool("inline", false, "render inline instead of using the alternate screen") + webMode = flags.Bool("web", false, "serve the experimental read-only browser interface on loopback") + webControl = flags.Bool("web-control", false, "enable experimental browser session approvals, prompts and configured quota profiles (requires --web)") + webPort = flags.Int("web-port", 0, "local web port (0 chooses an available port; requires --web)") + resetThreshold = flags.Int("reset-threshold", 80, "show reset at this quota consumption (0-100; also shown for expiring credits)") + resetWarningHours = flags.Int("reset-warning-hours", 72, "warn this many hours before a reset credit expires (0 disables expiry warnings)") + checkAuth = flags.Bool("check-auth", false, "verify access to the current Codex login and exit") + digBenchGame = flags.String("digbench-game", "", "run one experimental DigBench game and exit") + digBenchModel = flags.String("digbench-model", "gpt-5.6-sol", "Codex model for --digbench-game") + digBenchEffort = flags.String("digbench-effort", "high", "reasoning effort for --digbench-game") + digBenchTimeout = flags.Duration("digbench-timeout", codex.DefaultDigBenchTimeout, "hard limit for --digbench-game") + printVersion bool ) flags.Var("aSteps, "quota-step-down", "set PERCENT:MODEL:EFFORT[:SPEED[:ask|auto]] per session (repeatable; default ask; empty SPEED preserves speed)") flags.BoolVar(&printVersion, "version", false, "print the version and exit") @@ -416,6 +417,11 @@ func run(args []string, stdout, stderr io.Writer, deps dependencies) int { fmt.Fprintln(stdout, "codexometer "+version.Current()) return 0 } + mode, err := confirmation.Parse(*confirmationOption) + if err != nil { + fmt.Fprintln(stderr, "codexometer:", err) + return 2 + } if *webPort < 0 || *webPort > 65535 || (*webPort != 0 && !*webMode) { fmt.Fprintln(stderr, "codexometer: --web-port must be between 0 and 65535 and requires --web") return 2 @@ -520,16 +526,12 @@ func run(args []string, stdout, stderr io.Writer, deps dependencies) int { if *webMode { // Web mode deliberately gets no benchmark credentials or discovery calls. client := codex.Client{Binary: *codexPath, QuotaSteps: quotaSteps} - if liveUsage, err := codex.NewLiveUsageReader(""); err == nil { - client.LiveUsage = liveUsage - } else { - diagnostics.Error("local-rollouts", "initialise session reader", err, diagnostics.Fields{}) - } + client = withLiveUsage(client) var source web.Source = client if *demo { source = &demoFetcher{quotaSteps: quotaSteps} } - if err := deps.startWeb(source, *refresh, *webPort, stdout, *webControl, *noConfirm); err != nil { + if err := deps.startWeb(source, *refresh, *webPort, stdout, *webControl, mode); err != nil { diagnostics.Error("application", "web interface", err, diagnostics.Fields{}) fmt.Fprintln(stderr, "codexometer:", err) return 1 @@ -549,17 +551,13 @@ func run(args []string, stdout, stderr io.Writer, deps dependencies) int { } digBenchGames = normalizeDigBenchGames(digBenchGames) client := codex.Client{Binary: *codexPath, BenchmarkAPIKey: benchmarkAPIKey, DigBenchToken: digBenchToken, DigBenchGames: digBenchGames, QuotaSteps: quotaSteps} - if liveUsage, err := codex.NewLiveUsageReader(""); err == nil { - client.LiveUsage = liveUsage - } else { - diagnostics.Error("local-rollouts", "initialise session reader", err, diagnostics.Fields{}) - } + client = withLiveUsage(client) var fetcher ui.Fetcher = client if *demo { fetcher = &demoFetcher{quotaSteps: quotaSteps} } - if err := deps.startUI(fetcher, *refresh, *inline, *resetThreshold, *resetWarningHours, *noConfirm); err != nil { + if err := deps.startUI(fetcher, *refresh, *inline, *resetThreshold, *resetWarningHours, mode); err != nil { diagnostics.Error("application", "terminal interface", err, diagnostics.Fields{}) fmt.Fprintln(stderr, "codexometer:", err) return 1 @@ -676,7 +674,7 @@ func formatDigBenchResult(result codex.DigBenchResult) string { return line } -func startUI(fetcher ui.Fetcher, refresh time.Duration, inline bool, resetThreshold, resetWarningHours int, noConfirm bool) error { +func startUI(fetcher ui.Fetcher, refresh time.Duration, inline bool, resetThreshold, resetWarningHours int, mode confirmation.Mode) error { model := ui.New(fetcher, refresh) if store, storeErr := ui.NewDefaultPreferenceStore(); storeErr == nil { model = ui.NewWithPreferences(fetcher, refresh, store) @@ -684,7 +682,7 @@ func startUI(fetcher ui.Fetcher, refresh time.Duration, inline bool, resetThresh model.SetInline(inline) model.SetResetThreshold(resetThreshold) model.SetResetWarningHours(resetWarningHours) - model.SetNoConfirm(noConfirm) + model.SetConfirmationMode(mode) finalModel, runErr := tea.NewProgram(model, terminalProgramOptions(os.Environ(), appleTerminalSupportsTrueColor())...).Run() if final, ok := finalModel.(ui.Model); ok { final.CancelQuotaWork() @@ -694,3 +692,13 @@ func startUI(fetcher ui.Fetcher, refresh time.Duration, inline bool, resetThresh } return runErr } + +func withLiveUsage(client codex.Client) codex.Client { + reader, err := codex.NewLiveUsageReader("") + if err != nil { + diagnostics.Error("local-rollouts", "initialise session reader", err, diagnostics.Fields{}) + } else { + client.LiveUsage = reader + } + return client +} diff --git a/main_logging_test.go b/main_logging_test.go index e64cfc73..61028ac6 100644 --- a/main_logging_test.go +++ b/main_logging_test.go @@ -3,6 +3,7 @@ package main import ( "bytes" "errors" + "github.com/merefield/codexometer/internal/confirmation" "io" "os" "path/filepath" @@ -18,10 +19,10 @@ func TestLoggingFlagsAndLaunchFailures(t *testing.T) { for _, browser := range []bool{false, true} { path := filepath.Join(t.TempDir(), "error.log") deps := dependencies{ - startUI: func(ui.Fetcher, time.Duration, bool, int, int, bool) error { + startUI: func(ui.Fetcher, time.Duration, bool, int, int, confirmation.Mode) error { return errors.New("PRIVATE_UPSTREAM_BODY") }, - startWeb: func(web.Source, time.Duration, int, io.Writer, bool, bool) error { + startWeb: func(web.Source, time.Duration, int, io.Writer, bool, confirmation.Mode) error { return errors.New("PRIVATE_UPSTREAM_BODY") }, } diff --git a/main_test.go b/main_test.go index 24916ed6..1e04f0b6 100644 --- a/main_test.go +++ b/main_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" "github.com/merefield/codexometer/internal/ui" "github.com/merefield/codexometer/internal/version" ) @@ -189,7 +190,7 @@ func TestResetThresholdOption(t *testing.T) { t.Run(test.value, func(t *testing.T) { var stdout, stderr bytes.Buffer called := false - deps := dependencies{startUI: func(_ ui.Fetcher, _ time.Duration, _ bool, threshold, _ int, _ bool) error { + deps := dependencies{startUI: func(_ ui.Fetcher, _ time.Duration, _ bool, threshold, _ int, _ confirmation.Mode) error { called = true if threshold != test.want { t.Fatalf("threshold %d, want %d", threshold, test.want) @@ -214,7 +215,7 @@ func TestRunStartsDemoWithSelectedOptions(t *testing.T) { var stdout, stderr bytes.Buffer called := false deps := dependencies{ - startUI: func(fetcher ui.Fetcher, refresh time.Duration, inline bool, resetThreshold, warningHours int, _ bool) error { + startUI: func(fetcher ui.Fetcher, refresh time.Duration, inline bool, resetThreshold, warningHours int, _ confirmation.Mode) error { called = true if refresh != 30*time.Second || !inline || resetThreshold != 35 || warningHours != 72 { t.Fatalf("refresh=%s inline=%v", refresh, inline) @@ -267,7 +268,7 @@ func TestRunResetWarningHours(t *testing.T) { t.Run(test.value, func(t *testing.T) { var stdout, stderr bytes.Buffer called := false - deps := dependencies{startUI: func(_ ui.Fetcher, _ time.Duration, _ bool, _ int, hours int, _ bool) error { + deps := dependencies{startUI: func(_ ui.Fetcher, _ time.Duration, _ bool, _ int, hours int, _ confirmation.Mode) error { called = true if hours != test.want { t.Fatalf("got %d hours, want %d", hours, test.want) @@ -300,7 +301,9 @@ func sameDemoAccounting(left, right codex.LiveUsageSnapshot) bool { func TestRunReportsUIError(t *testing.T) { var stdout, stderr bytes.Buffer deps := dependencies{ - startUI: func(ui.Fetcher, time.Duration, bool, int, int, bool) error { return errors.New("terminal unavailable") }, + startUI: func(ui.Fetcher, time.Duration, bool, int, int, confirmation.Mode) error { + return errors.New("terminal unavailable") + }, } code := run(nil, &stdout, &stderr, deps) if code != 1 || !strings.Contains(stderr.String(), "terminal unavailable") { @@ -391,7 +394,7 @@ func TestRunPassesOpenAIAPIKeyToUIBenchmarks(t *testing.T) { t.Setenv("OPENAI_API_KEY", "openai-secret") var stdout, stderr bytes.Buffer deps := dependencies{ - startUI: func(fetcher ui.Fetcher, _ time.Duration, _ bool, _, _ int, _ bool) error { + startUI: func(fetcher ui.Fetcher, _ time.Duration, _ bool, _, _ int, _ confirmation.Mode) error { client, ok := fetcher.(codex.Client) if !ok || client.BenchmarkAPIKey != "openai-secret" { t.Fatalf("benchmark API key was not attached to Codex client") @@ -417,7 +420,7 @@ func TestRunPassesDigBenchTokenToUIWithoutLeavingItInEnvironment(t *testing.T) { } return []string{"P-2", "P-1", "P-2"}, nil }, - startUI: func(fetcher ui.Fetcher, _ time.Duration, _ bool, _, _ int, _ bool) error { + startUI: func(fetcher ui.Fetcher, _ time.Duration, _ bool, _, _ int, _ confirmation.Mode) error { client, ok := fetcher.(codex.Client) if !ok || client.DigBenchToken != "digbench-secret" { t.Fatalf("DigBench token was not attached to Codex client") diff --git a/main_web_test.go b/main_web_test.go index bc83c5ee..b50a06e3 100644 --- a/main_web_test.go +++ b/main_web_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/confirmation" "github.com/merefield/codexometer/internal/ui" "github.com/merefield/codexometer/internal/web" ) @@ -22,14 +23,14 @@ func TestLaunchModesAreIsolated(t *testing.T) { t.Setenv("OPENAI_API_KEY", "private-key") terminal, browser, discovery := 0, 0, 0 deps := dependencies{ - startUI: func(_ ui.Fetcher, refresh time.Duration, inline bool, threshold, hours int, _ bool) error { + startUI: func(_ ui.Fetcher, refresh time.Duration, inline bool, threshold, hours int, _ confirmation.Mode) error { terminal++ if refresh != time.Minute || inline || threshold != 80 || hours != 72 { t.Fatal("terminal defaults changed") } return nil }, - startWeb: func(source web.Source, refresh time.Duration, port int, output io.Writer, control bool, _ bool) error { + startWeb: func(source web.Source, refresh time.Duration, port int, output io.Writer, control bool, _ confirmation.Mode) error { browser++ if refresh != time.Minute || port != 54321 || control { t.Fatal("web options missing") @@ -76,7 +77,7 @@ func TestWebFlagsAndErrors(t *testing.T) { } } var out, err bytes.Buffer - deps := dependencies{startWeb: func(source web.Source, _ time.Duration, _ int, _ io.Writer, _ bool, _ bool) error { + deps := dependencies{startWeb: func(source web.Source, _ time.Duration, _ int, _ io.Writer, _ bool, _ confirmation.Mode) error { if _, ok := source.(*demoFetcher); !ok { t.Fatal("web demo not isolated") } @@ -94,7 +95,7 @@ func TestWebFlagsAndErrors(t *testing.T) { func TestWebControlExplicitOptIn(t *testing.T) { var out, err bytes.Buffer - deps := dependencies{startWeb: func(_ web.Source, _ time.Duration, _ int, _ io.Writer, control bool, _ bool) error { + deps := dependencies{startWeb: func(_ web.Source, _ time.Duration, _ int, _ io.Writer, control bool, _ confirmation.Mode) error { if !control { t.Fatal("explicit control flag lost") } @@ -105,22 +106,22 @@ func TestWebControlExplicitOptIn(t *testing.T) { } } -func TestNoConfirmFlagIsLaunchScopedAndDoesNotEnableWebWrites(t *testing.T) { +func TestConfirmationFlagIsLaunchScopedAndDoesNotEnableWebWrites(t *testing.T) { for _, browser := range []bool{false, true} { - for _, enabled := range []bool{false, true} { + for _, wanted := range []confirmation.Mode{confirmation.Balanced, confirmation.None, confirmation.Require} { seen := false deps := dependencies{ - startUI: func(_ ui.Fetcher, _ time.Duration, _ bool, _, _ int, noConfirm bool) error { + startUI: func(_ ui.Fetcher, _ time.Duration, _ bool, _, _ int, mode confirmation.Mode) error { seen = true - if browser || noConfirm != enabled { - t.Fatal("wrong terminal policy") + if browser || mode != wanted { + t.Fatal("wrong terminal policy", mode, wanted) } return nil }, - startWeb: func(_ web.Source, _ time.Duration, _ int, _ io.Writer, writable, noConfirm bool) error { + startWeb: func(_ web.Source, _ time.Duration, _ int, _ io.Writer, writable bool, mode confirmation.Mode) error { seen = true - if !browser || writable || noConfirm != enabled { - t.Fatal("no-confirm enabled web writes or lost policy") + if !browser || writable || mode != wanted { + t.Fatal("confirmation policy enabled writes or lost mode", mode, wanted) } return nil }, @@ -129,13 +130,22 @@ func TestNoConfirmFlagIsLaunchScopedAndDoesNotEnableWebWrites(t *testing.T) { if browser { args = append(args, "--web") } - if enabled { - args = append(args, "--no-confirm") + if wanted != confirmation.Balanced { + args = append(args, "--confirmation", string(wanted)) } var out, stderr bytes.Buffer if code := run(args, &out, &stderr, deps); code != 0 || !seen { - t.Fatal("confirmation flag did not reach launch", code, stderr.String()) + t.Fatal(code, stderr.String()) } } } } + +func TestInvalidConfirmationFlagsFailBeforeLaunch(t *testing.T) { + for _, args := range [][]string{{"--confirmation", "no"}, {"--confirmation", ""}, {"--no-confirm"}, {"--require-confirm"}} { + var out, stderr bytes.Buffer + if code := run(args, &out, &stderr, dependencies{}); code != 2 || stderr.Len() == 0 { + t.Fatal(args, code, stderr.String()) + } + } +} diff --git a/web/src/SessionActions.svelte b/web/src/SessionActions.svelte index 811aa01c..69f09bbc 100644 --- a/web/src/SessionActions.svelte +++ b/web/src/SessionActions.svelte @@ -1,4 +1,5 @@