From 26776f32d2f9561f6c636e27b2f6a8c215ce2a81 Mon Sep 17 00:00:00 2001 From: merefield Date: Tue, 6 Oct 2026 17:14:56 +0100 Subject: [PATCH 01/17] FEAT: schedule in-memory session follow-ups --- README.md | 40 ++ internal/schedule/queue.go | 131 +++++++ internal/schedule/queue_test.go | 142 ++++++++ internal/schedule/quota.go | 62 ++++ internal/ui/model.go | 7 + internal/ui/monitor.go | 3 + internal/ui/monitor_detail.go | 23 +- internal/ui/monitor_editor.go | 10 +- internal/ui/monitor_prompt.go | 6 + internal/ui/monitor_schedule.go | 383 ++++++++++++++++++++ internal/ui/monitor_schedule_test.go | 89 +++++ internal/ui/view.go | 3 + internal/web/control.go | 40 +- internal/web/dist/assets/index-B4Mh-Ts2.js | 37 -- internal/web/dist/assets/index-BQmnXb7B.js | 41 +++ internal/web/dist/assets/index-CjLW2fqm.css | 1 - internal/web/dist/assets/index-DdN1yutC.css | 1 + internal/web/dist/index.html | 4 +- internal/web/schedules.go | 131 +++++++ internal/web/schedules_test.go | 70 ++++ internal/web/server.go | 4 +- internal/web/state.go | 3 + intro-post.md | 2 + web/src/SessionActions.svelte | 158 +++++++- web/src/Sessions.svelte | 5 + web/src/state.svelte.ts | 3 +- web/tests/browser.spec.ts | 57 +++ 27 files changed, 1399 insertions(+), 57 deletions(-) create mode 100644 internal/schedule/queue.go create mode 100644 internal/schedule/queue_test.go create mode 100644 internal/schedule/quota.go create mode 100644 internal/ui/monitor_schedule.go create mode 100644 internal/ui/monitor_schedule_test.go delete mode 100644 internal/web/dist/assets/index-B4Mh-Ts2.js create mode 100644 internal/web/dist/assets/index-BQmnXb7B.js delete mode 100644 internal/web/dist/assets/index-CjLW2fqm.css create mode 100644 internal/web/dist/assets/index-DdN1yutC.css create mode 100644 internal/web/schedules.go create mode 100644 internal/web/schedules_test.go diff --git a/README.md b/README.md index e1821e5..66dd64d 100644 --- a/README.md +++ b/README.md @@ -2460,6 +2460,46 @@ full snapshots on reconnect. Refresh errors and disconnections are labelled; cached observations are not proof that a session is still working. Account history is hidden unless its account matches the current successful quota read. +### Scheduled session follow-ups (experimental) + +In **Sessions → full detail**, use **Ctrl+S** (or click the composer's +schedule heading) to schedule a follow-up for an idle shared app-server session. +Normal Enter-to-send remains immediate. The structured form offers **after quota +refresh**, a delay in hours/minutes, or a calendar date and local time. Use Tab to +move between fields, arrows to adjust, Page Up/Down to change calendar month, and +Enter on **Confirm schedule**. Escape returns without saving. The calendar shows +the local timezone and UTC offset; check the displayed time around daylight-saving +changes. The experimental scheduling form currently uses English labels. + +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 +mode cannot create or access scheduled prompts. Both composers have a subtle +theme-coloured background. + +- **One pending follow-up per session.** Saving another replaces it. A separate + **TRIGGER SET** signpost preserves the session's normal status and warnings. + Full detail shows the trigger; Ctrl+S opens the saved text/target/time for editing + or cancellation. Web detail provides **Edit** and **Cancel trigger** controls. +- **Memory only:** keep the Codexometer process running. Quitting, restarting or + crashing cancels its queue; it is not a durable background scheduler. Separate + Codexometer processes have separate queues. Closing a browser tab alone does + not stop the web server or its pending requests. +- Sending requires a fresh quota snapshot, the same account and an authoritative + idle follow-up capability from the connected shared app-server. Approval, + question and quota-threshold reviews are not bypassed. Closed/unavailable + sessions wait until eligible or until you cancel them. A due request can send + late after the session becomes idle or the computer resumes. +- **After quota refresh** checks actual quota recovery; reaching a predicted reset + time alone is insufficient. All reported quota windows must have capacity, with + no reported spend-control/limit block. This can conservatively wait for a bucket + unrelated to the selected model. No reset credit is redeemed automatically. + Choosing this trigger when quota is already available sends when next eligible. +- Requests follow the session's model, reasoning and speed settings at dispatch; + no temporary overrides or natural-language time parsing are provided. Sending + starts ordinary Codex work and can consume quota and run tools under that + session's permissions. An uncertain send is retained for inspection and **never + automatically retried**; check Codex before cancelling and scheduling again. + ### Optional browser session control ```sh diff --git a/internal/schedule/queue.go b/internal/schedule/queue.go new file mode 100644 index 0000000..6dc9fc6 --- /dev/null +++ b/internal/schedule/queue.go @@ -0,0 +1,131 @@ +// Package schedule owns in-memory one-off follow-ups independently of the UI. +// Closing Codexometer cancels pending work. Uncertain dispatch is never retried. +package schedule + +import ( + "context" + "crypto/rand" + "errors" + "github.com/merefield/codexometer/internal/codex" + "strings" + "sync" + "time" +) + +type Job struct { + ID string `json:"id"` + Session string `json:"session"` + Text string `json:"text"` + Trigger string `json:"trigger"` // at or quota + At time.Time `json:"at,omitempty"` + Zone string `json:"zone"` + Status string `json:"status"` // pending, sending, sent, uncertain + Windows []string `json:"-"` // Observed windows must not silently disappear. + account string +} + +type Queue struct { + mu sync.Mutex + jobs []Job +} + +func New() *Queue { return &Queue{} } +func (q *Queue) List(session string) []Job { + q.mu.Lock() + defer q.mu.Unlock() + out := []Job{} + for _, j := range q.jobs { + if session == "" || j.Session == session { + j.Windows = append([]string(nil), j.Windows...) + out = append(out, j) + } + } + return out +} + +func (q *Queue) Save(j Job, account string, now time.Time) error { + j.Text = strings.TrimSpace(j.Text) + if account == "" || j.Session == "" || len(j.Session) > 512 || j.Text == "" || len([]rune(j.Text)) > 4096 || len(j.Zone) > 128 || codex.SanitizeSessionContext(j.Text) != j.Text || (j.Trigger == "quota" && !j.At.IsZero()) || + (j.Trigger != "at" && j.Trigger != "quota") || (j.Trigger == "at" && (!j.At.After(now) || j.At.After(now.AddDate(1, 0, 0)))) { + return errors.New("choose a live session, a message and a future time within one year, or quota recovery") + } + q.mu.Lock() + defer q.mu.Unlock() + index := -1 + for i, v := range q.jobs { + if v.Session == j.Session { + if v.Status == "sending" || v.Status == "uncertain" { + return errors.New("check the previous send in Codex before cancelling or replacing it") + } + index = i + j.ID = v.ID + break + } + } + j.Status = "pending" + j.Windows = append([]string(nil), j.Windows...) + j.account = account + j.At = j.At.UTC() + if index >= 0 { + q.jobs[index] = j + } else { + if len(q.jobs) >= 128 { + return errors.New("schedule limit reached; remove old entries first") + } + j.ID = rand.Text() + q.jobs = append(q.jobs, j) + } + return nil +} + +func (q *Queue) Cancel(session, id string) error { + q.mu.Lock() + defer q.mu.Unlock() + for i, j := range q.jobs { + if j.Session != session || j.ID != id { + continue + } + if j.Status == "sending" { + return errors.New("send in progress; check Codex") + } + q.jobs = append(q.jobs[:i], q.jobs[i+1:]...) + return nil + } + return errors.New("schedule changed; refresh") +} + +// Dispatch is called only after the UI adapter has checked freshness, session +// readiness and pending reviews. Claim sending before network IO. This is +// intentionally at-most-one attempt, not a claim of exactly-once delivery. +func (q *Queue) Dispatch(ctx context.Context, id, account string, quotaReady bool, now time.Time, send func(context.Context, Job) error) error { + q.mu.Lock() + index := -1 + for i, j := range q.jobs { + if j.ID == id && j.Status == "pending" && account != "" && j.account == account && + ((j.Trigger == "at" && !now.Before(j.At)) || (j.Trigger == "quota" && quotaReady)) { + index = i + break + } + } + if index < 0 { + q.mu.Unlock() + return nil + } + j := q.jobs[index] + q.jobs[index].Status = "sending" + q.mu.Unlock() + err := send(ctx, j) + q.mu.Lock() + defer q.mu.Unlock() + for i, v := range q.jobs { + if v.ID == id { + index = i + break + } + } + q.jobs[index].Status = "sent" + if err != nil { + q.jobs[index].Status = "uncertain" + } + return err +} diff --git a/internal/schedule/queue_test.go b/internal/schedule/queue_test.go new file mode 100644 index 0000000..1e7bbf1 --- /dev/null +++ b/internal/schedule/queue_test.go @@ -0,0 +1,142 @@ +package schedule + +import ( + "context" + "errors" + "github.com/merefield/codexometer/internal/codex" + "sync" + "sync/atomic" + "testing" + "time" +) + +func TestQueueGuardsAndSingleAttempt(t *testing.T) { + now := time.Now() + q := New() + j := Job{Session: "root", Text: "hello", Trigger: "at", At: now.Add(time.Minute)} + if err := q.Save(j, "account", now); err != nil { + t.Fatal(err) + } + id := q.List("root")[0].ID + var calls atomic.Int32 + send := func(context.Context, Job) error { calls.Add(1); return errors.New("lost connection") } + for _, tc := range []struct { + account string + at time.Time + }{{"other", now.Add(time.Hour)}, {"account", now}} { + _ = q.Dispatch(context.Background(), id, tc.account, true, tc.at, send) + } + if calls.Load() != 0 { + t.Fatal("premature dispatch") + } + var wg sync.WaitGroup + for range 20 { + wg.Go(func() { _ = q.Dispatch(context.Background(), id, "account", true, now.Add(time.Hour), send) }) + } + wg.Wait() + if calls.Load() != 1 || q.List("root")[0].Status != "uncertain" { + t.Fatal("must attempt once and retain uncertain outcome") + } + if q.Save(j, "account", now) == nil { + t.Fatal("replaced uncertain send") + } + if q.Cancel("other", id) == nil { + t.Fatal("cancelled wrong session") + } + if err := q.Cancel("root", id); err != nil { + t.Fatal(err) + } + if len(q.List("")) != 0 { + t.Fatal("not cancelled") + } +} + +func TestQueueReplaceQuotaCancelAndMemory(t *testing.T) { + now := time.Now() + q := New() + j := Job{Session: "root", Text: "one", Trigger: "quota"} + if err := q.Save(j, "account", now); err != nil { + t.Fatal(err) + } + id := q.List("")[0].ID + j.Text = "two" + if err := q.Save(j, "account", now); err != nil { + t.Fatal(err) + } + if len(q.List("")) != 1 || q.List("")[0].ID != id { + t.Fatal("replacement duplicated job") + } + calls := 0 + send := func(_ context.Context, j Job) error { + calls++ + if j.Text != "two" { + t.Fatal(j.Text) + } + return nil + } + _ = q.Dispatch(context.Background(), id, "account", false, now, send) + if calls != 0 { + t.Fatal("quota not ready") + } + _ = q.Dispatch(context.Background(), id, "account", true, now, send) + _ = q.Dispatch(context.Background(), id, "account", true, now, send) + if calls != 1 { + t.Fatal(calls) + } + if len(New().List("")) != 0 { + t.Fatal("persisted queue") + } + if err := q.Save(j, "account", now); err != nil { + t.Fatal(err) + } + if len(q.List("")) != 1 { + t.Fatal("sent records accumulated") + } +} + +func TestQuotaReadiness(t *testing.T) { + now := time.Now() + s := codex.Snapshot{AccountFingerprint: "a", FetchedAt: now, RateLimits: codex.RateLimitSnapshot{Primary: &codex.Window{UsedPercent: 10}}} + if !QuotaReady(s, now) { + t.Fatal("ready quota rejected") + } + s.RateLimits.Primary.UsedPercent = 100 + if QuotaReady(s, now) { + t.Fatal("exhausted quota accepted") + } + s.RateLimits.Primary.UsedPercent = 0 + if QuotaReady(s, now.Add(91*time.Second)) || QuotaReady(s, now.Add(-time.Second)) { + t.Fatal("stale/future snapshot") + } + flag := true + s.RateLimits.SpendControlReached = &flag + if QuotaReady(s, now) { + t.Fatal("spend control ignored") + } + s.RateLimits.SpendControlReached = nil + s.RateLimits.Primary = nil + if QuotaReady(s, now) { + t.Fatal("missing windows accepted") + } +} + +func TestInvalidJobs(t *testing.T) { + now := time.Now() + for _, j := range []Job{{Session: "s", Text: "hi", Trigger: "at", At: now.Add(-time.Minute)}, {Session: "s", Text: "\x1b[31mhello", Trigger: "quota"}, {Session: "s", Text: "hi", Trigger: "quota", At: now}, {Session: "s", Trigger: "quota"}} { + if New().Save(j, "a", now) == nil { + t.Fatalf("accepted %+v", j) + } + } +} + +func TestMissingWindowIsNotRecovery(t *testing.T) { + s := codex.Snapshot{RateLimits: codex.RateLimitSnapshot{Primary: &codex.Window{UsedPercent: 100}}} + j := Job{Windows: WindowKeys(s)} + if !Covers(j, s) { + t.Fatal("same window rejected") + } + s.RateLimits.Primary = nil + if Covers(j, s) { + t.Fatal("missing exhausted window treated as recovered") + } +} diff --git a/internal/schedule/quota.go b/internal/schedule/quota.go new file mode 100644 index 0000000..819fd15 --- /dev/null +++ b/internal/schedule/quota.go @@ -0,0 +1,62 @@ +package schedule + +import ( + "fmt" + "github.com/merefield/codexometer/internal/codex" + "slices" + "time" +) + +func WindowKeys(s codex.Snapshot) []string { + var keys []string + for _, m := range s.Meters() { + keys = append(keys, fmt.Sprintf("%s/%d/%s", m.LimitID, m.Kind, m.Name)) + } + return keys +} + +// Missing data is not evidence that an exhausted window recovered. +func Covers(j Job, s codex.Snapshot) bool { + keys := WindowKeys(s) + for _, k := range j.Windows { + if !slices.Contains(keys, k) { + return false + } + } + return true +} + +// Until Codex exposes authoritative model-to-bucket applicability, waiting for +// every reported limit is conservative: never assume an exhausted bucket is +// irrelevant. No inference, reset redemption, or timestamp-only release. +func QuotaReady(s codex.Snapshot, now time.Time) bool { + if !Fresh(s, now) { + return false + } + meters := s.Meters() + if len(meters) == 0 { + return false + } + for _, m := range meters { + if m.Window.UsedPercent < 0 || m.Window.UsedPercent >= 100 { + return false + } + } + buckets := s.RateLimitsByLimitID + if len(buckets) == 0 { + buckets = map[string]codex.RateLimitSnapshot{"codex": s.RateLimits} + } + for _, b := range buckets { + if b.SpendControlReached != nil && *b.SpendControlReached { + return false + } + if b.RateLimitReachedType != nil && *b.RateLimitReachedType != "" { + return false + } + } + return true +} + +func Fresh(s codex.Snapshot, now time.Time) bool { + return s.AccountFingerprint != "" && !s.FetchedAt.IsZero() && !now.Before(s.FetchedAt) && now.Sub(s.FetchedAt) <= 90*time.Second +} diff --git a/internal/ui/model.go b/internal/ui/model.go index caa4a4a..0acd1a0 100644 --- a/internal/ui/model.go +++ b/internal/ui/model.go @@ -44,6 +44,7 @@ type BenchmarkTaskProvider interface { } type Model struct { + scheduleUI scheduleUI monitorPrompt monitorPromptState monitorContextHidden bool monitorContextDetail string @@ -459,6 +460,11 @@ func (m Model) Init() tea.Cmd { } func (m Model) Update(message tea.Msg) (tea.Model, tea.Cmd) { + if next, cmd, handled := m.updateSchedule(message); handled { + return next, cmd + } else { + m = next + } if next, cmd, handled := m.updateMonitorPrompt(message); handled { return next, cmd } else { @@ -1073,6 +1079,7 @@ func (m Model) Update(message tea.Msg) (tea.Model, tea.Cmd) { } m.phase++ commands := []tea.Cmd{secondTick()} + commands = append(commands, m.dispatchSchedules()) if m.monitorState == monitorRunning { now := time.Time(message) if !m.monitorNextSample.IsZero() && !now.Before(m.monitorNextSample) { diff --git a/internal/ui/monitor.go b/internal/ui/monitor.go index 513f810..e6c0873 100644 --- a/internal/ui/monitor.go +++ b/internal/ui/monitor.go @@ -312,6 +312,9 @@ func (m Model) renderMonitorSessionMetrics(width, height int, session monitorSes bodyRows := max(height-2, 1) share := m.monitorSessionShare(total) usageLine := i18n.Format("%s TOKENS // %.0f%% LOCAL", formatTokens(total), share*100) + if m.hasSchedule(session.id) { + usageLine = "TRIGGER SET // " + usageLine + } lines := make([]string, 0, bodyRows) badge := m.renderMonitorSessionBadge(session, innerWidth, colors) if badge != "" { diff --git a/internal/ui/monitor_detail.go b/internal/ui/monitor_detail.go index 8f2fcda..caeb1b2 100644 --- a/internal/ui/monitor_detail.go +++ b/internal/ui/monitor_detail.go @@ -31,8 +31,29 @@ func (line detailLine) render(colors palette) string { // A single document owns both display and scroll geometry. Formatting never // changes the stored request, capability or text sent back to Codex. -func (m Model) contextDetailDocument(width int) []detailLine { +func (m Model) contextDetailDocument(width int) (document []detailLine) { width = max(width, 1) + defer func() { + if !m.hasSchedule(m.monitorContextDetail) { + return + } + var header []detailLine + for _, j := range m.scheduleUI.queue.List(m.monitorContextDetail) { + if j.Status == "sent" { + continue + } + text := "TRIGGER SET // Ctrl+S: view / edit / cancel // " + j.Status + if j.Trigger == "at" { + text += " // " + j.At.Local().Format("02 Jan 15:04 MST") + } else { + text += " // after quota recovery" + } + for _, line := range strings.Split(ansi.Hardwrap(text, width, true), "\n") { + header = append(header, detailLine{ansi.Truncate(line, width, ""), "heading"}) + } + } + document = append(append(header, detailLine{}), document...) + }() s, ok := m.contextDetailSession() if !ok { return []detailLine{{i18n.Text("NO CONTEXT"), "metadata"}} diff --git a/internal/ui/monitor_editor.go b/internal/ui/monitor_editor.go index c761d5d..e6c90e0 100644 --- a/internal/ui/monitor_editor.go +++ b/internal/ui/monitor_editor.go @@ -4,6 +4,7 @@ import ( "charm.land/bubbles/v2/textarea" "charm.land/bubbles/v2/textinput" tea "charm.land/bubbletea/v2" + "image/color" ) // The textarea owns wrapping and cursor scrolling. Password questions keep @@ -129,9 +130,14 @@ func (e monitorEditor) View(colors palette) string { return e.password.View() } s := e.area.Styles() - s.Focused.Text = colors.label() + pr, pg, pb, _ := colors.primary.RGBA() + br, bg, bb, _ := colors.background.RGBA() + tint := color.RGBA{uint8((pr + br*9) / 10 >> 8), uint8((pg + bg*9) / 10 >> 8), uint8((pb + bb*9) / 10 >> 8), 255} + s.Focused.Base = s.Focused.Base.Background(tint) + s.Blurred.Base = s.Blurred.Base.Background(tint) + s.Focused.Text = colors.label().Background(tint) s.Focused.Prompt = colors.label().Foreground(colors.primary) - s.Focused.CursorLine = colors.label() + s.Focused.CursorLine = colors.label().Background(tint) s.Cursor.Color = colors.primary e.area.SetStyles(s) return e.area.View() diff --git a/internal/ui/monitor_prompt.go b/internal/ui/monitor_prompt.go index 3034f17..e800612 100644 --- a/internal/ui/monitor_prompt.go +++ b/internal/ui/monitor_prompt.go @@ -147,6 +147,12 @@ func (m Model) renderMonitorPrompt(width, height int, colors palette) string { p := m.monitorPrompt o := m.monitorPromptOffer() header := i18n.Text("FOLLOW-UP") + " // " + terminalLabel(o.ThreadID) + if m.monitorContextDetail != "" && len(o.Questions) == 0 { + header += " // [ Ctrl+S: SCHEDULE ]" + if m.hasSchedule(m.monitorContextDetail) { + header = "TRIGGER SET // [ Ctrl+S: VIEW / EDIT / CANCEL ]" + } + } if len(o.Questions) > 0 { n := 0 if p.offer.Token == o.Token { diff --git a/internal/ui/monitor_schedule.go b/internal/ui/monitor_schedule.go new file mode 100644 index 0000000..e05ed1e --- /dev/null +++ b/internal/ui/monitor_schedule.go @@ -0,0 +1,383 @@ +package ui + +import ( + "context" + "fmt" + "strconv" + "strings" + "time" + + tea "charm.land/bubbletea/v2" + "github.com/charmbracelet/x/ansi" + "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/schedule" +) + +type scheduleUI struct { + queue *schedule.Queue + open, polling bool + session, id, notice string + input monitorEditor + mode, focus, hours, minutes int + date time.Time +} +type scheduleDone struct{} + +func (m Model) hasSchedule(id string) bool { + if m.scheduleUI.queue == nil { + return false + } + for _, j := range m.scheduleUI.queue.List(id) { + if j.Status != "sent" { + return true + } + } + return false +} + +func (m *Model) openSchedule() tea.Cmd { + if m.meterView != viewMonitor || m.monitorContextDetail == "" { + return nil + } + id := m.monitorContextDetail + o := m.monitorPromptOffer() + if !m.hasSchedule(id) && (o.Token == "" || o.ThreadID != id || len(o.Questions) > 0) { + return nil + } + q := m.scheduleUI.queue + if q == nil { + q = schedule.New() + } + p := scheduleUI{queue: q, polling: m.scheduleUI.polling, open: true, session: id, input: newMonitorEditor(), hours: 1, date: time.Now().Add(time.Hour).Truncate(time.Minute)} + if m.monitorPrompt.session == id { + p.input.SetValue(m.monitorPrompt.input.Value()) + } + for _, j := range q.List(id) { + if j.Status == "sent" { + continue + } + p.id = j.ID + p.input.SetValue(j.Text) + p.notice = "Status: " + j.Status + if j.Trigger == "quota" { + p.mode = 0 + } else { + p.mode = 2 + p.date = j.At.Local() + } + break + } + if p.id == "" && schedule.QuotaReady(m.snapshot, time.Now()) { + p.mode = 1 + } + m.scheduleUI = p + m.monitorPrompt.input.Blur() + return m.scheduleUI.input.Focus() +} + +func (m *Model) dispatchSchedules() tea.Cmd { + q := m.scheduleUI.queue + client, ok := m.fetcher.(codex.SessionPromptClient) + if q == nil || !ok || m.scheduleUI.polling || m.err != nil || m.monitorError != "" || !schedule.QuotaReady(m.snapshot, time.Now()) { + return nil + } + // Do not compete with a draft, manual confirmation or profile transition. + if m.scheduleUI.open || m.monitorPrompt.input.Focused() || m.monitorPrompt.busy || m.quota.busySession != "" { + return nil + } + ready := map[string]bool{} + for _, s := range m.monitorSessionData { + _, pending := m.quotaSessionCandidate(s) + if !pending && s.preview.Kind != codex.SessionContextApproval && s.preview.Kind != codex.SessionContextQuestion { + ready[s.id] = true + } + } + account := m.snapshot.AccountFingerprint + snapshot := m.snapshot + m.scheduleUI.polling = true + return func() tea.Msg { + for _, j := range q.List("") { + if !ready[j.Session] || j.Status != "pending" || !schedule.Covers(j, snapshot) || !schedule.Fresh(snapshot, time.Now()) { + continue + } + o := client.SessionPrompt(j.Session) + if o.Token == "" || o.ThreadID != j.Session || len(o.Questions) > 0 { + continue + } + ctx, cancel := context.WithTimeout(context.Background(), 6*time.Second) + _ = q.Dispatch(ctx, j.ID, account, true, time.Now(), func(ctx context.Context, j schedule.Job) error { + return client.SendSessionPrompt(ctx, o.Token, []string{j.Text}) + }) + cancel() + } + return scheduleDone{} + } +} + +func (m Model) updateSchedule(msg tea.Msg) (Model, tea.Cmd, bool) { + if _, ok := msg.(scheduleDone); ok { + m.scheduleUI.polling = false + return m, nil, true + } + key, isKey := msg.(tea.KeyPressMsg) + if m.scheduleUI.open && isKey && key.String() == "ctrl+c" { + return m, tea.Quit, true + } + if !m.scheduleUI.open { + if isKey && key.String() == "ctrl+s" && m.monitorContextDetail != "" { + cmd := m.openSchedule() + return m, cmd, true + } + // The full-detail composer heading is a dedicated schedule click surface. + if click, ok := msg.(tea.MouseClickMsg); ok && click.Button == tea.MouseLeft && m.monitorContextDetail != "" { + g := m.monitorDashboardLayout() + rows := m.monitorPromptRows(g.contentWidth, g.meterHeight) + _, _, y := monitorContextBodyLayout(g.meterHeight, rows) + if rows > 0 && click.Y == g.meterY+y && click.X >= 4 && click.X < g.contentWidth { + cmd := m.openSchedule() + return m, cmd, true + } + } + return m, nil, false + } + p := &m.scheduleUI + p.input.configure(max(m.width-4, 20), 11) + if size, ok := msg.(tea.WindowSizeMsg); ok { + m.width = size.Width + m.height = size.Height + return m, nil, true + } + if isKey && (key.String() == "esc" || key.String() == "ctrl+s") { + p.open = false + p.input.Blur() + return m, nil, true + } + if m.width < 48 || m.height < 24 { + if _, mouse := msg.(tea.MouseMsg); isKey || mouse { + return m, nil, true + } + return m, nil, false + } + if click, ok := msg.(tea.MouseClickMsg); ok { + if click.Button != tea.MouseLeft { + return m, nil, true + } + switch { + case click.Y >= 3 && click.Y <= 5: + p.focus = 0 + return m, p.input.Focus(), true + case click.Y == 7 && click.X >= 2 && click.X < 44: + p.focus = 1 + if click.X < 25 { + p.mode = 0 + } else if click.X < 35 { + p.mode = 1 + } else { + p.mode = 2 + } + case click.Y == 9: + p.focus = 2 + case click.Y == 18: + if click.X < 22 { + p.focus = 3 + } else { + p.focus = 4 + } + case click.Y == 22 && click.X >= 2 && click.X < 46: + if click.X < 21 { + p.focus = 5 + isKey = true + key = tea.KeyPressMsg{Code: tea.KeyEnter} + } else if click.X >= 25 { + p.focus = 6 + isKey = true + key = tea.KeyPressMsg{Code: tea.KeyEnter} + } + case p.mode == 2 && click.Y >= 11 && click.Y <= 16 && click.X >= 2 && click.X < 30: + first := time.Date(p.date.Year(), p.date.Month(), 1, 0, 0, 0, 0, p.date.Location()) + d := (click.Y-11)*7 + (click.X-2)/4 - int(first.Weekday()) + 1 + if d >= 1 && d <= time.Date(p.date.Year(), p.date.Month()+1, 0, 0, 0, 0, 0, p.date.Location()).Day() { + p.date = time.Date(p.date.Year(), p.date.Month(), d, p.date.Hour(), p.date.Minute(), 0, 0, p.date.Location()) + p.focus = 2 + } + } + p.input.Blur() + if !isKey { + return m, nil, true + } + } + if isKey { + switch key.String() { + case "tab", "shift+tab": + d := 1 + if key.String() == "shift+tab" { + d = 6 + } + p.focus = (p.focus + d) % 7 + p.input.Blur() + if p.focus == 0 { + return m, p.input.Focus(), true + } + return m, nil, true + case "enter": + if p.focus == 5 { + o := m.monitorPromptOffer() + if o.Token == "" || o.ThreadID != p.session || len(o.Questions) > 0 || m.err != nil || !schedule.Fresh(m.snapshot, time.Now()) { + p.notice = "Session unavailable or changed; review in Codex." + return m, nil, true + } + j := schedule.Job{Session: p.session, Text: p.input.Value(), Trigger: "quota", Zone: time.Now().Location().String(), Windows: schedule.WindowKeys(m.snapshot)} + if p.mode == 1 { + j.Trigger = "at" + j.At = time.Now().Add(time.Duration(p.hours)*time.Hour + time.Duration(p.minutes)*time.Minute) + } + if p.mode == 2 { + j.Trigger = "at" + j.At = p.date + } + if codex.SanitizeSessionContext(j.Text) != strings.TrimSpace(j.Text) { + p.notice = "Remove terminal control characters." + return m, nil, true + } + if err := p.queue.Save(j, m.snapshot.AccountFingerprint, time.Now()); err != nil { + p.notice = err.Error() + } else { + p.open = false + p.input.Reset() + m.monitorPrompt.input.Reset() + } + } else if p.focus == 6 { + if p.id != "" { + if err := p.queue.Cancel(p.session, p.id); err != nil { + p.notice = err.Error() + return m, nil, true + } + } + p.open = false + } + return m, nil, true + case "left", "right", "up", "down", "pgup", "pgdown": + if p.focus != 0 { + d := 1 + if key.String() == "left" || key.String() == "down" || key.String() == "pgup" { + d = -1 + } + switch p.focus { + case 1: + p.mode = (p.mode + d + 3) % 3 + case 2: + if p.mode == 1 { + p.hours = max(0, min(8760, p.hours+d)) + } else if p.mode == 2 { + if key.String() == "pgup" || key.String() == "pgdown" { + p.date = time.Date(p.date.Year(), p.date.Month()+time.Month(d), 1, p.date.Hour(), p.date.Minute(), 0, 0, p.date.Location()) + } else { + if key.String() == "up" { + d = -7 + } + if key.String() == "down" { + d = 7 + } + p.date = p.date.AddDate(0, 0, d) + } + } + case 3: + if p.mode == 1 { + p.minutes = (p.minutes + d + 60) % 60 + } else { + p.date = p.date.Add(time.Duration(d) * time.Hour) + } + case 4: + if p.mode == 2 { + p.date = p.date.Add(time.Duration(d) * time.Minute) + } + } + return m, nil, true + } + } + } + if p.focus == 0 { + var cmd tea.Cmd + p.input, cmd = p.input.Update(msg) + if isKey { + return m, cmd, true + } + if _, ok := msg.(tea.PasteMsg); ok { + return m, cmd, true + } + } + if isKey { + return m, nil, true + } + return m, nil, false +} + +func (m Model) renderScheduleForm() string { + p := m.scheduleUI + c := paletteFor(m.theme) + if m.width < 48 || m.height < 24 { + return "Scheduling needs 48 columns × 24 rows. Resize or Esc to return." + } + lines := make([]string, 24) + lines[0] = "SCHEDULE FOLLOW-UP // " + terminalLabel(p.session) + lines[1] = "In memory only • closing Codexometer cancels this trigger" + p.input.configure(m.width-4, 11) + for i, s := range strings.Split(p.input.View(c), "\n") { + if i < 3 { + lines[3+i] = s + } + } + control := func(label string, focus int) string { + if p.focus == focus { + return c.label().Foreground(c.primary).Reverse(true).Render(label) + } + return c.label().Render(label) + } + mode := []string{"AFTER QUOTA REFRESH", "IN…", "AT…"} + for i, s := range mode { + mode[i] = fmt.Sprintf("%-9s", "[ "+s+" ]") + if p.mode == i { + mode[i] = c.label().Foreground(c.primary).Bold(true).Render(mode[i]) + } + } + lines[7] = strings.Join(mode, " ") + if p.mode == 1 { + lines[9] = control(fmt.Sprintf("Hours: %d", p.hours), 2) + lines[18] = control(fmt.Sprintf("Minutes: %02d", p.minutes), 3) + } + if p.mode == 2 { + lines[9] = control(p.date.Format("January 2006")+" // PgUp/PgDn", 2) + lines[10] = "Su Mo Tu We Th Fr Sa" + first := time.Date(p.date.Year(), p.date.Month(), 1, 0, 0, 0, 0, p.date.Location()) + end := first.AddDate(0, 1, -1).Day() + for row := 0; row < 6; row++ { + for col := 0; col < 7; col++ { + d := row*7 + col - int(first.Weekday()) + 1 + s := " " + if d >= 1 && d <= end { + s = fmt.Sprintf("%2d ", d) + if d == p.date.Day() { + s = c.label().Foreground(c.primary).Reverse(true).Render(fmt.Sprintf("%2d", d)) + " " + } + } + lines[11+row] += s + } + } + lines[18] = control("Hour: "+p.date.Format("15"), 3) + " " + control("Minute: "+p.date.Format("04"), 4) + } + summary := "When fresh quota is available and this session is idle" + if p.mode == 1 { + summary = "In " + strconv.Itoa(p.hours) + "h " + strconv.Itoa(p.minutes) + "m, when idle" + } + if p.mode == 2 { + summary = p.date.Format("Mon 02 Jan 2006 15:04 MST -07:00") + " • when idle" + } + lines[20] = summary + " // Follow session model / reasoning / speed" + lines[21] = "Tab: next field • arrows: adjust • Enter: selected action • Esc: back" + lines[22] = control("[ CONFIRM SCHEDULE ]", 5) + " " + control("[ CANCEL / BACK ]", 6) + lines[23] = p.notice + for i, s := range lines { + lines[i] = " " + ansi.Truncate(s, max(m.width-4, 1), "…") + } + return strings.Join(lines, "\n") +} diff --git a/internal/ui/monitor_schedule_test.go b/internal/ui/monitor_schedule_test.go new file mode 100644 index 0000000..28b1901 --- /dev/null +++ b/internal/ui/monitor_schedule_test.go @@ -0,0 +1,89 @@ +package ui + +import ( + tea "charm.land/bubbletea/v2" + "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/schedule" + "strings" + "testing" + "time" +) + +func TestScheduleFormSaveSignpostAndCancel(t *testing.T) { + m, c := promptTestModel() + m.width = 100 + m.height = 40 + m.snapshot = codex.Snapshot{AccountFingerprint: "a", FetchedAt: time.Now(), RateLimits: codex.RateLimitSnapshot{Primary: &codex.Window{UsedPercent: 100}}} + m.openSchedule() + if !m.scheduleUI.open { + t.Fatal("form unavailable") + } + m.scheduleUI.input.SetValue("Do this later") + m.scheduleUI.focus = 5 + m, _, _ = m.updateSchedule(tea.KeyPressMsg{Code: tea.KeyEnter}) + if m.scheduleUI.open || !m.hasSchedule("root-one") || c.answers != nil { + t.Fatal("save sent immediately or lost schedule") + } + if !strings.Contains(m.renderMonitorContextDetail(100, 30, paletteFor(m.theme)), "TRIGGER SET") { + t.Fatal("missing signpost") + } + if cmd := m.dispatchSchedules(); cmd != nil { + t.Fatal("dispatch despite exhausted quota") + } + m.openSchedule() + m.scheduleUI.focus = 6 + m, _, _ = m.updateSchedule(tea.KeyPressMsg{Code: tea.KeyEnter}) + if m.hasSchedule("root-one") { + t.Fatal("cancel failed") + } +} + +func TestScheduleDispatchAndBusyGuard(t *testing.T) { + m, c := promptTestModel() + m.monitorPrompt.input.Blur() + m.snapshot = codex.Snapshot{AccountFingerprint: "a", FetchedAt: time.Now(), RateLimits: codex.RateLimitSnapshot{Primary: &codex.Window{UsedPercent: 10}}} + m.scheduleUI.queue = schedule.New() + if err := m.scheduleUI.queue.Save(schedule.Job{Session: "root-one", Text: "hello", Trigger: "quota"}, "a", time.Now()); err != nil { + t.Fatal(err) + } + m.scheduleUI.open = true + if m.dispatchSchedules() != nil { + t.Fatal("competed with editor") + } + m.scheduleUI.open = false + cmd := m.dispatchSchedules() + if cmd == nil { + t.Fatal("missing dispatch") + } + cmd() + if len(c.answers) != 1 || c.answers[0] != "hello" { + t.Fatal(c.answers) + } + if m.hasSchedule("root-one") { + t.Fatal("sent job still pending") + } +} + +func TestScheduleMouseSurfacesAndCalendar(t *testing.T) { + m, _ := promptTestModel() + m.width = 100 + m.height = 40 + m.openSchedule() + for _, tc := range []struct{ x, mode int }{{3, 0}, {26, 1}, {36, 2}} { + m, _, _ = m.updateSchedule(tea.MouseClickMsg{X: tc.x, Y: 7, Button: tea.MouseLeft}) + if m.scheduleUI.mode != tc.mode { + t.Fatal("wrong trigger click", tc) + } + } + m.scheduleUI.date = time.Date(2026, time.January, 31, 12, 0, 0, 0, time.UTC) + m.scheduleUI.focus = 2 + m, _, _ = m.updateSchedule(tea.KeyPressMsg{Code: tea.KeyPgDown}) + if m.scheduleUI.date.Month() != time.February { + t.Fatal("calendar skipped February") + } + m.width = 30 + _, _, handled := m.updateSchedule(tea.MouseClickMsg{X: 3, Y: 7, Button: tea.MouseLeft}) + if !handled { + t.Fatal("short terminal passed click to underlying screen") + } +} diff --git a/internal/ui/view.go b/internal/ui/view.go index f21e862..fe9519a 100644 --- a/internal/ui/view.go +++ b/internal/ui/view.go @@ -24,6 +24,9 @@ func (m Model) View() tea.View { } func (m Model) render() string { + if m.scheduleUI.open { + return m.renderScheduleForm() + } colors := paletteFor(m.theme) layout := m.dashboardLayout() contentWidth := layout.contentWidth diff --git a/internal/web/control.go b/internal/web/control.go index 80866db..30df038 100644 --- a/internal/web/control.go +++ b/internal/web/control.go @@ -16,12 +16,14 @@ import ( "time" "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/schedule" ) // Control capabilities never enter the shared snapshot. A keyed offer digest // binds the browser's selection to the exact source request without disclosing // Codex tokens. One pending confirmation bounds memory (including secret input). type control struct { + schedules *schedule.Queue profiles *profileControl mu sync.Mutex store *store @@ -68,12 +70,14 @@ type offeredAction struct { } type actionRequest struct { - Review string `json:"review,omitempty"` - Session string `json:"session"` - Offer string `json:"offer"` - Choice *int `json:"choice,omitempty"` - Answers []string `json:"answers,omitempty"` - Confirmation string `json:"confirmation,omitempty"` + Schedule *scheduleRule `json:"schedule,omitempty"` + CancelID string `json:"cancelId,omitempty"` + Review string `json:"review,omitempty"` + Session string `json:"session"` + Offer string `json:"offer"` + Choice *int `json:"choice,omitempty"` + Answers []string `json:"answers,omitempty"` + Confirmation string `json:"confirmation,omitempty"` } type preparedAction struct { @@ -83,7 +87,7 @@ type preparedAction struct { } func newControl(source Source, store *store) *control { - c := &control{store: store, key: rand.Text()} + c := &control{store: store, key: rand.Text(), schedules: schedule.New()} c.approvals, _ = source.(codex.SessionApprovalClient) c.prompts, _ = source.(codex.SessionPromptClient) c.profiles = newProfileControl(source) @@ -156,6 +160,12 @@ func (c *control) offer(id string) (offeredAction, error) { } func validAction(o offeredAction, r actionRequest) bool { + if r.CancelID != "" { + return false + } + if r.Schedule != nil && (o.Kind != "prompt" || len(o.Questions) > 0 || !r.Schedule.valid(time.Now())) { + return false + } if o.ID == "" || o.ID != r.Offer { return false } @@ -200,6 +210,10 @@ func (c *control) handle(action, origin string) http.HandlerFunc { http.Error(w, "Invalid request", 400) return } + if action == "schedules" { + c.handleSchedules(w, r, body) + return + } c.mu.Lock() if c.pending != nil && !time.Now().Before(c.pending.until) { c.pending = nil @@ -266,6 +280,18 @@ func (c *control) handle(action, origin string) http.HandlerFunc { err = c.commitProfile(ctx, o, *body.Choice) } else if o.Kind == "approval" { err = c.approvals.RespondSessionApproval(ctx, o.token, o.decisions[*body.Choice]) + } else if body.Schedule != nil { + q := c.scheduleSnapshot() + if !schedule.Fresh(q, time.Now()) || c.scheduleBlocked(body.Session) { + http.Error(w, errUnavailable.Error(), 409) + return + } + err = c.schedules.Save(schedule.Job{Session: body.Session, Text: body.Answers[0], Trigger: body.Schedule.Trigger, At: body.Schedule.At, Zone: body.Schedule.Zone, Windows: schedule.WindowKeys(q)}, q.AccountFingerprint, time.Now()) + if err != nil { + http.Error(w, err.Error(), 409) + return + } + c.publishSchedules() } else { err = c.prompts.SendSessionPrompt(ctx, o.token, body.Answers) } diff --git a/internal/web/dist/assets/index-B4Mh-Ts2.js b/internal/web/dist/assets/index-B4Mh-Ts2.js deleted file mode 100644 index 0a9c49e..0000000 --- a/internal/web/dist/assets/index-B4Mh-Ts2.js +++ /dev/null @@ -1,37 +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,ee=32768,C=1<<25,w=65536,T=1<<19,te=1<<20,E=1<<25,ne=1<<21,re=1<<22,ie=1<<23,D=Symbol(`$state`),ae=Symbol(`component`),oe=Symbol(`legacy props`),se=Symbol(``),ce=Symbol(`attributes`),le=Symbol(`class`),ue=Symbol(`style`),de=Symbol(`text`),fe=Symbol(`form reset`),pe=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},me=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`),he={},ge=Symbol(`uninitialized`),_e=`http://www.w3.org/1999/xhtml`;function ve(){console.warn(`https://svelte.dev/e/derived_inert`)}function ye(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function be(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function xe(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var O=!1;function Se(e){O=e}var k;function Ce(e){if(e===null)throw ye(),he;return k=e}function we(){return Ce(cn(k))}function A(e){if(O){if(cn(k)!==null)throw ye(),he;k=e}}function Te(e=1){if(O){for(var t=e,n=k;t--;)n=cn(n);k=n}}function Ee(e=!0){for(var t=0,n=k;;){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=cn(n);e&&n.remove(),n=i}}function De(e){if(!e||e.nodeType!==8)throw ye(),he;return e.data}function Oe(e){return e===this.v}function ke(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Ae(e){return!ke(e,this.v)}function je(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function Me(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function Ne(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function Pe(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Fe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Ie(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Le(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Re(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function ze(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Be(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Ve(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function He(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var Ue=!1;function We(){Ue=!0}var j=null;function Ge(e){j=e}function Ke(e,t=!1,n){j={p:j,i:!1,c:null,e:null,s:e,x:null,r:U,l:Ue&&!t?{s:null,u:null,$:[]}:null}}function qe(e){var t=j,n=t.e;if(n!==null){t.e=null;for(var r of n)xn(r)}return e!==void 0&&(t.x=e),t.i=!0,j=t.p,Je(e)}function Je(e={}){return i(e,ae,{value:!0}),e}function Ye(){return!Ue||j!==null&&j.l===null}var Xe=[];function Ze(){var e=Xe;Xe=[],m(e)}function Qe(e){if(Xe.length===0&&!Tt){var t=Xe;queueMicrotask(()=>{t===Xe&&Ze()})}Xe.push(e)}function $e(){for(;Xe.length>0;)Ze()}var et=~(y|b|v);function M(e,t){e.f=e.f&et|t}function tt(e){e.f&512||e.deps===null?M(e,v):M(e,b)}function nt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),M(e,v)}function rt(e){O&&sn(e)!==null&&ln(e)}var it=!1;function at(){it||(it=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[fe]?.()})},{capture:!0}))}function ot(e){var t=H,n=U;Gn(null),Kn(null);try{return e()}finally{Gn(t),Kn(n)}}function st(e,t,n,r=n){e.addEventListener(t,()=>ot(n));let i=e[fe];e[fe]=i?()=>{i(),r(!0)}:()=>r(!0),at()}function ct(e,t,n,r){let i=Ye()?ft:ht;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=U,c=lt(),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){mn(e,s)}ut()}}var d=dt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>mt(e))).then(u).catch(e=>mn(e,s)).finally(d)}l?l.then(()=>{c(),f(),ut()}):f()}function lt(){var e=U,t=H,n=j,r=P;return function(i=!0){Kn(e),Gn(t),Ge(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function ut(e=!0){Kn(null),Gn(null),Ge(null),e&&P?.deactivate()}function dt(){var e=U,t=e.b,n=P,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 ft(e){var t=2|y;return U!==null&&(U.f|=T),{ctx:j,deps:null,effects:null,equals:Oe,f:t,fn:e,reactions:null,rv:0,v:ge,wv:0,parent:U,ac:null}}var pt=Symbol(`obsolete`);function mt(e,t,n){let r=U;r===null&&Me();var i=void 0,a=Ht(ge),o=!H,s=new Set;return Tn(()=>{var t=U,n=h();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==pe&&n.reject(e)}).finally(ut)}catch(e){n.reject(e),ut()}var c=P;if(o){if(t.f&32768)var l=dt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(pt);else for(let e of s.values())e.reject(pt);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==pt&&(c.activate(),t?(a.f|=ie,Kt(a,t)):(a.f&8388608&&(a.f^=ie),Kt(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),yn(()=>{for(let e of s)e.reject(pt)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function N(e){let t=ft(e);return Jn(t),t}function ht(e){let t=ft(e);return t.equals=Ae,t}function gt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(pe),t.ac=null}),t.fn!==null&&(t.teardown=f),lr(t,0),An(t))}function bt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&ur(t)}var xt=null,P=null,St=null,Ct=null,wt=null,Tt=!1,Et=!1,Dt=null,Ot=null,kt=0,At=1,jt=class e{id=At++;#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(){xt===null?xt=this:(xt.#n=this,this.#t=xt),xt=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)M(r,y),t(r);for(r of n.m)M(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),M(e,y),this.schedule(e);for(let e of this.#d)M(e,b),this.schedule(e);this.apply();for(var t=Dt=[],n=[],r=Ot=[];this.#c.length>0;){kt++>1e3&&(this.#S(),Nt());for(let e of this.#g())try{this.#v(e,t,n)}catch(t){throw Rt(e),this.#h()||this.discard(),t}}if(P=null,r.length>0){var i=e.ensure();for(let e of r)i.schedule(e)}if(Dt=null,Ot=null,this.#h()){this.#x(n),this.#x(t);for(let[e,t]of this.#f)Lt(e,t);r.length>0&&P.#_();return}let a=this.#y();if(a){this.#x(n),this.#x(t),a.#b(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),St=this,Ft(n),Ft(t),St=null,this.#s?.resolve();var o=P;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&&(Bt.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):ir(r)&&(i&16&&this.#d.add(r),ur(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),M(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),P=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(P===null){let t=P=new e;!Et&&!Tt&&Qe(()=>{t.#e||t.flush()})}return P}apply(){Ct=null}schedule(e){if(wt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}this.#c.push(e)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?xt=e:t.#t=e,this.linked=!1}}};function Mt(e){var t=Tt;Tt=!0;try{var n;for(e&&(P!==null&&!P.is_fork&&P.flush(),n=e());;){if($e(),P===null)return n;P.flush()}}finally{Tt=t}}function Nt(){try{Le()}catch(e){mn(e,wt)}}var Pt=null;function Ft(e){var t=e.length;if(t!==0){for(var n=0;n0)){Bt.clear();for(let e of Pt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Pt.has(n)&&(Pt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||ur(n)}}Pt.clear()}}Pt=null}}function It(e){P.schedule(e)}function Lt(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),M(e,v);for(var n=e.first;n!==null;)Lt(n,t),n=n.next}}function Rt(e){M(e,v);for(var t=e.first;t!==null;)Rt(t),t=t.next}var zt=new Set,Bt=new Map,Vt=!1;function Ht(e,t){return{f:0,v:e,reactions:null,equals:Oe,rv:0,wv:0}}function F(e,t){let n=Ht(e,t);return Jn(n),n}function Ut(e,t=!1,n=!0){let r=Ht(e);return t||(r.equals=Ae),Ue&&n&&j!==null&&j.l!==null&&(j.l.s??=[]).push(r),r}function I(e,t,n=!1){return H!==null&&(!Wn||H.f&131072)&&Ye()&&H.f&4325394&&(qn===null||!qn.has(e))&&Ve(),Kt(e,n?Zt(t):t,Ot)}var Wt=null,Gt=0;function Kt(e,t,n=null){if(!e.equals(t)){Hn?Bt.set(e,t):Bt.has(e)||Bt.set(e,e.v);var r=jt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&_t(t),Ct===null&&tt(t)}e.wv=rr(),Wt=null,Gt=0,Xt(e,y,n),Wt=null,Ye()&&U!==null&&U.f&1024&&!(U.f&96)&&(Zn===null?Qn([e]):Zn.push(e)),!r.is_fork&&zt.size>0&&!Vt&&qt()}return t}function qt(){Vt=!1;for(let e of zt){e.f&1024&&M(e,b);let t;try{t=ir(e)}catch{t=!0}t&&ur(e)}zt.clear()}function Jt(e,t=1){var n=W(e),r=t===1?n++:n--;return I(e,n),r}function Yt(e){I(e,e.v+1)}function Xt(e,t,n){var r=e.reactions;if(r!==null){var i=Ye(),a=r.length;if(Gt+=a,Gt>1e5&&Wt===null&&(Wt=new Set),Wt!==null){if(Wt.has(e))return;Wt.add(e)}for(var o=0;o{if(tr===d)return e();var t=H,n=tr;Gn(null),nr(d);var r=e();return Gn(t),nr(n),r};return i&&r.set(`length`,F(t.length,u)),new Proxy(t,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&ze();var i=r.get(t);return i===void 0?f(()=>{var e=F(n.value,u);return r.set(t,e),e}):I(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>F(ge,u));r.set(t,e),Yt(o)}}else I(n,ge),Yt(o);return!0},get(e,n,i){if(n===D)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>F(Zt(s?e[n]:ge),u)),r.set(n,o)),o!==void 0){var c=W(o);return c===ge?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=W(i);if(a===ge)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===D)return!0;var n=r.get(t),i=n!==void 0&&n.v!==ge||Reflect.has(e,t);return(n!==void 0||U!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>F(i?Zt(e[t]):ge,u)),r.set(t,n)),W(n)===ge)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dF(ge,u)),r.set(d+``,p)):I(p,ge)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>F(void 0,u)),I(c,Zt(n)),r.set(t,c));else{l=c.v!==ge;var m=f(()=>Zt(n));I(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&&I(g,_+1)}Yt(o)}return!0},ownKeys(e){W(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==ge});for(var[n,i]of r)i.v!==ge&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Be()}})}function Qt(e){try{if(typeof e==`object`&&e&&D in e)return e[D]}catch{}return e}function $t(e,t){return Object.is(Qt(e),Qt(t))}var en,tn,nn,rn;function an(){if(en===void 0){en=window,tn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;nn=a(t,`firstChild`).get,rn=a(t,`nextSibling`).get,u(e)&&(e[le]=void 0,e[ce]=null,e[ue]=void 0,e.__e=void 0),u(n)&&(n[de]=void 0)}}function on(e=``){return document.createTextNode(e)}function sn(e){return nn.call(e)}function cn(e){return rn.call(e)}function L(e,t){if(!O)return sn(e);var n=sn(k);if(n===null)n=k.appendChild(on());else if(t&&n.nodeType!==3){var r=on();return n?.before(r),Ce(r),r}return t&&fn(n),Ce(n),n}function R(e,t=!1){if(!O){var n=sn(e);return n instanceof Comment&&n.data===``?cn(n):n}if(t){if(k?.nodeType!==3){var r=on();return k?.before(r),Ce(r),r}fn(k)}return k}function z(e,t=!1){if(!O)return sn(e);var n=L(e,t);return A(e),n}function B(e,t=1,n=!1){let r=O?k:e;for(var i;t--;)i=r,r=cn(r);if(!O)return r;if(n){if(r?.nodeType!==3){var a=on();return r===null?i?.after(a):r.before(a),Ce(a),a}fn(r)}return Ce(r),r}function ln(e){e.textContent=``}function un(){return!1}function dn(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 fn(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 pn(e){var t=U;if(t===null)return H.f|=ie,e;if(!(t.f&32768)&&!(t.f&4))throw e;mn(e,t)}function mn(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 hn(e){U===null&&(H===null&&Ie(e),Fe()),Hn&&Pe(e)}function gn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function _n(e,t){var n=U;n!==null&&n.f&8192&&(e|=x);var r={ctx:j,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};P?.register_created_effect(r);var i=r;if(e&4)Dt===null?jt.ensure().schedule(r):Dt.push(r);else if(t!==null){try{ur(r)}catch(e){throw Mn(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|=w))}if(i!==null&&(i.parent=n,n!==null&&gn(i,n),H!==null&&H.f&2&&!(e&64))){var a=H;(a.effects??=[]).push(i)}return r}function vn(){return H!==null&&!Wn}function yn(e){let t=_n(8,null);return M(t,v),t.teardown=e,t}function bn(e){hn(`$effect`);var t=U.f;if(!H&&t&32&&j!==null&&!j.i){var n=j;(n.e??=[]).push(e)}else return xn(e)}function xn(e){return _n(4|te,e)}function Sn(e){return hn(`$effect.pre`),_n(8|te,e)}function Cn(e){jt.ensure();let t=_n(64|T,e);return(e={})=>new Promise(n=>{e.outro?Fn(t,()=>{Mn(t),n(void 0)}):(Mn(t),n(void 0))})}function wn(e){return _n(4,e)}function Tn(e){return _n(re|T,e)}function En(e,t=0){return _n(8|t,e)}function V(e,t=[],n=[],r=[]){ct(r,t,n,t=>{_n(8,()=>{e(...t.map(W))})})}function Dn(e,t=0){return _n(16|t,e)}function On(e){return _n(32|T,e)}function kn(e){var t=e.teardown;if(t!==null){let n=Hn,r=H;Un(!0),Gn(null);try{t.call(null)}catch(t){mn(t,e.parent)}finally{Un(n),Gn(r)}}}function An(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&ot(()=>{e.abort(pe)});var r=n.next;n.f&64?n.parent=null:Mn(n,t),n=r}}function jn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Mn(t),t=n}}function Mn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Nn(e.nodes.start,e.nodes.end),n=!0),e.f|=C,An(e,t&&!n),lr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();kn(e),e.f^=C,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Pn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Nn(e,t){for(;e!==null;){var n=e===t?null:cn(e);e.remove(),e=n}}function Pn(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 Fn(e,t,n=!0){var r=[];e.f|=256,In(e,r,!0);var i=()=>{n&&Mn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function In(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);In(i,t,o?n:!1)}i=a}}}function Ln(e){e.f&=-257,Rn(e,!0)}function Rn(e,t){if(!(e.f&256)&&e.f&8192){e.f^=x,e.f&1024||(M(e,y),jt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=!!(n.f&65536)||!!(n.f&32);Rn(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 zn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:cn(n);t.append(n),n=i}}var Bn=null,Vn=!1,Hn=!1;function Un(e){Hn=e}var H=null,Wn=!1;function Gn(e){H=e}var U=null;function Kn(e){U=e}var qn=null;function Jn(e){H!==null&&(H.f&2097152||H.f&2)&&(qn??=new Set).add(e)}var Yn=null,Xn=0,Zn=null;function Qn(e){Zn=e}var $n=1,er=0,tr=er;function nr(e){tr=e}function rr(){return++$n}function ir(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&&Ct===null&&M(e,v)}return!1}function ar(e,t,n=!0){var r=e.reactions;if(r!==null&&!(qn!==null&&qn.has(e)))for(var i=0;i{e.ac.abort(pe)}),e.ac=null);try{e.f|=ne;var u=e.fn,d=u();e.f|=ee;var f=sr(e);if(Ye()&&Zn!==null&&!Wn&&f!==null&&!(e.f&6146))for(var p=0;p0)for(t.length=Xn+Yn.length,r=0;r{s.ac.abort(pe),s.ac=null,M(s,y)}),yt(s),lr(s,0)}}function lr(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,Qe(()=>{i.__removed||t.addEventListener(e,i,r)})):t.addEventListener(e,i,r),i}function Cr(e,t,n,r,i){var a={capture:r,passive:i},o=Sr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&yn(()=>{o.__removed=!0,t.removeEventListener(e,o,a)})}function G(e,t,n){(t[yr]??={})[e]=n}function wr(e){for(var t=0;t{Er=!1,Tr=null}));var s=0,c=Tr===e&&e[yr];if(c){var l=a.indexOf(c);if(l!==-1&&(t===document||t===window)){e[yr]=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=H,f=U;Gn(null),Kn(null);try{for(var p,m=[];o!==null&&o!==t;){try{var h=o[yr]?.[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[yr]=t,delete e.currentTarget,Gn(d),Kn(f)}}}var Or=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function kr(e){return Or?.createHTML(e)??e}function Ar(e){var t=dn(`template`);return t.innerHTML=kr(e.replaceAll(``,``)),t.content}function jr(e,t){var n=U;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function K(e,t){var n=!!(t&1),r=!!(t&2),i,a=!e.startsWith(``);return()=>{if(O)return jr(k,null),k;i===void 0&&(i=Ar(a?e:``+e),n||(i=sn(i)));var t=r||tn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=sn(t),s=t.lastChild;jr(o,s)}else jr(t,t);return t}}function Mr(e,t,n=`svg`){var r=!e.startsWith(``),i=!!(t&1),a=`<${n}>${r?e:``+e}`,o;return()=>{if(O)return jr(k,null),k;if(!o){var e=sn(Ar(a));if(i)for(o=document.createDocumentFragment();sn(e);)o.appendChild(sn(e));else o=sn(e)}var t=o.cloneNode(!0);if(i){var n=sn(t),r=t.lastChild;jr(n,r)}else jr(t,t);return t}}function Nr(e,t){return Mr(e,t,`svg`)}function Pr(e=``){if(!O){var t=on(e+``);return jr(t,t),t}var n=k;return n.nodeType===3?fn(n):(n.before(n=on()),Ce(n)),jr(n,n),n}function Fr(){if(O)return jr(k,null),k;var e=document.createDocumentFragment(),t=document.createComment(``),n=on();return e.append(t,n),jr(t,n),e}function q(e,t){if(O){var n=U;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=k),we();return}e!==null&&e.before(t)}function Ir(){if(O&&k&&k.nodeType===8&&k.textContent?.startsWith(`$`)){let e=k.textContent.substring(1);return we(),e}return(window.__svelte??={}).uid??=1,`c${window.__svelte.uid++}`}function Lr(e){let t=0,n=Ht(0),r;return()=>{vn()&&(W(n),En(()=>(t===0&&(r=mr(()=>e(()=>Yt(n)))),t+=1,()=>{Qe(()=>{--t,t===0&&(r?.(),r=void 0,Yt(n))})})))}}var Rr=w|T;function zr(e,t,n,r){new Br(e,t,n,r)}var Br=class{parent;is_pending=!1;transform_error;#e;#t=O?k: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=Lr(()=>(this.#m=Ht(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=U;t.b=this,t.f|=128,n(e)},this.parent=U.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Dn(()=>{if(O){let e=this.#t;we();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()},Rr),O&&(this.#e=k)}#g(){try{this.#a=On(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed,{reset:n,invoke_onerror:r}=this.#v(e);Qe(r),t&&(this.#s=On(()=>{t(this.#e,()=>e,()=>n)}))}#v(e){var t=!1,n=!1;let r=()=>{if(t){xe();return}t=!0,n&&He(),this.#s!==null&&Fn(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){mn(e,this.#i&&this.#i.parent)}}}}#y(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=On(()=>e(this.#e)),Qe(()=>{var e=this.#c=document.createDocumentFragment(),t=on(),n=!1;if(e.append(t),this.#a=this.#S(()=>{try{return On(()=>this.#r(t))}catch(e){try{this.error(e),n=!0}catch(e){mn(e,this.#i.parent)}return null}}),this.#a===null){this.#c=null,n&&this.#x(P);return}this.#u===0&&(this.#e.before(e),this.#c=null,Fn(this.#o,()=>{this.#o=null}),this.#x(P))}))}#b(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=On(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();zn(this.#a,e);let t=this.#n.pending;this.#o=On(()=>t(this.#e))}else this.#x(P)}catch(e){this.error(e)}}#x(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){nt(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=U,n=H,r=j;Kn(this.#i),Gn(this.#i),Ge(this.#i.ctx);try{return jt.ensure(),e()}finally{Kn(t),Gn(n),Ge(r)}}#C(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#C(e,t);return}this.#u+=e,this.#u===0&&(this.#x(t),this.#o&&Fn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#C(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,Qe(()=>{this.#d=!1,this.#m&&Kt(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),W(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;P?.is_fork?(this.#a&&P.skip_effect(this.#a),this.#o&&P.skip_effect(this.#o),this.#s&&P.skip_effect(this.#s),P.oncommit(()=>{this.#w(e)})):this.#w(e)}#w(e){this.#a&&=(Mn(this.#a),null),this.#o&&=(Mn(this.#o),null),this.#s&&=(Mn(this.#s),null),O&&(Ce(this.#t),Te(),Ce(Ee()));let t=this.#n.failed,n=e=>{let{reset:n,invoke_onerror:r}=this.#v(e);r(),t&&(this.#s=this.#S(()=>{try{return On(()=>{var r=U;r.b=this,r.f|=128,t(this.#e,()=>e,()=>n)})}catch(e){return mn(e,this.#i.parent),null}}))};Qe(()=>{var t;try{t=this.transform_error(e)}catch(e){mn(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(n,e=>mn(e,this.#i&&this.#i.parent)):n(t)})}};function J(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[de]??=e.nodeValue)&&(e[de]=n,e.nodeValue=`${n}`)}function Vr(e,t){return Ur(e,t)}var Hr=new Map;function Ur(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){an();var l=void 0,u=Cn(()=>{var s=n??t.appendChild(on());zr(s,{pending:()=>{}},t=>{Ke({});var n=j;if(o&&(n.c=o),a&&(i.$$events=a),O&&jr(t,null),l=e(t,i)||Je(),O&&(U.nodes.end=k,k===null||k.nodeType!==8||k.data!==`]`))throw ye(),he;qe()},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=Hr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Dr),r.delete(e),r.size===0&&Hr.delete(n)):r.set(e,i)}xr.delete(d),s!==n&&s.parentNode?.removeChild(s)}});return Wr.set(l,u),l}var Wr=new WeakMap,Gr=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)Ln(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Ln(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&&(Mn(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();zn(r,t),t.append(on()),this.#n.set(e,{effect:r,fragment:t})}else Mn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Fn(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)||(Mn(n.effect),this.#n.delete(e))};ensure(e,t){var n=P,r=un();if(t&&!this.#t.has(e)&&!this.#n.has(e)){if(r){var i=document.createDocumentFragment(),a=on();i.append(a),this.#n.set(e,{effect:On(()=>t(a)),fragment:i})}else this.#t.set(e,On(()=>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 O&&(this.anchor=k),this.#a(n)}};function Y(e,t,n=!1){var r;O&&(r=k,we());var i=new Gr(e),a=n?w:0;function o(e,t){if(O){var n=De(r);if(e!==parseInt(n.substring(1))){var a=Ee();Ce(a),i.anchor=a,Se(!1),i.ensure(e,t),Se(!0);return}}i.ensure(e,t)}Dn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var Kr=Symbol(`NaN`);function qr(e,t,n){O&&we();var r=new Gr(e),i=!Ye();Dn(()=>{var e=t();e!==e&&(e=Kr),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function X(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;ln(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^=E,ei(d,null,c)):Ln(d):Fn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Dn(()=>{p=W(f);var e=p.length;let t=!1;O&&De(c)===`[!`!=(e===0)&&(c=Ee(),Ce(c),Se(!1),t=!0);for(var r=new Set,u=P,v=un(),y=0;ys(c)):(d=On(()=>s(Xr??=on())),d.f|=E)),e>r.size&&Ne(``,``,``),O&&e>0&&Ce(Ee()),!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&&Se(!0),W(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,O&&(c=k)}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 T=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?Ht(n):Ut(n,!1,!1):null,l=o&2?Ht(i):null;return{v:c,i:l,e:On(()=>(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=cn(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;O&&(r=k,we());var i=new Gr(e);Dn(()=>{var e=t()??null;if(O&&De(r)===`[`!=(e!==null)){var a=Ee();Ce(a),i.anchor=a,Se(!1),i.ensure(e,e&&(t=>n(t,e))),Se(!0);return}i.ensure(e,e&&(t=>n(t,e)))},w)}var ri=[...` -\r\f\xA0\v`];function ii(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||ri.includes(r[o-1]))&&(s===r.length||ri.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function ai(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 oi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function si(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(oi)),i&&c.push(...Object.keys(i).map(oi));var l=0,u=-1;let t=e.length;for(var d=0;d{t.every(_i)||(`__defaultValue`in e&&fi(e,!1),`__value`in e&&pi(e,e.__value))});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),yn(()=>{t.disconnect()})}function hi(e,t,n=t){var r=new WeakSet,i=!0;st(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),gi);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&gi(o)}n(a),e.__value=a,P!==null&&r.add(P)}),wn(()=>{var a=t();if(e===document.activeElement){var o=P;if(r.has(o))return}if(pi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=gi(s),n(a))}e.__value=a,i=!1})}function gi(e){return`__value`in e?e.__value:e.value}function _i(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 vi=Symbol(`is custom element`),yi=Symbol(`is html`),bi=me?`link`:`LINK`;function xi(e){if(O){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[fe]=n,Qe(n),at()}}function Q(e,t,n,r){var i=Si(e);O&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===bi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[se]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&wi(e).has(t)?e[t]=n:e.setAttribute(t,n))}function Si(e){return e[ce]??={[vi]:e.nodeName.includes(`-`),[yi]:e.namespaceURI===_e}}var Ci=new Map;function wi(e){var t=e.getAttribute(`is`)||e.nodeName,n=Ci.get(t);if(n)return n;Ci.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 Ti(e,t,n=t){var r=new WeakSet;st(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=ki(e)?Ai(a):a,n(a),P!==null&&r.add(P),await dr(),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))}}}),(O&&e.defaultValue!==e.value||mr(t)==null&&e.value)&&(n(ki(e)?Ai(e.value):e.value),P!==null&&r.add(P)),En(()=>{var n=t();if(e===document.activeElement){var i=P;if(r.has(i))return}ki(e)&&n===Ai(e.value)||(e.type!==`date`||n||e.value)&&n!==e.value&&(e.value=n??``)})}var Ei=new Set;function Di(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),st(n,`change`,()=>{var e=n.__value;a&&(e=Oi(o,e,n.checked)),i(e)},()=>i(a?[]:null)),En(()=>{var e=r();if(O&&n.defaultChecked!==n.checked){s=!0;return}a?(e||=[],n.checked=e.includes(n.__value)):n.checked=$t(n.__value,e)}),yn(()=>{var e=o.indexOf(n);e!==-1&&o.splice(e,1)}),Ei.has(o)||(Ei.add(o),Qe(()=>{o.sort((e,t)=>e.compareDocumentPosition(t)===4?-1:1),Ei.delete(o)})),Qe(()=>{if(s){var e=a?Oi(o,e,n.checked):o.find(e=>e.checked)?.__value;i(e)}})}function Oi(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 Mi(e,t,n){var r=ji.observe(e,()=>n(e[t]));wn(()=>(mr(()=>n(e[t])),r))}function Ni(e,t,n,r,i){var a=()=>{r(n[e])};n.addEventListener(t,a),i?En(()=>{n[e]=i()}):a(),(n===document.body||n===window||n===document)&&yn(()=>{n.removeEventListener(t,a)})}function Pi(e=!1){let t=j,n=t.l.u;if(!n)return;let r=()=>hr(t.s);if(e){let e=0,n={},i=ft(()=>{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=()=>W(i)}n.b.length&&Sn(()=>{Fi(t,r),m(n.b)}),bn(()=>{let e=mr(()=>n.m.map(p));return()=>{for(let t of e)typeof t==`function`&&t()}}),n.a.length&&bn(()=>{Fi(t,r),m(n.a)})}function Fi(e,t){if(e.l.s)for(let t of e.l.s)W(t);t()}var Ii=!1;function Li(e){var t=Ii;try{return Ii=!1,[e(),Ii]}finally{Ii=t}}var Ri={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===D||t===oe)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 zi(...e){return new Proxy({props:e},Ri)}function Bi(e,t,n,r){var i=!Ue||!!(n&2),o=!!(n&8),s=!!(n&16),c=r,l=!0,u=void 0,d=()=>s&&i?(u??=ft(r),W(u)):(l&&(l=!1,c=s?mr(r):r),c);let f;if(o){var p=D in e||oe in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=Li(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&Re(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?ft:ht)(()=>(v=!1,g()));o&&W(y);var b=U;return(function(e,t){if(arguments.length>0){let n=t?W(y):i&&o?Zt(e):e;return I(y,n),v=!0,c!==void 0&&(c=n),e}return Hn&&v||b.f&16384?y.v:W(y)})}function Vi(e){j===null&&je(`onMount`),Ue&&j.l!==null?Hi(j).m.push(e):bn(()=>{let t=mr(e);if(typeof t==`function`)return t})}function Hi(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);function Ui(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 Wi=new class{#e=F(Gi());get _loc(){return W(this.#e)}set _loc(e){I(this.#e,e)}#t=N(()=>this._loc.location);get _location(){return W(this.#t)}set _location(e){I(this.#t,e)}#n=N(()=>this._loc.querystring);get _querystring(){return W(this.#n)}set _querystring(e){I(this.#n,e)}#r=F(void 0);get _params(){return W(this.#r)}set _params(e){I(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=Gi()}):console.warn(`[svelte-spa-router] window 'window' is not defined, skipping initiation`)}};function Gi(){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}}function Ki(e){e?window.scrollTo(e.__svelte_spa_router_scrollX||0,e.__svelte_spa_router_scrollY||0):window.scrollTo(0,0)}function qi(e,t){Ke(t,!0);let n=Bi(t,`routes`,19,()=>({})),r=Bi(t,`prefix`,3,``),i=Bi(t,`restoreScrollState`,3,!1),a=Bi(t,`onConditionsFailed`,3,()=>{}),o=Bi(t,`onRouteLoaded`,3,()=>{}),s=Bi(t,`onRouteLoading`,3,()=>{}),c=Bi(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=Ui(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=F(null),f=F(null),p=F({}),m=null,h=null;bn(()=>{history.scrollRestoration=i()?`manual`:`auto`}),bn(()=>{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 dr(),e(t)}bn(()=>{let e=Wi.loc,t=!1;return mr(async()=>{let n=0;for(;n{t=!0}});function _(e){return e&&typeof e==`object`&&Object.keys(e).length?e:null}var v=Fr(),y=R(v),b=e=>{let t=N(()=>W(d));var n=Fr(),r=R(n),i=e=>{var n=Fr();ni(R(n),()=>W(t),(e,t)=>{t(e,zi({get params(){return W(f)},get onRouteEvent(){return c()}},()=>W(p)))}),q(e,n)},a=e=>{var n=Fr();ni(R(n),()=>W(t),(e,t)=>{t(e,zi({get onRouteEvent(){return c()}},()=>W(p)))}),q(e,n)};Y(r,e=>{W(f)?e(i):e(a,-1)}),q(e,n)};Y(y,e=>{W(d)&&e(b)}),q(e,v),qe()}var Ji=[`bars`,`pace`,`zone`,`pie`,`fuel`,`resets`,`thresholds`],Yi=`codexometer.web.preferences.v1`,Xi={tab:`quota`,view:`bars`,selected:``,defaultDetail:0,layouts:[]};function Zi(){try{let e=JSON.parse(localStorage.getItem(Yi)||`null`);return!e||typeof e!=`object`?Xi:{tab:[`quota`,`sessions`,`usage`].includes(e.tab)?e.tab:`quota`,view:Ji.includes(e.view)?e.view:`bars`,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 Xi}}var Qi=Zt(Zi());function $i(){let e=JSON.stringify(Qi);try{localStorage.setItem(Yi,e)}catch{}}function ea(){return Qi.tab===`quota`?`/quota/`+Qi.view:`/`+Qi.tab}function ta(e){return Qi.layouts.find(t=>t.id===e)?.level??Qi.defaultDetail}function na(e){Qi.defaultDetail=e,Qi.layouts=[]}function ra(e,t){Qi.layouts=[...Qi.layouts.filter(t=>t.id!==e),{id:e,level:Math.max(0,Math.min(2,t))}].slice(-100)}var $=Zt({data:null,connected:!1,error:``}),ia=e=>e==null?`Unavailable`:e.toLocaleString(`en-GB`),aa=e=>!e||String(e).startsWith(`0001-`)?`Not yet available`:new Date(typeof e==`number`?e*1e3:e).toLocaleString(`en-GB`),oa=`codexometer.web.session`,sa=class extends Error{},ca;async function la(e,t,n){if(!ca||!$.connected||!$.data?.control||$.data.sessionsError)throw Error(`Session controls unavailable. Check the live connection.`);return await ca(e,t,n)}function ua(){let e=new AbortController,t,n=``;ca=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 sa(`Action rejected, expired or changed. Refresh and check Codex; nothing was retried.`);return a.json()};try{n=sessionStorage.getItem(oa)||``}catch{}let r=location.hash,i=r.startsWith(`#pair=`)?r.slice(6):``;(i||!r||r===`#`)&&(history.replaceState(null,``,`/#`+ea()),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(oa,n)}catch{}}catch(t){e.signal.aborted||($.error=t instanceof Error?t.message:`Pairing failed`);return}if(!n){$.error=`Open the private pairing link printed by codexometer --web in your terminal.`;return}await o()}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(oa)}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(),()=>{ca=void 0,e.abort(),clearTimeout(t),$.connected=!1}}We();var da=K(`

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

`),fa=K(`

`),pa=K(`

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),ma=K(`

No threshold-based model steps were configured at launch.

`);function ha(e,t){Ke(t,!1),Pi();var n=Fr(),r=R(n),i=e=>{var t=pa(),n=R(t),r=z(n),i=B(n,2),a=e=>{q(e,da())};Y(i,e=>{$.data.quotaError&&e(a)});var o=B(i,2),s=L(o),c=z(s),l=B(s,4);Z(l,5,()=>$.data.thresholds,X,(e,t)=>{var n=fa();let r;var i=L(n),a=z(i),o=B(i,2),s=L(o),c=z(s,!0),l=z(B(s,2));A(o);var u=B(o,2),d=z(u,!0),f=z(B(u,2));A(n),V((e,i)=>{r=ci(n,1,``,null,r,{active:W(t).state===`ACTIVE`,next:W(t).state===`NEXT`}),J(a,`${W(t).threshold??``}%`),J(c,W(t).model),J(l,`${e??``} REASONING // ${i??``} - SPEED`),J(d,W(t).mode),J(f,`${W(t).state??``}${W(t).state===`NEXT`?` // ${W(t).remaining||0} PP TO GO`:``}`)},[()=>W(t).effort.toUpperCase(),()=>W(t).speed.toUpperCase()]),q(e,n)}),A(l),A(o),V(e=>{J(r,`MODEL STEP POLICY // OBSERVED ${e??``}`),J(c,`THRESHOLDS // ${$.data.thresholds.length??``} CONFIGURED`)},[()=>aa($.data.quotaAt)]),q(e,t)},a=e=>{q(e,ma())};Y(r,e=>{$.data?.thresholds?.length?e(i):e(a,-1)}),q(e,n),qe()}var ga=Nr(` `,1),_a=Nr(` `,1),va=K(` `),ya=K(`
Quota observations
Observed atPeriod elapsedConsumedTrail segment
`),ba=K(`


Observed quota - path, not individual session usage. Gaps are not interpolated. Expand the - observation table for times, positions and gaps.

OBSERVATION TABLE
`,1),xa=K(`
CONSUMPTIONQUOTA PERIOD ELAPSED


`,1);function Sa(e,t){let n=Ir();Ke(t,!0);let r=Bi(t,`trail`,19,()=>[]),i=F(!1),a=[0,25,50,75,100],o=F(400),s=F(240),c=N(()=>W(o)-24),l=N(()=>W(s)-48),u=N(()=>Math.max(1,W(c)-48)),d=N(()=>Math.max(1,W(l)-20)),f=N(()=>48+Math.max(0,Math.min(100,t.elapsed))/100*W(u)),p=N(()=>W(l)-Math.max(0,Math.min(100,t.used))/100*W(d)),m=N(()=>t.used-t.elapsed),h=N(()=>r().map((e,t)=>`${t===0||e.break?`M`:`L`}${48+e.elapsed/100*W(u)} ${W(l)-e.used/100*W(d)}`).join(` `));var g=xa(),_=R(g),v=L(_),y=L(v),b=z(y),x=B(y),S=B(x);Z(S,17,()=>a,X,(e,t)=>{var n=ga(),r=R(n),i=B(r),a=B(i),o=z(a),s=B(a),f=z(s);V(()=>{Q(r,`x1`,48+W(t)/100*W(u)),Q(r,`x2`,48+W(t)/100*W(u)),Q(r,`y2`,W(l)),Q(i,`y1`,W(l)-W(t)/100*W(d)),Q(i,`x2`,W(c)),Q(i,`y2`,W(l)-W(t)/100*W(d)),Q(a,`x`,48+W(t)/100*W(u)),Q(a,`y`,W(l)+20),J(o,`${W(t)??``}%`),Q(s,`y`,W(l)+4-W(t)/100*W(d)),J(f,`${W(t)??``}%`)}),q(e,n)});var ee=B(S),C=B(ee),w=B(C),T=e=>{var t=_a(),n=R(t),i=B(n),a=z(L(i));A(i),V(e=>{Q(n,`d`,W(h)),Q(i,`cx`,48+r()[0].elapsed/100*W(u)),Q(i,`cy`,W(l)-r()[0].used/100*W(d)),J(a,`First observation: ${e??``}`)},[()=>aa(r()[0].at)]),q(e,t)};Y(w,e=>{r().length&&e(T)});var te=B(w,2),E=B(te),ne=B(E),re=z(L(ne));A(ne),A(v),A(_);var ie=B(_,2),D=L(ie),ae=z(B(D,3),!0);A(ie);var oe=B(ie,2),se=e=>{var t=ba(),a=R(t),o=L(a);Te(2),A(a);var s=B(a,2),c=B(L(s),2),l=e=>{var t=ya(),n=L(t),i=B(L(n),2);Z(i,21,r,X,(e,t,n)=>{var r=va(),i=L(r),a=L(i),o=z(a,!0);A(i);var s=B(i),c=z(s),l=B(s),u=z(l),d=z(B(l),!0);A(r),V((e,r)=>{Q(a,`datetime`,W(t).at),J(o,e),J(c,`${r??``}%`),J(u,`${W(t).used??``}%`),J(d,n===0?`First observation`:W(t).break?`Gap before this observation`:`Connected to previous observation`)},[()=>aa(W(t).at),()=>W(t).elapsed.toFixed(1)]),q(e,r)}),A(i),A(n),A(t),q(e,t)};Y(c,e=>{W(i)&&e(l)}),A(s),V(e=>{Q(a,`id`,n+`-trail-summary`),J(o,`○ START ${e??``} // ${r().length??``} - ${r().length===1?`OBSERVATION`:`OBSERVATIONS`}`)},[()=>aa(r()[0].at)]),Ni(`open`,`toggle`,s,e=>I(i,e),()=>W(i)),q(e,t)};Y(oe,e=>{r().length&&e(se)}),V((e,i,a,m)=>{Q(v,`viewBox`,`0 0 ${W(o)} ${W(s)}`),Q(v,`aria-describedby`,r().length?n+`-trail-summary`:void 0),Q(v,`aria-label`,e),Q(b,`id`,n),Q(x,`width`,W(u)),Q(x,`height`,W(d)),Q(x,`fill`,`url(#${n})`),Q(ee,`d`,`M48 20 V${W(l)} H${W(c)}`),Q(C,`y1`,W(l)),Q(C,`x2`,W(c)),Q(te,`x`,48+W(u)/2),Q(te,`y`,W(s)-5),Q(E,`cx`,W(f)),Q(E,`cy`,W(p)),Q(ne,`cx`,W(f)),Q(ne,`cy`,W(p)),J(re,`${t.used??``}% consumed // ${i??``}% of period elapsed`),J(D,`${t.used??``}% USED // ${a??``}% TIME ELAPSED`),J(ae,m)},[()=>`Consumption zone: ${t.used}% consumed, ${t.elapsed.toFixed(1)}% of quota period elapsed. ${W(m)>0?`Above`:W(m)<0?`Below`:`On`} the steady-consumption line.`,()=>t.elapsed.toFixed(1),()=>t.elapsed.toFixed(1),()=>Math.abs(W(m))<.05?`ON PACE`:W(m)>0?`ABOVE THE LINE — CONSUMING FASTER THAN TIME`:`BELOW THE LINE — WITHIN PACE`]),Mi(_,`clientWidth`,e=>I(o,e)),Mi(_,`clientHeight`,e=>I(s,e)),q(e,g),qe()}var Ca=K(` `),wa=K(`

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

`),Ta=K(`

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

`),Ea=K(`

`),Da=K(`

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

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

`),Oa=K(` `,1),ka=Nr(``),Aa=Nr(``),ja=K(`
`),Ma=K(`

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

`),Na=K(`
▼
−100 // OVER BUDGET+100 // HEADROOM

`,1),Pa=K(`

Cycle duration unavailable — pace cannot be calculated.

`),Fa=K(`
EMPTYFULL
`),Ia=K(`

`,1),La=K(`
`,1),Ra=K(`

`),za=K(`

`),Ba=K(`

No quota windows reported yet.

`),Va=K(`
`,1),Ha=K(`

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

`,1),Ua=K(` `,1);function Wa(e,t){Ke(t,!0);let n=Bi(t,`params`,19,()=>({})),r=N(()=>Ji.filter(e=>e!==`thresholds`||!!$.data?.thresholds?.length)),i=F(Zt(Date.now())),a=N(()=>W(r).includes(n().view||``)?n().view:`bars`);Vi(()=>{let e=setInterval(()=>I(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-W(i))/(e.duration*6e4))))}bn(()=>{Qi.view=W(a)});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=Ua(),l=R(c);Z(l,21,()=>W(r),X,(e,t)=>{var n=Ca();let r;var i=z(n,!0);V(e=>{Q(n,`href`,`#/quota/`+W(t)),Q(n,`aria-current`,W(a)===W(t)?`page`:void 0),r=ci(n,1,``,null,r,{active:W(a)===W(t)}),J(i,e)},[()=>W(t)===`pace`?`CONSUMPTION PACE`:W(t)===`zone`?`CONSUMPTION ZONE`:W(t)===`fuel`?`FUEL TANK`:W(t).toUpperCase()]),q(e,n)}),A(l);var u=B(l,2),d=e=>{var t=Ha(),n=R(t),r=e=>{q(e,wa())};Y(n,e=>{$.data.quotaError&&e(r)});var i=B(n,2),c=z(i),l=B(i,2),u=e=>{ha(e,{})},d=e=>{var t=Da(),n=L(t),r=z(n),i=B(n,4),a=e=>{q(e,Ta())};Y(i,e=>{$.data.credits.length||e(a)}),Z(B(i,2),17,()=>$.data.credits,X,(e,t)=>{var n=Ea(),r=L(n),i=z(r),a=z(B(r,2),!0);A(n),V(e=>{J(i,`${(W(t).title||`Quota reset`)??``} // ${W(t).status??``}`),J(a,e)},[()=>W(t).expiryKnown?W(t).expires?`EXPIRES `+aa(W(t).expires):`Does not expire`:`Expiry information unavailable`]),q(e,n)}),Te(2),A(t),V(()=>J(r,`RESET INVENTORY // ${$.data.creditCount??``} AVAILABLE`)),q(e,t)},f=e=>{var t=Va(),n=R(t);let r;Z(n,21,()=>$.data.meters,X,(e,t)=>{let n=N(()=>o(W(t))),r=N(()=>W(n)===null?null:W(n)-W(t).used);var i=za(),c=L(i),l=z(c,!0),u=B(c,2),d=L(u),f=e=>{var n=Oa(),r=R(n),i=z(r),a=z(B(r));V(()=>{J(i,`FREE ${100-W(t).used}%`),J(a,`USED ${W(t).used??``}%`)}),q(e,n)},p=e=>{var n=Oa(),r=R(n),i=z(r),a=z(B(r));V(()=>{J(i,`USED ${W(t).used??``}%`),J(a,`FREE ${100-W(t).used}%`)}),q(e,n)};Y(d,e=>{W(a)===`fuel`?e(f):e(p,-1)}),A(u);var m=B(u,2);let h;var g=L(m),_=e=>{var n=ja(),r=L(n),i=B(L(r)),a=e=>{q(e,ka())},o=e=>{var n=Aa();V(e=>Q(n,`d`,e),[()=>s(W(t).used)]),q(e,n)};Y(i,e=>{W(t).used>=100?e(a):W(t).used>0&&e(o,1)}),A(r),A(n),V(()=>Q(r,`aria-label`,`${W(t).used}% quota used`)),q(e,n)},v=e=>{var r=Fr(),i=R(r),a=e=>{{let r=N(()=>W(t).trail||[]);Sa(e,{get used(){return W(t).used},get elapsed(){return W(n)},get trail(){return W(r)}})}},o=e=>{q(e,Ma())};Y(i,e=>{W(n)===null?e(o,-1):e(a)}),q(e,r)},y=e=>{var t=Fr(),n=R(t),i=e=>{var t=Na(),n=R(t),i=B(L(n),2);let a;A(n);var o=B(n,4),s=L(o),c=z(B(s),!0);A(o),V(e=>{a=ui(i,``,a,{left:`${(W(r)+100)/2}%`}),J(s,`${W(r)>=0?`+`:``}${e??``} PP `),J(c,W(r)>=0?`WITHIN PACE`:`USING FASTER THAN TIME`)},[()=>W(r).toFixed(1)]),q(e,t)},a=e=>{q(e,Pa())};Y(n,e=>{W(r)===null?e(a,-1):e(i)}),q(e,t)},b=e=>{var r=La(),i=R(r),o=L(i);let s;A(i);var c=B(i,2),l=e=>{q(e,Fa())};Y(c,e=>{W(a)===`fuel`&&e(l)});var u=B(c,2),d=e=>{var t=Ia(),r=R(t),i=z(r),o=B(r,2),s=L(o);let c;A(o),V(e=>{J(i,`RESET CYCLE // ${e??``}% ELAPSED`),c=ui(s,``,c,{width:`${W(a)===`fuel`?100-W(n):W(n)}%`})},[()=>Math.floor(W(n))]),q(e,t)};Y(u,e=>{W(n)!==null&&e(d)}),V(()=>{Q(i,`aria-label`,W(a)===`fuel`?`Fuel remaining`:`Quota used`),Q(i,`aria-valuenow`,W(a)===`fuel`?100-W(t).used:W(t).used),s=ui(o,``,s,{width:`${W(a)===`fuel`?100-W(t).used:W(t).used}%`})}),q(e,r)};Y(g,e=>{W(a)===`pie`?e(_):W(a)===`zone`?e(v,1):W(a)===`pace`?e(y,2):e(b,-1)}),A(m);var x=B(m,2),S=z(x),ee=B(x,2),C=e=>{var n=Ra(),r=z(n,!0);V(()=>J(r,W(t).details)),q(e,n)};Y(ee,e=>{W(t).details&&e(C)}),A(i),V(e=>{J(l,W(t).name),h=ci(m,1,`meter-graphic`,null,h,{"bar-graphic":W(a)===`bars`||W(a)===`fuel`}),J(S,`RESETS // ${e??``}`)},[()=>aa(W(t).reset)]),q(e,i)}),A(n);var i=B(n,2),c=e=>{q(e,Ba())};Y(i,e=>{$.data.meters.length||e(c)}),V(()=>r=ci(n,1,`quota-grid`,null,r,{radial:W(a)===`pie`,zone:W(a)===`zone`})),q(e,t)};Y(l,e=>{W(a)===`thresholds`?e(u):W(a)===`resets`?e(d,1):e(f,-1)}),Te(2),V(e=>J(c,`QUOTA // OBSERVED ${e??``}`),[()=>aa($.data.quotaAt)]),q(e,t)};Y(u,e=>{$.data&&e(d)}),q(e,c),qe()}var Ga=K(`
`),Ka=K(`

`,1);function qa(e,t){Ke(t,!0);let n=Bi(t,`values`,19,()=>[]),r=Bi(t,`label`,3,`Token activity`),i=Bi(t,`capacity`,3,0),a=N(()=>Math.max(0,...n())),o=N(()=>i()>n().length?[...Array(i()-n().length).fill(0),...n()]:n());var s=Ka(),c=R(s),l=z(c),u=B(c,2);Z(u,21,()=>W(o),X,(e,t)=>{var n=Ga();let r;V((e,t)=>{Q(n,`title`,e),r=ui(n,``,r,{height:t})},[()=>W(t).toLocaleString(`en-GB`)+` tokens`,()=>`${100*W(t)/Math.max(1,W(a))}%`]),q(e,n)}),A(u),V((e,t)=>{J(l,`SCALE // 0 — ${e??``} TOKENS`),Q(u,`aria-label`,t)},[()=>W(a).toLocaleString(`en-GB`),()=>`${r()}. Peak ${W(a).toLocaleString(`en-GB`)} tokens.`]),q(e,s),qe()}var Ja=K(`

CURRENT PROFILE

MODEL / REASONING LEVEL / SPEED

 

PROPOSED PROFILE

MODEL / REASONING LEVEL / SPEED

 

Applied settings remain after Codexometer closes.

`,1),Ya=K(`

`),Xa=K(`

 
`,1),Za=K(`

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

`),Qa=K(`

Session controls temporarily unavailable. Check Codex for current state.

`),$a=K(`

Checking session controls…

`),eo=K(`

`),to=K(`
About browser controls

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

`),no=K(` `,1),ro=K(` `),io=K(`Grants permission beyond this one command. Check the scope - carefully.`),ao=K(``),oo=K(``),so=K(``),co=K(``),lo=K(` `,1),uo=K(`
  • `),fo=K(`
    View fixed choices

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

      `),po=K(` `,1),mo=K(`

      `,1),ho=K(``),go=K(`

      `,1),_o=K(`

      `);function vo(e,t){Ke(t,!0);let n=[],r=Bi(t,`observedCommand`,3,``),i=Bi(t,`review`,3,``),a=Bi(t,`suspended`,3,!1),o=Bi(t,`onProtectedChange`,3,e=>{}),s=F(null),c=F(Zt([])),l=F(null),u=F(``),d=F(0),f=F(Zt(Date.now())),p=F(!1),m=F(``),h=F(!1),g=F(!1),_=F(``);bn(()=>(o()(W(p)||W(c).some(e=>e.length>0)),()=>o()(!1)));let v=N(()=>$.data?.sessions.find(e=>e.id===t.session)?.status),y=N(()=>!$.connected||!!$.data?.sessionsError),b=N(()=>i()!==`profile`&&W(s)?.kind===`prompt`&&!W(s).questions?.length&&!!$.data?.profiles?.some(e=>e.session===t.session&&e.pending)),x=N(()=>!W(y)&&!W(g)&&!!W(s)?.id&&W(s).kind===`approval`&&W(_)!==W(s).id),S=N(()=>W(x)?W(s).command:r()),ee=N(()=>!!W(u)&&W(f)W(s)?.questions?.length?W(s).questions:[{text:`Follow-up message`,secret:!1,freeText:!0,options:[]}]),w=N(()=>W(s)?.kind===`approval`||W(s)?.kind===`profile`?W(l)!==null:W(c).length===W(C).length&&W(c).every((e,t)=>e.trim().length>0&&(W(C)[t].freeText||W(C)[t].options?.includes(e))));bn(()=>{(W(y)||a()||W(b)||W(f)>=W(d))&&I(u,``)});let T=new AbortController;Vi(()=>{let e,n=setInterval(()=>{I(f,Date.now(),!0)},1e3);async function r(){try{let e=await la(`offer`,{session:t.session,...i()?{review:i()}:{}},T.signal);if(T.signal.aborted)return;I(g,!1),W(s)?.id!==e.id&&(I(u,``),I(l,null),I(c,Array(Math.max(1,e.questions?.length||0)).fill(``),!0)),I(s,e,!0),W(h)&&e.id&&e.id!==W(_)&&(I(m,``),I(h,!1))}catch{T.signal.aborted||(I(s,null),I(g,!0),I(u,``))}finally{T.signal.aborted||(e=setTimeout(r,2e3))}}return r(),()=>{T.abort(),clearTimeout(e),clearInterval(n)}});async function te(){if(!W(s)?.id||W(p)||W(y)||a()||W(b)||!W(w))return;let e=W(s).id;I(p,!0),I(m,``),I(h,!1),I(u,``);try{let n=await la(`prepare`,{session:t.session,...i()?{review:i()}:{},offer:e,...W(s).kind===`approval`||W(s).kind===`profile`?{choice:W(l)}:{answers:[...W(c)]}},T.signal);W(s)?.id===e&&!T.signal.aborted&&!W(y)&&!a()&&!W(b)&&(I(u,n.confirmation,!0),I(d,Date.parse(n.expires),!0))}catch(e){T.signal.aborted||I(m,e instanceof Error?e.message:`Unable to prepare action.`,!0)}finally{I(p,!1)}}async function E(){if(!W(s)?.id||W(p)||a()||W(b)||!W(ee))return;let e=W(s).id,n=W(s).kind,r=W(u);I(u,``),I(p,!0),I(_,e,!0);try{await la(`commit`,{session:t.session,...i()?{review:i()}:{},offer:e,confirmation:r},T.signal),I(h,!0),I(m,n===`profile`?`Profile decision completed.`:n===`approval`?`Decision sent.`:`Text sent.`,!0)}catch(e){I(m,e instanceof sa?e.message:`Outcome uncertain. Check Codex before taking another action; nothing was retried.`,!0)}finally{I(p,!1),I(c,[],!0),I(l,null)}}var ne=Fr(),re=R(ne),ie=e=>{var r=_o(),a=L(r),o=z(a,!0),b=B(a,2),T=e=>{var t=Ja(),n=R(t),r=z(n),i=B(n,6),a=z(i,!0),o=z(B(i,6),!0);Te(2),V(()=>{J(r,`Your ${W(s).profile.threshold??``}% quota threshold has been reached. Review - the profile for subsequent turns.`),J(a,W(s).profile.current),J(o,W(s).profile.proposed)}),q(e,t)};Y(b,e=>{W(s)?.profile&&!W(y)&&!W(g)&&e(T)});var ne=B(b,2),re=e=>{var t=Ya();let n;var r=z(t,!0);V(()=>{n=ci(t,1,`svelte-1oupzfc`,null,n,{notice:!W(h),sent:W(h)}),J(r,W(m))}),q(e,t)};Y(ne,e=>{W(m)&&e(re)});var ie=B(ne,2),D=e=>{var t=Xa(),n=R(t),r=z(n,!0),i=z(B(n,2),!0);V(()=>{J(r,W(x)?`EXACT COMMAND`:`LAST OBSERVED COMMAND`),J(i,W(S))}),q(e,t)},ae=e=>{q(e,Za())};Y(ie,e=>{W(S)?e(D):i()!==`profile`&&W(v)===`APPROVAL NEEDED`&&!W(h)&&e(ae,1)});var oe=B(ie,2),se=e=>{q(e,Qa())},ce=e=>{q(e,$a())},le=e=>{var t=no(),n=R(t),r=e=>{var t=eo(),n=z(t,!0);V(e=>J(n,e),[()=>W(v)===`WORKING`?`Codex is working — nothing to respond to.`:[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(v)||``)?`Respond in Codex for this request.`:`Nothing needs a response right now.`]),q(e,t)};Y(n,e=>{(W(v)===`WORKING`||!W(h)&&!W(p))&&e(r)});var i=B(n,2),a=e=>{q(e,to())},o=N(()=>[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(v)||``)&&!W(h));Y(i,e=>{W(o)&&e(a)}),q(e,t)},ue=e=>{var r=go(),a=R(r),o=z(a),m=B(a,2),h=L(m),g=z(h,!0),_=B(h,2),v=e=>{var r=Fr();Z(R(r),17,()=>W(s).choices||[],X,(e,r,a)=>{var o=ao(),s=L(o);xi(s),s.value=s.__value=a;var c=B(s),u=B(c),d=e=>{var t=ro(),n=z(t,!0);V(()=>J(n,W(r).detail)),q(e,t)};Y(u,e=>{W(r).detail&&e(d)});var f=B(u,2),p=e=>{q(e,io())};Y(f,e=>{W(r).persistent&&e(p)}),A(o),V(()=>{Q(s,`name`,`decision-`+t.session+`-`+i()),J(c,` ${W(r).label??``} `)}),Di(n,[],s,()=>W(l),e=>I(l,e)),q(e,o)}),q(e,r)},b=e=>{var t=Fr();Z(R(t),17,()=>W(C),X,(e,t,n)=>{var r=po(),i=R(r),a=L(i),o=B(a),s=e=>{var t=oo();xi(t),Ti(t,()=>W(c)[n],e=>W(c)[n]=e),q(e,t)},l=e=>{var r=co(),i=L(r);i.value=i.__value=``,Z(B(i),17,()=>W(t).options||[],X,(e,t)=>{var n=so(),r=z(n,!0),i={};V(()=>{J(r,W(t)),i!==(i=W(t))&&(n.value=(n.__value=i)??``)}),q(e,n)}),A(r),mi(r),hi(r,()=>W(c)[n],e=>W(c)[n]=e),q(e,r)},u=e=>{var r=lo(),i=R(r);rt(i);var a=B(i,2),o=e=>{var n=eo(),r=z(n);V(e=>J(r,`Suggested answers: ${e??``}`),[()=>W(t).options.join(` · `)]),q(e,n)};Y(a,e=>{W(t).options?.length&&e(o)}),Ti(i,()=>W(c)[n],e=>W(c)[n]=e),q(e,r)};Y(o,e=>{W(t).secret?e(s):W(t).freeText?e(u,-1):e(l,1)}),A(i);var d=B(i,2),f=e=>{var n=fo(),r=B(L(n),4);Z(r,21,()=>W(t).options||[],X,(e,t)=>{var n=uo(),r=z(n,!0);V(()=>J(r,W(t))),q(e,n)}),A(r),A(n),q(e,n)};Y(d,e=>{W(t).secret&&!W(t).freeText&&e(f)}),V(()=>J(a,`${W(t).text??``} `)),q(e,r)}),q(e,t)};Y(_,e=>{W(s).kind===`approval`||W(s).kind===`profile`?e(v):e(b,-1)}),A(m);var x=B(m,2),S=e=>{var t=mo(),n=R(t),r=z(n),i=B(n,2),a=z(i),o=B(i,2);V(e=>{J(r,`Check the target and ${W(s).kind===`profile`?`profile above`:W(s).kind===`approval`?`exact command and permission scope`:`message above`}. This will send to Codex; it may start work - using your quota. Confirmation expires in ${e??``}s.`),i.disabled=W(p)||W(y),J(a,`CONFIRM ${(W(s).kind===`approval`||W(s).kind===`profile`?W(s).choices?.[W(l)]?.label:`SEND`)??``}`)},[()=>Math.max(0,Math.ceil((W(d)-W(f))/1e3))]),G(`click`,i,E),G(`click`,o,()=>{I(u,``)}),q(e,t)},T=e=>{var t=ho(),n=z(t,!0);V(()=>{t.disabled=W(p)||W(y)||!W(w),J(n,W(p)?`SENDING…`:`REVIEW BEFORE SENDING`)}),G(`click`,t,te),q(e,t)};Y(x,e=>{W(ee)?e(S):e(T,-1)}),V(()=>{J(o,`TARGET // ${W(s).thread??``} // ${(W(s).directory||`Directory unavailable`)??``}`),m.disabled=W(p)||W(ee)||W(y),J(g,W(s).kind===`approval`||W(s).kind===`profile`?`Choose a decision`:`Reply to this session`)}),q(e,r)};Y(oe,e=>{W(y)||W(g)?e(se):W(s)?W(s).id?W(_)!==W(s).id&&e(ue,3):e(le,2):e(ce,1)}),A(r),V(()=>J(o,i()===`profile`?`QUOTA THRESHOLD`:`SESSION CONTROL // EXPERIMENTAL`)),q(e,r)};Y(re,e=>{W(b)||e(ie)}),q(e,ne),qe()}wr([`click`]);var yo=K(`
      `);function bo(e,t){Ke(t,!0);let n=Bi(t,`active`,3,!1),r=N(()=>t.session.text||t.session.contextKind===`LAST ACTIVITY`&&t.session.workingCommand||``),i=N(()=>[`LAST REPLY`,`LAST ACTIVITY`].includes(t.session.contextKind)&&!!W(r).trim()),a=F(!1),o=F(``),s=F(!1);bn(()=>{if(!W(s))return;let e=setTimeout(()=>{I(s,!1)},150);return()=>clearTimeout(e)}),bn(()=>{W(r),t.session.status,I(o,``)});async function c(){if(!W(i)||W(a))return;let e=W(r);I(a,!0),I(s,!0),I(o,``);try{await navigator.clipboard.writeText(e),W(r)===e&&I(o,`Copied.`)}catch{W(r)===e&&I(o,`Clipboard unavailable. Select the visible text and copy it manually.`)}finally{I(a,!1)}}function l(e){!n()||!W(i)||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(),c())}var u=Fr();Cr(`keydown`,en,l);var d=R(u),f=e=>{var t=yo(),n=L(t),r=z(n,!0),i=B(n,2);let l;A(t),V(()=>{J(r,W(o)),i.disabled=W(a),l=ci(i,1,`svelte-543j00`,null,l,{flashed:W(s)})}),G(`click`,i,c),q(e,t)};Y(d,e=>{W(i)&&e(f)}),q(e,u),qe()}wr([`click`]);var xo=K(`

      CONTEXT

       

      `,1),So=K(`

      `),Co=K(`

      `),wo=K(`
       
      `),To=K(`

       
      `,1),Eo=K(`
       
      `),Do=K(`

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

      `),Oo=K(`

      `,1),ko=K(`

      `),Ao=K(` `,1),jo=K(`
      `),Mo=K(`

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

      `),No=K(`

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

      `),Po=K(` `),Fo=K(` `),Io=K(``),Lo=K(`

      Read only — reply or approve in Codex.

      `),Ro=K(`

      `),zo=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),Bo=K(`
      `),Vo=K(`
      `),Ho=K(`

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

      `),Uo=K(`

      `),Wo=K(``),Go=K(`

      `),Ko=K(` `),qo=K(`

      `),Jo=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),Yo=K(` `,1),Xo=K(`

      `),Zo=K(`

      TOKEN ACTIVITY // 30 SECOND SAMPLES

      `),Qo=K(`

      TOKENS

      FULL DETAIL →
      `),$o=K(`

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

      `),es=K(`

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

      `,1),ts=K(`

      SESSION TOTALS

      `,1);function ns(e,t){Ke(t,!0);let n=(e,t=f,n,r)=>{let i=ht(()=>g(n?.(),!0)),a=ht(()=>g(r?.(),!1));var o=Ao(),s=R(o),c=e=>{var n=xo(),r=z(B(R(n),2),!0);Te(2),V(()=>J(r,t().approvalContext)),q(e,n)};Y(s,e=>{W(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(c)});var l=B(s,2),u=e=>{var n=So();let r;var i=z(n,!0);V(e=>{r=ci(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),J(i,e)},[()=>b(t())]),q(e,n)},p=N(()=>b(t())&&(!W(a)||W(d)||t().status===`CHECK SESSION`));Y(l,e=>{W(p)&&e(u)});var m=B(l,2),h=e=>{var n=Co(),r=z(n,!0);V(()=>J(r,t().contextKind||`LAST ACTIVITY`)),q(e,n)};Y(m,e=>{W(i)&&e(h)});var _=B(m,2),v=e=>{var n=wo(),r=z(n,!0);V(()=>J(r,t().text||`No session context available.`)),q(e,n)};Y(_,e=>{(t().text||!t().workingCommand)&&e(v)});var y=B(_,2),x=e=>{var n=To(),r=B(R(n),2),i=L(r),a=B(i),o=e=>{var n=Pr();V(()=>J(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),q(e,n)};Y(a,e=>{!W(d)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(o)});var s=B(a,2),c=e=>{q(e,Pr(`+`))};Y(s,e=>{t().runningLimited&&e(c)}),A(r);var l=z(B(r,2),!0);V(e=>{J(i,`COMMAND // ${e??``} `),J(l,t().workingCommand)},[()=>W(d)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),q(e,n)};Y(y,e=>{t().workingCommand&&e(x)});var S=B(y,2),ee=e=>{var n=Oo(),r=B(R(n),2),i=z(r,!0),a=B(r,2),o=e=>{var n=Eo(),r=z(n,!0);V(()=>J(r,t().command)),q(e,n)},s=e=>{q(e,Do())};Y(a,e=>{t().command?e(o):e(s,-1)}),V(()=>J(i,W(d)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),q(e,n)};Y(S,e=>{(!W(a)||!$.data?.control)&&(t().command||t().status===`APPROVAL NEEDED`)&&e(ee)});var C=B(S,2),w=e=>{var n=ko(),r=z(n);V(()=>J(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),q(e,n)};Y(C,e=>{W(a)||e(w)}),q(e,o)},r=Bi(t,`params`,19,()=>({})),i=N(()=>$.data?.sessions||[]),a=N(()=>$.data?.control&&$.data.profiles||[]),o=F(!1);function s(e,t){if(r().id&&r().id!==t&&W(o)){e.preventDefault();return}h(t)}bn(()=>{let e=r().id;e&&mr(()=>{Qi.selected=e,ra(e,2)})});let c=N(()=>W(i).find(e=>e.id===r().id)),l=N(()=>new URLSearchParams(Wi.querystring).get(`review`)===`profile`&&W(a).some(e=>e.session===r().id&&e.pending)),u=N(()=>W(i).some(e=>e.id===Qi.selected)?Qi.selected:W(i)[0]?.id),d=N(()=>!$.connected||!!$.data?.sessionsError),p=N(()=>[[`OBSERVED TOKENS`,ia(W(i).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,ia(W(i).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,W(d)?`—`:ia(W(i).filter(e=>e.status===t).length)])]),m=N(()=>W(i).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`,`CHECK SESSION`].includes(e.status)));function h(e){Qi.selected=e,dr().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function v(e,t){if(h(e),r().id){t<0&&(ra(e,2),location.hash=`/sessions`);return}let n=ta(e)+t;n>2?location.hash=`/sessions/`+encodeURIComponent(e):ra(e,n)}function y(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`&&r().id)e.preventDefault(),v(r().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(r().id||W(u)))e.preventDefault(),v(r().id||W(u),e.key===`ArrowLeft`?-1:1);else if(!r().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&W(i).length){e.preventDefault();let t=W(i).findIndex(e=>e.id===W(u));h(W(i)[Math.max(0,Math.min(W(i).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function b(e){return W(d)?`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.`:$.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.`:``}var x=ts();Cr(`keydown`,en,y);var S=R(x),ee=z(B(L(S),2));A(S);var C=B(S,2);let w;Z(C,21,()=>W(p),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1];var a=jo(),o=L(a),s=z(o,!0),c=z(B(o,2),!0);A(a),V(()=>{J(s,r()),J(c,i())}),q(e,a)}),A(C);var T=B(C,2),te=z(T),E=B(T,2),ne=e=>{q(e,Mo())};Y(E,e=>{W(d)&&e(ne)});var re=B(E,2),ie=e=>{q(e,No())};Y(re,e=>{$.data?.profileError&&e(ie)});var D=B(re,2),ae=e=>{var t=Io(),n=L(t);Z(n,17,()=>W(m),X,(e,t)=>{var n=Po();let r;var i=z(n);V((e,a)=>{r=ci(n,1,`button`,null,r,{approval:W(t).status===`APPROVAL NEEDED`}),Q(n,`href`,e),J(i,`${W(t).status??``} - ${a??``} // ${(W(t).name||W(t).directory||W(t).id)??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,n,()=>h(W(t).id)),q(e,n)}),Z(B(n,2),17,()=>W(a).filter(e=>e.pending&&W(i).some(t=>t.id===e.session)),X,(e,t)=>{var n=Fo(),a=z(n);V((e,i,s)=>{Q(n,`title`,r().id&&r().id!==W(t).session&&W(o)?`Finish sending or clear your current draft before switching sessions.`:`Review this session’s quota threshold`),Q(n,`href`,e),J(a,`QUOTA THRESHOLD ${i??``} // ${s??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session)+`?review=profile`,()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory||W(t).session]),G(`click`,n,e=>s(e,W(t).session)),q(e,n)}),A(t),q(e,t)},oe=N(()=>(W(m).length||W(a).some(e=>e.pending))&&!W(d));Y(D,e=>{W(oe)&&e(ae)});var se=B(D,2),ce=e=>{var t=Fr(),i=R(t),s=e=>{var t=Vo(),i=L(t),s=L(i),u=L(s);let f;var p=B(u);A(s);var m=B(s,2);A(i);var g=B(i,2),_=e=>{var t=ko(),n=z(t,!0);V(()=>J(n,W(c).directory)),q(e,t)};Y(g,e=>{W(c).name&&W(c).directory&&e(_)});var v=B(g,2),y=z(v),b=B(v,2);let x;var S=L(b),ee=L(S);n(ee,()=>W(c),()=>!0,()=>!0),A(S);var C=B(S,2),w=e=>{var t=Fr();qr(R(t),()=>W(c).id,e=>{vo(e,{get session(){return W(c).id},get observedCommand(){return W(c).command},get suspended(){return W(l)},onProtectedChange:e=>{I(o,e,!0)}})}),q(e,t)},T=e=>{q(e,Lo())};Y(C,e=>{$.data?.control?e(w):e(T,-1)}),A(b);var te=B(b,2);Z(te,17,()=>W(a).filter(e=>e.session===W(c).id),e=>e.session,(e,t)=>{var n=Bo(),r=L(n),i=e=>{var n=Ro(),r=z(n,!0);V(()=>J(r,W(t).notice)),q(e,n)};Y(r,e=>{W(t).notice&&e(i)});var a=B(r,2),o=e=>{vo(e,{get session(){return W(c).id},review:`profile`})},s=e=>{var t=zo();V(e=>Q(t,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(c).id)+`?review=profile`]),q(e,t)};Y(a,e=>{W(t).pending&&W(l)?e(o):W(t).pending&&e(s,1)}),A(n),V(()=>Q(n,`id`,`quota-profile-`+W(c).id)),q(e,n)});var E=B(te,2),ne=e=>{var t=Fr();qr(R(t),()=>W(c).id,e=>{bo(e,{get session(){return W(c)},active:!0})}),q(e,t)};Y(E,e=>{W(l)||e(ne)}),A(t),V(e=>{f=ci(u,1,`lamp lit`,null,f,{working:W(c).status===`WORKING`&&!W(d)}),J(p,`${(W(d)?`STALE`:W(l)?`QUOTA THRESHOLD`:W(c).status)??``} // ${(W(c).name||W(c).directory)??``}`),J(y,`${e??``} TOKENS // ${W(c).id??``} // CONTEXT SOURCE // ${(W(c).source||`LOCAL`)??``}`),x=ui(b,``,x,{display:W(l)?`none`:void 0})},[()=>ia(W(c).tokens)]),G(`click`,m,()=>{h(r().id),ra(r().id,2)}),q(e,t)},u=e=>{q(e,Ho())};Y(i,e=>{W(c)?e(s):e(u,-1)}),q(e,t)},le=e=>{var t=es(),r=R(t),o=B(L(r),2),c=L(o),l=B(c,2);A(o),A(r);var f=B(r,2);Z(f,17,()=>W(i),e=>e.id,(e,t)=>{let r=N(()=>ta(W(t).id));var i=Qo();let o;var c=L(i),l=L(c),f=e=>{var n=Uo(),r=L(n),i=z(r);A(n),V(e=>{Q(r,`aria-pressed`,W(u)===W(t).id),J(i,`${e??``} // ${W(t).name??``}`)},[()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,r,()=>h(W(t).id)),q(e,n)};Y(l,e=>{W(t).name&&e(f)});var p=B(l,2),m=L(p),g=L(m);let _;var y=B(g,1,!0);A(m),A(p);var b=B(p,2),x=e=>{var n=Wo(),r=z(n,!0);V(()=>{Q(n,`aria-pressed`,W(u)===W(t).id),J(r,W(t).directory||W(t).id)}),G(`click`,n,()=>h(W(t).id)),q(e,n)};Y(b,e=>{W(t).name||e(x)});var S=B(b,2),ee=L(S);Te(),A(S);var C=B(S,2),w=e=>{var n=ko(),r=z(n,!0);V(()=>J(r,W(t).directory)),q(e,n)};Y(C,e=>{W(t).name&&W(t).directory&&e(w)});var T=B(C,2),te=z(T),E=B(T,2),ne=z(E),re=B(E,2),ie=L(re),D=B(ie,2),ae=z(D,!0),oe=B(D,2);A(re);var se=B(re,2),ce=B(se,2),le=e=>{var n=Go(),r=z(n,!0);V(()=>J(r,W(t).status===`CHECK SESSION`?`INFERRED INACTIVITY`:$.data?.control?`OPEN FULL DETAIL OR REPLY IN CODEX`:W(t).status===`APPROVAL NEEDED`?`APPROVE OR DECLINE IN CODEX`:`REPLY IN CODEX`)),q(e,n)},ue=N(()=>!W(d)&&[`APPROVAL NEEDED`,`INPUT NEEDED`,`CHECK SESSION`].includes(W(t).status));Y(ce,e=>{W(ue)&&e(le)}),A(c);var de=B(c,2),fe=e=>{var r=Xo(),i=L(r),o=L(i),c=z(o,!0),l=B(o,2),f=e=>{var n=Ko(),r=z(n,!0);V(e=>{Q(n,`href`,e),J(r,$.data?.control?`REVIEW IN FULL DETAIL ↗`:`APPROVAL IN CODEX ↗`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id)]),q(e,n)};Y(l,e=>{!W(d)&&W(t).status===`APPROVAL NEEDED`&&e(f)}),A(i);var p=B(i,2);n(p,()=>W(t),()=>!1);var m=B(p,2);Z(m,17,()=>W(a).filter(e=>e.session===W(t).id),X,(e,n)=>{var r=Yo(),i=R(r),a=e=>{var t=qo(),r=z(t,!0);V(()=>J(r,W(n).notice)),q(e,t)};Y(i,e=>{W(n).notice&&e(a)});var o=B(i,2),c=e=>{var n=Jo();V(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(t).id)+`?review=profile`]),G(`click`,n,e=>s(e,W(t).id)),q(e,n)};Y(o,e=>{W(n).pending&&e(c)}),q(e,r)});var h=B(m,2);{let e=N(()=>W(u)===W(t).id);bo(h,{get session(){return W(t)},get active(){return W(e)}})}A(r),V(()=>J(c,W(t).contextKind||`LAST ACTIVITY`)),q(e,r)};Y(de,e=>{W(r)>0&&e(fe)});var pe=B(de,2),me=e=>{var n=Zo(),r=B(L(n),2);{let e=N(()=>(W(t).samples||[]).map(e=>e.tokens));qa(r,{get values(){return W(e)},capacity:120})}var i=z(B(r,2));A(n),V(()=>J(i,`LAST ${(W(t).samples?.length||0)??``} SAMPLES // AUTO SCALE`)),q(e,n)};Y(pe,e=>{W(r)<2&&e(me)}),A(i),V((e,n,a,s)=>{o=ci(i,1,`session-row`,null,o,{selected:W(u)===W(t).id,wide:W(r)===2,split:W(r)===1}),Q(i,`aria-label`,`Session `+(W(t).name||W(t).directory||W(t).id)),Q(m,`href`,e),_=ci(g,1,`lamp lit`,null,_,{working:W(t).status===`WORKING`&&!W(d)}),J(y,W(d)?`STALE`:W(t).status),J(ee,`${n??``} `),J(te,`${W(t).agents??``} LINKED AGENTS`),J(ne,`ACTIVE // ${a??``}`),ie.disabled=W(r)===0,Q(D,`aria-expanded`,W(r)>0),J(ae,W(r)?`HIDE DETAIL`:`SHOW DETAIL`),Q(se,`href`,s)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>ia(W(t).tokens),()=>aa(W(t).activity),()=>`#/sessions/`+encodeURIComponent(W(t).id)]),G(`click`,m,()=>h(W(t).id)),G(`click`,ie,()=>v(W(t).id,-1)),G(`click`,D,()=>{h(W(t).id),ra(W(t).id,+!W(r))}),G(`click`,oe,()=>v(W(t).id,1)),G(`click`,se,()=>h(W(t).id)),q(e,i)});var p=B(f,2),m=e=>{q(e,$o())};Y(p,e=>{W(i).length||e(m)}),G(`click`,c,()=>na(1)),G(`click`,l,()=>na(0)),q(e,t)};Y(se,e=>{r().id?e(ce):e(le,-1)}),V(e=>{J(ee,`OBSERVED ${e??``}`),w=ci(C,1,`session-totals`,null,w,{stale:W(d)}),J(te,`${W(d)?`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.`)},[()=>aa($.data?.sessionsAt)]),q(e,x),qe()}wr([`click`]);var rs=K(`

      `),is=K(`

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

      `,1),as=K(`// APPROXIMATE`),os=K(`

      Partial accounting: totals may still change.

      `),ss=K(`

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

      `,1),cs=K(`

      `,1),ls=K(`

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

      `),us=K(`
      `),ds=K(`
      `),fs=K(`

      No usage reported for this day.

      `),ps=K(`

      Selected breakdown unavailable; missing does not mean zero.

      `),ms=K(`

      `,1);function hs(e,t){Ke(t,!0);let n=F(`surface`),r=F(0),i=N(()=>t.reports?.daily),a=N(()=>t.reports?.plan),o=N(()=>t.mode===`breakdown`?W(i)?.days.length||0:W(a)?.periods.length||0),s=N(()=>Math.min(W(r),Math.max(0,W(o)-1))),c=N(()=>W(i)?.days[(W(i)?.days.length||0)-1-W(s)]),l=N(()=>W(a)?.periods[W(s)]),u=N(()=>t.mode===`breakdown`?W(i)?.units||``:`%`),d=N(()=>{let e=Object.create(null);if(t.mode===`breakdown`)e=W(c)?.groups[W(n)]||{};else{let t=W(n)===`feature`?`thread_source`:W(n)===`task start`?`turn_trigger`:W(n);for(let n of W(l)?.breakdowns||[])if(n.dimension===t)for(let t of n.rows)e[t.key]=(e[t.key]||0)+t.basis_points/100}return Object.entries(e).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}),f=N(()=>t.mode===`breakdown`?W(c)?.total:W(l)?.used_basis_points==null?null:W(l).used_basis_points/100),p=N(()=>Math.max(1,W(f)||0,...W(d).map(([,e])=>e))),m=e=>e==null?`UNKNOWN`:e.toLocaleString(`en-GB`,{maximumFractionDigits:2});var h=ms(),g=R(h),v=L(g),y=B(L(v)),b=L(y);b.value=b.__value=`surface`;var x=B(b);x.value=x.__value=`model`;var S=B(x);S.value=S.__value=`feature`;var ee=B(S);ee.value=ee.__value=`task start`,A(y),mi(y),A(v);var C=B(v,2),w=B(C,2),T=z(B(w,2),!0);A(g);var te=B(g,2),E=L(te),ne=z(E,!0),re=B(E,2),ie=z(re),D=B(re,2),ae=e=>{var t=is(),n=R(t),r=z(n),a=B(n,2),o=e=>{var t=rs(),n=z(t);V(()=>J(n,`Data as of ${W(i).dataAsOf??``}`)),q(e,t)};Y(a,e=>{W(i).dataAsOf&&e(o)});var s=z(B(a,2));Te(2),V((e,t)=>{J(r,`Latest fetch ${e??``} // queried ${W(i).from??``} → ${W(i).through??``}. - Reports are fetched from OpenAI and are not saved between runs.`),J(s,`${(W(c)?.date||`No daily buckets reported`)??``} // ${t??``} - ${W(u)??``}`)},[()=>aa(W(i).fetchedAt),()=>m(W(f))]),q(e,t)},oe=e=>{var t=cs(),n=R(t),r=L(n);let i;var o=z(r,!0),s=B(r),c=e=>{q(e,as())};Y(s,e=>{W(a).approximate&&e(c)});var u=B(s);A(n);var d=B(n,2),p=L(d),h=B(p),g=e=>{var t=Pr();V(()=>J(t,`// Boundary tolerance ${W(a).boundary_tolerance_seconds??``}s`)),q(e,t)};Y(h,e=>{W(a).boundary_tolerance_seconds!=null&&e(g)}),A(d);var _=B(d,2),v=e=>{var t=ss(),n=R(t),r=L(n),i=B(r);let a;var o=z(i);A(n);var s=B(n,2),c=z(s),u=B(s,2),d=e=>{q(e,os())};Y(u,e=>{W(l).accounting_complete||e(d)}),Te(2),V(e=>{J(r,`${W(l).window_minutes??``} MIN // ${W(l).plan_type??``} // `),a=ci(i,1,`svelte-1fbui7h`,null,a,{muted:W(f)==null,"quota-near":W(f)!=null&&W(f)>=80&&W(f)<100,"quota-full":W(f)!=null&&W(f)>=100}),J(o,`USED ${e??``}${W(f)==null?``:`%`}`),J(c,`${W(l).starts_at??``} → ${W(l).ends_at??``}`)},[()=>m(W(f))]),q(e,t)};Y(_,e=>{W(l)&&e(v)}),V(e=>{i=ci(r,1,`svelte-1fbui7h`,null,i,{"quality-warning":!W(a).coverage_complete}),J(o,W(a).coverage_complete?`Reported range complete`:`Partial coverage`),J(u,` // Latest fetch ${e??``}`),J(p,`Coverage starts ${(W(a).coverage_start||`unknown`)??``} // Data as of ${(W(a).data_as_of||`unknown`)??``}`)},[()=>aa(W(a).fetchedAt)]),q(e,t)},se=e=>{q(e,ls())};Y(D,e=>{t.mode===`breakdown`&&W(i)?e(ae):t.mode===`periods`&&W(a)?e(oe,1):e(se,-1)});var ce=B(D,2),le=e=>{var n=ds(),r=L(n),i=z(B(L(r),2),!0);A(r),Z(B(r,2),17,()=>W(d),X,(e,n,r)=>{var i=N(()=>_(W(n),2));let a=()=>W(i)[0],o=()=>W(i)[1];var s=us();let c;var l=L(s),u=z(l,!0),d=B(l,2),f=L(d);let h;A(d);var g=z(B(d,2));A(s),V((e,n,i)=>{c=ci(s,1,`report-row svelte-1fbui7h`,null,c,{unknown:e,alternate:r%2==1}),Q(l,`title`,a()),J(u,a()),h=ui(f,``,h,{width:n}),J(g,`${i??``}${t.mode===`periods`?`%`:``}`)},[()=>a().trim().toLowerCase()===`unknown`,()=>`${Math.max(0,100*o()/W(p))}%`,()=>m(o())]),q(e,s)}),A(n),V(()=>J(i,t.mode===`breakdown`?W(u):`QUOTA USED`)),q(e,n)},ue=e=>{q(e,fs())},de=e=>{q(e,ps())};Y(ce,e=>{W(d).length?e(le):t.mode===`breakdown`&&W(c)?.total===0&&W(c)?.groups[W(n)]!=null?e(ue,1):(W(i)&&t.mode===`breakdown`||W(a)&&t.mode===`periods`)&&e(de,2)}),A(te),V(()=>{C.disabled=W(s)>=W(o)-1,w.disabled=W(s)===0,J(T,W(o)?`${W(s)+1} / ${W(o)}`:`NO DATA`),J(ne,t.mode===`breakdown`?`DAILY BREAKDOWN`:`QUOTA WINDOWS`),J(ie,`${(t.mode===`breakdown`?t.reports?.dailyStatus||`UNAVAILABLE`:t.reports?.planStatus||`UNAVAILABLE`)??``} // UTC`)}),hi(y,()=>W(n),e=>I(n,e)),G(`click`,C,()=>I(r,W(s)+1)),G(`click`,w,()=>I(r,W(s)-1)),q(e,h),qe()}wr([`click`]);var gs=864e5;function _s(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 vs(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));for(let e=0;;e++){let i=_s(r,-t),a=new Date(i.getTime()+gs);if(e===n)return{start:a,end:r};r=i}}var ys=K(``),bs=K(``,1),xs=K(`

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

      `),Ss=K(`

      Token history unavailable; other reports may still be available.

      `),Cs=K(``),ws=K(`
      `),Ts=K(`

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

      `,1),Es=K(`
      `,1),Ds=K(` `),Os=K(`

      LIFETIME TOKENS

      PEAK DAY

      CURRENT STREAK

      DAYS

      LONGEST TURN

      SECONDS

      LONGEST STREAK

      DAYS

      OPENAI // UTC

      Accessible data table
      Date (UTC)Tokens

      `,1),ks=K(`

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

      `),As=K(`

      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 js(e,t){Ke(t,!0);let n=F(`daily`),r=F(12),i=F(0),a=N(()=>{let e=$.data?.usage?.dailyUsageBuckets;if(!e)return[];let{start:t,end:n}=vs(new Date,W(r),W(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=N(()=>Math.max(1,...W(a).map(e=>e.tokens))),s=N(()=>W(a).length?new Date(W(a)[0].date+`T00:00:00Z`).getUTCDay():0),c=N(()=>{if(W(n)===`monthly`){let e=new Map;for(let t of W(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 W(a).map(t=>({date:t.date,tokens:e+=t.tokens}))});var l=As(),u=B(R(l),4);Z(u,20,()=>[[`daily`,`Daily`],[`monthly`,`Monthly`],[`cumulative`,`Cumulative`],[`breakdown`,`Breakdown`],[`periods`,`Windows`]],X,(e,t)=>{var r=N(()=>_(t,2));let a=()=>W(r)[0],o=()=>W(r)[1];var s=ys();let c;var l=z(s,!0);V(()=>{Q(s,`aria-pressed`,W(n)===a()),c=ci(s,1,``,null,c,{active:W(n)===a()}),J(l,o())}),G(`click`,s,()=>{I(n,a(),!0),I(i,0)}),q(e,s)}),A(u);var d=B(u,2),f=L(d),p=e=>{var t=bs(),n=R(t),a=B(L(n)),o=L(a);o.value=o.__value=6;var s=B(o);s.value=s.__value=12,A(a),mi(a),A(n);var c=B(n),l=B(c);V(()=>l.disabled=W(i)===0),G(`change`,a,()=>I(i,0)),hi(a,()=>W(r),e=>I(r,e)),G(`click`,c,()=>Jt(i)),G(`click`,l,()=>Jt(i,-1)),q(e,t)};Y(f,e=>{W(n)!==`breakdown`&&W(n)!==`periods`&&e(p)}),A(d);var m=B(d,2),h=e=>{q(e,xs())};Y(m,e=>{$.data?.usageError&&e(h)});var g=B(m,2),v=e=>{q(e,Ss())};Y(g,e=>{$.data?.usage?.tokenStatus===`UNAVAILABLE`&&W(n)!==`breakdown`&&W(n)!==`periods`&&e(v)});var y=B(g,2),b=e=>{var t=Fr();qr(R(t),()=>W(n),e=>{{let t=N(()=>$.data?.usage?.reports);hs(e,{get reports(){return W(t)},get mode(){return W(n)}})}}),q(e,t)},x=e=>{var t=Os(),r=R(t),i=L(r),l=z(B(L(i),2),!0);A(i);var u=B(i,2),d=z(B(L(u),2),!0);A(u);var f=B(u,2),p=B(L(f),2),m=L(p);Te(),A(p),A(f);var h=B(f,2),g=B(L(h),2),_=L(g);Te(),A(g),A(h);var v=B(h,2),y=B(L(v),2),b=L(y);Te(),A(y),A(v),A(r);var x=B(r,4),S=L(x),ee=z(S),C=B(S,2),w=e=>{var t=Ts(),n=R(t),r=L(n),i=L(r);Z(i,17,()=>Array(W(s)),X,(e,t)=>{q(e,Cs())}),Z(B(i,2),17,()=>W(a),X,(e,t)=>{var n=ws();let r,i;V(e=>{r=ci(n,1,`heat-cell`,null,r,{zero:W(t).tokens===0}),Q(n,`title`,e),i=ui(n,``,i,{opacity:W(t).tokens?.25+.75*W(t).tokens/W(o):1})},[()=>`${W(t).date}: ${ia(W(t).tokens)} tokens`]),q(e,n)}),A(r),A(n),Te(2),q(e,t)},T=e=>{var t=Es(),r=R(t);{let e=N(()=>W(c).map(e=>e.tokens)),t=N(()=>W(n)+` usage`);qa(r,{get values(){return W(e)},get label(){return W(t)}})}var i=B(r,2),a=L(i),o=z(a,!0),s=z(B(a),!0);A(i),V(e=>{J(o,W(c)[0]?.date),J(s,e)},[()=>W(c).at(-1)?.date]),q(e,t)};Y(C,e=>{W(n)===`daily`?e(w):e(T,-1)});var te=B(C,2),E=B(L(te),2),ne=L(E),re=B(L(ne));Z(re,21,()=>W(n)===`daily`?W(a):W(c),X,(e,t)=>{var n=Ds(),r=L(n),i=z(r,!0),a=z(B(r),!0);A(n),V(e=>{J(i,W(t).date),J(a,e)},[()=>ia(W(t).tokens)]),q(e,n)}),A(re),A(ne),A(E),A(te),A(x);var ie=z(B(x,2));V((e,t,n,r,i,o,s)=>{J(l,e),J(d,t),J(m,`${n??``} `),J(_,`${r??``} `),J(b,`${i??``} `),J(ee,`${W(a)[0]?.date??``} — ${o??``}`),J(ie,`OBSERVED ${s??``} // CUMULATIVE IS FOR THE SELECTED PERIOD`)},[()=>ia($.data.usage.summary.lifetimeTokens),()=>ia($.data.usage.summary.peakDailyTokens),()=>ia($.data.usage.summary.currentStreakDays),()=>ia($.data.usage.summary.longestRunningTurnSec),()=>ia($.data.usage.summary.longestStreakDays),()=>W(a).at(-1)?.date,()=>aa($.data.usageAt)]),q(e,t)},S=e=>{q(e,ks())};Y(y,e=>{W(n)===`breakdown`||W(n)===`periods`?e(b):$.data?.usage&&$.data.usage.dailyUsageBuckets!==null?e(x,1):e(S,-1)}),q(e,l),qe()}wr([`click`,`change`]);var Ms=K(`

      Page not found

      Return to Quota

      `,1);function Ns(e){var t=Ms();Te(2),q(e,t)}var Ps=K(` `),Fs=K(`

      `),Is=K(`

      Connecting to your local Codexometer…

      `),Ls=K(``),Rs=K(`
      CODEXOMETER

      Your quota. Your sessions. Your command centre.

      `);function zs(e,t){Ke(t,!0);let n={"/":Wa,"/quota/:view?":Wa,"/sessions/:id?":ns,"/usage":js,"*":Ns},r={quota:/^(?:\/|\/quota(?:\/[^/]+)?\/?)$/,sessions:/^\/sessions(?:\/[^/]+)?\/?$/,usage:/^\/usage\/?$/},i=F(`hacker`),a=[`hacker`,`rust`,`blue-steel`,`ultraviolet`,`nightshade`];bn(()=>{$i()}),bn(()=>{if($.data)for(let[e,t]of Object.entries(r))t.test(Wi.location)&&(Qi.tab=e)}),Vi(()=>{try{let e=localStorage.getItem(`codexometer.web.theme`);e&&a.includes(e)&&I(i,e,!0)}catch{}return ua()});function o(){try{localStorage.setItem(`codexometer.web.theme`,W(i))}catch{}}var s=Rs(),c=L(s),l=B(L(c),2),u=L(l);let d;var f=B(u,1,!0),p=z(B(f));A(l),A(c);var m=B(c,2);Z(m,21,()=>Object.entries(r),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1],a=N(()=>i().test(Wi.location));var o=Ps();let s;var c=z(o,!0);V(e=>{Q(o,`href`,r()===`quota`?`#/quota/`+Qi.view:`#/`+r()),Q(o,`aria-current`,W(a)?`page`:void 0),s=ci(o,1,``,null,s,{active:W(a)}),J(c,e)},[()=>r().toUpperCase()]),q(e,o)}),A(m);var h=B(m,2),g=L(h),v=e=>{var t=Fs(),n=z(t,!0);V(()=>J(n,$.error)),q(e,t)};Y(g,e=>{$.error&&e(v)});var y=B(g,2),b=e=>{qi(e,{get routes(){return n}})},x=e=>{q(e,Is())};Y(y,e=>{$.data?e(b):$.error||e(x,1)}),A(h);var S=B(h,2),ee=L(S),C=z(ee),w=B(ee,2),T=z(w,!0),te=B(w,2),E=B(L(te));Z(E,21,()=>a,X,(e,t)=>{var n=Ls(),r=z(n,!0),i={};V(e=>{J(r,e),i!==(i=W(t))&&(n.value=(n.__value=i)??``)},[()=>W(t).replace(`-`,` `).toUpperCase()]),q(e,n)}),A(E),mi(E),A(te),A(S),A(s),V(()=>{Q(s,`data-theme`,W(i)),d=ci(u,1,`lamp`,null,d,{lit:$.connected}),J(f,$.connected?`CONNECTED`:`OFFLINE`),J(p,`EXPERIMENTAL // ${$.data?.control?`SESSION CONTROL`:`READ ONLY`}`),J(C,`v${($.data?.version||`…`)??``} // LOCAL ONLY`),J(T,$.data?.control?`Session control enabled. Stop the server to revoke access.`:`No actions can be sent from this preview.`)}),G(`change`,E,o),hi(E,()=>W(i),e=>I(i,e)),q(e,s),qe()}wr([`change`]),Vr(zs,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/web/dist/assets/index-BQmnXb7B.js b/internal/web/dist/assets/index-BQmnXb7B.js new file mode 100644 index 0000000..da7d96e --- /dev/null +++ b/internal/web/dist/assets/index-BQmnXb7B.js @@ -0,0 +1,41 @@ +(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,ee=1<<19,E=1<<20,D=1<<25,te=1<<21,ne=1<<22,re=1<<23,ie=Symbol(`$state`),ae=Symbol(`component`),O=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={},he=Symbol(`uninitialized`),ge=`http://www.w3.org/1999/xhtml`;function _e(){console.warn(`https://svelte.dev/e/derived_inert`)}function ve(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function ye(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function be(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var k=!1;function xe(e){k=e}var A;function Se(e){if(e===null)throw ve(),me;return A=e}function Ce(){return Se(cn(A))}function j(e){if(k){if(cn(A)!==null)throw ve(),me;A=e}}function we(e=1){if(k){for(var t=e,n=A;t--;)n=cn(n);A=n}}function Te(e=!0){for(var t=0,n=A;;){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=cn(n);e&&n.remove(),n=i}}function Ee(e){if(!e||e.nodeType!==8)throw ve(),me;return e.data}function De(e){return e===this.v}function Oe(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function ke(e){return!Oe(e,this.v)}function Ae(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function je(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function Me(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function Ne(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Pe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Fe(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ie(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Le(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Re(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function ze(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Be(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Ve(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var He=!1;function Ue(){He=!0}var M=null;function We(e){M=e}function Ge(e,t=!1,n){M={p:M,i:!1,c:null,e:null,s:e,x:null,r:U,l:He&&!t?{s:null,u:null,$:[]}:null}}function Ke(e){var t=M,n=t.e;if(n!==null){t.e=null;for(var r of n)xn(r)}return e!==void 0&&(t.x=e),t.i=!0,M=t.p,qe(e)}function qe(e={}){return i(e,ae,{value:!0}),e}function Je(){return!He||M!==null&&M.l===null}var Ye=[];function Xe(){var e=Ye;Ye=[],m(e)}function Ze(e){if(Ye.length===0&&!Tt){var t=Ye;queueMicrotask(()=>{t===Ye&&Xe()})}Ye.push(e)}function Qe(){for(;Ye.length>0;)Xe()}var $e=~(y|b|v);function et(e,t){e.f=e.f&$e|t}function tt(e){e.f&512||e.deps===null?et(e,v):et(e,b)}function nt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),et(e,v)}function rt(e){k&&sn(e)!==null&&ln(e)}var it=!1;function at(){it||(it=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[de]?.()})},{capture:!0}))}function ot(e){var t=H,n=U;Gn(null),Kn(null);try{return e()}finally{Gn(t),Kn(n)}}function st(e,t,n,r=n){e.addEventListener(t,()=>ot(n));let i=e[de];e[de]=i?()=>{i(),r(!0)}:()=>r(!0),at()}function ct(e,t,n,r){let i=Je()?ft:ht;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=U,c=lt(),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){mn(e,s)}ut()}}var d=dt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>mt(e))).then(u).catch(e=>mn(e,s)).finally(d)}l?l.then(()=>{c(),f(),ut()}):f()}function lt(){var e=U,t=H,n=M,r=P;return function(i=!0){Kn(e),Gn(t),We(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function ut(e=!0){Kn(null),Gn(null),We(null),e&&P?.deactivate()}function dt(){var e=U,t=e.b,n=P,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 ft(e){var t=2|y;return U!==null&&(U.f|=ee),{ctx:M,deps:null,effects:null,equals:De,f:t,fn:e,reactions:null,rv:0,v:he,wv:0,parent:U,ac:null}}var pt=Symbol(`obsolete`);function mt(e,t,n){let r=U;r===null&&je();var i=void 0,a=Ht(he),o=!H,s=new Set;return Tn(()=>{var t=U,n=h();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==fe&&n.reject(e)}).finally(ut)}catch(e){n.reject(e),ut()}var c=P;if(o){if(t.f&32768)var l=dt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(pt);else for(let e of s.values())e.reject(pt);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==pt&&(c.activate(),t?(a.f|=re,Kt(a,t)):(a.f&8388608&&(a.f^=re),Kt(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),yn(()=>{for(let e of s)e.reject(pt)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function N(e){let t=ft(e);return Jn(t),t}function ht(e){let t=ft(e);return t.equals=ke,t}function gt(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),lr(t,0),An(t))}function bt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&ur(t)}var xt=null,P=null,St=null,Ct=null,wt=null,Tt=!1,Et=!1,Dt=null,Ot=null,kt=0,At=1,jt=class e{id=At++;#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(){xt===null?xt=this:(xt.#n=this,this.#t=xt),xt=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)et(r,y),t(r);for(r of n.m)et(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),et(e,y),this.schedule(e);for(let e of this.#d)et(e,b),this.schedule(e);this.apply();for(var t=Dt=[],n=[],r=Ot=[];this.#c.length>0;){kt++>1e3&&(this.#S(),Nt());for(let e of this.#g())try{this.#v(e,t,n)}catch(t){throw Rt(e),this.#h()||this.discard(),t}}if(P=null,r.length>0){var i=e.ensure();for(let e of r)i.schedule(e)}if(Dt=null,Ot=null,this.#h()){this.#x(n),this.#x(t);for(let[e,t]of this.#f)Lt(e,t);r.length>0&&P.#_();return}let a=this.#y();if(a){this.#x(n),this.#x(t),a.#b(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),St=this,Ft(n),Ft(t),St=null,this.#s?.resolve();var o=P;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&&(Bt.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):ir(r)&&(i&16&&this.#d.add(r),ur(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),et(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),P=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(P===null){let t=P=new e;!Et&&!Tt&&Ze(()=>{t.#e||t.flush()})}return P}apply(){Ct=null}schedule(e){if(wt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}this.#c.push(e)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?xt=e:t.#t=e,this.linked=!1}}};function Mt(e){var t=Tt;Tt=!0;try{var n;for(e&&(P!==null&&!P.is_fork&&P.flush(),n=e());;){if(Qe(),P===null)return n;P.flush()}}finally{Tt=t}}function Nt(){try{Ie()}catch(e){mn(e,wt)}}var Pt=null;function Ft(e){var t=e.length;if(t!==0){for(var n=0;n0)){Bt.clear();for(let e of Pt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Pt.has(n)&&(Pt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||ur(n)}}Pt.clear()}}Pt=null}}function It(e){P.schedule(e)}function Lt(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),et(e,v);for(var n=e.first;n!==null;)Lt(n,t),n=n.next}}function Rt(e){et(e,v);for(var t=e.first;t!==null;)Rt(t),t=t.next}var zt=new Set,Bt=new Map,Vt=!1;function Ht(e,t){return{f:0,v:e,reactions:null,equals:De,rv:0,wv:0}}function F(e,t){let n=Ht(e,t);return Jn(n),n}function Ut(e,t=!1,n=!0){let r=Ht(e);return t||(r.equals=ke),He&&n&&M!==null&&M.l!==null&&(M.l.s??=[]).push(r),r}function I(e,t,n=!1){return H!==null&&(!Wn||H.f&131072)&&Je()&&H.f&4325394&&(qn===null||!qn.has(e))&&Be(),Kt(e,n?Zt(t):t,Ot)}var Wt=null,Gt=0;function Kt(e,t,n=null){if(!e.equals(t)){Hn?Bt.set(e,t):Bt.has(e)||Bt.set(e,e.v);var r=jt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&_t(t),Ct===null&&tt(t)}e.wv=rr(),Wt=null,Gt=0,Xt(e,y,n),Wt=null,Je()&&U!==null&&U.f&1024&&!(U.f&96)&&(Zn===null?Qn([e]):Zn.push(e)),!r.is_fork&&zt.size>0&&!Vt&&qt()}return t}function qt(){Vt=!1;for(let e of zt){e.f&1024&&et(e,b);let t;try{t=ir(e)}catch{t=!0}t&&ur(e)}zt.clear()}function Jt(e,t=1){var n=W(e),r=t===1?n++:n--;return I(e,n),r}function Yt(e){I(e,e.v+1)}function Xt(e,t,n){var r=e.reactions;if(r!==null){var i=Je(),a=r.length;if(Gt+=a,Gt>1e5&&Wt===null&&(Wt=new Set),Wt!==null){if(Wt.has(e))return;Wt.add(e)}for(var o=0;o{if(tr===d)return e();var t=H,n=tr;Gn(null),nr(d);var r=e();return Gn(t),nr(n),r};return i&&r.set(`length`,F(t.length,u)),new Proxy(t,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&Re();var i=r.get(t);return i===void 0?f(()=>{var e=F(n.value,u);return r.set(t,e),e}):I(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>F(he,u));r.set(t,e),Yt(o)}}else I(n,he),Yt(o);return!0},get(e,n,i){if(n===ie)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>F(Zt(s?e[n]:he),u)),r.set(n,o)),o!==void 0){var c=W(o);return c===he?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=W(i);if(a===he)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===ie)return!0;var n=r.get(t),i=n!==void 0&&n.v!==he||Reflect.has(e,t);return(n!==void 0||U!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>F(i?Zt(e[t]):he,u)),r.set(t,n)),W(n)===he)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dF(he,u)),r.set(d+``,p)):I(p,he)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>F(void 0,u)),I(c,Zt(n)),r.set(t,c));else{l=c.v!==he;var m=f(()=>Zt(n));I(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&&I(g,_+1)}Yt(o)}return!0},ownKeys(e){W(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==he});for(var[n,i]of r)i.v!==he&&!(n in e)&&t.push(n);return t},setPrototypeOf(){ze()}})}function Qt(e){try{if(typeof e==`object`&&e&&ie in e)return e[ie]}catch{}return e}function $t(e,t){return Object.is(Qt(e),Qt(t))}var en,tn,nn,rn;function an(){if(en===void 0){en=window,tn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;nn=a(t,`firstChild`).get,rn=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 on(e=``){return document.createTextNode(e)}function sn(e){return nn.call(e)}function cn(e){return rn.call(e)}function L(e,t){if(!k)return sn(e);var n=sn(A);if(n===null)n=A.appendChild(on());else if(t&&n.nodeType!==3){var r=on();return n?.before(r),Se(r),r}return t&&fn(n),Se(n),n}function R(e,t=!1){if(!k){var n=sn(e);return n instanceof Comment&&n.data===``?cn(n):n}if(t){if(A?.nodeType!==3){var r=on();return A?.before(r),Se(r),r}fn(A)}return A}function z(e,t=!1){if(!k)return sn(e);var n=L(e,t);return j(e),n}function B(e,t=1,n=!1){let r=k?A:e;for(var i;t--;)i=r,r=cn(r);if(!k)return r;if(n){if(r?.nodeType!==3){var a=on();return r===null?i?.after(a):r.before(a),Se(a),a}fn(r)}return Se(r),r}function ln(e){e.textContent=``}function un(){return!1}function dn(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 fn(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 pn(e){var t=U;if(t===null)return H.f|=re,e;if(!(t.f&32768)&&!(t.f&4))throw e;mn(e,t)}function mn(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 hn(e){U===null&&(H===null&&Fe(e),Pe()),Hn&&Ne(e)}function gn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function _n(e,t){var n=U;n!==null&&n.f&8192&&(e|=x);var r={ctx:M,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};P?.register_created_effect(r);var i=r;if(e&4)Dt===null?jt.ensure().schedule(r):Dt.push(r);else if(t!==null){try{ur(r)}catch(e){throw Mn(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&&gn(i,n),H!==null&&H.f&2&&!(e&64))){var a=H;(a.effects??=[]).push(i)}return r}function vn(){return H!==null&&!Wn}function yn(e){let t=_n(8,null);return et(t,v),t.teardown=e,t}function bn(e){hn(`$effect`);var t=U.f;if(!H&&t&32&&M!==null&&!M.i){var n=M;(n.e??=[]).push(e)}else return xn(e)}function xn(e){return _n(4|E,e)}function Sn(e){return hn(`$effect.pre`),_n(8|E,e)}function Cn(e){jt.ensure();let t=_n(64|ee,e);return(e={})=>new Promise(n=>{e.outro?Fn(t,()=>{Mn(t),n(void 0)}):(Mn(t),n(void 0))})}function wn(e){return _n(4,e)}function Tn(e){return _n(ne|ee,e)}function En(e,t=0){return _n(8|t,e)}function V(e,t=[],n=[],r=[]){ct(r,t,n,t=>{_n(8,()=>{e(...t.map(W))})})}function Dn(e,t=0){return _n(16|t,e)}function On(e){return _n(32|ee,e)}function kn(e){var t=e.teardown;if(t!==null){let n=Hn,r=H;Un(!0),Gn(null);try{t.call(null)}catch(t){mn(t,e.parent)}finally{Un(n),Gn(r)}}}function An(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&ot(()=>{e.abort(fe)});var r=n.next;n.f&64?n.parent=null:Mn(n,t),n=r}}function jn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Mn(t),t=n}}function Mn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Nn(e.nodes.start,e.nodes.end),n=!0),e.f|=w,An(e,t&&!n),lr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();kn(e),e.f^=w,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Pn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Nn(e,t){for(;e!==null;){var n=e===t?null:cn(e);e.remove(),e=n}}function Pn(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 Fn(e,t,n=!0){var r=[];e.f|=256,In(e,r,!0);var i=()=>{n&&Mn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function In(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);In(i,t,o?n:!1)}i=a}}}function Ln(e){e.f&=-257,Rn(e,!0)}function Rn(e,t){if(!(e.f&256)&&e.f&8192){e.f^=x,e.f&1024||(et(e,y),jt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=!!(n.f&65536)||!!(n.f&32);Rn(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 zn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:cn(n);t.append(n),n=i}}var Bn=null,Vn=!1,Hn=!1;function Un(e){Hn=e}var H=null,Wn=!1;function Gn(e){H=e}var U=null;function Kn(e){U=e}var qn=null;function Jn(e){H!==null&&(H.f&2097152||H.f&2)&&(qn??=new Set).add(e)}var Yn=null,Xn=0,Zn=null;function Qn(e){Zn=e}var $n=1,er=0,tr=er;function nr(e){tr=e}function rr(){return++$n}function ir(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&&Ct===null&&et(e,v)}return!1}function ar(e,t,n=!0){var r=e.reactions;if(r!==null&&!(qn!==null&&qn.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=sr(e);if(Je()&&Zn!==null&&!Wn&&f!==null&&!(e.f&6146))for(var p=0;p0)for(t.length=Xn+Yn.length,r=0;r{s.ac.abort(fe),s.ac=null,et(s,y)}),yt(s),lr(s,0)}}function lr(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,Ze(()=>{i.__removed||t.addEventListener(e,i,r)})):t.addEventListener(e,i,r),i}function Cr(e,t,n,r,i){var a={capture:r,passive:i},o=Sr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&yn(()=>{o.__removed=!0,t.removeEventListener(e,o,a)})}function G(e,t,n){(t[yr]??={})[e]=n}function wr(e){for(var t=0;t{Er=!1,Tr=null}));var s=0,c=Tr===e&&e[yr];if(c){var l=a.indexOf(c);if(l!==-1&&(t===document||t===window)){e[yr]=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=H,f=U;Gn(null),Kn(null);try{for(var p,m=[];o!==null&&o!==t;){try{var h=o[yr]?.[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[yr]=t,delete e.currentTarget,Gn(d),Kn(f)}}}var Or=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function kr(e){return Or?.createHTML(e)??e}function Ar(e){var t=dn(`template`);return t.innerHTML=kr(e.replaceAll(``,``)),t.content}function jr(e,t){var n=U;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function K(e,t){var n=!!(t&1),r=!!(t&2),i,a=!e.startsWith(``);return()=>{if(k)return jr(A,null),A;i===void 0&&(i=Ar(a?e:``+e),n||(i=sn(i)));var t=r||tn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=sn(t),s=t.lastChild;jr(o,s)}else jr(t,t);return t}}function Mr(e,t,n=`svg`){var r=!e.startsWith(``),i=!!(t&1),a=`<${n}>${r?e:``+e}`,o;return()=>{if(k)return jr(A,null),A;if(!o){var e=sn(Ar(a));if(i)for(o=document.createDocumentFragment();sn(e);)o.appendChild(sn(e));else o=sn(e)}var t=o.cloneNode(!0);if(i){var n=sn(t),r=t.lastChild;jr(n,r)}else jr(t,t);return t}}function Nr(e,t){return Mr(e,t,`svg`)}function Pr(e=``){if(!k){var t=on(e+``);return jr(t,t),t}var n=A;return n.nodeType===3?fn(n):(n.before(n=on()),Se(n)),jr(n,n),n}function Fr(){if(k)return jr(A,null),A;var e=document.createDocumentFragment(),t=document.createComment(``),n=on();return e.append(t,n),jr(t,n),e}function q(e,t){if(k){var n=U;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=A),Ce();return}e!==null&&e.before(t)}function Ir(){if(k&&A&&A.nodeType===8&&A.textContent?.startsWith(`$`)){let e=A.textContent.substring(1);return Ce(),e}return(window.__svelte??={}).uid??=1,`c${window.__svelte.uid++}`}function Lr(e){let t=0,n=Ht(0),r;return()=>{vn()&&(W(n),En(()=>(t===0&&(r=mr(()=>e(()=>Yt(n)))),t+=1,()=>{Ze(()=>{--t,t===0&&(r?.(),r=void 0,Yt(n))})})))}}var Rr=T|ee;function zr(e,t,n,r){new Br(e,t,n,r)}var Br=class{parent;is_pending=!1;transform_error;#e;#t=k?A: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=Lr(()=>(this.#m=Ht(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=U;t.b=this,t.f|=128,n(e)},this.parent=U.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Dn(()=>{if(k){let e=this.#t;Ce();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()},Rr),k&&(this.#e=A)}#g(){try{this.#a=On(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed,{reset:n,invoke_onerror:r}=this.#v(e);Ze(r),t&&(this.#s=On(()=>{t(this.#e,()=>e,()=>n)}))}#v(e){var t=!1,n=!1;let r=()=>{if(t){be();return}t=!0,n&&Ve(),this.#s!==null&&Fn(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){mn(e,this.#i&&this.#i.parent)}}}}#y(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=On(()=>e(this.#e)),Ze(()=>{var e=this.#c=document.createDocumentFragment(),t=on(),n=!1;if(e.append(t),this.#a=this.#S(()=>{try{return On(()=>this.#r(t))}catch(e){try{this.error(e),n=!0}catch(e){mn(e,this.#i.parent)}return null}}),this.#a===null){this.#c=null,n&&this.#x(P);return}this.#u===0&&(this.#e.before(e),this.#c=null,Fn(this.#o,()=>{this.#o=null}),this.#x(P))}))}#b(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=On(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();zn(this.#a,e);let t=this.#n.pending;this.#o=On(()=>t(this.#e))}else this.#x(P)}catch(e){this.error(e)}}#x(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){nt(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=U,n=H,r=M;Kn(this.#i),Gn(this.#i),We(this.#i.ctx);try{return jt.ensure(),e()}finally{Kn(t),Gn(n),We(r)}}#C(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#C(e,t);return}this.#u+=e,this.#u===0&&(this.#x(t),this.#o&&Fn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#C(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,Ze(()=>{this.#d=!1,this.#m&&Kt(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),W(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;P?.is_fork?(this.#a&&P.skip_effect(this.#a),this.#o&&P.skip_effect(this.#o),this.#s&&P.skip_effect(this.#s),P.oncommit(()=>{this.#w(e)})):this.#w(e)}#w(e){this.#a&&=(Mn(this.#a),null),this.#o&&=(Mn(this.#o),null),this.#s&&=(Mn(this.#s),null),k&&(Se(this.#t),we(),Se(Te()));let t=this.#n.failed,n=e=>{let{reset:n,invoke_onerror:r}=this.#v(e);r(),t&&(this.#s=this.#S(()=>{try{return On(()=>{var r=U;r.b=this,r.f|=128,t(this.#e,()=>e,()=>n)})}catch(e){return mn(e,this.#i.parent),null}}))};Ze(()=>{var t;try{t=this.transform_error(e)}catch(e){mn(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(n,e=>mn(e,this.#i&&this.#i.parent)):n(t)})}};function J(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[ue]??=e.nodeValue)&&(e[ue]=n,e.nodeValue=`${n}`)}function Vr(e,t){return Ur(e,t)}var Hr=new Map;function Ur(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){an();var l=void 0,u=Cn(()=>{var s=n??t.appendChild(on());zr(s,{pending:()=>{}},t=>{Ge({});var n=M;if(o&&(n.c=o),a&&(i.$$events=a),k&&jr(t,null),l=e(t,i)||qe(),k&&(U.nodes.end=A,A===null||A.nodeType!==8||A.data!==`]`))throw ve(),me;Ke()},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=Hr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Dr),r.delete(e),r.size===0&&Hr.delete(n)):r.set(e,i)}xr.delete(d),s!==n&&s.parentNode?.removeChild(s)}});return Wr.set(l,u),l}var Wr=new WeakMap,Gr=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)Ln(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Ln(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&&(Mn(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();zn(r,t),t.append(on()),this.#n.set(e,{effect:r,fragment:t})}else Mn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Fn(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)||(Mn(n.effect),this.#n.delete(e))};ensure(e,t){var n=P,r=un();if(t&&!this.#t.has(e)&&!this.#n.has(e)){if(r){var i=document.createDocumentFragment(),a=on();i.append(a),this.#n.set(e,{effect:On(()=>t(a)),fragment:i})}else this.#t.set(e,On(()=>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 k&&(this.anchor=A),this.#a(n)}};function Y(e,t,n=!1){var r;k&&(r=A,Ce());var i=new Gr(e),a=n?T:0;function o(e,t){if(k){var n=Ee(r);if(e!==parseInt(n.substring(1))){var a=Te();Se(a),i.anchor=a,xe(!1),i.ensure(e,t),xe(!0);return}}i.ensure(e,t)}Dn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var Kr=Symbol(`NaN`);function qr(e,t,n){k&&Ce();var r=new Gr(e),i=!Je();Dn(()=>{var e=t();e!==e&&(e=Kr),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function X(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;ln(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^=D,ei(d,null,c)):Ln(d):Fn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Dn(()=>{p=W(f);var e=p.length;let t=!1;k&&Ee(c)===`[!`!=(e===0)&&(c=Te(),Se(c),xe(!1),t=!0);for(var r=new Set,u=P,v=un(),y=0;ys(c)):(d=On(()=>s(Xr??=on())),d.f|=D)),e>r.size&&Me(``,``,``),k&&e>0&&Se(Te()),!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&&xe(!0),W(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,k&&(c=A)}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 ee=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?Ht(n):Ut(n,!1,!1):null,l=o&2?Ht(i):null;return{v:c,i:l,e:On(()=>(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=cn(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;k&&(r=A,Ce());var i=new Gr(e);Dn(()=>{var e=t()??null;if(k&&Ee(r)===`[`!=(e!==null)){var a=Te();Se(a),i.anchor=a,xe(!1),i.ensure(e,e&&(t=>n(t,e))),xe(!0);return}i.ensure(e,e&&(t=>n(t,e)))},T)}var ri=[...` +\r\f\xA0\v`];function ii(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||ri.includes(r[o-1]))&&(s===r.length||ri.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function ai(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 oi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function si(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(oi)),i&&c.push(...Object.keys(i).map(oi));var l=0,u=-1;let t=e.length;for(var d=0;d{t.every(_i)||(`__defaultValue`in e&&fi(e,!1),`__value`in e&&pi(e,e.__value))});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),yn(()=>{t.disconnect()})}function hi(e,t,n=t){var r=new WeakSet,i=!0;st(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),gi);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&gi(o)}n(a),e.__value=a,P!==null&&r.add(P)}),wn(()=>{var a=t();if(e===document.activeElement){var o=P;if(r.has(o))return}if(pi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=gi(s),n(a))}e.__value=a,i=!1})}function gi(e){return`__value`in e?e.__value:e.value}function _i(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 vi=Symbol(`is custom element`),yi=Symbol(`is html`),bi=pe?`link`:`LINK`;function xi(e){if(k){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,Ze(n),at()}}function Q(e,t,n,r){var i=Si(e);k&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===bi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[oe]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&wi(e).has(t)?e[t]=n:e.setAttribute(t,n))}function Si(e){return e[se]??={[vi]:e.nodeName.includes(`-`),[yi]:e.namespaceURI===ge}}var Ci=new Map;function wi(e){var t=e.getAttribute(`is`)||e.nodeName,n=Ci.get(t);if(n)return n;Ci.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 Ti(e,t,n=t){var r=new WeakSet;st(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=ki(e)?Ai(a):a,n(a),P!==null&&r.add(P),await dr(),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))}}}),(k&&e.defaultValue!==e.value||mr(t)==null&&e.value)&&(n(ki(e)?Ai(e.value):e.value),P!==null&&r.add(P)),En(()=>{var n=t();if(e===document.activeElement){var i=P;if(r.has(i))return}ki(e)&&n===Ai(e.value)||(e.type!==`date`||n||e.value)&&n!==e.value&&(e.value=n??``)})}var Ei=new Set;function Di(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),st(n,`change`,()=>{var e=n.__value;a&&(e=Oi(o,e,n.checked)),i(e)},()=>i(a?[]:null)),En(()=>{var e=r();if(k&&n.defaultChecked!==n.checked){s=!0;return}a?(e||=[],n.checked=e.includes(n.__value)):n.checked=$t(n.__value,e)}),yn(()=>{var e=o.indexOf(n);e!==-1&&o.splice(e,1)}),Ei.has(o)||(Ei.add(o),Ze(()=>{o.sort((e,t)=>e.compareDocumentPosition(t)===4?-1:1),Ei.delete(o)})),Ze(()=>{if(s){var e=a?Oi(o,e,n.checked):o.find(e=>e.checked)?.__value;i(e)}})}function Oi(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 Mi(e,t,n){var r=ji.observe(e,()=>n(e[t]));wn(()=>(mr(()=>n(e[t])),r))}function Ni(e,t,n,r,i){var a=()=>{r(n[e])};n.addEventListener(t,a),i?En(()=>{n[e]=i()}):a(),(n===document.body||n===window||n===document)&&yn(()=>{n.removeEventListener(t,a)})}function Pi(e=!1){let t=M,n=t.l.u;if(!n)return;let r=()=>hr(t.s);if(e){let e=0,n={},i=ft(()=>{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=()=>W(i)}n.b.length&&Sn(()=>{Fi(t,r),m(n.b)}),bn(()=>{let e=mr(()=>n.m.map(p));return()=>{for(let t of e)typeof t==`function`&&t()}}),n.a.length&&bn(()=>{Fi(t,r),m(n.a)})}function Fi(e,t){if(e.l.s)for(let t of e.l.s)W(t);t()}var Ii=!1;function Li(e){var t=Ii;try{return Ii=!1,[e(),Ii]}finally{Ii=t}}var Ri={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===ie||t===O)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 zi(...e){return new Proxy({props:e},Ri)}function Bi(e,t,n,r){var i=!He||!!(n&2),o=!!(n&8),s=!!(n&16),c=r,l=!0,u=void 0,d=()=>s&&i?(u??=ft(r),W(u)):(l&&(l=!1,c=s?mr(r):r),c);let f;if(o){var p=ie in e||O in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=Li(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&Le(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?ft:ht)(()=>(v=!1,g()));o&&W(y);var b=U;return(function(e,t){if(arguments.length>0){let n=t?W(y):i&&o?Zt(e):e;return I(y,n),v=!0,c!==void 0&&(c=n),e}return Hn&&v||b.f&16384?y.v:W(y)})}function Vi(e){M===null&&Ae(`onMount`),He&&M.l!==null?Hi(M).m.push(e):bn(()=>{let t=mr(e);if(typeof t==`function`)return t})}function Hi(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);function Ui(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 Wi=new class{#e=F(Gi());get _loc(){return W(this.#e)}set _loc(e){I(this.#e,e)}#t=N(()=>this._loc.location);get _location(){return W(this.#t)}set _location(e){I(this.#t,e)}#n=N(()=>this._loc.querystring);get _querystring(){return W(this.#n)}set _querystring(e){I(this.#n,e)}#r=F(void 0);get _params(){return W(this.#r)}set _params(e){I(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=Gi()}):console.warn(`[svelte-spa-router] window 'window' is not defined, skipping initiation`)}};function Gi(){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}}function Ki(e){e?window.scrollTo(e.__svelte_spa_router_scrollX||0,e.__svelte_spa_router_scrollY||0):window.scrollTo(0,0)}function qi(e,t){Ge(t,!0);let n=Bi(t,`routes`,19,()=>({})),r=Bi(t,`prefix`,3,``),i=Bi(t,`restoreScrollState`,3,!1),a=Bi(t,`onConditionsFailed`,3,()=>{}),o=Bi(t,`onRouteLoaded`,3,()=>{}),s=Bi(t,`onRouteLoading`,3,()=>{}),c=Bi(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=Ui(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=F(null),f=F(null),p=F({}),m=null,h=null;bn(()=>{history.scrollRestoration=i()?`manual`:`auto`}),bn(()=>{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 dr(),e(t)}bn(()=>{let e=Wi.loc,t=!1;return mr(async()=>{let n=0;for(;n{t=!0}});function _(e){return e&&typeof e==`object`&&Object.keys(e).length?e:null}var v=Fr(),y=R(v),b=e=>{let t=N(()=>W(d));var n=Fr(),r=R(n),i=e=>{var n=Fr();ni(R(n),()=>W(t),(e,t)=>{t(e,zi({get params(){return W(f)},get onRouteEvent(){return c()}},()=>W(p)))}),q(e,n)},a=e=>{var n=Fr();ni(R(n),()=>W(t),(e,t)=>{t(e,zi({get onRouteEvent(){return c()}},()=>W(p)))}),q(e,n)};Y(r,e=>{W(f)?e(i):e(a,-1)}),q(e,n)};Y(y,e=>{W(d)&&e(b)}),q(e,v),Ke()}var Ji=[`bars`,`pace`,`zone`,`pie`,`fuel`,`resets`,`thresholds`],Yi=`codexometer.web.preferences.v1`,Xi={tab:`quota`,view:`bars`,selected:``,defaultDetail:0,layouts:[]};function Zi(){try{let e=JSON.parse(localStorage.getItem(Yi)||`null`);return!e||typeof e!=`object`?Xi:{tab:[`quota`,`sessions`,`usage`].includes(e.tab)?e.tab:`quota`,view:Ji.includes(e.view)?e.view:`bars`,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 Xi}}var Qi=Zt(Zi());function $i(){let e=JSON.stringify(Qi);try{localStorage.setItem(Yi,e)}catch{}}function ea(){return Qi.tab===`quota`?`/quota/`+Qi.view:`/`+Qi.tab}function ta(e){return Qi.layouts.find(t=>t.id===e)?.level??Qi.defaultDetail}function na(e){Qi.defaultDetail=e,Qi.layouts=[]}function ra(e,t){Qi.layouts=[...Qi.layouts.filter(t=>t.id!==e),{id:e,level:Math.max(0,Math.min(2,t))}].slice(-100)}var $=Zt({data:null,connected:!1,error:``}),ia=e=>e==null?`Unavailable`:e.toLocaleString(`en-GB`),aa=e=>!e||String(e).startsWith(`0001-`)?`Not yet available`:new Date(typeof e==`number`?e*1e3:e).toLocaleString(`en-GB`),oa=`codexometer.web.session`,sa=class extends Error{},ca;async function la(e,t,n){if(!ca||!$.connected||!$.data?.control||$.data.sessionsError)throw Error(`Session controls unavailable. Check the live connection.`);return await ca(e,t,n)}function ua(){let e=new AbortController,t,n=``;ca=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 sa(`Action rejected, expired or changed. Refresh and check Codex; nothing was retried.`);return a.json()};try{n=sessionStorage.getItem(oa)||``}catch{}let r=location.hash,i=r.startsWith(`#pair=`)?r.slice(6):``;(i||!r||r===`#`)&&(history.replaceState(null,``,`/#`+ea()),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(oa,n)}catch{}}catch(t){e.signal.aborted||($.error=t instanceof Error?t.message:`Pairing failed`);return}if(!n){$.error=`Open the private pairing link printed by codexometer --web in your terminal.`;return}await o()}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(oa)}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(),()=>{ca=void 0,e.abort(),clearTimeout(t),$.connected=!1}}Ue();var da=K(`

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

      `),fa=K(`

      `),pa=K(`

      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),ma=K(`

      No threshold-based model steps were configured at launch.

      `);function ha(e,t){Ge(t,!1),Pi();var n=Fr(),r=R(n),i=e=>{var t=pa(),n=R(t),r=z(n),i=B(n,2),a=e=>{q(e,da())};Y(i,e=>{$.data.quotaError&&e(a)});var o=B(i,2),s=L(o),c=z(s),l=B(s,4);Z(l,5,()=>$.data.thresholds,X,(e,t)=>{var n=fa();let r;var i=L(n),a=z(i),o=B(i,2),s=L(o),c=z(s,!0),l=z(B(s,2));j(o);var u=B(o,2),d=z(u,!0),f=z(B(u,2));j(n),V((e,i)=>{r=ci(n,1,``,null,r,{active:W(t).state===`ACTIVE`,next:W(t).state===`NEXT`}),J(a,`${W(t).threshold??``}%`),J(c,W(t).model),J(l,`${e??``} REASONING // ${i??``} + SPEED`),J(d,W(t).mode),J(f,`${W(t).state??``}${W(t).state===`NEXT`?` // ${W(t).remaining||0} PP TO GO`:``}`)},[()=>W(t).effort.toUpperCase(),()=>W(t).speed.toUpperCase()]),q(e,n)}),j(l),j(o),V(e=>{J(r,`MODEL STEP POLICY // OBSERVED ${e??``}`),J(c,`THRESHOLDS // ${$.data.thresholds.length??``} CONFIGURED`)},[()=>aa($.data.quotaAt)]),q(e,t)},a=e=>{q(e,ma())};Y(r,e=>{$.data?.thresholds?.length?e(i):e(a,-1)}),q(e,n),Ke()}var ga=Nr(` `,1),_a=Nr(` `,1),va=K(` `),ya=K(`
      Quota observations
      Observed atPeriod elapsedConsumedTrail segment
      `),ba=K(`


      Observed quota + path, not individual session usage. Gaps are not interpolated. Expand the + observation table for times, positions and gaps.

      OBSERVATION TABLE
      `,1),xa=K(`
      CONSUMPTIONQUOTA PERIOD ELAPSED


      `,1);function Sa(e,t){let n=Ir();Ge(t,!0);let r=Bi(t,`trail`,19,()=>[]),i=F(!1),a=[0,25,50,75,100],o=F(400),s=F(240),c=N(()=>W(o)-24),l=N(()=>W(s)-48),u=N(()=>Math.max(1,W(c)-48)),d=N(()=>Math.max(1,W(l)-20)),f=N(()=>48+Math.max(0,Math.min(100,t.elapsed))/100*W(u)),p=N(()=>W(l)-Math.max(0,Math.min(100,t.used))/100*W(d)),m=N(()=>t.used-t.elapsed),h=N(()=>r().map((e,t)=>`${t===0||e.break?`M`:`L`}${48+e.elapsed/100*W(u)} ${W(l)-e.used/100*W(d)}`).join(` `));var g=xa(),_=R(g),v=L(_),y=L(v),b=z(y),x=B(y),S=B(x);Z(S,17,()=>a,X,(e,t)=>{var n=ga(),r=R(n),i=B(r),a=B(i),o=z(a),s=B(a),f=z(s);V(()=>{Q(r,`x1`,48+W(t)/100*W(u)),Q(r,`x2`,48+W(t)/100*W(u)),Q(r,`y2`,W(l)),Q(i,`y1`,W(l)-W(t)/100*W(d)),Q(i,`x2`,W(c)),Q(i,`y2`,W(l)-W(t)/100*W(d)),Q(a,`x`,48+W(t)/100*W(u)),Q(a,`y`,W(l)+20),J(o,`${W(t)??``}%`),Q(s,`y`,W(l)+4-W(t)/100*W(d)),J(f,`${W(t)??``}%`)}),q(e,n)});var C=B(S),w=B(C),T=B(w),ee=e=>{var t=_a(),n=R(t),i=B(n),a=z(L(i));j(i),V(e=>{Q(n,`d`,W(h)),Q(i,`cx`,48+r()[0].elapsed/100*W(u)),Q(i,`cy`,W(l)-r()[0].used/100*W(d)),J(a,`First observation: ${e??``}`)},[()=>aa(r()[0].at)]),q(e,t)};Y(T,e=>{r().length&&e(ee)});var E=B(T,2),D=B(E),te=B(D),ne=z(L(te));j(te),j(v),j(_);var re=B(_,2),ie=L(re),ae=z(B(ie,3),!0);j(re);var O=B(re,2),oe=e=>{var t=ba(),a=R(t),o=L(a);we(2),j(a);var s=B(a,2),c=B(L(s),2),l=e=>{var t=ya(),n=L(t),i=B(L(n),2);Z(i,21,r,X,(e,t,n)=>{var r=va(),i=L(r),a=L(i),o=z(a,!0);j(i);var s=B(i),c=z(s),l=B(s),u=z(l),d=z(B(l),!0);j(r),V((e,r)=>{Q(a,`datetime`,W(t).at),J(o,e),J(c,`${r??``}%`),J(u,`${W(t).used??``}%`),J(d,n===0?`First observation`:W(t).break?`Gap before this observation`:`Connected to previous observation`)},[()=>aa(W(t).at),()=>W(t).elapsed.toFixed(1)]),q(e,r)}),j(i),j(n),j(t),q(e,t)};Y(c,e=>{W(i)&&e(l)}),j(s),V(e=>{Q(a,`id`,n+`-trail-summary`),J(o,`○ START ${e??``} // ${r().length??``} + ${r().length===1?`OBSERVATION`:`OBSERVATIONS`}`)},[()=>aa(r()[0].at)]),Ni(`open`,`toggle`,s,e=>I(i,e),()=>W(i)),q(e,t)};Y(O,e=>{r().length&&e(oe)}),V((e,i,a,m)=>{Q(v,`viewBox`,`0 0 ${W(o)} ${W(s)}`),Q(v,`aria-describedby`,r().length?n+`-trail-summary`:void 0),Q(v,`aria-label`,e),Q(b,`id`,n),Q(x,`width`,W(u)),Q(x,`height`,W(d)),Q(x,`fill`,`url(#${n})`),Q(C,`d`,`M48 20 V${W(l)} H${W(c)}`),Q(w,`y1`,W(l)),Q(w,`x2`,W(c)),Q(E,`x`,48+W(u)/2),Q(E,`y`,W(s)-5),Q(D,`cx`,W(f)),Q(D,`cy`,W(p)),Q(te,`cx`,W(f)),Q(te,`cy`,W(p)),J(ne,`${t.used??``}% consumed // ${i??``}% of period elapsed`),J(ie,`${t.used??``}% USED // ${a??``}% TIME ELAPSED`),J(ae,m)},[()=>`Consumption zone: ${t.used}% consumed, ${t.elapsed.toFixed(1)}% of quota period elapsed. ${W(m)>0?`Above`:W(m)<0?`Below`:`On`} the steady-consumption line.`,()=>t.elapsed.toFixed(1),()=>t.elapsed.toFixed(1),()=>Math.abs(W(m))<.05?`ON PACE`:W(m)>0?`ABOVE THE LINE — CONSUMING FASTER THAN TIME`:`BELOW THE LINE — WITHIN PACE`]),Mi(_,`clientWidth`,e=>I(o,e)),Mi(_,`clientHeight`,e=>I(s,e)),q(e,g),Ke()}var Ca=K(` `),wa=K(`

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

      `),Ta=K(`

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

      `),Ea=K(`

      `),Da=K(`

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

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

      `),Oa=K(` `,1),ka=Nr(``),Aa=Nr(``),ja=K(`
      `),Ma=K(`

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

      `),Na=K(`
      ▼
      −100 // OVER BUDGET+100 // HEADROOM

      `,1),Pa=K(`

      Cycle duration unavailable — pace cannot be calculated.

      `),Fa=K(`
      EMPTYFULL
      `),Ia=K(`

      `,1),La=K(`
      `,1),Ra=K(`

      `),za=K(`

      `),Ba=K(`

      No quota windows reported yet.

      `),Va=K(`
      `,1),Ha=K(`

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

      `,1),Ua=K(` `,1);function Wa(e,t){Ge(t,!0);let n=Bi(t,`params`,19,()=>({})),r=N(()=>Ji.filter(e=>e!==`thresholds`||!!$.data?.thresholds?.length)),i=F(Zt(Date.now())),a=N(()=>W(r).includes(n().view||``)?n().view:`bars`);Vi(()=>{let e=setInterval(()=>I(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-W(i))/(e.duration*6e4))))}bn(()=>{Qi.view=W(a)});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=Ua(),l=R(c);Z(l,21,()=>W(r),X,(e,t)=>{var n=Ca();let r;var i=z(n,!0);V(e=>{Q(n,`href`,`#/quota/`+W(t)),Q(n,`aria-current`,W(a)===W(t)?`page`:void 0),r=ci(n,1,``,null,r,{active:W(a)===W(t)}),J(i,e)},[()=>W(t)===`pace`?`CONSUMPTION PACE`:W(t)===`zone`?`CONSUMPTION ZONE`:W(t)===`fuel`?`FUEL TANK`:W(t).toUpperCase()]),q(e,n)}),j(l);var u=B(l,2),d=e=>{var t=Ha(),n=R(t),r=e=>{q(e,wa())};Y(n,e=>{$.data.quotaError&&e(r)});var i=B(n,2),c=z(i),l=B(i,2),u=e=>{ha(e,{})},d=e=>{var t=Da(),n=L(t),r=z(n),i=B(n,4),a=e=>{q(e,Ta())};Y(i,e=>{$.data.credits.length||e(a)}),Z(B(i,2),17,()=>$.data.credits,X,(e,t)=>{var n=Ea(),r=L(n),i=z(r),a=z(B(r,2),!0);j(n),V(e=>{J(i,`${(W(t).title||`Quota reset`)??``} // ${W(t).status??``}`),J(a,e)},[()=>W(t).expiryKnown?W(t).expires?`EXPIRES `+aa(W(t).expires):`Does not expire`:`Expiry information unavailable`]),q(e,n)}),we(2),j(t),V(()=>J(r,`RESET INVENTORY // ${$.data.creditCount??``} AVAILABLE`)),q(e,t)},f=e=>{var t=Va(),n=R(t);let r;Z(n,21,()=>$.data.meters,X,(e,t)=>{let n=N(()=>o(W(t))),r=N(()=>W(n)===null?null:W(n)-W(t).used);var i=za(),c=L(i),l=z(c,!0),u=B(c,2),d=L(u),f=e=>{var n=Oa(),r=R(n),i=z(r),a=z(B(r));V(()=>{J(i,`FREE ${100-W(t).used}%`),J(a,`USED ${W(t).used??``}%`)}),q(e,n)},p=e=>{var n=Oa(),r=R(n),i=z(r),a=z(B(r));V(()=>{J(i,`USED ${W(t).used??``}%`),J(a,`FREE ${100-W(t).used}%`)}),q(e,n)};Y(d,e=>{W(a)===`fuel`?e(f):e(p,-1)}),j(u);var m=B(u,2);let h;var g=L(m),_=e=>{var n=ja(),r=L(n),i=B(L(r)),a=e=>{q(e,ka())},o=e=>{var n=Aa();V(e=>Q(n,`d`,e),[()=>s(W(t).used)]),q(e,n)};Y(i,e=>{W(t).used>=100?e(a):W(t).used>0&&e(o,1)}),j(r),j(n),V(()=>Q(r,`aria-label`,`${W(t).used}% quota used`)),q(e,n)},v=e=>{var r=Fr(),i=R(r),a=e=>{{let r=N(()=>W(t).trail||[]);Sa(e,{get used(){return W(t).used},get elapsed(){return W(n)},get trail(){return W(r)}})}},o=e=>{q(e,Ma())};Y(i,e=>{W(n)===null?e(o,-1):e(a)}),q(e,r)},y=e=>{var t=Fr(),n=R(t),i=e=>{var t=Na(),n=R(t),i=B(L(n),2);let a;j(n);var o=B(n,4),s=L(o),c=z(B(s),!0);j(o),V(e=>{a=ui(i,``,a,{left:`${(W(r)+100)/2}%`}),J(s,`${W(r)>=0?`+`:``}${e??``} PP `),J(c,W(r)>=0?`WITHIN PACE`:`USING FASTER THAN TIME`)},[()=>W(r).toFixed(1)]),q(e,t)},a=e=>{q(e,Pa())};Y(n,e=>{W(r)===null?e(a,-1):e(i)}),q(e,t)},b=e=>{var r=La(),i=R(r),o=L(i);let s;j(i);var c=B(i,2),l=e=>{q(e,Fa())};Y(c,e=>{W(a)===`fuel`&&e(l)});var u=B(c,2),d=e=>{var t=Ia(),r=R(t),i=z(r),o=B(r,2),s=L(o);let c;j(o),V(e=>{J(i,`RESET CYCLE // ${e??``}% ELAPSED`),c=ui(s,``,c,{width:`${W(a)===`fuel`?100-W(n):W(n)}%`})},[()=>Math.floor(W(n))]),q(e,t)};Y(u,e=>{W(n)!==null&&e(d)}),V(()=>{Q(i,`aria-label`,W(a)===`fuel`?`Fuel remaining`:`Quota used`),Q(i,`aria-valuenow`,W(a)===`fuel`?100-W(t).used:W(t).used),s=ui(o,``,s,{width:`${W(a)===`fuel`?100-W(t).used:W(t).used}%`})}),q(e,r)};Y(g,e=>{W(a)===`pie`?e(_):W(a)===`zone`?e(v,1):W(a)===`pace`?e(y,2):e(b,-1)}),j(m);var x=B(m,2),S=z(x),C=B(x,2),w=e=>{var n=Ra(),r=z(n,!0);V(()=>J(r,W(t).details)),q(e,n)};Y(C,e=>{W(t).details&&e(w)}),j(i),V(e=>{J(l,W(t).name),h=ci(m,1,`meter-graphic`,null,h,{"bar-graphic":W(a)===`bars`||W(a)===`fuel`}),J(S,`RESETS // ${e??``}`)},[()=>aa(W(t).reset)]),q(e,i)}),j(n);var i=B(n,2),c=e=>{q(e,Ba())};Y(i,e=>{$.data.meters.length||e(c)}),V(()=>r=ci(n,1,`quota-grid`,null,r,{radial:W(a)===`pie`,zone:W(a)===`zone`})),q(e,t)};Y(l,e=>{W(a)===`thresholds`?e(u):W(a)===`resets`?e(d,1):e(f,-1)}),we(2),V(e=>J(c,`QUOTA // OBSERVED ${e??``}`),[()=>aa($.data.quotaAt)]),q(e,t)};Y(u,e=>{$.data&&e(d)}),q(e,c),Ke()}var Ga=K(`
      `),Ka=K(`

      `,1);function qa(e,t){Ge(t,!0);let n=Bi(t,`values`,19,()=>[]),r=Bi(t,`label`,3,`Token activity`),i=Bi(t,`capacity`,3,0),a=N(()=>Math.max(0,...n())),o=N(()=>i()>n().length?[...Array(i()-n().length).fill(0),...n()]:n());var s=Ka(),c=R(s),l=z(c),u=B(c,2);Z(u,21,()=>W(o),X,(e,t)=>{var n=Ga();let r;V((e,t)=>{Q(n,`title`,e),r=ui(n,``,r,{height:t})},[()=>W(t).toLocaleString(`en-GB`)+` tokens`,()=>`${100*W(t)/Math.max(1,W(a))}%`]),q(e,n)}),j(u),V((e,t)=>{J(l,`SCALE // 0 — ${e??``} TOKENS`),Q(u,`aria-label`,t)},[()=>W(a).toLocaleString(`en-GB`),()=>`${r()}. Peak ${W(a).toLocaleString(`en-GB`)} tokens.`]),q(e,s),Ke()}var Ja=K(`

       

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

      `),Ya=K(`

      CURRENT PROFILE

      MODEL / REASONING LEVEL / SPEED

       

      PROPOSED PROFILE

      MODEL / REASONING LEVEL / SPEED

       

      Applied settings remain after Codexometer closes.

      `,1),Xa=K(`

      `),Za=K(`

       
      `,1),Qa=K(`

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

      `),$a=K(`

      Session controls temporarily unavailable. Check Codex for current state.

      `),eo=K(`

      Checking session controls…

      `),to=K(`

      `),no=K(`
      About browser controls

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

      `),ro=K(` `,1),io=K(` `),ao=K(`Grants permission beyond this one command. Check the scope + carefully.`),oo=K(``),so=K(``),co=K(``),lo=K(`

      `),uo=K(` `,1),fo=K(``),po=K(``),mo=K(``),ho=K(` `,1),go=K(`
    • `),_o=K(`
      View fixed choices

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

        `),vo=K(` `,1),yo=K(`

        `),bo=K(`

        `,1),xo=K(``),So=K(`

        `,1),Co=K(`

        `);function wo(e,t){Ge(t,!0);let n=[],r=Bi(t,`observedCommand`,3,``),i=Bi(t,`review`,3,``),a=Bi(t,`suspended`,3,!1),o=Bi(t,`onProtectedChange`,3,e=>{}),s=F(null),c=F(Zt([])),l=F(null),u=F(``),d=F(0),f=F(Zt(Date.now())),p=F(!1),m=F(``),h=F(!1),g=F(!1),_=F(``),v=F(`now`),y=F(60),b=F(``),x=F(!1),S=F(``),C=F(Zt([]));async function w(){if(!i())try{I(C,await la(`schedules`,{session:t.session},O.signal),!0)}catch{}}async function T(e){try{I(C,await la(`schedules`,{session:t.session,cancelId:e},O.signal),!0)}catch(e){I(m,e instanceof Error?e.message:`Unable to cancel trigger.`,!0)}}bn(()=>(o()(W(p)||W(c).some(e=>e.length>0)),()=>o()(!1)));let ee=N(()=>$.data?.sessions.find(e=>e.id===t.session)?.status),E=N(()=>!$.connected||!!$.data?.sessionsError),D=N(()=>i()!==`profile`&&W(s)?.kind===`prompt`&&!W(s).questions?.length&&!!$.data?.profiles?.some(e=>e.session===t.session&&e.pending)),te=N(()=>!W(E)&&!W(g)&&!!W(s)?.id&&W(s).kind===`approval`&&W(_)!==W(s).id),ne=N(()=>W(te)?W(s).command:r()),re=N(()=>!!W(u)&&W(f)W(s)?.questions?.length?W(s).questions:[{text:`Follow-up message`,secret:!1,freeText:!0,options:[]}]),ae=N(()=>W(s)?.kind===`approval`||W(s)?.kind===`profile`?W(l)!==null:W(c).length===W(ie).length&&W(c).every((e,t)=>e.trim().length>0&&(W(ie)[t].freeText||W(ie)[t].options?.includes(e))));bn(()=>{(W(E)||a()||W(D)||W(f)>=W(d))&&I(u,``)});let O=new AbortController;Vi(()=>{let e,n=setInterval(()=>{I(f,Date.now(),!0)},1e3);async function r(){await w();try{let e=await la(`offer`,{session:t.session,...i()?{review:i()}:{}},O.signal);if(O.signal.aborted)return;I(g,!1),W(s)?.id!==e.id&&(I(u,``),I(l,null),I(c,Array(Math.max(1,e.questions?.length||0)).fill(``),!0)),I(s,e,!0),W(h)&&e.id&&e.id!==W(_)&&(I(m,``),I(h,!1))}catch{O.signal.aborted||(I(s,null),I(g,!0),I(u,``))}finally{O.signal.aborted||(e=setTimeout(r,2e3))}}return r(),()=>{O.abort(),clearTimeout(e),clearInterval(n)}});async function oe(){if(!W(s)?.id||W(p)||W(E)||a()||W(D)||!W(ae))return;let e=W(s).id;I(p,!0),I(m,``),I(h,!1),I(u,``);try{let n=W(s).kind===`prompt`&&!W(s).questions?.length&&W(v)!==`now`?{trigger:W(v)===`quota`?`quota`:`at`,zone:Intl.DateTimeFormat().resolvedOptions().timeZone,...W(v)===`quota`?{}:{at:(W(v)===`delay`?new Date(Date.now()+W(y)*6e4):new Date(W(b))).toISOString()}}:void 0;I(x,!!n),I(S,n?n.trigger===`quota`?`After fresh quota becomes available, when the session is idle`:new Date(n.at).toLocaleString()+` — when idle`:``,!0);let r=await la(`prepare`,{session:t.session,...i()?{review:i()}:{},offer:e,...n?{schedule:n}:{},...W(s).kind===`approval`||W(s).kind===`profile`?{choice:W(l)}:{answers:[...W(c)]}},O.signal);W(s)?.id===e&&!O.signal.aborted&&!W(E)&&!a()&&!W(D)&&(I(u,r.confirmation,!0),I(d,Date.parse(r.expires),!0))}catch(e){O.signal.aborted||I(m,e instanceof Error?e.message:`Unable to prepare action.`,!0)}finally{I(p,!1)}}async function se(){if(!W(s)?.id||W(p)||a()||W(D)||!W(re))return;let e=W(s).id,n=W(s).kind,r=W(u);I(u,``),I(p,!0),I(_,e,!0);try{await la(`commit`,{session:t.session,...i()?{review:i()}:{},offer:e,confirmation:r},O.signal),I(h,!0),W(x)&&(I(_,``),await w()),I(m,W(x)?`Trigger set. Closing Codexometer cancels it.`:n===`profile`?`Profile decision completed.`:n===`approval`?`Decision sent.`:`Text sent.`,!0)}catch(e){I(m,e instanceof sa?e.message:`Outcome uncertain. Check Codex before taking another action; nothing was retried.`,!0)}finally{I(p,!1),I(c,[],!0),I(l,null)}}var ce=ro(),le=R(ce),ue=e=>{var t=Fr();Z(R(t),17,()=>W(C).filter(e=>e.status!==`sent`),e=>e.id,(e,t)=>{var n=Ja(),r=L(n),i=z(r,!0),a=B(r,2),o=z(a),l=B(a,2),d=z(l),f=B(l,2),m=z(f,!0),h=B(f,4),g=B(h,2);j(n),V(e=>{J(i,W(t).status===`uncertain`?`CHECK TRIGGER — outcome uncertain; not retried`:`TRIGGER SET`),J(o,`TARGET // ${W(t).session??``}`),J(d,`${e??``} // ${W(t).status??``}`),J(m,W(t).text),h.disabled=W(p)||!W(s)?.id||W(s).kind!==`prompt`||!!W(s).questions?.length||W(t).status!==`pending`,g.disabled=W(p)||W(t).status===`sending`},[()=>W(t).trigger===`quota`?`After confirmed quota recovery, when idle`:`${new Date(W(t).at).toLocaleString()} — when idle`]),G(`click`,h,()=>{I(c,[W(t).text],!0),I(v,W(t).trigger===`quota`?`quota`:`at`,!0);let e=new Date(W(t).at);W(t).trigger!==`quota`&&I(b,new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16),!0),I(u,``)}),G(`click`,g,()=>T(W(t).id)),q(e,n)}),q(e,t)};Y(le,e=>{i()||e(ue)});var de=B(le,2),fe=e=>{var r=Co(),a=L(r),o=z(a,!0),C=B(a,2),w=e=>{var t=Ya(),n=R(t),r=z(n),i=B(n,6),a=z(i,!0),o=z(B(i,6),!0);we(2),V(()=>{J(r,`Your ${W(s).profile.threshold??``}% quota threshold has been reached. Review + the profile for subsequent turns.`),J(a,W(s).profile.current),J(o,W(s).profile.proposed)}),q(e,t)};Y(C,e=>{W(s)?.profile&&!W(E)&&!W(g)&&e(w)});var T=B(C,2),D=e=>{var t=Xa();let n;var r=z(t,!0);V(()=>{n=ci(t,1,`svelte-1oupzfc`,null,n,{notice:!W(h),sent:W(h)}),J(r,W(m))}),q(e,t)};Y(T,e=>{W(m)&&e(D)});var O=B(T,2),ce=e=>{var t=Za(),n=R(t),r=z(n,!0),i=z(B(n,2),!0);V(()=>{J(r,W(te)?`EXACT COMMAND`:`LAST OBSERVED COMMAND`),J(i,W(ne))}),q(e,t)},le=e=>{q(e,Qa())};Y(O,e=>{W(ne)?e(ce):i()!==`profile`&&W(ee)===`APPROVAL NEEDED`&&!W(h)&&e(le,1)});var ue=B(O,2),de=e=>{q(e,$a())},fe=e=>{q(e,eo())},pe=e=>{var t=ro(),n=R(t),r=e=>{var t=to(),n=z(t,!0);V(e=>J(n,e),[()=>W(ee)===`WORKING`?`Codex is working — nothing to respond to.`:[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(ee)||``)?`Respond in Codex for this request.`:`Nothing needs a response right now.`]),q(e,t)};Y(n,e=>{(W(ee)===`WORKING`||!W(h)&&!W(p))&&e(r)});var i=B(n,2),a=e=>{q(e,no())},o=N(()=>[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(ee)||``)&&!W(h));Y(i,e=>{W(o)&&e(a)}),q(e,t)},me=e=>{var r=So(),a=R(r),o=z(a),m=B(a,2),h=L(m),g=z(h,!0),_=B(h,2),C=e=>{var r=Fr();Z(R(r),17,()=>W(s).choices||[],X,(e,r,a)=>{var o=oo(),s=L(o);xi(s),s.value=s.__value=a;var c=B(s),u=B(c),d=e=>{var t=io(),n=z(t,!0);V(()=>J(n,W(r).detail)),q(e,t)};Y(u,e=>{W(r).detail&&e(d)});var f=B(u,2),p=e=>{q(e,ao())};Y(f,e=>{W(r).persistent&&e(p)}),j(o),V(()=>{Q(s,`name`,`decision-`+t.session+`-`+i()),J(c,` ${W(r).label??``} `)}),Di(n,[],s,()=>W(l),e=>I(l,e)),q(e,o)}),q(e,r)},w=e=>{var t=ro(),n=R(t),r=e=>{var t=uo(),n=R(t),r=B(L(n)),i=L(r);i.value=i.__value=`now`;var a=B(i);a.value=a.__value=`quota`;var o=B(a);o.value=o.__value=`delay`;var s=B(o);s.value=s.__value=`at`,j(r),mi(r),j(n);var c=B(n,2),l=e=>{var t=so(),n=B(L(t));xi(n),j(t),Ti(n,()=>W(y),e=>I(y,e)),q(e,t)};Y(c,e=>{W(v)===`delay`&&e(l)});var u=B(c,2),d=e=>{var t=co(),n=B(L(t));xi(n),j(t),Ti(n,()=>W(b),e=>I(b,e)),q(e,t)};Y(u,e=>{W(v)===`at`&&e(d)});var f=B(u,2),p=e=>{var t=lo();t.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.`,q(e,t)};Y(f,e=>{W(v)!==`now`&&e(p)}),hi(r,()=>W(v),e=>I(v,e)),q(e,t)};Y(n,e=>{W(s).questions?.length||e(r)}),Z(B(n,2),17,()=>W(ie),X,(e,t,n)=>{var r=vo(),i=R(r),a=L(i),o=B(a),s=e=>{var t=fo();xi(t),Ti(t,()=>W(c)[n],e=>W(c)[n]=e),q(e,t)},l=e=>{var r=mo(),i=L(r);i.value=i.__value=``,Z(B(i),17,()=>W(t).options||[],X,(e,t)=>{var n=po(),r=z(n,!0),i={};V(()=>{J(r,W(t)),i!==(i=W(t))&&(n.value=(n.__value=i)??``)}),q(e,n)}),j(r),mi(r),hi(r,()=>W(c)[n],e=>W(c)[n]=e),q(e,r)},u=e=>{var r=ho(),i=R(r);rt(i);var a=B(i,2),o=e=>{var n=to(),r=z(n);V(e=>J(r,`Suggested answers: ${e??``}`),[()=>W(t).options.join(` · `)]),q(e,n)};Y(a,e=>{W(t).options?.length&&e(o)}),Ti(i,()=>W(c)[n],e=>W(c)[n]=e),q(e,r)};Y(o,e=>{W(t).secret?e(s):W(t).freeText?e(u,-1):e(l,1)}),j(i);var d=B(i,2),f=e=>{var n=_o(),r=B(L(n),4);Z(r,21,()=>W(t).options||[],X,(e,t)=>{var n=go(),r=z(n,!0);V(()=>J(r,W(t))),q(e,n)}),j(r),j(n),q(e,n)};Y(d,e=>{W(t).secret&&!W(t).freeText&&e(f)}),V(()=>J(a,`${W(t).text??``} `)),q(e,r)}),q(e,t)};Y(_,e=>{W(s).kind===`approval`||W(s).kind===`profile`?e(C):e(w,-1)}),j(m);var T=B(m,2),ee=e=>{var t=bo(),n=R(t),r=e=>{var t=yo(),n=z(t);V(()=>J(n,`TRIGGER // ${W(S)??``}`)),q(e,t)};Y(n,e=>{W(x)&&e(r)});var i=B(n,2),a=z(i),o=B(i,2),c=z(o),m=B(o,2);V(e=>{J(a,`Check the target and ${W(s).kind===`profile`?`profile above`:W(s).kind===`approval`?`exact command and permission scope`:`message above`}. ${W(x)?`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=W(p)||W(E),J(c,`CONFIRM ${(W(s).kind===`approval`||W(s).kind===`profile`?W(s).choices?.[W(l)]?.label:W(x)?`SCHEDULE`:`SEND`)??``}`)},[()=>Math.max(0,Math.ceil((W(d)-W(f))/1e3))]),G(`click`,o,se),G(`click`,m,()=>{I(u,``)}),q(e,t)},D=e=>{var t=xo(),n=z(t,!0);V(()=>{t.disabled=W(p)||W(E)||!W(ae),J(n,W(p)?`SENDING…`:`REVIEW BEFORE SENDING`)}),G(`click`,t,oe),q(e,t)};Y(T,e=>{W(re)?e(ee):e(D,-1)}),V(()=>{J(o,`TARGET // ${W(s).thread??``} // ${(W(s).directory||`Directory unavailable`)??``}`),m.disabled=W(p)||W(re)||W(E),J(g,W(s).kind===`approval`||W(s).kind===`profile`?`Choose a decision`:`Reply to this session`)}),q(e,r)};Y(ue,e=>{W(E)||W(g)?e(de):W(s)?W(s).id?W(_)!==W(s).id&&e(me,3):e(pe,2):e(fe,1)}),j(r),V(()=>J(o,i()===`profile`?`QUOTA THRESHOLD`:`SESSION CONTROL // EXPERIMENTAL`)),q(e,r)};Y(de,e=>{W(D)||e(fe)}),q(e,ce),Ke()}wr([`click`]);var To=K(`
        `);function Eo(e,t){Ge(t,!0);let n=Bi(t,`active`,3,!1),r=N(()=>t.session.text||t.session.contextKind===`LAST ACTIVITY`&&t.session.workingCommand||``),i=N(()=>[`LAST REPLY`,`LAST ACTIVITY`].includes(t.session.contextKind)&&!!W(r).trim()),a=F(!1),o=F(``),s=F(!1);bn(()=>{if(!W(s))return;let e=setTimeout(()=>{I(s,!1)},150);return()=>clearTimeout(e)}),bn(()=>{W(r),t.session.status,I(o,``)});async function c(){if(!W(i)||W(a))return;let e=W(r);I(a,!0),I(s,!0),I(o,``);try{await navigator.clipboard.writeText(e),W(r)===e&&I(o,`Copied.`)}catch{W(r)===e&&I(o,`Clipboard unavailable. Select the visible text and copy it manually.`)}finally{I(a,!1)}}function l(e){!n()||!W(i)||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(),c())}var u=Fr();Cr(`keydown`,en,l);var d=R(u),f=e=>{var t=To(),n=L(t),r=z(n,!0),i=B(n,2);let l;j(t),V(()=>{J(r,W(o)),i.disabled=W(a),l=ci(i,1,`svelte-543j00`,null,l,{flashed:W(s)})}),G(`click`,i,c),q(e,t)};Y(d,e=>{W(i)&&e(f)}),q(e,u),Ke()}wr([`click`]);var Do=K(`

        CONTEXT

         

        `,1),Oo=K(`

        `),ko=K(`

        `),Ao=K(`
         
        `),jo=K(`

         
        `,1),Mo=K(`
         
        `),No=K(`

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

        `),Po=K(`

        `,1),Fo=K(`

        `),Io=K(` `,1),Lo=K(`
        `),Ro=K(`

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

        `),zo=K(`

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

        `),Bo=K(` `),Vo=K(` `),Ho=K(``),Uo=K(`

        Read only — reply or approve in Codex.

        `),Wo=K(`

        `),Go=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),Ko=K(`
        `),qo=K(`
        `),Jo=K(`

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

        `),Yo=K(`

        `),Xo=K(``),Zo=K(`TRIGGER SET`),Qo=K(`

        `),$o=K(` `),es=K(`

        `),ts=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),ns=K(` `,1),rs=K(`

        `),is=K(`

        TOKEN ACTIVITY // 30 SECOND SAMPLES

        `),as=K(`

        TOKENS

        FULL DETAIL →
        `),os=K(`

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

        `),ss=K(`

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

        `,1),cs=K(`

        SESSION TOTALS

        `,1);function ls(e,t){Ge(t,!0);let n=(e,t=f,n,r)=>{let i=ht(()=>g(n?.(),!0)),a=ht(()=>g(r?.(),!1));var o=Io(),s=R(o),c=e=>{var n=Do(),r=z(B(R(n),2),!0);we(2),V(()=>J(r,t().approvalContext)),q(e,n)};Y(s,e=>{W(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(c)});var l=B(s,2),u=e=>{var n=Oo();let r;var i=z(n,!0);V(e=>{r=ci(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),J(i,e)},[()=>b(t())]),q(e,n)},p=N(()=>b(t())&&(!W(a)||W(d)||t().status===`CHECK SESSION`));Y(l,e=>{W(p)&&e(u)});var m=B(l,2),h=e=>{var n=ko(),r=z(n,!0);V(()=>J(r,t().contextKind||`LAST ACTIVITY`)),q(e,n)};Y(m,e=>{W(i)&&e(h)});var _=B(m,2),v=e=>{var n=Ao(),r=z(n,!0);V(()=>J(r,t().text||`No session context available.`)),q(e,n)};Y(_,e=>{(t().text||!t().workingCommand)&&e(v)});var y=B(_,2),x=e=>{var n=jo(),r=B(R(n),2),i=L(r),a=B(i),o=e=>{var n=Pr();V(()=>J(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),q(e,n)};Y(a,e=>{!W(d)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(o)});var s=B(a,2),c=e=>{q(e,Pr(`+`))};Y(s,e=>{t().runningLimited&&e(c)}),j(r);var l=z(B(r,2),!0);V(e=>{J(i,`COMMAND // ${e??``} `),J(l,t().workingCommand)},[()=>W(d)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),q(e,n)};Y(y,e=>{t().workingCommand&&e(x)});var S=B(y,2),C=e=>{var n=Po(),r=B(R(n),2),i=z(r,!0),a=B(r,2),o=e=>{var n=Mo(),r=z(n,!0);V(()=>J(r,t().command)),q(e,n)},s=e=>{q(e,No())};Y(a,e=>{t().command?e(o):e(s,-1)}),V(()=>J(i,W(d)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),q(e,n)};Y(S,e=>{(!W(a)||!$.data?.control)&&(t().command||t().status===`APPROVAL NEEDED`)&&e(C)});var w=B(S,2),T=e=>{var n=Fo(),r=z(n);V(()=>J(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),q(e,n)};Y(w,e=>{W(a)||e(T)}),q(e,o)},r=Bi(t,`params`,19,()=>({})),i=N(()=>$.data?.sessions||[]),a=N(()=>$.data?.control&&$.data.profiles||[]),o=F(!1);function s(e,t){if(r().id&&r().id!==t&&W(o)){e.preventDefault();return}h(t)}bn(()=>{let e=r().id;e&&mr(()=>{Qi.selected=e,ra(e,2)})});let c=N(()=>W(i).find(e=>e.id===r().id)),l=N(()=>new URLSearchParams(Wi.querystring).get(`review`)===`profile`&&W(a).some(e=>e.session===r().id&&e.pending)),u=N(()=>W(i).some(e=>e.id===Qi.selected)?Qi.selected:W(i)[0]?.id),d=N(()=>!$.connected||!!$.data?.sessionsError),p=N(()=>[[`OBSERVED TOKENS`,ia(W(i).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,ia(W(i).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,W(d)?`—`:ia(W(i).filter(e=>e.status===t).length)])]),m=N(()=>W(i).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`,`CHECK SESSION`].includes(e.status)));function h(e){Qi.selected=e,dr().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function v(e,t){if(h(e),r().id){t<0&&(ra(e,2),location.hash=`/sessions`);return}let n=ta(e)+t;n>2?location.hash=`/sessions/`+encodeURIComponent(e):ra(e,n)}function y(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`&&r().id)e.preventDefault(),v(r().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(r().id||W(u)))e.preventDefault(),v(r().id||W(u),e.key===`ArrowLeft`?-1:1);else if(!r().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&W(i).length){e.preventDefault();let t=W(i).findIndex(e=>e.id===W(u));h(W(i)[Math.max(0,Math.min(W(i).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function b(e){return W(d)?`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.`:$.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.`:``}var x=cs();Cr(`keydown`,en,y);var S=R(x),C=z(B(L(S),2));j(S);var w=B(S,2);let T;Z(w,21,()=>W(p),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1];var a=Lo(),o=L(a),s=z(o,!0),c=z(B(o,2),!0);j(a),V(()=>{J(s,r()),J(c,i())}),q(e,a)}),j(w);var ee=B(w,2),E=z(ee),D=B(ee,2),te=e=>{q(e,Ro())};Y(D,e=>{W(d)&&e(te)});var ne=B(D,2),re=e=>{q(e,zo())};Y(ne,e=>{$.data?.profileError&&e(re)});var ie=B(ne,2),ae=e=>{var t=Ho(),n=L(t);Z(n,17,()=>W(m),X,(e,t)=>{var n=Bo();let r;var i=z(n);V((e,a)=>{r=ci(n,1,`button`,null,r,{approval:W(t).status===`APPROVAL NEEDED`}),Q(n,`href`,e),J(i,`${W(t).status??``} + ${a??``} // ${(W(t).name||W(t).directory||W(t).id)??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,n,()=>h(W(t).id)),q(e,n)}),Z(B(n,2),17,()=>W(a).filter(e=>e.pending&&W(i).some(t=>t.id===e.session)),X,(e,t)=>{var n=Vo(),a=z(n);V((e,i,s)=>{Q(n,`title`,r().id&&r().id!==W(t).session&&W(o)?`Finish sending or clear your current draft before switching sessions.`:`Review this session’s quota threshold`),Q(n,`href`,e),J(a,`QUOTA THRESHOLD ${i??``} // ${s??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session)+`?review=profile`,()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory||W(t).session]),G(`click`,n,e=>s(e,W(t).session)),q(e,n)}),j(t),q(e,t)},O=N(()=>(W(m).length||W(a).some(e=>e.pending))&&!W(d));Y(ie,e=>{W(O)&&e(ae)});var oe=B(ie,2),se=e=>{var t=Fr(),i=R(t),s=e=>{var t=qo(),i=L(t),s=L(i),u=L(s);let f;var p=B(u);j(s);var m=B(s,2);j(i);var g=B(i,2),_=e=>{var t=Fo(),n=z(t,!0);V(()=>J(n,W(c).directory)),q(e,t)};Y(g,e=>{W(c).name&&W(c).directory&&e(_)});var v=B(g,2),y=z(v),b=B(v,2);let x;var S=L(b),C=L(S);n(C,()=>W(c),()=>!0,()=>!0),j(S);var w=B(S,2),T=e=>{var t=Fr();qr(R(t),()=>W(c).id,e=>{wo(e,{get session(){return W(c).id},get observedCommand(){return W(c).command},get suspended(){return W(l)},onProtectedChange:e=>{I(o,e,!0)}})}),q(e,t)},ee=e=>{q(e,Uo())};Y(w,e=>{$.data?.control?e(T):e(ee,-1)}),j(b);var E=B(b,2);Z(E,17,()=>W(a).filter(e=>e.session===W(c).id),e=>e.session,(e,t)=>{var n=Ko(),r=L(n),i=e=>{var n=Wo(),r=z(n,!0);V(()=>J(r,W(t).notice)),q(e,n)};Y(r,e=>{W(t).notice&&e(i)});var a=B(r,2),o=e=>{wo(e,{get session(){return W(c).id},review:`profile`})},s=e=>{var t=Go();V(e=>Q(t,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(c).id)+`?review=profile`]),q(e,t)};Y(a,e=>{W(t).pending&&W(l)?e(o):W(t).pending&&e(s,1)}),j(n),V(()=>Q(n,`id`,`quota-profile-`+W(c).id)),q(e,n)});var D=B(E,2),te=e=>{var t=Fr();qr(R(t),()=>W(c).id,e=>{Eo(e,{get session(){return W(c)},active:!0})}),q(e,t)};Y(D,e=>{W(l)||e(te)}),j(t),V(e=>{f=ci(u,1,`lamp lit`,null,f,{working:W(c).status===`WORKING`&&!W(d)}),J(p,`${(W(d)?`STALE`:W(l)?`QUOTA THRESHOLD`:W(c).status)??``} // ${(W(c).name||W(c).directory)??``}`),J(y,`${e??``} TOKENS // ${W(c).id??``} // CONTEXT SOURCE // ${(W(c).source||`LOCAL`)??``}`),x=ui(b,``,x,{display:W(l)?`none`:void 0})},[()=>ia(W(c).tokens)]),G(`click`,m,()=>{h(r().id),ra(r().id,2)}),q(e,t)},u=e=>{q(e,Jo())};Y(i,e=>{W(c)?e(s):e(u,-1)}),q(e,t)},ce=e=>{var t=ss(),r=R(t),o=B(L(r),2),c=L(o),l=B(c,2);j(o),j(r);var f=B(r,2);Z(f,17,()=>W(i),e=>e.id,(e,t)=>{let r=N(()=>ta(W(t).id));var i=as();let o;var c=L(i),l=L(c),f=e=>{var n=Yo(),r=L(n),i=z(r);j(n),V(e=>{Q(r,`aria-pressed`,W(u)===W(t).id),J(i,`${e??``} // ${W(t).name??``}`)},[()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,r,()=>h(W(t).id)),q(e,n)};Y(l,e=>{W(t).name&&e(f)});var p=B(l,2),m=L(p),g=L(m);let _;var y=B(g,1,!0);j(m),j(p);var b=B(p,2),x=e=>{var n=Xo(),r=z(n,!0);V(()=>{Q(n,`aria-pressed`,W(u)===W(t).id),J(r,W(t).directory||W(t).id)}),G(`click`,n,()=>h(W(t).id)),q(e,n)};Y(b,e=>{W(t).name||e(x)});var S=B(b,2),C=L(S);we(),j(S);var w=B(S,2),T=e=>{var n=Zo();V(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(t).id)]),q(e,n)},ee=N(()=>$.data?.triggers?.some(e=>e.session===W(t).id));Y(w,e=>{W(ee)&&e(T)});var E=B(w,2),D=e=>{var n=Fo(),r=z(n,!0);V(()=>J(r,W(t).directory)),q(e,n)};Y(E,e=>{W(t).name&&W(t).directory&&e(D)});var te=B(E,2),ne=z(te),re=B(te,2),ie=z(re),ae=B(re,2),O=L(ae),oe=B(O,2),se=z(oe,!0),ce=B(oe,2);j(ae);var le=B(ae,2),ue=B(le,2),de=e=>{var n=Qo(),r=z(n,!0);V(()=>J(r,W(t).status===`CHECK SESSION`?`INFERRED INACTIVITY`:$.data?.control?`OPEN FULL DETAIL OR REPLY IN CODEX`:W(t).status===`APPROVAL NEEDED`?`APPROVE OR DECLINE IN CODEX`:`REPLY IN CODEX`)),q(e,n)},fe=N(()=>!W(d)&&[`APPROVAL NEEDED`,`INPUT NEEDED`,`CHECK SESSION`].includes(W(t).status));Y(ue,e=>{W(fe)&&e(de)}),j(c);var pe=B(c,2),me=e=>{var r=rs(),i=L(r),o=L(i),c=z(o,!0),l=B(o,2),f=e=>{var n=$o(),r=z(n,!0);V(e=>{Q(n,`href`,e),J(r,$.data?.control?`REVIEW IN FULL DETAIL ↗`:`APPROVAL IN CODEX ↗`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id)]),q(e,n)};Y(l,e=>{!W(d)&&W(t).status===`APPROVAL NEEDED`&&e(f)}),j(i);var p=B(i,2);n(p,()=>W(t),()=>!1);var m=B(p,2);Z(m,17,()=>W(a).filter(e=>e.session===W(t).id),X,(e,n)=>{var r=ns(),i=R(r),a=e=>{var t=es(),r=z(t,!0);V(()=>J(r,W(n).notice)),q(e,t)};Y(i,e=>{W(n).notice&&e(a)});var o=B(i,2),c=e=>{var n=ts();V(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(t).id)+`?review=profile`]),G(`click`,n,e=>s(e,W(t).id)),q(e,n)};Y(o,e=>{W(n).pending&&e(c)}),q(e,r)});var h=B(m,2);{let e=N(()=>W(u)===W(t).id);Eo(h,{get session(){return W(t)},get active(){return W(e)}})}j(r),V(()=>J(c,W(t).contextKind||`LAST ACTIVITY`)),q(e,r)};Y(pe,e=>{W(r)>0&&e(me)});var he=B(pe,2),ge=e=>{var n=is(),r=B(L(n),2);{let e=N(()=>(W(t).samples||[]).map(e=>e.tokens));qa(r,{get values(){return W(e)},capacity:120})}var i=z(B(r,2));j(n),V(()=>J(i,`LAST ${(W(t).samples?.length||0)??``} SAMPLES // AUTO SCALE`)),q(e,n)};Y(he,e=>{W(r)<2&&e(ge)}),j(i),V((e,n,a,s)=>{o=ci(i,1,`session-row`,null,o,{selected:W(u)===W(t).id,wide:W(r)===2,split:W(r)===1}),Q(i,`aria-label`,`Session `+(W(t).name||W(t).directory||W(t).id)),Q(m,`href`,e),_=ci(g,1,`lamp lit`,null,_,{working:W(t).status===`WORKING`&&!W(d)}),J(y,W(d)?`STALE`:W(t).status),J(C,`${n??``} `),J(ne,`${W(t).agents??``} LINKED AGENTS`),J(ie,`ACTIVE // ${a??``}`),O.disabled=W(r)===0,Q(oe,`aria-expanded`,W(r)>0),J(se,W(r)?`HIDE DETAIL`:`SHOW DETAIL`),Q(le,`href`,s)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>ia(W(t).tokens),()=>aa(W(t).activity),()=>`#/sessions/`+encodeURIComponent(W(t).id)]),G(`click`,m,()=>h(W(t).id)),G(`click`,O,()=>v(W(t).id,-1)),G(`click`,oe,()=>{h(W(t).id),ra(W(t).id,+!W(r))}),G(`click`,ce,()=>v(W(t).id,1)),G(`click`,le,()=>h(W(t).id)),q(e,i)});var p=B(f,2),m=e=>{q(e,os())};Y(p,e=>{W(i).length||e(m)}),G(`click`,c,()=>na(1)),G(`click`,l,()=>na(0)),q(e,t)};Y(oe,e=>{r().id?e(se):e(ce,-1)}),V(e=>{J(C,`OBSERVED ${e??``}`),T=ci(w,1,`session-totals`,null,T,{stale:W(d)}),J(E,`${W(d)?`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.`)},[()=>aa($.data?.sessionsAt)]),q(e,x),Ke()}wr([`click`]);var us=K(`

        `),ds=K(`

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

        `,1),fs=K(`// APPROXIMATE`),ps=K(`

        Partial accounting: totals may still change.

        `),ms=K(`

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

        `,1),hs=K(`

        `,1),gs=K(`

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

        `),_s=K(`
        `),vs=K(`
        `),ys=K(`

        No usage reported for this day.

        `),bs=K(`

        Selected breakdown unavailable; missing does not mean zero.

        `),xs=K(`

        `,1);function Ss(e,t){Ge(t,!0);let n=F(`surface`),r=F(0),i=N(()=>t.reports?.daily),a=N(()=>t.reports?.plan),o=N(()=>t.mode===`breakdown`?W(i)?.days.length||0:W(a)?.periods.length||0),s=N(()=>Math.min(W(r),Math.max(0,W(o)-1))),c=N(()=>W(i)?.days[(W(i)?.days.length||0)-1-W(s)]),l=N(()=>W(a)?.periods[W(s)]),u=N(()=>t.mode===`breakdown`?W(i)?.units||``:`%`),d=N(()=>{let e=Object.create(null);if(t.mode===`breakdown`)e=W(c)?.groups[W(n)]||{};else{let t=W(n)===`feature`?`thread_source`:W(n)===`task start`?`turn_trigger`:W(n);for(let n of W(l)?.breakdowns||[])if(n.dimension===t)for(let t of n.rows)e[t.key]=(e[t.key]||0)+t.basis_points/100}return Object.entries(e).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}),f=N(()=>t.mode===`breakdown`?W(c)?.total:W(l)?.used_basis_points==null?null:W(l).used_basis_points/100),p=N(()=>Math.max(1,W(f)||0,...W(d).map(([,e])=>e))),m=e=>e==null?`UNKNOWN`:e.toLocaleString(`en-GB`,{maximumFractionDigits:2});var h=xs(),g=R(h),v=L(g),y=B(L(v)),b=L(y);b.value=b.__value=`surface`;var x=B(b);x.value=x.__value=`model`;var S=B(x);S.value=S.__value=`feature`;var C=B(S);C.value=C.__value=`task start`,j(y),mi(y),j(v);var w=B(v,2),T=B(w,2),ee=z(B(T,2),!0);j(g);var E=B(g,2),D=L(E),te=z(D,!0),ne=B(D,2),re=z(ne),ie=B(ne,2),ae=e=>{var t=ds(),n=R(t),r=z(n),a=B(n,2),o=e=>{var t=us(),n=z(t);V(()=>J(n,`Data as of ${W(i).dataAsOf??``}`)),q(e,t)};Y(a,e=>{W(i).dataAsOf&&e(o)});var s=z(B(a,2));we(2),V((e,t)=>{J(r,`Latest fetch ${e??``} // queried ${W(i).from??``} → ${W(i).through??``}. + Reports are fetched from OpenAI and are not saved between runs.`),J(s,`${(W(c)?.date||`No daily buckets reported`)??``} // ${t??``} + ${W(u)??``}`)},[()=>aa(W(i).fetchedAt),()=>m(W(f))]),q(e,t)},O=e=>{var t=hs(),n=R(t),r=L(n);let i;var o=z(r,!0),s=B(r),c=e=>{q(e,fs())};Y(s,e=>{W(a).approximate&&e(c)});var u=B(s);j(n);var d=B(n,2),p=L(d),h=B(p),g=e=>{var t=Pr();V(()=>J(t,`// Boundary tolerance ${W(a).boundary_tolerance_seconds??``}s`)),q(e,t)};Y(h,e=>{W(a).boundary_tolerance_seconds!=null&&e(g)}),j(d);var _=B(d,2),v=e=>{var t=ms(),n=R(t),r=L(n),i=B(r);let a;var o=z(i);j(n);var s=B(n,2),c=z(s),u=B(s,2),d=e=>{q(e,ps())};Y(u,e=>{W(l).accounting_complete||e(d)}),we(2),V(e=>{J(r,`${W(l).window_minutes??``} MIN // ${W(l).plan_type??``} // `),a=ci(i,1,`svelte-1fbui7h`,null,a,{muted:W(f)==null,"quota-near":W(f)!=null&&W(f)>=80&&W(f)<100,"quota-full":W(f)!=null&&W(f)>=100}),J(o,`USED ${e??``}${W(f)==null?``:`%`}`),J(c,`${W(l).starts_at??``} → ${W(l).ends_at??``}`)},[()=>m(W(f))]),q(e,t)};Y(_,e=>{W(l)&&e(v)}),V(e=>{i=ci(r,1,`svelte-1fbui7h`,null,i,{"quality-warning":!W(a).coverage_complete}),J(o,W(a).coverage_complete?`Reported range complete`:`Partial coverage`),J(u,` // Latest fetch ${e??``}`),J(p,`Coverage starts ${(W(a).coverage_start||`unknown`)??``} // Data as of ${(W(a).data_as_of||`unknown`)??``}`)},[()=>aa(W(a).fetchedAt)]),q(e,t)},oe=e=>{q(e,gs())};Y(ie,e=>{t.mode===`breakdown`&&W(i)?e(ae):t.mode===`periods`&&W(a)?e(O,1):e(oe,-1)});var se=B(ie,2),ce=e=>{var n=vs(),r=L(n),i=z(B(L(r),2),!0);j(r),Z(B(r,2),17,()=>W(d),X,(e,n,r)=>{var i=N(()=>_(W(n),2));let a=()=>W(i)[0],o=()=>W(i)[1];var s=_s();let c;var l=L(s),u=z(l,!0),d=B(l,2),f=L(d);let h;j(d);var g=z(B(d,2));j(s),V((e,n,i)=>{c=ci(s,1,`report-row svelte-1fbui7h`,null,c,{unknown:e,alternate:r%2==1}),Q(l,`title`,a()),J(u,a()),h=ui(f,``,h,{width:n}),J(g,`${i??``}${t.mode===`periods`?`%`:``}`)},[()=>a().trim().toLowerCase()===`unknown`,()=>`${Math.max(0,100*o()/W(p))}%`,()=>m(o())]),q(e,s)}),j(n),V(()=>J(i,t.mode===`breakdown`?W(u):`QUOTA USED`)),q(e,n)},le=e=>{q(e,ys())},ue=e=>{q(e,bs())};Y(se,e=>{W(d).length?e(ce):t.mode===`breakdown`&&W(c)?.total===0&&W(c)?.groups[W(n)]!=null?e(le,1):(W(i)&&t.mode===`breakdown`||W(a)&&t.mode===`periods`)&&e(ue,2)}),j(E),V(()=>{w.disabled=W(s)>=W(o)-1,T.disabled=W(s)===0,J(ee,W(o)?`${W(s)+1} / ${W(o)}`:`NO DATA`),J(te,t.mode===`breakdown`?`DAILY BREAKDOWN`:`QUOTA WINDOWS`),J(re,`${(t.mode===`breakdown`?t.reports?.dailyStatus||`UNAVAILABLE`:t.reports?.planStatus||`UNAVAILABLE`)??``} // UTC`)}),hi(y,()=>W(n),e=>I(n,e)),G(`click`,w,()=>I(r,W(s)+1)),G(`click`,T,()=>I(r,W(s)-1)),q(e,h),Ke()}wr([`click`]);var Cs=864e5;function ws(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 Ts(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));for(let e=0;;e++){let i=ws(r,-t),a=new Date(i.getTime()+Cs);if(e===n)return{start:a,end:r};r=i}}var Es=K(``),Ds=K(``,1),Os=K(`

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

        `),ks=K(`

        Token history unavailable; other reports may still be available.

        `),As=K(``),js=K(`
        `),Ms=K(`

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

        `,1),Ns=K(`
        `,1),Ps=K(` `),Fs=K(`

        LIFETIME TOKENS

        PEAK DAY

        CURRENT STREAK

        DAYS

        LONGEST TURN

        SECONDS

        LONGEST STREAK

        DAYS

        OPENAI // UTC

        Accessible data table
        Date (UTC)Tokens

        `,1),Is=K(`

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

        `),Ls=K(`

        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 Rs(e,t){Ge(t,!0);let n=F(`daily`),r=F(12),i=F(0),a=N(()=>{let e=$.data?.usage?.dailyUsageBuckets;if(!e)return[];let{start:t,end:n}=Ts(new Date,W(r),W(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=N(()=>Math.max(1,...W(a).map(e=>e.tokens))),s=N(()=>W(a).length?new Date(W(a)[0].date+`T00:00:00Z`).getUTCDay():0),c=N(()=>{if(W(n)===`monthly`){let e=new Map;for(let t of W(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 W(a).map(t=>({date:t.date,tokens:e+=t.tokens}))});var l=Ls(),u=B(R(l),4);Z(u,20,()=>[[`daily`,`Daily`],[`monthly`,`Monthly`],[`cumulative`,`Cumulative`],[`breakdown`,`Breakdown`],[`periods`,`Windows`]],X,(e,t)=>{var r=N(()=>_(t,2));let a=()=>W(r)[0],o=()=>W(r)[1];var s=Es();let c;var l=z(s,!0);V(()=>{Q(s,`aria-pressed`,W(n)===a()),c=ci(s,1,``,null,c,{active:W(n)===a()}),J(l,o())}),G(`click`,s,()=>{I(n,a(),!0),I(i,0)}),q(e,s)}),j(u);var d=B(u,2),f=L(d),p=e=>{var t=Ds(),n=R(t),a=B(L(n)),o=L(a);o.value=o.__value=6;var s=B(o);s.value=s.__value=12,j(a),mi(a),j(n);var c=B(n),l=B(c);V(()=>l.disabled=W(i)===0),G(`change`,a,()=>I(i,0)),hi(a,()=>W(r),e=>I(r,e)),G(`click`,c,()=>Jt(i)),G(`click`,l,()=>Jt(i,-1)),q(e,t)};Y(f,e=>{W(n)!==`breakdown`&&W(n)!==`periods`&&e(p)}),j(d);var m=B(d,2),h=e=>{q(e,Os())};Y(m,e=>{$.data?.usageError&&e(h)});var g=B(m,2),v=e=>{q(e,ks())};Y(g,e=>{$.data?.usage?.tokenStatus===`UNAVAILABLE`&&W(n)!==`breakdown`&&W(n)!==`periods`&&e(v)});var y=B(g,2),b=e=>{var t=Fr();qr(R(t),()=>W(n),e=>{{let t=N(()=>$.data?.usage?.reports);Ss(e,{get reports(){return W(t)},get mode(){return W(n)}})}}),q(e,t)},x=e=>{var t=Fs(),r=R(t),i=L(r),l=z(B(L(i),2),!0);j(i);var u=B(i,2),d=z(B(L(u),2),!0);j(u);var f=B(u,2),p=B(L(f),2),m=L(p);we(),j(p),j(f);var h=B(f,2),g=B(L(h),2),_=L(g);we(),j(g),j(h);var v=B(h,2),y=B(L(v),2),b=L(y);we(),j(y),j(v),j(r);var x=B(r,4),S=L(x),C=z(S),w=B(S,2),T=e=>{var t=Ms(),n=R(t),r=L(n),i=L(r);Z(i,17,()=>Array(W(s)),X,(e,t)=>{q(e,As())}),Z(B(i,2),17,()=>W(a),X,(e,t)=>{var n=js();let r,i;V(e=>{r=ci(n,1,`heat-cell`,null,r,{zero:W(t).tokens===0}),Q(n,`title`,e),i=ui(n,``,i,{opacity:W(t).tokens?.25+.75*W(t).tokens/W(o):1})},[()=>`${W(t).date}: ${ia(W(t).tokens)} tokens`]),q(e,n)}),j(r),j(n),we(2),q(e,t)},ee=e=>{var t=Ns(),r=R(t);{let e=N(()=>W(c).map(e=>e.tokens)),t=N(()=>W(n)+` usage`);qa(r,{get values(){return W(e)},get label(){return W(t)}})}var i=B(r,2),a=L(i),o=z(a,!0),s=z(B(a),!0);j(i),V(e=>{J(o,W(c)[0]?.date),J(s,e)},[()=>W(c).at(-1)?.date]),q(e,t)};Y(w,e=>{W(n)===`daily`?e(T):e(ee,-1)});var E=B(w,2),D=B(L(E),2),te=L(D),ne=B(L(te));Z(ne,21,()=>W(n)===`daily`?W(a):W(c),X,(e,t)=>{var n=Ps(),r=L(n),i=z(r,!0),a=z(B(r),!0);j(n),V(e=>{J(i,W(t).date),J(a,e)},[()=>ia(W(t).tokens)]),q(e,n)}),j(ne),j(te),j(D),j(E),j(x);var re=z(B(x,2));V((e,t,n,r,i,o,s)=>{J(l,e),J(d,t),J(m,`${n??``} `),J(_,`${r??``} `),J(b,`${i??``} `),J(C,`${W(a)[0]?.date??``} — ${o??``}`),J(re,`OBSERVED ${s??``} // CUMULATIVE IS FOR THE SELECTED PERIOD`)},[()=>ia($.data.usage.summary.lifetimeTokens),()=>ia($.data.usage.summary.peakDailyTokens),()=>ia($.data.usage.summary.currentStreakDays),()=>ia($.data.usage.summary.longestRunningTurnSec),()=>ia($.data.usage.summary.longestStreakDays),()=>W(a).at(-1)?.date,()=>aa($.data.usageAt)]),q(e,t)},S=e=>{q(e,Is())};Y(y,e=>{W(n)===`breakdown`||W(n)===`periods`?e(b):$.data?.usage&&$.data.usage.dailyUsageBuckets!==null?e(x,1):e(S,-1)}),q(e,l),Ke()}wr([`click`,`change`]);var zs=K(`

        Page not found

        Return to Quota

        `,1);function Bs(e){var t=zs();we(2),q(e,t)}var Vs=K(` `),Hs=K(`

        `),Us=K(`

        Connecting to your local Codexometer…

        `),Ws=K(``),Gs=K(`
        CODEXOMETER

        Your quota. Your sessions. Your command centre.

        `);function Ks(e,t){Ge(t,!0);let n={"/":Wa,"/quota/:view?":Wa,"/sessions/:id?":ls,"/usage":Rs,"*":Bs},r={quota:/^(?:\/|\/quota(?:\/[^/]+)?\/?)$/,sessions:/^\/sessions(?:\/[^/]+)?\/?$/,usage:/^\/usage\/?$/},i=F(`hacker`),a=[`hacker`,`rust`,`blue-steel`,`ultraviolet`,`nightshade`];bn(()=>{$i()}),bn(()=>{if($.data)for(let[e,t]of Object.entries(r))t.test(Wi.location)&&(Qi.tab=e)}),Vi(()=>{try{let e=localStorage.getItem(`codexometer.web.theme`);e&&a.includes(e)&&I(i,e,!0)}catch{}return ua()});function o(){try{localStorage.setItem(`codexometer.web.theme`,W(i))}catch{}}var s=Gs(),c=L(s),l=B(L(c),2),u=L(l);let d;var f=B(u,1,!0),p=z(B(f));j(l),j(c);var m=B(c,2);Z(m,21,()=>Object.entries(r),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1],a=N(()=>i().test(Wi.location));var o=Vs();let s;var c=z(o,!0);V(e=>{Q(o,`href`,r()===`quota`?`#/quota/`+Qi.view:`#/`+r()),Q(o,`aria-current`,W(a)?`page`:void 0),s=ci(o,1,``,null,s,{active:W(a)}),J(c,e)},[()=>r().toUpperCase()]),q(e,o)}),j(m);var h=B(m,2),g=L(h),v=e=>{var t=Hs(),n=z(t,!0);V(()=>J(n,$.error)),q(e,t)};Y(g,e=>{$.error&&e(v)});var y=B(g,2),b=e=>{qi(e,{get routes(){return n}})},x=e=>{q(e,Us())};Y(y,e=>{$.data?e(b):$.error||e(x,1)}),j(h);var S=B(h,2),C=L(S),w=z(C),T=B(C,2),ee=z(T,!0),E=B(T,2),D=B(L(E));Z(D,21,()=>a,X,(e,t)=>{var n=Ws(),r=z(n,!0),i={};V(e=>{J(r,e),i!==(i=W(t))&&(n.value=(n.__value=i)??``)},[()=>W(t).replace(`-`,` `).toUpperCase()]),q(e,n)}),j(D),mi(D),j(E),j(S),j(s),V(()=>{Q(s,`data-theme`,W(i)),d=ci(u,1,`lamp`,null,d,{lit:$.connected}),J(f,$.connected?`CONNECTED`:`OFFLINE`),J(p,`EXPERIMENTAL // ${$.data?.control?`SESSION CONTROL`:`READ ONLY`}`),J(w,`v${($.data?.version||`…`)??``} // LOCAL ONLY`),J(ee,$.data?.control?`Session control enabled. Stop the server to revoke access.`:`No actions can be sent from this preview.`)}),G(`change`,D,o),hi(D,()=>W(i),e=>I(i,e)),q(e,s),Ke()}wr([`change`]),Vr(Ks,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/web/dist/assets/index-CjLW2fqm.css b/internal/web/dist/assets/index-CjLW2fqm.css deleted file mode 100644 index b5cb577..0000000 --- a/internal/web/dist/assets/index-CjLW2fqm.css +++ /dev/null @@ -1 +0,0 @@ -.observation-details.svelte-1wk8llw{font-size:12px}summary.svelte-1wk8llw{cursor:pointer;color:var(--accent)}.observation-table.svelte-1wk8llw{max-height:240px;overflow:auto}.zone-canvas.svelte-1wk8llw{flex:1;min-height:170px;margin-top:6px;position:relative}svg.svelte-1wk8llw{width:100%;height:100%;display:block;position:absolute;inset:0}text.svelte-1wk8llw{fill:var(--ink);font:14px Cascadia Code,Consolas,monospace}.axis-title.svelte-1wk8llw{letter-spacing:.04em;font-size:12px}.grid.svelte-1wk8llw{stroke:#fff;stroke-opacity:.14;stroke-width:1px}.axes.svelte-1wk8llw{stroke:var(--ink);stroke-width:1.5px;fill:none}.pace-line.svelte-1wk8llw{stroke:#fff;stroke-width:2px;stroke-dasharray:6 4}.position-halo.svelte-1wk8llw{fill:#101820;stroke:#fff;stroke-width:1.5px}.position-dot.svelte-1wk8llw{fill:#fff}.observation-trail.svelte-1wk8llw{fill:none;stroke:#fff;stroke-width:2.5px;stroke-linejoin:round}.trail-start.svelte-1wk8llw{fill:none;stroke:#fff;stroke-width:2px}.trail-caption.svelte-1wk8llw{text-align:center;font-size:11px}.zone-caption.svelte-1wk8llw{color:var(--accent);text-align:center}fieldset.svelte-1oupzfc{border:1px solid;margin:.5rem 0;padding:.35rem .6rem}.decision.svelte-1oupzfc,.answer.svelte-1oupzfc{margin:.3rem 0;display:block}.decision.svelte-1oupzfc code:where(.svelte-1oupzfc),.decision.svelte-1oupzfc span:where(.svelte-1oupzfc){overflow-wrap:anywhere;margin:.3rem 0 .3rem 1.5rem;display:block}textarea.svelte-1oupzfc,.answer.svelte-1oupzfc input:where(.svelte-1oupzfc),.answer.svelte-1oupzfc select:where(.svelte-1oupzfc){box-sizing:border-box;background:var(--bg);width:100%;color:inherit;font:inherit;border:1px solid;margin-top:.4rem;padding:.5rem;display:block}textarea.svelte-1oupzfc{resize:vertical}button.svelte-1oupzfc{margin:.3rem .5rem .3rem 0}h3.svelte-1oupzfc,p.svelte-1oupzfc{margin-block:.4rem}.sent.svelte-1oupzfc{color:var(--accent)}.session-copy.svelte-543j00{justify-content:flex-end;align-items:center;gap:8px;margin-top:auto;padding-top:6px;display:flex}span.svelte-543j00{color:var(--muted);overflow-wrap:anywhere;font-size:12px}button.svelte-543j00{color:var(--accent);flex-shrink:0;padding:3px 7px}button.svelte-543j00:hover,button.flashed.svelte-543j00{color:var(--bg);background:var(--accent)}h3.svelte-1fbui7h,.window-dates.svelte-1fbui7h,.report-value.svelte-1fbui7h{color:var(--accent);font-weight:700}.quality-warning.svelte-1fbui7h,.quota-near.svelte-1fbui7h{color:var(--approval)}.quota-full.svelte-1fbui7h{color:#ff6680}.alternate.svelte-1fbui7h .report-fill:where(.svelte-1fbui7h){background:radial-gradient(circle, var(--panel) .7px, transparent .9px) 0 0 / 3px 3px, var(--accent)}.unknown.svelte-1fbui7h,.unknown.svelte-1fbui7h .report-value:where(.svelte-1fbui7h){color:var(--muted)}.unknown.svelte-1fbui7h .report-fill:where(.svelte-1fbui7h){background:var(--muted);opacity:1}.report-bars.svelte-1fbui7h{grid-template-columns:minmax(5rem,1fr) minmax(2rem,3fr) auto;gap:.6rem;display:grid}.report-row.svelte-1fbui7h,.report-head.svelte-1fbui7h{grid-column:1/-1;grid-template-columns:subgrid;align-items:center;gap:.6rem;display:grid}.report-head.svelte-1fbui7h{color:var(--muted);font-size:.85rem}.report-head.svelte-1fbui7h>span:where(.svelte-1fbui7h):last-child,.report-value.svelte-1fbui7h{text-align:right}.report-row.svelte-1fbui7h>span:where(.svelte-1fbui7h):first-child{overflow-wrap:anywhere}.report-track.svelte-1fbui7h{background:var(--panel);height:1rem}.report-fill.svelte-1fbui7h{background:var(--accent);height:100%}:root{font-synthesis:none;--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;background:#080e0c;font-family:Cascadia Code,SFMono-Regular,Consolas,monospace}*{box-sizing:border-box}body{margin:0}.shell{--accent:#80edac;--approval:#ffca58;--muted:#98aaa0;--edge:#31473a;--panel:#101c16;--bg:#080e0c;--ink:#e2eee5;background:var(--bg);height:100dvh;color:var(--ink);grid-template-rows:auto auto minmax(0,1fr) auto;padding:clamp(10px,1.2vw,20px);display:grid}.shell[data-theme=rust]{--approval:#ff8a3d;--accent:#ffbc75;--muted:#bfac95;--edge:#59412c;--panel:#261b14;--bg:#140e0a}.shell[data-theme=blue-steel]{--approval:#e8c46a;--accent:#85c8ff;--muted:#9cacc4;--edge:#334d69;--panel:#142235;--bg:#0b1421}.shell[data-theme=ultraviolet]{--approval:#f9a8d4;--accent:#c5adff;--muted:#b3a6c9;--edge:#4b3c68;--panel:#241a35;--bg:#140d22}.shell[data-theme=nightshade]{--approval:#8f7cff;--accent:#e59bff;--muted:#c6a7cf;--edge:#673976;--panel:#301739;--bg:#1c0b24}header,.spread,footer,.controls{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:10px;display:flex}header{margin-bottom:10px}.brand{letter-spacing:.08em;color:var(--accent);text-shadow:0 0 22px color-mix(in srgb, var(--accent) 20%, transparent);font-size:clamp(22px,2.5vw,32px);font-weight:800;text-decoration:none}header p{color:var(--muted);margin:3px 0 0;font-size:13px}.connection{color:var(--accent);text-align:right}small,.eyebrow{letter-spacing:.04em;font-size:12px}.connection small{color:var(--muted);margin-top:4px;display:block}.lamp{background:var(--muted);border-radius:50%;width:9px;height:9px;margin-right:9px;display:inline-block}.lamp.lit{background:var(--accent);box-shadow:0 0 8px color-mix(in srgb, var(--accent) 40%, transparent)}.working{animation:1.5s ease-in-out infinite pulse}@keyframes pulse{50%{opacity:.3}}nav{flex-wrap:wrap;gap:6px;margin-bottom:10px;display:flex}nav a,button,.button,select{font:inherit;color:var(--accent);border:1px solid var(--edge);background:var(--panel);cursor:pointer;border-radius:3px;padding:7px 11px;font-size:13px;text-decoration:none}button:hover,.button:hover,nav a:hover{border-color:var(--accent)}nav a.active,nav button.active{background:var(--accent);color:var(--bg);border-color:var(--accent)}:focus-visible{outline:2px solid var(--accent);outline-offset:4px}.secondary{margin-bottom:8px}.secondary a,.secondary button{padding:6px 10px;font-size:12px}main{scrollbar-gutter:stable;flex-direction:column;min-width:0;min-height:0;display:flex;overflow:auto}main>*{flex-shrink:0}.panel{border:1px solid var(--edge);border-top:2px solid var(--accent);background:var(--panel);border-radius:4px;min-width:0;padding:clamp(10px,1vw,16px)}h1{color:var(--accent);font-size:20px}h2{letter-spacing:.04em;color:var(--accent);overflow-wrap:anywhere;margin:0 0 10px;font-size:13px}h3{overflow-wrap:anywhere;font-size:13px}p{margin:6px 0;font-size:13px;line-height:1.45}a{color:var(--accent)}.muted,.eyebrow{color:var(--muted)}.notice{color:#ffe0aa;background:#332611;border-left:3px solid #ffc26e;padding:12px 16px}.empty{color:var(--muted);padding:35px 0}.quota-grid{flex:1 0 auto;grid-auto-rows:minmax(220px,1fr);gap:10px;display:grid}.quota-card{flex-direction:column;min-height:0;display:flex}.quota-card>:not(.meter-graphic){flex-shrink:0}.meter-graphic{flex-direction:column;flex:1;min-height:100px;display:flex}.bar-graphic{min-height:65px}.quota-card .gauge{flex:2;height:auto;min-height:16px;margin:7px 0}.quota-card .timeline{flex:1;min-height:8px}.quota-card .pace{flex:1;height:auto;min-height:20px;margin:20px 14px 8px}.quota-card .readout{margin:6px 0;font-size:clamp(18px,2vw,28px)}.quota-grid.zone{grid-template-columns:repeat(auto-fit,minmax(min(100%,420px),1fr));grid-auto-rows:minmax(330px,1fr)}.quota-grid.radial{grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));grid-auto-rows:minmax(260px,1fr)}.gauge{background:var(--edge);height:35px;margin:15px 0;overflow:hidden}.gauge>div{background:repeating-linear-gradient(90deg, var(--accent) 0, var(--accent) 9px, transparent 9px, transparent 12px);height:100%;transition:width .5s}.gauge.timeline{height:14px}.pie-wrap{flex:1;min-height:100px;margin:6px 0;position:relative}.pie-wrap svg{width:100%;height:100%;position:absolute;inset:0}.pie-base{fill:var(--edge);stroke:var(--accent);stroke-width:1px}.pie-fill{fill:var(--accent)}.pace{background:linear-gradient(90deg, #6d3838, var(--edge) 50%, #376348);height:28px;margin:28px 14px 15px;position:relative}.pace-mid{border-left:2px solid var(--ink);height:100%;position:absolute;left:50%}.pace-marker{color:var(--accent);font-size:27px;position:absolute;top:-16px;transform:translate(-50%)}.readout{overflow-wrap:anywhere;color:var(--accent);margin:18px 0;font-size:clamp(22px,3vw,34px)}.credit+.credit{border-top:1px solid var(--edge);padding-top:20px}.credit{margin-top:24px}.session-row{grid-template-columns:minmax(210px,1.1fr) minmax(0,1.2fr) minmax(0,1.5fr);align-items:stretch;gap:14px;margin:18px 0;display:grid}.session-totals{grid-template-columns:repeat(auto-fit,minmax(min(145px,100%),1fr));gap:8px;margin:8px 0;display:grid}.session-totals>div{border:1px solid var(--edge);min-width:0;padding:10px}.session-totals dt{color:var(--muted);font-size:11px}.session-totals dd{color:var(--accent);overflow-wrap:anywhere;margin:6px 0 0;font-size:24px}.session-totals.stale dd{color:var(--muted)}.session-row.selected{outline:1px solid var(--accent);outline-offset:4px}.session-row.wide .context{grid-column:2/-1}.detail-controls{flex-wrap:wrap;gap:6px;display:flex}.attention-summary{flex-wrap:wrap;gap:8px;margin-block:8px;display:flex}.attention-summary .approval{color:var(--approval);border-color:var(--approval)}.attention-summary .approval:hover{background:color-mix(in srgb, var(--approval) 12%, var(--panel))}.attention-summary .approval:focus-visible{outline-color:var(--approval)}.attention-note,.attention-badge{color:var(--accent);border-left:3px solid;padding-left:8px}.attention-note.inferred{color:var(--muted)}.attention-badge{font-size:12px}.session-select{text-align:left;overflow-wrap:anywhere;max-width:100%}.status-detail{color:inherit;text-decoration:none}.status-detail:hover{text-decoration:underline}button:disabled{opacity:.4;cursor:default}.session-row .graph-panel{flex-direction:column;grid-column:2/-1;display:flex}.session-row.split .graph-panel{grid-column:auto}.session-row .button,.session-row button{margin-top:8px;display:inline-block}.context pre{max-height:230px;overflow:auto}.session-row .context{flex-direction:column;display:flex}pre{font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;line-height:1.7}.full-detail{margin-top:6px}.detail-heading{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:6px 12px;display:flex}.detail-heading h2{flex:250px;min-width:0;margin:0}.detail-metadata{overflow-wrap:anywhere}.detail-workspace{border-top:1px solid var(--edge);flex-direction:column;gap:10px;margin-top:8px;padding-top:4px;display:flex}.detail-context,.detail-workspace .session-actions{min-width:0}.detail-workspace .session-actions{border-top:1px solid var(--edge);padding-top:6px}.full-detail h3{margin-block:8px}.full-detail pre{margin-block:8px;line-height:1.5}.full-detail hr{margin-block:12px}.full-detail .command,.full-detail .notice{padding:8px 10px}.command{background:var(--bg);border-left:3px solid var(--accent);padding:16px}hr{border:0;border-top:1px solid var(--edge);margin:24px 0}.chart{border-bottom:1px solid var(--muted);align-items:flex-end;gap:2px;height:clamp(120px,22vh,320px);margin-top:18px;display:flex}.chart-bar{background:var(--accent);flex:1;min-width:0;max-height:100%}.controls{justify-content:flex-start;margin:20px 0}.summary-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr));gap:16px;margin:20px 0;display:grid}.thresholds-panel{padding:clamp(14px,2vw,22px)}.thresholds-panel h1{margin-top:0}.threshold-list{gap:8px;margin-top:16px;display:grid}.threshold-list article{border:1px solid var(--edge);grid-template-columns:minmax(64px,.5fr) minmax(220px,3fr) minmax(64px,.6fr) minmax(120px,1.2fr);align-items:center;gap:12px;padding:10px 12px;display:grid}.threshold-list article.active{border-color:var(--accent);box-shadow:inset 3px 0 0 var(--accent)}.threshold-list article.next{border-color:var(--approval);box-shadow:inset 3px 0 0 var(--approval)}.threshold-list p{color:var(--muted);margin:3px 0 0;font-size:12px}.threshold-trigger{color:var(--accent);font-size:22px;font-weight:800}.threshold-mode,.threshold-state{color:var(--muted);font-size:12px;font-weight:700}.threshold-list article.active .threshold-state{color:var(--accent)}.threshold-list article.next .threshold-state{color:var(--approval)}.heat-scroll{overflow-x:auto}.heatmap{grid-template-rows:repeat(7,13px);grid-auto-columns:minmax(9px,1fr);grid-auto-flow:column;gap:4px;min-width:620px;margin:25px 0;display:grid}.heat-cell{background:var(--accent);border-radius:2px}.heat-cell.zero{background:var(--edge)}.table-scroll{max-height:280px;overflow:auto}table{border-collapse:collapse;width:100%;margin-top:15px}th,td{text-align:left;border-bottom:1px solid var(--edge);padding:8px}summary{cursor:pointer;color:var(--accent);padding-top:14px}footer{border-top:1px solid var(--edge);color:var(--muted);margin-top:8px;padding-top:8px;font-size:11px}footer select{padding:6px}@media (width<=850px){.session-row{grid-template-columns:minmax(0,1fr)}.session-row.wide .context,.session-row .graph-panel{grid-column:auto}.connection{text-align:left}.threshold-list article{grid-template-columns:64px minmax(0,1fr)}.threshold-mode,.threshold-state{grid-column:2}}@media (prefers-reduced-motion:reduce){*,:before,:after{transition:none!important;animation:none!important}} diff --git a/internal/web/dist/assets/index-DdN1yutC.css b/internal/web/dist/assets/index-DdN1yutC.css new file mode 100644 index 0000000..09a4caf --- /dev/null +++ b/internal/web/dist/assets/index-DdN1yutC.css @@ -0,0 +1 @@ +.observation-details.svelte-1wk8llw{font-size:12px}summary.svelte-1wk8llw{cursor:pointer;color:var(--accent)}.observation-table.svelte-1wk8llw{max-height:240px;overflow:auto}.zone-canvas.svelte-1wk8llw{flex:1;min-height:170px;margin-top:6px;position:relative}svg.svelte-1wk8llw{width:100%;height:100%;display:block;position:absolute;inset:0}text.svelte-1wk8llw{fill:var(--ink);font:14px Cascadia Code,Consolas,monospace}.axis-title.svelte-1wk8llw{letter-spacing:.04em;font-size:12px}.grid.svelte-1wk8llw{stroke:#fff;stroke-opacity:.14;stroke-width:1px}.axes.svelte-1wk8llw{stroke:var(--ink);stroke-width:1.5px;fill:none}.pace-line.svelte-1wk8llw{stroke:#fff;stroke-width:2px;stroke-dasharray:6 4}.position-halo.svelte-1wk8llw{fill:#101820;stroke:#fff;stroke-width:1.5px}.position-dot.svelte-1wk8llw{fill:#fff}.observation-trail.svelte-1wk8llw{fill:none;stroke:#fff;stroke-width:2.5px;stroke-linejoin:round}.trail-start.svelte-1wk8llw{fill:none;stroke:#fff;stroke-width:2px}.trail-caption.svelte-1wk8llw{text-align:center;font-size:11px}.zone-caption.svelte-1wk8llw{color:var(--accent);text-align:center}fieldset.svelte-1oupzfc{border:1px solid;margin:.5rem 0;padding:.35rem .6rem}.decision.svelte-1oupzfc,.answer.svelte-1oupzfc{margin:.3rem 0;display:block}.decision.svelte-1oupzfc code:where(.svelte-1oupzfc),.decision.svelte-1oupzfc span:where(.svelte-1oupzfc){overflow-wrap:anywhere;margin:.3rem 0 .3rem 1.5rem;display:block}textarea.svelte-1oupzfc,.answer.svelte-1oupzfc input:where(.svelte-1oupzfc),.answer.svelte-1oupzfc select:where(.svelte-1oupzfc){box-sizing:border-box;background:var(--bg);width:100%;color:inherit;font:inherit;border:1px solid;margin-top:.4rem;padding:.5rem;display:block}textarea.svelte-1oupzfc{resize:vertical;background:color-mix(in srgb, currentColor 8%, var(--bg))}button.svelte-1oupzfc{margin:.3rem .5rem .3rem 0}h3.svelte-1oupzfc,p.svelte-1oupzfc{margin-block:.4rem}.sent.svelte-1oupzfc{color:var(--accent)}.session-copy.svelte-543j00{justify-content:flex-end;align-items:center;gap:8px;margin-top:auto;padding-top:6px;display:flex}span.svelte-543j00{color:var(--muted);overflow-wrap:anywhere;font-size:12px}button.svelte-543j00{color:var(--accent);flex-shrink:0;padding:3px 7px}button.svelte-543j00:hover,button.flashed.svelte-543j00{color:var(--bg);background:var(--accent)}h3.svelte-1fbui7h,.window-dates.svelte-1fbui7h,.report-value.svelte-1fbui7h{color:var(--accent);font-weight:700}.quality-warning.svelte-1fbui7h,.quota-near.svelte-1fbui7h{color:var(--approval)}.quota-full.svelte-1fbui7h{color:#ff6680}.alternate.svelte-1fbui7h .report-fill:where(.svelte-1fbui7h){background:radial-gradient(circle, var(--panel) .7px, transparent .9px) 0 0 / 3px 3px, var(--accent)}.unknown.svelte-1fbui7h,.unknown.svelte-1fbui7h .report-value:where(.svelte-1fbui7h){color:var(--muted)}.unknown.svelte-1fbui7h .report-fill:where(.svelte-1fbui7h){background:var(--muted);opacity:1}.report-bars.svelte-1fbui7h{grid-template-columns:minmax(5rem,1fr) minmax(2rem,3fr) auto;gap:.6rem;display:grid}.report-row.svelte-1fbui7h,.report-head.svelte-1fbui7h{grid-column:1/-1;grid-template-columns:subgrid;align-items:center;gap:.6rem;display:grid}.report-head.svelte-1fbui7h{color:var(--muted);font-size:.85rem}.report-head.svelte-1fbui7h>span:where(.svelte-1fbui7h):last-child,.report-value.svelte-1fbui7h{text-align:right}.report-row.svelte-1fbui7h>span:where(.svelte-1fbui7h):first-child{overflow-wrap:anywhere}.report-track.svelte-1fbui7h{background:var(--panel);height:1rem}.report-fill.svelte-1fbui7h{background:var(--accent);height:100%}:root{font-synthesis:none;--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;background:#080e0c;font-family:Cascadia Code,SFMono-Regular,Consolas,monospace}*{box-sizing:border-box}body{margin:0}.shell{--accent:#80edac;--approval:#ffca58;--muted:#98aaa0;--edge:#31473a;--panel:#101c16;--bg:#080e0c;--ink:#e2eee5;background:var(--bg);height:100dvh;color:var(--ink);grid-template-rows:auto auto minmax(0,1fr) auto;padding:clamp(10px,1.2vw,20px);display:grid}.shell[data-theme=rust]{--approval:#ff8a3d;--accent:#ffbc75;--muted:#bfac95;--edge:#59412c;--panel:#261b14;--bg:#140e0a}.shell[data-theme=blue-steel]{--approval:#e8c46a;--accent:#85c8ff;--muted:#9cacc4;--edge:#334d69;--panel:#142235;--bg:#0b1421}.shell[data-theme=ultraviolet]{--approval:#f9a8d4;--accent:#c5adff;--muted:#b3a6c9;--edge:#4b3c68;--panel:#241a35;--bg:#140d22}.shell[data-theme=nightshade]{--approval:#8f7cff;--accent:#e59bff;--muted:#c6a7cf;--edge:#673976;--panel:#301739;--bg:#1c0b24}header,.spread,footer,.controls{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:10px;display:flex}header{margin-bottom:10px}.brand{letter-spacing:.08em;color:var(--accent);text-shadow:0 0 22px color-mix(in srgb, var(--accent) 20%, transparent);font-size:clamp(22px,2.5vw,32px);font-weight:800;text-decoration:none}header p{color:var(--muted);margin:3px 0 0;font-size:13px}.connection{color:var(--accent);text-align:right}small,.eyebrow{letter-spacing:.04em;font-size:12px}.connection small{color:var(--muted);margin-top:4px;display:block}.lamp{background:var(--muted);border-radius:50%;width:9px;height:9px;margin-right:9px;display:inline-block}.lamp.lit{background:var(--accent);box-shadow:0 0 8px color-mix(in srgb, var(--accent) 40%, transparent)}.working{animation:1.5s ease-in-out infinite pulse}@keyframes pulse{50%{opacity:.3}}nav{flex-wrap:wrap;gap:6px;margin-bottom:10px;display:flex}nav a,button,.button,select{font:inherit;color:var(--accent);border:1px solid var(--edge);background:var(--panel);cursor:pointer;border-radius:3px;padding:7px 11px;font-size:13px;text-decoration:none}button:hover,.button:hover,nav a:hover{border-color:var(--accent)}nav a.active,nav button.active{background:var(--accent);color:var(--bg);border-color:var(--accent)}:focus-visible{outline:2px solid var(--accent);outline-offset:4px}.secondary{margin-bottom:8px}.secondary a,.secondary button{padding:6px 10px;font-size:12px}main{scrollbar-gutter:stable;flex-direction:column;min-width:0;min-height:0;display:flex;overflow:auto}main>*{flex-shrink:0}.panel{border:1px solid var(--edge);border-top:2px solid var(--accent);background:var(--panel);border-radius:4px;min-width:0;padding:clamp(10px,1vw,16px)}h1{color:var(--accent);font-size:20px}h2{letter-spacing:.04em;color:var(--accent);overflow-wrap:anywhere;margin:0 0 10px;font-size:13px}h3{overflow-wrap:anywhere;font-size:13px}p{margin:6px 0;font-size:13px;line-height:1.45}a{color:var(--accent)}.muted,.eyebrow{color:var(--muted)}.notice{color:#ffe0aa;background:#332611;border-left:3px solid #ffc26e;padding:12px 16px}.empty{color:var(--muted);padding:35px 0}.quota-grid{flex:1 0 auto;grid-auto-rows:minmax(220px,1fr);gap:10px;display:grid}.quota-card{flex-direction:column;min-height:0;display:flex}.quota-card>:not(.meter-graphic){flex-shrink:0}.meter-graphic{flex-direction:column;flex:1;min-height:100px;display:flex}.bar-graphic{min-height:65px}.quota-card .gauge{flex:2;height:auto;min-height:16px;margin:7px 0}.quota-card .timeline{flex:1;min-height:8px}.quota-card .pace{flex:1;height:auto;min-height:20px;margin:20px 14px 8px}.quota-card .readout{margin:6px 0;font-size:clamp(18px,2vw,28px)}.quota-grid.zone{grid-template-columns:repeat(auto-fit,minmax(min(100%,420px),1fr));grid-auto-rows:minmax(330px,1fr)}.quota-grid.radial{grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));grid-auto-rows:minmax(260px,1fr)}.gauge{background:var(--edge);height:35px;margin:15px 0;overflow:hidden}.gauge>div{background:repeating-linear-gradient(90deg, var(--accent) 0, var(--accent) 9px, transparent 9px, transparent 12px);height:100%;transition:width .5s}.gauge.timeline{height:14px}.pie-wrap{flex:1;min-height:100px;margin:6px 0;position:relative}.pie-wrap svg{width:100%;height:100%;position:absolute;inset:0}.pie-base{fill:var(--edge);stroke:var(--accent);stroke-width:1px}.pie-fill{fill:var(--accent)}.pace{background:linear-gradient(90deg, #6d3838, var(--edge) 50%, #376348);height:28px;margin:28px 14px 15px;position:relative}.pace-mid{border-left:2px solid var(--ink);height:100%;position:absolute;left:50%}.pace-marker{color:var(--accent);font-size:27px;position:absolute;top:-16px;transform:translate(-50%)}.readout{overflow-wrap:anywhere;color:var(--accent);margin:18px 0;font-size:clamp(22px,3vw,34px)}.credit+.credit{border-top:1px solid var(--edge);padding-top:20px}.credit{margin-top:24px}.session-row{grid-template-columns:minmax(210px,1.1fr) minmax(0,1.2fr) minmax(0,1.5fr);align-items:stretch;gap:14px;margin:18px 0;display:grid}.session-totals{grid-template-columns:repeat(auto-fit,minmax(min(145px,100%),1fr));gap:8px;margin:8px 0;display:grid}.session-totals>div{border:1px solid var(--edge);min-width:0;padding:10px}.session-totals dt{color:var(--muted);font-size:11px}.session-totals dd{color:var(--accent);overflow-wrap:anywhere;margin:6px 0 0;font-size:24px}.session-totals.stale dd{color:var(--muted)}.session-row.selected{outline:1px solid var(--accent);outline-offset:4px}.session-row.wide .context{grid-column:2/-1}.detail-controls{flex-wrap:wrap;gap:6px;display:flex}.attention-summary{flex-wrap:wrap;gap:8px;margin-block:8px;display:flex}.attention-summary .approval{color:var(--approval);border-color:var(--approval)}.attention-summary .approval:hover{background:color-mix(in srgb, var(--approval) 12%, var(--panel))}.attention-summary .approval:focus-visible{outline-color:var(--approval)}.attention-note,.attention-badge{color:var(--accent);border-left:3px solid;padding-left:8px}.attention-note.inferred{color:var(--muted)}.attention-badge{font-size:12px}.session-select{text-align:left;overflow-wrap:anywhere;max-width:100%}.status-detail{color:inherit;text-decoration:none}.status-detail:hover{text-decoration:underline}button:disabled{opacity:.4;cursor:default}.session-row .graph-panel{flex-direction:column;grid-column:2/-1;display:flex}.session-row.split .graph-panel{grid-column:auto}.session-row .button,.session-row button{margin-top:8px;display:inline-block}.context pre{max-height:230px;overflow:auto}.session-row .context{flex-direction:column;display:flex}pre{font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;line-height:1.7}.full-detail{margin-top:6px}.detail-heading{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:6px 12px;display:flex}.detail-heading h2{flex:250px;min-width:0;margin:0}.detail-metadata{overflow-wrap:anywhere}.detail-workspace{border-top:1px solid var(--edge);flex-direction:column;gap:10px;margin-top:8px;padding-top:4px;display:flex}.detail-context,.detail-workspace .session-actions{min-width:0}.detail-workspace .session-actions{border-top:1px solid var(--edge);padding-top:6px}.full-detail h3{margin-block:8px}.full-detail pre{margin-block:8px;line-height:1.5}.full-detail hr{margin-block:12px}.full-detail .command,.full-detail .notice{padding:8px 10px}.command{background:var(--bg);border-left:3px solid var(--accent);padding:16px}hr{border:0;border-top:1px solid var(--edge);margin:24px 0}.chart{border-bottom:1px solid var(--muted);align-items:flex-end;gap:2px;height:clamp(120px,22vh,320px);margin-top:18px;display:flex}.chart-bar{background:var(--accent);flex:1;min-width:0;max-height:100%}.controls{justify-content:flex-start;margin:20px 0}.summary-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr));gap:16px;margin:20px 0;display:grid}.thresholds-panel{padding:clamp(14px,2vw,22px)}.thresholds-panel h1{margin-top:0}.threshold-list{gap:8px;margin-top:16px;display:grid}.threshold-list article{border:1px solid var(--edge);grid-template-columns:minmax(64px,.5fr) minmax(220px,3fr) minmax(64px,.6fr) minmax(120px,1.2fr);align-items:center;gap:12px;padding:10px 12px;display:grid}.threshold-list article.active{border-color:var(--accent);box-shadow:inset 3px 0 0 var(--accent)}.threshold-list article.next{border-color:var(--approval);box-shadow:inset 3px 0 0 var(--approval)}.threshold-list p{color:var(--muted);margin:3px 0 0;font-size:12px}.threshold-trigger{color:var(--accent);font-size:22px;font-weight:800}.threshold-mode,.threshold-state{color:var(--muted);font-size:12px;font-weight:700}.threshold-list article.active .threshold-state{color:var(--accent)}.threshold-list article.next .threshold-state{color:var(--approval)}.heat-scroll{overflow-x:auto}.heatmap{grid-template-rows:repeat(7,13px);grid-auto-columns:minmax(9px,1fr);grid-auto-flow:column;gap:4px;min-width:620px;margin:25px 0;display:grid}.heat-cell{background:var(--accent);border-radius:2px}.heat-cell.zero{background:var(--edge)}.table-scroll{max-height:280px;overflow:auto}table{border-collapse:collapse;width:100%;margin-top:15px}th,td{text-align:left;border-bottom:1px solid var(--edge);padding:8px}summary{cursor:pointer;color:var(--accent);padding-top:14px}footer{border-top:1px solid var(--edge);color:var(--muted);margin-top:8px;padding-top:8px;font-size:11px}footer select{padding:6px}@media (width<=850px){.session-row{grid-template-columns:minmax(0,1fr)}.session-row.wide .context,.session-row .graph-panel{grid-column:auto}.connection{text-align:left}.threshold-list article{grid-template-columns:64px minmax(0,1fr)}.threshold-mode,.threshold-state{grid-column:2}}@media (prefers-reduced-motion:reduce){*,:before,:after{transition:none!important;animation:none!important}} diff --git a/internal/web/dist/index.html b/internal/web/dist/index.html index 5691482..92522f5 100644 --- a/internal/web/dist/index.html +++ b/internal/web/dist/index.html @@ -5,8 +5,8 @@ Codexometer // Experimental web - - + +
        diff --git a/internal/web/schedules.go b/internal/web/schedules.go new file mode 100644 index 0000000..6d2871f --- /dev/null +++ b/internal/web/schedules.go @@ -0,0 +1,131 @@ +package web + +import ( + "context" + "encoding/json" + "net/http" + "slices" + "time" + + "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/schedule" +) + +type scheduleRule struct { + Trigger string `json:"trigger"` + At time.Time `json:"at"` + Zone string `json:"zone"` +} + +func (r scheduleRule) valid(now time.Time) bool { + return len(r.Zone) <= 128 && ((r.Trigger == "quota" && r.At.IsZero()) || (r.Trigger == "at" && r.At.After(now) && r.At.Before(now.AddDate(1, 0, 0)))) +} + +type triggerSummary struct { + Session string `json:"session"` + Status string `json:"status"` +} + +func (c *control) scheduleSnapshot() codex.Snapshot { + c.store.mu.Lock() + defer c.store.mu.Unlock() + if c.store.state.QuotaError { + return codex.Snapshot{} + } + return c.store.scheduleQuota +} +func (c *control) scheduleBlocked(session string) bool { + c.store.mu.Lock() + defer c.store.mu.Unlock() + if c.store.state.ProfileError { + return true + } + for _, p := range c.store.state.Profiles { + if p.Session == session && (p.Pending || p.Notice != "") { + return true + } + } + return false +} +func (c *control) publishSchedules() { + jobs := c.schedules.List("") + c.store.mu.Lock() + defer c.store.mu.Unlock() + var next []triggerSummary + for _, j := range jobs { + if j.Status != "sent" { + next = append(next, triggerSummary{j.Session, j.Status}) + } + } + if slices.Equal(c.store.state.Triggers, next) { + return + } + c.store.state.Triggers = next + c.store.publish() +} +func (c *control) handleSchedules(w http.ResponseWriter, r *http.Request, b actionRequest) { + if b.Schedule != nil || b.Offer != "" || b.Choice != nil || len(b.Answers) > 0 || b.Review != "" || b.Confirmation != "" { + http.Error(w, "Invalid schedule request", 400) + return + } + if b.CancelID != "" { + if err := c.schedules.Cancel(b.Session, b.CancelID); err != nil { + http.Error(w, err.Error(), 409) + return + } + c.publishSchedules() + } + w.Header().Set("Content-Type", "application/json") + _ = json.NewEncoder(w).Encode(c.schedules.List(b.Session)) +} +func (c *control) collectSchedules(ctx context.Context) func() { + done := make(chan struct{}) + go func() { + defer close(done) + ticker := time.NewTicker(time.Second) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + c.dispatchSchedules(ctx) + } + } + }() + return func() { <-done } +} +func (c *control) dispatchSchedules(ctx context.Context) { + if c.prompts == nil { + return + } + q := c.scheduleSnapshot() + if !schedule.QuotaReady(q, time.Now()) { + return + } + c.mu.Lock() + confirming := c.pending != nil && time.Now().Before(c.pending.until) + c.mu.Unlock() + if confirming { + return + } + for _, j := range c.schedules.List("") { + if j.Status != "pending" || c.scheduleBlocked(j.Session) || !schedule.Covers(j, q) || !schedule.Fresh(q, time.Now()) { + continue + } + o, err := c.offer(j.Session) + if err != nil || o.Kind != "prompt" || o.Thread != j.Session || len(o.Questions) > 0 { + continue + } + call, cancel := context.WithTimeout(ctx, 6*time.Second) + _ = c.schedules.Dispatch(call, j.ID, q.AccountFingerprint, true, time.Now(), func(ctx context.Context, j schedule.Job) error { + latest := c.scheduleSnapshot() + if latest.AccountFingerprint != q.AccountFingerprint || !schedule.QuotaReady(latest, time.Now()) || !schedule.Covers(j, latest) || c.scheduleBlocked(j.Session) { + return errUnavailable + } + return c.prompts.SendSessionPrompt(ctx, o.token, []string{j.Text}) + }) + cancel() + } + c.publishSchedules() +} diff --git a/internal/web/schedules_test.go b/internal/web/schedules_test.go new file mode 100644 index 0000000..562d159 --- /dev/null +++ b/internal/web/schedules_test.go @@ -0,0 +1,70 @@ +package web + +import ( + "context" + "github.com/merefield/codexometer/internal/codex" + "testing" + "time" +) + +func TestSchedulePrepareCommitDispatchAndCancel(t *testing.T) { + s, f, token := controlServer(t) + s.store.contexts["parent"] = codex.SessionContext{Kind: codex.SessionContextReply} + f.prompt = codex.SessionPromptOffer{ThreadID: "parent", Token: "idle"} + s.store.scheduleQuota = codex.Snapshot{AccountFingerprint: "a", FetchedAt: time.Now(), RateLimits: codex.RateLimitSnapshot{Primary: &codex.Window{UsedPercent: 100}}} + o := getOffer(t, s, token) + r := prepareAction(t, s, token, actionRequest{Session: "parent", Offer: o.ID, Answers: []string{"later"}, Schedule: &scheduleRule{Trigger: "quota"}}) + if len(s.control.schedules.List("")) != 0 { + t.Fatal("prepare saved") + } + if w := actionCall(s, token, "commit", r); w.Code != 200 { + t.Fatalf("commit: %s", w.Body) + } + if f.calls != 0 { + t.Fatal("schedule sent immediately") + } + s.control.dispatchSchedules(context.Background()) + if f.calls != 0 { + t.Fatal("sent while exhausted") + } + s.store.scheduleQuota.RateLimits.Primary.UsedPercent = 0 + s.control.dispatchSchedules(context.Background()) + s.control.dispatchSchedules(context.Background()) + if f.calls != 1 || len(f.answers) != 1 || f.answers[0] != "later" { + t.Fatal("wrong dispatch", f.calls, f.answers) + } + jobs := s.control.schedules.List("parent") + if jobs[0].Status != "sent" { + t.Fatal(jobs) + } + if w := actionCall(s, token, "schedules", actionRequest{Session: "parent", CancelID: jobs[0].ID}); w.Code != 200 { + t.Fatal(w.Body) + } + if len(s.control.schedules.List("")) != 0 { + t.Fatal("not cancelled") + } +} + +func TestScheduleCannotAttachToApproval(t *testing.T) { + s, _, token := controlServer(t) + o := getOffer(t, s, token) + choice := 0 + w := actionCall(s, token, "prepare", actionRequest{Session: "parent", Offer: o.ID, Choice: &choice, Schedule: &scheduleRule{Trigger: "quota"}}) + if w.Code != 409 { + t.Fatal("scheduled approval", w.Code) + } +} + +func TestScheduleFreshnessAndAuthentication(t *testing.T) { + s, f, token := controlServer(t) + s.store.contexts["parent"] = codex.SessionContext{Kind: codex.SessionContextReply} + f.prompt = codex.SessionPromptOffer{ThreadID: "parent", Token: "idle"} + o := getOffer(t, s, token) + r := prepareAction(t, s, token, actionRequest{Session: "parent", Offer: o.ID, Answers: []string{"later"}, Schedule: &scheduleRule{Trigger: "quota"}}) + if w := actionCall(s, token, "commit", r); w.Code != 409 { + t.Fatal("accepted missing quota", w.Code) + } + if w := actionCall(s, "", "schedules", actionRequest{Session: "parent"}); w.Code == 200 { + t.Fatal("unauthenticated schedule access") + } +} diff --git a/internal/web/server.go b/internal/web/server.go index 4d6bb13..6e1cb1b 100644 --- a/internal/web/server.go +++ b/internal/web/server.go @@ -62,6 +62,8 @@ func Run(ctx context.Context, source Source, refresh time.Duration, port int, ou ctx, cancel := context.WithCancel(ctx) defer cancel() if s.control != nil { + waitSchedules := s.control.collectSchedules(ctx) + defer func() { cancel(); waitSchedules() }() waitProfiles := s.control.collectProfiles(ctx, refresh) defer func() { cancel(); waitProfiles() }() } @@ -101,7 +103,7 @@ func (s *server) handler() http.Handler { }))) mux.Handle("GET /api/events", s.authorize(http.HandlerFunc(s.events))) if s.control != nil { - for _, action := range []string{"offer", "prepare", "commit"} { + for _, action := range []string{"offer", "prepare", "commit", "schedules"} { mux.Handle("POST /api/control/"+action, s.authorize(http.HandlerFunc(s.control.handle(action, "http://"+s.host)))) } } diff --git a/internal/web/state.go b/internal/web/state.go index 2d45e57..830cfe6 100644 --- a/internal/web/state.go +++ b/internal/web/state.go @@ -114,6 +114,7 @@ type quotaThreshold struct { } type state struct { + Triggers []triggerSummary `json:"triggers,omitempty"` Profiles []profileReview `json:"profiles,omitempty"` Thresholds []quotaThreshold `json:"thresholds,omitempty"` ProfileError bool `json:"profileError,omitempty"` @@ -136,6 +137,7 @@ type store struct { profileWindow string profileRevision uint64 quotaSnapshot codex.Snapshot + scheduleQuota codex.Snapshot contexts map[string]codex.SessionContext // Private: never published in state/SSE. directories map[string]string mu sync.Mutex @@ -207,6 +209,7 @@ func (s *store) quota(q codex.Snapshot, err error, now time.Time) { gap := s.state.QuotaError s.state.QuotaError = err != nil if err == nil { + s.scheduleQuota = q s.quotaSnapshot = codex.CaptureQuotaProfile(q) previous := s.state.Meters if s.account != q.AccountFingerprint { diff --git a/intro-post.md b/intro-post.md index 9d2a357..4a5b4a8 100644 --- a/intro-post.md +++ b/intro-post.md @@ -87,6 +87,8 @@ Subtle animated dots in inline and full-screen detail indicate observed work, di On a shared-server session ready for input, the selected full-width detail row also offers a follow-up composer when there is room for the complete context. Click or press Enter to write, Enter to send, and Escape to leave the editor. Smaller panels and structured questions keep full-screen detail as the fallback. +**Schedule the next move:** experimental full-detail scheduling (Ctrl+S, also in writable web mode) offers a delay, a calendar date/time, or confirmed quota recovery. A **TRIGGER SET** signpost keeps the one pending request per session visible; inspect, edit or cancel it in detail. Requests follow session settings and wait for an eligible idle session. Keep Codexometer running: the queue is memory-only, closing the process cancels it, and uncertain sends are never automatically retried. It does not redeem reset credits. + ## Quota estimates, resets, and session attention API-equivalent figures are workload-dependent estimates, not your subscription’s cash value or a statement of OpenAI’s private quota formula. They need clean observed quota movement to learn, show uncertainty, and restart learning when Codexometer is relaunched. Pricing uses published input, cached-input, and output rates where the model and usage are known; missing data is not treated as free. diff --git a/web/src/SessionActions.svelte b/web/src/SessionActions.svelte index 9dd0a82..dede70f 100644 --- a/web/src/SessionActions.svelte +++ b/web/src/SessionActions.svelte @@ -43,6 +43,44 @@ let success = $state(false); let offerError = $state(false); let sent = $state(''); + let timing = $state('now'); + let delay = $state(60); + let dateTime = $state(''); + let scheduled = $state(false); + let triggerDescription = $state(''); + interface Job { + id: string; + session: string; + text: string; + trigger: string; + at: string; + status: string; + } + let jobs = $state([]); + async function loadJobs() { + if (review) return; + try { + jobs = await controlRequest( + 'schedules', + { session }, + controller.signal, + ); + } catch { + /* Keep last known pending job visible on disconnect. */ + } + } + async function cancelJob(id: string) { + try { + jobs = await controlRequest( + 'schedules', + { session, cancelId: id }, + controller.signal, + ); + } catch (error) { + notice = + error instanceof Error ? error.message : 'Unable to cancel trigger.'; + } + } $effect(() => { onProtectedChange(busy || answers.some((answer) => answer.length > 0)); return () => onProtectedChange(false); @@ -102,6 +140,7 @@ now = Date.now(); }, 1000); async function poll() { + await loadJobs(); try { const next = await controlRequest( 'offer', @@ -146,6 +185,27 @@ success = false; confirmation = ''; try { + const schedule = + offer.kind === 'prompt' && !offer.questions?.length && timing !== 'now' + ? { + trigger: timing === 'quota' ? 'quota' : 'at', + zone: Intl.DateTimeFormat().resolvedOptions().timeZone, + ...(timing === 'quota' + ? {} + : { + at: (timing === 'delay' + ? new Date(Date.now() + delay * 60000) + : new Date(dateTime) + ).toISOString(), + }), + } + : undefined; + scheduled = !!schedule; + triggerDescription = schedule + ? schedule.trigger === 'quota' + ? 'After fresh quota becomes available, when the session is idle' + : new Date(schedule.at!).toLocaleString() + ' — when idle' + : ''; const result = await controlRequest<{ confirmation: string; expires: string; @@ -155,6 +215,7 @@ session, ...(review ? { review } : {}), offer: id, + ...(schedule ? { schedule } : {}), ...(offer.kind === 'approval' || offer.kind === 'profile' ? { choice } : { answers: [...answers] }), @@ -200,8 +261,13 @@ controller.signal, ); success = true; - notice = - kind === 'profile' + if (scheduled) { + sent = ''; + await loadJobs(); + } + notice = scheduled + ? 'Trigger set. Closing Codexometer cancels it.' + : kind === 'profile' ? 'Profile decision completed.' : kind === 'approval' ? 'Decision sent.' @@ -219,6 +285,50 @@ } +{#if !review} + {#each jobs.filter((j) => j.status !== 'sent') as job (job.id)} +
        +

        + {job.status === 'uncertain' + ? 'CHECK TRIGGER — outcome uncertain; not retried' + : 'TRIGGER SET'} +

        +

        TARGET // {job.session}

        +

        + {job.trigger === 'quota' + ? 'After confirmed quota recovery, when idle' + : `${new Date(job.at).toLocaleString()} — when idle`} // {job.status} +

        +
        {job.text}
        +

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

        + + +
        + {/each} +{/if} + {#if !followUpBlocked}

        @@ -304,6 +414,38 @@ {/each} {:else} + {#if !offer.questions?.length} + + {#if timing === 'delay'}{/if} + {#if timing === 'at'}{/if} + {#if timing !== 'now'}

        + 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. +

        {/if} + {/if} {#each questions as question, index}

        {/each} {/if} -{#if !followUpBlocked} +{#if !followUpBlocked && (!pending || editing || review || offer?.kind !== 'prompt' || offer.questions?.length)}

        {review === 'profile' @@ -418,8 +513,8 @@ `),uo=K(``),fo=K(``),po=K(``),mo=K(`

        `),ho=K(` `,1),go=K(``),_o=K(``),vo=K(``),yo=K(` `,1),bo=K(`
      • `),xo=K(`
        View fixed choices

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

          `),So=K(` `,1),Co=K(`

          `),wo=K(`

          `,1),To=K(``),Eo=K(``),Do=K(`

          `,1),Oo=K(`

          `);function ko(e,t){Ge(t,!0);let n=[],r=Bi(t,`observedCommand`,3,``),i=Bi(t,`review`,3,``),a=Bi(t,`suspended`,3,!1),o=Bi(t,`openScheduler`,3,!1),s=Bi(t,`onProtectedChange`,3,e=>{}),c=F(null),l=F(Zt([])),u=F(null),d=F(``),f=F(0),p=F(Zt(Date.now())),m=F(!1),h=F(``),g=F(!1),_=F(!1),v=F(``),y=F(!1),b=F(!1),x=F(``),S=F(`now`),C=F(60),w=F(``),T=F(!1),ee=F(``),E=F(Zt([])),D=N(()=>W(E).find(e=>e.status!==`sent`));function te(e){if(e.status!==`pending`||W(m)||!W(c)?.id||W(c).kind!==`prompt`||W(c).questions?.length)return;I(y,!0),I(l,[e.text],!0),I(S,e.trigger===`quota`?`quota`:`at`,!0),I(d,``),I(x,``);let t=new Date(e.at);e.trigger!==`quota`&&I(w,new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,16),!0)}bn(()=>{o()&&W(D)&&!W(b)&&W(c)?.id&&W(c).kind===`prompt`&&!W(c).questions?.length&&(I(b,!0),te(W(D)))});async function ne(){if(!i())try{I(E,await la(`schedules`,{session:t.session},fe.signal),!0),W(x)&&!W(E).some(e=>e.id===W(x)&&e.status===`pending`)&&(I(d,``),I(x,``))}catch{}}async function re(e){try{I(E,await la(`schedules`,{session:t.session,cancelId:e},fe.signal),!0),I(y,!1),I(d,``),I(x,``),I(l,[],!0)}catch(e){I(h,e instanceof Error?e.message:`Unable to cancel trigger.`,!0)}}bn(()=>(s()(W(m)||W(l).some(e=>e.length>0)),()=>s()(!1)));let ie=N(()=>$.data?.sessions.find(e=>e.id===t.session)?.status),ae=N(()=>!$.connected||!!$.data?.sessionsError),oe=N(()=>i()!==`profile`&&W(c)?.kind===`prompt`&&!W(c).questions?.length&&!!$.data?.profiles?.some(e=>e.session===t.session&&e.pending)),se=N(()=>!W(ae)&&!W(_)&&!!W(c)?.id&&W(c).kind===`approval`&&W(v)!==W(c).id),ce=N(()=>W(se)?W(c).command:r()),le=N(()=>!!W(d)&&W(p)W(c)?.questions?.length?W(c).questions:[{text:`Follow-up message`,secret:!1,freeText:!0,options:[]}]),de=N(()=>W(c)?.kind===`approval`||W(c)?.kind===`profile`?W(u)!==null:W(l).length===W(ue).length&&W(l).every((e,t)=>e.trim().length>0&&(W(ue)[t].freeText||W(ue)[t].options?.includes(e))));bn(()=>{(W(ae)||a()||W(oe)||W(p)>=W(f))&&I(d,``)});let fe=new AbortController;Vi(()=>{let e=e=>{e.ctrlKey&&e.key.toLowerCase()===`s`&&!i()&&W(D)&&(e.preventDefault(),te(W(D)))},n=e=>{e.detail===t.session&&!i()&&W(D)&&te(W(D))};window.addEventListener(`keydown`,e),window.addEventListener(`edit-trigger`,n);let r,a=setInterval(()=>{I(p,Date.now(),!0)},1e3);async function o(){await ne();try{let e=await la(`offer`,{session:t.session,...i()?{review:i()}:{}},fe.signal);if(fe.signal.aborted)return;I(_,!1),W(c)?.id!==e.id&&(I(d,``),I(u,null),I(l,Array(Math.max(1,e.questions?.length||0)).fill(``),!0)),I(c,e,!0),W(g)&&e.id&&e.id!==W(v)&&(I(h,``),I(g,!1))}catch{fe.signal.aborted||(I(c,null),I(_,!0),I(d,``))}finally{fe.signal.aborted||(r=setTimeout(o,2e3))}}return o(),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`edit-trigger`,n),fe.abort(),clearTimeout(r),clearInterval(a)}});async function pe(e){if(!W(c)?.id||W(m)||W(ae)||a()||W(oe)||(e?!e.canSend:!W(de)))return;let n=W(c).id;I(m,!0),I(h,``),I(g,!1),I(d,``),I(x,e?.id||``,!0);try{let r=!e&&W(c).kind===`prompt`&&!W(c).questions?.length&&W(S)!==`now`?{trigger:W(S)===`quota`?`quota`:`at`,zone:Intl.DateTimeFormat().resolvedOptions().timeZone,...W(S)===`quota`?{}:{at:(W(S)===`delay`?new Date(Date.now()+W(C)*6e4):new Date(W(w))).toISOString()}}:void 0;I(T,!!r),I(ee,r?r.trigger===`quota`?`After fresh quota becomes available, when the session is idle`:new Date(r.at).toLocaleString()+` — when idle`:``,!0);let o=await la(`prepare`,{session:t.session,...i()?{review:i()}:{},offer:n,...e?{sendId:e.id}:{},...r?{schedule:r}:{},...W(c).kind===`approval`||W(c).kind===`profile`?{choice:W(u)}:{answers:e?[e.text]:[...W(l)]}},fe.signal);W(c)?.id===n&&!fe.signal.aborted&&!W(ae)&&!a()&&!W(oe)&&(I(d,o.confirmation,!0),I(f,Date.parse(o.expires),!0))}catch(e){fe.signal.aborted||I(h,e instanceof Error?e.message:`Unable to prepare action.`,!0)}finally{I(m,!1)}}async function me(){if(!W(c)?.id||W(m)||a()||W(oe)||!W(le))return;let e=W(c).id,n=W(c).kind,r=W(d);I(d,``),I(m,!0),I(v,e,!0);try{await la(`commit`,{session:t.session,...i()?{review:i()}:{},offer:e,confirmation:r},fe.signal),I(g,!0),I(y,!1),W(T)&&(I(v,``),await ne()),I(h,W(T)?`Trigger set. Closing Codexometer cancels it.`:n===`profile`?`Profile decision completed.`:n===`approval`?`Decision sent.`:`Text sent.`,!0)}catch(e){I(h,e instanceof sa?e.message:`Outcome uncertain. Check Codex before taking another action; nothing was retried.`,!0)}finally{I(m,!1),I(x,``),await ne(),I(l,[],!0),I(u,null)}}var he=oo(),O=R(he),ge=e=>{var t=Fr();Z(R(t),17,()=>W(E).filter(e=>e.status!==`sent`),e=>e.id,(e,t)=>{var n=Za(),r=L(n),i=z(r,!0),o=B(r,2),s=z(o),l=B(o,2),u=z(l),f=B(l,2),g=z(f,!0),_=B(f,2),v=e=>{var t=Ja(),n=z(t,!0);V(()=>J(n,W(h))),q(e,t)};Y(_,e=>{W(h)&&e(v)});var y=B(_,4),b=B(y,2),S=B(b,2),C=e=>{var n=Ya(),r=B(R(n),2),i=B(r,2);V(()=>r.disabled=W(m)||W(ae)||!W(t).canSend),G(`click`,r,me),G(`click`,i,()=>{I(d,``),I(x,``)}),q(e,n)},w=e=>{var n=Xa();V(()=>n.disabled=W(m)||W(ae)||!W(t).canSend||a()),G(`click`,n,()=>pe(W(t))),q(e,n)};Y(S,e=>{W(le)&&W(x)===W(t).id?e(C):e(w,-1)}),j(n),V(e=>{J(i,W(t).status===`uncertain`?`CHECK TRIGGER — outcome uncertain; not retried`:`TRIGGER SET`),J(s,`TARGET // ${W(t).session??``}`),J(u,`${e??``} - // ${W(t).status??``}`),J(g,W(t).text),y.disabled=W(m)||!W(c)?.id||W(c).kind!==`prompt`||!!W(c).questions?.length||W(t).status!==`pending`,b.disabled=W(m)||W(t).status===`sending`},[()=>W(t).trigger===`quota`?`After confirmed quota recovery, when idle`:`Not before ${new Date(W(t).at).toLocaleString([],{timeZoneName:`short`})} // ${Date.parse(W(t).at)>W(p)?`in `+Math.ceil((Date.parse(W(t).at)-W(p))/6e4)+` min`:`due — waiting for quota and an eligible idle session`}`]),G(`click`,y,()=>te(W(t))),G(`click`,b,()=>re(W(t).id)),q(e,n)}),q(e,t)};Y(O,e=>{i()||e(ge)});var _e=B(O,2),ve=e=>{var r=Oo(),a=L(r),o=z(a,!0),s=B(a,2),b=e=>{var t=Qa(),n=R(t),r=z(n),i=B(n,6),a=z(i,!0),o=z(B(i,6),!0);we(2),V(()=>{J(r,`Your ${W(c).profile.threshold??``}% quota threshold has been reached. Review - the profile for subsequent turns.`),J(a,W(c).profile.current),J(o,W(c).profile.proposed)}),q(e,t)};Y(s,e=>{W(c)?.profile&&!W(ae)&&!W(_)&&e(b)});var x=B(s,2),E=e=>{var t=$a();let n;var r=z(t,!0);V(()=>{n=ci(t,1,`svelte-1oupzfc`,null,n,{notice:!W(g),sent:W(g)}),J(r,W(h))}),q(e,t)};Y(x,e=>{W(h)&&e(E)});var D=B(x,2),te=e=>{var t=eo(),n=R(t),r=z(n,!0),i=z(B(n,2),!0);V(()=>{J(r,W(se)?`EXACT COMMAND`:`LAST OBSERVED COMMAND`),J(i,W(ce))}),q(e,t)},ne=e=>{q(e,to())};Y(D,e=>{W(ce)?e(te):i()!==`profile`&&W(ie)===`APPROVAL NEEDED`&&!W(g)&&e(ne,1)});var re=B(D,2),oe=e=>{q(e,no())},fe=e=>{q(e,ro())},he=e=>{var t=oo(),n=R(t),r=e=>{var t=io(),n=z(t,!0);V(e=>J(n,e),[()=>W(ie)===`WORKING`?`Codex is working — nothing to respond to.`:[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(ie)||``)?`Respond in Codex for this request.`:`Nothing needs a response right now.`]),q(e,t)};Y(n,e=>{(W(ie)===`WORKING`||!W(g)&&!W(m))&&e(r)});var i=B(n,2),a=e=>{q(e,ao())},o=N(()=>[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(ie)||``)&&!W(g));Y(i,e=>{W(o)&&e(a)}),q(e,t)},O=e=>{var r=Do(),a=R(r),o=z(a),s=B(a,2),h=L(s),g=z(h,!0),_=B(h,2),v=e=>{var r=Fr();Z(R(r),17,()=>W(c).choices||[],X,(e,r,a)=>{var o=lo(),s=L(o);xi(s),s.value=s.__value=a;var c=B(s),l=B(c),d=e=>{var t=so(),n=z(t,!0);V(()=>J(n,W(r).detail)),q(e,t)};Y(l,e=>{W(r).detail&&e(d)});var f=B(l,2),p=e=>{q(e,co())};Y(f,e=>{W(r).persistent&&e(p)}),j(o),V(()=>{Q(s,`name`,`decision-`+t.session+`-`+i()),J(c,` ${W(r).label??``} `)}),Di(n,[],s,()=>W(u),e=>I(u,e)),q(e,o)}),q(e,r)},b=e=>{var t=oo(),n=R(t),r=e=>{var t=ho(),n=R(t),r=B(L(n)),i=L(r),a=e=>{var t=uo();t.value=t.__value=`now`,q(e,t)};Y(i,e=>{W(y)||e(a)});var o=B(i);o.value=o.__value=`quota`;var s=B(o);s.value=s.__value=`delay`;var c=B(s);c.value=c.__value=`at`,j(r),mi(r),j(n);var l=B(n,2),u=e=>{var t=fo(),n=B(L(t));xi(n),j(t),Ti(n,()=>W(C),e=>I(C,e)),q(e,t)};Y(l,e=>{W(S)===`delay`&&e(u)});var d=B(l,2),f=e=>{var t=po(),n=B(L(t));xi(n),j(t),Ti(n,()=>W(w),e=>I(w,e)),q(e,t)};Y(d,e=>{W(S)===`at`&&e(f)});var p=B(d,2),m=e=>{var t=mo();t.textContent=`Timezone: ${Intl.DateTimeFormat().resolvedOptions().timeZone??``}. + observation table for times, positions and gaps.

          OBSERVATION TABLE
          `,1),Ca=K(`
          CONSUMPTIONQUOTA PERIOD ELAPSED


          `,1);function wa(e,t){let n=Ir();Ge(t,!0);let r=Hi(t,`trail`,19,()=>[]),i=F(!1),a=[0,25,50,75,100],o=F(400),s=F(240),c=N(()=>W(o)-24),l=N(()=>W(s)-48),u=N(()=>Math.max(1,W(c)-48)),d=N(()=>Math.max(1,W(l)-20)),f=N(()=>48+Math.max(0,Math.min(100,t.elapsed))/100*W(u)),p=N(()=>W(l)-Math.max(0,Math.min(100,t.used))/100*W(d)),m=N(()=>t.used-t.elapsed),h=N(()=>r().map((e,t)=>`${t===0||e.break?`M`:`L`}${48+e.elapsed/100*W(u)} ${W(l)-e.used/100*W(d)}`).join(` `));var g=Ca(),_=R(g),v=L(_),y=L(v),b=z(y),x=B(y),S=B(x);Z(S,17,()=>a,X,(e,t)=>{var n=va(),r=R(n),i=B(r),a=B(i),o=z(a),s=B(a),f=z(s);V(()=>{Q(r,`x1`,48+W(t)/100*W(u)),Q(r,`x2`,48+W(t)/100*W(u)),Q(r,`y2`,W(l)),Q(i,`y1`,W(l)-W(t)/100*W(d)),Q(i,`x2`,W(c)),Q(i,`y2`,W(l)-W(t)/100*W(d)),Q(a,`x`,48+W(t)/100*W(u)),Q(a,`y`,W(l)+20),J(o,`${W(t)??``}%`),Q(s,`y`,W(l)+4-W(t)/100*W(d)),J(f,`${W(t)??``}%`)}),q(e,n)});var C=B(S),w=B(C),T=B(w),ee=e=>{var t=ya(),n=R(t),i=B(n),a=z(L(i));j(i),V(e=>{Q(n,`d`,W(h)),Q(i,`cx`,48+r()[0].elapsed/100*W(u)),Q(i,`cy`,W(l)-r()[0].used/100*W(d)),J(a,`First observation: ${e??``}`)},[()=>sa(r()[0].at)]),q(e,t)};Y(T,e=>{r().length&&e(ee)});var E=B(T,2),D=B(E),te=B(D),ne=z(L(te));j(te),j(v),j(_);var re=B(_,2),ie=L(re),ae=z(B(ie,3),!0);j(re);var oe=B(re,2),se=e=>{var t=Sa(),a=R(t),o=L(a);we(2),j(a);var s=B(a,2),c=B(L(s),2),l=e=>{var t=xa(),n=L(t),i=B(L(n),2);Z(i,21,r,X,(e,t,n)=>{var r=ba(),i=L(r),a=L(i),o=z(a,!0);j(i);var s=B(i),c=z(s),l=B(s),u=z(l),d=z(B(l),!0);j(r),V((e,r)=>{Q(a,`datetime`,W(t).at),J(o,e),J(c,`${r??``}%`),J(u,`${W(t).used??``}%`),J(d,n===0?`First observation`:W(t).break?`Gap before this observation`:`Connected to previous observation`)},[()=>sa(W(t).at),()=>W(t).elapsed.toFixed(1)]),q(e,r)}),j(i),j(n),j(t),q(e,t)};Y(c,e=>{W(i)&&e(l)}),j(s),V(e=>{Q(a,`id`,n+`-trail-summary`),J(o,`○ START ${e??``} // ${r().length??``} + ${r().length===1?`OBSERVATION`:`OBSERVATIONS`}`)},[()=>sa(r()[0].at)]),Fi(`open`,`toggle`,s,e=>I(i,e),()=>W(i)),q(e,t)};Y(oe,e=>{r().length&&e(se)}),V((e,i,a,m)=>{Q(v,`viewBox`,`0 0 ${W(o)} ${W(s)}`),Q(v,`aria-describedby`,r().length?n+`-trail-summary`:void 0),Q(v,`aria-label`,e),Q(b,`id`,n),Q(x,`width`,W(u)),Q(x,`height`,W(d)),Q(x,`fill`,`url(#${n})`),Q(C,`d`,`M48 20 V${W(l)} H${W(c)}`),Q(w,`y1`,W(l)),Q(w,`x2`,W(c)),Q(E,`x`,48+W(u)/2),Q(E,`y`,W(s)-5),Q(D,`cx`,W(f)),Q(D,`cy`,W(p)),Q(te,`cx`,W(f)),Q(te,`cy`,W(p)),J(ne,`${t.used??``}% consumed // ${i??``}% of period elapsed`),J(ie,`${t.used??``}% USED // ${a??``}% TIME ELAPSED`),J(ae,m)},[()=>`Consumption zone: ${t.used}% consumed, ${t.elapsed.toFixed(1)}% of quota period elapsed. ${W(m)>0?`Above`:W(m)<0?`Below`:`On`} the steady-consumption line.`,()=>t.elapsed.toFixed(1),()=>t.elapsed.toFixed(1),()=>Math.abs(W(m))<.05?`ON PACE`:W(m)>0?`ABOVE THE LINE — CONSUMING FASTER THAN TIME`:`BELOW THE LINE — WITHIN PACE`]),Mi(_,`clientWidth`,e=>I(o,e)),Mi(_,`clientHeight`,e=>I(s,e)),q(e,g),Ke()}var Ta=K(` `),Ea=K(`

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

          `),Da=K(`

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

          `),Oa=K(`

          `),ka=K(`

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

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

          `),Aa=K(` `,1),ja=Nr(``),Ma=Nr(``),Na=K(`
          `),Pa=K(`

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

          `),Fa=K(`
          ▼
          −100 // OVER BUDGET+100 // HEADROOM

          `,1),Ia=K(`

          Cycle duration unavailable — pace cannot be calculated.

          `),La=K(`
          EMPTYFULL
          `),Ra=K(`

          `,1),za=K(`
          `,1),Ba=K(`

          `),Va=K(`

          `),Ha=K(`

          No quota windows reported yet.

          `),Ua=K(`
          `,1),Wa=K(`

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

          `,1),Ga=K(` `,1);function Ka(e,t){Ge(t,!0);let n=Hi(t,`params`,19,()=>({})),r=N(()=>Xi.filter(e=>e!==`thresholds`||!!$.data?.thresholds?.length)),i=F(Zt(Date.now())),a=N(()=>W(r).includes(n().view||``)?n().view:`bars`);Ui(()=>{let e=setInterval(()=>I(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-W(i))/(e.duration*6e4))))}bn(()=>{ea.view=W(a)});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=Ga(),l=R(c);Z(l,21,()=>W(r),X,(e,t)=>{var n=Ta();let r;var i=z(n,!0);V(e=>{Q(n,`href`,`#/quota/`+W(t)),Q(n,`aria-current`,W(a)===W(t)?`page`:void 0),r=ci(n,1,``,null,r,{active:W(a)===W(t)}),J(i,e)},[()=>W(t)===`pace`?`CONSUMPTION PACE`:W(t)===`zone`?`CONSUMPTION ZONE`:W(t)===`fuel`?`FUEL TANK`:W(t).toUpperCase()]),q(e,n)}),j(l);var u=B(l,2),d=e=>{var t=Wa(),n=R(t),r=e=>{q(e,Ea())};Y(n,e=>{$.data.quotaError&&e(r)});var i=B(n,2),c=z(i),l=B(i,2),u=e=>{_a(e,{})},d=e=>{var t=ka(),n=L(t),r=z(n),i=B(n,4),a=e=>{q(e,Da())};Y(i,e=>{$.data.credits.length||e(a)}),Z(B(i,2),17,()=>$.data.credits,X,(e,t)=>{var n=Oa(),r=L(n),i=z(r),a=z(B(r,2),!0);j(n),V(e=>{J(i,`${(W(t).title||`Quota reset`)??``} // ${W(t).status??``}`),J(a,e)},[()=>W(t).expiryKnown?W(t).expires?`EXPIRES `+sa(W(t).expires):`Does not expire`:`Expiry information unavailable`]),q(e,n)}),we(2),j(t),V(()=>J(r,`RESET INVENTORY // ${$.data.creditCount??``} AVAILABLE`)),q(e,t)},f=e=>{var t=Ua(),n=R(t);let r;Z(n,21,()=>$.data.meters,X,(e,t)=>{let n=N(()=>o(W(t))),r=N(()=>W(n)===null?null:W(n)-W(t).used);var i=Va(),c=L(i),l=z(c,!0),u=B(c,2),d=L(u),f=e=>{var n=Aa(),r=R(n),i=z(r),a=z(B(r));V(()=>{J(i,`FREE ${100-W(t).used}%`),J(a,`USED ${W(t).used??``}%`)}),q(e,n)},p=e=>{var n=Aa(),r=R(n),i=z(r),a=z(B(r));V(()=>{J(i,`USED ${W(t).used??``}%`),J(a,`FREE ${100-W(t).used}%`)}),q(e,n)};Y(d,e=>{W(a)===`fuel`?e(f):e(p,-1)}),j(u);var m=B(u,2);let h;var g=L(m),_=e=>{var n=Na(),r=L(n),i=B(L(r)),a=e=>{q(e,ja())},o=e=>{var n=Ma();V(e=>Q(n,`d`,e),[()=>s(W(t).used)]),q(e,n)};Y(i,e=>{W(t).used>=100?e(a):W(t).used>0&&e(o,1)}),j(r),j(n),V(()=>Q(r,`aria-label`,`${W(t).used}% quota used`)),q(e,n)},v=e=>{var r=Fr(),i=R(r),a=e=>{{let r=N(()=>W(t).trail||[]);wa(e,{get used(){return W(t).used},get elapsed(){return W(n)},get trail(){return W(r)}})}},o=e=>{q(e,Pa())};Y(i,e=>{W(n)===null?e(o,-1):e(a)}),q(e,r)},y=e=>{var t=Fr(),n=R(t),i=e=>{var t=Fa(),n=R(t),i=B(L(n),2);let a;j(n);var o=B(n,4),s=L(o),c=z(B(s),!0);j(o),V(e=>{a=ui(i,``,a,{left:`${(W(r)+100)/2}%`}),J(s,`${W(r)>=0?`+`:``}${e??``} PP `),J(c,W(r)>=0?`WITHIN PACE`:`USING FASTER THAN TIME`)},[()=>W(r).toFixed(1)]),q(e,t)},a=e=>{q(e,Ia())};Y(n,e=>{W(r)===null?e(a,-1):e(i)}),q(e,t)},b=e=>{var r=za(),i=R(r),o=L(i);let s;j(i);var c=B(i,2),l=e=>{q(e,La())};Y(c,e=>{W(a)===`fuel`&&e(l)});var u=B(c,2),d=e=>{var t=Ra(),r=R(t),i=z(r),o=B(r,2),s=L(o);let c;j(o),V(e=>{J(i,`RESET CYCLE // ${e??``}% ELAPSED`),c=ui(s,``,c,{width:`${W(a)===`fuel`?100-W(n):W(n)}%`})},[()=>Math.floor(W(n))]),q(e,t)};Y(u,e=>{W(n)!==null&&e(d)}),V(()=>{Q(i,`aria-label`,W(a)===`fuel`?`Fuel remaining`:`Quota used`),Q(i,`aria-valuenow`,W(a)===`fuel`?100-W(t).used:W(t).used),s=ui(o,``,s,{width:`${W(a)===`fuel`?100-W(t).used:W(t).used}%`})}),q(e,r)};Y(g,e=>{W(a)===`pie`?e(_):W(a)===`zone`?e(v,1):W(a)===`pace`?e(y,2):e(b,-1)}),j(m);var x=B(m,2),S=z(x),C=B(x,2),w=e=>{var n=Ba(),r=z(n,!0);V(()=>J(r,W(t).details)),q(e,n)};Y(C,e=>{W(t).details&&e(w)}),j(i),V(e=>{J(l,W(t).name),h=ci(m,1,`meter-graphic`,null,h,{"bar-graphic":W(a)===`bars`||W(a)===`fuel`}),J(S,`RESETS // ${e??``}`)},[()=>sa(W(t).reset)]),q(e,i)}),j(n);var i=B(n,2),c=e=>{q(e,Ha())};Y(i,e=>{$.data.meters.length||e(c)}),V(()=>r=ci(n,1,`quota-grid`,null,r,{radial:W(a)===`pie`,zone:W(a)===`zone`})),q(e,t)};Y(l,e=>{W(a)===`thresholds`?e(u):W(a)===`resets`?e(d,1):e(f,-1)}),we(2),V(e=>J(c,`QUOTA // OBSERVED ${e??``}`),[()=>sa($.data.quotaAt)]),q(e,t)};Y(u,e=>{$.data&&e(d)}),q(e,c),Ke()}var qa=K(`
          `),Ja=K(`

          `,1);function Ya(e,t){Ge(t,!0);let n=Hi(t,`values`,19,()=>[]),r=Hi(t,`label`,3,`Token activity`),i=Hi(t,`capacity`,3,0),a=N(()=>Math.max(0,...n())),o=N(()=>i()>n().length?[...Array(i()-n().length).fill(0),...n()]:n());var s=Ja(),c=R(s),l=z(c),u=B(c,2);Z(u,21,()=>W(o),X,(e,t)=>{var n=qa();let r;V((e,t)=>{Q(n,`title`,e),r=ui(n,``,r,{height:t})},[()=>W(t).toLocaleString(`en-GB`)+` tokens`,()=>`${100*W(t)/Math.max(1,W(a))}%`]),q(e,n)}),j(u),V((e,t)=>{J(l,`SCALE // 0 — ${e??``} TOKENS`),Q(u,`aria-label`,t)},[()=>W(a).toLocaleString(`en-GB`),()=>`${r()}. Peak ${W(a).toLocaleString(`en-GB`)} tokens.`]),q(e,s),Ke()}var Xa=K(`

          `),Za=K(`

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

          `,1),Qa=K(``),$a=K(`

           

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

          `),eo=K(`

          CURRENT PROFILE

          MODEL / REASONING LEVEL / SPEED

           

          PROPOSED PROFILE

          MODEL / REASONING LEVEL / SPEED

           

          Applied settings remain after Codexometer closes.

          `,1),to=K(`

          `),no=K(`

           
          `,1),ro=K(`

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

          `),io=K(`

          Session controls temporarily unavailable. Check Codex for current state.

          `),ao=K(`

          Checking session controls…

          `),oo=K(`

          `),so=K(`
          About browser controls

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

          `),co=K(` `,1),lo=K(` `),uo=K(`Grants permission beyond this one command. Check the scope + carefully.`),fo=K(``),po=K(``),mo=K(``),ho=K(``),go=K(`

          `),_o=K(` `,1),vo=K(``),yo=K(``),bo=K(``),xo=K(` `,1),So=K(`
        • `),Co=K(`
          View fixed choices

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

            `),wo=K(` `,1),To=K(`

            `),Eo=K(`

            `,1),Do=K(``),Oo=K(``),ko=K(`

            `,1),Ao=K(`

            `);function jo(e,t){Ge(t,!0);let n=[],r=Hi(t,`observedCommand`,3,``),i=Hi(t,`review`,3,``),a=Hi(t,`suspended`,3,!1),o=Hi(t,`openScheduler`,3,!1),s=Hi(t,`onProtectedChange`,3,e=>{}),c=F(null),l=F(Zt([])),u=F(null),d=F(``),f=F(0),p=F(Zt(Date.now())),m=F(!1),h=F(``),g=F(!1),_=F(!1),v=F(``),y=F(!1),b=F(!1),x=F(``),S=F(`now`),C=F(60),w=F(``),T=F(!1),ee=F(``),E=F(Zt([])),D=N(()=>W(E).find(e=>e.status!==`sent`)),te=F(void 0);function ne(e){if(W(y)){dr().then(()=>W(te)?.focus());return}if(e.status!==`pending`||W(m)||!W(c)?.id||W(c).kind!==`prompt`||W(c).questions?.length)return;I(y,!0),dr().then(()=>W(te)?.focus()),I(l,[e.text],!0),I(S,e.trigger===`quota`?`quota`:`at`,!0),I(d,``),I(x,``);let t=new Date(e.at);e.trigger!==`quota`&&I(w,new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,16),!0)}bn(()=>{o()&&W(D)&&!W(b)&&W(c)?.id&&W(c).kind===`prompt`&&!W(c).questions?.length&&(I(b,!0),ne(W(D)))});async function re(){if(!i())try{I(E,await da(`schedules`,{session:t.session},pe.signal),!0),W(x)&&!W(E).some(e=>e.id===W(x)&&e.status===`pending`)&&(I(d,``),I(x,``))}catch{}}async function ie(e){try{I(E,await da(`schedules`,{session:t.session,cancelId:e},pe.signal),!0),I(y,!1),I(d,``),I(x,``),I(l,[],!0)}catch(e){I(h,e instanceof Error?e.message:`Unable to cancel trigger.`,!0)}}bn(()=>(s()(W(m)||W(l).some(e=>e.length>0)),()=>s()(!1)));let ae=N(()=>$.data?.sessions.find(e=>e.id===t.session)?.status),oe=N(()=>!$.connected||!!$.data?.sessionsError),se=N(()=>i()!==`profile`&&W(c)?.kind===`prompt`&&!W(c).questions?.length&&!!$.data?.profiles?.some(e=>e.session===t.session&&e.pending)),ce=N(()=>!W(oe)&&!W(_)&&!!W(c)?.id&&W(c).kind===`approval`&&W(v)!==W(c).id),le=N(()=>W(ce)?W(c).command:r()),ue=N(()=>!!W(d)&&W(p)W(c)?.questions?.length?W(c).questions:[{text:`Follow-up message`,secret:!1,freeText:!0,options:[]}]),fe=N(()=>W(c)?.kind===`approval`||W(c)?.kind===`profile`?W(u)!==null:W(l).length===W(de).length&&W(l).every((e,t)=>e.trim().length>0&&(W(de)[t].freeText||W(de)[t].options?.includes(e))));bn(()=>{(W(oe)||a()||W(se)||W(p)>=W(f))&&I(d,``)});let pe=new AbortController;Ui(()=>{let e=e=>{e.ctrlKey&&e.key.toLowerCase()===`s`&&!i()&&W(D)&&(e.preventDefault(),ne(W(D)))},n=e=>{e.detail===t.session&&!i()&&W(D)&&ne(W(D))};window.addEventListener(`keydown`,e),window.addEventListener(`edit-trigger`,n);let r,a=setInterval(()=>{I(p,Date.now(),!0)},1e3);async function o(){await re();try{let e=await da(`offer`,{session:t.session,...i()?{review:i()}:{}},pe.signal);if(pe.signal.aborted)return;I(_,!1),W(c)?.id!==e.id&&(I(d,``),I(u,null),I(l,Array(Math.max(1,e.questions?.length||0)).fill(``),!0)),I(c,e,!0),W(g)&&e.id&&e.id!==W(v)&&(I(h,``),I(g,!1))}catch{pe.signal.aborted||(I(c,null),I(_,!0),I(d,``))}finally{pe.signal.aborted||(r=setTimeout(o,2e3))}}return o(),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`edit-trigger`,n),pe.abort(),clearTimeout(r),clearInterval(a)}});async function me(e){if(!W(c)?.id||W(m)||W(oe)||a()||W(se)||(e?!e.canSend:!W(fe)))return;let n=W(c).id;I(m,!0),I(h,``),I(g,!1),I(d,``),I(x,e?.id||``,!0);try{let r=!e&&W(c).kind===`prompt`&&!W(c).questions?.length&&W(S)!==`now`?{trigger:W(S)===`quota`?`quota`:`at`,zone:Intl.DateTimeFormat().resolvedOptions().timeZone,...W(S)===`quota`?{}:{at:(W(S)===`delay`?new Date(Date.now()+W(C)*6e4):new Date(W(w))).toISOString()}}:void 0;I(T,!!r),I(ee,r?r.trigger===`quota`?`After fresh quota becomes available, when the session is idle`:new Date(r.at).toLocaleString()+` — when idle`:``,!0);let o=await da(`prepare`,{session:t.session,...i()?{review:i()}:{},offer:n,...e?{sendId:e.id}:{},...r?{schedule:r}:{},...W(c).kind===`approval`||W(c).kind===`profile`?{choice:W(u)}:{answers:e?[e.text]:[...W(l)]}},pe.signal);W(c)?.id===n&&!pe.signal.aborted&&!W(oe)&&!a()&&!W(se)&&(I(d,o.confirmation,!0),I(f,Date.parse(o.expires),!0))}catch(e){pe.signal.aborted||I(h,e instanceof Error?e.message:`Unable to prepare action.`,!0)}finally{I(m,!1)}}async function he(){if(!W(c)?.id||W(m)||a()||W(se)||!W(ue))return;let e=W(c).id,n=W(c).kind,r=W(d);I(d,``),I(m,!0),I(v,e,!0);try{await da(`commit`,{session:t.session,...i()?{review:i()}:{},offer:e,confirmation:r},pe.signal),I(g,!0),I(y,!1),W(T)&&(I(v,``),await re()),I(h,W(T)?`Trigger set. Closing Codexometer cancels it.`:n===`profile`?`Profile decision completed.`:n===`approval`?`Decision sent.`:`Text sent.`,!0)}catch(e){I(h,e instanceof la?e.message:`Outcome uncertain. Check Codex before taking another action; nothing was retried.`,!0)}finally{I(m,!1),I(x,``),await re(),I(l,[],!0),I(u,null)}}var O=co(),ge=R(O),_e=e=>{var t=Fr();Z(R(t),17,()=>W(E).filter(e=>e.status!==`sent`),e=>e.id,(e,t)=>{var n=$a(),r=L(n),i=z(r,!0),o=B(r,2),s=z(o),l=B(o,2),u=z(l),f=B(l,2),g=z(f,!0),_=B(f,2),v=e=>{var t=Xa(),n=z(t,!0);V(()=>J(n,W(h))),q(e,t)};Y(_,e=>{W(h)&&e(v)});var y=B(_,4),b=B(y,2),S=B(b,2),C=e=>{var n=Za(),r=B(R(n),2),i=B(r,2);V(()=>r.disabled=W(m)||W(oe)||!W(t).canSend),G(`click`,r,he),G(`click`,i,()=>{I(d,``),I(x,``)}),q(e,n)},w=e=>{var n=Qa();V(()=>n.disabled=W(m)||W(oe)||!W(t).canSend||a()),G(`click`,n,()=>me(W(t))),q(e,n)};Y(S,e=>{W(ue)&&W(x)===W(t).id?e(C):e(w,-1)}),j(n),V(e=>{J(i,W(t).status===`uncertain`?`CHECK TRIGGER — outcome uncertain; not retried`:`TRIGGER SET`),J(s,`TARGET // ${W(t).session??``}`),J(u,`${e??``} + // ${W(t).status??``}`),J(g,W(t).text),y.disabled=W(m)||!W(c)?.id||W(c).kind!==`prompt`||!!W(c).questions?.length||W(t).status!==`pending`,b.disabled=W(m)||W(t).status===`sending`},[()=>W(t).trigger===`quota`?`After confirmed quota recovery, when idle`:`Not before ${new Date(W(t).at).toLocaleString([],{timeZoneName:`short`})} // ${Date.parse(W(t).at)>W(p)?`in `+Math.ceil((Date.parse(W(t).at)-W(p))/6e4)+` min`:`due — waiting for quota and an eligible idle session`}`]),G(`click`,y,()=>ne(W(t))),G(`click`,b,()=>ie(W(t).id)),q(e,n)}),q(e,t)};Y(ge,e=>{i()||e(_e)});var ve=B(ge,2),ye=e=>{var r=Ao(),a=L(r),o=z(a,!0),s=B(a,2),b=e=>{var t=eo(),n=R(t),r=z(n),i=B(n,6),a=z(i,!0),o=z(B(i,6),!0);we(2),V(()=>{J(r,`Your ${W(c).profile.threshold??``}% quota threshold has been reached. Review + the profile for subsequent turns.`),J(a,W(c).profile.current),J(o,W(c).profile.proposed)}),q(e,t)};Y(s,e=>{W(c)?.profile&&!W(oe)&&!W(_)&&e(b)});var x=B(s,2),E=e=>{var t=to();let n;var r=z(t,!0);V(()=>{n=ci(t,1,`svelte-1oupzfc`,null,n,{notice:!W(g),sent:W(g)}),J(r,W(h))}),q(e,t)};Y(x,e=>{W(h)&&e(E)});var D=B(x,2),ne=e=>{var t=no(),n=R(t),r=z(n,!0),i=z(B(n,2),!0);V(()=>{J(r,W(ce)?`EXACT COMMAND`:`LAST OBSERVED COMMAND`),J(i,W(le))}),q(e,t)},re=e=>{q(e,ro())};Y(D,e=>{W(le)?e(ne):i()!==`profile`&&W(ae)===`APPROVAL NEEDED`&&!W(g)&&e(re,1)});var ie=B(D,2),se=e=>{q(e,io())},pe=e=>{q(e,ao())},O=e=>{var t=co(),n=R(t),r=e=>{var t=oo(),n=z(t,!0);V(e=>J(n,e),[()=>W(ae)===`WORKING`?`Codex is working — nothing to respond to.`:[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(ae)||``)?`Respond in Codex for this request.`:`Nothing needs a response right now.`]),q(e,t)};Y(n,e=>{(W(ae)===`WORKING`||!W(g)&&!W(m))&&e(r)});var i=B(n,2),a=e=>{q(e,so())},o=N(()=>[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(ae)||``)&&!W(g));Y(i,e=>{W(o)&&e(a)}),q(e,t)},ge=e=>{var r=ko(),a=R(r),o=z(a),s=B(a,2),h=L(s),g=z(h,!0),_=B(h,2),v=e=>{var r=Fr();Z(R(r),17,()=>W(c).choices||[],X,(e,r,a)=>{var o=fo(),s=L(o);xi(s),s.value=s.__value=a;var c=B(s),l=B(c),d=e=>{var t=lo(),n=z(t,!0);V(()=>J(n,W(r).detail)),q(e,t)};Y(l,e=>{W(r).detail&&e(d)});var f=B(l,2),p=e=>{q(e,uo())};Y(f,e=>{W(r).persistent&&e(p)}),j(o),V(()=>{Q(s,`name`,`decision-`+t.session+`-`+i()),J(c,` ${W(r).label??``} `)}),Di(n,[],s,()=>W(u),e=>I(u,e)),q(e,o)}),q(e,r)},b=e=>{var t=co(),n=R(t),r=e=>{var t=_o(),n=R(t),r=B(L(n)),i=L(r),a=e=>{var t=po();t.value=t.__value=`now`,q(e,t)};Y(i,e=>{W(y)||e(a)});var o=B(i);o.value=o.__value=`quota`;var s=B(o);s.value=s.__value=`delay`;var c=B(s);c.value=c.__value=`at`,j(r),mi(r),j(n);var l=B(n,2),u=e=>{var t=mo(),n=B(L(t));xi(n),j(t),Ti(n,()=>W(C),e=>I(C,e)),q(e,t)};Y(l,e=>{W(S)===`delay`&&e(u)});var d=B(l,2),f=e=>{var t=ho(),n=B(L(t));xi(n),j(t),Ti(n,()=>W(w),e=>I(w,e)),q(e,t)};Y(d,e=>{W(S)===`at`&&e(f)});var p=B(d,2),m=e=>{var t=go();t.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.`,q(e,t)};Y(p,e=>{W(S)!==`now`&&e(m)}),hi(r,()=>W(S),e=>I(S,e)),q(e,t)};Y(n,e=>{W(c).questions?.length||e(r)}),Z(B(n,2),17,()=>W(ue),X,(e,t,n)=>{var r=So(),i=R(r),a=L(i),o=B(a),s=e=>{var t=go();xi(t),Ti(t,()=>W(l)[n],e=>W(l)[n]=e),q(e,t)},c=e=>{var r=vo(),i=L(r);i.value=i.__value=``,Z(B(i),17,()=>W(t).options||[],X,(e,t)=>{var n=_o(),r=z(n,!0),i={};V(()=>{J(r,W(t)),i!==(i=W(t))&&(n.value=(n.__value=i)??``)}),q(e,n)}),j(r),mi(r),hi(r,()=>W(l)[n],e=>W(l)[n]=e),q(e,r)},u=e=>{var r=yo(),i=R(r);rt(i);var a=B(i,2),o=e=>{var n=io(),r=z(n);V(e=>J(r,`Suggested answers: ${e??``}`),[()=>W(t).options.join(` · `)]),q(e,n)};Y(a,e=>{W(t).options?.length&&e(o)}),Ti(i,()=>W(l)[n],e=>W(l)[n]=e),q(e,r)};Y(o,e=>{W(t).secret?e(s):W(t).freeText?e(u,-1):e(c,1)}),j(i);var d=B(i,2),f=e=>{var n=xo(),r=B(L(n),4);Z(r,21,()=>W(t).options||[],X,(e,t)=>{var n=bo(),r=z(n,!0);V(()=>J(r,W(t))),q(e,n)}),j(r),j(n),q(e,n)};Y(d,e=>{W(t).secret&&!W(t).freeText&&e(f)}),V(()=>J(a,`${W(t).text??``} `)),q(e,r)}),q(e,t)};Y(_,e=>{W(c).kind===`approval`||W(c).kind===`profile`?e(v):e(b,-1)}),j(s);var x=B(s,2),E=e=>{var t=wo(),n=R(t),r=e=>{var t=Co(),n=z(t);V(()=>J(n,`TRIGGER // ${W(ee)??``}`)),q(e,t)};Y(n,e=>{W(T)&&e(r)});var i=B(n,2),a=z(i),o=B(i,2),s=z(o),l=B(o,2);V(e=>{J(a,`Check the target and ${W(c).kind===`profile`?`profile above`:W(c).kind===`approval`?`exact command and permission scope`:`message above`}. ${W(T)?`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=W(m)||W(ae),J(s,`CONFIRM ${(W(c).kind===`approval`||W(c).kind===`profile`?W(c).choices?.[W(u)]?.label:W(T)?`SCHEDULE`:`SEND`)??``}`)},[()=>Math.max(0,Math.ceil((W(f)-W(p))/1e3))]),G(`click`,o,me),G(`click`,l,()=>{I(d,``)}),q(e,t)},D=e=>{var t=To(),n=z(t,!0);V(()=>{t.disabled=W(m)||W(ae)||!W(de),J(n,W(m)?`SENDING…`:`REVIEW BEFORE SENDING`)}),G(`click`,t,()=>pe()),q(e,t)};Y(x,e=>{W(le)?e(E):e(D,-1)});var te=B(x,2),ne=e=>{var t=Eo();G(`click`,t,()=>{I(y,!1),I(d,``),I(l,[],!0)}),q(e,t)};Y(te,e=>{W(y)&&e(ne)}),V(()=>{J(o,`TARGET // ${W(c).thread??``} // ${(W(c).directory||`Directory unavailable`)??``}`),s.disabled=W(m)||W(le)||W(ae),J(g,W(c).kind===`approval`||W(c).kind===`profile`?`Choose a decision`:`Reply to this session`)}),q(e,r)};Y(re,e=>{W(ae)||W(_)?e(oe):W(c)?W(c).id?W(v)!==W(c).id&&e(O,3):e(he,2):e(fe,1)}),j(r),V(()=>J(o,i()===`profile`?`QUOTA THRESHOLD`:`SESSION CONTROL // EXPERIMENTAL`)),q(e,r)};Y(_e,e=>{!W(oe)&&(!W(D)||W(y)||i()||W(c)?.kind!==`prompt`||W(c).questions?.length)&&e(ve)}),q(e,he),Ke()}wr([`click`]);var Ao=K(`
            `);function jo(e,t){Ge(t,!0);let n=Bi(t,`active`,3,!1),r=N(()=>t.session.text||t.session.contextKind===`LAST ACTIVITY`&&t.session.workingCommand||``),i=N(()=>[`LAST REPLY`,`LAST ACTIVITY`].includes(t.session.contextKind)&&!!W(r).trim()),a=F(!1),o=F(``),s=F(!1);bn(()=>{if(!W(s))return;let e=setTimeout(()=>{I(s,!1)},150);return()=>clearTimeout(e)}),bn(()=>{W(r),t.session.status,I(o,``)});async function c(){if(!W(i)||W(a))return;let e=W(r);I(a,!0),I(s,!0),I(o,``);try{await navigator.clipboard.writeText(e),W(r)===e&&I(o,`Copied.`)}catch{W(r)===e&&I(o,`Clipboard unavailable. Select the visible text and copy it manually.`)}finally{I(a,!1)}}function l(e){!n()||!W(i)||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(),c())}var u=Fr();Cr(`keydown`,en,l);var d=R(u),f=e=>{var t=Ao(),n=L(t),r=z(n,!0),i=B(n,2);let l;j(t),V(()=>{J(r,W(o)),i.disabled=W(a),l=ci(i,1,`svelte-543j00`,null,l,{flashed:W(s)})}),G(`click`,i,c),q(e,t)};Y(d,e=>{W(i)&&e(f)}),q(e,u),Ke()}wr([`click`]);var Mo=K(`

            CONTEXT

             

            `,1),No=K(`

            `),Po=K(`

            `),Fo=K(`
             
            `),Io=K(`

             
            `,1),Lo=K(`
             
            `),Ro=K(`

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

            `),zo=K(`

            `,1),Bo=K(`

            `),Vo=K(` `,1),Ho=K(`
            `),Uo=K(`

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

            `),Wo=K(`

            Some quota profile checks are unavailable. Only sessions with freshly + reasoning and speed.`,q(e,t)};Y(p,e=>{W(S)!==`now`&&e(m)}),hi(r,()=>W(S),e=>I(S,e)),q(e,t)};Y(n,e=>{W(c).questions?.length||e(r)}),Z(B(n,2),17,()=>W(de),X,(e,t,n)=>{var r=wo(),i=R(r),a=L(i),o=B(a),s=e=>{var t=vo();xi(t),Ti(t,()=>W(l)[n],e=>W(l)[n]=e),q(e,t)},c=e=>{var r=bo(),i=L(r);i.value=i.__value=``,Z(B(i),17,()=>W(t).options||[],X,(e,t)=>{var n=yo(),r=z(n,!0),i={};V(()=>{J(r,W(t)),i!==(i=W(t))&&(n.value=(n.__value=i)??``)}),q(e,n)}),j(r),mi(r),hi(r,()=>W(l)[n],e=>W(l)[n]=e),q(e,r)},u=e=>{var r=xo(),i=R(r);rt(i),Pi(i,e=>I(te,e),()=>W(te));var a=B(i,2),o=e=>{var n=oo(),r=z(n);V(e=>J(r,`Suggested answers: ${e??``}`),[()=>W(t).options.join(` · `)]),q(e,n)};Y(a,e=>{W(t).options?.length&&e(o)}),Ti(i,()=>W(l)[n],e=>W(l)[n]=e),q(e,r)};Y(o,e=>{W(t).secret?e(s):W(t).freeText?e(u,-1):e(c,1)}),j(i);var d=B(i,2),f=e=>{var n=Co(),r=B(L(n),4);Z(r,21,()=>W(t).options||[],X,(e,t)=>{var n=So(),r=z(n,!0);V(()=>J(r,W(t))),q(e,n)}),j(r),j(n),q(e,n)};Y(d,e=>{W(t).secret&&!W(t).freeText&&e(f)}),V(()=>J(a,`${W(t).text??``} `)),q(e,r)}),q(e,t)};Y(_,e=>{W(c).kind===`approval`||W(c).kind===`profile`?e(v):e(b,-1)}),j(s);var x=B(s,2),E=e=>{var t=Eo(),n=R(t),r=e=>{var t=To(),n=z(t);V(()=>J(n,`TRIGGER // ${W(ee)??``}`)),q(e,t)};Y(n,e=>{W(T)&&e(r)});var i=B(n,2),a=z(i),o=B(i,2),s=z(o),l=B(o,2);V(e=>{J(a,`Check the target and ${W(c).kind===`profile`?`profile above`:W(c).kind===`approval`?`exact command and permission scope`:`message above`}. ${W(T)?`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=W(m)||W(oe),J(s,`CONFIRM ${(W(c).kind===`approval`||W(c).kind===`profile`?W(c).choices?.[W(u)]?.label:W(T)?`SCHEDULE`:`SEND`)??``}`)},[()=>Math.max(0,Math.ceil((W(f)-W(p))/1e3))]),G(`click`,o,he),G(`click`,l,()=>{I(d,``)}),q(e,t)},D=e=>{var t=Do(),n=z(t,!0);V(()=>{t.disabled=W(m)||W(oe)||!W(fe),J(n,W(m)?`SENDING…`:`REVIEW BEFORE SENDING`)}),G(`click`,t,()=>me()),q(e,t)};Y(x,e=>{W(ue)?e(E):e(D,-1)});var ne=B(x,2),re=e=>{var t=Oo();G(`click`,t,()=>{I(y,!1),I(d,``),I(l,[],!0)}),q(e,t)};Y(ne,e=>{W(y)&&e(re)}),V(()=>{J(o,`TARGET // ${W(c).thread??``} // ${(W(c).directory||`Directory unavailable`)??``}`),s.disabled=W(m)||W(ue)||W(oe),J(g,W(c).kind===`approval`||W(c).kind===`profile`?`Choose a decision`:`Reply to this session`)}),q(e,r)};Y(ie,e=>{W(oe)||W(_)?e(se):W(c)?W(c).id?W(v)!==W(c).id&&e(ge,3):e(O,2):e(pe,1)}),j(r),V(()=>J(o,i()===`profile`?`QUOTA THRESHOLD`:`SESSION CONTROL // EXPERIMENTAL`)),q(e,r)};Y(ve,e=>{!W(se)&&(!W(D)||W(y)||i()||W(c)?.kind!==`prompt`||W(c).questions?.length)&&e(ye)}),q(e,O),Ke()}wr([`click`]);var Mo=K(`

            `);function No(e,t){Ge(t,!0);let n=Hi(t,`active`,3,!1),r=N(()=>t.session.text||t.session.contextKind===`LAST ACTIVITY`&&t.session.workingCommand||``),i=N(()=>[`LAST REPLY`,`LAST ACTIVITY`].includes(t.session.contextKind)&&!!W(r).trim()),a=F(!1),o=F(``),s=F(!1);bn(()=>{if(!W(s))return;let e=setTimeout(()=>{I(s,!1)},150);return()=>clearTimeout(e)}),bn(()=>{W(r),t.session.status,I(o,``)});async function c(){if(!W(i)||W(a))return;let e=W(r);I(a,!0),I(s,!0),I(o,``);try{await navigator.clipboard.writeText(e),W(r)===e&&I(o,`Copied.`)}catch{W(r)===e&&I(o,`Clipboard unavailable. Select the visible text and copy it manually.`)}finally{I(a,!1)}}function l(e){!n()||!W(i)||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(),c())}var u=Fr();Cr(`keydown`,en,l);var d=R(u),f=e=>{var t=Mo(),n=L(t),r=z(n,!0),i=B(n,2);let l;j(t),V(()=>{J(r,W(o)),i.disabled=W(a),l=ci(i,1,`svelte-543j00`,null,l,{flashed:W(s)})}),G(`click`,i,c),q(e,t)};Y(d,e=>{W(i)&&e(f)}),q(e,u),Ke()}wr([`click`]);var Po=K(`

            CONTEXT

             

            `,1),Fo=K(`

            `),Io=K(`

            `),Lo=K(`
             
            `),Ro=K(`

             
            `,1),zo=K(`
             
            `),Bo=K(`

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

            `),Vo=K(`

            `,1),Ho=K(`

            `),Uo=K(` `,1),Wo=K(`
            `),Go=K(`

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

            `),Ko=K(`

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

            `),Go=K(` `),Ko=K(` `),qo=K(` `),Jo=K(``),Yo=K(`

            Read only — reply or approve in Codex.

            `),Xo=K(`

            `),Zo=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),Qo=K(`
            `),$o=K(`
            `),es=K(`

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

            `),ts=K(`

            `),ns=K(``),rs=K(`TRIGGER SET`),is=K(`

            `),as=K(` `),os=K(`

            `),ss=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),cs=K(` `,1),ls=K(`

            `),us=K(`

            TOKEN ACTIVITY // 30 SECOND SAMPLES

            `),ds=K(`

            TOKENS

            FULL DETAIL →
            `),fs=K(`

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

            `),ps=K(`

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

            `,1),ms=K(`

            SESSION TOTALS

            `,1);function hs(e,t){Ge(t,!0);let n=(e,t=f,n,r)=>{let i=ht(()=>g(n?.(),!0)),a=ht(()=>g(r?.(),!1));var o=Vo(),s=R(o),c=e=>{var n=Mo(),r=z(B(R(n),2),!0);we(2),V(()=>J(r,t().approvalContext)),q(e,n)};Y(s,e=>{W(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(c)});var l=B(s,2),u=e=>{var n=No();let r;var i=z(n,!0);V(e=>{r=ci(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),J(i,e)},[()=>S(t())]),q(e,n)},d=N(()=>S(t())&&(!W(a)||W(m)||t().status===`CHECK SESSION`));Y(l,e=>{W(d)&&e(u)});var p=B(l,2),h=e=>{var n=Po(),r=z(n,!0);V(()=>J(r,t().contextKind||`LAST ACTIVITY`)),q(e,n)};Y(p,e=>{W(i)&&e(h)});var _=B(p,2),v=e=>{var n=Fo(),r=z(n,!0);V(()=>J(r,t().text||`No session context available.`)),q(e,n)};Y(_,e=>{(t().text||!t().workingCommand)&&e(v)});var y=B(_,2),b=e=>{var n=Io(),r=B(R(n),2),i=L(r),a=B(i),o=e=>{var n=Pr();V(()=>J(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),q(e,n)};Y(a,e=>{!W(m)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(o)});var s=B(a,2),c=e=>{q(e,Pr(`+`))};Y(s,e=>{t().runningLimited&&e(c)}),j(r);var l=z(B(r,2),!0);V(e=>{J(i,`COMMAND // ${e??``} `),J(l,t().workingCommand)},[()=>W(m)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),q(e,n)};Y(y,e=>{t().workingCommand&&e(b)});var x=B(y,2),C=e=>{var n=zo(),r=B(R(n),2),i=z(r,!0),a=B(r,2),o=e=>{var n=Lo(),r=z(n,!0);V(()=>J(r,t().command)),q(e,n)},s=e=>{q(e,Ro())};Y(a,e=>{t().command?e(o):e(s,-1)}),V(()=>J(i,W(m)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),q(e,n)};Y(x,e=>{(!W(a)||!$.data?.control)&&(t().command||t().status===`APPROVAL NEEDED`)&&e(C)});var w=B(x,2),T=e=>{var n=Bo(),r=z(n);V(()=>J(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),q(e,n)};Y(w,e=>{W(a)||e(T)}),q(e,o)},r=Bi(t,`params`,19,()=>({})),i=N(()=>$.data?.sessions||[]),a=N(()=>$.data?.control&&$.data.profiles||[]),o=N(()=>($.data?.triggers||[]).filter(e=>W(i).some(t=>t.id===e.session)));function s(e,t){if(r().id&&r().id!==t&&W(c)){e.preventDefault();return}y(t),window.dispatchEvent(new CustomEvent(`edit-trigger`,{detail:t}))}let c=F(!1);function l(e,t){if(r().id&&r().id!==t&&W(c)){e.preventDefault();return}y(t)}bn(()=>{let e=r().id;e&&mr(()=>{Qi.selected=e,ra(e,2)})});let u=N(()=>W(i).find(e=>e.id===r().id)),d=N(()=>new URLSearchParams(Wi.querystring).get(`review`)===`profile`&&W(a).some(e=>e.session===r().id&&e.pending)),p=N(()=>W(i).some(e=>e.id===Qi.selected)?Qi.selected:W(i)[0]?.id),m=N(()=>!$.connected||!!$.data?.sessionsError),h=N(()=>[[`OBSERVED TOKENS`,ia(W(i).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,ia(W(i).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,W(m)?`—`:ia(W(i).filter(e=>e.status===t).length)])]),v=N(()=>W(i).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`,`CHECK SESSION`].includes(e.status)));function y(e){Qi.selected=e,dr().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function b(e,t){if(y(e),r().id){t<0&&(ra(e,2),location.hash=`/sessions`);return}let n=ta(e)+t;n>2?location.hash=`/sessions/`+encodeURIComponent(e):ra(e,n)}function x(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`&&r().id)e.preventDefault(),b(r().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(r().id||W(p)))e.preventDefault(),b(r().id||W(p),e.key===`ArrowLeft`?-1:1);else if(!r().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&W(i).length){e.preventDefault();let t=W(i).findIndex(e=>e.id===W(p));y(W(i)[Math.max(0,Math.min(W(i).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function S(e){return W(m)?`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.`:$.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.`:``}var C=ms();Cr(`keydown`,en,x);var w=R(C),T=z(B(L(w),2));j(w);var ee=B(w,2);let E;Z(ee,21,()=>W(h),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1];var a=Ho(),o=L(a),s=z(o,!0),c=z(B(o,2),!0);j(a),V(()=>{J(s,r()),J(c,i())}),q(e,a)}),j(ee);var D=B(ee,2),te=z(D),ne=B(D,2),re=e=>{q(e,Uo())};Y(ne,e=>{W(m)&&e(re)});var ie=B(ne,2),ae=e=>{q(e,Wo())};Y(ie,e=>{$.data?.profileError&&e(ae)});var oe=B(ie,2),se=e=>{var t=Jo(),n=L(t);Z(n,17,()=>W(v),X,(e,t)=>{var n=Go();let r;var i=z(n);V((e,a)=>{r=ci(n,1,`button`,null,r,{approval:W(t).status===`APPROVAL NEEDED`}),Q(n,`href`,e),J(i,`${W(t).status??``} - ${a??``} // ${(W(t).name||W(t).directory||W(t).id)??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,n,()=>y(W(t).id)),q(e,n)});var u=B(n,2);Z(u,17,()=>W(a).filter(e=>e.pending&&W(i).some(t=>t.id===e.session)),X,(e,t)=>{var n=Ko(),a=z(n);V((e,i,o)=>{Q(n,`title`,r().id&&r().id!==W(t).session&&W(c)?`Finish sending or clear your current draft before switching sessions.`:`Review this session’s quota threshold`),Q(n,`href`,e),J(a,`QUOTA THRESHOLD ${i??``} // ${o??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session)+`?review=profile`,()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory||W(t).session]),G(`click`,n,e=>l(e,W(t).session)),q(e,n)}),Z(B(u,2),17,()=>W(o),X,(e,t)=>{var n=qo(),r=z(n);V((e,t,i)=>{Q(n,`href`,e),J(r,`TRIGGER SET ${t??``} // ${i??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session)+`?schedule=edit`,()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory]),G(`click`,n,e=>s(e,W(t).session)),q(e,n)}),j(t),q(e,t)},ce=N(()=>(W(v).length||W(a).some(e=>e.pending)||W(o).length)&&!W(m));Y(oe,e=>{W(ce)&&e(se)});var le=B(oe,2),ue=e=>{var t=Fr(),i=R(t),o=e=>{var t=$o(),i=L(t),o=L(i),s=L(o);let l;var f=B(s);j(o);var p=B(o,2);j(i);var h=B(i,2),g=e=>{var t=Bo(),n=z(t,!0);V(()=>J(n,W(u).directory)),q(e,t)};Y(h,e=>{W(u).name&&W(u).directory&&e(g)});var _=B(h,2),v=z(_),b=B(_,2);let x;var S=L(b),C=L(S);n(C,()=>W(u),()=>!0,()=>!0),j(S);var w=B(S,2),T=e=>{var t=Fr();qr(R(t),()=>W(u).id,e=>{{let t=N(()=>new URLSearchParams(Wi.querystring).get(`schedule`)===`edit`);ko(e,{get session(){return W(u).id},get openScheduler(){return W(t)},get observedCommand(){return W(u).command},get suspended(){return W(d)},onProtectedChange:e=>{I(c,e,!0)}})}}),q(e,t)},ee=e=>{q(e,Yo())};Y(w,e=>{$.data?.control?e(T):e(ee,-1)}),j(b);var E=B(b,2);Z(E,17,()=>W(a).filter(e=>e.session===W(u).id),e=>e.session,(e,t)=>{var n=Qo(),r=L(n),i=e=>{var n=Xo(),r=z(n,!0);V(()=>J(r,W(t).notice)),q(e,n)};Y(r,e=>{W(t).notice&&e(i)});var a=B(r,2),o=e=>{ko(e,{get session(){return W(u).id},review:`profile`})},s=e=>{var t=Zo();V(e=>Q(t,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(u).id)+`?review=profile`]),q(e,t)};Y(a,e=>{W(t).pending&&W(d)?e(o):W(t).pending&&e(s,1)}),j(n),V(()=>Q(n,`id`,`quota-profile-`+W(u).id)),q(e,n)});var D=B(E,2),te=e=>{var t=Fr();qr(R(t),()=>W(u).id,e=>{jo(e,{get session(){return W(u)},active:!0})}),q(e,t)};Y(D,e=>{W(d)||e(te)}),j(t),V(e=>{l=ci(s,1,`lamp lit`,null,l,{working:W(u).status===`WORKING`&&!W(m)}),J(f,`${(W(m)?`STALE`:W(d)?`QUOTA THRESHOLD`:W(u).status)??``} // ${(W(u).name||W(u).directory)??``}`),J(v,`${e??``} TOKENS // ${W(u).id??``} // CONTEXT SOURCE // ${(W(u).source||`LOCAL`)??``}`),x=ui(b,``,x,{display:W(d)?`none`:void 0})},[()=>ia(W(u).tokens)]),G(`click`,p,()=>{y(r().id),ra(r().id,2)}),q(e,t)},s=e=>{q(e,es())};Y(i,e=>{W(u)?e(o):e(s,-1)}),q(e,t)},de=e=>{var t=ps(),r=R(t),o=B(L(r),2),c=L(o),u=B(c,2);j(o),j(r);var d=B(r,2);Z(d,17,()=>W(i),e=>e.id,(e,t)=>{let r=N(()=>ta(W(t).id));var i=ds();let o;var c=L(i),u=L(c),d=e=>{var n=ts(),r=L(n),i=z(r);j(n),V(e=>{Q(r,`aria-pressed`,W(p)===W(t).id),J(i,`${e??``} // ${W(t).name??``}`)},[()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,r,()=>y(W(t).id)),q(e,n)};Y(u,e=>{W(t).name&&e(d)});var f=B(u,2),h=L(f),g=L(h);let _;var v=B(g,1,!0);j(h),j(f);var x=B(f,2),S=e=>{var n=ns(),r=z(n,!0);V(()=>{Q(n,`aria-pressed`,W(p)===W(t).id),J(r,W(t).directory||W(t).id)}),G(`click`,n,()=>y(W(t).id)),q(e,n)};Y(x,e=>{W(t).name||e(S)});var C=B(x,2),w=L(C);we(),j(C);var T=B(C,2),ee=e=>{var n=rs();V(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(t).id)+`?schedule=edit`]),G(`click`,n,e=>s(e,W(t).id)),q(e,n)},E=N(()=>$.data?.triggers?.some(e=>e.session===W(t).id));Y(T,e=>{W(E)&&e(ee)});var D=B(T,2),te=e=>{var n=Bo(),r=z(n,!0);V(()=>J(r,W(t).directory)),q(e,n)};Y(D,e=>{W(t).name&&W(t).directory&&e(te)});var ne=B(D,2),re=z(ne),ie=B(ne,2),ae=z(ie),oe=B(ie,2),se=L(oe),ce=B(se,2),le=z(ce,!0),ue=B(ce,2);j(oe);var de=B(oe,2),fe=B(de,2),pe=e=>{var n=is(),r=z(n,!0);V(()=>J(r,W(t).status===`CHECK SESSION`?`INFERRED INACTIVITY`:$.data?.control?`OPEN FULL DETAIL OR REPLY IN CODEX`:W(t).status===`APPROVAL NEEDED`?`APPROVE OR DECLINE IN CODEX`:`REPLY IN CODEX`)),q(e,n)},me=N(()=>!W(m)&&[`APPROVAL NEEDED`,`INPUT NEEDED`,`CHECK SESSION`].includes(W(t).status));Y(fe,e=>{W(me)&&e(pe)}),j(c);var he=B(c,2),O=e=>{var r=ls(),i=L(r),o=L(i),s=z(o,!0),c=B(o,2),u=e=>{var n=as(),r=z(n,!0);V(e=>{Q(n,`href`,e),J(r,$.data?.control?`REVIEW IN FULL DETAIL ↗`:`APPROVAL IN CODEX ↗`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id)]),q(e,n)};Y(c,e=>{!W(m)&&W(t).status===`APPROVAL NEEDED`&&e(u)}),j(i);var d=B(i,2);n(d,()=>W(t),()=>!1);var f=B(d,2);Z(f,17,()=>W(a).filter(e=>e.session===W(t).id),X,(e,n)=>{var r=cs(),i=R(r),a=e=>{var t=os(),r=z(t,!0);V(()=>J(r,W(n).notice)),q(e,t)};Y(i,e=>{W(n).notice&&e(a)});var o=B(i,2),s=e=>{var n=ss();V(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(t).id)+`?review=profile`]),G(`click`,n,e=>l(e,W(t).id)),q(e,n)};Y(o,e=>{W(n).pending&&e(s)}),q(e,r)});var h=B(f,2);{let e=N(()=>W(p)===W(t).id);jo(h,{get session(){return W(t)},get active(){return W(e)}})}j(r),V(()=>J(s,W(t).contextKind||`LAST ACTIVITY`)),q(e,r)};Y(he,e=>{W(r)>0&&e(O)});var ge=B(he,2),_e=e=>{var n=us(),r=B(L(n),2);{let e=N(()=>(W(t).samples||[]).map(e=>e.tokens));qa(r,{get values(){return W(e)},capacity:120})}var i=z(B(r,2));j(n),V(()=>J(i,`LAST ${(W(t).samples?.length||0)??``} SAMPLES // AUTO SCALE`)),q(e,n)};Y(ge,e=>{W(r)<2&&e(_e)}),j(i),V((e,n,a,s)=>{o=ci(i,1,`session-row`,null,o,{selected:W(p)===W(t).id,wide:W(r)===2,split:W(r)===1}),Q(i,`aria-label`,`Session `+(W(t).name||W(t).directory||W(t).id)),Q(h,`href`,e),_=ci(g,1,`lamp lit`,null,_,{working:W(t).status===`WORKING`&&!W(m)}),J(v,W(m)?`STALE`:W(t).status),J(w,`${n??``} `),J(re,`${W(t).agents??``} LINKED AGENTS`),J(ae,`ACTIVE // ${a??``}`),se.disabled=W(r)===0,Q(ce,`aria-expanded`,W(r)>0),J(le,W(r)?`HIDE DETAIL`:`SHOW DETAIL`),Q(de,`href`,s)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>ia(W(t).tokens),()=>aa(W(t).activity),()=>`#/sessions/`+encodeURIComponent(W(t).id)]),G(`click`,h,()=>y(W(t).id)),G(`click`,se,()=>b(W(t).id,-1)),G(`click`,ce,()=>{y(W(t).id),ra(W(t).id,+!W(r))}),G(`click`,ue,()=>b(W(t).id,1)),G(`click`,de,()=>y(W(t).id)),q(e,i)});var f=B(d,2),h=e=>{q(e,fs())};Y(f,e=>{W(i).length||e(h)}),G(`click`,c,()=>na(1)),G(`click`,u,()=>na(0)),q(e,t)};Y(le,e=>{r().id?e(ue):e(de,-1)}),V(e=>{J(T,`OBSERVED ${e??``}`),E=ci(ee,1,`session-totals`,null,E,{stale:W(m)}),J(te,`${W(m)?`LAST KNOWN TOTALS — live state counts unavailable. `:``}Tokens + visible.

            `),qo=K(` `),Jo=K(` `),Yo=K(` `),Xo=K(``),Zo=K(`

            Read only — reply or approve in Codex.

            `),Qo=K(`

            `),$o=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),es=K(`
            `),ts=K(`
            `),ns=K(`

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

            `),rs=K(`

            `),is=K(``),as=K(`TRIGGER SET`),os=K(`

            `),ss=K(` `),cs=K(`

            `),ls=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),us=K(` `,1),ds=K(`

            `),fs=K(`

            TOKEN ACTIVITY // 30 SECOND SAMPLES

            `),ps=K(`

            TOKENS

            FULL DETAIL →
            `),ms=K(`

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

            `),hs=K(`

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

            `,1),gs=K(`

            SESSION TOTALS

            `,1);function _s(e,t){Ge(t,!0);let n=(e,t=f,n,r)=>{let i=ht(()=>g(n?.(),!0)),a=ht(()=>g(r?.(),!1));var o=Uo(),s=R(o),c=e=>{var n=Po(),r=z(B(R(n),2),!0);we(2),V(()=>J(r,t().approvalContext)),q(e,n)};Y(s,e=>{W(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(c)});var l=B(s,2),u=e=>{var n=Fo();let r;var i=z(n,!0);V(e=>{r=ci(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),J(i,e)},[()=>S(t())]),q(e,n)},d=N(()=>S(t())&&(!W(a)||W(m)||t().status===`CHECK SESSION`));Y(l,e=>{W(d)&&e(u)});var p=B(l,2),h=e=>{var n=Io(),r=z(n,!0);V(()=>J(r,t().contextKind||`LAST ACTIVITY`)),q(e,n)};Y(p,e=>{W(i)&&e(h)});var _=B(p,2),v=e=>{var n=Lo(),r=z(n,!0);V(()=>J(r,t().text||`No session context available.`)),q(e,n)};Y(_,e=>{(t().text||!t().workingCommand)&&e(v)});var y=B(_,2),b=e=>{var n=Ro(),r=B(R(n),2),i=L(r),a=B(i),o=e=>{var n=Pr();V(()=>J(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),q(e,n)};Y(a,e=>{!W(m)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(o)});var s=B(a,2),c=e=>{q(e,Pr(`+`))};Y(s,e=>{t().runningLimited&&e(c)}),j(r);var l=z(B(r,2),!0);V(e=>{J(i,`COMMAND // ${e??``} `),J(l,t().workingCommand)},[()=>W(m)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),q(e,n)};Y(y,e=>{t().workingCommand&&e(b)});var x=B(y,2),C=e=>{var n=Vo(),r=B(R(n),2),i=z(r,!0),a=B(r,2),o=e=>{var n=zo(),r=z(n,!0);V(()=>J(r,t().command)),q(e,n)},s=e=>{q(e,Bo())};Y(a,e=>{t().command?e(o):e(s,-1)}),V(()=>J(i,W(m)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),q(e,n)};Y(x,e=>{(!W(a)||!$.data?.control)&&(t().command||t().status===`APPROVAL NEEDED`)&&e(C)});var w=B(x,2),T=e=>{var n=Ho(),r=z(n);V(()=>J(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),q(e,n)};Y(w,e=>{W(a)||e(T)}),q(e,o)},r=Hi(t,`params`,19,()=>({})),i=N(()=>$.data?.sessions||[]),a=N(()=>$.data?.control&&$.data.profiles||[]),o=N(()=>($.data?.triggers||[]).filter(e=>W(i).some(t=>t.id===e.session)));function s(e,t){if(r().id&&r().id!==t&&W(c)){e.preventDefault();return}y(t),window.dispatchEvent(new CustomEvent(`edit-trigger`,{detail:t}))}let c=F(!1);function l(e,t){if(r().id&&r().id!==t&&W(c)){e.preventDefault();return}y(t)}bn(()=>{let e=r().id;e&&mr(()=>{ea.selected=e,aa(e,2)})});let u=N(()=>W(i).find(e=>e.id===r().id)),d=N(()=>new URLSearchParams(Ki.querystring).get(`review`)===`profile`&&W(a).some(e=>e.session===r().id&&e.pending)),p=N(()=>W(i).some(e=>e.id===ea.selected)?ea.selected:W(i)[0]?.id),m=N(()=>!$.connected||!!$.data?.sessionsError),h=N(()=>[[`OBSERVED TOKENS`,oa(W(i).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,oa(W(i).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,W(m)?`—`:oa(W(i).filter(e=>e.status===t).length)])]),v=N(()=>W(i).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`,`CHECK SESSION`].includes(e.status)));function y(e){ea.selected=e,dr().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function b(e,t){if(y(e),r().id){t<0&&(aa(e,2),location.hash=`/sessions`);return}let n=ra(e)+t;n>2?location.hash=`/sessions/`+encodeURIComponent(e):aa(e,n)}function x(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`&&r().id)e.preventDefault(),b(r().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(r().id||W(p)))e.preventDefault(),b(r().id||W(p),e.key===`ArrowLeft`?-1:1);else if(!r().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&W(i).length){e.preventDefault();let t=W(i).findIndex(e=>e.id===W(p));y(W(i)[Math.max(0,Math.min(W(i).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function S(e){return W(m)?`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.`:$.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.`:``}var C=gs();Cr(`keydown`,en,x);var w=R(C),T=z(B(L(w),2));j(w);var ee=B(w,2);let E;Z(ee,21,()=>W(h),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1];var a=Wo(),o=L(a),s=z(o,!0),c=z(B(o,2),!0);j(a),V(()=>{J(s,r()),J(c,i())}),q(e,a)}),j(ee);var D=B(ee,2),te=z(D),ne=B(D,2),re=e=>{q(e,Go())};Y(ne,e=>{W(m)&&e(re)});var ie=B(ne,2),ae=e=>{q(e,Ko())};Y(ie,e=>{$.data?.profileError&&e(ae)});var oe=B(ie,2),se=e=>{var t=Xo(),n=L(t);Z(n,17,()=>W(v),X,(e,t)=>{var n=qo();let r;var i=z(n);V((e,a)=>{r=ci(n,1,`button`,null,r,{approval:W(t).status===`APPROVAL NEEDED`}),Q(n,`href`,e),J(i,`${W(t).status??``} + ${a??``} // ${(W(t).name||W(t).directory||W(t).id)??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,n,()=>y(W(t).id)),q(e,n)});var u=B(n,2);Z(u,17,()=>W(a).filter(e=>e.pending&&W(i).some(t=>t.id===e.session)),X,(e,t)=>{var n=Jo(),a=z(n);V((e,i,o)=>{Q(n,`title`,r().id&&r().id!==W(t).session&&W(c)?`Finish sending or clear your current draft before switching sessions.`:`Review this session’s quota threshold`),Q(n,`href`,e),J(a,`QUOTA THRESHOLD ${i??``} // ${o??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session)+`?review=profile`,()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory||W(t).session]),G(`click`,n,e=>l(e,W(t).session)),q(e,n)}),Z(B(u,2),17,()=>W(o),X,(e,t)=>{var n=Yo(),r=z(n);V((e,t,i)=>{Q(n,`href`,e),J(r,`TRIGGER SET ${t??``} // ${i??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session)+`?schedule=edit`,()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory]),G(`click`,n,e=>s(e,W(t).session)),q(e,n)}),j(t),q(e,t)},ce=N(()=>(W(v).length||W(a).some(e=>e.pending)||W(o).length)&&!W(m));Y(oe,e=>{W(ce)&&e(se)});var le=B(oe,2),ue=e=>{var t=Fr(),i=R(t),o=e=>{var t=ts(),i=L(t),o=L(i),s=L(o);let l;var f=B(s);j(o);var p=B(o,2);j(i);var h=B(i,2),g=e=>{var t=Ho(),n=z(t,!0);V(()=>J(n,W(u).directory)),q(e,t)};Y(h,e=>{W(u).name&&W(u).directory&&e(g)});var _=B(h,2),v=z(_),b=B(_,2);let x;var S=L(b),C=L(S);n(C,()=>W(u),()=>!0,()=>!0),j(S);var w=B(S,2),T=e=>{var t=Fr();qr(R(t),()=>W(u).id,e=>{{let t=N(()=>new URLSearchParams(Ki.querystring).get(`schedule`)===`edit`);jo(e,{get session(){return W(u).id},get openScheduler(){return W(t)},get observedCommand(){return W(u).command},get suspended(){return W(d)},onProtectedChange:e=>{I(c,e,!0)}})}}),q(e,t)},ee=e=>{q(e,Zo())};Y(w,e=>{$.data?.control?e(T):e(ee,-1)}),j(b);var E=B(b,2);Z(E,17,()=>W(a).filter(e=>e.session===W(u).id),e=>e.session,(e,t)=>{var n=es(),r=L(n),i=e=>{var n=Qo(),r=z(n,!0);V(()=>J(r,W(t).notice)),q(e,n)};Y(r,e=>{W(t).notice&&e(i)});var a=B(r,2),o=e=>{jo(e,{get session(){return W(u).id},review:`profile`})},s=e=>{var t=$o();V(e=>Q(t,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(u).id)+`?review=profile`]),q(e,t)};Y(a,e=>{W(t).pending&&W(d)?e(o):W(t).pending&&e(s,1)}),j(n),V(()=>Q(n,`id`,`quota-profile-`+W(u).id)),q(e,n)});var D=B(E,2),te=e=>{var t=Fr();qr(R(t),()=>W(u).id,e=>{No(e,{get session(){return W(u)},active:!0})}),q(e,t)};Y(D,e=>{W(d)||e(te)}),j(t),V(e=>{l=ci(s,1,`lamp lit`,null,l,{working:W(u).status===`WORKING`&&!W(m)}),J(f,`${(W(m)?`STALE`:W(d)?`QUOTA THRESHOLD`:W(u).status)??``} // ${(W(u).name||W(u).directory)??``}`),J(v,`${e??``} TOKENS // ${W(u).id??``} // CONTEXT SOURCE // ${(W(u).source||`LOCAL`)??``}`),x=ui(b,``,x,{display:W(d)?`none`:void 0})},[()=>oa(W(u).tokens)]),G(`click`,p,()=>{y(r().id),aa(r().id,2)}),q(e,t)},s=e=>{q(e,ns())};Y(i,e=>{W(u)?e(o):e(s,-1)}),q(e,t)},de=e=>{var t=hs(),r=R(t),o=B(L(r),2),c=L(o),u=B(c,2);j(o),j(r);var d=B(r,2);Z(d,17,()=>W(i),e=>e.id,(e,t)=>{let r=N(()=>ra(W(t).id));var i=ps();let o;var c=L(i),u=L(c),d=e=>{var n=rs(),r=L(n),i=z(r);j(n),V(e=>{Q(r,`aria-pressed`,W(p)===W(t).id),J(i,`${e??``} // ${W(t).name??``}`)},[()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,r,()=>y(W(t).id)),q(e,n)};Y(u,e=>{W(t).name&&e(d)});var f=B(u,2),h=L(f),g=L(h);let _;var v=B(g,1,!0);j(h),j(f);var x=B(f,2),S=e=>{var n=is(),r=z(n,!0);V(()=>{Q(n,`aria-pressed`,W(p)===W(t).id),J(r,W(t).directory||W(t).id)}),G(`click`,n,()=>y(W(t).id)),q(e,n)};Y(x,e=>{W(t).name||e(S)});var C=B(x,2),w=L(C);we(),j(C);var T=B(C,2),ee=e=>{var n=as();V(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(t).id)+`?schedule=edit`]),G(`click`,n,e=>s(e,W(t).id)),q(e,n)},E=N(()=>$.data?.triggers?.some(e=>e.session===W(t).id));Y(T,e=>{W(E)&&e(ee)});var D=B(T,2),te=e=>{var n=Ho(),r=z(n,!0);V(()=>J(r,W(t).directory)),q(e,n)};Y(D,e=>{W(t).name&&W(t).directory&&e(te)});var ne=B(D,2),re=z(ne),ie=B(ne,2),ae=z(ie),oe=B(ie,2),se=L(oe),ce=B(se,2),le=z(ce,!0),ue=B(ce,2);j(oe);var de=B(oe,2),fe=B(de,2),pe=e=>{var n=os(),r=z(n,!0);V(()=>J(r,W(t).status===`CHECK SESSION`?`INFERRED INACTIVITY`:$.data?.control?`OPEN FULL DETAIL OR REPLY IN CODEX`:W(t).status===`APPROVAL NEEDED`?`APPROVE OR DECLINE IN CODEX`:`REPLY IN CODEX`)),q(e,n)},me=N(()=>!W(m)&&[`APPROVAL NEEDED`,`INPUT NEEDED`,`CHECK SESSION`].includes(W(t).status));Y(fe,e=>{W(me)&&e(pe)}),j(c);var he=B(c,2),O=e=>{var r=ds(),i=L(r),o=L(i),s=z(o,!0),c=B(o,2),u=e=>{var n=ss(),r=z(n,!0);V(e=>{Q(n,`href`,e),J(r,$.data?.control?`REVIEW IN FULL DETAIL ↗`:`APPROVAL IN CODEX ↗`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id)]),q(e,n)};Y(c,e=>{!W(m)&&W(t).status===`APPROVAL NEEDED`&&e(u)}),j(i);var d=B(i,2);n(d,()=>W(t),()=>!1);var f=B(d,2);Z(f,17,()=>W(a).filter(e=>e.session===W(t).id),X,(e,n)=>{var r=us(),i=R(r),a=e=>{var t=cs(),r=z(t,!0);V(()=>J(r,W(n).notice)),q(e,t)};Y(i,e=>{W(n).notice&&e(a)});var o=B(i,2),s=e=>{var n=ls();V(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(t).id)+`?review=profile`]),G(`click`,n,e=>l(e,W(t).id)),q(e,n)};Y(o,e=>{W(n).pending&&e(s)}),q(e,r)});var h=B(f,2);{let e=N(()=>W(p)===W(t).id);No(h,{get session(){return W(t)},get active(){return W(e)}})}j(r),V(()=>J(s,W(t).contextKind||`LAST ACTIVITY`)),q(e,r)};Y(he,e=>{W(r)>0&&e(O)});var ge=B(he,2),_e=e=>{var n=fs(),r=B(L(n),2);{let e=N(()=>(W(t).samples||[]).map(e=>e.tokens));Ya(r,{get values(){return W(e)},capacity:120})}var i=z(B(r,2));j(n),V(()=>J(i,`LAST ${(W(t).samples?.length||0)??``} SAMPLES // AUTO SCALE`)),q(e,n)};Y(ge,e=>{W(r)<2&&e(_e)}),j(i),V((e,n,a,s)=>{o=ci(i,1,`session-row`,null,o,{selected:W(p)===W(t).id,wide:W(r)===2,split:W(r)===1}),Q(i,`aria-label`,`Session `+(W(t).name||W(t).directory||W(t).id)),Q(h,`href`,e),_=ci(g,1,`lamp lit`,null,_,{working:W(t).status===`WORKING`&&!W(m)}),J(v,W(m)?`STALE`:W(t).status),J(w,`${n??``} `),J(re,`${W(t).agents??``} LINKED AGENTS`),J(ae,`ACTIVE // ${a??``}`),se.disabled=W(r)===0,Q(ce,`aria-expanded`,W(r)>0),J(le,W(r)?`HIDE DETAIL`:`SHOW DETAIL`),Q(de,`href`,s)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>oa(W(t).tokens),()=>sa(W(t).activity),()=>`#/sessions/`+encodeURIComponent(W(t).id)]),G(`click`,h,()=>y(W(t).id)),G(`click`,se,()=>b(W(t).id,-1)),G(`click`,ce,()=>{y(W(t).id),aa(W(t).id,+!W(r))}),G(`click`,ue,()=>b(W(t).id,1)),G(`click`,de,()=>y(W(t).id)),q(e,i)});var f=B(d,2),h=e=>{q(e,ms())};Y(f,e=>{W(i).length||e(h)}),G(`click`,c,()=>ia(1)),G(`click`,u,()=>ia(0)),q(e,t)};Y(le,e=>{r().id?e(ue):e(de,-1)}),V(e=>{J(T,`OBSERVED ${e??``}`),E=ci(ee,1,`session-totals`,null,E,{stale:W(m)}),J(te,`${W(m)?`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.`)},[()=>aa($.data?.sessionsAt)]),q(e,C),Ke()}wr([`click`]);var gs=K(`

            `),_s=K(`

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

            `,1),vs=K(`// APPROXIMATE`),ys=K(`

            Partial accounting: totals may still change.

            `),bs=K(`

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

            `,1),xs=K(`

            `,1),Ss=K(`

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

            `),Cs=K(`
            `),ws=K(`
            `),Ts=K(`

            No usage reported for this day.

            `),Es=K(`

            Selected breakdown unavailable; missing does not mean zero.

            `),Ds=K(`

            `,1);function Os(e,t){Ge(t,!0);let n=F(`surface`),r=F(0),i=N(()=>t.reports?.daily),a=N(()=>t.reports?.plan),o=N(()=>t.mode===`breakdown`?W(i)?.days.length||0:W(a)?.periods.length||0),s=N(()=>Math.min(W(r),Math.max(0,W(o)-1))),c=N(()=>W(i)?.days[(W(i)?.days.length||0)-1-W(s)]),l=N(()=>W(a)?.periods[W(s)]),u=N(()=>t.mode===`breakdown`?W(i)?.units||``:`%`),d=N(()=>{let e=Object.create(null);if(t.mode===`breakdown`)e=W(c)?.groups[W(n)]||{};else{let t=W(n)===`feature`?`thread_source`:W(n)===`task start`?`turn_trigger`:W(n);for(let n of W(l)?.breakdowns||[])if(n.dimension===t)for(let t of n.rows)e[t.key]=(e[t.key]||0)+t.basis_points/100}return Object.entries(e).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}),f=N(()=>t.mode===`breakdown`?W(c)?.total:W(l)?.used_basis_points==null?null:W(l).used_basis_points/100),p=N(()=>Math.max(1,W(f)||0,...W(d).map(([,e])=>e))),m=e=>e==null?`UNKNOWN`:e.toLocaleString(`en-GB`,{maximumFractionDigits:2});var h=Ds(),g=R(h),v=L(g),y=B(L(v)),b=L(y);b.value=b.__value=`surface`;var x=B(b);x.value=x.__value=`model`;var S=B(x);S.value=S.__value=`feature`;var C=B(S);C.value=C.__value=`task start`,j(y),mi(y),j(v);var w=B(v,2),T=B(w,2),ee=z(B(T,2),!0);j(g);var E=B(g,2),D=L(E),te=z(D,!0),ne=B(D,2),re=z(ne),ie=B(ne,2),ae=e=>{var t=_s(),n=R(t),r=z(n),a=B(n,2),o=e=>{var t=gs(),n=z(t);V(()=>J(n,`Data as of ${W(i).dataAsOf??``}`)),q(e,t)};Y(a,e=>{W(i).dataAsOf&&e(o)});var s=z(B(a,2));we(2),V((e,t)=>{J(r,`Latest fetch ${e??``} // queried ${W(i).from??``} → ${W(i).through??``}. + list. History samples every 30 seconds. Not account-wide totals.`)},[()=>sa($.data?.sessionsAt)]),q(e,C),Ke()}wr([`click`]);var vs=K(`

            `),ys=K(`

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

            `,1),bs=K(`// APPROXIMATE`),xs=K(`

            Partial accounting: totals may still change.

            `),Ss=K(`

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

            `,1),Cs=K(`

            `,1),ws=K(`

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

            `),Ts=K(`
            `),Es=K(`
            `),Ds=K(`

            No usage reported for this day.

            `),Os=K(`

            Selected breakdown unavailable; missing does not mean zero.

            `),ks=K(`

            `,1);function As(e,t){Ge(t,!0);let n=F(`surface`),r=F(0),i=N(()=>t.reports?.daily),a=N(()=>t.reports?.plan),o=N(()=>t.mode===`breakdown`?W(i)?.days.length||0:W(a)?.periods.length||0),s=N(()=>Math.min(W(r),Math.max(0,W(o)-1))),c=N(()=>W(i)?.days[(W(i)?.days.length||0)-1-W(s)]),l=N(()=>W(a)?.periods[W(s)]),u=N(()=>t.mode===`breakdown`?W(i)?.units||``:`%`),d=N(()=>{let e=Object.create(null);if(t.mode===`breakdown`)e=W(c)?.groups[W(n)]||{};else{let t=W(n)===`feature`?`thread_source`:W(n)===`task start`?`turn_trigger`:W(n);for(let n of W(l)?.breakdowns||[])if(n.dimension===t)for(let t of n.rows)e[t.key]=(e[t.key]||0)+t.basis_points/100}return Object.entries(e).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}),f=N(()=>t.mode===`breakdown`?W(c)?.total:W(l)?.used_basis_points==null?null:W(l).used_basis_points/100),p=N(()=>Math.max(1,W(f)||0,...W(d).map(([,e])=>e))),m=e=>e==null?`UNKNOWN`:e.toLocaleString(`en-GB`,{maximumFractionDigits:2});var h=ks(),g=R(h),v=L(g),y=B(L(v)),b=L(y);b.value=b.__value=`surface`;var x=B(b);x.value=x.__value=`model`;var S=B(x);S.value=S.__value=`feature`;var C=B(S);C.value=C.__value=`task start`,j(y),mi(y),j(v);var w=B(v,2),T=B(w,2),ee=z(B(T,2),!0);j(g);var E=B(g,2),D=L(E),te=z(D,!0),ne=B(D,2),re=z(ne),ie=B(ne,2),ae=e=>{var t=ys(),n=R(t),r=z(n),a=B(n,2),o=e=>{var t=vs(),n=z(t);V(()=>J(n,`Data as of ${W(i).dataAsOf??``}`)),q(e,t)};Y(a,e=>{W(i).dataAsOf&&e(o)});var s=z(B(a,2));we(2),V((e,t)=>{J(r,`Latest fetch ${e??``} // queried ${W(i).from??``} → ${W(i).through??``}. Reports are fetched from OpenAI and are not saved between runs.`),J(s,`${(W(c)?.date||`No daily buckets reported`)??``} // ${t??``} - ${W(u)??``}`)},[()=>aa(W(i).fetchedAt),()=>m(W(f))]),q(e,t)},oe=e=>{var t=xs(),n=R(t),r=L(n);let i;var o=z(r,!0),s=B(r),c=e=>{q(e,vs())};Y(s,e=>{W(a).approximate&&e(c)});var u=B(s);j(n);var d=B(n,2),p=L(d),h=B(p),g=e=>{var t=Pr();V(()=>J(t,`// Boundary tolerance ${W(a).boundary_tolerance_seconds??``}s`)),q(e,t)};Y(h,e=>{W(a).boundary_tolerance_seconds!=null&&e(g)}),j(d);var _=B(d,2),v=e=>{var t=bs(),n=R(t),r=L(n),i=B(r);let a;var o=z(i);j(n);var s=B(n,2),c=z(s),u=B(s,2),d=e=>{q(e,ys())};Y(u,e=>{W(l).accounting_complete||e(d)}),we(2),V(e=>{J(r,`${W(l).window_minutes??``} MIN // ${W(l).plan_type??``} // `),a=ci(i,1,`svelte-1fbui7h`,null,a,{muted:W(f)==null,"quota-near":W(f)!=null&&W(f)>=80&&W(f)<100,"quota-full":W(f)!=null&&W(f)>=100}),J(o,`USED ${e??``}${W(f)==null?``:`%`}`),J(c,`${W(l).starts_at??``} → ${W(l).ends_at??``}`)},[()=>m(W(f))]),q(e,t)};Y(_,e=>{W(l)&&e(v)}),V(e=>{i=ci(r,1,`svelte-1fbui7h`,null,i,{"quality-warning":!W(a).coverage_complete}),J(o,W(a).coverage_complete?`Reported range complete`:`Partial coverage`),J(u,` // Latest fetch ${e??``}`),J(p,`Coverage starts ${(W(a).coverage_start||`unknown`)??``} // Data as of ${(W(a).data_as_of||`unknown`)??``}`)},[()=>aa(W(a).fetchedAt)]),q(e,t)},se=e=>{q(e,Ss())};Y(ie,e=>{t.mode===`breakdown`&&W(i)?e(ae):t.mode===`periods`&&W(a)?e(oe,1):e(se,-1)});var ce=B(ie,2),le=e=>{var n=ws(),r=L(n),i=z(B(L(r),2),!0);j(r),Z(B(r,2),17,()=>W(d),X,(e,n,r)=>{var i=N(()=>_(W(n),2));let a=()=>W(i)[0],o=()=>W(i)[1];var s=Cs();let c;var l=L(s),u=z(l,!0),d=B(l,2),f=L(d);let h;j(d);var g=z(B(d,2));j(s),V((e,n,i)=>{c=ci(s,1,`report-row svelte-1fbui7h`,null,c,{unknown:e,alternate:r%2==1}),Q(l,`title`,a()),J(u,a()),h=ui(f,``,h,{width:n}),J(g,`${i??``}${t.mode===`periods`?`%`:``}`)},[()=>a().trim().toLowerCase()===`unknown`,()=>`${Math.max(0,100*o()/W(p))}%`,()=>m(o())]),q(e,s)}),j(n),V(()=>J(i,t.mode===`breakdown`?W(u):`QUOTA USED`)),q(e,n)},ue=e=>{q(e,Ts())},de=e=>{q(e,Es())};Y(ce,e=>{W(d).length?e(le):t.mode===`breakdown`&&W(c)?.total===0&&W(c)?.groups[W(n)]!=null?e(ue,1):(W(i)&&t.mode===`breakdown`||W(a)&&t.mode===`periods`)&&e(de,2)}),j(E),V(()=>{w.disabled=W(s)>=W(o)-1,T.disabled=W(s)===0,J(ee,W(o)?`${W(s)+1} / ${W(o)}`:`NO DATA`),J(te,t.mode===`breakdown`?`DAILY BREAKDOWN`:`QUOTA WINDOWS`),J(re,`${(t.mode===`breakdown`?t.reports?.dailyStatus||`UNAVAILABLE`:t.reports?.planStatus||`UNAVAILABLE`)??``} // UTC`)}),hi(y,()=>W(n),e=>I(n,e)),G(`click`,w,()=>I(r,W(s)+1)),G(`click`,T,()=>I(r,W(s)-1)),q(e,h),Ke()}wr([`click`]);var ks=864e5;function As(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 js(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));for(let e=0;;e++){let i=As(r,-t),a=new Date(i.getTime()+ks);if(e===n)return{start:a,end:r};r=i}}var Ms=K(``),Ns=K(``,1),Ps=K(`

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

            `),Fs=K(`

            Token history unavailable; other reports may still be available.

            `),Is=K(``),Ls=K(`
            `),Rs=K(`

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

            `,1),zs=K(`
            `,1),Bs=K(` `),Vs=K(`

            LIFETIME TOKENS

            PEAK DAY

            CURRENT STREAK

            DAYS

            LONGEST TURN

            SECONDS

            LONGEST STREAK

            DAYS

            OPENAI // UTC

            Accessible data table
            Date (UTC)Tokens

            `,1),Hs=K(`

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

            `),Us=K(`

            USAGE // ACCOUNT HISTORY

            Account-wide history reported by Codex, not the local Sessions counter. Dates + ${W(u)??``}`)},[()=>sa(W(i).fetchedAt),()=>m(W(f))]),q(e,t)},oe=e=>{var t=Cs(),n=R(t),r=L(n);let i;var o=z(r,!0),s=B(r),c=e=>{q(e,bs())};Y(s,e=>{W(a).approximate&&e(c)});var u=B(s);j(n);var d=B(n,2),p=L(d),h=B(p),g=e=>{var t=Pr();V(()=>J(t,`// Boundary tolerance ${W(a).boundary_tolerance_seconds??``}s`)),q(e,t)};Y(h,e=>{W(a).boundary_tolerance_seconds!=null&&e(g)}),j(d);var _=B(d,2),v=e=>{var t=Ss(),n=R(t),r=L(n),i=B(r);let a;var o=z(i);j(n);var s=B(n,2),c=z(s),u=B(s,2),d=e=>{q(e,xs())};Y(u,e=>{W(l).accounting_complete||e(d)}),we(2),V(e=>{J(r,`${W(l).window_minutes??``} MIN // ${W(l).plan_type??``} // `),a=ci(i,1,`svelte-1fbui7h`,null,a,{muted:W(f)==null,"quota-near":W(f)!=null&&W(f)>=80&&W(f)<100,"quota-full":W(f)!=null&&W(f)>=100}),J(o,`USED ${e??``}${W(f)==null?``:`%`}`),J(c,`${W(l).starts_at??``} → ${W(l).ends_at??``}`)},[()=>m(W(f))]),q(e,t)};Y(_,e=>{W(l)&&e(v)}),V(e=>{i=ci(r,1,`svelte-1fbui7h`,null,i,{"quality-warning":!W(a).coverage_complete}),J(o,W(a).coverage_complete?`Reported range complete`:`Partial coverage`),J(u,` // Latest fetch ${e??``}`),J(p,`Coverage starts ${(W(a).coverage_start||`unknown`)??``} // Data as of ${(W(a).data_as_of||`unknown`)??``}`)},[()=>sa(W(a).fetchedAt)]),q(e,t)},se=e=>{q(e,ws())};Y(ie,e=>{t.mode===`breakdown`&&W(i)?e(ae):t.mode===`periods`&&W(a)?e(oe,1):e(se,-1)});var ce=B(ie,2),le=e=>{var n=Es(),r=L(n),i=z(B(L(r),2),!0);j(r),Z(B(r,2),17,()=>W(d),X,(e,n,r)=>{var i=N(()=>_(W(n),2));let a=()=>W(i)[0],o=()=>W(i)[1];var s=Ts();let c;var l=L(s),u=z(l,!0),d=B(l,2),f=L(d);let h;j(d);var g=z(B(d,2));j(s),V((e,n,i)=>{c=ci(s,1,`report-row svelte-1fbui7h`,null,c,{unknown:e,alternate:r%2==1}),Q(l,`title`,a()),J(u,a()),h=ui(f,``,h,{width:n}),J(g,`${i??``}${t.mode===`periods`?`%`:``}`)},[()=>a().trim().toLowerCase()===`unknown`,()=>`${Math.max(0,100*o()/W(p))}%`,()=>m(o())]),q(e,s)}),j(n),V(()=>J(i,t.mode===`breakdown`?W(u):`QUOTA USED`)),q(e,n)},ue=e=>{q(e,Ds())},de=e=>{q(e,Os())};Y(ce,e=>{W(d).length?e(le):t.mode===`breakdown`&&W(c)?.total===0&&W(c)?.groups[W(n)]!=null?e(ue,1):(W(i)&&t.mode===`breakdown`||W(a)&&t.mode===`periods`)&&e(de,2)}),j(E),V(()=>{w.disabled=W(s)>=W(o)-1,T.disabled=W(s)===0,J(ee,W(o)?`${W(s)+1} / ${W(o)}`:`NO DATA`),J(te,t.mode===`breakdown`?`DAILY BREAKDOWN`:`QUOTA WINDOWS`),J(re,`${(t.mode===`breakdown`?t.reports?.dailyStatus||`UNAVAILABLE`:t.reports?.planStatus||`UNAVAILABLE`)??``} // UTC`)}),hi(y,()=>W(n),e=>I(n,e)),G(`click`,w,()=>I(r,W(s)+1)),G(`click`,T,()=>I(r,W(s)-1)),q(e,h),Ke()}wr([`click`]);var js=864e5;function Ms(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 Ns(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));for(let e=0;;e++){let i=Ms(r,-t),a=new Date(i.getTime()+js);if(e===n)return{start:a,end:r};r=i}}var Ps=K(``),Fs=K(``,1),Is=K(`

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

            `),Ls=K(`

            Token history unavailable; other reports may still be available.

            `),Rs=K(``),zs=K(`
            `),Bs=K(`

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

            `,1),Vs=K(`
            `,1),Hs=K(` `),Us=K(`

            LIFETIME TOKENS

            PEAK DAY

            CURRENT STREAK

            DAYS

            LONGEST TURN

            SECONDS

            LONGEST STREAK

            DAYS

            OPENAI // UTC

            Accessible data table
            Date (UTC)Tokens

            `,1),Ws=K(`

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

            `),Gs=K(`

            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 Ws(e,t){Ge(t,!0);let n=F(`daily`),r=F(12),i=F(0),a=N(()=>{let e=$.data?.usage?.dailyUsageBuckets;if(!e)return[];let{start:t,end:n}=js(new Date,W(r),W(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=N(()=>Math.max(1,...W(a).map(e=>e.tokens))),s=N(()=>W(a).length?new Date(W(a)[0].date+`T00:00:00Z`).getUTCDay():0),c=N(()=>{if(W(n)===`monthly`){let e=new Map;for(let t of W(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 W(a).map(t=>({date:t.date,tokens:e+=t.tokens}))});var l=Us(),u=B(R(l),4);Z(u,20,()=>[[`daily`,`Daily`],[`monthly`,`Monthly`],[`cumulative`,`Cumulative`],[`breakdown`,`Breakdown`],[`periods`,`Windows`]],X,(e,t)=>{var r=N(()=>_(t,2));let a=()=>W(r)[0],o=()=>W(r)[1];var s=Ms();let c;var l=z(s,!0);V(()=>{Q(s,`aria-pressed`,W(n)===a()),c=ci(s,1,``,null,c,{active:W(n)===a()}),J(l,o())}),G(`click`,s,()=>{I(n,a(),!0),I(i,0)}),q(e,s)}),j(u);var d=B(u,2),f=L(d),p=e=>{var t=Ns(),n=R(t),a=B(L(n)),o=L(a);o.value=o.__value=6;var s=B(o);s.value=s.__value=12,j(a),mi(a),j(n);var c=B(n),l=B(c);V(()=>l.disabled=W(i)===0),G(`change`,a,()=>I(i,0)),hi(a,()=>W(r),e=>I(r,e)),G(`click`,c,()=>Jt(i)),G(`click`,l,()=>Jt(i,-1)),q(e,t)};Y(f,e=>{W(n)!==`breakdown`&&W(n)!==`periods`&&e(p)}),j(d);var m=B(d,2),h=e=>{q(e,Ps())};Y(m,e=>{$.data?.usageError&&e(h)});var g=B(m,2),v=e=>{q(e,Fs())};Y(g,e=>{$.data?.usage?.tokenStatus===`UNAVAILABLE`&&W(n)!==`breakdown`&&W(n)!==`periods`&&e(v)});var y=B(g,2),b=e=>{var t=Fr();qr(R(t),()=>W(n),e=>{{let t=N(()=>$.data?.usage?.reports);Os(e,{get reports(){return W(t)},get mode(){return W(n)}})}}),q(e,t)},x=e=>{var t=Vs(),r=R(t),i=L(r),l=z(B(L(i),2),!0);j(i);var u=B(i,2),d=z(B(L(u),2),!0);j(u);var f=B(u,2),p=B(L(f),2),m=L(p);we(),j(p),j(f);var h=B(f,2),g=B(L(h),2),_=L(g);we(),j(g),j(h);var v=B(h,2),y=B(L(v),2),b=L(y);we(),j(y),j(v),j(r);var x=B(r,4),S=L(x),C=z(S),w=B(S,2),T=e=>{var t=Rs(),n=R(t),r=L(n),i=L(r);Z(i,17,()=>Array(W(s)),X,(e,t)=>{q(e,Is())}),Z(B(i,2),17,()=>W(a),X,(e,t)=>{var n=Ls();let r,i;V(e=>{r=ci(n,1,`heat-cell`,null,r,{zero:W(t).tokens===0}),Q(n,`title`,e),i=ui(n,``,i,{opacity:W(t).tokens?.25+.75*W(t).tokens/W(o):1})},[()=>`${W(t).date}: ${ia(W(t).tokens)} tokens`]),q(e,n)}),j(r),j(n),we(2),q(e,t)},ee=e=>{var t=zs(),r=R(t);{let e=N(()=>W(c).map(e=>e.tokens)),t=N(()=>W(n)+` usage`);qa(r,{get values(){return W(e)},get label(){return W(t)}})}var i=B(r,2),a=L(i),o=z(a,!0),s=z(B(a),!0);j(i),V(e=>{J(o,W(c)[0]?.date),J(s,e)},[()=>W(c).at(-1)?.date]),q(e,t)};Y(w,e=>{W(n)===`daily`?e(T):e(ee,-1)});var E=B(w,2),D=B(L(E),2),te=L(D),ne=B(L(te));Z(ne,21,()=>W(n)===`daily`?W(a):W(c),X,(e,t)=>{var n=Bs(),r=L(n),i=z(r,!0),a=z(B(r),!0);j(n),V(e=>{J(i,W(t).date),J(a,e)},[()=>ia(W(t).tokens)]),q(e,n)}),j(ne),j(te),j(D),j(E),j(x);var re=z(B(x,2));V((e,t,n,r,i,o,s)=>{J(l,e),J(d,t),J(m,`${n??``} `),J(_,`${r??``} `),J(b,`${i??``} `),J(C,`${W(a)[0]?.date??``} — ${o??``}`),J(re,`OBSERVED ${s??``} // CUMULATIVE IS FOR THE SELECTED PERIOD`)},[()=>ia($.data.usage.summary.lifetimeTokens),()=>ia($.data.usage.summary.peakDailyTokens),()=>ia($.data.usage.summary.currentStreakDays),()=>ia($.data.usage.summary.longestRunningTurnSec),()=>ia($.data.usage.summary.longestStreakDays),()=>W(a).at(-1)?.date,()=>aa($.data.usageAt)]),q(e,t)},S=e=>{q(e,Hs())};Y(y,e=>{W(n)===`breakdown`||W(n)===`periods`?e(b):$.data?.usage&&$.data.usage.dailyUsageBuckets!==null?e(x,1):e(S,-1)}),q(e,l),Ke()}wr([`click`,`change`]);var Gs=K(`

            Page not found

            Return to Quota

            `,1);function Ks(e){var t=Gs();we(2),q(e,t)}var qs=K(` `),Js=K(`

            `),Ys=K(`

            Connecting to your local Codexometer…

            `),Xs=K(``),Zs=K(`
            CODEXOMETER

            Your quota. Your sessions. Your command centre.

            `);function Qs(e,t){Ge(t,!0);let n={"/":Wa,"/quota/:view?":Wa,"/sessions/:id?":hs,"/usage":Ws,"*":Ks},r={quota:/^(?:\/|\/quota(?:\/[^/]+)?\/?)$/,sessions:/^\/sessions(?:\/[^/]+)?\/?$/,usage:/^\/usage\/?$/},i=F(`hacker`),a=[`hacker`,`rust`,`blue-steel`,`ultraviolet`,`nightshade`];bn(()=>{$i()}),bn(()=>{if($.data)for(let[e,t]of Object.entries(r))t.test(Wi.location)&&(Qi.tab=e)}),Vi(()=>{try{let e=localStorage.getItem(`codexometer.web.theme`);e&&a.includes(e)&&I(i,e,!0)}catch{}return ua()});function o(){try{localStorage.setItem(`codexometer.web.theme`,W(i))}catch{}}var s=Zs(),c=L(s),l=B(L(c),2),u=L(l);let d;var f=B(u,1,!0),p=z(B(f));j(l),j(c);var m=B(c,2);Z(m,21,()=>Object.entries(r),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1],a=N(()=>i().test(Wi.location));var o=qs();let s;var c=z(o,!0);V(e=>{Q(o,`href`,r()===`quota`?`#/quota/`+Qi.view:`#/`+r()),Q(o,`aria-current`,W(a)?`page`:void 0),s=ci(o,1,``,null,s,{active:W(a)}),J(c,e)},[()=>r().toUpperCase()]),q(e,o)}),j(m);var h=B(m,2),g=L(h),v=e=>{var t=Js(),n=z(t,!0);V(()=>J(n,$.error)),q(e,t)};Y(g,e=>{$.error&&e(v)});var y=B(g,2),b=e=>{qi(e,{get routes(){return n}})},x=e=>{q(e,Ys())};Y(y,e=>{$.data?e(b):$.error||e(x,1)}),j(h);var S=B(h,2),C=L(S),w=z(C),T=B(C,2),ee=z(T,!0),E=B(T,2),D=B(L(E));Z(D,21,()=>a,X,(e,t)=>{var n=Xs(),r=z(n,!0),i={};V(e=>{J(r,e),i!==(i=W(t))&&(n.value=(n.__value=i)??``)},[()=>W(t).replace(`-`,` `).toUpperCase()]),q(e,n)}),j(D),mi(D),j(E),j(S),j(s),V(()=>{Q(s,`data-theme`,W(i)),d=ci(u,1,`lamp`,null,d,{lit:$.connected}),J(f,$.connected?`CONNECTED`:`OFFLINE`),J(p,`EXPERIMENTAL // ${$.data?.control?`SESSION CONTROL`:`READ ONLY`}`),J(w,`v${($.data?.version||`…`)??``} // LOCAL ONLY`),J(ee,$.data?.control?`Session control enabled. Stop the server to revoke access.`:`No actions can be sent from this preview.`)}),G(`change`,D,o),hi(D,()=>W(i),e=>I(i,e)),q(e,s),Ke()}wr([`change`]),Vr(Qs,{target:document.getElementById(`app`)}); \ No newline at end of file + not provided.

            `,1);function Ks(e,t){Ge(t,!0);let n=F(`daily`),r=F(12),i=F(0),a=N(()=>{let e=$.data?.usage?.dailyUsageBuckets;if(!e)return[];let{start:t,end:n}=Ns(new Date,W(r),W(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=N(()=>Math.max(1,...W(a).map(e=>e.tokens))),s=N(()=>W(a).length?new Date(W(a)[0].date+`T00:00:00Z`).getUTCDay():0),c=N(()=>{if(W(n)===`monthly`){let e=new Map;for(let t of W(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 W(a).map(t=>({date:t.date,tokens:e+=t.tokens}))});var l=Gs(),u=B(R(l),4);Z(u,20,()=>[[`daily`,`Daily`],[`monthly`,`Monthly`],[`cumulative`,`Cumulative`],[`breakdown`,`Breakdown`],[`periods`,`Windows`]],X,(e,t)=>{var r=N(()=>_(t,2));let a=()=>W(r)[0],o=()=>W(r)[1];var s=Ps();let c;var l=z(s,!0);V(()=>{Q(s,`aria-pressed`,W(n)===a()),c=ci(s,1,``,null,c,{active:W(n)===a()}),J(l,o())}),G(`click`,s,()=>{I(n,a(),!0),I(i,0)}),q(e,s)}),j(u);var d=B(u,2),f=L(d),p=e=>{var t=Fs(),n=R(t),a=B(L(n)),o=L(a);o.value=o.__value=6;var s=B(o);s.value=s.__value=12,j(a),mi(a),j(n);var c=B(n),l=B(c);V(()=>l.disabled=W(i)===0),G(`change`,a,()=>I(i,0)),hi(a,()=>W(r),e=>I(r,e)),G(`click`,c,()=>Jt(i)),G(`click`,l,()=>Jt(i,-1)),q(e,t)};Y(f,e=>{W(n)!==`breakdown`&&W(n)!==`periods`&&e(p)}),j(d);var m=B(d,2),h=e=>{q(e,Is())};Y(m,e=>{$.data?.usageError&&e(h)});var g=B(m,2),v=e=>{q(e,Ls())};Y(g,e=>{$.data?.usage?.tokenStatus===`UNAVAILABLE`&&W(n)!==`breakdown`&&W(n)!==`periods`&&e(v)});var y=B(g,2),b=e=>{var t=Fr();qr(R(t),()=>W(n),e=>{{let t=N(()=>$.data?.usage?.reports);As(e,{get reports(){return W(t)},get mode(){return W(n)}})}}),q(e,t)},x=e=>{var t=Us(),r=R(t),i=L(r),l=z(B(L(i),2),!0);j(i);var u=B(i,2),d=z(B(L(u),2),!0);j(u);var f=B(u,2),p=B(L(f),2),m=L(p);we(),j(p),j(f);var h=B(f,2),g=B(L(h),2),_=L(g);we(),j(g),j(h);var v=B(h,2),y=B(L(v),2),b=L(y);we(),j(y),j(v),j(r);var x=B(r,4),S=L(x),C=z(S),w=B(S,2),T=e=>{var t=Bs(),n=R(t),r=L(n),i=L(r);Z(i,17,()=>Array(W(s)),X,(e,t)=>{q(e,Rs())}),Z(B(i,2),17,()=>W(a),X,(e,t)=>{var n=zs();let r,i;V(e=>{r=ci(n,1,`heat-cell`,null,r,{zero:W(t).tokens===0}),Q(n,`title`,e),i=ui(n,``,i,{opacity:W(t).tokens?.25+.75*W(t).tokens/W(o):1})},[()=>`${W(t).date}: ${oa(W(t).tokens)} tokens`]),q(e,n)}),j(r),j(n),we(2),q(e,t)},ee=e=>{var t=Vs(),r=R(t);{let e=N(()=>W(c).map(e=>e.tokens)),t=N(()=>W(n)+` usage`);Ya(r,{get values(){return W(e)},get label(){return W(t)}})}var i=B(r,2),a=L(i),o=z(a,!0),s=z(B(a),!0);j(i),V(e=>{J(o,W(c)[0]?.date),J(s,e)},[()=>W(c).at(-1)?.date]),q(e,t)};Y(w,e=>{W(n)===`daily`?e(T):e(ee,-1)});var E=B(w,2),D=B(L(E),2),te=L(D),ne=B(L(te));Z(ne,21,()=>W(n)===`daily`?W(a):W(c),X,(e,t)=>{var n=Hs(),r=L(n),i=z(r,!0),a=z(B(r),!0);j(n),V(e=>{J(i,W(t).date),J(a,e)},[()=>oa(W(t).tokens)]),q(e,n)}),j(ne),j(te),j(D),j(E),j(x);var re=z(B(x,2));V((e,t,n,r,i,o,s)=>{J(l,e),J(d,t),J(m,`${n??``} `),J(_,`${r??``} `),J(b,`${i??``} `),J(C,`${W(a)[0]?.date??``} — ${o??``}`),J(re,`OBSERVED ${s??``} // CUMULATIVE IS FOR THE SELECTED PERIOD`)},[()=>oa($.data.usage.summary.lifetimeTokens),()=>oa($.data.usage.summary.peakDailyTokens),()=>oa($.data.usage.summary.currentStreakDays),()=>oa($.data.usage.summary.longestRunningTurnSec),()=>oa($.data.usage.summary.longestStreakDays),()=>W(a).at(-1)?.date,()=>sa($.data.usageAt)]),q(e,t)},S=e=>{q(e,Ws())};Y(y,e=>{W(n)===`breakdown`||W(n)===`periods`?e(b):$.data?.usage&&$.data.usage.dailyUsageBuckets!==null?e(x,1):e(S,-1)}),q(e,l),Ke()}wr([`click`,`change`]);var qs=K(`

            Page not found

            Return to Quota

            `,1);function Js(e){var t=qs();we(2),q(e,t)}var Ys=K(` `),Xs=K(`

            `),Zs=K(`

            Connecting to your local Codexometer…

            `),Qs=K(``),$s=K(`
            CODEXOMETER

            Your quota. Your sessions. Your command centre.

            `);function ec(e,t){Ge(t,!0);let n={"/":Ka,"/quota/:view?":Ka,"/sessions/:id?":_s,"/usage":Ks,"*":Js},r={quota:/^(?:\/|\/quota(?:\/[^/]+)?\/?)$/,sessions:/^\/sessions(?:\/[^/]+)?\/?$/,usage:/^\/usage\/?$/},i=F(`hacker`),a=[`hacker`,`rust`,`blue-steel`,`ultraviolet`,`nightshade`];bn(()=>{ta()}),bn(()=>{if($.data)for(let[e,t]of Object.entries(r))t.test(Ki.location)&&(ea.tab=e)}),Ui(()=>{try{let e=localStorage.getItem(`codexometer.web.theme`);e&&a.includes(e)&&I(i,e,!0)}catch{}return fa()});function o(){try{localStorage.setItem(`codexometer.web.theme`,W(i))}catch{}}var s=$s(),c=L(s),l=B(L(c),2),u=L(l);let d;var f=B(u,1,!0),p=z(B(f));j(l),j(c);var m=B(c,2);Z(m,21,()=>Object.entries(r),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1],a=N(()=>i().test(Ki.location));var o=Ys();let s;var c=z(o,!0);V(e=>{Q(o,`href`,r()===`quota`?`#/quota/`+ea.view:`#/`+r()),Q(o,`aria-current`,W(a)?`page`:void 0),s=ci(o,1,``,null,s,{active:W(a)}),J(c,e)},[()=>r().toUpperCase()]),q(e,o)}),j(m);var h=B(m,2),g=L(h),v=e=>{var t=Xs(),n=z(t,!0);V(()=>J(n,$.error)),q(e,t)};Y(g,e=>{$.error&&e(v)});var y=B(g,2),b=e=>{Yi(e,{get routes(){return n}})},x=e=>{q(e,Zs())};Y(y,e=>{$.data?e(b):$.error||e(x,1)}),j(h);var S=B(h,2),C=L(S),w=z(C),T=B(C,2),ee=z(T,!0),E=B(T,2),D=B(L(E));Z(D,21,()=>a,X,(e,t)=>{var n=Qs(),r=z(n,!0),i={};V(e=>{J(r,e),i!==(i=W(t))&&(n.value=(n.__value=i)??``)},[()=>W(t).replace(`-`,` `).toUpperCase()]),q(e,n)}),j(D),mi(D),j(E),j(S),j(s),V(()=>{Q(s,`data-theme`,W(i)),d=ci(u,1,`lamp`,null,d,{lit:$.connected}),J(f,$.connected?`CONNECTED`:`OFFLINE`),J(p,`EXPERIMENTAL // ${$.data?.control?`SESSION CONTROL`:`READ ONLY`}`),J(w,`v${($.data?.version||`…`)??``} // LOCAL ONLY`),J(ee,$.data?.control?`Session control enabled. Stop the server to revoke access.`:`No actions can be sent from this preview.`)}),G(`change`,D,o),hi(D,()=>W(i),e=>I(i,e)),q(e,s),Ke()}wr([`change`]),Vr(ec,{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 d2e67e2..a7227f2 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/schedules.go b/internal/web/schedules.go index eed4efc..82a67aa 100644 --- a/internal/web/schedules.go +++ b/internal/web/schedules.go @@ -144,7 +144,7 @@ func (c *control) dispatchSchedules(ctx context.Context) { _ = c.schedules.Dispatch(call, j.ID, q.AccountFingerprint, true, time.Now(), func(ctx context.Context, j schedule.Job) error { latest := c.scheduleSnapshot() if latest.AccountFingerprint != q.AccountFingerprint || !schedule.QuotaReady(latest, time.Now()) || !schedule.Covers(j, latest) || c.scheduleBlocked(j.Session) { - return errUnavailable + return schedule.ErrDeferred } return c.prompts.SendSessionPrompt(ctx, o.token, []string{j.Text}) }) diff --git a/internal/web/schedules_test.go b/internal/web/schedules_test.go index 2f2b64f..3be0dce 100644 --- a/internal/web/schedules_test.go +++ b/internal/web/schedules_test.go @@ -118,3 +118,38 @@ func TestScheduleSendNowRejectsExhaustedQuota(t *testing.T) { t.Fatal("quota bypassed", w.Code) } } + +type preflightPromptSource struct { + *actionSource + beforeReturn func() +} + +func (f *preflightPromptSource) SessionPrompt(thread string) codex.SessionPromptOffer { + o := f.actionSource.SessionPrompt(thread) + if f.beforeReturn != nil { + f.beforeReturn() + } + return o +} + +func TestSchedulerDefersWhenQuotaChangesBeforeSend(t *testing.T) { + s, f, _ := controlServer(t) + s.store.contexts["parent"] = codex.SessionContext{Kind: codex.SessionContextReply} + f.prompt = codex.SessionPromptOffer{ThreadID: "parent", Token: "idle"} + s.store.scheduleQuota = codex.Snapshot{AccountFingerprint: "a", FetchedAt: time.Now(), RateLimits: codex.RateLimitSnapshot{Primary: &codex.Window{UsedPercent: 0}}} + if err := s.control.schedules.Save(schedule.Job{Session: "parent", Text: "later", Trigger: "quota"}, "a", time.Now()); err != nil { + t.Fatal(err) + } + p := &preflightPromptSource{actionSource: f, beforeReturn: func() { s.store.scheduleQuota.RateLimits.Primary.UsedPercent = 100 }} + s.control.prompts = p + s.control.dispatchSchedules(context.Background()) + if f.calls != 0 || s.control.schedules.List("parent")[0].Status != "pending" { + t.Fatal("preflight deferral dispatched or became uncertain") + } + p.beforeReturn = nil + s.store.scheduleQuota.RateLimits.Primary.UsedPercent = 0 + s.control.dispatchSchedules(context.Background()) + if f.calls != 1 { + t.Fatal("deferred request did not recover") + } +} diff --git a/web/src/SessionActions.svelte b/web/src/SessionActions.svelte index 2856b38..611b4b6 100644 --- a/web/src/SessionActions.svelte +++ b/web/src/SessionActions.svelte @@ -1,5 +1,5 @@ + diff --git a/internal/web/schedules.go b/internal/web/schedules.go index 82a67aa..a205256 100644 --- a/internal/web/schedules.go +++ b/internal/web/schedules.go @@ -78,13 +78,31 @@ func (c *control) handleSchedules(w http.ResponseWriter, r *http.Request, b acti w.Header().Set("Content-Type", "application/json") type visibleJob struct { schedule.Job - CanSend bool `json:"canSend"` + CanSend bool `json:"canSend"` + WaitingReason string `json:"waitingReason"` } jobs := []visibleJob{} o, _ := c.offer(b.Session) for _, j := range c.schedules.List(b.Session) { _, ready := c.sendNowJob(b.Session, j.ID) - jobs = append(jobs, visibleJob{j, ready && o.Kind == "prompt" && o.Thread == b.Session && len(o.Questions) == 0 && o.ID != ""}) + canSend := ready && o.Kind == "prompt" && o.Thread == b.Session && len(o.Questions) == 0 && o.ID != "" + reason := "waiting for an eligible idle session" + q, now := c.scheduleSnapshot(), time.Now() + switch { + case !schedule.Fresh(q, now): + reason = "waiting for fresh quota" + case !j.MatchesAccount(q.AccountFingerprint): + reason = "waiting for the original account" + case !schedule.Covers(j, q): + reason = "waiting for observed quota windows" + case !schedule.QuotaReady(q, now): + reason = "waiting for quota" + case c.scheduleBlocked(j.Session): + reason = "waiting for profile review or verification" + case canSend: + reason = "ready; awaiting dispatch" + } + jobs = append(jobs, visibleJob{j, canSend, reason}) } _ = json.NewEncoder(w).Encode(jobs) } diff --git a/internal/web/schedules_test.go b/internal/web/schedules_test.go index 3be0dce..9d25ab1 100644 --- a/internal/web/schedules_test.go +++ b/internal/web/schedules_test.go @@ -2,12 +2,40 @@ package web import ( "context" + "encoding/json" "github.com/merefield/codexometer/internal/codex" "github.com/merefield/codexometer/internal/schedule" "testing" "time" ) +func TestScheduleWaitingReasons(t *testing.T) { + s, f, token := controlServer(t) + s.store.contexts["parent"] = codex.SessionContext{Kind: codex.SessionContextReply} + f.prompt = codex.SessionPromptOffer{ThreadID: "parent", Token: "idle"} + s.store.scheduleQuota = codex.Snapshot{AccountFingerprint: "a", FetchedAt: time.Now(), RateLimits: codex.RateLimitSnapshot{Primary: &codex.Window{UsedPercent: 100}}} + if err := s.control.schedules.Save(schedule.Job{Session: "parent", Text: "Later", Trigger: "quota"}, "a", time.Now()); err != nil { + t.Fatal(err) + } + check := func(want string, ready bool) { + t.Helper() + w := actionCall(s, token, "schedules", actionRequest{Session: "parent"}) + var jobs []struct { + WaitingReason string `json:"waitingReason"` + CanSend bool `json:"canSend"` + } + if w.Code != 200 || json.Unmarshal(w.Body.Bytes(), &jobs) != nil || len(jobs) != 1 || jobs[0].WaitingReason != want || jobs[0].CanSend != ready { + t.Fatalf("unexpected readiness: %s", w.Body) + } + } + check("waiting for quota", false) + s.store.scheduleQuota.FetchedAt = time.Now().Add(-time.Hour) + check("waiting for fresh quota", false) + s.store.scheduleQuota.FetchedAt = time.Now() + s.store.scheduleQuota.RateLimits.Primary.UsedPercent = 0 + check("ready; awaiting dispatch", true) +} + func TestSchedulePrepareCommitDispatchAndCancel(t *testing.T) { s, f, token := controlServer(t) s.store.contexts["parent"] = codex.SessionContext{Kind: codex.SessionContextReply} diff --git a/web/src/SessionActions.svelte b/web/src/SessionActions.svelte index 611b4b6..df4e7df 100644 --- a/web/src/SessionActions.svelte +++ b/web/src/SessionActions.svelte @@ -61,6 +61,7 @@ at: string; status: string; canSend?: boolean; + waitingReason?: string; } let jobs = $state([]); let pending = $derived(jobs.find((j) => j.status !== 'sent')); @@ -186,6 +187,39 @@ questions[index].options?.includes(a)), ), ); + let scheduling = $derived( + offer?.kind === 'prompt' && !offer.questions?.length && timing !== 'now', + ); + let targetTime = $derived( + timing === 'delay' ? now + delay * 60000 : Date.parse(dateTime), + ); + let scheduleError = $derived.by(() => { + if (!scheduling) return ''; + if (!answers[0]?.trim()) return 'Enter a message to schedule.'; + if (timing === 'quota') return ''; + if (!Number.isFinite(targetTime) || targetTime <= now) + return 'Choose a future date/time or a delay greater than zero.'; + const limit = new Date(now); + limit.setFullYear(limit.getFullYear() + 1); + return targetTime >= limit.getTime() + ? 'Choose a time within one year.' + : ''; + }); + function localTime(value: number | string) { + return new Date(value).toLocaleString([], { timeZoneName: 'short' }); + } + function waitingText(job: Job) { + if (job.status !== 'pending') return job.status; + if (job.trigger === 'at' && Date.parse(job.at) > now) + return 'Due in ' + Math.ceil((Date.parse(job.at) - now) / 60000) + ' min'; + const reason = stale + ? 'waiting for a fresh connection' + : job.waitingReason || + (job.canSend + ? 'ready; awaiting dispatch' + : 'waiting for quota and an eligible idle session'); + return (job.trigger === 'at' ? 'Time reached — ' : '') + reason; + } $effect(() => { if (stale || suspended || followUpBlocked || now >= expires) confirmation = ''; @@ -203,12 +237,7 @@ editJob(pending); } }; - const edit = (event: Event) => { - if ((event as CustomEvent).detail === session && !review && pending) - editJob(pending); - }; window.addEventListener('keydown', key); - window.addEventListener('edit-trigger', edit); let timer: ReturnType; const clock = setInterval(() => { now = Date.now(); @@ -246,7 +275,6 @@ void poll(); return () => { window.removeEventListener('keydown', key); - window.removeEventListener('edit-trigger', edit); controller.abort(); clearTimeout(timer); clearInterval(clock); @@ -259,7 +287,7 @@ stale || suspended || followUpBlocked || - (job ? !job.canSend : !valid) + (job ? !job.canSend : !valid || !!scheduleError) ) return; const id = offer.id; @@ -291,7 +319,8 @@ triggerDescription = schedule ? schedule.trigger === 'quota' ? 'After fresh quota becomes available, when the session is idle' - : new Date(schedule.at!).toLocaleString() + ' — when idle' + : localTime(schedule.at!) + + ' — not before this time; when quota and idle allow' : ''; const result = await controlRequest<{ confirmation: string; @@ -388,9 +417,9 @@

            {job.trigger === 'quota' ? 'After confirmed quota recovery, when idle' - : `Not before ${new Date(job.at).toLocaleString([], { timeZoneName: 'short' })} // ${Date.parse(job.at) > now ? 'in ' + Math.ceil((Date.parse(job.at) - now) / 60000) + ' min' : 'due — waiting for quota and an eligible idle session'}`} - // {job.status} + : `Not before ${localTime(job.at)}`}

            +

            {waitingText(job)}

            {job.text}
            {#if notice}

            {notice}

            {/if}

            @@ -495,7 +524,9 @@ {offer.kind === 'approval' || offer.kind === 'profile' ? 'Choose a decision' - : 'Reply to this session'} {#if offer.kind === 'approval' || offer.kind === 'profile'} {#each offer.choices || [] as option, index} @@ -540,7 +571,18 @@ bind:value={dateTime} />{/if} - {#if timing !== 'now'}

            + {#if timing !== 'now'} +

            + Will send: {timing === 'quota' + ? 'when quota is available and this session is idle' + : Number.isFinite(targetTime) + ? localTime(targetTime) + : 'choose a date and time'} +

            + {#if timing !== 'quota'}

            + Not before this time; when quota and idle allow. +

            {/if} +

            Timezone: {Intl.DateTimeFormat().resolvedOptions().timeZone}. One pending request per session; saving replaces it. Memory only; Codexometer must stay running. Uses session model, @@ -611,7 +653,9 @@ >CONFIRM {offer.kind === 'approval' || offer.kind === 'profile' ? offer.choices?.[choice!]?.label : scheduled - ? 'SCHEDULE' + ? editing + ? 'SAVE CHANGES' + : 'SCHEDULE' : 'SEND'} {:else} - {scheduleError}

            {/if} + {/if} {#if editing}

            `),as=K(``),os=K(`TRIGGER SET`),ss=K(`

            `),cs=K(` `),ls=K(`

            `),us=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),ds=K(` `,1),fs=K(`

            `),ps=K(`

            TOKEN ACTIVITY // 30 SECOND SAMPLES

            `),ms=K(`

            TOKENS

            FULL DETAIL →
            `),hs=K(`

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

            `),gs=K(`

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

            `,1),_s=K(`

            SESSION TOTALS

            `,1);function vs(e,t){Ge(t,!0);let n=(e,t=f,n,r)=>{let i=ht(()=>g(n?.(),!0)),a=ht(()=>g(r?.(),!1));var o=Wo(),s=R(o),c=e=>{var n=Fo(),r=z(B(R(n),2),!0);we(2),V(()=>J(r,t().approvalContext)),q(e,n)};Y(s,e=>{W(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(c)});var l=B(s,2),u=e=>{var n=Io();let r;var i=z(n,!0);V(e=>{r=ci(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),J(i,e)},[()=>S(t())]),q(e,n)},d=N(()=>S(t())&&(!W(a)||W(m)||t().status===`CHECK SESSION`));Y(l,e=>{W(d)&&e(u)});var p=B(l,2),h=e=>{var n=Lo(),r=z(n,!0);V(()=>J(r,t().contextKind||`LAST ACTIVITY`)),q(e,n)};Y(p,e=>{W(i)&&e(h)});var _=B(p,2),v=e=>{var n=Ro(),r=z(n,!0);V(()=>J(r,t().text||`No session context available.`)),q(e,n)};Y(_,e=>{(t().text||!t().workingCommand)&&e(v)});var y=B(_,2),b=e=>{var n=zo(),r=B(R(n),2),i=L(r),a=B(i),o=e=>{var n=Pr();V(()=>J(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),q(e,n)};Y(a,e=>{!W(m)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(o)});var s=B(a,2),c=e=>{q(e,Pr(`+`))};Y(s,e=>{t().runningLimited&&e(c)}),j(r);var l=z(B(r,2),!0);V(e=>{J(i,`COMMAND // ${e??``} `),J(l,t().workingCommand)},[()=>W(m)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),q(e,n)};Y(y,e=>{t().workingCommand&&e(b)});var x=B(y,2),C=e=>{var n=Ho(),r=B(R(n),2),i=z(r,!0),a=B(r,2),o=e=>{var n=Bo(),r=z(n,!0);V(()=>J(r,t().command)),q(e,n)},s=e=>{q(e,Vo())};Y(a,e=>{t().command?e(o):e(s,-1)}),V(()=>J(i,W(m)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),q(e,n)};Y(x,e=>{(!W(a)||!$.data?.control)&&(t().command||t().status===`APPROVAL NEEDED`)&&e(C)});var w=B(x,2),T=e=>{var n=Uo(),r=z(n);V(()=>J(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),q(e,n)};Y(w,e=>{W(a)||e(T)}),q(e,o)},r=Hi(t,`params`,19,()=>({})),i=N(()=>$.data?.sessions||[]),a=N(()=>$.data?.control&&$.data.profiles||[]),o=N(()=>($.data?.triggers||[]).filter(e=>W(i).some(t=>t.id===e.session)));function s(e,t){if(r().id&&r().id!==t&&W(c)){e.preventDefault();return}y(t)}let c=F(!1);function l(e,t){if(r().id&&r().id!==t&&W(c)){e.preventDefault();return}y(t)}bn(()=>{let e=r().id;e&&mr(()=>{ea.selected=e,aa(e,2)})});let u=N(()=>W(i).find(e=>e.id===r().id)),d=N(()=>new URLSearchParams(Ki.querystring).get(`review`)===`profile`&&W(a).some(e=>e.session===r().id&&e.pending)),p=N(()=>W(i).some(e=>e.id===ea.selected)?ea.selected:W(i)[0]?.id),m=N(()=>!$.connected||!!$.data?.sessionsError),h=N(()=>[[`OBSERVED TOKENS`,oa(W(i).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,oa(W(i).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,W(m)?`—`:oa(W(i).filter(e=>e.status===t).length)])]),v=N(()=>W(i).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`,`CHECK SESSION`].includes(e.status)));function y(e){ea.selected=e,dr().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function b(e,t){if(y(e),r().id){t<0&&(aa(e,2),location.hash=`/sessions`);return}let n=ra(e)+t;n>2?location.hash=`/sessions/`+encodeURIComponent(e):aa(e,n)}function x(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`&&r().id)e.preventDefault(),b(r().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(r().id||W(p)))e.preventDefault(),b(r().id||W(p),e.key===`ArrowLeft`?-1:1);else if(!r().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&W(i).length){e.preventDefault();let t=W(i).findIndex(e=>e.id===W(p));y(W(i)[Math.max(0,Math.min(W(i).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function S(e){return W(m)?`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.`:$.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.`:``}var C=_s();Cr(`keydown`,en,x);var w=R(C),T=z(B(L(w),2));j(w);var ee=B(w,2);let E;Z(ee,21,()=>W(h),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1];var a=Go(),o=L(a),s=z(o,!0),c=z(B(o,2),!0);j(a),V(()=>{J(s,r()),J(c,i())}),q(e,a)}),j(ee);var D=B(ee,2),te=z(D),ne=B(D,2),re=e=>{q(e,Ko())};Y(ne,e=>{W(m)&&e(re)});var ie=B(ne,2),ae=e=>{q(e,qo())};Y(ie,e=>{$.data?.profileError&&e(ae)});var oe=B(ie,2),se=e=>{var t=Zo(),n=L(t);Z(n,17,()=>W(v),X,(e,t)=>{var n=Jo();let r;var i=z(n);V((e,a)=>{r=ci(n,1,`button`,null,r,{approval:W(t).status===`APPROVAL NEEDED`}),Q(n,`href`,e),J(i,`${W(t).status??``} - ${a??``} // ${(W(t).name||W(t).directory||W(t).id)??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,n,()=>y(W(t).id)),q(e,n)});var u=B(n,2);Z(u,17,()=>W(a).filter(e=>e.pending&&W(i).some(t=>t.id===e.session)),X,(e,t)=>{var n=Yo(),a=z(n);V((e,i,o)=>{Q(n,`title`,r().id&&r().id!==W(t).session&&W(c)?`Finish sending or clear your current draft before switching sessions.`:`Review this session’s quota threshold`),Q(n,`href`,e),J(a,`QUOTA THRESHOLD ${i??``} // ${o??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session)+`?review=profile`,()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory||W(t).session]),G(`click`,n,e=>l(e,W(t).session)),q(e,n)}),Z(B(u,2),17,()=>W(o),X,(e,t)=>{var n=Xo(),r=z(n);V((e,t,i)=>{Q(n,`href`,e),J(r,`TRIGGER SET ${t??``} // ${i??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session),()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory]),G(`click`,n,e=>s(e,W(t).session)),q(e,n)}),j(t),q(e,t)},ce=N(()=>(W(v).length||W(a).some(e=>e.pending)||W(o).length)&&!W(m));Y(oe,e=>{W(ce)&&e(se)});var le=B(oe,2),ue=e=>{var t=Fr(),i=R(t),o=e=>{var t=ns(),i=L(t),o=L(i),s=L(o);let l;var f=B(s);j(o);var p=B(o,2);j(i);var h=B(i,2),g=e=>{var t=Uo(),n=z(t,!0);V(()=>J(n,W(u).directory)),q(e,t)};Y(h,e=>{W(u).name&&W(u).directory&&e(g)});var _=B(h,2),v=z(_),b=B(_,2);let x;var S=L(b),C=L(S);n(C,()=>W(u),()=>!0,()=>!0),j(S);var w=B(S,2),T=e=>{var t=Fr();qr(R(t),()=>W(u).id,e=>{{let t=N(()=>new URLSearchParams(Ki.querystring).get(`schedule`)===`edit`);Mo(e,{get session(){return W(u).id},get openScheduler(){return W(t)},get observedCommand(){return W(u).command},get suspended(){return W(d)},onProtectedChange:e=>{I(c,e,!0)}})}}),q(e,t)},ee=e=>{q(e,Qo())};Y(w,e=>{$.data?.control?e(T):e(ee,-1)}),j(b);var E=B(b,2);Z(E,17,()=>W(a).filter(e=>e.session===W(u).id),e=>e.session,(e,t)=>{var n=ts(),r=L(n),i=e=>{var n=$o(),r=z(n,!0);V(()=>J(r,W(t).notice)),q(e,n)};Y(r,e=>{W(t).notice&&e(i)});var a=B(r,2),o=e=>{Mo(e,{get session(){return W(u).id},review:`profile`})},s=e=>{var t=es();V(e=>Q(t,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(u).id)+`?review=profile`]),q(e,t)};Y(a,e=>{W(t).pending&&W(d)?e(o):W(t).pending&&e(s,1)}),j(n),V(()=>Q(n,`id`,`quota-profile-`+W(u).id)),q(e,n)});var D=B(E,2),te=e=>{var t=Fr();qr(R(t),()=>W(u).id,e=>{Po(e,{get session(){return W(u)},active:!0})}),q(e,t)};Y(D,e=>{W(d)||e(te)}),j(t),V(e=>{l=ci(s,1,`lamp lit`,null,l,{working:W(u).status===`WORKING`&&!W(m)}),J(f,`${(W(m)?`STALE`:W(d)?`QUOTA THRESHOLD`:W(u).status)??``} // ${(W(u).name||W(u).directory)??``}`),J(v,`${e??``} TOKENS // ${W(u).id??``} // CONTEXT SOURCE // ${(W(u).source||`LOCAL`)??``}`),x=ui(b,``,x,{display:W(d)?`none`:void 0})},[()=>oa(W(u).tokens)]),G(`click`,p,()=>{y(r().id),aa(r().id,2)}),q(e,t)},s=e=>{q(e,rs())};Y(i,e=>{W(u)?e(o):e(s,-1)}),q(e,t)},de=e=>{var t=gs(),r=R(t),o=B(L(r),2),c=L(o),u=B(c,2);j(o),j(r);var d=B(r,2);Z(d,17,()=>W(i),e=>e.id,(e,t)=>{let r=N(()=>ra(W(t).id));var i=ms();let o;var c=L(i),u=L(c),d=e=>{var n=is(),r=L(n),i=z(r);j(n),V(e=>{Q(r,`aria-pressed`,W(p)===W(t).id),J(i,`${e??``} // ${W(t).name??``}`)},[()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,r,()=>y(W(t).id)),q(e,n)};Y(u,e=>{W(t).name&&e(d)});var f=B(u,2),h=L(f),g=L(h);let _;var v=B(g,1,!0);j(h),j(f);var x=B(f,2),S=e=>{var n=as(),r=z(n,!0);V(()=>{Q(n,`aria-pressed`,W(p)===W(t).id),J(r,W(t).directory||W(t).id)}),G(`click`,n,()=>y(W(t).id)),q(e,n)};Y(x,e=>{W(t).name||e(S)});var C=B(x,2),w=L(C);we(),j(C);var T=B(C,2),ee=e=>{var n=os();V(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(t).id)]),G(`click`,n,e=>s(e,W(t).id)),q(e,n)},E=N(()=>$.data?.triggers?.some(e=>e.session===W(t).id));Y(T,e=>{W(E)&&e(ee)});var D=B(T,2),te=e=>{var n=Uo(),r=z(n,!0);V(()=>J(r,W(t).directory)),q(e,n)};Y(D,e=>{W(t).name&&W(t).directory&&e(te)});var ne=B(D,2),re=z(ne),ie=B(ne,2),ae=z(ie),oe=B(ie,2),se=L(oe),ce=B(se,2),le=z(ce,!0),ue=B(ce,2);j(oe);var de=B(oe,2),fe=B(de,2),pe=e=>{var n=ss(),r=z(n,!0);V(()=>J(r,W(t).status===`CHECK SESSION`?`INFERRED INACTIVITY`:$.data?.control?`OPEN FULL DETAIL OR REPLY IN CODEX`:W(t).status===`APPROVAL NEEDED`?`APPROVE OR DECLINE IN CODEX`:`REPLY IN CODEX`)),q(e,n)},me=N(()=>!W(m)&&[`APPROVAL NEEDED`,`INPUT NEEDED`,`CHECK SESSION`].includes(W(t).status));Y(fe,e=>{W(me)&&e(pe)}),j(c);var he=B(c,2),O=e=>{var r=fs(),i=L(r),o=L(i),s=z(o,!0),c=B(o,2),u=e=>{var n=cs(),r=z(n,!0);V(e=>{Q(n,`href`,e),J(r,$.data?.control?`REVIEW IN FULL DETAIL ↗`:`APPROVAL IN CODEX ↗`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id)]),q(e,n)};Y(c,e=>{!W(m)&&W(t).status===`APPROVAL NEEDED`&&e(u)}),j(i);var d=B(i,2);n(d,()=>W(t),()=>!1);var f=B(d,2);Z(f,17,()=>W(a).filter(e=>e.session===W(t).id),X,(e,n)=>{var r=ds(),i=R(r),a=e=>{var t=ls(),r=z(t,!0);V(()=>J(r,W(n).notice)),q(e,t)};Y(i,e=>{W(n).notice&&e(a)});var o=B(i,2),s=e=>{var n=us();V(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(t).id)+`?review=profile`]),G(`click`,n,e=>l(e,W(t).id)),q(e,n)};Y(o,e=>{W(n).pending&&e(s)}),q(e,r)});var h=B(f,2);{let e=N(()=>W(p)===W(t).id);Po(h,{get session(){return W(t)},get active(){return W(e)}})}j(r),V(()=>J(s,W(t).contextKind||`LAST ACTIVITY`)),q(e,r)};Y(he,e=>{W(r)>0&&e(O)});var ge=B(he,2),_e=e=>{var n=ps(),r=B(L(n),2);{let e=N(()=>(W(t).samples||[]).map(e=>e.tokens));Ya(r,{get values(){return W(e)},capacity:120})}var i=z(B(r,2));j(n),V(()=>J(i,`LAST ${(W(t).samples?.length||0)??``} SAMPLES // AUTO SCALE`)),q(e,n)};Y(ge,e=>{W(r)<2&&e(_e)}),j(i),V((e,n,a,s)=>{o=ci(i,1,`session-row`,null,o,{selected:W(p)===W(t).id,wide:W(r)===2,split:W(r)===1}),Q(i,`aria-label`,`Session `+(W(t).name||W(t).directory||W(t).id)),Q(h,`href`,e),_=ci(g,1,`lamp lit`,null,_,{working:W(t).status===`WORKING`&&!W(m)}),J(v,W(m)?`STALE`:W(t).status),J(w,`${n??``} `),J(re,`${W(t).agents??``} LINKED AGENTS`),J(ae,`ACTIVE // ${a??``}`),se.disabled=W(r)===0,Q(ce,`aria-expanded`,W(r)>0),J(le,W(r)?`HIDE DETAIL`:`SHOW DETAIL`),Q(de,`href`,s)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>oa(W(t).tokens),()=>sa(W(t).activity),()=>`#/sessions/`+encodeURIComponent(W(t).id)]),G(`click`,h,()=>y(W(t).id)),G(`click`,se,()=>b(W(t).id,-1)),G(`click`,ce,()=>{y(W(t).id),aa(W(t).id,+!W(r))}),G(`click`,ue,()=>b(W(t).id,1)),G(`click`,de,()=>y(W(t).id)),q(e,i)});var f=B(d,2),h=e=>{q(e,hs())};Y(f,e=>{W(i).length||e(h)}),G(`click`,c,()=>ia(1)),G(`click`,u,()=>ia(0)),q(e,t)};Y(le,e=>{r().id?e(ue):e(de,-1)}),V(e=>{J(T,`OBSERVED ${e??``}`),E=ci(ee,1,`session-totals`,null,E,{stale:W(m)}),J(te,`${W(m)?`LAST KNOWN TOTALS — live state counts unavailable. `:``}Tokens + visible.

            `),Jo=K(` `),Yo=K(` `),Xo=K(` `),Zo=K(``),Qo=K(`

            Read only — reply or approve in Codex.

            `),$o=K(`

            `),es=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),ts=K(`
            `),ns=K(`
            `),rs=K(`

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

            `),is=K(`

            `),as=K(``),os=K(`

            `),ss=K(` `),cs=K(`

            `),ls=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),us=K(` `,1),ds=K(`

            `),fs=K(`

            TOKEN ACTIVITY // 30 SECOND SAMPLES

            `),ps=K(`

            TOKENS

            FULL DETAIL →
            `),ms=K(`

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

            `),hs=K(`

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

            `,1),gs=K(`

            SESSION TOTALS

            `,1);function _s(e,t){Ge(t,!0);let n=(e,t=f,n,r)=>{let i=ht(()=>g(n?.(),!0)),a=ht(()=>g(r?.(),!1));var o=Wo(),s=R(o),c=e=>{var n=Fo(),r=z(B(R(n),2),!0);we(2),V(()=>J(r,t().approvalContext)),q(e,n)};Y(s,e=>{W(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(c)});var l=B(s,2),u=e=>{var n=Io();let r;var i=z(n,!0);V(e=>{r=ci(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),J(i,e)},[()=>C(t())]),q(e,n)},d=N(()=>C(t())&&(!W(a)||W(h)||t().status===`CHECK SESSION`));Y(l,e=>{W(d)&&e(u)});var p=B(l,2),m=e=>{var n=Lo(),r=z(n,!0);V(()=>J(r,t().contextKind||`LAST ACTIVITY`)),q(e,n)};Y(p,e=>{W(i)&&e(m)});var _=B(p,2),v=e=>{var n=Ro(),r=z(n,!0);V(()=>J(r,t().text||`No session context available.`)),q(e,n)};Y(_,e=>{(t().text||!t().workingCommand)&&e(v)});var y=B(_,2),b=e=>{var n=zo(),r=B(R(n),2),i=L(r),a=B(i),o=e=>{var n=Pr();V(()=>J(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),q(e,n)};Y(a,e=>{!W(h)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(o)});var s=B(a,2),c=e=>{q(e,Pr(`+`))};Y(s,e=>{t().runningLimited&&e(c)}),j(r);var l=z(B(r,2),!0);V(e=>{J(i,`COMMAND // ${e??``} `),J(l,t().workingCommand)},[()=>W(h)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),q(e,n)};Y(y,e=>{t().workingCommand&&e(b)});var x=B(y,2),S=e=>{var n=Ho(),r=B(R(n),2),i=z(r,!0),a=B(r,2),o=e=>{var n=Bo(),r=z(n,!0);V(()=>J(r,t().command)),q(e,n)},s=e=>{q(e,Vo())};Y(a,e=>{t().command?e(o):e(s,-1)}),V(()=>J(i,W(h)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),q(e,n)};Y(x,e=>{(!W(a)||!$.data?.control)&&(t().command||t().status===`APPROVAL NEEDED`)&&e(S)});var w=B(x,2),T=e=>{var n=Uo(),r=z(n);V(()=>J(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),q(e,n)};Y(w,e=>{W(a)||e(T)}),q(e,o)},r=Hi(t,`params`,19,()=>({})),i=N(()=>$.data?.sessions||[]),a=N(()=>$.data?.control&&$.data.profiles||[]),o=N(()=>($.data?.triggers||[]).filter(e=>W(i).some(t=>t.id===e.session)));function s(e,t){if(r().id&&r().id!==t&&W(l)){e.preventDefault();return}b(t)}function c(e){return e.status===`TURN COMPLETE`&&W(o).some(t=>t.session===e.id)?`TRIGGER SET`:e.status}let l=F(!1);function u(e,t){if(r().id&&r().id!==t&&W(l)){e.preventDefault();return}b(t)}bn(()=>{let e=r().id;e&&mr(()=>{ea.selected=e,aa(e,2)})});let d=N(()=>W(i).find(e=>e.id===r().id)),p=N(()=>new URLSearchParams(Ki.querystring).get(`review`)===`profile`&&W(a).some(e=>e.session===r().id&&e.pending)),m=N(()=>W(i).some(e=>e.id===ea.selected)?ea.selected:W(i)[0]?.id),h=N(()=>!$.connected||!!$.data?.sessionsError),v=N(()=>[[`OBSERVED TOKENS`,oa(W(i).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,oa(W(i).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,W(h)?`—`:oa(W(i).filter(e=>e.status===t).length)])]),y=N(()=>W(i).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`,`CHECK SESSION`].includes(e.status)));function b(e){ea.selected=e,dr().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function x(e,t){if(b(e),r().id){t<0&&(aa(e,2),location.hash=`/sessions`);return}let n=ra(e)+t;n>2?location.hash=`/sessions/`+encodeURIComponent(e):aa(e,n)}function S(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`&&r().id)e.preventDefault(),x(r().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(r().id||W(m)))e.preventDefault(),x(r().id||W(m),e.key===`ArrowLeft`?-1:1);else if(!r().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&W(i).length){e.preventDefault();let t=W(i).findIndex(e=>e.id===W(m));b(W(i)[Math.max(0,Math.min(W(i).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function C(e){return W(h)?`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.`:$.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.`:``}var w=gs();Cr(`keydown`,en,S);var T=R(w),ee=z(B(L(T),2));j(T);var E=B(T,2);let D;Z(E,21,()=>W(v),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1];var a=Go(),o=L(a),s=z(o,!0),c=z(B(o,2),!0);j(a),V(()=>{J(s,r()),J(c,i())}),q(e,a)}),j(E);var te=B(E,2),ne=z(te),re=B(te,2),ie=e=>{q(e,Ko())};Y(re,e=>{W(h)&&e(ie)});var ae=B(re,2),oe=e=>{q(e,qo())};Y(ae,e=>{$.data?.profileError&&e(oe)});var se=B(ae,2),ce=e=>{var t=Zo(),n=L(t);Z(n,17,()=>W(y),X,(e,t)=>{var n=Jo();let r;var i=z(n);V((e,a)=>{r=ci(n,1,`button`,null,r,{approval:W(t).status===`APPROVAL NEEDED`}),Q(n,`href`,e),J(i,`${W(t).status??``} + ${a??``} // ${(W(t).name||W(t).directory||W(t).id)??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,n,()=>b(W(t).id)),q(e,n)});var c=B(n,2);Z(c,17,()=>W(a).filter(e=>e.pending&&W(i).some(t=>t.id===e.session)),X,(e,t)=>{var n=Yo(),a=z(n);V((e,i,o)=>{Q(n,`title`,r().id&&r().id!==W(t).session&&W(l)?`Finish sending or clear your current draft before switching sessions.`:`Review this session’s quota threshold`),Q(n,`href`,e),J(a,`QUOTA THRESHOLD ${i??``} // ${o??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session)+`?review=profile`,()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory||W(t).session]),G(`click`,n,e=>u(e,W(t).session)),q(e,n)}),Z(B(c,2),17,()=>W(o),X,(e,t)=>{var n=Xo(),r=z(n);V((e,t,i)=>{Q(n,`href`,e),J(r,`TRIGGER SET ${t??``} // ${i??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session),()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory]),G(`click`,n,e=>s(e,W(t).session)),q(e,n)}),j(t),q(e,t)},le=N(()=>(W(y).length||W(a).some(e=>e.pending)||W(o).length)&&!W(h));Y(se,e=>{W(le)&&e(ce)});var ue=B(se,2),de=e=>{var t=Fr(),i=R(t),o=e=>{var t=ns(),i=L(t),o=L(i),s=L(o);let u;var f=B(s);j(o);var m=B(o,2);j(i);var g=B(i,2),_=e=>{var t=Uo(),n=z(t,!0);V(()=>J(n,W(d).directory)),q(e,t)};Y(g,e=>{W(d).name&&W(d).directory&&e(_)});var v=B(g,2),y=z(v),x=B(v,2);let S;var C=L(x),w=L(C);n(w,()=>W(d),()=>!0,()=>!0),j(C);var T=B(C,2),ee=e=>{var t=Fr();qr(R(t),()=>W(d).id,e=>{{let t=N(()=>new URLSearchParams(Ki.querystring).get(`schedule`)===`edit`);Mo(e,{get session(){return W(d).id},get openScheduler(){return W(t)},get observedCommand(){return W(d).command},get suspended(){return W(p)},onProtectedChange:e=>{I(l,e,!0)}})}}),q(e,t)},E=e=>{q(e,Qo())};Y(T,e=>{$.data?.control?e(ee):e(E,-1)}),j(x);var D=B(x,2);Z(D,17,()=>W(a).filter(e=>e.session===W(d).id),e=>e.session,(e,t)=>{var n=ts(),r=L(n),i=e=>{var n=$o(),r=z(n,!0);V(()=>J(r,W(t).notice)),q(e,n)};Y(r,e=>{W(t).notice&&e(i)});var a=B(r,2),o=e=>{Mo(e,{get session(){return W(d).id},review:`profile`})},s=e=>{var t=es();V(e=>Q(t,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(d).id)+`?review=profile`]),q(e,t)};Y(a,e=>{W(t).pending&&W(p)?e(o):W(t).pending&&e(s,1)}),j(n),V(()=>Q(n,`id`,`quota-profile-`+W(d).id)),q(e,n)});var te=B(D,2),ne=e=>{var t=Fr();qr(R(t),()=>W(d).id,e=>{Po(e,{get session(){return W(d)},active:!0})}),q(e,t)};Y(te,e=>{W(p)||e(ne)}),j(t),V((e,t)=>{u=ci(s,1,`lamp lit`,null,u,{working:W(d).status===`WORKING`&&!W(h)}),J(f,`${e??``} // ${(W(d).name||W(d).directory)??``}`),J(y,`${t??``} TOKENS // ${W(d).id??``} // CONTEXT SOURCE // ${(W(d).source||`LOCAL`)??``}`),S=ui(x,``,S,{display:W(p)?`none`:void 0})},[()=>W(h)?`STALE`:W(p)?`QUOTA THRESHOLD`:c(W(d)),()=>oa(W(d).tokens)]),G(`click`,m,()=>{b(r().id),aa(r().id,2)}),q(e,t)},s=e=>{q(e,rs())};Y(i,e=>{W(d)?e(o):e(s,-1)}),q(e,t)},fe=e=>{var t=hs(),r=R(t),o=B(L(r),2),s=L(o),l=B(s,2);j(o),j(r);var d=B(r,2);Z(d,17,()=>W(i),e=>e.id,(e,t)=>{let r=N(()=>ra(W(t).id));var i=ps();let o;var s=L(i),l=L(s),d=e=>{var n=is(),r=L(n),i=z(r);j(n),V(e=>{Q(r,`aria-pressed`,W(m)===W(t).id),J(i,`${e??``} // ${W(t).name??``}`)},[()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,r,()=>b(W(t).id)),q(e,n)};Y(l,e=>{W(t).name&&e(d)});var f=B(l,2),p=L(f),g=L(p);let _;var v=B(g,1,!0);j(p),j(f);var y=B(f,2),S=e=>{var n=as(),r=z(n,!0);V(()=>{Q(n,`aria-pressed`,W(m)===W(t).id),J(r,W(t).directory||W(t).id)}),G(`click`,n,()=>b(W(t).id)),q(e,n)};Y(y,e=>{W(t).name||e(S)});var C=B(y,2),w=L(C);we(),j(C);var T=B(C,2),ee=e=>{var n=Uo(),r=z(n,!0);V(()=>J(r,W(t).directory)),q(e,n)};Y(T,e=>{W(t).name&&W(t).directory&&e(ee)});var E=B(T,2),D=z(E),te=B(E,2),ne=z(te),re=B(te,2),ie=L(re),ae=B(ie,2),oe=z(ae,!0),se=B(ae,2);j(re);var ce=B(re,2),le=B(ce,2),ue=e=>{var n=os(),r=z(n,!0);V(()=>J(r,W(t).status===`CHECK SESSION`?`INFERRED INACTIVITY`:$.data?.control?`OPEN FULL DETAIL OR REPLY IN CODEX`:W(t).status===`APPROVAL NEEDED`?`APPROVE OR DECLINE IN CODEX`:`REPLY IN CODEX`)),q(e,n)},de=N(()=>!W(h)&&[`APPROVAL NEEDED`,`INPUT NEEDED`,`CHECK SESSION`].includes(W(t).status));Y(le,e=>{W(de)&&e(ue)}),j(s);var fe=B(s,2),pe=e=>{var r=ds(),i=L(r),o=L(i),s=z(o,!0),c=B(o,2),l=e=>{var n=ss(),r=z(n,!0);V(e=>{Q(n,`href`,e),J(r,$.data?.control?`REVIEW IN FULL DETAIL ↗`:`APPROVAL IN CODEX ↗`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id)]),q(e,n)};Y(c,e=>{!W(h)&&W(t).status===`APPROVAL NEEDED`&&e(l)}),j(i);var d=B(i,2);n(d,()=>W(t),()=>!1);var f=B(d,2);Z(f,17,()=>W(a).filter(e=>e.session===W(t).id),X,(e,n)=>{var r=us(),i=R(r),a=e=>{var t=cs(),r=z(t,!0);V(()=>J(r,W(n).notice)),q(e,t)};Y(i,e=>{W(n).notice&&e(a)});var o=B(i,2),s=e=>{var n=ls();V(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(t).id)+`?review=profile`]),G(`click`,n,e=>u(e,W(t).id)),q(e,n)};Y(o,e=>{W(n).pending&&e(s)}),q(e,r)});var p=B(f,2);{let e=N(()=>W(m)===W(t).id);Po(p,{get session(){return W(t)},get active(){return W(e)}})}j(r),V(()=>J(s,W(t).contextKind||`LAST ACTIVITY`)),q(e,r)};Y(fe,e=>{W(r)>0&&e(pe)});var me=B(fe,2),he=e=>{var n=fs(),r=B(L(n),2);{let e=N(()=>(W(t).samples||[]).map(e=>e.tokens));Ya(r,{get values(){return W(e)},capacity:120})}var i=z(B(r,2));j(n),V(()=>J(i,`LAST ${(W(t).samples?.length||0)??``} SAMPLES // AUTO SCALE`)),q(e,n)};Y(me,e=>{W(r)<2&&e(he)}),j(i),V((e,n,a,s,c)=>{o=ci(i,1,`session-row`,null,o,{selected:W(m)===W(t).id,wide:W(r)===2,split:W(r)===1}),Q(i,`aria-label`,`Session `+(W(t).name||W(t).directory||W(t).id)),Q(p,`href`,e),_=ci(g,1,`lamp lit`,null,_,{working:W(t).status===`WORKING`&&!W(h)}),J(v,n),J(w,`${a??``} `),J(D,`${W(t).agents??``} LINKED AGENTS`),J(ne,`ACTIVE // ${s??``}`),ie.disabled=W(r)===0,Q(ae,`aria-expanded`,W(r)>0),J(oe,W(r)?`HIDE DETAIL`:`SHOW DETAIL`),Q(ce,`href`,c)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>W(h)?`STALE`:c(W(t)),()=>oa(W(t).tokens),()=>sa(W(t).activity),()=>`#/sessions/`+encodeURIComponent(W(t).id)]),G(`click`,p,()=>b(W(t).id)),G(`click`,ie,()=>x(W(t).id,-1)),G(`click`,ae,()=>{b(W(t).id),aa(W(t).id,+!W(r))}),G(`click`,se,()=>x(W(t).id,1)),G(`click`,ce,()=>b(W(t).id)),q(e,i)});var f=B(d,2),p=e=>{q(e,ms())};Y(f,e=>{W(i).length||e(p)}),G(`click`,s,()=>ia(1)),G(`click`,l,()=>ia(0)),q(e,t)};Y(ue,e=>{r().id?e(de):e(fe,-1)}),V(e=>{J(ee,`OBSERVED ${e??``}`),D=ci(E,1,`session-totals`,null,D,{stale:W(h)}),J(ne,`${W(h)?`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.`)},[()=>sa($.data?.sessionsAt)]),q(e,C),Ke()}wr([`click`]);var ys=K(`

            `),bs=K(`

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

            `,1),xs=K(`// APPROXIMATE`),Ss=K(`

            Partial accounting: totals may still change.

            `),Cs=K(`

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

            `,1),ws=K(`

            `,1),Ts=K(`

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

            `),Es=K(`
            `),Ds=K(`
            `),Os=K(`

            No usage reported for this day.

            `),ks=K(`

            Selected breakdown unavailable; missing does not mean zero.

            `),As=K(`

            `,1);function js(e,t){Ge(t,!0);let n=F(`surface`),r=F(0),i=N(()=>t.reports?.daily),a=N(()=>t.reports?.plan),o=N(()=>t.mode===`breakdown`?W(i)?.days.length||0:W(a)?.periods.length||0),s=N(()=>Math.min(W(r),Math.max(0,W(o)-1))),c=N(()=>W(i)?.days[(W(i)?.days.length||0)-1-W(s)]),l=N(()=>W(a)?.periods[W(s)]),u=N(()=>t.mode===`breakdown`?W(i)?.units||``:`%`),d=N(()=>{let e=Object.create(null);if(t.mode===`breakdown`)e=W(c)?.groups[W(n)]||{};else{let t=W(n)===`feature`?`thread_source`:W(n)===`task start`?`turn_trigger`:W(n);for(let n of W(l)?.breakdowns||[])if(n.dimension===t)for(let t of n.rows)e[t.key]=(e[t.key]||0)+t.basis_points/100}return Object.entries(e).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}),f=N(()=>t.mode===`breakdown`?W(c)?.total:W(l)?.used_basis_points==null?null:W(l).used_basis_points/100),p=N(()=>Math.max(1,W(f)||0,...W(d).map(([,e])=>e))),m=e=>e==null?`UNKNOWN`:e.toLocaleString(`en-GB`,{maximumFractionDigits:2});var h=As(),g=R(h),v=L(g),y=B(L(v)),b=L(y);b.value=b.__value=`surface`;var x=B(b);x.value=x.__value=`model`;var S=B(x);S.value=S.__value=`feature`;var C=B(S);C.value=C.__value=`task start`,j(y),mi(y),j(v);var w=B(v,2),T=B(w,2),ee=z(B(T,2),!0);j(g);var E=B(g,2),D=L(E),te=z(D,!0),ne=B(D,2),re=z(ne),ie=B(ne,2),ae=e=>{var t=bs(),n=R(t),r=z(n),a=B(n,2),o=e=>{var t=ys(),n=z(t);V(()=>J(n,`Data as of ${W(i).dataAsOf??``}`)),q(e,t)};Y(a,e=>{W(i).dataAsOf&&e(o)});var s=z(B(a,2));we(2),V((e,t)=>{J(r,`Latest fetch ${e??``} // queried ${W(i).from??``} → ${W(i).through??``}. + list. History samples every 30 seconds. Not account-wide totals.`)},[()=>sa($.data?.sessionsAt)]),q(e,w),Ke()}wr([`click`]);var vs=K(`

            `),ys=K(`

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

            `,1),bs=K(`// APPROXIMATE`),xs=K(`

            Partial accounting: totals may still change.

            `),Ss=K(`

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

            `,1),Cs=K(`

            `,1),ws=K(`

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

            `),Ts=K(`
            `),Es=K(`
            `),Ds=K(`

            No usage reported for this day.

            `),Os=K(`

            Selected breakdown unavailable; missing does not mean zero.

            `),ks=K(`

            `,1);function As(e,t){Ge(t,!0);let n=F(`surface`),r=F(0),i=N(()=>t.reports?.daily),a=N(()=>t.reports?.plan),o=N(()=>t.mode===`breakdown`?W(i)?.days.length||0:W(a)?.periods.length||0),s=N(()=>Math.min(W(r),Math.max(0,W(o)-1))),c=N(()=>W(i)?.days[(W(i)?.days.length||0)-1-W(s)]),l=N(()=>W(a)?.periods[W(s)]),u=N(()=>t.mode===`breakdown`?W(i)?.units||``:`%`),d=N(()=>{let e=Object.create(null);if(t.mode===`breakdown`)e=W(c)?.groups[W(n)]||{};else{let t=W(n)===`feature`?`thread_source`:W(n)===`task start`?`turn_trigger`:W(n);for(let n of W(l)?.breakdowns||[])if(n.dimension===t)for(let t of n.rows)e[t.key]=(e[t.key]||0)+t.basis_points/100}return Object.entries(e).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}),f=N(()=>t.mode===`breakdown`?W(c)?.total:W(l)?.used_basis_points==null?null:W(l).used_basis_points/100),p=N(()=>Math.max(1,W(f)||0,...W(d).map(([,e])=>e))),m=e=>e==null?`UNKNOWN`:e.toLocaleString(`en-GB`,{maximumFractionDigits:2});var h=ks(),g=R(h),v=L(g),y=B(L(v)),b=L(y);b.value=b.__value=`surface`;var x=B(b);x.value=x.__value=`model`;var S=B(x);S.value=S.__value=`feature`;var C=B(S);C.value=C.__value=`task start`,j(y),mi(y),j(v);var w=B(v,2),T=B(w,2),ee=z(B(T,2),!0);j(g);var E=B(g,2),D=L(E),te=z(D,!0),ne=B(D,2),re=z(ne),ie=B(ne,2),ae=e=>{var t=ys(),n=R(t),r=z(n),a=B(n,2),o=e=>{var t=vs(),n=z(t);V(()=>J(n,`Data as of ${W(i).dataAsOf??``}`)),q(e,t)};Y(a,e=>{W(i).dataAsOf&&e(o)});var s=z(B(a,2));we(2),V((e,t)=>{J(r,`Latest fetch ${e??``} // queried ${W(i).from??``} → ${W(i).through??``}. Reports are fetched from OpenAI and are not saved between runs.`),J(s,`${(W(c)?.date||`No daily buckets reported`)??``} // ${t??``} - ${W(u)??``}`)},[()=>sa(W(i).fetchedAt),()=>m(W(f))]),q(e,t)},oe=e=>{var t=ws(),n=R(t),r=L(n);let i;var o=z(r,!0),s=B(r),c=e=>{q(e,xs())};Y(s,e=>{W(a).approximate&&e(c)});var u=B(s);j(n);var d=B(n,2),p=L(d),h=B(p),g=e=>{var t=Pr();V(()=>J(t,`// Boundary tolerance ${W(a).boundary_tolerance_seconds??``}s`)),q(e,t)};Y(h,e=>{W(a).boundary_tolerance_seconds!=null&&e(g)}),j(d);var _=B(d,2),v=e=>{var t=Cs(),n=R(t),r=L(n),i=B(r);let a;var o=z(i);j(n);var s=B(n,2),c=z(s),u=B(s,2),d=e=>{q(e,Ss())};Y(u,e=>{W(l).accounting_complete||e(d)}),we(2),V(e=>{J(r,`${W(l).window_minutes??``} MIN // ${W(l).plan_type??``} // `),a=ci(i,1,`svelte-1fbui7h`,null,a,{muted:W(f)==null,"quota-near":W(f)!=null&&W(f)>=80&&W(f)<100,"quota-full":W(f)!=null&&W(f)>=100}),J(o,`USED ${e??``}${W(f)==null?``:`%`}`),J(c,`${W(l).starts_at??``} → ${W(l).ends_at??``}`)},[()=>m(W(f))]),q(e,t)};Y(_,e=>{W(l)&&e(v)}),V(e=>{i=ci(r,1,`svelte-1fbui7h`,null,i,{"quality-warning":!W(a).coverage_complete}),J(o,W(a).coverage_complete?`Reported range complete`:`Partial coverage`),J(u,` // Latest fetch ${e??``}`),J(p,`Coverage starts ${(W(a).coverage_start||`unknown`)??``} // Data as of ${(W(a).data_as_of||`unknown`)??``}`)},[()=>sa(W(a).fetchedAt)]),q(e,t)},se=e=>{q(e,Ts())};Y(ie,e=>{t.mode===`breakdown`&&W(i)?e(ae):t.mode===`periods`&&W(a)?e(oe,1):e(se,-1)});var ce=B(ie,2),le=e=>{var n=Ds(),r=L(n),i=z(B(L(r),2),!0);j(r),Z(B(r,2),17,()=>W(d),X,(e,n,r)=>{var i=N(()=>_(W(n),2));let a=()=>W(i)[0],o=()=>W(i)[1];var s=Es();let c;var l=L(s),u=z(l,!0),d=B(l,2),f=L(d);let h;j(d);var g=z(B(d,2));j(s),V((e,n,i)=>{c=ci(s,1,`report-row svelte-1fbui7h`,null,c,{unknown:e,alternate:r%2==1}),Q(l,`title`,a()),J(u,a()),h=ui(f,``,h,{width:n}),J(g,`${i??``}${t.mode===`periods`?`%`:``}`)},[()=>a().trim().toLowerCase()===`unknown`,()=>`${Math.max(0,100*o()/W(p))}%`,()=>m(o())]),q(e,s)}),j(n),V(()=>J(i,t.mode===`breakdown`?W(u):`QUOTA USED`)),q(e,n)},ue=e=>{q(e,Os())},de=e=>{q(e,ks())};Y(ce,e=>{W(d).length?e(le):t.mode===`breakdown`&&W(c)?.total===0&&W(c)?.groups[W(n)]!=null?e(ue,1):(W(i)&&t.mode===`breakdown`||W(a)&&t.mode===`periods`)&&e(de,2)}),j(E),V(()=>{w.disabled=W(s)>=W(o)-1,T.disabled=W(s)===0,J(ee,W(o)?`${W(s)+1} / ${W(o)}`:`NO DATA`),J(te,t.mode===`breakdown`?`DAILY BREAKDOWN`:`QUOTA WINDOWS`),J(re,`${(t.mode===`breakdown`?t.reports?.dailyStatus||`UNAVAILABLE`:t.reports?.planStatus||`UNAVAILABLE`)??``} // UTC`)}),hi(y,()=>W(n),e=>I(n,e)),G(`click`,w,()=>I(r,W(s)+1)),G(`click`,T,()=>I(r,W(s)-1)),q(e,h),Ke()}wr([`click`]);var Ms=864e5;function Ns(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 Ps(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));for(let e=0;;e++){let i=Ns(r,-t),a=new Date(i.getTime()+Ms);if(e===n)return{start:a,end:r};r=i}}var Fs=K(``),Is=K(``,1),Ls=K(`

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

            `),Rs=K(`

            Token history unavailable; other reports may still be available.

            `),zs=K(``),Bs=K(`
            `),Vs=K(`

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

            `,1),Hs=K(`
            `,1),Us=K(` `),Ws=K(`

            LIFETIME TOKENS

            PEAK DAY

            CURRENT STREAK

            DAYS

            LONGEST TURN

            SECONDS

            LONGEST STREAK

            DAYS

            OPENAI // UTC

            Accessible data table
            Date (UTC)Tokens

            `,1),Gs=K(`

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

            `),Ks=K(`

            USAGE // ACCOUNT HISTORY

            Account-wide history reported by Codex, not the local Sessions counter. Dates + ${W(u)??``}`)},[()=>sa(W(i).fetchedAt),()=>m(W(f))]),q(e,t)},oe=e=>{var t=Cs(),n=R(t),r=L(n);let i;var o=z(r,!0),s=B(r),c=e=>{q(e,bs())};Y(s,e=>{W(a).approximate&&e(c)});var u=B(s);j(n);var d=B(n,2),p=L(d),h=B(p),g=e=>{var t=Pr();V(()=>J(t,`// Boundary tolerance ${W(a).boundary_tolerance_seconds??``}s`)),q(e,t)};Y(h,e=>{W(a).boundary_tolerance_seconds!=null&&e(g)}),j(d);var _=B(d,2),v=e=>{var t=Ss(),n=R(t),r=L(n),i=B(r);let a;var o=z(i);j(n);var s=B(n,2),c=z(s),u=B(s,2),d=e=>{q(e,xs())};Y(u,e=>{W(l).accounting_complete||e(d)}),we(2),V(e=>{J(r,`${W(l).window_minutes??``} MIN // ${W(l).plan_type??``} // `),a=ci(i,1,`svelte-1fbui7h`,null,a,{muted:W(f)==null,"quota-near":W(f)!=null&&W(f)>=80&&W(f)<100,"quota-full":W(f)!=null&&W(f)>=100}),J(o,`USED ${e??``}${W(f)==null?``:`%`}`),J(c,`${W(l).starts_at??``} → ${W(l).ends_at??``}`)},[()=>m(W(f))]),q(e,t)};Y(_,e=>{W(l)&&e(v)}),V(e=>{i=ci(r,1,`svelte-1fbui7h`,null,i,{"quality-warning":!W(a).coverage_complete}),J(o,W(a).coverage_complete?`Reported range complete`:`Partial coverage`),J(u,` // Latest fetch ${e??``}`),J(p,`Coverage starts ${(W(a).coverage_start||`unknown`)??``} // Data as of ${(W(a).data_as_of||`unknown`)??``}`)},[()=>sa(W(a).fetchedAt)]),q(e,t)},se=e=>{q(e,ws())};Y(ie,e=>{t.mode===`breakdown`&&W(i)?e(ae):t.mode===`periods`&&W(a)?e(oe,1):e(se,-1)});var ce=B(ie,2),le=e=>{var n=Es(),r=L(n),i=z(B(L(r),2),!0);j(r),Z(B(r,2),17,()=>W(d),X,(e,n,r)=>{var i=N(()=>_(W(n),2));let a=()=>W(i)[0],o=()=>W(i)[1];var s=Ts();let c;var l=L(s),u=z(l,!0),d=B(l,2),f=L(d);let h;j(d);var g=z(B(d,2));j(s),V((e,n,i)=>{c=ci(s,1,`report-row svelte-1fbui7h`,null,c,{unknown:e,alternate:r%2==1}),Q(l,`title`,a()),J(u,a()),h=ui(f,``,h,{width:n}),J(g,`${i??``}${t.mode===`periods`?`%`:``}`)},[()=>a().trim().toLowerCase()===`unknown`,()=>`${Math.max(0,100*o()/W(p))}%`,()=>m(o())]),q(e,s)}),j(n),V(()=>J(i,t.mode===`breakdown`?W(u):`QUOTA USED`)),q(e,n)},ue=e=>{q(e,Ds())},de=e=>{q(e,Os())};Y(ce,e=>{W(d).length?e(le):t.mode===`breakdown`&&W(c)?.total===0&&W(c)?.groups[W(n)]!=null?e(ue,1):(W(i)&&t.mode===`breakdown`||W(a)&&t.mode===`periods`)&&e(de,2)}),j(E),V(()=>{w.disabled=W(s)>=W(o)-1,T.disabled=W(s)===0,J(ee,W(o)?`${W(s)+1} / ${W(o)}`:`NO DATA`),J(te,t.mode===`breakdown`?`DAILY BREAKDOWN`:`QUOTA WINDOWS`),J(re,`${(t.mode===`breakdown`?t.reports?.dailyStatus||`UNAVAILABLE`:t.reports?.planStatus||`UNAVAILABLE`)??``} // UTC`)}),hi(y,()=>W(n),e=>I(n,e)),G(`click`,w,()=>I(r,W(s)+1)),G(`click`,T,()=>I(r,W(s)-1)),q(e,h),Ke()}wr([`click`]);var js=864e5;function Ms(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 Ns(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));for(let e=0;;e++){let i=Ms(r,-t),a=new Date(i.getTime()+js);if(e===n)return{start:a,end:r};r=i}}var Ps=K(``),Fs=K(``,1),Is=K(`

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

            `),Ls=K(`

            Token history unavailable; other reports may still be available.

            `),Rs=K(``),zs=K(`
            `),Bs=K(`

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

            `,1),Vs=K(`
            `,1),Hs=K(` `),Us=K(`

            LIFETIME TOKENS

            PEAK DAY

            CURRENT STREAK

            DAYS

            LONGEST TURN

            SECONDS

            LONGEST STREAK

            DAYS

            OPENAI // UTC

            Accessible data table
            Date (UTC)Tokens

            `,1),Ws=K(`

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

            `),Gs=K(`

            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 qs(e,t){Ge(t,!0);let n=F(`daily`),r=F(12),i=F(0),a=N(()=>{let e=$.data?.usage?.dailyUsageBuckets;if(!e)return[];let{start:t,end:n}=Ps(new Date,W(r),W(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=N(()=>Math.max(1,...W(a).map(e=>e.tokens))),s=N(()=>W(a).length?new Date(W(a)[0].date+`T00:00:00Z`).getUTCDay():0),c=N(()=>{if(W(n)===`monthly`){let e=new Map;for(let t of W(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 W(a).map(t=>({date:t.date,tokens:e+=t.tokens}))});var l=Ks(),u=B(R(l),4);Z(u,20,()=>[[`daily`,`Daily`],[`monthly`,`Monthly`],[`cumulative`,`Cumulative`],[`breakdown`,`Breakdown`],[`periods`,`Windows`]],X,(e,t)=>{var r=N(()=>_(t,2));let a=()=>W(r)[0],o=()=>W(r)[1];var s=Fs();let c;var l=z(s,!0);V(()=>{Q(s,`aria-pressed`,W(n)===a()),c=ci(s,1,``,null,c,{active:W(n)===a()}),J(l,o())}),G(`click`,s,()=>{I(n,a(),!0),I(i,0)}),q(e,s)}),j(u);var d=B(u,2),f=L(d),p=e=>{var t=Is(),n=R(t),a=B(L(n)),o=L(a);o.value=o.__value=6;var s=B(o);s.value=s.__value=12,j(a),mi(a),j(n);var c=B(n),l=B(c);V(()=>l.disabled=W(i)===0),G(`change`,a,()=>I(i,0)),hi(a,()=>W(r),e=>I(r,e)),G(`click`,c,()=>Jt(i)),G(`click`,l,()=>Jt(i,-1)),q(e,t)};Y(f,e=>{W(n)!==`breakdown`&&W(n)!==`periods`&&e(p)}),j(d);var m=B(d,2),h=e=>{q(e,Ls())};Y(m,e=>{$.data?.usageError&&e(h)});var g=B(m,2),v=e=>{q(e,Rs())};Y(g,e=>{$.data?.usage?.tokenStatus===`UNAVAILABLE`&&W(n)!==`breakdown`&&W(n)!==`periods`&&e(v)});var y=B(g,2),b=e=>{var t=Fr();qr(R(t),()=>W(n),e=>{{let t=N(()=>$.data?.usage?.reports);js(e,{get reports(){return W(t)},get mode(){return W(n)}})}}),q(e,t)},x=e=>{var t=Ws(),r=R(t),i=L(r),l=z(B(L(i),2),!0);j(i);var u=B(i,2),d=z(B(L(u),2),!0);j(u);var f=B(u,2),p=B(L(f),2),m=L(p);we(),j(p),j(f);var h=B(f,2),g=B(L(h),2),_=L(g);we(),j(g),j(h);var v=B(h,2),y=B(L(v),2),b=L(y);we(),j(y),j(v),j(r);var x=B(r,4),S=L(x),C=z(S),w=B(S,2),T=e=>{var t=Vs(),n=R(t),r=L(n),i=L(r);Z(i,17,()=>Array(W(s)),X,(e,t)=>{q(e,zs())}),Z(B(i,2),17,()=>W(a),X,(e,t)=>{var n=Bs();let r,i;V(e=>{r=ci(n,1,`heat-cell`,null,r,{zero:W(t).tokens===0}),Q(n,`title`,e),i=ui(n,``,i,{opacity:W(t).tokens?.25+.75*W(t).tokens/W(o):1})},[()=>`${W(t).date}: ${oa(W(t).tokens)} tokens`]),q(e,n)}),j(r),j(n),we(2),q(e,t)},ee=e=>{var t=Hs(),r=R(t);{let e=N(()=>W(c).map(e=>e.tokens)),t=N(()=>W(n)+` usage`);Ya(r,{get values(){return W(e)},get label(){return W(t)}})}var i=B(r,2),a=L(i),o=z(a,!0),s=z(B(a),!0);j(i),V(e=>{J(o,W(c)[0]?.date),J(s,e)},[()=>W(c).at(-1)?.date]),q(e,t)};Y(w,e=>{W(n)===`daily`?e(T):e(ee,-1)});var E=B(w,2),D=B(L(E),2),te=L(D),ne=B(L(te));Z(ne,21,()=>W(n)===`daily`?W(a):W(c),X,(e,t)=>{var n=Us(),r=L(n),i=z(r,!0),a=z(B(r),!0);j(n),V(e=>{J(i,W(t).date),J(a,e)},[()=>oa(W(t).tokens)]),q(e,n)}),j(ne),j(te),j(D),j(E),j(x);var re=z(B(x,2));V((e,t,n,r,i,o,s)=>{J(l,e),J(d,t),J(m,`${n??``} `),J(_,`${r??``} `),J(b,`${i??``} `),J(C,`${W(a)[0]?.date??``} — ${o??``}`),J(re,`OBSERVED ${s??``} // CUMULATIVE IS FOR THE SELECTED PERIOD`)},[()=>oa($.data.usage.summary.lifetimeTokens),()=>oa($.data.usage.summary.peakDailyTokens),()=>oa($.data.usage.summary.currentStreakDays),()=>oa($.data.usage.summary.longestRunningTurnSec),()=>oa($.data.usage.summary.longestStreakDays),()=>W(a).at(-1)?.date,()=>sa($.data.usageAt)]),q(e,t)},S=e=>{q(e,Gs())};Y(y,e=>{W(n)===`breakdown`||W(n)===`periods`?e(b):$.data?.usage&&$.data.usage.dailyUsageBuckets!==null?e(x,1):e(S,-1)}),q(e,l),Ke()}wr([`click`,`change`]);var Js=K(`

            Page not found

            Return to Quota

            `,1);function Ys(e){var t=Js();we(2),q(e,t)}var Xs=K(` `),Zs=K(`

            `),Qs=K(`

            Connecting to your local Codexometer…

            `),$s=K(``),ec=K(`
            CODEXOMETER

            Your quota. Your sessions. Your command centre.

            `);function tc(e,t){Ge(t,!0);let n={"/":Ka,"/quota/:view?":Ka,"/sessions/:id?":vs,"/usage":qs,"*":Ys},r={quota:/^(?:\/|\/quota(?:\/[^/]+)?\/?)$/,sessions:/^\/sessions(?:\/[^/]+)?\/?$/,usage:/^\/usage\/?$/},i=F(`hacker`),a=[`hacker`,`rust`,`blue-steel`,`ultraviolet`,`nightshade`];bn(()=>{ta()}),bn(()=>{if($.data)for(let[e,t]of Object.entries(r))t.test(Ki.location)&&(ea.tab=e)}),Ui(()=>{try{let e=localStorage.getItem(`codexometer.web.theme`);e&&a.includes(e)&&I(i,e,!0)}catch{}return fa()});function o(){try{localStorage.setItem(`codexometer.web.theme`,W(i))}catch{}}var s=ec(),c=L(s),l=B(L(c),2),u=L(l);let d;var f=B(u,1,!0),p=z(B(f));j(l),j(c);var m=B(c,2);Z(m,21,()=>Object.entries(r),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1],a=N(()=>i().test(Ki.location));var o=Xs();let s;var c=z(o,!0);V(e=>{Q(o,`href`,r()===`quota`?`#/quota/`+ea.view:`#/`+r()),Q(o,`aria-current`,W(a)?`page`:void 0),s=ci(o,1,``,null,s,{active:W(a)}),J(c,e)},[()=>r().toUpperCase()]),q(e,o)}),j(m);var h=B(m,2),g=L(h),v=e=>{var t=Zs(),n=z(t,!0);V(()=>J(n,$.error)),q(e,t)};Y(g,e=>{$.error&&e(v)});var y=B(g,2),b=e=>{Yi(e,{get routes(){return n}})},x=e=>{q(e,Qs())};Y(y,e=>{$.data?e(b):$.error||e(x,1)}),j(h);var S=B(h,2),C=L(S),w=z(C),T=B(C,2),ee=z(T,!0),E=B(T,2),D=B(L(E));Z(D,21,()=>a,X,(e,t)=>{var n=$s(),r=z(n,!0),i={};V(e=>{J(r,e),i!==(i=W(t))&&(n.value=(n.__value=i)??``)},[()=>W(t).replace(`-`,` `).toUpperCase()]),q(e,n)}),j(D),mi(D),j(E),j(S),j(s),V(()=>{Q(s,`data-theme`,W(i)),d=ci(u,1,`lamp`,null,d,{lit:$.connected}),J(f,$.connected?`CONNECTED`:`OFFLINE`),J(p,`EXPERIMENTAL // ${$.data?.control?`SESSION CONTROL`:`READ ONLY`}`),J(w,`v${($.data?.version||`…`)??``} // LOCAL ONLY`),J(ee,$.data?.control?`Session control enabled. Stop the server to revoke access.`:`No actions can be sent from this preview.`)}),G(`change`,D,o),hi(D,()=>W(i),e=>I(i,e)),q(e,s),Ke()}wr([`change`]),Vr(tc,{target:document.getElementById(`app`)}); \ No newline at end of file + not provided.

            `,1);function Ks(e,t){Ge(t,!0);let n=F(`daily`),r=F(12),i=F(0),a=N(()=>{let e=$.data?.usage?.dailyUsageBuckets;if(!e)return[];let{start:t,end:n}=Ns(new Date,W(r),W(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=N(()=>Math.max(1,...W(a).map(e=>e.tokens))),s=N(()=>W(a).length?new Date(W(a)[0].date+`T00:00:00Z`).getUTCDay():0),c=N(()=>{if(W(n)===`monthly`){let e=new Map;for(let t of W(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 W(a).map(t=>({date:t.date,tokens:e+=t.tokens}))});var l=Gs(),u=B(R(l),4);Z(u,20,()=>[[`daily`,`Daily`],[`monthly`,`Monthly`],[`cumulative`,`Cumulative`],[`breakdown`,`Breakdown`],[`periods`,`Windows`]],X,(e,t)=>{var r=N(()=>_(t,2));let a=()=>W(r)[0],o=()=>W(r)[1];var s=Ps();let c;var l=z(s,!0);V(()=>{Q(s,`aria-pressed`,W(n)===a()),c=ci(s,1,``,null,c,{active:W(n)===a()}),J(l,o())}),G(`click`,s,()=>{I(n,a(),!0),I(i,0)}),q(e,s)}),j(u);var d=B(u,2),f=L(d),p=e=>{var t=Fs(),n=R(t),a=B(L(n)),o=L(a);o.value=o.__value=6;var s=B(o);s.value=s.__value=12,j(a),mi(a),j(n);var c=B(n),l=B(c);V(()=>l.disabled=W(i)===0),G(`change`,a,()=>I(i,0)),hi(a,()=>W(r),e=>I(r,e)),G(`click`,c,()=>Jt(i)),G(`click`,l,()=>Jt(i,-1)),q(e,t)};Y(f,e=>{W(n)!==`breakdown`&&W(n)!==`periods`&&e(p)}),j(d);var m=B(d,2),h=e=>{q(e,Is())};Y(m,e=>{$.data?.usageError&&e(h)});var g=B(m,2),v=e=>{q(e,Ls())};Y(g,e=>{$.data?.usage?.tokenStatus===`UNAVAILABLE`&&W(n)!==`breakdown`&&W(n)!==`periods`&&e(v)});var y=B(g,2),b=e=>{var t=Fr();qr(R(t),()=>W(n),e=>{{let t=N(()=>$.data?.usage?.reports);As(e,{get reports(){return W(t)},get mode(){return W(n)}})}}),q(e,t)},x=e=>{var t=Us(),r=R(t),i=L(r),l=z(B(L(i),2),!0);j(i);var u=B(i,2),d=z(B(L(u),2),!0);j(u);var f=B(u,2),p=B(L(f),2),m=L(p);we(),j(p),j(f);var h=B(f,2),g=B(L(h),2),_=L(g);we(),j(g),j(h);var v=B(h,2),y=B(L(v),2),b=L(y);we(),j(y),j(v),j(r);var x=B(r,4),S=L(x),C=z(S),w=B(S,2),T=e=>{var t=Bs(),n=R(t),r=L(n),i=L(r);Z(i,17,()=>Array(W(s)),X,(e,t)=>{q(e,Rs())}),Z(B(i,2),17,()=>W(a),X,(e,t)=>{var n=zs();let r,i;V(e=>{r=ci(n,1,`heat-cell`,null,r,{zero:W(t).tokens===0}),Q(n,`title`,e),i=ui(n,``,i,{opacity:W(t).tokens?.25+.75*W(t).tokens/W(o):1})},[()=>`${W(t).date}: ${oa(W(t).tokens)} tokens`]),q(e,n)}),j(r),j(n),we(2),q(e,t)},ee=e=>{var t=Vs(),r=R(t);{let e=N(()=>W(c).map(e=>e.tokens)),t=N(()=>W(n)+` usage`);Ya(r,{get values(){return W(e)},get label(){return W(t)}})}var i=B(r,2),a=L(i),o=z(a,!0),s=z(B(a),!0);j(i),V(e=>{J(o,W(c)[0]?.date),J(s,e)},[()=>W(c).at(-1)?.date]),q(e,t)};Y(w,e=>{W(n)===`daily`?e(T):e(ee,-1)});var E=B(w,2),D=B(L(E),2),te=L(D),ne=B(L(te));Z(ne,21,()=>W(n)===`daily`?W(a):W(c),X,(e,t)=>{var n=Hs(),r=L(n),i=z(r,!0),a=z(B(r),!0);j(n),V(e=>{J(i,W(t).date),J(a,e)},[()=>oa(W(t).tokens)]),q(e,n)}),j(ne),j(te),j(D),j(E),j(x);var re=z(B(x,2));V((e,t,n,r,i,o,s)=>{J(l,e),J(d,t),J(m,`${n??``} `),J(_,`${r??``} `),J(b,`${i??``} `),J(C,`${W(a)[0]?.date??``} — ${o??``}`),J(re,`OBSERVED ${s??``} // CUMULATIVE IS FOR THE SELECTED PERIOD`)},[()=>oa($.data.usage.summary.lifetimeTokens),()=>oa($.data.usage.summary.peakDailyTokens),()=>oa($.data.usage.summary.currentStreakDays),()=>oa($.data.usage.summary.longestRunningTurnSec),()=>oa($.data.usage.summary.longestStreakDays),()=>W(a).at(-1)?.date,()=>sa($.data.usageAt)]),q(e,t)},S=e=>{q(e,Ws())};Y(y,e=>{W(n)===`breakdown`||W(n)===`periods`?e(b):$.data?.usage&&$.data.usage.dailyUsageBuckets!==null?e(x,1):e(S,-1)}),q(e,l),Ke()}wr([`click`,`change`]);var qs=K(`

            Page not found

            Return to Quota

            `,1);function Js(e){var t=qs();we(2),q(e,t)}var Ys=K(` `),Xs=K(`

            `),Zs=K(`

            Connecting to your local Codexometer…

            `),Qs=K(``),$s=K(`
            CODEXOMETER

            Your quota. Your sessions. Your command centre.

            `);function ec(e,t){Ge(t,!0);let n={"/":Ka,"/quota/:view?":Ka,"/sessions/:id?":_s,"/usage":Ks,"*":Js},r={quota:/^(?:\/|\/quota(?:\/[^/]+)?\/?)$/,sessions:/^\/sessions(?:\/[^/]+)?\/?$/,usage:/^\/usage\/?$/},i=F(`hacker`),a=[`hacker`,`rust`,`blue-steel`,`ultraviolet`,`nightshade`];bn(()=>{ta()}),bn(()=>{if($.data)for(let[e,t]of Object.entries(r))t.test(Ki.location)&&(ea.tab=e)}),Ui(()=>{try{let e=localStorage.getItem(`codexometer.web.theme`);e&&a.includes(e)&&I(i,e,!0)}catch{}return fa()});function o(){try{localStorage.setItem(`codexometer.web.theme`,W(i))}catch{}}var s=$s(),c=L(s),l=B(L(c),2),u=L(l);let d;var f=B(u,1,!0),p=z(B(f));j(l),j(c);var m=B(c,2);Z(m,21,()=>Object.entries(r),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1],a=N(()=>i().test(Ki.location));var o=Ys();let s;var c=z(o,!0);V(e=>{Q(o,`href`,r()===`quota`?`#/quota/`+ea.view:`#/`+r()),Q(o,`aria-current`,W(a)?`page`:void 0),s=ci(o,1,``,null,s,{active:W(a)}),J(c,e)},[()=>r().toUpperCase()]),q(e,o)}),j(m);var h=B(m,2),g=L(h),v=e=>{var t=Xs(),n=z(t,!0);V(()=>J(n,$.error)),q(e,t)};Y(g,e=>{$.error&&e(v)});var y=B(g,2),b=e=>{Yi(e,{get routes(){return n}})},x=e=>{q(e,Zs())};Y(y,e=>{$.data?e(b):$.error||e(x,1)}),j(h);var S=B(h,2),C=L(S),w=z(C),T=B(C,2),ee=z(T,!0),E=B(T,2),D=B(L(E));Z(D,21,()=>a,X,(e,t)=>{var n=Qs(),r=z(n,!0),i={};V(e=>{J(r,e),i!==(i=W(t))&&(n.value=(n.__value=i)??``)},[()=>W(t).replace(`-`,` `).toUpperCase()]),q(e,n)}),j(D),mi(D),j(E),j(S),j(s),V(()=>{Q(s,`data-theme`,W(i)),d=ci(u,1,`lamp`,null,d,{lit:$.connected}),J(f,$.connected?`CONNECTED`:`OFFLINE`),J(p,`EXPERIMENTAL // ${$.data?.control?`SESSION CONTROL`:`READ ONLY`}`),J(w,`v${($.data?.version||`…`)??``} // LOCAL ONLY`),J(ee,$.data?.control?`Session control enabled. Stop the server to revoke access.`:`No actions can be sent from this preview.`)}),G(`change`,D,o),hi(D,()=>W(i),e=>I(i,e)),q(e,s),Ke()}wr([`change`]),Vr(ec,{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 adb2ad0..8e921e9 100644 --- a/internal/web/dist/index.html +++ b/internal/web/dist/index.html @@ -5,7 +5,7 @@ Codexometer // Experimental web - + diff --git a/web/src/Sessions.svelte b/web/src/Sessions.svelte index 552a49d..542a476 100644 --- a/web/src/Sessions.svelte +++ b/web/src/Sessions.svelte @@ -26,6 +26,12 @@ } select(id); } + function sessionStatus(session: Session) { + return session.status === 'TURN COMPLETE' && + triggers.some((t) => t.session === session.id) + ? 'TRIGGER SET' + : session.status; + } let nativeProtected = $state(false); function openProfile(event: MouseEvent, id: string) { if (params.id && params.id !== id && nativeProtected) { @@ -290,7 +296,8 @@ ? 'STALE' : profileFocused ? 'QUOTA THRESHOLD' - : selected.status} // {selected.name || selected.directory} + : sessionStatus(selected)} // {selected.name || + selected.directory} {stale ? 'STALE' : session.status} + >{stale ? 'STALE' : sessionStatus(session)} {#if !session.name}{/if}

            {number(session.tokens)} TOKENS

            - {#if live.data?.triggers?.some((t) => t.session === session.id)} - openTrigger(event, session.id)}>TRIGGER SET - {/if} {#if session.name && session.directory}

            {session.directory}

            {/if} diff --git a/web/tests/browser.spec.ts b/web/tests/browser.spec.ts index 57a7a59..cc06f0d 100644 --- a/web/tests/browser.spec.ts +++ b/web/tests/browser.spec.ts @@ -730,6 +730,17 @@ test('trigger pill and row link open detail; send now confirms the saved job', a { ...snapshot, triggers: [{ session: 'parent', status: 'pending' }] }, ); await page.getByRole('link', { name: 'SESSIONS', exact: true }).click(); + await expect( + page + .locator('.telemetry') + .getByRole('link', { name: 'TRIGGER SET', exact: true }), + ).toHaveCount(1); + await expect( + page + .locator('.telemetry') + .getByRole('link', { name: 'TURN COMPLETE', exact: true }) + .and(page.locator('[href="#/sessions/parent"]')), + ).toHaveCount(0); await page .getByRole('navigation', { name: 'Sessions needing attention' }) .getByRole('link', { name: /TRIGGER SET/ }) @@ -760,6 +771,23 @@ test('trigger pill and row link open detail; send now confirms the saved job', a page.getByRole('region', { name: 'Pending follow-up' }), ).toHaveCount(0); expect(sends).toBe(1); + await page.evaluate( + (detail) => + window.dispatchEvent(new CustomEvent('test-snapshot', { detail })), + { ...snapshot, triggers: [] }, + ); + await page.getByRole('link', { name: '← ALL SESSIONS' }).click(); + await expect( + page + .locator('.telemetry') + .getByRole('link', { name: 'TURN COMPLETE', exact: true }) + .and(page.locator('[href="#/sessions/parent"]')), + ).toHaveCount(1); + await expect( + page + .locator('.telemetry') + .getByRole('link', { name: 'TRIGGER SET', exact: true }), + ).toHaveCount(0); }); for (const control of [false, true]) { From 01a7a2f8b911ea0d06a193f56d5b247e443cac18 Mon Sep 17 00:00:00 2001 From: merefield Date: Tue, 6 Oct 2026 23:20:53 +0100 Subject: [PATCH 09/17] FIX: match placeholder background to session composer --- internal/ui/monitor_editor.go | 10 ++++++--- internal/ui/monitor_prompt.go | 3 ++- internal/ui/monitor_prompt_test.go | 35 ++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/internal/ui/monitor_editor.go b/internal/ui/monitor_editor.go index e6c90e0..4a2d00f 100644 --- a/internal/ui/monitor_editor.go +++ b/internal/ui/monitor_editor.go @@ -130,9 +130,7 @@ func (e monitorEditor) View(colors palette) string { return e.password.View() } s := e.area.Styles() - pr, pg, pb, _ := colors.primary.RGBA() - br, bg, bb, _ := colors.background.RGBA() - tint := color.RGBA{uint8((pr + br*9) / 10 >> 8), uint8((pg + bg*9) / 10 >> 8), uint8((pb + bb*9) / 10 >> 8), 255} + tint := monitorComposerBackground(colors) s.Focused.Base = s.Focused.Base.Background(tint) s.Blurred.Base = s.Blurred.Base.Background(tint) s.Focused.Text = colors.label().Background(tint) @@ -142,3 +140,9 @@ func (e monitorEditor) View(colors palette) string { e.area.SetStyles(s) return e.area.View() } + +func monitorComposerBackground(colors palette) color.RGBA { + pr, pg, pb, _ := colors.primary.RGBA() + br, bg, bb, _ := colors.background.RGBA() + return color.RGBA{uint8((pr + br*9) / 10 >> 8), uint8((pg + bg*9) / 10 >> 8), uint8((pb + bb*9) / 10 >> 8), 255} +} diff --git a/internal/ui/monitor_prompt.go b/internal/ui/monitor_prompt.go index 5543b3e..1df86e4 100644 --- a/internal/ui/monitor_prompt.go +++ b/internal/ui/monitor_prompt.go @@ -161,7 +161,8 @@ func (m Model) renderMonitorPrompt(width, height int, colors palette) string { n = min(n, len(o.Questions)-1) header = fmt.Sprintf("%s %d/%d // %s", i18n.Text("REPLY"), n+1, len(o.Questions), o.Questions[n].Text) } - line := i18n.Text("[ Click here or press Enter to write ]") + line := colors.dimmed().Background(monitorComposerBackground(colors)). + Width(max(width-4, 1)).Render(ansi.Truncate(i18n.Text("[ Click here or press Enter to write ]"), max(width-4, 1), "")) hint := i18n.Text("Enter: send / next answer • Esc: leave editor • ↑/↓: choices") if p.offer.Token == o.Token && p.input.Focused() && !p.busy { input := p.input diff --git a/internal/ui/monitor_prompt_test.go b/internal/ui/monitor_prompt_test.go index ac8ce87..2b47bf4 100644 --- a/internal/ui/monitor_prompt_test.go +++ b/internal/ui/monitor_prompt_test.go @@ -3,16 +3,51 @@ package ui import ( "context" "errors" + "image" "strings" "testing" tea "charm.land/bubbletea/v2" "charm.land/lipgloss/v2" + uv "github.com/charmbracelet/ultraviolet" "github.com/charmbracelet/x/ansi" "github.com/merefield/codexometer/internal/codex" "github.com/merefield/codexometer/internal/i18n" ) +func TestMonitorPromptPlaceholderComposerBackground(t *testing.T) { + for theme := themeHacker; theme < themeCount; theme++ { + for _, width := range []int{24, 80, 120} { + m, _ := promptTestModel() + colors := paletteFor(theme) + placeholder := m.renderMonitorPrompt(width, 30, colors) + cells := uv.NewScreenBuffer(width, 6) + uv.NewStyledString(placeholder).Draw(&cells, image.Rect(0, 0, width, 6)) + editor := newMonitorEditor() + editor.configure(width, 30) + editor.SetValue("Typing") + editor.Focus() + active := uv.NewScreenBuffer(width, 3) + uv.NewStyledString(editor.View(colors)).Draw(&active, image.Rect(0, 0, width, 3)) + want := active.CellAt(3, 0).Style.Bg + if want == nil { + t.Fatal("composer has no background") + } + for x := 0; x < width-4; x++ { + cell := cells.CellAt(x, 1) + if cell == nil || cell.Style.Bg == nil { + t.Fatalf("theme %d width %d: missing placeholder background at %d", theme, width, x) + } + wr, wg, wb, wa := want.RGBA() + r, g, b, a := cell.Style.Bg.RGBA() + if r != wr || g != wg || b != wb || a != wa { + t.Fatalf("theme %d width %d: placeholder and composer backgrounds differ at %d", theme, width, x) + } + } + } + } +} + type promptTestClient struct { offer codex.SessionPromptOffer answers []string From 63b0a27f6595aab238af9270da395b41b6a27833 Mon Sep 17 00:00:00 2001 From: merefield Date: Tue, 6 Oct 2026 23:25:54 +0100 Subject: [PATCH 10/17] FIX: unify detail status headings and scheduled action hover --- README.md | 2 + internal/ui/monitor.go | 12 +-- internal/ui/monitor_context.go | 15 +++- internal/ui/monitor_context_modes_test.go | 8 +- internal/ui/monitor_detail.go | 2 +- internal/ui/monitor_detail_activity.go | 2 +- internal/ui/monitor_schedule.go | 2 +- internal/ui/monitor_schedule_panel.go | 33 ++++++-- internal/ui/monitor_schedule_test.go | 75 +++++++++++++++++++ .../{index-DFwvJBRP.js => index-BZEiNW06.js} | 4 +- internal/web/dist/index.html | 2 +- web/src/SessionActions.svelte | 2 +- web/src/Sessions.svelte | 2 +- web/tests/browser.spec.ts | 6 ++ 14 files changed, 143 insertions(+), 24 deletions(-) rename internal/web/dist/assets/{index-DFwvJBRP.js => index-BZEiNW06.js} (96%) diff --git a/README.md b/README.md index 99141cc..9ee48d6 100644 --- a/README.md +++ b/README.md @@ -2485,6 +2485,8 @@ theme-coloured background. Working and attention-needed statuses remain unchanged. Removing or sending the trigger restores the underlying status. Full detail retains the saved prompt and trigger information. + The full-detail border shows the current state; the body uses content labels + such as **FOLLOW-UP** and **LAST REPLY** rather than repeating that state. Its terminal attention pill comes after TURN COMPLETE, at the lowest priority. Click the pill or the label in the session's left-hand box to open that session's detail page with the saved prompt, timing and actions; web provides equivalent diff --git a/internal/ui/monitor.go b/internal/ui/monitor.go index 474a2b2..acb92b4 100644 --- a/internal/ui/monitor.go +++ b/internal/ui/monitor.go @@ -410,11 +410,11 @@ func monitorSessionDismissRect(metricsWidth, rowY int) (monitorRect, bool) { func (m Model) renderMonitorSessionBadge(session monitorSession, width int, colors palette) string { badgeLabel := "" - if session.attention != codex.SessionAttentionNone { + trigger := m.sessionTriggerStatus(session) + if trigger { + badgeLabel = "TRIGGER SET" + } else if session.attention != codex.SessionAttentionNone { badgeLabel = monitorSessionAttentionLabel(session) - if m.sessionTriggerStatus(session) { - badgeLabel = "TRIGGER SET" - } } else if m.sessionObservedWorking(session) { badgeLabel = i18n.Text("WORKING") } @@ -422,7 +422,7 @@ func (m Model) renderMonitorSessionBadge(session monitorSession, width int, colo badgeColor := colors.primary if monitorNeedsAttention(session.attention) { badgeColor = colors.warning - } else if session.attention == codex.SessionAttentionNone { + } else if session.attention == codex.SessionAttentionNone && !trigger { badgeColor = colors.success } else if session.id != "" && (session.id == m.monitorSelectedID || session.id == m.monitorContextExpanded) { // Selection accents the frame, not the meaning of the status badge. @@ -433,7 +433,7 @@ func (m Model) renderMonitorSessionBadge(session monitorSession, width int, colo badge = badge.Underline(true) } ball := "●" - if session.attention == codex.SessionAttentionNone && m.phase%2 == 1 { + if session.attention == codex.SessionAttentionNone && !trigger && m.phase%2 == 1 { ball = " " // Blink only WORKING, reserving its cell to avoid layout movement. } return badge.Render(ansi.Truncate(" "+ball+" "+badgeLabel+" ", width, "")) diff --git a/internal/ui/monitor_context.go b/internal/ui/monitor_context.go index 767e46c..a204bb3 100644 --- a/internal/ui/monitor_context.go +++ b/internal/ui/monitor_context.go @@ -182,11 +182,18 @@ func (m Model) renderMonitorContextDetail(width, height int, colors palette) str } body := strings.Join(bodyLines, "\n") action := m.renderMonitorNavigation(width, m.monitorContextDetail, true, colors) - title := i18n.Text("SESSION CONTEXT") + title := i18n.Text("UNKNOWN") if s, ok := m.contextDetailSession(); ok { + title = i18n.Text("IDLE") + if s.active { + title = i18n.Text("ACTIVE") + } if badge := m.renderMonitorSessionBadge(s, max(width-4, 1), colors); badge != "" { title = badge } + if m.monitorState != monitorRunning || m.monitorError != "" { + title = i18n.Text("STALE") + } if m.hasSessionProfile(s) { title = i18n.Text("QUOTA THRESHOLD") } @@ -323,6 +330,12 @@ func (m Model) monitorContextAt(x, y int) string { if hit := m.monitorAttentionAt(x, y); hit != "" { return hit } + if b, hit := m.scheduleButtonAt(x, y); hit { + if b.enabled { + return "schedule:" + b.key + } + return "schedule:disabled" + } g := m.monitorDashboardLayout() x -= 2 y -= g.meterY diff --git a/internal/ui/monitor_context_modes_test.go b/internal/ui/monitor_context_modes_test.go index e526073..3323cef 100644 --- a/internal/ui/monitor_context_modes_test.go +++ b/internal/ui/monitor_context_modes_test.go @@ -109,7 +109,13 @@ func TestMonitorStatusAndContentHeadings(t *testing.T) { full := strings.Split(ansi.Strip(m.renderMonitorContextDetail(120, 20, paletteFor(m.theme))), "\n") badge := ansi.Strip(m.renderMonitorSessionBadge(s, 100, paletteFor(m.theme))) if badge == "" { - badge = i18n.Text("SESSION CONTEXT") + badge = i18n.Text("IDLE") + if s.active { + badge = i18n.Text("ACTIVE") + } + } + if tc.state != monitorRunning || tc.err != "" { + badge = i18n.Text("STALE") } if !strings.Contains(full[0], badge) { t.Fatalf("full title lost telemetry badge %q: %q", badge, full[0]) diff --git a/internal/ui/monitor_detail.go b/internal/ui/monitor_detail.go index 02f3151..421aad6 100644 --- a/internal/ui/monitor_detail.go +++ b/internal/ui/monitor_detail.go @@ -42,7 +42,7 @@ func (m Model) contextDetailDocument(width int) (document []detailLine) { if j.Status == "sent" { continue } - text := "TRIGGER SET // " + m.triggerSummary(j) + text := i18n.Text("FOLLOW-UP") + " // " + m.triggerSummary(j) for _, line := range strings.Split(ansi.Hardwrap(text, width, true), "\n") { header = append(header, detailLine{ansi.Truncate(line, width, ""), "heading"}) } diff --git a/internal/ui/monitor_detail_activity.go b/internal/ui/monitor_detail_activity.go index 3fa917b..4cae3a1 100644 --- a/internal/ui/monitor_detail_activity.go +++ b/internal/ui/monitor_detail_activity.go @@ -109,7 +109,7 @@ func (m Model) layoutDetailControls(width, height int) detailControlLayout { } if m.monitorContextDetail != "" && m.hasSchedule(m.monitorContextDetail) && len(m.monitorPromptOffer().Questions) == 0 { if width < 24 || height < 8 { - return detailControlLayout{kind: "notice", rows: 1, notice: "TRIGGER SET // Ctrl+S"} + return detailControlLayout{kind: "notice", rows: 1, notice: "Ctrl+S: EDIT"} } return detailControlLayout{kind: "schedule", rows: len(m.schedulePanelLines(width))} } diff --git a/internal/ui/monitor_schedule.go b/internal/ui/monitor_schedule.go index 3eb6cc5..44b9462 100644 --- a/internal/ui/monitor_schedule.go +++ b/internal/ui/monitor_schedule.go @@ -30,7 +30,7 @@ type scheduleDone struct{ err error } // A scheduled follow-up replaces the invitation to reply, not live work or warnings. func (m Model) sessionTriggerStatus(s monitorSession) bool { - return s.attention == codex.SessionAttentionComplete && !s.working && m.hasSchedule(s.id) + return (s.attention == codex.SessionAttentionComplete || s.attention == codex.SessionAttentionNone) && !s.working && m.hasSchedule(s.id) } func (m Model) hasSchedule(id string) bool { diff --git a/internal/ui/monitor_schedule_panel.go b/internal/ui/monitor_schedule_panel.go index bed04c1..815b0a1 100644 --- a/internal/ui/monitor_schedule_panel.go +++ b/internal/ui/monitor_schedule_panel.go @@ -108,6 +108,8 @@ func (m Model) schedulePanelLines(width int) []string { style := c.label().Foreground(c.primary) if !b.enabled { style = c.dimmed() + } else if m.monitorContextHover == "schedule:"+b.key { + style = style.Foreground(c.background).Background(c.primary) } if lines[b.y] != "" { lines[b.y] += " " @@ -126,6 +128,24 @@ func (m Model) schedulePanelLines(width int) []string { return lines } +// Use the same visible rectangles for hover and click, including wrapped rows. +func (m Model) scheduleButtonAt(x, y int) (triggerButton, bool) { + if m.meterView != viewMonitor || m.monitorContextDetail == "" || m.contextTargetHidden() || !m.hasSchedule(m.monitorContextDetail) { + return triggerButton{}, false + } + g := m.monitorDashboardLayout() + if m.layoutDetailControls(g.contentWidth, g.meterHeight).kind != "schedule" || x < 4 || x >= g.contentWidth { + return triggerButton{}, false + } + _, _, top := monitorContextBodyLayout(g.meterHeight, len(m.schedulePanelLines(g.contentWidth))) + for _, b := range m.triggerButtons(g.contentWidth) { + if y == g.meterY+top+b.y && x >= 4+b.x && x < 4+b.x+ansi.StringWidth(b.text) { + return b, true + } + } + return triggerButton{}, false +} + func (m *Model) triggerAction(key string) tea.Cmd { j, ok := m.pendingTrigger() if !ok { @@ -188,15 +208,12 @@ func (m Model) schedulePanelKey(msg tea.Msg) (Model, tea.Cmd, bool) { key = k.String() } if click, ok := msg.(tea.MouseClickMsg); ok && click.Button == tea.MouseLeft { - _, _, y := monitorContextBodyLayout(g.meterHeight, len(m.schedulePanelLines(g.contentWidth))) - for _, b := range m.triggerButtons(g.contentWidth) { - if click.Y == g.meterY+y+b.y && click.X >= 4+b.x && click.X < 4+b.x+ansi.StringWidth(b.text) { - if b.enabled { - key = b.key - } - cmd := m.triggerAction(key) - return m, cmd, true + if b, hit := m.scheduleButtonAt(click.X, click.Y); hit { + if b.enabled { + key = b.key } + cmd := m.triggerAction(key) + return m, cmd, true } } if strings.Contains("|ctrl+n|ctrl+d|ctrl+y|", "|"+key+"|") || (key == "esc" && m.scheduleUI.confirmID != "") { diff --git a/internal/ui/monitor_schedule_test.go b/internal/ui/monitor_schedule_test.go index e013088..7fc17a5 100644 --- a/internal/ui/monitor_schedule_test.go +++ b/internal/ui/monitor_schedule_test.go @@ -178,6 +178,7 @@ func TestScheduleTriggerSelectionSurvivesTab(t *testing.T) { func TestScheduleFormSaveSignpostAndCancel(t *testing.T) { m, c := promptTestModel() + m.monitorSessionData[0].working = false m.width = 100 m.height = 40 m.snapshot = codex.Snapshot{AccountFingerprint: "a", FetchedAt: time.Now(), RateLimits: codex.RateLimitSnapshot{Primary: &codex.Window{UsedPercent: 100}}} @@ -295,6 +296,60 @@ func TestSchedulePanelReadOnlyAndSendNow(t *testing.T) { } } +func TestScheduleButtonsHoverMatchesClickSurfaces(t *testing.T) { + for _, width := range []int{50, 120} { + for _, confirming := range []bool{false, true} { + m, _ := scheduledTestModel(t) + m.width = width + if confirming { + m.triggerAction("ctrl+n") + } + g := m.monitorDashboardLayout() + _, _, top := monitorContextBodyLayout(g.meterHeight, len(m.schedulePanelLines(g.contentWidth))) + for _, button := range m.triggerButtons(g.contentWidth) { + x, y := 4+button.x, g.meterY+top+button.y + for _, hitX := range []int{x, x + ansi.StringWidth(button.text) - 1} { + if hitX >= g.contentWidth { + continue + } + hit, ok := m.scheduleButtonAt(hitX, y) + if !ok || hit.key != button.key || !hit.enabled { + t.Fatalf("width %d: missing click surface for %s", width, button.key) + } + updated, _ := m.Update(tea.MouseMotionMsg{X: hitX, Y: y}) + n := updated.(Model) + if n.monitorContextHover != "schedule:"+button.key { + t.Fatalf("missing hover for %s: %s", button.key, n.monitorContextHover) + } + c := paletteFor(m.theme) + want := c.label().Foreground(c.background).Background(c.primary).Render(button.text) + if !strings.Contains(strings.Join(n.schedulePanelLines(g.contentWidth), "\n"), want) { + t.Fatal("button not highlighted", button.key) + } + updated, _ = n.Update(tea.MouseMotionMsg{X: 0, Y: 0}) + if updated.(Model).monitorContextHover == "schedule:"+button.key { + t.Fatal("hover stuck after leaving button") + } + } + } + } + } + m, _ := scheduledTestModel(t) + m.snapshot.RateLimits.Primary.UsedPercent = 100 + g := m.monitorDashboardLayout() + _, _, top := monitorContextBodyLayout(g.meterHeight, len(m.schedulePanelLines(g.contentWidth))) + before := strings.Join(m.schedulePanelLines(g.contentWidth), "\n") + updated, _ := m.Update(tea.MouseMotionMsg{X: 4, Y: g.meterY + top}) + n := updated.(Model) + if n.monitorContextHover != "schedule:disabled" || strings.Join(n.schedulePanelLines(g.contentWidth), "\n") != before { + t.Fatal("disabled Send now gained hover styling") + } + n, cmd, handled := n.schedulePanelKey(tea.MouseClickMsg{X: 4, Y: g.meterY + top, Button: tea.MouseLeft}) + if !handled || cmd != nil || n.scheduleUI.confirmID != "" { + t.Fatal("disabled Send now was activated") + } +} + func TestScheduleFormKeyboardVisitsOnlyVisibleFields(t *testing.T) { m, _ := scheduledTestModel(t) m.openSchedule() @@ -372,6 +427,9 @@ func TestScheduleReplacesCompleteWithoutMaskingOtherStates(t *testing.T) { t.Fatal("duplicate or outdated row status", row) } detail := ansi.Strip(m.renderMonitorContextDetail(100, 30, paletteFor(m.theme))) + if strings.Count(detail, "TRIGGER SET") != 1 || !strings.Contains(strings.Split(detail, "\n")[0], "TRIGGER SET") { + t.Fatal("trigger state must appear only on detail border", detail) + } if !strings.Contains(detail, "The saved trigger prompt") || !strings.Contains(detail, "Not before") { t.Fatal("trigger detail disappeared", detail) } @@ -410,6 +468,23 @@ func TestScheduleReplacesCompleteWithoutMaskingOtherStates(t *testing.T) { } } +func TestScheduledIdleDetailTitleHasNoDuplicateStatus(t *testing.T) { + m, _ := scheduledTestModel(t) + m.monitorSessionData[0].attention = codex.SessionAttentionNone + m.monitorSessionData[0].working = false + for phase := 0; phase < 2; phase++ { + m.phase = phase + out := ansi.Strip(m.renderMonitorContextDetail(100, 30, paletteFor(m.theme))) + lines := strings.Split(out, "\n") + if !strings.Contains(lines[0], "● TRIGGER SET") || strings.Count(out, "TRIGGER SET") != 1 || strings.Contains(out, "SESSION CONTEXT") { + t.Fatal("idle trigger state missing, blinking, or repeated", out) + } + if !strings.Contains(out, "FOLLOW-UP //") || !strings.Contains(out, "The saved trigger prompt") { + t.Fatal("trigger information lost", out) + } + } +} + func TestScheduleHeadingNamesSessionBeforeID(t *testing.T) { for _, tc := range []struct{ name, directory, want string }{ {"Fix dashboard", "/work/project", "Fix dashboard"}, diff --git a/internal/web/dist/assets/index-DFwvJBRP.js b/internal/web/dist/assets/index-BZEiNW06.js similarity index 96% rename from internal/web/dist/assets/index-DFwvJBRP.js rename to internal/web/dist/assets/index-BZEiNW06.js index 7bea98a..e058bf4 100644 --- a/internal/web/dist/assets/index-DFwvJBRP.js +++ b/internal/web/dist/assets/index-BZEiNW06.js @@ -15,7 +15,7 @@ Codexometer cancels pending work.

            `),eo=K(`

            CURRENT PROFILE

            MODEL / REASONING LEVEL / SPEED

             

            PROPOSED PROFILE

            MODEL / REASONING LEVEL / SPEED

             

            Applied settings remain after Codexometer closes.

            `,1),to=K(`

            `),no=K(`

             
            `,1),ro=K(`

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

            `),io=K(`

            Session controls temporarily unavailable. Check Codex for current state.

            `),ao=K(`

            Checking session controls…

            `),oo=K(`

            `),so=K(`
            About browser controls

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

            `),co=K(` `,1),lo=K(` `),uo=K(`Grants permission beyond this one command. Check the scope - carefully.`),fo=K(``),po=K(``),mo=K(``),ho=K(``),go=K(`

            Not before this time; when quota and idle allow.

            `),_o=K(`

            `,1),vo=K(` `,1),yo=K(``),bo=K(``),xo=K(``),So=K(` `,1),Co=K(`
          • `),wo=K(`
            View fixed choices

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

              `),To=K(` `,1),Eo=K(`

              `),Do=K(`

              `,1),Oo=K(` `,1),ko=K(``),Ao=K(`

              `,1),jo=K(`

              `);function Mo(e,t){Ge(t,!0);let n=[],r=Hi(t,`observedCommand`,3,``),i=Hi(t,`review`,3,``),a=Hi(t,`suspended`,3,!1),o=Hi(t,`openScheduler`,3,!1),s=Hi(t,`onProtectedChange`,3,e=>{}),c=F(null),l=F(Zt([])),u=F(null),d=F(``),f=F(0),p=F(Zt(Date.now())),m=F(!1),h=F(``),g=F(!1),_=F(!1),v=F(``),y=F(!1),b=F(!1),x=F(``),S=F(`now`),C=F(60),w=F(``),T=F(!1),ee=F(``),E=F(Zt([])),D=N(()=>W(E).find(e=>e.status!==`sent`)),te=F(void 0);function ne(e){if(W(y)){dr().then(()=>W(te)?.focus());return}if(e.status!==`pending`||W(m)||!W(c)?.id||W(c).kind!==`prompt`||W(c).questions?.length)return;I(y,!0),dr().then(()=>W(te)?.focus()),I(l,[e.text],!0),I(S,e.trigger===`quota`?`quota`:`at`,!0),I(d,``),I(x,``);let t=new Date(e.at);e.trigger!==`quota`&&I(w,new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,16),!0)}bn(()=>{o()&&W(D)&&!W(b)&&W(c)?.id&&W(c).kind===`prompt`&&!W(c).questions?.length&&(I(b,!0),ne(W(D)))});async function re(){if(!i())try{I(E,await da(`schedules`,{session:t.session},_e.signal),!0),W(x)&&!W(E).some(e=>e.id===W(x)&&e.status===`pending`)&&(I(d,``),I(x,``))}catch{}}async function ie(e){try{I(E,await da(`schedules`,{session:t.session,cancelId:e},_e.signal),!0),I(y,!1),I(d,``),I(x,``),I(l,[],!0)}catch(e){I(h,e instanceof Error?e.message:`Unable to cancel trigger.`,!0)}}bn(()=>(s()(W(m)||W(l).some(e=>e.length>0)),()=>s()(!1)));let ae=N(()=>$.data?.sessions.find(e=>e.id===t.session)?.status),oe=N(()=>!$.connected||!!$.data?.sessionsError),se=N(()=>i()!==`profile`&&W(c)?.kind===`prompt`&&!W(c).questions?.length&&!!$.data?.profiles?.some(e=>e.session===t.session&&e.pending)),ce=N(()=>!W(oe)&&!W(_)&&!!W(c)?.id&&W(c).kind===`approval`&&W(v)!==W(c).id),le=N(()=>W(ce)?W(c).command:r()),ue=N(()=>!!W(d)&&W(p)W(c)?.questions?.length?W(c).questions:[{text:`Follow-up message`,secret:!1,freeText:!0,options:[]}]),fe=N(()=>W(c)?.kind===`approval`||W(c)?.kind===`profile`?W(u)!==null:W(l).length===W(de).length&&W(l).every((e,t)=>e.trim().length>0&&(W(de)[t].freeText||W(de)[t].options?.includes(e)))),pe=N(()=>W(c)?.kind===`prompt`&&!W(c).questions?.length&&W(S)!==`now`),me=N(()=>W(S)===`delay`?W(p)+W(C)*6e4:Date.parse(W(w))),he=N(()=>{if(!W(pe))return``;if(!W(l)[0]?.trim())return`Enter a message to schedule.`;if(W(S)===`quota`)return``;if(!Number.isFinite(W(me))||W(me)<=W(p))return`Choose a future date/time or a delay greater than zero.`;let e=new Date(W(p));return e.setFullYear(e.getFullYear()+1),W(me)>=e.getTime()?`Choose a time within one year.`:``});function O(e){return new Date(e).toLocaleString([],{timeZoneName:`short`})}function ge(e){if(e.status!==`pending`)return e.status;if(e.trigger===`at`&&Date.parse(e.at)>W(p))return`Due in `+Math.ceil((Date.parse(e.at)-W(p))/6e4)+` min`;let t=W(oe)?`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}bn(()=>{(W(oe)||a()||W(se)||W(p)>=W(f))&&I(d,``)});let _e=new AbortController;Ui(()=>{let e=e=>{e.ctrlKey&&e.key.toLowerCase()===`s`&&!i()&&W(D)&&(e.preventDefault(),ne(W(D)))};window.addEventListener(`keydown`,e);let n,r=setInterval(()=>{I(p,Date.now(),!0)},1e3);async function a(){await re();try{let e=await da(`offer`,{session:t.session,...i()?{review:i()}:{}},_e.signal);if(_e.signal.aborted)return;I(_,!1),W(c)?.id!==e.id&&(I(d,``),I(u,null),I(l,Array(Math.max(1,e.questions?.length||0)).fill(``),!0)),I(c,e,!0),W(g)&&e.id&&e.id!==W(v)&&(I(h,``),I(g,!1))}catch{_e.signal.aborted||(I(c,null),I(_,!0),I(d,``))}finally{_e.signal.aborted||(n=setTimeout(a,2e3))}}return a(),()=>{window.removeEventListener(`keydown`,e),_e.abort(),clearTimeout(n),clearInterval(r)}});async function ve(e){if(!W(c)?.id||W(m)||W(oe)||a()||W(se)||(e?!e.canSend:!W(fe)||W(he)))return;let n=W(c).id;I(m,!0),I(h,``),I(g,!1),I(d,``),I(x,e?.id||``,!0);try{let r=!e&&W(c).kind===`prompt`&&!W(c).questions?.length&&W(S)!==`now`?{trigger:W(S)===`quota`?`quota`:`at`,zone:Intl.DateTimeFormat().resolvedOptions().timeZone,...W(S)===`quota`?{}:{at:(W(S)===`delay`?new Date(Date.now()+W(C)*6e4):new Date(W(w))).toISOString()}}:void 0;I(T,!!r),I(ee,r?r.trigger===`quota`?`After fresh quota becomes available, when the session is idle`:O(r.at)+` — not before this time; when quota and idle allow`:``,!0);let o=await da(`prepare`,{session:t.session,...i()?{review:i()}:{},offer:n,...e?{sendId:e.id}:{},...r?{schedule:r}:{},...W(c).kind===`approval`||W(c).kind===`profile`?{choice:W(u)}:{answers:e?[e.text]:[...W(l)]}},_e.signal);W(c)?.id===n&&!_e.signal.aborted&&!W(oe)&&!a()&&!W(se)&&(I(d,o.confirmation,!0),I(f,Date.parse(o.expires),!0))}catch(e){_e.signal.aborted||I(h,e instanceof Error?e.message:`Unable to prepare action.`,!0)}finally{I(m,!1)}}async function ye(){if(!W(c)?.id||W(m)||a()||W(se)||!W(ue))return;let e=W(c).id,n=W(c).kind,r=W(d);I(d,``),I(m,!0),I(v,e,!0);try{await da(`commit`,{session:t.session,...i()?{review:i()}:{},offer:e,confirmation:r},_e.signal),I(g,!0),I(y,!1),W(T)&&(I(v,``),await re()),I(h,W(T)?`Trigger set. Closing Codexometer cancels it.`:n===`profile`?`Profile decision completed.`:n===`approval`?`Decision sent.`:`Text sent.`,!0)}catch(e){I(h,e instanceof la?e.message:`Outcome uncertain. Check Codex before taking another action; nothing was retried.`,!0)}finally{I(m,!1),I(x,``),await re(),I(l,[],!0),I(u,null)}}var be=co(),k=R(be),xe=e=>{var t=Fr();Z(R(t),17,()=>W(E).filter(e=>e.status!==`sent`),e=>e.id,(e,t)=>{var n=$a(),r=L(n),i=z(r,!0),o=B(r,2),s=z(o),l=B(o,2),u=z(l,!0),f=B(l,2),p=z(f,!0),g=B(f,2),_=z(g,!0),v=B(g,2),y=e=>{var t=Xa(),n=z(t,!0);V(()=>J(n,W(h))),q(e,t)};Y(v,e=>{W(h)&&e(y)});var b=B(v,4),S=B(b,2),C=B(S,2),w=e=>{var n=Za(),r=B(R(n),2),i=B(r,2);V(()=>r.disabled=W(m)||W(oe)||!W(t).canSend),G(`click`,r,ye),G(`click`,i,()=>{I(d,``),I(x,``)}),q(e,n)},T=e=>{var n=Qa();V(()=>n.disabled=W(m)||W(oe)||!W(t).canSend||a()),G(`click`,n,()=>ve(W(t))),q(e,n)};Y(C,e=>{W(ue)&&W(x)===W(t).id?e(w):e(T,-1)}),j(n),V((e,n)=>{J(i,W(t).status===`uncertain`?`CHECK TRIGGER — outcome uncertain; not retried`:`TRIGGER SET`),J(s,`TARGET // ${W(t).session??``}`),J(u,e),J(p,n),J(_,W(t).text),b.disabled=W(m)||!W(c)?.id||W(c).kind!==`prompt`||!!W(c).questions?.length||W(t).status!==`pending`,S.disabled=W(m)||W(t).status===`sending`},[()=>W(t).trigger===`quota`?`After confirmed quota recovery, when idle`:`Not before ${O(W(t).at)}`,()=>ge(W(t))]),G(`click`,b,()=>ne(W(t))),G(`click`,S,()=>ie(W(t).id)),q(e,n)}),q(e,t)};Y(k,e=>{i()||e(xe)});var A=B(k,2),Se=e=>{var r=jo(),a=L(r),o=z(a,!0),s=B(a,2),b=e=>{var t=eo(),n=R(t),r=z(n),i=B(n,6),a=z(i,!0),o=z(B(i,6),!0);we(2),V(()=>{J(r,`Your ${W(c).profile.threshold??``}% quota threshold has been reached. Review + carefully.`),fo=K(``),po=K(``),mo=K(``),ho=K(``),go=K(`

              Not before this time; when quota and idle allow.

              `),_o=K(`

              `,1),vo=K(` `,1),yo=K(``),bo=K(``),xo=K(``),So=K(` `,1),Co=K(`
            • `),wo=K(`
              View fixed choices

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

                `),To=K(` `,1),Eo=K(`

                `),Do=K(`

                `,1),Oo=K(` `,1),ko=K(``),Ao=K(`

                `,1),jo=K(`

                `);function Mo(e,t){Ge(t,!0);let n=[],r=Hi(t,`observedCommand`,3,``),i=Hi(t,`review`,3,``),a=Hi(t,`suspended`,3,!1),o=Hi(t,`openScheduler`,3,!1),s=Hi(t,`onProtectedChange`,3,e=>{}),c=F(null),l=F(Zt([])),u=F(null),d=F(``),f=F(0),p=F(Zt(Date.now())),m=F(!1),h=F(``),g=F(!1),_=F(!1),v=F(``),y=F(!1),b=F(!1),x=F(``),S=F(`now`),C=F(60),w=F(``),T=F(!1),ee=F(``),E=F(Zt([])),D=N(()=>W(E).find(e=>e.status!==`sent`)),te=F(void 0);function ne(e){if(W(y)){dr().then(()=>W(te)?.focus());return}if(e.status!==`pending`||W(m)||!W(c)?.id||W(c).kind!==`prompt`||W(c).questions?.length)return;I(y,!0),dr().then(()=>W(te)?.focus()),I(l,[e.text],!0),I(S,e.trigger===`quota`?`quota`:`at`,!0),I(d,``),I(x,``);let t=new Date(e.at);e.trigger!==`quota`&&I(w,new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,16),!0)}bn(()=>{o()&&W(D)&&!W(b)&&W(c)?.id&&W(c).kind===`prompt`&&!W(c).questions?.length&&(I(b,!0),ne(W(D)))});async function re(){if(!i())try{I(E,await da(`schedules`,{session:t.session},_e.signal),!0),W(x)&&!W(E).some(e=>e.id===W(x)&&e.status===`pending`)&&(I(d,``),I(x,``))}catch{}}async function ie(e){try{I(E,await da(`schedules`,{session:t.session,cancelId:e},_e.signal),!0),I(y,!1),I(d,``),I(x,``),I(l,[],!0)}catch(e){I(h,e instanceof Error?e.message:`Unable to cancel trigger.`,!0)}}bn(()=>(s()(W(m)||W(l).some(e=>e.length>0)),()=>s()(!1)));let ae=N(()=>$.data?.sessions.find(e=>e.id===t.session)?.status),oe=N(()=>!$.connected||!!$.data?.sessionsError),se=N(()=>i()!==`profile`&&W(c)?.kind===`prompt`&&!W(c).questions?.length&&!!$.data?.profiles?.some(e=>e.session===t.session&&e.pending)),ce=N(()=>!W(oe)&&!W(_)&&!!W(c)?.id&&W(c).kind===`approval`&&W(v)!==W(c).id),le=N(()=>W(ce)?W(c).command:r()),ue=N(()=>!!W(d)&&W(p)W(c)?.questions?.length?W(c).questions:[{text:`Follow-up message`,secret:!1,freeText:!0,options:[]}]),fe=N(()=>W(c)?.kind===`approval`||W(c)?.kind===`profile`?W(u)!==null:W(l).length===W(de).length&&W(l).every((e,t)=>e.trim().length>0&&(W(de)[t].freeText||W(de)[t].options?.includes(e)))),pe=N(()=>W(c)?.kind===`prompt`&&!W(c).questions?.length&&W(S)!==`now`),me=N(()=>W(S)===`delay`?W(p)+W(C)*6e4:Date.parse(W(w))),he=N(()=>{if(!W(pe))return``;if(!W(l)[0]?.trim())return`Enter a message to schedule.`;if(W(S)===`quota`)return``;if(!Number.isFinite(W(me))||W(me)<=W(p))return`Choose a future date/time or a delay greater than zero.`;let e=new Date(W(p));return e.setFullYear(e.getFullYear()+1),W(me)>=e.getTime()?`Choose a time within one year.`:``});function O(e){return new Date(e).toLocaleString([],{timeZoneName:`short`})}function ge(e){if(e.status!==`pending`)return e.status;if(e.trigger===`at`&&Date.parse(e.at)>W(p))return`Due in `+Math.ceil((Date.parse(e.at)-W(p))/6e4)+` min`;let t=W(oe)?`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}bn(()=>{(W(oe)||a()||W(se)||W(p)>=W(f))&&I(d,``)});let _e=new AbortController;Ui(()=>{let e=e=>{e.ctrlKey&&e.key.toLowerCase()===`s`&&!i()&&W(D)&&(e.preventDefault(),ne(W(D)))};window.addEventListener(`keydown`,e);let n,r=setInterval(()=>{I(p,Date.now(),!0)},1e3);async function a(){await re();try{let e=await da(`offer`,{session:t.session,...i()?{review:i()}:{}},_e.signal);if(_e.signal.aborted)return;I(_,!1),W(c)?.id!==e.id&&(I(d,``),I(u,null),I(l,Array(Math.max(1,e.questions?.length||0)).fill(``),!0)),I(c,e,!0),W(g)&&e.id&&e.id!==W(v)&&(I(h,``),I(g,!1))}catch{_e.signal.aborted||(I(c,null),I(_,!0),I(d,``))}finally{_e.signal.aborted||(n=setTimeout(a,2e3))}}return a(),()=>{window.removeEventListener(`keydown`,e),_e.abort(),clearTimeout(n),clearInterval(r)}});async function ve(e){if(!W(c)?.id||W(m)||W(oe)||a()||W(se)||(e?!e.canSend:!W(fe)||W(he)))return;let n=W(c).id;I(m,!0),I(h,``),I(g,!1),I(d,``),I(x,e?.id||``,!0);try{let r=!e&&W(c).kind===`prompt`&&!W(c).questions?.length&&W(S)!==`now`?{trigger:W(S)===`quota`?`quota`:`at`,zone:Intl.DateTimeFormat().resolvedOptions().timeZone,...W(S)===`quota`?{}:{at:(W(S)===`delay`?new Date(Date.now()+W(C)*6e4):new Date(W(w))).toISOString()}}:void 0;I(T,!!r),I(ee,r?r.trigger===`quota`?`After fresh quota becomes available, when the session is idle`:O(r.at)+` — not before this time; when quota and idle allow`:``,!0);let o=await da(`prepare`,{session:t.session,...i()?{review:i()}:{},offer:n,...e?{sendId:e.id}:{},...r?{schedule:r}:{},...W(c).kind===`approval`||W(c).kind===`profile`?{choice:W(u)}:{answers:e?[e.text]:[...W(l)]}},_e.signal);W(c)?.id===n&&!_e.signal.aborted&&!W(oe)&&!a()&&!W(se)&&(I(d,o.confirmation,!0),I(f,Date.parse(o.expires),!0))}catch(e){_e.signal.aborted||I(h,e instanceof Error?e.message:`Unable to prepare action.`,!0)}finally{I(m,!1)}}async function ye(){if(!W(c)?.id||W(m)||a()||W(se)||!W(ue))return;let e=W(c).id,n=W(c).kind,r=W(d);I(d,``),I(m,!0),I(v,e,!0);try{await da(`commit`,{session:t.session,...i()?{review:i()}:{},offer:e,confirmation:r},_e.signal),I(g,!0),I(y,!1),W(T)&&(I(v,``),await re()),I(h,W(T)?`Trigger set. Closing Codexometer cancels it.`:n===`profile`?`Profile decision completed.`:n===`approval`?`Decision sent.`:`Text sent.`,!0)}catch(e){I(h,e instanceof la?e.message:`Outcome uncertain. Check Codex before taking another action; nothing was retried.`,!0)}finally{I(m,!1),I(x,``),await re(),I(l,[],!0),I(u,null)}}var be=co(),k=R(be),xe=e=>{var t=Fr();Z(R(t),17,()=>W(E).filter(e=>e.status!==`sent`),e=>e.id,(e,t)=>{var n=$a(),r=L(n),i=z(r,!0),o=B(r,2),s=z(o),l=B(o,2),u=z(l,!0),f=B(l,2),p=z(f,!0),g=B(f,2),_=z(g,!0),v=B(g,2),y=e=>{var t=Xa(),n=z(t,!0);V(()=>J(n,W(h))),q(e,t)};Y(v,e=>{W(h)&&e(y)});var b=B(v,4),S=B(b,2),C=B(S,2),w=e=>{var n=Za(),r=B(R(n),2),i=B(r,2);V(()=>r.disabled=W(m)||W(oe)||!W(t).canSend),G(`click`,r,ye),G(`click`,i,()=>{I(d,``),I(x,``)}),q(e,n)},T=e=>{var n=Qa();V(()=>n.disabled=W(m)||W(oe)||!W(t).canSend||a()),G(`click`,n,()=>ve(W(t))),q(e,n)};Y(C,e=>{W(ue)&&W(x)===W(t).id?e(w):e(T,-1)}),j(n),V((e,n)=>{J(i,W(t).status===`uncertain`?`CHECK TRIGGER — outcome uncertain; not retried`:`SCHEDULED FOLLOW-UP`),J(s,`TARGET // ${W(t).session??``}`),J(u,e),J(p,n),J(_,W(t).text),b.disabled=W(m)||!W(c)?.id||W(c).kind!==`prompt`||!!W(c).questions?.length||W(t).status!==`pending`,S.disabled=W(m)||W(t).status===`sending`},[()=>W(t).trigger===`quota`?`After confirmed quota recovery, when idle`:`Not before ${O(W(t).at)}`,()=>ge(W(t))]),G(`click`,b,()=>ne(W(t))),G(`click`,S,()=>ie(W(t).id)),q(e,n)}),q(e,t)};Y(k,e=>{i()||e(xe)});var A=B(k,2),Se=e=>{var r=jo(),a=L(r),o=z(a,!0),s=B(a,2),b=e=>{var t=eo(),n=R(t),r=z(n),i=B(n,6),a=z(i,!0),o=z(B(i,6),!0);we(2),V(()=>{J(r,`Your ${W(c).profile.threshold??``}% quota threshold has been reached. Review the profile for subsequent turns.`),J(a,W(c).profile.current),J(o,W(c).profile.proposed)}),q(e,t)};Y(s,e=>{W(c)?.profile&&!W(oe)&&!W(_)&&e(b)});var x=B(s,2),E=e=>{var t=to();let n;var r=z(t,!0);V(()=>{n=ci(t,1,`svelte-1oupzfc`,null,n,{notice:!W(g),sent:W(g)}),J(r,W(h))}),q(e,t)};Y(x,e=>{W(h)&&e(E)});var D=B(x,2),ne=e=>{var t=no(),n=R(t),r=z(n,!0),i=z(B(n,2),!0);V(()=>{J(r,W(ce)?`EXACT COMMAND`:`LAST OBSERVED COMMAND`),J(i,W(le))}),q(e,t)},re=e=>{q(e,ro())};Y(D,e=>{W(le)?e(ne):i()!==`profile`&&W(ae)===`APPROVAL NEEDED`&&!W(g)&&e(re,1)});var ie=B(D,2),se=e=>{q(e,io())},pe=e=>{q(e,ao())},ge=e=>{var t=co(),n=R(t),r=e=>{var t=oo(),n=z(t,!0);V(e=>J(n,e),[()=>W(ae)===`WORKING`?`Codex is working — nothing to respond to.`:[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(ae)||``)?`Respond in Codex for this request.`:`Nothing needs a response right now.`]),q(e,t)};Y(n,e=>{(W(ae)===`WORKING`||!W(g)&&!W(m))&&e(r)});var i=B(n,2),a=e=>{q(e,so())},o=N(()=>[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(ae)||``)&&!W(g));Y(i,e=>{W(o)&&e(a)}),q(e,t)},_e=e=>{var r=Ao(),a=R(r),o=z(a),s=B(a,2),h=L(s),g=z(h,!0),_=B(h,2),v=e=>{var r=Fr();Z(R(r),17,()=>W(c).choices||[],X,(e,r,a)=>{var o=fo(),s=L(o);xi(s),s.value=s.__value=a;var c=B(s),l=B(c),d=e=>{var t=lo(),n=z(t,!0);V(()=>J(n,W(r).detail)),q(e,t)};Y(l,e=>{W(r).detail&&e(d)});var f=B(l,2),p=e=>{q(e,uo())};Y(f,e=>{W(r).persistent&&e(p)}),j(o),V(()=>{Q(s,`name`,`decision-`+t.session+`-`+i()),J(c,` ${W(r).label??``} `)}),Di(n,[],s,()=>W(u),e=>I(u,e)),q(e,o)}),q(e,r)},b=e=>{var t=co(),n=R(t),r=e=>{var t=vo(),n=R(t),r=B(L(n)),i=L(r),a=e=>{var t=po();t.value=t.__value=`now`,q(e,t)};Y(i,e=>{W(y)||e(a)});var o=B(i);o.value=o.__value=`quota`;var s=B(o);s.value=s.__value=`delay`;var c=B(s);c.value=c.__value=`at`,j(r),mi(r),j(n);var l=B(n,2),u=e=>{var t=mo(),n=B(L(t));xi(n),j(t),Ti(n,()=>W(C),e=>I(C,e)),q(e,t)};Y(l,e=>{W(S)===`delay`&&e(u)});var d=B(l,2),f=e=>{var t=ho(),n=B(L(t));xi(n),j(t),Ti(n,()=>W(w),e=>I(w,e)),q(e,t)};Y(d,e=>{W(S)===`at`&&e(f)});var p=B(d,2),m=e=>{var t=_o(),n=R(t),r=z(n),i=B(n,2),a=e=>{q(e,go())};Y(i,e=>{W(S)!==`quota`&&e(a)});var o=B(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, @@ -25,7 +25,7 @@ stale.

                `),qo=K(`

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

                `),Jo=K(` `),Yo=K(` `),Xo=K(` `),Zo=K(``),Qo=K(`

                Read only — reply or approve in Codex.

                `),$o=K(`

                `),es=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),ts=K(`
                `),ns=K(`
                `),rs=K(`

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

                `),is=K(`

                `),as=K(``),os=K(`

                `),ss=K(` `),cs=K(`

                `),ls=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),us=K(` `,1),ds=K(`

                `),fs=K(`

                TOKEN ACTIVITY // 30 SECOND SAMPLES

                `),ps=K(`

                TOKENS

                FULL DETAIL →
                `),ms=K(`

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

                `),hs=K(`

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

                `,1),gs=K(`

                SESSION TOTALS

                `,1);function _s(e,t){Ge(t,!0);let n=(e,t=f,n,r)=>{let i=ht(()=>g(n?.(),!0)),a=ht(()=>g(r?.(),!1));var o=Wo(),s=R(o),c=e=>{var n=Fo(),r=z(B(R(n),2),!0);we(2),V(()=>J(r,t().approvalContext)),q(e,n)};Y(s,e=>{W(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(c)});var l=B(s,2),u=e=>{var n=Io();let r;var i=z(n,!0);V(e=>{r=ci(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),J(i,e)},[()=>C(t())]),q(e,n)},d=N(()=>C(t())&&(!W(a)||W(h)||t().status===`CHECK SESSION`));Y(l,e=>{W(d)&&e(u)});var p=B(l,2),m=e=>{var n=Lo(),r=z(n,!0);V(()=>J(r,t().contextKind||`LAST ACTIVITY`)),q(e,n)};Y(p,e=>{W(i)&&e(m)});var _=B(p,2),v=e=>{var n=Ro(),r=z(n,!0);V(()=>J(r,t().text||`No session context available.`)),q(e,n)};Y(_,e=>{(t().text||!t().workingCommand)&&e(v)});var y=B(_,2),b=e=>{var n=zo(),r=B(R(n),2),i=L(r),a=B(i),o=e=>{var n=Pr();V(()=>J(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),q(e,n)};Y(a,e=>{!W(h)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(o)});var s=B(a,2),c=e=>{q(e,Pr(`+`))};Y(s,e=>{t().runningLimited&&e(c)}),j(r);var l=z(B(r,2),!0);V(e=>{J(i,`COMMAND // ${e??``} `),J(l,t().workingCommand)},[()=>W(h)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),q(e,n)};Y(y,e=>{t().workingCommand&&e(b)});var x=B(y,2),S=e=>{var n=Ho(),r=B(R(n),2),i=z(r,!0),a=B(r,2),o=e=>{var n=Bo(),r=z(n,!0);V(()=>J(r,t().command)),q(e,n)},s=e=>{q(e,Vo())};Y(a,e=>{t().command?e(o):e(s,-1)}),V(()=>J(i,W(h)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),q(e,n)};Y(x,e=>{(!W(a)||!$.data?.control)&&(t().command||t().status===`APPROVAL NEEDED`)&&e(S)});var w=B(x,2),T=e=>{var n=Uo(),r=z(n);V(()=>J(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),q(e,n)};Y(w,e=>{W(a)||e(T)}),q(e,o)},r=Hi(t,`params`,19,()=>({})),i=N(()=>$.data?.sessions||[]),a=N(()=>$.data?.control&&$.data.profiles||[]),o=N(()=>($.data?.triggers||[]).filter(e=>W(i).some(t=>t.id===e.session)));function s(e,t){if(r().id&&r().id!==t&&W(l)){e.preventDefault();return}b(t)}function c(e){return e.status===`TURN COMPLETE`&&W(o).some(t=>t.session===e.id)?`TRIGGER SET`:e.status}let l=F(!1);function u(e,t){if(r().id&&r().id!==t&&W(l)){e.preventDefault();return}b(t)}bn(()=>{let e=r().id;e&&mr(()=>{ea.selected=e,aa(e,2)})});let d=N(()=>W(i).find(e=>e.id===r().id)),p=N(()=>new URLSearchParams(Ki.querystring).get(`review`)===`profile`&&W(a).some(e=>e.session===r().id&&e.pending)),m=N(()=>W(i).some(e=>e.id===ea.selected)?ea.selected:W(i)[0]?.id),h=N(()=>!$.connected||!!$.data?.sessionsError),v=N(()=>[[`OBSERVED TOKENS`,oa(W(i).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,oa(W(i).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,W(h)?`—`:oa(W(i).filter(e=>e.status===t).length)])]),y=N(()=>W(i).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`,`CHECK SESSION`].includes(e.status)));function b(e){ea.selected=e,dr().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function x(e,t){if(b(e),r().id){t<0&&(aa(e,2),location.hash=`/sessions`);return}let n=ra(e)+t;n>2?location.hash=`/sessions/`+encodeURIComponent(e):aa(e,n)}function S(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`&&r().id)e.preventDefault(),x(r().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(r().id||W(m)))e.preventDefault(),x(r().id||W(m),e.key===`ArrowLeft`?-1:1);else if(!r().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&W(i).length){e.preventDefault();let t=W(i).findIndex(e=>e.id===W(m));b(W(i)[Math.max(0,Math.min(W(i).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function C(e){return W(h)?`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.`:$.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.`:``}var w=gs();Cr(`keydown`,en,S);var T=R(w),ee=z(B(L(T),2));j(T);var E=B(T,2);let D;Z(E,21,()=>W(v),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1];var a=Go(),o=L(a),s=z(o,!0),c=z(B(o,2),!0);j(a),V(()=>{J(s,r()),J(c,i())}),q(e,a)}),j(E);var te=B(E,2),ne=z(te),re=B(te,2),ie=e=>{q(e,Ko())};Y(re,e=>{W(h)&&e(ie)});var ae=B(re,2),oe=e=>{q(e,qo())};Y(ae,e=>{$.data?.profileError&&e(oe)});var se=B(ae,2),ce=e=>{var t=Zo(),n=L(t);Z(n,17,()=>W(y),X,(e,t)=>{var n=Jo();let r;var i=z(n);V((e,a)=>{r=ci(n,1,`button`,null,r,{approval:W(t).status===`APPROVAL NEEDED`}),Q(n,`href`,e),J(i,`${W(t).status??``} + Codexometer.

                `),hs=K(`

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

                `,1),gs=K(`

                SESSION TOTALS

                `,1);function _s(e,t){Ge(t,!0);let n=(e,t=f,n,r)=>{let i=ht(()=>g(n?.(),!0)),a=ht(()=>g(r?.(),!1));var o=Wo(),s=R(o),c=e=>{var n=Fo(),r=z(B(R(n),2),!0);we(2),V(()=>J(r,t().approvalContext)),q(e,n)};Y(s,e=>{W(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(c)});var l=B(s,2),u=e=>{var n=Io();let r;var i=z(n,!0);V(e=>{r=ci(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),J(i,e)},[()=>C(t())]),q(e,n)},d=N(()=>C(t())&&(!W(a)||W(h)||t().status===`CHECK SESSION`));Y(l,e=>{W(d)&&e(u)});var p=B(l,2),m=e=>{var n=Lo(),r=z(n,!0);V(()=>J(r,t().contextKind||`LAST ACTIVITY`)),q(e,n)};Y(p,e=>{W(i)&&e(m)});var _=B(p,2),v=e=>{var n=Ro(),r=z(n,!0);V(()=>J(r,t().text||`No session context available.`)),q(e,n)};Y(_,e=>{(t().text||!t().workingCommand)&&e(v)});var y=B(_,2),b=e=>{var n=zo(),r=B(R(n),2),i=L(r),a=B(i),o=e=>{var n=Pr();V(()=>J(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),q(e,n)};Y(a,e=>{!W(h)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(o)});var s=B(a,2),c=e=>{q(e,Pr(`+`))};Y(s,e=>{t().runningLimited&&e(c)}),j(r);var l=z(B(r,2),!0);V(e=>{J(i,`COMMAND // ${e??``} `),J(l,t().workingCommand)},[()=>W(h)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),q(e,n)};Y(y,e=>{t().workingCommand&&e(b)});var x=B(y,2),S=e=>{var n=Ho(),r=B(R(n),2),i=z(r,!0),a=B(r,2),o=e=>{var n=Bo(),r=z(n,!0);V(()=>J(r,t().command)),q(e,n)},s=e=>{q(e,Vo())};Y(a,e=>{t().command?e(o):e(s,-1)}),V(()=>J(i,W(h)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),q(e,n)};Y(x,e=>{(!W(a)||!$.data?.control)&&(t().command||t().status===`APPROVAL NEEDED`)&&e(S)});var w=B(x,2),T=e=>{var n=Uo(),r=z(n);V(()=>J(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),q(e,n)};Y(w,e=>{W(a)||e(T)}),q(e,o)},r=Hi(t,`params`,19,()=>({})),i=N(()=>$.data?.sessions||[]),a=N(()=>$.data?.control&&$.data.profiles||[]),o=N(()=>($.data?.triggers||[]).filter(e=>W(i).some(t=>t.id===e.session)));function s(e,t){if(r().id&&r().id!==t&&W(l)){e.preventDefault();return}b(t)}function c(e){return[`TURN COMPLETE`,`IDLE`,`ACTIVE`].includes(e.status)&&W(o).some(t=>t.session===e.id)?`TRIGGER SET`:e.status}let l=F(!1);function u(e,t){if(r().id&&r().id!==t&&W(l)){e.preventDefault();return}b(t)}bn(()=>{let e=r().id;e&&mr(()=>{ea.selected=e,aa(e,2)})});let d=N(()=>W(i).find(e=>e.id===r().id)),p=N(()=>new URLSearchParams(Ki.querystring).get(`review`)===`profile`&&W(a).some(e=>e.session===r().id&&e.pending)),m=N(()=>W(i).some(e=>e.id===ea.selected)?ea.selected:W(i)[0]?.id),h=N(()=>!$.connected||!!$.data?.sessionsError),v=N(()=>[[`OBSERVED TOKENS`,oa(W(i).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,oa(W(i).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,W(h)?`—`:oa(W(i).filter(e=>e.status===t).length)])]),y=N(()=>W(i).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`,`CHECK SESSION`].includes(e.status)));function b(e){ea.selected=e,dr().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function x(e,t){if(b(e),r().id){t<0&&(aa(e,2),location.hash=`/sessions`);return}let n=ra(e)+t;n>2?location.hash=`/sessions/`+encodeURIComponent(e):aa(e,n)}function S(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`&&r().id)e.preventDefault(),x(r().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(r().id||W(m)))e.preventDefault(),x(r().id||W(m),e.key===`ArrowLeft`?-1:1);else if(!r().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&W(i).length){e.preventDefault();let t=W(i).findIndex(e=>e.id===W(m));b(W(i)[Math.max(0,Math.min(W(i).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function C(e){return W(h)?`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.`:$.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.`:``}var w=gs();Cr(`keydown`,en,S);var T=R(w),ee=z(B(L(T),2));j(T);var E=B(T,2);let D;Z(E,21,()=>W(v),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1];var a=Go(),o=L(a),s=z(o,!0),c=z(B(o,2),!0);j(a),V(()=>{J(s,r()),J(c,i())}),q(e,a)}),j(E);var te=B(E,2),ne=z(te),re=B(te,2),ie=e=>{q(e,Ko())};Y(re,e=>{W(h)&&e(ie)});var ae=B(re,2),oe=e=>{q(e,qo())};Y(ae,e=>{$.data?.profileError&&e(oe)});var se=B(ae,2),ce=e=>{var t=Zo(),n=L(t);Z(n,17,()=>W(y),X,(e,t)=>{var n=Jo();let r;var i=z(n);V((e,a)=>{r=ci(n,1,`button`,null,r,{approval:W(t).status===`APPROVAL NEEDED`}),Q(n,`href`,e),J(i,`${W(t).status??``} ${a??``} // ${(W(t).name||W(t).directory||W(t).id)??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,n,()=>b(W(t).id)),q(e,n)});var c=B(n,2);Z(c,17,()=>W(a).filter(e=>e.pending&&W(i).some(t=>t.id===e.session)),X,(e,t)=>{var n=Yo(),a=z(n);V((e,i,o)=>{Q(n,`title`,r().id&&r().id!==W(t).session&&W(l)?`Finish sending or clear your current draft before switching sessions.`:`Review this session’s quota threshold`),Q(n,`href`,e),J(a,`QUOTA THRESHOLD ${i??``} // ${o??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session)+`?review=profile`,()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory||W(t).session]),G(`click`,n,e=>u(e,W(t).session)),q(e,n)}),Z(B(c,2),17,()=>W(o),X,(e,t)=>{var n=Xo(),r=z(n);V((e,t,i)=>{Q(n,`href`,e),J(r,`TRIGGER SET ${t??``} // ${i??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session),()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory]),G(`click`,n,e=>s(e,W(t).session)),q(e,n)}),j(t),q(e,t)},le=N(()=>(W(y).length||W(a).some(e=>e.pending)||W(o).length)&&!W(h));Y(se,e=>{W(le)&&e(ce)});var ue=B(se,2),de=e=>{var t=Fr(),i=R(t),o=e=>{var t=ns(),i=L(t),o=L(i),s=L(o);let u;var f=B(s);j(o);var m=B(o,2);j(i);var g=B(i,2),_=e=>{var t=Uo(),n=z(t,!0);V(()=>J(n,W(d).directory)),q(e,t)};Y(g,e=>{W(d).name&&W(d).directory&&e(_)});var v=B(g,2),y=z(v),x=B(v,2);let S;var C=L(x),w=L(C);n(w,()=>W(d),()=>!0,()=>!0),j(C);var T=B(C,2),ee=e=>{var t=Fr();qr(R(t),()=>W(d).id,e=>{{let t=N(()=>new URLSearchParams(Ki.querystring).get(`schedule`)===`edit`);Mo(e,{get session(){return W(d).id},get openScheduler(){return W(t)},get observedCommand(){return W(d).command},get suspended(){return W(p)},onProtectedChange:e=>{I(l,e,!0)}})}}),q(e,t)},E=e=>{q(e,Qo())};Y(T,e=>{$.data?.control?e(ee):e(E,-1)}),j(x);var D=B(x,2);Z(D,17,()=>W(a).filter(e=>e.session===W(d).id),e=>e.session,(e,t)=>{var n=ts(),r=L(n),i=e=>{var n=$o(),r=z(n,!0);V(()=>J(r,W(t).notice)),q(e,n)};Y(r,e=>{W(t).notice&&e(i)});var a=B(r,2),o=e=>{Mo(e,{get session(){return W(d).id},review:`profile`})},s=e=>{var t=es();V(e=>Q(t,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(d).id)+`?review=profile`]),q(e,t)};Y(a,e=>{W(t).pending&&W(p)?e(o):W(t).pending&&e(s,1)}),j(n),V(()=>Q(n,`id`,`quota-profile-`+W(d).id)),q(e,n)});var te=B(D,2),ne=e=>{var t=Fr();qr(R(t),()=>W(d).id,e=>{Po(e,{get session(){return W(d)},active:!0})}),q(e,t)};Y(te,e=>{W(p)||e(ne)}),j(t),V((e,t)=>{u=ci(s,1,`lamp lit`,null,u,{working:W(d).status===`WORKING`&&!W(h)}),J(f,`${e??``} // ${(W(d).name||W(d).directory)??``}`),J(y,`${t??``} TOKENS // ${W(d).id??``} // CONTEXT SOURCE // ${(W(d).source||`LOCAL`)??``}`),S=ui(x,``,S,{display:W(p)?`none`:void 0})},[()=>W(h)?`STALE`:W(p)?`QUOTA THRESHOLD`:c(W(d)),()=>oa(W(d).tokens)]),G(`click`,m,()=>{b(r().id),aa(r().id,2)}),q(e,t)},s=e=>{q(e,rs())};Y(i,e=>{W(d)?e(o):e(s,-1)}),q(e,t)},fe=e=>{var t=hs(),r=R(t),o=B(L(r),2),s=L(o),l=B(s,2);j(o),j(r);var d=B(r,2);Z(d,17,()=>W(i),e=>e.id,(e,t)=>{let r=N(()=>ra(W(t).id));var i=ps();let o;var s=L(i),l=L(s),d=e=>{var n=is(),r=L(n),i=z(r);j(n),V(e=>{Q(r,`aria-pressed`,W(m)===W(t).id),J(i,`${e??``} // ${W(t).name??``}`)},[()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,r,()=>b(W(t).id)),q(e,n)};Y(l,e=>{W(t).name&&e(d)});var f=B(l,2),p=L(f),g=L(p);let _;var v=B(g,1,!0);j(p),j(f);var y=B(f,2),S=e=>{var n=as(),r=z(n,!0);V(()=>{Q(n,`aria-pressed`,W(m)===W(t).id),J(r,W(t).directory||W(t).id)}),G(`click`,n,()=>b(W(t).id)),q(e,n)};Y(y,e=>{W(t).name||e(S)});var C=B(y,2),w=L(C);we(),j(C);var T=B(C,2),ee=e=>{var n=Uo(),r=z(n,!0);V(()=>J(r,W(t).directory)),q(e,n)};Y(T,e=>{W(t).name&&W(t).directory&&e(ee)});var E=B(T,2),D=z(E),te=B(E,2),ne=z(te),re=B(te,2),ie=L(re),ae=B(ie,2),oe=z(ae,!0),se=B(ae,2);j(re);var ce=B(re,2),le=B(ce,2),ue=e=>{var n=os(),r=z(n,!0);V(()=>J(r,W(t).status===`CHECK SESSION`?`INFERRED INACTIVITY`:$.data?.control?`OPEN FULL DETAIL OR REPLY IN CODEX`:W(t).status===`APPROVAL NEEDED`?`APPROVE OR DECLINE IN CODEX`:`REPLY IN CODEX`)),q(e,n)},de=N(()=>!W(h)&&[`APPROVAL NEEDED`,`INPUT NEEDED`,`CHECK SESSION`].includes(W(t).status));Y(le,e=>{W(de)&&e(ue)}),j(s);var fe=B(s,2),pe=e=>{var r=ds(),i=L(r),o=L(i),s=z(o,!0),c=B(o,2),l=e=>{var n=ss(),r=z(n,!0);V(e=>{Q(n,`href`,e),J(r,$.data?.control?`REVIEW IN FULL DETAIL ↗`:`APPROVAL IN CODEX ↗`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id)]),q(e,n)};Y(c,e=>{!W(h)&&W(t).status===`APPROVAL NEEDED`&&e(l)}),j(i);var d=B(i,2);n(d,()=>W(t),()=>!1);var f=B(d,2);Z(f,17,()=>W(a).filter(e=>e.session===W(t).id),X,(e,n)=>{var r=us(),i=R(r),a=e=>{var t=cs(),r=z(t,!0);V(()=>J(r,W(n).notice)),q(e,t)};Y(i,e=>{W(n).notice&&e(a)});var o=B(i,2),s=e=>{var n=ls();V(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(t).id)+`?review=profile`]),G(`click`,n,e=>u(e,W(t).id)),q(e,n)};Y(o,e=>{W(n).pending&&e(s)}),q(e,r)});var p=B(f,2);{let e=N(()=>W(m)===W(t).id);Po(p,{get session(){return W(t)},get active(){return W(e)}})}j(r),V(()=>J(s,W(t).contextKind||`LAST ACTIVITY`)),q(e,r)};Y(fe,e=>{W(r)>0&&e(pe)});var me=B(fe,2),he=e=>{var n=fs(),r=B(L(n),2);{let e=N(()=>(W(t).samples||[]).map(e=>e.tokens));Ya(r,{get values(){return W(e)},capacity:120})}var i=z(B(r,2));j(n),V(()=>J(i,`LAST ${(W(t).samples?.length||0)??``} SAMPLES // AUTO SCALE`)),q(e,n)};Y(me,e=>{W(r)<2&&e(he)}),j(i),V((e,n,a,s,c)=>{o=ci(i,1,`session-row`,null,o,{selected:W(m)===W(t).id,wide:W(r)===2,split:W(r)===1}),Q(i,`aria-label`,`Session `+(W(t).name||W(t).directory||W(t).id)),Q(p,`href`,e),_=ci(g,1,`lamp lit`,null,_,{working:W(t).status===`WORKING`&&!W(h)}),J(v,n),J(w,`${a??``} `),J(D,`${W(t).agents??``} LINKED AGENTS`),J(ne,`ACTIVE // ${s??``}`),ie.disabled=W(r)===0,Q(ae,`aria-expanded`,W(r)>0),J(oe,W(r)?`HIDE DETAIL`:`SHOW DETAIL`),Q(ce,`href`,c)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>W(h)?`STALE`:c(W(t)),()=>oa(W(t).tokens),()=>sa(W(t).activity),()=>`#/sessions/`+encodeURIComponent(W(t).id)]),G(`click`,p,()=>b(W(t).id)),G(`click`,ie,()=>x(W(t).id,-1)),G(`click`,ae,()=>{b(W(t).id),aa(W(t).id,+!W(r))}),G(`click`,se,()=>x(W(t).id,1)),G(`click`,ce,()=>b(W(t).id)),q(e,i)});var f=B(d,2),p=e=>{q(e,ms())};Y(f,e=>{W(i).length||e(p)}),G(`click`,s,()=>ia(1)),G(`click`,l,()=>ia(0)),q(e,t)};Y(ue,e=>{r().id?e(de):e(fe,-1)}),V(e=>{J(ee,`OBSERVED ${e??``}`),D=ci(E,1,`session-totals`,null,D,{stale:W(h)}),J(ne,`${W(h)?`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 diff --git a/internal/web/dist/index.html b/internal/web/dist/index.html index 8e921e9..87db5e5 100644 --- a/internal/web/dist/index.html +++ b/internal/web/dist/index.html @@ -5,7 +5,7 @@ Codexometer // Experimental web - + diff --git a/web/src/SessionActions.svelte b/web/src/SessionActions.svelte index df4e7df..5d02d38 100644 --- a/web/src/SessionActions.svelte +++ b/web/src/SessionActions.svelte @@ -411,7 +411,7 @@

                {job.status === 'uncertain' ? 'CHECK TRIGGER — outcome uncertain; not retried' - : 'TRIGGER SET'} + : 'SCHEDULED FOLLOW-UP'}

                TARGET // {job.session}

                diff --git a/web/src/Sessions.svelte b/web/src/Sessions.svelte index 542a476..4234dac 100644 --- a/web/src/Sessions.svelte +++ b/web/src/Sessions.svelte @@ -27,7 +27,7 @@ select(id); } function sessionStatus(session: Session) { - return session.status === 'TURN COMPLETE' && + return ['TURN COMPLETE', 'IDLE', 'ACTIVE'].includes(session.status) && triggers.some((t) => t.session === session.id) ? 'TRIGGER SET' : session.status; diff --git a/web/tests/browser.spec.ts b/web/tests/browser.spec.ts index cc06f0d..ce10de4 100644 --- a/web/tests/browser.spec.ts +++ b/web/tests/browser.spec.ts @@ -750,6 +750,12 @@ test('trigger pill and row link open detail; send now confirms the saved job', a await expect( page.getByRole('region', { name: 'Pending follow-up' }), ).toContainText('Saved job text'); + await expect(page.locator('.full-detail .detail-heading')).toContainText( + 'TRIGGER SET', + ); + await expect( + page.getByRole('region', { name: 'Pending follow-up' }), + ).not.toContainText('TRIGGER SET'); await page.getByRole('link', { name: '← ALL SESSIONS' }).click(); await page .locator('.telemetry') From 8aa4dbcc8230c18978ee6bd5d7ca7895daed0e1c Mon Sep 17 00:00:00 2001 From: merefield Date: Tue, 6 Oct 2026 23:53:17 +0100 Subject: [PATCH 11/17] FEAT: support live session composers and harden scheduled edits --- README.md | 36 +++- internal/codex/session_context_daemon.go | 2 + internal/codex/session_prompt.go | 26 +++ internal/codex/session_prompt_unix.go | 20 +- internal/codex/session_turn_unix.go | 59 ++++++ internal/codex/session_turn_unix_test.go | 83 ++++++++ internal/schedule/queue.go | 15 ++ internal/schedule/queue_test.go | 65 ++++++ internal/ui/monitor_detail.go | 3 + internal/ui/monitor_prompt.go | 89 +++++++- internal/ui/monitor_schedule.go | 6 +- internal/ui/monitor_schedule_test.go | 24 +++ internal/ui/monitor_turn_test.go | 234 +++++++++++++++++++++ internal/web/control.go | 6 +- internal/web/dist/assets/index-BZEiNW06.js | 41 ---- internal/web/dist/assets/index-iKInt6oX.js | 42 ++++ internal/web/dist/index.html | 2 +- internal/web/schedules.go | 2 +- internal/web/schedules_test.go | 51 +++++ web/src/SessionActions.svelte | 17 +- web/tests/browser.spec.ts | 61 ++++++ 21 files changed, 828 insertions(+), 56 deletions(-) create mode 100644 internal/codex/session_turn_unix.go create mode 100644 internal/codex/session_turn_unix_test.go create mode 100644 internal/ui/monitor_turn_test.go delete mode 100644 internal/web/dist/assets/index-BZEiNW06.js create mode 100644 internal/web/dist/assets/index-iKInt6oX.js diff --git a/README.md b/README.md index 9ee48d6..b3fa75a 100644 --- a/README.md +++ b/README.md @@ -1487,6 +1487,28 @@ it again. Enter still submits rather than inserting a newline. This is a text editor, not the Codex slash-command UI. Secret answers retain a single-line masked password field. +In terminal **full detail**, or the **selected wide detail row** when its context +and composer fit, a live **WORKING** turn also offers a composer once +its turn ID has been observed. Only the selected row accepts input; switching +sessions never transfers a draft to the new session. The animated progress dots sit directly above +the input. While the editor is focused, **Enter steers the current turn**, +**Tab queues the message for the next turn**, and **Esc requests interruption** +without discarding the draft. **Ctrl+C** leaves the editor without interrupting; +Esc outside the editor keeps its normal back-navigation behaviour. Once idle, +Enter sends a normal follow-up. A working-to-idle transition preserves the +draft but never submits it automatically; a key arriving during that transition +is consumed so it cannot accidentally change meaning. Approval and question +controls retain priority over the ordinary composer. + +Queuing uses Codex's experimental `thread/queue/add` API, not Codexometer's timed +scheduler. Codex owns queued-message storage and dispatch, so queued messages +may survive closing Codexometer. Manage queued messages in Codex; this first +composer integration acknowledges submissions but does not provide a queue +list/editor. If the daemon lacks this API, the action reports an error and +retains the draft—there is no silent local scheduling fallback or automatic +retry. These active-turn controls are currently terminal-only; browser controls +continue to offer idle follow-ups and explicit approvals/questions. + For a question with multiple parts, `Enter` records each answer locally; only after the last answer is the complete response sent. Use `↑`/`↓` to select offered choices. Custom text is accepted only if the question permits it, and secret @@ -1501,14 +1523,15 @@ which can be a linked agent. The editor shows the target thread or question. Drafts are memory-only, bounded to 4,096 characters per answer, and discarded when leaving detail, hiding context, or when the request/connection changes. Submitted text is sent to Codex and can become part of its normal session history. -No text is sent automatically; pressing Enter while focused is the send action. +Drafts are never submitted automatically. Explicitly queued messages are +dispatched by Codex when eligible. Capabilities are one-use and connection-bound. Follow-ups recheck the live idle state immediately before `turn/start`, and pending answers use their original JSON-RPC request and question IDs. The protocol has no atomic “start only if this completed turn is still current” condition, so avoid submitting in Codex and Codexometer simultaneously. Failed or ambiguous sends are never automatically -retried: check Codex first. Local-only, disconnected, busy and very small views +retried: check Codex first. Local-only, disconnected and very small views do not offer an editor; use Codex itself in those cases. Codexometer does not detect the CLI's visual keyboard-focus state or type into its terminal. @@ -2479,8 +2502,8 @@ browser's date/time picker and a separate review/confirmation step. Read-only we mode cannot create or access scheduled prompts. Both composers have a subtle theme-coloured background. -- **One pending follow-up per session.** Saving another replaces it. A separate - **TRIGGER SET** replaces **TURN COMPLETE** in the session status and terminal +- **One pending follow-up per session.** Saving an edit replaces it. The + **TRIGGER SET** label replaces **TURN COMPLETE** in the session status and terminal pill while a follow-up is queued; it is not repeated beside the token count. Working and attention-needed statuses remain unchanged. Removing or sending the trigger restores the underlying status. Full detail retains the saved prompt @@ -2512,6 +2535,11 @@ theme-coloured background. - Writable web detail provides **Edit · Ctrl+S**, **Delete trigger** and separately confirmed **Send now**. 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 + reopen the current trigger. Edits are checked against the exact saved job. + Active approval/question and quota-profile review panes omit unrelated saved + follow-up text, without deleting the queued trigger. - **Memory only:** keep the Codexometer process running. Quitting, restarting or crashing cancels its queue; it is not a durable background scheduler. Separate Codexometer processes have separate queues. Closing a browser tab alone does diff --git a/internal/codex/session_context_daemon.go b/internal/codex/session_context_daemon.go index 29fa80c..95068fb 100644 --- a/internal/codex/session_context_daemon.go +++ b/internal/codex/session_context_daemon.go @@ -10,6 +10,8 @@ import ( // Pending requests are keyed by JSON-RPC request id, so resolving one request // cannot clear a different outstanding question/approval for the same thread. type daemonContextState struct { + activeTurn string + turnToken string activity sessionActivityState approvalsLimited bool promptToken string diff --git a/internal/codex/session_prompt.go b/internal/codex/session_prompt.go index 863d3ca..392d26e 100644 --- a/internal/codex/session_prompt.go +++ b/internal/codex/session_prompt.go @@ -12,6 +12,32 @@ type SessionPromptOffer struct { Token string ThreadID string Questions []PromptQuestion + TurnID string // Nonempty only for a separately requested active-turn offer. +} + +// Active-turn controls are deliberately separate from idle follow-ups: neither +// scheduled jobs nor browser prompt controls may accidentally steer a turn. +type SessionTurnClient interface { + SessionTurn(string) SessionPromptOffer + SendSessionTurn(context.Context, SessionPromptOffer, string, string) error +} + +func (c Client) SessionTurn(thread string) SessionPromptOffer { + if c.LiveUsage != nil { + if p, ok := c.LiveUsage.statusProvider.(SessionTurnClient); ok { + return p.SessionTurn(thread) + } + } + return SessionPromptOffer{} +} + +func (c Client) SendSessionTurn(ctx context.Context, offer SessionPromptOffer, action, text string) error { + if c.LiveUsage != nil { + if p, ok := c.LiveUsage.statusProvider.(SessionTurnClient); ok { + return p.SendSessionTurn(ctx, offer, action, text) + } + } + return errors.New("live turn controls unavailable; use Codex") } type PromptQuestion struct { diff --git a/internal/codex/session_prompt_unix.go b/internal/codex/session_prompt_unix.go index 3d4b796..2d0ae29 100644 --- a/internal/codex/session_prompt_unix.go +++ b/internal/codex/session_prompt_unix.go @@ -13,7 +13,11 @@ import ( func (p *daemonStatusProvider) promptLifecycleLocked(method string, raw json.RawMessage) { var event struct { ThreadID string `json:"threadId"` - Status struct { + TurnID string `json:"turnId"` + Turn struct { + ID string `json:"id"` + } `json:"turn"` + Status struct { Type string `json:"type"` ActiveFlags []string `json:"activeFlags"` } `json:"status"` @@ -21,6 +25,20 @@ func (p *daemonStatusProvider) promptLifecycleLocked(method string, raw json.Raw if json.Unmarshal(raw, &event) != nil || event.ThreadID == "" { return } + if method == "turn/started" { + if p.contexts == nil { + p.contexts = map[string]*daemonContextState{} + } + p.contexts[event.ThreadID] = &daemonContextState{activeTurn: event.Turn.ID, requests: map[string]SessionContext{}, commands: map[string]contextCommandItem{}} + } + if s := p.contexts[event.ThreadID]; s != nil { + if event.TurnID != "" && s.activeTurn == "" && p.statuses[event.ThreadID] == sessionRuntimeWorking { + s.activeTurn = event.TurnID + } + if method == "turn/completed" || method == "turn/interrupted" { + s.activeTurn, s.turnToken = "", "" + } + } status := sessionRuntimeUnknown switch method { case "turn/started": diff --git a/internal/codex/session_turn_unix.go b/internal/codex/session_turn_unix.go new file mode 100644 index 0000000..d8b5b14 --- /dev/null +++ b/internal/codex/session_turn_unix.go @@ -0,0 +1,59 @@ +//go:build unix + +package codex + +import ( + "context" + "crypto/rand" + "errors" +) + +func (p *daemonStatusProvider) SessionTurn(thread string) SessionPromptOffer { + p.mu.Lock() + defer p.mu.Unlock() + s := p.contexts[thread] + _, subscribed := p.subscribed[thread] + if p.connection == nil || !subscribed || s == nil || s.activeTurn == "" || len(s.requests) != 0 || p.statuses[thread] != sessionRuntimeWorking { + return SessionPromptOffer{} + } + if s.turnToken == "" { + s.turnToken = rand.Text() + } + return SessionPromptOffer{Token: s.turnToken, ThreadID: thread, TurnID: s.activeTurn} +} + +func (p *daemonStatusProvider) SendSessionTurn(ctx context.Context, offer SessionPromptOffer, action, text string) error { + if err := ctx.Err(); err != nil { + return err + } + if action != "interrupt" && action != "steer" && action != "queue" { + return errors.New("unknown turn action") + } + if action != "interrupt" && !validPromptAnswers(SessionPromptOffer{}, []string{text}) { + return errors.New("invalid message") + } + p.mu.Lock() + s, connection := p.contexts[offer.ThreadID], p.connection + _, subscribed := p.subscribed[offer.ThreadID] + if connection == nil || !subscribed || s == nil || offer.Token == "" || offer.TurnID == "" || s.turnToken != offer.Token || s.activeTurn != offer.TurnID || len(s.requests) != 0 || p.statuses[offer.ThreadID] != sessionRuntimeWorking { + p.mu.Unlock() + return errors.New("turn changed; review Codex before sending") + } + // Consume before IO; ambiguous mutations are never automatically retried. + s.turnToken = "" + p.mu.Unlock() + params := map[string]any{"threadId": offer.ThreadID} + method := "turn/" + action + switch action { + case "interrupt": + params["turnId"] = offer.TurnID + case "steer": + params["expectedTurnId"] = offer.TurnID + params["input"] = []any{map[string]any{"type": "text", "text": text}} + case "queue": + method = "thread/queue/add" + params["clientUserMessageId"] = rand.Text() + params["input"] = []any{map[string]any{"type": "text", "text": text}} + } + return p.requestOn(ctx, connection, method, params, nil) +} diff --git a/internal/codex/session_turn_unix_test.go b/internal/codex/session_turn_unix_test.go new file mode 100644 index 0000000..04aed13 --- /dev/null +++ b/internal/codex/session_turn_unix_test.go @@ -0,0 +1,83 @@ +//go:build unix + +package codex + +import ( + "context" + "encoding/json" + "testing" +) + +func TestSessionTurnWireAndIsolation(t *testing.T) { + for _, action := range []string{"steer", "queue", "interrupt"} { + t.Run(action, func(t *testing.T) { + p, received := promptProvider(t, "active") + p.mu.Lock() + p.promptLifecycleLocked("turn/started", json.RawMessage(`{"threadId":"root","turn":{"id":"turn-one"}}`)) + p.mu.Unlock() + o := p.SessionTurn("root") + if o.Token == "" || o.TurnID != "turn-one" || p.SessionPrompt("root").Token != "" { + t.Fatal("active offer missing or leaked into idle API") + } + if err := p.SendSessionTurn(context.Background(), o, action, "next task"); err != nil { + t.Fatal(err) + } + e := <-received + var params map[string]json.RawMessage + if err := json.Unmarshal(e.Params, ¶ms); err != nil { + t.Fatal(err) + } + method := "turn/" + action + if action == "queue" { + method = "thread/queue/add" + } + if e.Method != method || string(params["threadId"]) != `"root"` { + t.Fatal(e.Method, string(e.Params)) + } + if action == "steer" && string(params["expectedTurnId"]) != `"turn-one"` { + t.Fatal(string(e.Params)) + } + if action == "interrupt" && string(params["turnId"]) != `"turn-one"` { + t.Fatal(string(e.Params)) + } + if action == "queue" && len(params["clientUserMessageId"]) < 10 { + t.Fatal("missing client identity") + } + if action != "interrupt" && string(params["input"]) != `[{"text":"next task","type":"text"}]` { + t.Fatal(string(e.Params)) + } + if err := p.SendSessionTurn(context.Background(), o, action, "duplicate"); err == nil { + t.Fatal("reused capability") + } + }) + } +} + +func TestSessionTurnRejectsChangedTurnAndApproval(t *testing.T) { + p, received := promptProvider(t, "active") + p.mu.Lock() + p.promptLifecycleLocked("turn/started", json.RawMessage(`{"threadId":"root","turn":{"id":"one"}}`)) + p.mu.Unlock() + o := p.SessionTurn("root") + p.mu.Lock() + p.promptLifecycleLocked("turn/started", json.RawMessage(`{"threadId":"root","turn":{"id":"two"}}`)) + p.mu.Unlock() + if err := p.SendSessionTurn(context.Background(), o, "interrupt", ""); err == nil { + t.Fatal("interrupted replacement turn") + } + o = p.SessionTurn("root") + p.mu.Lock() + p.contexts["root"].requests["approval"] = SessionContext{Kind: SessionContextApproval} + p.mu.Unlock() + if p.SessionTurn("root").Token != "" { + t.Fatal("approval exposed composer") + } + if err := p.SendSessionTurn(context.Background(), o, "queue", "message"); err == nil { + t.Fatal("approval bypassed") + } + select { + case e := <-received: + t.Fatal("unexpected write", e.Method) + default: + } +} diff --git a/internal/schedule/queue.go b/internal/schedule/queue.go index 73b9c73..462bbc4 100644 --- a/internal/schedule/queue.go +++ b/internal/schedule/queue.go @@ -51,6 +51,16 @@ func (q *Queue) List(session string) []Job { } func (q *Queue) Save(j Job, account string, now time.Time) error { + return q.save(j, account, now, nil) +} + +// SaveIfCurrent binds an edit to the exact pending job. An empty expected ID +// creates only if there is no current job. Check and replacement share the lock. +func (q *Queue) SaveIfCurrent(j Job, account string, now time.Time, expectedID string) error { + return q.save(j, account, now, &expectedID) +} + +func (q *Queue) save(j Job, account string, now time.Time, expectedID *string) error { j.Text = strings.TrimSpace(j.Text) if account == "" || j.Session == "" || len(j.Session) > 512 || j.Text == "" || len([]rune(j.Text)) > 4096 || len(j.Zone) > 128 || codex.SanitizeSessionContext(j.Text) != j.Text || (j.Trigger == "quota" && !j.At.IsZero()) || (j.Trigger != "at" && j.Trigger != "quota") || (j.Trigger == "at" && (!j.At.After(now) || j.At.After(now.AddDate(1, 0, 0)))) { @@ -69,6 +79,11 @@ func (q *Queue) Save(j Job, account string, now time.Time) error { break } } + if expectedID != nil { + if index < 0 && *expectedID != "" || index >= 0 && (q.jobs[index].ID != *expectedID || !q.jobs[index].MatchesAccount(account)) { + return errors.New("trigger changed, removed or already sent; reopen it before editing") + } + } j.Status = "pending" j.ID = rand.Text() // An edit invalidates confirmations for the old payload. j.Windows = append([]string(nil), j.Windows...) diff --git a/internal/schedule/queue_test.go b/internal/schedule/queue_test.go index d05c01d..2ef361f 100644 --- a/internal/schedule/queue_test.go +++ b/internal/schedule/queue_test.go @@ -28,6 +28,71 @@ func TestPreflightDeferralDoesNotBecomeUncertain(t *testing.T) { } } +func TestEditsRequireCurrentPendingJob(t *testing.T) { + for _, change := range []string{"replace", "cancel", "send", "account"} { + t.Run(change, func(t *testing.T) { + q, now := New(), time.Now() + job := Job{Session: "one", Text: "original", Trigger: "quota"} + if err := q.SaveIfCurrent(job, "a", now, ""); err != nil { + t.Fatal(err) + } + id := q.List("one")[0].ID + account := "a" + switch change { + case "replace": + job.Text = "newer edit" + if err := q.SaveIfCurrent(job, "a", now, id); err != nil { + t.Fatal(err) + } + case "cancel": + if err := q.Cancel("one", id); err != nil { + t.Fatal(err) + } + case "send": + if err := q.Dispatch(context.Background(), id, "a", true, now, func(context.Context, Job) error { return nil }); err != nil { + t.Fatal(err) + } + case "account": + account = "b" + } + job.Text = "stale edit" + if err := q.SaveIfCurrent(job, account, now, id); err == nil { + t.Fatal("stale edit accepted") + } + for _, j := range q.List("one") { + if j.Text == "stale edit" { + t.Fatal("stale edit changed queue") + } + } + }) + } +} + +func TestConcurrentEditsHaveOneWinner(t *testing.T) { + q, now := New(), time.Now() + j := Job{Session: "one", Text: "original", Trigger: "quota"} + if err := q.SaveIfCurrent(j, "a", now, ""); err != nil { + t.Fatal(err) + } + id := q.List("one")[0].ID + if err := q.SaveIfCurrent(j, "a", now, ""); err == nil { + t.Fatal("create overwrote existing job") + } + var wg sync.WaitGroup + var wins atomic.Int32 + for range 2 { + wg.Go(func() { + if q.SaveIfCurrent(j, "a", now, id) == nil { + wins.Add(1) + } + }) + } + wg.Wait() + if wins.Load() != 1 { + t.Fatalf("%d edits won", wins.Load()) + } +} + func TestCompletedJobsDoNotConsumeQueueCapacity(t *testing.T) { q := New() now := time.Now() diff --git a/internal/ui/monitor_detail.go b/internal/ui/monitor_detail.go index 421aad6..3fab322 100644 --- a/internal/ui/monitor_detail.go +++ b/internal/ui/monitor_detail.go @@ -34,6 +34,9 @@ func (line detailLine) render(colors palette) string { func (m Model) contextDetailDocument(width int) (document []detailLine) { width = max(width, 1) defer func() { + if s, ok := m.contextDetailSession(); ok && (m.hasSessionProfile(s) || s.preview.Kind == codex.SessionContextApproval || s.preview.Kind == codex.SessionContextQuestion || s.attention == codex.SessionAttentionApproval || s.attention == codex.SessionAttentionInput) { + return // A live review owns the detail document; never prepend another prompt. + } if !m.hasSchedule(m.monitorContextDetail) { return } diff --git a/internal/ui/monitor_prompt.go b/internal/ui/monitor_prompt.go index 1df86e4..a672208 100644 --- a/internal/ui/monitor_prompt.go +++ b/internal/ui/monitor_prompt.go @@ -28,6 +28,11 @@ type monitorPromptResult struct { err error } +type monitorTurnResult struct { + session, token, action string + err error +} + func (m Model) monitorPromptOffer() codex.SessionPromptOffer { if m.meterView != viewMonitor || m.monitorContextTarget() == "" || m.contextTargetHidden() || (m.monitorContextDetail == "" && (m.monitorSelectedID != m.monitorContextTarget() || m.rowContextMode(m.monitorSelectedID) != contextWide)) { @@ -54,6 +59,11 @@ func (m Model) monitorPromptOffer() codex.SessionPromptOffer { thread = s.preview.ThreadID } o := c.SessionPrompt(thread) + if o.Token == "" { + if active, ok := m.fetcher.(codex.SessionTurnClient); ok { + o = active.SessionTurn(thread) + } + } // Structured questions retain the full-detail interface. if m.monitorContextDetail == "" && len(o.Questions) > 0 { return codex.SessionPromptOffer{} @@ -138,7 +148,11 @@ func (m *Model) focusMonitorPrompt() tea.Cmd { return nil } if m.monitorPrompt.offer.Token != o.Token { - m.monitorPrompt = monitorPromptState{session: m.monitorContextTarget(), offer: o, input: newMonitorEditor(), choice: -1} + if m.monitorPrompt.offer.Token != "" && m.monitorPrompt.session == m.monitorContextTarget() && len(o.Questions) == 0 && len(m.monitorPrompt.offer.Questions) == 0 { + m.monitorPrompt.offer = o + } else { + m.monitorPrompt = monitorPromptState{session: m.monitorContextTarget(), offer: o, input: newMonitorEditor(), choice: -1} + } } m.monitorPrompt.input.setSecret(len(o.Questions) > 0 && o.Questions[m.monitorPrompt.question].Secret) m.monitorPrompt.input.configure(w, m.monitorPromptEditorHeight(w, h)) @@ -150,7 +164,7 @@ func (m Model) renderMonitorPrompt(width, height int, colors palette) string { p := m.monitorPrompt o := m.monitorPromptOffer() header := i18n.Text("FOLLOW-UP") + " // " + terminalLabel(o.ThreadID) - if m.monitorContextDetail != "" && len(o.Questions) == 0 { + if m.monitorContextDetail != "" && len(o.Questions) == 0 && o.TurnID == "" { header += " // [ Ctrl+S: SCHEDULE ]" } if len(o.Questions) > 0 { @@ -164,6 +178,10 @@ func (m Model) renderMonitorPrompt(width, height int, colors palette) string { line := colors.dimmed().Background(monitorComposerBackground(colors)). Width(max(width-4, 1)).Render(ansi.Truncate(i18n.Text("[ Click here or press Enter to write ]"), max(width-4, 1), "")) hint := i18n.Text("Enter: send / next answer • Esc: leave editor • ↑/↓: choices") + if o.TurnID != "" { + header = i18n.Text("WORKING") + " " + monitorDotWave(m.phase) + " // " + i18n.Text("FOLLOW-UP") + hint = "Enter: steer • Tab: queue next turn • Esc: interrupt" + } if p.offer.Token == o.Token && p.input.Focused() && !p.busy { input := p.input input.configure(width, m.monitorPromptEditorHeight(width, height)) @@ -188,6 +206,24 @@ func (m Model) renderMonitorPrompt(width, height int, colors palette) string { func (m Model) updateMonitorPrompt(msg tea.Msg) (Model, tea.Cmd, bool) { p := &m.monitorPrompt + if result, ok := msg.(monitorTurnResult); ok { + if p.session == result.session && p.offer.Token == result.token { + p.busy = false + if result.err != nil { + p.notice = "Action unconfirmed or unsupported; check Codex before retrying. Draft retained." + } else if result.action == "interrupt" { + p.notice = "Interrupt requested. Draft retained." + } else { + p.input.Reset() + p.notice = i18n.Text("Text sent ...") + m.recordDetailSent(p.notice) + if result.action == "queue" { + p.notice = "Queued in Codex for the next turn." + } + } + } + return m, nil, true + } if result, ok := msg.(monitorPromptResult); ok { if p.session == result.session && p.offer.Token == result.token { p.busy = false @@ -218,7 +254,21 @@ func (m Model) updateMonitorPrompt(msg tea.Msg) (Model, tea.Cmd, bool) { if p.session != "" && (m.meterView != viewMonitor || m.monitorContextTarget() != p.session || m.contextTargetHidden() || m.monitorContextDetail == "" && m.monitorSelectedID != p.session) { *p = monitorPromptState{} } else if p.offer.Token != "" && !p.busy && m.monitorPromptOffer().Token != p.offer.Token { - *p = monitorPromptState{session: p.session, notice: i18n.Text("Prompt changed; review the session before replying.")} + next := m.monitorPromptOffer() + if len(p.offer.Questions) == 0 && len(next.Questions) == 0 && (p.offer.TurnID != "" || next.TurnID != "") { + // Keep ordinary drafts across working/idle transitions, but never + // reinterpret the key that arrived during a capability change. + if next.Token != "" { + p.offer = next + } else { + p.input.Blur() + } + if _, key := msg.(tea.KeyPressMsg); key { + return m, nil, true + } + } else { + *p = monitorPromptState{session: p.session, notice: i18n.Text("Prompt changed; review the session before replying.")} + } } if wasFocused && !p.input.Focused() { switch msg.(type) { @@ -226,16 +276,32 @@ func (m Model) updateMonitorPrompt(msg tea.Msg) (Model, tea.Cmd, bool) { return m, nil, true } } + if p.busy && p.input.Focused() { + switch msg.(type) { + case tea.KeyPressMsg, tea.PasteMsg: + return m, nil, true + } + } if !p.input.Focused() || p.busy { return m, nil, false } if key, ok := msg.(tea.KeyPressMsg); ok { switch key.String() { case "esc", "ctrl+c": + if key.String() == "esc" && p.offer.TurnID != "" { + return m.submitMonitorTurn("interrupt") + } p.input.Blur() return m, nil, true case "enter": + if p.offer.TurnID != "" { + return m.submitMonitorTurn("steer") + } return m.submitMonitorPrompt() + case "tab": + if p.offer.TurnID != "" { + return m.submitMonitorTurn("queue") + } case "up", "down": if len(p.offer.Questions) > 0 { options := p.offer.Questions[p.question].Options @@ -269,6 +335,23 @@ func (m Model) updateMonitorPrompt(msg tea.Msg) (Model, tea.Cmd, bool) { return m, nil, false } +func (m Model) submitMonitorTurn(action string) (Model, tea.Cmd, bool) { + p := &m.monitorPrompt + o := m.monitorPromptOffer() + c, ok := m.fetcher.(codex.SessionTurnClient) + text := strings.TrimSpace(p.input.Value()) + if !ok || p.busy || o.Token == "" || o.Token != p.offer.Token || o.TurnID == "" || action != "interrupt" && text == "" { + return m, nil, true + } + p.busy, p.notice = true, "" + session := p.session + return m, func() tea.Msg { + ctx, cancel := context.WithTimeout(context.Background(), 6*time.Second) + defer cancel() + return monitorTurnResult{session: session, token: o.Token, action: action, err: c.SendSessionTurn(ctx, o, action, text)} + }, true +} + func (m Model) submitMonitorPrompt() (Model, tea.Cmd, bool) { p := &m.monitorPrompt if p.busy || p.offer.Token == "" || m.monitorPromptOffer().Token != p.offer.Token { diff --git a/internal/ui/monitor_schedule.go b/internal/ui/monitor_schedule.go index 44b9462..c31f76d 100644 --- a/internal/ui/monitor_schedule.go +++ b/internal/ui/monitor_schedule.go @@ -51,7 +51,7 @@ func (m *Model) openSchedule() tea.Cmd { } id := m.monitorContextDetail o := m.monitorPromptOffer() - if !m.hasSchedule(id) && (o.Token == "" || o.ThreadID != id || len(o.Questions) > 0) { + if !m.hasSchedule(id) && (o.Token == "" || o.TurnID != "" || o.ThreadID != id || len(o.Questions) > 0) { return nil } q := m.scheduleUI.queue @@ -291,7 +291,7 @@ func (m Model) updateSchedule(msg tea.Msg) (Model, tea.Cmd, bool) { return m, nil, true } o := m.monitorPromptOffer() - if o.Token == "" || o.ThreadID != p.session || len(o.Questions) > 0 || m.err != nil || !schedule.Fresh(m.snapshot, time.Now()) { + if o.Token == "" || o.TurnID != "" || o.ThreadID != p.session || len(o.Questions) > 0 || m.err != nil || !schedule.Fresh(m.snapshot, time.Now()) { p.notice = "Session unavailable or changed; review in Codex." return m, nil, true } @@ -304,7 +304,7 @@ func (m Model) updateSchedule(msg tea.Msg) (Model, tea.Cmd, bool) { j.Trigger = "at" j.At = p.date } - if err := p.queue.Save(j, m.snapshot.AccountFingerprint, time.Now()); err != nil { + if err := p.queue.SaveIfCurrent(j, m.snapshot.AccountFingerprint, time.Now(), p.id); err != nil { p.notice = err.Error() } else { p.open = false diff --git a/internal/ui/monitor_schedule_test.go b/internal/ui/monitor_schedule_test.go index 7fc17a5..22f94e8 100644 --- a/internal/ui/monitor_schedule_test.go +++ b/internal/ui/monitor_schedule_test.go @@ -485,6 +485,30 @@ func TestScheduledIdleDetailTitleHasNoDuplicateStatus(t *testing.T) { } } +func TestScheduledPromptDoesNotPrecedeReviews(t *testing.T) { + for _, kind := range []codex.SessionContextKind{codex.SessionContextApproval, codex.SessionContextQuestion} { + m, _ := scheduledTestModel(t) + m.monitorSessionData[0].preview.Kind = kind + m.monitorSessionData[0].preview.Text = "Actual request requiring a response" + out := ansi.Strip(m.renderMonitorContextDetail(100, 30, paletteFor(m.theme))) + if strings.Contains(out, "The saved trigger prompt") || !strings.Contains(out, "Actual request requiring a response") { + t.Fatal("saved prompt crowded out request", out) + } + if !m.hasSchedule("root-one") { + t.Fatal("hiding saved prompt removed trigger") + } + } + m, _ := profileTestModel(t) + m.scheduleUI.queue = schedule.New() + if err := m.scheduleUI.queue.Save(schedule.Job{Session: "one", Text: "Unrelated scheduled prompt", Trigger: "quota"}, "a", time.Now()); err != nil { + t.Fatal(err) + } + out := ansi.Strip(m.renderMonitorContextDetail(120, 40, paletteFor(m.theme))) + if strings.Contains(out, "Unrelated scheduled prompt") || !strings.Contains(out, "CURRENT PROFILE") { + t.Fatal("saved prompt leaked into profile review", out) + } +} + func TestScheduleHeadingNamesSessionBeforeID(t *testing.T) { for _, tc := range []struct{ name, directory, want string }{ {"Fix dashboard", "/work/project", "Fix dashboard"}, diff --git a/internal/ui/monitor_turn_test.go b/internal/ui/monitor_turn_test.go new file mode 100644 index 0000000..3411918 --- /dev/null +++ b/internal/ui/monitor_turn_test.go @@ -0,0 +1,234 @@ +package ui + +import ( + "context" + "errors" + "strings" + "testing" + + tea "charm.land/bubbletea/v2" + "github.com/charmbracelet/x/ansi" + "github.com/merefield/codexometer/internal/codex" +) + +type turnTestClient struct { + *promptTestClient + active codex.SessionPromptOffer + action, text string +} + +func inlineTurnTestModel() (Model, *turnTestClient) { + m, idle := inlinePromptTestModel() + idle.offer = codex.SessionPromptOffer{} + c := &turnTestClient{promptTestClient: idle, active: codex.SessionPromptOffer{Token: "working", ThreadID: "root-one", TurnID: "turn"}} + m.fetcher = c + return m, c +} + +func TestInlineWorkingComposerKeysAndClicks(t *testing.T) { + for _, width := range []int{80, 120, 200} { + for _, tc := range []struct { + key rune + action string + }{{tea.KeyEnter, "steer"}, {tea.KeyTab, "queue"}, {tea.KeyEscape, "interrupt"}} { + m, c := inlineTurnTestModel() + m.width = width + w, h := m.monitorPromptSize() + rows := m.monitorPromptRows(w, h) + if rows != 3 || !strings.Contains(ansi.Strip(m.render()), "Tab: queue") { + t.Fatalf("missing working composer at width %d", width) + } + g := m.dashboardLayout() + a := m.monitorArea(g.contentWidth, g.meterHeight) + mw, _, _ := monitorSessionColumnWidths(a.width) + _, _, cy := monitorContextBodyLayout(h, rows) + y := g.meterY + a.topHeight + a.gap - 1 + cy + 1 + for x := mw + 5; x < mw+3+w-2; x++ { + if got := m.monitorContextAt(x, y); got != "prompt" { + t.Fatalf("click %d,%d = %q", x, y, got) + } + } + next, _ := m.Update(tea.MouseClickMsg{X: mw + 5, Y: y, Button: tea.MouseLeft}) + m = next.(Model) + if !m.monitorPrompt.input.Focused() || m.monitorContextDetail != "" { + t.Fatal("inline click navigated instead of focusing") + } + m.monitorPrompt.input.SetValue("Inline task") + m, cmd := promptKey(m, tc.key, "") + if cmd == nil { + t.Fatal("missing turn command") + } + m, _, _ = m.updateMonitorPrompt(cmd()) + if c.action != tc.action || c.text != "Inline task" { + t.Fatal(c.action, c.text) + } + if tc.action == "interrupt" && m.monitorPrompt.input.Value() != "Inline task" { + t.Fatal("interrupt discarded draft") + } + } + } +} + +func TestInlineWorkingComposerSpaceAndSelection(t *testing.T) { + m, c := inlineTurnTestModel() + w, h := m.monitorPromptSize() + m.monitorSessionData[0].preview.Text = strings.Repeat("context\n", 100) + if m.monitorPromptRows(w, h) != 0 { + t.Fatal("composer displaced context") + } + m.monitorSessionData[0].preview.Text = "Working." + m.monitorSessionData[0].preview.Kind = codex.SessionContextApproval + if m.monitorPromptRows(w, h) != 0 { + t.Fatal("composer displaced approval") + } + m.monitorSessionData[0].preview.Kind = codex.SessionContextActivity + m.focusMonitorPrompt() + m.monitorPrompt.input.SetValue("Private draft") + next, _ := m.Update(tea.WindowSizeMsg{Width: 60, Height: 14}) + m = next.(Model) + w, h = m.monitorPromptSize() + if m.monitorPromptRows(w, h) != 0 || m.monitorPrompt.input.Focused() { + t.Fatal("hidden composer retained focus") + } + if c.action != "" { + t.Fatal("resize sent input") + } + next, _ = m.Update(tea.WindowSizeMsg{Width: 160, Height: 40}) + m = next.(Model) + m.focusMonitorPrompt() + if m.monitorPrompt.input.Value() != "Private draft" { + t.Fatal("resize lost draft") + } + m.monitorSelectedID = "another" + m, _, _ = m.updateMonitorPrompt(tea.KeyPressMsg(tea.Key{Code: tea.KeyEnter})) + if m.monitorPrompt.input.Value() != "" || m.monitorPrompt.input.Focused() || c.action != "" { + t.Fatal("draft or action leaked to new selection") + } +} + +func TestInlineWorkingComposerSingleOwner(t *testing.T) { + m, idle := promptTestModel() + idle.offer = codex.SessionPromptOffer{} + m.width, m.height = 180, 65 + m.monitorSessionData = m.monitorSessionData[:2] + for i := range m.monitorSessionData { + m.monitorSessionData[i].preview.Text = "Working." + m.setRowContext(m.monitorSessionData[i].id, contextWide) + } + id := m.monitorSessionData[1].id + c := &turnTestClient{promptTestClient: idle, active: codex.SessionPromptOffer{Token: "second-turn", ThreadID: id, TurnID: "turn-two"}} + m.fetcher = c + if got := strings.Count(ansi.Strip(m.render()), "Tab: queue"); got != 1 { + t.Fatalf("rendered %d working composers, want one", got) + } + m.focusMonitorPrompt() + if m.monitorPrompt.session != id { + t.Fatal("wrong session owns composer") + } + m.monitorPrompt.input.SetValue("Only second session") + m, cmd := promptKey(m, tea.KeyTab, "") + if cmd == nil { + t.Fatal("missing queue command") + } + m, _, _ = m.updateMonitorPrompt(cmd()) + if c.action != "queue" || c.text != "Only second session" { + t.Fatal("queue targeted wrong session") + } + m.selectMonitorSession(-1) + if m.monitorPromptOffer().Token != "" || m.monitorPrompt.input.Focused() { + t.Fatal("selection change retained previous working composer") + } +} + +func (c *turnTestClient) SessionTurn(id string) codex.SessionPromptOffer { + if id == c.active.ThreadID { + return c.active + } + return codex.SessionPromptOffer{} +} +func (c *turnTestClient) SendSessionTurn(_ context.Context, o codex.SessionPromptOffer, action, text string) error { + if o.Token != c.active.Token { + return errors.New("expired") + } + c.action, c.text = action, text + return c.err +} +func turnTestModel() (Model, *turnTestClient) { + m, idle := promptTestModel() + idle.offer = codex.SessionPromptOffer{} + c := &turnTestClient{promptTestClient: idle, active: codex.SessionPromptOffer{Token: "working", ThreadID: "root-one", TurnID: "turn"}} + m.fetcher = c + m.focusMonitorPrompt() + m.monitorPrompt.input.SetValue("Keep this draft") + return m, c +} +func TestWorkingComposerKeys(t *testing.T) { + for _, tc := range []struct { + key rune + action string + }{{tea.KeyEnter, "steer"}, {tea.KeyTab, "queue"}, {tea.KeyEscape, "interrupt"}} { + t.Run(tc.action, func(t *testing.T) { + m, c := turnTestModel() + m, cmd := promptKey(m, tc.key, "") + if cmd == nil { + t.Fatal("missing command") + } + m, _, _ = m.updateMonitorPrompt(cmd()) + if c.action != tc.action || c.text != "Keep this draft" { + t.Fatal(c.action, c.text) + } + if tc.action == "interrupt" && m.monitorPrompt.input.Value() != "Keep this draft" { + t.Fatal("draft lost") + } + if tc.action != "interrupt" && m.monitorPrompt.input.Value() != "" { + t.Fatal("sent text remained") + } + }) + } +} +func TestWorkingComposerTransitionKeepsDraftWithoutSending(t *testing.T) { + m, c := turnTestModel() + c.active = codex.SessionPromptOffer{} + c.offer = codex.SessionPromptOffer{Token: "idle", ThreadID: "root-one"} + m, cmd := promptKey(m, tea.KeyEnter, "") + if cmd != nil || len(c.answers) != 0 || m.monitorPrompt.input.Value() != "Keep this draft" { + t.Fatal("transition sent or lost draft") + } + m, cmd = promptKey(m, tea.KeyEnter, "") + if cmd == nil { + t.Fatal("idle send unavailable") + } + cmd() + if len(c.answers) != 1 || c.answers[0] != "Keep this draft" { + t.Fatal(c.answers) + } +} +func TestWorkingComposerErrorAndScheduleIsolation(t *testing.T) { + m, c := turnTestModel() + m.openSchedule() + if m.scheduleUI.open { + t.Fatal("working offer enabled scheduler") + } + c.err = errors.New("unsupported") + m, cmd := promptKey(m, tea.KeyTab, "") + m, _, _ = m.updateMonitorPrompt(cmd()) + if m.monitorPrompt.input.Value() != "Keep this draft" || !strings.Contains(m.monitorPrompt.notice, "unconfirmed") { + t.Fatal("failed queue lost draft or hid error") + } + view := m.renderMonitorPrompt(120, 30, paletteFor(themeHacker)) + if !strings.Contains(view, monitorDotWave(m.phase)) || !strings.Contains(view, "WORKING") { + t.Fatal("missing progress above composer") + } +} + +func TestWorkingComposerBusyKeysDoNotReachDashboard(t *testing.T) { + m, _ := turnTestModel() + m, _ = promptKey(m, tea.KeyEnter, "") + for _, text := range []string{"q", "t", "r"} { + var cmd tea.Cmd + m, cmd = promptKey(m, []rune(text)[0], text) + if cmd != nil || m.monitorPrompt.input.Value() != "Keep this draft" { + t.Fatal("busy editor leaked dashboard key or modified in-flight input") + } + } +} diff --git a/internal/web/control.go b/internal/web/control.go index 78a9de4..6e42be0 100644 --- a/internal/web/control.go +++ b/internal/web/control.go @@ -70,6 +70,7 @@ type offeredAction struct { } type actionRequest struct { + EditID string `json:"editId,omitempty"` SendID string `json:"sendId,omitempty"` Schedule *scheduleRule `json:"schedule,omitempty"` CancelID string `json:"cancelId,omitempty"` @@ -161,6 +162,9 @@ func (c *control) offer(id string) (offeredAction, error) { } func validAction(o offeredAction, r actionRequest) bool { + if len(r.EditID) > 128 || (r.EditID != "" && r.Schedule == nil) { + return false + } if r.SendID != "" && (r.Schedule != nil || o.Kind != "prompt" || len(o.Questions) > 0) { return false } @@ -312,7 +316,7 @@ func (c *control) handle(action, origin string) http.HandlerFunc { http.Error(w, errUnavailable.Error(), 409) return } - err = c.schedules.Save(schedule.Job{Session: body.Session, Text: body.Answers[0], Trigger: body.Schedule.Trigger, At: body.Schedule.At, Zone: body.Schedule.Zone, Windows: schedule.WindowKeys(q)}, q.AccountFingerprint, time.Now()) + err = c.schedules.SaveIfCurrent(schedule.Job{Session: body.Session, Text: body.Answers[0], Trigger: body.Schedule.Trigger, At: body.Schedule.At, Zone: body.Schedule.Zone, Windows: schedule.WindowKeys(q)}, q.AccountFingerprint, time.Now(), body.EditID) if err != nil { http.Error(w, err.Error(), 409) return diff --git a/internal/web/dist/assets/index-BZEiNW06.js b/internal/web/dist/assets/index-BZEiNW06.js deleted file mode 100644 index e058bf4..0000000 --- a/internal/web/dist/assets/index-BZEiNW06.js +++ /dev/null @@ -1,41 +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,ee=1<<19,E=1<<20,D=1<<25,te=1<<21,ne=1<<22,re=1<<23,ie=Symbol(`$state`),ae=Symbol(`component`),oe=Symbol(`legacy props`),se=Symbol(``),ce=Symbol(`attributes`),le=Symbol(`class`),ue=Symbol(`style`),de=Symbol(`text`),fe=Symbol(`form reset`),pe=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},me=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`),he={},O=Symbol(`uninitialized`),ge=`http://www.w3.org/1999/xhtml`;function _e(){console.warn(`https://svelte.dev/e/derived_inert`)}function ve(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function ye(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function be(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var k=!1;function xe(e){k=e}var A;function Se(e){if(e===null)throw ve(),he;return A=e}function Ce(){return Se(cn(A))}function j(e){if(k){if(cn(A)!==null)throw ve(),he;A=e}}function we(e=1){if(k){for(var t=e,n=A;t--;)n=cn(n);A=n}}function Te(e=!0){for(var t=0,n=A;;){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=cn(n);e&&n.remove(),n=i}}function Ee(e){if(!e||e.nodeType!==8)throw ve(),he;return e.data}function De(e){return e===this.v}function Oe(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function ke(e){return!Oe(e,this.v)}function Ae(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function je(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function Me(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function Ne(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Pe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Fe(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ie(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Le(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Re(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function ze(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Be(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Ve(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var He=!1;function Ue(){He=!0}var M=null;function We(e){M=e}function Ge(e,t=!1,n){M={p:M,i:!1,c:null,e:null,s:e,x:null,r:U,l:He&&!t?{s:null,u:null,$:[]}:null}}function Ke(e){var t=M,n=t.e;if(n!==null){t.e=null;for(var r of n)xn(r)}return e!==void 0&&(t.x=e),t.i=!0,M=t.p,qe(e)}function qe(e={}){return i(e,ae,{value:!0}),e}function Je(){return!He||M!==null&&M.l===null}var Ye=[];function Xe(){var e=Ye;Ye=[],m(e)}function Ze(e){if(Ye.length===0&&!Tt){var t=Ye;queueMicrotask(()=>{t===Ye&&Xe()})}Ye.push(e)}function Qe(){for(;Ye.length>0;)Xe()}var $e=~(y|b|v);function et(e,t){e.f=e.f&$e|t}function tt(e){e.f&512||e.deps===null?et(e,v):et(e,b)}function nt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),et(e,v)}function rt(e){k&&sn(e)!==null&&ln(e)}var it=!1;function at(){it||(it=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[fe]?.()})},{capture:!0}))}function ot(e){var t=H,n=U;Gn(null),Kn(null);try{return e()}finally{Gn(t),Kn(n)}}function st(e,t,n,r=n){e.addEventListener(t,()=>ot(n));let i=e[fe];e[fe]=i?()=>{i(),r(!0)}:()=>r(!0),at()}function ct(e,t,n,r){let i=Je()?ft:ht;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=U,c=lt(),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){mn(e,s)}ut()}}var d=dt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>mt(e))).then(u).catch(e=>mn(e,s)).finally(d)}l?l.then(()=>{c(),f(),ut()}):f()}function lt(){var e=U,t=H,n=M,r=P;return function(i=!0){Kn(e),Gn(t),We(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function ut(e=!0){Kn(null),Gn(null),We(null),e&&P?.deactivate()}function dt(){var e=U,t=e.b,n=P,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 ft(e){var t=2|y;return U!==null&&(U.f|=ee),{ctx:M,deps:null,effects:null,equals:De,f:t,fn:e,reactions:null,rv:0,v:O,wv:0,parent:U,ac:null}}var pt=Symbol(`obsolete`);function mt(e,t,n){let r=U;r===null&&je();var i=void 0,a=Ht(O),o=!H,s=new Set;return Tn(()=>{var t=U,n=h();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==pe&&n.reject(e)}).finally(ut)}catch(e){n.reject(e),ut()}var c=P;if(o){if(t.f&32768)var l=dt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(pt);else for(let e of s.values())e.reject(pt);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==pt&&(c.activate(),t?(a.f|=re,Kt(a,t)):(a.f&8388608&&(a.f^=re),Kt(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),yn(()=>{for(let e of s)e.reject(pt)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function N(e){let t=ft(e);return Jn(t),t}function ht(e){let t=ft(e);return t.equals=ke,t}function gt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(pe),t.ac=null}),t.fn!==null&&(t.teardown=f),lr(t,0),An(t))}function bt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&ur(t)}var xt=null,P=null,St=null,Ct=null,wt=null,Tt=!1,Et=!1,Dt=null,Ot=null,kt=0,At=1,jt=class e{id=At++;#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(){xt===null?xt=this:(xt.#n=this,this.#t=xt),xt=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)et(r,y),t(r);for(r of n.m)et(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),et(e,y),this.schedule(e);for(let e of this.#d)et(e,b),this.schedule(e);this.apply();for(var t=Dt=[],n=[],r=Ot=[];this.#c.length>0;){kt++>1e3&&(this.#S(),Nt());for(let e of this.#g())try{this.#v(e,t,n)}catch(t){throw Rt(e),this.#h()||this.discard(),t}}if(P=null,r.length>0){var i=e.ensure();for(let e of r)i.schedule(e)}if(Dt=null,Ot=null,this.#h()){this.#x(n),this.#x(t);for(let[e,t]of this.#f)Lt(e,t);r.length>0&&P.#_();return}let a=this.#y();if(a){this.#x(n),this.#x(t),a.#b(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),St=this,Ft(n),Ft(t),St=null,this.#s?.resolve();var o=P;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&&(Bt.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):ir(r)&&(i&16&&this.#d.add(r),ur(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),et(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),P=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(P===null){let t=P=new e;!Et&&!Tt&&Ze(()=>{t.#e||t.flush()})}return P}apply(){Ct=null}schedule(e){if(wt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}this.#c.push(e)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?xt=e:t.#t=e,this.linked=!1}}};function Mt(e){var t=Tt;Tt=!0;try{var n;for(e&&(P!==null&&!P.is_fork&&P.flush(),n=e());;){if(Qe(),P===null)return n;P.flush()}}finally{Tt=t}}function Nt(){try{Ie()}catch(e){mn(e,wt)}}var Pt=null;function Ft(e){var t=e.length;if(t!==0){for(var n=0;n0)){Bt.clear();for(let e of Pt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Pt.has(n)&&(Pt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||ur(n)}}Pt.clear()}}Pt=null}}function It(e){P.schedule(e)}function Lt(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),et(e,v);for(var n=e.first;n!==null;)Lt(n,t),n=n.next}}function Rt(e){et(e,v);for(var t=e.first;t!==null;)Rt(t),t=t.next}var zt=new Set,Bt=new Map,Vt=!1;function Ht(e,t){return{f:0,v:e,reactions:null,equals:De,rv:0,wv:0}}function F(e,t){let n=Ht(e,t);return Jn(n),n}function Ut(e,t=!1,n=!0){let r=Ht(e);return t||(r.equals=ke),He&&n&&M!==null&&M.l!==null&&(M.l.s??=[]).push(r),r}function I(e,t,n=!1){return H!==null&&(!Wn||H.f&131072)&&Je()&&H.f&4325394&&(qn===null||!qn.has(e))&&Be(),Kt(e,n?Zt(t):t,Ot)}var Wt=null,Gt=0;function Kt(e,t,n=null){if(!e.equals(t)){Hn?Bt.set(e,t):Bt.has(e)||Bt.set(e,e.v);var r=jt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&_t(t),Ct===null&&tt(t)}e.wv=rr(),Wt=null,Gt=0,Xt(e,y,n),Wt=null,Je()&&U!==null&&U.f&1024&&!(U.f&96)&&(Zn===null?Qn([e]):Zn.push(e)),!r.is_fork&&zt.size>0&&!Vt&&qt()}return t}function qt(){Vt=!1;for(let e of zt){e.f&1024&&et(e,b);let t;try{t=ir(e)}catch{t=!0}t&&ur(e)}zt.clear()}function Jt(e,t=1){var n=W(e),r=t===1?n++:n--;return I(e,n),r}function Yt(e){I(e,e.v+1)}function Xt(e,t,n){var r=e.reactions;if(r!==null){var i=Je(),a=r.length;if(Gt+=a,Gt>1e5&&Wt===null&&(Wt=new Set),Wt!==null){if(Wt.has(e))return;Wt.add(e)}for(var o=0;o{if(tr===d)return e();var t=H,n=tr;Gn(null),nr(d);var r=e();return Gn(t),nr(n),r};return i&&r.set(`length`,F(t.length,u)),new Proxy(t,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&Re();var i=r.get(t);return i===void 0?f(()=>{var e=F(n.value,u);return r.set(t,e),e}):I(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>F(O,u));r.set(t,e),Yt(o)}}else I(n,O),Yt(o);return!0},get(e,n,i){if(n===ie)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>F(Zt(s?e[n]:O),u)),r.set(n,o)),o!==void 0){var c=W(o);return c===O?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=W(i);if(a===O)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===ie)return!0;var n=r.get(t),i=n!==void 0&&n.v!==O||Reflect.has(e,t);return(n!==void 0||U!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>F(i?Zt(e[t]):O,u)),r.set(t,n)),W(n)===O)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dF(O,u)),r.set(d+``,p)):I(p,O)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>F(void 0,u)),I(c,Zt(n)),r.set(t,c));else{l=c.v!==O;var m=f(()=>Zt(n));I(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&&I(g,_+1)}Yt(o)}return!0},ownKeys(e){W(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==O});for(var[n,i]of r)i.v!==O&&!(n in e)&&t.push(n);return t},setPrototypeOf(){ze()}})}function Qt(e){try{if(typeof e==`object`&&e&&ie in e)return e[ie]}catch{}return e}function $t(e,t){return Object.is(Qt(e),Qt(t))}var en,tn,nn,rn;function an(){if(en===void 0){en=window,tn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;nn=a(t,`firstChild`).get,rn=a(t,`nextSibling`).get,u(e)&&(e[le]=void 0,e[ce]=null,e[ue]=void 0,e.__e=void 0),u(n)&&(n[de]=void 0)}}function on(e=``){return document.createTextNode(e)}function sn(e){return nn.call(e)}function cn(e){return rn.call(e)}function L(e,t){if(!k)return sn(e);var n=sn(A);if(n===null)n=A.appendChild(on());else if(t&&n.nodeType!==3){var r=on();return n?.before(r),Se(r),r}return t&&fn(n),Se(n),n}function R(e,t=!1){if(!k){var n=sn(e);return n instanceof Comment&&n.data===``?cn(n):n}if(t){if(A?.nodeType!==3){var r=on();return A?.before(r),Se(r),r}fn(A)}return A}function z(e,t=!1){if(!k)return sn(e);var n=L(e,t);return j(e),n}function B(e,t=1,n=!1){let r=k?A:e;for(var i;t--;)i=r,r=cn(r);if(!k)return r;if(n){if(r?.nodeType!==3){var a=on();return r===null?i?.after(a):r.before(a),Se(a),a}fn(r)}return Se(r),r}function ln(e){e.textContent=``}function un(){return!1}function dn(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 fn(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 pn(e){var t=U;if(t===null)return H.f|=re,e;if(!(t.f&32768)&&!(t.f&4))throw e;mn(e,t)}function mn(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 hn(e){U===null&&(H===null&&Fe(e),Pe()),Hn&&Ne(e)}function gn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function _n(e,t){var n=U;n!==null&&n.f&8192&&(e|=x);var r={ctx:M,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};P?.register_created_effect(r);var i=r;if(e&4)Dt===null?jt.ensure().schedule(r):Dt.push(r);else if(t!==null){try{ur(r)}catch(e){throw Mn(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&&gn(i,n),H!==null&&H.f&2&&!(e&64))){var a=H;(a.effects??=[]).push(i)}return r}function vn(){return H!==null&&!Wn}function yn(e){let t=_n(8,null);return et(t,v),t.teardown=e,t}function bn(e){hn(`$effect`);var t=U.f;if(!H&&t&32&&M!==null&&!M.i){var n=M;(n.e??=[]).push(e)}else return xn(e)}function xn(e){return _n(4|E,e)}function Sn(e){return hn(`$effect.pre`),_n(8|E,e)}function Cn(e){jt.ensure();let t=_n(64|ee,e);return(e={})=>new Promise(n=>{e.outro?Fn(t,()=>{Mn(t),n(void 0)}):(Mn(t),n(void 0))})}function wn(e){return _n(4,e)}function Tn(e){return _n(ne|ee,e)}function En(e,t=0){return _n(8|t,e)}function V(e,t=[],n=[],r=[]){ct(r,t,n,t=>{_n(8,()=>{e(...t.map(W))})})}function Dn(e,t=0){return _n(16|t,e)}function On(e){return _n(32|ee,e)}function kn(e){var t=e.teardown;if(t!==null){let n=Hn,r=H;Un(!0),Gn(null);try{t.call(null)}catch(t){mn(t,e.parent)}finally{Un(n),Gn(r)}}}function An(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&ot(()=>{e.abort(pe)});var r=n.next;n.f&64?n.parent=null:Mn(n,t),n=r}}function jn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Mn(t),t=n}}function Mn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Nn(e.nodes.start,e.nodes.end),n=!0),e.f|=w,An(e,t&&!n),lr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();kn(e),e.f^=w,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Pn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Nn(e,t){for(;e!==null;){var n=e===t?null:cn(e);e.remove(),e=n}}function Pn(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 Fn(e,t,n=!0){var r=[];e.f|=256,In(e,r,!0);var i=()=>{n&&Mn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function In(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);In(i,t,o?n:!1)}i=a}}}function Ln(e){e.f&=-257,Rn(e,!0)}function Rn(e,t){if(!(e.f&256)&&e.f&8192){e.f^=x,e.f&1024||(et(e,y),jt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=!!(n.f&65536)||!!(n.f&32);Rn(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 zn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:cn(n);t.append(n),n=i}}var Bn=null,Vn=!1,Hn=!1;function Un(e){Hn=e}var H=null,Wn=!1;function Gn(e){H=e}var U=null;function Kn(e){U=e}var qn=null;function Jn(e){H!==null&&(H.f&2097152||H.f&2)&&(qn??=new Set).add(e)}var Yn=null,Xn=0,Zn=null;function Qn(e){Zn=e}var $n=1,er=0,tr=er;function nr(e){tr=e}function rr(){return++$n}function ir(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&&Ct===null&&et(e,v)}return!1}function ar(e,t,n=!0){var r=e.reactions;if(r!==null&&!(qn!==null&&qn.has(e)))for(var i=0;i{e.ac.abort(pe)}),e.ac=null);try{e.f|=te;var u=e.fn,d=u();e.f|=C;var f=sr(e);if(Je()&&Zn!==null&&!Wn&&f!==null&&!(e.f&6146))for(var p=0;p0)for(t.length=Xn+Yn.length,r=0;r{s.ac.abort(pe),s.ac=null,et(s,y)}),yt(s),lr(s,0)}}function lr(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,Ze(()=>{i.__removed||t.addEventListener(e,i,r)})):t.addEventListener(e,i,r),i}function Cr(e,t,n,r,i){var a={capture:r,passive:i},o=Sr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&yn(()=>{o.__removed=!0,t.removeEventListener(e,o,a)})}function G(e,t,n){(t[yr]??={})[e]=n}function wr(e){for(var t=0;t{Er=!1,Tr=null}));var s=0,c=Tr===e&&e[yr];if(c){var l=a.indexOf(c);if(l!==-1&&(t===document||t===window)){e[yr]=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=H,f=U;Gn(null),Kn(null);try{for(var p,m=[];o!==null&&o!==t;){try{var h=o[yr]?.[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[yr]=t,delete e.currentTarget,Gn(d),Kn(f)}}}var Or=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function kr(e){return Or?.createHTML(e)??e}function Ar(e){var t=dn(`template`);return t.innerHTML=kr(e.replaceAll(``,``)),t.content}function jr(e,t){var n=U;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function K(e,t){var n=!!(t&1),r=!!(t&2),i,a=!e.startsWith(``);return()=>{if(k)return jr(A,null),A;i===void 0&&(i=Ar(a?e:``+e),n||(i=sn(i)));var t=r||tn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=sn(t),s=t.lastChild;jr(o,s)}else jr(t,t);return t}}function Mr(e,t,n=`svg`){var r=!e.startsWith(``),i=!!(t&1),a=`<${n}>${r?e:``+e}`,o;return()=>{if(k)return jr(A,null),A;if(!o){var e=sn(Ar(a));if(i)for(o=document.createDocumentFragment();sn(e);)o.appendChild(sn(e));else o=sn(e)}var t=o.cloneNode(!0);if(i){var n=sn(t),r=t.lastChild;jr(n,r)}else jr(t,t);return t}}function Nr(e,t){return Mr(e,t,`svg`)}function Pr(e=``){if(!k){var t=on(e+``);return jr(t,t),t}var n=A;return n.nodeType===3?fn(n):(n.before(n=on()),Se(n)),jr(n,n),n}function Fr(){if(k)return jr(A,null),A;var e=document.createDocumentFragment(),t=document.createComment(``),n=on();return e.append(t,n),jr(t,n),e}function q(e,t){if(k){var n=U;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=A),Ce();return}e!==null&&e.before(t)}function Ir(){if(k&&A&&A.nodeType===8&&A.textContent?.startsWith(`$`)){let e=A.textContent.substring(1);return Ce(),e}return(window.__svelte??={}).uid??=1,`c${window.__svelte.uid++}`}function Lr(e){let t=0,n=Ht(0),r;return()=>{vn()&&(W(n),En(()=>(t===0&&(r=mr(()=>e(()=>Yt(n)))),t+=1,()=>{Ze(()=>{--t,t===0&&(r?.(),r=void 0,Yt(n))})})))}}var Rr=T|ee;function zr(e,t,n,r){new Br(e,t,n,r)}var Br=class{parent;is_pending=!1;transform_error;#e;#t=k?A: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=Lr(()=>(this.#m=Ht(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=U;t.b=this,t.f|=128,n(e)},this.parent=U.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Dn(()=>{if(k){let e=this.#t;Ce();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()},Rr),k&&(this.#e=A)}#g(){try{this.#a=On(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed,{reset:n,invoke_onerror:r}=this.#v(e);Ze(r),t&&(this.#s=On(()=>{t(this.#e,()=>e,()=>n)}))}#v(e){var t=!1,n=!1;let r=()=>{if(t){be();return}t=!0,n&&Ve(),this.#s!==null&&Fn(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){mn(e,this.#i&&this.#i.parent)}}}}#y(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=On(()=>e(this.#e)),Ze(()=>{var e=this.#c=document.createDocumentFragment(),t=on(),n=!1;if(e.append(t),this.#a=this.#S(()=>{try{return On(()=>this.#r(t))}catch(e){try{this.error(e),n=!0}catch(e){mn(e,this.#i.parent)}return null}}),this.#a===null){this.#c=null,n&&this.#x(P);return}this.#u===0&&(this.#e.before(e),this.#c=null,Fn(this.#o,()=>{this.#o=null}),this.#x(P))}))}#b(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=On(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();zn(this.#a,e);let t=this.#n.pending;this.#o=On(()=>t(this.#e))}else this.#x(P)}catch(e){this.error(e)}}#x(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){nt(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=U,n=H,r=M;Kn(this.#i),Gn(this.#i),We(this.#i.ctx);try{return jt.ensure(),e()}finally{Kn(t),Gn(n),We(r)}}#C(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#C(e,t);return}this.#u+=e,this.#u===0&&(this.#x(t),this.#o&&Fn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#C(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,Ze(()=>{this.#d=!1,this.#m&&Kt(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),W(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;P?.is_fork?(this.#a&&P.skip_effect(this.#a),this.#o&&P.skip_effect(this.#o),this.#s&&P.skip_effect(this.#s),P.oncommit(()=>{this.#w(e)})):this.#w(e)}#w(e){this.#a&&=(Mn(this.#a),null),this.#o&&=(Mn(this.#o),null),this.#s&&=(Mn(this.#s),null),k&&(Se(this.#t),we(),Se(Te()));let t=this.#n.failed,n=e=>{let{reset:n,invoke_onerror:r}=this.#v(e);r(),t&&(this.#s=this.#S(()=>{try{return On(()=>{var r=U;r.b=this,r.f|=128,t(this.#e,()=>e,()=>n)})}catch(e){return mn(e,this.#i.parent),null}}))};Ze(()=>{var t;try{t=this.transform_error(e)}catch(e){mn(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(n,e=>mn(e,this.#i&&this.#i.parent)):n(t)})}};function J(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[de]??=e.nodeValue)&&(e[de]=n,e.nodeValue=`${n}`)}function Vr(e,t){return Ur(e,t)}var Hr=new Map;function Ur(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){an();var l=void 0,u=Cn(()=>{var s=n??t.appendChild(on());zr(s,{pending:()=>{}},t=>{Ge({});var n=M;if(o&&(n.c=o),a&&(i.$$events=a),k&&jr(t,null),l=e(t,i)||qe(),k&&(U.nodes.end=A,A===null||A.nodeType!==8||A.data!==`]`))throw ve(),he;Ke()},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=Hr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Dr),r.delete(e),r.size===0&&Hr.delete(n)):r.set(e,i)}xr.delete(d),s!==n&&s.parentNode?.removeChild(s)}});return Wr.set(l,u),l}var Wr=new WeakMap,Gr=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)Ln(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Ln(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&&(Mn(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();zn(r,t),t.append(on()),this.#n.set(e,{effect:r,fragment:t})}else Mn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Fn(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)||(Mn(n.effect),this.#n.delete(e))};ensure(e,t){var n=P,r=un();if(t&&!this.#t.has(e)&&!this.#n.has(e)){if(r){var i=document.createDocumentFragment(),a=on();i.append(a),this.#n.set(e,{effect:On(()=>t(a)),fragment:i})}else this.#t.set(e,On(()=>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 k&&(this.anchor=A),this.#a(n)}};function Y(e,t,n=!1){var r;k&&(r=A,Ce());var i=new Gr(e),a=n?T:0;function o(e,t){if(k){var n=Ee(r);if(e!==parseInt(n.substring(1))){var a=Te();Se(a),i.anchor=a,xe(!1),i.ensure(e,t),xe(!0);return}}i.ensure(e,t)}Dn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var Kr=Symbol(`NaN`);function qr(e,t,n){k&&Ce();var r=new Gr(e),i=!Je();Dn(()=>{var e=t();e!==e&&(e=Kr),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function X(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;ln(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^=D,ei(d,null,c)):Ln(d):Fn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Dn(()=>{p=W(f);var e=p.length;let t=!1;k&&Ee(c)===`[!`!=(e===0)&&(c=Te(),Se(c),xe(!1),t=!0);for(var r=new Set,u=P,v=un(),y=0;ys(c)):(d=On(()=>s(Xr??=on())),d.f|=D)),e>r.size&&Me(``,``,``),k&&e>0&&Se(Te()),!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&&xe(!0),W(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,k&&(c=A)}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 ee=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?Ht(n):Ut(n,!1,!1):null,l=o&2?Ht(i):null;return{v:c,i:l,e:On(()=>(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=cn(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;k&&(r=A,Ce());var i=new Gr(e);Dn(()=>{var e=t()??null;if(k&&Ee(r)===`[`!=(e!==null)){var a=Te();Se(a),i.anchor=a,xe(!1),i.ensure(e,e&&(t=>n(t,e))),xe(!0);return}i.ensure(e,e&&(t=>n(t,e)))},T)}var ri=[...` -\r\f\xA0\v`];function ii(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||ri.includes(r[o-1]))&&(s===r.length||ri.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function ai(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 oi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function si(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(oi)),i&&c.push(...Object.keys(i).map(oi));var l=0,u=-1;let t=e.length;for(var d=0;d{t.every(_i)||(`__defaultValue`in e&&fi(e,!1),`__value`in e&&pi(e,e.__value))});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),yn(()=>{t.disconnect()})}function hi(e,t,n=t){var r=new WeakSet,i=!0;st(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),gi);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&gi(o)}n(a),e.__value=a,P!==null&&r.add(P)}),wn(()=>{var a=t();if(e===document.activeElement){var o=P;if(r.has(o))return}if(pi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=gi(s),n(a))}e.__value=a,i=!1})}function gi(e){return`__value`in e?e.__value:e.value}function _i(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 vi=Symbol(`is custom element`),yi=Symbol(`is html`),bi=me?`link`:`LINK`;function xi(e){if(k){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[fe]=n,Ze(n),at()}}function Q(e,t,n,r){var i=Si(e);k&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===bi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[se]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&wi(e).has(t)?e[t]=n:e.setAttribute(t,n))}function Si(e){return e[ce]??={[vi]:e.nodeName.includes(`-`),[yi]:e.namespaceURI===ge}}var Ci=new Map;function wi(e){var t=e.getAttribute(`is`)||e.nodeName,n=Ci.get(t);if(n)return n;Ci.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 Ti(e,t,n=t){var r=new WeakSet;st(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=ki(e)?Ai(a):a,n(a),P!==null&&r.add(P),await dr(),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))}}}),(k&&e.defaultValue!==e.value||mr(t)==null&&e.value)&&(n(ki(e)?Ai(e.value):e.value),P!==null&&r.add(P)),En(()=>{var n=t();if(e===document.activeElement){var i=P;if(r.has(i))return}ki(e)&&n===Ai(e.value)||(e.type!==`date`||n||e.value)&&n!==e.value&&(e.value=n??``)})}var Ei=new Set;function Di(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),st(n,`change`,()=>{var e=n.__value;a&&(e=Oi(o,e,n.checked)),i(e)},()=>i(a?[]:null)),En(()=>{var e=r();if(k&&n.defaultChecked!==n.checked){s=!0;return}a?(e||=[],n.checked=e.includes(n.__value)):n.checked=$t(n.__value,e)}),yn(()=>{var e=o.indexOf(n);e!==-1&&o.splice(e,1)}),Ei.has(o)||(Ei.add(o),Ze(()=>{o.sort((e,t)=>e.compareDocumentPosition(t)===4?-1:1),Ei.delete(o)})),Ze(()=>{if(s){var e=a?Oi(o,e,n.checked):o.find(e=>e.checked)?.__value;i(e)}})}function Oi(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 Mi(e,t,n){var r=ji.observe(e,()=>n(e[t]));wn(()=>(mr(()=>n(e[t])),r))}function Ni(e,t){return e===t||e?.[ie]===t}function Pi(e=qe(),t,n,r){var i=M.r,a=U;return wn(()=>{var o,s;return En(()=>{o=s,s=r?.()||[],mr(()=>{Ni(n(...s),e)||(t(e,...s),o&&Ni(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&&Ni(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function Fi(e,t,n,r,i){var a=()=>{r(n[e])};n.addEventListener(t,a),i?En(()=>{n[e]=i()}):a(),(n===document.body||n===window||n===document)&&yn(()=>{n.removeEventListener(t,a)})}function Ii(e=!1){let t=M,n=t.l.u;if(!n)return;let r=()=>hr(t.s);if(e){let e=0,n={},i=ft(()=>{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=()=>W(i)}n.b.length&&Sn(()=>{Li(t,r),m(n.b)}),bn(()=>{let e=mr(()=>n.m.map(p));return()=>{for(let t of e)typeof t==`function`&&t()}}),n.a.length&&bn(()=>{Li(t,r),m(n.a)})}function Li(e,t){if(e.l.s)for(let t of e.l.s)W(t);t()}var Ri=!1;function zi(e){var t=Ri;try{return Ri=!1,[e(),Ri]}finally{Ri=t}}var Bi={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===ie||t===oe)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 Vi(...e){return new Proxy({props:e},Bi)}function Hi(e,t,n,r){var i=!He||!!(n&2),o=!!(n&8),s=!!(n&16),c=r,l=!0,u=void 0,d=()=>s&&i?(u??=ft(r),W(u)):(l&&(l=!1,c=s?mr(r):r),c);let f;if(o){var p=ie in e||oe in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=zi(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&Le(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?ft:ht)(()=>(v=!1,g()));o&&W(y);var b=U;return(function(e,t){if(arguments.length>0){let n=t?W(y):i&&o?Zt(e):e;return I(y,n),v=!0,c!==void 0&&(c=n),e}return Hn&&v||b.f&16384?y.v:W(y)})}function Ui(e){M===null&&Ae(`onMount`),He&&M.l!==null?Wi(M).m.push(e):bn(()=>{let t=mr(e);if(typeof t==`function`)return t})}function Wi(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);function Gi(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 Ki=new class{#e=F(qi());get _loc(){return W(this.#e)}set _loc(e){I(this.#e,e)}#t=N(()=>this._loc.location);get _location(){return W(this.#t)}set _location(e){I(this.#t,e)}#n=N(()=>this._loc.querystring);get _querystring(){return W(this.#n)}set _querystring(e){I(this.#n,e)}#r=F(void 0);get _params(){return W(this.#r)}set _params(e){I(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=qi()}):console.warn(`[svelte-spa-router] window 'window' is not defined, skipping initiation`)}};function qi(){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}}function Ji(e){e?window.scrollTo(e.__svelte_spa_router_scrollX||0,e.__svelte_spa_router_scrollY||0):window.scrollTo(0,0)}function Yi(e,t){Ge(t,!0);let n=Hi(t,`routes`,19,()=>({})),r=Hi(t,`prefix`,3,``),i=Hi(t,`restoreScrollState`,3,!1),a=Hi(t,`onConditionsFailed`,3,()=>{}),o=Hi(t,`onRouteLoaded`,3,()=>{}),s=Hi(t,`onRouteLoading`,3,()=>{}),c=Hi(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=Gi(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=F(null),f=F(null),p=F({}),m=null,h=null;bn(()=>{history.scrollRestoration=i()?`manual`:`auto`}),bn(()=>{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 dr(),e(t)}bn(()=>{let e=Ki.loc,t=!1;return mr(async()=>{let n=0;for(;n{t=!0}});function _(e){return e&&typeof e==`object`&&Object.keys(e).length?e:null}var v=Fr(),y=R(v),b=e=>{let t=N(()=>W(d));var n=Fr(),r=R(n),i=e=>{var n=Fr();ni(R(n),()=>W(t),(e,t)=>{t(e,Vi({get params(){return W(f)},get onRouteEvent(){return c()}},()=>W(p)))}),q(e,n)},a=e=>{var n=Fr();ni(R(n),()=>W(t),(e,t)=>{t(e,Vi({get onRouteEvent(){return c()}},()=>W(p)))}),q(e,n)};Y(r,e=>{W(f)?e(i):e(a,-1)}),q(e,n)};Y(y,e=>{W(d)&&e(b)}),q(e,v),Ke()}var Xi=[`bars`,`pace`,`zone`,`pie`,`fuel`,`resets`,`thresholds`],Zi=`codexometer.web.preferences.v1`,Qi={tab:`quota`,view:`bars`,selected:``,defaultDetail:0,layouts:[]};function $i(){try{let e=JSON.parse(localStorage.getItem(Zi)||`null`);return!e||typeof e!=`object`?Qi:{tab:[`quota`,`sessions`,`usage`].includes(e.tab)?e.tab:`quota`,view:Xi.includes(e.view)?e.view:`bars`,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 Qi}}var ea=Zt($i());function ta(){let e=JSON.stringify(ea);try{localStorage.setItem(Zi,e)}catch{}}function na(){return ea.tab===`quota`?`/quota/`+ea.view:`/`+ea.tab}function ra(e){return ea.layouts.find(t=>t.id===e)?.level??ea.defaultDetail}function ia(e){ea.defaultDetail=e,ea.layouts=[]}function aa(e,t){ea.layouts=[...ea.layouts.filter(t=>t.id!==e),{id:e,level:Math.max(0,Math.min(2,t))}].slice(-100)}var $=Zt({data:null,connected:!1,error:``}),oa=e=>e==null?`Unavailable`:e.toLocaleString(`en-GB`),sa=e=>!e||String(e).startsWith(`0001-`)?`Not yet available`:new Date(typeof e==`number`?e*1e3:e).toLocaleString(`en-GB`),ca=`codexometer.web.session`,la=class extends Error{},ua;async function da(e,t,n){if(!ua||!$.connected||!$.data?.control||$.data.sessionsError)throw Error(`Session controls unavailable. Check the live connection.`);return await ua(e,t,n)}function fa(){let e=new AbortController,t,n=``;ua=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 la(`Action rejected, expired or changed. Refresh and check Codex; nothing was retried.`);return a.json()};try{n=sessionStorage.getItem(ca)||``}catch{}let r=location.hash,i=r.startsWith(`#pair=`)?r.slice(6):``;(i||!r||r===`#`)&&(history.replaceState(null,``,`/#`+na()),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(ca,n)}catch{}}catch(t){e.signal.aborted||($.error=t instanceof Error?t.message:`Pairing failed`);return}if(!n){$.error=`Open the private pairing link printed by codexometer --web in your terminal.`;return}await o()}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(ca)}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(),()=>{ua=void 0,e.abort(),clearTimeout(t),$.connected=!1}}Ue();var pa=K(`

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

                `),ma=K(`

                `),ha=K(`

                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),ga=K(`

                No threshold-based model steps were configured at launch.

                `);function _a(e,t){Ge(t,!1),Ii();var n=Fr(),r=R(n),i=e=>{var t=ha(),n=R(t),r=z(n),i=B(n,2),a=e=>{q(e,pa())};Y(i,e=>{$.data.quotaError&&e(a)});var o=B(i,2),s=L(o),c=z(s),l=B(s,4);Z(l,5,()=>$.data.thresholds,X,(e,t)=>{var n=ma();let r;var i=L(n),a=z(i),o=B(i,2),s=L(o),c=z(s,!0),l=z(B(s,2));j(o);var u=B(o,2),d=z(u,!0),f=z(B(u,2));j(n),V((e,i)=>{r=ci(n,1,``,null,r,{active:W(t).state===`ACTIVE`,next:W(t).state===`NEXT`}),J(a,`${W(t).threshold??``}%`),J(c,W(t).model),J(l,`${e??``} REASONING // ${i??``} - SPEED`),J(d,W(t).mode),J(f,`${W(t).state??``}${W(t).state===`NEXT`?` // ${W(t).remaining||0} PP TO GO`:``}`)},[()=>W(t).effort.toUpperCase(),()=>W(t).speed.toUpperCase()]),q(e,n)}),j(l),j(o),V(e=>{J(r,`MODEL STEP POLICY // OBSERVED ${e??``}`),J(c,`THRESHOLDS // ${$.data.thresholds.length??``} CONFIGURED`)},[()=>sa($.data.quotaAt)]),q(e,t)},a=e=>{q(e,ga())};Y(r,e=>{$.data?.thresholds?.length?e(i):e(a,-1)}),q(e,n),Ke()}var va=Nr(` `,1),ya=Nr(` `,1),ba=K(` `),xa=K(`
                Quota observations
                Observed atPeriod elapsedConsumedTrail segment
                `),Sa=K(`


                Observed quota - path, not individual session usage. Gaps are not interpolated. Expand the - observation table for times, positions and gaps.

                OBSERVATION TABLE
                `,1),Ca=K(`
                CONSUMPTIONQUOTA PERIOD ELAPSED


                `,1);function wa(e,t){let n=Ir();Ge(t,!0);let r=Hi(t,`trail`,19,()=>[]),i=F(!1),a=[0,25,50,75,100],o=F(400),s=F(240),c=N(()=>W(o)-24),l=N(()=>W(s)-48),u=N(()=>Math.max(1,W(c)-48)),d=N(()=>Math.max(1,W(l)-20)),f=N(()=>48+Math.max(0,Math.min(100,t.elapsed))/100*W(u)),p=N(()=>W(l)-Math.max(0,Math.min(100,t.used))/100*W(d)),m=N(()=>t.used-t.elapsed),h=N(()=>r().map((e,t)=>`${t===0||e.break?`M`:`L`}${48+e.elapsed/100*W(u)} ${W(l)-e.used/100*W(d)}`).join(` `));var g=Ca(),_=R(g),v=L(_),y=L(v),b=z(y),x=B(y),S=B(x);Z(S,17,()=>a,X,(e,t)=>{var n=va(),r=R(n),i=B(r),a=B(i),o=z(a),s=B(a),f=z(s);V(()=>{Q(r,`x1`,48+W(t)/100*W(u)),Q(r,`x2`,48+W(t)/100*W(u)),Q(r,`y2`,W(l)),Q(i,`y1`,W(l)-W(t)/100*W(d)),Q(i,`x2`,W(c)),Q(i,`y2`,W(l)-W(t)/100*W(d)),Q(a,`x`,48+W(t)/100*W(u)),Q(a,`y`,W(l)+20),J(o,`${W(t)??``}%`),Q(s,`y`,W(l)+4-W(t)/100*W(d)),J(f,`${W(t)??``}%`)}),q(e,n)});var C=B(S),w=B(C),T=B(w),ee=e=>{var t=ya(),n=R(t),i=B(n),a=z(L(i));j(i),V(e=>{Q(n,`d`,W(h)),Q(i,`cx`,48+r()[0].elapsed/100*W(u)),Q(i,`cy`,W(l)-r()[0].used/100*W(d)),J(a,`First observation: ${e??``}`)},[()=>sa(r()[0].at)]),q(e,t)};Y(T,e=>{r().length&&e(ee)});var E=B(T,2),D=B(E),te=B(D),ne=z(L(te));j(te),j(v),j(_);var re=B(_,2),ie=L(re),ae=z(B(ie,3),!0);j(re);var oe=B(re,2),se=e=>{var t=Sa(),a=R(t),o=L(a);we(2),j(a);var s=B(a,2),c=B(L(s),2),l=e=>{var t=xa(),n=L(t),i=B(L(n),2);Z(i,21,r,X,(e,t,n)=>{var r=ba(),i=L(r),a=L(i),o=z(a,!0);j(i);var s=B(i),c=z(s),l=B(s),u=z(l),d=z(B(l),!0);j(r),V((e,r)=>{Q(a,`datetime`,W(t).at),J(o,e),J(c,`${r??``}%`),J(u,`${W(t).used??``}%`),J(d,n===0?`First observation`:W(t).break?`Gap before this observation`:`Connected to previous observation`)},[()=>sa(W(t).at),()=>W(t).elapsed.toFixed(1)]),q(e,r)}),j(i),j(n),j(t),q(e,t)};Y(c,e=>{W(i)&&e(l)}),j(s),V(e=>{Q(a,`id`,n+`-trail-summary`),J(o,`○ START ${e??``} // ${r().length??``} - ${r().length===1?`OBSERVATION`:`OBSERVATIONS`}`)},[()=>sa(r()[0].at)]),Fi(`open`,`toggle`,s,e=>I(i,e),()=>W(i)),q(e,t)};Y(oe,e=>{r().length&&e(se)}),V((e,i,a,m)=>{Q(v,`viewBox`,`0 0 ${W(o)} ${W(s)}`),Q(v,`aria-describedby`,r().length?n+`-trail-summary`:void 0),Q(v,`aria-label`,e),Q(b,`id`,n),Q(x,`width`,W(u)),Q(x,`height`,W(d)),Q(x,`fill`,`url(#${n})`),Q(C,`d`,`M48 20 V${W(l)} H${W(c)}`),Q(w,`y1`,W(l)),Q(w,`x2`,W(c)),Q(E,`x`,48+W(u)/2),Q(E,`y`,W(s)-5),Q(D,`cx`,W(f)),Q(D,`cy`,W(p)),Q(te,`cx`,W(f)),Q(te,`cy`,W(p)),J(ne,`${t.used??``}% consumed // ${i??``}% of period elapsed`),J(ie,`${t.used??``}% USED // ${a??``}% TIME ELAPSED`),J(ae,m)},[()=>`Consumption zone: ${t.used}% consumed, ${t.elapsed.toFixed(1)}% of quota period elapsed. ${W(m)>0?`Above`:W(m)<0?`Below`:`On`} the steady-consumption line.`,()=>t.elapsed.toFixed(1),()=>t.elapsed.toFixed(1),()=>Math.abs(W(m))<.05?`ON PACE`:W(m)>0?`ABOVE THE LINE — CONSUMING FASTER THAN TIME`:`BELOW THE LINE — WITHIN PACE`]),Mi(_,`clientWidth`,e=>I(o,e)),Mi(_,`clientHeight`,e=>I(s,e)),q(e,g),Ke()}var Ta=K(` `),Ea=K(`

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

                `),Da=K(`

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

                `),Oa=K(`

                `),ka=K(`

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

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

                `),Aa=K(` `,1),ja=Nr(``),Ma=Nr(``),Na=K(`
                `),Pa=K(`

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

                `),Fa=K(`
                ▼
                −100 // OVER BUDGET+100 // HEADROOM

                `,1),Ia=K(`

                Cycle duration unavailable — pace cannot be calculated.

                `),La=K(`
                EMPTYFULL
                `),Ra=K(`

                `,1),za=K(`
                `,1),Ba=K(`

                `),Va=K(`

                `),Ha=K(`

                No quota windows reported yet.

                `),Ua=K(`
                `,1),Wa=K(`

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

                `,1),Ga=K(` `,1);function Ka(e,t){Ge(t,!0);let n=Hi(t,`params`,19,()=>({})),r=N(()=>Xi.filter(e=>e!==`thresholds`||!!$.data?.thresholds?.length)),i=F(Zt(Date.now())),a=N(()=>W(r).includes(n().view||``)?n().view:`bars`);Ui(()=>{let e=setInterval(()=>I(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-W(i))/(e.duration*6e4))))}bn(()=>{ea.view=W(a)});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=Ga(),l=R(c);Z(l,21,()=>W(r),X,(e,t)=>{var n=Ta();let r;var i=z(n,!0);V(e=>{Q(n,`href`,`#/quota/`+W(t)),Q(n,`aria-current`,W(a)===W(t)?`page`:void 0),r=ci(n,1,``,null,r,{active:W(a)===W(t)}),J(i,e)},[()=>W(t)===`pace`?`CONSUMPTION PACE`:W(t)===`zone`?`CONSUMPTION ZONE`:W(t)===`fuel`?`FUEL TANK`:W(t).toUpperCase()]),q(e,n)}),j(l);var u=B(l,2),d=e=>{var t=Wa(),n=R(t),r=e=>{q(e,Ea())};Y(n,e=>{$.data.quotaError&&e(r)});var i=B(n,2),c=z(i),l=B(i,2),u=e=>{_a(e,{})},d=e=>{var t=ka(),n=L(t),r=z(n),i=B(n,4),a=e=>{q(e,Da())};Y(i,e=>{$.data.credits.length||e(a)}),Z(B(i,2),17,()=>$.data.credits,X,(e,t)=>{var n=Oa(),r=L(n),i=z(r),a=z(B(r,2),!0);j(n),V(e=>{J(i,`${(W(t).title||`Quota reset`)??``} // ${W(t).status??``}`),J(a,e)},[()=>W(t).expiryKnown?W(t).expires?`EXPIRES `+sa(W(t).expires):`Does not expire`:`Expiry information unavailable`]),q(e,n)}),we(2),j(t),V(()=>J(r,`RESET INVENTORY // ${$.data.creditCount??``} AVAILABLE`)),q(e,t)},f=e=>{var t=Ua(),n=R(t);let r;Z(n,21,()=>$.data.meters,X,(e,t)=>{let n=N(()=>o(W(t))),r=N(()=>W(n)===null?null:W(n)-W(t).used);var i=Va(),c=L(i),l=z(c,!0),u=B(c,2),d=L(u),f=e=>{var n=Aa(),r=R(n),i=z(r),a=z(B(r));V(()=>{J(i,`FREE ${100-W(t).used}%`),J(a,`USED ${W(t).used??``}%`)}),q(e,n)},p=e=>{var n=Aa(),r=R(n),i=z(r),a=z(B(r));V(()=>{J(i,`USED ${W(t).used??``}%`),J(a,`FREE ${100-W(t).used}%`)}),q(e,n)};Y(d,e=>{W(a)===`fuel`?e(f):e(p,-1)}),j(u);var m=B(u,2);let h;var g=L(m),_=e=>{var n=Na(),r=L(n),i=B(L(r)),a=e=>{q(e,ja())},o=e=>{var n=Ma();V(e=>Q(n,`d`,e),[()=>s(W(t).used)]),q(e,n)};Y(i,e=>{W(t).used>=100?e(a):W(t).used>0&&e(o,1)}),j(r),j(n),V(()=>Q(r,`aria-label`,`${W(t).used}% quota used`)),q(e,n)},v=e=>{var r=Fr(),i=R(r),a=e=>{{let r=N(()=>W(t).trail||[]);wa(e,{get used(){return W(t).used},get elapsed(){return W(n)},get trail(){return W(r)}})}},o=e=>{q(e,Pa())};Y(i,e=>{W(n)===null?e(o,-1):e(a)}),q(e,r)},y=e=>{var t=Fr(),n=R(t),i=e=>{var t=Fa(),n=R(t),i=B(L(n),2);let a;j(n);var o=B(n,4),s=L(o),c=z(B(s),!0);j(o),V(e=>{a=ui(i,``,a,{left:`${(W(r)+100)/2}%`}),J(s,`${W(r)>=0?`+`:``}${e??``} PP `),J(c,W(r)>=0?`WITHIN PACE`:`USING FASTER THAN TIME`)},[()=>W(r).toFixed(1)]),q(e,t)},a=e=>{q(e,Ia())};Y(n,e=>{W(r)===null?e(a,-1):e(i)}),q(e,t)},b=e=>{var r=za(),i=R(r),o=L(i);let s;j(i);var c=B(i,2),l=e=>{q(e,La())};Y(c,e=>{W(a)===`fuel`&&e(l)});var u=B(c,2),d=e=>{var t=Ra(),r=R(t),i=z(r),o=B(r,2),s=L(o);let c;j(o),V(e=>{J(i,`RESET CYCLE // ${e??``}% ELAPSED`),c=ui(s,``,c,{width:`${W(a)===`fuel`?100-W(n):W(n)}%`})},[()=>Math.floor(W(n))]),q(e,t)};Y(u,e=>{W(n)!==null&&e(d)}),V(()=>{Q(i,`aria-label`,W(a)===`fuel`?`Fuel remaining`:`Quota used`),Q(i,`aria-valuenow`,W(a)===`fuel`?100-W(t).used:W(t).used),s=ui(o,``,s,{width:`${W(a)===`fuel`?100-W(t).used:W(t).used}%`})}),q(e,r)};Y(g,e=>{W(a)===`pie`?e(_):W(a)===`zone`?e(v,1):W(a)===`pace`?e(y,2):e(b,-1)}),j(m);var x=B(m,2),S=z(x),C=B(x,2),w=e=>{var n=Ba(),r=z(n,!0);V(()=>J(r,W(t).details)),q(e,n)};Y(C,e=>{W(t).details&&e(w)}),j(i),V(e=>{J(l,W(t).name),h=ci(m,1,`meter-graphic`,null,h,{"bar-graphic":W(a)===`bars`||W(a)===`fuel`}),J(S,`RESETS // ${e??``}`)},[()=>sa(W(t).reset)]),q(e,i)}),j(n);var i=B(n,2),c=e=>{q(e,Ha())};Y(i,e=>{$.data.meters.length||e(c)}),V(()=>r=ci(n,1,`quota-grid`,null,r,{radial:W(a)===`pie`,zone:W(a)===`zone`})),q(e,t)};Y(l,e=>{W(a)===`thresholds`?e(u):W(a)===`resets`?e(d,1):e(f,-1)}),we(2),V(e=>J(c,`QUOTA // OBSERVED ${e??``}`),[()=>sa($.data.quotaAt)]),q(e,t)};Y(u,e=>{$.data&&e(d)}),q(e,c),Ke()}var qa=K(`
                `),Ja=K(`

                `,1);function Ya(e,t){Ge(t,!0);let n=Hi(t,`values`,19,()=>[]),r=Hi(t,`label`,3,`Token activity`),i=Hi(t,`capacity`,3,0),a=N(()=>Math.max(0,...n())),o=N(()=>i()>n().length?[...Array(i()-n().length).fill(0),...n()]:n());var s=Ja(),c=R(s),l=z(c),u=B(c,2);Z(u,21,()=>W(o),X,(e,t)=>{var n=qa();let r;V((e,t)=>{Q(n,`title`,e),r=ui(n,``,r,{height:t})},[()=>W(t).toLocaleString(`en-GB`)+` tokens`,()=>`${100*W(t)/Math.max(1,W(a))}%`]),q(e,n)}),j(u),V((e,t)=>{J(l,`SCALE // 0 — ${e??``} TOKENS`),Q(u,`aria-label`,t)},[()=>W(a).toLocaleString(`en-GB`),()=>`${r()}. Peak ${W(a).toLocaleString(`en-GB`)} tokens.`]),q(e,s),Ke()}var Xa=K(`

                `),Za=K(`

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

                `,1),Qa=K(``),$a=K(`

                 

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

                `),eo=K(`

                CURRENT PROFILE

                MODEL / REASONING LEVEL / SPEED

                 

                PROPOSED PROFILE

                MODEL / REASONING LEVEL / SPEED

                 

                Applied settings remain after Codexometer closes.

                `,1),to=K(`

                `),no=K(`

                 
                `,1),ro=K(`

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

                `),io=K(`

                Session controls temporarily unavailable. Check Codex for current state.

                `),ao=K(`

                Checking session controls…

                `),oo=K(`

                `),so=K(`
                About browser controls

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

                `),co=K(` `,1),lo=K(` `),uo=K(`Grants permission beyond this one command. Check the scope - carefully.`),fo=K(``),po=K(``),mo=K(``),ho=K(``),go=K(`

                Not before this time; when quota and idle allow.

                `),_o=K(`

                `,1),vo=K(` `,1),yo=K(``),bo=K(``),xo=K(``),So=K(` `,1),Co=K(`
              • `),wo=K(`
                View fixed choices

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

                  `),To=K(` `,1),Eo=K(`

                  `),Do=K(`

                  `,1),Oo=K(` `,1),ko=K(``),Ao=K(`

                  `,1),jo=K(`

                  `);function Mo(e,t){Ge(t,!0);let n=[],r=Hi(t,`observedCommand`,3,``),i=Hi(t,`review`,3,``),a=Hi(t,`suspended`,3,!1),o=Hi(t,`openScheduler`,3,!1),s=Hi(t,`onProtectedChange`,3,e=>{}),c=F(null),l=F(Zt([])),u=F(null),d=F(``),f=F(0),p=F(Zt(Date.now())),m=F(!1),h=F(``),g=F(!1),_=F(!1),v=F(``),y=F(!1),b=F(!1),x=F(``),S=F(`now`),C=F(60),w=F(``),T=F(!1),ee=F(``),E=F(Zt([])),D=N(()=>W(E).find(e=>e.status!==`sent`)),te=F(void 0);function ne(e){if(W(y)){dr().then(()=>W(te)?.focus());return}if(e.status!==`pending`||W(m)||!W(c)?.id||W(c).kind!==`prompt`||W(c).questions?.length)return;I(y,!0),dr().then(()=>W(te)?.focus()),I(l,[e.text],!0),I(S,e.trigger===`quota`?`quota`:`at`,!0),I(d,``),I(x,``);let t=new Date(e.at);e.trigger!==`quota`&&I(w,new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,16),!0)}bn(()=>{o()&&W(D)&&!W(b)&&W(c)?.id&&W(c).kind===`prompt`&&!W(c).questions?.length&&(I(b,!0),ne(W(D)))});async function re(){if(!i())try{I(E,await da(`schedules`,{session:t.session},_e.signal),!0),W(x)&&!W(E).some(e=>e.id===W(x)&&e.status===`pending`)&&(I(d,``),I(x,``))}catch{}}async function ie(e){try{I(E,await da(`schedules`,{session:t.session,cancelId:e},_e.signal),!0),I(y,!1),I(d,``),I(x,``),I(l,[],!0)}catch(e){I(h,e instanceof Error?e.message:`Unable to cancel trigger.`,!0)}}bn(()=>(s()(W(m)||W(l).some(e=>e.length>0)),()=>s()(!1)));let ae=N(()=>$.data?.sessions.find(e=>e.id===t.session)?.status),oe=N(()=>!$.connected||!!$.data?.sessionsError),se=N(()=>i()!==`profile`&&W(c)?.kind===`prompt`&&!W(c).questions?.length&&!!$.data?.profiles?.some(e=>e.session===t.session&&e.pending)),ce=N(()=>!W(oe)&&!W(_)&&!!W(c)?.id&&W(c).kind===`approval`&&W(v)!==W(c).id),le=N(()=>W(ce)?W(c).command:r()),ue=N(()=>!!W(d)&&W(p)W(c)?.questions?.length?W(c).questions:[{text:`Follow-up message`,secret:!1,freeText:!0,options:[]}]),fe=N(()=>W(c)?.kind===`approval`||W(c)?.kind===`profile`?W(u)!==null:W(l).length===W(de).length&&W(l).every((e,t)=>e.trim().length>0&&(W(de)[t].freeText||W(de)[t].options?.includes(e)))),pe=N(()=>W(c)?.kind===`prompt`&&!W(c).questions?.length&&W(S)!==`now`),me=N(()=>W(S)===`delay`?W(p)+W(C)*6e4:Date.parse(W(w))),he=N(()=>{if(!W(pe))return``;if(!W(l)[0]?.trim())return`Enter a message to schedule.`;if(W(S)===`quota`)return``;if(!Number.isFinite(W(me))||W(me)<=W(p))return`Choose a future date/time or a delay greater than zero.`;let e=new Date(W(p));return e.setFullYear(e.getFullYear()+1),W(me)>=e.getTime()?`Choose a time within one year.`:``});function O(e){return new Date(e).toLocaleString([],{timeZoneName:`short`})}function ge(e){if(e.status!==`pending`)return e.status;if(e.trigger===`at`&&Date.parse(e.at)>W(p))return`Due in `+Math.ceil((Date.parse(e.at)-W(p))/6e4)+` min`;let t=W(oe)?`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}bn(()=>{(W(oe)||a()||W(se)||W(p)>=W(f))&&I(d,``)});let _e=new AbortController;Ui(()=>{let e=e=>{e.ctrlKey&&e.key.toLowerCase()===`s`&&!i()&&W(D)&&(e.preventDefault(),ne(W(D)))};window.addEventListener(`keydown`,e);let n,r=setInterval(()=>{I(p,Date.now(),!0)},1e3);async function a(){await re();try{let e=await da(`offer`,{session:t.session,...i()?{review:i()}:{}},_e.signal);if(_e.signal.aborted)return;I(_,!1),W(c)?.id!==e.id&&(I(d,``),I(u,null),I(l,Array(Math.max(1,e.questions?.length||0)).fill(``),!0)),I(c,e,!0),W(g)&&e.id&&e.id!==W(v)&&(I(h,``),I(g,!1))}catch{_e.signal.aborted||(I(c,null),I(_,!0),I(d,``))}finally{_e.signal.aborted||(n=setTimeout(a,2e3))}}return a(),()=>{window.removeEventListener(`keydown`,e),_e.abort(),clearTimeout(n),clearInterval(r)}});async function ve(e){if(!W(c)?.id||W(m)||W(oe)||a()||W(se)||(e?!e.canSend:!W(fe)||W(he)))return;let n=W(c).id;I(m,!0),I(h,``),I(g,!1),I(d,``),I(x,e?.id||``,!0);try{let r=!e&&W(c).kind===`prompt`&&!W(c).questions?.length&&W(S)!==`now`?{trigger:W(S)===`quota`?`quota`:`at`,zone:Intl.DateTimeFormat().resolvedOptions().timeZone,...W(S)===`quota`?{}:{at:(W(S)===`delay`?new Date(Date.now()+W(C)*6e4):new Date(W(w))).toISOString()}}:void 0;I(T,!!r),I(ee,r?r.trigger===`quota`?`After fresh quota becomes available, when the session is idle`:O(r.at)+` — not before this time; when quota and idle allow`:``,!0);let o=await da(`prepare`,{session:t.session,...i()?{review:i()}:{},offer:n,...e?{sendId:e.id}:{},...r?{schedule:r}:{},...W(c).kind===`approval`||W(c).kind===`profile`?{choice:W(u)}:{answers:e?[e.text]:[...W(l)]}},_e.signal);W(c)?.id===n&&!_e.signal.aborted&&!W(oe)&&!a()&&!W(se)&&(I(d,o.confirmation,!0),I(f,Date.parse(o.expires),!0))}catch(e){_e.signal.aborted||I(h,e instanceof Error?e.message:`Unable to prepare action.`,!0)}finally{I(m,!1)}}async function ye(){if(!W(c)?.id||W(m)||a()||W(se)||!W(ue))return;let e=W(c).id,n=W(c).kind,r=W(d);I(d,``),I(m,!0),I(v,e,!0);try{await da(`commit`,{session:t.session,...i()?{review:i()}:{},offer:e,confirmation:r},_e.signal),I(g,!0),I(y,!1),W(T)&&(I(v,``),await re()),I(h,W(T)?`Trigger set. Closing Codexometer cancels it.`:n===`profile`?`Profile decision completed.`:n===`approval`?`Decision sent.`:`Text sent.`,!0)}catch(e){I(h,e instanceof la?e.message:`Outcome uncertain. Check Codex before taking another action; nothing was retried.`,!0)}finally{I(m,!1),I(x,``),await re(),I(l,[],!0),I(u,null)}}var be=co(),k=R(be),xe=e=>{var t=Fr();Z(R(t),17,()=>W(E).filter(e=>e.status!==`sent`),e=>e.id,(e,t)=>{var n=$a(),r=L(n),i=z(r,!0),o=B(r,2),s=z(o),l=B(o,2),u=z(l,!0),f=B(l,2),p=z(f,!0),g=B(f,2),_=z(g,!0),v=B(g,2),y=e=>{var t=Xa(),n=z(t,!0);V(()=>J(n,W(h))),q(e,t)};Y(v,e=>{W(h)&&e(y)});var b=B(v,4),S=B(b,2),C=B(S,2),w=e=>{var n=Za(),r=B(R(n),2),i=B(r,2);V(()=>r.disabled=W(m)||W(oe)||!W(t).canSend),G(`click`,r,ye),G(`click`,i,()=>{I(d,``),I(x,``)}),q(e,n)},T=e=>{var n=Qa();V(()=>n.disabled=W(m)||W(oe)||!W(t).canSend||a()),G(`click`,n,()=>ve(W(t))),q(e,n)};Y(C,e=>{W(ue)&&W(x)===W(t).id?e(w):e(T,-1)}),j(n),V((e,n)=>{J(i,W(t).status===`uncertain`?`CHECK TRIGGER — outcome uncertain; not retried`:`SCHEDULED FOLLOW-UP`),J(s,`TARGET // ${W(t).session??``}`),J(u,e),J(p,n),J(_,W(t).text),b.disabled=W(m)||!W(c)?.id||W(c).kind!==`prompt`||!!W(c).questions?.length||W(t).status!==`pending`,S.disabled=W(m)||W(t).status===`sending`},[()=>W(t).trigger===`quota`?`After confirmed quota recovery, when idle`:`Not before ${O(W(t).at)}`,()=>ge(W(t))]),G(`click`,b,()=>ne(W(t))),G(`click`,S,()=>ie(W(t).id)),q(e,n)}),q(e,t)};Y(k,e=>{i()||e(xe)});var A=B(k,2),Se=e=>{var r=jo(),a=L(r),o=z(a,!0),s=B(a,2),b=e=>{var t=eo(),n=R(t),r=z(n),i=B(n,6),a=z(i,!0),o=z(B(i,6),!0);we(2),V(()=>{J(r,`Your ${W(c).profile.threshold??``}% quota threshold has been reached. Review - the profile for subsequent turns.`),J(a,W(c).profile.current),J(o,W(c).profile.proposed)}),q(e,t)};Y(s,e=>{W(c)?.profile&&!W(oe)&&!W(_)&&e(b)});var x=B(s,2),E=e=>{var t=to();let n;var r=z(t,!0);V(()=>{n=ci(t,1,`svelte-1oupzfc`,null,n,{notice:!W(g),sent:W(g)}),J(r,W(h))}),q(e,t)};Y(x,e=>{W(h)&&e(E)});var D=B(x,2),ne=e=>{var t=no(),n=R(t),r=z(n,!0),i=z(B(n,2),!0);V(()=>{J(r,W(ce)?`EXACT COMMAND`:`LAST OBSERVED COMMAND`),J(i,W(le))}),q(e,t)},re=e=>{q(e,ro())};Y(D,e=>{W(le)?e(ne):i()!==`profile`&&W(ae)===`APPROVAL NEEDED`&&!W(g)&&e(re,1)});var ie=B(D,2),se=e=>{q(e,io())},pe=e=>{q(e,ao())},ge=e=>{var t=co(),n=R(t),r=e=>{var t=oo(),n=z(t,!0);V(e=>J(n,e),[()=>W(ae)===`WORKING`?`Codex is working — nothing to respond to.`:[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(ae)||``)?`Respond in Codex for this request.`:`Nothing needs a response right now.`]),q(e,t)};Y(n,e=>{(W(ae)===`WORKING`||!W(g)&&!W(m))&&e(r)});var i=B(n,2),a=e=>{q(e,so())},o=N(()=>[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(ae)||``)&&!W(g));Y(i,e=>{W(o)&&e(a)}),q(e,t)},_e=e=>{var r=Ao(),a=R(r),o=z(a),s=B(a,2),h=L(s),g=z(h,!0),_=B(h,2),v=e=>{var r=Fr();Z(R(r),17,()=>W(c).choices||[],X,(e,r,a)=>{var o=fo(),s=L(o);xi(s),s.value=s.__value=a;var c=B(s),l=B(c),d=e=>{var t=lo(),n=z(t,!0);V(()=>J(n,W(r).detail)),q(e,t)};Y(l,e=>{W(r).detail&&e(d)});var f=B(l,2),p=e=>{q(e,uo())};Y(f,e=>{W(r).persistent&&e(p)}),j(o),V(()=>{Q(s,`name`,`decision-`+t.session+`-`+i()),J(c,` ${W(r).label??``} `)}),Di(n,[],s,()=>W(u),e=>I(u,e)),q(e,o)}),q(e,r)},b=e=>{var t=co(),n=R(t),r=e=>{var t=vo(),n=R(t),r=B(L(n)),i=L(r),a=e=>{var t=po();t.value=t.__value=`now`,q(e,t)};Y(i,e=>{W(y)||e(a)});var o=B(i);o.value=o.__value=`quota`;var s=B(o);s.value=s.__value=`delay`;var c=B(s);c.value=c.__value=`at`,j(r),mi(r),j(n);var l=B(n,2),u=e=>{var t=mo(),n=B(L(t));xi(n),j(t),Ti(n,()=>W(C),e=>I(C,e)),q(e,t)};Y(l,e=>{W(S)===`delay`&&e(u)});var d=B(l,2),f=e=>{var t=ho(),n=B(L(t));xi(n),j(t),Ti(n,()=>W(w),e=>I(w,e)),q(e,t)};Y(d,e=>{W(S)===`at`&&e(f)});var p=B(d,2),m=e=>{var t=_o(),n=R(t),r=z(n),i=B(n,2),a=e=>{q(e,go())};Y(i,e=>{W(S)!==`quota`&&e(a)});var o=B(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.`,V(e=>J(r,`Will send: ${e??``}`),[()=>W(S)===`quota`?`when quota is available and this session is idle`:Number.isFinite(W(me))?O(W(me)):`choose a date and time`]),q(e,t)};Y(p,e=>{W(S)!==`now`&&e(m)}),hi(r,()=>W(S),e=>I(S,e)),q(e,t)};Y(n,e=>{W(c).questions?.length||e(r)}),Z(B(n,2),17,()=>W(de),X,(e,t,n)=>{var r=To(),i=R(r),a=L(i),o=B(a),s=e=>{var t=yo();xi(t),Ti(t,()=>W(l)[n],e=>W(l)[n]=e),q(e,t)},c=e=>{var r=xo(),i=L(r);i.value=i.__value=``,Z(B(i),17,()=>W(t).options||[],X,(e,t)=>{var n=bo(),r=z(n,!0),i={};V(()=>{J(r,W(t)),i!==(i=W(t))&&(n.value=(n.__value=i)??``)}),q(e,n)}),j(r),mi(r),hi(r,()=>W(l)[n],e=>W(l)[n]=e),q(e,r)},u=e=>{var r=So(),i=R(r);rt(i),Pi(i,e=>I(te,e),()=>W(te));var a=B(i,2),o=e=>{var n=oo(),r=z(n);V(e=>J(r,`Suggested answers: ${e??``}`),[()=>W(t).options.join(` · `)]),q(e,n)};Y(a,e=>{W(t).options?.length&&e(o)}),Ti(i,()=>W(l)[n],e=>W(l)[n]=e),q(e,r)};Y(o,e=>{W(t).secret?e(s):W(t).freeText?e(u,-1):e(c,1)}),j(i);var d=B(i,2),f=e=>{var n=wo(),r=B(L(n),4);Z(r,21,()=>W(t).options||[],X,(e,t)=>{var n=Co(),r=z(n,!0);V(()=>J(r,W(t))),q(e,n)}),j(r),j(n),q(e,n)};Y(d,e=>{W(t).secret&&!W(t).freeText&&e(f)}),V(()=>J(a,`${W(t).text??``} `)),q(e,r)}),q(e,t)};Y(_,e=>{W(c).kind===`approval`||W(c).kind===`profile`?e(v):e(b,-1)}),j(s);var x=B(s,2),E=e=>{var t=Do(),n=R(t),r=e=>{var t=Eo(),n=z(t);V(()=>J(n,`TRIGGER // ${W(ee)??``}`)),q(e,t)};Y(n,e=>{W(T)&&e(r)});var i=B(n,2),a=z(i),o=B(i,2),s=z(o),l=B(o,2);V(e=>{J(a,`Check the target and ${W(c).kind===`profile`?`profile above`:W(c).kind===`approval`?`exact command and permission scope`:`message above`}. ${W(T)?`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=W(m)||W(oe),J(s,`CONFIRM ${(W(c).kind===`approval`||W(c).kind===`profile`?W(c).choices?.[W(u)]?.label:W(T)?W(y)?`SAVE CHANGES`:`SCHEDULE`:`SEND`)??``}`)},[()=>Math.max(0,Math.ceil((W(f)-W(p))/1e3))]),G(`click`,o,ye),G(`click`,l,()=>{I(d,``)}),q(e,t)},D=e=>{var t=Oo(),n=R(t),r=e=>{var t=Xa(),n=z(t,!0);V(()=>J(n,W(he))),q(e,t)};Y(n,e=>{W(he)&&e(r)});var i=B(n,2),a=z(i,!0);V(()=>{i.disabled=W(m)||W(oe)||!W(fe)||!!W(he),J(a,W(m)?`SENDING…`:W(y)?`REVIEW CHANGES`:`REVIEW BEFORE SENDING`)}),G(`click`,i,()=>ve()),q(e,t)};Y(x,e=>{W(ue)?e(E):e(D,-1)});var ne=B(x,2),re=e=>{var t=ko();G(`click`,t,()=>{I(y,!1),I(d,``),I(l,[],!0)}),q(e,t)};Y(ne,e=>{W(y)&&e(re)}),V(()=>{J(o,`TARGET // ${W(c).thread??``} // ${(W(c).directory||`Directory unavailable`)??``}`),s.disabled=W(m)||W(ue)||W(oe),J(g,W(c).kind===`approval`||W(c).kind===`profile`?`Choose a decision`:W(y)?`EDIT SCHEDULED FOLLOW-UP`:`Reply to this session`)}),q(e,r)};Y(ie,e=>{W(oe)||W(_)?e(se):W(c)?W(c).id?W(v)!==W(c).id&&e(_e,3):e(ge,2):e(pe,1)}),j(r),V(()=>J(o,i()===`profile`?`QUOTA THRESHOLD`:`SESSION CONTROL // EXPERIMENTAL`)),q(e,r)};Y(A,e=>{!W(se)&&(!W(D)||W(y)||i()||W(c)?.kind!==`prompt`||W(c).questions?.length)&&e(Se)}),q(e,be),Ke()}wr([`click`]);var No=K(`
                  `);function Po(e,t){Ge(t,!0);let n=Hi(t,`active`,3,!1),r=N(()=>t.session.text||t.session.contextKind===`LAST ACTIVITY`&&t.session.workingCommand||``),i=N(()=>[`LAST REPLY`,`LAST ACTIVITY`].includes(t.session.contextKind)&&!!W(r).trim()),a=F(!1),o=F(``),s=F(!1);bn(()=>{if(!W(s))return;let e=setTimeout(()=>{I(s,!1)},150);return()=>clearTimeout(e)}),bn(()=>{W(r),t.session.status,I(o,``)});async function c(){if(!W(i)||W(a))return;let e=W(r);I(a,!0),I(s,!0),I(o,``);try{await navigator.clipboard.writeText(e),W(r)===e&&I(o,`Copied.`)}catch{W(r)===e&&I(o,`Clipboard unavailable. Select the visible text and copy it manually.`)}finally{I(a,!1)}}function l(e){!n()||!W(i)||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(),c())}var u=Fr();Cr(`keydown`,en,l);var d=R(u),f=e=>{var t=No(),n=L(t),r=z(n,!0),i=B(n,2);let l;j(t),V(()=>{J(r,W(o)),i.disabled=W(a),l=ci(i,1,`svelte-543j00`,null,l,{flashed:W(s)})}),G(`click`,i,c),q(e,t)};Y(d,e=>{W(i)&&e(f)}),q(e,u),Ke()}wr([`click`]);var Fo=K(`

                  CONTEXT

                   

                  `,1),Io=K(`

                  `),Lo=K(`

                  `),Ro=K(`
                   
                  `),zo=K(`

                   
                  `,1),Bo=K(`
                   
                  `),Vo=K(`

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

                  `),Ho=K(`

                  `,1),Uo=K(`

                  `),Wo=K(` `,1),Go=K(`
                  `),Ko=K(`

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

                  `),qo=K(`

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

                  `),Jo=K(` `),Yo=K(` `),Xo=K(` `),Zo=K(``),Qo=K(`

                  Read only — reply or approve in Codex.

                  `),$o=K(`

                  `),es=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),ts=K(`
                  `),ns=K(`
                  `),rs=K(`

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

                  `),is=K(`

                  `),as=K(``),os=K(`

                  `),ss=K(` `),cs=K(`

                  `),ls=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),us=K(` `,1),ds=K(`

                  `),fs=K(`

                  TOKEN ACTIVITY // 30 SECOND SAMPLES

                  `),ps=K(`

                  TOKENS

                  FULL DETAIL →
                  `),ms=K(`

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

                  `),hs=K(`

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

                  `,1),gs=K(`

                  SESSION TOTALS

                  `,1);function _s(e,t){Ge(t,!0);let n=(e,t=f,n,r)=>{let i=ht(()=>g(n?.(),!0)),a=ht(()=>g(r?.(),!1));var o=Wo(),s=R(o),c=e=>{var n=Fo(),r=z(B(R(n),2),!0);we(2),V(()=>J(r,t().approvalContext)),q(e,n)};Y(s,e=>{W(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(c)});var l=B(s,2),u=e=>{var n=Io();let r;var i=z(n,!0);V(e=>{r=ci(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),J(i,e)},[()=>C(t())]),q(e,n)},d=N(()=>C(t())&&(!W(a)||W(h)||t().status===`CHECK SESSION`));Y(l,e=>{W(d)&&e(u)});var p=B(l,2),m=e=>{var n=Lo(),r=z(n,!0);V(()=>J(r,t().contextKind||`LAST ACTIVITY`)),q(e,n)};Y(p,e=>{W(i)&&e(m)});var _=B(p,2),v=e=>{var n=Ro(),r=z(n,!0);V(()=>J(r,t().text||`No session context available.`)),q(e,n)};Y(_,e=>{(t().text||!t().workingCommand)&&e(v)});var y=B(_,2),b=e=>{var n=zo(),r=B(R(n),2),i=L(r),a=B(i),o=e=>{var n=Pr();V(()=>J(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),q(e,n)};Y(a,e=>{!W(h)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(o)});var s=B(a,2),c=e=>{q(e,Pr(`+`))};Y(s,e=>{t().runningLimited&&e(c)}),j(r);var l=z(B(r,2),!0);V(e=>{J(i,`COMMAND // ${e??``} `),J(l,t().workingCommand)},[()=>W(h)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),q(e,n)};Y(y,e=>{t().workingCommand&&e(b)});var x=B(y,2),S=e=>{var n=Ho(),r=B(R(n),2),i=z(r,!0),a=B(r,2),o=e=>{var n=Bo(),r=z(n,!0);V(()=>J(r,t().command)),q(e,n)},s=e=>{q(e,Vo())};Y(a,e=>{t().command?e(o):e(s,-1)}),V(()=>J(i,W(h)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),q(e,n)};Y(x,e=>{(!W(a)||!$.data?.control)&&(t().command||t().status===`APPROVAL NEEDED`)&&e(S)});var w=B(x,2),T=e=>{var n=Uo(),r=z(n);V(()=>J(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),q(e,n)};Y(w,e=>{W(a)||e(T)}),q(e,o)},r=Hi(t,`params`,19,()=>({})),i=N(()=>$.data?.sessions||[]),a=N(()=>$.data?.control&&$.data.profiles||[]),o=N(()=>($.data?.triggers||[]).filter(e=>W(i).some(t=>t.id===e.session)));function s(e,t){if(r().id&&r().id!==t&&W(l)){e.preventDefault();return}b(t)}function c(e){return[`TURN COMPLETE`,`IDLE`,`ACTIVE`].includes(e.status)&&W(o).some(t=>t.session===e.id)?`TRIGGER SET`:e.status}let l=F(!1);function u(e,t){if(r().id&&r().id!==t&&W(l)){e.preventDefault();return}b(t)}bn(()=>{let e=r().id;e&&mr(()=>{ea.selected=e,aa(e,2)})});let d=N(()=>W(i).find(e=>e.id===r().id)),p=N(()=>new URLSearchParams(Ki.querystring).get(`review`)===`profile`&&W(a).some(e=>e.session===r().id&&e.pending)),m=N(()=>W(i).some(e=>e.id===ea.selected)?ea.selected:W(i)[0]?.id),h=N(()=>!$.connected||!!$.data?.sessionsError),v=N(()=>[[`OBSERVED TOKENS`,oa(W(i).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,oa(W(i).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,W(h)?`—`:oa(W(i).filter(e=>e.status===t).length)])]),y=N(()=>W(i).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`,`CHECK SESSION`].includes(e.status)));function b(e){ea.selected=e,dr().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function x(e,t){if(b(e),r().id){t<0&&(aa(e,2),location.hash=`/sessions`);return}let n=ra(e)+t;n>2?location.hash=`/sessions/`+encodeURIComponent(e):aa(e,n)}function S(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`&&r().id)e.preventDefault(),x(r().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(r().id||W(m)))e.preventDefault(),x(r().id||W(m),e.key===`ArrowLeft`?-1:1);else if(!r().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&W(i).length){e.preventDefault();let t=W(i).findIndex(e=>e.id===W(m));b(W(i)[Math.max(0,Math.min(W(i).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function C(e){return W(h)?`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.`:$.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.`:``}var w=gs();Cr(`keydown`,en,S);var T=R(w),ee=z(B(L(T),2));j(T);var E=B(T,2);let D;Z(E,21,()=>W(v),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1];var a=Go(),o=L(a),s=z(o,!0),c=z(B(o,2),!0);j(a),V(()=>{J(s,r()),J(c,i())}),q(e,a)}),j(E);var te=B(E,2),ne=z(te),re=B(te,2),ie=e=>{q(e,Ko())};Y(re,e=>{W(h)&&e(ie)});var ae=B(re,2),oe=e=>{q(e,qo())};Y(ae,e=>{$.data?.profileError&&e(oe)});var se=B(ae,2),ce=e=>{var t=Zo(),n=L(t);Z(n,17,()=>W(y),X,(e,t)=>{var n=Jo();let r;var i=z(n);V((e,a)=>{r=ci(n,1,`button`,null,r,{approval:W(t).status===`APPROVAL NEEDED`}),Q(n,`href`,e),J(i,`${W(t).status??``} - ${a??``} // ${(W(t).name||W(t).directory||W(t).id)??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,n,()=>b(W(t).id)),q(e,n)});var c=B(n,2);Z(c,17,()=>W(a).filter(e=>e.pending&&W(i).some(t=>t.id===e.session)),X,(e,t)=>{var n=Yo(),a=z(n);V((e,i,o)=>{Q(n,`title`,r().id&&r().id!==W(t).session&&W(l)?`Finish sending or clear your current draft before switching sessions.`:`Review this session’s quota threshold`),Q(n,`href`,e),J(a,`QUOTA THRESHOLD ${i??``} // ${o??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session)+`?review=profile`,()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory||W(t).session]),G(`click`,n,e=>u(e,W(t).session)),q(e,n)}),Z(B(c,2),17,()=>W(o),X,(e,t)=>{var n=Xo(),r=z(n);V((e,t,i)=>{Q(n,`href`,e),J(r,`TRIGGER SET ${t??``} // ${i??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session),()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory]),G(`click`,n,e=>s(e,W(t).session)),q(e,n)}),j(t),q(e,t)},le=N(()=>(W(y).length||W(a).some(e=>e.pending)||W(o).length)&&!W(h));Y(se,e=>{W(le)&&e(ce)});var ue=B(se,2),de=e=>{var t=Fr(),i=R(t),o=e=>{var t=ns(),i=L(t),o=L(i),s=L(o);let u;var f=B(s);j(o);var m=B(o,2);j(i);var g=B(i,2),_=e=>{var t=Uo(),n=z(t,!0);V(()=>J(n,W(d).directory)),q(e,t)};Y(g,e=>{W(d).name&&W(d).directory&&e(_)});var v=B(g,2),y=z(v),x=B(v,2);let S;var C=L(x),w=L(C);n(w,()=>W(d),()=>!0,()=>!0),j(C);var T=B(C,2),ee=e=>{var t=Fr();qr(R(t),()=>W(d).id,e=>{{let t=N(()=>new URLSearchParams(Ki.querystring).get(`schedule`)===`edit`);Mo(e,{get session(){return W(d).id},get openScheduler(){return W(t)},get observedCommand(){return W(d).command},get suspended(){return W(p)},onProtectedChange:e=>{I(l,e,!0)}})}}),q(e,t)},E=e=>{q(e,Qo())};Y(T,e=>{$.data?.control?e(ee):e(E,-1)}),j(x);var D=B(x,2);Z(D,17,()=>W(a).filter(e=>e.session===W(d).id),e=>e.session,(e,t)=>{var n=ts(),r=L(n),i=e=>{var n=$o(),r=z(n,!0);V(()=>J(r,W(t).notice)),q(e,n)};Y(r,e=>{W(t).notice&&e(i)});var a=B(r,2),o=e=>{Mo(e,{get session(){return W(d).id},review:`profile`})},s=e=>{var t=es();V(e=>Q(t,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(d).id)+`?review=profile`]),q(e,t)};Y(a,e=>{W(t).pending&&W(p)?e(o):W(t).pending&&e(s,1)}),j(n),V(()=>Q(n,`id`,`quota-profile-`+W(d).id)),q(e,n)});var te=B(D,2),ne=e=>{var t=Fr();qr(R(t),()=>W(d).id,e=>{Po(e,{get session(){return W(d)},active:!0})}),q(e,t)};Y(te,e=>{W(p)||e(ne)}),j(t),V((e,t)=>{u=ci(s,1,`lamp lit`,null,u,{working:W(d).status===`WORKING`&&!W(h)}),J(f,`${e??``} // ${(W(d).name||W(d).directory)??``}`),J(y,`${t??``} TOKENS // ${W(d).id??``} // CONTEXT SOURCE // ${(W(d).source||`LOCAL`)??``}`),S=ui(x,``,S,{display:W(p)?`none`:void 0})},[()=>W(h)?`STALE`:W(p)?`QUOTA THRESHOLD`:c(W(d)),()=>oa(W(d).tokens)]),G(`click`,m,()=>{b(r().id),aa(r().id,2)}),q(e,t)},s=e=>{q(e,rs())};Y(i,e=>{W(d)?e(o):e(s,-1)}),q(e,t)},fe=e=>{var t=hs(),r=R(t),o=B(L(r),2),s=L(o),l=B(s,2);j(o),j(r);var d=B(r,2);Z(d,17,()=>W(i),e=>e.id,(e,t)=>{let r=N(()=>ra(W(t).id));var i=ps();let o;var s=L(i),l=L(s),d=e=>{var n=is(),r=L(n),i=z(r);j(n),V(e=>{Q(r,`aria-pressed`,W(m)===W(t).id),J(i,`${e??``} // ${W(t).name??``}`)},[()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,r,()=>b(W(t).id)),q(e,n)};Y(l,e=>{W(t).name&&e(d)});var f=B(l,2),p=L(f),g=L(p);let _;var v=B(g,1,!0);j(p),j(f);var y=B(f,2),S=e=>{var n=as(),r=z(n,!0);V(()=>{Q(n,`aria-pressed`,W(m)===W(t).id),J(r,W(t).directory||W(t).id)}),G(`click`,n,()=>b(W(t).id)),q(e,n)};Y(y,e=>{W(t).name||e(S)});var C=B(y,2),w=L(C);we(),j(C);var T=B(C,2),ee=e=>{var n=Uo(),r=z(n,!0);V(()=>J(r,W(t).directory)),q(e,n)};Y(T,e=>{W(t).name&&W(t).directory&&e(ee)});var E=B(T,2),D=z(E),te=B(E,2),ne=z(te),re=B(te,2),ie=L(re),ae=B(ie,2),oe=z(ae,!0),se=B(ae,2);j(re);var ce=B(re,2),le=B(ce,2),ue=e=>{var n=os(),r=z(n,!0);V(()=>J(r,W(t).status===`CHECK SESSION`?`INFERRED INACTIVITY`:$.data?.control?`OPEN FULL DETAIL OR REPLY IN CODEX`:W(t).status===`APPROVAL NEEDED`?`APPROVE OR DECLINE IN CODEX`:`REPLY IN CODEX`)),q(e,n)},de=N(()=>!W(h)&&[`APPROVAL NEEDED`,`INPUT NEEDED`,`CHECK SESSION`].includes(W(t).status));Y(le,e=>{W(de)&&e(ue)}),j(s);var fe=B(s,2),pe=e=>{var r=ds(),i=L(r),o=L(i),s=z(o,!0),c=B(o,2),l=e=>{var n=ss(),r=z(n,!0);V(e=>{Q(n,`href`,e),J(r,$.data?.control?`REVIEW IN FULL DETAIL ↗`:`APPROVAL IN CODEX ↗`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id)]),q(e,n)};Y(c,e=>{!W(h)&&W(t).status===`APPROVAL NEEDED`&&e(l)}),j(i);var d=B(i,2);n(d,()=>W(t),()=>!1);var f=B(d,2);Z(f,17,()=>W(a).filter(e=>e.session===W(t).id),X,(e,n)=>{var r=us(),i=R(r),a=e=>{var t=cs(),r=z(t,!0);V(()=>J(r,W(n).notice)),q(e,t)};Y(i,e=>{W(n).notice&&e(a)});var o=B(i,2),s=e=>{var n=ls();V(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(t).id)+`?review=profile`]),G(`click`,n,e=>u(e,W(t).id)),q(e,n)};Y(o,e=>{W(n).pending&&e(s)}),q(e,r)});var p=B(f,2);{let e=N(()=>W(m)===W(t).id);Po(p,{get session(){return W(t)},get active(){return W(e)}})}j(r),V(()=>J(s,W(t).contextKind||`LAST ACTIVITY`)),q(e,r)};Y(fe,e=>{W(r)>0&&e(pe)});var me=B(fe,2),he=e=>{var n=fs(),r=B(L(n),2);{let e=N(()=>(W(t).samples||[]).map(e=>e.tokens));Ya(r,{get values(){return W(e)},capacity:120})}var i=z(B(r,2));j(n),V(()=>J(i,`LAST ${(W(t).samples?.length||0)??``} SAMPLES // AUTO SCALE`)),q(e,n)};Y(me,e=>{W(r)<2&&e(he)}),j(i),V((e,n,a,s,c)=>{o=ci(i,1,`session-row`,null,o,{selected:W(m)===W(t).id,wide:W(r)===2,split:W(r)===1}),Q(i,`aria-label`,`Session `+(W(t).name||W(t).directory||W(t).id)),Q(p,`href`,e),_=ci(g,1,`lamp lit`,null,_,{working:W(t).status===`WORKING`&&!W(h)}),J(v,n),J(w,`${a??``} `),J(D,`${W(t).agents??``} LINKED AGENTS`),J(ne,`ACTIVE // ${s??``}`),ie.disabled=W(r)===0,Q(ae,`aria-expanded`,W(r)>0),J(oe,W(r)?`HIDE DETAIL`:`SHOW DETAIL`),Q(ce,`href`,c)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>W(h)?`STALE`:c(W(t)),()=>oa(W(t).tokens),()=>sa(W(t).activity),()=>`#/sessions/`+encodeURIComponent(W(t).id)]),G(`click`,p,()=>b(W(t).id)),G(`click`,ie,()=>x(W(t).id,-1)),G(`click`,ae,()=>{b(W(t).id),aa(W(t).id,+!W(r))}),G(`click`,se,()=>x(W(t).id,1)),G(`click`,ce,()=>b(W(t).id)),q(e,i)});var f=B(d,2),p=e=>{q(e,ms())};Y(f,e=>{W(i).length||e(p)}),G(`click`,s,()=>ia(1)),G(`click`,l,()=>ia(0)),q(e,t)};Y(ue,e=>{r().id?e(de):e(fe,-1)}),V(e=>{J(ee,`OBSERVED ${e??``}`),D=ci(E,1,`session-totals`,null,D,{stale:W(h)}),J(ne,`${W(h)?`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.`)},[()=>sa($.data?.sessionsAt)]),q(e,w),Ke()}wr([`click`]);var vs=K(`

                  `),ys=K(`

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

                  `,1),bs=K(`// APPROXIMATE`),xs=K(`

                  Partial accounting: totals may still change.

                  `),Ss=K(`

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

                  `,1),Cs=K(`

                  `,1),ws=K(`

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

                  `),Ts=K(`
                  `),Es=K(`
                  `),Ds=K(`

                  No usage reported for this day.

                  `),Os=K(`

                  Selected breakdown unavailable; missing does not mean zero.

                  `),ks=K(`

                  `,1);function As(e,t){Ge(t,!0);let n=F(`surface`),r=F(0),i=N(()=>t.reports?.daily),a=N(()=>t.reports?.plan),o=N(()=>t.mode===`breakdown`?W(i)?.days.length||0:W(a)?.periods.length||0),s=N(()=>Math.min(W(r),Math.max(0,W(o)-1))),c=N(()=>W(i)?.days[(W(i)?.days.length||0)-1-W(s)]),l=N(()=>W(a)?.periods[W(s)]),u=N(()=>t.mode===`breakdown`?W(i)?.units||``:`%`),d=N(()=>{let e=Object.create(null);if(t.mode===`breakdown`)e=W(c)?.groups[W(n)]||{};else{let t=W(n)===`feature`?`thread_source`:W(n)===`task start`?`turn_trigger`:W(n);for(let n of W(l)?.breakdowns||[])if(n.dimension===t)for(let t of n.rows)e[t.key]=(e[t.key]||0)+t.basis_points/100}return Object.entries(e).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}),f=N(()=>t.mode===`breakdown`?W(c)?.total:W(l)?.used_basis_points==null?null:W(l).used_basis_points/100),p=N(()=>Math.max(1,W(f)||0,...W(d).map(([,e])=>e))),m=e=>e==null?`UNKNOWN`:e.toLocaleString(`en-GB`,{maximumFractionDigits:2});var h=ks(),g=R(h),v=L(g),y=B(L(v)),b=L(y);b.value=b.__value=`surface`;var x=B(b);x.value=x.__value=`model`;var S=B(x);S.value=S.__value=`feature`;var C=B(S);C.value=C.__value=`task start`,j(y),mi(y),j(v);var w=B(v,2),T=B(w,2),ee=z(B(T,2),!0);j(g);var E=B(g,2),D=L(E),te=z(D,!0),ne=B(D,2),re=z(ne),ie=B(ne,2),ae=e=>{var t=ys(),n=R(t),r=z(n),a=B(n,2),o=e=>{var t=vs(),n=z(t);V(()=>J(n,`Data as of ${W(i).dataAsOf??``}`)),q(e,t)};Y(a,e=>{W(i).dataAsOf&&e(o)});var s=z(B(a,2));we(2),V((e,t)=>{J(r,`Latest fetch ${e??``} // queried ${W(i).from??``} → ${W(i).through??``}. - Reports are fetched from OpenAI and are not saved between runs.`),J(s,`${(W(c)?.date||`No daily buckets reported`)??``} // ${t??``} - ${W(u)??``}`)},[()=>sa(W(i).fetchedAt),()=>m(W(f))]),q(e,t)},oe=e=>{var t=Cs(),n=R(t),r=L(n);let i;var o=z(r,!0),s=B(r),c=e=>{q(e,bs())};Y(s,e=>{W(a).approximate&&e(c)});var u=B(s);j(n);var d=B(n,2),p=L(d),h=B(p),g=e=>{var t=Pr();V(()=>J(t,`// Boundary tolerance ${W(a).boundary_tolerance_seconds??``}s`)),q(e,t)};Y(h,e=>{W(a).boundary_tolerance_seconds!=null&&e(g)}),j(d);var _=B(d,2),v=e=>{var t=Ss(),n=R(t),r=L(n),i=B(r);let a;var o=z(i);j(n);var s=B(n,2),c=z(s),u=B(s,2),d=e=>{q(e,xs())};Y(u,e=>{W(l).accounting_complete||e(d)}),we(2),V(e=>{J(r,`${W(l).window_minutes??``} MIN // ${W(l).plan_type??``} // `),a=ci(i,1,`svelte-1fbui7h`,null,a,{muted:W(f)==null,"quota-near":W(f)!=null&&W(f)>=80&&W(f)<100,"quota-full":W(f)!=null&&W(f)>=100}),J(o,`USED ${e??``}${W(f)==null?``:`%`}`),J(c,`${W(l).starts_at??``} → ${W(l).ends_at??``}`)},[()=>m(W(f))]),q(e,t)};Y(_,e=>{W(l)&&e(v)}),V(e=>{i=ci(r,1,`svelte-1fbui7h`,null,i,{"quality-warning":!W(a).coverage_complete}),J(o,W(a).coverage_complete?`Reported range complete`:`Partial coverage`),J(u,` // Latest fetch ${e??``}`),J(p,`Coverage starts ${(W(a).coverage_start||`unknown`)??``} // Data as of ${(W(a).data_as_of||`unknown`)??``}`)},[()=>sa(W(a).fetchedAt)]),q(e,t)},se=e=>{q(e,ws())};Y(ie,e=>{t.mode===`breakdown`&&W(i)?e(ae):t.mode===`periods`&&W(a)?e(oe,1):e(se,-1)});var ce=B(ie,2),le=e=>{var n=Es(),r=L(n),i=z(B(L(r),2),!0);j(r),Z(B(r,2),17,()=>W(d),X,(e,n,r)=>{var i=N(()=>_(W(n),2));let a=()=>W(i)[0],o=()=>W(i)[1];var s=Ts();let c;var l=L(s),u=z(l,!0),d=B(l,2),f=L(d);let h;j(d);var g=z(B(d,2));j(s),V((e,n,i)=>{c=ci(s,1,`report-row svelte-1fbui7h`,null,c,{unknown:e,alternate:r%2==1}),Q(l,`title`,a()),J(u,a()),h=ui(f,``,h,{width:n}),J(g,`${i??``}${t.mode===`periods`?`%`:``}`)},[()=>a().trim().toLowerCase()===`unknown`,()=>`${Math.max(0,100*o()/W(p))}%`,()=>m(o())]),q(e,s)}),j(n),V(()=>J(i,t.mode===`breakdown`?W(u):`QUOTA USED`)),q(e,n)},ue=e=>{q(e,Ds())},de=e=>{q(e,Os())};Y(ce,e=>{W(d).length?e(le):t.mode===`breakdown`&&W(c)?.total===0&&W(c)?.groups[W(n)]!=null?e(ue,1):(W(i)&&t.mode===`breakdown`||W(a)&&t.mode===`periods`)&&e(de,2)}),j(E),V(()=>{w.disabled=W(s)>=W(o)-1,T.disabled=W(s)===0,J(ee,W(o)?`${W(s)+1} / ${W(o)}`:`NO DATA`),J(te,t.mode===`breakdown`?`DAILY BREAKDOWN`:`QUOTA WINDOWS`),J(re,`${(t.mode===`breakdown`?t.reports?.dailyStatus||`UNAVAILABLE`:t.reports?.planStatus||`UNAVAILABLE`)??``} // UTC`)}),hi(y,()=>W(n),e=>I(n,e)),G(`click`,w,()=>I(r,W(s)+1)),G(`click`,T,()=>I(r,W(s)-1)),q(e,h),Ke()}wr([`click`]);var js=864e5;function Ms(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 Ns(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));for(let e=0;;e++){let i=Ms(r,-t),a=new Date(i.getTime()+js);if(e===n)return{start:a,end:r};r=i}}var Ps=K(``),Fs=K(``,1),Is=K(`

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

                  `),Ls=K(`

                  Token history unavailable; other reports may still be available.

                  `),Rs=K(``),zs=K(`
                  `),Bs=K(`

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

                  `,1),Vs=K(`
                  `,1),Hs=K(` `),Us=K(`

                  LIFETIME TOKENS

                  PEAK DAY

                  CURRENT STREAK

                  DAYS

                  LONGEST TURN

                  SECONDS

                  LONGEST STREAK

                  DAYS

                  OPENAI // UTC

                  Accessible data table
                  Date (UTC)Tokens

                  `,1),Ws=K(`

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

                  `),Gs=K(`

                  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 Ks(e,t){Ge(t,!0);let n=F(`daily`),r=F(12),i=F(0),a=N(()=>{let e=$.data?.usage?.dailyUsageBuckets;if(!e)return[];let{start:t,end:n}=Ns(new Date,W(r),W(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=N(()=>Math.max(1,...W(a).map(e=>e.tokens))),s=N(()=>W(a).length?new Date(W(a)[0].date+`T00:00:00Z`).getUTCDay():0),c=N(()=>{if(W(n)===`monthly`){let e=new Map;for(let t of W(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 W(a).map(t=>({date:t.date,tokens:e+=t.tokens}))});var l=Gs(),u=B(R(l),4);Z(u,20,()=>[[`daily`,`Daily`],[`monthly`,`Monthly`],[`cumulative`,`Cumulative`],[`breakdown`,`Breakdown`],[`periods`,`Windows`]],X,(e,t)=>{var r=N(()=>_(t,2));let a=()=>W(r)[0],o=()=>W(r)[1];var s=Ps();let c;var l=z(s,!0);V(()=>{Q(s,`aria-pressed`,W(n)===a()),c=ci(s,1,``,null,c,{active:W(n)===a()}),J(l,o())}),G(`click`,s,()=>{I(n,a(),!0),I(i,0)}),q(e,s)}),j(u);var d=B(u,2),f=L(d),p=e=>{var t=Fs(),n=R(t),a=B(L(n)),o=L(a);o.value=o.__value=6;var s=B(o);s.value=s.__value=12,j(a),mi(a),j(n);var c=B(n),l=B(c);V(()=>l.disabled=W(i)===0),G(`change`,a,()=>I(i,0)),hi(a,()=>W(r),e=>I(r,e)),G(`click`,c,()=>Jt(i)),G(`click`,l,()=>Jt(i,-1)),q(e,t)};Y(f,e=>{W(n)!==`breakdown`&&W(n)!==`periods`&&e(p)}),j(d);var m=B(d,2),h=e=>{q(e,Is())};Y(m,e=>{$.data?.usageError&&e(h)});var g=B(m,2),v=e=>{q(e,Ls())};Y(g,e=>{$.data?.usage?.tokenStatus===`UNAVAILABLE`&&W(n)!==`breakdown`&&W(n)!==`periods`&&e(v)});var y=B(g,2),b=e=>{var t=Fr();qr(R(t),()=>W(n),e=>{{let t=N(()=>$.data?.usage?.reports);As(e,{get reports(){return W(t)},get mode(){return W(n)}})}}),q(e,t)},x=e=>{var t=Us(),r=R(t),i=L(r),l=z(B(L(i),2),!0);j(i);var u=B(i,2),d=z(B(L(u),2),!0);j(u);var f=B(u,2),p=B(L(f),2),m=L(p);we(),j(p),j(f);var h=B(f,2),g=B(L(h),2),_=L(g);we(),j(g),j(h);var v=B(h,2),y=B(L(v),2),b=L(y);we(),j(y),j(v),j(r);var x=B(r,4),S=L(x),C=z(S),w=B(S,2),T=e=>{var t=Bs(),n=R(t),r=L(n),i=L(r);Z(i,17,()=>Array(W(s)),X,(e,t)=>{q(e,Rs())}),Z(B(i,2),17,()=>W(a),X,(e,t)=>{var n=zs();let r,i;V(e=>{r=ci(n,1,`heat-cell`,null,r,{zero:W(t).tokens===0}),Q(n,`title`,e),i=ui(n,``,i,{opacity:W(t).tokens?.25+.75*W(t).tokens/W(o):1})},[()=>`${W(t).date}: ${oa(W(t).tokens)} tokens`]),q(e,n)}),j(r),j(n),we(2),q(e,t)},ee=e=>{var t=Vs(),r=R(t);{let e=N(()=>W(c).map(e=>e.tokens)),t=N(()=>W(n)+` usage`);Ya(r,{get values(){return W(e)},get label(){return W(t)}})}var i=B(r,2),a=L(i),o=z(a,!0),s=z(B(a),!0);j(i),V(e=>{J(o,W(c)[0]?.date),J(s,e)},[()=>W(c).at(-1)?.date]),q(e,t)};Y(w,e=>{W(n)===`daily`?e(T):e(ee,-1)});var E=B(w,2),D=B(L(E),2),te=L(D),ne=B(L(te));Z(ne,21,()=>W(n)===`daily`?W(a):W(c),X,(e,t)=>{var n=Hs(),r=L(n),i=z(r,!0),a=z(B(r),!0);j(n),V(e=>{J(i,W(t).date),J(a,e)},[()=>oa(W(t).tokens)]),q(e,n)}),j(ne),j(te),j(D),j(E),j(x);var re=z(B(x,2));V((e,t,n,r,i,o,s)=>{J(l,e),J(d,t),J(m,`${n??``} `),J(_,`${r??``} `),J(b,`${i??``} `),J(C,`${W(a)[0]?.date??``} — ${o??``}`),J(re,`OBSERVED ${s??``} // CUMULATIVE IS FOR THE SELECTED PERIOD`)},[()=>oa($.data.usage.summary.lifetimeTokens),()=>oa($.data.usage.summary.peakDailyTokens),()=>oa($.data.usage.summary.currentStreakDays),()=>oa($.data.usage.summary.longestRunningTurnSec),()=>oa($.data.usage.summary.longestStreakDays),()=>W(a).at(-1)?.date,()=>sa($.data.usageAt)]),q(e,t)},S=e=>{q(e,Ws())};Y(y,e=>{W(n)===`breakdown`||W(n)===`periods`?e(b):$.data?.usage&&$.data.usage.dailyUsageBuckets!==null?e(x,1):e(S,-1)}),q(e,l),Ke()}wr([`click`,`change`]);var qs=K(`

                  Page not found

                  Return to Quota

                  `,1);function Js(e){var t=qs();we(2),q(e,t)}var Ys=K(` `),Xs=K(`

                  `),Zs=K(`

                  Connecting to your local Codexometer…

                  `),Qs=K(``),$s=K(`
                  CODEXOMETER

                  Your quota. Your sessions. Your command centre.

                  `);function ec(e,t){Ge(t,!0);let n={"/":Ka,"/quota/:view?":Ka,"/sessions/:id?":_s,"/usage":Ks,"*":Js},r={quota:/^(?:\/|\/quota(?:\/[^/]+)?\/?)$/,sessions:/^\/sessions(?:\/[^/]+)?\/?$/,usage:/^\/usage\/?$/},i=F(`hacker`),a=[`hacker`,`rust`,`blue-steel`,`ultraviolet`,`nightshade`];bn(()=>{ta()}),bn(()=>{if($.data)for(let[e,t]of Object.entries(r))t.test(Ki.location)&&(ea.tab=e)}),Ui(()=>{try{let e=localStorage.getItem(`codexometer.web.theme`);e&&a.includes(e)&&I(i,e,!0)}catch{}return fa()});function o(){try{localStorage.setItem(`codexometer.web.theme`,W(i))}catch{}}var s=$s(),c=L(s),l=B(L(c),2),u=L(l);let d;var f=B(u,1,!0),p=z(B(f));j(l),j(c);var m=B(c,2);Z(m,21,()=>Object.entries(r),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1],a=N(()=>i().test(Ki.location));var o=Ys();let s;var c=z(o,!0);V(e=>{Q(o,`href`,r()===`quota`?`#/quota/`+ea.view:`#/`+r()),Q(o,`aria-current`,W(a)?`page`:void 0),s=ci(o,1,``,null,s,{active:W(a)}),J(c,e)},[()=>r().toUpperCase()]),q(e,o)}),j(m);var h=B(m,2),g=L(h),v=e=>{var t=Xs(),n=z(t,!0);V(()=>J(n,$.error)),q(e,t)};Y(g,e=>{$.error&&e(v)});var y=B(g,2),b=e=>{Yi(e,{get routes(){return n}})},x=e=>{q(e,Zs())};Y(y,e=>{$.data?e(b):$.error||e(x,1)}),j(h);var S=B(h,2),C=L(S),w=z(C),T=B(C,2),ee=z(T,!0),E=B(T,2),D=B(L(E));Z(D,21,()=>a,X,(e,t)=>{var n=Qs(),r=z(n,!0),i={};V(e=>{J(r,e),i!==(i=W(t))&&(n.value=(n.__value=i)??``)},[()=>W(t).replace(`-`,` `).toUpperCase()]),q(e,n)}),j(D),mi(D),j(E),j(S),j(s),V(()=>{Q(s,`data-theme`,W(i)),d=ci(u,1,`lamp`,null,d,{lit:$.connected}),J(f,$.connected?`CONNECTED`:`OFFLINE`),J(p,`EXPERIMENTAL // ${$.data?.control?`SESSION CONTROL`:`READ ONLY`}`),J(w,`v${($.data?.version||`…`)??``} // LOCAL ONLY`),J(ee,$.data?.control?`Session control enabled. Stop the server to revoke access.`:`No actions can be sent from this preview.`)}),G(`change`,D,o),hi(D,()=>W(i),e=>I(i,e)),q(e,s),Ke()}wr([`change`]),Vr(ec,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/web/dist/assets/index-iKInt6oX.js b/internal/web/dist/assets/index-iKInt6oX.js new file mode 100644 index 0000000..d6e0fbd --- /dev/null +++ b/internal/web/dist/assets/index-iKInt6oX.js @@ -0,0 +1,42 @@ +(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,ee=1<<19,te=1<<20,E=1<<25,ne=1<<21,re=1<<22,ie=1<<23,D=Symbol(`$state`),ae=Symbol(`component`),oe=Symbol(`legacy props`),se=Symbol(``),ce=Symbol(`attributes`),le=Symbol(`class`),ue=Symbol(`style`),de=Symbol(`text`),fe=Symbol(`form reset`),pe=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},me=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`),he={},O=Symbol(`uninitialized`),ge=`http://www.w3.org/1999/xhtml`;function _e(){console.warn(`https://svelte.dev/e/derived_inert`)}function ve(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function ye(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function be(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var k=!1;function xe(e){k=e}var A;function Se(e){if(e===null)throw ve(),he;return A=e}function Ce(){return Se(cn(A))}function j(e){if(k){if(cn(A)!==null)throw ve(),he;A=e}}function we(e=1){if(k){for(var t=e,n=A;t--;)n=cn(n);A=n}}function Te(e=!0){for(var t=0,n=A;;){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=cn(n);e&&n.remove(),n=i}}function Ee(e){if(!e||e.nodeType!==8)throw ve(),he;return e.data}function De(e){return e===this.v}function Oe(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function ke(e){return!Oe(e,this.v)}function Ae(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function je(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function Me(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function Ne(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Pe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Fe(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ie(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Le(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Re(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function ze(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Be(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Ve(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var He=!1;function Ue(){He=!0}var M=null;function We(e){M=e}function Ge(e,t=!1,n){M={p:M,i:!1,c:null,e:null,s:e,x:null,r:U,l:He&&!t?{s:null,u:null,$:[]}:null}}function Ke(e){var t=M,n=t.e;if(n!==null){t.e=null;for(var r of n)xn(r)}return e!==void 0&&(t.x=e),t.i=!0,M=t.p,qe(e)}function qe(e={}){return i(e,ae,{value:!0}),e}function Je(){return!He||M!==null&&M.l===null}var Ye=[];function Xe(){var e=Ye;Ye=[],m(e)}function Ze(e){if(Ye.length===0&&!Tt){var t=Ye;queueMicrotask(()=>{t===Ye&&Xe()})}Ye.push(e)}function Qe(){for(;Ye.length>0;)Xe()}var $e=~(y|b|v);function et(e,t){e.f=e.f&$e|t}function tt(e){e.f&512||e.deps===null?et(e,v):et(e,b)}function nt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),et(e,v)}function rt(e){k&&sn(e)!==null&&ln(e)}var it=!1;function at(){it||(it=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[fe]?.()})},{capture:!0}))}function ot(e){var t=H,n=U;Gn(null),Kn(null);try{return e()}finally{Gn(t),Kn(n)}}function st(e,t,n,r=n){e.addEventListener(t,()=>ot(n));let i=e[fe];e[fe]=i?()=>{i(),r(!0)}:()=>r(!0),at()}function ct(e,t,n,r){let i=Je()?ft:ht;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=U,c=lt(),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){mn(e,s)}ut()}}var d=dt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>mt(e))).then(u).catch(e=>mn(e,s)).finally(d)}l?l.then(()=>{c(),f(),ut()}):f()}function lt(){var e=U,t=H,n=M,r=P;return function(i=!0){Kn(e),Gn(t),We(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function ut(e=!0){Kn(null),Gn(null),We(null),e&&P?.deactivate()}function dt(){var e=U,t=e.b,n=P,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 ft(e){var t=2|y;return U!==null&&(U.f|=ee),{ctx:M,deps:null,effects:null,equals:De,f:t,fn:e,reactions:null,rv:0,v:O,wv:0,parent:U,ac:null}}var pt=Symbol(`obsolete`);function mt(e,t,n){let r=U;r===null&&je();var i=void 0,a=Ht(O),o=!H,s=new Set;return Tn(()=>{var t=U,n=h();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==pe&&n.reject(e)}).finally(ut)}catch(e){n.reject(e),ut()}var c=P;if(o){if(t.f&32768)var l=dt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(pt);else for(let e of s.values())e.reject(pt);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==pt&&(c.activate(),t?(a.f|=ie,Kt(a,t)):(a.f&8388608&&(a.f^=ie),Kt(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),yn(()=>{for(let e of s)e.reject(pt)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function N(e){let t=ft(e);return Jn(t),t}function ht(e){let t=ft(e);return t.equals=ke,t}function gt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(pe),t.ac=null}),t.fn!==null&&(t.teardown=f),lr(t,0),An(t))}function bt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&ur(t)}var xt=null,P=null,St=null,Ct=null,wt=null,Tt=!1,Et=!1,Dt=null,Ot=null,kt=0,At=1,jt=class e{id=At++;#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(){xt===null?xt=this:(xt.#n=this,this.#t=xt),xt=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)et(r,y),t(r);for(r of n.m)et(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),et(e,y),this.schedule(e);for(let e of this.#d)et(e,b),this.schedule(e);this.apply();for(var t=Dt=[],n=[],r=Ot=[];this.#c.length>0;){kt++>1e3&&(this.#S(),Nt());for(let e of this.#g())try{this.#v(e,t,n)}catch(t){throw Rt(e),this.#h()||this.discard(),t}}if(P=null,r.length>0){var i=e.ensure();for(let e of r)i.schedule(e)}if(Dt=null,Ot=null,this.#h()){this.#x(n),this.#x(t);for(let[e,t]of this.#f)Lt(e,t);r.length>0&&P.#_();return}let a=this.#y();if(a){this.#x(n),this.#x(t),a.#b(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),St=this,Ft(n),Ft(t),St=null,this.#s?.resolve();var o=P;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&&(Bt.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):ir(r)&&(i&16&&this.#d.add(r),ur(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),et(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),P=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(P===null){let t=P=new e;!Et&&!Tt&&Ze(()=>{t.#e||t.flush()})}return P}apply(){Ct=null}schedule(e){if(wt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}this.#c.push(e)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?xt=e:t.#t=e,this.linked=!1}}};function Mt(e){var t=Tt;Tt=!0;try{var n;for(e&&(P!==null&&!P.is_fork&&P.flush(),n=e());;){if(Qe(),P===null)return n;P.flush()}}finally{Tt=t}}function Nt(){try{Ie()}catch(e){mn(e,wt)}}var Pt=null;function Ft(e){var t=e.length;if(t!==0){for(var n=0;n0)){Bt.clear();for(let e of Pt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Pt.has(n)&&(Pt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||ur(n)}}Pt.clear()}}Pt=null}}function It(e){P.schedule(e)}function Lt(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),et(e,v);for(var n=e.first;n!==null;)Lt(n,t),n=n.next}}function Rt(e){et(e,v);for(var t=e.first;t!==null;)Rt(t),t=t.next}var zt=new Set,Bt=new Map,Vt=!1;function Ht(e,t){return{f:0,v:e,reactions:null,equals:De,rv:0,wv:0}}function F(e,t){let n=Ht(e,t);return Jn(n),n}function Ut(e,t=!1,n=!0){let r=Ht(e);return t||(r.equals=ke),He&&n&&M!==null&&M.l!==null&&(M.l.s??=[]).push(r),r}function I(e,t,n=!1){return H!==null&&(!Wn||H.f&131072)&&Je()&&H.f&4325394&&(qn===null||!qn.has(e))&&Be(),Kt(e,n?Zt(t):t,Ot)}var Wt=null,Gt=0;function Kt(e,t,n=null){if(!e.equals(t)){Hn?Bt.set(e,t):Bt.has(e)||Bt.set(e,e.v);var r=jt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&_t(t),Ct===null&&tt(t)}e.wv=rr(),Wt=null,Gt=0,Xt(e,y,n),Wt=null,Je()&&U!==null&&U.f&1024&&!(U.f&96)&&(Zn===null?Qn([e]):Zn.push(e)),!r.is_fork&&zt.size>0&&!Vt&&qt()}return t}function qt(){Vt=!1;for(let e of zt){e.f&1024&&et(e,b);let t;try{t=ir(e)}catch{t=!0}t&&ur(e)}zt.clear()}function Jt(e,t=1){var n=W(e),r=t===1?n++:n--;return I(e,n),r}function Yt(e){I(e,e.v+1)}function Xt(e,t,n){var r=e.reactions;if(r!==null){var i=Je(),a=r.length;if(Gt+=a,Gt>1e5&&Wt===null&&(Wt=new Set),Wt!==null){if(Wt.has(e))return;Wt.add(e)}for(var o=0;o{if(tr===d)return e();var t=H,n=tr;Gn(null),nr(d);var r=e();return Gn(t),nr(n),r};return i&&r.set(`length`,F(t.length,u)),new Proxy(t,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&Re();var i=r.get(t);return i===void 0?f(()=>{var e=F(n.value,u);return r.set(t,e),e}):I(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>F(O,u));r.set(t,e),Yt(o)}}else I(n,O),Yt(o);return!0},get(e,n,i){if(n===D)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>F(Zt(s?e[n]:O),u)),r.set(n,o)),o!==void 0){var c=W(o);return c===O?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=W(i);if(a===O)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===D)return!0;var n=r.get(t),i=n!==void 0&&n.v!==O||Reflect.has(e,t);return(n!==void 0||U!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>F(i?Zt(e[t]):O,u)),r.set(t,n)),W(n)===O)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dF(O,u)),r.set(d+``,p)):I(p,O)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>F(void 0,u)),I(c,Zt(n)),r.set(t,c));else{l=c.v!==O;var m=f(()=>Zt(n));I(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&&I(g,_+1)}Yt(o)}return!0},ownKeys(e){W(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==O});for(var[n,i]of r)i.v!==O&&!(n in e)&&t.push(n);return t},setPrototypeOf(){ze()}})}function Qt(e){try{if(typeof e==`object`&&e&&D in e)return e[D]}catch{}return e}function $t(e,t){return Object.is(Qt(e),Qt(t))}var en,tn,nn,rn;function an(){if(en===void 0){en=window,tn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;nn=a(t,`firstChild`).get,rn=a(t,`nextSibling`).get,u(e)&&(e[le]=void 0,e[ce]=null,e[ue]=void 0,e.__e=void 0),u(n)&&(n[de]=void 0)}}function on(e=``){return document.createTextNode(e)}function sn(e){return nn.call(e)}function cn(e){return rn.call(e)}function L(e,t){if(!k)return sn(e);var n=sn(A);if(n===null)n=A.appendChild(on());else if(t&&n.nodeType!==3){var r=on();return n?.before(r),Se(r),r}return t&&fn(n),Se(n),n}function R(e,t=!1){if(!k){var n=sn(e);return n instanceof Comment&&n.data===``?cn(n):n}if(t){if(A?.nodeType!==3){var r=on();return A?.before(r),Se(r),r}fn(A)}return A}function z(e,t=!1){if(!k)return sn(e);var n=L(e,t);return j(e),n}function B(e,t=1,n=!1){let r=k?A:e;for(var i;t--;)i=r,r=cn(r);if(!k)return r;if(n){if(r?.nodeType!==3){var a=on();return r===null?i?.after(a):r.before(a),Se(a),a}fn(r)}return Se(r),r}function ln(e){e.textContent=``}function un(){return!1}function dn(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 fn(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 pn(e){var t=U;if(t===null)return H.f|=ie,e;if(!(t.f&32768)&&!(t.f&4))throw e;mn(e,t)}function mn(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 hn(e){U===null&&(H===null&&Fe(e),Pe()),Hn&&Ne(e)}function gn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function _n(e,t){var n=U;n!==null&&n.f&8192&&(e|=x);var r={ctx:M,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};P?.register_created_effect(r);var i=r;if(e&4)Dt===null?jt.ensure().schedule(r):Dt.push(r);else if(t!==null){try{ur(r)}catch(e){throw Mn(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&&gn(i,n),H!==null&&H.f&2&&!(e&64))){var a=H;(a.effects??=[]).push(i)}return r}function vn(){return H!==null&&!Wn}function yn(e){let t=_n(8,null);return et(t,v),t.teardown=e,t}function bn(e){hn(`$effect`);var t=U.f;if(!H&&t&32&&M!==null&&!M.i){var n=M;(n.e??=[]).push(e)}else return xn(e)}function xn(e){return _n(4|te,e)}function Sn(e){return hn(`$effect.pre`),_n(8|te,e)}function Cn(e){jt.ensure();let t=_n(64|ee,e);return(e={})=>new Promise(n=>{e.outro?Fn(t,()=>{Mn(t),n(void 0)}):(Mn(t),n(void 0))})}function wn(e){return _n(4,e)}function Tn(e){return _n(re|ee,e)}function En(e,t=0){return _n(8|t,e)}function V(e,t=[],n=[],r=[]){ct(r,t,n,t=>{_n(8,()=>{e(...t.map(W))})})}function Dn(e,t=0){return _n(16|t,e)}function On(e){return _n(32|ee,e)}function kn(e){var t=e.teardown;if(t!==null){let n=Hn,r=H;Un(!0),Gn(null);try{t.call(null)}catch(t){mn(t,e.parent)}finally{Un(n),Gn(r)}}}function An(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&ot(()=>{e.abort(pe)});var r=n.next;n.f&64?n.parent=null:Mn(n,t),n=r}}function jn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Mn(t),t=n}}function Mn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Nn(e.nodes.start,e.nodes.end),n=!0),e.f|=w,An(e,t&&!n),lr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();kn(e),e.f^=w,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Pn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Nn(e,t){for(;e!==null;){var n=e===t?null:cn(e);e.remove(),e=n}}function Pn(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 Fn(e,t,n=!0){var r=[];e.f|=256,In(e,r,!0);var i=()=>{n&&Mn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function In(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);In(i,t,o?n:!1)}i=a}}}function Ln(e){e.f&=-257,Rn(e,!0)}function Rn(e,t){if(!(e.f&256)&&e.f&8192){e.f^=x,e.f&1024||(et(e,y),jt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=!!(n.f&65536)||!!(n.f&32);Rn(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 zn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:cn(n);t.append(n),n=i}}var Bn=null,Vn=!1,Hn=!1;function Un(e){Hn=e}var H=null,Wn=!1;function Gn(e){H=e}var U=null;function Kn(e){U=e}var qn=null;function Jn(e){H!==null&&(H.f&2097152||H.f&2)&&(qn??=new Set).add(e)}var Yn=null,Xn=0,Zn=null;function Qn(e){Zn=e}var $n=1,er=0,tr=er;function nr(e){tr=e}function rr(){return++$n}function ir(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&&Ct===null&&et(e,v)}return!1}function ar(e,t,n=!0){var r=e.reactions;if(r!==null&&!(qn!==null&&qn.has(e)))for(var i=0;i{e.ac.abort(pe)}),e.ac=null);try{e.f|=ne;var u=e.fn,d=u();e.f|=C;var f=sr(e);if(Je()&&Zn!==null&&!Wn&&f!==null&&!(e.f&6146))for(var p=0;p0)for(t.length=Xn+Yn.length,r=0;r{s.ac.abort(pe),s.ac=null,et(s,y)}),yt(s),lr(s,0)}}function lr(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,Ze(()=>{i.__removed||t.addEventListener(e,i,r)})):t.addEventListener(e,i,r),i}function Cr(e,t,n,r,i){var a={capture:r,passive:i},o=Sr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&yn(()=>{o.__removed=!0,t.removeEventListener(e,o,a)})}function G(e,t,n){(t[yr]??={})[e]=n}function wr(e){for(var t=0;t{Er=!1,Tr=null}));var s=0,c=Tr===e&&e[yr];if(c){var l=a.indexOf(c);if(l!==-1&&(t===document||t===window)){e[yr]=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=H,f=U;Gn(null),Kn(null);try{for(var p,m=[];o!==null&&o!==t;){try{var h=o[yr]?.[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[yr]=t,delete e.currentTarget,Gn(d),Kn(f)}}}var Or=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function kr(e){return Or?.createHTML(e)??e}function Ar(e){var t=dn(`template`);return t.innerHTML=kr(e.replaceAll(``,``)),t.content}function jr(e,t){var n=U;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function K(e,t){var n=!!(t&1),r=!!(t&2),i,a=!e.startsWith(``);return()=>{if(k)return jr(A,null),A;i===void 0&&(i=Ar(a?e:``+e),n||(i=sn(i)));var t=r||tn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=sn(t),s=t.lastChild;jr(o,s)}else jr(t,t);return t}}function Mr(e,t,n=`svg`){var r=!e.startsWith(``),i=!!(t&1),a=`<${n}>${r?e:``+e}`,o;return()=>{if(k)return jr(A,null),A;if(!o){var e=sn(Ar(a));if(i)for(o=document.createDocumentFragment();sn(e);)o.appendChild(sn(e));else o=sn(e)}var t=o.cloneNode(!0);if(i){var n=sn(t),r=t.lastChild;jr(n,r)}else jr(t,t);return t}}function Nr(e,t){return Mr(e,t,`svg`)}function Pr(e=``){if(!k){var t=on(e+``);return jr(t,t),t}var n=A;return n.nodeType===3?fn(n):(n.before(n=on()),Se(n)),jr(n,n),n}function Fr(){if(k)return jr(A,null),A;var e=document.createDocumentFragment(),t=document.createComment(``),n=on();return e.append(t,n),jr(t,n),e}function q(e,t){if(k){var n=U;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=A),Ce();return}e!==null&&e.before(t)}function Ir(){if(k&&A&&A.nodeType===8&&A.textContent?.startsWith(`$`)){let e=A.textContent.substring(1);return Ce(),e}return(window.__svelte??={}).uid??=1,`c${window.__svelte.uid++}`}function Lr(e){let t=0,n=Ht(0),r;return()=>{vn()&&(W(n),En(()=>(t===0&&(r=mr(()=>e(()=>Yt(n)))),t+=1,()=>{Ze(()=>{--t,t===0&&(r?.(),r=void 0,Yt(n))})})))}}var Rr=T|ee;function zr(e,t,n,r){new Br(e,t,n,r)}var Br=class{parent;is_pending=!1;transform_error;#e;#t=k?A: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=Lr(()=>(this.#m=Ht(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=U;t.b=this,t.f|=128,n(e)},this.parent=U.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Dn(()=>{if(k){let e=this.#t;Ce();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()},Rr),k&&(this.#e=A)}#g(){try{this.#a=On(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed,{reset:n,invoke_onerror:r}=this.#v(e);Ze(r),t&&(this.#s=On(()=>{t(this.#e,()=>e,()=>n)}))}#v(e){var t=!1,n=!1;let r=()=>{if(t){be();return}t=!0,n&&Ve(),this.#s!==null&&Fn(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){mn(e,this.#i&&this.#i.parent)}}}}#y(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=On(()=>e(this.#e)),Ze(()=>{var e=this.#c=document.createDocumentFragment(),t=on(),n=!1;if(e.append(t),this.#a=this.#S(()=>{try{return On(()=>this.#r(t))}catch(e){try{this.error(e),n=!0}catch(e){mn(e,this.#i.parent)}return null}}),this.#a===null){this.#c=null,n&&this.#x(P);return}this.#u===0&&(this.#e.before(e),this.#c=null,Fn(this.#o,()=>{this.#o=null}),this.#x(P))}))}#b(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=On(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();zn(this.#a,e);let t=this.#n.pending;this.#o=On(()=>t(this.#e))}else this.#x(P)}catch(e){this.error(e)}}#x(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){nt(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=U,n=H,r=M;Kn(this.#i),Gn(this.#i),We(this.#i.ctx);try{return jt.ensure(),e()}finally{Kn(t),Gn(n),We(r)}}#C(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#C(e,t);return}this.#u+=e,this.#u===0&&(this.#x(t),this.#o&&Fn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#C(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,Ze(()=>{this.#d=!1,this.#m&&Kt(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),W(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;P?.is_fork?(this.#a&&P.skip_effect(this.#a),this.#o&&P.skip_effect(this.#o),this.#s&&P.skip_effect(this.#s),P.oncommit(()=>{this.#w(e)})):this.#w(e)}#w(e){this.#a&&=(Mn(this.#a),null),this.#o&&=(Mn(this.#o),null),this.#s&&=(Mn(this.#s),null),k&&(Se(this.#t),we(),Se(Te()));let t=this.#n.failed,n=e=>{let{reset:n,invoke_onerror:r}=this.#v(e);r(),t&&(this.#s=this.#S(()=>{try{return On(()=>{var r=U;r.b=this,r.f|=128,t(this.#e,()=>e,()=>n)})}catch(e){return mn(e,this.#i.parent),null}}))};Ze(()=>{var t;try{t=this.transform_error(e)}catch(e){mn(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(n,e=>mn(e,this.#i&&this.#i.parent)):n(t)})}};function J(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[de]??=e.nodeValue)&&(e[de]=n,e.nodeValue=`${n}`)}function Vr(e,t){return Ur(e,t)}var Hr=new Map;function Ur(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){an();var l=void 0,u=Cn(()=>{var s=n??t.appendChild(on());zr(s,{pending:()=>{}},t=>{Ge({});var n=M;if(o&&(n.c=o),a&&(i.$$events=a),k&&jr(t,null),l=e(t,i)||qe(),k&&(U.nodes.end=A,A===null||A.nodeType!==8||A.data!==`]`))throw ve(),he;Ke()},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=Hr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Dr),r.delete(e),r.size===0&&Hr.delete(n)):r.set(e,i)}xr.delete(d),s!==n&&s.parentNode?.removeChild(s)}});return Wr.set(l,u),l}var Wr=new WeakMap,Gr=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)Ln(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Ln(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&&(Mn(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();zn(r,t),t.append(on()),this.#n.set(e,{effect:r,fragment:t})}else Mn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Fn(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)||(Mn(n.effect),this.#n.delete(e))};ensure(e,t){var n=P,r=un();if(t&&!this.#t.has(e)&&!this.#n.has(e)){if(r){var i=document.createDocumentFragment(),a=on();i.append(a),this.#n.set(e,{effect:On(()=>t(a)),fragment:i})}else this.#t.set(e,On(()=>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 k&&(this.anchor=A),this.#a(n)}};function Y(e,t,n=!1){var r;k&&(r=A,Ce());var i=new Gr(e),a=n?T:0;function o(e,t){if(k){var n=Ee(r);if(e!==parseInt(n.substring(1))){var a=Te();Se(a),i.anchor=a,xe(!1),i.ensure(e,t),xe(!0);return}}i.ensure(e,t)}Dn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var Kr=Symbol(`NaN`);function qr(e,t,n){k&&Ce();var r=new Gr(e),i=!Je();Dn(()=>{var e=t();e!==e&&(e=Kr),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function X(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;ln(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^=E,ei(d,null,c)):Ln(d):Fn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Dn(()=>{p=W(f);var e=p.length;let t=!1;k&&Ee(c)===`[!`!=(e===0)&&(c=Te(),Se(c),xe(!1),t=!0);for(var r=new Set,u=P,v=un(),y=0;ys(c)):(d=On(()=>s(Xr??=on())),d.f|=E)),e>r.size&&Me(``,``,``),k&&e>0&&Se(Te()),!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&&xe(!0),W(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,k&&(c=A)}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 ee=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?Ht(n):Ut(n,!1,!1):null,l=o&2?Ht(i):null;return{v:c,i:l,e:On(()=>(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=cn(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;k&&(r=A,Ce());var i=new Gr(e);Dn(()=>{var e=t()??null;if(k&&Ee(r)===`[`!=(e!==null)){var a=Te();Se(a),i.anchor=a,xe(!1),i.ensure(e,e&&(t=>n(t,e))),xe(!0);return}i.ensure(e,e&&(t=>n(t,e)))},T)}var ri=[...` +\r\f\xA0\v`];function ii(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||ri.includes(r[o-1]))&&(s===r.length||ri.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function ai(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 oi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function si(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(oi)),i&&c.push(...Object.keys(i).map(oi));var l=0,u=-1;let t=e.length;for(var d=0;d{t.every(_i)||(`__defaultValue`in e&&fi(e,!1),`__value`in e&&pi(e,e.__value))});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),yn(()=>{t.disconnect()})}function hi(e,t,n=t){var r=new WeakSet,i=!0;st(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),gi);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&gi(o)}n(a),e.__value=a,P!==null&&r.add(P)}),wn(()=>{var a=t();if(e===document.activeElement){var o=P;if(r.has(o))return}if(pi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=gi(s),n(a))}e.__value=a,i=!1})}function gi(e){return`__value`in e?e.__value:e.value}function _i(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 vi=Symbol(`is custom element`),yi=Symbol(`is html`),bi=me?`link`:`LINK`;function xi(e){if(k){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[fe]=n,Ze(n),at()}}function Q(e,t,n,r){var i=Si(e);k&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===bi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[se]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&wi(e).has(t)?e[t]=n:e.setAttribute(t,n))}function Si(e){return e[ce]??={[vi]:e.nodeName.includes(`-`),[yi]:e.namespaceURI===ge}}var Ci=new Map;function wi(e){var t=e.getAttribute(`is`)||e.nodeName,n=Ci.get(t);if(n)return n;Ci.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 Ti(e,t,n=t){var r=new WeakSet;st(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=ki(e)?Ai(a):a,n(a),P!==null&&r.add(P),await dr(),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))}}}),(k&&e.defaultValue!==e.value||mr(t)==null&&e.value)&&(n(ki(e)?Ai(e.value):e.value),P!==null&&r.add(P)),En(()=>{var n=t();if(e===document.activeElement){var i=P;if(r.has(i))return}ki(e)&&n===Ai(e.value)||(e.type!==`date`||n||e.value)&&n!==e.value&&(e.value=n??``)})}var Ei=new Set;function Di(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),st(n,`change`,()=>{var e=n.__value;a&&(e=Oi(o,e,n.checked)),i(e)},()=>i(a?[]:null)),En(()=>{var e=r();if(k&&n.defaultChecked!==n.checked){s=!0;return}a?(e||=[],n.checked=e.includes(n.__value)):n.checked=$t(n.__value,e)}),yn(()=>{var e=o.indexOf(n);e!==-1&&o.splice(e,1)}),Ei.has(o)||(Ei.add(o),Ze(()=>{o.sort((e,t)=>e.compareDocumentPosition(t)===4?-1:1),Ei.delete(o)})),Ze(()=>{if(s){var e=a?Oi(o,e,n.checked):o.find(e=>e.checked)?.__value;i(e)}})}function Oi(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 Mi(e,t,n){var r=ji.observe(e,()=>n(e[t]));wn(()=>(mr(()=>n(e[t])),r))}function Ni(e,t){return e===t||e?.[D]===t}function Pi(e=qe(),t,n,r){var i=M.r,a=U;return wn(()=>{var o,s;return En(()=>{o=s,s=r?.()||[],mr(()=>{Ni(n(...s),e)||(t(e,...s),o&&Ni(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&&Ni(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function Fi(e,t,n,r,i){var a=()=>{r(n[e])};n.addEventListener(t,a),i?En(()=>{n[e]=i()}):a(),(n===document.body||n===window||n===document)&&yn(()=>{n.removeEventListener(t,a)})}function Ii(e=!1){let t=M,n=t.l.u;if(!n)return;let r=()=>hr(t.s);if(e){let e=0,n={},i=ft(()=>{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=()=>W(i)}n.b.length&&Sn(()=>{Li(t,r),m(n.b)}),bn(()=>{let e=mr(()=>n.m.map(p));return()=>{for(let t of e)typeof t==`function`&&t()}}),n.a.length&&bn(()=>{Li(t,r),m(n.a)})}function Li(e,t){if(e.l.s)for(let t of e.l.s)W(t);t()}var Ri=!1;function zi(e){var t=Ri;try{return Ri=!1,[e(),Ri]}finally{Ri=t}}var Bi={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===D||t===oe)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 Vi(...e){return new Proxy({props:e},Bi)}function Hi(e,t,n,r){var i=!He||!!(n&2),o=!!(n&8),s=!!(n&16),c=r,l=!0,u=void 0,d=()=>s&&i?(u??=ft(r),W(u)):(l&&(l=!1,c=s?mr(r):r),c);let f;if(o){var p=D in e||oe in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=zi(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&Le(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?ft:ht)(()=>(v=!1,g()));o&&W(y);var b=U;return(function(e,t){if(arguments.length>0){let n=t?W(y):i&&o?Zt(e):e;return I(y,n),v=!0,c!==void 0&&(c=n),e}return Hn&&v||b.f&16384?y.v:W(y)})}function Ui(e){M===null&&Ae(`onMount`),He&&M.l!==null?Wi(M).m.push(e):bn(()=>{let t=mr(e);if(typeof t==`function`)return t})}function Wi(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);function Gi(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 Ki=new class{#e=F(qi());get _loc(){return W(this.#e)}set _loc(e){I(this.#e,e)}#t=N(()=>this._loc.location);get _location(){return W(this.#t)}set _location(e){I(this.#t,e)}#n=N(()=>this._loc.querystring);get _querystring(){return W(this.#n)}set _querystring(e){I(this.#n,e)}#r=F(void 0);get _params(){return W(this.#r)}set _params(e){I(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=qi()}):console.warn(`[svelte-spa-router] window 'window' is not defined, skipping initiation`)}};function qi(){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}}function Ji(e){e?window.scrollTo(e.__svelte_spa_router_scrollX||0,e.__svelte_spa_router_scrollY||0):window.scrollTo(0,0)}function Yi(e,t){Ge(t,!0);let n=Hi(t,`routes`,19,()=>({})),r=Hi(t,`prefix`,3,``),i=Hi(t,`restoreScrollState`,3,!1),a=Hi(t,`onConditionsFailed`,3,()=>{}),o=Hi(t,`onRouteLoaded`,3,()=>{}),s=Hi(t,`onRouteLoading`,3,()=>{}),c=Hi(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=Gi(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=F(null),f=F(null),p=F({}),m=null,h=null;bn(()=>{history.scrollRestoration=i()?`manual`:`auto`}),bn(()=>{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 dr(),e(t)}bn(()=>{let e=Ki.loc,t=!1;return mr(async()=>{let n=0;for(;n{t=!0}});function _(e){return e&&typeof e==`object`&&Object.keys(e).length?e:null}var v=Fr(),y=R(v),b=e=>{let t=N(()=>W(d));var n=Fr(),r=R(n),i=e=>{var n=Fr();ni(R(n),()=>W(t),(e,t)=>{t(e,Vi({get params(){return W(f)},get onRouteEvent(){return c()}},()=>W(p)))}),q(e,n)},a=e=>{var n=Fr();ni(R(n),()=>W(t),(e,t)=>{t(e,Vi({get onRouteEvent(){return c()}},()=>W(p)))}),q(e,n)};Y(r,e=>{W(f)?e(i):e(a,-1)}),q(e,n)};Y(y,e=>{W(d)&&e(b)}),q(e,v),Ke()}var Xi=[`bars`,`pace`,`zone`,`pie`,`fuel`,`resets`,`thresholds`],Zi=`codexometer.web.preferences.v1`,Qi={tab:`quota`,view:`bars`,selected:``,defaultDetail:0,layouts:[]};function $i(){try{let e=JSON.parse(localStorage.getItem(Zi)||`null`);return!e||typeof e!=`object`?Qi:{tab:[`quota`,`sessions`,`usage`].includes(e.tab)?e.tab:`quota`,view:Xi.includes(e.view)?e.view:`bars`,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 Qi}}var ea=Zt($i());function ta(){let e=JSON.stringify(ea);try{localStorage.setItem(Zi,e)}catch{}}function na(){return ea.tab===`quota`?`/quota/`+ea.view:`/`+ea.tab}function ra(e){return ea.layouts.find(t=>t.id===e)?.level??ea.defaultDetail}function ia(e){ea.defaultDetail=e,ea.layouts=[]}function aa(e,t){ea.layouts=[...ea.layouts.filter(t=>t.id!==e),{id:e,level:Math.max(0,Math.min(2,t))}].slice(-100)}var $=Zt({data:null,connected:!1,error:``}),oa=e=>e==null?`Unavailable`:e.toLocaleString(`en-GB`),sa=e=>!e||String(e).startsWith(`0001-`)?`Not yet available`:new Date(typeof e==`number`?e*1e3:e).toLocaleString(`en-GB`),ca=`codexometer.web.session`,la=class extends Error{},ua;async function da(e,t,n){if(!ua||!$.connected||!$.data?.control||$.data.sessionsError)throw Error(`Session controls unavailable. Check the live connection.`);return await ua(e,t,n)}function fa(){let e=new AbortController,t,n=``;ua=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 la(`Action rejected, expired or changed. Refresh and check Codex; nothing was retried.`);return a.json()};try{n=sessionStorage.getItem(ca)||``}catch{}let r=location.hash,i=r.startsWith(`#pair=`)?r.slice(6):``;(i||!r||r===`#`)&&(history.replaceState(null,``,`/#`+na()),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(ca,n)}catch{}}catch(t){e.signal.aborted||($.error=t instanceof Error?t.message:`Pairing failed`);return}if(!n){$.error=`Open the private pairing link printed by codexometer --web in your terminal.`;return}await o()}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(ca)}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(),()=>{ua=void 0,e.abort(),clearTimeout(t),$.connected=!1}}Ue();var pa=K(`

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

                  `),ma=K(`

                  `),ha=K(`

                  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),ga=K(`

                  No threshold-based model steps were configured at launch.

                  `);function _a(e,t){Ge(t,!1),Ii();var n=Fr(),r=R(n),i=e=>{var t=ha(),n=R(t),r=z(n),i=B(n,2),a=e=>{q(e,pa())};Y(i,e=>{$.data.quotaError&&e(a)});var o=B(i,2),s=L(o),c=z(s),l=B(s,4);Z(l,5,()=>$.data.thresholds,X,(e,t)=>{var n=ma();let r;var i=L(n),a=z(i),o=B(i,2),s=L(o),c=z(s,!0),l=z(B(s,2));j(o);var u=B(o,2),d=z(u,!0),f=z(B(u,2));j(n),V((e,i)=>{r=ci(n,1,``,null,r,{active:W(t).state===`ACTIVE`,next:W(t).state===`NEXT`}),J(a,`${W(t).threshold??``}%`),J(c,W(t).model),J(l,`${e??``} REASONING // ${i??``} + SPEED`),J(d,W(t).mode),J(f,`${W(t).state??``}${W(t).state===`NEXT`?` // ${W(t).remaining||0} PP TO GO`:``}`)},[()=>W(t).effort.toUpperCase(),()=>W(t).speed.toUpperCase()]),q(e,n)}),j(l),j(o),V(e=>{J(r,`MODEL STEP POLICY // OBSERVED ${e??``}`),J(c,`THRESHOLDS // ${$.data.thresholds.length??``} CONFIGURED`)},[()=>sa($.data.quotaAt)]),q(e,t)},a=e=>{q(e,ga())};Y(r,e=>{$.data?.thresholds?.length?e(i):e(a,-1)}),q(e,n),Ke()}var va=Nr(` `,1),ya=Nr(` `,1),ba=K(` `),xa=K(`
                  Quota observations
                  Observed atPeriod elapsedConsumedTrail segment
                  `),Sa=K(`


                  Observed quota + path, not individual session usage. Gaps are not interpolated. Expand the + observation table for times, positions and gaps.

                  OBSERVATION TABLE
                  `,1),Ca=K(`
                  CONSUMPTIONQUOTA PERIOD ELAPSED


                  `,1);function wa(e,t){let n=Ir();Ge(t,!0);let r=Hi(t,`trail`,19,()=>[]),i=F(!1),a=[0,25,50,75,100],o=F(400),s=F(240),c=N(()=>W(o)-24),l=N(()=>W(s)-48),u=N(()=>Math.max(1,W(c)-48)),d=N(()=>Math.max(1,W(l)-20)),f=N(()=>48+Math.max(0,Math.min(100,t.elapsed))/100*W(u)),p=N(()=>W(l)-Math.max(0,Math.min(100,t.used))/100*W(d)),m=N(()=>t.used-t.elapsed),h=N(()=>r().map((e,t)=>`${t===0||e.break?`M`:`L`}${48+e.elapsed/100*W(u)} ${W(l)-e.used/100*W(d)}`).join(` `));var g=Ca(),_=R(g),v=L(_),y=L(v),b=z(y),x=B(y),S=B(x);Z(S,17,()=>a,X,(e,t)=>{var n=va(),r=R(n),i=B(r),a=B(i),o=z(a),s=B(a),f=z(s);V(()=>{Q(r,`x1`,48+W(t)/100*W(u)),Q(r,`x2`,48+W(t)/100*W(u)),Q(r,`y2`,W(l)),Q(i,`y1`,W(l)-W(t)/100*W(d)),Q(i,`x2`,W(c)),Q(i,`y2`,W(l)-W(t)/100*W(d)),Q(a,`x`,48+W(t)/100*W(u)),Q(a,`y`,W(l)+20),J(o,`${W(t)??``}%`),Q(s,`y`,W(l)+4-W(t)/100*W(d)),J(f,`${W(t)??``}%`)}),q(e,n)});var C=B(S),w=B(C),T=B(w),ee=e=>{var t=ya(),n=R(t),i=B(n),a=z(L(i));j(i),V(e=>{Q(n,`d`,W(h)),Q(i,`cx`,48+r()[0].elapsed/100*W(u)),Q(i,`cy`,W(l)-r()[0].used/100*W(d)),J(a,`First observation: ${e??``}`)},[()=>sa(r()[0].at)]),q(e,t)};Y(T,e=>{r().length&&e(ee)});var te=B(T,2),E=B(te),ne=B(E),re=z(L(ne));j(ne),j(v),j(_);var ie=B(_,2),D=L(ie),ae=z(B(D,3),!0);j(ie);var oe=B(ie,2),se=e=>{var t=Sa(),a=R(t),o=L(a);we(2),j(a);var s=B(a,2),c=B(L(s),2),l=e=>{var t=xa(),n=L(t),i=B(L(n),2);Z(i,21,r,X,(e,t,n)=>{var r=ba(),i=L(r),a=L(i),o=z(a,!0);j(i);var s=B(i),c=z(s),l=B(s),u=z(l),d=z(B(l),!0);j(r),V((e,r)=>{Q(a,`datetime`,W(t).at),J(o,e),J(c,`${r??``}%`),J(u,`${W(t).used??``}%`),J(d,n===0?`First observation`:W(t).break?`Gap before this observation`:`Connected to previous observation`)},[()=>sa(W(t).at),()=>W(t).elapsed.toFixed(1)]),q(e,r)}),j(i),j(n),j(t),q(e,t)};Y(c,e=>{W(i)&&e(l)}),j(s),V(e=>{Q(a,`id`,n+`-trail-summary`),J(o,`○ START ${e??``} // ${r().length??``} + ${r().length===1?`OBSERVATION`:`OBSERVATIONS`}`)},[()=>sa(r()[0].at)]),Fi(`open`,`toggle`,s,e=>I(i,e),()=>W(i)),q(e,t)};Y(oe,e=>{r().length&&e(se)}),V((e,i,a,m)=>{Q(v,`viewBox`,`0 0 ${W(o)} ${W(s)}`),Q(v,`aria-describedby`,r().length?n+`-trail-summary`:void 0),Q(v,`aria-label`,e),Q(b,`id`,n),Q(x,`width`,W(u)),Q(x,`height`,W(d)),Q(x,`fill`,`url(#${n})`),Q(C,`d`,`M48 20 V${W(l)} H${W(c)}`),Q(w,`y1`,W(l)),Q(w,`x2`,W(c)),Q(te,`x`,48+W(u)/2),Q(te,`y`,W(s)-5),Q(E,`cx`,W(f)),Q(E,`cy`,W(p)),Q(ne,`cx`,W(f)),Q(ne,`cy`,W(p)),J(re,`${t.used??``}% consumed // ${i??``}% of period elapsed`),J(D,`${t.used??``}% USED // ${a??``}% TIME ELAPSED`),J(ae,m)},[()=>`Consumption zone: ${t.used}% consumed, ${t.elapsed.toFixed(1)}% of quota period elapsed. ${W(m)>0?`Above`:W(m)<0?`Below`:`On`} the steady-consumption line.`,()=>t.elapsed.toFixed(1),()=>t.elapsed.toFixed(1),()=>Math.abs(W(m))<.05?`ON PACE`:W(m)>0?`ABOVE THE LINE — CONSUMING FASTER THAN TIME`:`BELOW THE LINE — WITHIN PACE`]),Mi(_,`clientWidth`,e=>I(o,e)),Mi(_,`clientHeight`,e=>I(s,e)),q(e,g),Ke()}var Ta=K(` `),Ea=K(`

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

                  `),Da=K(`

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

                  `),Oa=K(`

                  `),ka=K(`

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

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

                  `),Aa=K(` `,1),ja=Nr(``),Ma=Nr(``),Na=K(`
                  `),Pa=K(`

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

                  `),Fa=K(`
                  ▼
                  −100 // OVER BUDGET+100 // HEADROOM

                  `,1),Ia=K(`

                  Cycle duration unavailable — pace cannot be calculated.

                  `),La=K(`
                  EMPTYFULL
                  `),Ra=K(`

                  `,1),za=K(`
                  `,1),Ba=K(`

                  `),Va=K(`

                  `),Ha=K(`

                  No quota windows reported yet.

                  `),Ua=K(`
                  `,1),Wa=K(`

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

                  `,1),Ga=K(` `,1);function Ka(e,t){Ge(t,!0);let n=Hi(t,`params`,19,()=>({})),r=N(()=>Xi.filter(e=>e!==`thresholds`||!!$.data?.thresholds?.length)),i=F(Zt(Date.now())),a=N(()=>W(r).includes(n().view||``)?n().view:`bars`);Ui(()=>{let e=setInterval(()=>I(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-W(i))/(e.duration*6e4))))}bn(()=>{ea.view=W(a)});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=Ga(),l=R(c);Z(l,21,()=>W(r),X,(e,t)=>{var n=Ta();let r;var i=z(n,!0);V(e=>{Q(n,`href`,`#/quota/`+W(t)),Q(n,`aria-current`,W(a)===W(t)?`page`:void 0),r=ci(n,1,``,null,r,{active:W(a)===W(t)}),J(i,e)},[()=>W(t)===`pace`?`CONSUMPTION PACE`:W(t)===`zone`?`CONSUMPTION ZONE`:W(t)===`fuel`?`FUEL TANK`:W(t).toUpperCase()]),q(e,n)}),j(l);var u=B(l,2),d=e=>{var t=Wa(),n=R(t),r=e=>{q(e,Ea())};Y(n,e=>{$.data.quotaError&&e(r)});var i=B(n,2),c=z(i),l=B(i,2),u=e=>{_a(e,{})},d=e=>{var t=ka(),n=L(t),r=z(n),i=B(n,4),a=e=>{q(e,Da())};Y(i,e=>{$.data.credits.length||e(a)}),Z(B(i,2),17,()=>$.data.credits,X,(e,t)=>{var n=Oa(),r=L(n),i=z(r),a=z(B(r,2),!0);j(n),V(e=>{J(i,`${(W(t).title||`Quota reset`)??``} // ${W(t).status??``}`),J(a,e)},[()=>W(t).expiryKnown?W(t).expires?`EXPIRES `+sa(W(t).expires):`Does not expire`:`Expiry information unavailable`]),q(e,n)}),we(2),j(t),V(()=>J(r,`RESET INVENTORY // ${$.data.creditCount??``} AVAILABLE`)),q(e,t)},f=e=>{var t=Ua(),n=R(t);let r;Z(n,21,()=>$.data.meters,X,(e,t)=>{let n=N(()=>o(W(t))),r=N(()=>W(n)===null?null:W(n)-W(t).used);var i=Va(),c=L(i),l=z(c,!0),u=B(c,2),d=L(u),f=e=>{var n=Aa(),r=R(n),i=z(r),a=z(B(r));V(()=>{J(i,`FREE ${100-W(t).used}%`),J(a,`USED ${W(t).used??``}%`)}),q(e,n)},p=e=>{var n=Aa(),r=R(n),i=z(r),a=z(B(r));V(()=>{J(i,`USED ${W(t).used??``}%`),J(a,`FREE ${100-W(t).used}%`)}),q(e,n)};Y(d,e=>{W(a)===`fuel`?e(f):e(p,-1)}),j(u);var m=B(u,2);let h;var g=L(m),_=e=>{var n=Na(),r=L(n),i=B(L(r)),a=e=>{q(e,ja())},o=e=>{var n=Ma();V(e=>Q(n,`d`,e),[()=>s(W(t).used)]),q(e,n)};Y(i,e=>{W(t).used>=100?e(a):W(t).used>0&&e(o,1)}),j(r),j(n),V(()=>Q(r,`aria-label`,`${W(t).used}% quota used`)),q(e,n)},v=e=>{var r=Fr(),i=R(r),a=e=>{{let r=N(()=>W(t).trail||[]);wa(e,{get used(){return W(t).used},get elapsed(){return W(n)},get trail(){return W(r)}})}},o=e=>{q(e,Pa())};Y(i,e=>{W(n)===null?e(o,-1):e(a)}),q(e,r)},y=e=>{var t=Fr(),n=R(t),i=e=>{var t=Fa(),n=R(t),i=B(L(n),2);let a;j(n);var o=B(n,4),s=L(o),c=z(B(s),!0);j(o),V(e=>{a=ui(i,``,a,{left:`${(W(r)+100)/2}%`}),J(s,`${W(r)>=0?`+`:``}${e??``} PP `),J(c,W(r)>=0?`WITHIN PACE`:`USING FASTER THAN TIME`)},[()=>W(r).toFixed(1)]),q(e,t)},a=e=>{q(e,Ia())};Y(n,e=>{W(r)===null?e(a,-1):e(i)}),q(e,t)},b=e=>{var r=za(),i=R(r),o=L(i);let s;j(i);var c=B(i,2),l=e=>{q(e,La())};Y(c,e=>{W(a)===`fuel`&&e(l)});var u=B(c,2),d=e=>{var t=Ra(),r=R(t),i=z(r),o=B(r,2),s=L(o);let c;j(o),V(e=>{J(i,`RESET CYCLE // ${e??``}% ELAPSED`),c=ui(s,``,c,{width:`${W(a)===`fuel`?100-W(n):W(n)}%`})},[()=>Math.floor(W(n))]),q(e,t)};Y(u,e=>{W(n)!==null&&e(d)}),V(()=>{Q(i,`aria-label`,W(a)===`fuel`?`Fuel remaining`:`Quota used`),Q(i,`aria-valuenow`,W(a)===`fuel`?100-W(t).used:W(t).used),s=ui(o,``,s,{width:`${W(a)===`fuel`?100-W(t).used:W(t).used}%`})}),q(e,r)};Y(g,e=>{W(a)===`pie`?e(_):W(a)===`zone`?e(v,1):W(a)===`pace`?e(y,2):e(b,-1)}),j(m);var x=B(m,2),S=z(x),C=B(x,2),w=e=>{var n=Ba(),r=z(n,!0);V(()=>J(r,W(t).details)),q(e,n)};Y(C,e=>{W(t).details&&e(w)}),j(i),V(e=>{J(l,W(t).name),h=ci(m,1,`meter-graphic`,null,h,{"bar-graphic":W(a)===`bars`||W(a)===`fuel`}),J(S,`RESETS // ${e??``}`)},[()=>sa(W(t).reset)]),q(e,i)}),j(n);var i=B(n,2),c=e=>{q(e,Ha())};Y(i,e=>{$.data.meters.length||e(c)}),V(()=>r=ci(n,1,`quota-grid`,null,r,{radial:W(a)===`pie`,zone:W(a)===`zone`})),q(e,t)};Y(l,e=>{W(a)===`thresholds`?e(u):W(a)===`resets`?e(d,1):e(f,-1)}),we(2),V(e=>J(c,`QUOTA // OBSERVED ${e??``}`),[()=>sa($.data.quotaAt)]),q(e,t)};Y(u,e=>{$.data&&e(d)}),q(e,c),Ke()}var qa=K(`
                  `),Ja=K(`

                  `,1);function Ya(e,t){Ge(t,!0);let n=Hi(t,`values`,19,()=>[]),r=Hi(t,`label`,3,`Token activity`),i=Hi(t,`capacity`,3,0),a=N(()=>Math.max(0,...n())),o=N(()=>i()>n().length?[...Array(i()-n().length).fill(0),...n()]:n());var s=Ja(),c=R(s),l=z(c),u=B(c,2);Z(u,21,()=>W(o),X,(e,t)=>{var n=qa();let r;V((e,t)=>{Q(n,`title`,e),r=ui(n,``,r,{height:t})},[()=>W(t).toLocaleString(`en-GB`)+` tokens`,()=>`${100*W(t)/Math.max(1,W(a))}%`]),q(e,n)}),j(u),V((e,t)=>{J(l,`SCALE // 0 — ${e??``} TOKENS`),Q(u,`aria-label`,t)},[()=>W(a).toLocaleString(`en-GB`),()=>`${r()}. Peak ${W(a).toLocaleString(`en-GB`)} tokens.`]),q(e,s),Ke()}var Xa=K(`

                  `),Za=K(`

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

                  `,1),Qa=K(``),$a=K(`

                   

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

                  `),eo=K(`

                  CURRENT PROFILE

                  MODEL / REASONING LEVEL / SPEED

                   

                  PROPOSED PROFILE

                  MODEL / REASONING LEVEL / SPEED

                   

                  Applied settings remain after Codexometer closes.

                  `,1),to=K(`

                  `),no=K(`

                   
                  `,1),ro=K(`

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

                  `),io=K(`

                  Session controls temporarily unavailable. Check Codex for current state.

                  `),ao=K(`

                  Checking session controls…

                  `),oo=K(`

                  `),so=K(`
                  About browser controls

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

                  `),co=K(` `,1),lo=K(` `),uo=K(`Grants permission beyond this one command. Check the scope + carefully.`),fo=K(``),po=K(``),mo=K(``),ho=K(``),go=K(`

                  Not before this time; when quota and idle allow.

                  `),_o=K(`

                  `,1),vo=K(`

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

                  `),yo=K(` `,1),bo=K(``),xo=K(``),So=K(``),Co=K(` `,1),wo=K(`
                • `),To=K(`
                  View fixed choices

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

                    `),Eo=K(` `,1),Do=K(`

                    `),Oo=K(`

                    `,1),ko=K(` `,1),Ao=K(``),jo=K(`

                    `,1),Mo=K(`

                    `);function No(e,t){Ge(t,!0);let n=[],r=Hi(t,`observedCommand`,3,``),i=Hi(t,`review`,3,``),a=Hi(t,`suspended`,3,!1),o=Hi(t,`openScheduler`,3,!1),s=Hi(t,`onProtectedChange`,3,e=>{}),c=F(null),l=F(Zt([])),u=F(null),d=F(``),f=F(0),p=F(Zt(Date.now())),m=F(!1),h=F(``),g=F(!1),_=F(!1),v=F(``),y=F(!1),b=F(``),x=F(!1),S=F(``),C=F(`now`),w=F(60),T=F(``),ee=F(!1),te=F(``),E=F(Zt([])),ne=N(()=>W(E).find(e=>e.status!==`sent`)),re=F(void 0);function ie(e){if(W(y)){dr().then(()=>W(re)?.focus());return}if(e.status!==`pending`||W(m)||!W(c)?.id||W(c).kind!==`prompt`||W(c).questions?.length)return;I(y,!0),I(b,e.id,!0),dr().then(()=>W(re)?.focus()),I(l,[e.text],!0),I(C,e.trigger===`quota`?`quota`:`at`,!0),I(d,``),I(S,``);let t=new Date(e.at);e.trigger!==`quota`&&I(T,new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,16),!0)}bn(()=>{o()&&W(ne)&&!W(x)&&W(c)?.id&&W(c).kind===`prompt`&&!W(c).questions?.length&&(I(x,!0),ie(W(ne)))});async function D(){if(!i())try{I(E,await da(`schedules`,{session:t.session},ve.signal),!0),W(y)&&!W(E).some(e=>e.id===W(b)&&e.status===`pending`)&&I(d,``),W(S)&&!W(E).some(e=>e.id===W(S)&&e.status===`pending`)&&(I(d,``),I(S,``))}catch{}}async function ae(e){try{I(E,await da(`schedules`,{session:t.session,cancelId:e},ve.signal),!0),I(y,!1),I(d,``),I(S,``),I(l,[],!0)}catch(e){I(h,e instanceof Error?e.message:`Unable to cancel trigger.`,!0)}}bn(()=>(s()(W(m)||W(l).some(e=>e.length>0)),()=>s()(!1)));let oe=N(()=>$.data?.sessions.find(e=>e.id===t.session)?.status),se=N(()=>!$.connected||!!$.data?.sessionsError),ce=N(()=>i()!==`profile`&&W(c)?.kind===`prompt`&&!W(c).questions?.length&&!!$.data?.profiles?.some(e=>e.session===t.session&&e.pending)),le=N(()=>!W(se)&&!W(_)&&!!W(c)?.id&&W(c).kind===`approval`&&W(v)!==W(c).id),ue=N(()=>W(le)?W(c).command:r()),de=N(()=>!!W(d)&&W(p)W(c)?.questions?.length?W(c).questions:[{text:`Follow-up message`,secret:!1,freeText:!0,options:[]}]),pe=N(()=>W(c)?.kind===`approval`||W(c)?.kind===`profile`?W(u)!==null:W(l).length===W(fe).length&&W(l).every((e,t)=>e.trim().length>0&&(W(fe)[t].freeText||W(fe)[t].options?.includes(e)))),me=N(()=>W(c)?.kind===`prompt`&&!W(c).questions?.length&&W(C)!==`now`),he=N(()=>W(C)===`delay`?W(p)+W(w)*6e4:Date.parse(W(T))),O=N(()=>{if(!W(me))return``;if(W(y)&&!W(E).some(e=>e.id===W(b)&&e.status===`pending`))return`Trigger changed, removed or already sent. Go back and reopen it; your draft has not been saved.`;if(!W(l)[0]?.trim())return`Enter a message to schedule.`;if(W(C)===`quota`)return``;if(!Number.isFinite(W(he))||W(he)<=W(p))return`Choose a future date/time or a delay greater than zero.`;let e=new Date(W(p));return e.setFullYear(e.getFullYear()+1),W(he)>=e.getTime()?`Choose a time within one year.`:``});function ge(e){return new Date(e).toLocaleString([],{timeZoneName:`short`})}function _e(e){if(e.status!==`pending`)return e.status;if(e.trigger===`at`&&Date.parse(e.at)>W(p))return`Due in `+Math.ceil((Date.parse(e.at)-W(p))/6e4)+` min`;let t=W(se)?`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}bn(()=>{(W(se)||a()||W(ce)||W(p)>=W(f))&&I(d,``)});let ve=new AbortController;Ui(()=>{let e=e=>{e.ctrlKey&&e.key.toLowerCase()===`s`&&!i()&&W(ne)&&(e.preventDefault(),ie(W(ne)))};window.addEventListener(`keydown`,e);let n,r=setInterval(()=>{I(p,Date.now(),!0)},1e3);async function a(){await D();try{let e=await da(`offer`,{session:t.session,...i()?{review:i()}:{}},ve.signal);if(ve.signal.aborted)return;I(_,!1),W(c)?.id!==e.id&&(I(d,``),I(u,null),I(l,Array(Math.max(1,e.questions?.length||0)).fill(``),!0)),I(c,e,!0),W(g)&&e.id&&e.id!==W(v)&&(I(h,``),I(g,!1))}catch{ve.signal.aborted||(I(c,null),I(_,!0),I(d,``))}finally{ve.signal.aborted||(n=setTimeout(a,2e3))}}return a(),()=>{window.removeEventListener(`keydown`,e),ve.abort(),clearTimeout(n),clearInterval(r)}});async function ye(e){if(!W(c)?.id||W(m)||W(se)||a()||W(ce)||(e?!e.canSend:!W(pe)||W(O)))return;let n=W(c).id;I(m,!0),I(h,``),I(g,!1),I(d,``),I(S,e?.id||``,!0);try{let r=!e&&W(c).kind===`prompt`&&!W(c).questions?.length&&W(C)!==`now`?{trigger:W(C)===`quota`?`quota`:`at`,zone:Intl.DateTimeFormat().resolvedOptions().timeZone,...W(C)===`quota`?{}:{at:(W(C)===`delay`?new Date(Date.now()+W(w)*6e4):new Date(W(T))).toISOString()}}:void 0;I(ee,!!r),I(te,r?r.trigger===`quota`?`After fresh quota becomes available, when the session is idle`:ge(r.at)+` — not before this time; when quota and idle allow`:``,!0);let o=await da(`prepare`,{session:t.session,...i()?{review:i()}:{},offer:n,...e?{sendId:e.id}:{},...r?{schedule:r}:{},...r&&W(y)?{editId:W(b)}:{},...W(c).kind===`approval`||W(c).kind===`profile`?{choice:W(u)}:{answers:e?[e.text]:[...W(l)]}},ve.signal);W(c)?.id===n&&!ve.signal.aborted&&!W(se)&&!a()&&!W(ce)&&(I(d,o.confirmation,!0),I(f,Date.parse(o.expires),!0))}catch(e){ve.signal.aborted||I(h,e instanceof Error?e.message:`Unable to prepare action.`,!0)}finally{I(m,!1)}}async function be(){if(!W(c)?.id||W(m)||a()||W(ce)||!W(de))return;let e=W(c).id,n=W(c).kind,r=W(d);I(d,``),I(m,!0),I(v,e,!0);try{await da(`commit`,{session:t.session,...i()?{review:i()}:{},offer:e,confirmation:r},ve.signal),I(g,!0),I(y,!1),W(ee)&&(I(v,``),await D()),I(h,W(ee)?`Trigger set. Closing Codexometer cancels it.`:n===`profile`?`Profile decision completed.`:n===`approval`?`Decision sent.`:`Text sent.`,!0)}catch(e){I(h,e instanceof la?e.message:`Outcome uncertain. Check Codex before taking another action; nothing was retried.`,!0)}finally{I(m,!1),I(S,``),await D(),I(l,[],!0),I(u,null)}}var k=co(),xe=R(k),A=e=>{var t=Fr();Z(R(t),17,()=>W(E).filter(e=>e.status!==`sent`),e=>e.id,(e,t)=>{var n=$a(),r=L(n),i=z(r,!0),o=B(r,2),s=z(o),l=B(o,2),u=z(l,!0),f=B(l,2),p=z(f,!0),g=B(f,2),_=z(g,!0),v=B(g,2),y=e=>{var t=Xa(),n=z(t,!0);V(()=>J(n,W(h))),q(e,t)};Y(v,e=>{W(h)&&e(y)});var b=B(v,4),x=B(b,2),C=B(x,2),w=e=>{var n=Za(),r=B(R(n),2),i=B(r,2);V(()=>r.disabled=W(m)||W(se)||!W(t).canSend),G(`click`,r,be),G(`click`,i,()=>{I(d,``),I(S,``)}),q(e,n)},T=e=>{var n=Qa();V(()=>n.disabled=W(m)||W(se)||!W(t).canSend||a()),G(`click`,n,()=>ye(W(t))),q(e,n)};Y(C,e=>{W(de)&&W(S)===W(t).id?e(w):e(T,-1)}),j(n),V((e,n)=>{J(i,W(t).status===`uncertain`?`CHECK TRIGGER — outcome uncertain; not retried`:`SCHEDULED FOLLOW-UP`),J(s,`TARGET // ${W(t).session??``}`),J(u,e),J(p,n),J(_,W(t).text),b.disabled=W(m)||!W(c)?.id||W(c).kind!==`prompt`||!!W(c).questions?.length||W(t).status!==`pending`,x.disabled=W(m)||W(t).status===`sending`},[()=>W(t).trigger===`quota`?`After confirmed quota recovery, when idle`:`Not before ${ge(W(t).at)}`,()=>_e(W(t))]),G(`click`,b,()=>ie(W(t))),G(`click`,x,()=>ae(W(t).id)),q(e,n)}),q(e,t)},Se=N(()=>!i()&&W(c)?.kind!==`approval`&&!W(c)?.questions?.length&&![`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(oe)||``));Y(xe,e=>{W(Se)&&e(A)});var Ce=B(xe,2),Te=e=>{var r=Mo(),a=L(r),o=z(a,!0),s=B(a,2),b=e=>{var t=eo(),n=R(t),r=z(n),i=B(n,6),a=z(i,!0),o=z(B(i,6),!0);we(2),V(()=>{J(r,`Your ${W(c).profile.threshold??``}% quota threshold has been reached. Review + the profile for subsequent turns.`),J(a,W(c).profile.current),J(o,W(c).profile.proposed)}),q(e,t)};Y(s,e=>{W(c)?.profile&&!W(se)&&!W(_)&&e(b)});var x=B(s,2),S=e=>{var t=to();let n;var r=z(t,!0);V(()=>{n=ci(t,1,`svelte-1oupzfc`,null,n,{notice:!W(g),sent:W(g)}),J(r,W(h))}),q(e,t)};Y(x,e=>{W(h)&&e(S)});var E=B(x,2),ne=e=>{var t=no(),n=R(t),r=z(n,!0),i=z(B(n,2),!0);V(()=>{J(r,W(le)?`EXACT COMMAND`:`LAST OBSERVED COMMAND`),J(i,W(ue))}),q(e,t)},ie=e=>{q(e,ro())};Y(E,e=>{W(ue)?e(ne):i()!==`profile`&&W(oe)===`APPROVAL NEEDED`&&!W(g)&&e(ie,1)});var D=B(E,2),ae=e=>{q(e,io())},ce=e=>{q(e,ao())},me=e=>{var t=co(),n=R(t),r=e=>{var t=oo(),n=z(t,!0);V(e=>J(n,e),[()=>W(oe)===`WORKING`?`Codex is working — nothing to respond to.`:[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(oe)||``)?`Respond in Codex for this request.`:`Nothing needs a response right now.`]),q(e,t)};Y(n,e=>{(W(oe)===`WORKING`||!W(g)&&!W(m))&&e(r)});var i=B(n,2),a=e=>{q(e,so())},o=N(()=>[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(oe)||``)&&!W(g));Y(i,e=>{W(o)&&e(a)}),q(e,t)},_e=e=>{var r=jo(),a=R(r),o=z(a),s=B(a,2),h=L(s),g=z(h,!0),_=B(h,2),v=e=>{var r=Fr();Z(R(r),17,()=>W(c).choices||[],X,(e,r,a)=>{var o=fo(),s=L(o);xi(s),s.value=s.__value=a;var c=B(s),l=B(c),d=e=>{var t=lo(),n=z(t,!0);V(()=>J(n,W(r).detail)),q(e,t)};Y(l,e=>{W(r).detail&&e(d)});var f=B(l,2),p=e=>{q(e,uo())};Y(f,e=>{W(r).persistent&&e(p)}),j(o),V(()=>{Q(s,`name`,`decision-`+t.session+`-`+i()),J(c,` ${W(r).label??``} `)}),Di(n,[],s,()=>W(u),e=>I(u,e)),q(e,o)}),q(e,r)},b=e=>{var t=co(),n=R(t),r=e=>{var t=yo(),n=R(t),r=B(L(n)),i=L(r),a=e=>{var t=po();t.value=t.__value=`now`,q(e,t)};Y(i,e=>{W(y)||e(a)});var o=B(i);o.value=o.__value=`quota`;var s=B(o);s.value=s.__value=`delay`;var c=B(s);c.value=c.__value=`at`,j(r),mi(r),j(n);var l=B(n,2),u=e=>{var t=mo(),n=B(L(t));xi(n),j(t),Ti(n,()=>W(w),e=>I(w,e)),q(e,t)};Y(l,e=>{W(C)===`delay`&&e(u)});var d=B(l,2),f=e=>{var t=ho(),n=B(L(t));xi(n),j(t),Ti(n,()=>W(T),e=>I(T,e)),q(e,t)};Y(d,e=>{W(C)===`at`&&e(f)});var p=B(d,2),m=e=>{var t=_o(),n=R(t),r=z(n),i=B(n,2),a=e=>{q(e,go())};Y(i,e=>{W(C)!==`quota`&&e(a)});var o=B(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.`,V(e=>J(r,`Will send: ${e??``}`),[()=>W(C)===`quota`?`when quota is available and this session is idle`:Number.isFinite(W(he))?ge(W(he)):`choose a date and time`]),q(e,t)};Y(p,e=>{W(C)!==`now`&&e(m)});var h=B(p,2),g=e=>{q(e,vo())};Y(h,e=>{W(y)&&e(g)}),hi(r,()=>W(C),e=>I(C,e)),q(e,t)};Y(n,e=>{W(c).questions?.length||e(r)}),Z(B(n,2),17,()=>W(fe),X,(e,t,n)=>{var r=Eo(),i=R(r),a=L(i),o=B(a),s=e=>{var t=bo();xi(t),Ti(t,()=>W(l)[n],e=>W(l)[n]=e),q(e,t)},c=e=>{var r=So(),i=L(r);i.value=i.__value=``,Z(B(i),17,()=>W(t).options||[],X,(e,t)=>{var n=xo(),r=z(n,!0),i={};V(()=>{J(r,W(t)),i!==(i=W(t))&&(n.value=(n.__value=i)??``)}),q(e,n)}),j(r),mi(r),hi(r,()=>W(l)[n],e=>W(l)[n]=e),q(e,r)},u=e=>{var r=Co(),i=R(r);rt(i),Pi(i,e=>I(re,e),()=>W(re));var a=B(i,2),o=e=>{var n=oo(),r=z(n);V(e=>J(r,`Suggested answers: ${e??``}`),[()=>W(t).options.join(` · `)]),q(e,n)};Y(a,e=>{W(t).options?.length&&e(o)}),Ti(i,()=>W(l)[n],e=>W(l)[n]=e),q(e,r)};Y(o,e=>{W(t).secret?e(s):W(t).freeText?e(u,-1):e(c,1)}),j(i);var d=B(i,2),f=e=>{var n=To(),r=B(L(n),4);Z(r,21,()=>W(t).options||[],X,(e,t)=>{var n=wo(),r=z(n,!0);V(()=>J(r,W(t))),q(e,n)}),j(r),j(n),q(e,n)};Y(d,e=>{W(t).secret&&!W(t).freeText&&e(f)}),V(()=>J(a,`${W(t).text??``} `)),q(e,r)}),q(e,t)};Y(_,e=>{W(c).kind===`approval`||W(c).kind===`profile`?e(v):e(b,-1)}),j(s);var x=B(s,2),S=e=>{var t=Oo(),n=R(t),r=e=>{var t=Do(),n=z(t);V(()=>J(n,`TRIGGER // ${W(te)??``}`)),q(e,t)};Y(n,e=>{W(ee)&&e(r)});var i=B(n,2),a=z(i),o=B(i,2),s=z(o),l=B(o,2);V(e=>{J(a,`Check the target and ${W(c).kind===`profile`?`profile above`:W(c).kind===`approval`?`exact command and permission scope`:`message above`}. ${W(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=W(m)||W(se),J(s,`CONFIRM ${(W(c).kind===`approval`||W(c).kind===`profile`?W(c).choices?.[W(u)]?.label:W(ee)?W(y)?`SAVE CHANGES`:`SCHEDULE`:`SEND`)??``}`)},[()=>Math.max(0,Math.ceil((W(f)-W(p))/1e3))]),G(`click`,o,be),G(`click`,l,()=>{I(d,``)}),q(e,t)},E=e=>{var t=ko(),n=R(t),r=e=>{var t=Xa(),n=z(t,!0);V(()=>J(n,W(O))),q(e,t)};Y(n,e=>{W(O)&&e(r)});var i=B(n,2),a=z(i,!0);V(()=>{i.disabled=W(m)||W(se)||!W(pe)||!!W(O),J(a,W(m)?`SENDING…`:W(y)?`REVIEW CHANGES`:`REVIEW BEFORE SENDING`)}),G(`click`,i,()=>ye()),q(e,t)};Y(x,e=>{W(de)?e(S):e(E,-1)});var ne=B(x,2),ie=e=>{var t=Ao();G(`click`,t,()=>{I(y,!1),I(d,``),I(l,[],!0)}),q(e,t)};Y(ne,e=>{W(y)&&e(ie)}),V(()=>{J(o,`TARGET // ${W(c).thread??``} // ${(W(c).directory||`Directory unavailable`)??``}`),s.disabled=W(m)||W(de)||W(se),J(g,W(c).kind===`approval`||W(c).kind===`profile`?`Choose a decision`:W(y)?`EDIT SCHEDULED FOLLOW-UP`:`Reply to this session`)}),q(e,r)};Y(D,e=>{W(se)||W(_)?e(ae):W(c)?W(c).id?W(v)!==W(c).id&&e(_e,3):e(me,2):e(ce,1)}),j(r),V(()=>J(o,i()===`profile`?`QUOTA THRESHOLD`:`SESSION CONTROL // EXPERIMENTAL`)),q(e,r)};Y(Ce,e=>{!W(ce)&&(!W(ne)||W(y)||i()||W(c)?.kind!==`prompt`||W(c).questions?.length)&&e(Te)}),q(e,k),Ke()}wr([`click`]);var Po=K(`
                    `);function Fo(e,t){Ge(t,!0);let n=Hi(t,`active`,3,!1),r=N(()=>t.session.text||t.session.contextKind===`LAST ACTIVITY`&&t.session.workingCommand||``),i=N(()=>[`LAST REPLY`,`LAST ACTIVITY`].includes(t.session.contextKind)&&!!W(r).trim()),a=F(!1),o=F(``),s=F(!1);bn(()=>{if(!W(s))return;let e=setTimeout(()=>{I(s,!1)},150);return()=>clearTimeout(e)}),bn(()=>{W(r),t.session.status,I(o,``)});async function c(){if(!W(i)||W(a))return;let e=W(r);I(a,!0),I(s,!0),I(o,``);try{await navigator.clipboard.writeText(e),W(r)===e&&I(o,`Copied.`)}catch{W(r)===e&&I(o,`Clipboard unavailable. Select the visible text and copy it manually.`)}finally{I(a,!1)}}function l(e){!n()||!W(i)||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(),c())}var u=Fr();Cr(`keydown`,en,l);var d=R(u),f=e=>{var t=Po(),n=L(t),r=z(n,!0),i=B(n,2);let l;j(t),V(()=>{J(r,W(o)),i.disabled=W(a),l=ci(i,1,`svelte-543j00`,null,l,{flashed:W(s)})}),G(`click`,i,c),q(e,t)};Y(d,e=>{W(i)&&e(f)}),q(e,u),Ke()}wr([`click`]);var Io=K(`

                    CONTEXT

                     

                    `,1),Lo=K(`

                    `),Ro=K(`

                    `),zo=K(`
                     
                    `),Bo=K(`

                     
                    `,1),Vo=K(`
                     
                    `),Ho=K(`

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

                    `),Uo=K(`

                    `,1),Wo=K(`

                    `),Go=K(` `,1),Ko=K(`
                    `),qo=K(`

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

                    `),Jo=K(`

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

                    `),Yo=K(` `),Xo=K(` `),Zo=K(` `),Qo=K(``),$o=K(`

                    Read only — reply or approve in Codex.

                    `),es=K(`

                    `),ts=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),ns=K(`
                    `),rs=K(`
                    `),is=K(`

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

                    `),as=K(`

                    `),os=K(``),ss=K(`

                    `),cs=K(` `),ls=K(`

                    `),us=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),ds=K(` `,1),fs=K(`

                    `),ps=K(`

                    TOKEN ACTIVITY // 30 SECOND SAMPLES

                    `),ms=K(`

                    TOKENS

                    FULL DETAIL →
                    `),hs=K(`

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

                    `),gs=K(`

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

                    `,1),_s=K(`

                    SESSION TOTALS

                    `,1);function vs(e,t){Ge(t,!0);let n=(e,t=f,n,r)=>{let i=ht(()=>g(n?.(),!0)),a=ht(()=>g(r?.(),!1));var o=Go(),s=R(o),c=e=>{var n=Io(),r=z(B(R(n),2),!0);we(2),V(()=>J(r,t().approvalContext)),q(e,n)};Y(s,e=>{W(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(c)});var l=B(s,2),u=e=>{var n=Lo();let r;var i=z(n,!0);V(e=>{r=ci(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),J(i,e)},[()=>C(t())]),q(e,n)},d=N(()=>C(t())&&(!W(a)||W(h)||t().status===`CHECK SESSION`));Y(l,e=>{W(d)&&e(u)});var p=B(l,2),m=e=>{var n=Ro(),r=z(n,!0);V(()=>J(r,t().contextKind||`LAST ACTIVITY`)),q(e,n)};Y(p,e=>{W(i)&&e(m)});var _=B(p,2),v=e=>{var n=zo(),r=z(n,!0);V(()=>J(r,t().text||`No session context available.`)),q(e,n)};Y(_,e=>{(t().text||!t().workingCommand)&&e(v)});var y=B(_,2),b=e=>{var n=Bo(),r=B(R(n),2),i=L(r),a=B(i),o=e=>{var n=Pr();V(()=>J(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),q(e,n)};Y(a,e=>{!W(h)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(o)});var s=B(a,2),c=e=>{q(e,Pr(`+`))};Y(s,e=>{t().runningLimited&&e(c)}),j(r);var l=z(B(r,2),!0);V(e=>{J(i,`COMMAND // ${e??``} `),J(l,t().workingCommand)},[()=>W(h)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),q(e,n)};Y(y,e=>{t().workingCommand&&e(b)});var x=B(y,2),S=e=>{var n=Uo(),r=B(R(n),2),i=z(r,!0),a=B(r,2),o=e=>{var n=Vo(),r=z(n,!0);V(()=>J(r,t().command)),q(e,n)},s=e=>{q(e,Ho())};Y(a,e=>{t().command?e(o):e(s,-1)}),V(()=>J(i,W(h)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),q(e,n)};Y(x,e=>{(!W(a)||!$.data?.control)&&(t().command||t().status===`APPROVAL NEEDED`)&&e(S)});var w=B(x,2),T=e=>{var n=Wo(),r=z(n);V(()=>J(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),q(e,n)};Y(w,e=>{W(a)||e(T)}),q(e,o)},r=Hi(t,`params`,19,()=>({})),i=N(()=>$.data?.sessions||[]),a=N(()=>$.data?.control&&$.data.profiles||[]),o=N(()=>($.data?.triggers||[]).filter(e=>W(i).some(t=>t.id===e.session)));function s(e,t){if(r().id&&r().id!==t&&W(l)){e.preventDefault();return}b(t)}function c(e){return[`TURN COMPLETE`,`IDLE`,`ACTIVE`].includes(e.status)&&W(o).some(t=>t.session===e.id)?`TRIGGER SET`:e.status}let l=F(!1);function u(e,t){if(r().id&&r().id!==t&&W(l)){e.preventDefault();return}b(t)}bn(()=>{let e=r().id;e&&mr(()=>{ea.selected=e,aa(e,2)})});let d=N(()=>W(i).find(e=>e.id===r().id)),p=N(()=>new URLSearchParams(Ki.querystring).get(`review`)===`profile`&&W(a).some(e=>e.session===r().id&&e.pending)),m=N(()=>W(i).some(e=>e.id===ea.selected)?ea.selected:W(i)[0]?.id),h=N(()=>!$.connected||!!$.data?.sessionsError),v=N(()=>[[`OBSERVED TOKENS`,oa(W(i).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,oa(W(i).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,W(h)?`—`:oa(W(i).filter(e=>e.status===t).length)])]),y=N(()=>W(i).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`,`CHECK SESSION`].includes(e.status)));function b(e){ea.selected=e,dr().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function x(e,t){if(b(e),r().id){t<0&&(aa(e,2),location.hash=`/sessions`);return}let n=ra(e)+t;n>2?location.hash=`/sessions/`+encodeURIComponent(e):aa(e,n)}function S(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`&&r().id)e.preventDefault(),x(r().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(r().id||W(m)))e.preventDefault(),x(r().id||W(m),e.key===`ArrowLeft`?-1:1);else if(!r().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&W(i).length){e.preventDefault();let t=W(i).findIndex(e=>e.id===W(m));b(W(i)[Math.max(0,Math.min(W(i).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function C(e){return W(h)?`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.`:$.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.`:``}var w=_s();Cr(`keydown`,en,S);var T=R(w),ee=z(B(L(T),2));j(T);var te=B(T,2);let E;Z(te,21,()=>W(v),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1];var a=Ko(),o=L(a),s=z(o,!0),c=z(B(o,2),!0);j(a),V(()=>{J(s,r()),J(c,i())}),q(e,a)}),j(te);var ne=B(te,2),re=z(ne),ie=B(ne,2),D=e=>{q(e,qo())};Y(ie,e=>{W(h)&&e(D)});var ae=B(ie,2),oe=e=>{q(e,Jo())};Y(ae,e=>{$.data?.profileError&&e(oe)});var se=B(ae,2),ce=e=>{var t=Qo(),n=L(t);Z(n,17,()=>W(y),X,(e,t)=>{var n=Yo();let r;var i=z(n);V((e,a)=>{r=ci(n,1,`button`,null,r,{approval:W(t).status===`APPROVAL NEEDED`}),Q(n,`href`,e),J(i,`${W(t).status??``} + ${a??``} // ${(W(t).name||W(t).directory||W(t).id)??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,n,()=>b(W(t).id)),q(e,n)});var c=B(n,2);Z(c,17,()=>W(a).filter(e=>e.pending&&W(i).some(t=>t.id===e.session)),X,(e,t)=>{var n=Xo(),a=z(n);V((e,i,o)=>{Q(n,`title`,r().id&&r().id!==W(t).session&&W(l)?`Finish sending or clear your current draft before switching sessions.`:`Review this session’s quota threshold`),Q(n,`href`,e),J(a,`QUOTA THRESHOLD ${i??``} // ${o??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session)+`?review=profile`,()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory||W(t).session]),G(`click`,n,e=>u(e,W(t).session)),q(e,n)}),Z(B(c,2),17,()=>W(o),X,(e,t)=>{var n=Zo(),r=z(n);V((e,t,i)=>{Q(n,`href`,e),J(r,`TRIGGER SET ${t??``} // ${i??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session),()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory]),G(`click`,n,e=>s(e,W(t).session)),q(e,n)}),j(t),q(e,t)},le=N(()=>(W(y).length||W(a).some(e=>e.pending)||W(o).length)&&!W(h));Y(se,e=>{W(le)&&e(ce)});var ue=B(se,2),de=e=>{var t=Fr(),i=R(t),o=e=>{var t=rs(),i=L(t),o=L(i),s=L(o);let u;var f=B(s);j(o);var m=B(o,2);j(i);var g=B(i,2),_=e=>{var t=Wo(),n=z(t,!0);V(()=>J(n,W(d).directory)),q(e,t)};Y(g,e=>{W(d).name&&W(d).directory&&e(_)});var v=B(g,2),y=z(v),x=B(v,2);let S;var C=L(x),w=L(C);n(w,()=>W(d),()=>!0,()=>!0),j(C);var T=B(C,2),ee=e=>{var t=Fr();qr(R(t),()=>W(d).id,e=>{{let t=N(()=>new URLSearchParams(Ki.querystring).get(`schedule`)===`edit`);No(e,{get session(){return W(d).id},get openScheduler(){return W(t)},get observedCommand(){return W(d).command},get suspended(){return W(p)},onProtectedChange:e=>{I(l,e,!0)}})}}),q(e,t)},te=e=>{q(e,$o())};Y(T,e=>{$.data?.control?e(ee):e(te,-1)}),j(x);var E=B(x,2);Z(E,17,()=>W(a).filter(e=>e.session===W(d).id),e=>e.session,(e,t)=>{var n=ns(),r=L(n),i=e=>{var n=es(),r=z(n,!0);V(()=>J(r,W(t).notice)),q(e,n)};Y(r,e=>{W(t).notice&&e(i)});var a=B(r,2),o=e=>{No(e,{get session(){return W(d).id},review:`profile`})},s=e=>{var t=ts();V(e=>Q(t,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(d).id)+`?review=profile`]),q(e,t)};Y(a,e=>{W(t).pending&&W(p)?e(o):W(t).pending&&e(s,1)}),j(n),V(()=>Q(n,`id`,`quota-profile-`+W(d).id)),q(e,n)});var ne=B(E,2),re=e=>{var t=Fr();qr(R(t),()=>W(d).id,e=>{Fo(e,{get session(){return W(d)},active:!0})}),q(e,t)};Y(ne,e=>{W(p)||e(re)}),j(t),V((e,t)=>{u=ci(s,1,`lamp lit`,null,u,{working:W(d).status===`WORKING`&&!W(h)}),J(f,`${e??``} // ${(W(d).name||W(d).directory)??``}`),J(y,`${t??``} TOKENS // ${W(d).id??``} // CONTEXT SOURCE // ${(W(d).source||`LOCAL`)??``}`),S=ui(x,``,S,{display:W(p)?`none`:void 0})},[()=>W(h)?`STALE`:W(p)?`QUOTA THRESHOLD`:c(W(d)),()=>oa(W(d).tokens)]),G(`click`,m,()=>{b(r().id),aa(r().id,2)}),q(e,t)},s=e=>{q(e,is())};Y(i,e=>{W(d)?e(o):e(s,-1)}),q(e,t)},fe=e=>{var t=gs(),r=R(t),o=B(L(r),2),s=L(o),l=B(s,2);j(o),j(r);var d=B(r,2);Z(d,17,()=>W(i),e=>e.id,(e,t)=>{let r=N(()=>ra(W(t).id));var i=ms();let o;var s=L(i),l=L(s),d=e=>{var n=as(),r=L(n),i=z(r);j(n),V(e=>{Q(r,`aria-pressed`,W(m)===W(t).id),J(i,`${e??``} // ${W(t).name??``}`)},[()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,r,()=>b(W(t).id)),q(e,n)};Y(l,e=>{W(t).name&&e(d)});var f=B(l,2),p=L(f),g=L(p);let _;var v=B(g,1,!0);j(p),j(f);var y=B(f,2),S=e=>{var n=os(),r=z(n,!0);V(()=>{Q(n,`aria-pressed`,W(m)===W(t).id),J(r,W(t).directory||W(t).id)}),G(`click`,n,()=>b(W(t).id)),q(e,n)};Y(y,e=>{W(t).name||e(S)});var C=B(y,2),w=L(C);we(),j(C);var T=B(C,2),ee=e=>{var n=Wo(),r=z(n,!0);V(()=>J(r,W(t).directory)),q(e,n)};Y(T,e=>{W(t).name&&W(t).directory&&e(ee)});var te=B(T,2),E=z(te),ne=B(te,2),re=z(ne),ie=B(ne,2),D=L(ie),ae=B(D,2),oe=z(ae,!0),se=B(ae,2);j(ie);var ce=B(ie,2),le=B(ce,2),ue=e=>{var n=ss(),r=z(n,!0);V(()=>J(r,W(t).status===`CHECK SESSION`?`INFERRED INACTIVITY`:$.data?.control?`OPEN FULL DETAIL OR REPLY IN CODEX`:W(t).status===`APPROVAL NEEDED`?`APPROVE OR DECLINE IN CODEX`:`REPLY IN CODEX`)),q(e,n)},de=N(()=>!W(h)&&[`APPROVAL NEEDED`,`INPUT NEEDED`,`CHECK SESSION`].includes(W(t).status));Y(le,e=>{W(de)&&e(ue)}),j(s);var fe=B(s,2),pe=e=>{var r=fs(),i=L(r),o=L(i),s=z(o,!0),c=B(o,2),l=e=>{var n=cs(),r=z(n,!0);V(e=>{Q(n,`href`,e),J(r,$.data?.control?`REVIEW IN FULL DETAIL ↗`:`APPROVAL IN CODEX ↗`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id)]),q(e,n)};Y(c,e=>{!W(h)&&W(t).status===`APPROVAL NEEDED`&&e(l)}),j(i);var d=B(i,2);n(d,()=>W(t),()=>!1);var f=B(d,2);Z(f,17,()=>W(a).filter(e=>e.session===W(t).id),X,(e,n)=>{var r=ds(),i=R(r),a=e=>{var t=ls(),r=z(t,!0);V(()=>J(r,W(n).notice)),q(e,t)};Y(i,e=>{W(n).notice&&e(a)});var o=B(i,2),s=e=>{var n=us();V(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(t).id)+`?review=profile`]),G(`click`,n,e=>u(e,W(t).id)),q(e,n)};Y(o,e=>{W(n).pending&&e(s)}),q(e,r)});var p=B(f,2);{let e=N(()=>W(m)===W(t).id);Fo(p,{get session(){return W(t)},get active(){return W(e)}})}j(r),V(()=>J(s,W(t).contextKind||`LAST ACTIVITY`)),q(e,r)};Y(fe,e=>{W(r)>0&&e(pe)});var me=B(fe,2),he=e=>{var n=ps(),r=B(L(n),2);{let e=N(()=>(W(t).samples||[]).map(e=>e.tokens));Ya(r,{get values(){return W(e)},capacity:120})}var i=z(B(r,2));j(n),V(()=>J(i,`LAST ${(W(t).samples?.length||0)??``} SAMPLES // AUTO SCALE`)),q(e,n)};Y(me,e=>{W(r)<2&&e(he)}),j(i),V((e,n,a,s,c)=>{o=ci(i,1,`session-row`,null,o,{selected:W(m)===W(t).id,wide:W(r)===2,split:W(r)===1}),Q(i,`aria-label`,`Session `+(W(t).name||W(t).directory||W(t).id)),Q(p,`href`,e),_=ci(g,1,`lamp lit`,null,_,{working:W(t).status===`WORKING`&&!W(h)}),J(v,n),J(w,`${a??``} `),J(E,`${W(t).agents??``} LINKED AGENTS`),J(re,`ACTIVE // ${s??``}`),D.disabled=W(r)===0,Q(ae,`aria-expanded`,W(r)>0),J(oe,W(r)?`HIDE DETAIL`:`SHOW DETAIL`),Q(ce,`href`,c)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>W(h)?`STALE`:c(W(t)),()=>oa(W(t).tokens),()=>sa(W(t).activity),()=>`#/sessions/`+encodeURIComponent(W(t).id)]),G(`click`,p,()=>b(W(t).id)),G(`click`,D,()=>x(W(t).id,-1)),G(`click`,ae,()=>{b(W(t).id),aa(W(t).id,+!W(r))}),G(`click`,se,()=>x(W(t).id,1)),G(`click`,ce,()=>b(W(t).id)),q(e,i)});var f=B(d,2),p=e=>{q(e,hs())};Y(f,e=>{W(i).length||e(p)}),G(`click`,s,()=>ia(1)),G(`click`,l,()=>ia(0)),q(e,t)};Y(ue,e=>{r().id?e(de):e(fe,-1)}),V(e=>{J(ee,`OBSERVED ${e??``}`),E=ci(te,1,`session-totals`,null,E,{stale:W(h)}),J(re,`${W(h)?`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.`)},[()=>sa($.data?.sessionsAt)]),q(e,w),Ke()}wr([`click`]);var ys=K(`

                    `),bs=K(`

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

                    `,1),xs=K(`// APPROXIMATE`),Ss=K(`

                    Partial accounting: totals may still change.

                    `),Cs=K(`

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

                    `,1),ws=K(`

                    `,1),Ts=K(`

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

                    `),Es=K(`
                    `),Ds=K(`
                    `),Os=K(`

                    No usage reported for this day.

                    `),ks=K(`

                    Selected breakdown unavailable; missing does not mean zero.

                    `),As=K(`

                    `,1);function js(e,t){Ge(t,!0);let n=F(`surface`),r=F(0),i=N(()=>t.reports?.daily),a=N(()=>t.reports?.plan),o=N(()=>t.mode===`breakdown`?W(i)?.days.length||0:W(a)?.periods.length||0),s=N(()=>Math.min(W(r),Math.max(0,W(o)-1))),c=N(()=>W(i)?.days[(W(i)?.days.length||0)-1-W(s)]),l=N(()=>W(a)?.periods[W(s)]),u=N(()=>t.mode===`breakdown`?W(i)?.units||``:`%`),d=N(()=>{let e=Object.create(null);if(t.mode===`breakdown`)e=W(c)?.groups[W(n)]||{};else{let t=W(n)===`feature`?`thread_source`:W(n)===`task start`?`turn_trigger`:W(n);for(let n of W(l)?.breakdowns||[])if(n.dimension===t)for(let t of n.rows)e[t.key]=(e[t.key]||0)+t.basis_points/100}return Object.entries(e).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}),f=N(()=>t.mode===`breakdown`?W(c)?.total:W(l)?.used_basis_points==null?null:W(l).used_basis_points/100),p=N(()=>Math.max(1,W(f)||0,...W(d).map(([,e])=>e))),m=e=>e==null?`UNKNOWN`:e.toLocaleString(`en-GB`,{maximumFractionDigits:2});var h=As(),g=R(h),v=L(g),y=B(L(v)),b=L(y);b.value=b.__value=`surface`;var x=B(b);x.value=x.__value=`model`;var S=B(x);S.value=S.__value=`feature`;var C=B(S);C.value=C.__value=`task start`,j(y),mi(y),j(v);var w=B(v,2),T=B(w,2),ee=z(B(T,2),!0);j(g);var te=B(g,2),E=L(te),ne=z(E,!0),re=B(E,2),ie=z(re),D=B(re,2),ae=e=>{var t=bs(),n=R(t),r=z(n),a=B(n,2),o=e=>{var t=ys(),n=z(t);V(()=>J(n,`Data as of ${W(i).dataAsOf??``}`)),q(e,t)};Y(a,e=>{W(i).dataAsOf&&e(o)});var s=z(B(a,2));we(2),V((e,t)=>{J(r,`Latest fetch ${e??``} // queried ${W(i).from??``} → ${W(i).through??``}. + Reports are fetched from OpenAI and are not saved between runs.`),J(s,`${(W(c)?.date||`No daily buckets reported`)??``} // ${t??``} + ${W(u)??``}`)},[()=>sa(W(i).fetchedAt),()=>m(W(f))]),q(e,t)},oe=e=>{var t=ws(),n=R(t),r=L(n);let i;var o=z(r,!0),s=B(r),c=e=>{q(e,xs())};Y(s,e=>{W(a).approximate&&e(c)});var u=B(s);j(n);var d=B(n,2),p=L(d),h=B(p),g=e=>{var t=Pr();V(()=>J(t,`// Boundary tolerance ${W(a).boundary_tolerance_seconds??``}s`)),q(e,t)};Y(h,e=>{W(a).boundary_tolerance_seconds!=null&&e(g)}),j(d);var _=B(d,2),v=e=>{var t=Cs(),n=R(t),r=L(n),i=B(r);let a;var o=z(i);j(n);var s=B(n,2),c=z(s),u=B(s,2),d=e=>{q(e,Ss())};Y(u,e=>{W(l).accounting_complete||e(d)}),we(2),V(e=>{J(r,`${W(l).window_minutes??``} MIN // ${W(l).plan_type??``} // `),a=ci(i,1,`svelte-1fbui7h`,null,a,{muted:W(f)==null,"quota-near":W(f)!=null&&W(f)>=80&&W(f)<100,"quota-full":W(f)!=null&&W(f)>=100}),J(o,`USED ${e??``}${W(f)==null?``:`%`}`),J(c,`${W(l).starts_at??``} → ${W(l).ends_at??``}`)},[()=>m(W(f))]),q(e,t)};Y(_,e=>{W(l)&&e(v)}),V(e=>{i=ci(r,1,`svelte-1fbui7h`,null,i,{"quality-warning":!W(a).coverage_complete}),J(o,W(a).coverage_complete?`Reported range complete`:`Partial coverage`),J(u,` // Latest fetch ${e??``}`),J(p,`Coverage starts ${(W(a).coverage_start||`unknown`)??``} // Data as of ${(W(a).data_as_of||`unknown`)??``}`)},[()=>sa(W(a).fetchedAt)]),q(e,t)},se=e=>{q(e,Ts())};Y(D,e=>{t.mode===`breakdown`&&W(i)?e(ae):t.mode===`periods`&&W(a)?e(oe,1):e(se,-1)});var ce=B(D,2),le=e=>{var n=Ds(),r=L(n),i=z(B(L(r),2),!0);j(r),Z(B(r,2),17,()=>W(d),X,(e,n,r)=>{var i=N(()=>_(W(n),2));let a=()=>W(i)[0],o=()=>W(i)[1];var s=Es();let c;var l=L(s),u=z(l,!0),d=B(l,2),f=L(d);let h;j(d);var g=z(B(d,2));j(s),V((e,n,i)=>{c=ci(s,1,`report-row svelte-1fbui7h`,null,c,{unknown:e,alternate:r%2==1}),Q(l,`title`,a()),J(u,a()),h=ui(f,``,h,{width:n}),J(g,`${i??``}${t.mode===`periods`?`%`:``}`)},[()=>a().trim().toLowerCase()===`unknown`,()=>`${Math.max(0,100*o()/W(p))}%`,()=>m(o())]),q(e,s)}),j(n),V(()=>J(i,t.mode===`breakdown`?W(u):`QUOTA USED`)),q(e,n)},ue=e=>{q(e,Os())},de=e=>{q(e,ks())};Y(ce,e=>{W(d).length?e(le):t.mode===`breakdown`&&W(c)?.total===0&&W(c)?.groups[W(n)]!=null?e(ue,1):(W(i)&&t.mode===`breakdown`||W(a)&&t.mode===`periods`)&&e(de,2)}),j(te),V(()=>{w.disabled=W(s)>=W(o)-1,T.disabled=W(s)===0,J(ee,W(o)?`${W(s)+1} / ${W(o)}`:`NO DATA`),J(ne,t.mode===`breakdown`?`DAILY BREAKDOWN`:`QUOTA WINDOWS`),J(ie,`${(t.mode===`breakdown`?t.reports?.dailyStatus||`UNAVAILABLE`:t.reports?.planStatus||`UNAVAILABLE`)??``} // UTC`)}),hi(y,()=>W(n),e=>I(n,e)),G(`click`,w,()=>I(r,W(s)+1)),G(`click`,T,()=>I(r,W(s)-1)),q(e,h),Ke()}wr([`click`]);var Ms=864e5;function Ns(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 Ps(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));for(let e=0;;e++){let i=Ns(r,-t),a=new Date(i.getTime()+Ms);if(e===n)return{start:a,end:r};r=i}}var Fs=K(``),Is=K(``,1),Ls=K(`

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

                    `),Rs=K(`

                    Token history unavailable; other reports may still be available.

                    `),zs=K(``),Bs=K(`
                    `),Vs=K(`

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

                    `,1),Hs=K(`
                    `,1),Us=K(` `),Ws=K(`

                    LIFETIME TOKENS

                    PEAK DAY

                    CURRENT STREAK

                    DAYS

                    LONGEST TURN

                    SECONDS

                    LONGEST STREAK

                    DAYS

                    OPENAI // UTC

                    Accessible data table
                    Date (UTC)Tokens

                    `,1),Gs=K(`

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

                    `),Ks=K(`

                    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 qs(e,t){Ge(t,!0);let n=F(`daily`),r=F(12),i=F(0),a=N(()=>{let e=$.data?.usage?.dailyUsageBuckets;if(!e)return[];let{start:t,end:n}=Ps(new Date,W(r),W(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=N(()=>Math.max(1,...W(a).map(e=>e.tokens))),s=N(()=>W(a).length?new Date(W(a)[0].date+`T00:00:00Z`).getUTCDay():0),c=N(()=>{if(W(n)===`monthly`){let e=new Map;for(let t of W(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 W(a).map(t=>({date:t.date,tokens:e+=t.tokens}))});var l=Ks(),u=B(R(l),4);Z(u,20,()=>[[`daily`,`Daily`],[`monthly`,`Monthly`],[`cumulative`,`Cumulative`],[`breakdown`,`Breakdown`],[`periods`,`Windows`]],X,(e,t)=>{var r=N(()=>_(t,2));let a=()=>W(r)[0],o=()=>W(r)[1];var s=Fs();let c;var l=z(s,!0);V(()=>{Q(s,`aria-pressed`,W(n)===a()),c=ci(s,1,``,null,c,{active:W(n)===a()}),J(l,o())}),G(`click`,s,()=>{I(n,a(),!0),I(i,0)}),q(e,s)}),j(u);var d=B(u,2),f=L(d),p=e=>{var t=Is(),n=R(t),a=B(L(n)),o=L(a);o.value=o.__value=6;var s=B(o);s.value=s.__value=12,j(a),mi(a),j(n);var c=B(n),l=B(c);V(()=>l.disabled=W(i)===0),G(`change`,a,()=>I(i,0)),hi(a,()=>W(r),e=>I(r,e)),G(`click`,c,()=>Jt(i)),G(`click`,l,()=>Jt(i,-1)),q(e,t)};Y(f,e=>{W(n)!==`breakdown`&&W(n)!==`periods`&&e(p)}),j(d);var m=B(d,2),h=e=>{q(e,Ls())};Y(m,e=>{$.data?.usageError&&e(h)});var g=B(m,2),v=e=>{q(e,Rs())};Y(g,e=>{$.data?.usage?.tokenStatus===`UNAVAILABLE`&&W(n)!==`breakdown`&&W(n)!==`periods`&&e(v)});var y=B(g,2),b=e=>{var t=Fr();qr(R(t),()=>W(n),e=>{{let t=N(()=>$.data?.usage?.reports);js(e,{get reports(){return W(t)},get mode(){return W(n)}})}}),q(e,t)},x=e=>{var t=Ws(),r=R(t),i=L(r),l=z(B(L(i),2),!0);j(i);var u=B(i,2),d=z(B(L(u),2),!0);j(u);var f=B(u,2),p=B(L(f),2),m=L(p);we(),j(p),j(f);var h=B(f,2),g=B(L(h),2),_=L(g);we(),j(g),j(h);var v=B(h,2),y=B(L(v),2),b=L(y);we(),j(y),j(v),j(r);var x=B(r,4),S=L(x),C=z(S),w=B(S,2),T=e=>{var t=Vs(),n=R(t),r=L(n),i=L(r);Z(i,17,()=>Array(W(s)),X,(e,t)=>{q(e,zs())}),Z(B(i,2),17,()=>W(a),X,(e,t)=>{var n=Bs();let r,i;V(e=>{r=ci(n,1,`heat-cell`,null,r,{zero:W(t).tokens===0}),Q(n,`title`,e),i=ui(n,``,i,{opacity:W(t).tokens?.25+.75*W(t).tokens/W(o):1})},[()=>`${W(t).date}: ${oa(W(t).tokens)} tokens`]),q(e,n)}),j(r),j(n),we(2),q(e,t)},ee=e=>{var t=Hs(),r=R(t);{let e=N(()=>W(c).map(e=>e.tokens)),t=N(()=>W(n)+` usage`);Ya(r,{get values(){return W(e)},get label(){return W(t)}})}var i=B(r,2),a=L(i),o=z(a,!0),s=z(B(a),!0);j(i),V(e=>{J(o,W(c)[0]?.date),J(s,e)},[()=>W(c).at(-1)?.date]),q(e,t)};Y(w,e=>{W(n)===`daily`?e(T):e(ee,-1)});var te=B(w,2),E=B(L(te),2),ne=L(E),re=B(L(ne));Z(re,21,()=>W(n)===`daily`?W(a):W(c),X,(e,t)=>{var n=Us(),r=L(n),i=z(r,!0),a=z(B(r),!0);j(n),V(e=>{J(i,W(t).date),J(a,e)},[()=>oa(W(t).tokens)]),q(e,n)}),j(re),j(ne),j(E),j(te),j(x);var ie=z(B(x,2));V((e,t,n,r,i,o,s)=>{J(l,e),J(d,t),J(m,`${n??``} `),J(_,`${r??``} `),J(b,`${i??``} `),J(C,`${W(a)[0]?.date??``} — ${o??``}`),J(ie,`OBSERVED ${s??``} // CUMULATIVE IS FOR THE SELECTED PERIOD`)},[()=>oa($.data.usage.summary.lifetimeTokens),()=>oa($.data.usage.summary.peakDailyTokens),()=>oa($.data.usage.summary.currentStreakDays),()=>oa($.data.usage.summary.longestRunningTurnSec),()=>oa($.data.usage.summary.longestStreakDays),()=>W(a).at(-1)?.date,()=>sa($.data.usageAt)]),q(e,t)},S=e=>{q(e,Gs())};Y(y,e=>{W(n)===`breakdown`||W(n)===`periods`?e(b):$.data?.usage&&$.data.usage.dailyUsageBuckets!==null?e(x,1):e(S,-1)}),q(e,l),Ke()}wr([`click`,`change`]);var Js=K(`

                    Page not found

                    Return to Quota

                    `,1);function Ys(e){var t=Js();we(2),q(e,t)}var Xs=K(` `),Zs=K(`

                    `),Qs=K(`

                    Connecting to your local Codexometer…

                    `),$s=K(``),ec=K(`
                    CODEXOMETER

                    Your quota. Your sessions. Your command centre.

                    `);function tc(e,t){Ge(t,!0);let n={"/":Ka,"/quota/:view?":Ka,"/sessions/:id?":vs,"/usage":qs,"*":Ys},r={quota:/^(?:\/|\/quota(?:\/[^/]+)?\/?)$/,sessions:/^\/sessions(?:\/[^/]+)?\/?$/,usage:/^\/usage\/?$/},i=F(`hacker`),a=[`hacker`,`rust`,`blue-steel`,`ultraviolet`,`nightshade`];bn(()=>{ta()}),bn(()=>{if($.data)for(let[e,t]of Object.entries(r))t.test(Ki.location)&&(ea.tab=e)}),Ui(()=>{try{let e=localStorage.getItem(`codexometer.web.theme`);e&&a.includes(e)&&I(i,e,!0)}catch{}return fa()});function o(){try{localStorage.setItem(`codexometer.web.theme`,W(i))}catch{}}var s=ec(),c=L(s),l=B(L(c),2),u=L(l);let d;var f=B(u,1,!0),p=z(B(f));j(l),j(c);var m=B(c,2);Z(m,21,()=>Object.entries(r),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1],a=N(()=>i().test(Ki.location));var o=Xs();let s;var c=z(o,!0);V(e=>{Q(o,`href`,r()===`quota`?`#/quota/`+ea.view:`#/`+r()),Q(o,`aria-current`,W(a)?`page`:void 0),s=ci(o,1,``,null,s,{active:W(a)}),J(c,e)},[()=>r().toUpperCase()]),q(e,o)}),j(m);var h=B(m,2),g=L(h),v=e=>{var t=Zs(),n=z(t,!0);V(()=>J(n,$.error)),q(e,t)};Y(g,e=>{$.error&&e(v)});var y=B(g,2),b=e=>{Yi(e,{get routes(){return n}})},x=e=>{q(e,Qs())};Y(y,e=>{$.data?e(b):$.error||e(x,1)}),j(h);var S=B(h,2),C=L(S),w=z(C),T=B(C,2),ee=z(T,!0),te=B(T,2),E=B(L(te));Z(E,21,()=>a,X,(e,t)=>{var n=$s(),r=z(n,!0),i={};V(e=>{J(r,e),i!==(i=W(t))&&(n.value=(n.__value=i)??``)},[()=>W(t).replace(`-`,` `).toUpperCase()]),q(e,n)}),j(E),mi(E),j(te),j(S),j(s),V(()=>{Q(s,`data-theme`,W(i)),d=ci(u,1,`lamp`,null,d,{lit:$.connected}),J(f,$.connected?`CONNECTED`:`OFFLINE`),J(p,`EXPERIMENTAL // ${$.data?.control?`SESSION CONTROL`:`READ ONLY`}`),J(w,`v${($.data?.version||`…`)??``} // LOCAL ONLY`),J(ee,$.data?.control?`Session control enabled. Stop the server to revoke access.`:`No actions can be sent from this preview.`)}),G(`change`,E,o),hi(E,()=>W(i),e=>I(i,e)),q(e,s),Ke()}wr([`change`]),Vr(tc,{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 87db5e5..8451d90 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/schedules.go b/internal/web/schedules.go index a205256..5aa003f 100644 --- a/internal/web/schedules.go +++ b/internal/web/schedules.go @@ -64,7 +64,7 @@ func (c *control) publishSchedules() { c.store.publish() } func (c *control) handleSchedules(w http.ResponseWriter, r *http.Request, b actionRequest) { - if b.SendID != "" || b.Schedule != nil || b.Offer != "" || b.Choice != nil || len(b.Answers) > 0 || b.Review != "" || b.Confirmation != "" { + if b.EditID != "" || b.SendID != "" || b.Schedule != nil || b.Offer != "" || b.Choice != nil || len(b.Answers) > 0 || b.Review != "" || b.Confirmation != "" { http.Error(w, "Invalid schedule request", 400) return } diff --git a/internal/web/schedules_test.go b/internal/web/schedules_test.go index 9d25ab1..db1cc9f 100644 --- a/internal/web/schedules_test.go +++ b/internal/web/schedules_test.go @@ -36,6 +36,57 @@ func TestScheduleWaitingReasons(t *testing.T) { check("ready; awaiting dispatch", true) } +func TestScheduleEditCommitRejectsChangedJob(t *testing.T) { + for _, change := range []string{"none", "replace", "cancel", "send", "unbound"} { + t.Run(change, func(t *testing.T) { + s, f, token := controlServer(t) + s.store.contexts["parent"] = codex.SessionContext{Kind: codex.SessionContextReply} + f.prompt = codex.SessionPromptOffer{ThreadID: "parent", Token: "idle"} + s.store.scheduleQuota = codex.Snapshot{AccountFingerprint: "a", FetchedAt: time.Now(), RateLimits: codex.RateLimitSnapshot{Primary: &codex.Window{UsedPercent: 0}}} + j := schedule.Job{Session: "parent", Text: "original", Trigger: "quota"} + if err := s.control.schedules.Save(j, "a", time.Now()); err != nil { + t.Fatal(err) + } + id := s.control.schedules.List("parent")[0].ID + editID := id + if change == "unbound" { + editID = "" + } + o := getOffer(t, s, token) + r := prepareAction(t, s, token, actionRequest{Session: "parent", Offer: o.ID, EditID: editID, Answers: []string{"edited"}, Schedule: &scheduleRule{Trigger: "quota"}}) + switch change { + case "replace": + if err := s.control.schedules.Save(j, "a", time.Now()); err != nil { + t.Fatal(err) + } + case "cancel": + if err := s.control.schedules.Cancel("parent", id); err != nil { + t.Fatal(err) + } + case "send": + if err := s.control.schedules.Dispatch(context.Background(), id, "a", true, time.Now(), func(context.Context, schedule.Job) error { return nil }); err != nil { + t.Fatal(err) + } + } + want := 409 + if change == "none" { + want = 200 + } + if w := actionCall(s, token, "commit", r); w.Code != want { + t.Fatalf("commit = %d: %s", w.Code, w.Body) + } + if f.calls != 0 { + t.Fatal("editing sent a prompt") + } + for _, got := range s.control.schedules.List("parent") { + if change != "none" && got.Text == "edited" { + t.Fatal("stale edit saved") + } + } + }) + } +} + func TestSchedulePrepareCommitDispatchAndCancel(t *testing.T) { s, f, token := controlServer(t) s.store.contexts["parent"] = codex.SessionContext{Kind: codex.SessionContextReply} diff --git a/web/src/SessionActions.svelte b/web/src/SessionActions.svelte index 5d02d38..ca42f2a 100644 --- a/web/src/SessionActions.svelte +++ b/web/src/SessionActions.svelte @@ -46,6 +46,7 @@ let offerError = $state(false); let sent = $state(''); let editing = $state(false); + let editID = $state(''); let openedScheduler = $state(false); let sendNowID = $state(''); let timing = $state('now'); @@ -80,6 +81,7 @@ ) return; editing = true; + editID = job.id; void tick().then(() => composer?.focus()); answers = [job.text]; timing = job.trigger === 'quota' ? 'quota' : 'at'; @@ -112,6 +114,12 @@ { session }, controller.signal, ); + if ( + editing && + !jobs.some((j) => j.id === editID && j.status === 'pending') + ) { + confirmation = ''; + } if ( sendNowID && !jobs.some((j) => j.id === sendNowID && j.status === 'pending') @@ -195,6 +203,8 @@ ); let scheduleError = $derived.by(() => { if (!scheduling) return ''; + if (editing && !jobs.some((j) => j.id === editID && j.status === 'pending')) + return 'Trigger changed, removed or already sent. Go back and reopen it; your draft has not been saved.'; if (!answers[0]?.trim()) return 'Enter a message to schedule.'; if (timing === 'quota') return ''; if (!Number.isFinite(targetTime) || targetTime <= now) @@ -333,6 +343,7 @@ offer: id, ...(job ? { sendId: job.id } : {}), ...(schedule ? { schedule } : {}), + ...(schedule && editing ? { editId: editID } : {}), ...(offer.kind === 'approval' || offer.kind === 'profile' ? { choice } : { answers: job ? [job.text] : [...answers] }), @@ -405,7 +416,7 @@ } -{#if !review} +{#if !review && offer?.kind !== 'approval' && !offer?.questions?.length && !['APPROVAL NEEDED', 'INPUT NEEDED'].includes(status || '')} {#each jobs.filter((j) => j.status !== 'sent') as job (job.id)}

                    @@ -588,6 +599,10 @@ only; Codexometer must stay running. Uses session model, reasoning and speed.

                    {/if} + {#if editing}

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

                    {/if} {/if} {#each questions as question, index}